| 343 | | char *uid = opie_xml_get_tagged_uid(item_node); |
|---|
| 344 | | unsigned char *hash = hash_xml_node(env->doc, item_node); |
|---|
| | 341 | /* Create the new change to report */ |
|---|
| | 342 | OSyncChange *change = osync_change_new(&error); |
|---|
| | 343 | if (!change) { |
|---|
| | 344 | osync_context_report_osyncwarning(ctx, error); |
|---|
| | 345 | osync_error_unref(&error); |
|---|
| | 346 | } |
|---|
| | 347 | else { |
|---|
| | 348 | |
|---|
| | 349 | /* Retrieve and set the uid of the object */ |
|---|
| | 350 | char *uid = opie_xml_get_tagged_uid(item_node); |
|---|
| | 351 | osync_change_set_uid(change, uid); |
|---|
| | 352 | g_free(uid); |
|---|
| | 353 | |
|---|
| | 354 | /* Calculate and set the hash of the object */ |
|---|
| | 355 | unsigned char *hash = hash_xml_node(env->doc, item_node); |
|---|
| | 356 | osync_change_set_hash(change, hash); |
|---|
| | 357 | g_free(hash); |
|---|
| | 358 | |
|---|
| | 359 | /* Detect and set the type of change */ |
|---|
| | 360 | OSyncChangeType changetype = osync_hashtable_get_changetype(env->hashtable, change); |
|---|
| | 361 | osync_change_set_changetype(change, changetype); |
|---|
| | 362 | |
|---|
| | 363 | /* Update the hashtable with the hash of the object */ |
|---|
| | 364 | osync_hashtable_update_change(env->hashtable, change); |
|---|
| | 365 | |
|---|
| | 366 | if (changetype != OSYNC_CHANGE_TYPE_UNMODIFIED) { |
|---|
| | 367 | /* Convert category IDs to names that other systems can use */ |
|---|
| | 368 | g_mutex_lock(env->plugin_env->plugin_mutex); |
|---|
| | 369 | char *categories_bkup = opie_xml_get_categories(item_node); |
|---|
| | 370 | if(env->plugin_env->categories_doc && categories_bkup) |
|---|
| | 371 | opie_xml_category_ids_to_names(env->plugin_env->categories_doc, item_node); |
|---|
| | 372 | g_mutex_unlock(env->plugin_env->plugin_mutex); |
|---|
| | 373 | |
|---|
| | 374 | char *data = xml_node_to_text(env->doc, item_node); |
|---|
| 346 | | /* Convert category IDs to names that other systems can use */ |
|---|
| 347 | | g_mutex_lock(env->plugin_env->plugin_mutex); |
|---|
| 348 | | char *categories_bkup = opie_xml_get_categories(item_node); |
|---|
| 349 | | if(env->plugin_env->categories_doc && categories_bkup) |
|---|
| 350 | | opie_xml_category_ids_to_names(env->plugin_env->categories_doc, item_node); |
|---|
| 351 | | g_mutex_unlock(env->plugin_env->plugin_mutex); |
|---|
| 352 | | |
|---|
| 353 | | char *data = xml_node_to_text(env->doc, item_node); |
|---|
| 354 | | |
|---|
| 355 | | /* Restore old categories value as we don't want to save this back to our XML file */ |
|---|
| 356 | | if(categories_bkup) { |
|---|
| 357 | | opie_xml_set_categories(item_node, categories_bkup); |
|---|
| 358 | | g_free(categories_bkup); |
|---|
| 359 | | } |
|---|
| 360 | | |
|---|
| 361 | | // Report every entry .. every unreported entry got deleted. |
|---|
| 362 | | osync_hashtable_report(env->hashtable, uid); |
|---|
| 363 | | |
|---|
| 364 | | OSyncChangeType changetype = osync_hashtable_get_changetype(env->hashtable, uid, hash); |
|---|
| 365 | | |
|---|
| 366 | | if (changetype != OSYNC_CHANGE_TYPE_UNMODIFIED) { |
|---|
| 367 | | //Set the hash of the object (optional, only required if you use hashtabled) |
|---|
| 368 | | osync_hashtable_update_hash(env->hashtable, changetype, uid, hash); |
|---|
| 369 | | |
|---|
| 370 | | //Make the new change to report |
|---|
| 371 | | OSyncChange *change = osync_change_new(&error); |
|---|
| 372 | | if (!change) { |
|---|
| 373 | | osync_context_report_osyncwarning(ctx, error); |
|---|
| 374 | | osync_error_unref(&error); |
|---|
| 375 | | } |
|---|
| 376 | | else { |
|---|
| 377 | | |
|---|
| 378 | | //Now set the uid of the object |
|---|
| 379 | | osync_change_set_uid(change, uid); |
|---|
| 380 | | osync_change_set_hash(change, hash); |
|---|
| 381 | | osync_change_set_changetype(change, changetype); |
|---|
| 382 | | |
|---|
| | 376 | /* Restore old categories value as we don't want to save this back to our XML file */ |
|---|
| | 377 | if(categories_bkup) { |
|---|
| | 378 | opie_xml_set_categories(item_node, categories_bkup); |
|---|
| | 379 | g_free(categories_bkup); |
|---|
| | 380 | } |
|---|
| | 381 | |
|---|
| 411 | | //When you are done looping and if you are using hashtables |
|---|
| 412 | | //check for deleted entries ... via hashtable |
|---|
| 413 | | int i; |
|---|
| 414 | | char **uids = osync_hashtable_get_deleted(env->hashtable); |
|---|
| 415 | | for (i=0; uids[i]; i++) { |
|---|
| | 406 | /* Check for deleted entries using the hashtable */ |
|---|
| | 407 | OSyncList *u, *uids = osync_hashtable_get_deleted(env->hashtable); |
|---|
| | 408 | for (u = uids; u; u = u->next) { |
|---|
| | 409 | const char *uid = u->data; |
|---|
| | 410 | |
|---|