diff options
author | JP Rosevear <jpr@helixcode.com> | 2000-10-12 06:02:37 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2000-10-12 06:02:37 +0800 |
commit | c04a8d1e3868146d5920b1f1e280942359ddeda2 (patch) | |
tree | b43ccfc84ab802efeb30ff0c30b6936018bc1f0e /calendar/conduits | |
parent | d55e310762a3ba82f1cadf118bf2994541199520 (diff) | |
download | gsoc2013-evolution-c04a8d1e3868146d5920b1f1e280942359ddeda2.tar.gz gsoc2013-evolution-c04a8d1e3868146d5920b1f1e280942359ddeda2.tar.zst gsoc2013-evolution-c04a8d1e3868146d5920b1f1e280942359ddeda2.zip |
Take CalObjType as a param because its impossible to determine after a
2000-10-11 JP Rosevear <jpr@helixcode.com>
* pcs/cal-backend.c (cal_backend_log_entry): Take CalObjType
as a param because its impossible to determine after a delete.
(cal_backend_remove_object): Calculate CalObjType and pass
it to cal_backend_log_entry
(cal_backend_update_object): ditto
* conduits/todo/todo-conduit.c (local_record_from_comp): Kill
unused variables.
(add_archive_record): Don't kill the sync if this happens
(update_record): Kill old function
(replace_record): New function to handle replace_record signal
(conduit_get_gpilot_conduit): Listen for replace record signal
(add_record): Always add a new record, never replace
(replace_record): Always replace an existing record
* conduits/calendar/calendar-conduit.c: Same as above
2000-10-11 JP Rosevear <jpr@helixcode.com>
* configure.in: Fix bonobo error message
svn path=/trunk/; revision=5866
Diffstat (limited to 'calendar/conduits')
-rw-r--r-- | calendar/conduits/calendar/calendar-conduit.c | 124 | ||||
-rw-r--r-- | calendar/conduits/todo/todo-conduit.c | 125 |
2 files changed, 116 insertions, 133 deletions
diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c index 2a694187ef..aad146d03f 100644 --- a/calendar/conduits/calendar/calendar-conduit.c +++ b/calendar/conduits/calendar/calendar-conduit.c @@ -465,12 +465,16 @@ local_record_from_uid (ECalLocalRecord *local, if (status == CAL_CLIENT_GET_SUCCESS) { local_record_from_comp (local, comp, ctxt); + } else if (status == CAL_CLIENT_GET_NOT_FOUND) { + comp = cal_component_new (); + cal_component_set_new_vtype (comp, CAL_COMPONENT_EVENT); + cal_component_set_uid (comp, uid); + local_record_from_comp (local, comp, ctxt); } else { INFO ("Object did not exist"); } } - static CalComponent * comp_from_remote_record (GnomePilotConduitSyncAbs *conduit, GnomePilotRecord *remote, @@ -498,7 +502,7 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit, } LOG (" comp_from_remote_record: " - "merging remote %s into local %s\n", + "creating from remote %s and comp %s\n", print_remote (remote), cal_component_get_as_string (comp)); cal_component_set_last_modified (comp, &now); @@ -580,62 +584,6 @@ check_for_slow_setting (GnomePilotConduit *c, ECalConduitContext *ctxt) } } -static gint -update_record (GnomePilotConduitSyncAbs *conduit, - GnomePilotRecord *remote, - ECalConduitContext *ctxt) -{ - CalComponent *comp; - CalClientGetStatus status; - struct Appointment appt; - const char *uid; - - LOG ("update_record\n"); - - g_return_val_if_fail (remote != NULL, -1); - - memset (&appt, 0, sizeof (struct Appointment)); - unpack_Appointment (&appt, remote->record, remote->length); - - uid = g_hash_table_lookup (ctxt->pid_map, &remote->ID); - - if (uid) - status = cal_client_get_object (ctxt->client, uid, &comp); - else - status = CAL_CLIENT_LOAD_ERROR; - - if (status != CAL_CLIENT_GET_SUCCESS) { - LOG (" new record being created\n"); - comp = comp_from_remote_record (conduit, remote, NULL); - } else { - CalComponent *new_comp; - - LOG (" record found\n"); - - new_comp = comp_from_remote_record (conduit, remote, comp); - gtk_object_unref (GTK_OBJECT (comp)); - comp = new_comp; - } - - update_comp (conduit, comp, ctxt); - - if (!uid) { - guint32 *pid = g_new (guint32, 1); - char *new_uid; - - *pid = remote->ID; - cal_component_get_uid (comp, &uid); - new_uid = g_strdup (uid); - g_hash_table_insert (ctxt->pid_map, pid, new_uid); - g_hash_table_insert (ctxt->pid_map, new_uid, pid); - } - - gtk_object_unref (GTK_OBJECT (comp)); - free_Appointment (&appt); - - return 0; -} - /* Pilot syncing callbacks */ static gint pre_sync (GnomePilotConduit *conduit, @@ -761,11 +709,16 @@ set_pilot_id (GnomePilotConduitSyncAbs *conduit, ECalConduitContext *ctxt) { const char *uid; + char *new_uid; guint32 *pid = g_new (guint32, 1); + + LOG ("set_pilot_id: setting to %d\n", ID); cal_component_get_uid (local->comp, &uid); *pid = ID; - g_hash_table_insert (ctxt->pid_map, pid, g_strdup (uid)); + new_uid = g_strdup (uid); + g_hash_table_insert (ctxt->pid_map, pid, new_uid); + g_hash_table_insert (ctxt->uid_map, new_uid, pid); return 0; } @@ -897,9 +850,9 @@ compare (GnomePilotConduitSyncAbs *conduit, retval = 1; if (retval == 0) - LOG (" match.\n"); + LOG (" equal"); else - LOG (" did not match"); + LOG (" not equal"); g_free (local_pilot); @@ -911,15 +864,26 @@ add_record (GnomePilotConduitSyncAbs *conduit, GnomePilotRecord *remote, ECalConduitContext *ctxt) { - int ret; - + CalComponent *comp; + const char *uid; + char *new_uid; + guint32 *pid = g_new (guint32, 1); + int retval = 0; + g_return_val_if_fail (remote != NULL, -1); LOG ("add_record: adding %s to desktop\n", print_remote (remote)); - ret = update_record (conduit, remote, ctxt); + comp = comp_from_remote_record (conduit, remote, NULL); + update_comp (conduit, comp, ctxt); + + *pid = remote->ID; + cal_component_get_uid (comp, &uid); + new_uid = g_strdup (uid); + g_hash_table_insert (ctxt->pid_map, pid, new_uid); + g_hash_table_insert (ctxt->uid_map, new_uid, pid); - return ret; + return retval; } static gint @@ -928,13 +892,39 @@ add_archive_record (GnomePilotConduitSyncAbs *conduit, GnomePilotRecord *remote, ECalConduitContext *ctxt) { + int retval = 0; + g_return_val_if_fail (remote != NULL, -1); g_return_val_if_fail (local != NULL, -1); LOG ("add_archive_record: doing nothing with %s\n", print_local (local)); - return -1; + return retval; +} + +static gint +replace_record (GnomePilotConduitSyncAbs *conduit, + ECalLocalRecord *local, + GnomePilotRecord *remote, + ECalConduitContext *ctxt) +{ + CalComponent *new_comp; + int retval = 0; + + g_return_val_if_fail (remote != NULL, -1); + + LOG ("replace_record: replace %s with %s\n", + print_local (local), print_remote (remote)); + + new_comp = comp_from_remote_record (conduit, remote, local->comp); + gtk_object_unref (GTK_OBJECT (local->comp)); + local->comp = new_comp; + update_comp (conduit, local->comp, ctxt); + + gtk_object_unref (GTK_OBJECT (new_comp)); + + return retval; } static gint @@ -1098,6 +1088,8 @@ conduit_get_gpilot_conduit (guint32 pilot_id) gtk_signal_connect (retval, "add_record", (GtkSignalFunc) add_record, ctxt); /* gtk_signal_connect (retval, "add_archive_record", (GtkSignalFunc) add_archive_record, ctxt); */ + gtk_signal_connect (retval, "replace_record", (GtkSignalFunc) replace_record, ctxt); + gtk_signal_connect (retval, "delete_record", (GtkSignalFunc) delete_record, ctxt); /* gtk_signal_connect (retval, "delete_archive_record", (GtkSignalFunc) delete_archive_record, ctxt); */ diff --git a/calendar/conduits/todo/todo-conduit.c b/calendar/conduits/todo/todo-conduit.c index 525d85de51..90ce255210 100644 --- a/calendar/conduits/todo/todo-conduit.c +++ b/calendar/conduits/todo/todo-conduit.c @@ -399,8 +399,6 @@ local_record_from_comp (EToDoLocalRecord *local, CalComponent *comp, EToDoCondui CalComponentDateTime due; time_t due_time; CalComponentClassification classif; - unsigned long *pilot_id; - unsigned long *pilot_status; LOG ("local_record_from_comp\n"); @@ -478,6 +476,11 @@ local_record_from_uid (EToDoLocalRecord *local, if (status == CAL_CLIENT_GET_SUCCESS) { local_record_from_comp (local, comp, ctxt); + } else if (status == CAL_CLIENT_GET_NOT_FOUND) { + comp = cal_component_new (); + cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO); + cal_component_set_uid (comp, uid); + local_record_from_comp (local, comp, ctxt); } else { INFO ("Object did not exist"); } @@ -512,7 +515,7 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit, } LOG (" comp_from_remote_record: " - "merging remote %s into local %s\n", + "creating from remote %s and comp %s\n", print_remote (remote), cal_component_get_as_string (comp)); cal_component_set_last_modified (comp, &now); @@ -593,62 +596,6 @@ check_for_slow_setting (GnomePilotConduit *c, EToDoConduitContext *ctxt) } } -static gint -update_record (GnomePilotConduitSyncAbs *conduit, - GnomePilotRecord *remote, - EToDoConduitContext *ctxt) -{ - CalComponent *comp; - CalClientGetStatus status; - struct ToDo todo; - const char *uid; - - LOG ("update_record\n"); - - g_return_val_if_fail (remote != NULL, -1); - - memset (&todo, 0, sizeof (struct ToDo)); - unpack_ToDo (&todo, remote->record, remote->length); - - uid = g_hash_table_lookup (ctxt->pid_map, &remote->ID); - - if (uid) - status = cal_client_get_object (ctxt->client, uid, &comp); - else - status = CAL_CLIENT_LOAD_ERROR; - - if (status != CAL_CLIENT_GET_SUCCESS) { - LOG (" new record being created\n"); - comp = comp_from_remote_record (conduit, remote, NULL); - } else { - CalComponent *new_comp; - - LOG (" record found\n"); - - new_comp = comp_from_remote_record (conduit, remote, comp); - gtk_object_unref (GTK_OBJECT (comp)); - comp = new_comp; - } - - update_comp (conduit, comp, ctxt); - - if (!uid) { - guint32 *pid = g_new (guint32, 1); - char *new_uid; - - *pid = remote->ID; - cal_component_get_uid (comp, &uid); - new_uid = g_strdup (uid); - g_hash_table_insert (ctxt->pid_map, pid, new_uid); - g_hash_table_insert (ctxt->pid_map, new_uid, pid); - } - - gtk_object_unref (GTK_OBJECT (comp)); - free_ToDo(&todo); - - return 0; -} - /* Pilot syncing callbacks */ static gint pre_sync (GnomePilotConduit *conduit, @@ -774,11 +721,16 @@ set_pilot_id (GnomePilotConduitSyncAbs *conduit, EToDoConduitContext *ctxt) { const char *uid; + char *new_uid; guint32 *pid = g_new (guint32, 1); + + LOG ("set_pilot_id: setting to %d\n", ID); cal_component_get_uid (local->comp, &uid); *pid = ID; - g_hash_table_insert (ctxt->pid_map, pid, g_strdup (uid)); + new_uid = g_strdup (uid); + g_hash_table_insert (ctxt->pid_map, pid, new_uid); + g_hash_table_insert (ctxt->uid_map, new_uid, pid); return 0; } @@ -910,9 +862,9 @@ compare (GnomePilotConduitSyncAbs *conduit, retval = 1; if (retval == 0) - LOG (" match.\n"); + LOG (" equal"); else - LOG (" did not match"); + LOG (" not equal"); g_free (local_pilot); @@ -924,15 +876,26 @@ add_record (GnomePilotConduitSyncAbs *conduit, GnomePilotRecord *remote, EToDoConduitContext *ctxt) { - int ret; - + CalComponent *comp; + const char *uid; + char *new_uid; + guint32 *pid = g_new (guint32, 1); + int retval = 0; + g_return_val_if_fail (remote != NULL, -1); LOG ("add_record: adding %s to desktop\n", print_remote (remote)); - ret = update_record (conduit, remote, ctxt); + comp = comp_from_remote_record (conduit, remote, NULL); + update_comp (conduit, comp, ctxt); + + *pid = remote->ID; + cal_component_get_uid (comp, &uid); + new_uid = g_strdup (uid); + g_hash_table_insert (ctxt->pid_map, pid, new_uid); + g_hash_table_insert (ctxt->uid_map, new_uid, pid); - return ret; + return retval; } static gint @@ -941,13 +904,39 @@ add_archive_record (GnomePilotConduitSyncAbs *conduit, GnomePilotRecord *remote, EToDoConduitContext *ctxt) { + int retval = 0; + g_return_val_if_fail (remote != NULL, -1); g_return_val_if_fail (local != NULL, -1); LOG ("add_archive_record: doing nothing with %s\n", print_local (local)); - return -1; + return retval; +} + +static gint +replace_record (GnomePilotConduitSyncAbs *conduit, + EToDoLocalRecord *local, + GnomePilotRecord *remote, + EToDoConduitContext *ctxt) +{ + CalComponent *new_comp; + int retval = 0; + + g_return_val_if_fail (remote != NULL, -1); + + LOG ("replace_record: replace %s with %s\n", + print_local (local), print_remote (remote)); + + new_comp = comp_from_remote_record (conduit, remote, local->comp); + gtk_object_unref (GTK_OBJECT (local->comp)); + local->comp = new_comp; + update_comp (conduit, local->comp, ctxt); + + gtk_object_unref (GTK_OBJECT (new_comp)); + + return retval; } static gint @@ -1111,6 +1100,8 @@ conduit_get_gpilot_conduit (guint32 pilot_id) gtk_signal_connect (retval, "add_record", (GtkSignalFunc) add_record, ctxt); /* gtk_signal_connect (retval, "add_archive_record", (GtkSignalFunc) add_archive_record, ctxt); */ + gtk_signal_connect (retval, "replace_record", (GtkSignalFunc) replace_record, ctxt); + gtk_signal_connect (retval, "delete_record", (GtkSignalFunc) delete_record, ctxt); /* gtk_signal_connect (retval, "delete_archive_record", (GtkSignalFunc) delete_archive_record, ctxt); */ |