diff options
author | JP Rosevear <jpr@ximian.com> | 2001-09-29 05:22:43 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2001-09-29 05:22:43 +0800 |
commit | 564c06f69d3de76e62687137306316de4ee09a87 (patch) | |
tree | 57ff5a1d0e57cae24f2afa04a1d0431cfced7e5b /calendar | |
parent | 8f338e40f91fcdf430b29ea4b9ebcd3e384b0ff1 (diff) | |
download | gsoc2013-evolution-564c06f69d3de76e62687137306316de4ee09a87.tar gsoc2013-evolution-564c06f69d3de76e62687137306316de4ee09a87.tar.gz gsoc2013-evolution-564c06f69d3de76e62687137306316de4ee09a87.tar.bz2 gsoc2013-evolution-564c06f69d3de76e62687137306316de4ee09a87.tar.lz gsoc2013-evolution-564c06f69d3de76e62687137306316de4ee09a87.tar.xz gsoc2013-evolution-564c06f69d3de76e62687137306316de4ee09a87.tar.zst gsoc2013-evolution-564c06f69d3de76e62687137306316de4ee09a87.zip |
Handle the fields and category we don't sync by making sure we don't
2001-09-28 JP Rosevear <jpr@ximian.com>
* conduits/calendar/calendar-conduit.c (local_record_from_comp):
Handle the fields and category we don't sync by making sure we
don't overwrite them
(local_record_to_pilot_record): use local record category
(pre_sync): track db info
* conduits/calendar/calendar-conduit.h: db info field
* conduits/todo/todo-conduit.[hc]: same as above
svn path=/trunk/; revision=13235
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 18 | ||||
-rw-r--r-- | calendar/conduits/calendar/calendar-conduit.c | 26 | ||||
-rw-r--r-- | calendar/conduits/calendar/calendar-conduit.h | 3 | ||||
-rw-r--r-- | calendar/conduits/todo/todo-conduit.c | 28 | ||||
-rw-r--r-- | calendar/conduits/todo/todo-conduit.h | 3 | ||||
-rw-r--r-- | calendar/pcs/cal-backend-file.c | 12 |
6 files changed, 74 insertions, 16 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index c42fdc0859..7011e0c103 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,5 +1,23 @@ 2001-09-28 JP Rosevear <jpr@ximian.com> + * conduits/calendar/calendar-conduit.c (local_record_from_comp): + Handle the fields and category we don't sync by making sure we + don't overwrite them + (local_record_to_pilot_record): use local record category + (pre_sync): track db info + + * conduits/calendar/calendar-conduit.h: db info field + + * conduits/todo/todo-conduit.[hc]: same as above + + * pcs/cal-backend-file.c + (cal_backend_file_compute_changes_foreach_key): create a dummy + component of the right type and strdup the uid + (cal_backend_file_compute_changes): sync the db hash after each + change and free the uid + +2001-09-28 JP Rosevear <jpr@ximian.com> + * cal-client/cal-client.c (cal_client_open_calendar): init the execption rather than freeing it diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c index 87f766cb37..00d61930ec 100644 --- a/calendar/conduits/calendar/calendar-conduit.c +++ b/calendar/conduits/calendar/calendar-conduit.c @@ -390,7 +390,7 @@ local_record_to_pilot_record (ECalLocalRecord *local, g_assert (local->appt != NULL ); p.ID = local->local.ID; - p.category = 0; + p.category = local->local.category; p.attr = local->local.attr; p.archived = local->local.archived; p.secret = local->local.secret; @@ -429,6 +429,22 @@ local_record_from_comp (ECalLocalRecord *local, CalComponent *comp, ECalConduitC local->appt = g_new0 (struct Appointment, 1); + /* Handle the fields and category we don't sync by making sure + * we don't overwrite them + */ + if (local->local.ID != 0) { + char record[0xffff]; + int cat = 0; + + if (dlp_ReadRecordById (ctxt->dbi->pilot_socket, + ctxt->dbi->db_handle, + local->local.ID, &record, + NULL, NULL, NULL, &cat) > 0) { + local->local.category = cat; + unpack_Appointment (local->appt, record, 0xffff); + } + } + /* STOP: don't replace these with g_strdup, since free_Appointment uses free to deallocate */ cal_component_get_summary (comp, &summary); @@ -772,6 +788,7 @@ pre_sync (GnomePilotConduit *conduit, LOG ("---------------------------------------------------------\n"); LOG ("pre_sync: Calendar Conduit v.%s", CONDUIT_VERSION); + ctxt->dbi = dbi; ctxt->client = NULL; if (start_calendar_server (ctxt) != 0) { @@ -823,14 +840,12 @@ pre_sync (GnomePilotConduit *conduit, } /* Set the count information */ - num_records = cal_client_get_n_objects (ctxt->client, CALOBJ_TYPE_TODO); + num_records = cal_client_get_n_objects (ctxt->client, CALOBJ_TYPE_EVENT); gnome_pilot_conduit_sync_abs_set_num_local_records(abs_conduit, num_records); gnome_pilot_conduit_sync_abs_set_num_new_local_records (abs_conduit, add_records); gnome_pilot_conduit_sync_abs_set_num_updated_local_records (abs_conduit, mod_records); gnome_pilot_conduit_sync_abs_set_num_deleted_local_records(abs_conduit, del_records); - gtk_object_set_data (GTK_OBJECT (conduit), "dbinfo", dbi); - buf = (unsigned char*)g_malloc (0xffff); len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0, (unsigned char *)buf, 0xffff); @@ -859,7 +874,6 @@ post_sync (GnomePilotConduit *conduit, gchar *filename, *change_id; LOG ("post_sync: Calendar Conduit v.%s", CONDUIT_VERSION); - LOG ("---------------------------------------------------------\n"); filename = map_name (ctxt); e_pilot_map_write (filename, ctxt->map); @@ -872,6 +886,8 @@ post_sync (GnomePilotConduit *conduit, changed = cal_client_get_changes (ctxt->client, CALOBJ_TYPE_EVENT, change_id); cal_client_change_list_free (changed); + LOG ("---------------------------------------------------------\n"); + return 0; } diff --git a/calendar/conduits/calendar/calendar-conduit.h b/calendar/conduits/calendar/calendar-conduit.h index d0c7eed9bb..244a022c00 100644 --- a/calendar/conduits/calendar/calendar-conduit.h +++ b/calendar/conduits/calendar/calendar-conduit.h @@ -56,7 +56,8 @@ struct _ECalLocalRecord { typedef struct _ECalConduitContext ECalConduitContext; struct _ECalConduitContext { ECalConduitCfg *cfg; - + GnomePilotDBInfo *dbi; + struct AppointmentAppInfo ai; CalClient *client; diff --git a/calendar/conduits/todo/todo-conduit.c b/calendar/conduits/todo/todo-conduit.c index 05451ed754..c073b22eb0 100644 --- a/calendar/conduits/todo/todo-conduit.c +++ b/calendar/conduits/todo/todo-conduit.c @@ -339,7 +339,7 @@ local_record_to_pilot_record (EToDoLocalRecord *local, LOG ("local_record_to_pilot_record\n"); p.ID = local->local.ID; - p.category = 0; + p.category = local->local.category; p.attr = local->local.attr; p.archived = local->local.archived; p.secret = local->local.secret; @@ -382,6 +382,22 @@ local_record_from_comp (EToDoLocalRecord *local, CalComponent *comp, EToDoCondui local->todo = g_new0 (struct ToDo,1); + /* Handle the fields and category we don't sync by making sure + * we don't overwrite them + */ + if (local->local.ID != 0) { + char record[0xffff]; + int cat = 0; + + if (dlp_ReadRecordById (ctxt->dbi->pilot_socket, + ctxt->dbi->db_handle, + local->local.ID, &record, + NULL, NULL, NULL, &cat) > 0) { + local->local.category = cat; + unpack_ToDo (local->todo, record, 0xffff); + } + } + /* STOP: don't replace these with g_strdup, since free_ToDo uses free to deallocate */ cal_component_get_summary (comp, &summary); @@ -586,6 +602,7 @@ pre_sync (GnomePilotConduit *conduit, LOG ("pre_sync: ToDo Conduit v.%s", CONDUIT_VERSION); g_message ("ToDo Conduit v.%s", CONDUIT_VERSION); + ctxt->dbi = dbi; ctxt->client = NULL; if (start_calendar_server (ctxt) != 0) { @@ -643,8 +660,6 @@ pre_sync (GnomePilotConduit *conduit, gnome_pilot_conduit_sync_abs_set_num_updated_local_records (abs_conduit, mod_records); gnome_pilot_conduit_sync_abs_set_num_deleted_local_records(abs_conduit, del_records); - gtk_object_set_data (GTK_OBJECT (conduit), "dbinfo", dbi); - buf = (unsigned char*)g_malloc (0xffff); len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0, (unsigned char *)buf, 0xffff); @@ -671,10 +686,9 @@ post_sync (GnomePilotConduit *conduit, { GList *changed; gchar *filename, *change_id; - - LOG ("post_sync: ToDo Conduit v.%s", CONDUIT_VERSION); - LOG ("---------------------------------------------------------\n"); + LOG ("post_sync: ToDo Conduit v.%s", CONDUIT_VERSION); + filename = map_name (ctxt); e_pilot_map_write (filename, ctxt->map); g_free (filename); @@ -686,6 +700,8 @@ post_sync (GnomePilotConduit *conduit, changed = cal_client_get_changes (ctxt->client, CALOBJ_TYPE_TODO, change_id); cal_client_change_list_free (changed); + LOG ("---------------------------------------------------------\n"); + return 0; } diff --git a/calendar/conduits/todo/todo-conduit.h b/calendar/conduits/todo/todo-conduit.h index e92ad7a9d5..8e365ce78f 100644 --- a/calendar/conduits/todo/todo-conduit.h +++ b/calendar/conduits/todo/todo-conduit.h @@ -56,7 +56,8 @@ struct _EToDoLocalRecord { typedef struct _EToDoConduitContext EToDoConduitContext; struct _EToDoConduitContext { EToDoConduitCfg *cfg; - + GnomePilotDBInfo *dbi; + struct ToDoAppInfo ai; CalClient *client; diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c index c3fdea7234..0cc7c89f3e 100644 --- a/calendar/pcs/cal-backend-file.c +++ b/calendar/pcs/cal-backend-file.c @@ -1368,6 +1368,7 @@ cal_backend_file_get_free_busy (CalBackend *backend, GList *users, time_t start, typedef struct { CalBackend *backend; + CalObjType type; GList *changes; GList *change_ids; } CalBackendFileComputeChangesData; @@ -1383,14 +1384,17 @@ cal_backend_file_compute_changes_foreach_key (const char *key, gpointer data) GNOME_Evolution_Calendar_CalObjChange *coc; comp = cal_component_new (); - cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO); + if (be_data->type == GNOME_Evolution_Calendar_TYPE_TODO) + cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO); + else + cal_component_set_new_vtype (comp, CAL_COMPONENT_EVENT); cal_component_set_uid (comp, key); coc = GNOME_Evolution_Calendar_CalObjChange__alloc (); coc->calobj = CORBA_string_dup (cal_component_get_as_string (comp)); coc->type = GNOME_Evolution_Calendar_DELETED; be_data->changes = g_list_prepend (be_data->changes, coc); - be_data->change_ids = g_list_prepend (be_data->change_ids, (gpointer) key); + be_data->change_ids = g_list_prepend (be_data->change_ids, g_strdup (key)); } } @@ -1446,6 +1450,7 @@ cal_backend_file_compute_changes (CalBackend *backend, CalObjType type, const ch /* Calculate deletions */ be_data.backend = backend; + be_data.type = type; be_data.changes = changes; be_data.change_ids = change_ids; e_dbhash_foreach_key (ehash, (EDbHashFunc)cal_backend_file_compute_changes_foreach_key, &be_data); @@ -1477,10 +1482,11 @@ cal_backend_file_compute_changes (CalBackend *backend, CalObjType type, const ch } else { e_dbhash_remove (ehash, uid); } + e_dbhash_write (ehash); CORBA_free (coc); + g_free (uid); } - e_dbhash_write (ehash); e_dbhash_destroy (ehash); cal_obj_uid_list_free (uids); |