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