Remove hardcoded path for multiuser support
[platform/core/system/sync-agent.git] / src / fw-plugins / common-public / call-log / src / plugin_interface.c
1 /*
2  * sync-agent
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
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
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  */
17
18 #include <glib.h>
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <contacts.h>
23 #include <time.h>
24
25 /* for log */
26 #include "utility/sync_util.h"
27
28 #include "plugin/data_connector_interface.h"
29
30 #include <tzplatform_config.h>
31
32 #define BACKUP_PATH tzplatform_mkpath(TZ_USER_CONTENT,"Downloads/Kies/.BnR/CallLog.bk")
33
34 #ifndef EXPORT_API
35 #define EXPORT_API __attribute__ ((visibility("default")))
36 #endif
37
38 #ifndef SYNC_AGENT_LOG
39 #undef LOG_TAG
40 #define LOG_TAG "PLUGIN_DA_CALL_LOG"
41 #endif
42
43 #define CALLOG_SYNC_PERIODIC 60*60*24*8 /*8days */
44
45 /* call log Internal Struct */
46 typedef struct {
47         int v_type:16;
48         bool embedded;
49         bool img_loaded;
50         int id;
51         int num_type;
52         char *first;
53         char *last;
54         char *display;
55         const char *number;
56         char *img_path;
57         int log_time;
58         int log_type;
59         int extra_data1;        /* duration, message_id */
60         const char *extra_data2;        /*short message */
61         int related_id;         /* contact id */
62 } dc_plog_list_s;
63
64 static void _del_all_calllogs(void);
65
66 static sync_agent_da_return_e _convert_service_error_to_common_error(contacts_error_e err);
67
68 EXPORT_API sync_agent_da_return_e sync_agent_plugin_open_service(void)
69 {
70         _EXTERN_FUNC_ENTER;
71
72         sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
73         contacts_error_e err = contacts_connect2();
74         if (err != CONTACTS_ERROR_NONE) {
75                 _DEBUG_ERROR("[da_calllog_plugIn] in calllog Fail!\n");
76                 ret = _convert_service_error_to_common_error(err);
77         } else {
78                 _DEBUG_INFO("[da_calllog_plugIn] in calllog Success!\n");
79         }
80
81         _EXTERN_FUNC_EXIT;
82
83         return ret;
84 }
85
86 EXPORT_API sync_agent_da_return_e sync_agent_plugin_close_service(void)
87 {
88         _EXTERN_FUNC_ENTER;
89
90         sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
91         contacts_error_e err = contacts_disconnect2();
92         if (err != CONTACTS_ERROR_NONE) {
93                 _DEBUG_ERROR("[da_calllog_plugIn] in calllog Fail!\n");
94                 ret = _convert_service_error_to_common_error(err);
95         } else {
96                 _DEBUG_INFO("[da_calllog_plugIn] in calllog Success!\n");
97         }
98
99         _EXTERN_FUNC_EXIT;
100
101         return ret;
102 }
103
104 EXPORT_API int *sync_agent_plugin_get_account_id_list(int *count)
105 {
106         _EXTERN_FUNC_ENTER;
107
108         _DEBUG_INFO("[da_calllog_plugIn] calllog Start !!");
109         int *account_id_list = (int *)calloc(1, sizeof(int));
110         if (account_id_list == NULL) {
111                 _DEBUG_ERROR("CALLOC failed !!!");
112                 return NULL;
113         }
114         account_id_list[0] = -1;
115         *count = 1;
116
117         _DEBUG_INFO("[da_calllog_plugIn] calllog End !!");
118
119         _EXTERN_FUNC_EXIT;
120
121         return account_id_list;
122 }
123
124 EXPORT_API sync_agent_da_return_e sync_agent_plugin_backup_service_items_to_file(int account_ID, char **file_path)
125 {
126         _EXTERN_FUNC_ENTER;
127
128 //      sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
129 //      FILE *file = 0;
130 //      int cur_size = 0;
131 //      CTSiter *iter = 0;
132 //      CTSvalue *plog = 0;     /*plog_list */
133 //
134 //      file = fopen(BACKUP_PATH, "w");
135 //      if (file == NULL) {
136 //              _DEBUG_INFO("[da_call_log_plugIn] fopen fail\n");
137 //              return SYNC_AGENT_DA_ERRORS;
138 //      }
139 //
140 //      contacts_svc_get_list(CTS_LIST_ALL_PLOG, &iter);
141 //      while (CTS_SUCCESS == contacts_svc_iter_next(iter)) {
142 //              dc_plog_list_s plog_list;
143 //
144 //              /* get call log */
145 //              plog = contacts_svc_iter_get_info(iter);
146 //              if (plog == NULL)
147 //                      continue;
148 //
149 //              plog_list.number = contacts_svc_value_get_str(plog, CTS_LIST_PLOG_NUMBER_STR);
150 //              plog_list.log_time = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_LOG_TIME_INT);
151 //              plog_list.log_type = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_LOG_TYPE_INT);
152 //              plog_list.extra_data1 = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_DURATION_INT);
153 //              plog_list.extra_data2 = contacts_svc_value_get_str(plog, CTS_LIST_PLOG_SHORTMSG_STR);
154 //              plog_list.related_id = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_RELATED_ID_INT);
155 //
156 //              _DEBUG_INFO("plog_list.number : %s\n", plog_list.number);
157 //              _DEBUG_INFO("plog_list.related_id : %d\n", plog_list.related_id);
158 //              _DEBUG_INFO("plog_list.log_time : %d\n", plog_list.log_time);
159 //              _DEBUG_INFO("plog_list.log_type : %d\n", plog_list.log_type);
160 //              _DEBUG_INFO("plog_list.extra_data1 : %d\n", plog_list.extra_data1);
161 //              _DEBUG_INFO("plog_list.extra_data2 : %s\n", plog_list.extra_data2);
162 //
163 //              /* save call log : to file text */
164 //              cur_size = fprintf(file, "%s %d %d %d %d %s ", plog_list.number, plog_list.related_id, plog_list.log_time, plog_list.log_type, plog_list.extra_data1, plog_list.extra_data2);
165 //
166 //              if (cur_size == -1) {
167 //                      _DEBUG_INFO("[da_call_log_plugIn] fprintf fail\n");
168 //                      ret = SYNC_AGENT_DA_ERRORS;
169 //                      goto DACI_FINISH;
170 //              }
171 //
172 //              /* memory free */
173 //              if (plog != NULL) {
174 //                      contacts_svc_value_free(plog);
175 //                      plog = 0;
176 //              }
177 //      }
178 //
179 //DACI_FINISH:
180 //
181 //      if (file != NULL) {
182 //              fclose(file);
183 //              file = 0;
184 //      }
185 //
186 //      /* memory free */
187 //      if (plog != NULL) {
188 //              contacts_svc_value_free(plog);
189 //              plog = 0;
190 //      }
191 //
192 //      if (iter != NULL) {
193 //              contacts_svc_iter_remove(iter);
194 //              iter = 0;
195 //      }
196 //
197 //      *file_path = strdup(BACKUP_PATH);
198
199         sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
200         FILE *file = 0;
201         int cur_size = 0;
202
203         contacts_error_e err = CONTACTS_ERROR_NONE;
204         contacts_list_h list = NULL;
205
206         char *number = NULL;
207         int related_id;
208         int log_time;
209         int log_type;
210         int duration;
211         char *short_msg = NULL;
212
213         file = fopen(BACKUP_PATH, "w");
214         if (file == NULL) {
215                 _DEBUG_ERROR("[da_call_log_plugIn] fopen fail\n");
216                 return SYNC_AGENT_DA_ERRORS;
217         }
218
219         err = contacts_db_get_all_records(_contacts_phone_log._uri, 0, 0, &list);
220         if (err != CONTACTS_ERROR_NONE) {
221                 _DEBUG_ERROR("[da_call_log_plugIn] contacts_db_get_all_records fail\n");
222                 ret = _convert_service_error_to_common_error(err);
223                 goto DACI_FINISH;
224         }
225
226         err = contacts_list_first(list);
227         while (err == CONTACTS_ERROR_NONE) {
228                 contacts_record_h record = NULL;
229
230                 /* get call log */
231                 err = contacts_list_get_current_record_p(list, &record);
232                 if (err != CONTACTS_ERROR_NONE) {
233                         _DEBUG_ERROR("[da_call_log_plugIn] contacts_list_get_current_record_p fail\n");
234                         continue;
235                 }
236
237                 contacts_record_get_str_p(record, _contacts_phone_log.address, &number);
238                 contacts_record_get_int(record, _contacts_phone_log.person_id, &related_id);
239                 contacts_record_get_int(record, _contacts_phone_log.log_time, &log_time);
240                 contacts_record_get_int(record, _contacts_phone_log.log_type, &log_type);
241                 contacts_record_get_int(record, _contacts_phone_log.extra_data1, &duration);
242                 contacts_record_get_str_p(record, _contacts_phone_log.extra_data2, &short_msg);
243
244                 _DEBUG_INFO("plog_list.number : %s\n", number);
245                 _DEBUG_INFO("plog_list.related_id : %d\n", related_id);
246                 _DEBUG_INFO("plog_list.log_time : %d\n", log_time);
247                 _DEBUG_INFO("plog_list.log_type : %d\n", log_type);
248                 _DEBUG_INFO("plog_list.extra_data1 : %d\n", duration);
249                 _DEBUG_INFO("plog_list.extra_data2 : %s\n", short_msg);
250
251                 /* save call log : to file text */
252                 cur_size = fprintf(file, "%s %d %d %d %d %s ", number, related_id, log_time, log_type, duration, short_msg);
253                 if (cur_size == -1) {
254                         _DEBUG_ERROR("[da_call_log_plugIn] fprintf fail\n");
255                         ret = SYNC_AGENT_DA_ERRORS;
256                         goto DACI_FINISH;
257                 }
258
259                 err = contacts_list_next(list);
260         }
261
262  DACI_FINISH:
263
264         if (file != NULL) {
265                 fclose(file);
266                 file = 0;
267         }
268
269         contacts_list_destroy(list, true);
270
271         *file_path = strdup(BACKUP_PATH);
272
273         _EXTERN_FUNC_EXIT;
274
275         return ret;
276 }
277
278 EXPORT_API sync_agent_da_return_e sync_agent_plugin_restore_service_items_from_file(int account_ID, const char *file_path)
279 {
280         _EXTERN_FUNC_ENTER;
281
282         retvm_if(file_path == NULL, SYNC_AGENT_DA_ERRORS, "[da_call_log_plugIn] file_path is NULL. FAIL !!!");
283
284         sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
285         int err = 0;
286         int cur_size = 0;
287         int contact_id = 0;
288         FILE *file = NULL;
289         contacts_record_h record = NULL;
290
291         /* open call log : from file text */
292         file = fopen(BACKUP_PATH, "r");
293         if (file == NULL) {
294                 _DEBUG_ERROR("[da_call_log_plugIn] fopen() fail");
295                 return SYNC_AGENT_DA_ERRORS;
296         }
297
298         /* delete call log from contact service database */
299         _del_all_calllogs();
300
301         while (1) {
302                 dc_plog_list_s plog_list;
303                 char temp_number[100] = { 0 };
304                 char temp_extra_data2[1024] = { 0 };
305
306                 /* read call log : from file text */
307                 cur_size = fscanf(file, "%100s %d %d %d %d %1024s ", temp_number, &(plog_list.related_id), &(plog_list.log_time), &(plog_list.log_type), &(plog_list.extra_data1), temp_extra_data2);
308                 if (cur_size == -1) {
309                         _DEBUG_INFO("[da_call_log_plugIn] The end of file");
310                         ret = SYNC_AGENT_DA_SUCCESS;
311                         goto DACI_FINISH;
312                 }
313
314                 err = contacts_record_create(_contacts_phone_log._uri, &record);
315                 if (err != CONTACTS_ERROR_NONE) {
316                         _DEBUG_ERROR("[da_call_log_plugIn] contacts_record_create() Fail, err[%d]", err);
317                         ret = _convert_service_error_to_common_error(err);
318                         goto DACI_FINISH;
319                 }
320
321                 /* add call log to contact service database */
322                 contacts_record_set_str(record, _contacts_phone_log.address, temp_number);
323                 contacts_record_set_int(record, _contacts_phone_log.person_id, plog_list.related_id);
324                 contacts_record_set_int(record, _contacts_phone_log.log_time, plog_list.log_time);
325                 contacts_record_set_int(record, _contacts_phone_log.log_type, plog_list.log_type);
326                 contacts_record_set_int(record, _contacts_phone_log.extra_data1, plog_list.extra_data1);
327                 contacts_record_set_str(record, _contacts_phone_log.extra_data2, temp_extra_data2);
328
329                 _DEBUG_INFO("[da_contact_plugIn] plog_list.number : [%s]", temp_number);
330                 _DEBUG_INFO("[da_contact_plugIn] plog_list.related_id : [%d]", plog_list.related_id);
331                 _DEBUG_INFO("[da_contact_plugIn] plog_list.log_time : [%d]", plog_list.log_time);
332                 _DEBUG_INFO("[da_contact_plugIn] plog_list.log_type : [%d]", plog_list.log_type);
333                 _DEBUG_INFO("[da_contact_plugIn] plog_list.extra_data1 : [%d]", plog_list.extra_data1);
334                 _DEBUG_INFO("[da_contact_plugIn] plog_list.extra_data2 : [%s]", temp_extra_data2);
335
336                 err = contacts_db_insert_record(record, &contact_id);
337                 if (err != CONTACTS_ERROR_NONE) {
338                         _DEBUG_ERROR("[da_contact_plugIn] contacts_db_insert_record() Fail, err[%d]", err);
339                         ret = _convert_service_error_to_common_error(err);
340                         goto DACI_FINISH;
341                 } else {
342                         _DEBUG_INFO("[da_contact_plugIn] contacts_db_insert_record() Success, contact_id = [%d]", contact_id);
343                 }
344         }
345
346 DACI_FINISH:
347         _DEBUG_INFO("[da_contact_plugIn] DACI_FINISH");
348
349         contacts_record_destroy(record, true);
350
351         if (file != NULL) {
352                 fclose(file);
353                 file = NULL;
354         }
355
356         _EXTERN_FUNC_EXIT;
357         return ret;
358 }
359
360 EXPORT_API sync_agent_da_return_e sync_agent_plugin_get_item(int account_id, char *folder_id, char *item_id, void **data)
361 {
362         _EXTERN_FUNC_ENTER;
363
364         retvm_if(item_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "item_id is NULL. FAIL !!!");
365
366 //      sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
367 //      cts_error err = 0;
368 //      CTSvalue *item = 0;
369 //
370 //      /* get item */
371 //      int colllog_id = atoi(item_id);
372 //      _DEBUG_INFO("[da_call-log_plugIn] colllog_id : %d\n", colllog_id);
373 //      err = contacts_svc_get_phonelog(colllog_id, &item);
374 //      if (err < CTS_SUCCESS) {
375 //              _DEBUG_INFO("[da_call-log_plugIn] contacts_svc_get_phonelog() Fail!\n");
376 //              ret = _convert_service_error_to_common_error(err);
377 //              *data = 0;
378 //      } else {
379 //              _DEBUG_INFO("[da_call-log_plugIn] contacts_svc_get_phonelog() Success!\n");
380 //              *data = (void *)item;
381 //      }
382
383         sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
384         int err = 0;
385         contacts_record_h record = NULL;
386
387         /* get item */
388         int colllog_id = atoi(item_id);
389         _DEBUG_INFO("[da_call-log_plugIn] colllog_id : %d\n", colllog_id);
390         err = contacts_db_get_record(_contacts_phone_log._uri, colllog_id, &record);
391         if (err != CONTACTS_ERROR_NONE) {
392                 _DEBUG_ERROR("[da_call-log_plugIn] contacts_db_get_record() Fail!\n");
393                 ret = _convert_service_error_to_common_error(err);
394                 *data = 0;
395         } else {
396                 _DEBUG_INFO("[da_call-log_plugIn] contacts_db_get_record() Success!\n");
397                 *data = (void *)record;
398         }
399
400         _EXTERN_FUNC_EXIT;
401
402         return ret;
403 }
404
405 static void _del_all_calllogs(void)
406 {
407         _INNER_FUNC_ENTER;
408
409         contacts_error_e err = CONTACTS_ERROR_NONE;
410         contacts_list_h list = NULL;
411
412         err = contacts_db_get_all_records(_contacts_phone_log._uri, 0, 0, &list);
413         if (err != CONTACTS_ERROR_NONE) {
414                 _DEBUG_ERROR("[da_call_log_plugIn] contacts_db_get_all_records() fail, err[%d]", err);
415                 err = contacts_list_destroy(list, true);
416                 if (err != CONTACTS_ERROR_NONE) {
417                         _DEBUG_ERROR("[da_call_log_plugIn] contacts_list_destroy() fail, err[%d]", err);
418                 }
419                 return;
420         }
421
422         err = contacts_list_first(list);
423         while (err == CONTACTS_ERROR_NONE) {
424                 contacts_record_h record = NULL;
425
426                 /* get call log */
427                 err = contacts_list_get_current_record_p(list, &record);
428                 if (err != CONTACTS_ERROR_NONE) {
429                         _DEBUG_ERROR("[da_call_log_plugIn] contacts_list_get_current_record_p() fail, err[%d]", err);
430                         continue;
431                 }
432
433                 int id;
434                 err = contacts_record_get_int(record, _contacts_phone_log.id, &id);
435                 if (err != CONTACTS_ERROR_NONE) {
436                         _DEBUG_ERROR("[da_call_log_plugIn] contacts_record_get_int() fail, err[%d]", err);
437                         continue;
438                 }
439
440                 _DEBUG_TRACE("[da_call_log_plugIn] id : [%d]", id);
441
442                 /* delete call log */
443                 contacts_db_delete_record(_contacts_phone_log._uri, id);
444
445                 err = contacts_list_next(list);
446         }
447
448         /* memory free */
449         err = contacts_list_destroy(list, true);
450         if (err != CONTACTS_ERROR_NONE) {
451                 _DEBUG_ERROR("[da_call_log_plugIn] contacts_list_destroy() fail, err[%d]", err);
452         }
453
454         _INNER_FUNC_EXIT;
455 }
456
457 EXPORT_API sync_agent_plugin_item_node_s *sync_agent_plugin_get_changed_item_for_folder_add(int account_id, const char *folder_id, int changepoint, int *changeCount)
458 {
459         _EXTERN_FUNC_ENTER;
460
461         _DEBUG_INFO("[da_call-log_plugIn] account_id : [%d]", account_id);
462         _DEBUG_INFO("[da_call-log_plugIn] folder_id : [%s]", folder_id);
463         _DEBUG_INFO("[da_call-log_plugIn] changepoint : [%d]", changepoint);
464
465         sync_agent_plugin_item_node_s *root_ptr = 0;
466         sync_agent_plugin_item_node_s *cursor_ptr = 0;
467         int chagned_count = 0;
468         int current_time = time(NULL);
469
470         char *calllog_id_str = NULL;
471
472         contacts_error_e err = CONTACTS_ERROR_NONE;
473         contacts_list_h list = NULL;
474
475         err = contacts_db_get_all_records(_contacts_phone_log._uri, 0, 0, &list);
476         if (err != CONTACTS_ERROR_NONE) {
477                 _DEBUG_ERROR("[da_call_log_plugIn] contacts_db_get_all_records() fail, err[%d]", err);
478                 err = contacts_list_destroy(list, true);
479                 if (err != CONTACTS_ERROR_NONE) {
480                         _DEBUG_ERROR("[da_call_log_plugIn] contacts_list_destroy() fail, err[%d]", err);
481                 }
482                 return NULL;
483         }
484
485         err = contacts_list_first(list);
486         while (err == CONTACTS_ERROR_NONE) {
487                 contacts_record_h record = NULL;
488
489                 /* get call log */
490                 err = contacts_list_get_current_record_p(list, &record);
491                 if (err != CONTACTS_ERROR_NONE) {
492                         _DEBUG_ERROR("[da_call_log_plugIn] contacts_list_get_current_record_p() fail, err[%d]", err);
493                         continue;
494                 }
495
496                 /*check that item is within 7 days before since at the time */
497                 int log_time;
498                 contacts_record_get_int(record, _contacts_phone_log.log_time, &log_time);
499
500                 if (current_time - CALLOG_SYNC_PERIODIC <= log_time) {
501                         int calllog_id;
502                         contacts_record_get_int(record, _contacts_phone_log.id, &calllog_id);
503
504                         calllog_id_str = g_strdup_printf("%d", calllog_id);
505                         _DEBUG_INFO("[da_call_log_plugIn] Calllog_id_str = [%s]", calllog_id_str);
506
507                         if (root_ptr == NULL) {
508                                 root_ptr = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
509                                 if (root_ptr == NULL) {
510                                         _DEBUG_ERROR("[da_call_log_plugIn] Calloc failed, root_ptr is NULL");
511                                         err = contacts_list_destroy(list, true);
512                                         if (err != CONTACTS_ERROR_NONE) {
513                                                 _DEBUG_ERROR("[da_call_log_plugIn] contacts_list_destroy() fail, err[%d]", err);
514                                         }
515                                         return NULL;
516                                 }
517                                 root_ptr->item_id = calllog_id_str;
518                                 root_ptr->next = 0;
519                                 cursor_ptr = root_ptr;
520                         } else {
521                                 cursor_ptr->next = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
522                                 if (cursor_ptr->next == NULL) {
523                                         _DEBUG_ERROR("[da_call_log_plugIn] Calloc failed, cursor_ptr->next is NULL");
524                                         err = contacts_list_destroy(list, true);
525                                         if (err != CONTACTS_ERROR_NONE) {
526                                                 _DEBUG_ERROR("[da_call_log_plugIn] contacts_list_destroy() fail, err[%d]", err);
527                                         }
528                                         if (root_ptr != NULL) {
529                                                 free(root_ptr);
530                                                 root_ptr = NULL;
531                                         }
532                                         return NULL;
533                                 }
534                                 cursor_ptr->next->item_id = calllog_id_str;
535                                 cursor_ptr->next->next = 0;
536                                 cursor_ptr = cursor_ptr->next;
537                         }
538
539                         chagned_count++;
540                 }
541
542                 err = contacts_list_next(list);
543         }
544
545         err = contacts_list_destroy(list, true);
546         if (err != CONTACTS_ERROR_NONE) {
547                 _DEBUG_ERROR("[da_call_log_plugIn] contacts_list_destroy() fail, err[%d]", err);
548         }
549
550         *changeCount = chagned_count;
551
552         _EXTERN_FUNC_EXIT;
553         return root_ptr;
554 }
555
556 EXPORT_API sync_agent_plugin_item_node_s *sync_agent_plugin_get_changed_item_for_folder_update(int account_id, const char *folder_id, int change_point, int *change_count)
557 {
558         _EXTERN_FUNC_ENTER;
559
560         _DEBUG_INFO("[da_call-log_plugIn] account_id : %d\n", account_id);
561         _DEBUG_INFO("[da_call-log_plugIn] folder_id : %s\n", folder_id);
562         _DEBUG_INFO("[da_call-log_plugIn] changepoint : %d\n", change_point);
563
564         *change_count = 0;
565
566         _EXTERN_FUNC_EXIT;
567
568         return NULL;
569 }
570
571 EXPORT_API sync_agent_plugin_item_node_s *sync_agent_plugin_get_changed_item_for_folder_delete(int account_id, const char *folder_id, int change_point, int *change_count)
572 {
573         _EXTERN_FUNC_ENTER;
574
575         _DEBUG_INFO("\n[da_contact_plugIn] account_id : %d\n", account_id);
576         _DEBUG_INFO("[da_contact_plugIn] folder_id : %s\n", folder_id);
577         _DEBUG_INFO("[da_contact_plugIn] changepoint : %d\n", change_point);
578
579         *change_count = 0;
580
581         _EXTERN_FUNC_EXIT;
582
583         return NULL;
584 }
585
586 static sync_agent_da_return_e _convert_service_error_to_common_error(contacts_error_e err)
587 {
588         _INNER_FUNC_ENTER;
589
590         sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
591         _DEBUG_TRACE("[da_contact_plugIn] Error Code : %d\n", err);
592
593         switch (err) {
594         case CONTACTS_ERROR_NONE:
595                 ret = SYNC_AGENT_DA_SUCCESS;
596                 break;
597         case CONTACTS_ERROR_OUT_OF_MEMORY:
598                 ret = SYNC_AGENT_DA_ERR_MEMORY_FULL;
599                 break;
600         case CONTACTS_ERROR_INVALID_PARAMETER:
601                 ret = SYNC_AGENT_DA_ERR_INVALID_PARAMETER;
602                 break;
603         case CONTACTS_ERROR_NO_DATA:
604                 ret = SYNC_AGENT_DA_ERR_NO_DATA;
605                 break;
606         case CONTACTS_ERROR_DB:
607                 ret = SYNC_AGENT_DA_ERR_SERVICE_DB;
608                 break;
609         case CONTACTS_ERROR_IPC:
610                 ret = SYNC_AGENT_DA_ERR_SERVICE_IPC;
611                 break;
612         default:
613                 ret = SYNC_AGENT_DA_ERRORS;
614                 break;
615         }
616
617         _INNER_FUNC_EXIT;
618
619         return ret;
620 }
621
622 EXPORT_API int sync_agent_plugin_get_last_change_point(void)
623 {
624         _EXTERN_FUNC_ENTER;
625
626 //      contacts_svc_begin_trans();
627 //      int contact_version = contacts_svc_end_trans(1);
628
629         int contact_version;
630         contacts_db_get_current_version(&contact_version);
631
632         _EXTERN_FUNC_EXIT;
633
634         return contact_version;
635 }