static gint post_sync (GnomePilotConduit *conduit, GnomePilotDBInfo *dbi, EAddrConduitContext *ctxt) { GList *changed; gchar *filename, *change_id; LOG (g_message ( "post_sync: Address Conduit v.%s", CONDUIT_VERSION )); g_free (ctxt->cfg->last_uri); ctxt->cfg->last_uri = g_strdup (e_book_get_uri (ctxt->ebook)); addrconduit_save_configuration (ctxt->cfg); filename = map_name (ctxt); e_pilot_map_write (filename, ctxt->map); g_free (filename); /* FIX ME ugly hack - our changes musn't count, this does introduce * a race condition if anyone changes a record elsewhere during sycnc */ change_id = g_strdup_printf ("pilot-sync-evolution-addressbook-%d", ctxt->cfg->pilot_id); if (e_book_get_changes (ctxt->ebook, change_id, &changed, NULL)) e_book_free_change_list (changed); g_free (change_id); LOG (g_message ( "---------------------------------------------------------\n" )); return 0; }
gint main (gint argc, gchar **argv) { EBook *book; EContact *contact; GList *changes; GError *error = NULL; EBookChange *change; gchar *uri; g_type_init (); book = ebook_test_utils_book_new_temp (&uri); ebook_test_utils_book_open (book, FALSE); /* get an initial change set */ if (!e_book_get_changes (book, "changeidtest", &changes, &error)) { printf ("failed to get changes: %s\n", error->message); exit (0); } /* make a change to the book */ contact = e_contact_new_from_vcard (NEW_VCARD); ebook_test_utils_book_add_contact (book, contact); /* get another change set */ if (!e_book_get_changes (book, "changeidtest", &changes, &error)) { printf ("failed to get second set of changes: %s\n", error->message); exit (0); } /* make sure that 1 change has occurred */ if (g_list_length (changes) != 1) { printf ("got back %d changes, was expecting 1\n", g_list_length (changes)); exit (0); } change = changes->data; if (change->change_type != E_BOOK_CHANGE_CARD_ADDED) { printf ("was expecting a CARD_ADDED change, but didn't get it.\n"); exit (0); } printf ("got changed vcard back: %s\n", (gchar *) e_contact_get_const (change->contact, E_CONTACT_UID)); e_book_free_change_list (changes); g_object_unref (contact); return 0; }
static void e_addr_context_destroy (EAddrConduitContext *ctxt) { GList *l; g_return_if_fail (ctxt != NULL); if (ctxt->cfg != NULL) addrconduit_destroy_configuration (ctxt->cfg); if (ctxt->new_cfg != NULL) addrconduit_destroy_configuration (ctxt->new_cfg); if (ctxt->gui != NULL) e_addr_gui_destroy (ctxt->gui); if (ctxt->ebook != NULL) g_object_unref (ctxt->ebook); if (ctxt->cards != NULL) { for (l = ctxt->cards; l != NULL; l = l->next) g_object_unref (l->data); g_list_free (ctxt->cards); } if (ctxt->changed_hash != NULL) g_hash_table_destroy (ctxt->changed_hash); if (ctxt->changed != NULL) e_book_free_change_list (ctxt->changed); if (ctxt->locals != NULL) { for (l = ctxt->locals; l != NULL; l = l->next) addrconduit_destroy_record (l->data); g_list_free (ctxt->locals); } if (ctxt->map != NULL) e_pilot_map_destroy (ctxt->map); g_free (ctxt); }