aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/conduits/todo
diff options
context:
space:
mode:
authorJP Rosevear <jpr@helixcode.com>2000-11-01 03:20:31 +0800
committerJP Rosevear <jpr@src.gnome.org>2000-11-01 03:20:31 +0800
commitb3a536d46bfc6f4ed4524ec6252abfcea2f97423 (patch)
treef327398c9f76da31d1248890f5781af95aa34fef /calendar/conduits/todo
parentae91213c361f16e5f132024dce23718f035a8c27 (diff)
downloadgsoc2013-evolution-b3a536d46bfc6f4ed4524ec6252abfcea2f97423.tar
gsoc2013-evolution-b3a536d46bfc6f4ed4524ec6252abfcea2f97423.tar.gz
gsoc2013-evolution-b3a536d46bfc6f4ed4524ec6252abfcea2f97423.tar.bz2
gsoc2013-evolution-b3a536d46bfc6f4ed4524ec6252abfcea2f97423.tar.lz
gsoc2013-evolution-b3a536d46bfc6f4ed4524ec6252abfcea2f97423.tar.xz
gsoc2013-evolution-b3a536d46bfc6f4ed4524ec6252abfcea2f97423.tar.zst
gsoc2013-evolution-b3a536d46bfc6f4ed4524ec6252abfcea2f97423.zip
Let the warning make sense (compute_pid): remove
2000-10-31 JP Rosevear <jpr@helixcode.com> * conduit/address-conduit.c (cursor_cb): Let the warning make sense (compute_pid): remove (local_record_from_ecard): Create local record from ecard - not finished (local_record_from_uid): Obtain local_record from uid with the proper e-book way (set_status_cleared): Add empty callback (add_archive_record): kill (delete_archive_record): kill (archive_record): Add empty callback (conduit_get_gpilot_conduit): Update signal connects * backend/pas/pas-backend-file.c (vcard_change_type): Function to determine the type of change - not finished (pas_backend_file_search_changes): Create a view and callback based on how the cards have changed (pas_backend_file_process_get_changes): Implement the get changes operation for files (pas_backend_file_process_client_requests): Add GetChanges method for processing * backend/pas/pas-book.c (pas_book_queue_get_changes): Add changes to the list (impl_Evolution_Book_get_changes): implement object method (pas_book_get_epv): Add get changes to epv (pas_book_respond_get_changes): Respond to the get changes operation * backend/pas/pas-book.h: Add GetChanges PASOperation * backend/idl/addressbook.idl: add get_changes and respond_get_changes methods * backend/ebook/e-book.c (e_book_get_changes): Client function to a view of the changed objects * backend/ebook/e-book.h: New prototype 2000-10-31 JP Rosevear <jpr@helixcode.com> * conduits/todo/todo-conduit.h: Remove add/del/mod hashes and add changed_hash. * conduits/calendar/calendar-conduit.h: ditto * conduits/todo/todo-conduit.c (next_changed_item): Utility function to get the next "really" changed item (changed status can be cleared now) (compute_status): Compute status based on changed_hash (pre_sync): Fill changed_hash and counts adds/mods/dels (set_status_cleared): New callback handler - avoid double syncing (for_each_modified): Use next_changed_item to iterate (add_archive_record): kill (delete_archive_record): kill (archive_record): New callback handler - mark/unmark archive status (conduit_get_gpilot_conduit): Adjust signal connects * conduits/calendar/calendar-conduit.c: ditto svn path=/trunk/; revision=6297
Diffstat (limited to 'calendar/conduits/todo')
-rw-r--r--calendar/conduits/todo/todo-conduit.c181
-rw-r--r--calendar/conduits/todo/todo-conduit.h7
2 files changed, 108 insertions, 80 deletions
diff --git a/calendar/conduits/todo/todo-conduit.c b/calendar/conduits/todo/todo-conduit.c
index 2c4e5e8ff3..12b04ad78c 100644
--- a/calendar/conduits/todo/todo-conduit.c
+++ b/calendar/conduits/todo/todo-conduit.c
@@ -214,20 +214,49 @@ map_name (EToDoConduitContext *ctxt)
return filename;
}
+static GList *
+next_changed_item (EToDoConduitContext *ctxt, GList *changes)
+{
+ CalObjChange *coc;
+ GList *l;
+
+ for (l = changes; l != NULL; l = l->next) {
+ coc = l->data;
+
+ if (g_hash_table_lookup (ctxt->changed_hash, coc->uid))
+ return l;
+ }
+
+ return NULL;
+}
+
static void
compute_status (EToDoConduitContext *ctxt, EToDoLocalRecord *local, const char *uid)
{
+ CalObjChange *coc;
+
local->local.archived = FALSE;
local->local.secret = FALSE;
+
+ coc = g_hash_table_lookup (ctxt->changed_hash, uid);
- if (g_hash_table_lookup (ctxt->added, uid))
- local->local.attr = GnomePilotRecordNew;
- else if (g_hash_table_lookup (ctxt->modified, uid))
- local->local.attr = GnomePilotRecordModified;
- else if (g_hash_table_lookup (ctxt->deleted, uid))
- local->local.attr = GnomePilotRecordDeleted;
- else
+ if (coc == NULL) {
local->local.attr = GnomePilotRecordNothing;
+ return;
+ }
+
+ switch (coc->type) {
+ case CALOBJ_UPDATED:
+ if (e_pilot_map_lookup_pid (ctxt->map, coc->uid) > 0)
+ local->local.attr = GnomePilotRecordModified;
+ else
+ local->local.attr = GnomePilotRecordNew;
+ break;
+
+ case CALOBJ_REMOVED:
+ local->local.attr = GnomePilotRecordDeleted;
+ break;
+ }
}
static GnomePilotRecord *
@@ -481,7 +510,7 @@ pre_sync (GnomePilotConduit *conduit,
int len;
unsigned char *buf;
char *filename;
- gint num_records;
+ gint num_records, add_records = 0, mod_records = 0, del_records = 0;
abs_conduit = GNOME_PILOT_CONDUIT_SYNC_ABS (conduit);
@@ -505,39 +534,40 @@ pre_sync (GnomePilotConduit *conduit,
e_pilot_map_read (filename, &ctxt->map);
g_free (filename);
- /* Find the added, modified and deleted items */
- ctxt->added = g_hash_table_new (g_str_hash, g_str_equal);
- ctxt->modified = g_hash_table_new (g_str_hash, g_str_equal);
- ctxt->deleted = g_hash_table_new (g_str_hash, g_str_equal);
-
+ /* Count and hash the changes */
+ ctxt->changed_hash = g_hash_table_new (g_str_hash, g_str_equal);
ctxt->changed = cal_client_get_changed_uids (ctxt->client,
CALOBJ_TYPE_TODO,
ctxt->map->since + 1);
+
for (l = ctxt->changed; l != NULL; l = l->next) {
CalObjChange *coc = l->data;
-
- switch (coc->type) {
- case CALOBJ_UPDATED:
- if (e_pilot_map_lookup_pid (ctxt->map, coc->uid) > 0)
- g_hash_table_insert (ctxt->modified, coc->uid, coc);
- else
- g_hash_table_insert (ctxt->added, coc->uid, coc);
- break;
- case CALOBJ_REMOVED:
- g_hash_table_insert (ctxt->deleted, coc->uid, coc);
- break;
+
+ if (!e_pilot_map_uid_is_archived (ctxt->map, coc->uid)) {
+
+ g_hash_table_insert (ctxt->changed_hash, coc->uid, coc);
+
+ switch (coc->type) {
+ case CALOBJ_UPDATED:
+ if (e_pilot_map_lookup_pid (ctxt->map, coc->uid) > 0)
+ mod_records++;
+ else
+ add_records++;
+ break;
+
+ case CALOBJ_REMOVED:
+ del_records++;
+ break;
+ }
}
}
/* Set the count information */
num_records = cal_client_get_n_objects (ctxt->client, CALOBJ_TYPE_TODO);
gnome_pilot_conduit_sync_abs_set_num_local_records(abs_conduit, num_records);
- num_records = g_hash_table_size (ctxt->added);
- gnome_pilot_conduit_sync_abs_set_num_new_local_records (abs_conduit, num_records);
- num_records = g_hash_table_size (ctxt->modified);
- gnome_pilot_conduit_sync_abs_set_num_updated_local_records (abs_conduit, num_records);
- num_records = g_hash_table_size (ctxt->deleted);
- gnome_pilot_conduit_sync_abs_set_num_deleted_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);
@@ -595,6 +625,21 @@ set_pilot_id (GnomePilotConduitSyncAbs *conduit,
}
static gint
+set_status_cleared (GnomePilotConduitSyncAbs *conduit,
+ EToDoLocalRecord *local,
+ EToDoConduitContext *ctxt)
+{
+ const char *uid;
+
+ LOG ("set_status_cleared: clearing status\n");
+
+ cal_component_get_uid (local->comp, &uid);
+ g_hash_table_remove (ctxt->changed_hash, uid);
+
+ return 0;
+}
+
+static gint
for_each (GnomePilotConduitSyncAbs *conduit,
EToDoLocalRecord **local,
EToDoConduitContext *ctxt)
@@ -647,7 +692,7 @@ for_each_modified (GnomePilotConduitSyncAbs *conduit,
EToDoLocalRecord **local,
EToDoConduitContext *ctxt)
{
- static GList *changes, *iterator;
+ static GList *iterator;
static int count;
g_return_val_if_fail (local != NULL, 0);
@@ -655,41 +700,41 @@ for_each_modified (GnomePilotConduitSyncAbs *conduit,
if (*local == NULL) {
LOG ("beginning for_each_modified: beginning\n");
- changes = ctxt->changed;
+ iterator = ctxt->changed;
count = 0;
+
+ LOG ("iterating over %d records", g_hash_table_size (ctxt->changed_hash));
- if (changes != NULL) {
- CalObjChange *coc = changes->data;
+ iterator = next_changed_item (ctxt, iterator);
+ if (iterator != NULL) {
+ CalObjChange *coc = NULL;
- LOG ("iterating over %d records", g_list_length (changes));
-
+ coc = iterator->data;
+
+ LOG ("iterating over %d records", g_hash_table_size (ctxt->changed_hash));
+
*local = g_new0 (EToDoLocalRecord, 1);
local_record_from_uid (*local, coc->uid, ctxt);
-
- iterator = changes;
} else {
LOG ("no events");
- (*local) = NULL;
- return 0;
+
+ *local = NULL;
}
} else {
count++;
- if (g_list_next (iterator)) {
- CalObjChange *coc;
+ if ((iterator = next_changed_item (ctxt, iterator))) {
+ CalObjChange *coc = NULL;
- iterator = g_list_next (iterator);
coc = iterator->data;
-
+
*local = g_new0 (EToDoLocalRecord, 1);
local_record_from_uid (*local, coc->uid, ctxt);
} else {
LOG ("for_each_modified ending");
- /* Tell the pilot the iteration is over */
- (*local) = NULL;
-
- return 0;
+ /* Signal the iteration is over */
+ *local = NULL;
}
}
@@ -754,21 +799,6 @@ add_record (GnomePilotConduitSyncAbs *conduit,
}
static gint
-add_archive_record (GnomePilotConduitSyncAbs *conduit,
- GnomePilotRecord *remote,
- EToDoConduitContext *ctxt)
-{
- int retval = 0;
-
- g_return_val_if_fail (remote != NULL, -1);
-
- LOG ("add_archive_record: doing nothing with %s\n",
- print_remote (remote));
-
- return retval;
-}
-
-static gint
replace_record (GnomePilotConduitSyncAbs *conduit,
EToDoLocalRecord *local,
GnomePilotRecord *remote,
@@ -787,8 +817,6 @@ replace_record (GnomePilotConduitSyncAbs *conduit,
local->comp = new_comp;
update_comp (conduit, local->comp, ctxt);
- gtk_object_unref (GTK_OBJECT (new_comp));
-
return retval;
}
@@ -800,7 +828,7 @@ delete_record (GnomePilotConduitSyncAbs *conduit,
const char *uid;
g_return_val_if_fail (local != NULL, -1);
- g_assert (local->comp != NULL);
+ g_return_val_if_fail (local->comp != NULL, -1);
cal_component_get_uid (local->comp, &uid);
@@ -812,16 +840,21 @@ delete_record (GnomePilotConduitSyncAbs *conduit,
}
static gint
-delete_archive_record (GnomePilotConduitSyncAbs *conduit,
- EToDoLocalRecord *local,
- EToDoConduitContext *ctxt)
+archive_record (GnomePilotConduitSyncAbs *conduit,
+ EToDoLocalRecord *local,
+ gboolean archive,
+ EToDoConduitContext *ctxt)
{
+ const char *uid;
int retval = 0;
- g_return_val_if_fail(local!=NULL,-1);
+ g_return_val_if_fail (local != NULL, -1);
- LOG ("delete_archive_record: doing nothing\n");
+ LOG ("archive_record: %s\n", archive ? "yes" : "no");
+ cal_component_get_uid (local->comp, &uid);
+ e_pilot_map_insert (ctxt->map, local->local.ID, uid, archive);
+
return retval;
}
@@ -947,18 +980,16 @@ conduit_get_gpilot_conduit (guint32 pilot_id)
gtk_signal_connect (retval, "post_sync", (GtkSignalFunc) post_sync, ctxt);
gtk_signal_connect (retval, "set_pilot_id", (GtkSignalFunc) set_pilot_id, ctxt);
+ gtk_signal_connect (retval, "set_status_cleared", (GtkSignalFunc) set_status_cleared, ctxt);
gtk_signal_connect (retval, "for_each", (GtkSignalFunc) for_each, ctxt);
gtk_signal_connect (retval, "for_each_modified", (GtkSignalFunc) for_each_modified, ctxt);
gtk_signal_connect (retval, "compare", (GtkSignalFunc) compare, ctxt);
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);
+ gtk_signal_connect (retval, "archive_record", (GtkSignalFunc) archive_record, ctxt);
gtk_signal_connect (retval, "match", (GtkSignalFunc) match, ctxt);
gtk_signal_connect (retval, "free_match", (GtkSignalFunc) free_match, ctxt);
diff --git a/calendar/conduits/todo/todo-conduit.h b/calendar/conduits/todo/todo-conduit.h
index 6e1f109a87..624c6271e7 100644
--- a/calendar/conduits/todo/todo-conduit.h
+++ b/calendar/conduits/todo/todo-conduit.h
@@ -65,12 +65,9 @@ struct _EToDoConduitContext {
GList *uids;
GList *changed;
-
- EPilotMap *map;
+ GHashTable *changed_hash;
- GHashTable *added;
- GHashTable *modified;
- GHashTable *deleted;
+ EPilotMap *map;
};
#endif __TODO_CONDUIT_H__