Changeset 2142
- Timestamp:
- 06/12/07 14:13:50 (1 year ago)
- Files:
-
- plugins/gnokii-sync/SConstruct (modified) (1 diff)
- plugins/gnokii-sync/build/linux/osync_build.py (modified) (2 diffs)
- plugins/gnokii-sync/src/SConscript (modified) (1 diff)
- plugins/gnokii-sync/src/gnokii_calendar.c (modified) (6 diffs)
- plugins/gnokii-sync/src/gnokii_calendar_format.c (modified) (8 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_config.c (modified) (7 diffs)
- plugins/gnokii-sync/src/gnokii_config.h (modified) (1 diff)
- plugins/gnokii-sync/src/gnokii_contact.c (modified) (9 diffs)
- plugins/gnokii-sync/src/gnokii_contact_format.c (modified) (7 diffs)
- plugins/gnokii-sync/src/gnokii_contact_utils.c (modified) (3 diffs)
- plugins/gnokii-sync/src/gnokii_sync.c (modified) (8 diffs)
- plugins/gnokii-sync/src/gnokii_sync.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/gnokii-sync/SConstruct
r2107 r2142 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'57 56 58 Export('env opts testenv install_prefix install_plugin install_format install_config')57 Export('env opts testenv install_prefix install_plugin install_format') 59 58 60 59 SConscript(['src/SConscript']) plugins/gnokii-sync/build/linux/osync_build.py
r2099 r2142 37 37 env.ParseConfig('pkg-config --cflags --libs gnokii') 38 38 env.Append(CCFLAGS = r'-I.') 39 # env.Append(CCFLAGS = [r'-Wall', r'-Werror', r'-O2']) 40 env.Append(CCFLAGS = [r'-Wall', r'-O2']) 39 env.Append(CCFLAGS = [r'-Wall', r'-Werror', r'-O2']) 41 40 env.Append(CCFLAGS = r'-DVERSION="\"' + config.version + r'\""') 42 41 … … 50 49 51 50 return testenv 51 plugins/gnokii-sync/src/SConscript
r2139 r2142 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'] )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'])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') 14 14 15 15 16 # install synchronization plugin and config16 # install synchronization plugin 17 17 env.Install(install_plugin, gnokii_sync) 18 env.Install(install_config, ['gnokii-sync']) 19 20 # install format plugins 18 # install format plugin 21 19 env.Install(install_format, gnokii_event) 22 20 env.Install(install_format, gnokii_contact) plugins/gnokii-sync/src/gnokii_calendar.c
r2133 r2142 202 202 if (error == GN_ERR_EMPTYLOCATION) { 203 203 osync_trace(TRACE_EXIT, "%s: no calendar note left.", __func__); 204 g_free(calnote);205 204 return NULL; 206 205 } … … 209 208 if (error != GN_ERR_NONE) { 210 209 osync_trace(TRACE_EXIT_ERROR, "%s(): error while query the phone - gnokii: %s", __func__, gn_error_print(error)); 211 g_free(calnote);212 210 return NULL; 213 211 } … … 369 367 break; 370 368 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 373 osync_change_set_uid(change, uid); 374 375 // get hash of calnote 375 376 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 389 osync_change_set_uid(change, uid);390 377 osync_change_set_hash(change, hash); 391 osync_change_set_changetype(change, type);392 378 393 379 // set 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) { 380 OSyncData *data = osync_data_new((char *) calnote, sizeof(gn_calnote), sinkenv->objformat, &error); 381 if (!data) { 397 382 osync_change_unref(change); 398 383 osync_context_report_osyncwarning(ctx, error); … … 400 385 g_free(hash); 401 386 g_free(uid); 402 g_free(calnote);403 387 continue; 404 388 } 405 389 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); 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 } 415 400 416 401 g_free(hash); … … 458 443 g_free(caldata); 459 444 460 osync_context_report_success(ctx);461 462 445 osync_trace(TRACE_EXIT, "%s", __func__); 463 446 } … … 575 558 } 576 559 560 // answer the call 577 561 osync_context_report_success(ctx); 578 562 563 // blubb 564 /* 565 osync_trace(TRACE_INTERNAL, "change->hash: %s change->changetype: %i", osync_change_get_hash(change), 566 osync_change_get_changetype(change)); 567 */ 568 569 g_free(calnote); 570 579 571 // update hashtable 580 572 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
r2133 r2142 56 56 57 57 // Type 58 xmlfield = osync_xmlfield_new(xmlformat, "Categor ies", error);58 xmlfield = osync_xmlfield_new(xmlformat, "Category", 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 libgnokii199 195 if (cal->alarm.tone) 200 osync_xmlfield_set_key_value(xmlfield, "AlarmAction", "AUDIO");201 else202 196 osync_xmlfield_set_key_value(xmlfield, "AlarmAction", "DISPLAY"); 203 204 197 205 198 … … 211 204 212 205 // Summary 213 if ( strlen(cal->text)) {206 if (cal->text) { 214 207 xmlfield = osync_xmlfield_new(xmlformat, "Summary", error); 215 208 osync_xmlfield_set_key_value(xmlfield, "Content", cal->text); … … 217 210 218 211 // Phone Number 219 if ( strlen(cal->phone_number)&& cal->type == GN_CALNOTE_CALL) {212 if (cal->phone_number && cal->type == GN_CALNOTE_CALL) { 220 213 xmlfield = osync_xmlfield_new(xmlformat, "Description", error); 221 214 osync_xmlfield_set_key_value(xmlfield, "Content", cal->phone_number); … … 223 216 224 217 // mlocation 225 if ( strlen(cal->mlocation)&& cal->type == GN_CALNOTE_MEETING) {218 if (cal->mlocation && cal->type == GN_CALNOTE_MEETING) { 226 219 xmlfield = osync_xmlfield_new(xmlformat, "Location", error); 227 220 osync_xmlfield_set_key_value(xmlfield, "Content", cal->mlocation); … … 296 289 } 297 290 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 else317 // When no known type was found it will check later318 // 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 event344 if (osync_time_isdate(dtstart))345 *alldayevent = 1;346 347 // Nokia cellphones cannot handle seconds in calendar - so set it to ZERO348 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 ZERO371 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 seconds403 start_timet = gnokii_util_timestamp2unix(&(calnote->time));404 405 // timestamp for alarm406 alarm_timet = start_timet - seconds_before;407 } else if (triggertype && ! strcasecmp("DATE-TIME", triggertype)) {408 // TODO: untested! - check UTC offeset issues409 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 timestamp416 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 weeks462 if (calnote->recurrence == GN_CALNOTE_WEEKLY && interval == 2)463 calnote->recurrence = GN_CALNOTE_2WEEKLY;464 }465 466 467 291 /* 468 292 * Converts from XMLFormat-event to the gnokii event object type (gn_calnote). … … 473 297 output, outpsize, config, free_input, error); 474 298 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; 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; 483 304 osync_bool alldayevent = 0; 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)); 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"); 487 310 goto error; 488 311 } 489 312 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 child 319 root = osxml_get_node(root, "Event"); 320 490 321 // prepare calnote 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 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 } 516 392 517 393 394 // DateEnd 395 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 ZERO 414 calnote->end_time.second = 0; 415 } 416 417 /* Alarm - TODO: is not fully supported 418 * Not supported: 419 * ^^^^^^^^^^^^^^ 420 * # alarm after event 421 * # alarm before event end 422 * # ... 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 root 439 xmlNode *sub = osxml_get_node(cur, "AlarmTrigger"); 440 441 // get node with iCal duration 442 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 seconds 450 start_timet = gnokii_util_timestamp2unix(&(calnote->time)); 451 452 // timestamp for alarm 453 alarm_timet = start_timet - seconds_before; 454 455 // convert timestamp of alarm to gnokii timestamp 456 calnote->alarm.timestamp = gnokii_util_unix2timestamp(alarm_timet); 457 } 458 459 // Summary 460 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 location 468 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 // PhoneNumber 479 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 // Reccurence 489 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 weeks 513 if (calnote->recurrence == GN_CALNOTE_WEEKLY && interval == 2) 514 calnote->recurrence = GN_CALNOTE_2WEEKLY; 515 } 518 516 519 517 // check for type which fits for given data if no type was set 520 518 if (!calnote->type) 521 519 calnote->type = gnokii_util_calendar_type(calnote, alldayevent); 520 522 521 523 522 *free_input = TRUE; … … 534 533 535 534 536 static void destroy_gnokii_event(char *input, unsigned int inpsize)535 static void destroy_gnokii_event(char *input, size_t inpsize) 537 536 { 538 537 osync_trace(TRACE_ENTRY, "%s(%p, %i)", __func__, input, inpsize); plugins/gnokii-sync/src/gnokii_calendar_utils.c
r2133 r2142 30 30 * Returns: seconds before event 31 31 */ 32 int gnokii_util_alarmevent2secs(c onst char *alarm) {32 int gnokii_util_alarmevent2secs(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);243 242 244 243 osync_trace(TRACE_EXIT, "%s: %ul", __func__, timet); plugins/gnokii-sync/src/gnokii_calendar_utils.h
r2133 r2142 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 onst char *alarm);28 int gnokii_util_alarmevent2secs(char *alarm); 29 29 char *gnokii_util_secs2alarmevent(int secs_before_event); 30 osync_bool gnokii_util_valid_number(c onst char *number);30 osync_bool gnokii_util_valid_number(char *number); 31 31 gn_calnote_type gnokii_util_calendar_type(gn_calnote *calnote, osync_bool alldayevent); 32 32 plugins/gnokii-sync/src/gnokii_config.c
r2099 r2142 21 21 #include "gnokii_sync.h" 22 22 23 /* Set connection types 24 */ 25 void parse_connection_type(char *str, gn_config *config) { 26 27 if (!strcasecmp(str, "bluetooth")) 28 config->connection_type = GN_CT_Bluetooth; 29 else if (!strcasecmp(str, "irda")) 30 config->connection_type = GN_CT_Irda; 31 else if (!strcasecmp(str, "dku2")) 32 config->connection_type = GN_CT_DKU2; 33 else if (!strcasecmp(str, "dau9p")) 34 config->connection_type = GN_CT_DAU9P; 35 else if (!strcasecmp(str, "dlr3p")) 36 config->connection_type = GN_CT_DLR3P; 37 else if (!strcasecmp(str, "serial")) 38 config->connection_type = GN_CT_Serial; 39 else if (!strcasecmp(str, "infrared")) 40 config->connection_type = GN_CT_Infrared; 41 else if (!strcasecmp(str, "tekram")) 42 config->connection_type = GN_CT_Tekram; 43 else if (!strcasecmp(str, "tcp")) 44 config->connection_type = GN_CT_TCP; 45 else if (!strcasecmp(str, "m2bus")) 46 config->connection_type = GN_CT_M2BUS; 47 else if (!strcasecmp(str, "dku2libusb")) 48 config->connection_type = GN_CT_DKU2LIBUSB; 49 else 50 config->connection_type = GN_CT_NONE; 51 } 52 23 53 /* Parse config file of gnokii plugin 24 54 * … … 27 57 * ReturnVal: false on error 28 58 */ 29 osync_bool gnokii_config_parse( struct gn_statemachine *state, const char *data, OSyncError **error)59 osync_bool gnokii_config_parse(gn_config *config, const char *data, OSyncError **error) 30 60 { 31 osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, state, data, error); 32 int i = 0; 61 osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, config, data, error); 33 62 char *str = NULL; 34 char **lines = malloc(sizeof(char*) * 10);35 memset(lines, 0, sizeof(char*) * 10);36 63 xmlDocPtr doc; 37 64 xmlNodePtr cur; … … 63 90 cur = cur->xmlChildrenNode; 64 91 65 lines[i] = g_strdup("[global]");66 67 92 while (cur != NULL) { 68 93 str = (char *) xmlNodeGetContent(cur); … … 70 95 if (str) { 71 96 if (!xmlStrcmp(cur->name, (const xmlChar *) "model")) 72 lines[++i] = g_strdup_printf("model = %s", str);97 strncpy(config->model, str, strlen(str)); 73 98 74 99 if (!xmlStrcmp(cur->name, (const xmlChar *) "port")) 75 lines[++i] = g_strdup_printf("port = %s", str);100 strncpy(config->port_device, str, strlen(str)); 76 101 77 if (!xmlStrcmp(cur->name, (const xmlChar *) "connection")) 78 lines[++i] = g_strdup_printf("connection = %s", str); 102 if (!xmlStrcmp(cur->name, (const xmlChar *) "connection")) { 103 // check for connection types which are supported by gnokii. 104 parse_connection_type(str, config); 105 } 79 106 80 107 // rfcomm channel 81 if (!xmlStrcmp(cur->name, (const xmlChar *) "rfcomm_channel")) 82 lines[++i] = g_strdup_printf("rfcomm_channel = %s", str); 108 if (!xmlStrcmp(cur->name, (const xmlChar *) "rfcomm_channel")) { 109 config->rfcomm_cn = atoi(str); 110 } 83 111 84 112 // check for debug option of libgnokii 85 113 if (!xmlStrcmp(cur->name, (const xmlChar *) "debug")) { 86 lines[++i] = g_strdup("[logging]");87 lines[++i] = g_strdup_printf("debug = %s", str);114 if (!strcasecmp(str, "on")) 115 gn_log_debug_mask = GN_LOG_T_STDERR; // debug output to stderr 88 116 } 89 117 g_free(str); … … 93 121 } 94 122 95 /* TODO: adapt error handling to return value of gn_cfg_phone_load()96 123 if (!strlen(config->model)) { 97 124 osync_error_set(error, OSYNC_ERROR_GENERIC, "Model is not set in configuration"); … … 111 138 return FALSE; 112 139 } 113 */114 140 115 gn_cfg_memory_read(lines);116 gn_cfg_phone_load(NULL, state);117 118 for (i=0; lines[i] != NULL; i++)119 g_free(lines[i]);120 121 g_free(lines);122 141 123 142 xmlFreeDoc(doc); … … 126 145 } 127 146 147 /* Fill the statemachine struct for libgnokii with: 148 * model, port (serial connection) or MAC address (bluetooth) and connection type. 149 * This is required for the cellphone connection. 150 * 151 */ 152 void gnokii_config_state(struct gn_statemachine *state, gn_config *config) { 153 154 /* model */ 155 strncpy(state->config.model, config->model, GN_MODEL_MAX_LENGTH); 156 157 /* port (bluetooth: destination mac address) */ 158 strncpy(state->config.port_device, config->port_device, GN_DEVICE_NAME_MAX_LENGTH); 159 160 /* connection type - gn_connection_type */ 161 state->config.connection_type = config->connection_type; 162 163 /* rfcomm channel */ 164 state->config.rfcomm_cn = config->rfcomm_cn; 165 166 } 167 plugins/gnokii-sync/src/gnokii_config.h
r2099 r2142 21 21 #include <gnokii.h> 22 22 23 osync_bool gnokii_config_parse(struct gn_statemachine *state, const char *data, OSyncError **error); 23 void gnokii_config_state(struct gn_statemachine *state, gn_config *config); 24 osync_bool gnokii_config_parse(gn_config *config, const char *data, OSyncError **error); 24 25 plugins/gnokii-sync/src/gnokii_contact.c
r2134 r2142 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);161 160 return contact; 162 161 } … … 167 166 } 168 167 169 g_free(data); 170 g_free(contact); 168 // TODO set error and leave 171 169 osync_trace(TRACE_EXIT, "%s(): NO FREE LOCATION!", __func__); 172 170 return NULL; … … 361 359 gn_phonebook_entry *contact = NULL; 362 360 gn_memory_status memstat; 363 gn_data *data = osync_try_malloc0(sizeof(gn_data), &error); 361 gn_data *data = (gn_data *) malloc(sizeof(gn_data)); 362 363 memset(data, 0, sizeof(gn_data)); 364 364 365 365 OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info); … … 367 367 gnokii_sinkenv *sinkenv = osync_objtype_sink_get_userdata(sink); 368 368 gnokii_environment *env = (gnokii_environment *) plugindata;&n
