Changeset 2097
- Timestamp:
- 06/07/07 13:31:22 (1 year ago)
- Files:
-
- plugins/gnokii-sync/Makefile.am (deleted)
- plugins/gnokii-sync/SConstruct (added)
- plugins/gnokii-sync/build (added)
- plugins/gnokii-sync/build/linux (added)
- plugins/gnokii-sync/build/linux/osync_build.py (added)
- plugins/gnokii-sync/build/osync_support.py (added)
- plugins/gnokii-sync/configure.in (deleted)
- plugins/gnokii-sync/src/Makefile.am (deleted)
- plugins/gnokii-sync/src/SConscript (added)
- plugins/gnokii-sync/src/gnokii_calendar.c (modified) (10 diffs)
- plugins/gnokii-sync/src/gnokii_calendar.h (modified) (1 diff)
- plugins/gnokii-sync/src/gnokii_calendar_format.c (modified) (11 diffs)
- plugins/gnokii-sync/src/gnokii_config.c (modified) (1 diff)
- plugins/gnokii-sync/src/gnokii_config.h (modified) (1 diff)
- plugins/gnokii-sync/src/gnokii_contact.c (modified) (11 diffs)
- plugins/gnokii-sync/src/gnokii_contact.h (modified) (1 diff)
- plugins/gnokii-sync/src/gnokii_contact_format.c (modified) (8 diffs)
- plugins/gnokii-sync/src/gnokii_format.c (deleted)
- plugins/gnokii-sync/src/gnokii_sync.c (modified) (7 diffs)
- plugins/gnokii-sync/src/gnokii_sync.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/gnokii-sync/src/gnokii_calendar.c
r1801 r2097 325 325 /* The function get all event entries with gnokii_calendar_get_calnote() and checks for 326 326 * changes by comparing old hash with new hash.... 327 *328 * Return: bool329 * ReturnVal: TRUE on success330 * ReturnVal: FALSE on error331 327 */ 332 osync_bool gnokii_calendar_get_changeinfo(OSyncContext *ctx) 328 329 void gnokii_calendar_get_changes(void *plugindata, OSyncPluginInfo *info, OSyncContext *ctx) 333 330 { 334 osync_trace(TRACE_ENTRY, "%s(%p )", __func__, ctx);331 osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, plugindata, info, ctx); 335 332 336 333 int i = 0; … … 340 337 gn_calnote *calnote = NULL; 341 338 339 340 OSyncError *error = NULL; 341 342 343 OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info); 344 342 345 gn_data *caldata = (gn_data *) malloc(sizeof(gn_data)); 343 346 … … 347 350 caldata->calnote_list = &calendar_list; 348 351 349 gnokii_environment *env = (gnokii_environment *)osync_context_get_plugin_data(ctx); 352 gnokii_sinkenv *sinkenv = osync_objtype_sink_get_userdata(sink); 353 gnokii_environment *env = (gnokii_environment *) plugindata; 350 354 351 355 // check for slowsync and prepare the "event" hashtable if needed 352 if (osync_ member_get_slow_sync(env->member, "event") == TRUE) {356 if (osync_objtype_sink_get_slowsync(sink)) { 353 357 osync_trace(TRACE_INTERNAL, "slow sync"); 354 osync_hashtable_ set_slow_sync(env->hashtable, "event");358 osync_hashtable_reset(sinkenv->hashtable); 355 359 } 356 360 … … 363 367 break; 364 368 365 OSyncChange *change = osync_change_new(); 366 osync_change_set_member(change, env->member); 369 OSyncChange *change = osync_change_new(&error); 367 370 368 371 // prepare UID with gnokii-calendar-<memory location> 369 372 uid = g_strdup_printf ("gnokii-calendar-%i", calnote->location); 370 373 osync_change_set_uid(change, uid); 371 g_free(uid);372 374 373 375 // get hash of calnote 374 376 hash = gnokii_calendar_hash(calnote); 375 377 osync_change_set_hash(change, hash); 376 g_free(hash); 377 378 osync_change_set_objformat_string(change, "gnokii-event"); 379 osync_change_set_objtype_string(change, "event"); 380 381 osync_change_set_data(change, (void *)calnote, sizeof(gn_calnote), TRUE); 382 383 if (osync_hashtable_detect_change(env->hashtable, change)) { 378 379 // set data 380 OSyncData *data = osync_data_new((char *) calnote, sizeof(gn_calnote), sinkenv->objformat, &error); 381 if (!data) { 382 osync_change_unref(change); 383 osync_context_report_osyncwarning(ctx, error); 384 osync_error_unref(&error); 385 g_free(hash); 386 g_free(uid); 387 continue; 388 } 389 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) { 384 396 osync_trace(TRACE_INTERNAL, "Position: %i Needs to be reported (!= hash)", calnote->location); 385 397 osync_context_report_change(ctx, change); 386 osync_hashtable_update_hash( env->hashtable, change);398 osync_hashtable_update_hash(sinkenv->hashtable, type, uid, hash); 387 399 } 388 400 401 g_free(hash); 402 g_free(uid); 389 403 } 390 404 391 405 osync_trace(TRACE_INTERNAL, "number of calendar notes: %i", i - 1); 392 406 393 osync_hashtable_report_deleted(env->hashtable, ctx, "event"); 407 char **uids = osync_hashtable_get_deleted(sinkenv->hashtable); 408 for (i = 0; uids[i]; i++) { 409 OSyncChange *change = osync_change_new(&error); 410 if (!change) { 411 g_free(uids[i]); 412 osync_context_report_osyncwarning(ctx, error); 413 osync_error_unref(&error); 414 continue; 415 } 416 417 osync_change_set_uid(change, uids[i]); 418 osync_change_set_changetype(change, OSYNC_CHANGE_TYPE_DELETED); 419 420 OSyncData *odata = osync_data_new(NULL, 0, sinkenv->objformat, &error); 421 if (!odata) { 422 g_free(uids[i]); 423 osync_change_unref(change); 424 osync_context_report_osyncwarning(ctx, error); 425 osync_error_unref(&error); 426 continue; 427 } 428 429 osync_data_set_objtype(odata, osync_objtype_sink_get_name(sink)); 430 osync_change_set_data(change, odata); 431 osync_data_unref(odata); 432 433 osync_context_report_change(ctx, change); 434 435 osync_hashtable_update_hash(sinkenv->hashtable, osync_change_get_changetype(change), osync_change_get_uid(change), NULL); 436 437 osync_change_unref(change); 438 g_free(uids[i]); 439 } 440 g_free(uids); 441 394 442 395 443 g_free(caldata); 396 444 397 445 osync_trace(TRACE_EXIT, "%s", __func__); 398 return TRUE; 399 } 400 401 /* The function commit changes of calendar entries to the cellphone. 402 * 403 * Return: bool 404 * ReturnVal: TRUE on success 405 * ReturnVal: FALSE on error 406 */ 407 osync_bool gnokii_calendar_commit(OSyncContext *ctx, OSyncChange *change) { 408 409 osync_trace(TRACE_ENTRY, "%s() (%p, %p)", __func__, ctx, change); 446 } 447 448 /* The function commit changes of calendar entries to the cellphone. */ 449 void gnokii_calendar_commit_change(void *plugindata, OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *change) { 450 451 osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, plugindata, info, change, ctx); 410 452 411 453 OSyncError *error = NULL; … … 413 455 char *uid = NULL; 414 456 char *hash = NULL; 415 416 gnokii_environment *env = (gnokii_environment *)osync_context_get_plugin_data(ctx); 457 char *buf = NULL; 458 459 OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info); 460 gnokii_sinkenv *sinkenv = osync_objtype_sink_get_userdata(sink); 461 gnokii_environment *env = (gnokii_environment *) plugindata; 417 462 418 463 // Get changed calendar note 419 calnote = (gn_calnote *) osync_change_get_data(change); 464 OSyncData *data = osync_change_get_data(change); 465 osync_data_get_data(data, &buf, NULL); 466 calnote = (gn_calnote *) buf; 420 467 421 468 // Check for type of changes 422 469 switch (osync_change_get_changetype(change)) { 423 case CHANGE_DELETED:470 case OSYNC_CHANGE_TYPE_DELETED: 424 471 // Delete the change 425 472 … … 431 478 432 479 break; 433 case CHANGE_ADDED:480 case OSYNC_CHANGE_TYPE_ADDED: 434 481 435 482 // Add the change … … 450 497 451 498 break; 452 case CHANGE_MODIFIED:499 case OSYNC_CHANGE_TYPE_MODIFIED: 453 500 // Modify the change 454 501 … … 465 512 466 513 /////////// WORKAROUND for "dirty" modify /////////// 514 /* 467 515 468 516 // fake a delete change to remove the old hash 469 OSyncChange *delete_change = osync_change_new(); 470 osync_change_set_member(change, env->member); 517 OSyncChange *delete_change = osync_change_new(&error); 471 518 472 519 // the old uid will be set for this "fake" change 473 520 osync_change_set_uid(delete_change, osync_change_get_uid(change)); 474 osync_change_set_changetype(delete_change, CHANGE_DELETED); 475 osync_hashtable_update_hash(env->hashtable, delete_change); 521 osync_change_set_changetype(delete_change, OSYNC_CHANGE_TYPE_DELETED); 522 osync_hashtable_update_hash(sinkenv->hashtable, OSYNC_CHANGE_TYPE_DELETED, osync_change_get_uid(change), delete_change); 523 */ 524 525 osync_hashtable_delete(sinkenv->hashtable, osync_change_get_uid(change)); 476 526 477 527 // update the old UID with the followed UID for the hashtable … … 479 529 uid = gnokii_calendar_memory_uid(calnote->location); 480 530 osync_change_set_uid(change, uid); 481 g_free(uid); 531 482 532 483 533 // set modified changetype for calendar entry 484 osync_change_set_changetype(change, CHANGE_MODIFIED);534 osync_change_set_changetype(change, OSYNC_CHANGE_TYPE_MODIFIED); 485 535 486 536 // set hash for the modified calendar entry 487 537 hash = gnokii_calendar_hash(calnote); 488 538 osync_change_set_hash(change, hash); 539 540 osync_hashtable_write(sinkenv->hashtable, uid, hash); 541 489 542 g_free(hash); 543 g_free(uid); 490 544 491 545 /* … … 513 567 */ 514 568 569 g_free(calnote); 515 570 516 571 // update hashtable 517 osync_hashtable_update_hash( env->hashtable, change);572 osync_hashtable_update_hash(sinkenv->hashtable, osync_change_get_changetype(change), osync_change_get_uid(change), osync_change_get_hash(change)); 518 573 519 574 osync_trace(TRACE_EXIT, "%s", __func__); 520 521 return TRUE; 575 return; 522 576 523 577 error: 524 osync_context_report_osyncerror(ctx, &error);578 osync_context_report_osyncerror(ctx, error); 525 579 osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); 526 osync_error_free(&error); 527 return FALSE; 528 } 529 580 osync_error_unref(&error); 581 } 582 plugins/gnokii-sync/src/gnokii_calendar.h
r824 r2097 21 21 #include "gnokii.h" 22 22 23 osync_bool gnokii_calendar_get_changeinfo(OSyncContext *ctx);24 osync_bool gnokii_calendar_commit(OSyncContext *ctx, OSyncChange *change);23 void gnokii_calendar_get_changes(void *plugindata, OSyncPluginInfo *info, OSyncContext *ctx); 24 void gnokii_calendar_commit_change(void *plugindata, OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *change); 25 25 plugins/gnokii-sync/src/gnokii_calendar_format.c
r1446 r2097 19 19 ***************************************************************************/ 20 20 21 #include "gnokii_sync.h" 21 #include <glib.h> 22 #include <opensync/opensync.h> 23 #include <opensync/opensync_xml.h> 24 #include <opensync/opensync-data.h> 25 #include <opensync/opensync-format.h> 26 #include <opensync/opensync-merger.h> 27 #include <opensync/opensync-time.h> 28 22 29 #include "gnokii_calendar_utils.h" 23 #include "gnokii_calendar_format.h"24 #include <opensync/opensync_xml.h>25 30 26 31 /* 27 32 * Converts the gnokii event object type (gn_calnote) into XML. 28 33 */ 29 static osync_bool conv_gnokii_event_to_xml (void *conv_data, char *input, int inpsize, char **output, int *outpsize, osync_bool *free_input, OSyncError **error)34 static osync_bool conv_gnokii_event_to_xmlformat(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, OSyncError **error) 30 35 { 31 osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %p, %p, %p, %p)", __func__, conv_data, input, inpsize, output, outpsize, free_input, error); 32 33 xmlNode *current = NULL; 36 osync_trace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p, %s, %p)", __func__, input, inpsize, output, outpsize, free_input, config, error); 37 38 OSyncXMLField *xmlfield = NULL; 39 34 40 time_t timet; 35 41 time_t start_timet = 0; … … 46 52 } 47 53 48 xmlDoc *doc = xmlNewDoc((xmlChar*) "1.0"); 49 xmlNode *root = osxml_node_add_root(doc, "vcal"); 50 root = xmlNewTextChild(root, NULL, (xmlChar*) "Event", NULL); 54 OSyncXMLFormat *xmlformat = osync_xmlformat_new("event", error); 55 51 56 52 57 // Type 53 current = xmlNewTextChild(root, NULL, (xmlChar *) "Categories", NULL);58 xmlfield = osync_xmlfield_new(xmlformat, "Category", error); 54 59 switch (cal->type) { 55 60 case GN_CALNOTE_MEETING: 56 osxml_node_add(current, "Category", "Meeting");61 osync_xmlfield_set_key_value(xmlfield, "Category", "Meeting"); 57 62 break; 58 63 case GN_CALNOTE_CALL: 59 osxml_node_add(current, "Category", "Calling");64 osync_xmlfield_set_key_value(xmlfield, "Category", "Calling"); 60 65 break; 61 66 case GN_CALNOTE_BIRTHDAY: 62 os xml_node_add(current, "Category", "Birthday");67 osync_xmlfield_set_key_value(xmlfield, "Category", "Birthday"); 63 68 break; 64 69 case GN_CALNOTE_REMINDER: 65 os xml_node_add(current, "Category", "Reminder");70 osync_xmlfield_set_key_value(xmlfield, "Category", "Reminder"); 66 71 break; 67 72 case GN_CALNOTE_MEMO: 68 os xml_node_add(current, "Category", "Memo");73 osync_xmlfield_set_key_value(xmlfield, "Category", "Memo"); 69 74 break; 70 75 } … … 104 109 105 110 osync_trace(TRACE_SENSITIVE, "start time: %s (ical - UTC)\n", vtime); 106 current = xmlNewTextChild(root, NULL, (xmlChar *) "DateStarted", NULL); 107 xmlNewTextChild(current, NULL, (xmlChar*) "Content", (xmlChar*) vtime); 108 111 xmlfield = osync_xmlfield_new(xmlformat, "DateStarted", error); 112 osync_xmlfield_set_key_value(xmlfield, "Content", vtime); 109 113 g_free(vtime); 110 114 … … 141 145 } 142 146 143 current = xmlNewTextChild(root, NULL, (xmlChar *) "DateEnd", NULL);144 xmlNewTextChild(current, NULL, (xmlChar*) "Content", (xmlChar*)vtime);147 xmlfield = osync_xmlfield_new(xmlformat, "DateEnd", error); 148 osync_xmlfield_set_key_value(xmlfield, "Content", vtime); 145 149 146 150 g_free(tmp); … … 187 191 tmp = gnokii_util_secs2alarmevent(secs_before_event); 188 192 189 current = xmlNewTextChild(root, NULL, (xmlChar *) "Alarm", NULL);193 xmlfield = osync_xmlfield_new(xmlformat, "Alarm", error); 190 194 191 195 if (cal->alarm.tone) 192 xmlNewTextChild(current, NULL, (xmlChar*) "AlarmAction", (xmlChar*)"DISPLAY");193 194 xmlNode *sub = xmlNewTextChild(current, NULL, (xmlChar*) "AlarmTrigger", NULL); 195 xmlNewTextChild(sub, NULL, (xmlChar*) "Content", (xmlChar*) tmp);196 xmlNewTextChild(sub, NULL, (xmlChar*) "Value", (xmlChar*)"DURATION");196 osync_xmlfield_set_key_value(xmlfield, "AlarmAction", "DISPLAY"); 197 198 199 osync_xmlfield_set_key_value(xmlfield, "AlarmTrigger", tmp); 200 osync_xmlfield_set_attr(xmlfield, "Value", "DURATION"); 197 201 198 202 g_free(tmp); … … 201 205 // Summary 202 206 if (cal->text) { 203 current = xmlNewTextChild(root, NULL, (xmlChar*) "Summary", NULL);204 xmlNewTextChild(current, NULL, (xmlChar*) "Content", (xmlChar *)cal->text);207 xmlfield = osync_xmlfield_new(xmlformat, "Summary", error); 208 osync_xmlfield_set_key_value(xmlfield, "Content", cal->text); 205 209 } 206 210 207 211 // Phone Number 208 212 if (cal->phone_number && cal->type == GN_CALNOTE_CALL) { 209 current = xmlNewTextChild(root, NULL, (xmlChar*) "Description", NULL);210 xmlNewTextChild(current, NULL, (xmlChar*) "Content", (xmlChar *)cal->phone_number);213 xmlfield = osync_xmlfield_new(xmlformat, "Description", error); 214 osync_xmlfield_set_key_value(xmlfield, "Content", cal->phone_number); 211 215 } 212 216 213 217 // mlocation 214 218 if (cal->mlocation && cal->type == GN_CALNOTE_MEETING) { 215 current = xmlNewTextChild(root, NULL, (xmlChar*) "Location", NULL);216 xmlNewTextChild(current, NULL, (xmlChar*) "Content", (xmlChar*)cal->mlocation);219 xmlfield = osync_xmlfield_new(xmlformat, "Location", error); 220 osync_xmlfield_set_key_value(xmlfield, "Content", cal->mlocation); 217 221 } 218 222 … … 220 224 if (cal->recurrence) { 221 225 226 xmlfield = osync_xmlfield_new(xmlformat, "RecurrenceRule", error); 227 222 228 switch (cal->recurrence) { 223 229 case GN_CALNOTE_DAILY: 224 tmp = g_strdup("FREQ=DAILY");230 osync_xmlfield_set_key_value(xmlfield, "Frequency", "DAILY"); 225 231 break; 226 232 case GN_CALNOTE_WEEKLY: 227 233 case GN_CALNOTE_2WEEKLY: 228 tmp = g_strdup("FREQ=WEEKLY");234 osync_xmlfield_set_key_value(xmlfield, "Frequency", "WEEKLY"); 229 235 break; 230 236 case GN_CALNOTE_MONTHLY: 231 tmp = g_strdup("FREQ=MONTHLY");237 osync_xmlfield_set_key_value(xmlfield, "Frequency", "MONTHLY"); 232 238 break; 233 239 case GN_CALNOTE_YEARLY: 234 tmp = g_strdup("FREQ=YEARLY");240 osync_xmlfield_set_key_value(xmlfield, "Frequency", "YEARLY"); 235 241 break; 236 default: 237 tmp = g_strdup(""); 242 case GN_CALNOTE_NEVER: 238 243 break; 239 244 } 240 245 241 current = xmlNewTextChild(root, NULL, (xmlChar*) "RecurrenceRule", NULL);242 xmlNewTextChild(current, NULL, (xmlChar*) "Rule", (xmlChar*) tmp);243 g_free(tmp);244 245 246 // prepare "by day/day of month/..." string 246 247 // TODO: BYMONTHDAY … … 249 250 break; 250 251 case GN_CALNOTE_2WEEKLY: 251 tmp = g_strdup("INTERVAL=4");252 xmlNewTextChild(current, NULL, (xmlChar*) "Rule", (xmlChar*) tmp);252 // tmp = g_strdup("INTERVAL=4"); - was 4 wrong?!?!? - Bug?! 253 osync_xmlfield_set_key_value(xmlfield, "Interval", "2"); 253 254 case GN_CALNOTE_WEEKLY: 255 // XXX: Always BYDAY? 254 256 wday = gnokii_util_unix2wday(&start_timet); 255 tmp = g_strdup_printf("BYDAY=%s", wday); 256 xmlNewTextChild(current, NULL, (xmlChar*) "Rule", (xmlChar*) tmp); 257 osync_xmlfield_set_key_value(xmlfield, "ByDay", wday); 257 258 g_free(wday); 258 259 break; 259 260 case GN_CALNOTE_MONTHLY: 261 case GN_CALNOTE_YEARLY: 262 case GN_CALNOTE_NEVER: 260 263 break; 261 case GN_CALNOTE_YEARLY: 262 break; 263 default: 264 break; 265 } 266 267 // g_free(tmp); 264 } 265 268 266 } 269 267 270 268 *free_input = TRUE; 271 *output = (char *)doc; 272 *outpsize = sizeof(doc); 273 274 osync_trace(TRACE_SENSITIVE, "Output XML is:\n%s", osxml_write_to_string((xmlDoc *)doc)); 275 269 *output = (char *)xmlformat; 270 *outpsize = sizeof(xmlformat); 271 272 // XXX: remove this later? 273 osync_xmlformat_sort(xmlformat); 274 275 unsigned int size; 276 char *str; 277 osync_xmlformat_assemble(xmlformat, &str, &size); 278 osync_trace(TRACE_INTERNAL, "Output XMLFormat is:\n%s", str); 279 g_free(str); 280 281 if (osync_xmlformat_validate(xmlformat) == FALSE) 282 osync_trace(TRACE_INTERNAL, "XMLFORMAT EVENT: Not valid!"); 283 else 284 osync_trace(TRACE_INTERNAL, "XMLFORMAT EVENT: VAILD"); 285 286 276 287 osync_trace(TRACE_EXIT, "%s", __func__); 277 288 return TRUE; … … 279 290 280 291 /* 281 * Converts from XML to the gnokii event object type (gn_calnote).292 * Converts from XMLFormat-event to the gnokii event object type (gn_calnote). 282 293 */ 283 static osync_bool conv_xml _event_to_gnokii(void *conv_data, char *input, int inpsize, char **output, int *outpsize, osync_bool *free_input, OSyncError **error)294 static osync_bool conv_xmlformat_to_gnokii_event(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, OSyncError **error) 284 295 { 285 osync_trace(TRACE_ENTRY, "%s(%p, % p, %i, %p, %p, %p, %p)", __func__, conv_data, input, inpsize,286 output, outpsize, free_input, error);296 osync_trace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %s, %p, %p)", __func__, input, inpsize, 297 output, outpsize, config, free_input, error); 287 298 288 299 osync_trace(TRACE_SENSITIVE, "Input XML is:\n%s", osxml_write_to_string((xmlDoc *)input)); … … 540 551 * Print the gnokii format in a human readable form. 541 552 */ 553 #if 0 542 554 static char *print_gnokii_event(OSyncChange *change) 543 555 { 544 556 osync_trace(TRACE_ENTRY, "%s(%p)", __func__, change); 545 557 546 char *tmp = NULL, *type = NULL;558 unsigned int size; 547 559 GString *output = g_string_new(""); 548 gn_calnote *calnote = (gn_calnote *) osync_change_get_data(change); 560 char *buf = NULL; 561 562 OSyncData *data = osync_change_get_data(change); 563 osync_data_get_data(data, &buf, &size); 564 565 gn_calnote *calnote = (gn_calnote *) buf; 549 566 550 567 // Event Type 551 type = gnokii_util_caltype2string(calnote->type);552 tmp = g_strdup_printf("Type: %s\n", type);568 char *type = gnokii_util_caltype2string(calnote->type); 569 char *tmp = g_strdup_printf("Type: %s\n", type); 553 570 output = g_string_append(output, tmp); 554 571 g_free(type); … … 630 647 return g_string_free(output, FALSE); 631 648 } 632 633 634 635 void gnokii_calendar_format_get_info(OSyncEnv *env) 649 #endif 650 651 void get_format_info(OSyncFormatEnv *env, OSyncError **error) 636 652 { 637 osync_env_register_objtype(env, "event"); 638 639 //Tell OpenSync that we want to register a new format 640 osync_env_register_objformat(env, "event", "gnokii-event"); 641 //Now we can set the function on your format we have created above 642 // osync_env_format_set_compare_func(env, "gnokii-event", compare_format1); 643 // osync_env_format_set_duplicate_func(env, "gnokii-event", duplicate_format1); 644 osync_env_format_set_destroy_func(env, "gnokii-event", destroy_gnokii_event); 645 osync_env_format_set_print_func(env, "gnokii-event", print_gnokii_event); 646 647 osync_env_register_converter(env, CONVERTER_CONV, "gnokii-event", "xml-event", conv_gnokii_event_to_xml); 648 osync_env_register_converter(env, CONVERTER_CONV, "xml-event", "gnokii-event", conv_xml_event_to_gnokii); 653 654 /* register gnokii-event format */ 655 OSyncObjFormat *format = osync_objformat_new("gnokii-event", "event", error); 656 if (!format) { 657 osync_trace(TRACE_ERROR, "Unable to register gnokii-event format: %s", osync_error_print(error)); 658 osync_error_unref(error); 659 return; 660 } 661 662 // osync_objformat_set_compare_func(format, compare_event); 663 osync_objformat_set_destroy_func(format, destroy_gnokii_event); 664 // osync_objformat_set_duplicate_func(format, duplicate_xmlformat); 665 // osync_objformat_set_print_func(format, print_gnokii_event); 666 // osync_objformat_set_copy_func(format, copy_xmlformat); 667 // osync_objformat_set_create_func(format, create_event); 668 669 // osync_objformat_set_revision_func(format, get_revision); 670 671 672 // osync_objformat_must_marshal(format); 673 // osync_objformat_set_marshal_func(format, marshal_xmlformat); 674 // osync_objformat_set_demarshal_func(format, demarshal_xmlformat); 675 676 677 osync_format_env_register_objformat(env, format); 678 osync_objformat_unref(format); 649 679 650 680 } 651 681 682 void get_conversion_info(OSyncFormatEnv *env) 683 { 684 OSyncFormatConverter *conv; 685 OSyncError *error = NULL; 686 687 OSyncObjFormat *xmlformat = osync_format_env_find_objformat(env, "xmlformat-event"); 688 OSyncObjFormat *gnokii_event = osync_format_env_find_objformat(env, "gnokii-event"); 689 690 conv = osync_converter_new(OSYNC_CONVERTER_CONV, xmlformat, gnokii_event, conv_xmlformat_to_gnokii_event, &error); 691 if (!conv) { 692 osync_trace(TRACE_ERROR, "Unable to register format converter: %s", osync_error_print(&error)); 693 osync_error_unref(&error); 694 return; 695 } 696 osync_format_env_register_converter(env, conv); 697 osync_converter_unref(conv); 698 699 conv = osync_converter_new(OSYNC_CONVERTER_CONV, gnokii_event, xmlformat, conv_gnokii_event_to_xmlformat, &error); 700 if (!conv) { 701 osync_trace(TRACE_ERROR, "Unable to register format converter: %s", osync_error_print(&error)); 702 osync_error_unref(&error); 703 return; 704 } 705 osync_format_env_register_converter(env, conv); 706 osync_converter_unref(conv); 707 } 708 709 int get_version(void) 710 { 711 return 1; 712 } 713 plugins/gnokii-sync/src/gnokii_config.c
r1464 r2097 57 57 * ReturnVal: false on error 58 58 */ 59 osync_bool gnokii_config_parse(gn_config *config, c har *data, int size, OSyncError **error)59 osync_bool gnokii_config_parse(gn_config *config, const char *data, OSyncError **error) 60 60 { 61 osync_trace(TRACE_ENTRY, "%s(%p, %p, % i, %p)", __func__, config, data, size, error);61 osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, config, data, error); 62 62 char *str = NULL; 63 63 xmlDocPtr doc; 64 64 xmlNodePtr cur; 65 65 66 doc = xmlParseMemory(data, s ize);66 doc = xmlParseMemory(data, strlen(data) + 1); 67 67 68 68 if (!doc) { plugins/gnokii-sync/src/gnokii_config.h
r824 r2097 22 22 23 23 void gnokii_config_state(struct gn_statemachine *state, gn_config *config); 24 osync_bool gnokii_config_parse(gn_config *config, c har *data, int size, OSyncError **error);24 osync_bool gnokii_config_parse(gn_config *config, const char *data, OSyncError **error); 25 25 plugins/gnokii-sync/src/gnokii_contact.c
r1801 r2097 346 346 /* The function get all contact entries with gnokii_contact_get_entry() and checks for 347 347 * changes by comparing old hash with new hash.... 348 *349 * Return: bool350 * ReturnVal: TRUE on success351 * ReturnVal: FALSE on error352 348 */ 353 osync_bool gnokii_contact_get_changeinfo(OSyncContext *ctx) 349 350 void gnokii_contact_get_changes(void *plugindata, OSyncPluginInfo *info, OSyncContext *ctx) 354 351 { 355 osync_trace(TRACE_ENTRY, "%s(%p )", __func__, ctx);352 osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, plugindata, info, ctx); 356 353 357 354 int location = 0, memtype, num_entries; 358 355 char *hash = NULL; 359 356 char *uid = NULL; 357 OSyncError *error = NULL; 360 358 gn_error gnokii_error = GN_ERR_NONE; // gnokii error messages 361 359 gn_phonebook_entry *contact = NULL; … … 365 363 memset(data, 0, sizeof(gn_data)); 366 364 367 gnokii_environment *env = (gnokii_environment *)osync_context_get_plugin_data(ctx); 365 OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info); 366 367 gnokii_sinkenv *sinkenv = osync_objtype_sink_get_userdata(sink); 368 gnokii_environment *env = (gnokii_environment *) plugindata; 369 368 370 369 371 // check for slowsync and prepare the "contact" hashtable if needed 370 if (osync_ member_get_slow_sync(env->member, "contact") == TRUE) {372 if (osync_objtype_sink_get_slowsync(sink)) { 371 373 osync_trace(TRACE_INTERNAL, "slow sync"); 372 osync_hashtable_ set_slow_sync(env->hashtable, "contact");374 osync_hashtable_reset(sinkenv->hashtable); 373 375 } 374 376 … … 382 384 memstat.memory_type = memtype; 383 385 memstat.used = 0; 386 osync_trace(TRACE_INTERNAL, "env->state: %p", env->state); 384 387 gnokii_error = gn_sm_functions(GN_OP_GetMemoryStatus, data, env->state); 385 388 if (gnokii_error != GN_ERR_NONE) { … … 417 420 continue; 418 421 419 OSyncChange *change = osync_change_new(); 420 osync_change_set_member(change, env->member); 422 OSyncChange *change = osync_change_new(&error); 421 423 422 424 // prepare UID with gnokii-contact-<memory type>-<memory location> … … 430 432 g_free(hash); 431 433 432 osync_change_set_objformat_string(change, "gnokii-contact"); 433 osync_change_set_objtype_string(change, "contact"); 434 435 osync_change_set_data(change, (void *)contact, sizeof(gn_phonebook_entry), TRUE); 434 435 // set data 436 OSyncData *data = osync_data_new((char *) contact, sizeof(gn_calnote), sinkenv->objformat, &error); 437 if (!data) { 438 osync_change_unref(change); 439 osync_context_report_osyncwarning(ctx, error); 440 osync_error_unref(&error); 441 g_free(hash); 442 g_free(uid); 443 continue; 444 } 445 446 osync_data_set_objtype(data, osync_objtype_sink_get_name(sink)); 447 osync_change_set_data(change, data); 448 osync_data_unref(data); 436 449 437 if (osync_hashtable_detect_change(env->hashtable, change)) { 438 osync_trace(TRACE_INTERNAL, "Position: %i Needs to be reported (!= hash)", contact->location); 450 OSyncChangeType type = osync_hashtable_get_changetype(sinkenv->hashtable, uid, hash); 451 if (type != OSYNC_CHANGE_TYPE_UNMODIFIED) { 452 osync_trace(TRACE_INTERNAL, "Position: %i Needs to be reported (!= hash)", location - 1); 439 453 osync_context_report_change(ctx, change); 440 osync_hashtable_update_hash( env->hashtable, change);454 osync_hashtable_update_hash(sinkenv->hashtable, type, uid, hash); 441 455 } 456 457 g_free(hash); 458 g_free(uid); 459 442 460 } 443 461 } … … 445 463 osync_trace(TRACE_INTERNAL, "number of contact notes: %i", location - 1); 446 464 447 osync_hashtable_report_deleted(env->hashtable, ctx, "contact"); 465 int i; 466 char **uids = osync_hashtable_get_deleted(sinkenv->hashtable); 467 for (i = 0; uids[i]; i++) { 468 OSyncChange *change = osync_change_new(&error); 469 if (!change) { 470 g_free(uids[i]); 471 osync_context_report_osyncwarning(ctx, error); 472 osync_error_unref(&error); 473 continue; 474 } 475 476 osync_change_set_uid(change, uids[i]); 477 osync_change_set_changetype(change, OSYNC_CHANGE_TYPE_DELETED); 478 479 OSyncData *odata = osync_data_new(NULL, 0, sinkenv->objformat, &error); 480 if (!odata) { 481 g_free(uids[i]); 482 osync_change_unref(change); 483 osync_context_report_osyncwarning(ctx, error); 484 osync_error_unref(&error); 485 continue; 486 } 487 488 osync_data_set_objtype(odata, osync_objtype_sink_get_name(sink)); 489 osync_change_set_data(change, odata); 490 osync_data_unref(odata); 491 492 osync_context_report_change(ctx, change); 493 494 osync_hashtable_update_hash(sinkenv->hashtable, osync_change_get_changetype(change), osync_change_get_uid(change), NULL); 495 496 osync_change_unref(change); 497 g_free(uids[i]); 498 } 499 g_free(uids); 500 501 448 502 449 503 osync_trace(TRACE_EXIT, "%s()", __func__); 450 return TRUE;451 504 } 452 505 453 506 /* The function commit changes of contact entries to the cellphone. 454 *455 * Return: bool456 * ReturnVal: TRUE on success457 * ReturnVal: FALSE on error458 507 */ 459 osync_bool gnokii_contact_commit(OSyncContext *ctx, OSyncChange *change) { 460 461 osync_trace(TRACE_ENTRY, "%s() (%p, %p)", __func__, ctx, change); 508 509 void gnokii_contact_commit_change(void *plugindata, OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *change) 510 { 511 512 osync_trace(TRACE_ENTRY, "%s() (%p, %p, %p, %p)", __func__, plugindata, info, change, ctx); 462 513 463 514 OSyncError *error = NULL; … … 466 517 char *hash = NULL; 467 518 468 gnokii_environment *env = (gnokii_environment *)osync_context_get_plugin_data(ctx); 519 OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info); 520 gnokii_sinkenv *sinkenv = osync_objtype_sink_get_userdata(sink); 521 gnokii_environment *env = (gnokii_environment *) plugindata; 469 522 470 523 // Get changed contact note … … 473 526 // Check for type of changes 474 527 switch (osync_change_get_changetype(change)) { 475 case CHANGE_DELETED:528 case OSYNC_CHANGE_TYPE_DELETED: 476 529 // Delete the change 477 530 … … 484 537
