You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
(56) |
Apr
(109) |
May
(15) |
Jun
(3) |
Jul
(37) |
Aug
(96) |
Sep
(40) |
Oct
(4) |
Nov
(54) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(47) |
Feb
(30) |
Mar
(102) |
Apr
(120) |
May
(68) |
Jun
(54) |
Jul
(53) |
Aug
(122) |
Sep
(190) |
Oct
(71) |
Nov
(85) |
Dec
(108) |
2007 |
Jan
(72) |
Feb
(190) |
Mar
(53) |
Apr
(101) |
May
(145) |
Jun
(148) |
Jul
(167) |
Aug
(143) |
Sep
(23) |
Oct
(198) |
Nov
(223) |
Dec
(195) |
2008 |
Jan
(100) |
Feb
(129) |
Mar
(79) |
Apr
(77) |
May
(34) |
Jun
(95) |
Jul
(112) |
Aug
(160) |
Sep
(82) |
Oct
(124) |
Nov
(199) |
Dec
(355) |
2009 |
Jan
(436) |
Feb
(89) |
Mar
(298) |
Apr
(189) |
May
(33) |
Jun
(88) |
Jul
(105) |
Aug
(44) |
Sep
(181) |
Oct
(87) |
Nov
(75) |
Dec
(1) |
2010 |
Jan
(63) |
Feb
(21) |
Mar
(3) |
Apr
(1) |
May
(1) |
Jun
(3) |
Jul
(26) |
Aug
(37) |
Sep
(26) |
Oct
(15) |
Nov
(13) |
Dec
|
From: <svn...@op...> - 2010-09-04 22:28:29
|
Author: paule Date: Sun Sep 5 00:28:21 2010 New Revision: 6116 URL: http://www.opensync.org/changeset/6116 Log: opie-sync: fix small memory leak in event format conversion code Modified: plugins/opie-sync/src/opie_format.c Modified: plugins/opie-sync/src/opie_format.c ============================================================================== --- plugins/opie-sync/src/opie_format.c Sun Sep 5 00:21:30 2010 (r6115) +++ plugins/opie-sync/src/opie_format.c Sun Sep 5 00:28:21 2010 (r6116) @@ -1573,6 +1573,7 @@ g_free(recurendvtime); xmlFree(recurendstr); } + xmlFree(hasEndDate); } xmlFree(recurType); |
From: <svn...@op...> - 2010-09-04 22:21:37
|
Author: paule Date: Sun Sep 5 00:21:30 2010 New Revision: 6115 URL: http://www.opensync.org/changeset/6115 Log: opie-sync: add support for exceptions in calendar events Modified: plugins/opie-sync/src/opie_format.c Modified: plugins/opie-sync/src/opie_format.c ============================================================================== --- plugins/opie-sync/src/opie_format.c Sun Sep 5 00:20:02 2010 (r6114) +++ plugins/opie-sync/src/opie_format.c Sun Sep 5 00:21:30 2010 (r6115) @@ -993,6 +993,16 @@ } g_strfreev(categorytokens); } + else if(!strcasecmp(iprop->name, "exceptions")) + { + gchar** excepttokens = g_strsplit(iprop->children->content, " ", 0); + for(j=0;excepttokens[j]!=NULL;j++) + { + out_xmlfield = osync_xmlfield_new(out_xmlformat, "ExceptionDateTime", error); + osync_xmlfield_set_key_value(out_xmlfield, "Content", excepttokens[j], error); + } + g_strfreev(excepttokens); + } } /* FIXME Stuff to handle: timezone? @@ -1075,7 +1085,9 @@ /* Create a new output xml document */ xmlDoc *odoc = xmlNewDoc((xmlChar*)"1.0"); xmlNode *on_event = xmlNewDocNode(odoc, NULL, "event", NULL); - + + GString *exceptions = g_string_new(""); + OSyncXMLField *in_xmlfield = osync_xmlformat_get_first_field(in_xmlformat); while(in_xmlfield) { const char *fieldname = osync_xmlfield_get_name(in_xmlfield); @@ -1103,9 +1115,21 @@ else if(!strcmp("RecurrenceRule", fieldname)) { xmlfield_recur_to_attr(in_xmlfield, on_event, error); } + else if(!strcmp("ExceptionDateTime", fieldname)) { + const char *value = osync_xmlfield_get_key_value(in_xmlfield, "Content"); + gchar *datestr = g_strndup(value, 8); /* we only want the date part */ + g_string_append_printf(exceptions, "%s ", datestr); + g_free(datestr); + } in_xmlfield = osync_xmlfield_get_next(in_xmlfield); } + + if(exceptions->len > 0) { + g_string_truncate(exceptions, exceptions->len - 1); + xmlSetProp(on_event, "exceptions", exceptions->str); + } + g_string_free(exceptions, TRUE); /* Check for all-day event */ int timediff = end_time - start_time; |
From: <svn...@op...> - 2010-09-04 22:20:11
|
Author: paule Date: Sun Sep 5 00:20:02 2010 New Revision: 6114 URL: http://www.opensync.org/changeset/6114 Log: opie-sync: fix for changes to osync_error_set() API function; fix warnings about format parameters Modified: plugins/opie-sync/src/opie_format.c Modified: plugins/opie-sync/src/opie_format.c ============================================================================== --- plugins/opie-sync/src/opie_format.c Sun Sep 5 00:13:00 2010 (r6113) +++ plugins/opie-sync/src/opie_format.c Sun Sep 5 00:20:02 2010 (r6114) @@ -47,7 +47,7 @@ **/ static osync_bool conv_opie_xml_contact_to_xml_contact(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error) { - osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %p, %p, %p, %p)", __func__, input, inpsize, output, outpsize, free_input, config, error); + osync_trace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p, %p, %p, %p)", __func__, input, inpsize, output, outpsize, free_input, config, userdata, error); int j; // anon_data* anon; gchar** emailtokens = NULL; @@ -338,9 +338,9 @@ GString *emails = NULL; - osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %p, %p, %p, %p)", + osync_trace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p, %p, %p)", __func__, input, inpsize, output, - outpsize, free_input, config, error); + outpsize, free_input, config, userdata, error); OSyncXMLFormat *in_xmlformat = (OSyncXMLFormat *)input; unsigned int size; @@ -535,7 +535,7 @@ **/ static osync_bool conv_opie_xml_todo_to_xml_todo(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error) { - osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %p, %p, %p, %p)", __func__, input, inpsize, output, outpsize, free_input, config, error); + osync_trace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p, %p, %p)", __func__, input, inpsize, output, outpsize, free_input, config, userdata, error); struct _xmlAttr *iprop; int j; OSyncXMLField *out_xmlfield = NULL; @@ -726,9 +726,9 @@ const char *startedstr = NULL; const char *duestr = NULL; - osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %p, %p, %p, %p)", + osync_trace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p, %p, %p)", __func__, input, inpsize, output, - outpsize, free_input, config, error); + outpsize, free_input, config, userdata, error); OSyncXMLFormat *in_xmlformat = (OSyncXMLFormat *)input; unsigned int size; @@ -871,7 +871,7 @@ **/ static osync_bool conv_opie_xml_event_to_xml_event(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error) { - osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %p, %p, %p, %p)", __func__, input, inpsize, output, outpsize, free_input, config, error); + osync_trace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p, %p, %p)", __func__, input, inpsize, output, outpsize, free_input, config, userdata, error); struct _xmlAttr *iprop; OSyncXMLField *out_xmlfield = NULL; GDate *startdate = NULL; @@ -1061,9 +1061,9 @@ time_t start_time = 0; time_t end_time = 0; - osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %p, %p, %p, %p)", + osync_trace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p, %p, %p)", __func__, input, inpsize, output, - outpsize, free_input, config, error); + outpsize, free_input, config, userdata, error); OSyncXMLFormat *in_xmlformat = (OSyncXMLFormat *)input; unsigned int size; @@ -1146,7 +1146,7 @@ **/ static osync_bool conv_opie_xml_note_to_xml_note(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error) { - osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %p, %p, %p, %p)", __func__, input, inpsize, output, outpsize, free_input, config, error); + osync_trace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p, %p, %p)", __func__, input, inpsize, output, outpsize, free_input, config, userdata, error); OSyncXMLField *out_xmlfield = NULL; @@ -1213,9 +1213,9 @@ **/ static osync_bool conv_xml_note_to_opie_xml_note(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error) { - osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %p, %p, %p, %p)", + osync_trace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p, %p, %p)", __func__, input, inpsize, output, - outpsize, free_input, config, error); + outpsize, free_input, config, userdata, error); OSyncXMLFormat *in_xmlformat = (OSyncXMLFormat *)input; unsigned int size; @@ -1300,17 +1300,13 @@ { OSyncObjFormat *format1 = osync_format_env_find_objformat(env, format1_name); if (!format1) { - char *errmsg = g_strdup_printf("Unable to find format \"%s\"", format1_name); - osync_error_set(error, OSYNC_ERROR_GENERIC, errmsg); - g_free(errmsg); + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find format \"%s\"", format1_name); return FALSE; } OSyncObjFormat *format2 = osync_format_env_find_objformat(env, format2_name); if (!format2) { - char *errmsg = g_strdup_printf("Unable to find format \"%s\"", format2_name); - osync_error_set(error, OSYNC_ERROR_GENERIC, errmsg); - g_free(errmsg); + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find format \"%s\"", format2_name); return FALSE; } |
From: <svn...@op...> - 2010-09-04 22:13:12
|
Author: paule Date: Sun Sep 5 00:13:00 2010 New Revision: 6113 URL: http://www.opensync.org/changeset/6113 Log: opie-sync: update change type of change before sending to hashtable Modified: plugins/opie-sync/src/opie_sync.c Modified: plugins/opie-sync/src/opie_sync.c ============================================================================== --- plugins/opie-sync/src/opie_sync.c Tue Aug 31 06:21:43 2010 (r6112) +++ plugins/opie-sync/src/opie_sync.c Sun Sep 5 00:13:00 2010 (r6113) @@ -476,14 +476,16 @@ else { /* Detect the type of change */ changetype = osync_hashtable_get_changetype(hashtable, change); - - /* Update the hashtable with the hash of the object */ - osync_hashtable_update_change(hashtable, change); } /* Set the type of change */ osync_change_set_changetype(change, changetype); - + + if( !env->fastcapable ) { + /* Update the hashtable with the hash of the object */ + osync_hashtable_update_change(hashtable, change); + } + if (changetype != OSYNC_CHANGE_TYPE_UNMODIFIED) { /* Convert category IDs to names that other systems can use */ g_mutex_lock(env->plugin_env->plugin_mutex); |
From: <svn...@op...> - 2010-08-31 04:21:51
|
Author: cdfrey Date: Tue Aug 31 06:21:43 2010 New Revision: 6112 URL: http://www.opensync.org/changeset/6112 Log: Updated INSTALL doc: must use libgcal 0.9.6 or higher Modified: plugins/google-calendar/INSTALL Modified: plugins/google-calendar/INSTALL ============================================================================== --- plugins/google-calendar/INSTALL Tue Aug 31 06:14:16 2010 (r6111) +++ plugins/google-calendar/INSTALL Tue Aug 31 06:21:43 2010 (r6112) @@ -1,5 +1,5 @@ Same compiling instructions as opensync trunk (0.4x). -Also has a requirement libgcal, developed using version 0.9.5: +Also has a requirement libgcal, version 0.9.6 or higher: http://libgcal.googlecode.com |
From: <svn...@op...> - 2010-08-31 04:14:24
|
Author: cdfrey Date: Tue Aug 31 06:14:16 2010 New Revision: 6111 URL: http://www.opensync.org/changeset/6111 Log: Reworked the state_db flags, storing both edit_url and etag for modification During testing, it appears that it is necessary to supply to Google both the edit_url and the etag in order to modify an entry, and just the edit_url to delete it. Also of interest, when adding or modifying an existing entry, the response from Google does not include the original ID, but puts the edit URL in its place. So it is not possible to rely on the ID always being there, even though Google documentation asks for it to be there. Fortunately, it seems to work with just edit URL and etag. This large patch updates both modify and delete logic, as well as supporting code, to accommodate this requirement, using the edit URL as the state_db key (again), and the etag as the data. Modified: plugins/google-calendar/src/gcalendar.c Modified: plugins/google-calendar/src/gcalendar.c ============================================================================== --- plugins/google-calendar/src/gcalendar.c Tue Aug 31 06:14:05 2010 (r6110) +++ plugins/google-calendar/src/gcalendar.c Tue Aug 31 06:14:16 2010 (r6111) @@ -74,7 +74,7 @@ static void gc_sync_done(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *data); -static int timestamp_cmp(char *timestamp1, char *timestamp2) +static int timestamp_cmp(const char *timestamp1, const char *timestamp2) { // timestamp (RFC3339) formating string char format[] = "%FT%T"; @@ -357,7 +357,9 @@ OSyncData *odata = NULL; OSyncChange *chg = NULL; int result = 0, i; - char *timestamp = NULL, *msg = NULL, *raw_xml = NULL; + char *timestamp = NULL, *msg = NULL; + const char *raw_xml = NULL; + char *seen = NULL; gcal_event_t event; OSyncError *state_db_error = NULL; OSyncSinkStateDB *state_db = NULL; @@ -401,6 +403,12 @@ // Calendar returns most recently updated event as first element for (i = 0; i < plgdata->all_events.length; ++i) { + // cleanup for a fresh run + if (seen) { + osync_free(seen); + seen = NULL; + } + // grab the next event object event = gcal_event_element(&(plgdata->all_events), i); if (!event) { @@ -429,12 +437,14 @@ timestamp, gcal_event_get_updated(event)); // grab ID for current change... this is a Google URL - const char *id = gcal_event_get_id(event); + // the edit_url and etag are required later for modification, + // so save them in the state_db as the "seen" marker + const char *url = gcal_event_get_url(event); + const char *etag = gcal_event_get_etag(event); // check state_db for id to see if we've seen this // one before - const char *seen = osync_sink_state_get(state_db, - id, &state_db_error); + seen = osync_sink_state_get(state_db, url, &state_db_error); // determine changetype - we do not use osync_hashtable here // because I believe that requires us to download all @@ -444,27 +454,35 @@ OSyncChangeType ct = OSYNC_CHANGE_TYPE_UNKNOWN; if( gcal_event_is_deleted(event) ) { ct = OSYNC_CHANGE_TYPE_DELETED; - if( !osync_sink_state_set(state_db, id, "0", &state_db_error) ) { - msg = "Error setting state_db for id"; + + // remember this item as deleted + if( !osync_sink_state_set(state_db, url, "", &state_db_error) ) { + msg = "Error setting state_db with url"; goto error; } - if( slow_sync || !seen || seen[0] == '0' ) { + if( slow_sync || !seen || strlen(seen) == 0 ) { // in slow sync mode, we don't care about // deleted objects continue; } } else { - if( !slow_sync && seen && seen[0] == '1' ) { + if( !slow_sync && seen && strlen(seen) > 0 ) { // we've seen this object before ct = OSYNC_CHANGE_TYPE_MODIFIED; } else { ct = OSYNC_CHANGE_TYPE_ADDED; - if( !osync_sink_state_set(state_db, id, "1", &state_db_error) ) { - msg = "Error setting state_db for id"; - goto error; - } + } + + // the etag will have changed for MODIFIED, and + // it's a new item if ADDED, so save the url/etag + // string either way + // FIXME - should perhaps set this only after + // success, such as in the done() plugin call + if( !osync_sink_state_set(state_db, url, etag, &state_db_error) ) { + msg = "Error setting state_db with url/etag"; + goto error; } } @@ -474,7 +492,7 @@ goto cleanup; // setup the change - osync_change_set_uid(chg, id); + osync_change_set_uid(chg, url); osync_change_set_hash(chg, gcal_event_get_updated(event)); osync_change_set_changetype(chg, ct); @@ -528,6 +546,8 @@ // osync_sink_state_get uses osync_strdup osync_free(timestamp); + if (seen) + osync_free(seen); } @@ -543,7 +563,8 @@ OSyncData *odata = NULL; OSyncChange *chg = NULL; int result = 0, i; - char *timestamp = NULL, *msg, *raw_xml = NULL; + char *timestamp = NULL, *msg; + const char *raw_xml = NULL; gcal_contact_t contact; OSyncError *state_db_error = NULL; @@ -690,6 +711,7 @@ unsigned int size; int result = 55555; // something odd for the logs char *osync_xml = NULL, *msg = NULL, *raw_xml = NULL, *updated_event = NULL; + char *etag = NULL; OSyncData *odata = NULL; OSyncError *state_db_error = NULL; OSyncSinkStateDB *state_db = NULL; @@ -706,22 +728,38 @@ goto error; } - osync_data_get_data(odata, &osync_xml, &size); - if( !osync_xml ) { - msg = "Failed getting xml from xmlobj!\n"; - goto error; - } + // transform data, only for ADD / MODIFY + if( osync_change_get_changetype(change) != OSYNC_CHANGE_TYPE_DELETED ) { + osync_data_get_data(odata, &osync_xml, &size); + if( !osync_xml ) { + msg = "Failed getting xml from xmlobj!\n"; + goto error; + } - // Convert to gdata format - result = xslt_transform(plgdata->xslt_ctx_ocal, osync_xml); - if( result ) { - msg = "Failed converting from osync xmlevent to gcalendar\n"; - goto error; - } + // Convert to gdata format + result = xslt_transform(plgdata->xslt_ctx_ocal, osync_xml); + if( result ) { + msg = "Failed converting from osync xmlevent to gcalendar\n"; + osync_trace(TRACE_INTERNAL, "--- osync_uid: %s", + osync_change_get_uid(change)); + osync_trace(TRACE_INTERNAL,"Failed converting from osync xmlevent to gcalendar: %u, %s", + size, osync_xml); + goto error; + } - raw_xml = vtime2gtime( (char*) plgdata->xslt_ctx_gcal->xml_str ); + osync_trace(TRACE_INTERNAL, "--- transformed xml: %s", + (char*) plgdata->xslt_ctx_ocal->xml_str); - osync_trace(TRACE_EXIT, "osync: %s\ngcont: %s\n\n", osync_xml, raw_xml); + raw_xml = vtime2gtime((char*)plgdata->xslt_ctx_ocal->xml_str); + osync_trace(TRACE_INTERNAL, "--- gtime adjusted: %s", raw_xml); + } + + // check state_db for id to see if we've seen this + // one before, and grab the etag if so + if( osync_change_get_uid(change) ) { + etag = osync_sink_state_get(state_db, + osync_change_get_uid(change), &state_db_error); + } switch( osync_change_get_changetype(change) ) { @@ -730,7 +768,10 @@ &updated_event); if( result == -1 ) { msg = "Failed adding new event!\n"; - result = gcal_status_httpcode(plgdata->calendar); + osync_trace(TRACE_INTERNAL, "Failed adding new event! HTTP code: %d, %s, %s\n", + gcal_status_httpcode(plgdata->calendar), + gcal_status_msg(plgdata->calendar), + gcal_access_buffer(plgdata->calendar)); goto error; } @@ -740,21 +781,35 @@ goto error; } + osync_trace(TRACE_INTERNAL, "New event added: url = %s etag = %s", + gcal_event_get_url(event), + gcal_event_get_etag(event)); + // mark this as "seen" - if( !osync_sink_state_set(state_db, gcal_event_get_id(event), "1", &state_db_error) ) { + if( !osync_sink_state_set(state_db, gcal_event_get_url(event), gcal_event_get_etag(event), &state_db_error) ) { msg = "Error setting added state"; goto error; } // tell opensync to store the new ID - osync_change_set_uid(change, gcal_event_get_id(event)); + osync_change_set_uid(change, gcal_event_get_url(event)); break; case OSYNC_CHANGE_TYPE_MODIFIED: + if( !etag ) { + msg = "Trying to modify an unknown entry!"; + goto error; + } + result = gcal_update_xmlentry(plgdata->calendar, raw_xml, - &updated_event, NULL, NULL); + &updated_event, osync_change_get_uid(change), etag); if( result == -1 ) { msg = "Failed editing event!\n"; + osync_trace(TRACE_INTERNAL, "Failed editing event: (etag: %s). HTTP code: %d, %s, %s\n", + etag, + gcal_status_httpcode(plgdata->calendar), + gcal_status_msg(plgdata->calendar), + gcal_access_buffer(plgdata->calendar)); goto error; } @@ -764,23 +819,49 @@ goto error; } + osync_trace(TRACE_INTERNAL,"Modified event: url = %s etag = %s", + gcal_event_get_url(event), + gcal_event_get_etag(event)); + + // make sure that new ID is the same as existing UID + if( strcmp(osync_change_get_uid(change), gcal_event_get_url(event)) != 0 ) { + msg = "Opensync UID != modified event ID"; + osync_trace(TRACE_INTERNAL, "Opensync UID != modified event ID: uid = %s, event_id = %s, updated_event = %s", + osync_change_get_uid(change), + gcal_event_get_url(event), + updated_event); + goto error; + } + // mark this as "seen" - if( !osync_sink_state_set(state_db, gcal_event_get_id(event), "1", &state_db_error) ) { + if( !osync_sink_state_set(state_db, gcal_event_get_url(event), gcal_event_get_etag(event), &state_db_error) ) { msg = "Error setting modified state"; goto error; } break; case OSYNC_CHANGE_TYPE_DELETED: - result = gcal_erase_xmlentry(plgdata->calendar, raw_xml); + // create empty event, set the edit_url, and then delete + event = gcal_event_new(NULL); + result = gcal_event_set_url(event, osync_change_get_uid(change)); + if( result == -1 ) { + msg = "Failed setting url for event delete\n"; + goto error; + } + + result = gcal_erase_event(plgdata->calendar, event); if( result == -1 ) { msg = "Failed deleting event!\n"; + osync_trace(TRACE_INTERNAL, "Failed deleting event! HTTP code: %d, %s, %s\n", + gcal_status_httpcode(plgdata->calendar), + gcal_status_msg(plgdata->calendar), + gcal_access_buffer(plgdata->calendar)); goto error; } // mark this as "unseen" if( !osync_sink_state_set(state_db, - osync_change_get_uid(change), "0", &state_db_error) ) + osync_change_get_uid(change), "", &state_db_error) ) { msg = "Error setting modified state"; goto error; @@ -792,7 +873,7 @@ goto error; } - if (event) { + if( event && gcal_event_get_updated(event) ) { // update the timestamp if( plgdata->cal_timestamp ) { // only if newer @@ -828,6 +909,8 @@ gcal_event_delete(event); if (raw_xml) free(raw_xml); + if (etag) + free(etag); } static void gc_commit_change_contact(OSyncObjTypeSink *sink, |
From: <svn...@op...> - 2010-08-31 04:14:13
|
Author: cdfrey Date: Tue Aug 31 06:14:05 2010 New Revision: 6110 URL: http://www.opensync.org/changeset/6110 Log: Cleaned up cleanup code in calendar get_changes function Modified: plugins/google-calendar/src/gcalendar.c Modified: plugins/google-calendar/src/gcalendar.c ============================================================================== --- plugins/google-calendar/src/gcalendar.c Tue Aug 31 06:13:55 2010 (r6109) +++ plugins/google-calendar/src/gcalendar.c Tue Aug 31 06:14:05 2010 (r6110) @@ -516,19 +516,18 @@ exit: - // osync_sink_state_get uses osync_strdup - osync_free(timestamp); osync_context_report_success(ctx); - return; + goto cleanup; + +error: + osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "%s", msg); cleanup: osync_error_unref(&error); + // osync_sink_state_get uses osync_strdup osync_free(timestamp); -error: - osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "%s", msg); - } |
From: <svn...@op...> - 2010-08-31 04:14:03
|
Author: cdfrey Date: Tue Aug 31 06:13:55 2010 New Revision: 6109 URL: http://www.opensync.org/changeset/6109 Log: Cleaned up cleanup code in the calendar commit function Modified: plugins/google-calendar/src/gcalendar.c Modified: plugins/google-calendar/src/gcalendar.c ============================================================================== --- plugins/google-calendar/src/gcalendar.c Tue Aug 31 06:13:44 2010 (r6108) +++ plugins/google-calendar/src/gcalendar.c Tue Aug 31 06:13:55 2010 (r6109) @@ -789,16 +789,10 @@ break; default: - osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, - "Unknown change type"); msg = "Unknown change type"; goto error; - break; } - if (updated_event) - free(updated_event); - if (event) { // update the timestamp if( plgdata->cal_timestamp ) { @@ -817,25 +811,24 @@ msg = "Failed copying contact timestamp!\n"; goto error; } - - gcal_event_delete(event); - } - // free(osync_xml); - osync_context_report_success(ctx); osync_trace(TRACE_EXIT, "%s", __func__); - return; + goto cleanup; + error: + osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "%s", msg); + osync_trace(TRACE_EXIT, "%s:%sResult code: %d", __func__, msg, result); + +cleanup: if (updated_event) free(updated_event); + if (event) + gcal_event_delete(event); if (raw_xml) free(raw_xml); - - osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "%s", msg); - osync_trace(TRACE_EXIT, "%s:%sHTTP code: %d", __func__, msg, result); } static void gc_commit_change_contact(OSyncObjTypeSink *sink, |
From: <svn...@op...> - 2010-08-31 04:13:52
|
Author: cdfrey Date: Tue Aug 31 06:13:44 2010 New Revision: 6108 URL: http://www.opensync.org/changeset/6108 Log: When committing, only need to set uid for an ADDED entry Modified: plugins/google-calendar/src/gcalendar.c Modified: plugins/google-calendar/src/gcalendar.c ============================================================================== --- plugins/google-calendar/src/gcalendar.c Tue Aug 31 06:13:36 2010 (r6107) +++ plugins/google-calendar/src/gcalendar.c Tue Aug 31 06:13:44 2010 (r6108) @@ -746,6 +746,9 @@ msg = "Error setting added state"; goto error; } + + // tell opensync to store the new ID + osync_change_set_uid(change, gcal_event_get_id(event)); break; case OSYNC_CHANGE_TYPE_MODIFIED: @@ -815,8 +818,6 @@ goto error; } - // Inform the new ID - osync_change_set_uid(change, gcal_event_get_id(event)); gcal_event_delete(event); } |
From: <svn...@op...> - 2010-08-31 04:13:45
|
Author: cdfrey Date: Tue Aug 31 06:13:36 2010 New Revision: 6107 URL: http://www.opensync.org/changeset/6107 Log: Fixed comparison in timestamp_cmp() If NULL pointers are passed in, consider them as empty, and compare accordingly. Modified: plugins/google-calendar/src/gcalendar.c Modified: plugins/google-calendar/src/gcalendar.c ============================================================================== --- plugins/google-calendar/src/gcalendar.c Tue Aug 31 06:13:28 2010 (r6106) +++ plugins/google-calendar/src/gcalendar.c Tue Aug 31 06:13:36 2010 (r6107) @@ -82,8 +82,12 @@ time_t t_first, t_second; int result = 0; - if (!timestamp1 || !timestamp2) + if (!timestamp1 && !timestamp2) + return 0; + if (!timestamp2) return 1; + if (!timestamp1) + return -1; // From timestamp string to time structure timestamp2tm(timestamp1, format, &first); |
From: <svn...@op...> - 2010-08-31 04:13:38
|
Author: cdfrey Date: Tue Aug 31 06:13:28 2010 New Revision: 6106 URL: http://www.opensync.org/changeset/6106 Log: xslt: only add an <author> block if data exists for it Modified: plugins/google-calendar/src/osync2gcal.xslt Modified: plugins/google-calendar/src/osync2gcal.xslt ============================================================================== --- plugins/google-calendar/src/osync2gcal.xslt Fri Aug 27 19:31:46 2010 (r6105) +++ plugins/google-calendar/src/osync2gcal.xslt Tue Aug 31 06:13:28 2010 (r6106) @@ -44,10 +44,12 @@ </xsl:attribute> </link> + <!-- May not always have a contact, and google whines if it's empty --> + <xsl:if test="string-length(descendant::Contact/Content) > 0"> <author> <name><xsl:value-of select="descendant::Contact/Content"/></name> - <!-- TODO: add author's email --> </author> + </xsl:if> <!-- Hard-coded for while... --> <gd:visibility value="http://schemas.google.com/g/2005#event.default"/> |
From: <svn...@op...> - 2010-08-27 17:31:55
|
Author: paule Date: Fri Aug 27 19:31:46 2010 New Revision: 6105 URL: http://www.opensync.org/changeset/6105 Log: opie-sync: fix for changes to osync_error_set() API function Modified: plugins/opie-sync/src/opie_sync.c Modified: plugins/opie-sync/src/opie_sync.c ============================================================================== --- plugins/opie-sync/src/opie_sync.c Thu Aug 26 21:33:51 2010 (r6104) +++ plugins/opie-sync/src/opie_sync.c Fri Aug 27 19:31:46 2010 (r6105) @@ -168,26 +168,20 @@ env->username, env->password); if(!env->qcopconn->result) { - char *errmsg = g_strdup_printf("qcop_connect failed: %s", env->qcopconn->resultmsg); - osync_error_set(error, OSYNC_ERROR_GENERIC, errmsg); - g_free(errmsg); + osync_error_set(error, OSYNC_ERROR_GENERIC, "qcop_connect failed: %s", env->qcopconn->resultmsg); goto error; } qcop_start_sync(env->qcopconn, &sync_cancelled); if(!env->qcopconn->result) { - char *errmsg = g_strdup_printf("qcop_start_sync_failed: %s", env->qcopconn->resultmsg); - osync_error_set(error, OSYNC_ERROR_GENERIC, errmsg); - g_free(errmsg); + osync_error_set(error, OSYNC_ERROR_GENERIC, "qcop_start_sync_failed: %s", env->qcopconn->resultmsg); qcop_stop_sync(env->qcopconn); goto error; } env->dev_root_path = qcop_get_root(env->qcopconn); if(!env->dev_root_path) { - char *errmsg = g_strdup_printf("qcop_get_root failed: %s\n", env->qcopconn->resultmsg); - osync_error_set(error, OSYNC_ERROR_GENERIC, errmsg); - g_free(errmsg); + osync_error_set(error, OSYNC_ERROR_GENERIC, "qcop_get_root failed: %s\n", env->qcopconn->resultmsg); qcop_stop_sync(env->qcopconn); goto error; } @@ -218,9 +212,7 @@ if(env->qcopconn) { qcop_stop_sync(env->qcopconn); if (!env->qcopconn->result) { - char *errmsg = g_strdup_printf("qcop_stop_sync_failed: %s", env->qcopconn->resultmsg); - osync_error_set(error, OSYNC_ERROR_GENERIC, errmsg); - g_free(errmsg); + osync_error_set(error, OSYNC_ERROR_GENERIC, "qcop_stop_sync_failed: %s", env->qcopconn->resultmsg); qcop_disconnect(env->qcopconn); /* frees qcopconn */ env->qcopconn = NULL; goto error; @@ -281,9 +273,7 @@ if(env->plugin_env->use_qcop) { qcop_version_info version; if(!qcop_get_version(env->plugin_env->qcopconn, &version)) { - char *errmsg = g_strdup_printf("qcop_get_version failed: %s", env->plugin_env->qcopconn->resultmsg); - osync_error_set(&error, OSYNC_ERROR_GENERIC, errmsg); - g_free(errmsg); + osync_error_set(&error, OSYNC_ERROR_GENERIC, "qcop_get_version failed: %s", env->plugin_env->qcopconn->resultmsg); g_mutex_unlock(env->plugin_env->plugin_mutex); goto error; } @@ -320,9 +310,7 @@ /* Get hostname */ const gchar *hostname = g_get_host_name(); if(!qcop_set_peer_info(env->plugin_env->qcopconn, env->plugin_env->peer_id, hostname)) { - char *errmsg = g_strdup_printf("qcop_set_peer_info failed: %s", env->plugin_env->qcopconn->resultmsg); - osync_error_set(&error, OSYNC_ERROR_GENERIC, errmsg); - g_free(errmsg); + osync_error_set(&error, OSYNC_ERROR_GENERIC, "qcop_set_peer_info failed: %s", env->plugin_env->qcopconn->resultmsg); g_mutex_unlock(env->plugin_env->plugin_mutex); goto error; } @@ -358,10 +346,7 @@ g_mutex_unlock(env->plugin_env->plugin_mutex); if(!connected) { - char *errmsg; - errmsg = g_strdup_printf("Device not connected"); - osync_error_set(&error, OSYNC_ERROR_GENERIC, errmsg); - g_free(errmsg); + osync_error_set(&error, OSYNC_ERROR_GENERIC, "Device not connected"); goto error; } @@ -379,10 +364,7 @@ if(env->plugin_env->opie_v1_2_5 && env->plugin_env->use_qcop) { env->slow_sync_en = FALSE; if(!qcop_start_app_sync(env->plugin_env->qcopconn, env->appname, env->slow_sync_en, FALSE, &env->fastcapable, &force_slowsync)) { - char *errmsg; - errmsg = g_strdup_printf("Couldn't start application sync for %s: %s", env->appname, env->plugin_env->qcopconn->resultmsg); - osync_error_set(&error, OSYNC_ERROR_GENERIC, errmsg); - g_free(errmsg); + osync_error_set(&error, OSYNC_ERROR_GENERIC, "Couldn't start application sync for %s: %s", env->appname, env->plugin_env->qcopconn->resultmsg); goto error; } if(env->fastcapable) { @@ -433,10 +415,7 @@ gboolean unused1, unused2; /* Slow-sync requested by someone else, we have to tell Opie about it */ if(!qcop_start_app_sync(env->plugin_env->qcopconn, env->appname, TRUE, FALSE, &unused1, &unused2)) { - char *errmsg; - errmsg = g_strdup_printf("Couldn't start application slow-sync for %s: %s", env->appname, env->plugin_env->qcopconn->resultmsg); - osync_error_set(&error, OSYNC_ERROR_GENERIC, errmsg); - g_free(errmsg); + osync_error_set(&error, OSYNC_ERROR_GENERIC, "Couldn't start application slow-sync for %s: %s", env->appname, env->plugin_env->qcopconn->resultmsg); goto error; } env->slow_sync_en = TRUE; @@ -446,12 +425,9 @@ if(!opie_fetch_sink(env, ctx)) { /* failed */ - char *errmsg; /* FIXME this should be being done already? */ device_disconnect(env->plugin_env, &error); - errmsg = g_strdup_printf("Failed to load data from device %s", env->plugin_env->host); - osync_error_set(&error, OSYNC_ERROR_GENERIC, errmsg); - g_free(errmsg); + osync_error_set(&error, OSYNC_ERROR_GENERIC, "Failed to load data from device %s", env->plugin_env->host); goto error; } @@ -481,7 +457,7 @@ /* Retrieve and set the uid of the object */ char *uid = opie_xml_get_tagged_uid(item_node); if(!uid) { - osync_trace(TRACE_EXIT_ERROR, "%s: unable to get UID from entry"); + osync_trace(TRACE_EXIT_ERROR, "%s: unable to get UID from entry", __func__); return; } osync_change_set_uid(change, uid); @@ -712,9 +688,8 @@ if ( !opie_put_sink(env) ) { osync_trace( TRACE_INTERNAL, "opie_put_sink failed" ); - char *errmsg = g_strdup_printf( "Failed to send data to device %s", env->plugin_env->host ); /* FIXME specify which data */ - osync_error_set(&error, OSYNC_ERROR_GENERIC, errmsg); - g_free(errmsg); + /* FIXME specify which data */ + osync_error_set(&error, OSYNC_ERROR_GENERIC, "Failed to send data to device %s", env->plugin_env->host); goto error; } @@ -727,10 +702,7 @@ if(env->plugin_env->opie_v1_2_5 && env->plugin_env->use_qcop) { if(!qcop_finish_app_sync(env->plugin_env->qcopconn, env->appname)) { osync_trace( TRACE_INTERNAL, "qcop_finish_app_sync failed" ); - char *errmsg; - errmsg = g_strdup_printf("Couldn't finish application sync for %s: %s", env->appname, env->plugin_env->qcopconn->resultmsg); - osync_error_set(&error, OSYNC_ERROR_GENERIC, errmsg); - g_free(errmsg); + osync_error_set(&error, OSYNC_ERROR_GENERIC, "Couldn't finish application sync for %s: %s", env->appname, env->plugin_env->qcopconn->resultmsg); goto error; } } |
From: <svn...@op...> - 2010-08-26 19:34:00
|
Author: cdfrey Date: Thu Aug 26 21:33:51 2010 New Revision: 6104 URL: http://www.opensync.org/changeset/6104 Log: If deleted events have been seen before, don't bother deleting them again Modified: plugins/google-calendar/src/gcalendar.c Modified: plugins/google-calendar/src/gcalendar.c ============================================================================== --- plugins/google-calendar/src/gcalendar.c Thu Aug 26 21:33:43 2010 (r6103) +++ plugins/google-calendar/src/gcalendar.c Thu Aug 26 21:33:51 2010 (r6104) @@ -427,6 +427,11 @@ // grab ID for current change... this is a Google URL const char *id = gcal_event_get_id(event); + // check state_db for id to see if we've seen this + // one before + const char *seen = osync_sink_state_get(state_db, + id, &state_db_error); + // determine changetype - we do not use osync_hashtable here // because I believe that requires us to download all // events in order to feed the timestamp to the hashtable @@ -439,24 +444,14 @@ msg = "Error setting state_db for id"; goto error; } - if( slow_sync ) { + if( slow_sync || !seen || seen[0] == '0' ) { // in slow sync mode, we don't care about // deleted objects continue; } } else { - // not deleted, so either ADDED or MODIFIED... - // check state_db for id to see if we've seen this - // one before - const char *seen = osync_sink_state_get(state_db, - id, &state_db_error); - if( !seen ) { - msg = "sink_state_get returned NULL"; - goto error; - } - - if( !slow_sync && seen[0] == '1' ) { + if( !slow_sync && seen && seen[0] == '1' ) { // we've seen this object before ct = OSYNC_CHANGE_TYPE_MODIFIED; } |
From: <svn...@op...> - 2010-08-26 19:33:51
|
Author: cdfrey Date: Thu Aug 26 21:33:43 2010 New Revision: 6103 URL: http://www.opensync.org/changeset/6103 Log: DELETED change objects need a data object too, even if empty Modified: plugins/google-calendar/src/gcalendar.c Modified: plugins/google-calendar/src/gcalendar.c ============================================================================== --- plugins/google-calendar/src/gcalendar.c Thu Aug 26 21:33:36 2010 (r6102) +++ plugins/google-calendar/src/gcalendar.c Thu Aug 26 21:33:43 2010 (r6103) @@ -495,12 +495,21 @@ osync_change_unref(chg); goto cleanup; } - - osync_data_set_objtype(odata, - osync_objtype_sink_get_name(sink)); - osync_change_set_data(chg, odata); - osync_data_unref(odata); } + else { + // deleted changes need empty data sets + odata = osync_data_new(NULL, 0, plgdata->gcal_format, + &error); + if( !odata ) { + osync_change_unref(chg); + goto cleanup; + } + } + + osync_data_set_objtype(odata, + osync_objtype_sink_get_name(sink)); + osync_change_set_data(chg, odata); + osync_data_unref(odata); osync_context_report_change(ctx, chg); osync_change_unref(chg); |
From: <svn...@op...> - 2010-08-26 19:33:45
|
Author: cdfrey Date: Thu Aug 26 21:33:36 2010 New Revision: 6102 URL: http://www.opensync.org/changeset/6102 Log: Fixed missing unref() call for gcont_format Modified: plugins/google-calendar/src/gcalendar.c Modified: plugins/google-calendar/src/gcalendar.c ============================================================================== --- plugins/google-calendar/src/gcalendar.c Thu Aug 26 21:33:29 2010 (r6101) +++ plugins/google-calendar/src/gcalendar.c Thu Aug 26 21:33:36 2010 (r6102) @@ -258,6 +258,8 @@ xmlFree(plgdata->password); if (plgdata->gcal_format) osync_objformat_unref(plgdata->gcal_format); + if (plgdata->gcont_format) + osync_objformat_unref(plgdata->gcont_format); g_free(plgdata); } |
From: <svn...@op...> - 2010-08-26 19:33:39
|
Author: cdfrey Date: Thu Aug 26 21:33:29 2010 New Revision: 6101 URL: http://www.opensync.org/changeset/6101 Log: Fix segfault when using libxml2 Should not do a general, global memory cleanup in a local delete function. The libxml2 library has a global list of schema type pointers that are freed when calling xmlCleanupParser(). If other code, such as opensync itself, is still relying on these schema types, a segfault will occur. Leave the global cleanups for the applications. Modified: plugins/google-calendar/src/xslt_aux.h Modified: plugins/google-calendar/src/xslt_aux.h ============================================================================== --- plugins/google-calendar/src/xslt_aux.h Tue Aug 17 04:03:05 2010 (r6100) +++ plugins/google-calendar/src/xslt_aux.h Thu Aug 26 21:33:29 2010 (r6101) @@ -175,8 +175,6 @@ xmlFree(ctx->xml_str); if (ctx->cur) { xsltFreeStylesheet(ctx->cur); - xsltCleanupGlobals(); - xmlCleanupParser(); } exit: |
From: <svn...@op...> - 2010-08-17 02:03:14
|
Author: cdfrey Date: Tue Aug 17 04:03:05 2010 New Revision: 6100 URL: http://www.opensync.org/changeset/6100 Log: Fixed printf format string bugs Messages may have printf-style escape codes, and may cause a crash, so print the messages indirectly with "%s" Modified: plugins/google-calendar/src/gcalendar.c Modified: plugins/google-calendar/src/gcalendar.c ============================================================================== --- plugins/google-calendar/src/gcalendar.c Tue Aug 17 00:36:03 2010 (r6099) +++ plugins/google-calendar/src/gcalendar.c Tue Aug 17 04:03:05 2010 (r6100) @@ -517,7 +517,7 @@ osync_free(timestamp); error: - osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, msg); + osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "%s", msg); } @@ -666,7 +666,7 @@ osync_free(timestamp); error: - osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, msg); + osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "%s", msg); } static void gc_commit_change_calendar(OSyncObjTypeSink *sink, @@ -823,7 +823,7 @@ if (raw_xml) free(raw_xml); - osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, msg); + osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "%s", msg); osync_trace(TRACE_EXIT, "%s:%sHTTP code: %d", __func__, msg, result); } @@ -938,7 +938,7 @@ if (raw_xml) free(raw_xml); - osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, msg); + osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "%s", msg); osync_trace(TRACE_EXIT, "%s:%sHTTP code: %d", __func__, msg, result); } |
From: <svn...@op...> - 2010-08-16 22:36:11
|
Author: cdfrey Date: Tue Aug 17 00:36:03 2010 New Revision: 6099 URL: http://www.opensync.org/changeset/6099 Log: Added xslt conversion code for the osync -> google transform Modified: plugins/google-calendar/src/gcalendar.c Modified: plugins/google-calendar/src/gcalendar.c ============================================================================== --- plugins/google-calendar/src/gcalendar.c Tue Aug 17 00:35:57 2010 (r6098) +++ plugins/google-calendar/src/gcalendar.c Tue Aug 17 00:36:03 2010 (r6099) @@ -215,8 +215,12 @@ // contact sink/format OSyncObjFormat *gcont_format; // XSLT context resource struct + // google -> osync struct xslt_resources *xslt_ctx_gcal; struct xslt_resources *xslt_ctx_gcont; + // osync -> google + struct xslt_resources *xslt_ctx_ocal; + struct xslt_resources *xslt_ctx_ocont; }; static void free_plg(struct gc_plgdata *plgdata) @@ -236,6 +240,10 @@ xslt_delete(plgdata->xslt_ctx_gcal); if (plgdata->xslt_ctx_gcont) xslt_delete(plgdata->xslt_ctx_gcont); + if (plgdata->xslt_ctx_ocal) + xslt_delete(plgdata->xslt_ctx_ocal); + if (plgdata->xslt_ctx_ocont) + xslt_delete(plgdata->xslt_ctx_ocont); if (plgdata->cal_timestamp) free(plgdata->cal_timestamp); if (plgdata->cont_timestamp) @@ -267,11 +275,19 @@ if (result == -1) goto error; + // google -> osync snprintf(buffer, sizeof(buffer) - 1, "%sgcal2osync.xslt", plgdata->xslt_path); if ((result = xslt_initialize(plgdata->xslt_ctx_gcal, buffer))) goto error; - osync_trace(TRACE_INTERNAL, "\ndone calendar: %s\n", buffer); + osync_trace(TRACE_INTERNAL, "loaded calendar xslt: %s\n", buffer); + + // osync -> google + snprintf(buffer, sizeof(buffer) - 1, "%sosync2gcal.xslt", + plgdata->xslt_path); + if ((result = xslt_initialize(plgdata->xslt_ctx_ocal, buffer))) + goto error; + osync_trace(TRACE_INTERNAL, "loaded calendar xslt: %s\n", buffer); osync_context_report_success(ctx); osync_trace(TRACE_EXIT, "%s", __func__); @@ -299,11 +315,19 @@ if (result == -1) goto error; + // google -> osync snprintf(buffer, sizeof(buffer) - 1, "%sgcont2osync.xslt", plgdata->xslt_path); if ((result = xslt_initialize(plgdata->xslt_ctx_gcont, buffer))) goto error; - osync_trace(TRACE_INTERNAL, "\ndone contact: %s\n", buffer); + osync_trace(TRACE_INTERNAL, "loaded contact xslt: %s\n", buffer); + + // osync -> google + snprintf(buffer, sizeof(buffer) - 1, "%sosync2gcont.xslt", + plgdata->xslt_path); + if ((result = xslt_initialize(plgdata->xslt_ctx_ocont, buffer))) + goto error; + osync_trace(TRACE_INTERNAL, "loaded contact xslt: %s\n", buffer); osync_context_report_success(ctx); osync_trace(TRACE_EXIT, "%s", __func__); @@ -680,7 +704,7 @@ } // Convert to gdata format - result = xslt_transform(plgdata->xslt_ctx_gcal, osync_xml); + result = xslt_transform(plgdata->xslt_ctx_ocal, osync_xml); if( result ) { msg = "Failed converting from osync xmlevent to gcalendar\n"; goto error; @@ -1113,14 +1137,18 @@ if( plgdata->calendar ) { - if (!(plgdata->xslt_ctx_gcal = xslt_new())) + plgdata->xslt_ctx_gcal = xslt_new(); + plgdata->xslt_ctx_ocal = xslt_new(); + if (!plgdata->xslt_ctx_gcal || !plgdata->xslt_ctx_ocal) goto error_freeplg; else osync_trace(TRACE_INTERNAL, "\tsucceed creating xslt_gcal!\n"); } if( plgdata->contacts ) { - if (!(plgdata->xslt_ctx_gcont = xslt_new())) + plgdata->xslt_ctx_gcont = xslt_new(); + plgdata->xslt_ctx_ocont = xslt_new(); + if (!plgdata->xslt_ctx_gcont || !plgdata->xslt_ctx_ocont) goto error_freeplg; else osync_trace(TRACE_INTERNAL, "\tsucceed creating xslt_gcont!\n"); |
From: <svn...@op...> - 2010-08-16 22:36:06
|
Author: cdfrey Date: Tue Aug 17 00:35:57 2010 New Revision: 6098 URL: http://www.opensync.org/changeset/6098 Log: Fixed silly if statement bug and improved log messages Modified: plugins/google-calendar/src/gcalendar.c Modified: plugins/google-calendar/src/gcalendar.c ============================================================================== --- plugins/google-calendar/src/gcalendar.c Mon Aug 16 22:57:14 2010 (r6097) +++ plugins/google-calendar/src/gcalendar.c Tue Aug 17 00:35:57 2010 (r6098) @@ -655,16 +655,17 @@ struct gc_plgdata *plgdata = data; gcal_event_t event = NULL; unsigned int size; - int result; + int result = 55555; // something odd for the logs char *osync_xml = NULL, *msg = NULL, *raw_xml = NULL, *updated_event = NULL; OSyncData *odata = NULL; OSyncError *state_db_error = NULL; OSyncSinkStateDB *state_db = NULL; state_db = osync_objtype_sink_get_state_db(sink); - if( !state_db ) + if( !state_db ) { msg = "Cannot start state_db!"; goto error; + } odata = osync_change_get_data(change); if( !odata ) { @@ -753,6 +754,7 @@ default: osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "Unknown change type"); + msg = "Unknown change type"; goto error; break; } |
From: <svn...@op...> - 2010-08-16 20:57:27
|
Author: cdfrey Date: Mon Aug 16 22:57:14 2010 New Revision: 6097 URL: http://www.opensync.org/changeset/6097 Log: Fixed missing state_db update when new records are added Modified: plugins/google-calendar/src/gcalendar.c Modified: plugins/google-calendar/src/gcalendar.c ============================================================================== --- plugins/google-calendar/src/gcalendar.c Mon Aug 16 20:52:10 2010 (r6096) +++ plugins/google-calendar/src/gcalendar.c Mon Aug 16 22:57:14 2010 (r6097) @@ -436,6 +436,10 @@ } else { ct = OSYNC_CHANGE_TYPE_ADDED; + if( !osync_sink_state_set(state_db, id, "1", &state_db_error) ) { + msg = "Error setting state_db for id"; + goto error; + } } } |
From: <svn...@op...> - 2010-08-16 18:52:19
|
Author: cdfrey Date: Mon Aug 16 20:52:10 2010 New Revision: 6096 URL: http://www.opensync.org/changeset/6096 Log: Make sure vformat output does not have separators in timestamps The vformat RFCs do not allow separators in their timestamps, even though they are based on the ISO 8601 spec. It may happen that the plugins create xmlformat data with ISO 8601 timestamps, even though this is not technically supposed to happen. If it does, the best tactic is to convert the timestamp to the RFC format using osync_time_timestamp(). Modified: format-plugins/vformat/src/xmlformat-common.c format-plugins/vformat/src/xmlformat-common.h format-plugins/vformat/src/xmlformat-vcalendar.c Modified: format-plugins/vformat/src/xmlformat-common.c ============================================================================== --- format-plugins/vformat/src/xmlformat-common.c Mon Aug 16 20:52:03 2010 (r6095) +++ format-plugins/vformat/src/xmlformat-common.c Mon Aug 16 20:52:10 2010 (r6096) @@ -149,6 +149,40 @@ return attr; } +VFormatAttribute *handle_xml_attribute_simple_content_timestamp(VFormat *vformat, OSyncXMLField *xmlfield, const char *name, const char *encoding) +{ + g_assert(vformat); + g_assert(xmlfield); + g_assert(name); + + VFormatAttribute *attr = vformat_attribute_new(NULL, name); + + const char *tmp = osync_xmlfield_get_key_value(xmlfield, "Content"); + char *timestamp = NULL; + if( tmp ) { + // vformat must not have any separators in its timestamp, + // so run the timestamp through osync_time_timestamp() + // just to make sure it is in a valid state, in case + // a plugin gave us an ISO 8601 timestamp + timestamp = osync_time_timestamp(tmp); + } + else { + timestamp = strdup(""); + } + + add_value_data(attr, xmlfield, timestamp, encoding); + + // TODO timezone +// char *tzid = osxml_find_node(xmlfield, "TimezoneID") +// vformat_attribute_add_param_with_value(attr, "TZID", tzid); +// g_free(tzid); + + vformat_add_attribute(vformat, attr); + + osync_free(timestamp); + return attr; +} + VFormatAttribute *handle_xml_categories_attribute(VFormat *vformat, OSyncXMLField *xmlfield, const char *encoding) { return handle_xml_attribute_simple_content(vformat, xmlfield, "CATEGORIES", encoding); Modified: format-plugins/vformat/src/xmlformat-common.h ============================================================================== --- format-plugins/vformat/src/xmlformat-common.h Mon Aug 16 20:52:03 2010 (r6095) +++ format-plugins/vformat/src/xmlformat-common.h Mon Aug 16 20:52:10 2010 (r6096) @@ -62,6 +62,7 @@ /** XML Attributes **/ VFormatAttribute *handle_xml_attribute_simple_content(VFormat *vformat, OSyncXMLField *xmlfield, const char *name, const char *encoding); +VFormatAttribute *handle_xml_attribute_simple_content_timestamp(VFormat *vformat, OSyncXMLField *xmlfield, const char *name, const char *encoding); VFormatAttribute *handle_xml_categories_attribute(VFormat *vcard, OSyncXMLField *xmlfield, const char *encoding); VFormatAttribute *handle_xml_class_attribute(VFormat *vcard, OSyncXMLField *xmlfield, const char *encoding); VFormatAttribute *handle_xml_uid_attribute(VFormat *vcard, OSyncXMLField *xmlfield, const char *encoding); Modified: format-plugins/vformat/src/xmlformat-vcalendar.c ============================================================================== --- format-plugins/vformat/src/xmlformat-vcalendar.c Mon Aug 16 20:52:03 2010 (r6095) +++ format-plugins/vformat/src/xmlformat-vcalendar.c Mon Aug 16 20:52:10 2010 (r6096) @@ -970,26 +970,12 @@ VFormatAttribute *handle_xml_due_attribute(VFormat *vevent, OSyncXMLField *xmlfield, const char *encoding) { - /*TODO timezone*/ - VFormatAttribute *attr = vformat_attribute_new(NULL, "DUE"); - add_value(attr, xmlfield, "Content", encoding); -// char *tzid = osxml_find_node(xmlfield, "TimezoneID") -// vformat_attribute_add_param_with_value(attr, "TZID", tzid); -// g_free(tzid); - vformat_add_attribute(vevent, attr); - return attr; + return handle_xml_attribute_simple_content_timestamp(vevent, xmlfield, "DUE", encoding); } VFormatAttribute *handle_xml_dtstart_attribute(VFormat *vevent, OSyncXMLField *xmlfield, const char *encoding) { - /* TODO timezone */ - VFormatAttribute *attr = vformat_attribute_new(NULL, "DTSTART"); - add_value(attr, xmlfield, "Content", encoding); -// char *tzid = osxml_find_node(xmlfield, "TimezoneID") -// vformat_attribute_add_param_with_value(attr, "TZID", tzid); -// g_free(tzid); - vformat_add_attribute(vevent, attr); - return attr; + return handle_xml_attribute_simple_content_timestamp(vevent, xmlfield, "DTSTART", encoding); } VFormatAttribute *handle_xml_percent_complete_attribute(VFormat *vevent, OSyncXMLField *xmlfield, const char *encoding) @@ -1105,14 +1091,7 @@ VFormatAttribute *handle_xml_dtend_attribute(VFormat *vevent, OSyncXMLField *xmlfield, const char *encoding) { - /* TODO timezone */ - VFormatAttribute *attr = vformat_attribute_new(NULL, "DTEND"); - add_value(attr, xmlfield, "Content", encoding); -// char *tzid = osxml_find_node(xmlfield, "TimezoneID") -// vformat_attribute_add_param_with_value(attr, "TZID", tzid); -// g_free(tzid); - vformat_add_attribute(vevent, attr); - return attr; + return handle_xml_attribute_simple_content_timestamp(vevent, xmlfield, "DTEND", encoding); } VFormatAttribute *handle_xml_transp_attribute(VFormat *vevent, OSyncXMLField *xmlfield, const char *encoding) |
From: <svn...@op...> - 2010-08-16 18:52:14
|
Author: cdfrey Date: Mon Aug 16 20:52:03 2010 New Revision: 6095 URL: http://www.opensync.org/changeset/6095 Log: Split add_value() into add_value() and add_value_data() Allow adding of pure data, instead of just accessing through the XML tree Modified: format-plugins/vformat/src/xmlformat-common.c format-plugins/vformat/src/xmlformat-common.h Modified: format-plugins/vformat/src/xmlformat-common.c ============================================================================== --- format-plugins/vformat/src/xmlformat-common.c Mon Aug 16 20:45:08 2010 (r6094) +++ format-plugins/vformat/src/xmlformat-common.c Mon Aug 16 20:52:03 2010 (r6095) @@ -211,7 +211,17 @@ */ tmp = ""; } - + + add_value_data(attr, xmlfield, tmp, encoding); +} + +void add_value_data(VFormatAttribute *attr, OSyncXMLField *xmlfield, const char *data, const char *encoding) +{ + g_assert(xmlfield); + g_assert(data); + + const char *tmp = data; + if (needs_charset((unsigned char*)tmp)) if (!vformat_attribute_has_param (attr, "CHARSET")) vformat_attribute_add_param_with_value(attr, "CHARSET", "UTF-8"); Modified: format-plugins/vformat/src/xmlformat-common.h ============================================================================== --- format-plugins/vformat/src/xmlformat-common.h Mon Aug 16 20:45:08 2010 (r6094) +++ format-plugins/vformat/src/xmlformat-common.h Mon Aug 16 20:52:03 2010 (r6095) @@ -71,6 +71,7 @@ osync_bool needs_charset(const unsigned char *tmp); void add_value(VFormatAttribute *attr, OSyncXMLField *xmlfield, const char *name, const char *encoding); +void add_value_data(VFormatAttribute *attr, OSyncXMLField *xmlfield, const char *data, const char *encoding); void add_value_array(VFormatAttribute *attr, OSyncXMLField *xmlfield, const char *parameterNameArray[], int nParameters, const char *encoding); void add_values(VFormatAttribute *attr, OSyncXMLField *xmlfield, const char *encoding); void add_values_from_nth_field_on(VFormatAttribute *attr, OSyncXMLField *xmlfield, const char *encoding, int nth); |
From: <svn...@op...> - 2010-08-16 18:45:17
|
Author: cdfrey Date: Mon Aug 16 20:45:08 2010 New Revision: 6094 URL: http://www.opensync.org/changeset/6094 Log: Enhanced osync_time_timestamp() to handle ISO timezone offsets as well If an ISO 8601 timezone offset exists in the timestamp passed to osync_time_timestamp(), then it will attempt to convert it into a UTC vtime timestamp in the form of YYYYMMDDTHHMMSSZ, which is the Opensync time format. Modified: trunk/opensync/format/opensync_time.c trunk/opensync/format/opensync_time.h trunk/tests/CMakeLists.txt trunk/tests/format-tests/check_time.c Modified: trunk/opensync/format/opensync_time.c ============================================================================== --- trunk/opensync/format/opensync_time.c Mon Aug 16 20:44:57 2010 (r6093) +++ trunk/opensync/format/opensync_time.c Mon Aug 16 20:45:08 2010 (r6094) @@ -95,11 +95,39 @@ char *osync_time_timestamp(const char *vtime) { - char *timestamp; + char *timestamp = NULL; + int found, offset; + OSyncError *error = NULL; osync_trace(TRACE_ENTRY, "%s(%s)", __func__, vtime); - timestamp = osync_time_timestamp_remove_dash(vtime); + // check for ISO 8601 timezone offset + // YYYY-MM-DDTHH:MM:SS.uuu-HH:MM + offset = osync_time_parse_iso_timezone_diff(vtime, &found, &error); + if( error ) + osync_error_unref(&error); + if( found ) { + time_t utc = osync_time_vtime2unix(vtime, offset, &error); + if( error ) { + osync_error_unref(&error); + } + else { + timestamp = osync_time_unix2vtime(&utc, &error); + if( error ) { + osync_error_unref(&error); + if( timestamp ) { + free(timestamp); + timestamp = NULL; + } + } + } + } + // timezone and unix conversion didn't work... fallback to dash removal + if( timestamp == NULL ) { + timestamp = osync_time_timestamp_remove_dash(vtime); + } + + // return timestamp in YYYYMMDDTHHMMSSZ osync_trace(TRACE_EXIT, "%s: %s", __func__, timestamp); return timestamp; } Modified: trunk/opensync/format/opensync_time.h ============================================================================== --- trunk/opensync/format/opensync_time.h Mon Aug 16 20:44:57 2010 (r6093) +++ trunk/opensync/format/opensync_time.h Mon Aug 16 20:45:08 2010 (r6094) @@ -43,6 +43,9 @@ */ /** @brief Function returns a date-timestamp in OSyncTime Spec format + * OSyncTime Spec format is YYYYMMDDTHHMMSSZ with Z optional. + * Input format can be in ISO 8601, including dashes and timezone + * offsets, and the returned timestamp will adjust it to UTC. * * @param vtime The timestamp which gets converted to a valid osync date-timestamp * @returns vtime date-timestring (the caller is responsible for freeing) Modified: trunk/tests/CMakeLists.txt ============================================================================== --- trunk/tests/CMakeLists.txt Mon Aug 16 20:44:57 2010 (r6093) +++ trunk/tests/CMakeLists.txt Mon Aug 16 20:45:08 2010 (r6094) @@ -393,6 +393,7 @@ OSYNC_TESTCASE(time time_relative2tm) OSYNC_TESTCASE(time time_unix_converters) OSYNC_TESTCASE(time time_utc_offset) +OSYNC_TESTCASE(time time_timestamp) BUILD_CHECK_TEST( version version-tests/check_version.c ${TEST_TARGET_LIBRARIES} ) OSYNC_TESTCASE(version version_new) Modified: trunk/tests/format-tests/check_time.c ============================================================================== --- trunk/tests/format-tests/check_time.c Mon Aug 16 20:44:57 2010 (r6093) +++ trunk/tests/format-tests/check_time.c Mon Aug 16 20:45:08 2010 (r6094) @@ -296,11 +296,24 @@ } END_TEST +START_TEST(time_timestamp) +{ + char *result = osync_time_timestamp("2010-08-10T11:15:22.234-03:00"); + int match = strcmp(result, "20100810T141522Z"); + fail_unless(match == 0, NULL); + + result = osync_time_timestamp("2010-08-10T11:15:22.234-03:0"); + match = strcmp(result, "20100810T111522.234-030"); + fail_unless(match == 0, NULL); +} +END_TEST + OSYNC_TESTCASE_START("time") OSYNC_TESTCASE_ADD(time_timezone_diff) OSYNC_TESTCASE_ADD(time_parse_iso_timezone_diff) OSYNC_TESTCASE_ADD(time_relative2tm) OSYNC_TESTCASE_ADD(time_unix_converters) OSYNC_TESTCASE_ADD(time_utc_offset) +OSYNC_TESTCASE_ADD(time_timestamp) OSYNC_TESTCASE_END |
From: <svn...@op...> - 2010-08-16 18:45:11
|
Author: cdfrey Date: Mon Aug 16 20:44:57 2010 New Revision: 6093 URL: http://www.opensync.org/changeset/6093 Log: Added missing time_utc_offset test to 'make test' run Modified: trunk/tests/CMakeLists.txt Modified: trunk/tests/CMakeLists.txt ============================================================================== --- trunk/tests/CMakeLists.txt Mon Aug 16 20:44:44 2010 (r6092) +++ trunk/tests/CMakeLists.txt Mon Aug 16 20:44:57 2010 (r6093) @@ -392,6 +392,7 @@ OSYNC_TESTCASE(time time_parse_iso_timezone_diff) OSYNC_TESTCASE(time time_relative2tm) OSYNC_TESTCASE(time time_unix_converters) +OSYNC_TESTCASE(time time_utc_offset) BUILD_CHECK_TEST( version version-tests/check_version.c ${TEST_TARGET_LIBRARIES} ) OSYNC_TESTCASE(version version_new) |
From: <svn...@op...> - 2010-08-16 18:44:57
|
Author: cdfrey Date: Mon Aug 16 20:44:44 2010 New Revision: 6092 URL: http://www.opensync.org/changeset/6092 Log: Added osync_time_parse_iso_timezone_diff() Modified: trunk/opensync.sym trunk/opensync/format/opensync_time.c trunk/opensync/format/opensync_time.h trunk/tests/CMakeLists.txt trunk/tests/format-tests/check_time.c Modified: trunk/opensync.sym ============================================================================== --- trunk/opensync.sym Sat Aug 14 02:24:19 2010 (r6091) +++ trunk/opensync.sym Mon Aug 16 20:44:44 2010 (r6092) @@ -676,6 +676,7 @@ osync_time_isdate osync_time_isutc osync_time_localtm2unix +osync_time_parse_iso_timezone_diff osync_time_relative2tm osync_time_sec2alarmdu osync_time_str2wday Modified: trunk/opensync/format/opensync_time.c ============================================================================== --- trunk/opensync/format/opensync_time.c Sat Aug 14 02:24:19 2010 (r6091) +++ trunk/opensync/format/opensync_time.c Mon Aug 16 20:44:44 2010 (r6092) @@ -487,6 +487,47 @@ return 0; } +int osync_time_parse_iso_timezone_diff(const char *iso_vtime, int *found, OSyncError **error) +{ + char *zonepart = NULL, *plainzone = NULL; + int hour, min, scanned, offset; + + char *timepart = strchr(iso_vtime, 'T'); + if( timepart == NULL ) { + *found = 0; + return 0; + } + + zonepart = strchr(timepart, '-'); + if( zonepart == NULL ) { + zonepart = strchr(timepart, '+'); + if( zonepart == NULL ) { + *found = 0; + return 0; + } + } + + plainzone = osync_time_timestamp_remove_dash(zonepart+1); + scanned = sscanf(plainzone, "%02d%02d", &hour, &min); + if( strlen(plainzone) != 4 || scanned != 2 ) { + *found = 0; + osync_error_set(error, OSYNC_ERROR_GENERIC, "Invalid timezone offset in ISO timestamp."); + return 0; + } + + *found = 1; + offset = (hour * 60 + min) * 60; + + // timezone offset is the same as the ISO format indicates... + // negative values are west of UTC (like Canada) and positive + // values are east of UTC (like Germany) + if( zonepart[0] == '-' ) { + offset *= -1; + } + + return offset; +} + struct tm *osync_time_tm2utc(const struct tm *ltime, int offset, OSyncError **error) { osync_trace(TRACE_ENTRY, "%s(%p, %i)", __func__, ltime, offset); Modified: trunk/opensync/format/opensync_time.h ============================================================================== --- trunk/opensync/format/opensync_time.h Sat Aug 14 02:24:19 2010 (r6091) +++ trunk/opensync/format/opensync_time.h Mon Aug 16 20:44:44 2010 (r6092) @@ -215,6 +215,25 @@ */ OSYNC_EXPORT int osync_time_timezone_diff(const struct tm *local, OSyncError **error); +/** @brief Parse an ISO 8601 timestamp string, and if a timezone offset + * exists, return an offset suitable for feeding into vtime2unix(). + * (seconds east of UTC.. i.e. east is positive, west is negative) + * + * @param iso_vtime String containing an ISO 8601 timestamp string, in the + * format of YYYYMMDDTHHMMSS-HHMM or YYYY-MM-DDTHH:MM:SS-HH:MM. + * @param found Pointer to an int. Will be set to 1 if a valid offset was + * found, or 0 if not. Not all timestamps have a timezone offset. + * If not found, 0 will also be returned as the offset. + * @param error An OSyncError struct. Always check if error is set using + * osync_error_is_set(error) before using the return value. A non- + * existing timezone offset is not an error, but a mal-formed one, + * like "-03:0" is an error. + * @return Seconds of timezone offset. On error, sets the error parameter, + * and the return value will be zero. If no offset is found in the + * string, return is zero. + */ +OSYNC_EXPORT int osync_time_parse_iso_timezone_diff(const char *iso_vtime, int *found, OSyncError **error); + /** @brief Function converts (struct tm) ltime from localtime to UTC. * Paramter offset is used as UTC offset. Note that _only_ the * following fields can be relied upon in the result: Modified: trunk/tests/CMakeLists.txt ============================================================================== --- trunk/tests/CMakeLists.txt Sat Aug 14 02:24:19 2010 (r6091) +++ trunk/tests/CMakeLists.txt Mon Aug 16 20:44:44 2010 (r6092) @@ -389,6 +389,7 @@ BUILD_CHECK_TEST( time format-tests/check_time.c ${TEST_TARGET_LIBRARIES} ) OSYNC_TESTCASE(time time_timezone_diff) +OSYNC_TESTCASE(time time_parse_iso_timezone_diff) OSYNC_TESTCASE(time time_relative2tm) OSYNC_TESTCASE(time time_unix_converters) Modified: trunk/tests/format-tests/check_time.c ============================================================================== --- trunk/tests/format-tests/check_time.c Sat Aug 14 02:24:19 2010 (r6091) +++ trunk/tests/format-tests/check_time.c Mon Aug 16 20:44:44 2010 (r6092) @@ -60,6 +60,56 @@ } END_TEST +START_TEST (time_parse_iso_timezone_diff) +{ + OSyncError *error = NULL; + int offset, found; + + // Not found + offset = osync_time_parse_iso_timezone_diff( + "20100810T001500Z", &found, &error); + fail_unless(offset == 0 && found == 0 && error == NULL, NULL); + + // Not found with dashes + offset = osync_time_parse_iso_timezone_diff( + "2010-08-10T00:15:00Z", &found, &error); + fail_unless(offset == 0 && found == 0 && error == NULL, NULL); + + // Found, with no separators + offset = osync_time_parse_iso_timezone_diff( + "20100810T001500-0300", &found, &error); + fail_unless(offset == -3*60*60 && found == 1 && error == NULL, NULL); + + // Found, with separators + offset = osync_time_parse_iso_timezone_diff( + "2010-08-10T00:15:00-03:00", &found, &error); + fail_unless(offset == -3*60*60 && found == 1 && error == NULL, NULL); + + // Found, positive offset, full ISO 8601 separaors + offset = osync_time_parse_iso_timezone_diff( + "2010-08-10T00:15:00.000+04:30", &found, &error); + fail_unless(offset == 4*60*60+30*60 && found == 1 && error == NULL, NULL); + + // Error: incomplete offset + offset = osync_time_parse_iso_timezone_diff( + "2010-08-10T00:15:00+04:3", &found, &error); + fail_unless(offset == 0 && found == 0 && error != NULL, NULL); + osync_error_unref(&error); + + // Error: too much offset + offset = osync_time_parse_iso_timezone_diff( + "2010-08-10T00:15:00+04:300", &found, &error); + fail_unless(offset == 0 && found == 0 && error != NULL, NULL); + osync_error_unref(&error); + + // No error, not found: offset without a time (no T found) + offset = osync_time_parse_iso_timezone_diff( + "2010-08-10+04:30", &found, &error); + fail_unless(offset == 0 && found == 0 && error == NULL, NULL); + osync_error_unref(&error); +} +END_TEST + static int test_relative2tm(const char *byday, int month, int year, int expected_day, int expected_wday) { @@ -248,6 +298,7 @@ OSYNC_TESTCASE_START("time") OSYNC_TESTCASE_ADD(time_timezone_diff) +OSYNC_TESTCASE_ADD(time_parse_iso_timezone_diff) OSYNC_TESTCASE_ADD(time_relative2tm) OSYNC_TESTCASE_ADD(time_unix_converters) OSYNC_TESTCASE_ADD(time_utc_offset) |