Changeset 2146
- Timestamp:
- 06/12/07 14:28:42 (1 year ago)
- Files:
-
- plugins/gnokii-sync/SConstruct (modified) (1 diff)
- plugins/gnokii-sync/build/linux/osync_build.py (modified) (1 diff)
- plugins/gnokii-sync/src/SConscript (modified) (1 diff)
- plugins/gnokii-sync/src/gnokii_calendar.c (modified) (5 diffs)
- plugins/gnokii-sync/src/gnokii_calendar_format.c (modified) (9 diffs)
- plugins/gnokii-sync/src/gnokii_calendar_utils.c (modified) (2 diffs)
- plugins/gnokii-sync/src/gnokii_calendar_utils.h (modified) (1 diff)
- plugins/gnokii-sync/src/gnokii_contact.c (modified) (7 diffs)
- plugins/gnokii-sync/src/gnokii_contact_format.c (modified) (5 diffs)
- plugins/gnokii-sync/src/gnokii_contact_utils.c (modified) (3 diffs)
- plugins/gnokii-sync/src/gnokii_sync.c (modified) (3 diffs)
- plugins/gnokii-sync/src/gnokii_sync.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/gnokii-sync/SConstruct
r2142 r2146 54 54 install_plugin = '${DESTDIR}$prefix/$libsuffix/opensync/plugins' 55 55 install_format = '${DESTDIR}$prefix/$libsuffix/opensync/formats' 56 install_config = '${DESTDIR}$prefix/share/opensync/defaults' 56 57 57 Export('env opts testenv install_prefix install_plugin install_format ')58 Export('env opts testenv install_prefix install_plugin install_format install_config') 58 59 59 60 SConscript(['src/SConscript']) plugins/gnokii-sync/build/linux/osync_build.py
r2143 r2146 50 50 51 51 return testenv 52 plugins/gnokii-sync/src/SConscript
r2142 r2146 9 9 10 10 # basic vformat plugins 11 gnokii_sync = env.SharedLibrary('gnokii-sync', ['gnokii_sync.c', 'gnokii_calendar.c', 'gnokii_contact.c', 'gnokii_config.c', 'gnokii_comm.c'], LIBS = ['opensync', 'gnokii'] , LIBPATH = '$prefix/$libsuffix')12 gnokii_event = env.SharedLibrary('gnokii-event', ['gnokii_calendar_format.c' ], LIBS = ['opensync'], LIBPATH = '$prefix/$libsuffix')13 gnokii_contact = env.SharedLibrary('gnokii-contact', ['gnokii_contact_format.c' ], LIBS = ['opensync'], LIBPATH = '$prefix/$libsuffix')11 gnokii_sync = env.SharedLibrary('gnokii-sync', ['gnokii_sync.c', 'gnokii_calendar.c', 'gnokii_contact.c', 'gnokii_config.c', 'gnokii_comm.c'], LIBS = ['opensync', 'gnokii']) 12 gnokii_event = env.SharedLibrary('gnokii-event', ['gnokii_calendar_format.c', 'gnokii_calendar_utils.c'], LIBS = ['opensync']) 13 gnokii_contact = env.SharedLibrary('gnokii-contact', ['gnokii_contact_format.c', 'gnokii_contact_utils.c'], LIBS = ['opensync']) 14 14 15 15 16 # install synchronization plugin 16 # install synchronization plugin and config 17 17 env.Install(install_plugin, gnokii_sync) 18 # install format plugin 18 env.Install(install_config, ['gnokii-sync']) 19 20 # install format plugins 19 21 env.Install(install_format, gnokii_event) 20 22 env.Install(install_format, gnokii_contact) plugins/gnokii-sync/src/gnokii_calendar.c
r2145 r2146 202 202 if (error == GN_ERR_EMPTYLOCATION) { 203 203 osync_trace(TRACE_EXIT, "%s: no calendar note left.", __func__); 204 g_free(calnote); 204 205 return NULL; 205 206 } … … 208 209 if (error != GN_ERR_NONE) { 209 210 osync_trace(TRACE_EXIT_ERROR, "%s(): error while query the phone - gnokii: %s", __func__, gn_error_print(error)); 211 g_free(calnote); 210 212 return NULL; 211 213 } … … 367 369 break; 368 370 369 OSyncChange *change = osync_change_new(&error);370 371 371 // prepare UID with gnokii-calendar-<memory location> 372 372 uid = g_strdup_printf ("gnokii-calendar-%i", calnote->location); 373 osync_hashtable_report(sinkenv->hashtable, uid); 374 375 hash = gnokii_calendar_hash(calnote); 376 OSyncChangeType type = osync_hashtable_get_changetype(sinkenv->hashtable, uid, hash); 377 378 if (type == OSYNC_CHANGE_TYPE_UNMODIFIED) { 379 g_free(hash); 380 g_free(uid); 381 g_free(calnote); 382 continue; 383 } 384 385 osync_hashtable_update_hash(sinkenv->hashtable, type, uid, hash); 386 387 OSyncChange *change = osync_change_new(&error); 388 373 389 osync_change_set_uid(change, uid); 374 375 // get hash of calnote376 hash = gnokii_calendar_hash(calnote);377 390 osync_change_set_hash(change, hash); 391 osync_change_set_changetype(change, type); 378 392 379 393 // set data 380 OSyncData *data = osync_data_new((char *) calnote, sizeof(gn_calnote), sinkenv->objformat, &error); 381 if (!data) { 394 osync_trace(TRACE_INTERNAL, "objformat: %p", sinkenv->objformat); 395 OSyncData *odata = osync_data_new((char *) calnote, sizeof(gn_calnote), sinkenv->objformat, &error); 396 if (!odata) { 382 397 osync_change_unref(change); 383 398 osync_context_report_osyncwarning(ctx, error); … … 385 400 g_free(hash); 386 401 g_free(uid); 402 g_free(calnote); 387 403 continue; 388 404 } 389 405 390 osync_data_set_objtype(data, osync_objtype_sink_get_name(sink)); 391 osync_change_set_data(change, data); 392 osync_data_unref(data); 393 394 OSyncChangeType type = osync_hashtable_get_changetype(sinkenv->hashtable, uid, hash); 395 if (type != OSYNC_CHANGE_TYPE_UNMODIFIED) { 396 osync_trace(TRACE_INTERNAL, "Position: %i Needs to be reported (!= hash)", calnote->location); 397 osync_context_report_change(ctx, change); 398 osync_hashtable_update_hash(sinkenv->hashtable, type, uid, hash); 399 } 406 osync_data_set_objtype(odata, osync_objtype_sink_get_name(sink)); 407 osync_change_set_data(change, odata); 408 osync_data_unref(odata); 409 410 osync_context_report_change(ctx, change); 411 412 osync_trace(TRACE_INTERNAL, "Change: %p", change); 413 414 osync_change_unref(change); 400 415 401 416 g_free(hash); … … 560 575 } 561 576 562 // answer the call563 577 osync_context_report_success(ctx); 564 565 // blubb 566 /* 567 osync_trace(TRACE_INTERNAL, "change->hash: %s change->changetype: %i", osync_change_get_hash(change), 568 osync_change_get_changetype(change)); 569 */ 570 571 g_free(calnote); 572 578 573 579 // update hashtable 574 580 osync_hashtable_update_hash(sinkenv->hashtable, osync_change_get_changetype(change), osync_change_get_uid(change), osync_change_get_hash(change)); plugins/gnokii-sync/src/gnokii_calendar_format.c
r2142 r2146 56 56 57 57 // Type 58 xmlfield = osync_xmlfield_new(xmlformat, "Categor y", error);58 xmlfield = osync_xmlfield_new(xmlformat, "Categories", error); 59 59 switch (cal->type) { 60 60 case GN_CALNOTE_MEETING: … … 193 193 xmlfield = osync_xmlfield_new(xmlformat, "Alarm", error); 194 194 195 // TODO: How to handle AlarmAction? 196 // AUDIO by tone? 197 // DISPLAY by silent? 198 // EMAIL and PRODECDURE isn't supported by libgnokii 195 199 if (cal->alarm.tone) 200 osync_xmlfield_set_key_value(xmlfield, "AlarmAction", "AUDIO"); 201 else 196 202 osync_xmlfield_set_key_value(xmlfield, "AlarmAction", "DISPLAY"); 203 197 204 198 205 … … 204 211 205 212 // Summary 206 if ( cal->text) {213 if (strlen(cal->text)) { 207 214 xmlfield = osync_xmlfield_new(xmlformat, "Summary", error); 208 215 osync_xmlfield_set_key_value(xmlfield, "Content", cal->text); … … 210 217 211 218 // Phone Number 212 if ( cal->phone_number&& cal->type == GN_CALNOTE_CALL) {219 if (strlen(cal->phone_number) && cal->type == GN_CALNOTE_CALL) { 213 220 xmlfield = osync_xmlfield_new(xmlformat, "Description", error); 214 221 osync_xmlfield_set_key_value(xmlfield, "Content", cal->phone_number); … … 216 223 217 224 // mlocation 218 if ( cal->mlocation&& cal->type == GN_CALNOTE_MEETING) {225 if (strlen(cal->mlocation) && cal->type == GN_CALNOTE_MEETING) { 219 226 xmlfield = osync_xmlfield_new(xmlformat, "Location", error); 220 227 osync_xmlfield_set_key_value(xmlfield, "Content", cal->mlocation); … … 289 296 } 290 297 298 static void _xmlfield_category(gn_calnote *calnote, OSyncXMLField *xmlfield) 299 { 300 int i; 301 int numnodes = osync_xmlfield_get_key_count(xmlfield); 302 for (i=0; i < numnodes; i++) { 303 const char *category = osync_xmlfield_get_nth_key_value(xmlfield, i); 304 305 if (!strcasecmp(category, "Meeting")) 306 calnote->type = GN_CALNOTE_MEETING; 307 else if (!strcasecmp(category, "Calling")) 308 calnote->type = GN_CALNOTE_CALL; 309 else if (!strcasecmp(category, "Birthday")) 310 calnote->type = GN_CALNOTE_BIRTHDAY; 311 else if (!strcasecmp(category, "Reminder")) 312 calnote->type = GN_CALNOTE_REMINDER; 313 else if (!strcasecmp(category, "Memo")) 314 calnote->type = GN_CALNOTE_MEMO; 315 316 else 317 // When no known type was found it will check later 318 // for a valid type. 319 calnote->type = 0; 320 321 } 322 } 323 324 static void _xmlfield_datestarted(gn_calnote *calnote, OSyncXMLField *xmlfield, int *alldayevent) 325 { 326 327 const char *dtstart = osync_xmlfield_get_key_value(xmlfield, "Content"); 328 329 struct tm *starttm = osync_time_vtime2tm(dtstart); 330 struct tm *tmptm = NULL; 331 332 if (!osync_time_isdate(dtstart) && osync_time_isutc(dtstart)) { 333 tmptm = starttm; 334 int offset = osync_time_timezone_diff(tmptm); 335 starttm = osync_time_tm2localtime(tmptm, offset); 336 g_free(tmptm); 337 } 338 339 calnote->time = gnokii_util_tm2timestamp(starttm); 340 341 g_free(starttm); 342 343 // Only 3 matches (=date) means all day event 344 if (osync_time_isdate(dtstart)) 345 *alldayevent = 1; 346 347 // Nokia cellphones cannot handle seconds in calendar - so set it to ZERO 348 calnote->time.second = 0; 349 350 } 351 352 void static _xmlfield_dateend(gn_calnote *calnote, OSyncXMLField *xmlfield) 353 { 354 355 const char *dtend = osync_xmlfield_get_key_value(xmlfield, "Content"); 356 357 358 struct tm *endtm = osync_time_vtime2tm(dtend); 359 struct tm *tmptm = NULL; 360 if (!osync_time_isdate(dtend) && osync_time_isutc(dtend)) { 361 tmptm = endtm; 362 int offset = osync_time_timezone_diff(tmptm); 363 endtm = osync_time_tm2localtime(tmptm, offset); 364 g_free(tmptm); 365 } 366 367 calnote->end_time = gnokii_util_tm2timestamp(endtm); 368 g_free(endtm); 369 370 // Nokia cellphones cannot handle seconds in calendar so set it to ZERO 371 calnote->end_time.second = 0; 372 373 } 374 375 void static _xmlfield_alarm(gn_calnote *calnote, OSyncXMLField *xmlfield) 376 { 377 int seconds_before = 0; 378 time_t start_timet, alarm_timet; 379 380 calnote->alarm.enabled = 1; 381 382 const char *action = osync_xmlfield_get_key_value(xmlfield, "AlarmAction"); 383 384 if (!action) 385 osync_trace(TRACE_INTERNAL, "AlarmAction wasn't set!"); 386 387 if (action && (!strcasecmp(action, "DISPLAY") || !strcasecmp(action, "AUDIO"))) 388 calnote->alarm.tone = 1; 389 390 391 392 const char *trigger = osync_xmlfield_get_key_value(xmlfield, "AlarmTrigger"); 393 394 if (!trigger) 395 osync_trace(TRACE_INTERNAL, "AlarmTrigger wasn't set!"); 396 397 const char *triggertype = osync_xmlfield_get_attr(xmlfield, "Value"); 398 399 if (triggertype && !strcasecmp("DURATION", triggertype)) { 400 seconds_before = gnokii_util_alarmevent2secs(trigger); 401 402 // convert start event in to seconds 403 start_timet = gnokii_util_timestamp2unix(&(calnote->time)); 404 405 // timestamp for alarm 406 alarm_timet = start_timet - seconds_before; 407 } else if (triggertype && ! strcasecmp("DATE-TIME", triggertype)) { 408 // TODO: untested! - check UTC offeset issues 409 alarm_timet = osync_time_vtime2unix(trigger, 0); 410 } else { 411 osync_trace(TRACE_INTERNAL, "Unkown TRIGGERVALUE - skip Alarm."); 412 return; 413 } 414 415 // convert timestamp of alarm to gnokii timestamp 416 calnote->alarm.timestamp = gnokii_util_unix2timestamp(alarm_timet); 417 } 418 419 void static _xmlfield_summary(gn_calnote *calnote, OSyncXMLField *xmlfield) 420 { 421 const char *summary = osync_xmlfield_get_key_value(xmlfield, "Content"); 422 strncpy(calnote->text, summary, GN_CALNOTE_MAX_LENGTH); 423 } 424 425 void static _xmlfield_location(gn_calnote *calnote, OSyncXMLField *xmlfield) 426 { 427 const char *location = osync_xmlfield_get_key_value(xmlfield, "Content"); 428 // if (calnote->type == GN_CALNOTE_MEETING && location) 429 strncpy(calnote->mlocation, location, GN_CALNOTE_MAX_LENGTH); 430 } 431 432 void static _xmlfield_description(gn_calnote *calnote, OSyncXMLField *xmlfield) 433 { 434 435 const char *description = osync_xmlfield_get_key_value(xmlfield, "Content"); 436 // if (calnote->type == GN_CALNOTE_CALL || gnokii_util_valid_number(tmp)) 437 strncpy(calnote->phone_number, description, GN_CALNOTE_NUMBER_MAX_LENGTH); 438 } 439 440 void static _xmlfield_recurrencerule(gn_calnote *calnote, OSyncXMLField *xmlfield) 441 { 442 int interval = 0; 443 444 const char *freq = osync_xmlfield_get_key_value(xmlfield, "Frequency"); 445 446 if (!strcasecmp(freq, "DAILY")) 447 calnote->recurrence = GN_CALNOTE_DAILY; 448 else if (!strcasecmp(freq, "WEEKLY")) 449 calnote->recurrence = GN_CALNOTE_WEEKLY; 450 else if (!strcasecmp(freq, "MONTHLY")) 451 calnote->recurrence = GN_CALNOTE_MONTHLY; 452 else if (!strcasecmp(freq, "YEARLY")) 453 calnote->recurrence = GN_CALNOTE_YEARLY; 454 455 const char *ival = osync_xmlfield_get_key_value(xmlfield, "Interval"); 456 457 if (ival) 458 sscanf(ival, "%u", &interval); 459 460 // TODO: Get this merged by demerger.... 461 // Nokia phones only support a interval of 2 for weeks 462 if (calnote->recurrence == GN_CALNOTE_WEEKLY && interval == 2) 463 calnote->recurrence = GN_CALNOTE_2WEEKLY; 464 } 465 466 291 467 /* 292 468 * Converts from XMLFormat-event to the gnokii event object type (gn_calnote). … … 297 473 output, outpsize, config, free_input, error); 298 474 299 osync_trace(TRACE_SENSITIVE, "Input XML is:\n%s", osxml_write_to_string((xmlDoc *)input)); 300 301 char *tmp; 302 struct tm *starttm = NULL, *endtm = NULL, *tmptm = NULL; 303 int offset = 0; 475 OSyncXMLFormat *xmlformat = (OSyncXMLFormat *)input; 476 unsigned int size; 477 char *str; 478 osync_xmlformat_assemble(xmlformat, &str, &size); 479 osync_trace(TRACE_INTERNAL, "Input XMLFormat is:\n%s", str); 480 g_free(str); 481 482 // struct tm *starttm = NULL, *endtm = NULL, *tmptm = NULL; 304 483 osync_bool alldayevent = 0; 305 xmlNode *cur = NULL; 306 xmlNode *root = xmlDocGetRootElement((xmlDoc *)input); 307 308 if (!root) { 309 osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to get xml root element"); 484 485 if (strcmp("event", osync_xmlformat_get_objtype(xmlformat))) { 486 osync_error_set(error, OSYNC_ERROR_GENERIC, "Wrong xmlformat: %s", osync_xmlformat_get_objtype(xmlformat)); 310 487 goto error; 311 488 } 312 489 313 if (xmlStrcmp(root->name, (xmlChar *) "vcal")) {314 osync_error_set(error, OSYNC_ERROR_GENERIC, "Wrong (event) xml root element");315 goto error;316 }317 318 // Event child319 root = osxml_get_node(root, "Event");320 321 490 // prepare calnote 322 gn_calnote *calnote = NULL; 323 calnote = (gn_calnote *) malloc(sizeof(gn_calnote)); 324 325 memset(calnote, 0, sizeof(gn_calnote)); 326 327 // Type 328 // TODO: handle more then one category - not only the first 329 cur = osxml_get_node(root, "Categories"); 330 if (cur) { 331 332 tmp = (char *) xmlNodeGetContent(cur); 333 334 if (!strcasecmp(tmp, "Meeting")) 335 calnote->type = GN_CALNOTE_MEETING; 336 else if (!strcasecmp(tmp, "Calling")) 337 calnote->type = GN_CALNOTE_CALL; 338 else if (!strcasecmp(tmp, "Birthday")) 339 calnote->type = GN_CALNOTE_BIRTHDAY; 340 else if (!strcasecmp(tmp, "Reminder")) 341 calnote->type = GN_CALNOTE_REMINDER; 342 else if (!strcasecmp(tmp, "Memo")) 343 calnote->type = GN_CALNOTE_MEMO; 344 345 else 346 // When no known type was found it will check later 347 // for a valid type. 348 calnote->type = 0; 349 350 g_free(tmp); 351 } 352 353 // DateStarted 354 cur = osxml_get_node(root, "DateStarted"); 355 if (cur) { 356 357 tmp = osxml_find_node(cur, "Content"); 358 359 /* 360 ret = sscanf(tmp, "%04u%02u%02uT%02u%02u%02u", 361 &(calnote->time.year), 362 &(calnote->time.month), 363 &(calnote->time.day), 364 &(calnote->time.hour), 365 &(calnote->time.minute), 366 &(calnote->time.second)); 367 */ 368 369 starttm = osync_time_vtime2tm(tmp); 370 371 if (!osync_time_isdate(tmp) && osync_time_isutc(tmp)) { 372 tmptm = starttm; 373 offset = osync_time_timezone_diff(tmptm); 374 starttm = osync_time_tm2localtime(tmptm, offset); 375 g_free(tmptm); 376 } 377 378 calnote->time = gnokii_util_tm2timestamp(starttm); 379 380 g_free(starttm); 381 382 // Only 3 matches (=date) means all day event 383 if (osync_time_isdate(tmp)) 384 alldayevent = 1; 385 386 g_free(tmp); 387 388 389 // Nokia cellphones cannot handle seconds in calendar - so set it to ZERO 390 calnote->time.second = 0; 391 } 491 gn_calnote *calnote = osync_try_malloc0(sizeof(gn_calnote), error); 492 493 OSyncXMLField *xmlfield = osync_xmlformat_get_first_field(xmlformat); 494 for (; xmlfield; xmlfield = osync_xmlfield_get_next(xmlfield)) { 495 osync_trace(TRACE_INTERNAL, "Field: %s", osync_xmlfield_get_name(xmlfield)); 496 497 if (!strcmp("Categories", osync_xmlfield_get_name(xmlfield))) 498 _xmlfield_category(calnote, xmlfield); 499 else if (!strcmp("DateStarted", osync_xmlfield_get_name(xmlfield))) 500 _xmlfield_datestarted(calnote, xmlfield, &alldayevent); 501 else if (!strcmp("DateEnd", osync_xmlfield_get_name(xmlfield))) 502 _xmlfield_dateend(calnote, xmlfield); 503 else if (!strcmp("Alarm", osync_xmlfield_get_name(xmlfield))) 504 _xmlfield_alarm(calnote, xmlfield); 505 else if (!strcmp("Summary", osync_xmlfield_get_name(xmlfield))) 506 _xmlfield_summary(calnote, xmlfield); 507 else if (!strcmp("Location", osync_xmlfield_get_name(xmlfield))) 508 _xmlfield_location(calnote, xmlfield); 509 else if (!strcmp("Description", osync_xmlfield_get_name(xmlfield))) 510 _xmlfield_description(calnote, xmlfield); 511 else if (!strcmp("RecurrenceRule", osync_xmlfield_get_name(xmlfield))) 512 _xmlfield_recurrencerule(calnote, xmlfield); 513 514 } 515 392 516 393 517 394 // DateEnd395 cur = osxml_get_node(root, "DateEnd");396 if (cur) {397 398 tmp = osxml_find_node(cur, "Content");399 400 endtm = osync_time_vtime2tm(tmp);401 if (!osync_time_isdate(tmp) && osync_time_isutc(tmp)) {402 tmptm = endtm;403 endtm = osync_time_tm2localtime(tmptm, offset);404 g_free(tmptm);405 }406 407 g_free(tmp);408 409 calnote->end_time = gnokii_util_tm2timestamp(endtm);410 411 g_free(endtm);412 413 // Nokia cellphones cannot handle seconds in calendar so set it to ZERO414 calnote->end_time.second = 0;415 }416 417 /* Alarm - TODO: is not fully supported418 * Not supported:419 * ^^^^^^^^^^^^^^420 * # alarm after event421 * # alarm before event end422 * # ...423 */424 cur = osxml_get_node(root, "Alarm");425 if (cur && calnote->time.year) {426 427 int seconds_before = 0;428 time_t start_timet, alarm_timet;429 430 calnote->alarm.enabled = 1;431 432 tmp = osxml_find_node(cur, "AlarmAction");433 if (tmp && !strcasecmp(tmp, "DISPLAY"))434 calnote->alarm.tone = 1;435 436 g_free(tmp);437 438 // get AlarmTrigger root439 xmlNode *sub = osxml_get_node(cur, "AlarmTrigger");440 441 // get node with iCal duration442 tmp = osxml_find_node(sub, "Content");443 444 // convert iCal duration string into seconds (before event)445 seconds_before = gnokii_util_alarmevent2secs(tmp);446 447 g_free(tmp);448 449 // convert start event in to seconds450 start_timet = gnokii_util_timestamp2unix(&(calnote->time));451 452 // timestamp for alarm453 alarm_timet = start_timet - seconds_before;454 455 // convert timestamp of alarm to gnokii timestamp456 calnote->alarm.timestamp = gnokii_util_unix2timestamp(alarm_timet);457 }458 459 // Summary460 cur = osxml_get_node(root, "Summary");461 if (cur) {462 tmp = (char *) xmlNodeGetContent(cur);463 strncpy(calnote->text, tmp, sizeof(calnote->text));464 g_free(tmp);465 }466 467 // meeting location468 cur = osxml_get_node(root, "Location");469 if (cur) {470 tmp = (char *) xmlNodeGetContent(cur);471 472 if (calnote->type == GN_CALNOTE_MEETING && tmp)473 strncpy(calnote->mlocation, tmp, sizeof(calnote->mlocation));474 475 g_free(tmp);476 }477 478 // PhoneNumber479 cur = osxml_get_node(root, "Description");480 if (cur) {481 tmp = (char *) xmlNodeGetContent(cur);482 if (calnote->type == GN_CALNOTE_CALL || gnokii_util_valid_number(tmp))483 strncpy(calnote->phone_number, tmp, sizeof(calnote->phone_number));484 485 g_free(tmp);486 }487 488 // Reccurence489 cur = osxml_get_node(root, "RecurrenceRule");490 if (cur) {491 int interval = 0;492 493 for (cur = cur->children; cur; cur = cur->next) {494 495 tmp = (char *) xmlNodeGetContent(cur);496 497 if (strstr(tmp, "DAILY"))498 calnote->recurrence = GN_CALNOTE_DAILY;499 else if (strstr(tmp, "WEEKLY"))500 calnote->recurrence = GN_CALNOTE_WEEKLY;501 else if (strstr(tmp, "MONTHLY"))502 calnote->recurrence = GN_CALNOTE_MONTHLY;503 else if (strstr(tmp, "YEARLY"))504 calnote->recurrence = GN_CALNOTE_YEARLY;505 506 else if (strstr(tmp, "INTERVAL"))507 sscanf(tmp, "INTERVAL=%u", &interval);508 509 g_free(tmp);510 }511 512 // Nokia phones only support a interval of 2 for weeks513 if (calnote->recurrence == GN_CALNOTE_WEEKLY && interval == 2)514 calnote->recurrence = GN_CALNOTE_2WEEKLY;515 }516 518 517 519 // check for type which fits for given data if no type was set … … 519 521 calnote->type = gnokii_util_calendar_type(calnote, alldayevent); 520 522 521 522 523 *free_input = TRUE; 523 524 *output = (void *)calnote; … … 533 534 534 535 535 static void destroy_gnokii_event(char *input, size_t inpsize)536 static void destroy_gnokii_event(char *input, unsigned int inpsize) 536 537 { 537 538 osync_trace(TRACE_ENTRY, "%s(%p, %i)", __func__, input, inpsize); plugins/gnokii-sync/src/gnokii_calendar_utils.c
r2142 r2146 30 30 * Returns: seconds before event 31 31 */ 32 int gnokii_util_alarmevent2secs(c har *alarm) {32 int gnokii_util_alarmevent2secs(const char *alarm) { 33 33 34 34 osync_trace(TRACE_ENTRY, "%s(%s)", __func__, alarm); … … 240 240 date = gnokii_util_timestamp2tm(timestamp); 241 241 timet = mktime(date); 242 g_free(date); 242 243 243 244 osync_trace(TRACE_EXIT, "%s: %ul", __func__, timet); plugins/gnokii-sync/src/gnokii_calendar_utils.h
r2142 r2146 26 26 gn_timestamp gnokii_util_tm2timestamp(const struct tm *timetm); 27 27 time_t gnokii_util_timestamp2unix(gn_timestamp *timestamp); 28 int gnokii_util_alarmevent2secs(c har *alarm);28 int gnokii_util_alarmevent2secs(const char *alarm); 29 29 char *gnokii_util_secs2alarmevent(int secs_before_event); 30 osync_bool gnokii_util_valid_number(c har *number);30 osync_bool gnokii_util_valid_number(const char *number); 31 31 gn_calnote_type gnokii_util_calendar_type(gn_calnote *calnote, osync_bool alldayevent); 32 32 plugins/gnokii-sync/src/gnokii_contact.c
r2145 r2146 158 158 if (error == GN_ERR_EMPTYLOCATION) { 159 159 osync_trace(TRACE_EXIT, "%s(): memorty_type: %i location: %i counter: %i", __func__, contact->memory_type, contact->location, i); 160 g_free(data); 160 161 return contact; 161 162 } … … 166 167 } 167 168 168 // TODO set error and leave 169 g_free(data); 170 g_free(contact); 169 171 osync_trace(TRACE_EXIT, "%s(): NO FREE LOCATION!", __func__); 170 172 return NULL; … … 422 424 // prepare UID with gnokii-contact-<memory type>-<memory location> 423 425 uid = gnokii_contact_uid(contact); 426 osync_hashtable_report(sinkenv->hashtable, uid); 424 427 425 428 hash = gnokii_contact_hash(contact); … … 473 476 g_free(data); 474 477 475 476 /* FIXME: this is really really broken :(477 478 int i; 478 479 479 char **uids = osync_hashtable_get_deleted(sinkenv->hashtable); 480 480 for (i = 0; uids[i]; i++) { … … 511 511 } 512 512 g_free(uids); 513 */514 513 515 514 osync_context_report_success(ctx); … … 528 527 OSyncError *error = NULL; 529 528 gn_phonebook_entry *contact = NULL; 529 char *buf; 530 530 char *uid = NULL; 531 531 char *hash = NULL; … … 536 536 537 537 // Get changed contact note 538 contact = (gn_phonebook_entry *) osync_change_get_data(change); 538 osync_data_get_data(osync_change_get_data(change), &buf, NULL); 539 contact = (gn_phonebook_entry *) buf; 539 540 540 541 // Check for type of changes plugins/gnokii-sync/src/gnokii_contact_format.c
r2145 r2146 53 53 54 54 // Name 55 if ( contact->name) {55 if (strlen(contact->name)) { 56 56 57 57 xmlfield = osync_xmlfield_new(xmlformat, "FormattedName", error); … … 59 59 60 60 // FIXME: evo2 workaround - evo2 requires a Name / N filed :( 61 /* 61 62 xmlfield = osync_xmlfield_new(xmlformat, "Name", error); 62 63 osync_xmlfield_set_key_value(xmlfield, "FirstName", contact->name); 64 */ 63 65 } 64 66 … … 216 218 } 217 219 220 static void _xmlfield_formattedname(gn_phonebook_entry *contact, OSyncXMLField *xmlfield) 221 { 222 const char *name = osync_xmlfield_get_key_value(xmlfield, "Content"); 223 strncpy(contact->name, name, GN_PHONEBOOK_NAME_MAX_LENGTH); 224 } 225 226 static void _xmlfield_telephone(gn_phonebook_entry *contact, OSyncXMLField *xmlfield, int *subcount) 227 { 228 const char *tele = osync_xmlfield_get_key_value(xmlfield, "Content"); 229 230 char *number = gnokii_contact_util_cleannumber(tele); 231 strncpy(contact->subentries[*subcount].data.number, number, GN_PHONEBOOK_NAME_MAX_LENGTH); 232 g_free(number); 233 234 contact->subentries[*subcount].entry_type = GN_PHONEBOOK_ENTRY_Number; 235 236 const char *type = osync_xmlfield_get_attr(xmlfield, "Type"); 237 const char *location = osync_xmlfield_get_attr(xmlfield, "Location"); 238 239 if (location && !strcasecmp(location, "Work")) 240 contact->subentries[*subcount].number_type = GN_PHONEBOOK_NUMBER_Work; 241 else if (location && !strcasecmp(location, "Home")) 242 contact->subentries[*subcount].number_type = GN_PHONEBOOK_NUMBER_Home; 243 else if (type && !strcasecmp(type, "Fax")) 244 contact->subentries[*subcount].number_type = GN_PHONEBOOK_NUMBER_Fax; 245 else if (type && !strcasecmp(type, "Cellular")) 246 contact->subentries[*subcount].number_type = GN_PHONEBOOK_NUMBER_Mobile; 247 else 248 contact->subentries[*subcount].number_type = GN_PHONEBOOK_NUMBER_General; 249 250 (*subcount)++; 251 } 252 253 static void _xmlfield_url(gn_phonebook_entry *contact, OSyncXMLField *xmlfield, int *subcount) 254 { 255 const char *url = osync_xmlfield_get_key_value(xmlfield, "Content"); 256 257 contact->subentries[*subcount].entry_type = GN_PHONEBOOK_ENTRY_URL; 258 strncpy(contact->subentries[*subcount].data.number, url, GN_PHONEBOOK_NAME_MAX_LENGTH); 259 (*subcount)++; 260 } 261 262 static void _xmlfield_email(gn_phonebook_entry *contact, OSyncXMLField *xmlfield, int *subcount) 263 { 264 const char *email = osync_xmlfield_get_key_value(xmlfield, "Content"); 265 contact->subentries[*subcount].entry_type = GN_PHONEBOOK_ENTRY_Email; 266 strncpy(contact->subentries[*subcount].data.number, email, GN_PHONEBOOK_NAME_MAX_LENGTH); 267 268 (*subcount)++; 269 } 270 271 static void _xmlfield_note(gn_phonebook_entry *contact, OSyncXMLField *xmlfield, int *subcount) 272 { 273 const char *note = osync_xmlfield_get_key_value(xmlfield, "Content"); 274 275 contact->subentries[*subcount].entry_type = GN_PHONEBOOK_ENTRY_Note; 276 strncpy(contact->subentries[*subcount].data.number, note, GN_PHONEBOOK_NAME_MAX_LENGTH); 277 (*subcount)++; 278 } 279 280 static void _xmlfield_addresslabel(gn_phonebook_entry *contact, OSyncXMLField *xmlfield, int *subcount) 281 { 282 const char *label = osync_xmlfield_get_key_value(xmlfield, "Content"); 283 contact->subentries[*subcount].entry_type = GN_PHONEBOOK_ENTRY_Postal; 284 strncpy(contact->subentries[*subcount].data.number, label, GN_PHONEBOOK_NAME_MAX_LENGTH); 285 (*subcount)++; 286 } 287 288 static void _xmlfield_category(gn_phonebook_entry *contact, OSyncXMLField *xmlfield) 289 { 290 contact->caller_group = GN_PHONEBOOK_GROUP_None; 291 292 int i; 293 int numnodes = osync_xmlfield_get_key_count(xmlfield); 294 for (i=0; i < numnodes; i++) { 295 const char *category = osync_xmlfield_get_nth_key_value(xmlfield, i); 296 297 if (!strcasecmp(category, "FAMILY")) { 298 contact->caller_group = GN_PHONEBOOK_GROUP_Family; 299 } else if (!strcasecmp(category, "VIPS") || !strcasecmp(category, "VIP")) { // FIXME: evo2-sync workaround fix that in vformat plugin 300 contact->caller_group = GN_PHONEBOOK_GROUP_Vips; 301 } else if (!strcasecmp(category, "FRIENDS")) { 302 contact->caller_group = GN_PHONEBOOK_GROUP_Friends; 303 } else if (!strcasecmp(category, "WORK")) { 304 contact->caller_group = GN_PHONEBOOK_GROUP_Work; 305 } else if (!strcasecmp(category, "OTHERS")) { 306 contact->caller_group = GN_PHONEBOOK_GROUP_Others; 307 } 308 309 } 310 } 311 312 313 218 314 /* 219 315 * Converts from XML to the gnokii contact object type (gn_phonebook_entry). … … 224 320 output, outpsize, free_input, config, error); 225 321 226 osync_trace(TRACE_SENSITIVE, "Input XML is:\n%s", osxml_write_to_string((xmlDoc *)input)); 227 228 char *tmp = NULL, *number = NULL; 229 xmlNode *cur = NULL; 230 xmlNode *sub = NULL; 231 xmlNode *root = xmlDocGetRootElement((xmlDoc *)input); 232 xmlXPathObject *xobj = NULL; 233 xmlNodeSet *nodes = NULL; 234 int numnodes = 0; 322 OSyncXMLFormat *xmlformat = (OSyncXMLFormat *)input; 323 unsigned int size; 324 char *str; 325 osync_xmlformat_assemble(xmlformat, &str, &size); 326 osync_trace(TRACE_INTERNAL, "Input XMLFormat is:\n%s", str); 327 g_free(str); 328 235 329 int subcount = 0; 236 int i; 237 238 239 if (!root) { 240 osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to get xml root element"); 330 331 // prepare contact 332 gn_phonebook_entry *contact = osync_try_malloc0(sizeof(gn_phonebook_entry), error); 333 334 if (strcmp("contact", osync_xmlformat_get_objtype(xmlformat))) { 335 osync_error_set(error, OSYNC_ERROR_GENERIC, "Wrong xmlformat: %s", osync_xmlformat_get_objtype(xmlformat)); 241 336 goto error; 242 337 } 243 338 244 if (xmlStrcmp(root->name, (const xmlChar *) "contact")) { 245 osync_error_set(error, OSYNC_ERROR_GENERIC, "Wrong (contact) xml root element"); 246 goto error; 247 } 248 249 // prepare contact 250 gn_phonebook_entry *contact = NULL; 251 contact = (gn_phonebook_entry *) malloc(sizeof(gn_phonebook_entry)); 252 253 memset(contact, 0, sizeof(gn_phonebook_entry)); 254 255 // FormattedName - XXX Also Node "Name"? 256 cur = osxml_get_node(root, "FormattedName"); 257 if (cur) { 258 tmp = (char *) xmlNodeGetContent(cur); 259 strncpy(contact->name, tmp, GN_PHONEBOOK_
