summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lord <chris@openedhand.com>2006-08-02 15:40:43 +0000
committerChris Lord <chris@openedhand.com>2006-08-02 15:40:43 +0000
commit9c1367ca63d2c81b203f2340de01617c4eee438d (patch)
treedce5bb8482f9ae5cba93041c19cfcfe02c296ebe
parentfca7612de85561902a9aaad2f4e36d027a252157 (diff)
downloadsync-9c1367ca63d2c81b203f2340de01617c4eee438d.tar.gz
sync-9c1367ca63d2c81b203f2340de01617c4eee438d.tar.bz2
sync-9c1367ca63d2c81b203f2340de01617c4eee438d.zip
- Add error reporting to SyncGroup in the 'failed' signal
- Append the type to the name of the SyncML item, but not to its gconf settings, to avoid massive amounts of gconf data for the same SyncML server syncing with different types.
-rw-r--r--sync/ChangeLog16
-rw-r--r--sync/data/sync.glade2
-rw-r--r--sync/src/sync_group.c60
-rw-r--r--sync/src/sync_group.h2
-rw-r--r--sync/src/sync_main.c4
-rw-r--r--sync/src/sync_syncml_item.c21
6 files changed, 82 insertions, 23 deletions
diff --git a/sync/ChangeLog b/sync/ChangeLog
index adadbe9..f4c7e7b 100644
--- a/sync/ChangeLog
+++ b/sync/ChangeLog
@@ -1,3 +1,19 @@
+2006-08-02 Chris Lord,,, <chris@openedhand.com>
+
+ * data/sync.glade:
+ * src/sync_group.c: (sync_group_class_init),
+ (OSyncChangeType2String), (sync_enginestatus_cb),
+ (sync_memberstatus_cb):
+ * src/sync_group.h:
+ * src/sync_main.c: (sync_finished_cb):
+ Add error reporting to SyncGroup in the 'failed' signal
+
+ * src/sync_syncml_item.c: (sync_syncml_item_get_member),
+ (sync_syncml_item_new):
+ Append the type to the name of the SyncML item, but not to its gconf
+ settings, to avoid massive amounts of gconf data for the same
+ SyncML server syncing with different types
+
2006-08-01 Chris Lord,,, <chris@openedhand.com>
* data/sync.glade:
diff --git a/sync/data/sync.glade b/sync/data/sync.glade
index df45c86..fd18ec7 100644
--- a/sync/data/sync.glade
+++ b/sync/data/sync.glade
@@ -961,7 +961,7 @@
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
+ <property name="wrap">True</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
diff --git a/sync/src/sync_group.c b/sync/src/sync_group.c
index b5771c5..284eb2f 100644
--- a/sync/src/sync_group.c
+++ b/sync/src/sync_group.c
@@ -43,6 +43,7 @@ struct _SyncGroupPrivate
gint max_changes; /* Used to work out sync progress */
gint changes;
guint progress_id;
+ gchar *error;
GMutex *mutex;
};
@@ -191,8 +192,8 @@ sync_group_class_init (SyncGroupClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (SyncGroupClass, failed),
NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
g_type_class_add_private (klass, sizeof (SyncGroupPrivate));
@@ -462,8 +463,13 @@ sync_group_finished_idle (SyncGroup *group)
static gboolean
sync_group_failed_idle (SyncGroup *group)
{
+ SyncGroupPrivate *priv = GROUP_PRIVATE (group);
+
sync_group_free_engine (group);
- g_signal_emit (group, signals[FAILED], 0);
+ g_signal_emit (group, signals[FAILED], 0, priv->error ?
+ priv->error : "");
+ g_free (priv->error);
+ priv->error = NULL;
return FALSE;
}
@@ -482,6 +488,21 @@ OSyncChangeType2String (OSyncChangeType c)
}
static void
+sync_append_error (SyncGroup *group, gchar *text)
+{
+ SyncGroupPrivate *priv = GROUP_PRIVATE (group);
+
+ if (!priv->error) {
+ priv->error = text;
+ } else {
+ gchar *new_string = g_strconcat (priv->error, "\n", text);
+ g_free (text);
+ g_free (priv->error);
+ priv->error = new_string;
+ }
+}
+
+static void
sync_conflict_cb (OSyncEngine *engine, OSyncMapping *mapping,
void *user_data)
{
@@ -624,10 +645,13 @@ sync_enginestatus_cb (OSyncEngine *engine, OSyncEngineUpdate *status,
break;
}
}
-#ifdef DEBUG
+
static void
sync_memberstatus_cb (OSyncMemberUpdate *status, void *user_data)
{
+ SyncGroup *group = (SyncGroup *)user_data;
+
+#ifdef DEBUG
switch (status->type) {
case MEMBER_CONNECTED:
g_debug ("Member %lli of type %s just connected",
@@ -650,44 +674,50 @@ sync_memberstatus_cb (OSyncMemberUpdate *status, void *user_data)
osync_member_get_id (status->member),
osync_member_get_pluginname (status->member));
break;
+#endif
case MEMBER_CONNECT_ERROR:
- g_debug ("Member %lli of type %s had an "
+ sync_append_error (group, g_strdup_printf (
+ "Member %lli of type %s had an "
"error while connecting: %s",
osync_member_get_id (status->member),
osync_member_get_pluginname (status->member),
- osync_error_print (&(status->error)));
+ osync_error_print (&(status->error))));
break;
case MEMBER_GET_CHANGES_ERROR:
- g_debug ("Member %lli of type %s had an error while "
+ sync_append_error (group, g_strdup_printf (
+ "Member %lli of type %s had an error while "
"getting changes: %s",
osync_member_get_id (status->member),
osync_member_get_pluginname (status->member),
- osync_error_print (&(status->error)));
+ osync_error_print (&(status->error))));
break;
case MEMBER_SYNC_DONE_ERROR:
- g_debug ("Member %lli of type %s had an error while "
+ sync_append_error (group, g_strdup_printf (
+ "Member %lli of type %s had an error while "
"calling sync done: %s",
osync_member_get_id (status->member),
osync_member_get_pluginname (status->member),
- osync_error_print (&(status->error)));
+ osync_error_print (&(status->error))));
break;
case MEMBER_DISCONNECT_ERROR:
- g_debug ("Member %lli of type %s had an error while "
+ sync_append_error (group, g_strdup_printf (
+ "Member %lli of type %s had an error while "
"disconnecting: %s",
osync_member_get_id (status->member),
osync_member_get_pluginname (status->member),
- osync_error_print (&(status->error)));
+ osync_error_print (&(status->error))));
break;
case MEMBER_COMMITTED_ALL_ERROR:
- g_debug ("Member %lli of type %s had an error while "
+ sync_append_error (group, g_strdup_printf (
+ "Member %lli of type %s had an error while "
"commiting changes: %s",
osync_member_get_id (status->member),
osync_member_get_pluginname (status->member),
- osync_error_print (&(status->error)));
+ osync_error_print (&(status->error))));
break;
}
}
-#endif
+
gboolean
sync_group_start (SyncGroup *group)
{
diff --git a/sync/src/sync_group.h b/sync/src/sync_group.h
index a9e5869..783f9de 100644
--- a/sync/src/sync_group.h
+++ b/sync/src/sync_group.h
@@ -41,7 +41,7 @@ typedef struct {
void (* progress) (SyncGroup *group, gdouble progress);
void (* conflict) (SyncGroup *group);
void (* finished) (SyncGroup *group);
- void (* failed) (SyncGroup *group);
+ void (* failed) (SyncGroup *group, const gchar *error);
} SyncGroupClass;
GType sync_group_get_type (void);
diff --git a/sync/src/sync_main.c b/sync/src/sync_main.c
index c5d4278..e3d2f1e 100644
--- a/sync/src/sync_main.c
+++ b/sync/src/sync_main.c
@@ -225,10 +225,12 @@ sync_finished_cb (SyncGroup *group, SyncData *data)
}
static void
-sync_failed_cb (SyncGroup *group, SyncData *data)
+sync_failed_cb (SyncGroup *group, const gchar *error, SyncData *data)
{
GtkWidget *widget = glade_xml_get_widget (data->xml, "main_notebook");
gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), TAB_ERROR);
+ widget = glade_xml_get_widget (data->xml, "sync_error_label");
+ gtk_label_set_text (GTK_LABEL (widget), error);
g_source_remove (data->animate_id);
}
diff --git a/sync/src/sync_syncml_item.c b/sync/src/sync_syncml_item.c
index 00a9b56..0e57959 100644
--- a/sync/src/sync_syncml_item.c
+++ b/sync/src/sync_syncml_item.c
@@ -80,6 +80,7 @@ static const SyncGConfSchema syncml_config[] = {
typedef struct {
SyncSyncMLType type;
+ gchar *name;
gchar *username;
gchar *password;
gchar *dir;
@@ -152,7 +153,7 @@ sync_syncml_item_get_member (SyncItem *item)
/* Configure OpenSync conf */
gconf_root = g_strconcat (GCONF_ROOT,
- sync_item_get_name (item), NULL);
+ data->name, NULL);
xml_config = g_strdup_printf (SYNCML_CONFIG, gconf_root,
sync_syncml_type_to_type_string (data->type),
@@ -173,7 +174,7 @@ sync_syncml_item_get_member (SyncItem *item)
gconf_path = g_strconcat (gconf_root, NAME_KEY, NULL);
gconf_client_set_string (client, gconf_path,
- sync_item_get_name (item), NULL);
+ data->name, NULL);
g_free (gconf_path);
gconf_path = g_strconcat (gconf_root, ADR_KEY, NULL);
@@ -218,9 +219,10 @@ sync_syncml_item_get_member (SyncItem *item)
static void
sync_syncml_free_data (SyncSyncMLItemData *data)
{
+ g_free (data->name);
g_free (data->username);
g_free (data->password);
- if (data->dir) g_free (data->dir);
+ g_free (data->dir);
g_free (data);
}
@@ -231,14 +233,23 @@ sync_syncml_item_new (const gchar *name, const gchar *address,
{
SyncItem *item;
SyncSyncMLItemData *data;
+ gchar *full_name;
- item = sync_item_new (name, address, sync_syncml_item_get_member);
+ /* Append the type to the name for the OpenSync config, but use the
+ * same name for different types for the GConf config, to avoid
+ * duplicating configuration.
+ */
+ full_name = g_strconcat (name, "-",
+ sync_syncml_type_to_type_string (type), NULL);
+ item = sync_item_new (full_name, address, sync_syncml_item_get_member);
+ g_free (full_name);
data = g_new0 (SyncSyncMLItemData, 1);
+ data->name = g_strdup (name);
data->type = type;
data->username = username ? g_strdup (username) : g_strdup ("");
data->password = password ? g_strdup (password) : g_strdup ("");
- data->dir = dir ? g_strdup (dir) : NULL;
+ data->dir = dir ? g_strdup (dir) : g_strdup ("");
sync_item_set_data (item, data);
sync_item_set_data_free_func (item,