aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/conduits/todo/todo-conduit.c
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/conduits/todo/todo-conduit.c')
-rw-r--r--calendar/conduits/todo/todo-conduit.c77
1 files changed, 48 insertions, 29 deletions
diff --git a/calendar/conduits/todo/todo-conduit.c b/calendar/conduits/todo/todo-conduit.c
index 7db0f39861..d232b88173 100644
--- a/calendar/conduits/todo/todo-conduit.c
+++ b/calendar/conduits/todo/todo-conduit.c
@@ -47,7 +47,7 @@
GnomePilotConduit * conduit_get_gpilot_conduit (guint32);
void conduit_destroy_gpilot_conduit (GnomePilotConduit*);
-#define CONDUIT_VERSION "0.1.3"
+#define CONDUIT_VERSION "0.1.4"
#ifdef G_LOG_DOMAIN
#undef G_LOG_DOMAIN
#endif
@@ -115,29 +115,49 @@ static char *print_remote (GnomePilotRecord *remote)
}
/* Context Routines */
-static void
-e_todo_context_new (EToDoConduitContext **ctxt, guint32 pilot_id)
+static EToDoConduitContext *
+e_todo_context_new (guint32 pilot_id)
{
- *ctxt = g_new0 (EToDoConduitContext,1);
- g_assert (ctxt!=NULL);
+ EToDoConduitContext *ctxt = g_new0 (EToDoConduitContext, 1);
+
+ todoconduit_load_configuration (&ctxt->cfg, pilot_id);
+
+ return ctxt;
+}
- todoconduit_load_configuration (&(*ctxt)->cfg, pilot_id);
+static void
+e_todo_context_foreach_change (gpointer key, gpointer value, gpointer data)
+{
+ g_free (key);
}
static void
-e_todo_context_destroy (EToDoConduitContext **ctxt)
+e_todo_context_destroy (EToDoConduitContext *ctxt)
{
- g_return_if_fail (ctxt!=NULL);
- g_return_if_fail (*ctxt!=NULL);
+ g_return_if_fail (ctxt != NULL);
+
+ if (ctxt->cfg != NULL)
+ todoconduit_destroy_configuration (&ctxt->cfg);
+
+ if (ctxt->client != NULL)
+ gtk_object_unref (GTK_OBJECT (ctxt->client));
- if ((*ctxt)->client != NULL)
- gtk_object_unref (GTK_OBJECT ((*ctxt)->client));
+ if (ctxt->calendar_file)
+ g_free (ctxt->calendar_file);
- if ((*ctxt)->cfg != NULL)
- todoconduit_destroy_configuration (&(*ctxt)->cfg);
+ if (ctxt->uids)
+ cal_obj_uid_list_free (ctxt->uids);
- g_free (*ctxt);
- *ctxt = NULL;
+ if (ctxt->changed_hash)
+ g_hash_table_foreach (ctxt->changed_hash, e_todo_context_foreach_change, NULL);
+
+ if (ctxt->changed)
+ cal_client_change_list_free (ctxt->changed);
+
+ if (ctxt->map)
+ e_pilot_map_destroy (ctxt->map);
+
+ g_free (ctxt);
}
/* Calendar Server routines */
@@ -402,7 +422,8 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
CalComponentText summary = {NULL, NULL};
CalComponentDateTime dt = {NULL, NULL};
struct icaltimetype due;
-
+ char *txt;
+
g_return_val_if_fail (remote != NULL, NULL);
memset (&todo, 0, sizeof (struct ToDo));
@@ -418,9 +439,9 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
cal_component_set_last_modified (comp, &now);
- summary.value = e_pilot_utf8_from_pchar (todo.description);
+ summary.value = txt = e_pilot_utf8_from_pchar (todo.description);
cal_component_set_summary (comp, &summary);
- free (summary.value);
+ free (txt);
/* The iCal description field */
if (!todo.note) {
@@ -429,13 +450,13 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
GSList l;
CalComponentText text;
- text.value = e_pilot_utf8_from_pchar (todo.note);
+ text.value = txt = e_pilot_utf8_from_pchar (todo.note);
text.altrep = NULL;
l.data = &text;
l.next = NULL;
cal_component_set_description_list (comp, &l);
- free (text.value);
+ free (txt);
}
if (todo.complete) {
@@ -444,7 +465,7 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
cal_component_set_percent (comp, &percent);
}
- if (is_empty_time (todo.due)) {
+ if (!is_empty_time (todo.due)) {
due = icaltime_from_timet (mktime (&todo.due), FALSE, TRUE);
dt.value = &due;
cal_component_set_due (comp, &dt);
@@ -603,7 +624,6 @@ post_sync (GnomePilotConduit *conduit,
filename = map_name (ctxt);
e_pilot_map_write (filename, ctxt->map);
- e_pilot_map_destroy (ctxt->map);
g_free (filename);
/* FIX ME ugly hack - our changes musn't count, this does introduce
@@ -954,7 +974,7 @@ conduit_get_gpilot_conduit (guint32 pilot_id)
gnome_pilot_conduit_construct (GNOME_PILOT_CONDUIT (retval),
"e_todo_conduit");
- e_todo_context_new (&ctxt, pilot_id);
+ ctxt = e_todo_context_new (pilot_id);
gtk_object_set_data (GTK_OBJECT (retval), "todoconduit_context", ctxt);
gtk_signal_connect (retval, "pre_sync", (GtkSignalFunc) pre_sync, ctxt);
@@ -983,12 +1003,11 @@ conduit_get_gpilot_conduit (guint32 pilot_id)
void
conduit_destroy_gpilot_conduit (GnomePilotConduit *conduit)
{
+ GtkObject *obj = GTK_OBJECT (conduit);
EToDoConduitContext *ctxt;
+
+ ctxt = gtk_object_get_data (obj, "todoconduit_context");
+ e_todo_context_destroy (ctxt);
- ctxt = gtk_object_get_data (GTK_OBJECT (conduit),
- "todoconduit_context");
-
- e_todo_context_destroy (&ctxt);
-
- gtk_object_destroy (GTK_OBJECT (conduit));
+ gtk_object_destroy (obj);
}