gtk-ui & dbus wrapper: handle waiting status for sources

This commit is contained in:
Jussi Kukkonen 2009-12-08 14:06:21 +02:00
parent 0c79b4afb5
commit 6338d75a1e
3 changed files with 48 additions and 7 deletions

View file

@ -238,6 +238,31 @@ syncevo_sync_mode_from_string (const char *mode_str)
}
}
static SyncevoSourceStatus
syncevo_source_status_from_string (const char *status_str)
{
SyncevoSourceStatus status;
if (!status_str) {
status = SYNCEVO_SOURCE_UNKNOWN;
} else if (g_str_has_prefix (status_str, "idle")) {
status = SYNCEVO_SOURCE_IDLE;
} else if (g_str_has_prefix (status_str, "running")) {
status = SYNCEVO_SOURCE_RUNNING;
} else if (g_str_has_prefix (status_str, "done")) {
status = SYNCEVO_SOURCE_DONE;
} else {
status = SYNCEVO_SOURCE_UNKNOWN;
}
/* check modifiers */
if (status_str && strstr (status_str, ";waiting")) {
status |= SYNCEVO_SOURCE_WAITING;
}
return status;
}
void
syncevo_source_statuses_foreach (SyncevoSourceStatuses *source_statuses,
SourceStatusFunc func,
@ -262,7 +287,7 @@ syncevo_source_statuses_foreach (SyncevoSourceStatuses *source_statuses,
mode = syncevo_sync_mode_from_string (mode_str);
status_str = g_value_get_string (g_value_array_get_nth (source_status, 1));
status = syncevo_session_status_from_string (status_str);
status = syncevo_source_status_from_string (status_str);
error_code = g_value_get_uint (g_value_array_get_nth (source_status, 2));
func (name, mode, status, error_code, data);

View file

@ -50,12 +50,17 @@ typedef enum {
SYNCEVO_STATUS_DONE,
} SyncevoSessionStatus;
/* SyncevoSourceStatus is a bitfield, but only one of four first values
* will be present */
typedef enum {
SYNCEVO_SOURCE_IDLE,
SYNCEVO_SOURCE_RUNNING,
SYNCEVO_SOURCE_RUNNING_WAITING,
SYNCEVO_SOURCE_RUNNING_PROCESSING,
SYNCEVO_SOURCE_DONE,
SYNCEVO_SOURCE_UNKNOWN = 0,
SYNCEVO_SOURCE_IDLE = 1 << 0,
SYNCEVO_SOURCE_RUNNING = 1 << 1,
SYNCEVO_SOURCE_DONE = 1 << 2,
/* the ones below are modifiers */
SYNCEVO_SOURCE_WAITING = 1 << 3,
} SyncevoSourceStatus;
typedef enum {

View file

@ -1282,13 +1282,24 @@ update_source_status (char *name,
app_data *data)
{
char *error;
static char *waiting_source = NULL;
error = get_error_string_for_code (error_code);
if (error) {
/* TODO show sync error in UI -- but not duplicates */
g_warning ("Source '%s' error: %s", name, error);
g_free (error);
}
if (status & SYNCEVO_SOURCE_WAITING) {
g_free (waiting_source);
waiting_source = g_strdup (name);
/* TODO: start spinner */
} else if (waiting_source && strcmp (waiting_source, name) == 0) {
g_free (waiting_source);
waiting_source = NULL;
/* TODO: stop spinner */
}
}
static void