From 66304baebdef12bc9c6966fe51d6d141f6e9478d Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Date: Tue, 2 Sep 2008 15:02:47 -0400 Subject: [PATCH] Creating an gcal_contact object out of returned XML from google server (same case as google calendar events). --- src/gcalendar.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/gcalendar.c b/src/gcalendar.c index 640995b..bad8e90 100644 --- a/src/gcalendar.c +++ b/src/gcalendar.c @@ -487,9 +487,9 @@ static void gc_commit_change_contact(void *data, OSyncPluginInfo *info, OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info); struct gc_plgdata *plgdata = data; - + gcal_contact contact = NULL; int size, result; - char *osync_xml = NULL, *msg = NULL, *raw_xml = NULL, *updated_event = NULL; + char *osync_xml = NULL, *msg = NULL, *raw_xml = NULL, *updated_contact = NULL; OSyncData *odata = NULL; if (!(odata = osync_change_get_data(change))) { @@ -512,28 +512,32 @@ static void gc_commit_change_contact(void *data, OSyncPluginInfo *info, switch (osync_change_get_changetype(change)) { case OSYNC_CHANGE_TYPE_ADDED: - result = gcal_add_xmlentry(plgdata->contacts, raw_xml, &updated_event); + result = gcal_add_xmlentry(plgdata->contacts, raw_xml, &updated_contact); if (result == -1) { msg = "Failed adding new contact!\n"; goto error; } - /* TODO: get the ID and report back to opensync the updated fields - * (edit url, updated, etc) - */ + if (!(contact = gcal_contact_new(updated_contact))) { + msg = "Failed recovering updated fields!\n"; + goto error; + } + /* TODO: inform back the id/edit_url/last_updated */ break; case OSYNC_CHANGE_TYPE_MODIFIED: - result = gcal_update_xmlentry(plgdata->contacts, raw_xml, &updated_event, + result = gcal_update_xmlentry(plgdata->contacts, raw_xml, &updated_contact, NULL); if (result == -1) { msg = "Failed editing event!\n"; goto error; } - /* TODO: report back to opensync the updated fields (edit url, updated, etc) - */ - + if (!(contact = gcal_contact_new(updated_contact))) { + msg = "Failed recovering updated fields!\n"; + goto error; + } + /* TODO: inform back the id/edit_url/last_updated */ break; case OSYNC_CHANGE_TYPE_DELETED: @@ -554,8 +558,11 @@ static void gc_commit_change_contact(void *data, OSyncPluginInfo *info, if (osync_xml) g_free(osync_xml); - if (updated_event) - free(updated_event); + if (updated_contact) + free(updated_contact); + + if (contact) + free(contact); osync_context_report_success(ctx); osync_trace(TRACE_EXIT, "%s", __func__); -- 2.11.4.GIT