3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #include "utility/sync_util.h"
20 #include "plugin/data_connector_plugin.h"
21 #include "plugin/data_converter_plugin.h"
23 #include "account/manager.h"
24 #include "account/util_internal.h"
26 #include "data-adapter/agent.h"
27 #include "data-adapter/agent_handler_manager.h"
28 #include "data-adapter/agent_handler_manager_internal.h"
30 #include "data-adapter/interface_item.h"
31 #include "data-adapter/interface_service_item.h"
32 #include "data-adapter/service_internal.h"
37 #define EXPORT_API __attribute__ ((visibility("default")))
40 #ifndef SYNC_AGENT_LOG
42 #define LOG_TAG "AF_DACI"
45 EXPORT_API sync_agent_da_return_e sync_agent_open_service(int content_type)
49 sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
50 plugin_open_service_cb func_service_open = plugin_get_function_open_service(content_type);
52 retvm_if(func_service_open == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_open_service_cb !!");
54 ret = func_service_open();
55 if (ret != SYNC_AGENT_DA_SUCCESS) {
56 _DEBUG_ERROR("[sync_agent_open_service] Fail!");
58 _DEBUG_INFO("[sync_agent_open_service] Success!");
66 EXPORT_API sync_agent_da_return_e sync_agent_close_service(int content_type)
70 sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
71 plugin_close_service_cb func_service_close = plugin_get_function_close_service(content_type);
73 retvm_if(func_service_close == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_close_service_cb !!");
75 ret = func_service_close();
76 if (ret != SYNC_AGENT_DA_SUCCESS) {
77 _DEBUG_ERROR("[sync_agent_close_service] Fail!");
79 _DEBUG_INFO("[sync_agent_close_service] Success!");
87 EXPORT_API sync_agent_da_return_e sync_agent_begin_service(int content_type)
91 sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
92 plugin_begin_transaction_cb func_begin_transaction = plugin_get_function_begin_transaction(content_type);
94 retvm_if(func_begin_transaction == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_begin_transaction_cb !!");
96 ret = func_begin_transaction();
97 if (ret != SYNC_AGENT_DA_SUCCESS) {
98 _DEBUG_ERROR("[sync_agent_begin_service] Fail!");
100 _DEBUG_INFO("[sync_agent_begin_service] Success!");
108 EXPORT_API sync_agent_da_return_e sync_agent_end_service(int content_type, int is_success)
112 _DEBUG_INFO("[sync_agent_end_service] start");
114 sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
115 plugin_end_transaction_cb func_end_transaction = plugin_get_function_end_transaction(content_type);
117 retvm_if(func_end_transaction == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_end_transaction_cb !!");
119 ret = func_end_transaction(is_success);
120 if (ret != SYNC_AGENT_DA_SUCCESS) {
121 _DEBUG_ERROR("[sync_agent_end_service] Fail!");
123 _DEBUG_INFO("[sync_agent_end_service] Success!");
131 EXPORT_API sync_agent_da_return_e sync_agent_create_service_item(sync_agent_da_service_item_s ** service_item)
135 *service_item = (sync_agent_da_service_item_s *) calloc(1, sizeof(sync_agent_da_service_item_s));
136 if (*service_item == NULL) {
137 _DEBUG_ERROR("calloc failed !!");
138 return SYNC_AGENT_DA_ERRORS;
142 return SYNC_AGENT_DA_SUCCESS;
145 EXPORT_API sync_agent_da_return_e sync_agent_create_service_folder(sync_agent_da_service_folder_s ** service_folder)
149 *service_folder = (sync_agent_da_service_folder_s *) calloc(1, sizeof(sync_agent_da_service_folder_s));
150 if (*service_folder == NULL) {
151 _DEBUG_ERROR("calloc failed !!");
152 return SYNC_AGENT_DA_ERRORS;
157 return SYNC_AGENT_DA_SUCCESS;
160 EXPORT_API sync_agent_da_return_e sync_agent_free_service_item(sync_agent_da_service_item_s * service_item)
164 if (service_item != NULL) {
165 if (service_item->item_id != NULL)
166 free(service_item->item_id);
167 service_item->item_id = NULL;
168 if (service_item->parent_id != NULL)
169 free(service_item->parent_id);
170 service_item->parent_id = NULL;
171 if (service_item->folder_id != NULL)
172 free(service_item->folder_id);
173 service_item->folder_id = NULL;
174 if (service_item->access_name != NULL)
175 free(service_item->access_name);
176 service_item->access_name = NULL;
177 if (service_item->data != NULL)
178 free((void *)(service_item->data));
179 service_item->data = NULL;
183 _DEBUG_ERROR("service_item is NULL !!");
184 return SYNC_AGENT_DA_ERRORS;
188 return SYNC_AGENT_DA_SUCCESS;
191 EXPORT_API sync_agent_da_return_e sync_agent_free_service_folder(sync_agent_da_service_folder_s * service_folder)
195 if (service_folder != NULL) {
196 if (service_folder->folder_id != NULL)
197 free(service_folder->folder_id);
199 if (service_folder->folder_name != NULL)
200 free(service_folder->folder_name);
202 free(service_folder);
204 _DEBUG_ERROR("service_folder is NULL !!");
205 return SYNC_AGENT_DA_ERRORS;
208 return SYNC_AGENT_DA_SUCCESS;
211 EXPORT_API sync_agent_da_return_e sync_agent_add_service_item(sync_agent_da_service_item_s * service_item, char **item_id, bool update_changelog)
215 retvm_if(service_item == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_service_item_s is NULL !!");
217 sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
218 sync_agent_da_item_s *fw_item = NULL;
219 int service_account_id = 0;
220 char *service_item_id = NULL;
221 char *service_folder_id = NULL;
222 void *service_data = NULL;
223 plugin_converter_cb func_converter;
224 plugin_add_item_cb func_addItem;
226 /* 1. get service account id */
227 service_account_id = acc_get_service_account_id(service_item->content_type, service_item->account_id);
228 _DEBUG_INFO("[sync_agent_add_service_item] service_acount_id : %d", service_account_id);
230 /* 2. get service folder id */
231 service_folder_id = sync_agent_get_service_folder_id(service_item->folder_id);
232 _DEBUG_INFO("[sync_agent_add_service_item] service_folder_id : %s", service_folder_id);
234 /* 3. call plugIn dataconverter */
235 int converter_plugIn_id = plugin_get_data_converter_plugin_id(service_item->content_type);
236 func_converter = plugin_get_function_converter(converter_plugIn_id);
237 if (func_converter == NULL) {
238 _DEBUG_ERROR("%d", __LINE__);
239 ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
243 ret = func_converter(service_item->data, &service_data);
244 if (ret != SYNC_AGENT_DA_SUCCESS) {
245 _DEBUG_ERROR("%d", __LINE__);
249 /* 4. call plugIn dataconnector */
250 func_addItem = plugin_get_function_add_item(service_item->content_type);
251 if (func_addItem == NULL) {
252 _DEBUG_ERROR("%d", __LINE__);
253 ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
257 ret = func_addItem(service_account_id, service_folder_id, service_data, &service_item_id);
258 if (ret != SYNC_AGENT_DA_SUCCESS) {
259 _DEBUG_INFO("[sync_agent_add_service_item] failed pFunc_AddItem()\n");
262 _DEBUG_INFO("[sync_agent_add_service_item] success pFunc_AddItem()\n");
263 _DEBUG_INFO("[sync_agent_add_service_item] added service item id : %s", service_item_id);
266 ret = sync_agent_create_item(&fw_item);
267 if (ret != SYNC_AGENT_DA_SUCCESS) {
268 _DEBUG_INFO("[sync_agent_add_service_item] failed sync_agent_create_item()\n");
272 fw_item->data_store_id = service_item->content_type;
273 fw_item->account_id = service_item->account_id;
274 fw_item->item_id = g_strdup(service_item->item_id);
275 fw_item->folder_id = g_strdup(service_item->folder_id);
276 fw_item->service_id = g_strdup(service_item_id);
277 fw_item->parent_service_id = g_strdup(service_item->parent_id);
278 fw_item->access_name = g_strdup(service_item->access_name);
280 ret = sync_agent_add_item(fw_item, item_id, update_changelog);
281 if (ret != SYNC_AGENT_DA_SUCCESS) {
282 _DEBUG_INFO("[sync_agent_add_service_item] failed sync_agent_add_item()\n");
285 _DEBUG_INFO("[sync_agent_add_service_item] success sync_agent_add_item()\n");
286 _DEBUG_INFO("[sync_agent_add_service_item] added fw item id : %s", *item_id);
291 if (ret != SYNC_AGENT_DA_SUCCESS)
296 sync_agent_free_item(fw_item);
297 if (service_item_id != NULL)
298 free(service_item_id);
299 if (service_folder_id != NULL)
300 free(service_folder_id);
307 EXPORT_API sync_agent_da_return_e sync_agent_add_service_bulk_item(sync_agent_da_service_item_s *service_item, char **item_id, bool update_changelog)
311 retvm_if(service_item == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_service_item_s is NULL !!");
313 char *service_folder_id = NULL;
314 char service_item_id_tmp[10] = {0,};
315 int service_account_id = 0;
318 int *service_item_id = NULL;
319 int service_item_id_count = 0;
320 void *service_data = NULL;
321 sync_agent_da_return_e da_ret = SYNC_AGENT_DA_SUCCESS;
322 sync_agent_da_item_s *fw_item = NULL;
323 plugin_converter_cb func_converter;
324 plugin_add_bulk_item_cb func_addBulkItem;
326 /* 1. get service account id */
327 service_account_id = acc_get_service_account_id(service_item->content_type, service_item->account_id);
328 _DEBUG_INFO(" service_acount_id : [%d]", service_account_id);
330 /* 2. get service folder id */
331 service_folder_id = sync_agent_get_service_folder_id(service_item->folder_id);
332 _DEBUG_INFO(" service_folder_id : [%s]", service_folder_id);
334 /* 3. call plugIn dataconverter */
335 int converter_plugIn_id = plugin_get_data_converter_plugin_id(service_item->content_type);
336 func_converter = plugin_get_function_converter(converter_plugIn_id);
337 if (func_converter == NULL) {
338 _DEBUG_ERROR(" plugin_get_function_converter() fail, func_converter is NULL");
339 da_ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
343 /**************** phase 1 : vcard -> ctsvc struct **********************/
344 count = g_list_length((GList *)service_item->data);
345 _DEBUG_INFO(" count of vcard list = [%d]", count);
347 GList *service_data_list = NULL;
348 for (index = 0; index < count; ++index) {
349 da_ret = func_converter((char *)g_list_nth_data((GList *)service_item->data, index), &service_data);
350 if (da_ret != SYNC_AGENT_DA_SUCCESS) {
351 _DEBUG_ERROR(" func_converter() fail, da_ret[%d]", da_ret);
354 /**************** phase 2 : ctsvc struct -> GList **********************/
355 service_data_list = g_list_append(service_data_list, service_data);
357 _DEBUG_INFO(" count of ctsvc struct list = [%d]", g_list_length(service_data_list));
360 /* 4. call plugIn dataconnector */
361 func_addBulkItem = plugin_get_function_add_bulk_item(service_item->content_type);
362 if (func_addBulkItem == NULL) {
363 _DEBUG_ERROR(" plugin_get_function_add_bulk_item() fail, func_addBulkItem is NULL");
364 da_ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
368 da_ret = func_addBulkItem(service_account_id, service_folder_id, service_data_list, &service_item_id, &service_item_id_count);
369 if (da_ret != SYNC_AGENT_DA_SUCCESS) {
370 _DEBUG_ERROR(" func_addBulkItem() fail, da_ret[%d]", da_ret);
373 _DEBUG_INFO("added service item id size = [%d]", service_item_id_count);
376 /**************** phase 4 : inserted contact DB -> insert kies DB **********************/
377 for (index = 0; index < service_item_id_count; ++index) {
378 da_ret = sync_agent_create_item(&fw_item);
379 if (da_ret != SYNC_AGENT_DA_SUCCESS) {
380 _DEBUG_ERROR("sync_agent_create_item() fail, da_ret[%s]", da_ret);
383 if (fw_item == NULL) {
384 _DEBUG_ERROR("sync_agent_create_item() fail, fw_item is NULL");
388 fw_item->data_store_id = service_item->content_type;
389 fw_item->account_id = service_item->account_id;
390 fw_item->item_id = g_strdup(item_id[index]);
391 fw_item->folder_id = g_strdup(service_item->folder_id);
392 memset(service_item_id_tmp, 0, 10);
393 snprintf(service_item_id_tmp, 10, "%d", service_item_id[index]);
394 fw_item->service_id = g_strdup(service_item_id_tmp);
395 fw_item->parent_service_id = g_strdup(service_item->parent_id);
396 _DEBUG_INFO("fw_item->parent_service_id = %s", fw_item->parent_service_id);
397 fw_item->access_name = g_strdup(service_item->access_name);
399 //_DEBUG_INFO("fw_item->service_id[%d] = [%s], item_id[%d] = [%s], fw_item->item_id = [%s]", index, fw_item->service_id, index, item_id[index], fw_item->item_id);
401 da_ret = sync_agent_add_item(fw_item, &item_id[index], update_changelog);
402 if (da_ret != SYNC_AGENT_DA_SUCCESS) {
403 _DEBUG_ERROR("sync_agent_add_bulk_item() fail, da_ret[%d]", da_ret);
407 //_DEBUG_INFO("sync_agent_add_bulk_item() success, added fw item id = [%s]", item_id[index]);
410 if (fw_item != NULL) {
411 da_ret = sync_agent_free_item(fw_item);
412 if (da_ret != SYNC_AGENT_DA_SUCCESS) {
413 _DEBUG_ERROR("sync_agent_free_item() fail, da_ret[%d]", da_ret);
421 _DEBUG_INFO("daci_finish");
423 if (da_ret != SYNC_AGENT_DA_SUCCESS) {
426 if (fw_item != NULL) {
427 da_ret = sync_agent_free_item(fw_item);
428 if (da_ret != SYNC_AGENT_DA_SUCCESS) {
429 _DEBUG_ERROR("sync_agent_free_item() fail, da_ret[%d]", da_ret);
433 if (service_item_id != NULL) {
434 free(service_item_id);
435 service_item_id = NULL;
437 if (service_folder_id != NULL) {
438 free(service_folder_id);
439 service_folder_id = NULL;
445 EXPORT_API sync_agent_da_return_e sync_agent_update_service_item(sync_agent_da_service_item_s * service_item, char *item_id, bool update_changelog)
449 retvm_if(service_item == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_service_item_s is NULL !!");
450 retvm_if(item_id == NULL, SYNC_AGENT_DA_ERRORS, "item id is NULL !!");
452 _DEBUG_INFO("[sync_agent_update_service_item] account_id : %d", service_item->account_id);
453 _DEBUG_INFO("[sync_agent_update_service_item] folder_id : %s", service_item->folder_id);
454 _DEBUG_INFO("[sync_agent_update_service_item] item_id : %s", item_id);
455 _DEBUG_INFO("[sync_agent_update_service_item] data : %s", (char *)service_item->data);
457 sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
458 int service_account_id = 0;
459 char *service_folder_id = NULL;
460 char *service_item_id = NULL;
461 void *service_data = NULL;
462 void *new_service_data = NULL;
463 plugin_get_item_cb func_get_item;
464 plugin_update_item_cb func_update_item;
465 plugin_replace_converter_cb func_replace_converter;
467 /* 1. get service account id */
468 service_account_id = acc_get_service_account_id(service_item->content_type, service_item->account_id);
469 _DEBUG_INFO("[sync_agent_update_service_item] service_acount_id : %d", service_account_id);
471 /* 2. get service folder id */
472 service_folder_id = sync_agent_get_service_folder_id(service_item->folder_id);
473 _DEBUG_INFO("[sync_agent_update_service_item] service_folder_id : %s", service_folder_id);
475 /* 3. get service item id */
476 service_item_id = sync_agent_get_service_item_id(item_id);
477 _DEBUG_INFO("[sync_agent_update_service_item] service_item_id : %s", service_item_id);
479 /* 4. call plugIn dataconnector */
480 func_get_item = plugin_get_function_get_item(service_item->content_type);
481 if (func_get_item == NULL) {
482 _DEBUG_ERROR("%d", __LINE__);
483 ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
487 ret = func_get_item(service_account_id, service_folder_id, service_item_id, &service_data);
488 if (ret != SYNC_AGENT_DA_SUCCESS) {
489 _DEBUG_INFO("%d", __LINE__);
493 /* 5. call plugIn dataconverter */
494 int converter_plugIn_id = plugin_get_data_converter_plugin_id(service_item->content_type);
495 func_replace_converter = plugin_get_function_replace_converter(converter_plugIn_id);
496 if (func_replace_converter == NULL) {
497 _DEBUG_ERROR("%d", __LINE__);
498 ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
502 ret = func_replace_converter(service_data, service_item->data, &new_service_data);
503 if (ret != SYNC_AGENT_DA_SUCCESS) {
504 _DEBUG_INFO("%d", __LINE__);
508 /* 6. call plugIn dataconverter */
509 func_update_item = plugin_get_function_update_item(service_item->content_type);
510 if (func_update_item == NULL) {
511 _DEBUG_ERROR("%d", __LINE__);
512 ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
516 ret = func_update_item(service_account_id, service_folder_id, service_item_id, new_service_data);
517 if (ret != SYNC_AGENT_DA_SUCCESS) {
518 _DEBUG_INFO("[sync_agent_update_service_item] failed func_update_item()\n");
521 _DEBUG_INFO("[sync_agent_update_service_item] success func_update_item()\n");
524 ret = sync_agent_update_item(item_id, update_changelog);
525 if (ret != SYNC_AGENT_DA_SUCCESS) {
526 _DEBUG_INFO("[sync_agent_update_service_item] failed sync_agent_update_item()\n");
529 _DEBUG_INFO("[sync_agent_update_service_item] success sync_agent_update_item()\n");
530 _DEBUG_INFO("[sync_agent_update_service_item] updated fw item id : %s", item_id);
536 if (service_folder_id != NULL)
537 free(service_folder_id);
539 if (service_item_id != NULL)
540 free(service_item_id);
546 EXPORT_API sync_agent_da_return_e sync_agent_update_service_bulk_item(sync_agent_da_service_item_s *service_item, char **item_id, bool update_changelog)
550 retvm_if(service_item == NULL, SYNC_AGENT_DA_ERRORS, "service_item is NULL");
551 retvm_if(item_id == NULL, SYNC_AGENT_DA_ERRORS, "item_id is NULL");
553 sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
554 char *service_item_id = NULL;
556 int count = g_list_length((GList *)service_item->data);
557 void *service_data = NULL;
558 void *new_service_data = NULL;
559 GList *service_data_list = NULL;
560 plugin_get_item_cb func_get_item;
561 plugin_replace_converter_cb func_replace_converter;
562 plugin_update_bulk_item_cb func_update_bulk_item;
564 /*Get service_account_id*/
565 int service_account_id = acc_get_service_account_id(service_item->content_type, service_item->account_id);
566 _DEBUG_INFO("service_account_id = [%d]", service_account_id);
568 /*Get service_folder_id*/
569 char *service_folder_id = sync_agent_get_service_folder_id(service_item->folder_id);
570 _DEBUG_INFO("service_folder_id = [%s]", service_folder_id);
572 /*Get service_item_id*/
573 for (index = 0; index < count; ++index) {
574 service_item_id = sync_agent_get_service_item_id(item_id[index]);
575 _DEBUG_INFO("service_item_id = [%s]", service_item_id);
578 func_get_item = plugin_get_function_get_item(service_item->content_type);
579 if (func_get_item == NULL) {
580 _DEBUG_ERROR("func_get_item is NULL");
581 ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
584 ret = func_get_item(service_account_id, service_folder_id, service_item_id, &service_data);
585 if (ret != SYNC_AGENT_DA_SUCCESS) {
586 _DEBUG_ERROR("func_get_item() fail, ret[%d]", ret);
591 int converter_plugin_id = plugin_get_data_converter_plugin_id(service_item->content_type);
592 func_replace_converter = plugin_get_function_replace_converter(converter_plugin_id);
593 if (func_replace_converter == NULL) {
594 _DEBUG_ERROR("func_replace_converter is NULL");
595 ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
598 ret = func_replace_converter(service_data, ((char *)g_list_nth_data((GList *)service_item->data, index)), &new_service_data);
599 if (ret != SYNC_AGENT_DA_SUCCESS) {
600 _DEBUG_ERROR("func_replace_converter() fail, ret[%d]", ret);
603 service_data_list = g_list_append(service_data_list, new_service_data);
606 func_update_bulk_item = plugin_get_function_update_bulk_item(service_item->content_type);
607 if (func_update_bulk_item == NULL) {
608 _DEBUG_ERROR("func_update_bulk_item is NULL");
609 ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
612 ret = func_update_bulk_item(service_data_list);
613 if (ret != SYNC_AGENT_DA_SUCCESS) {
614 _DEBUG_ERROR("func_update_bulk_item() fail, ret[%d]", ret);
618 _DEBUG_INFO("DACI_FINISH");
620 if (service_folder_id != NULL) {
621 free(service_folder_id);
622 service_folder_id = NULL;
625 if (service_item_id != NULL) {
626 free(service_item_id);
627 service_item_id = NULL;
634 EXPORT_API sync_agent_da_return_e sync_agent_add_updated_exdate_item(sync_agent_da_service_item_s * service_item, char *parent_id, char *child_id, bool update_changelog)
638 retvm_if(service_item == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_service_item_s is NULL !!");
639 retvm_if(parent_id == NULL, SYNC_AGENT_DA_ERRORS, "parent_id is NULL !!");
641 _DEBUG_INFO("account_id : %d", service_item->account_id);
642 _DEBUG_INFO("folder_id : %s", service_item->folder_id);
643 _DEBUG_INFO("parent_id : %s", parent_id);
644 _DEBUG_INFO("child_id : %s", child_id);
645 _DEBUG_INFO("service_item->item_id : %s", service_item->item_id);
646 _DEBUG_INFO("data : %s", (char *)service_item->data);
648 char *service_folder_id = NULL;
649 char *service_parent_item_id = NULL;
650 void *service_data = NULL;
651 void *new_service_data = NULL;
652 sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
653 int service_account_id = 0;
654 plugin_get_item_cb func_get_item;
655 plugin_replace_converter_cb func_replace_converter;
657 service_account_id = acc_get_service_account_id(service_item->content_type, service_item->account_id);
658 _DEBUG_INFO("service_acount_id : %d", service_account_id);
659 service_folder_id = sync_agent_get_service_folder_id(service_item->folder_id);
660 _DEBUG_INFO("service_folder_id : %s", service_folder_id);
661 service_parent_item_id = sync_agent_get_service_item_id(parent_id);
662 _DEBUG_INFO("service_parent_item_id : %s", service_parent_item_id);
664 /* 4. call plugIn dataconnector */
665 func_get_item = plugin_get_function_get_item(service_item->content_type);
666 if (func_get_item == NULL) {
667 _DEBUG_ERROR("%d", __LINE__);
668 ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
672 ret = func_get_item(service_account_id, service_folder_id, service_parent_item_id, &service_data);
673 goto_if(ret != SYNC_AGENT_DA_SUCCESS, "func_get_item() failed, ret = [%d]", ret);
675 /* 5. checking whether the item exist or not*/
676 ret = sync_agent_is_exist_exdate_item(service_item->content_type, service_parent_item_id, (char *)service_item->data);
677 if (ret == SYNC_AGENT_DA_ERR_ALREADY_EXIST) {
678 _DEBUG_INFO("SYNC_AGENT_DA_ERR_ALREADY_EXIST");
679 ret = SYNC_AGENT_DA_SUCCESS;
683 /* 6. call plugIn dataconverter */
684 int converter_plugIn_id = plugin_get_data_converter_plugin_id(service_item->content_type);
685 func_replace_converter = plugin_get_function_replace_converter(converter_plugIn_id);
686 if (func_replace_converter == NULL) {
687 _DEBUG_ERROR("%d", __LINE__);
688 ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
692 ret = func_replace_converter(service_data, service_item->data, &new_service_data);
693 goto_if(ret != SYNC_AGENT_DA_SUCCESS, "func_replace_converter() failed, ret = [%d]", ret);
696 //////////////////////////////////////// construct the parent item ////////////////////////////////
697 // All child item of parent item whose has original_event_id as service_id field should be deleted before callback_add_item()
698 // Requesting by Calendar Svc Team (2013-03-26 tw123.kim & iamjs.kim)
699 sync_agent_construct_exdate_parent_item(service_item->content_type, service_parent_item_id);
702 _DEBUG_INFO("return_part");
703 if (service_folder_id != NULL){
704 free(service_folder_id);
705 service_folder_id = NULL;
707 if (new_service_data != NULL){
708 free(new_service_data);
709 new_service_data = NULL;
715 EXPORT_API sync_agent_da_return_e sync_agent_delete_service_item(char *item_id, bool update_changelog)
719 retvm_if(item_id == NULL, SYNC_AGENT_DA_ERRORS, "item id is NULL !!");
721 sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
722 sync_agent_da_item_s *fw_item = NULL;
723 int service_account_id = 0;
724 char *service_folder_id = NULL;
725 char *service_item_id = NULL;
726 plugin_delete_item_cb func_del_item;
728 ret = sync_agent_create_item(&fw_item);
729 if (ret != SYNC_AGENT_DA_SUCCESS) {
730 _DEBUG_ERROR("sync_agent_create_item() failed !!");
734 ret = sync_agent_get_item(item_id, &fw_item);
735 if (ret != SYNC_AGENT_DA_SUCCESS) {
736 _DEBUG_ERROR("sync_agent_get_item() failed !!");
740 /* 1. get service account id */
741 service_account_id = acc_get_service_account_id(fw_item->data_store_id, fw_item->account_id);
742 _DEBUG_INFO("[sync_agent_delete_service_item] service_acount_id : %d", service_account_id);
744 /* 2. get service folder id */
745 service_folder_id = sync_agent_get_service_folder_id(fw_item->folder_id);
746 _DEBUG_INFO("[sync_agent_delete_service_item] service_folder_id : %s", service_folder_id);
748 /* 3. get service item id */
749 service_item_id = sync_agent_get_service_item_id(item_id);
750 _DEBUG_INFO("[sync_agent_delete_service_item] service_item_id : %s", service_item_id);
752 /* 4. call plugIn dataconnector */
753 func_del_item = plugin_get_function_del_item(fw_item->data_store_id);
754 if (func_del_item == NULL) {
755 _DEBUG_ERROR("%d", __LINE__);
756 ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
760 ret = func_del_item(service_account_id, service_folder_id, service_item_id);
761 if (ret != SYNC_AGENT_DA_SUCCESS) {
762 _DEBUG_INFO("[sync_agent_delete_service_item] failed func_del_item()\n");
765 _DEBUG_INFO("[sync_agent_delete_service_item] success func_del_item()\n");
768 ret = sync_agent_delete_item(item_id, update_changelog);
769 if (ret != SYNC_AGENT_DA_SUCCESS) {
770 _DEBUG_INFO("[sync_agent_delete_service_item] failed sync_agent_delete_item()\n");
773 _DEBUG_INFO("[sync_agent_delete_service_item] success sync_agent_delete_item()\n");
774 _DEBUG_INFO("[sync_agent_delete_service_item] deleted fw item id : %s", item_id);
781 sync_agent_free_item(fw_item);
783 if (service_folder_id != NULL)
784 free(service_folder_id);
786 if (service_item_id != NULL)
787 free(service_item_id);
794 EXPORT_API sync_agent_da_return_e sync_agent_delete_service_bulk_item(char **item_id, int count, bool update_changelog)
798 retvm_if(item_id == NULL, SYNC_AGENT_DA_ERRORS, "item_id is NULL");
799 retvm_if(count == 0, SYNC_AGENT_DA_ERRORS, "count is 0");
801 sync_agent_da_return_e da_ret = SYNC_AGENT_DA_SUCCESS;
802 sync_agent_da_item_s *fw_item = NULL;
803 plugin_delete_bulk_item_cb func_del_bulk_item;
804 char *service_item_id_tmp = NULL;
806 int service_item_id[count];
808 da_ret = sync_agent_create_item(&fw_item);
809 if (da_ret != SYNC_AGENT_DA_SUCCESS) {
810 _DEBUG_ERROR("sync_agent_create_item() fail, da_Ret[%d]", da_ret);
814 da_ret = sync_agent_get_item_data_store_id(*item_id, &fw_item);
815 if (da_ret != SYNC_AGENT_DA_SUCCESS) {
816 _DEBUG_ERROR("sync_agent_get_item_data_store_id() fail, da_ret[%d]", da_ret);
820 memset(service_item_id, 0, count);
821 for (index = 0; index < count; ++index) {
822 service_item_id_tmp = sync_agent_get_service_item_id(item_id[index]);
823 service_item_id[index] = atoi(service_item_id_tmp);
826 func_del_bulk_item = plugin_get_function_del_bulk_item(fw_item->data_store_id);
827 if (func_del_bulk_item == NULL) {
828 _DEBUG_ERROR("func_del_bulk_item is NULL");
829 da_ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
833 da_ret = func_del_bulk_item(service_item_id, count);
834 if (da_ret != SYNC_AGENT_DA_SUCCESS) {
835 _DEBUG_ERROR("func_del_bulk_item() fail, da_ret[%d]", da_ret);
839 for (index = 0; index < count; ++index) {
840 da_ret = sync_agent_delete_item(item_id[index], update_changelog);
841 if (da_ret != SYNC_AGENT_DA_SUCCESS) {
842 _DEBUG_ERROR("sync_agent_delete_item() fail, da_ret[%d]", da_ret);
846 //_DEBUG_INFO("sync_agent_delete_item() success, deleted fw_item_id = [%s]", item_id[index]);
851 _DEBUG_INFO("daci_finish");
853 if (fw_item != NULL) {
854 da_ret = sync_agent_free_item(fw_item);
855 if (da_ret != SYNC_AGENT_DA_SUCCESS) {
856 _DEBUG_ERROR("sync_agent_free_item() fail, da_ret[%d]", da_ret);
864 EXPORT_API sync_agent_da_return_e sync_agent_query_delete_service_items(sync_agent_da_delete_service_item_query_s * query)
868 retvm_if(query == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_delete_service_item_query_s is NULL !!");
870 sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
871 int service_account_id = 0;
872 plugin_delete_all_items_cb func_del_all_items;
874 /* 1. get service account id */
875 service_account_id = acc_get_service_account_id(query->content_type, query->account_id);
876 _DEBUG_INFO("[sync_agent_query_delete_service_items] service_acount_id : %d", service_account_id);
878 /* 2. call plugIn dataconnector */
879 func_del_all_items = plugin_get_function_del_all_items(query->content_type);
881 retvm_if(func_del_all_items == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_delete_all_items_cb !!");
883 ret = func_del_all_items(service_account_id);
884 if (ret != SYNC_AGENT_DA_SUCCESS) {
885 _DEBUG_INFO("[sync_agent_query_delete_service_items] failed func_del_all_items()\n");
887 _DEBUG_INFO("[sync_agent_query_delete_service_items] success func_del_all_items()\n");
894 EXPORT_API sync_agent_da_return_e sync_agent_get_service_item(char *item_id, sync_agent_da_service_item_s ** service_item)
898 retvm_if(item_id == NULL, SYNC_AGENT_DA_ERRORS, "item id is NULL !!");
900 sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
901 sync_agent_da_item_s *fw_item = NULL;
902 int service_account_id = 0;
904 char *service_folder_id = NULL;
905 char *service_item_id = NULL;
906 void *service_data = NULL;
907 plugin_get_item_cb func_get_item;
908 plugin_reverse_converter_cb func_reverse_converter;
910 ret = sync_agent_create_item(&fw_item);
911 if (ret != SYNC_AGENT_DA_SUCCESS) {
912 _DEBUG_ERROR("sync_agent_create_item() failed !!");
916 ret = sync_agent_get_item(item_id, &fw_item);
917 if (ret != SYNC_AGENT_DA_SUCCESS) {
918 _DEBUG_ERROR("sync_agent_get_item() failed !!");
922 /* 1. get service account id */
923 service_account_id = acc_get_service_account_id(fw_item->data_store_id, fw_item->account_id);
924 _DEBUG_INFO("[sync_agent_get_service_item] service_acount_id : %d", service_account_id);
926 /* 2. get service folder id */
927 service_folder_id = sync_agent_get_service_folder_id(fw_item->folder_id);
928 _DEBUG_INFO("[sync_agent_get_service_item] service_folder_id : %s", service_folder_id);
930 /* 3. get service item id */
931 service_item_id = sync_agent_get_service_item_id(item_id);
932 _DEBUG_INFO("[sync_agent_get_service_item] service_item_id : %s", service_item_id);
934 /* 4. call plugIn dataconnector */
935 func_get_item = plugin_get_function_get_item(fw_item->data_store_id);
936 if (func_get_item == NULL) {
937 _DEBUG_ERROR("%d", __LINE__);
938 ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
942 ret = func_get_item(service_account_id, service_folder_id, service_item_id, &service_data);
943 if (ret != SYNC_AGENT_DA_SUCCESS) {
944 _DEBUG_ERROR("%d", __LINE__);
948 /* 5. call plugIn dataconverter */
949 int converter_plugIn_id = plugin_get_data_converter_plugin_id(fw_item->data_store_id);
950 func_reverse_converter = plugin_get_function_reverse_converter(converter_plugIn_id);
951 if (func_reverse_converter == NULL) {
952 _DEBUG_ERROR("%d", __LINE__);
953 ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
957 ret = func_reverse_converter(service_data, (void **)(&((*service_item)->data)));
958 if (ret != SYNC_AGENT_DA_SUCCESS) {
959 _DEBUG_INFO("[sync_agent_get_service_item] failed func_reverse_converter()\n");
962 _DEBUG_INFO("[sync_agent_get_service_item] success func_reverse_converter()\n");
965 (*service_item)->content_type = fw_item->data_store_id;
966 (*service_item)->account_id = fw_item->account_id;
967 (*service_item)->item_id = g_strdup(fw_item->item_id);
968 (*service_item)->folder_id = g_strdup(fw_item->folder_id);
969 (*service_item)->access_name = g_strdup(fw_item->access_name);
971 // in case of exdate item (only Calendar), The framework id of it's parent should be alloc to service_item->parent_id
972 if (fw_item->parent_service_id != NULL) {
973 parent_id = atoi(fw_item->parent_service_id);
974 _DEBUG_INFO("parent_id = %d", parent_id);
976 (*service_item)->parent_id = da_get_item_id_internal((*service_item)->account_id, fw_item->parent_service_id, (*service_item)->content_type);
982 sync_agent_free_item(fw_item);
985 if (service_folder_id != NULL)
986 free(service_folder_id);
987 service_folder_id = NULL;
989 if (service_item_id != NULL)
990 free(service_item_id);
991 service_item_id = NULL;
997 EXPORT_API sync_agent_da_return_e sync_agent_get_service_folder(char *folder_id, sync_agent_da_service_folder_s ** service_folder)
1001 retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERRORS, "folder id is NULL !!");
1003 sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
1004 sync_agent_da_folder_s *fw_folder = NULL;
1005 int service_account_id = 0;
1006 char *service_folder_id = NULL;
1007 plugin_get_folder_cb func_get_folder;
1009 ret = sync_agent_create_folder(&fw_folder);
1010 if (ret != SYNC_AGENT_DA_SUCCESS) {
1011 _DEBUG_ERROR("sync_agent_create_folder() failed !!");
1015 ret = sync_agent_get_folder(folder_id, &fw_folder);
1016 if (ret != SYNC_AGENT_DA_SUCCESS) {
1017 _DEBUG_ERROR("sync_agent_get_folder() failed !!");
1021 _DEBUG_INFO("folder[%s] info => data_store_id[%d], account_id[%d]", fw_folder->folder_id, fw_folder->data_store_id, fw_folder->account_id);
1023 /* 1. get service account id */
1024 service_account_id = acc_get_service_account_id(fw_folder->data_store_id, fw_folder->account_id);
1025 _DEBUG_INFO("[sync_agent_get_service_folder] service_acount_id : %d", service_account_id);
1027 /* 2. get service folder id */
1028 service_folder_id = sync_agent_get_service_folder_id(folder_id);
1029 _DEBUG_INFO("[sync_agent_get_service_folder] service_folder_id : %s", service_folder_id);
1031 /* 3. call plugIn dataconnector */
1032 func_get_folder = plugin_get_function_get_folder(fw_folder->data_store_id);
1033 if (func_get_folder == NULL) {
1034 _DEBUG_ERROR("%d", __LINE__);
1035 ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
1039 ret = func_get_folder(service_account_id, service_folder_id, &((*service_folder)->folder_name), &((*service_folder)->folder_type));
1040 if (ret != SYNC_AGENT_DA_SUCCESS) {
1041 _DEBUG_INFO("[sync_agent_get_service_folder] failed func_get_folder()\n");
1044 _DEBUG_INFO("[sync_agent_get_service_folder] success func_get_folder()\n");
1047 (*service_folder)->folder_id = g_strdup(folder_id);
1051 if (service_folder_id != NULL)
1052 free(service_folder_id);
1053 if (fw_folder != NULL)
1054 sync_agent_free_folder(fw_folder);
1061 EXPORT_API sync_agent_da_return_e sync_agent_execute_service(int content_type, int account_id, const char *execute_key, void *execute_values, void **result)
1065 retvm_if(execute_key == NULL, SYNC_AGENT_DA_ERRORS, "execute key is NULL !!");
1066 retvm_if(execute_values == NULL, SYNC_AGENT_DA_ERRORS, "execute value is NULL !!");
1068 sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
1069 int service_account_id = 0;
1070 plugin_execute_cb func_execute;
1072 /* 1. get service account id */
1073 service_account_id = acc_get_service_account_id(content_type, account_id);
1074 _DEBUG_INFO("[sync_agent_execute_service] service_acount_id : %d", service_account_id);
1076 /* 2. call plugIn dataconnector */
1077 func_execute = plugin_get_function_execute(content_type);
1079 retvm_if(func_execute == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_execute_cb !!");
1081 ret = func_execute(service_account_id, execute_key, execute_values, result);
1082 if (ret != SYNC_AGENT_DA_SUCCESS) {
1083 _DEBUG_INFO("[sync_agent_execute_service] failed pFunc_Execute()\n");
1085 _DEBUG_INFO("[sync_agent_execute_service] success pFunc_Execute()\n");
1093 EXPORT_API int sync_agent_get_used_service_item_count(int content_type)
1097 plugin_get_used_item_count_cb func_get_used_count = plugin_get_function_get_used_item_count(content_type);
1099 retvm_if(func_get_used_count == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_get_used_item_count_cb !!");
1101 /* 1. call plugIn dataconnector */
1102 int used_count = func_get_used_count();
1103 if (used_count <= -1) {
1104 _DEBUG_INFO("[sync_agent_get_used_service_item_count] failed pFunc_Get_Used_Count()\n");
1106 _DEBUG_INFO("[sync_agent_get_used_service_item_count] success pFunc_Get_Used_Count() : %d\n", used_count);
1114 EXPORT_API int sync_agent_get_deleted_exdate_item_count(int content_type)
1118 plugin_get_deleted_exdate_item_count func_get_used_count = plugin_get_function_get_deleted_exdate_item_count(content_type);
1119 retvm_if(func_get_used_count == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_get_deleted_exdate_item_count !!");
1121 /* 1. call plugIn dataconnector */
1122 int used_count = func_get_used_count();
1123 if (used_count <= -1) {
1124 _DEBUG_INFO("[sync_agent_get_deleted_exdate_item_count] failed pFunc_Get_Used_Count()\n");
1126 _DEBUG_INFO("[sync_agent_get_deleted_exdate_item_count] success pFunc_Get_Used_Count() : %d\n", used_count);
1133 EXPORT_API void sync_agent_construct_exdate_parent_item(int content_type, char *parent_service_id)
1136 retm_if(parent_service_id == NULL, "parent_service_id is NULL !!");
1138 plugin_construct_exdate_parent_item func_construct_exdate_parent_item = plugin_function_construct_exdate_parent_item(content_type);
1139 goto_if(func_construct_exdate_parent_item == NULL, "cannot get plugin_construct_exdate_parent_item !!");
1140 func_construct_exdate_parent_item(parent_service_id);
1148 EXPORT_API sync_agent_da_return_e sync_agent_is_exist_exdate_item(int content_type, const char *fw_parent_id, const char *child_vcalendar)
1152 plugin_is_exist_exdate_item func_is_exist_exdate_item = plugin_function_is_exist_exdate_item(content_type);
1153 retvm_if(func_is_exist_exdate_item == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_is_exist_exdate_item !!");
1155 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
1156 ret = func_is_exist_exdate_item(fw_parent_id, child_vcalendar);
1162 EXPORT_API int sync_agent_get_used_service_item_count_for_folder(int content_type, int account_id, char *folder_id)
1166 retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERRORS, "folder id is NULL !!");
1168 int used_count = SYNC_AGENT_DA_SUCCESS;
1169 int service_account_id = 0;
1170 char *service_folder_id = NULL;
1171 plugin_get_used_count_for_folder_cb func_get_used_item_count_for_folder;
1173 /* 1. get service account id */
1174 service_account_id = acc_get_service_account_id(content_type, account_id);
1175 _DEBUG_INFO("[sync_agent_get_used_service_item_count_for_folder] service_acount_id : %d", service_account_id);
1177 /* 2. get service folder id */
1178 service_folder_id = sync_agent_get_service_folder_id(folder_id);
1179 _DEBUG_INFO("[sync_agent_get_used_service_item_count_for_folder] service_folder_id : %s", service_folder_id);
1181 /* 3. call plugIn dataconnector */
1182 func_get_used_item_count_for_folder = plugin_get_function_get_used_count_for_folder(content_type);
1183 if (func_get_used_item_count_for_folder == NULL) {
1184 _DEBUG_ERROR("%d", __LINE__);
1185 used_count = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
1189 used_count = func_get_used_item_count_for_folder(service_account_id, service_folder_id);
1190 if (used_count <= -1) {
1191 _DEBUG_INFO("[sync_agent_get_used_service_item_count_for_folder] failed pFunc_Get_Used_item_Count_For_Folder()\n");
1193 _DEBUG_INFO("[sync_agent_get_used_service_item_count_for_folder] success pFunc_Get_Used_item_Count_For_Folder() : %d\n", used_count);
1199 if (service_folder_id != NULL)
1200 free(service_folder_id);
1207 EXPORT_API sync_agent_da_return_e sync_agent_backup_service_items_to_file(int content_type, int account_id, char **file_path)
1211 sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
1212 int service_account_id = 0;
1213 plugin_backup_service_items_to_file_cb func_write_items_to_files;
1215 /* 1. get service account id */
1216 service_account_id = acc_get_service_account_id(content_type, account_id);
1217 _DEBUG_INFO("service_acount_id : %d", service_account_id);
1219 /* 3. call plugIn dataconnector */
1220 func_write_items_to_files = plugin_get_function_backup_service_items_to_file(content_type);
1221 if (func_write_items_to_files == NULL) {
1222 _DEBUG_ERROR("%d", __LINE__);
1223 ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
1227 ret = func_write_items_to_files(service_account_id, file_path);
1228 if (ret != SYNC_AGENT_DA_SUCCESS) {
1229 _DEBUG_INFO("failed pFunc_Write_Items_To_Files()\n");
1231 _DEBUG_INFO("success pFunc_Write_Items_To_Files() : %d\n", ret);
1241 EXPORT_API sync_agent_da_return_e sync_agent_restore_service_items_from_file(int content_type, int account_id, const char *file_path)
1245 retvm_if(file_path == NULL, SYNC_AGENT_DA_ERRORS, "file path is NULL !!");
1247 sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
1248 int service_account_id = 0;
1249 plugin_restore_service_items_from_file_cb func_add_file_wrote_items_to_datastore;
1251 /* 1. get service account id */
1252 service_account_id = acc_get_service_account_id(content_type, account_id);
1253 _DEBUG_INFO("service_acount_id : %d", service_account_id);
1255 /* 3. call plugIn dataconnector */
1256 func_add_file_wrote_items_to_datastore = plugin_get_function_restore_service_items_from_file(content_type);
1257 if (func_add_file_wrote_items_to_datastore == NULL) {
1258 _DEBUG_ERROR("%d", __LINE__);
1259 ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
1263 ret = func_add_file_wrote_items_to_datastore(service_account_id, file_path);
1264 if (ret != SYNC_AGENT_DA_SUCCESS) {
1265 _DEBUG_INFO("failed pFunc_Add_File_Wrote_Items_To_Datastore()\n");
1267 _DEBUG_INFO("success pFunc_Add_File_Wrote_Items_To_Datastore() : %d\n", ret);
1277 EXPORT_API char *sync_agent_get_service_item_id(char *item_id)
1281 retvm_if(item_id == NULL, NULL, "item id is NULL !!");
1283 SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
1284 if (daci_handler == NULL) {
1285 _DEBUG_ERROR("[%s] no handler for key\n", __func__);
1291 return da_get_item_service_id(daci_handler, item_id);
1294 EXPORT_API char *sync_agent_get_service_folder_id(char *folder_id)
1298 retvm_if(folder_id == NULL, NULL, "folder id is NULL !!");
1300 SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
1301 if (daci_handler == NULL) {
1302 _DEBUG_ERROR("[%s] no handler for key\n", __func__);
1308 return da_get_folder_service_id(daci_handler, folder_id);
1311 EXPORT_API int sync_agent_get_sim_contact_info_max_name_length(int content_type)
1315 plugin_get_info_sim_contact_max_name_length_cb func_get_info_sim_contact_max_name_length = plugin_get_function_get_info_sim_contact_max_name_length(content_type);
1316 retvm_if(func_get_info_sim_contact_max_name_length == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_get_info_sim_contact_max_name_length_cb !!");
1318 int maxNameLength = func_get_info_sim_contact_max_name_length();
1321 return maxNameLength;
1324 EXPORT_API int sync_agent_get_sim_contact_info_max_number_length(int content_type)
1328 plugin_get_info_sim_contact_max_number_length_cb func_get_info_sim_contact_max_number_length = plugin_get_function_get_info_sim_contact_max_number_length(content_type);
1329 retvm_if(func_get_info_sim_contact_max_number_length == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_get_info_sim_contact_max_number_length_cb !!");
1331 int maxNumberLength = func_get_info_sim_contact_max_number_length();
1334 return maxNumberLength;
1337 EXPORT_API int sync_agent_get_sim_contact_info_max_email_length(int content_type)
1341 plugin_get_info_sim_contact_max_email_length_cb func_get_info_sim_contact_max_email_length = plugin_get_function_get_info_sim_contact_max_email_length(content_type);
1342 retvm_if(func_get_info_sim_contact_max_email_length == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_get_info_sim_contact_max_email_length_cb !!");
1344 int maxEmailLength = func_get_info_sim_contact_max_email_length();
1347 return maxEmailLength;
1350 EXPORT_API int sync_agent_get_sim_contact_empty_count(int content_type)
1354 plugin_get_info_sim_contact_empty_count_cb func_get_info_sim_contact_empty_count = plugin_get_function_get_info_sim_contact_empty_count(content_type);
1355 retvm_if(func_get_info_sim_contact_empty_count == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_get_info_sim_contact_empty_count_cb !!");
1357 int emptyCount = func_get_info_sim_contact_empty_count();
1363 EXPORT_API int sync_agent_get_sim_contact_empty_number_count(int content_type)
1367 plugin_get_info_sim_contact_empty_number_count_cb func_get_info_sim_contact_empty_number_count = plugin_get_function_get_info_sim_contact_empty_number_count(content_type);
1368 retvm_if(func_get_info_sim_contact_empty_number_count == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_get_info_sim_contact_empty_number_count_cb !!");
1370 int emptyNumberCount = func_get_info_sim_contact_empty_number_count();
1373 return emptyNumberCount;
1376 EXPORT_API int sync_agent_get_sim_contact_empty_email_count(int content_type)
1380 plugin_get_info_sim_contact_empty_email_count_cb func_get_info_sim_contact_empty_email_count = plugin_get_function_get_info_sim_contact_empty_email_count(content_type);
1381 retvm_if(func_get_info_sim_contact_empty_email_count == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_get_info_sim_contact_empty_email_count_cb !!");
1383 int emptyEmailCount = func_get_info_sim_contact_empty_email_count();
1386 return emptyEmailCount;
1389 EXPORT_API int sync_agent_get_sim_contact_addressbook_id(int content_type)
1393 plugin_get_info_sim_contact_addressbook_id_cb func_get_info_sim_contact_addressbook_id = plugin_get_function_get_info_sim_contact_addressbook_id(content_type);
1394 retvm_if(func_get_info_sim_contact_addressbook_id == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_get_info_sim_contact_addressbook_id !!");
1396 int simContactAddressbookId = func_get_info_sim_contact_addressbook_id();
1399 return simContactAddressbookId;
1402 EXPORT_API sync_agent_da_return_e sync_agent_get_sim_contact_item_id(int content_type, int sim_addressbook_id, GList **item_id)
1406 sync_agent_da_return_e da_ret = SYNC_AGENT_DA_SUCCESS;
1408 plugin_get_info_sim_contact_item_id_cb func_get_info_sim_contact_item_id = plugin_get_function_get_info_sim_contact_item_id(content_type);
1409 retvm_if(func_get_info_sim_contact_item_id == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get func_get_info_sim_contact_item_id !!");
1411 GList *item_id_list = NULL;
1412 da_ret = func_get_info_sim_contact_item_id(sim_addressbook_id, &item_id_list);
1413 if (da_ret != SYNC_AGENT_DA_SUCCESS) {
1414 _DEBUG_ERROR("func_get_info_sim_contact_item_id() fail, da_ret[%d]", da_ret);
1416 *item_id = item_id_list;
1422 EXPORT_API sync_agent_da_return_e sync_agent_get_sim_contact_item(int content_type, int item_id, char **data)
1426 sync_agent_da_return_e da_ret = SYNC_AGENT_DA_SUCCESS;
1428 plugin_get_info_sim_contact_item_cb func_get_info_sim_contact_item = plugin_get_function_get_info_sim_contact_item(content_type);
1429 retvm_if(func_get_info_sim_contact_item == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get func_get_info_sim_contact_item !!");
1431 char *item_data = NULL;
1432 da_ret = func_get_info_sim_contact_item(item_id, &item_data);
1433 if (da_ret != SYNC_AGENT_DA_SUCCESS) {
1434 _DEBUG_ERROR("func_get_info_sim_contact_item() fail, da_ret[%d]", da_ret);
1442 EXPORT_API sync_agent_da_return_e sync_agent_add_sim_contact_item(int content_type, int sim_addressbook_id, int **item_id, char *data)
1446 sync_agent_da_return_e da_ret = SYNC_AGENT_DA_SUCCESS;
1448 plugin_add_sim_contact_item_cb func_add_sim_contact_item = plugin_get_function_add_sim_contact_item(content_type);
1449 retvm_if(func_add_sim_contact_item == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get func_add_sim_contact_item !!");
1451 int *item_id_tmp = NULL;
1452 da_ret = func_add_sim_contact_item(sim_addressbook_id, &item_id_tmp, data);
1453 if (da_ret != SYNC_AGENT_DA_SUCCESS) {
1454 _DEBUG_ERROR("func_add_sim_contact_item() fail, da_ret[%d]", da_ret);
1457 *item_id = item_id_tmp;
1463 EXPORT_API sync_agent_da_return_e sync_agent_write_sim_contact_item(int content_type, int item_id, char *data)
1467 sync_agent_da_return_e da_ret = SYNC_AGENT_DA_SUCCESS;
1469 plugin_write_sim_contact_item_cb func_write_sim_contact_item = plugin_get_function_write_sim_contact_item(content_type);
1470 retvm_if(func_write_sim_contact_item == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get func_write_sim_contact_item !!");
1472 da_ret = func_write_sim_contact_item(item_id, data);
1473 if (da_ret != SYNC_AGENT_DA_SUCCESS) {
1474 _DEBUG_ERROR("func_write_sim_contact_item() fail, da_ret[%d]", da_ret);
1481 EXPORT_API sync_agent_da_return_e sync_agent_delete_sim_contact_item(int content_type, int item_id)
1485 sync_agent_da_return_e da_ret = SYNC_AGENT_DA_SUCCESS;
1487 plugin_delete_sim_contact_item_cb func_delete_sim_contact_item = plugin_get_function_delete_sim_contact_item(content_type);
1488 retvm_if(func_delete_sim_contact_item == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get func_delete_sim_contact_item !!");
1490 da_ret = func_delete_sim_contact_item(item_id);
1491 if (da_ret != SYNC_AGENT_DA_SUCCESS) {
1492 _DEBUG_ERROR("func_delete_sim_contact_item() fail, da_ret[%d]", da_ret);