dts_fail(API_NAME_SYNC_START_UP);
}
- event_err = sync_agent_set_noti_callback(NOTI_NUM, _noti_cb, NULL);
- if (event_err != SYNC_AGENT_EVENT_SUCCESS) {
- dts_message(API_NAME_SYNC_START_UP, "sync_agent_set_noti_callback : %d", event_err);
+ sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+ ds_err = sync_agent_ds_set_noti_callback(NOTI_NUM, _noti_cb, NULL);
+ if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+ dts_message(API_NAME_SYNC_START_UP, "sync_agent_ds_set_noti_callback : %d", ds_err);
dts_fail(API_NAME_SYNC_START_UP);
}
static void utc_sync_agent_framework_sync_agent_set_noti_callback_p(void)
{
- char *api_name = API_NAME_SYNC_AGENT_SET_NOTI_CALLBACK;
- sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+ char *api_name = SYNC_AGENT_EVENT_SUCCESS;
+ sync_agent_event_error_e event_err = SYNC_AGENT_DS_SUCCESS;
event_err = sync_agent_set_noti_callback(NOTI_NUM, _noti_cb, NULL);
if (event_err == SYNC_AGENT_EVENT_SUCCESS) {
dts_fail(api_name);
}
- ds_err = sync_agent_ds_set_profile_name(profile_h, profile_dir_name, profile_name);
+ ds_err = sync_agent_ds_set_profile_dir_name(profile_h, profile_dir_name);
+ if (ds_err == SYNC_AGENT_DS_SUCCESS) {
+ dts_pass(api_name);
+ } else {
+ dts_message(api_name, "sync_agent_ds_set_profile_dir_name : %d", ds_err);
+ dts_fail(api_name);
+ }
+
+ ds_err = sync_agent_ds_set_profile_name(profile_h, profile_name);
if (ds_err == SYNC_AGENT_DS_SUCCESS) {
dts_pass(api_name);
} else {
sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
ds_profile_h profile_h = NULL;
- char *sync_mode = "Periodic";
- char *sync_type = "Update both";
- char *interval = "1 hour";
+ sync_agent_ds_sync_mode_e sync_mode = SYNC_AGENT_SYNC_MODE_PERIODIC;
+ sync_agent_ds_sync_type_e sync_type = SYNC_AGENT_SYNC_TYPE_UPDATE_BOTH;
+ sync_agent_ds_sync_interval_e interval = SYNC_AGENT_SYNC_INTERVAL_1_HOUR;
ds_err = sync_agent_ds_create_profile_info(&profile_h);
if (ds_err != SYNC_AGENT_DS_SUCCESS) {
ds_profile_h profile_h = NULL;
sync_agent_ds_service_type_e service_type = SYNC_AGENT_CONTACT;
int enabled = 1;
- char *src_uri = "Contacts";
+ sync_agent_ds_src_uri_e src_uri = SYNC_AGENT_SRC_URI_CONTACT;
char *tgt_uri = "card";
char *id = "id";
char *password = "password";
char *id = "id";
char *password = "password";
- char *sync_mode = "Periodic";
- char *sync_type = "Update both";
- char *interval = "1 hour";
+ sync_agent_ds_sync_mode_e sync_mode = SYNC_AGENT_SYNC_MODE_PERIODIC;
+ sync_agent_ds_sync_type_e sync_type = SYNC_AGENT_SYNC_TYPE_UPDATE_BOTH;
+ sync_agent_ds_sync_interval_e interval = SYNC_AGENT_SYNC_INTERVAL_1_HOUR;
sync_agent_ds_service_type_e service_type = SYNC_AGENT_CONTACT;
int enabled = 1;
- char *src_uri = "Contacts";
+ sync_agent_ds_src_uri_e src_uri = SYNC_AGENT_SRC_URI_CONTACT;
char *tgt_uri = "card";
int profile_id = 0;
dts_fail(api_name);
}
- ds_err = sync_agent_ds_set_profile_name(profile_h, profile_dir_name, profile_name);
+ ds_err = sync_agent_ds_set_profile_dir_name(profile_h, profile_dir_name);
+ if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+ dts_message(api_name, "sync_agent_ds_set_profile_dir_name : %d", ds_err);
+ dts_fail(api_name);
+ }
+
+ ds_err = sync_agent_ds_set_profile_name(profile_h, profile_name);
if (ds_err != SYNC_AGENT_DS_SUCCESS) {
dts_message(api_name, "sync_agent_ds_set_profile_name : %d", ds_err);
dts_fail(api_name);
char *id = "id";
char *password = "password";
- char *sync_mode = "Periodic";
- char *sync_type = "Update both";
- char *interval = "1 hour";
+ sync_agent_ds_sync_mode_e sync_mode = SYNC_AGENT_SYNC_MODE_PERIODIC;
+ sync_agent_ds_sync_type_e sync_type = SYNC_AGENT_SYNC_TYPE_UPDATE_BOTH;
+ sync_agent_ds_sync_interval_e interval = SYNC_AGENT_SYNC_INTERVAL_1_HOUR;
sync_agent_ds_service_type_e service_type = SYNC_AGENT_CONTACT;
int enabled = 1;
- char *src_uri = "Contacts";
+ sync_agent_ds_src_uri_e src_uri = SYNC_AGENT_SRC_URI_CONTACT;
char *tgt_uri = "card";
ds_err = sync_agent_ds_create_profile_info(&profile_h);
dts_fail(api_name);
}
- ds_err = sync_agent_ds_set_profile_name(profile_h, profile_dir_name, profile_name);
+ ds_err = sync_agent_ds_set_profile_dir_name(profile_h, profile_dir_name);
+ if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+ dts_message(api_name, "sync_agent_ds_set_profile_dir_name : %d", ds_err);
+ dts_fail(api_name);
+ }
+
+ ds_err = sync_agent_ds_set_profile_name(profile_h, profile_name);
if (ds_err != SYNC_AGENT_DS_SUCCESS) {
dts_message(api_name, "sync_agent_ds_set_profile_name : %d", ds_err);
dts_fail(api_name);
dts_fail(api_name);
}
- ds_err = sync_agent_ds_set_profile_name(profile_h, profileDirName, NULL);
+ ds_err = sync_agent_ds_set_profile_dir_name(profile_h, profileDirName);
if (ds_err != SYNC_AGENT_DS_SUCCESS) {
- dts_message(api_name, "sync_agent_ds_set_profile_name : %d", ds_err);
+ dts_message(api_name, "sync_agent_ds_set_profile_dir_name : %d", ds_err);
dts_fail(api_name);
}
dts_fail(api_name);
}
- ds_err = sync_agent_ds_set_profile_name(profile_h, profileDirName, NULL);
+ ds_err = sync_agent_ds_set_profile_dir_name(profile_h, profileDirName);
if (ds_err != SYNC_AGENT_DS_SUCCESS) {
- dts_message(api_name, "sync_agent_ds_set_profile_name : %d", ds_err);
+ dts_message(api_name, "sync_agent_ds_set_profile_dir_name : %d", ds_err);
dts_fail(api_name);
}
dts_fail(api_name);
}
- ds_err = sync_agent_ds_set_profile_name(profile_h, profileDirName, NULL);
+ ds_err = sync_agent_ds_set_profile_dir_name(profile_h, profileDirName);
if (ds_err != SYNC_AGENT_DS_SUCCESS) {
- dts_message(api_name, "sync_agent_ds_set_profile_name : %d", ds_err);
+ dts_message(api_name, "sync_agent_ds_set_profile_dir_name : %d", ds_err);
dts_fail(api_name);
}
-libsync-agent-framework (0.1.8) unstable; urgency=low
+sync-agent (0.1.80) unstable; urgency=low
- * 1. prevent defect patch. - resource free.
+ * 1. when profile info gets, return value changed.
* Git: framework/system/sync-agent
- * Tag: sync-agent_0.1.8
+ * Tag: sync-agent_0.1.80
- -- Juhaki Park <juhaki.park@samsung.com> Thu, 24 Jan 2013 11:12:10 +0900
+ -- sanghyuk.ko <sanghyuk.ko@samsung.com> Fri, 08 Mar 2013 09:39:45 +0900
-libsync-agent-framework (0.1.7) unstable; urgency=low
+sync-agent (0.1.79) precise; urgency=low
- * 1. license , prevent defect patch.
+ * 1. sync_interval enum type added
* Git: framework/system/sync-agent
- * Tag: sync-agent_0.1.7
+ * Tag: sync-agent_0.1.79
- -- Juhaki Park <juhaki.park@samsung.com> Mon, 21 Jan 2013 21:55:10 +0900
+ -- sanghyukko <sanghyuk.ko@samsung.com> Thu, 28 Feb 2013 17:09:45 +0900
-libsync-agent-framework (0.1.6) unstable; urgency=low
+sync-agent (0.1.78) unstable; urgency=low
- * 1. account api patch.
+ * 1. profile_dir_name create automatically.
+ * 2. sync_mode, sync_type src_uri enum type added
* Git: framework/system/sync-agent
- * Tag: sync-agent_0.1.6
+ * Tag: sync-agent_0.1.78
- -- Juhaki Park <juhaki.park@samsung.com> Fri, 11 Jan 2013 14:15:10 +0900
+ -- sanghyukko <sanghyuk.ko@samsung.com> Tue, 26 Feb 2013 17:16:02 +0900
-libsync-agent-framework (0.1.5) unstable; urgency=low
+sync-agent (0.1.77) unstable; urgency=low
- * 1. Prevent defects fixed.
+ * 1. tizen_2.0 code merge
+ * 2. Private code merge
+ * 3. sync_agent patch for emulator
+ * 4. g_type_init add
+ * 5. oma-ds-client test_server_info change(orange)
* Git: framework/system/sync-agent
- * Tag: sync-agent_0.1.5
+ * Tag: sync-agent_0.1.77
+
+ -- sanghyukko <sanghyuk.ko@samsung.com> Thu, 21 Feb 2013 14:34:49 +0900
+
+sync-agent (0.1.76) unstable; urgency=low
+
+ * 1. oma-ds-agent-enabled file add.
+ * Git: magnolia/framework/system/sync-agent
+ * Tag: sync-agent_0.1.76
+
+ -- sanghyukko <sanghyuk.ko@samsung.com> Fri, 15 Feb 2013 23:28:08 +0900
+
+sync-agent (0.1.75) unstable; urgency=low
+
+ * 1. A vcalendar which has exdate schedule, child vcalendar creating and parsing
+ * 2. Adding UID / X-EXTYPE / EXDATE option
+ * Git: magnolia/framework/system/sync-agent
+ * Tag: sync-agent_0.1.75
+
+ -- WooJin Yun <suhoangel9@samsung.com> Fri, 15 Feb 2013 20:56:51 +0900
+
+sync-agent (0.1.74) unstable; urgency=low
+
+ * 1. appsync patch for power saving.
+ * 2. Task Sync
+ * 3. Get gcc version patch
+ * 4. Adjust Contact Bulk API(Create, Delete)
+ * 5. Build error fixed.
+ * 6. Adjust changed calendar-service's api.
+ * Git: magnolia/framework/system/sync-agent
+ * Tag: sync-agent_0.1.74
+
+ -- Sunbong Ha <sunbong.ha@samsung.com> Wed, 13 Feb 2013 12:13:03 +0900
+
+sync-agent (0.1.73) unstable; urgency=low
+
+ * 1. Fixed prevent issues (10EA)
+ * 2. Add task sync feature
+ * - Adding the image sync feature
+ * - Adding the export feature of an alarm data that created by user
+ * - VEVENT+VTODO : process change due to calendar svc changes apply
+ * - VEVENT+VTODO : batch_write API apply
+ * - VEVENT+VTODO : "all day" apply
+ * - VTODO : "alarm" apply
+ * - VTODO : "no due date" feature apply
+ * - VEVENT+VTODO : old api remove
+ * - VEVENT+VTODO : unlimited rrule data apply
+ * 3. Fixed fota bug
+ * - sync_agent_execute_dev_function patch for FOTA-flag set
+ * Git: magnolia/framework/system/sync-agent
+ * Tag: sync-agent_0.1.73
+
+ -- WooJin Yun <suhoangel9@samsung.com> Thu, 07 Feb 2013 20:29:36 +0900
+
+sync-agent (0.1.72) unstable; urgency=low
+
+ * 1. Add task sync feature
+ * - Creating files for task sync
+ * - Enabing the Task feature at calendar info
+ * - Apply task priority converting
+ * 2. Fixed prevent issues.(6EA)
+ * Git: magnolia/framework/system/sync-agent
+ * Tag: sync-agent_0.1.72
+
+ -- WooJin Yun <suhoangel9@samsung.com> Thu, 31 Jan 2013 19:07:47 +0900
+
+sync-agent (0.1.71) unstable; urgency=low
+
+ * 1. vcalendar 1.0 <-> 2.0 converting (alarm field)
+ * - apply for existing month value - 1
+ * 2. Disclaimer confirm interface added.
+ * 3. Message api related changes added.
+ * 4. FMM Ring my mobile feature added.
+ * 5. Fix prevent defects.
+ * 6. sync_agent_get_event_data_param API changed.
+ * - sync_agent_get_event_data_param_int
+ * - sync_agent_get_event_data_param_str
+ * Git: magnolia/framework/system/sync-agent
+ * Tag: sync-agent_0.1.71
+
+ -- WooJin Yun <suhoangel9@samsung.com> Fri, 25 Jan 2013 15:12:34 +0900
+
+sync-agent (0.1.70) unstable; urgency=low
+
+ * 1. vcalendar 1.0 <-> 2.0 converting (final)
+ * - apply icu library
+ * - alarm feature implementation
+ * - image import to Phone feature implementation
+ * - Galleray/Camera/S-Note image feature implementation
+ * 2. Check Profile handle validance / Array index for item_id is wrong.
+ * Git: magnolia/framework/system/sync-agent
+ * Tag: sync-agent_0.1.70
+
+ -- WooJin Yun <suhoangel9@samsung.com> Fri, 18 Jan 2013 19:06:07 +0900
+
+sync-agent (0.1.69) unstable; urgency=low
+
+ * 1. If not exist data. SYNC_AGENT_DM_MO_FAIL return. (oma-dm-agent BS patch)
+ * Git: magnolia/framework/system/sync-agent
+ * Tag: sync-agent_0.1.69
+
+ -- Juhaki Park <juhaki.park@samsung.com> Fri, 11 Jan 2013 19:24:16 +0900
+
+sync-agent (0.1.68) unstable; urgency=low
+
+ * 1. Fix Calllog Backup fail issue
+ * 2. vcalendar 1.0 <-> 2.0 converting (1st)
+ * - adding 'weekly repeat' feature
+ * 3. vcalendar 1.0 <-> 2.0 converting (2nd : not completed)
+ * - completion the 'repeat' feature (daily / weekly / monthly / yearly)
+ * Tag: sync-agent_0.1.68
+
+ -- WooJin Yun <suhoangel9@samsung.com> Thu, 10 Jan 2013 17:34:16 +0900
+
+sync-agent (0.1.67) unstable; urgency=low
+
+ * 1. Unnecessary build packages removed.
+ * 2. model info patch.
+ * 3. Kies Full test issue patch. - updated contact items are not loaded.
+ * 4. libaccount-svc changed api apply
+ * Tag: sync-agent_0.1.67
+
+ -- Juhaki Park <juhaki.park@samsung.com> Tue, 08 Jan 2012 16:22:40 +0900
+
+sync-agent (0.1.66) unstable; urgency=low
+
+ * 1. mobex/calendar/write fail issue fix.
+ * 2. ignore account else of local, eas and google.
+ * 3. sync_agent_deinit() implemented.
+ * 4. ignore account else of local, eas and google.
+ * 5. build error fix.
+ * 6. deinit bug fix.
+ * 7. changed - copyright modified.
+ * 8. copyright - copyright modified.
+ * 9. dlog log format unified.
+ * 10. indent : sync-agent
+ * 11. rsa - gcf naming patch.
+ * 12. doxygen file update
+ * 13. deleted contact items are not loaded.
+ * Tag: sync-agent_0.1.66
+
+ -- Juhaki Park <juhaki.park@samsung.com> Thu, 27 Dec 2012 19:45:40 +0900
+
+sync-agent (0.1.65) unstable; urgency=low
+
+ * 1. Fixes for Prevent defects (#10)
+ * 2. DTS TC codes added
+ * 3. dm client api
+ * - get profile praram
+ * - change interface naming
+ * 4. Bug fix : hide server info
+ * 5. Bug fix : user initiate on admin ui
+ * 5. Bug fix : add include "oma_dm_dmacc_control_api.h"
+ * 6. Socket-based noti mechanism removed
+ * 7. Bug fix : g_source_remove added when stop noti
+ * 8. Error num added to unlink() api log
+ * 9. Build error fix : #ifdef __cplusplus macro added
+ * 10. Fix connection fail issues.
+ * - change path from /opt/media to /opt/usr/media
+ * 11. Spec file update : Lincense info added
+ * Tag: sync-agent_0.1.65
+
+ -- WooJin Yun <suhoangel9@samsung.com> Thu, 20 Dec 2012 22:25:40 +0900
+
+sync-agent (0.1.64) unstable; urgency=low
+
+ * 1. Bug fix : P121208-0725
+ * - ignore facebook account
+ * Tag: sync-agent_0.1.64
+
+ -- Sunbong Ha <sunbong.ha@samsung.com> Fri, 14 Dec 2012 15:01:10 +0900
+
+sync-agent (0.1.63) unstable; urgency=low
+
+ * 1. Bug fix of om dm client
+ * 2. Doxygen update
+ * - Internal headers done.
+ * - Package detail description pages composed.
+ * 3. Bug fix : dm client noti api
+ * 4. Bug fix : remove dm acc
+ * - Delete runtime property
+ * - Delete framework proeprty
+ * 5. Fixes for Prevent defects.(#38)
+ * 6. Fix TC bug
+ * 7. Bug fix : delete mo tree
+ * - Modify delete mo tree
+ * - Add error handling
+ * 8. Bug fix : check pin validataion
+ * Tag: sync-agent_0.1.63
+
+ -- WooJin Yun <suhoangel9@samsung.com> Thu, 13 Dec 2012 14:31:18 +0900
+
+sync-agent (0.1.62) unstable; urgency=low
+
+ * 1. Additional pages added
+ * 2. External headers Doxygen completed
+ * 3. Apply tizen managed API
+ * Tag: sync-agent_0.1.62
+
+ -- WooJin Yun <suhoangel9@samsung.com> Fri, 07 Dec 2012 22:22:16 +0900
+
+sync-agent (0.1.61) unstable; urgency=low
+
+ * 1. Add oma dm api set
+ * 2. Temporary support for both socket and inotify-based noti
+ * 3. Doxygen updated
+ * 4. ID provider set to null
+ * 5. Examples added
+ * 6. libcurl option(gzip,deflate) applied
+ * Tag: sync-agent_0.1.61
+
+ -- WooJin Yun <suhoangel9@samsung.com> Thu, 06 Dec 2012 16:23:03 +0900
+
+sync-agent (0.1.60) unstable; urgency=low
+
+ * 1. Add exception handle for __dispatch_event func
+ * 2. Missing 'server type' in MO node, added
+ * 3. Fixes for Prevent defects.(#3)
+ * 4. Fixes for contact batch create bug for noti
+ * Tag: sync-agent_0.1.60
+
+ -- WooJin Yun <suhoangel9@samsung.com> Thu, 29 Nov 2012 21:13:37 +0900
+
+sync-agent (0.1.59) unstable; urgency=low
+
+ * 1. PLM issue fix. event_get_event_callback return value NULL check.
+ * Tag: sync-agent_0.1.59
+
+ -- Juhaki Park <juhaki.park@samsung.com> Tue, 27 Nov 2012 17:00:07 +0900
+
+sync-agent (0.1.58) unstable; urgency=low
+
+ * 1. contact service api name changed.
+ * 2. oma-dm bootstrap bouble free fixed.
+ * 3. DTS tetware template added.
+ * 4. Prevent fixed.
+ * Tag: sync-agent_0.1.58
+
+ -- Juhaki Park <juhaki.park@samsung.com> Mon, 26 Nov 2012 14:28:07 +0900
+
+sync-agent (0.1.57) unstable; urgency=low
+
+ * 1. Add free interface
+ * 2. Fixes for Prevent defects.(#22)
+ * 3. Noti listener based on Inotify
+ * 4. Fixes for Prevent defects.(#1)
+ * 5. oma ds api added
+ * 6. Bug fix free mo
+ * 7. capi-messaging-push removed
+ * 8. Fixes for Prevent defects.(#12)
+ * 9. Priority issue of inoti solved
+ * 10. API name changed
+ * Tag: sync-agent_0.1.57
+
+ -- WooJin Yun <suhoangel9@samsung.com> Thu, 22 Nov 2012 19:31:07 +0900
+
+sync-agent (0.1.56) unstable; urgency=low
+
+ * 1. Fixes for Prevent defects (#6).
+ * 2. Fixes for Prevent defects (#22)
+ * 3. Fixes for Prevent defects (#13)
+ * 4. Free API added for WBXML tree node usage in external
+ * 5. Exposed DA service open/close API
+ * 6. Fixes for Prevent defects (#9)
+ * 7. Fixes for Prevent defects (#7)
+ * 8. Fixes for Prevent defects. (#9)
+ * 9. Calendar service open/close control in change-noti handler
+ * 10. contacts-service2(managed) api applied
+ * 11. BS patch in sync_agent_load_devinfo_plugin( )
+ * 12. BS patch in sync_agent_free_mo( )
+ * Tag: sync-agent_0.1.56
+
+ -- WooJin Yun <suhoangel9@samsung.com> Fri, 16 Nov 2012 13:46:04 +0900
+
+sync-agent (0.1.55) unstable; urgency=low
+
+ * 1. Bug fix for gcf
+ * - 0701, 0801, 0802, 0901, 1001, 1203, 1308, 1401, 2101, 2102
+ * 2. Check accesstype
+ * 3. Bug fix for gcf
+ * - 0502, 2101
+ * 4. Fixes for Prevent defects.(#48)
+ * 5. Add doc directory for doxygen
+ * 6. Applied calendar-service2 api
+ * 7. Applied calendar insert api change
+ * 8. Fixes for Prevent defects. (#9)
+ * 9. Applied changes for capi-network-connection api
+ * Tag: sync-agent_0.1.55
+
+ -- WooJin Yun <suhoangel9@samsung.com> Thu, 08 Nov 2012 18:03:30 +0900
+
+sync-agent (0.1.54) unstable; urgency=low
+
+ * 1. Bug fix of set_value_to_object()
+ * 2. Fixes for Prevent defects
+ * Tag: sync-agent_0.1.54
+
+ -- WooJin Yun <suhoangel9@samsung.com> Thu, 01 Nov 2012 17:50:16 +0900
+
+sync-agent (0.1.53) unstable; urgency=low
+
+ * 1. Get dmacc / Get . (root)
+ * 2. GCF Bug fix : 1302, 0501, 0502, 0601, 0503, 0901, 1308, 1401, 1501
+ * 3. Add api that can add multiple config items
+ * 4. Apply symbol visibility
+ * 5. GCF Bug fix : 0502, 0601, 0901, 1001, 1203, 1308, 1401, 1501, 1601, 2301, 1302
+ * Git: magnolia/framework/system/sync-agent
+ * Tag: sync-agent_0.1.53
+
+ -- WooJin Yun <suhoangel9@samsung.com> Thu, 25 Oct 2012 19:33:59 +0900
+
+sync-agent (0.1.52) unstable; urgency=low
+
+ * 1. Add acl to root (".")
+ * 2. Error type added for handling group item is read only
+ * 3. Remove retm_if for intentional NULL parameter
+ * 4. Move specific internal API to external API
+ * 5. Sms count and load command bugs fix
+ * 6. File path is removed from log message
+ * 7. Added exception handling code so that failed code line may get detected directly.
+ * 8. Bug fix for basename
+ * 9. extern C for Cpp is added
+ * Git: magnolia/framework/system/sync-agent
+ * Tag: sync-agent_0.1.52
+
+ -- WooJin Yun <suhoangel9@samsung.com> Thu, 18 Oct 2012 17:58:50 +0900
+
+sync-agent (0.1.51) unstable; urgency=low
+
+ * 1. Unifying item-manpulating APIs(data-adapter)
+ * 2. Macro is modified
+ * 3. dlog_refactoring : logging macro
+ * 4. dlog_refactoring : add assertion macro
+ * 5. Remove warning
+ * Git: magnolia/framework/system/sync-agent
+ * Tag: sync-agent_0.1.51
+
+ -- WooJin Yun <suhoangel9@samsung.com> Fri, 12 Oct 2012 15:50:45 +0900
+
+sync-agent (0.1.50) unstable; urgency=low
+
+ * 1. Unifying item-manpulating APIs(account module)
+ * 2. Daemonize feature is added
+ * 3. Remove namespace variable
+ * 4. Unifying item-manpulating APIs(mo)
+ * 5. Bug fix in manifest file
+ * 6. Bug fix in libcul curl_progress_cb
+ * 7. check acl
+ * 8. Bug fix in calendar schesule update
+ * Git: magnolia/framework/system/sync-agent
+ * Tag: sync-agent_0.1.50
+
+ -- WooJin Yun <suhoangel9@samsung.com> Thu, 27 Sep 2012 16:44:56 +0900
+
+sync-agent (0.1.49) unstable; urgency=low
+
+ * 1. Bug fix in manifest file
+ * Git: magnolia/framework/system/sync-agent
+ * Tag: sync-agent_0.1.49
+
+ -- WooJin Yun <suhoangel9@samsung.com> Tue, 25 Sep 2012 13:27:09 +0900
+
+sync-agent (0.1.48) unstable; urgency=low
+
+ * 1. New log header is added
+ * 2. Manifest files are added
+ * Git: magnolia/framework/system/sync-agent
+ * Tag: sync-agent_0.1.48
+
+ -- WooJin Yun <suhoangel9@samsung.com> Fri, 21 Sep 2012 12:30:03 +0900
+
+sync-agent (0.1.47) unstable; urgency=low
+
+ * 1. Fixed bug regarding pda, modem, csc version info.
+ * Git: magnolia/framework/system/sync-agent
+ * Tag: sync-agent_0.1.47
+
+ -- WooJin Yun <suhoangel9@samsung.com> Thu, 13 Sep 2012 16:47:44 +0900
+
+sync-agent (0.1.46) unstable; urgency=low
+
+ * 1. Package name changed : sync-agent-framework -> sync-agent
+ * 2. Add to smemo plugin and BnR
+ * 3. Add gmain loop in main thread
+ * 4. Wrong event reply path fixed
+ * 5. Plugins moved to agent daemon
+ * 7. Added callback feature for 'network status changed' case
+ * Git: magnolia/framework/system/sync-agent
+ * Tag: sync-agent_0.1.46
+
+ -- WooJin Yun <suhoangel9@samsung.com> Thu, 06 Sep 2012 19:48:28 +0900
+
+sync-agent-framework (0.1.45) unstable; urgency=low
+
+ * 1. Fix failure to call network close function bug : delete network flag
+ * 2. Apply Tizen Managed API changes
+ * 3. Add acl server command
+ * 4. Fix memory leak issue
+ * 5. Apply Tizen Managed API changes : Missing changes in external
+ * 6. Remove module name from internal source file name
+ * 7. Hiding external APIs which external modules are not using for now.
+ * 8. Apply Tizen Managed API changes : src/framework
+ * 9. Apply Tizen Managed API changes : src/fw-plugins
+ * Git: magnolia/framework/system/sync-agent
+ * Tag: sync-agent-framework_0.1.45
+
+ -- WooJin Yun <suhoangel9@samsung.com> Fri, 31 Aug 2012 11:24:30 +0900
+
+sync-agent-framework (0.1.44) unstable; urgency=low
+
+ * 1. Fix undefined error : -lcrypt
+ * 2. Add pmapi in slp-device plugin cmakelist file
+ * 3. Add NULL check logic (protection code) for the registered user callback functions
+ * 4. Modify BuildFlags.cmake to enable log
+ * 5. Header installation script added to cmakelists.txt
+ * 6. Apply contacts service api
+ * Git: magnolia/framework/system/sync-agent
+ * Tag: sync-agent-framework_0.1.44
+
+ -- WooJin Yun <suhoangel9@samsung.com> Thu, 23 Aug 2012 14:10:20 +0900
+
+libsync-agent-framework (0.1.42) unstable; urgency=low
- -- Juhaki Park <juhaki.park@samsung.com> Thu, 10 Jan 2013 10:06:10 +0900
+ * 1. External header renaming
+ * 2. plugin separation : framework module generic
+ * 3. remove include/agent-framework
+ * 4. Fix libxml2 API multi-thread issue
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.42
+
+ -- WooJin Yun <suhoangel9@samsung.com> Fri, 17 Aug 2012 11:18:03 +0900
+
+libsync-agent-framework (0.1.41) unstable; urgency=low
+
+ * 1. KIES not supposed to handle DRM backup & restore
+ * 2. Data router capi applied
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.41
+
+ -- WooJin Yun <suhoangel9@samsung.com> Wed, 08 Aug 2012 17:13:31 +0900
+
+libsync-agent-framework (0.1.40) unstable; urgency=low
+
+ * Directory restructuring applied
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.40
+
+ -- WooJin Yun <suhoangel9@samsung.com> Tue, 07 Aug 2012 20:20:06 +0900
+
+libsync-agent-framework (0.1.39) unstable; urgency=low
+
+ * New email api applied
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.39
+
+ -- WooJin <suhoangel9@samsung.com> Tue, 07 Aug 2012 15:26:16 +0900
+
+libsync-agent-framework (0.1.38) unstable; urgency=low
+
+ * New message api applied
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.38
+
+ -- WooJin Yun <suhoangel9@samsung.com> Mon, 06 Aug 2012 14:01:22 +0900
+
+libsync-agent-framework (0.1.37) unstable; urgency=low
+
+ * Local Test done. NULL check ,
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.37
+
+ -- Juhaki Park <juhaki.park@samsung.com> Tue, 24 Jul 2012 15:20:05 +0900
+
+libsync-agent-framework (0.1.36) unstable; urgency=low
+
+ * Local Test done. NULL check , maintainer update , lib symbolic link
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.36
+
+ -- Juhaki Park <juhaki.park@samsung.com> Wed, 18 Jul 2012 18:20:05 +0900
+
+libsync-agent-framework (0.1.35) unstable; urgency=low
+
+ * Test done. JIRA S1-5787 fix.
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.35
+
+ -- Juhaki Park <juhaki.park@samsung.com> Fri, 13 Jul 2012 19:20:05 +0900
+
+libsync-agent-framework (0.1.34) unstable; urgency=low
+
+ * pkg upload.
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.34
+
+ -- Juhaki Park <juhaki.park@samsung.com> Tue, 10 Jul 2012 10:10:05 +0900
+
+libsync-agent-framework (0.1.33) unstable; urgency=low
+
+ * filename update.
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.33
+
+ -- Juhaki Park <juhaki.park@samsung.com> Wed, 04 Jul 2012 15:40:05 +0900
+
+libsync-agent-framework (0.1.32) unstable; urgency=low
+
+ * calendar api.
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.32
+
+ -- Juhaki Park <juhaki.park@samsung.com> Wed, 04 Jul 2012 15:00:05 +0900
+
+libsync-agent-framework (0.1.31) unstable; urgency=low
+
+ * changed telephony lib - spec , changelog update.
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.31
+
+ -- Juhaki Park <juhaki.park@samsung.com> Mon, 25 Jun 2012 14:20:05 +0900
+
+libsync-agent-framework (0.1.26) unstable; urgency=low
+
+ * SMACK update - pkg upload
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.26
+
+ -- Juhaki Park <juhaki.park@samsung.com> Mon, 11 Jun 2012 14:20:05 +0900
+
+libsync-agent-framework (0.1.24) unstable; urgency=low
+
+ * vconf key update - pkg upload
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.24
+
+ -- Juhaki Park <juhaki.park@samsung.com> Thu, 24 May 2012 18:16:05 +0900
+
+libsync-agent-framework (0.1.23) unstable; urgency=low
+
+ * pkg upload
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.23
+
+ -- Sunbong Ha <sunbong.ha@samsung.com> Wed, 23 May 2012 09:16:05 +0900
+
+libsync-agent-framework (0.1.22) unstable; urgency=low
+
+ * pkg upload
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.22
+
+ -- Juhaki Park <juhaki.park@samsung.com> Mon, 21 May 2012 12:27:36 +0900
+
+libsync-agent-framework (0.1.21) unstable; urgency=low
+
+ * pkg upload
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.21
+
+ -- Sunbong Ha <sunbong.ha@samsung.com> Wed, 09 May 2012 08:27:36 +0900
+
+libsync-agent-framework (0.1.20) unstable; urgency=low
+
+ * pkg upload
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.20
+
+ -- Sunbong Ha <sunbong.ha@samsung.com> Thu, 26 Apr 2012 17:22:00 +0900
+
+libsync-agent-framework (0.1.19) unstable; urgency=low
+
+ * pkg upload
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.19
+
+ -- Sunbong Ha <sunbong.ha@samsung.com> Tue, 17 Apr 2012 16:13:20 +0900
+
+libsync-agent-framework (0.1.18) unstable; urgency=low
+
+ * modified device update table(oma-dm)
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.18
+
+ -- Junhyuk Lee <junhyuk7.lee@samsung.com> Mon, 09 Apr 2012 19:58:06 +0900
+
+libsync-agent-framework (0.1.17) unstable; urgency=low
+
+ * pkg upload
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.17
+
+ -- Sunbong Ha <sunbong.ha@samsung.com> Mon, 09 Apr 2012 10:24:14 +0900
+
+libsync-agent-framework (0.1.16) unstable; urgency=low
+
+ * pkg upload
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.16
+
+ -- Sunbong Ha <sunbong.ha@samsung.com> Tue, 03 Apr 2012 10:13:20 +0900
+
+libsync-agent-framework (0.1.15) unstable; urgency=low
+
+ * pkg upload
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.15
+
+ -- Sunbong Ha <sunbong.ha@samsung.com> Thu, 29 Mar 2012 16:22:12 +0900
+
+libsync-agent-framework (0.1.14) unstable; urgency=low
+
+ * pkg upload
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.14
+
+ -- Sunbong Ha <sunbong.ha@samsung.com> Thu, 29 Mar 2012 10:41:38 +0900
+
+libsync-agent-framework (0.1.13) unstable; urgency=low
+
+ * pkg upload sync-agent fw source
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.13
+
+ -- Junhyuk Lee <junhyuk7.lee@samsung.com> Thu, 22 Mar 2012 20:38:15 +0900
+
+libsync-agent-framework (0.1.12) unstable; urgency=low
+
+ * code merge sync-agent-framework open repo
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.12
+
+ -- Junhyuk Lee <junhyuk7.lee@samsung.com> Wed, 21 Mar 2012 20:08:04 +0900
+
+libsync-agent-framework (0.1.11) unstable; urgency=low
+
+ * fixed model ver err & remove build test script
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.11
+
+ -- Junhyuk Lee <junhyuk7.lee@samsung.com> Mon, 19 Mar 2012 10:46:53 +0900
+
+libsync-agent-framework (0.1.10) unstable; urgency=low
+
+ * upload the package
+ * Git: slp/pkgs/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.10
+
+ -- Sunbong Ha <sunbong.ha@samsung.com> Thu, 15 Mar 2012 16:39:28 +0900
+
+libsync-agent-framework (0.1.9) unstable; urgency=low
+
+ * telephony register block for crash
+ * Git: slp/apps/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.9
+
+ -- Junhyuk Lee <junhyuk7.lee@samsung.com> Mon, 12 Mar 2012 12:32:13 +0900
+
+libsync-agent-framework (0.1.8) unstable; urgency=low
+
+ * spp bug fixed & pkg upload for version up
+ * Git: slp/apps/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.8
+
+ -- Junhyuk Lee <junhyuk7.lee@samsung.com> Thu, 08 Mar 2012 11:26:13 +0900
+
+libsync-agent-framework (0.1.7) unstable; urgency=low
+
+ * package upload for fix build error
+ * Git: slp/apps/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.7
+
+ -- Sunbong Ha <sunbong.ha@samsung.com> Fri, 02 Mar 2012 11:12:35 +0900
+
+libsync-agent-framework (0.1.6) unstable; urgency=low
+
+ * package upload
+ * Git: slp/apps/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.6
+
+ -- Sunbong Ha <sunbong.ha@samsung.com> Wed, 29 Feb 2012 14:01:02 +0900
+
+libsync-agent-framework (0.1.5) unstable; urgency=low
+
+ * package upload for fix i386 build error
+ * Git: slp/apps/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.5
+
+ -- Sunbong Ha <sunbong.ha@samsung.com> Mon, 27 Feb 2012 20:00:03 +0900
libsync-agent-framework (0.1.4) unstable; urgency=low
- * 1. Smack file removed (common-private-plugins.manifest)
- * Git: framework/system/sync-agent
- * Tag: sync-agent_0.1.4
+ * package upload
+ * Git: slp/apps/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.4
- -- WooJin Yun <suhoangel9@samsung.com> Wed, 09 Jan 2013 18:46:16 +0900
+ -- leejunhyuk <junhyuk7.lee@samsung.com> Mon, 27 Feb 2012 18:12:42 +0900
libsync-agent-framework (0.1.3) unstable; urgency=low
- * 1. Prevent defects fixed.
- * Git: framework/system/sync-agent
- * Tag: sync-agent_0.1.3
+ * package upload
+ * Git: slp/apps/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.3
- -- Juhaki Park <juhaki.park@samsung.com> Wed, 09 Jan 2013 18:16:10 +0900
+ -- leejunhyuk <junhyuk7.lee@samsung.com> Tue, 21 Feb 2012 16:19:50 +0900
libsync-agent-framework (0.1.2) unstable; urgency=low
- * 1. Internal: build error & dependency patch
- * Git: framework/system/sync-agent
- * Tag: sync-agent_0.1.2
+ * bug fixed in slp-device & pkg update
+ * Git: slp/apps/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.2
- -- WooJin Yun <suhoangel9@samsung.com> Fri, 28 Dec 2012 22:40:10 +0900
+ -- leejunhyuk <junhyuk7.lee@samsung.com> Thu, 09 Feb 2012 16:14:16 +0900
libsync-agent-framework (0.1.1) unstable; urgency=low
- * Initial update
- * Git: framework/system/sync-agent
- * Tag: sync-agent_0.1.1
+ * Initial release
+ * Git: slp/apps/s/sync-agent-framework
+ * Tag: libsync-agent-framework_0.1.1
- -- WooJin Yun <suhoangel9@samsung.com> Wed, 01 Feb 2012 10:30:16 +0900
+ -- leejunhyuk <junhyuk7.lee@samsung.com> Wed, 01 Feb 2012 10:30:16 +0900
sync_agent_da_return_e sync_agent_get_item(char *item_id, sync_agent_da_item_s ** sync_agent_item);
/**
+ * @brief Get data store item id
+ * @par Usage:
+ * @code
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_item_s *item = NULL;
+
+ ret = sync_agent_get_item_data_store_id(item_id, &item);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ ...
+ }
+
+ * @endcode
+ * @param[in] item_id id of framework folder item instance desired to get
+ * @param[out] sync_agent_item framework item instance fetched
+ * @return operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval error_value fail
+ */
+ sync_agent_da_return_e sync_agent_get_item_data_store_id(char *item_id, sync_agent_da_item_s ** sync_agent_item);
+
+/**
+ * @brief Get account item id
+ * @par Usage:
+ * @code
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_item_s *item = NULL;
+
+ ret = sync_agent_get_item_account_id(item_id, &item);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ ...
+ }
+
+ * @endcode
+ * @param[in] item_id id of framework folder item instance desired to get
+ * @param[out] sync_agent_item framework item instance fetched
+ * @return operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval error_value fail
+ */
+ sync_agent_da_return_e sync_agent_get_item_account_id(char *item_id, sync_agent_da_item_s ** sync_agent_item);
+
+/**
* @brief Fetch framework items according to given query in GList form
* @par Usage:
* @code
*/
sync_agent_da_return_e sync_agent_add_service_item(sync_agent_da_service_item_s * service_item, char **item_id, bool update_changelog);
+
+/**
+* @brief Add framework service item instance into frameowrk db
+* @par Usage:
+* @code
+
+sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+sync_agent_da_service_item_s *service_item = NULL;
+char *item_id = NULL;
+
+ret = sync_agent_create_service_item(&service_item);
+if (ret != SYNC_AGENT_DA_SUCCESS) {
+ ...
+}
+
+...
+
+ret = sync_agent_add_service_bulk_item(service_item, &item_id, true);
+if (ret != SYNC_AGENT_DA_SUCCESS) {
+ ...
+}
+
+* @endcode
+* @param[in] service_item sync_agent_da_service_item_s type of framework service item instance to add into framework db
+* @param[out] item_id id of framework service item instance added new
+* @param[in] update_changelog option specifying whether use of changelog for sync history
+* @return operation result
+* @retval SYNC_AGENT_DA_SUCCESS success
+* @retval error_value fail
+*/
+ 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);
+
/**
* @brief Update framework service item on framework db
* @par Usage:
sync_agent_da_return_e sync_agent_update_service_item(sync_agent_da_service_item_s * service_item, char *item_id, bool update_changelog);
/**
+* @brief Update framework service item on framework db
+* @par Usage:
+* @code
+
+sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+sync_agent_da_service_item_s *service_item = NULL;
+
+ret = sync_agent_get_service_item(item_id, &service_item);
+if (ret != SYNC_AGENT_DA_SUCCESS) {
+ ...
+}
+
+...
+
+ret = sync_agent_update_service_bulk_item(service_item, &item_id, true);
+if (ret != SYNC_AGENT_DA_SUCCESS) {
+ ...
+}
+
+* @endcode
+* @param[in] service_item sync_agent_da_service_item_s type of framework service item instance to update into framework db
+* @param[in] item_id id of framework service item instance desired to update
+* @param[in] update_changelog option specifying whether use of changelog for sync history
+* @return operation result
+* @retval SYNC_AGENT_DA_SUCCESS success
+* @retval error_value fail
+*/
+ 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);
+
+/**
* @brief Delete framework service item instance from frameowrk db
* @par Usage:
* @code
sync_agent_da_return_e sync_agent_delete_service_item(char *item_id, bool update_changelog);
/**
+* @brief Delete framework service item instance from frameowrk db
+* @par Usage:
+* @code
+
+sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+ret = sync_agent_delete_service_bulk_item(item_id, true);
+if (ret != SYNC_AGENT_DA_SUCCESS) {
+ ...
+}
+
+* @endcode
+* @param[in] item_id id of framework service item instance desired to delete
+* @param[in] update_changelog option specifying whether use of changelog for sync history
+* @return operation result
+* @retval SYNC_AGENT_DA_SUCCESS success
+* @retval error_value fail
+*/
+ sync_agent_da_return_e sync_agent_delete_service_bulk_item(char **item_id, int count, bool update_changelog);
+
+
+/**
* @brief Delete framework service item instance from frameowrk db using query option
* @par Usage:
* @code
void sync_agent_get_event_data_param(sync_agent_event_data_s * iter, void *data);
/**
+ * API to extract parameter from Event packet
+ * @remarks This function will be used when extracting received event packet.
+ * extracted order is matched the order of @ref sync_agent_append_event_data_param().
+ *
+ * @par Usage:
+ * @code
+ int event_num = 1;
+ int event_int_data = 0;
+ int result_int = 0;
+ char *result_char = NULL;
+ sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+ sync_agent_event_data_s *request_event = NULL;
+ sync_agent_event_data_s *response_event = NULL;
+ ...
+ request_event = sync_agent_create_event(event_num);
+ if (request_event == NULL) {
+ // error handling
+ ...
+ }
+
+ sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_int_data);
+ ...
+ response_event = sync_agent_send_event(request_event, &error);
+ if (error != SYNC_AGENT_EVENT_SUCCESS) {
+ // error handling
+ ...
+ }
+
+ if (response_event == NULL) {
+ // error handling
+ ...
+ }
+
+ sync_agent_get_event_data_param_int(response_event, &result_int);
+ sync_agent_get_event_data_param_str(response_event, &result_char);
+ ...
+ *
+ * @endcode
+ *
+ * @param[in] iter sync_agent_event_data_s pointer parameters to be extracted
+ * @param[in] data as returned by sync_agent_get_event_data_param() - real extracted data
+ *
+ * @par Since
+ *
+ *
+ * @see _event_listener(void *)
+ *
+ */
+ void sync_agent_get_event_data_param_int(sync_agent_event_data_s * iter, int *data);
+ void sync_agent_get_event_data_param_str(sync_agent_event_data_s * iter, char ** data);
+
+/**
* API to free sync_agent_event_data_s pointer (event object)
*
* @par Usage:
} sync_agent_ds_service_type_e;
/**
+ * Enumerations of sync mode
+ */
+ typedef enum {
+ SYNC_AGENT_SYNC_MODE_MANUAL = 0, /**< Manual */
+ SYNC_AGENT_SYNC_MODE_PERIODIC = 1, /**< Periodic */
+ SYNC_AGENT_SYNC_MODE_PUSH = 2 /**< Push */
+ } sync_agent_ds_sync_mode_e;
+
+/**
+ * Enumerations of sync type
+ */
+ typedef enum {
+ SYNC_AGENT_SYNC_TYPE_FULL_SYNC = 0, /**< Full */
+ SYNC_AGENT_SYNC_TYPE_UPDATE_BOTH = 1, /**< Update both */
+ SYNC_AGENT_SYNC_TYPE_UPDATE_TO_SERVER = 2, /**< Update to server */
+ SYNC_AGENT_SYNC_TYPE_UPDATE_TO_PHONE = 3, /**< Update to phone */
+ SYNC_AGENT_SYNC_TYPE_REFRESH_FROM_SERVER = 4, /**< Refresh from server */
+ SYNC_AGENT_SYNC_TYPE_REFRESH_FROM_PHONE = 5 /**< Refresh from phone */
+ } sync_agent_ds_sync_type_e;
+
+/**
+ * Enumerations of sync interval
+ */
+ typedef enum {
+ SYNC_AGENT_SYNC_INTERVAL_5_MINUTES = 0, /**< 5 minutes */
+ SYNC_AGENT_SYNC_INTERVAL_15_MINUTES = 1, /**< 15 minutes */
+ SYNC_AGENT_SYNC_INTERVAL_1_HOUR = 2, /**< 1 hour */
+ SYNC_AGENT_SYNC_INTERVAL_4_HOURS = 3, /**< 4 hours */
+ SYNC_AGENT_SYNC_INTERVAL_12_HOURS = 4, /**< 12 hours */
+ SYNC_AGENT_SYNC_INTERVAL_1_DAY = 5, /**< 1 day */
+ SYNC_AGENT_SYNC_INTERVAL_1_WEEK = 6, /**< 1 week */
+ SYNC_AGENT_SYNC_INTERVAL_1_MONTH = 7 /**< 1 month */
+ } sync_agent_ds_sync_interval_e;
+
+/**
+ * Enumerations of src uri
+ */
+ typedef enum {
+ SYNC_AGENT_SRC_URI_CONTACT = 0, /**< Contacts */
+ SYNC_AGENT_SRC_URI_CALENDAR = 1 /**< Calendar */
+ } sync_agent_ds_src_uri_e;
+
+/**
+ * Enumerations of sync callback
+ */
+ typedef enum {
+ SYNC_AGENT_DS_SYNC_SESSION = 1, /**< Sync session */
+ SYNC_AGENT_DS_SYNC_PROCESS = 2 /**< Sync process */
+ } sync_agent_ds_sync_callback_e;
+
+/**
* @brief Structure of OMA DS Server information instance
*/
typedef struct {
* @brief Structure of OMA DS Sync information instance
*/
typedef struct {
- char *sync_mode; /**< Sync mode */
- char *sync_type; /**< Sync type */
- char *interval; /**< Interval */
+ sync_agent_ds_sync_mode_e sync_mode; /**< Sync mode */
+ sync_agent_ds_sync_type_e sync_type; /**< Sync type */
+ sync_agent_ds_sync_interval_e interval; /**< Interval */
} sync_agent_ds_sync_info;
/**
typedef struct {
sync_agent_ds_service_type_e service_type; /**< Service type */
int enabled; /**< Enable or not */
- char *src_uri; /**< Source uri */
+ sync_agent_ds_src_uri_e src_uri; /**< Source uri */
char *tgt_uri; /**< Target uri */
char *id; /**< Id */
char *password; /**< password */
*
* ds_profile_h profile_h = NULL;
* char *profile_dir_name = "Sync1";
- * char *profile_name = "profile name";
*
* sync_agent_ds_error_e ds_err = sync_agent_ds_create_profile_info(&profile_h);
* if(ds_err != SYNC_AGENT_DS_SUCCESS) {
*
* ...
*
- * ds_err = sync_agent_ds_set_profile_name(profile_h, profile_dir_name, profile_name);
+ * ds_err = sync_agent_ds_set_profile_dir_name(profile_h, profile_dir_name);
* if(ds_err != SYNC_AGENT_DS_SUCCESS) {
* ...
* }
* @endcode
* @param[in] profile_h profile info initialized
* @param[in] profile_dir_name profile dir name
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ */
+ sync_agent_ds_error_e sync_agent_ds_set_profile_dir_name(ds_profile_h profile_h, char *profile_dir_name);
+
+/**
+ * @brief set profile name into profile info
+ * @par Usage:
+ * @code
+ *
+ * ds_profile_h profile_h = NULL;
+ * char *profile_name = "profile name";
+ *
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_create_profile_info(&profile_h);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ * ...
+ * }
+ *
+ * ...
+ *
+ * ds_err = sync_agent_ds_set_profile_name(profile_h, profile_name);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ * ...
+ * }
+ *
+ * ...
+ *
+ * @endcode
+ * @param[in] profile_h profile info initialized
* @param[in] profile_name profile name
* @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
*/
- sync_agent_ds_error_e sync_agent_ds_set_profile_name(ds_profile_h profile_h, char *profile_dir_name, char *profile_name);
+ sync_agent_ds_error_e sync_agent_ds_set_profile_name(ds_profile_h profile_h, char *profile_name);
/**
* @brief set server information into profile info
* @code
*
* ds_profile_h profile_h = NULL;
- * char *sync_mode = "Periodic";
- * char *sync_type = "Update both";
- * char *interval = "1 hour";
+ * sync_agent_ds_sync_mode_e sync_mode = SYNC_AGENT_SYNC_MODE_PERIODIC;
+ * sync_agent_ds_sync_type_e sync_type = SYNC_AGENT_SYNC_TYPE_UPDATE_BOTH;
+ * sync_agent_ds_sync_interval_e interval = SYNC_AGENT_SYNC_INTERVAL_1_HOUR;
*
* sync_agent_ds_error_e ds_err = sync_agent_ds_create_profile_info(&profile_h);
* if(ds_err != SYNC_AGENT_DS_SUCCESS) {
*
* @endcode
* @param[in] profile_h profile info initialized
- * @param[in] sync_mode sync mode(Push, Manual, Periodic)
- * @param[in] sync_type sync type(Full, Update both, Update to server, Update to phone, Refresh from server, Refresh from phone)
- * @param[in] interval interval(only for periodic sync(5 minutes, 15 minutes, 1 hour, 4 hours, 12 hours, 1 day, 1 week))
+ * @param[in] sync_mode sync mode(sync_agent_ds_sync_mode_e value)
+ * @param[in] sync_type sync type(sync_agent_ds_sync_type_e value)
+ * @param[in] interval interval(sync_agent_ds_sync_interval_e)
* @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
*/
- sync_agent_ds_error_e sync_agent_ds_set_sync_info(ds_profile_h profile_h, char *sync_mode, char *sync_type, char *interval);
+ sync_agent_ds_error_e sync_agent_ds_set_sync_info(ds_profile_h profile_h, sync_agent_ds_sync_mode_e sync_mode, sync_agent_ds_sync_type_e sync_type, sync_agent_ds_sync_interval_e interval);
/**
* @brief set service information into profile info
* @param[in] profile_h profile info initialized
* @param[in] service_type service type(SYNC_AGENT_CONTACT, SYNC_AGENT_CALENDAR, SYNC_AGENT_MEMO, SYNC_AGENT_CALLLOG)
* @param[in] enabled enable or not( 1 = enable, 0 = prevent)
- * @param[in] src_uri source uri
+ * @param[in] src_uri source uri (sync_agent_ds_src_uri_e)
* @param[in] tgt_uri target uri
* @param[in] id id
* @param[in] password password
* @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
*/
- sync_agent_ds_error_e sync_agent_ds_set_sync_service_info(ds_profile_h profile_h, sync_agent_ds_service_type_e service_type, int enabled, char *src_uri, char *tgt_uri, char *id, char *password);
+ sync_agent_ds_error_e sync_agent_ds_set_sync_service_info(ds_profile_h profile_h, sync_agent_ds_service_type_e service_type, int enabled, sync_agent_ds_src_uri_e src_uri, char *tgt_uri, char *id, char *password);
/**
* @brief get profile dir name, profile name from profile info
* ds_profile_h profile_h = NULL;
* char *profile_dir_name = "Sync1";
* char *get_profile_dir_name = NULL;
- * char *profile_name = NULL;
*
* sync_agent_ds_error_e ds_err = sync_agent_ds_get_profile(profile_dir_name, &profile_h);
* if(ds_err != SYNC_AGENT_DS_SUCCESS) {
*
* ...
*
- * ds_err = sync_agent_ds_get_profile_name(profile_h, &get_profile_dir_name, &profile_name);
+ * ds_err = sync_agent_ds_get_profile_dir_name(profile_h, &get_profile_dir_name);
* if(ds_err != SYNC_AGENT_DS_SUCCESS) {
* ...
* }
* @endcode
* @param[in] profile_h profile info
* @param[out] profile_dir_name profile dir name
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ * @see sync_agent_ds_get_profile
+ */
+ sync_agent_ds_error_e sync_agent_ds_get_profile_dir_name(ds_profile_h profile_h, char **profile_dir_name);
+
+/**
+ * @brief get profile dir name, profile name from profile info
+ * @par Usage:
+ * @code
+ *
+ * ds_profile_h profile_h = NULL;
+ * char *profile_dir_name = "Sync1";
+ * char *profile_name = NULL;
+ *
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_get_profile(profile_dir_name, &profile_h);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ * ...
+ * }
+ *
+ * ...
+ *
+ * ds_err = sync_agent_ds_get_profile_name(profile_h, &profile_name);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ * ...
+ * }
+ *
+ * ...
+ *
+ * @endcode
+ * @param[in] profile_h profile info
* @param[out] profile_name profile name
* @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
* @see sync_agent_ds_get_profile
*/
- sync_agent_ds_error_e sync_agent_ds_get_profile_name(ds_profile_h profile_h, char **profile_dir_name, char **profile_name);
+ sync_agent_ds_error_e sync_agent_ds_get_profile_name(ds_profile_h profile_h, char **profile_name);
/**
* @brief get profile server information from profile info
sync_agent_ds_error_e sync_agent_ds_deinit();
/**
+ * @brief deinitialize OMA DS
+ * @par Usage:
+ * @code
+ *
+ * sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+ *
+ * ds_err = sync_agent_ds_set_noti_callback(SYNC_AGENT_DS_SYNC_SESSION, _session_process_noti_cb, NULL);
+ * if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+ * _DEBUG_ERROR("sync_agent_ds_set_noti_callback() failed!!");
+ * return -1;
+ * }
+ *
+ * ds_err = sync_agent_ds_set_noti_callback(SYNC_AGENT_DS_SYNC_PROCESS, _process_update_noti_cb, NULL);
+ * if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+ * _DEBUG_ERROR("sync_agent_ds_set_noti_callback() failed!!");
+ * return -1;
+ * }
+ *
+ * @endcode
+ * @param[in] type noti callback type (sync_agent_ds_sync_callback_e)
+ * @param[in] callback noti callback function
+ * @param[in] data data
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ */
+ sync_agent_ds_error_e sync_agent_ds_set_noti_callback(sync_agent_ds_sync_callback_e type, sync_agent_noti_cb callback, void *data);
+
+/**
* @}
*/
sync_agent_da_return_e sync_agent_plugin_add_item(int account_id, char *folder_id, void *data, char **item_id);
/**
+ * API to insert item into service storage
+ *
+ * @param[in] account_id service account id
+ * @param[in] folder_id service folder id
+ * @param[in] data data to add to the service
+ * @param[in] item_id as returned by sync_agent_plugin_add_bulk_item() - success : id of the newly item added to the service, error : NULL
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_add_bulk_item(int, char *, void *, int **, int *)
+ *
+ */
+ sync_agent_da_return_e sync_agent_plugin_add_bulk_item(int account_id, char *folder_id, void *data, int **item_id, int *item_id_count);
+
+/**
* API to update item from service storage
*
* @param[in] account_id service account id
sync_agent_da_return_e sync_agent_plugin_update_item(int account_id, char *folder_id, char *item_id, void *data);
/**
+ * API to update item from service storage
+ *
+ * @param[in] data data to update to the service
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_update_bulk_item(void *)
+ *
+ */
+ sync_agent_da_return_e sync_agent_plugin_update_bulk_item(void *data);
+
+/**
* API to delete item from service storage
*
* @param[in] account_id service account id
sync_agent_da_return_e sync_agent_plugin_delete_item(int account_id, char *folder_id, char *item_id);
/**
+ * API to delete item from service storage
+ *
+ * @param[in] item_id service id of item expected to be deleted
+ * @param[in] count count of service item id expected to be deleted
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_delete_bulk_item(int *, int)
+ *
+ */
+ sync_agent_da_return_e sync_agent_plugin_delete_bulk_item(int *item_id, int count);
+
+
+/**
* API to delete all items from service storage
*
* @param[in] account_id service account id
Name: sync-agent
Summary: Sync agent FW Library
-Version: 0.1.8
+Version: 0.1.80
Release: 1
Group: TO_BE/FILLED_IN
License: Apache License, Version 2.0
BuildRequires: pkgconfig(dlog)
BuildRequires: libgcrypt-devel
BuildRequires: cmake
+BuildRequires: pkgconfig(dbus-glib-1)
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
%{_libdir}/*.so.*
%{_libdir}/pkgconfig/sync-agent.pc
-
#%files -n common-private-plugins
#%manifest common-private-plugins.manifest
#%defattr(-,root,root,-)
#/usr/lib/sync-agent/common-private/*
-
%files -n common-public-plugins
%manifest common-public-plugins.manifest
%defattr(-,root,root,-)
libsoup-2.4
vconf
uuid
- msg-service
libxml-2.0
libwbxml2
dlog
+ dbus-glib-1
)
#############################################
}
}
- _DEBUG_INFO("\n\nk : %d\n", k);
+ //_DEBUG_INFO("\n\nk : %d\n", k);
// Delete fw_service_account_id from vconf
if (k >= service_account_id_cnt) {
plugin_delete_platform_account_service_cb func_del_platform_account_service = plugin_get_function_delete_platform_account_service(plugin_get_account_plugin_id());
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
daci_stmt stmt = 0;
- char *query = "delete from item_tbl where item_id = ?";
+ char query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = {0,};
+
+ snprintf(query, sizeof(query), "delete from item_tbl where item_id = %s", itemId);
+ //for test
+ //_DEBUG_INFO("query = [%s]", query);
stmt = __query_prepare(daci_handler, query, strlen(query));
if (stmt == NULL)
return SYNC_AGENT_DA_ERR_QUERY_FAILED;
- __stmt_bind_text(daci_handler, stmt, 1, itemId);
-
ret = __stmt_write_step(daci_handler, stmt);
__stmt_finalize(daci_handler, stmt);
retvm_if(itemId == NULL, NULL, "item Id is NULL !!");
daci_stmt stmt = 0;
- char *query = "select service_id from item_tbl where item_id = ?";
+ char query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = {0,};
char *service_id = 0;
+ snprintf(query, sizeof(query), "select service_id from item_tbl where item_id = %s", itemId);
+ //for test
+ //_DEBUG_INFO("query = [%s]", query);
stmt = __query_prepare(daci_handler, query, strlen(query));
if (stmt != NULL) {
- __stmt_bind_text(daci_handler, stmt, 1, itemId);
-
if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA)
service_id = _stmt_column_text(stmt, 0);
}
_EXTERN_FUNC_EXIT;
-
return service_id;
}
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
daci_stmt stmt = 0;
- char *query = "select * from item_tbl where item_id = ?";
+ char query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = {0,};
+
+ snprintf(query, sizeof(query), "select * from item_tbl where item_id = %s", item_id);
+ //for test
+ //_DEBUG_INFO("query = [%s]", query);
stmt = __query_prepare(daci_handler, query, strlen(query));
if (stmt != NULL) {
- __stmt_bind_text(daci_handler, stmt, 1, item_id);
-
if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
(*sync_agent_item)->item_id = _stmt_column_text(stmt, 0);
(*sync_agent_item)->data_store_id = __stmt_column_int(stmt, 1);
}
_EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+sync_agent_da_return_e da_get_item_data_store_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, char *item_id, sync_agent_da_item_s ** sync_agent_item)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+ retvm_if(item_id == NULL, SYNC_AGENT_DA_ERRORS, "item Id is NULL !!");
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ daci_stmt stmt = 0;
+ char query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = {0,};
+
+ snprintf(query, sizeof(query), "select * from item_tbl where item_id = %s", item_id);
+ //for test
+ //_DEBUG_INFO("query = [%s]", query);
+
+ stmt = __query_prepare(daci_handler, query, strlen(query));
+ if (stmt != NULL) {
+ if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+ (*sync_agent_item)->data_store_id = __stmt_column_int(stmt, 1);
+ }
+ __stmt_finalize(daci_handler, stmt);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+sync_agent_da_return_e da_get_item_account_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, char *item_id, sync_agent_da_item_s ** sync_agent_item)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+ retvm_if(item_id == NULL, SYNC_AGENT_DA_ERRORS, "item Id is NULL !!");
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ daci_stmt stmt = 0;
+ char query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = {0,};
+
+ snprintf(query, sizeof(query), "select * from item_tbl where item_id = %s", item_id);
+ //for test
+ //_DEBUG_INFO("query = [%s]", query);
+
+ stmt = __query_prepare(daci_handler, query, strlen(query));
+ if (stmt != NULL) {
+ if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+ (*sync_agent_item)->account_id = __stmt_column_int(stmt, 2);
+ }
+ __stmt_finalize(daci_handler, stmt);
+ }
+ _EXTERN_FUNC_EXIT;
return ret;
}
int row_count = 0;
int col_count = 0;
int i = 0;
- int index = 5;
+ int index = 1;
char *item_id = NULL;
char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
_DEBUG_ERROR("__replace_table_name() failed !!");
return SYNC_AGENT_DA_ERRORS;
}
+
snprintf(g_daci_query, sizeof(g_daci_query), "select item.item_id " "from item_tbl as item " "join %s as changelog " "using (item_id) " "where item.account_id = %d and item.data_store_id = %d and changelog.operation_id = %d", new_table, account_id,
item_type_id, operation_id);
for (i = 0; i < row_count; i++) {
item_id = NULL;
item_id = SYNC_AGENT_DA_STRDUP(result[index]);
- index += 5;
+ index++;
*list = g_list_append(*list, item_id);
}
int err_mutex = pthread_mutex_lock(&exec_lock);
if (err_mutex) {
- _DEBUG_ERROR("Failed pthread_mutex_lock : %d", err_mutex);
+ _DEBUG_ERROR("Failed pthread_mutex_lock : [%d]", err_mutex);
}
+
+ //for test
+ //_DEBUG_INFO("query = [%s], size = [%d]", query, size);
ret = sqlite3_prepare_v2(daci_handler, query, size, &stmt, 0);
+ if (ret != SQLITE_OK) {
+ _DEBUG_ERROR("sqlite3_query_prepare failed[%d] : [%s]", ret, sqlite3_errmsg(daci_handler));
+ }
+
err_mutex = pthread_mutex_unlock(&exec_lock);
if (err_mutex) {
- _DEBUG_ERROR("Failed pthread_mutex_unlock : %d", err_mutex);
+ _DEBUG_ERROR("Failed pthread_mutex_unlock : [%d]", err_mutex);
}
- if (ret != SQLITE_OK)
- _DEBUG_ERROR("sqlite3_query_prepare failed(%d) : %s ", ret, sqlite3_errmsg(daci_handler));
-
_INNER_FUNC_EXIT;
-
return stmt;
}
sync_agent_da_return_e da_get_item_new(SYNC_AGENT_DA_HANDLER * daci_handler, char *item_id, sync_agent_da_item_s ** sync_agent_item);
/**
+ * @brief Get data_store item id from item_tbl
+ * @param[in] daci_handler sqlite3 handler pointer about thread
+ * @param[in] item_id item id
+ * @param[in] sync_agent_item as returned by da_get_item_new() - item info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_get_item_data_store_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, char *item_id, sync_agent_da_item_s ** sync_agent_item);
+
+/**
+ * @brief Get account item id from item_tbl
+ * @param[in] daci_handler sqlite3 handler pointer about thread
+ * @param[in] item_id item id
+ * @param[in] sync_agent_item as returned by da_get_item_new() - item info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_get_item_account_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, char *item_id, sync_agent_da_item_s ** sync_agent_item);
+
+/**
* @brief Get all item id from item_tbl
* @param[in] daci_handler sqlite3 handler pointer about thread
* @return Operation result
return ret;
}
+EXPORT_API sync_agent_da_return_e sync_agent_add_bulk_item(sync_agent_da_item_s * sync_agent_item, char **item_id, int use_changelog)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(sync_agent_item == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_item_s is NULL !!");
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+ if (use_changelog == 1) {
+ ret = sync_agent_changelog_add_item_new(sync_agent_item, item_id);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("da_changelog_add_item_internal() failed !!");
+ }
+ } else {
+ ret = sync_agent_add_item_new(sync_agent_item, 1, item_id);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("da_add_item_internal() failed !!");
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
EXPORT_API sync_agent_da_return_e sync_agent_update_item(char *item_id, int use_changelog)
{
_EXTERN_FUNC_ENTER;
if (use_changelog == 1) {
ret = sync_agent_create_item(&get_item);
if (ret != SYNC_AGENT_DA_SUCCESS) {
- _DEBUG_ERROR("sync_agent_create_item() failed !!");
+ _DEBUG_ERROR("sync_agent_create_item() failed, ret[%d]", ret);
return ret;
}
- ret = sync_agent_get_item(item_id, &get_item);
+ ret = sync_agent_get_item_account_id(item_id, &get_item);
if (ret != SYNC_AGENT_DA_SUCCESS) {
- _DEBUG_ERROR("sync_agent_get_item() failed !!");
+ _DEBUG_ERROR("sync_agent_get_item_account_id() failed, ret[%d]", ret);
int ret_temp = sync_agent_free_item(get_item);
if (ret_temp != SYNC_AGENT_DA_SUCCESS) {
- _DEBUG_ERROR("sync_agent_free_item() failed !!");
+ _DEBUG_ERROR("sync_agent_get_item_account_id() failed, ret[%d]", ret);
}
return ret;
}
ret = sync_agent_changelog_delete_item_new(get_item->account_id, item_id);
if (ret != SYNC_AGENT_DA_SUCCESS) {
- _DEBUG_ERROR("da_changelog_delete_item_internal() failed !!");
+ _DEBUG_ERROR("da_changelog_delete_item_internal() failed, ret[%d]", ret);
}
ret = sync_agent_free_item(get_item);
if (ret != SYNC_AGENT_DA_SUCCESS) {
- _DEBUG_ERROR("sync_agent_free_item() failed !!");
+ _DEBUG_ERROR("sync_agent_free_item() failed, ret[%d]", ret);
}
} else {
ret = da_delete_item_by_item_id_internal(item_id);
if (ret != SYNC_AGENT_DA_SUCCESS) {
- _DEBUG_ERROR("da_delete_item_by_item_id_internal() failed !!");
+ _DEBUG_ERROR("da_delete_item_by_item_id_internal() failed, ret[%d]", ret);
}
}
sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
-// if (item_id == NULL) {
-// _DEBUG_ERROR("item id is NULL !!");
-// return ret;
-// }
-
SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
if (daci_handler == NULL) {
- _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+ _DEBUG_ERROR("[%s] no handler for key");
return ret;
}
return ret;
}
+EXPORT_API sync_agent_da_return_e sync_agent_get_item_data_store_id(char *item_id, sync_agent_da_item_s ** sync_agent_item)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(item_id == NULL, SYNC_AGENT_DA_ERRORS, "item id is NULL !!");
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+ SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+ if (daci_handler == NULL) {
+ _DEBUG_ERROR("[%s] no handler for key");
+ return ret;
+ }
+
+ ret = da_get_item_data_store_id_new(daci_handler, item_id, sync_agent_item);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("da_get_item_data_store_id_new() faied, ret[%d]", ret);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_get_item_account_id(char *item_id, sync_agent_da_item_s ** sync_agent_item)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(item_id == NULL, SYNC_AGENT_DA_ERRORS, "item id is NULL !!");
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+ SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+ if (daci_handler == NULL) {
+ _DEBUG_ERROR("[%s] no handler for key");
+ return ret;
+ }
+
+ ret = da_get_item_account_id_new(daci_handler, item_id, sync_agent_item);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("da_get_item_account_id_new() faied, ret[%d]", ret);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
EXPORT_API sync_agent_da_return_e sync_agent_get_item_list(int account_id, sync_agent_da_get_item_list_query_s * query, GList ** list)
{
_EXTERN_FUNC_ENTER;
#include "data-adapter/interface_service_item.h"
#include "data-adapter/service_internal.h"
+#include <stdlib.h>
+
#ifndef EXPORT_API
#define EXPORT_API __attribute__ ((visibility("default")))
#endif
return ret;
}
+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)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(service_item == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_service_item_s is NULL !!");
+
+ char *service_folder_id = NULL;
+ char service_item_id_tmp[10] = {0,};
+ int service_account_id = 0;
+ int count = 0;
+ int index = 0;
+ int *service_item_id = NULL;
+ int service_item_id_count = 0;
+ void *service_data = NULL;
+ sync_agent_da_return_e da_ret = SYNC_AGENT_DA_SUCCESS;
+ sync_agent_da_item_s *fw_item = NULL;
+ plugin_converter_cb func_converter;
+ plugin_add_bulk_item_cb func_addBulkItem;
+
+ /* 1. get service account id */
+ service_account_id = acc_get_service_account_id(service_item->content_type, service_item->account_id);
+ _DEBUG_INFO(" service_acount_id : [%d]", service_account_id);
+
+ /* 2. get service folder id */
+ service_folder_id = sync_agent_get_service_folder_id(service_item->folder_id);
+ _DEBUG_INFO(" service_folder_id : [%s]", service_folder_id);
+
+ /* 3. call plugIn dataconverter */
+ int converter_plugIn_id = plugin_get_data_converter_plugin_id(service_item->content_type);
+ func_converter = plugin_get_function_converter(converter_plugIn_id);
+ if (func_converter == NULL) {
+ _DEBUG_ERROR(" plugin_get_function_converter() fail, func_converter is NULL");
+ da_ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
+ goto DACI_FINISH;
+ }
+
+ /**************** phase 1 : vcard -> ctsvc struct **********************/
+/*
+ //for test
+ _DEBUG_INFO(" glist[0] = [%s]", (char *)g_list_nth_data((GList *)service_item->data, 0));
+ _DEBUG_INFO(" glist[1] = [%s]", (char *)g_list_nth_data((GList *)service_item->data, 1));
+ _DEBUG_INFO(" glist[%d] = [%s]", g_list_length((GList *)service_item->data)-1, (char *)g_list_nth_data((GList *)service_item->data, g_list_length((GList *)service_item->data)-1));
+*/
+ count = g_list_length((GList *)service_item->data);
+ _DEBUG_INFO(" count of vcard list = [%d]", count);
+
+/*
+ //for test
+ for (index = 0; index < count; ++index) {
+ _DEBUG_INFO(" item id[%d] = [%s]", index, item_id[index]);
+ }
+*/
+ GList *service_data_list = NULL;
+ for (index = 0; index < count; ++index) {
+ da_ret = func_converter((char *)g_list_nth_data((GList *)service_item->data, index), &service_data);
+ if (da_ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR(" func_converter() fail, da_ret[%d]", da_ret);
+ goto DACI_FINISH;
+ }
+ /**************** phase 2 : ctsvc struct -> GList **********************/
+ service_data_list = g_list_append(service_data_list, service_data);
+ }
+ _DEBUG_INFO(" count of ctsvc struct list = [%d]", g_list_length(service_data_list));
+
+
+ /* 4. call plugIn dataconnector */
+ func_addBulkItem = plugin_get_function_add_bulk_item(service_item->content_type);
+ if (func_addBulkItem == NULL) {
+ _DEBUG_ERROR(" plugin_get_function_add_bulk_item() fail, func_addBulkItem is NULL");
+ da_ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
+ goto DACI_FINISH;
+ }
+
+ da_ret = func_addBulkItem(service_account_id, service_folder_id, service_data_list, &service_item_id, &service_item_id_count);
+ if (da_ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR(" func_addBulkItem() fail, da_ret[%d]", da_ret);
+ goto DACI_FINISH;
+ } else {
+ _DEBUG_INFO("added service item id size = [%d]", service_item_id_count);
+ }
+/*
+ //for test
+ int i = 0;
+ for (i = 0; i < service_item_id_count; i++) {
+ _DEBUG_INFO("service_item_id[%d] = [%d]", i, service_item_id[i]);
+ }
+*/
+ /**************** phase 4 : inserted contact DB -> insert kies DB **********************/
+ for (index = 0; index < service_item_id_count; ++index) {
+ da_ret = sync_agent_create_item(&fw_item);
+ if (da_ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_create_item() fail, da_ret[%s]", da_ret);
+ goto DACI_FINISH;
+ }
+ if (fw_item == NULL) {
+ _DEBUG_ERROR("sync_agent_create_item() fail, fw_item is NULL");
+ goto DACI_FINISH;
+ }
+
+ fw_item->data_store_id = service_item->content_type;
+ fw_item->account_id = service_item->account_id;
+ fw_item->item_id = g_strdup(item_id[index]);
+ fw_item->folder_id = g_strdup(service_item->folder_id);
+ memset(service_item_id_tmp, 0, 10);
+ snprintf(service_item_id_tmp, 10, "%d", service_item_id[index]);
+ fw_item->service_id = g_strdup(service_item_id_tmp);
+ fw_item->access_name = g_strdup(service_item->access_name);
+ //for test
+ //_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);
+
+ da_ret = sync_agent_add_item(fw_item, &item_id[index], update_changelog);
+ if (da_ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_add_bulk_item() fail, da_ret[%d]", da_ret);
+ goto DACI_FINISH;
+ } else {
+ //for test
+ //_DEBUG_INFO("sync_agent_add_bulk_item() success, added fw item id = [%s]", item_id[index]);
+ }
+
+ if (fw_item != NULL) {
+ da_ret = sync_agent_free_item(fw_item);
+ if (da_ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_free_item() fail, da_ret[%d]", da_ret);
+ goto DACI_FINISH;
+ }
+ fw_item = NULL;
+ }
+ }
+
+DACI_FINISH:
+ _DEBUG_INFO("daci_finish");
+
+ if (da_ret != SYNC_AGENT_DA_SUCCESS) {
+ *item_id = NULL;
+ }
+
+ if (fw_item != NULL) {
+ da_ret = sync_agent_free_item(fw_item);
+ if (da_ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_free_item() fail, da_ret[%d]", da_ret);
+ }
+ fw_item = NULL;
+ }
+
+ if (service_item_id != NULL) {
+ free(service_item_id);
+ service_item_id = NULL;
+ }
+
+ if (service_folder_id != NULL) {
+ free(service_folder_id);
+ service_folder_id = NULL;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return da_ret;
+}
+
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)
{
_EXTERN_FUNC_ENTER;
free(service_item_id);
_EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+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)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(service_item == NULL, SYNC_AGENT_DA_ERRORS, "service_item is NULL");
+ retvm_if(item_id == NULL, SYNC_AGENT_DA_ERRORS, "item_id is NULL");
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ char *service_item_id = NULL;
+ int index = 0;
+ int count = g_list_length((GList *)service_item->data);
+ void *service_data = NULL;
+ void *new_service_data = NULL;
+ GList *service_data_list = NULL;
+ plugin_get_item_cb func_get_item;
+ plugin_replace_converter_cb func_replace_converter;
+ plugin_update_bulk_item_cb func_update_bulk_item;
+
+ /*Get service_account_id*/
+ int service_account_id = acc_get_service_account_id(service_item->content_type, service_item->account_id);
+ _DEBUG_INFO("service_account_id = [%d]", service_account_id);
+
+ /*Get service_folder_id*/
+ char *service_folder_id = sync_agent_get_service_folder_id(service_item->folder_id);
+ _DEBUG_INFO("service_folder_id = [%s]", service_folder_id);
+
+ /*Get service_item_id*/
+ for (index = 0; index < count; ++index) {
+ service_item_id = sync_agent_get_service_item_id(item_id[index]);
+ _DEBUG_INFO("service_item_id = [%s]", service_item_id);
+
+ /*Get current data*/
+ func_get_item = plugin_get_function_get_item(service_item->content_type);
+ if (func_get_item == NULL) {
+ _DEBUG_ERROR("func_get_item is NULL");
+ ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
+ goto DACI_FINISH;
+ }
+ ret = func_get_item(service_account_id, service_folder_id, service_item_id, &service_data);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("func_get_item() fail, ret[%d]", ret);
+ goto DACI_FINISH;
+ }
+
+ /*Repleace data*/
+ int converter_plugin_id = plugin_get_data_converter_plugin_id(service_item->content_type);
+ func_replace_converter = plugin_get_function_replace_converter(converter_plugin_id);
+ if (func_replace_converter == NULL) {
+ _DEBUG_ERROR("func_replace_converter is NULL");
+ ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
+ goto DACI_FINISH;
+ }
+ ret = func_replace_converter(service_data, ((char *)g_list_nth_data((GList *)service_item->data, index)), &new_service_data);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("func_replace_converter() fail, ret[%d]", ret);
+ goto DACI_FINISH;
+ }
+ service_data_list = g_list_append(service_data_list, new_service_data);
+ }
+
+ func_update_bulk_item = plugin_get_function_update_bulk_item(service_item->content_type);
+ if (func_update_bulk_item == NULL) {
+ _DEBUG_ERROR("func_update_bulk_item is NULL");
+ ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
+ goto DACI_FINISH;
+ }
+ ret = func_update_bulk_item(service_data_list);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("func_update_bulk_item() fail, ret[%d]", ret);
+ }
+
+DACI_FINISH:
+ _DEBUG_INFO("DACI_FINISH");
+
+ if (service_folder_id != NULL) {
+ free(service_folder_id);
+ service_folder_id = NULL;
+ }
+
+ if (service_item_id != NULL) {
+ free(service_item_id);
+ service_item_id = NULL;
+ }
+
+ _EXTERN_FUNC_EXIT;
return ret;
}
return ret;
}
+EXPORT_API sync_agent_da_return_e sync_agent_delete_service_bulk_item(char **item_id, int count, bool update_changelog)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(item_id == NULL, SYNC_AGENT_DA_ERRORS, "item_id is NULL");
+ retvm_if(count == 0, SYNC_AGENT_DA_ERRORS, "count is 0");
+
+ sync_agent_da_return_e da_ret = SYNC_AGENT_DA_SUCCESS;
+ sync_agent_da_item_s *fw_item = NULL;
+ plugin_delete_bulk_item_cb func_del_bulk_item;
+ char *service_item_id_tmp = NULL;
+ int index = 0;
+ int service_item_id[count];
+
+ da_ret = sync_agent_create_item(&fw_item);
+ if (da_ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_create_item() fail, da_Ret[%d]", da_ret);
+ goto DACI_FINISH;
+ }
+/*
+ da_ret = sync_agent_get_item(*item_id, &fw_item);
+ if (da_ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_get_item() fail, da_ret[%d]", da_ret);
+ goto DACI_FINISH;
+ }
+*/
+ da_ret = sync_agent_get_item_data_store_id(*item_id, &fw_item);
+ if (da_ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_get_item_data_store_id() fail, da_ret[%d]", da_ret);
+ goto DACI_FINISH;
+ }
+
+ memset(service_item_id, 0, count);
+ for (index = 0; index < count; ++index) {
+ service_item_id_tmp = sync_agent_get_service_item_id(item_id[index]);
+ //for test
+ //_DEBUG_INFO("service_item_id_tmp = [%s]", service_item_id_tmp);
+ service_item_id[index] = atoi(service_item_id_tmp);
+ //for test
+ //_DEBUG_INFO("item_id[%d] = [%s], service_item_id[%d] = [%d]", index, item_id[index], index, service_item_id[index]);
+ }
+
+ func_del_bulk_item = plugin_get_function_del_bulk_item(fw_item->data_store_id);
+ if (func_del_bulk_item == NULL) {
+ _DEBUG_ERROR("func_del_bulk_item is NULL");
+ da_ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
+ goto DACI_FINISH;
+ }
+
+ da_ret = func_del_bulk_item(service_item_id, count);
+ if (da_ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("func_del_bulk_item() fail, da_ret[%d]", da_ret);
+ goto DACI_FINISH;
+ }
+
+ for (index = 0; index < count; ++index) {
+ da_ret = sync_agent_delete_item(item_id[index], update_changelog);
+ if (da_ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_delete_item() fail, da_ret[%d]", da_ret);
+ goto DACI_FINISH;
+ } else {
+ //for test
+ //_DEBUG_INFO("sync_agent_delete_item() success, deleted fw_item_id = [%s]", item_id[index]);
+ }
+ }
+
+DACI_FINISH:
+ _DEBUG_INFO("daci_finish");
+
+ if (fw_item != NULL) {
+ da_ret = sync_agent_free_item(fw_item);
+ if (da_ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_free_item() fail, da_ret[%d]", da_ret);
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return da_ret;
+}
+
EXPORT_API sync_agent_da_return_e sync_agent_query_delete_service_items(sync_agent_da_delete_service_item_query_s * query)
{
_EXTERN_FUNC_ENTER;
if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
_DEBUG_ERROR("delete mo tree: [%d]", err_code);
dm_free_mo(target_node, 1);
+
+ dm_free_mo(child_node_list, child_node_count);
+
return SYNC_AGENT_DM_MO_FAIL;
}
}
err = sync_agent_get_mo_items(mo_path, &sync_agent_mo_item);
if (err != SYNC_AGENT_DM_MO_SUCCESS) {
_DEBUG_ERROR("remove dm_acc fail, get mo ite fail");
+
+ if(sync_agent_mo_item != NULL) {
+ err = sync_agent_free_mo_item(sync_agent_mo_item);
+ if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_ERROR("free mo tree: [%d]", err);
+ } else {
+ _DEBUG_INFO("free mo success");
+ }
+ }
+
_EXTERN_FUNC_EXIT;
return SYNC_AGENT_DM_MO_FAIL;
}
_DEBUG_INFO("free mo success");
}
+ if(mo_parent_node != NULL) {
+ free(mo_parent_node);
+ mo_parent_node = NULL;
+ }
+
_EXTERN_FUNC_EXIT;
return err;
}
err_code = SYNC_AGENT_DM_MO_FAIL;
goto return_part;
}
+ memset(mo_server_id, 0, sizeof(char)*(server_id_length + 1));
strncpy(mo_server_id, ptr_cmd, server_id_length);
_DEBUG_INFO("[ mo_server_id = %s ]\n", mo_server_id);
return_part:
- if (mo_node != NULL)
+ if (mo_node != NULL) {
dm_free_mo(mo_node, 1);
+ }
+
+ if (mo_server_id != NULL) {
+ free(mo_server_id);
+ mo_server_id = NULL;
+ }
+
_EXTERN_FUNC_EXIT;
return err_code;
}
/* For test log */
__print_agentDBHashTableLog();
#endif
- pthread_mutex_unlock(pMoDBHandlerMgr->mo_handlerTable_mutex);
- if(pKey_copy != NULL) {
- free(pKey_copy);
- }
- _INNER_FUNC_EXIT;
- return ret;
addagentHandler:
pthread_mutex_unlock(pMoDBHandlerMgr->mo_handlerTable_mutex);
- if(pKey_copy != NULL) {
- free(pKey_copy);
- }
+
_INNER_FUNC_EXIT;
+
return ret;
}
va_start(ap, args_cnt);
int err = func_point_execute_dev_function(function_name, args_cnt, ap);
+ _DEBUG_INFO("ret [%d]", err);
if (err != 1) {
_DEBUG_INFO("fail !!\n");
+ res = SYNC_AGENT_DEV_RETURN_FAIL;
} else {
_DEBUG_INFO("success !! \n");
+ res = SYNC_AGENT_DEV_RETURN_SUCCESS;
}
va_end(ap);
retvm_if(child_tasks_info == NULL, NULL, "ec_child_tasks_info_t is NULL !!");
- if (0 <= child_task_index && child_task_index < child_tasks_info->child_task_cnt) {
+ if ( ((unsigned int)0 <= child_task_index) && (child_task_index < child_tasks_info->child_task_cnt)) {
_EXTERN_FUNC_EXIT;
return child_tasks_info->child_task_array[child_task_index];
} else {
retm_if(iter == NULL, "sync_agent_event_data_s is NULL !!");
retm_if(data == NULL, "data is NULL !!");
+ // get type
+ sync_agent_event_param_type_e type = *(iter->data++);
+
+ if (type == SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER) {
+ // get data
+ memcpy(data, iter->data, sizeof(int));
+ iter->data += sizeof(int);
+ } else if (type == SYNC_AGENT_EVENT_PARAM_TYPE_STRING) {
+ int size;
+ // get size
+ memcpy(&size, iter->data, sizeof(int));
+ iter->data += sizeof(int);
+
+ if (size > 0) {
+ // get data
+ char *return_char = (char *)malloc(size * sizeof(char));
+ if (return_char == NULL) {
+ _DEBUG_ERROR("Memory malloc FAILED. [return_char]");
+ } else {
+ memcpy(return_char, iter->data, size * sizeof(char));
+ }
+ iter->data += (sizeof(char) * size);
+
+ *(char **)data = return_char;
+ } else {
+ *(char **)data = NULL;
+ }
+ }
+
+ // setting for next
+ *(iter->size) -= 1;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_get_event_data_param_int(sync_agent_event_data_s * iter, int *data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if(iter == NULL, "sync_agent_event_data_s is NULL !!");
+ retm_if(data == NULL, "data is NULL !!");
+
/* get type */
sync_agent_event_param_type_e type = *(iter->data++);
memcpy(data, iter->data, sizeof(int));
iter->data += sizeof(int);
} else if (type == SYNC_AGENT_EVENT_PARAM_TYPE_STRING) {
+ _DEBUG_ERROR("Recommended : using sync_agent_get_event_data_param_str api");
+ }
+
+ /* setting for next */
+ *(iter->size) -= 1;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_get_event_data_param_str(sync_agent_event_data_s * iter, char ** data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if(iter == NULL, "sync_agent_event_data_s is NULL !!");
+ warn_if(data == NULL, "data is NULL !!");
+
+ /* get type */
+ sync_agent_event_param_type_e type = *(iter->data++);
+
+ if (type == SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER) {
+ /* get data */
+ _DEBUG_ERROR("Recommended : using sync_agent_get_event_data_param_int api");
+ } else if (type == SYNC_AGENT_EVENT_PARAM_TYPE_STRING) {
int size;
/* get size */
memcpy(&size, iter->data, sizeof(int));
}
int event_num;
- sync_agent_get_event_data_param(&request, &event_num);
+ sync_agent_get_event_data_param_int(&request, &event_num);
_DEBUG_TRACE("Received Event Number : %d\n", event_num);
__dispatch_event(event_num, &request, &response);
return UI_SYNC_AGENT_DM_FAIL;
}
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
_DEBUG_ERROR("api_result : failed !!");
sync_agent_free_event(request_event);
return UI_SYNC_AGENT_DM_FAIL;
}
- sync_agent_get_event_data_param(response_event, wifi_only);
+ sync_agent_get_event_data_param_int(response_event, wifi_only);
_DEBUG_VERBOSE("wifi_only : %d", *wifi_only);
return UI_SYNC_AGENT_DM_FAIL;
}
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
_DEBUG_ERROR("api_result : failed !!");
sync_agent_free_event(request_event);
return UI_SYNC_AGENT_DM_FAIL;
}
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
_DEBUG_ERROR("api_result : failed !!");
sync_agent_free_event(request_event);
return UI_SYNC_AGENT_DM_FAIL;
}
- sync_agent_get_event_data_param(response_event, &(((sync_agent_dm_setting_data_s *) * data)->profile_name));
- sync_agent_get_event_data_param(response_event, &(((sync_agent_dm_setting_data_s *) * data)->server_url));
- sync_agent_get_event_data_param(response_event, &(((sync_agent_dm_setting_data_s *) * data)->server_id));
- sync_agent_get_event_data_param(response_event, &(((sync_agent_dm_setting_data_s *) * data)->server_pwd));
- sync_agent_get_event_data_param(response_event, &(((sync_agent_dm_setting_data_s *) * data)->client_id));
- sync_agent_get_event_data_param(response_event, &(((sync_agent_dm_setting_data_s *) * data)->client_pwd));
- sync_agent_get_event_data_param(response_event, &(((sync_agent_dm_setting_data_s *) * data)->client_auth_type));
- sync_agent_get_event_data_param(response_event, &(((sync_agent_dm_setting_data_s *) * data)->server_auth_type));
+ sync_agent_get_event_data_param_str(response_event, &(((sync_agent_dm_setting_data_s *) * data)->profile_name));
+ sync_agent_get_event_data_param_str(response_event, &(((sync_agent_dm_setting_data_s *) * data)->server_url));
+ sync_agent_get_event_data_param_str(response_event, &(((sync_agent_dm_setting_data_s *) * data)->server_id));
+ sync_agent_get_event_data_param_str(response_event, &(((sync_agent_dm_setting_data_s *) * data)->server_pwd));
+ sync_agent_get_event_data_param_str(response_event, &(((sync_agent_dm_setting_data_s *) * data)->client_id));
+ sync_agent_get_event_data_param_str(response_event, &(((sync_agent_dm_setting_data_s *) * data)->client_pwd));
+ sync_agent_get_event_data_param_str(response_event, &(((sync_agent_dm_setting_data_s *) * data)->client_auth_type));
+ sync_agent_get_event_data_param_str(response_event, &(((sync_agent_dm_setting_data_s *) * data)->server_auth_type));
_DEBUG_VERBOSE("profile_name : %s", (*data)->profile_name);
_DEBUG_VERBOSE("server_url : %s", (*data)->server_url);
return UI_SYNC_AGENT_DM_FAIL;
}
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
_DEBUG_ERROR("api_result : failed !!");
sync_agent_free_event(request_event);
return UI_SYNC_AGENT_DM_FAIL;
}
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
_DEBUG_ERROR("api_result : failed !!");
sync_agent_free_event(request_event);
return UI_SYNC_AGENT_DM_FAIL;
}
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
_DEBUG_ERROR("api_result : failed !!");
sync_agent_free_event(request_event);
return SYNC_AGENT_DM_FAIL;
}
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
_DEBUG_ERROR("api_result : failed !!");
sync_agent_free_event(request_event);
return UI_SYNC_AGENT_DM_FAIL;
}
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
_DEBUG_ERROR("api_result : failed !!");
sync_agent_free_event(request_event);
return UI_SYNC_AGENT_DM_FAIL;
}
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
_DEBUG_ERROR("api_result : failed !!");
sync_agent_free_event(request_event);
return UI_SYNC_AGENT_DM_FAIL;
}
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
_DEBUG_ERROR("api_result : failed !!");
sync_agent_free_event(request_event);
return UI_SYNC_AGENT_DM_FAIL;
}
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
_DEBUG_ERROR("api_result : failed !!");
sync_agent_free_event(request_event);
}
char *display_string = NULL;
- sync_agent_get_event_data_param(request, &(alert_option->min_t));
- sync_agent_get_event_data_param(request, &(alert_option->max_t));
- sync_agent_get_event_data_param(request, &(alert_option->default_data));
- sync_agent_get_event_data_param(request, &(alert_option->maxlen));
- sync_agent_get_event_data_param(request, &(alert_option->input_type));
- sync_agent_get_event_data_param(request, &(alert_option->echo_type));
- sync_agent_get_event_data_param(request, &display_string);
+ sync_agent_get_event_data_param_str(request, &(alert_option->min_t));
+ sync_agent_get_event_data_param_str(request, &(alert_option->max_t));
+ sync_agent_get_event_data_param_str(request, &(alert_option->default_data));
+ sync_agent_get_event_data_param_str(request, &(alert_option->maxlen));
+ sync_agent_get_event_data_param_str(request, &(alert_option->input_type));
+ sync_agent_get_event_data_param_str(request, &(alert_option->echo_type));
+ sync_agent_get_event_data_param_str(request, &display_string);
_DEBUG_VERBOSE("min_t : %s", alert_option->min_t);
_DEBUG_VERBOSE("max_t : %s", alert_option->max_t);
}
char *display_string = NULL;
- sync_agent_get_event_data_param(request, &(alert_option->min_t));
- sync_agent_get_event_data_param(request, &(alert_option->max_t));
- sync_agent_get_event_data_param(request, &(alert_option->default_data));
- sync_agent_get_event_data_param(request, &(alert_option->maxlen));
- sync_agent_get_event_data_param(request, &(alert_option->input_type));
- sync_agent_get_event_data_param(request, &(alert_option->echo_type));
- sync_agent_get_event_data_param(request, &display_string);
+ sync_agent_get_event_data_param_str(request, &(alert_option->min_t));
+ sync_agent_get_event_data_param_str(request, &(alert_option->max_t));
+ sync_agent_get_event_data_param_str(request, &(alert_option->default_data));
+ sync_agent_get_event_data_param_str(request, &(alert_option->maxlen));
+ sync_agent_get_event_data_param_str(request, &(alert_option->input_type));
+ sync_agent_get_event_data_param_str(request, &(alert_option->echo_type));
+ sync_agent_get_event_data_param_str(request, &display_string);
_DEBUG_VERBOSE("min_t : %s", alert_option->min_t);
_DEBUG_VERBOSE("max_t : %s", alert_option->max_t);
}
char *display_string = NULL;
- sync_agent_get_event_data_param(request, &(alert_option->min_t));
- sync_agent_get_event_data_param(request, &(alert_option->max_t));
- sync_agent_get_event_data_param(request, &(alert_option->default_data));
- sync_agent_get_event_data_param(request, &(alert_option->maxlen));
- sync_agent_get_event_data_param(request, &(alert_option->input_type));
- sync_agent_get_event_data_param(request, &(alert_option->echo_type));
- sync_agent_get_event_data_param(request, &display_string);
+ sync_agent_get_event_data_param_str(request, &(alert_option->min_t));
+ sync_agent_get_event_data_param_str(request, &(alert_option->max_t));
+ sync_agent_get_event_data_param_str(request, &(alert_option->default_data));
+ sync_agent_get_event_data_param_str(request, &(alert_option->maxlen));
+ sync_agent_get_event_data_param_str(request, &(alert_option->input_type));
+ sync_agent_get_event_data_param_str(request, &(alert_option->echo_type));
+ sync_agent_get_event_data_param_str(request, &display_string);
_DEBUG_VERBOSE("min_t : %s", alert_option->min_t);
_DEBUG_VERBOSE("max_t : %s", alert_option->max_t);
int item_count = 0;
char *item = NULL;
- sync_agent_get_event_data_param(request, &(alert_option->min_t));
- sync_agent_get_event_data_param(request, &(alert_option->max_t));
- sync_agent_get_event_data_param(request, &(alert_option->default_data));
- sync_agent_get_event_data_param(request, &(alert_option->maxlen));
- sync_agent_get_event_data_param(request, &(alert_option->input_type));
- sync_agent_get_event_data_param(request, &(alert_option->echo_type));
- sync_agent_get_event_data_param(request, &display_string);
- sync_agent_get_event_data_param(request, &item_count);
- sync_agent_get_event_data_param(request, &item);
+ sync_agent_get_event_data_param_str(request, &(alert_option->min_t));
+ sync_agent_get_event_data_param_str(request, &(alert_option->max_t));
+ sync_agent_get_event_data_param_str(request, &(alert_option->default_data));
+ sync_agent_get_event_data_param_str(request, &(alert_option->maxlen));
+ sync_agent_get_event_data_param_str(request, &(alert_option->input_type));
+ sync_agent_get_event_data_param_str(request, &(alert_option->echo_type));
+ sync_agent_get_event_data_param_str(request, &display_string);
+ sync_agent_get_event_data_param_int(request, &item_count);
+ sync_agent_get_event_data_param_str(request, &item);
_DEBUG_VERBOSE("min_t : %s", alert_option->min_t);
_DEBUG_VERBOSE("max_t : %s", alert_option->max_t);
GList *item_list = NULL;
GList *iter = NULL;
- sync_agent_get_event_data_param(request, &(alert_option->min_t));
- sync_agent_get_event_data_param(request, &(alert_option->max_t));
- sync_agent_get_event_data_param(request, &(alert_option->default_data));
- sync_agent_get_event_data_param(request, &(alert_option->maxlen));
- sync_agent_get_event_data_param(request, &(alert_option->input_type));
- sync_agent_get_event_data_param(request, &(alert_option->echo_type));
- sync_agent_get_event_data_param(request, &display_string);
- sync_agent_get_event_data_param(request, &item_count);
+ sync_agent_get_event_data_param_str(request, &(alert_option->min_t));
+ sync_agent_get_event_data_param_str(request, &(alert_option->max_t));
+ sync_agent_get_event_data_param_str(request, &(alert_option->default_data));
+ sync_agent_get_event_data_param_str(request, &(alert_option->maxlen));
+ sync_agent_get_event_data_param_str(request, &(alert_option->input_type));
+ sync_agent_get_event_data_param_str(request, &(alert_option->echo_type));
+ sync_agent_get_event_data_param_str(request, &display_string);
+ sync_agent_get_event_data_param_int(request, &item_count);
_DEBUG_VERBOSE("min_t : %s", alert_option->min_t);
_DEBUG_VERBOSE("max_t : %s", alert_option->max_t);
for (; i < item_count; i++) {
char *item = NULL;
- sync_agent_get_event_data_param(request, &item);
+ sync_agent_get_event_data_param_str(request, &item);
_DEBUG_VERBOSE("item : %s", item);
item_list = g_list_append(item_list, item);
}
return UI_SYNC_AGENT_DM_FAIL;
}
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
_DEBUG_ERROR("api_result : failed !!");
sync_agent_free_event(request_event);
return UI_SYNC_AGENT_DM_FAIL;
}
- sync_agent_get_event_data_param(response_event, user_pin_val);
+ sync_agent_get_event_data_param_int(response_event, user_pin_val);
_DEBUG_VERBOSE("user pin validation value : %d", *user_pin_val);
/* free request & response event */
return UI_SYNC_AGENT_DM_FAIL;
}
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
_DEBUG_ERROR("api_result : failed !!");
sync_agent_free_event(request_event);
return UI_SYNC_AGENT_DM_FAIL;
}
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
_DEBUG_ERROR("api_result : failed !!");
sync_agent_free_event(request_event);
int file_size = 0;
char *file_path = NULL;
- sync_agent_get_event_data_param(request, &file_size);
- sync_agent_get_event_data_param(request, &file_path);
- sync_agent_get_event_data_param(request, &task_id);
+ sync_agent_get_event_data_param_int(request, &file_size);
+ sync_agent_get_event_data_param_str(request, &file_path);
+ sync_agent_get_event_data_param_int(request, &task_id);
_DEBUG_VERBOSE("file_size : %d", file_size);
_DEBUG_VERBOSE("file_path : %s", file_path);
{
_INNER_FUNC_ENTER;
- sync_agent_get_event_data_param(request, &task_id);
+ sync_agent_get_event_data_param_int(request, &task_id);
_DEBUG_VERBOSE("task id : %d", task_id);
int prev_noti_id = -1;
int fail_type = -1;
- sync_agent_get_event_data_param(request, &prev_noti_id);
- sync_agent_get_event_data_param(request, &fail_type);
+ sync_agent_get_event_data_param_int(request, &prev_noti_id);
+ sync_agent_get_event_data_param_int(request, &fail_type);
_DEBUG_VERBOSE("previous noti id : %d", prev_noti_id);
_DEBUG_VERBOSE("fail type : %d", fail_type);
int file_size = 0;
- sync_agent_get_event_data_param(request, &file_size);
+ sync_agent_get_event_data_param_int(request, &file_size);
_DEBUG_VERBOSE("file_size : %d", file_size);
char *battery_level = NULL;
- sync_agent_get_event_data_param(request, &battery_level);
+ sync_agent_get_event_data_param_str(request, &battery_level);
_DEBUG_VERBOSE("battery level : %s", battery_level);
return SYNC_AGENT_DM_API_RESULT_FAILURE;
}
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
_DEBUG_ERROR("api_result : failed !!");
sync_agent_free_event(request_event);
int file_size = 0;
char *file_path = NULL;
- sync_agent_get_event_data_param(request, &file_size);
- sync_agent_get_event_data_param(request, &file_path);
- sync_agent_get_event_data_param(request, &task_id);
+ sync_agent_get_event_data_param_int(request, &file_size);
+ sync_agent_get_event_data_param_str(request, &file_path);
+ sync_agent_get_event_data_param_int(request, &task_id);
_DEBUG_VERBOSE("file_size : %d", file_size);
_DEBUG_VERBOSE("file_path : %s", file_path);
{
_INNER_FUNC_ENTER;
- sync_agent_get_event_data_param(request, &task_id);
+ sync_agent_get_event_data_param_int(request, &task_id);
_DEBUG_VERBOSE("task id : %d", task_id);
int prev_noti_id = -1;
int fail_type = -1;
- sync_agent_get_event_data_param(request, &prev_noti_id);
- sync_agent_get_event_data_param(request, &fail_type);
+ sync_agent_get_event_data_param_int(request, &prev_noti_id);
+ sync_agent_get_event_data_param_int(request, &fail_type);
_DEBUG_VERBOSE("previous noti id : %d", prev_noti_id);
_DEBUG_VERBOSE("fail type : %d", fail_type);
int file_size = 0;
- sync_agent_get_event_data_param(request, &file_size);
+ sync_agent_get_event_data_param_int(request, &file_size);
_DEBUG_VERBOSE("file_size : %d", file_size);
char *battery_level = NULL;
- sync_agent_get_event_data_param(request, &battery_level);
+ sync_agent_get_event_data_param_str(request, &battery_level);
_DEBUG_VERBOSE("battery level : %s", battery_level);
return SYNC_AGENT_DM_API_RESULT_FAILURE;
}
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
_DEBUG_ERROR("api_result : failed !!");
sync_agent_free_event(request_event);
* must coding
*
*/
+ int api_result = SYNC_AGENT_DM_API_RESULT_SUCCESS;
+ sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+ sync_agent_event_data_s *request_event = NULL;
+ sync_agent_event_data_s *response_event = NULL;
+
+ request_event = sync_agent_create_event(EVENT_ACCOUNT_REGISTRATION);
+ if (request_event == NULL) {
+ _DEBUG_ERROR("request_event is NULL !!");
+ _EXTERN_FUNC_EXIT;
+ return UI_SYNC_AGENT_DM_FAIL;
+ }
+
+ _DEBUG_VERBOSE("event num : %d", EVENT_ACCOUNT_REGISTRATION);
+ //sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &dmacc_type);
+ //_DEBUG_VERBOSE("DMACC TYPE : %d", dmacc_type);
+
+ response_event = sync_agent_send_event(request_event, &error);
+ if (error != SYNC_AGENT_EVENT_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_send_event() failed !! - err = %d", error);
+ sync_agent_free_event(request_event);
+ _EXTERN_FUNC_EXIT;
+ return UI_SYNC_AGENT_DM_FAIL;
+ }
+
+ if (response_event == NULL) {
+ _DEBUG_ERROR("response_event is NULL !!");
+ sync_agent_free_event(request_event);
+ _EXTERN_FUNC_EXIT;
+ return UI_SYNC_AGENT_DM_FAIL;
+ }
+
+ sync_agent_get_event_data_param_int(response_event, &api_result);
+ if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+ _DEBUG_ERROR("api_result : failed !!");
+ sync_agent_free_event(request_event);
+ sync_agent_free_event_data(response_event);
+ _EXTERN_FUNC_EXIT;
+ return UI_SYNC_AGENT_DM_FAIL;
+ }
+
+ /* free request & response event */
+ sync_agent_free_event(request_event);
+ sync_agent_free_event_data(response_event);
+
+
_EXTERN_FUNC_EXIT;
return result;
}
+
#include <string.h>
#include <glib.h>
+#include <dbus/dbus-glib.h>
#ifndef SYNC_AGENT_LOG
#undef LOG_TAG
#define SYNC_AGENT_DS_API_RESULT_FAILURE 0
#define SYNC_AGENT_DS_API_RESULT_SUCCESS 1
+#define SYNC_TYPE_SLOW_SYNC_STR "Full"
+#define SYNC_TYPE_TWO_WAY_STR "Update both"
+#define SYNC_TYPE_ONE_WAY_FROM_CLIENT_STR "Update to server"
+#define SYNC_TYPE_ONE_WAY_FROM_SERVER_STR "Update to phone"
+#define SYNC_TYPE_REFRESH_FROM_SERVER_STR "Refresh from server"
+#define SYNC_TYPE_REFRESH_FROM_CLIENT_STR "Refresh from phone"
+
+#define SYNC_MODE_MANUAL_STR "Manual"
+#define SYNC_MODE_PUSH_STR "Push"
+#define SYNC_MODE_PERIODIC_STR "Periodic"
+
+#define SYNC_INTERVAL_5_MINUTES "5 minutes"
+#define SYNC_INTERVAL_15_MINUTES "15 minutes"
+#define SYNC_INTERVAL_1_HOUR "1 hour"
+#define SYNC_INTERVAL_4_HOURS "4 hours"
+#define SYNC_INTERVAL_12_HOURS "12 hours"
+#define SYNC_INTERVAL_1_DAY "1 day"
+#define SYNC_INTERVAL_1_WEEK "1 week"
+#define SYNC_INTERVAL_1_MONTH "1 month"
+
+#define SRC_URI_CONTACT_STR "Contacts"
+#define SRC_URI_CALENDAR_STR "Organizer"
+
typedef enum {
SYNC_AGENT_DS_ADD_PROFILE = 1,
SYNC_AGENT_DS_UPDATE_PROFILE = 2,
/* get response parameter from event packet */
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result == SYNC_AGENT_DS_API_RESULT_FAILURE) {
_DEBUG_ERROR("api_result = failed");
sync_agent_free_event(request_event);
return SYNC_AGENT_DS_FAIL;
}
- sync_agent_get_event_data_param(response_event, &((*service)->enabled));
- sync_agent_get_event_data_param(response_event, &((*service)->src_uri));
- sync_agent_get_event_data_param(response_event, &((*service)->tgt_uri));
- sync_agent_get_event_data_param(response_event, &((*service)->id));
- sync_agent_get_event_data_param(response_event, &((*service)->password));
+ sync_agent_get_event_data_param_int(response_event, &((*service)->enabled));
+ sync_agent_get_event_data_param_int(response_event, (int*) &((*service)->src_uri));
+ sync_agent_get_event_data_param_str(response_event, &((*service)->tgt_uri));
+ sync_agent_get_event_data_param_str(response_event, &((*service)->id));
+ sync_agent_get_event_data_param_str(response_event, &((*service)->password));
_DEBUG_TRACE("enabled = %d", (*service)->enabled);
- _DEBUG_TRACE("src_uri = %s", (*service)->src_uri);
+ _DEBUG_TRACE("src_uri = %d", (*service)->src_uri);
_DEBUG_TRACE("tgt_uri = %s", (*service)->tgt_uri);
_DEBUG_TRACE("id = %s", (*service)->id);
_DEBUG_TRACE("password = %s", (*service)->password);
/* get response parameter from event packet */
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result == SYNC_AGENT_DS_API_RESULT_FAILURE) {
_DEBUG_ERROR("api_result = failed");
sync_agent_free_event(request_event);
else if (service_type == SYNC_AGENT_DS_SYNC_MEMO)
statistics_cat = "memo";
- sync_agent_get_event_data_param(response_event, &((*statistics)->dbsynced));
- sync_agent_get_event_data_param(response_event, &((*statistics)->last_session_time));
- sync_agent_get_event_data_param(response_event, &((*statistics)->server2client_total));
- sync_agent_get_event_data_param(response_event, &((*statistics)->server2client_nrofadd));
- sync_agent_get_event_data_param(response_event, &((*statistics)->server2client_nrofdelete));
- sync_agent_get_event_data_param(response_event, &((*statistics)->server2client_nrofreplace));
- sync_agent_get_event_data_param(response_event, &((*statistics)->client2server_total));
- sync_agent_get_event_data_param(response_event, &((*statistics)->client2server_nrofadd));
- sync_agent_get_event_data_param(response_event, &((*statistics)->client2server_nrofdelete));
- sync_agent_get_event_data_param(response_event, &((*statistics)->client2server_nrofreplace));
+ sync_agent_get_event_data_param_str(response_event, &((*statistics)->dbsynced));
+ sync_agent_get_event_data_param_int(response_event, &((*statistics)->last_session_time));
+ sync_agent_get_event_data_param_int(response_event, &((*statistics)->server2client_total));
+ sync_agent_get_event_data_param_int(response_event, &((*statistics)->server2client_nrofadd));
+ sync_agent_get_event_data_param_int(response_event, &((*statistics)->server2client_nrofdelete));
+ sync_agent_get_event_data_param_int(response_event, &((*statistics)->server2client_nrofreplace));
+ sync_agent_get_event_data_param_int(response_event, &((*statistics)->client2server_total));
+ sync_agent_get_event_data_param_int(response_event, &((*statistics)->client2server_nrofadd));
+ sync_agent_get_event_data_param_int(response_event, &((*statistics)->client2server_nrofdelete));
+ sync_agent_get_event_data_param_int(response_event, &((*statistics)->client2server_nrofreplace));
_DEBUG_TRACE("%s dbSynced = %s", statistics_cat, (*statistics)->dbsynced);
_DEBUG_TRACE("%s lastSessionTime = %d", statistics_cat, (*statistics)->last_session_time);
return TRUE;
}
+static char * _convert_sync_mode_str(sync_agent_ds_sync_mode_e sync_mode)
+{
+ _INNER_FUNC_ENTER;
+
+ char* sync_mode_str = NULL;
+
+ _DEBUG_INFO("sync_mode : [%d]",sync_mode);
+ switch(sync_mode) {
+ case SYNC_AGENT_SYNC_MODE_MANUAL:
+ sync_mode_str = SYNC_MODE_MANUAL_STR;
+ break;
+ case SYNC_AGENT_SYNC_MODE_PERIODIC:
+ sync_mode_str = SYNC_MODE_PERIODIC_STR;
+ break;
+ case SYNC_AGENT_SYNC_MODE_PUSH:
+ sync_mode_str = SYNC_MODE_PUSH_STR;
+ break;
+ default:
+ break;
+ }
+
+ _INNER_FUNC_EXIT;
+ return sync_mode_str;
+}
+
+static char * _convert_sync_type_str(sync_agent_ds_sync_type_e sync_type)
+{
+ _INNER_FUNC_ENTER;
+
+ char* sync_type_str = NULL;
+
+ _DEBUG_INFO("sync_type : [%d]",sync_type);
+ switch(sync_type) {
+ case SYNC_AGENT_SYNC_TYPE_FULL_SYNC:
+ sync_type_str = SYNC_TYPE_SLOW_SYNC_STR;
+ break;
+ case SYNC_AGENT_SYNC_TYPE_UPDATE_BOTH:
+ sync_type_str = SYNC_TYPE_TWO_WAY_STR;
+ break;
+ case SYNC_AGENT_SYNC_TYPE_UPDATE_TO_SERVER:
+ sync_type_str = SYNC_TYPE_ONE_WAY_FROM_CLIENT_STR;
+ break;
+ case SYNC_AGENT_SYNC_TYPE_UPDATE_TO_PHONE:
+ sync_type_str = SYNC_TYPE_ONE_WAY_FROM_SERVER_STR;
+ break;
+ case SYNC_AGENT_SYNC_TYPE_REFRESH_FROM_SERVER:
+ sync_type_str = SYNC_TYPE_REFRESH_FROM_SERVER_STR;
+ break;
+ case SYNC_AGENT_SYNC_TYPE_REFRESH_FROM_PHONE:
+ sync_type_str = SYNC_TYPE_REFRESH_FROM_CLIENT_STR;
+ break;
+ default:
+ break;
+ }
+
+ _INNER_FUNC_EXIT;
+ return sync_type_str;
+}
+
+static char * _convert_sync_interval_str(sync_agent_ds_sync_interval_e interval)
+{
+ _INNER_FUNC_ENTER;
+
+ char* interval_str = NULL;
+
+ _DEBUG_INFO("interval : [%d]",interval);
+ switch(interval) {
+ case SYNC_AGENT_SYNC_INTERVAL_5_MINUTES:
+ interval_str = SYNC_INTERVAL_5_MINUTES;
+ break;
+ case SYNC_AGENT_SYNC_INTERVAL_15_MINUTES:
+ interval_str = SYNC_INTERVAL_15_MINUTES;
+ break;
+ case SYNC_AGENT_SYNC_INTERVAL_1_HOUR:
+ interval_str = SYNC_INTERVAL_1_HOUR;
+ break;
+ case SYNC_AGENT_SYNC_INTERVAL_4_HOURS:
+ interval_str = SYNC_INTERVAL_4_HOURS;
+ break;
+ case SYNC_AGENT_SYNC_INTERVAL_12_HOURS:
+ interval_str = SYNC_INTERVAL_12_HOURS;
+ break;
+ case SYNC_AGENT_SYNC_INTERVAL_1_DAY:
+ interval_str = SYNC_INTERVAL_1_DAY;
+ break;
+ case SYNC_AGENT_SYNC_INTERVAL_1_WEEK:
+ interval_str = SYNC_INTERVAL_1_WEEK;
+ break;
+ case SYNC_AGENT_SYNC_INTERVAL_1_MONTH:
+ interval_str = SYNC_INTERVAL_1_MONTH;
+ break;
+ default:
+ break;
+ }
+
+ _INNER_FUNC_EXIT;
+ return interval_str;
+}
+
+static char * _convert_src_uri_str(sync_agent_ds_src_uri_e src_uri)
+{
+ _INNER_FUNC_ENTER;
+
+ char* src_uri_str = NULL;
+
+ _DEBUG_INFO("src_uri : [%d]",src_uri);
+ switch(src_uri) {
+ case SYNC_AGENT_SRC_URI_CONTACT:
+ src_uri_str = SRC_URI_CONTACT_STR;
+ break;
+ case SYNC_AGENT_SRC_URI_CALENDAR:
+ src_uri_str = SRC_URI_CALENDAR_STR;
+ break;
+ default:
+ break;
+ }
+
+ _INNER_FUNC_EXIT;
+ return src_uri_str;
+}
+
static void _free_sync_category_info(sync_agent_ds_service_info * data)
{
- g_free(data->src_uri);
g_free(data->tgt_uri);
g_free(data->id);
g_free(data->password);
}
+static gboolean _is_existing_profile(void)
+{
+ _INNER_FUNC_ENTER;
+
+ int event_type = SYNC_AGENT_DS_GET_ALL_PROFILES;
+ sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+ sync_agent_event_data_s *request_event = NULL;
+ sync_agent_event_data_s *response_event = NULL;
+
+ int profile_count = 0;
+
+ int api_result = SYNC_AGENT_DS_API_RESULT_SUCCESS;
+
+ /* create empty event packet */
+ request_event = sync_agent_create_event(event_type);
+ if (request_event == NULL) {
+ _DEBUG_ERROR("event is NULL");
+ _INNER_FUNC_EXIT;
+ return SYNC_AGENT_DS_FAIL;
+ }
+
+ /* send event request to ds agent daemon, waiting for response */
+ response_event = sync_agent_send_event(request_event, &error);
+ if (error != SYNC_AGENT_EVENT_SUCCESS) {
+ _DEBUG_ERROR("error = %d", error);
+ sync_agent_free_event(request_event);
+ _INNER_FUNC_EXIT;
+ return SYNC_AGENT_DS_FAIL;
+ }
+ if (response_event == NULL) {
+ _DEBUG_ERROR("response_event is null!!");
+ sync_agent_free_event(request_event);
+ _INNER_FUNC_EXIT;
+ return SYNC_AGENT_DS_FAIL;
+ }
+
+ sync_agent_get_event_data_param_int(response_event, &api_result);
+ if (api_result == SYNC_AGENT_DS_API_RESULT_FAILURE) {
+ _DEBUG_ERROR("api_result = failed");
+ sync_agent_free_event(request_event);
+ sync_agent_free_event_data(response_event);
+ _INNER_FUNC_EXIT;
+ return SYNC_AGENT_DS_FAIL;
+ }
+
+ sync_agent_get_event_data_param_int(response_event, &profile_count);
+ _DEBUG_INFO("profile_count = %d", profile_count);
+
+ if (profile_count > 0) {
+ sync_agent_free_event(request_event);
+ sync_agent_free_event_data(response_event);
+
+ _INNER_FUNC_EXIT;
+ return TRUE;
+ }
+
+ /* free request & response event */
+ sync_agent_free_event(request_event);
+ sync_agent_free_event_data(response_event);
+
+ _INNER_FUNC_EXIT;
+
+ return FALSE;
+}
+
+static int _launch_omads_agent(void)
+{
+ _INNER_FUNC_ENTER;
+ GError *error = NULL;
+
+ DBusGConnection *connection = NULL;
+ DBusGProxy *dbus_proxy = NULL;
+
+ g_type_init();
+
+ connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
+ if (error != NULL) {
+ _DEBUG_ERROR("Connecting to system bus failed: %s\n", error->message);
+ g_error_free(error);
+ _INNER_FUNC_EXIT;
+ return -1;
+ }
+
+ dbus_proxy = dbus_g_proxy_new_for_name(connection, "com.samsung.omadsagent",
+ "/com/samsung/omadsagent", "com.samsung.omadsagent");
+
+ _DEBUG_INFO("dbus_proxy %x", dbus_proxy);
+
+ //dbus_g_proxy_call_no_reply(dbus_proxy, "Hello_Agent", G_TYPE_INVALID);
+ dbus_g_proxy_call(dbus_proxy, "Hello_Agent", &error, G_TYPE_INVALID, G_TYPE_INVALID);
+
+ g_object_unref(dbus_proxy);
+ dbus_g_connection_unref(connection);
+
+ _INNER_FUNC_EXIT;
+ return 0;
+}
+
+static int _kill_omads_agent(void)
+{
+ _INNER_FUNC_ENTER;
+ GError *error = NULL;
+
+ DBusGConnection *connection = NULL;
+ DBusGProxy *dbus_proxy = NULL;
+ gboolean isExisting = FALSE;
+
+ isExisting = _is_existing_profile();
+
+ if(isExisting) {
+ _DEBUG_INFO("Existing profile !!");
+
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+
+ connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
+ if (error != NULL) {
+ _DEBUG_ERROR("Connecting to system bus failed: %s\n", error->message);
+ g_error_free(error);
+ _INNER_FUNC_EXIT;
+ return -1;
+ }
+
+ dbus_proxy = dbus_g_proxy_new_for_name(connection, "com.samsung.omadsagent",
+ "/com/samsung/omadsagent", "com.samsung.omadsagent");
+
+ _DEBUG_INFO("dbus_proxy %x", dbus_proxy);
+
+ dbus_g_proxy_call_no_reply(dbus_proxy, "Goodbye_Agent", G_TYPE_INVALID);
+
+ g_object_unref(dbus_proxy);
+ dbus_g_connection_unref(connection);
+
+ _INNER_FUNC_EXIT;
+ return 0;
+}
+
EXPORT_API sync_agent_ds_error_e sync_agent_ds_init()
{
_EXTERN_FUNC_ENTER;
sync_agent_ds_error_e result = SYNC_AGENT_DS_SUCCESS;
+ sync_agent_init_error_e init_error = SYNC_AGENT_INIT_SUCCESS;
+ int ret = -1;
+
+ ret = _launch_omads_agent();
- sync_agent_init_error_e init_error = sync_agent_init(OMA_DS_CONFIG_FILE);
+ if (ret < 0 ) {
+ _DEBUG_ERROR("_launch_omads_agent() failed !!");
+ result = SYNC_AGENT_DS_FAIL;
+
+ _EXTERN_FUNC_EXIT;
+ return result;
+ }
+
+ init_error = sync_agent_init(OMA_DS_CONFIG_FILE);
if (init_error != SYNC_AGENT_INIT_SUCCESS) {
_DEBUG_ERROR("ds init failed");
return result;
}
-EXPORT_API sync_agent_ds_error_e sync_agent_ds_set_profile_name(ds_profile_h profile_h, char *profile_dir_name, char *profile_name)
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_set_profile_dir_name(ds_profile_h profile_h, char *profile_dir_name)
{
_EXTERN_FUNC_ENTER;
- sync_agent_ds_error_e result = SYNC_AGENT_DS_SUCCESS;
- sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
-
// check mandatory parameter
retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
retvm_if(profile_dir_name == NULL, SYNC_AGENT_DS_FAIL, "profile_dir_name is null!!");
+ sync_agent_ds_error_e result = SYNC_AGENT_DS_SUCCESS;
+ sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
+
// set profile name
profile_info->profile_dir_name = g_strdup(profile_dir_name);
- profile_info->profile_name = g_strdup(profile_name);
if (profile_info->profile_dir_name == NULL) {
_DEBUG_ERROR("g_strdup failed !!");
return result;
}
-EXPORT_API sync_agent_ds_error_e sync_agent_ds_set_server_info(ds_profile_h profile_h, char *addr, char *id, char *password)
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_set_profile_name(ds_profile_h profile_h, char *profile_name)
{
_EXTERN_FUNC_ENTER;
+ // check mandatory parameter
+ retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
+ retvm_if(profile_name == NULL, SYNC_AGENT_DS_FAIL, "profile_name is null!!");
+
sync_agent_ds_error_e result = SYNC_AGENT_DS_SUCCESS;
sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
- sync_agent_ds_server_info *server_info = &profile_info->server_info;
+
+ // set profile name
+ profile_info->profile_name = g_strdup(profile_name);
+
+ if (profile_info->profile_name == NULL) {
+ _DEBUG_ERROR("g_strdup failed !!");
+ return SYNC_AGENT_DS_FAIL;
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+ return result;
+}
+
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_set_server_info(ds_profile_h profile_h, char *addr, char *id, char *password)
+{
+ _EXTERN_FUNC_ENTER;
// check mandatory parameter
retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
retvm_if(id == NULL, SYNC_AGENT_DS_FAIL, "id is null!!");
retvm_if(password == NULL, SYNC_AGENT_DS_FAIL, "password is null!!");
+ sync_agent_ds_error_e result = SYNC_AGENT_DS_SUCCESS;
+ sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
+ sync_agent_ds_server_info *server_info = &profile_info->server_info;
+
// set server info
server_info->addr = g_strdup(addr);
server_info->id = g_strdup(id);
return result;
}
-EXPORT_API sync_agent_ds_error_e sync_agent_ds_set_sync_info(ds_profile_h profile_h, char *sync_mode, char *sync_type, char *interval)
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_set_sync_info(ds_profile_h profile_h, sync_agent_ds_sync_mode_e sync_mode, sync_agent_ds_sync_type_e sync_type, sync_agent_ds_sync_interval_e interval)
{
_EXTERN_FUNC_ENTER;
+ // check mandatory parameter
+ retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
+ retvm_if(sync_mode < 0, SYNC_AGENT_DS_FAIL, "sync_mode is invalid!!");
+ retvm_if(sync_type < 0, SYNC_AGENT_DS_FAIL, "sync_type is invalid!!");
+ retvm_if(interval < 0, SYNC_AGENT_DS_FAIL, "interval is invalid!!");
+
sync_agent_ds_error_e result = SYNC_AGENT_DS_SUCCESS;
sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
sync_agent_ds_sync_info *sync_info = &profile_info->sync_info;
- // check mandatory parameter
- retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
- retvm_if(sync_mode == NULL, SYNC_AGENT_DS_FAIL, "sync_mode is null!!");
- retvm_if(sync_type == NULL, SYNC_AGENT_DS_FAIL, "sync_type is null!!");
- retvm_if(interval == NULL, SYNC_AGENT_DS_FAIL, "interval is null!!");
+ char* sync_mode_str = NULL;
+ char* sync_type_str = NULL;
+ char* interval_str = NULL;
- // set server info
- sync_info->sync_mode = g_strdup(sync_mode);
- sync_info->sync_type = g_strdup(sync_type);
- sync_info->interval = g_strdup(interval);
+ sync_mode_str = _convert_sync_mode_str(sync_mode);
+ if (sync_mode_str == NULL) {
+ _DEBUG_ERROR("_convert_sync_mode_str failed !!");
+ _EXTERN_FUNC_EXIT;
+ return SYNC_AGENT_DS_FAIL;
+ }
- if ((sync_info->sync_mode == NULL)
- || (sync_info->sync_type == NULL)
- || (sync_info->interval == NULL)) {
- _DEBUG_ERROR("g_strdup failed !!");
+ sync_type_str = _convert_sync_type_str(sync_type);
+ if (sync_type_str == NULL) {
+ _DEBUG_ERROR("_convert_sync_type_str failed !!");
+ _EXTERN_FUNC_EXIT;
+ return SYNC_AGENT_DS_FAIL;
+ }
+
+ interval_str = _convert_sync_interval_str(interval);
+ if (interval_str == NULL) {
+ _DEBUG_ERROR("_convert_sync_interval_str failed !!");
+ _EXTERN_FUNC_EXIT;
return SYNC_AGENT_DS_FAIL;
}
+ // set server info
+ sync_info->sync_mode = sync_mode;
+ sync_info->sync_type = sync_type;
+ sync_info->interval = interval;
+
_EXTERN_FUNC_EXIT;
return result;
}
-EXPORT_API sync_agent_ds_error_e sync_agent_ds_set_sync_service_info(ds_profile_h profile_h, sync_agent_ds_service_type_e service_type, int enabled, char *src_uri, char *tgt_uri, char *id, char *password)
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_set_sync_service_info(ds_profile_h profile_h, sync_agent_ds_service_type_e service_type, int enabled, sync_agent_ds_src_uri_e src_uri, char *tgt_uri, char *id, char *password)
{
_EXTERN_FUNC_ENTER;
+ // check mandatory parameter
+ retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
+ retvm_if(src_uri < 0, SYNC_AGENT_DS_FAIL, "src_uri is invalid!!");
+
sync_agent_ds_error_e result = SYNC_AGENT_DS_SUCCESS;
sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
sync_agent_ds_service_info *category_info = NULL;
+ char* src_uri_str = NULL;
- // check mandatory parameter
- retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
- retvm_if(src_uri == NULL, SYNC_AGENT_DS_FAIL, "src_uri is null!!");
+ src_uri_str = _convert_src_uri_str(src_uri);
+ if (src_uri_str == NULL) {
+ _DEBUG_ERROR("_get_src_uri_string failed !!");
+ _EXTERN_FUNC_EXIT;
+ return SYNC_AGENT_DS_FAIL;
+ }
// allocate memory for sync_category
category_info = (sync_agent_ds_service_info *) calloc(1, sizeof(sync_agent_ds_service_info));
retvm_if(category_info == NULL, SYNC_AGENT_DS_FAIL, "calloc failed");
category_info->service_type = service_type;
category_info->enabled = enabled;
- category_info->src_uri = g_strdup(src_uri);
+ category_info->src_uri = src_uri;
category_info->tgt_uri = g_strdup(tgt_uri);
profile_info->service_list = g_list_append(profile_info->service_list, category_info);
- if (category_info->src_uri == NULL) {
+ _EXTERN_FUNC_EXIT;
+
+ return result;
+}
+
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_get_profile_dir_name(ds_profile_h profile_h, char **profile_dir_name)
+{
+ _EXTERN_FUNC_ENTER;
+
+ // check mandatory parameter
+ retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
+
+ sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
+
+ sync_agent_ds_error_e result = SYNC_AGENT_DS_SUCCESS;
+
+ *profile_dir_name = g_strdup(profile_info->profile_dir_name);
+
+ if (*profile_dir_name == NULL) {
_DEBUG_ERROR("g_strdup failed !!");
return SYNC_AGENT_DS_FAIL;
}
+ _DEBUG_INFO("profile_dir_name = %s", *profile_dir_name);
+
_EXTERN_FUNC_EXIT;
return result;
}
-EXPORT_API sync_agent_ds_error_e sync_agent_ds_get_profile_name(ds_profile_h profile_h, char **profile_dir_name, char **profile_name)
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_get_profile_name(ds_profile_h profile_h, char **profile_name)
{
_EXTERN_FUNC_ENTER;
sync_agent_ds_error_e result = SYNC_AGENT_DS_SUCCESS;
- *profile_dir_name = g_strdup(profile_info->profile_dir_name);
*profile_name = g_strdup(profile_info->profile_name);
- if ((*profile_dir_name == NULL)
- || (*profile_name == NULL)) {
+ if (*profile_name == NULL) {
_DEBUG_ERROR("g_strdup failed !!");
return SYNC_AGENT_DS_FAIL;
}
- _DEBUG_INFO("profileDirame = %s", *profile_dir_name);
- _DEBUG_INFO("get_profile_name = %s", *profile_name);
+ _DEBUG_INFO("profile_name = %s", *profile_name);
_EXTERN_FUNC_EXIT;
sync_agent_ds_error_e result = SYNC_AGENT_DS_SUCCESS;
- sync_info->sync_mode = g_strdup(ds_sync_info->sync_mode);
- sync_info->sync_type = g_strdup(ds_sync_info->sync_type);
- sync_info->interval = g_strdup(ds_sync_info->interval);
+ sync_info->sync_mode = ds_sync_info->sync_mode;
+ sync_info->sync_type = ds_sync_info->sync_type;
+ sync_info->interval = ds_sync_info->interval;
- if ((sync_info->sync_mode == NULL)
- || (sync_info->sync_type == NULL)
- || (sync_info->interval == NULL)) {
- _DEBUG_ERROR("g_strdup failed !!");
+ _DEBUG_INFO("get_sync_mode = %d", sync_info->sync_mode);
+ _DEBUG_INFO("get_sync_type = %d", sync_info->sync_type);
+ _DEBUG_INFO("get_interval = %d", sync_info->interval);
+
+ if (sync_info->sync_mode < 0) {
+ _DEBUG_ERROR("sync_mode is invalid !!");
+ return SYNC_AGENT_DS_FAIL;
+ }
+
+ if (sync_info->sync_type < 0) {
+ _DEBUG_ERROR("sync_type is invalid !!");
return SYNC_AGENT_DS_FAIL;
}
- _DEBUG_INFO("get_sync_mode = %s", sync_info->sync_mode);
- _DEBUG_INFO("get_sync_type = %s", sync_info->sync_type);
- _DEBUG_INFO("get_interval = %s", sync_info->interval);
+ if (sync_info->interval < 0) {
+ _DEBUG_ERROR("interval is invalid !!");
+ return SYNC_AGENT_DS_FAIL;
+ }
_EXTERN_FUNC_EXIT;
{
_EXTERN_FUNC_ENTER;
+ // check mandatory parameter
+ retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
+
sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
int category_count = 0;
category_info = (sync_agent_ds_service_info *) g_list_nth_data(*category_list, i);
_DEBUG_INFO("category[%d]->enabled = %d", i, category_info->enabled);
- _DEBUG_INFO("category[%d]->src_uri = %s", i, category_info->src_uri);
+ _DEBUG_INFO("category[%d]->src_uri = %d", i, category_info->src_uri);
_DEBUG_INFO("category[%d]->tgt_uri = %s", i, category_info->tgt_uri);
_DEBUG_INFO("category[%d]->id = %s", i, category_info->id);
_DEBUG_INFO("category[%d]->password = %s", i, category_info->password);
{
_EXTERN_FUNC_ENTER;
+ // check mandatory parameter
+ retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
+
sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
sync_agent_ds_statistics_info *statistics = NULL;
}
/* add request parameter to event packet */
- _DEBUG_INFO("profile_dir_name = %s", profile_info->profile_dir_name);
- sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)profile_info->profile_dir_name);
_DEBUG_INFO("profile_name = %s", profile_info->profile_name);
sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)profile_info->profile_name);
_DEBUG_INFO("addr = %s", server_info->addr);
sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)server_info->id);
_DEBUG_INFO("password = %s", server_info->password);
sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)server_info->password);
- _DEBUG_INFO("sync_mode = %s", sync_info->sync_mode);
- sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_info->sync_mode);
- _DEBUG_INFO("sync_type = %s", sync_info->sync_type);
- sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_info->sync_type);
- _DEBUG_INFO("interval = %s", sync_info->interval);
- sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_info->interval);
+ _DEBUG_INFO("sync_mode = %d", sync_info->sync_mode);
+ sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &(sync_info->sync_mode));
+ _DEBUG_INFO("sync_type = %d", sync_info->sync_type);
+ sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &(sync_info->sync_type));
+ _DEBUG_INFO("interval = %d", sync_info->interval);
+ sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &(sync_info->interval));
category_count = g_list_length(list);
sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &category_count);
sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &(category_info->service_type));
_DEBUG_INFO("category[%d]->enabled = %d", i, category_info->enabled);
sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &(category_info->enabled));
- _DEBUG_INFO("category[%d]->src_uri = %s", i, category_info->src_uri);
- sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)category_info->src_uri);
+ _DEBUG_INFO("category[%d]->src_uri = %d", i, category_info->src_uri);
+ sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &(category_info->src_uri));
_DEBUG_INFO("category[%d]->tgt_uri = %s", i, category_info->tgt_uri);
sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)category_info->tgt_uri);
_DEBUG_INFO("category[%d]->id = %s", i, category_info->id);
}
/* get response parameter from event packet */
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result == SYNC_AGENT_DS_API_RESULT_FAILURE) {
_DEBUG_ERROR("api_result = failed");
return SYNC_AGENT_DS_FAIL;
}
- sync_agent_get_event_data_param(response_event, &prof_id);
+ sync_agent_get_event_data_param_int(response_event, &prof_id);
_DEBUG_VERBOSE("profile_id = %d", prof_id);
*profile_id = prof_id;
{
_EXTERN_FUNC_ENTER;
+ // check mandatory parameter
+ retvm_if(profile_dir_name == NULL, SYNC_AGENT_DS_FAIL, "profile_dir_name is null!!");
+
int event_type = SYNC_AGENT_DS_GET_PROFILE;
sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
sync_agent_event_data_s *request_event = NULL;
int api_result = SYNC_AGENT_DS_API_RESULT_SUCCESS;
sync_agent_ds_service_info *category = NULL;
- // check mandatory parameter
- retvm_if(profile_dir_name == NULL, SYNC_AGENT_DS_FAIL, "profile_dir_name is null!!");
-
//////////////////////////////////
//
// Phase 1. get profile detail info
sync_agent_ds_sync_info *sync_info = &profile_info->sync_info;
// GList * list = profile_info->category_list;
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result == SYNC_AGENT_DS_API_RESULT_FAILURE) {
_DEBUG_ERROR("api_result = failed");
sync_agent_free_event(request_event);
profile_info->profile_dir_name = g_strdup(profile_dir_name);
- sync_agent_get_event_data_param(response_event, &profile_info->profile_name);
- sync_agent_get_event_data_param(response_event, &server_info->addr);
- sync_agent_get_event_data_param(response_event, &server_info->id);
- sync_agent_get_event_data_param(response_event, &server_info->password);
- sync_agent_get_event_data_param(response_event, &sync_info->sync_mode);
- sync_agent_get_event_data_param(response_event, &sync_info->sync_type);
- sync_agent_get_event_data_param(response_event, &sync_info->interval);
- sync_agent_get_event_data_param(response_event, &profile_info->last_sync_status);
- sync_agent_get_event_data_param(response_event, &profile_info->last_sync_time);
+ sync_agent_get_event_data_param_str(response_event, &profile_info->profile_name);
+ sync_agent_get_event_data_param_str(response_event, &server_info->addr);
+ sync_agent_get_event_data_param_str(response_event, &server_info->id);
+ sync_agent_get_event_data_param_str(response_event, &server_info->password);
+ sync_agent_get_event_data_param_int(response_event, (int*) &sync_info->sync_mode);
+ sync_agent_get_event_data_param_int(response_event, (int*) &sync_info->sync_type);
+ sync_agent_get_event_data_param_int(response_event, (int*) &sync_info->interval);
+ sync_agent_get_event_data_param_int(response_event, &profile_info->last_sync_status);
+ sync_agent_get_event_data_param_int(response_event, &profile_info->last_sync_time);
_DEBUG_INFO("profileDirame = %s", profile_info->profile_name);
_DEBUG_INFO("addr = %s", server_info->addr);
_DEBUG_INFO("id = %s", server_info->id);
_DEBUG_INFO("password = %s", server_info->password);
- _DEBUG_INFO("sync_mode = %s", sync_info->sync_mode);
- _DEBUG_INFO("sync_type = %s", sync_info->sync_type);
- _DEBUG_INFO("interval = %s", sync_info->interval);
+ _DEBUG_INFO("sync_mode = %d", sync_info->sync_mode);
+ _DEBUG_INFO("sync_type = %d", sync_info->sync_type);
+ _DEBUG_INFO("interval = %d", sync_info->interval);
_DEBUG_VERBOSE("lastSyncStatus = %d\n", profile_info->last_sync_status);
_DEBUG_VERBOSE("lastSyncTime = %d\n", profile_info->last_sync_time);
return SYNC_AGENT_DS_FAIL;
}
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result == SYNC_AGENT_DS_API_RESULT_FAILURE) {
_DEBUG_ERROR("api_result = failed");
sync_agent_free_event(request_event);
return SYNC_AGENT_DS_FAIL;
}
- sync_agent_get_event_data_param(response_event, &profile_count);
+ sync_agent_get_event_data_param_int(response_event, &profile_count);
_DEBUG_INFO("profile_count = %d", profile_count);
int i;
sync_agent_ds_server_info *server_info = &profile_info->server_info;
sync_agent_ds_sync_info *sync_info = &profile_info->sync_info;
- sync_agent_get_event_data_param(response_event, &profile_info->profile_dir_name);
- sync_agent_get_event_data_param(response_event, &profile_info->profile_name);
- sync_agent_get_event_data_param(response_event, &server_info->addr);
- sync_agent_get_event_data_param(response_event, &server_info->id);
- sync_agent_get_event_data_param(response_event, &server_info->password);
- sync_agent_get_event_data_param(response_event, &sync_info->sync_mode);
- sync_agent_get_event_data_param(response_event, &sync_info->sync_type);
- sync_agent_get_event_data_param(response_event, &sync_info->interval);
- sync_agent_get_event_data_param(response_event, &profile_info->last_sync_status);
- sync_agent_get_event_data_param(response_event, &profile_info->last_sync_time);
+ sync_agent_get_event_data_param_str(response_event, &profile_info->profile_dir_name);
+ sync_agent_get_event_data_param_str(response_event, &profile_info->profile_name);
+ sync_agent_get_event_data_param_str(response_event, &server_info->addr);
+ sync_agent_get_event_data_param_str(response_event, &server_info->id);
+ sync_agent_get_event_data_param_str(response_event, &server_info->password);
+ sync_agent_get_event_data_param_int(response_event, (int*) &sync_info->sync_mode);
+ sync_agent_get_event_data_param_int(response_event, (int*) &sync_info->sync_type);
+ sync_agent_get_event_data_param_int(response_event, (int*) &sync_info->interval);
+ sync_agent_get_event_data_param_int(response_event, &profile_info->last_sync_status);
+ sync_agent_get_event_data_param_int(response_event, &profile_info->last_sync_time);
_DEBUG_INFO("profile_info->profile_dir_name = %s", profile_info->profile_dir_name);
_DEBUG_INFO("profile_info->profile_name = %s", profile_info->profile_name);
_DEBUG_INFO("profile_info->addr = %s", server_info->addr);
_DEBUG_INFO("profile_info->id = %s", server_info->id);
_DEBUG_INFO("profile_info->password = %s", server_info->password);
- _DEBUG_INFO("profile_info->sync_mode = %s", sync_info->sync_mode);
- _DEBUG_INFO("profile_info->sync_type = %s", sync_info->sync_type);
- _DEBUG_INFO("profile_info->interval = %s", sync_info->interval);
+ _DEBUG_INFO("profile_info->sync_mode = %d", sync_info->sync_mode);
+ _DEBUG_INFO("profile_info->sync_type = %d", sync_info->sync_type);
+ _DEBUG_INFO("profile_info->interval = %d", sync_info->interval);
_DEBUG_INFO("profile_info->lastSyncStatus = %d", profile_info->last_sync_status);
_DEBUG_INFO("profile_info->lastSyncStatus = %d", profile_info->last_sync_status);
- sync_agent_get_event_data_param(response_event, &category_count);
+ sync_agent_get_event_data_param_int(response_event, &category_count);
int j;
for (j = 0; j < category_count; j++) {
return FALSE;
}
- sync_agent_get_event_data_param(response_event, &category_info->service_type);
- sync_agent_get_event_data_param(response_event, &category_info->enabled);
- sync_agent_get_event_data_param(response_event, &category_info->src_uri);
- sync_agent_get_event_data_param(response_event, &category_info->tgt_uri);
- sync_agent_get_event_data_param(response_event, &category_info->id);
- sync_agent_get_event_data_param(response_event, &category_info->password);
+ sync_agent_get_event_data_param_int(response_event, (int*) &category_info->service_type);
+ sync_agent_get_event_data_param_int(response_event, &category_info->enabled);
+ sync_agent_get_event_data_param_int(response_event, (int*) &category_info->src_uri);
+ sync_agent_get_event_data_param_str(response_event, &category_info->tgt_uri);
+ sync_agent_get_event_data_param_str(response_event, &category_info->id);
+ sync_agent_get_event_data_param_str(response_event, &category_info->password);
_DEBUG_INFO("category_info->service_type = %d", category_info->service_type);
_DEBUG_INFO("category_info->enabled = %d", category_info->enabled);
- _DEBUG_INFO("category_info->src_uri = %s", category_info->src_uri);
+ _DEBUG_INFO("category_info->src_uri = %d", category_info->src_uri);
_DEBUG_INFO("category_info->tgt_uri = %s", category_info->tgt_uri);
_DEBUG_INFO("category_info->id = %s", category_info->id);
_DEBUG_INFO("category_info->password = %s", category_info->password);
sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)server_info->id);
_DEBUG_INFO("password = %s", server_info->password);
sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)server_info->password);
- _DEBUG_INFO("sync_mode = %s", sync_info->sync_mode);
- sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_info->sync_mode);
- _DEBUG_INFO("sync_type = %s", sync_info->sync_type);
- sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_info->sync_type);
- _DEBUG_INFO("interval = %s", sync_info->interval);
- sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_info->interval);
+ _DEBUG_INFO("sync_mode = %d", sync_info->sync_mode);
+ sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &(sync_info->sync_mode));
+ _DEBUG_INFO("sync_type = %d", sync_info->sync_type);
+ sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &(sync_info->sync_type));
+ _DEBUG_INFO("interval = %d", sync_info->interval);
+ sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &(sync_info->interval));
category_count = g_list_length(list);
sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &category_count);
sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &(category_info->service_type));
_DEBUG_INFO("category[%d]->enabled = %d", i, category_info->enabled);
sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &(category_info->enabled));
- _DEBUG_INFO("category[%d]->src_uri = %s", i, category_info->src_uri);
- sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)category_info->src_uri);
+ _DEBUG_INFO("category[%d]->src_uri = %d", i, category_info->src_uri);
+ sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &(category_info->src_uri));
_DEBUG_INFO("category[%d]->tgt_uri = %s", i, category_info->tgt_uri);
sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)category_info->tgt_uri);
_DEBUG_INFO("category[%d]->id = %s", i, category_info->id);
}
/* get response parameter from event packet */
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result == SYNC_AGENT_DS_API_RESULT_FAILURE) {
_DEBUG_ERROR("api_result = failed");
{
_EXTERN_FUNC_ENTER;
+ // check mandatory parameter
+ retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
+
sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
+ retvm_if(profile_info->profile_dir_name == NULL, SYNC_AGENT_DS_FAIL, "profile_dir_name is null!!");
+
int event_type = SYNC_AGENT_DS_DELETE_PROFILE;
sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
sync_agent_event_data_s *request_event = NULL;
int count = 1;
int api_result = SYNC_AGENT_DS_API_RESULT_SUCCESS;
- // check mandatory parameter
- retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
- retvm_if(profile_info->profile_dir_name == NULL, SYNC_AGENT_DS_FAIL, "profile_dir_name is null!!");
-
/* create empty event packet */
request_event = sync_agent_create_event(event_type);
if (request_event == NULL) {
}
/* get response parameter from event packet */
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result == SYNC_AGENT_DS_API_RESULT_FAILURE) {
_DEBUG_ERROR("api_result = failed");
{
_EXTERN_FUNC_ENTER;
+ // check mandatory parameter
+ retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
+
sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
+ retvm_if(profile_info->profile_dir_name == NULL, SYNC_AGENT_DS_FAIL, "profile_dir_name is null!!");
+
int event_type = SYNC_AGENT_DS_START_SYNC;
sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
sync_agent_event_data_s *request_event = NULL;
int api_result = SYNC_AGENT_DS_API_RESULT_SUCCESS;
- // check mandatory parameter
- retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
- retvm_if(profile_info->profile_dir_name == NULL, SYNC_AGENT_DS_FAIL, "profile_dir_name is null!!");
-
/* create empty event packet */
request_event = sync_agent_create_event(event_type);
if (request_event == NULL) {
}
/* get response parameter from event packet */
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result == SYNC_AGENT_DS_API_RESULT_FAILURE) {
_DEBUG_ERROR("api_result = failed");
{
_EXTERN_FUNC_ENTER;
+ // check mandatory parameter
+ retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
+
sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
+ retvm_if(profile_info->profile_dir_name == NULL, SYNC_AGENT_DS_FAIL, "profile_dir_name is null!!");
+
int event_type = SYNC_AGENT_DS_STOP_SYNC;
sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
sync_agent_event_data_s *request_event = NULL;
int api_result = SYNC_AGENT_DS_API_RESULT_SUCCESS;
- // check mandatory parameter
- retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
- retvm_if(profile_info->profile_dir_name == NULL, SYNC_AGENT_DS_FAIL, "profile_dir_name is null!!");
-
/* create empty event packet */
request_event = sync_agent_create_event(event_type);
if (request_event == NULL) {
}
/* get response parameter from event packet */
- sync_agent_get_event_data_param(response_event, &api_result);
+ sync_agent_get_event_data_param_int(response_event, &api_result);
if (api_result == SYNC_AGENT_DS_API_RESULT_FAILURE) {
_DEBUG_ERROR("api_result = failed");
sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
sync_agent_ds_server_info *server_info = &profile_info->server_info;
- sync_agent_ds_sync_info *sync_info = &profile_info->sync_info;
+ //sync_agent_ds_sync_info *sync_info = &profile_info->sync_info;
GList *category_list = profile_info->service_list;
// free profile name
g_free(server_info->id);
g_free(server_info->password);
- // free sync mode information
- g_free(sync_info->sync_mode);
- g_free(sync_info->sync_type);
- g_free(sync_info->interval);
-
// free sync category information
g_list_free_full(category_list, (GDestroyNotify) _free_sync_category_info);
_EXTERN_FUNC_ENTER;
sync_agent_ds_error_e result = SYNC_AGENT_DS_SUCCESS;
-
sync_agent_deinit_error_e deinit = SYNC_AGENT_DEINIT_SUCCESS;
+ int ret = -1;
+
+ ret = _kill_omads_agent();
+
+ if (ret < 0 ) {
+ _DEBUG_ERROR("_kill_omads_agent() failed !!");
+ result = SYNC_AGENT_DS_FAIL;
+
+ _EXTERN_FUNC_EXIT;
+ return result;
+ }
deinit = sync_agent_deinit();
if (deinit != SYNC_AGENT_DEINIT_SUCCESS) {
return result;
}
+
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_set_noti_callback(sync_agent_ds_sync_callback_e type, sync_agent_noti_cb callback, void *data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ds_error_e result = SYNC_AGENT_DS_SUCCESS;
+
+ sync_agent_event_error_e err = sync_agent_set_noti_callback(type, callback, data);
+ if (err != SYNC_AGENT_EVENT_SUCCESS) {
+ _DEBUG_ERROR("failed sync_agent_set_noti_callback()");
+ result = SYNC_AGENT_DS_FAIL;
+ }
+
+ return result;
+
+ _EXTERN_FUNC_EXIT;
+}
+
}
int noti_num;
- sync_agent_get_event_data_param(noti, ¬i_num);
+ sync_agent_get_event_data_param_int(noti, ¬i_num);
_DEBUG_TRACE("Received Noti Number : %d", noti_num);
sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;;
static char *requested_filename_kept = NULL;
static FILE *fd_source_kept = NULL;
-static unsigned char _wss_str_to_hex_char(unsigned char hex);
+static unsigned char _sync_str_to_hex_char(unsigned char hex);
EXPORT_API sync_agent_fsapi_return_e sync_agent_is_existing_fs(const char *file_name)
{
char szTmp_digest[256] = { 0, };
int k;
for (k = 0; k < 16; k++) {
- szTmp_digest[k * 2] = _wss_str_to_hex_char((unsigned char)((real_md5_word[k] >> 4) & 0x0f));
- szTmp_digest[k * 2 + 1] = _wss_str_to_hex_char((unsigned char)(real_md5_word[k] & 0x0f));
+ szTmp_digest[k * 2] = _sync_str_to_hex_char((unsigned char)((real_md5_word[k] >> 4) & 0x0f));
+ szTmp_digest[k * 2 + 1] = _sync_str_to_hex_char((unsigned char)(real_md5_word[k] & 0x0f));
}
_DEBUG_INFO("find_md5_word = %s\n", find_md5_word);
return ret;
}
-static unsigned char _wss_str_to_hex_char(unsigned char hex)
+static unsigned char _sync_str_to_hex_char(unsigned char hex)
{
_INNER_FUNC_ENTER;
_DEBUG_INFO("network ON !!");
/*FW_NETWORK_TYPE fw_net_type = get_network_type(); */
sync_agent_na_network_connection_state_e conn_state = na_get_connection_state();
+ _DEBUG_INFO("conn_state [%d]", conn_state);
/*if ((fw_net_type == NETWORK_NONE) || (fw_net_type == NETWORK_3G_OFF) || (fw_net_type == NETWORK_WIFI_OFF) || (fw_net_type == NETWORK_WIFI_ON_NOT_CONNECTED)) { */
- if ((SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_NONE <= conn_state && conn_state <= SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_DISCONNECTED) ||
- (conn_state == SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_OUT_OF_SERVICE) || (conn_state == SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_CALL_ONLY_AVAILABLE) ||
- (SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_DEACTIVATED <= conn_state && conn_state <= SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_DISCONNECTED)) {
+ // if ((SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_NONE <= conn_state && conn_state <= SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_DISCONNECTED) ||
+ if ((SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_NONE <= conn_state && conn_state <= SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_DEACTIVATED) ||
+ (conn_state == SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_OUT_OF_SERVICE) || (conn_state == SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_CALL_ONLY_AVAILABLE) ||
+ (SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_DEACTIVATED <= conn_state && conn_state <= SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_DISCONNECTED)) {
_DEBUG_ERROR("network ON but not connected !!");
err = na_remove_session_info(*session_id);
if (err != 1) {
_DEBUG_INFO("[%s] network ON \n", __func__);
/*FW_NETWORK_TYPE fw_net_type = get_network_type(); */
sync_agent_na_network_connection_state_e conn_state = na_get_connection_state();
+ _DEBUG_INFO("conn_state [%d]", conn_state);
/*if ((fw_net_type == NETWORK_NONE) || (fw_net_type == NETWORK_3G_OFF) || (fw_net_type == NETWORK_WIFI_OFF) || (fw_net_type == NETWORK_WIFI_ON_NOT_CONNECTED)) { */
- if ((SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_NONE <= conn_state && conn_state <= SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_DISCONNECTED) ||
+ //if ((SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_NONE <= conn_state && conn_state <= SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_DISCONNECTED) ||
+ if ((SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_NONE <= conn_state && conn_state <= SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_DEACTIVATED) ||
(conn_state == SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_OUT_OF_SERVICE) || (conn_state == SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_CALL_ONLY_AVAILABLE) ||
(SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_DEACTIVATED <= conn_state && conn_state <= SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_DISCONNECTED)) {
_DEBUG_ERROR("network ON but not connected !!");
_EXTERN_FUNC_EXIT;
+ session_manager.fw_network_status = SYNC_AGENT_NA_NETWORK_ON; // this code is rsa & emulator.
return session_manager.fw_network_status;
}
_EXTERN_FUNC_ENTER;
_EXTERN_FUNC_EXIT;
-
+ session_manager.fw_connection_state = SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_CONNECTED; // this code is rsa & emulator.
return session_manager.fw_connection_state;
}
_EXTERN_FUNC_ENTER;
_EXTERN_FUNC_EXIT;
-
+ session_manager.fw_connection_type = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_ETHERNET; // this code is rsa & emulator.
return session_manager.fw_connection_type;
}
func_set.func_begin_transaction = dlsym(plugin_handle, "sync_agent_plugin_begin_transaction");
func_set.func_end_transaction = dlsym(plugin_handle, "sync_agent_plugin_end_transaction");
func_set.func_add_item = dlsym(plugin_handle, "sync_agent_plugin_add_item");
+ func_set.func_add_bulk_item = dlsym(plugin_handle, "sync_agent_plugin_add_bulk_item");
func_set.func_update_item = dlsym(plugin_handle, "sync_agent_plugin_update_item");
+ func_set.func_update_bulk_item = dlsym(plugin_handle, "sync_agent_plugin_update_bulk_item");
func_set.func_delete_item = dlsym(plugin_handle, "sync_agent_plugin_delete_item");
+ func_set.func_delete_bulk_item = dlsym(plugin_handle, "sync_agent_plugin_delete_bulk_item");
func_set.func_delete_all_items = dlsym(plugin_handle, "sync_agent_plugin_delete_all_items");
func_set.func_get_item = dlsym(plugin_handle, "sync_agent_plugin_get_item");
func_set.func_add_folder = dlsym(plugin_handle, "sync_agent_plugin_add_folder");
return plugin_repository[index].func_set.func_add_item;
}
+plugin_add_bulk_item_cb plugin_get_function_add_bulk_item(int plugin_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int index = _find_data_connector_plugin(plugin_id);
+ if (index == -1) {
+ return NULL;
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+ return plugin_repository[index].func_set.func_add_bulk_item;
+}
+
plugin_update_item_cb plugin_get_function_update_item(int plugin_id)
{
_EXTERN_FUNC_ENTER;
return plugin_repository[index].func_set.func_update_item;
}
+plugin_update_bulk_item_cb plugin_get_function_update_bulk_item(int plugin_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int index = _find_data_connector_plugin(plugin_id);
+ if (index == -1) {
+ return NULL;
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+ return plugin_repository[index].func_set.func_update_bulk_item;
+}
+
plugin_delete_item_cb plugin_get_function_del_item(int plugin_id)
{
_EXTERN_FUNC_ENTER;
return plugin_repository[index].func_set.func_delete_item;
}
+plugin_delete_bulk_item_cb plugin_get_function_del_bulk_item(int plugin_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int index = _find_data_connector_plugin(plugin_id);
+ if (index == -1) {
+ return NULL;
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+ return plugin_repository[index].func_set.func_delete_bulk_item;
+}
+
+
plugin_delete_all_items_cb plugin_get_function_del_all_items(int plugin_id)
{
_EXTERN_FUNC_ENTER;
typedef sync_agent_da_return_e(*plugin_add_item_cb) (int account_id, char *folder_id, void *data, char **item_id);
/**
+ * @brief Prototype of plugin function for inserting item into service storage
+ * @param[in] account_id service account id
+ * @param[in] folder_id service folder id
+ * @param[in] data data to add to the service
+ * @param[in] item_id as returned by plugin_add_item_cb - success : id of the newly item added to the service, error : NULL
+ * @param[in] item_id_count count of item_id
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_add_bulk_item_cb) (int account_id, char *folder_id, void *data, int **item_id, int *item_id_count);
+
+/**
* @brief Prototype of plugin function for updating item from service storage
* @param[in] account_id service account id
* @param[in] folder_id service folder id
typedef sync_agent_da_return_e(*plugin_update_item_cb) (int account_id, char *folder_id, char *item_id, void *data);
/**
+ * @brief Prototype of plugin function for updating item from service storage
+ * @param[in] data data to update to the service
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_update_bulk_item_cb) (void *data);
+
+/**
* @brief Prototype of plugin function for deleting item from service storage
* @param[in] account_id service account id
* @param[in] folder_id service folder id
typedef sync_agent_da_return_e(*plugin_delete_item_cb) (int account_id, char *folder_id, char *item_id);
/**
+ * @brief Prototype of plugin function for deleting item from service storage
+ * @param[in] item_id service id of item expected to be deleted
+ * @param[in] count count of service item id expected to be deleted
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_delete_bulk_item_cb) (int *item_id, int count);
+
+/**
* @brief Prototype of plugin function for deleting all items from service storage
* @param[in] account_id service account id
* @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
plugin_begin_transaction_cb func_begin_transaction; /**< function pointer of plugin_begin_transaction_cb */
plugin_end_transaction_cb func_end_transaction; /**< function pointer of plugin_end_transaction_cb */
plugin_add_item_cb func_add_item; /**< function pointer of plugin_add_item_cb */
+ plugin_add_bulk_item_cb func_add_bulk_item; /**< function pointer of plugin_add_bulk_item_cb */
plugin_update_item_cb func_update_item; /**< function pointer of plugin_update_item_cb */
+ plugin_update_bulk_item_cb func_update_bulk_item; /**< function pointer of plugin_update_item_bulk_cb */
plugin_delete_item_cb func_delete_item; /**< function pointer of plugin_delete_item_cb */
+ plugin_delete_bulk_item_cb func_delete_bulk_item; /**< function pointer of plugin_delete_bulk_item_cb */
plugin_delete_all_items_cb func_delete_all_items; /**< function pointer of plugin_delete_all_items_cb */
plugin_get_item_cb func_get_item; /**< function pointer of plugin_get_item_cb */
plugin_add_folder_cb func_add_folder; /**< function pointer of plugin_add_folder_cb */
plugin_add_item_cb plugin_get_function_add_item(int plugin_id);
/**
+ * @brief Get function pointer of plugin_add_bulk_item_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_add_bulk_item_cb on success, NULL on error
+ */
+plugin_add_bulk_item_cb plugin_get_function_add_bulk_item(int plugin_id);
+
+/**
* @brief Get function pointer of plugin_update_item_cb
* @param[in] plugin_id data-connector plugin id
* @return function pointer of plugin_update_item_cb on success, NULL on error
plugin_update_item_cb plugin_get_function_update_item(int plugin_id);
/**
+ * @brief Get function pointer of plugin_update_bulk_item_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_update_item_cb on success, NULL on error
+ */
+plugin_update_bulk_item_cb plugin_get_function_update_bulk_item(int plugin_id);
+
+/**
* @brief Get function pointer of plugin_delete_item_cb
* @param[in] plugin_id data-connector plugin id
* @return function pointer of plugin_delete_item_cb on success, NULL on error
plugin_delete_item_cb plugin_get_function_del_item(int plugin_id);
/**
+ * @brief Get function pointer of plugin_delete_bulk_item_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_delete_bulk_item_cb on success, NULL on error
+ */
+plugin_delete_bulk_item_cb plugin_get_function_del_bulk_item(int plugin_id);
+
+/**
* @brief Get function pointer of plugin_delete_all_items_cb
* @param[in] plugin_id data-connector plugin id
* @return function pointer of plugin_delete_all_items_cb on success, NULL on error
Name: sync-agent
Description: Sync Agent Library Package
-Requires:
+Requires: glib-2.0, sqlite3, libsoup-2.4, vconf, libxml-2.0, libwbxml2, dlog, dbus-glib-1
Version: @VERSION@
Libs: -L${libdir} -lsync-agent
Cflags: -I${includedir} -I${includedir}/sync-agent
ADD_SUBDIRECTORY(slp-sysnoti-alarm)
ADD_SUBDIRECTORY(slp-sysnoti-network-connection)
ADD_SUBDIRECTORY(slp-sysnoti-wap-push)
+ADD_SUBDIRECTORY(task)
ADD_SUBDIRECTORY(vcalendar)
+ADD_SUBDIRECTORY(vcalendar-task)
ADD_SUBDIRECTORY(vobject-tizen)
#define FW_CALENDAR 1
#define FW_MEMO 2
#define FW_CONTENT_COUNT 3
-
+#define FW_TASK 11
#define MAX_ACCOUNT_COUNT 20
static const char *agent_name = 0;
int slp_contact_id = sync_agent_plugin_get_service_account_id(FW_CONTACT, fw_account_id);
int slp_calendar_id = sync_agent_plugin_get_service_account_id(FW_CALENDAR, fw_account_id);
int slp_memo_id = sync_agent_plugin_get_service_account_id(FW_MEMO, fw_account_id);
+ int slp_task_id = sync_agent_plugin_get_service_account_id(FW_TASK, fw_account_id);
/*
* if not existed ?
_set_account_id_fw(FW_MEMO, slp_id, memo_index, fw_account_id);
}
+ if (slp_task_id == -100) {
+ _set_account_id_service(FW_TASK, fw_account_id, slp_id);
+ int task_index = _increase_account_count_fw(FW_TASK, slp_id);
+ if (task_index < 1 || task_index > MAX_ACCOUNT_COUNT) {
+ _DEBUG_ERROR("[account_plugIn] _increase_account_count_fw() returned OUT OF BOUND int !!!");
+ return;
+ }
+ _set_account_id_fw(FW_TASK, slp_id, task_index, fw_account_id);
+ }
+
_EXTERN_FUNC_EXIT;
}
static sync_agent_da_return_e _get_service_folder_list_by_account_id(int account_id, calendar_list_h * item_list, int *count);
+static int _get_exdate_count(calendar_query_h query);
+
+
static sync_agent_da_return_e _get_service_event_list_by_folder_id(int folder_id, calendar_list_h * item_list, int *count);
//static void _calendar_db_result_cb(int error, void *user_data);
_INNER_FUNC_EXIT;
}
+static int _get_exdate_count(calendar_query_h query)
+{
+ _EXTERN_FUNC_ENTER;
+ retvm_if(query == NULL, 0, "query is NULL");
+
+ calendar_filter_h filter = NULL;
+ calendar_list_h list = NULL;
+ calendar_record_h calendar_record = NULL;
+ int parent_count = 0;
+ int exdate_count = 0;
+ int ret = CALENDAR_ERROR_NONE;
+
+ ret = calendar_db_get_records_with_query(query, 0, 0, &list);
+ if (ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_db_get_records_with_query() failed");
+ goto return_part;
+ }
+ ret = calendar_list_get_count(list, &parent_count);
+ if (ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_get_count() failed");
+ goto return_part;
+ }
+ _DEBUG_INFO("parent_count = %d", parent_count);
+ ret = calendar_list_first(list);
+ if (ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_first() failed");
+ goto return_part;
+ }
+
+ int index = 0;
+ do
+ {
+ ret = calendar_list_get_current_record_p(list, &calendar_record);
+ if (ret != CALENDAR_ERROR_NONE || calendar_record == NULL) {
+ _DEBUG_ERROR("calendar_list_get_current_record_p() failed");
+ continue;
+ }
+
+ char *exdate = NULL;
+ ret = calendar_record_get_str(calendar_record, _calendar_event.exdate, &exdate);
+ if (ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_str() failed");
+ goto return_part;
+ }
+ _DEBUG_INFO("index = %d, exdate = %s", index, exdate);
+ index++;
+
+ gchar **array_exdate = g_strsplit(exdate, ",", -1);
+ if (array_exdate == NULL) {
+ _DEBUG_ERROR("g_strsplit failed");
+ goto return_part;
+ }
+
+ int array_length = 0;
+ array_length = g_strv_length(array_exdate);
+ _DEBUG_INFO("array_length = %d", array_length);
+
+ exdate_count += array_length;
+
+ int exdate_index = 0;
+ for (exdate_index = 0; array_exdate[exdate_index] != NULL; exdate_index++)
+ _DEBUG_INFO("exdate_index = %d, one_exdate = %s", exdate_index, array_exdate[exdate_index]);
+ g_strfreev(array_exdate);
+ } while (calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+
+return_part:
+ _DEBUG_INFO("return_part");
+ _DEBUG_INFO("exdate_count = %d", exdate_count);
+ calendar_list_destroy(list, false);
+ calendar_filter_destroy(filter);
+ _EXTERN_FUNC_EXIT;
+ return exdate_count;
+}
+
EXPORT_API sync_agent_da_return_e sync_agent_plugin_open_service(void)
{
_EXTERN_FUNC_ENTER;
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
- int err = calendar_connect_on_thread();
+ int err = calendar_connect();
+ //int err = calendar_connect_on_thread();
if (err != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] in calendar Fail!\n");
+ _DEBUG_ERROR("[da_calendar_plugIn] calendar_connect Fail!\n");
ret = _convert_service_error_to_common_error(err);
} else {
- _DEBUG_INFO("[da_calendar_plugIn] in calendar Success!\n");
+ _DEBUG_INFO("[da_calendar_plugIn] calendar_connect Success!\n");
}
_EXTERN_FUNC_EXIT;
_EXTERN_FUNC_ENTER;
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
- int err = calendar_disconnect_on_thread();
+ int err = calendar_disconnect();
+ //int err = calendar_disconnect_on_thread();
if (err != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] in calendar Fail!\n");
+ _DEBUG_ERROR("[da_calendar_plugIn] calendar_disconnect Fail!\n");
ret = _convert_service_error_to_common_error(err);
} else {
- _DEBUG_INFO("[da_calendar_plugIn] in calendar Success!\n");
+ _DEBUG_INFO("[da_calendar_plugIn] calendar_disconnect Success!\n");
}
_EXTERN_FUNC_EXIT;
calendar_record_h item = (calendar_record_h) data;
int int_folder_id = atoi(folder_id);
- /* setting folder id */
int service_ret = calendar_record_set_int(item, _calendar_event.calendar_book_id, int_folder_id);
if (service_ret != CALENDAR_ERROR_NONE) {
_DEBUG_ERROR("calendar_record_set_int() Fail! : err = %d", service_ret);
goto DACI_FINISH;
}
- /* update item */
err = calendar_db_update_record(item);
if (err != CALENDAR_ERROR_NONE) {
_DEBUG_ERROR("[da_calendar_plugIn] calendar_svc_update() Fail!\n");
is_storage_changed = 1;
}
- /* memory free */
DACI_FINISH:
- /* memory free */
if (item != NULL) {
calendar_record_destroy(item, false);
if (err != CALENDAR_ERROR_NONE) {
int service_ret = 0;
int item_id = 0;
- int *calendar_id_list = 0;
calendar_list_h event_list = NULL;
- /* get folder id list for account id */
folder_id_list = sync_agent_plugin_get_folder_id_list(account_id, &folder_id_list_cnt, &folder_type_list);
if (folder_id_list == NULL || folder_id_list_cnt == 0) {
_DEBUG_INFO("[da_calendar_plugIn] folder id list cnt : %d", folder_id_list_cnt);
+ if (folder_type_list != NULL) {
+ cfree(folder_type_list);
+ folder_type_list = NULL;
+ }
return SYNC_AGENT_DA_ERR_NO_DATA;
}
if (event_list_count == 0) {
continue;
}
- calendar_id_list = (int *)calloc(event_list_count, sizeof(int));
-// int count = 0;
+
do {
calendar_record_h event = NULL;
}
_DEBUG_INFO("[da_calendar_plugIn] item id : %d\n", item_id);
-// calendar_id_list[count] = item_id;
-// ++count;
-
err = calendar_db_delete_record(_calendar_event._uri, item_id);
if (err != CALENDAR_ERROR_NONE) {
_DEBUG_ERROR("[da_calendar_plugIn] calendar_svc_delete(%d) Fail!\n", item_id);
} while (calendar_list_next(event_list) != CALENDAR_ERROR_NO_DATA);
-// int i = 0;
-// for( ; i < count; i++) {
-// _DEBUG_INFO("%d = %d", i, calendar_id_list[i]);
-// }
-// /* delete items */
-// service_ret = calendar_db_delete_records(_calendar_event._uri, calendar_id_list, event_list_count, _calendar_db_result_cb, NULL);
-// if (service_ret != CALENDAR_ERROR_NONE) {
-// _DEBUG_ERROR("[da_calendar_plugIn] calendar_db_delete_records Fail!\n");
-// ret = _convert_service_error_to_common_error(service_ret);
-// goto DACI_FINISH;
-// } else {
-// _DEBUG_INFO("[da_calendar_plugIn] calendar_db_delete_records Success!\n");
-// is_storage_changed = 1;
-// }
-// if(calendar_id_list != NULL){
-// free(calendar_id_list);
-// calendar_id_list = NULL;
-// }
-
if (event_list != NULL) {
err = calendar_list_destroy(event_list, true);
if (err != CALENDAR_ERROR_NONE) {
}
DACI_FINISH:
- /* memory free */
- if (calendar_id_list != NULL) {
- free(calendar_id_list);
- calendar_id_list = NULL;
- }
-
if (event_list != NULL) {
err = calendar_list_destroy(event_list, true);
if (err != CALENDAR_ERROR_NONE) {
}
event_list = NULL;
}
-
if (folder_id_list != NULL) {
int cnt = 0;
for (cnt = 0; cnt < folder_id_list_cnt; cnt++) {
cfree(folder_id_list);
_DEBUG_INFO("[da_calendar_plugIn] folder id list free !! \n");
}
+ if (folder_type_list != NULL) {
+ cfree(folder_type_list);
+ folder_type_list = NULL;
+ }
_EXTERN_FUNC_EXIT;
calendar_record_h folder = 0;
/* new service struct */
- int calendar_ret = CALENDAR_ERROR_NONE;
- calendar_ret = calendar_record_create(_calendar_book._uri, &folder);
- if(calendar_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_INFO("[da_calendar_plugIn] calendar_record_create() = %d Fail!\n", calendar_ret);
- *folder_id = 0;
- return SYNC_AGENT_DA_ERRORS;
- }
+ calendar_record_create(_calendar_book._uri, &folder);
if (folder == NULL) {
_DEBUG_INFO("[da_calendar_plugIn] calendar_svc_struct_new() Fail!\n");
*folder_id = 0;
/* delete folder */
err = calendar_db_delete_record(_calendar_book._uri, atoi(folder_id));
if (err != CALENDAR_ERROR_NONE) {
- _DEBUG_INFO("[da_calendar_plugIn] calendar_db_delete_record() Fail!\n");
+ _DEBUG_INFO("[da_calendar_plugIn] calendar_db_delete_record() Fail, err[%d]", err);
ret = _convert_service_error_to_common_error(err);
} else {
_DEBUG_INFO("[da_calendar_plugIn] calendar_svc_delete() Success!\n");
- calendar_db_clean_after_sync(atoi(folder_id));
+ calendar_db_clean_after_sync(atoi(folder_id), 0);
is_storage_changed = 1;
}
{
_EXTERN_FUNC_ENTER;
- int ret = 0;
+ calendar_filter_h filter = NULL;
+ calendar_query_h query = NULL;
+
int used_cnt = 0;
- int err = calendar_db_get_count(_calendar_event._uri, &used_cnt);
- if (err != CALENDAR_ERROR_NONE) {
- _DEBUG_INFO("[da_calendar_plugIn] calendar_db_get_count() Fail\n");
- } else {
- _DEBUG_INFO("[da_calendar_plugIn] calendar_db_get_count() Success\n");
- _DEBUG_INFO("[da_calendar_plugIn] used_count = %d\n", used_cnt);
- ret = used_cnt;
+ int exdate_parent_count = 0;
+ int deleted_exdate_count = 0;
+ int err = CALENDAR_ERROR_NONE;
+
+ err = calendar_db_get_count(_calendar_event._uri, &used_cnt);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_calendar_plugIn] calendar_db_get_count() Fail");
+ goto return_part;
}
- _EXTERN_FUNC_EXIT;
+ _DEBUG_INFO("[da_calendar_plugIn] used_count = %d\n", used_cnt);
- return ret;
+ // check exdate count
+ err = calendar_query_create(_calendar_event._uri, &query);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_calendar_plugIn] calendar_query_create() Fail");
+ goto return_part;
+ }
+ err = calendar_filter_create(_calendar_event._uri, &filter);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_calendar_plugIn] calendar_filter_create() Fail");
+ goto return_part;
+ }
+ err = calendar_filter_add_str(filter, _calendar_event.exdate, CALENDAR_MATCH_EXISTS, "");
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_calendar_plugIn] calendar_filter_add_str() Fail");
+ goto return_part;
+ }
+ err = calendar_query_set_filter(query, filter);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_calendar_plugIn] calendar_query_set_filter() Fail");
+ goto return_part;
+ }
+ err = calendar_db_get_count_with_query(query, &exdate_parent_count);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_calendar_plugIn] calendar_db_get_count_with_query() Fail");
+ goto return_part;
+ }
+
+ _DEBUG_INFO("exdate_parent_count = %d\n", exdate_parent_count);
+
+ // if exdate:delete exist, get deleted exdate count
+ if (exdate_parent_count > 0) {
+ deleted_exdate_count = _get_exdate_count(query);
+ _DEBUG_INFO("deleted_exdate_count = %d\n", deleted_exdate_count);
+ used_cnt += deleted_exdate_count;
+ }
+
+return_part:
+ _DEBUG_INFO("used_cnt = %d", used_cnt);
+ calendar_filter_destroy(filter);
+ calendar_query_destroy(query);
+ _EXTERN_FUNC_EXIT;
+ return used_cnt;
}
EXPORT_API int sync_agent_plugin_get_used_item_count_for_folder(int account_id, char *folder_id)
calendar_filter_h filter = NULL;
calendar_query_h query = NULL;
ret = calendar_query_create(_calendar_event._uri, &query);
- // end pre condition
ret = calendar_filter_create(_calendar_event._uri, &filter);
ret = calendar_filter_add_int(filter, _calendar_event.calendar_book_id, CALENDAR_MATCH_EQUAL, atoi(folder_id));
- // end pre condition
-
ret = calendar_query_set_filter(query, filter);
int used_cnt = 0;
err = _get_service_folder_list_by_account_id(account_id, &service_folder_list, &count);
if (err != SYNC_AGENT_DA_SUCCESS || count == 0) {
_DEBUG_ERROR("_get_service_folder_list_by_account_id failed !!!");
+
+ if (service_folder_list != NULL) {
+ err = calendar_list_destroy(service_folder_list, true);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", err);
+ }
+ service_folder_list = NULL;
+ }
+
+ _EXTERN_FUNC_EXIT;
return NULL;
}
if (count > 0) {
folder_id_list = (char **)calloc(count, sizeof(char *));
if (folder_id_list == NULL) {
_DEBUG_ERROR("CALLOC failed !!!");
+ if (service_folder_list != NULL) {
+ err = calendar_list_destroy(service_folder_list, true);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", err);
+ }
+ service_folder_list = NULL;
+ }
+ _EXTERN_FUNC_EXIT;
return NULL;
}
*folder_type_list = (int *)calloc(count, sizeof(int));
if (*folder_type_list == NULL) {
_DEBUG_ERROR("CALLOC failed !!!");
+ if (folder_id_list) {
+ free(folder_id_list);
+ folder_id_list = NULL;
+ }
+ if (service_folder_list != NULL) {
+ err = calendar_list_destroy(service_folder_list, true);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", err);
+ }
+ service_folder_list = NULL;
+ }
+ _EXTERN_FUNC_EXIT;
return NULL;
}
id_list = (int *)calloc(*count, sizeof(int));
if (id_list == NULL) {
_DEBUG_ERROR("CALLOC failed !!!");
- free(account_info_list);
+ if (account_info_list) {
+ free(account_info_list);
+ account_info_list = NULL;
+ }
_EXTERN_FUNC_EXIT;
return NULL;
}
}
latest_calendar_version = sync_agent_plugin_get_last_change_point();
- _DEBUG_INFO("Current Latest Contact Version : %d", latest_calendar_version);
+ _DEBUG_INFO("Current Latest Calendar Version : %d", latest_calendar_version);
pthread_t thread_process_change_id;
if (pthread_create(&thread_process_change_id, 0, _rutine_calendar_change, 0) < 0) {
#include "plugin/data_connector_interface.h"
-#define BACKUP_PATH "/opt/media/Downloads/Kies/.BnR/CallLog.bk"
+#define BACKUP_PATH "/opt/usr/media/Downloads/Kies/.BnR/CallLog.bk"
#ifndef EXPORT_API
#define EXPORT_API __attribute__ ((visibility("default")))
{
_EXTERN_FUNC_ENTER;
-/* if (contactTimeStamp > 0)
- return contactTimeStamp;
-
- return ((int)time(0) - 1);*/
-
if (mode == 0) {
return contact_version;
}
-/* if (contactVersion > 0)
- return contactVersion;*/
-
-// contacts_svc_begin_trans();
-// contact_version = contacts_svc_end_trans(1);
+ contacts_error_e err_connect = contacts_connect2();
+ if (err_connect != CONTACTS_ERROR_NONE) {
+ _DEBUG_ERROR("contacts_connect2() failed");
+ }
contacts_error_e err = contacts_db_get_current_version(&contact_version);
- if (err != CONTACTS_ERROR_NONE)
- _DEBUG_ERROR("contacts_db_get_current_version is failed");
+ if (err != CONTACTS_ERROR_NONE) {
+ _DEBUG_ERROR("contacts_db_get_current_version() failed");
+ }
+ _DEBUG_INFO("contact_version = %d", contact_version);
- _EXTERN_FUNC_EXIT;
+ err_connect = contacts_disconnect2();
+ if (err_connect != CONTACTS_ERROR_NONE) {
+ _DEBUG_ERROR("contacts_disconnect2() failed");
+ }
+ _EXTERN_FUNC_EXIT;
return contact_version;
}
return ret;
}
-EXPORT_API sync_agent_da_return_e sync_agent_plugin_update_item(int account_id, char *folder_id, char *item_id, void *data)
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_add_bulk_item(int account_id, char *folder_id, void *data, int **item_id, int *item_id_count)
{
_EXTERN_FUNC_ENTER;
-// retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "folder_id is NULL. FAIL !!!");
-// retvm_if(item_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "item_id is NULL. FAIL !!!");
-//
-// sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
-// int err = 0;
-// CTSstruct *item = (CTSstruct *)data;
-//
-// /* update item */
-// err = contacts_svc_update_contact((CTSstruct *)item);
-// if (err < CTS_SUCCESS) {
-// _DEBUG_INFO("[da_contact_plugIn] contacts_svc_update_contact() Fail!\n");
-// ret = _convert_service_error_to_common_error(err);
-// } else {
-// _DEBUG_INFO("[da_contact_plugIn] contacts_svc_update_contact() Success!\n");
-// is_storage_changed = 1;
-// }
-//
-// /* memory free */
-// if (item != NULL)
-// contacts_svc_struct_free(item);
+ retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "[da_contact_plugIn] item_id is NULL. FAIL !!!");
- retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "folder_id is NULL. FAIL !!!");
- retvm_if(item_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "item_id is NULL. FAIL !!!");
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ contacts_error_e contacts_err = CONTACTS_ERROR_NONE;
+ contacts_record_h record = NULL;
+ contacts_list_h list = NULL;
+
+ contacts_err = contacts_list_create(&list);
+ if (contacts_err != CONTACTS_ERROR_NONE) {
+ _DEBUG_ERROR("[da_contact_plugIn] contacts_list_create() Fail, contacts_err[%d]", contacts_err);
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto DACI_FINISH;
+ }
+
+ int count = g_list_length((GList *)data);
+
+ int i = 0;
+ for (i = 0; i < count; ++i) {
+ record = (contacts_record_h)g_list_nth_data(data, i);
+ contacts_err = contacts_list_add(list, record);
+ if (contacts_err != CONTACTS_ERROR_NONE) {
+ _DEBUG_ERROR("[da_contact_plugIn] contacts_list_add() fail, contacts_err[%d]", contacts_err);
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto DACI_FINISH;
+ }
+ }
+
+ unsigned int id_count = 0;
+ int *ids = NULL;
+ contacts_err = contacts_db_insert_records(list, &ids, &id_count);
+ if (contacts_err != CONTACTS_ERROR_NONE) {
+ _DEBUG_ERROR("[da_contact_plugIn] contacts_db_insert_records() Fail, contacts_err[%d]", contacts_err);
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto DACI_FINISH;
+ }
+ _DEBUG_INFO("Inputed data's count = [%d], Saved data's count = [%d]", count, id_count);
+ if (count != id_count) {
+ _DEBUG_ERROR("[da_contact_plugIn] contacts_db_insert_records() API wesn't create all contact data.");
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto DACI_FINISH;
+ }
+
+/*
+ //for test
+ for (i = 0; i < count; ++i) {
+ _DEBUG_INFO("[da_contact_plugIn] ids[%d] of [%d]", ids[i], id_count);
+ }
+*/
+
+ is_storage_changed = 1;
+
+ *item_id = ids;
+ *item_id_count = id_count;
+
+DACI_FINISH:
+ _DEBUG_INFO("[da_contact_plugIn] DACI_FINISH");
+
+ if (list != NULL) {
+ contacts_err = contacts_list_destroy(list, true);
+ if (contacts_err != CONTACTS_ERROR_NONE) {
+ _DEBUG_ERROR("[da_contact_plugIn] contacts_list_destroy() fail, contacts_err[%d]", contacts_err);
+ }
+ list = NULL;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_update_item(int account_id, char *folder_id, char *item_id, void *data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "[da_contact_plugIn] folder_id is NULL. FAIL !!!");
+ retvm_if(item_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "[da_contact_plugIn] item_id is NULL. FAIL !!!");
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
contacts_error_e err = CONTACTS_ERROR_NONE;
contacts_record_destroy(record, true);
_EXTERN_FUNC_EXIT;
-
return ret;
+}
-/*sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
- int err = 0;
- CTSstruct *item = (CTSstruct *)data;
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_update_bulk_item(void *data)
+{
+ _EXTERN_FUNC_ENTER;
- err = contacts_svc_update_contact(item);
- if (err < CTS_SUCCESS) {
- _DEBUG_INFO("[da_contact_plugIn] contacts_svc_update_contact() Fail!\n");
- ret = _convert_service_error_to_common_error(err);
- } else {
- _DEBUG_INFO("[da_contact_plugIn] contacts_svc_update_contact() Success!\n");
+ sync_agent_da_return_e da_ret = SYNC_AGENT_DA_SUCCESS;
+ contacts_error_e contacts_ret = CONTACTS_ERROR_NONE;
+ contacts_record_h record = NULL;
+ contacts_list_h list = NULL;
+
+ contacts_ret = contacts_list_create(&list);
+ if (contacts_ret != CONTACTS_ERROR_NONE) {
+ _DEBUG_ERROR("[da_contact_plugIn] contacts_list_create() fail, contacts_ret[%d]", contacts_ret);
+ return SYNC_AGENT_DA_ERRORS;
}
- // memory free
- if (item != NULL)
- contacts_svc_struct_free(item);
+ int i = 0;
+ for (i = 0; i < g_list_length((GList *)data); ++i) {
+ record = (contacts_record_h)g_list_nth_data(data, i);
+ contacts_ret = contacts_list_add(list, record);
+ if (contacts_ret != CONTACTS_ERROR_NONE) {
+ _DEBUG_ERROR("[da_contact_plugIn] contacts_list_add() fail, contacts_ret[%d]", contacts_ret);
+ da_ret = SYNC_AGENT_DA_ERRORS;
+ goto DACI_FINISH;
+ }
+ }
+
+ contacts_ret = contacts_db_update_records(list);
+ if (contacts_ret != CONTACTS_ERROR_NONE) {
+ _DEBUG_ERROR("[da_contact_plugIn] contacts_db_update_records() fail, contacts_ret[%d]", contacts_ret);
+ da_ret = SYNC_AGENT_DA_ERRORS;
+ goto DACI_FINISH;
+ }
+ is_storage_changed = 1;
- return ret;*/
+DACI_FINISH:
+ _DEBUG_INFO("[da_contact_plugIn] DACI_FINISH");
+
+ if (list != NULL) {
+ contacts_ret = contacts_list_destroy(list, true);
+ if (contacts_ret != CONTACTS_ERROR_NONE) {
+ _DEBUG_ERROR("[da_contact_plugIn] contacts_list_destroy() fail, contacts_ret[%d]", contacts_ret);
+ da_ret = SYNC_AGENT_DA_ERRORS;
+ }
+ list = NULL;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return da_ret;
}
EXPORT_API sync_agent_da_return_e sync_agent_plugin_delete_item(int account_id, char *folder_id, char *item_id)
{
_EXTERN_FUNC_ENTER;
-// retvm_if(item_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "item_id is NULL. FAIL !!!");
-//
-// sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
-// int err = 0;
-//
-// /* delete item */
-// err = contacts_svc_delete_contact(atoi(item_id));
-// if (err < CTS_SUCCESS) {
-// _DEBUG_INFO("[da_contact_plugIn] contacts_svc_delete_contact(%s) Fail!\n", item_id);
-// ret = _convert_service_error_to_common_error(err);
-// } else {
-// _DEBUG_INFO("[da_contact_plugIn] contacts_svc_delete_contact(%s) Success!\n", item_id);
-// is_storage_changed = 1;
-// }
-
- retvm_if(item_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "item_id is NULL. FAIL !!!");
+ retvm_if(item_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "[da_contact_plugIn] item_id is NULL. FAIL !!!");
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
contacts_error_e err = CONTACTS_ERROR_NONE;
- /* delete item */
err = contacts_db_delete_record(_contacts_contact._uri, atoi(item_id));
if (err != CONTACTS_ERROR_NONE) {
_DEBUG_ERROR("[da_contact_plugIn] contacts_db_delete_record(%s) Fail!\n", item_id);
return ret;
}
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_delete_bulk_item(int *item_id, int count)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(item_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "[da_contact_plugIn] item_id is NULL. FAIL !!!");
+ retvm_if(count == 0, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "[da_contact_plugIn] count is 0. FAIL !!!");
+
+ sync_agent_da_return_e da_ret = SYNC_AGENT_DA_SUCCESS;
+ contacts_error_e contacts_err = CONTACTS_ERROR_NONE;
+
+ contacts_err = contacts_db_delete_records(_contacts_contact._uri, item_id, count);
+ if (contacts_err != CONTACTS_ERROR_NONE) {
+ _DEBUG_ERROR("[da_contact_plugIn] contacts_db_delete_records(%s) fail, contacts_err[%d]", *item_id, contacts_err);
+ da_ret = _convert_service_error_to_common_error(contacts_err);
+ } else {
+ is_storage_changed = 1;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return da_ret;
+}
+
EXPORT_API sync_agent_da_return_e sync_agent_plugin_delete_all_items(int account_id)
{
_EXTERN_FUNC_ENTER;
/* delete items */
err = contacts_db_delete_records_async(_contacts_contact._uri, contact_id_list, count, _contacts_db_result_cb, NULL);
if (err != CONTACTS_ERROR_NONE) {
- _DEBUG_ERROR("[da_contact_plugIn] contacts_db_delete_records Fail!\n");
+ _DEBUG_ERROR("[da_contact_plugIn] contacts_db_delete_records_async() Fail");
ret = _convert_service_error_to_common_error(err);
goto DACI_FINISH;
} else {
- _DEBUG_INFO("[da_contact_plugIn] contacts_db_delete_records Success!\n");
+ _DEBUG_INFO("[da_contact_plugIn] contacts_db_delete_records_async() Success");
is_storage_changed = 1;
}
free(folder_type_list);
_DEBUG_INFO("[da_contact_plugIn] folder type list free !! \n");
}
+ if (contact_id_list != NULL) {
+ free(contact_id_list);
+ contact_id_list = NULL;
+ }
_EXTERN_FUNC_EXIT;
id_list = (int *)calloc(*count, sizeof(int));
if (id_list == NULL) {
_DEBUG_ERROR("CALLOC failed !!!");
- free(account_info_list);
+ if (account_info_list) {
+ free(account_info_list);
+ account_info_list = NULL;
+ }
return NULL;
}
cursor_ptr = account_info_list;
{
_EXTERN_FUNC_ENTER;
-// _DEBUG_INFO("\n[da_contact_plugIn] account_id : %d\n", account_id);
-// _DEBUG_INFO("[da_contact_plugIn] folder_id : %s\n", folder_id);
-// _DEBUG_INFO("[da_contact_plugIn] changepoint : %d\n", change_point);
-//
-// sync_agent_plugin_item_node_s *root_ptr = 0;
-// sync_agent_plugin_item_node_s *cursor_ptr = 0;
-// int chagned_count = 0;
-//
-// int contact_version = change_point;
-//
-// int addressbook_id = atoi(folder_id);
-// CTSiter *iter = 0;
-// contacts_svc_get_updated_contacts(addressbook_id, contact_version, &iter);
-//
-// int contact_ret = contacts_svc_iter_next(iter);
-// while (CTS_SUCCESS == contact_ret) {
-// CTSvalue *row_info = 0;
-//
-// if ((row_info = contacts_svc_iter_get_info(iter)) == CTS_SUCCESS) {
-// _DEBUG_INFO("[da_contact_plugIn] contacts_svc_iter_get_info() failed.\n");
-// } else {
-// int type = contacts_svc_value_get_int(row_info, CTS_LIST_CHANGE_TYPE_INT);
-//
-// switch (type) {
-// case CTS_OPERATION_INSERTED:
-// {
-// int contact_id = contacts_svc_value_get_int(row_info, CTS_LIST_CHANGE_ID_INT);
-// char *contact_id_str = g_strdup_printf("%d", contact_id);
-// _DEBUG_INFO("[da_contact_plugIn] CTS_OPERATION_INSERTED : [%s]\n", contact_id_str);
-//
-// if (root_ptr == NULL) {
-// root_ptr = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
-// if( root_ptr == NULL ) {
-// _DEBUG_ERROR("CALLOC failed !!!");
-// return NULL;
-// }
-// root_ptr->item_id = contact_id_str;
-// root_ptr->next = 0;
-// cursor_ptr = root_ptr;
-// } else {
-// cursor_ptr->next = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
-// if( cursor_ptr->next == NULL ) {
-// _DEBUG_ERROR("CALLOC failed !!!");
-// return NULL;
-// }
-// cursor_ptr->next->item_id = contact_id_str;
-// cursor_ptr->next->next = 0;
-// cursor_ptr = cursor_ptr->next;
-// }
-//
-// chagned_count++;
-// }
-// break;
-// default:
-///* _DEBUG_INFO("[da_contact_plugIn] Another Contact Change Noti");*/
-// break;
-// }
-// }
-//
-// contacts_svc_value_free(row_info); /* next changing */
-// row_info = 0;
-// contact_ret = contacts_svc_iter_next(iter);
-// }
-//
-// /* memory free */
-// if (iter != NULL) {
-// contacts_svc_iter_remove(iter);
-// iter = 0;
-// _DEBUG_INFO("[da_contact_plugIn] contacts_svc_iter_remove !! \n");
-// }
-// *change_count = chagned_count;
-
- _DEBUG_INFO("\n[da_contact_plugIn] account_id : %d\n", account_id);
- _DEBUG_INFO("[da_contact_plugIn] folder_id : %s\n", folder_id);
- _DEBUG_INFO("[da_contact_plugIn] changepoint : %d\n", change_point);
+ _DEBUG_INFO("[da_contact_plugIn] account_id = [%d]", account_id);
+ _DEBUG_INFO("[da_contact_plugIn] folder_id = [%s]", folder_id);
+ _DEBUG_INFO("[da_contact_plugIn] changepoint = [%d]", change_point);
sync_agent_plugin_item_node_s *root_ptr = 0;
sync_agent_plugin_item_node_s *cursor_ptr = 0;
err = contacts_db_get_changes_by_version(_contacts_contact_updated_info._uri, addressbook_id, contact_version, &list, ¤t_contact_version);
if (err != CONTACTS_ERROR_NONE) {
- _DEBUG_ERROR("[da_contact_plugIn] contacts_db_get_changes_by_version Fail\n");
+ _DEBUG_ERROR("[da_contact_plugIn] contacts_db_get_changes_by_version() Fail, err[%d]", err);
goto DACI_FINISH;
}
err = contacts_list_first(list);
+ if (err != CONTACTS_ERROR_NONE) {
+ _DEBUG_ERROR("[da_contact_plugIn] contacts_list_first() fail, err[%d]", err);
+ goto DACI_FINISH;
+ }
+
while (CONTACTS_ERROR_NONE == err) {
err = contacts_list_get_current_record_p(list, &record);
if (err != CONTACTS_ERROR_NONE) {
- _DEBUG_ERROR("[da_contact_plugIn] contacts_list_get_current_record_p Fail\n");
+ _DEBUG_ERROR("[da_contact_plugIn] contacts_list_get_current_record_p() Fail, err[%d]", err);
} else {
int type;
err = contacts_record_get_int(record, _contacts_contact_updated_info.type, &type);
if (err != CONTACTS_ERROR_NONE) {
- _DEBUG_ERROR("[da_contact_plugIn] contacts_query_set_projection Fail\n");
+ _DEBUG_ERROR("[da_contact_plugIn] contacts_record_get_int() Fail, err[%d]", err);
goto DACI_FINISH;
}
int contact_id;
err = contacts_record_get_int(record, _contacts_contact_updated_info.contact_id, &contact_id);
if (err != CONTACTS_ERROR_NONE) {
- _DEBUG_ERROR("[da_contact_plugIn] contacts_query_set_projection Fail\n");
+ _DEBUG_ERROR("[da_contact_plugIn] contacts_record_get_int() Fail, err[%d]", err);
goto DACI_FINISH;
}
char *contact_id_str = g_strdup_printf("%d", contact_id);
- _DEBUG_INFO("[da_contact_plugIn] CTS_OPERATION_INSERTED : [%s]\n", contact_id_str);
+ _DEBUG_INFO("[da_contact_plugIn] CTS_OPERATION_INSERTED = [%s]", contact_id_str);
if (root_ptr == NULL) {
root_ptr = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
if (root_ptr == NULL) {
- _DEBUG_ERROR("CALLOC failed !!!");
- return NULL;
+ _DEBUG_ERROR("[da_contact_plugIn] Calloc failed, root_ptr is NULL");
+ goto DACI_FINISH;
}
root_ptr->item_id = contact_id_str;
root_ptr->next = 0;
} else {
cursor_ptr->next = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
if (cursor_ptr->next == NULL) {
- _DEBUG_ERROR("CALLOC failed !!!");
- return NULL;
+ _DEBUG_ERROR("[da_contact_plugIn] Calloc failed, cursor_ptr->next is NULL");
+ root_ptr = NULL;
+ goto DACI_FINISH;
}
cursor_ptr->next->item_id = contact_id_str;
cursor_ptr->next->next = 0;
break;
}
err = contacts_list_next(list);
+ if (err != CONTACTS_ERROR_NONE) {
+ _DEBUG_ERROR("[da_contact_plugIn] contacts_list_next() fail, err[%d]", err);
+ goto DACI_FINISH;
+ }
}
}
- DACI_FINISH:
+DACI_FINISH:
+ _DEBUG_INFO("DACI_FINISH");
*change_count = chagned_count;
- contacts_list_destroy(list, true);
+ if (list != NULL) {
+ err = contacts_list_destroy(list, true);
+ if (err != CONTACTS_ERROR_NONE) {
+ _DEBUG_ERROR("[da_contact_plugIn] contacts_list_destroy() fail, err[%d]", err);
+ goto DACI_FINISH;
+ }
+ }
_EXTERN_FUNC_EXIT;
-
return root_ptr;
}
{
_INNER_FUNC_ENTER;
- _DEBUG_TRACE("[da_contact_plugIn] detected contact storage changed!!\n");
-
int from_Me = _get_is_noti_from_me();
-
if (from_Me == 1) {
_DEBUG_TRACE("[da_contact_plugIn] This noti has been sended from Me!! so will be ignored!!\n");
_set_is_noti_from_me(0);
latest_contact_version++;
+ _DEBUG_INFO("latest_contact_version = %d", latest_contact_version);
return;
}
_DEBUG_ERROR("CALLOC failed !!!");
return;
}
+
*contactVersion = latest_contact_version;
latest_contact_version++;
+ _DEBUG_INFO("latest_contact_version = %d", latest_contact_version);
_DEBUG_TRACE("fw_async_queue_length = %d", sync_agent_async_queue_length(queue));
if (sync_agent_async_queue_length(queue) < 1) {
int current_contact_version;
err = contacts_db_get_changes_by_version(_contacts_contact_updated_info._uri, addressbook_id, contact_version, &contact_list, ¤t_contact_version);
+ _DEBUG_TRACE("contact_version = %d, current_contact_version = %d\n", contact_version, current_contact_version);
if (err != CONTACTS_ERROR_NONE)
_DEBUG_ERROR("[da_contact_plugIn] contacts_db_get_changes_by_version Fail\n");
err = contacts_list_first(contact_list);
- _DEBUG_TRACE("err = %d", err);
+ unsigned int contact_count = 0;
+ contacts_list_get_count(contact_list, &contact_count);
+ _DEBUG_INFO("err = %d, contact_count = %d", err, contact_count);
while (err == CONTACTS_ERROR_NONE) {
err = contacts_list_get_current_record_p(contact_list, &contact_record);
*/
curl = curl_easy_init();
if (proxy != NULL) {
- ret = curl_easy_setopt(curl, CURLOPT_PROXY, proxy);
+ if(strncmp(proxy,"http://0.0.0.0", strlen("http://0.0.0.0")) == 0) {
+ } else {
+ ret = curl_easy_setopt(curl, CURLOPT_PROXY, proxy);
+ }
}
ret = curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, timeout);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, curl_progress_cb);
- curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, msg->session);
+ curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, session);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_http_buffer_cb);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, msg->response_body);
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, write_http_buffer_cb);
#define LOG_TAG "SLP_DEVICE_INFO"
#endif
-#define _D_MSC_FIRMWARE_MAXSTRING_ 40
+#define _D_MSC_FIRMWARE_MAXSTRING_ 64
#define _D_SIZE_64_ 64
#define _D_SIZE_128_ 128
/* todo : temporary definition */
#define SW_VERSION "SLP-v1.0"
-#define HW_VERSION "GT-I9500-v1.0"
+#define HW_VERSION "GT-I8800-v1.0"
#define FW_VERSION "1.0"
-#define MODEM_VERSION "M.I9500XXUI"
-#define PDA_VERSION "P.I9500XXJI-"
+#define MODEM_VERSION "M.I8800XXUI"
+#define PDA_VERSION "P.I8800XXJI-"
#define PDA_BIN_VERSION "/usr/etc/info.ini"
#define PDA_VERSION_INFO_FILE "/etc/info.ini"
#define CSC_DB_VERSION "/mnt/csc/info.ini"
#define _D_PDA_BUILD_INFO_BUILD_ "Build="
#define MANUFACTURE "Samsung electronics"
-#define MODEL "GT-I9500"
+#define MODEL "GT-I8800"
#define OEM "Samsung Electronics"
#define DEV_TYPE "phone"
if (!handle)
_DEBUG_INFO("tapi handle is null\n");
- TelMiscVersionInformation *info = tel_get_misc_me_version_sync(handle);
+ //TelMiscVersionInformation *info = tel_get_misc_me_version_sync(handle);
+ TelMiscVersionInformation *info = NULL; // this code is rsa & emulator
if (!info) {
_DEBUG_INFO("tet_get_misc_me_version_sync -> return Fail\n");
get_str = strdup("I8800XXKI1");
return csc_version;
*/
+/*
char *csc_version = NULL;
TapiHandle *handle = tel_init(NULL);
if (!handle)
tel_deinit(handle);
_DEBUG_INFO("Modem version = %s\n", csc_version);
+*/
+ char *csc_version = NULL;
+ char CSC_Ver[64] = {0,};
+ int err = 0;
+ if (err == 0) {
+ _DEBUG_ERROR("CSC_Ver get fail\n");
+ snprintf(CSC_Ver, 64, "%s", "I8800OXAALJ4");
+ }
+ csc_version = strdup(CSC_Ver);
_EXTERN_FUNC_EXIT;
return csc_version;
return 0;
}
- char *modem_version = slp_device_info_get_modem_version();
- _DEBUG_INFO("firmware_ver modem - [%s]\n", modem_version);
- if (modem_version != NULL) {
- /*if( strncmp(modem_version,"I9500", sizeof(char)*strlen("I9500") ) == 0 ) */
- snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s-", modem_version + sizeof(char) * (strlen("I8800")));
- /*else
- snprintf(firmware_ver + index, _D_SIZE_128_/3 , "%s-", modem_version); */
- } else {
- snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s-", "XXKI1");
+
+ char *pda_version = slp_device_info_get_pda_version(); // GT-I8800_c210_2012_09_10_2
+ _DEBUG_INFO("firmware_ver pda [%s]\n", pda_version);
+ if (pda_version != NULL) {
+ snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s/", pda_version);
}
if (firmware_ver != NULL) {
_DEBUG_INFO("index = %d\n", index);
_DEBUG_INFO("firmware Ver1 = %s\n", firmware_ver);
- char *pda_version = slp_device_info_get_pda_version(); // GT-I8800_c210_2012_09_10_2
- _DEBUG_INFO("firmware_ver modem-pda-[%s]\n", pda_version);
- if (pda_version != NULL) {
- /*
- if (strncmp(pda_version, "I9500-c210-2012", (sizeof(char)) * (strlen("I9500-c210-2012"))) == 0)
- snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s-", pda_version + sizeof(char) * (strlen("I9500-c210-2012")));
- else if (strncmp(pda_version, "I9500-2012", sizeof(char) * (strlen("I9500-2012"))) == 0)
- snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s-", pda_version + sizeof(char) * (strlen("I9500-2012")));
- else
- snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s-", pda_version);
- */
- snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s-", pda_version);
+ char *csc_version = slp_device_info_get_csc_version();
+ _DEBUG_INFO("firmware_ver pda/csc [%s]\n", csc_version);
+ if (csc_version != NULL) {
+ snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s/", csc_version);
}
if (firmware_ver != NULL) {
return 0;
}
- char *csc_version = slp_device_info_get_csc_version();
- _DEBUG_INFO("firmware_ver modem-pda-csc - [%s]\n", csc_version);
- if (csc_version != NULL) {
- /*
- if (strncmp(csc_version, "I9500OXA-c210-2012", sizeof(char) * (strlen("I9500OXA-c210-2012"))) == 0)
- snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s", csc_version + sizeof(char) * (strlen("I9500OXA-c210-2012")));
- else if (strncmp(csc_version, "I9500OXA-2012", sizeof(char) * strlen("I9500OXA-2012")) == 0)
- snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s", csc_version + sizeof(char) * (strlen("I9500OXA-c210-2012")));
- else if (strncmp(csc_version, "I9500-c210-2012", sizeof(char) * strlen("I9500-c210-2012")) == 0)
- snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s", csc_version + sizeof(char) * (strlen("I9500-c210-2012")));
- else if (strncmp(csc_version, "I9500-2012", sizeof(char) * (strlen("I9500-2012"))) == 0)
- snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s", csc_version + sizeof(char) * (strlen("I9500-2012")));
- else
- snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s", csc_version);
- */
- snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s", csc_version);
+ char *modem_version = slp_device_info_get_modem_version();
+ _DEBUG_INFO("firmware_ver modem - [%s]\n", modem_version);
+ if (modem_version != NULL) {
+ //snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s", modem_version + sizeof(char) * (strlen("I8800")));
+ snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s", modem_version);
+ } else {
+ snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s", "XXKI1");
}
+
+
if (modem_version != NULL) {
free(modem_version);
modem_version = NULL;
_DEBUG_INFO("handle is NULL !!");
} else {
_DEBUG_INFO("handle : %d", handle);
- imei = tel_get_misc_me_imei_sync(handle);
+ //imei = tel_get_misc_me_imei_sync(handle);
+ imei = strdup("333333333333333"); // this code is rsa & emulator.
_DEBUG_INFO("imei : %s", imei);
}
pmci_alarm_s *temp_add_data = (pmci_alarm_s *) add_data;
- /* allocate service alarm struct */
- alarm_entry_t *service_add_data = NULL;
- service_add_data = alarmmgr_create_alarm();
- if (service_add_data == NULL)
- goto return_part;
-
- /* convert fw struct to service struct */
-
- /* setting start alarm time */
- if (temp_add_data->start_alarm_time != NULL) {
- alarm_date_t expire_time;
- memset(&expire_time, 0x00, sizeof(alarm_date_t));
- err = _convert_service_time(temp_add_data->start_alarm_time, &expire_time);
- if (err != 1)
- _DEBUG_ERROR("__convert_alarm_time() failed (err_code : %d ) !!", err);
-
- err = alarmmgr_set_time(service_add_data, expire_time);
- if (err != ALARMMGR_RESULT_SUCCESS)
- _DEBUG_ERROR("alarmmgr_set_time() failed ( err_code : %d ) !!", err);
- }
+ _DEBUG_INFO("temp_add_data start_alarm_time[%s], repeat_type[%d], repeat_value[%d], is_disposable[%d]", temp_add_data->start_alarm_time, temp_add_data->repeat_type, temp_add_data->repeat_value, temp_add_data->is_disposable);
+ int appsync_alarm = 0;
+
+
+ if(appsync_alarm == 0) {
+
+
+ /* allocate service alarm struct */
+ alarm_entry_t *service_add_data = NULL;
+ service_add_data = alarmmgr_create_alarm();
+ if (service_add_data == NULL)
+ goto return_part;
+
+ /* convert fw struct to service struct */
- /* setting repeat mode and repeat value */
- alarm_repeat_mode_t repeat_mode = 0;
- if (temp_add_data->repeat_type != REPEAT_NO_TYPE) {
- switch (temp_add_data->repeat_type) {
- case ONCE:
- repeat_mode = ALARM_REPEAT_MODE_ONCE;
- break;
- case REPEAT:
- repeat_mode = ALARM_REPEAT_MODE_REPEAT;
- break;
- case REPEAT_WEEKLY:
- repeat_mode = ALARM_REPEAT_MODE_WEEKLY;
- break;
- case REPEAT_MONTHLY:
- repeat_mode = ALARM_REPEAT_MODE_MONTHLY;
- break;
- case REPEAT_ANNUALLY:
- repeat_mode = ALARM_REPEAT_MODE_ANNUALLY;
- break;
- default:
- break;
+ /* setting start alarm time */
+ if (temp_add_data->start_alarm_time != NULL) {
+ alarm_date_t expire_time;
+ memset(&expire_time, 0x00, sizeof(alarm_date_t));
+ err = _convert_service_time(temp_add_data->start_alarm_time, &expire_time);
+ if (err != 1)
+ _DEBUG_ERROR("__convert_alarm_time() failed (err_code : %d ) !!", err);
+
+ err = alarmmgr_set_time(service_add_data, expire_time);
+ if (err != ALARMMGR_RESULT_SUCCESS)
+ _DEBUG_ERROR("alarmmgr_set_time() failed ( err_code : %d ) !!", err);
}
- }
- alarm_day_of_week_t repeat_value = 0;
- if (temp_add_data->repeat_value != DAY_NO_TYPE) {
- switch (temp_add_data->repeat_type) {
- case ONCE:
- case REPEAT:
- {
- repeat_value = temp_add_data->repeat_value;
+ /* setting repeat mode and repeat value */
+ alarm_repeat_mode_t repeat_mode = 0;
+ if (temp_add_data->repeat_type != REPEAT_NO_TYPE) {
+ switch (temp_add_data->repeat_type) {
+ case ONCE:
+ repeat_mode = ALARM_REPEAT_MODE_ONCE;
+ break;
+ case REPEAT:
+ repeat_mode = ALARM_REPEAT_MODE_REPEAT;
+ break;
+ case REPEAT_WEEKLY:
+ repeat_mode = ALARM_REPEAT_MODE_WEEKLY;
+ break;
+ case REPEAT_MONTHLY:
+ repeat_mode = ALARM_REPEAT_MODE_MONTHLY;
+ break;
+ case REPEAT_ANNUALLY:
+ repeat_mode = ALARM_REPEAT_MODE_ANNUALLY;
+ break;
+ default:
+ break;
}
- break;
- case REPEAT_ANNUALLY:
- case REPEAT_MONTHLY:
- case REPEAT_WEEKLY:
- {
- int tmp;
- int num = 1;
-
- int i;
- for (i = 1; i <= DAY_CNT; i++) {
- tmp = (temp_add_data->repeat_value >> i);
- switch (tmp) {
- case DAY_SUN:
- repeat_value |= ALARM_WDAY_SUNDAY;
- break;
- case DAY_MON:
- repeat_value |= ALARM_WDAY_MONDAY;
- break;
- case DAY_TUE:
- repeat_value |= ALARM_WDAY_TUESDAY;
- break;
- case DAY_WED:
- repeat_value |= ALARM_WDAY_WEDNESDAY;
- break;
- case DAY_THU:
- repeat_value |= ALARM_WDAY_THURSDAY;
- break;
- case DAY_FRI:
- repeat_value |= ALARM_WDAY_FRIDAY;
- break;
- case DAY_SAT:
- repeat_value |= ALARM_WDAY_SATURDAY;
- break;
- default:
- break;
- }
+ }
- num *= 2;
+ alarm_day_of_week_t repeat_value = 0;
+ if (temp_add_data->repeat_value != DAY_NO_TYPE) {
+ switch (temp_add_data->repeat_type) {
+ case ONCE:
+ case REPEAT:
+ {
+ repeat_value = temp_add_data->repeat_value;
}
+ break;
+ case REPEAT_ANNUALLY:
+ case REPEAT_MONTHLY:
+ case REPEAT_WEEKLY:
+ {
+ int tmp;
+ int num = 1;
+
+ int i;
+ for (i = 1; i <= DAY_CNT; i++) {
+ tmp = (temp_add_data->repeat_value >> i);
+ switch (tmp) {
+ case DAY_SUN:
+ repeat_value |= ALARM_WDAY_SUNDAY;
+ break;
+ case DAY_MON:
+ repeat_value |= ALARM_WDAY_MONDAY;
+ break;
+ case DAY_TUE:
+ repeat_value |= ALARM_WDAY_TUESDAY;
+ break;
+ case DAY_WED:
+ repeat_value |= ALARM_WDAY_WEDNESDAY;
+ break;
+ case DAY_THU:
+ repeat_value |= ALARM_WDAY_THURSDAY;
+ break;
+ case DAY_FRI:
+ repeat_value |= ALARM_WDAY_FRIDAY;
+ break;
+ case DAY_SAT:
+ repeat_value |= ALARM_WDAY_SATURDAY;
+ break;
+ default:
+ break;
+ }
+
+ num *= 2;
+ }
+ }
+ break;
+ default:
+ break;
}
- break;
- default:
- break;
}
- }
- err = alarmmgr_set_repeat_mode(service_add_data, repeat_mode, repeat_value);
- if (err != ALARMMGR_RESULT_SUCCESS)
- _DEBUG_ERROR("alarmmgr_set_repeat_mode() failed ( err_code : %d ) !!", err);
+ err = alarmmgr_set_repeat_mode(service_add_data, repeat_mode, repeat_value);
+ if (err != ALARMMGR_RESULT_SUCCESS)
+ _DEBUG_ERROR("alarmmgr_set_repeat_mode() failed ( err_code : %d ) !!", err);
- /* set alarm type */
- int alarm_type = 0;
- if (temp_add_data->is_disposable != 0) {
- alarm_type = ALARM_TYPE_VOLATILE;
- } else {
- alarm_type = ALARM_TYPE_DEFAULT;
- }
+ /* set alarm type */
+ int alarm_type = 0;
+ if (temp_add_data->is_disposable != 0) {
+ alarm_type = ALARM_TYPE_VOLATILE;
+ } else {
+ alarm_type = ALARM_TYPE_DEFAULT;
+ }
+
+ err = alarmmgr_set_type(service_add_data, alarm_type);
+ if (err != ALARMMGR_RESULT_SUCCESS)
+ _DEBUG_ERROR("alarmmgr_set_type() failed ( err_code : %d ) !!", err);
- err = alarmmgr_set_type(service_add_data, alarm_type);
- if (err != ALARMMGR_RESULT_SUCCESS)
- _DEBUG_ERROR("alarmmgr_set_type() failed ( err_code : %d ) !!", err);
+ /* insert add alarm item */
+ int alarm_id = 0;
+ int result = alarmmgr_add_alarm_with_localtime(service_add_data, 0, &alarm_id);
+ if (result != ALARMMGR_RESULT_SUCCESS) {
+ _DEBUG_ERROR("alarmmgr_add_alarm() failed ( err_code : %d ) !!", result);
+ err = 0;
+ } else {
+ _DEBUG_INFO("alarmmgr_add_alarm() success ( alarm_id : %d ) !!", alarm_id);
+ *added_data_id = alarm_id;
+ err = 1;
+ }
- /* insert add alarm item */
- int alarm_id = 0;
- int result = alarmmgr_add_alarm_with_localtime(service_add_data, 0, &alarm_id);
- if (result != ALARMMGR_RESULT_SUCCESS) {
- _DEBUG_ERROR("alarmmgr_add_alarm() failed ( err_code : %d ) !!", result);
- err = 0;
- } else {
- _DEBUG_INFO("alarmmgr_add_alarm() success ( alarm_id : %d ) !!", alarm_id);
- *added_data_id = alarm_id;
- err = 1;
+ if (service_add_data != NULL)
+ alarmmgr_free_alarm(service_add_data);
}
- if (service_add_data != NULL)
- alarmmgr_free_alarm(service_add_data);
-
return_part:
if (err != 1) {
ret = SYNC_AGENT_PM_FAIL;
--- /dev/null
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "da-calendar-task")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+ calendar-service2
+ glib-2.0
+ accounts-svc
+ dlog)
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${da-calendar-task_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${da-calendar-task_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub)
\ No newline at end of file
--- /dev/null
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef EXT_DATASTORE_INFO_CALENDAR_H_
+#define EXT_DATASTORE_INFO_CALENDAR_H_
+
+typedef enum {
+ CALENDAR_FIELD_DB_INDEX = 1,
+ CALENDAR_FIELD_SUMMARY,
+ CALENDAR_FIELD_DESCRIPTION,
+ CALENDAR_FIELD_LOCATOIN,
+ CALENDAR_FIELD_YEAR,
+ CALENDAR_FIELD_MODEL,
+ CALENDAR_FIELD_MEMO,
+ CALENDAR_FIELD_TIMEZONE,
+ CALENDAR_FIELD_TYPE_MODEL
+} calenadr_field_e;
+
+typedef enum {
+ CALENDAR_CHILD_FIELD_BIAS = 1,
+ CALENDAR_CHILD_FIELD_DAYLIGHT,
+ CALENDAR_CHILD_FIELD_DAYLIGHT_BIAS,
+ CALENDAR_CHILD_FIELD_DAYLIGHT_BEGIN,
+ CALENDAR_CHILD_FIELD_DAYLIGHT_END,
+ CALENDAR_CHILD_FIELD_STANDARD_TIMENAME,
+ CALENDAR_CHILD_FIELD_DAYLIGHT_TIMENAME
+} calendar_child_field_e;
+
+typedef enum {
+ CALENDAR_FEATURE_APPOINTMENT = 1,
+ CALENDAR_FEATURE_ANNIVERSARY,
+ CALENDAR_FEATURE_HOLIDAY,
+ CALENDAR_FEATURE_IMPORTANT,
+ CALENDAR_FEATURE_PRIVATE,
+ CALENDAR_FEATURE_MISCELLANEOUS,
+ CALENDAR_FEATURE_TASK,
+ CALENDAR_FEATURE_MEMO
+} calendar_feature_e;
+
+#endif /* EXT_DATASTORE_INFO_CALENDAR_H_ */
--- /dev/null
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef EXTERN_INFO_H_
+#define EXTERN_INFO_H_
+
+typedef enum {
+ DEFAULT_CALENDAR_FOLDER = 0,
+ USER_DEFINED_FOLDER
+} calendar_folder_type_e;
+
+#endif /* EXTERN_INFO_H_ */
--- /dev/null
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IN_DATASTORE_INFO_TASK_H_
+#define IN_DATASTORE_INFO_TASK_H_
+
+/* ITEM COUNT */
+#define MAX_ITEM_COUNT_TASK 65535
+
+/* TIMEZONE FIELD */
+#define VAL_TZ_BIAS NULL
+#define VAL_TZ_DAYLIGHT NULL
+#define VAL_TZ_DAYLIGHT_BIAS NULL
+#define VAL_TZ_DAYLIGHT_BEGIN NULL
+#define VAL_TZ_DAYLIGHT_END NULL
+#define VAL_TZ_STANDARD_TIMENAME NULL
+#define VAL_TZ_DAYLIGHT_TIMENAME NULL
+
+/* CALENDAR INFO */
+#define MAX_LEN_SUMMARY 65535
+#define MAX_LEN_DESCRIPTION 65535
+#define MAX_LEN_LOCATION 65535
+#define MIN_PERIOD_YEAR 1902
+#define MAX_PERIOD_YEAR 2037
+#define MAX_LEN_MEMO FALSE
+#define VAL_TYPE_MODEL "A"
+
+/* FEATURE */
+#define IF_SUPPORT_APPOINTMENT TRUE
+#define IF_SUPPORT_ANNIVERSARY FALSE
+#define IF_SUPPORT_HOLIDAY FALSE
+#define IF_SUPPORT_IMPORTANT FALSE
+#define IF_SUPPORT_PRIVATE FALSE
+#define IF_SUPPORT_MISCELLANEOUS FALSE
+#define IF_SUPPORT_TASK FALSE
+#define IF_SUPPORT_MEMO TRUE
+
+/* FEATURE FIELD */
+#define VAL_DB_INDEX_APPOINTMENT 1
+#define VAL_DB_INDEX_ANNIVERSARY 2
+#define VAL_DB_INDEX_HOLIDAY 3
+#define VAL_DB_INDEX_IMPORTANT 4
+#define VAL_DB_INDEX_PRIVATE 5
+#define VAL_DB_INDEX_MISCELLANEOUS 6
+#define VAL_DB_INDEX_TASK 7
+#define VAL_DB_INDEX_MEMO 8
+
+#endif /* IN_DATASTORE_INFO_TASK_H_ */
--- /dev/null
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ITEM_CHANGE_INFO_H_
+#define ITEM_CHANGE_INFO_H_
+
+int get_task_time_stamp(void);
+
+int set_task_time_stamp(int setting_time);
+
+#endif /* ITEM_CHANGE_INFO_H_ */
--- /dev/null
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <time.h>
+
+#include "utility/sync_util.h"
+#include "item_change_info.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "PLUGIN_DA_TASK"
+#endif
+
+static int task_time_stamp = 0;
+
+int get_task_time_stamp(void)
+{
+ _EXTERN_FUNC_ENTER;
+
+ _EXTERN_FUNC_EXIT;
+
+ return ((int)time(0) - 3);
+}
+
+int set_task_time_stamp(int setting_time)
+{
+ _EXTERN_FUNC_ENTER;
+
+ /* Critical Sectioin Start */
+ task_time_stamp = setting_time;
+ /* Critical Section End */
+
+ _EXTERN_FUNC_EXIT;
+
+ return setting_time;
+}
--- /dev/null
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <glib.h>
+#include <pthread.h>
+#include <calendar2.h>
+#include <account.h>
+
+#include "extern_info.h"
+#include "item_change_info.h"
+#include "ext_datastore_info_task.h"
+#include "in_datastore_info_task.h"
+
+/* for log */
+#include "utility/sync_util.h"
+#include "utility/fw_async_queue.h"
+#include "plugin/data_connector_interface.h"
+#include "data-adapter/agent_handler_manager.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "PLUGIN_DA_TASK"
+#endif
+
+#define FW_TASK 11
+
+static sync_agent_util_async_queue_s *queue;
+
+static int latest_task_version = 0;
+
+static pthread_mutex_t lockx;
+
+static int is_noti_from_me = 0;
+
+static int is_storage_changed = 0;
+
+static sync_agent_add_item_cb_plugin callback_add_item;
+
+static sync_agent_del_item_cb_plugin callback_del_item;
+
+static sync_agent_update_item_cb_plugin callback_update_item;
+
+static sync_agent_get_account_id_list_cb_plugin callback_get_account_id_list;
+
+static void _set_is_noti_from_me(int set_flag);
+
+static int __get_is_noti_from_me(void);
+
+static void _process_task_change(const char *view_uri, void *user_data);
+
+static void *_rutine_task_change(void *);
+
+static sync_agent_da_return_e _convert_service_error_to_common_error(int err);
+
+static bool _get_account_id(account_h account, void *user_data);
+
+static bool __is_task_id(const char* capability_type, account_capability_state_e capability_value, void *user_data);
+
+static sync_agent_da_return_e _get_service_folder_list_by_account_id(int account_id, calendar_list_h * item_list, int *count);
+
+static sync_agent_da_return_e _get_service_event_list_by_folder_id(int folder_id, calendar_list_h * item_list, int *count);
+
+typedef struct account_id {
+ int account_id;
+ struct account_id *next;
+} account_id_s;
+
+static sync_agent_da_return_e _get_service_event_list_by_folder_id(int folder_id, calendar_list_h * item_list, int *count)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ int service_ret = 0;
+
+ unsigned int ids[1];
+ calendar_query_h query = NULL;
+ calendar_filter_h filter = NULL;
+ calendar_list_h list = NULL;
+
+ // start pre condition
+ service_ret = calendar_query_create(_calendar_todo._uri, &query);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] in calendar_query_create Fail!\n");
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto DACI_FINISH;
+ }
+ service_ret = calendar_filter_create(_calendar_todo._uri, &filter);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] in calendar_filter_create Fail!\n");
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto DACI_FINISH;
+ }
+ service_ret = calendar_filter_add_int(filter, _calendar_todo.calendar_book_id, CALENDAR_MATCH_EQUAL, folder_id);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] in calendar_filter_add_int Fail!\n");
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto DACI_FINISH;
+ }
+ // end pre condition
+
+ service_ret = calendar_query_set_filter(query, filter);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] in calendar_query_set_filter Fail!\n");
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto DACI_FINISH;
+ }
+
+ ids[0] = _calendar_todo.id;
+ service_ret = calendar_query_set_projection(query, ids, 1);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] in calendar_query_set_projection Fail!\n");
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto DACI_FINISH;
+ }
+
+ service_ret = calendar_db_get_records_with_query(query, 0, 0, &list);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] in calendar_db_get_records_with_query Fail!\n");
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto DACI_FINISH;
+ }
+ service_ret = calendar_list_get_count(list, count);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] in calendar_list_get_count Fail!\n");
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto DACI_FINISH;
+ }
+ _DEBUG_INFO("count(%d)", *count);
+
+ service_ret = calendar_list_first(list);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] in calendar_list_get_count Fail!\n");
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto DACI_FINISH;
+ }
+
+ DACI_FINISH:
+ calendar_filter_destroy(filter);
+ calendar_query_destroy(query);
+
+ *item_list = list;
+ return ret;
+ _INNER_FUNC_EXIT;
+}
+
+static sync_agent_da_return_e _get_service_folder_list_by_account_id(int account_id, calendar_list_h * item_list, int *count)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ int service_ret = 0;
+
+ unsigned int ids[1];
+ calendar_query_h query = NULL;
+ calendar_filter_h filter = NULL;
+ calendar_list_h list = NULL;
+
+ // start pre condition
+ service_ret = calendar_query_create(_calendar_book._uri, &query);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] in calendar_query_create Fail!\n");
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto DACI_FINISH;
+ }
+ service_ret = calendar_filter_create(_calendar_book._uri, &filter);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] in calendar_filter_create Fail!\n");
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto DACI_FINISH;
+ }
+ service_ret = calendar_filter_add_int(filter, _calendar_book.account_id, CALENDAR_MATCH_EQUAL, account_id);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] in calendar_filter_add_int Fail!\n");
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto DACI_FINISH;
+ }
+ // end pre condition
+
+ service_ret = calendar_query_set_filter(query, filter);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] in calendar_query_set_filter Fail!\n");
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto DACI_FINISH;
+ }
+
+ ids[0] = _calendar_book.id;
+ service_ret = calendar_query_set_projection(query, ids, 1);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] in calendar_query_set_projection Fail!\n");
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto DACI_FINISH;
+ }
+
+ service_ret = calendar_db_get_records_with_query(query, 0, 0, &list);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] in calendar_db_get_records_with_query Fail!\n");
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto DACI_FINISH;
+ }
+ service_ret = calendar_list_get_count(list, count);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] in calendar_list_get_count Fail!\n");
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto DACI_FINISH;
+ }
+ _DEBUG_INFO("count(%d)", *count);
+
+ service_ret = calendar_list_first(list);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] in calendar_list_get_count Fail!\n");
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto DACI_FINISH;
+ }
+
+ DACI_FINISH:
+ calendar_filter_destroy(filter);
+ calendar_query_destroy(query);
+
+ *item_list = list;
+ return ret;
+ _INNER_FUNC_EXIT;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_open_service(void)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ //int err = calendar_connect_on_thread();
+ int err = calendar_connect();
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] calendar_connect Fail!\n");
+ ret = _convert_service_error_to_common_error(err);
+ } else {
+ _DEBUG_INFO("[da_task_plugIn] calendar_connect Success!\n");
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+ return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_close_service(void)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ int err = calendar_disconnect();
+ //int err = calendar_disconnect_on_thread();
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] calendar_disconnect Fail!\n");
+ ret = _convert_service_error_to_common_error(err);
+ } else {
+ _DEBUG_INFO("[da_task_plugIn] calendar_disconnect Success!\n");
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+ return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_begin_transaction(void)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ _DEBUG_INFO("No need to care about DB trasaction while using Calendar Service !!!");
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+EXPORT_API int sync_agent_plugin_end_transaction(int is_success)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ _DEBUG_INFO("No need to care about DB trasaction while using Calendar Service !!!");
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_add_item(int account_id, char *folder_id, void *data, char **item_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "folder_id is NULL. FAIL !!!");
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ int service_ret = 0;
+
+ calendar_record_h item = (calendar_record_h) data;
+
+ int un_type = 0;
+ memcpy(&un_type, item, 4);
+ int int_folder_id = atoi(folder_id);
+ _DEBUG_INFO("[da_task_plugIn] calendar type %d, in %d, folder id [%d]", un_type, item, int_folder_id);
+
+ /* setting folder id */
+ service_ret = calendar_record_set_int(item, _calendar_todo.calendar_book_id, int_folder_id);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_set_int() Fail! : err = %d", service_ret);
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto DACI_FINISH;
+ }
+ _DEBUG_INFO("[da_task_plugIn] calendar_svc_struct_set_int(folder %d) return [%d]!\n", atoi(folder_id), service_ret);
+
+ /* add item */
+ int slp_cal_info_id = 0;
+ service_ret = calendar_db_insert_record(item, &slp_cal_info_id);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_db_insert_record() Fail! : err = %d", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ *item_id = 0;
+ goto DACI_FINISH;
+ } else {
+ _DEBUG_INFO("[da_task_plugIn] calendar_svc_insert() Success!");
+ _DEBUG_INFO("calendar_svc_insert() Success!: id = %d", slp_cal_info_id);
+ *item_id = g_strdup_printf("%d", slp_cal_info_id);
+ is_storage_changed = 1;
+ }
+ DACI_FINISH:
+ service_ret = calendar_record_destroy(item, false);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_destroy() Fail! : err = %d", service_ret);
+ }
+ item = NULL;
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_update_item(int account_id, char *folder_id, char *item_id, void *data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "folder_id is NULL. FAIL !!!");
+ retvm_if(item_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "item_id is NULL. FAIL !!!");
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ int err = 0;
+ calendar_record_h item = (calendar_record_h) data;
+ int int_folder_id = atoi(folder_id);
+
+ /* setting folder id */
+ int service_ret = calendar_record_set_int(item, _calendar_todo.calendar_book_id, int_folder_id);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_set_int() Fail! : err = %d", service_ret);
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto DACI_FINISH;
+ }
+
+ /* update item */
+ err = calendar_db_update_record(item);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] calendar_svc_update() Fail!\n");
+ ret = _convert_service_error_to_common_error(err);
+ } else {
+ _DEBUG_INFO("[da_task_plugIn] calendar_svc_update() Success!");
+ is_storage_changed = 1;
+ }
+
+ /* memory free */
+ DACI_FINISH:
+ /* memory free */
+ if (item != NULL) {
+ calendar_record_destroy(item, false);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_destroy() Fail! : err = %d", err);
+ }
+ item = NULL;
+ }
+ _EXTERN_FUNC_EXIT;
+
+ return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_delete_item(int account_id, char *folder_id, char *item_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(item_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "item_id is NULL. FAIL !!!");
+
+ /* delete item */
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ int err = calendar_db_delete_record(_calendar_todo._uri, atoi(item_id));
+
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_INFO("[da_task_plugIn] calendar_svc_delete() Fail!");
+ ret = _convert_service_error_to_common_error(err);
+ } else {
+ _DEBUG_INFO("[da_task_plugIn] calendar_svc_delete() Success!");
+ is_storage_changed = 1;
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+ return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_delete_all_items(int account_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ int err = 1;
+
+ int folder_id_list_cnt = 0;
+ int *folder_type_list;
+ char **folder_id_list = 0;
+ int service_ret = 0;
+
+ int item_id = 0;
+ calendar_list_h event_list = NULL;
+
+ /* get folder id list for account id */
+ folder_id_list = sync_agent_plugin_get_folder_id_list(account_id, &folder_id_list_cnt, &folder_type_list);
+ if (folder_id_list == NULL || folder_id_list_cnt == 0) {
+ _DEBUG_INFO("[da_task_plugIn] folder id list cnt : %d", folder_id_list_cnt);
+ if (folder_type_list != NULL) {
+ cfree(folder_type_list);
+ folder_type_list = NULL;
+ }
+ return SYNC_AGENT_DA_ERR_NO_DATA;
+ }
+
+ int folder_iter = 0;
+ for (; folder_iter < folder_id_list_cnt; folder_iter++) {
+ int int_folder_id = atoi(folder_id_list[folder_iter]);
+ _DEBUG_INFO("[da_task_plugIn] folder id : %d\n", int_folder_id);
+ int event_count = 0;
+ ret = _get_service_event_list_by_folder_id(int_folder_id, &event_list, &event_count);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("_get_service_folder_list_by_account_id failed !!!");
+ continue;
+ } else if (event_count == 0) {
+ _DEBUG_INFO("_get_service_folder_list_by_account_id no list");
+ continue;
+ }
+
+ int event_list_count = 0;
+ service_ret = calendar_list_get_count(event_list, &event_list_count);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_get_count() Fail! : err = %d", service_ret);
+ continue;
+ }
+ _DEBUG_TRACE("recode list count = %d", event_list_count);
+ if (event_list_count == 0) {
+ continue;
+ }
+
+ do {
+ calendar_record_h event = NULL;
+
+ item_id = -1;
+ event = NULL;
+ service_ret = calendar_list_get_current_record_p(event_list, &event);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] in calendar_list_get_current_record_p Fail!\n");
+ ret = _convert_service_error_to_common_error(service_ret);
+ continue;
+ }
+ service_ret = calendar_record_get_int(event, _calendar_todo.id, &item_id);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] in calendar_record_get_int Fail!\n");
+ ret = _convert_service_error_to_common_error(service_ret);
+ continue;
+ }
+ _DEBUG_INFO("[da_task_plugIn] item id : %d\n", item_id);
+
+ err = calendar_db_delete_record(_calendar_todo._uri, item_id);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] calendar_svc_delete(%d) Fail!\n", item_id);
+ ret = _convert_service_error_to_common_error(err);
+ goto DACI_FINISH;
+ } else {
+ _DEBUG_INFO("[da_task_plugIn] calendar_svc_delete(%d) Success!\n", item_id);
+ is_storage_changed = 1;
+ }
+
+ } while (calendar_list_next(event_list) != CALENDAR_ERROR_NO_DATA);
+
+ if (event_list != NULL) {
+ err = calendar_list_destroy(event_list, true);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", err);
+ }
+ event_list = NULL;
+ }
+ }
+
+ DACI_FINISH:
+ if (event_list != NULL) {
+ err = calendar_list_destroy(event_list, true);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", err);
+ }
+ event_list = NULL;
+ }
+ if (folder_id_list != NULL) {
+ int cnt = 0;
+ for (cnt = 0; cnt < folder_id_list_cnt; cnt++) {
+ if (folder_id_list[cnt] != NULL) {
+ free(folder_id_list[cnt]);
+ _DEBUG_INFO("[da_task_plugIn] folder id free !! \n");
+ }
+ }
+ cfree(folder_id_list);
+ _DEBUG_INFO("[da_task_plugIn] folder id list free !! \n");
+ }
+ if (folder_type_list != NULL) {
+ cfree(folder_type_list);
+ folder_type_list = NULL;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_get_item(int account_id, char *folder_id, char *item_id, void **data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(item_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "item_id is NULL. FAIL !!!");
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ int err = 0;
+ calendar_record_h item = 0;
+
+ /* get item */
+ err = calendar_db_get_record(_calendar_todo._uri, atoi(item_id), &item);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_INFO("[da_task_plugIn] calendar_db_get_record() Fail!\n");
+ ret = _convert_service_error_to_common_error(err);
+ *data = 0;
+ } else {
+ _DEBUG_INFO("[da_task_plugIn] calendar_svc_get() Success!\n");
+ *data = (void *)item;
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+ return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_add_folder(int account_id, char *folder_name, int folder_type, char **folder_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(folder_name == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "folder_name is NULL. FAIL !!!");
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ int err = 0;
+ calendar_record_h folder = 0;
+
+ /* new service struct */
+ calendar_record_create(_calendar_book._uri, &folder);
+ if (folder == NULL) {
+ _DEBUG_INFO("[da_task_plugIn] calendar_svc_struct_new() Fail!\n");
+ *folder_id = 0;
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ /* setting folder data */
+ int cal_ret = calendar_record_set_int(folder, _calendar_book.account_id, account_id);
+ if (cal_ret != CALENDAR_ERROR_NONE) {
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto DACI_FINISH;
+ }
+ cal_ret = calendar_record_set_int(folder, _calendar_book.visibility, 1);
+ if (cal_ret != CALENDAR_ERROR_NONE) {
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto DACI_FINISH;
+ }
+ cal_ret = calendar_record_set_str(folder, _calendar_book.name, folder_name);
+ if (cal_ret != CALENDAR_ERROR_NONE) {
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto DACI_FINISH;
+ }
+
+ /* add folder */
+ int service_folder_item_id = 0;
+ cal_ret = calendar_db_insert_record(folder, &service_folder_item_id);
+ if (cal_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_INFO("[da_task_plugIn] calendar_svc_insert() Fail!\n");
+ ret = _convert_service_error_to_common_error(cal_ret);
+ *folder_id = 0;
+ } else {
+ _DEBUG_INFO("[da_task_plugIn] calendar_svc_insert() Success!");
+ *folder_id = g_strdup_printf("%d", service_folder_item_id);
+ is_storage_changed = 1;
+ }
+ DACI_FINISH:
+ /* memory free */
+ if (folder != NULL) {
+ calendar_record_destroy(folder, false);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_destroy() Fail! : err = %d", err);
+ }
+ folder = NULL;
+ }
+ _EXTERN_FUNC_EXIT;
+
+ return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_delete_folder(int account_id, char *folder_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "folder_id is NULL. FAIL !!!");
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ int err = 0;
+
+ /* delete folder */
+ err = calendar_db_delete_record(_calendar_book._uri, atoi(folder_id));
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_INFO("[da_task_plugIn] calendar_db_delete_record() Fail, err[%d]", err);
+ ret = _convert_service_error_to_common_error(err);
+ } else {
+ _DEBUG_INFO("[da_task_plugIn] calendar_svc_delete() Success!");
+ calendar_db_clean_after_sync(atoi(folder_id), 0);
+ is_storage_changed = 1;
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+ return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_get_folder(int account_id, char *folder_id, char **out_folder_name, int *out_folder_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "folder_id is NULL. FAIL !!!");
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ int err = 0;
+ calendar_record_h folder = 0;
+
+ /* get item */
+ int task_folder_id = atoi(folder_id);
+ _DEBUG_INFO("[da_task_plugIn] task_folder_id : %d\n", task_folder_id);
+ err = calendar_db_get_record(_calendar_book._uri, task_folder_id, &folder);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_INFO("[da_contact_plugIn] contacts_svc_get_addressbook() Fail!\n");
+ ret = _convert_service_error_to_common_error(err);
+ *out_folder_name = 0;
+ *out_folder_type = -1;
+ } else {
+ _DEBUG_INFO("[da_contact_plugIn] contacts_svc_get_addressbook() Success!\n");
+ *out_folder_name = 0;
+ calendar_record_get_str(folder, _calendar_book.name, out_folder_name);
+ *out_folder_type = DEFAULT_CALENDAR_FOLDER;
+ }
+
+ /* memory free */
+ if (folder != NULL) {
+ calendar_record_destroy(folder, false);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_destroy() Fail! : err = %d", err);
+ }
+ folder = NULL;
+ }
+ _EXTERN_FUNC_EXIT;
+
+ return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_execute(int account_ID, const char *execute_key, void *execute_values, void **result)
+{
+ _EXTERN_FUNC_ENTER;
+
+ _DEBUG_INFO("[da_task_plugIn] service is not supported execute. \n");
+ *result = 0;
+
+ _EXTERN_FUNC_EXIT;
+
+ return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API int sync_agent_plugin_get_used_item_count()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int ret = 0;
+ int used_cnt = 0;
+ int err = calendar_db_get_count(_calendar_todo._uri, &used_cnt);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_INFO("calendar_db_get_count() Fail\n");
+ } else {
+ _DEBUG_INFO("calendar_db_get_count() Success\n");
+ _DEBUG_INFO("used_count = %d\n", used_cnt);
+ ret = used_cnt;
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+ return ret;
+}
+
+EXPORT_API int sync_agent_plugin_get_used_item_count_for_folder(int account_id, char *folder_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "folder_id is NULL. FAIL !!!");
+
+ int ret = 0;
+
+ calendar_filter_h filter = NULL;
+ calendar_query_h query = NULL;
+ ret = calendar_query_create(_calendar_todo._uri, &query);
+ // end pre condition
+ ret = calendar_filter_create(_calendar_todo._uri, &filter);
+ ret = calendar_filter_add_int(filter, _calendar_todo.calendar_book_id, CALENDAR_MATCH_EQUAL, atoi(folder_id));
+ // end pre condition
+
+ ret = calendar_query_set_filter(query, filter);
+
+ int used_cnt = 0;
+ ret = calendar_db_get_count_with_query(query, &used_cnt);
+ if (ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] calendar_db_get_count() Fail\n");
+ } else {
+ _DEBUG_INFO("[da_task_plugIn] calendar_db_get_count() Success\n");
+ _DEBUG_INFO("[da_task_plugIn] used_count = %d\n", used_cnt);
+ }
+
+ if (filter != NULL)
+ calendar_filter_destroy(filter);
+ if (query != NULL)
+ calendar_query_destroy(query);
+
+ _EXTERN_FUNC_EXIT;
+
+ return used_cnt;
+}
+
+EXPORT_API char **sync_agent_plugin_get_folder_id_list(int account_id, int *folder_count, int **folder_type_list)
+{
+ _EXTERN_FUNC_ENTER;
+
+ char **folder_id_list = NULL;
+ int count = 0;
+ calendar_list_h service_folder_list = 0;
+ calendar_record_h folder = NULL;
+ int err = 0;
+ int i = 0;
+ *folder_count = 0;
+
+ _DEBUG_INFO("account_id [%d]", account_id);
+
+ err = _get_service_folder_list_by_account_id(account_id, &service_folder_list, &count);
+ if (err != SYNC_AGENT_DA_SUCCESS || count == 0) {
+ _DEBUG_ERROR("_get_service_folder_list_by_account_id failed !!!");
+ return NULL;
+ }
+ if (count > 0) {
+ folder_id_list = (char **)calloc(count, sizeof(char *));
+ if (folder_id_list == NULL) {
+ _DEBUG_ERROR("CALLOC failed !!!");
+ if (service_folder_list != NULL) {
+ err = calendar_list_destroy(service_folder_list, true);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", err);
+ }
+ service_folder_list = NULL;
+ }
+ return NULL;
+ }
+ *folder_type_list = (int *)calloc(count, sizeof(int));
+ if (*folder_type_list == NULL) {
+ _DEBUG_ERROR("CALLOC failed !!!");
+ if (folder_id_list) {
+ free(folder_id_list);
+ folder_id_list = NULL;
+ }
+ if (service_folder_list != NULL) {
+ err = calendar_list_destroy(service_folder_list, true);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", err);
+ }
+ service_folder_list = NULL;
+ }
+ return NULL;
+ }
+
+ /* find */
+ do {
+ /* get */
+ err = calendar_list_get_current_record_p(service_folder_list, &folder);
+ if ((err != CALENDAR_ERROR_NONE) && (folder == NULL)) {
+ _DEBUG_ERROR("calendar_list_get_current_record_p() Fail! : err = %d", err);
+ break;
+ }
+
+ /* check */
+ int int_folder_id = 0;
+ err = calendar_record_get_int(folder, _calendar_book.id, &int_folder_id);
+ folder_id_list[i] = g_strdup_printf("%d", int_folder_id);
+ (*folder_type_list)[i] = DEFAULT_CALENDAR_FOLDER;
+ i++;
+ *folder_count = i;
+
+// if (folder != NULL){
+// calendar_record_destroy(folder, false);
+// if (err != CALENDAR_ERROR_NONE) {
+// _DEBUG_ERROR("calendar_record_destroy() Fail! : err = %d", err);
+// }
+// folder = NULL;
+// }
+
+ } while (calendar_list_next(service_folder_list) != CALENDAR_ERROR_NO_DATA);
+ }
+ if (service_folder_list != NULL) {
+ err = calendar_list_destroy(service_folder_list, true);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", err);
+ }
+ service_folder_list = NULL;
+ }
+ _EXTERN_FUNC_EXIT;
+
+ return folder_id_list;
+}
+
+EXPORT_API int *sync_agent_plugin_get_account_id_list(int *count)
+{
+ _EXTERN_FUNC_ENTER;
+
+ _DEBUG_INFO("[da_task_plugIn] start!!\n");
+
+ int error_code = account_connect();
+
+ account_id_s *account_info_list = (account_id_s *) calloc(1, sizeof(account_id_s));
+ if (account_info_list == NULL) {
+ _DEBUG_ERROR("CALLOC failed !!!");
+ return NULL;
+ }
+ account_info_list->account_id = -1;
+ account_info_list->next = 0;
+
+ account_foreach_account_from_db(_get_account_id, account_info_list);
+
+ *count = 0;
+ account_id_s *cursor_ptr = account_info_list;
+ while (cursor_ptr != 0) {
+ cursor_ptr = cursor_ptr->next;
+ (*count)++;
+ }
+
+ int *id_list = 0;
+
+ if ((*count) > 0) {
+ id_list = (int *)calloc(*count, sizeof(int));
+ if (id_list == NULL) {
+ _DEBUG_ERROR("CALLOC failed !!!");
+ if (account_info_list) {
+ free(account_info_list);
+ account_info_list = NULL;
+ }
+ return NULL;
+ }
+ cursor_ptr = account_info_list;
+ int i = 0;
+ while (cursor_ptr != 0) {
+ id_list[i] = cursor_ptr->account_id;
+ cursor_ptr = cursor_ptr->next;
+ i++;
+ }
+ }
+
+ free(account_info_list);
+
+ error_code = account_disconnect();
+
+ _DEBUG_INFO("[da_task_plugIn] end!!\n");
+
+ _EXTERN_FUNC_EXIT;
+
+ return id_list;
+}
+
+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)
+{
+ _EXTERN_FUNC_ENTER;
+
+ _DEBUG_INFO("[da_task_plugIn] account_id : %d\n", account_id);
+ _DEBUG_INFO("[da_task_plugIn] folder_id : %s\n", folder_id);
+ _DEBUG_INFO("[da_task_plugIn] changepoint : %d\n", changepoint);
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ int taskTimeStamp = changepoint;
+ int current_change_point = 0;
+ int temp_folder_id = atoi(folder_id);
+ int service_ret = 0;
+
+ sync_agent_plugin_item_node_s *root_ptr = 0;
+ sync_agent_plugin_item_node_s *cursor_ptr = 0;
+ int chagned_count = 0;
+
+ calendar_list_h service_changed_list = 0;
+ calendar_record_h changed_task = NULL;
+
+ service_ret = calendar_db_get_changes_by_version(_calendar_todo._uri, temp_folder_id, taskTimeStamp, &service_changed_list, ¤t_change_point);
+ _DEBUG_INFO("[da_task_plugIn] calendar_db_get_changes_by_version service_ret : %d, input folder id [%d], current change point [%d]", service_ret, temp_folder_id, current_change_point);
+ if ((service_ret != CALENDAR_ERROR_NONE) && (service_changed_list == NULL)) {
+ _DEBUG_ERROR("calendar_db_get_changes_by_version() Fail! : err = %d", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto DACI_FINISH;
+ }
+
+ int list_count = 0;
+ service_ret = calendar_list_get_count(service_changed_list, &list_count);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] in calendar_list_get_count Fail!\n");
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto DACI_FINISH;
+ }
+
+ _DEBUG_INFO("[da_task_plugIn] in calendar_list_get_count [%d]!", list_count);
+ if (list_count <= 0) {
+// ret =SYNC_AGENT_DA_ERR_NO_DATA;
+ goto DACI_FINISH;
+ }
+// service_ret = calendar_svc_iter_next(iter);
+ service_ret = calendar_list_first(service_changed_list);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_first() Fail! : err = %d", service_ret);
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto DACI_FINISH;
+ }
+
+ _DEBUG_INFO("[da_task_plugIn] calendar_svc_iter_next service_ret : %d\n", service_ret);
+
+ do {
+ _DEBUG_INFO("while start");
+
+ service_ret = calendar_list_get_current_record_p(service_changed_list, &changed_task);
+ if ((service_ret != CALENDAR_ERROR_NONE) && (changed_task == NULL)) {
+ _DEBUG_ERROR("calendar_list_get_current_record_p() Fail! : err = %d", service_ret);
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto DACI_FINISH;
+ }
+ int type = 0;
+ service_ret = calendar_record_get_int(changed_task, _calendar_updated_info.modified_status, &type);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_int() Fail!: err = %d", service_ret);
+ break;
+ }
+
+ _DEBUG_INFO("[da_task_plugIn] type is [%d]", type);
+ if (type == CALENDAR_EVENT_MODIFIED_STATUS_INSERTED) {
+ int task_id = 0;
+ service_ret = calendar_record_get_int(changed_task, _calendar_updated_info.id, &task_id);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_int() Fail!: err = %d", service_ret);
+ break;
+ }
+ _DEBUG_INFO("[da_task_plugIn] calendar id is [%d]", task_id);
+ char *task_id_str = g_strdup_printf("%d", task_id);
+ _DEBUG_INFO("[da_task_plugIn] CALS_UPDATED_TYPE_INSERTED : [%s]\n", task_id_str);
+
+ if (root_ptr == NULL) {
+ root_ptr = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+ if (root_ptr == NULL) {
+ _DEBUG_ERROR("CALLOC failed !!!");
+ return NULL;
+ }
+ root_ptr->item_id = task_id_str;
+ root_ptr->next = 0;
+ cursor_ptr = root_ptr;
+ } else {
+ cursor_ptr->next = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+ if (cursor_ptr->next == NULL) {
+ _DEBUG_ERROR("CALLOC failed !!!");
+ return NULL;
+ }
+ cursor_ptr->next->item_id = task_id_str;
+ cursor_ptr->next->next = 0;
+ cursor_ptr = cursor_ptr->next;
+ }
+
+ chagned_count++;
+
+ }
+
+ /*if list can successfully free child than dont need this free */
+// if (changed_task != NULL)
+// calendar_record_destroy(changed_task, true);
+ } while (calendar_list_next(service_changed_list) != CALENDAR_ERROR_NO_DATA);
+
+ DACI_FINISH:
+
+ if (service_changed_list != NULL) {
+ calendar_list_destroy(service_changed_list, true);
+ service_changed_list = NULL;
+ }
+
+ *changeCount = chagned_count;
+
+ _EXTERN_FUNC_EXIT;
+
+ return root_ptr;
+}
+
+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)
+{
+ _EXTERN_FUNC_ENTER;
+
+ _DEBUG_INFO("[da_task_plugIn] account_id : %d\n", account_id);
+ _DEBUG_INFO("[da_task_plugIn] folder_id : %s\n", folder_id);
+ _DEBUG_INFO("[da_task_plugIn] changepoint : %d\n", change_point);
+ int current_change_point = 0;
+ int task_time_stamp = change_point;
+ int temp_folder_id = atoi(folder_id);
+ int service_ret = 0;
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ sync_agent_plugin_item_node_s *root_ptr = 0;
+ sync_agent_plugin_item_node_s *cursor_ptr = 0;
+ int chagned_count = 0;
+
+ calendar_list_h service_changed_list = 0;
+ calendar_record_h changed_task = NULL;
+
+ service_ret = calendar_db_get_changes_by_version(_calendar_todo._uri, temp_folder_id, task_time_stamp, &service_changed_list, ¤t_change_point);
+ _DEBUG_INFO("[da_task_plugIn] calendar_db_get_changes_by_version service_ret : %d, input folder id [%d], current change point [%d]", service_ret, temp_folder_id, current_change_point);
+ if ((service_ret != CALENDAR_ERROR_NONE) && (service_changed_list == NULL)) {
+ _DEBUG_ERROR("calendar_db_get_changes_by_version() Fail! : err = %d", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto DACI_FINISH;
+ }
+
+ int list_count = 0;
+ service_ret = calendar_list_get_count(service_changed_list, &list_count);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] in calendar_list_get_count Fail!\n");
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto DACI_FINISH;
+ }
+
+ _DEBUG_INFO("[da_task_plugIn] in calendar_list_get_count [%d]!", list_count);
+ if (list_count <= 0) {
+ goto DACI_FINISH;
+ }
+
+ service_ret = calendar_list_first(service_changed_list);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_first() Fail! : err = %d", service_ret);
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto DACI_FINISH;
+ }
+ _DEBUG_INFO("[da_task_plugIn] service_ret : %d\n", service_ret);
+
+ do {
+
+ service_ret = calendar_list_get_current_record_p(service_changed_list, &changed_task);
+ if ((service_ret != CALENDAR_ERROR_NONE) && (changed_task == NULL)) {
+ _DEBUG_ERROR("calendar_list_get_current_record_p() Fail! : err = %d", service_ret);
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto DACI_FINISH;
+ }
+
+ int type = 0;
+ service_ret = calendar_record_get_int(changed_task, _calendar_updated_info.modified_status, &type);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_int() Fail!: err = %d", service_ret);
+ break;
+ }
+ if (type == CALENDAR_EVENT_MODIFIED_STATUS_DELETED) {
+ int task_id = 0;
+ service_ret = calendar_record_get_int(changed_task, _calendar_updated_info.id, &task_id);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_int() Fail!: err = %d", service_ret);
+ break;
+ }
+ char *task_id_str = g_strdup_printf("%d", task_id);
+ _DEBUG_INFO("[da_task_plugIn] CALS_UPDATED_TYPE_DELETED : [%s]\n", task_id_str);
+
+ if (root_ptr == NULL) {
+ root_ptr = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+ if (root_ptr == NULL) {
+ _DEBUG_ERROR("CALLOC failed !!!");
+ return NULL;
+ }
+ root_ptr->item_id = task_id_str;
+ root_ptr->next = 0;
+ cursor_ptr = root_ptr;
+ } else {
+ cursor_ptr->next = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+ if (cursor_ptr->next == NULL) {
+ _DEBUG_ERROR("CALLOC failed !!!");
+ return NULL;
+ }
+ cursor_ptr->next->item_id = task_id_str;
+ cursor_ptr->next->next = 0;
+ cursor_ptr = cursor_ptr->next;
+ }
+
+ chagned_count++;
+ }
+
+ /*if list can successfully free child than dont need this free */
+// if (changed_task != NULL)
+// calendar_record_destroy(changed_task, true);
+ } while (calendar_list_next(service_changed_list) != CALENDAR_ERROR_NO_DATA);
+
+ DACI_FINISH:
+
+ if (service_changed_list != NULL) {
+ calendar_list_destroy(service_changed_list, true);
+ service_changed_list = NULL;
+ }
+
+ *change_count = chagned_count;
+
+ _EXTERN_FUNC_EXIT;
+
+ return root_ptr;
+}
+
+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)
+{
+ _EXTERN_FUNC_ENTER;
+
+ _DEBUG_INFO("\n[da_task_plugIn] account_id : %d\n", account_id);
+ _DEBUG_INFO("[da_task_plugIn] folder_id : %s\n", folder_id);
+ _DEBUG_INFO("[da_task_plugIn] changepoint : %d\n", change_point);
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ int task_time_stamp = change_point;
+ int temp_folder_id = atoi(folder_id);
+ int service_ret = 0;
+
+ calendar_list_h service_changed_list = 0;
+ calendar_record_h changed_task = NULL;
+
+ sync_agent_plugin_item_node_s *root_ptr = 0;
+ sync_agent_plugin_item_node_s *cursor_ptr = 0;
+ int chagned_count = 0;
+ int current_change_point = 0;
+ service_ret = calendar_db_get_changes_by_version(_calendar_todo._uri, temp_folder_id, task_time_stamp, &service_changed_list, ¤t_change_point);
+ _DEBUG_INFO("[da_task_plugIn] calendar_db_get_changes_by_version service_ret : %d, input folder id [%d], current change point [%d]", service_ret, temp_folder_id, current_change_point);
+ if ((service_ret != CALENDAR_ERROR_NONE) && (service_changed_list == NULL)) {
+ _DEBUG_ERROR("calendar_db_get_changes_by_version() Fail! : err = %d", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto DACI_FINISH;
+ }
+
+ int list_count = 0;
+ service_ret = calendar_list_get_count(service_changed_list, &list_count);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[da_task_plugIn] in calendar_list_get_count Fail!\n");
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto DACI_FINISH;
+ }
+
+ _DEBUG_INFO("[da_task_plugIn] in calendar_list_get_count [%d]!", list_count);
+ if (list_count <= 0) {
+ goto DACI_FINISH;
+ }
+
+ service_ret = calendar_list_first(service_changed_list);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_first() Fail! : err = %d", service_ret);
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto DACI_FINISH;
+ }
+
+ _DEBUG_INFO("[da_task_plugIn] service_ret : %d\n", service_ret);
+
+ do {
+ service_ret = calendar_list_get_current_record_p(service_changed_list, &changed_task);
+ if ((service_ret != CALENDAR_ERROR_NONE) && (changed_task == NULL)) {
+ _DEBUG_ERROR("calendar_list_get_current_record_p() Fail! : err = %d", service_ret);
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto DACI_FINISH;
+ }
+ int type = 0;
+ service_ret = calendar_record_get_int(changed_task, _calendar_updated_info.modified_status, &type);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_int() Fail!: err = %d", service_ret);
+ break;
+ }
+
+ if (type == CALENDAR_EVENT_MODIFIED_STATUS_UPDATED) {
+ int task_id = 0;
+ service_ret = calendar_record_get_int(changed_task, _calendar_updated_info.id, &task_id);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_int() Fail!: err = %d", service_ret);
+ break;
+ }
+ char *task_id_str = g_strdup_printf("%d", task_id);
+ _DEBUG_INFO("[da_task_plugIn] CALS_UPDATED_TYPE_MODIFIED : [%s]\n", task_id_str);
+
+ if (root_ptr == NULL) {
+ root_ptr = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+ if (root_ptr == NULL) {
+ _DEBUG_ERROR("CALLOC failed !!!");
+ return NULL;
+ }
+ root_ptr->item_id = task_id_str;
+ root_ptr->next = 0;
+ cursor_ptr = root_ptr;
+ } else {
+ cursor_ptr->next = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+ if (cursor_ptr->next == NULL) {
+ _DEBUG_ERROR("CALLOC failed !!!");
+ return NULL;
+ }
+ cursor_ptr->next->item_id = task_id_str;
+ cursor_ptr->next->next = 0;
+ cursor_ptr = cursor_ptr->next;
+ }
+
+ chagned_count++;
+ }
+
+ /*if list can successfully free child than dont need this free */
+// if (changed_task != NULL)
+// calendar_record_destroy(changed_task, true);
+ } while (calendar_list_next(service_changed_list) != CALENDAR_ERROR_NO_DATA);
+
+ DACI_FINISH:
+
+ if (service_changed_list != NULL) {
+ calendar_list_destroy(service_changed_list, true);
+ service_changed_list = NULL;
+ }
+
+ *change_count = chagned_count;
+
+ _EXTERN_FUNC_EXIT;
+
+ return root_ptr;
+}
+
+EXPORT_API int sync_agent_plugin_get_last_change_point(void)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int task_db_version = 0;
+ int service_ret = calendar_db_get_current_version(&task_db_version);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_int() Fail!: err = %d", service_ret);
+ }
+ _EXTERN_FUNC_EXIT;
+
+ return task_db_version;
+}
+
+EXPORT_API void sync_agent_plugin_start_listening_change_noti(void *data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int service_ret = calendar_db_add_changed_cb(_calendar_todo._uri, _process_task_change, NULL);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_db_add_changed_cb() Fail!: err = %d", service_ret);
+ }
+
+ latest_task_version = sync_agent_plugin_get_last_change_point();
+ _DEBUG_INFO("Current Latest Task Version : %d", latest_task_version);
+
+ pthread_t thread_process_change_id;
+ if (pthread_create(&thread_process_change_id, 0, _rutine_task_change, 0) < 0) {
+ _DEBUG_ERROR("task Change Noti Handling Thread Create Error");
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_plugin_set_callback_add_item(sync_agent_add_item_cb_plugin callback)
+{
+ _EXTERN_FUNC_ENTER;
+
+ callback_add_item = callback;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_plugin_set_callback_delete_item(sync_agent_del_item_cb_plugin callback)
+{
+ _EXTERN_FUNC_ENTER;
+
+ callback_del_item = callback;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_plugin_set_callback_update_item(sync_agent_update_item_cb_plugin callback)
+{
+ _EXTERN_FUNC_ENTER;
+
+ callback_update_item = callback;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_plugin_set_callback_get_account_id_list(sync_agent_get_account_id_list_cb_plugin callback)
+{
+ _EXTERN_FUNC_ENTER;
+
+ callback_get_account_id_list = callback;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API int sync_agent_plugin_get_max_item_count(int folder_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ _EXTERN_FUNC_EXIT;
+
+ return MAX_ITEM_COUNT_TASK;
+}
+
+EXPORT_API int sync_agent_plugin_get_max_field_length(int field_name, int child_field_name)
+{
+ _EXTERN_FUNC_ENTER;
+
+ switch (field_name) {
+ case CALENDAR_FIELD_SUMMARY:
+ _EXTERN_FUNC_EXIT;
+ return MAX_LEN_SUMMARY;
+ case CALENDAR_FIELD_DESCRIPTION:
+ _EXTERN_FUNC_EXIT;
+ return MAX_LEN_DESCRIPTION;
+ case CALENDAR_FIELD_LOCATOIN:
+ _EXTERN_FUNC_EXIT;
+ return MAX_LEN_LOCATION;
+ case CALENDAR_FIELD_MEMO:
+ _EXTERN_FUNC_EXIT;
+ return MAX_LEN_MEMO;
+ default:
+ _EXTERN_FUNC_EXIT;
+ return -1;
+ }
+}
+
+EXPORT_API int sync_agent_plugin_get_max_field_count(int field_name, int child_field_name)
+{
+ _EXTERN_FUNC_ENTER;
+ _EXTERN_FUNC_EXIT;
+ return -1;
+}
+
+EXPORT_API int sync_agent_plugin_get_field_value(int field_name, int child_field_name, char **str_val, int *num_val1, int *num_val2)
+{
+ _EXTERN_FUNC_ENTER;
+
+ switch (field_name) {
+ case CALENDAR_FIELD_YEAR:
+ *num_val1 = MIN_PERIOD_YEAR;
+ *num_val2 = MAX_PERIOD_YEAR;
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ case CALENDAR_FIELD_TYPE_MODEL:
+ *str_val = VAL_TYPE_MODEL;
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ case CALENDAR_FIELD_DB_INDEX:
+ switch (child_field_name) {
+ case CALENDAR_FEATURE_APPOINTMENT:
+ *num_val1 = VAL_DB_INDEX_APPOINTMENT;
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ case CALENDAR_FEATURE_ANNIVERSARY:
+ *num_val1 = VAL_DB_INDEX_ANNIVERSARY;
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ case CALENDAR_FEATURE_HOLIDAY:
+ *num_val1 = VAL_DB_INDEX_HOLIDAY;
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ case CALENDAR_FEATURE_IMPORTANT:
+ *num_val1 = VAL_DB_INDEX_IMPORTANT;
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ case CALENDAR_FEATURE_PRIVATE:
+ *num_val1 = VAL_DB_INDEX_PRIVATE;
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ case CALENDAR_FEATURE_MISCELLANEOUS:
+ *num_val1 = VAL_DB_INDEX_MISCELLANEOUS;
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ case CALENDAR_FEATURE_TASK:
+ *num_val1 = VAL_DB_INDEX_TASK;
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ case CALENDAR_FEATURE_MEMO:
+ *num_val1 = VAL_DB_INDEX_MEMO;
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ default:
+ return -1;
+ }
+ case CALENDAR_FIELD_TIMEZONE:
+ switch (child_field_name) {
+ case CALENDAR_CHILD_FIELD_BIAS:
+ *num_val1 = (int)VAL_TZ_BIAS;
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ case CALENDAR_CHILD_FIELD_DAYLIGHT:
+ *num_val1 = (int)VAL_TZ_DAYLIGHT;
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ case CALENDAR_CHILD_FIELD_DAYLIGHT_BIAS:
+ *num_val1 = (int)VAL_TZ_DAYLIGHT_BIAS;
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ case CALENDAR_CHILD_FIELD_DAYLIGHT_BEGIN:
+ *str_val = VAL_TZ_DAYLIGHT_BEGIN;
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ case CALENDAR_CHILD_FIELD_DAYLIGHT_END:
+ *str_val = VAL_TZ_DAYLIGHT_END;
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ case CALENDAR_CHILD_FIELD_STANDARD_TIMENAME:
+ *str_val = VAL_TZ_STANDARD_TIMENAME;
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ case CALENDAR_CHILD_FIELD_DAYLIGHT_TIMENAME:
+ *str_val = VAL_TZ_DAYLIGHT_TIMENAME;
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ default:
+ return -1;
+ }
+ default:
+ return -1;
+ }
+}
+
+EXPORT_API int sync_agent_plugin_get_is_support_feature(int feature)
+{
+ _EXTERN_FUNC_ENTER;
+
+ switch (feature) {
+ case CALENDAR_FEATURE_APPOINTMENT:
+ _EXTERN_FUNC_EXIT;
+ return IF_SUPPORT_APPOINTMENT;
+ case CALENDAR_FEATURE_ANNIVERSARY:
+ _EXTERN_FUNC_EXIT;
+ return IF_SUPPORT_ANNIVERSARY;
+ case CALENDAR_FEATURE_HOLIDAY:
+ _EXTERN_FUNC_EXIT;
+ return IF_SUPPORT_HOLIDAY;
+ case CALENDAR_FEATURE_IMPORTANT:
+ _EXTERN_FUNC_EXIT;
+ return IF_SUPPORT_IMPORTANT;
+ case CALENDAR_FEATURE_PRIVATE:
+ _EXTERN_FUNC_EXIT;
+ return IF_SUPPORT_PRIVATE;
+ case CALENDAR_FEATURE_MISCELLANEOUS:
+ _EXTERN_FUNC_EXIT;
+ return IF_SUPPORT_MISCELLANEOUS;
+ case CALENDAR_FEATURE_TASK:
+ _EXTERN_FUNC_EXIT;
+ return IF_SUPPORT_TASK;
+ case CALENDAR_FEATURE_MEMO:
+ _EXTERN_FUNC_EXIT;
+ return IF_SUPPORT_MEMO;
+ default:
+ return -1;
+ }
+}
+
+/********************************** static function *******************************************/
+
+static void _set_is_noti_from_me(int set_flag)
+{
+ _INNER_FUNC_ENTER;
+
+ if (pthread_mutex_lock(&lockx)) {
+ _DEBUG_ERROR("[da_task_plugIn] pthread_mutex_lock error");
+ }
+
+ is_noti_from_me = set_flag;
+
+ if (pthread_mutex_unlock(&lockx)) {
+ _DEBUG_ERROR("[da_task_plugIn] pthread_mutex_unlock error");
+ }
+
+ _INNER_FUNC_EXIT;
+}
+
+static int __get_is_noti_from_me(void)
+{
+ _INNER_FUNC_ENTER;
+
+ _INNER_FUNC_EXIT;
+
+ return is_noti_from_me;
+}
+
+void _process_task_change(const char *view_uri, void *user_data)
+{
+ _INNER_FUNC_ENTER;
+
+ _DEBUG_TRACE("[da_task_plugIn] detected task storage changed\n");
+
+ int from_Me = __get_is_noti_from_me();
+ if (from_Me == 1) {
+ _set_is_noti_from_me(0);
+ _DEBUG_TRACE("[da_task_plugIn] This noti is from Me!! so will be ignored!!\n");
+ return;
+ }
+
+ int *taskVersion = (int *)calloc(1, sizeof(int));
+ if (taskVersion == NULL) {
+ _DEBUG_ERROR("CALLOC failed !!!");
+ return;
+ }
+ *taskVersion = latest_task_version;
+ latest_task_version++;
+
+ _DEBUG_INFO("fw_async_queue_length = %d", sync_agent_async_queue_length(queue));
+ if (sync_agent_async_queue_length(queue) < 1) {
+ sync_agent_send_msg_async_queue(queue, (void *)taskVersion);
+ _DEBUG_INFO("fw_async_queue_length = %d", sync_agent_async_queue_length(queue));
+ }
+
+ _INNER_FUNC_EXIT;
+}
+
+static void *_rutine_task_change(void *data)
+{
+ _INNER_FUNC_ENTER;
+
+ _DEBUG_TRACE("[da_task_plugIn] Start __rutine_task_Change (create thread)\n");
+
+ /*
+ * Create Queue
+ */
+ queue = sync_agent_alloc_async_queue();
+ if (queue == NULL) {
+ _DEBUG_ERROR("Failed to call fw_async_queue_alloc()");
+ return 0;
+ }
+
+ calendar_list_h folder_list = NULL;
+ calendar_list_h record_list = NULL;
+ int service_ret = 0;
+
+ // open task service
+ sync_agent_plugin_open_service();
+
+ while (1) {
+ _DEBUG_TRACE("fw_async_queue_length = %d", sync_agent_async_queue_length(queue));
+ int *temp_task_version = sync_agent_receive_msg_async_queue(queue);
+ int task_version = *temp_task_version;
+ free(temp_task_version);
+
+ _DEBUG_TRACE("Detected Change taskVersion : %d", task_version);
+
+ int account_list_count;
+ int *account_list = callback_get_account_id_list(FW_TASK, &account_list_count);
+ if (account_list == NULL)
+ return 0;
+
+ int i = 0;
+ for (; i < account_list_count; i++) {
+ int task_account_id = account_list[i];
+ _DEBUG_TRACE("[da_task_plugIn] task_account_id : %d, count : %d\n", task_account_id, account_list_count);
+ _DEBUG_TRACE("[da_task_plugIn] Before calendar_svc_event_get_changes : %d\n", task_version);
+
+ /*get folder id */
+ int folder_list_count = 0;
+ service_ret = _get_service_folder_list_by_account_id(task_account_id, &folder_list, &folder_list_count);
+ if (service_ret != SYNC_AGENT_DA_SUCCESS || folder_list == NULL) {
+ _DEBUG_ERROR("calendar_list_get_count() Fail! : err = %d", service_ret);
+ break;
+ }
+ _DEBUG_TRACE("[da_task_plugIn] folder_list_count : %d", folder_list_count);
+
+ do {
+
+ calendar_record_h folder = NULL;
+ service_ret = calendar_list_get_current_record_p(folder_list, &folder);
+ if ((service_ret != CALENDAR_ERROR_NONE) && (folder == NULL)) {
+ _DEBUG_ERROR("calendar_list_get_current_record_p() Fail! : err = %d", service_ret);
+ break;
+ }
+
+ int task_folder_id = 0;
+ service_ret = calendar_record_get_int(folder, _calendar_book.id, &task_folder_id);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_int() Fail!: err = %d", service_ret);
+ break;
+ }
+
+ int current_cal_db_ver = 0;
+ service_ret = calendar_db_get_changes_by_version(_calendar_todo._uri, task_folder_id, task_version, &record_list, ¤t_cal_db_ver);
+ if (service_ret != CALENDAR_ERROR_NONE || record_list == NULL) {
+ _DEBUG_ERROR("calendar_db_get_changes_by_version() Fail!: task_folder_id = %d, err = %d", task_folder_id, service_ret);
+ continue;
+ }
+ _DEBUG_TRACE("calendar_db_get_changes_by_version() Success, task_folderId = %d", task_folder_id);
+
+ service_ret = calendar_list_first(record_list);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_first() Fail! : err = %d", service_ret);
+ break;
+ }
+ int recode_count = 0;
+ service_ret = calendar_list_get_count(record_list, &recode_count);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_get_count() Fail! : err = %d", service_ret);
+ break;
+ }
+ _DEBUG_TRACE("recode list count = %d", recode_count);
+ if (recode_count == 0) {
+ continue;
+ }
+
+ do {
+ calendar_record_h row_event = NULL;
+ service_ret = calendar_list_get_current_record_p(record_list, &row_event);
+ if ((service_ret != CALENDAR_ERROR_NONE) && (row_event == NULL)) {
+ _DEBUG_ERROR("calendar_list_get_current_record_p() Fail! : err = %d", service_ret);
+ break;
+ }
+
+ int task_id = 0;
+ service_ret = calendar_record_get_int(row_event, _calendar_updated_info.id, &task_id);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_int() Fail!: err = %d", service_ret);
+ break;
+ }
+
+ _DEBUG_TRACE("recode list count = %d", recode_count);
+ char task_id_str[12];
+ snprintf(task_id_str, sizeof(task_id_str), "%d", task_id);
+
+ int type = 0;
+ service_ret = calendar_record_get_int(row_event, _calendar_updated_info.modified_status, &type);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_int() Fail!: err = %d", service_ret);
+ break;
+ }
+ switch (type) {
+ case CALENDAR_EVENT_MODIFIED_STATUS_INSERTED:
+ {
+ char task_folder_id_str[12];
+ snprintf(task_folder_id_str, sizeof(task_folder_id_str), "%d", task_folder_id);
+
+ _DEBUG_TRACE("[da_task_plugIn] task Inserted!\n");
+ _DEBUG_TRACE("[da_task_plugIn] task folder id : %s\n", task_folder_id_str);
+ int result = callback_add_item(account_list[i], i, task_id_str, FW_TASK, task_folder_id_str, 0);
+ if (!result)
+ _DEBUG_TRACE("[da_task_plugIn] Failed to call SA_EH_Add_Item() \n");
+ else
+ _DEBUG_TRACE("[da_task_plugIn] Success to call SA_EH_Add_Item() \n");
+
+ }
+ break;
+ case CALENDAR_EVENT_MODIFIED_STATUS_UPDATED:
+ {
+ _DEBUG_TRACE("[da_task_plugIn] task Updated!\n");
+ int result = callback_update_item(account_list[i], i, task_id_str, FW_TASK);
+ if (!result)
+ _DEBUG_TRACE("[da_task_plugIn] Failed to call callback_del_item() \n");
+ }
+ break;
+ case CALENDAR_EVENT_MODIFIED_STATUS_DELETED:
+ {
+ _DEBUG_TRACE("[da_task_plugIn] task Deleted!\n");
+ int result = callback_del_item(account_list[i], i, task_id_str, FW_TASK);
+ if (!result)
+ _DEBUG_TRACE("[da_task_plugIn] Failed to call callback_del_item() \n");
+ }
+ break;
+ default:
+ _DEBUG_TRACE("[da_task_plugIn] cached Another task Change Noti!\n");
+ break;
+ }
+
+ /*if list can successfully free child than dont need this free */
+// if (row_event != NULL){
+// calendar_record_destroy(row_event, true);
+// row_event = NULL;
+// }
+
+ } while (calendar_list_next(record_list) != CALENDAR_ERROR_NO_DATA);
+
+ if (record_list != NULL) {
+ service_ret = calendar_list_destroy(record_list, true);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", service_ret);
+ }
+ record_list = NULL;
+ }
+ /*if list can successfully free child than dont need this free */
+// if (folder != NULL){
+// calendar_record_destroy(folder, true);
+// folder = NULL;
+// }
+
+ } while (calendar_list_next(folder_list) != CALENDAR_ERROR_NO_DATA); /*folder iter list */
+
+ _DEBUG_TRACE("folder list free");
+ if (folder_list != NULL) {
+ service_ret = calendar_list_destroy(folder_list, true);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", service_ret);
+ }
+ folder_list = NULL;
+ }
+
+ } /*account loop for */
+ _DEBUG_TRACE("account list free");
+ if (account_list != NULL) {
+ free(account_list);
+ }
+
+ } /*while (1) */
+
+ // close calendar service
+ sync_agent_plugin_close_service();
+
+ _DEBUG_TRACE("[da_task_plugIn] End __rutine_task_Change (create thread)\n");
+
+ _INNER_FUNC_EXIT;
+
+ return 0;
+}
+
+static sync_agent_da_return_e _convert_service_error_to_common_error(int err)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ _DEBUG_TRACE("[da_task_plugIn] Error Code : %d\n", err);
+
+ switch (err) {
+ case CALENDAR_ERROR_INVALID_PARAMETER: /* -4 */
+ ret = SYNC_AGENT_DA_ERR_INVALID_CONTENT;
+ break;
+
+ default:
+ ret = SYNC_AGENT_DA_ERRORS;
+ break;
+ }
+
+ _INNER_FUNC_EXIT;
+
+ return ret;
+}
+
+static bool _get_account_id(account_h account, void *user_data)
+{
+ _INNER_FUNC_ENTER;
+
+ account_id_s *account_info_list = user_data;
+
+ bool has_contact = FALSE;
+
+ account_get_capability_all(account, __is_task_id, &has_contact);
+
+ if (has_contact == FALSE) {
+ /* DO Nothing */
+ _DEBUG_INFO("has_contact is false");
+ } else {
+ char *domain_name = NULL;
+ account_error_e error_code = account_get_domain_name(account, &domain_name);
+ if (error_code != ACCOUNT_ERROR_NONE) {
+ _DEBUG_ERROR("Failed to call account_get_domain_name()");
+ return has_contact;
+ }
+
+ /*local service id already in id list so pass */
+ _DEBUG_INFO("domain_name = %s", domain_name);
+ if (strcmp(domain_name, "Gmail") && strcmp(domain_name, "exchange")) {
+ _DEBUG_TRACE("domain is [%s] is not gmail&exchange");
+ return has_contact;
+ }
+
+ account_id_s *account_info = (account_id_s *) calloc(1, sizeof(account_id_s));
+ if (account_info == NULL) {
+ _DEBUG_ERROR("CALLOC failed !!!");
+ return FALSE;
+ }
+ account_get_account_id(account, &(account_info->account_id));
+ _DEBUG_TRACE("Getted accont id : %d", account_info->account_id);
+ account_info->next = 0;
+
+ account_id_s *cursor_ptr = account_info_list;
+ while (cursor_ptr->next != 0) {
+ cursor_ptr = cursor_ptr->next;
+ }
+
+ cursor_ptr->next = account_info;
+ }
+
+ _INNER_FUNC_EXIT;
+
+ return has_contact;
+}
+
+static bool __is_task_id(/*account_capability_type_e*/const char* capability_type, account_capability_state_e capability_value, void *user_data)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if(capability_type == NULL, FALSE, "capability_type is NULL !!");
+
+ bool *has_contact = user_data;
+ //if (capability_type == ACCOUNT_CAPABILITY_CALENDAR) {
+ if (strncmp(capability_type, ACCOUNT_SUPPORTS_CAPABILITY_CALENDAR, strlen(capability_type)) == 0) {
+ *has_contact = TRUE;
+ _INNER_FUNC_EXIT;
+ return FALSE;
+ }
+ _INNER_FUNC_EXIT;
+ return TRUE;
+}
--- /dev/null
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "dc-vcalendar-task")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+# calendar
+ calendar-service2
+ glib-2.0
+ icu-i18n
+ dlog)
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${dc-vcalendar-task_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${dc-vcalendar-task_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub)
\ No newline at end of file
--- /dev/null
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ENCODING_UTIL_H_
+#define ENCODING_UTIL_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define QP_SIZE 76
+#define BASE64_SIZE 76
+
+typedef enum {
+ EN_TYPE_NONE = 0,
+ EN_TYPE_QUOTED_PRINTABLE,
+ EN_TYPE_BASE64
+} encoding_type_e;
+
+/*
+ * @brief encode original source ( encoding type : quoted-printable )
+ * @param[in] src original source
+ * @param[in] src_len length of original source
+ * @param[out] en_src encoded source
+ * @param[out] en_src_len length of encoded source
+ * @return operation result
+ * @retval 1 success
+ * @retval 0 fail
+ */
+int encode_qp(char *src, int src_len, char **en_src, int *en_src_len);
+
+/*
+ * @brief decode encoded source ( decoding type : quoted-printable )
+ * @param[in] src encoded source
+ * @param[in] src_len length of encoded source
+ * @param[out] de_src decoded source ( original source )
+ * @param[out] de_src_len length of decoded source
+ * @return operation result
+ * @retval 1 success
+ * @retval 0 fail
+ */
+int decode_qp(char *src, int src_len, char **de_src, int *de_src_len);
+
+/* Base64
+ *
+ * @example code
+
+ int main()
+{
+ char *src = "Hello";
+ char *encode_src;
+ int encode_src_len = 0;
+ char *decode_src;
+ int decode_src_len = 0;
+
+ int res = encode_base64(src, strlen(src), &encode_src, &encode_src_len);
+ if (res != 0)
+ fprintf(stdout, "encode src : %s ( %d ) \n", encode_src, encode_src_len);
+ else
+ fprintf(stdout, "%s\n", "encode error !!");
+
+ res = decode_base64(encode_src, encode_src_len, &decode_src, &decode_src_len);
+ if (res != 0)
+ fprintf(stdout, "decode src : %s ( %d ) \n", decode_src, decode_src_len);
+ else
+ fprintf(stdout, "%s\n", "decode error !!");
+
+ return 0;
+}
+
+ */
+
+/*
+ * @brief encode original source ( encoding type : base64 )
+ * @param[in] src original source
+ * @param[in] src_len length of original source
+ * @param[out] en_src encoded source
+ * @param[out] en_src_len length of encoded source
+ * @return operation result
+ * @retval 1 success
+ * @retval 0 fail
+ */
+int encode_base64(char *src, int src_len, char **en_src, int *en_src_len);
+
+/*
+ * @brief decode encoded source ( decoding type : base64 )
+ * @param[in] src encoded source
+ * @param[in] src_len length of encoded source
+ * @param[out] de_src decoded source ( original source )
+ * @param[out] de_src_len length of decoded source
+ * @return operation result
+ * @retval 1 success
+ * @retval 0 fail
+ */
+int decode_base64(char *src, int src_len, char **de_src, int *de_src_len);
+
+/*
+ * @brief make the decoding process
+ * @param[in] src encoded source
+ * @param[in] src_len length of encoded source
+ * @param[out] de_src decoded source ( original source )
+ * @param[out] de_src_len length of decoded source
+ * @return operation result
+ * @retval 1 success
+ * @retval 0 fail
+ *
+ * @example code
+
+int main()
+{
+ char *src = "..."; // decoded data
+ int src_len = strlen(src);
+ char *decode_src;
+ int decode_src_len = 0;
+
+ int res = proc_decoding(src, src_len, &decode_src, &decode_src_len);
+
+ if (res != 0)
+ fprintf(stdout, "decode src : \n%s\n", decode_src);
+ else
+ fprintf(stdout, "%s\n", "decode error !!");
+
+ if (decode_src != NULL)
+ free(decode_src);
+
+ return 0;
+}
+ */
+int proc_decoding(const char *src, int src_len, char **de_src, int *de_src_len);
+
+/*
+ * @brief encoded value is changed to the decoded value
+ * @param[in] type encoding type
+ * @param[in] value encoded value (end of string must be '\0' !!)
+ * ex) =EA=B9=80;=EC=B2=A0=EC=88=98;;;\0
+ * @param[in] value_size length of encoded value
+ * @param[out] decode_str decoded string
+ * @param[out] decode_str_len length of decoded string
+ * @return operation result
+ * @ratval 1 success
+ * @retval 0 fail
+ *
+ * @example code
+
+ int main()
+ {
+ char *data = "..."; // ex) ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8
+ encoding_type_e type = find_encoding_type((const char *)data);
+
+ char *value = "..."; // ex) =EA=B9=80;=EC=B2=A0=EC=88=98;;;\0
+ int value_size = strlen(value);
+
+ int decode_str_len = 0;
+ char *decode_str = (char*)malloc(sizeof(char)*BUF_SIZE); // BUF_SIZE : user define
+ if (decode_str == NULL) {
+ // error process
+ }
+ memset(decode_str, 0x00, sizeof(char)*BUF_SIZE);
+
+ int res = decode_value(type, value, data_size, &decode_str, &decode_str_len);
+
+ if (res == 1) {
+ // success process
+ if (decode_str != NULL)
+ free(decode_str);
+ } else {
+ // error process
+ if (decode_str != NULL)
+ free(decode_str);
+ }
+
+ return 0;
+ }
+ */
+int decode_value(encoding_type_e type, const char *value, int value_size, char **decode_str, int *decode_str_len);
+
+/*
+ * @brief get encoding type for data
+ * @param[in] data vobject data
+ * @return encoding type
+ * @ratval >= 1 success
+ * @retval 0 fail
+ */
+encoding_type_e find_encoding_type(const char *data);
+
+/*
+ * @brief check whether to exist this string, "ENCODING=" in the data
+ * @param[in] data vobject data
+ * @return operation result
+ * @retval 1 exist
+ * @retval 0 not exist
+ */
+int check_encoding_data(const char *data);
+
+#endif /* ENCODING_UTIL_H_ */
--- /dev/null
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IN_DATASTORE_INFO_TASK_H_
+#define IN_DATASTORE_INFO_TASK_H_
+
+#define VCALENDAR_TYPE "text/x-vcalendar"
+#define VCALENDAR_VERSION "1.0"
+
+typedef enum {
+ VCALENDAR_FIELD_BEGIN = 10,
+ VCALENDAR_FIELD_END,
+ VCALENDAR_FIELD_VERSION,
+ VCALENDAR_FIELD_AALARM,
+ VCALENDAR_FIELD_ACTION,
+ VCALENDAR_FIELD_ATTACH,
+ VCALENDAR_FIELD_ATTENDEE,
+ VCALENDAR_FIELD_CALSCALE,
+ VCALENDAR_FIELD_CATEGORIES,
+ VCALENDAR_FIELD_CLASS,
+ VCALENDAR_FIELD_COMMENT,
+ VCALENDAR_FIELD_COMPLETED,
+ VCALENDAR_FIELD_CONTACT,
+ VCALENDAR_FIELD_CREATED,
+ VCALENDAR_FIELD_DALARM,
+ VCALENDAR_FIELD_DAYLIGHT,
+ VCALENDAR_FIELD_DCREATED,
+ VCALENDAR_FIELD_DESCRIPTION,
+ VCALENDAR_FIELD_DTEND,
+ VCALENDAR_FIELD_DTSTAMP,
+ VCALENDAR_FIELD_DTSTART,
+ VCALENDAR_FIELD_DUE,
+ VCALENDAR_FIELD_DURATION,
+ VCALENDAR_FIELD_EXDATE,
+ VCALENDAR_FIELD_EXRULE,
+ VCALENDAR_FIELD_FREEBUSY,
+ VCALENDAR_FIELD_GEO,
+ VCALENDAR_FIELD_LAST_MODIFIED,
+ VCALENDAR_FIELD_LOCATION,
+ VCALENDAR_FIELD_MALARM,
+ VCALENDAR_FIELD_METHOD,
+ VCALENDAR_FIELD_ORGANIZER,
+ VCALENDAR_FIELD_PALARM,
+ VCALENDAR_FIELD_PERCENT_COMPLETE,
+ VCALENDAR_FIELD_PRIORITY,
+ VCALENDAR_FIELD_PRODID,
+ VCALENDAR_FIELD_RDATE,
+ VCALENDAR_FIELD_RECURRENCE_ID,
+ VCALENDAR_FIELD_RELATED_TO,
+ VCALENDAR_FIELD_REPEAT,
+ VCALENDAR_FIELD_REQUEST_STATUS,
+ VCALENDAR_FIELD_RESOURCES,
+ VCALENDAR_FIELD_RNUM,
+ VCALENDAR_FIELD_RRULE,
+ VCALENDAR_FIELD_SEQUENCE,
+ VCALENDAR_FIELD_STANDARD,
+ VCALENDAR_FIELD_STATUS,
+ VCALENDAR_FIELD_SUMMARY,
+ VCALENDAR_FIELD_TRANSP,
+ VCALENDAR_FIELD_TRIGGER,
+ VCALENDAR_FIELD_TZ,
+ VCALENDAR_FIELD_TZID,
+ VCALENDAR_FIELD_TZNAME,
+ VCALENDAR_FIELD_TZOFFSETFROM,
+ VCALENDAR_FIELD_TZOFFSETTO,
+ VCALENDAR_FIELD_TZURL,
+ VCALENDAR_FIELD_URL,
+ VCALENDAR_FIELD_UID,
+ VCALENDAR_FIELD_VALARM,
+ VCALENDAR_FIELD_VCALENDAR,
+ VCALENDAR_FIELD_VEVENT,
+ VCALENDAR_FIELD_VFREEBUSY,
+ VCALENDAR_FIELD_VJOURNAL,
+ VCALENDAR_FIELD_VTIMEZONE,
+ VCALENDAR_FIELD_VTODO,
+ VCALENDAR_FIELD_X_FUNAMBOL_ALLDAY,
+
+} vcalendadr_field_e;
+
+typedef enum {
+ VCALENDAR_FIELD_BEGIN_END_VCALENDAR = 100,
+ VCALENDAR_FIELD_BEGIN_END_VEVENT,
+ VCALENDAR_FIELD_BEGIN_END_VTODO,
+ VCALENDAR_FIELD_BEGIN_END_VJOURNAL,
+ VCALENDAR_FIELD_BEGIN_END_VFREEBUSY,
+ VCALENDAR_FIELD_BEGIN_END_VTIMEZONE,
+ VCALENDAR_FIELD_BEGIN_END_VALARM,
+ VCALENDAR_FIELD_BEGIN_END_STANDARD,
+ VCALENDAR_FIELD_BEGIN_END_DAYLIGHT,
+
+} vcalendar_field_begin_end_sub_e;
+
+typedef enum {
+ VCALENDAR_FIELD_CATEGORIES_APPOINTMENT = 200,
+ VCALENDAR_FIELD_CATEGORIES_HOLIDAY,
+ VCALENDAR_FIELD_CATEGORIES_BUSINESS,
+ VCALENDAR_FIELD_CATEGORIES_SPECIAL_OCCASION,
+ VCALENDAR_FIELD_CATEGORIES_IMPORTANT,
+ VCALENDAR_FIELD_CATEGORIES_BIRTHDAY,
+ VCALENDAR_FIELD_CATEGORIES_MISSCELLANEOUS,
+
+} vcalendadr_field_categories_sub_e;
+
+typedef enum {
+ VCALENDAR_FIELD_STATUS_NEEDS_ACTION = 300,
+ VCALENDAR_FIELD_STATUS_COMPLETED,
+
+} VCALENDAR_FIELD_STATUS_SUB;
+
+typedef struct vcalendar_field_list vcalendar_field_list_s;
+struct vcalendar_field_list {
+ int field_enum;
+ char *field_name;
+};
+
+static vcalendar_field_list_s vcalendar_field_list[] = {
+ {VCALENDAR_FIELD_BEGIN, "BEGIN"},
+ {VCALENDAR_FIELD_END, "END"},
+ {VCALENDAR_FIELD_VERSION, "VERSION"},
+ {VCALENDAR_FIELD_AALARM, "AALARM"},
+ {VCALENDAR_FIELD_ACTION, "ACTION"},
+ {VCALENDAR_FIELD_ATTACH, "ATTACH"},
+ {VCALENDAR_FIELD_ATTENDEE, "ATTENDEE"},
+ {VCALENDAR_FIELD_CALSCALE, "CALSCALE"},
+ {VCALENDAR_FIELD_CATEGORIES, "CATEGORIES"},
+ {VCALENDAR_FIELD_CLASS, "CLASS"},
+ {VCALENDAR_FIELD_COMMENT, "COMMENT"},
+ {VCALENDAR_FIELD_COMPLETED, "COMPLETED"},
+ {VCALENDAR_FIELD_CONTACT, "CONTACT"},
+ {VCALENDAR_FIELD_CREATED, "CREATED"},
+ {VCALENDAR_FIELD_DALARM, "DALARM"},
+ {VCALENDAR_FIELD_DAYLIGHT, "DAYLIGHT"},
+ {VCALENDAR_FIELD_DCREATED, "DCREATED"},
+ {VCALENDAR_FIELD_DESCRIPTION, "DESCRIPTION"},
+ {VCALENDAR_FIELD_DTEND, "DTEND"},
+ {VCALENDAR_FIELD_DTSTAMP, "DTSTAMP"},
+ {VCALENDAR_FIELD_DTSTART, "DTSTART"},
+ {VCALENDAR_FIELD_DUE, "DUE"},
+ {VCALENDAR_FIELD_DURATION, "DURATION"},
+ {VCALENDAR_FIELD_EXDATE, "EXDATE"},
+ {VCALENDAR_FIELD_EXRULE, "EXRULE"},
+ {VCALENDAR_FIELD_FREEBUSY, "FREEBUSY"},
+ {VCALENDAR_FIELD_GEO, "GEO"},
+ {VCALENDAR_FIELD_LAST_MODIFIED, "LAST-MODIFIED"},
+ {VCALENDAR_FIELD_LOCATION, "LOCATION"},
+ {VCALENDAR_FIELD_MALARM, "MALARM"},
+ {VCALENDAR_FIELD_METHOD, "METHOD"},
+ {VCALENDAR_FIELD_ORGANIZER, "ORGANIZER"},
+ {VCALENDAR_FIELD_PALARM, "PALARM"},
+ {VCALENDAR_FIELD_PERCENT_COMPLETE, "PERCENT-COMPLETE"},
+ {VCALENDAR_FIELD_PRIORITY, "PRIORITY"},
+ {VCALENDAR_FIELD_PRODID, "PRODID"},
+ {VCALENDAR_FIELD_RDATE, "RDATE"},
+ {VCALENDAR_FIELD_RECURRENCE_ID, "RECURRENCE-ID"},
+ {VCALENDAR_FIELD_RELATED_TO, "RELATED-TO"},
+ {VCALENDAR_FIELD_REPEAT, "REPEAT"},
+ {VCALENDAR_FIELD_REQUEST_STATUS, "REQUEST-STATUS"},
+ {VCALENDAR_FIELD_RESOURCES, "RESOURCES"},
+ {VCALENDAR_FIELD_RNUM, "RNUM"},
+ {VCALENDAR_FIELD_RRULE, "RRULE"},
+ {VCALENDAR_FIELD_SEQUENCE, "SEQUENCE"},
+ {VCALENDAR_FIELD_STANDARD, "STANDARD"},
+ {VCALENDAR_FIELD_STATUS, "STATUS"},
+ {VCALENDAR_FIELD_SUMMARY, "SUMMARY"},
+ {VCALENDAR_FIELD_TRANSP, "TRANSP"},
+ {VCALENDAR_FIELD_TRIGGER, "TRIGGER"},
+ {VCALENDAR_FIELD_TZ, "TZ"},
+ {VCALENDAR_FIELD_TZID, "TZID"},
+ {VCALENDAR_FIELD_TZNAME, "TZNAME"},
+ {VCALENDAR_FIELD_TZOFFSETFROM, "TZOFFSETFROM"},
+ {VCALENDAR_FIELD_TZOFFSETTO, "TZOFFSETTO"},
+ {VCALENDAR_FIELD_TZURL, "TZURL"},
+ {VCALENDAR_FIELD_URL, "URL"},
+ {VCALENDAR_FIELD_UID, "UID"},
+ {VCALENDAR_FIELD_VALARM, "VALARM"},
+ {VCALENDAR_FIELD_VCALENDAR, "VCALENDAR"},
+ {VCALENDAR_FIELD_VEVENT, "VEVENT"},
+ {VCALENDAR_FIELD_VFREEBUSY, "VFREEBUSY"},
+ {VCALENDAR_FIELD_VJOURNAL, "VJOURNAL"},
+ {VCALENDAR_FIELD_VTIMEZONE, "VTIMEZONE"},
+ {VCALENDAR_FIELD_VTODO, "VTODO"},
+ {VCALENDAR_FIELD_X_FUNAMBOL_ALLDAY, "X-FUNAMBOL-ALLDAY"}
+};
+
+static vcalendar_field_list_s vcalendar_field_list_begin_end[] = {
+ {VCALENDAR_FIELD_BEGIN_END_VCALENDAR, "VCALENDAR"},
+ {VCALENDAR_FIELD_BEGIN_END_VEVENT, "VEVENT"},
+ {VCALENDAR_FIELD_BEGIN_END_VTODO, "VTODO"},
+ {VCALENDAR_FIELD_BEGIN_END_VJOURNAL, "VJOURNAL"},
+ {VCALENDAR_FIELD_BEGIN_END_VFREEBUSY, "VFREEBUSY"},
+ {VCALENDAR_FIELD_BEGIN_END_VTIMEZONE, "VTIMEZONE"},
+ {VCALENDAR_FIELD_BEGIN_END_VALARM, "VALARM"},
+ {VCALENDAR_FIELD_BEGIN_END_STANDARD, "STANDARD"},
+ {VCALENDAR_FIELD_BEGIN_END_DAYLIGHT, "DAYLIGHT"}
+};
+
+static vcalendar_field_list_s vcalendar_field_list_version[] = {
+ {-1, VCALENDAR_VERSION}
+};
+
+static vcalendar_field_list_s vcalendar_field_list_categories[] = {
+ {VCALENDAR_FIELD_CATEGORIES_APPOINTMENT, "APPOINTMENT"},
+ {VCALENDAR_FIELD_CATEGORIES_HOLIDAY, "HOLIDAY"},
+ {VCALENDAR_FIELD_CATEGORIES_BUSINESS, "BUSINESS"},
+ {VCALENDAR_FIELD_CATEGORIES_SPECIAL_OCCASION, "SPECIAL OCCASION"},
+ {VCALENDAR_FIELD_CATEGORIES_IMPORTANT, "IMPORTANT"},
+ {VCALENDAR_FIELD_CATEGORIES_BIRTHDAY, "BIRTHDAY"},
+ {VCALENDAR_FIELD_CATEGORIES_MISSCELLANEOUS, "MISSCELLANEOUS"}
+};
+
+static vcalendar_field_list_s vcalendar_field_list_status[] = {
+ {VCALENDAR_FIELD_STATUS_NEEDS_ACTION, "NEEDS ACTION"},
+ {VCALENDAR_FIELD_STATUS_COMPLETED, "COMPLETED"}
+};
+
+#endif /* IN_DATASTORE_INFO_TASK_H_ */
--- /dev/null
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IN_VCALENDAR_STRING_UTIL_H_
+#define IN_VCALENDAR_STRING_UTIL_H_
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <glib/gprintf.h>
+
+#include <calendar2.h>
+#include <calendar_types2.h>
+#include <unicode/ucal.h>
+#include <unicode/ustring.h>
+#include <unicode/ustdio.h>
+#include <unicode/udat.h>
+#include <sys/types.h>
+
+#include "utility/sync_util.h"
+
+typedef enum cal_date_type {
+ CALENDAR_DATE_TYPE_ONTIME = 0,
+ CALENDAR_DATE_TYPE_YEAR,
+ CALENDAR_DATE_TYPE_MONTH,
+ CALENDAR_DATE_TYPE_WEEK,
+ CALENDAR_DATE_TYPE_DAY,
+ CALENDAR_DATE_TYPE_HOUR,
+ CALENDAR_DATE_TYPE_MINUTE,
+ CALENDAR_DATE_TYPE_SECOND,
+} calendar_date_type_e;
+
+#define RRULE_KEYWORD "\r\nRRULE:"
+#define RRULE_KEYWORD_FREQ_DAILY "\r\nRRULE:FREQ=DAILY"
+#define RRULE_KEYWORD_FREQ_WEEKLY "\r\nRRULE:FREQ=WEEKLY"
+#define RRULE_KEYWORD_FREQ_MONTHLY "\r\nRRULE:FREQ=MONTHLY"
+#define RRULE_KEYWORD_FREQ_YEARLY "\r\nRRULE:FREQ=YEARLY"
+#define RRULE_KEYWORD_INTERVAL "INTERVAL="
+#define RRULE_KEYWORD_BYDAY "BYDAY="
+#define RRULE_KEYWORD_BYMONTH "BYMONTH="
+#define RRULE_KEYWORD_BYMONTHDAY "BYMONTHDAY="
+#define RRULE_KEYWORD_UNTIL "UNTIL="
+#define RRULE_KEYWORD_COUNT "COUNT="
+#define DTSTART_KEYWORD "\r\nDTSTART"
+#define DTEND_KEYWORD "\r\nDTEND"
+#define BEGIN_ALARM_KEYWORD "\r\nBEGIN:VALARM"
+#define END_VTODO_KEYWORD "\r\nEND:VTODO\r\n"
+#define DUEDATE_KEYWORD "\r\nDUE:"
+#define MAX_RRULE_DATE_KEYWORD "20361231T000000Z"
+#define MAX_DUE_DATE_KEYWORD "\r\nDUE:20381231T000000Z\r\n" // refer to calendar info (min ~ max date)
+
+#define CALENDAR_IMAGE_KEYWORD_SNOTE "snote" // refer to Cal-svc.h (calendar\include)
+#define CALENDAR_IMAGE_KEYWORD_PHOTO "photo" // refer to Cal-svc.h (calendar\include)
+#define IMAGE_KEYWORD_PREFIX_SNOTE "\r\nX-SS-ATTACH-SNOTE;"
+#define IMAGE_KEYWORD_PREFIX_PHOTO "\r\nX-SS-ATTACH-IMAGE;"
+#define IMAGE_KEYWORD_BEGIN_PATH "PATH=3D"
+#define IMAGE_KEYWORD_END_PATH "=3bDATE=3D\r\n"
+
+#define INTERNAL_MEMORY_ORIGIN "/opt/usr/media"
+#define INTERNAL_MEMORY_CONVERTED "Internal=3a"
+#define EXTERNAL_MEMORY_ORIGIN "/opt/storage/sdcard"
+#define EXTERNAL_MEMORY_CONVERTED "External=3a"
+#define SNOTE_MEMORY_ORIGIN "/opt/usr/apps/com.samsung.smemo/data/"
+
+char * get_value_by_token(const char *src, const char *token, const char *end_of_token);
+char * replace_string(char *origin, const char *src, const char *dest);
+char * remove_timezone(char *origin);
+void insert_allday_data(const char *origin, calendar_record_h calendar_record);
+char * has_image_import(const char *origin);
+char * has_image_export(calendar_record_h cal_record);
+char * replace_max_rrule_data(char *origin);
+char * replace_image_data(char *origin, char *image_path);
+char * replace_priority_data(char *origin, bool is_phone_to_kies);
+
+#endif /* IN_VCALENDAR_STRING_UTIL_H_ */
--- /dev/null
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <glib/gprintf.h>
+
+#include "encoding_util.h"
+
+/* for log */
+#include "utility/sync_util.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "ENCODING_UTIL"
+#endif
+
+#define TYPE_CHECK_BUF_SIZE 100 /* temporary definition */
+#define TEMP_BUFFER_SIZE 1024 /* temporary definition */
+
+/* BASE64 TABLE */
+static char base64_table[65] = {
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
+ 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
+ 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a',
+ 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
+ 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1',
+ '2', '3', '4', '5', '6', '7', '8', '9', '+',
+ '/', '='
+};
+
+/* Quoted-Printable */
+static char *_dec_to_hex(int dec);
+static int _hex_to_dec(char *hex);
+
+/* Base64 */
+static int _find_base(char ch);
+
+/*
+ * Quoted-Printable
+ */
+int encode_qp(char *src, int src_len, char **en_src, int *en_src_len)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(src == NULL, 0, "[encoding_util] src is NULL\n");
+
+ char *en_hex;
+ int i = 0;
+ int j = 0;
+ int size_cnt = 0;
+
+ if (src == NULL) {
+ _DEBUG_ERROR("[encoding_util] src is NULL\n");
+ return 0;
+ }
+
+ /*encoded string length is three times longer than existing maximum string length */
+ int full_lenth = src_len * 3 + 1 + (int)(src_len * 3 / 76) * 3;
+ *en_src = (char *)malloc(sizeof(char) * full_lenth);
+ if (*en_src == NULL) {
+ _DEBUG_ERROR("[encoding_util] malloc fail !!\n");
+ return 0;
+ }
+ memset(*en_src, 0x00, src_len * 3 + 1);
+
+ _DEBUG_INFO("[encoding_util] src_len : %d\n", src_len);
+ for (i = 0; i < src_len; i++) {
+ /* _DEBUG_INFO("[encoding_util] i : %d\n", i); */
+ if (size_cnt >= QP_SIZE - 3) {
+ size_cnt = 0;
+ (*en_src)[j++] = 0x3D;
+ (*en_src)[j++] = 0x0D;
+ (*en_src)[j++] = 0x0A;
+ }
+
+ if ((src[i] >= 33 && src[i] <= 126) || (src[i] == 0x0A) || (src[i] == 0x0D)) {
+ if (src[i] == 61 || src[i] == 0x0A || src[i] == 0x0D) {
+ en_hex = _dec_to_hex(src[i]);
+ (*en_src)[j++] = 0x3D; /* '=' */
+ (*en_src)[j++] = en_hex[0];
+ (*en_src)[j++] = en_hex[1];
+ size_cnt += 3;
+ } else {
+ size_cnt++;
+ (*en_src)[j++] = src[i];
+ }
+ } else if (src[i] == 9 || src[i] == 32) {
+ if (src[i + 1] == 0x0A || src[i + 1] == '\0') { /* TAB or WhiteSpace */
+ en_hex = _dec_to_hex(src[i]);
+ (*en_src)[j++] = 0x3D; /* '=' */
+ (*en_src)[j++] = en_hex[0];
+ (*en_src)[j++] = en_hex[1];
+ size_cnt += 3;
+ } else {
+ size_cnt++;
+ (*en_src)[j++] = src[i];
+ }
+ } else {
+ en_hex = _dec_to_hex(src[i]);
+ (*en_src)[j++] = 0x3D; /* '=' */
+ (*en_src)[j++] = en_hex[0];
+ (*en_src)[j++] = en_hex[1];
+ _DEBUG_INFO("[encoding_util] en_src : %s\n", *en_src);
+ size_cnt += 3;
+ }
+ }
+
+ (*en_src)[j] = 0x00;
+ *en_src_len = size_cnt;
+
+ _EXTERN_FUNC_EXIT;
+
+ return 1;
+}
+
+int decode_qp(char *src, int src_len, char **de_src, int *de_src_len)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(src == NULL, 0, "[encoding_util] src is NULL\n");
+
+ char hex[3];
+ char ch;
+ int dec = 0;
+ int i = 0;
+ int j = 0;
+ int is_space = 0;
+ int is_equal = 0;
+
+ if (src == NULL) {
+ _DEBUG_ERROR("[encoding_util] src is NULL\n");
+ return 0;
+ }
+
+ *de_src = (char *)malloc(sizeof(char) * (src_len + 1));
+ if (*de_src == NULL) {
+ _DEBUG_ERROR("[encoding_util] malloc is fail !!\n");
+ return 0;
+ }
+ memset(*de_src, 0x00, sizeof(char) * (src_len + 1));
+
+ while (src[i] != '\0') {
+ if (src[i] == 0x3D) { /* '=' */
+ /* check whiteSpace */
+ ch = src[++i];
+
+ /* '=' skip if next character is a TAB or WhiteSpace */
+ while (ch == 0x09 || ch == 0x20) {
+ is_space = 1;
+ ch = src[++i];
+ break;
+ }
+
+ if (is_space == 1) {
+ is_space = 0;
+ continue;
+ }
+
+ /* '=' skip if next character is 3D which means '=' (encoding error case ??) */
+ while (ch == '3') {
+ ch = src[++i];
+
+ if (ch == 'D') {
+ is_equal = 1;
+ ch = src[++i];
+ break;
+ }
+ }
+
+ if (is_equal == 1) {
+ is_equal = 0;
+ goto insert_equal;
+ }
+
+ /* if next character is LF after '=' do doft line break
+ * encoded QP string on one line 76 character is allowed
+ */
+ if (ch == 0x0D) { /* LF */
+ ch = src[++i];
+ if (ch == 0x0A) {
+ ch = src[++i];
+ continue;
+ }
+ }
+
+ hex[0] = src[i++];
+ hex[1] = src[i++];
+ hex[2] = '\0';
+
+ dec = _hex_to_dec(hex);
+
+ /* decoding error */
+ if (dec < 0) {
+ /* when error occur, restore the previous encoding message */
+ (*de_src)[j++] = 0x3D; /* '=' */
+ (*de_src)[j++] = hex[0];
+ (*de_src)[j++] = hex[1];
+ } else {
+ (*de_src)[j++] = dec;
+ }
+ continue;
+ } else if (src[i] > 0x7E) { /* encoding error */
+ i++; /* ignore that character */
+ continue;
+ } else {
+ (*de_src)[j++] = src[i++];
+ continue;
+ }
+
+ insert_equal:
+ (*de_src)[j++] = 0x3D;
+ }
+
+ (*de_src)[j] = '\0';
+ *de_src_len = j;
+
+ _EXTERN_FUNC_EXIT;
+
+ return 1;
+}
+
+static char *_dec_to_hex(int dec)
+{
+ _INNER_FUNC_ENTER;
+
+ static char hex[3];
+ int i;
+ int ch;
+
+ for (i = 0; i < 2; i++) {
+ if (i == 0) {
+ ch = (dec & 0xF0) >> 4;
+ } else if (i == 1) {
+ ch = (dec & 0x0F);
+ }
+
+ if (ch >= 10) {
+ hex[i] = 'A' + ch - 10;
+ } else {
+ hex[i] = '0' + ch;
+ }
+ }
+
+ hex[i] = 0x00;
+
+ _DEBUG_TRACE("[encoding_util] hex : %s\n", hex);
+
+ _INNER_FUNC_EXIT;
+
+ return &hex[0];
+}
+
+static int _hex_to_dec(char *hex)
+{
+ _INNER_FUNC_ENTER;
+
+ int dec = 0;
+ int byte;
+ int i = 0;
+
+ for (i = 0; i < 2; i++) {
+ if (hex[i] >= '0' && hex[i] <= '9') {
+ byte = hex[i] - '0';
+ } else if (hex[i] >= 'A' && hex[i] <= 'F') {
+ byte = hex[i] - 'A' + 10;
+ } else if (hex[i] >= 'a' && hex[i] <= 'f') {
+ byte = hex[i] - 'a' + 10;
+ } else {
+ byte = -1;
+ }
+
+ if (byte < 0)
+ return -1;
+
+ dec += (i == 0) ? byte << 4 : byte;
+ }
+
+ _INNER_FUNC_EXIT;
+
+ return dec;
+}
+
+/*
+ * Base64
+ */
+int encode_base64(char *src, int src_len, char **en_src, int *en_src_len)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(src == NULL, 0, "[encoding_util] src is NULL\n");
+
+ int i = 0;
+ int j = 0;
+ int cnt = 0;
+ int ch = 0;
+ int size_cnt = 0;
+
+ if (src == NULL) {
+ _DEBUG_ERROR("[encoding_util] src is NULL\n");
+ return 0;
+ }
+
+ *en_src = (char *)malloc(sizeof(char) * (src_len * 2));
+
+ if (*en_src == NULL) {
+ _DEBUG_ERROR("[encoding_util] malloc fail !!\n");
+ return 0;
+ }
+ memset(*en_src, 0x00, src_len * 2);
+
+ while (1) {
+ switch (cnt++) {
+ case 0:
+ {
+ if (i < src_len) {
+ ch = (src[i] & 0xFC) >> 2;
+ } else {
+ ch = -1;
+ }
+ }
+ break;
+
+ case 1:
+ {
+ if (i < src_len) {
+ if (i + 1 < src_len) {
+ ch = ((src[i] & 0x03) << 4) | ((src[i + 1] & 0xF0) >> 4);
+ } else {
+ ch = ((src[i] & 0x03) << 4);
+ }
+ } else {
+ ch = -1;
+ }
+ i++;
+ break;
+ }
+
+ case 2:
+ {
+ if (i < src_len) {
+ if (i + 1 < src_len) {
+ ch = ((src[i] & 0x0F) << 2) | ((src[i] & 0xC0) >> 6);
+ } else {
+ ch = ((src[i] & 0x0F) << 2);
+ }
+ } else {
+ ch = -1;
+ }
+ i++;
+ }
+ break;
+
+ case 3:
+ {
+ if (i < src_len) {
+ ch = (src[i] & 0x3F);
+ } else {
+ ch = -1;
+ }
+ i++;
+ cnt = 0;
+ }
+ break;
+ }
+
+ /*
+ if (ch >= 0 && ch <= 25) { // Upper Case Alphabet
+ (*en_src)[j++] = 'A' + ch;
+ } else if (ch >= 26 && ch <= 51) { // Lower Case Alphabet
+ (*en_src)[j++] = 'a' + ch - 26;
+ } else if (ch >= 52 && ch <= 61) { // Digit
+ (*en_src)[j++] = '0' + ch - 52;
+ } else if (ch == 62) {
+ (*en_src)[j++] = '+';
+ } else if (ch == 63) {
+ (*en_src)[j++] = '/';
+ } else if (ch == -1) {
+ (*en_src)[j++] = '='; // padding
+ }
+ */
+
+ if ((ch != -1) && (ch >= 0 && ch <= 64)) {
+ (*en_src)[j++] = base64_table[ch];
+ } else {
+ (*en_src)[j++] = base64_table[64]; /* padding */
+ }
+
+ size_cnt++;
+
+ if (j % 4 == 0) {
+ if (size_cnt == BASE64_SIZE) {
+ size_cnt = 0;
+ (*en_src)[j++] = 0x0A; /* soft line break */
+ }
+
+ if (i >= src_len)
+ break;
+ }
+ }
+
+ (*en_src)[j] = 0x00;
+ *en_src_len = j;
+
+ _EXTERN_FUNC_EXIT;
+
+ return 1;
+}
+
+int decode_base64(char *src, int src_len, char **de_src, int *de_src_len)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(src == NULL, 0, "[encoding_util] src is NULL\n");
+
+ long tmp = 0; /* 4byte (using decoding) */
+ int i = 0;
+ int j = 0;
+ int cnt = 0;
+ int pad_cnt = 0;
+
+ if (src == NULL) {
+ _DEBUG_ERROR("[encoding_util] src is NULL\n");
+ return 0;
+ }
+
+ /* de_src is enough for the src_len 3/4 size */
+ *de_src = (char *)malloc(sizeof(char) * (src_len));
+ if (*de_src == NULL) {
+ _DEBUG_ERROR("malloc error !!");
+ return 0;
+ }
+ memset(*de_src, 0x00, src_len);
+
+ if (*de_src == NULL) {
+ _DEBUG_ERROR("[encoding_util] malloc is fail !!\n");
+ return 0;
+ }
+
+ while (src[i] != '\0') {
+ /*
+ if (isupper(src[i])) {
+ tmp = (tmp << 6) | (src[i] - 'A'); // Upper case : 0 ~ 25
+ } else if (islower(src[i])) {
+ tmp = (tmp << 6) | (src[i] - 'a' + 0x1A); // Lower case : 26(0x1A) ~ 51
+ } else if (isdigit(src[i])) {
+ tmp = (tmp << 6) | (src[i] - '0' + 0x34); // Number : 52(0x34) ~ 61
+ } else if (src[i] == '+') {
+ tmp = (tmp << 6) | 0x3E; // '+' : 62(0x3E)
+ } else if (src[i] == '/') {
+ tmp = (tmp << 6) | 0x3F; // '/' : 63(0x3F)
+ } else if (src[i] == '=') {
+ pad_cnt++;
+ tmp = (tmp << 6); // '=' : padding
+ } else {
+ tmp = (tmp << 6); // encoding error
+ f_DEBUG_INFO(stdout, "encoding error !! \n");
+ }
+ */
+
+ tmp = (tmp << 6) | (_find_base(src[i]));
+ if (tmp == 64) {
+ pad_cnt++;
+ } else if (tmp == -1) {
+ _DEBUG_ERROR("[encoding_util] encoding error \n");
+ }
+
+ if (++cnt >= 4) {
+ (*de_src)[j++] = (char)((tmp & 0x00FF0000) >> 16);
+ (*de_src)[j++] = (char)((tmp & 0x0000FF00) >> 8);
+ (*de_src)[j++] = (char)(tmp & 0x000000FF);
+
+ cnt = 0;
+ tmp = 0;
+
+ if (src[i + 1] == 0x0A) { /* soft line break */
+ i++;
+ }
+ }
+
+ i++;
+ }
+
+ (*de_src)[j - pad_cnt] = '\0';
+ *de_src_len = j - pad_cnt;
+
+ _EXTERN_FUNC_EXIT;
+
+ return 1;
+}
+
+int proc_decoding(const char *src, int src_len, char **de_src, int *de_src_len)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(src == NULL, 0, "[encoding_util] src is NULL\n");
+
+ const char *reg_src = NULL;
+ reg_src = src;
+
+ _DEBUG_INFO("[encoding_util] << src >> \n%s\n", src);
+
+ *de_src = (char *)malloc(sizeof(char) * (src_len + 1));
+ if (*de_src == NULL) {
+ _DEBUG_INFO("[encoding_util] malloc error !! \n");
+
+ return 0;
+ }
+ memset(*de_src, 0x00, sizeof(char) * (src_len + 1));
+
+ char colon[] = ":";
+ char line_breaker[] = "\r\n";
+ char *start_decoding = NULL;
+ int data_size = 0;
+ int res = 0;
+ int de_temp_len = 0;
+ int len = 0;
+
+ char *de_temp = (char *)malloc(sizeof(char) * TEMP_BUFFER_SIZE); /* todo : temporary */
+ if (de_temp == NULL) {
+ _DEBUG_ERROR("[encoding_util] malloc error !!\n");
+
+ if (*de_src != NULL)
+ free(*de_src);
+
+ return 0;
+ }
+
+ while ((start_decoding = strstr(src, "ENCODING="))) {
+ char *charset_loc = strstr(src, "CHARSET=");
+ char *colon_loc = strstr(start_decoding, colon); /* find ':''s location */
+ char *line_breaker_loc = 0;
+
+ /*edited code for line beaker */
+ char *colon_loc_temp = colon_loc;
+ while (line_breaker_loc == NULL) {
+ line_breaker_loc = strstr(colon_loc_temp, line_breaker); /* find "\r\n"'s location */
+ if (line_breaker_loc > colon_loc_temp && !strncmp(line_breaker_loc - 1, "=", 1)) {
+ colon_loc_temp = line_breaker_loc + 1;
+ line_breaker_loc = 0;
+ }
+ }
+
+ /*
+ * if find "ENCODING=" do strcat data until ":" to de_src
+ */
+ if (charset_loc != NULL) {
+ if (start_decoding > charset_loc) { /* CHARSET=UTF-8;ENCODING=abcxx: */
+ data_size = (charset_loc - 1) - src;
+ } else { /* ENCODING=abcxxx;CHARSET=UTF-8: */
+ data_size = (start_decoding - 1) - src;
+ }
+ } else {
+ data_size = (start_decoding - 1) - src;
+ }
+
+ char *temp = (char *)malloc(sizeof(char) * (data_size + 1));
+ if (temp == NULL) {
+ _DEBUG_ERROR("[encoding_util] malloc error !!");
+
+ if (*de_src != NULL)
+ free(*de_src);
+
+ if (de_temp != NULL)
+ free(de_temp);
+
+ return 0;
+ }
+ memset(temp, 0x00, sizeof(char) * (data_size + 1));
+ memcpy(temp, src, data_size);
+
+ len = g_strlcat(*de_src, temp, (src_len + 1));
+ if (len >= (src_len + 1)) {
+ _DEBUG_ERROR("*de_src buffer overflow !!");
+
+ if (*de_src != NULL)
+ free(*de_src);
+
+ if (de_temp != NULL)
+ free(de_temp);
+
+ if (temp != NULL)
+ free(temp);
+
+ return 0;
+ }
+
+ (*de_src)[strlen(*de_src)] = ':';
+ if (temp != NULL)
+ free(temp);
+
+ _DEBUG_INFO("[encoding_util] << *de_src >> \n %s\n", *de_src);
+
+ /*
+ * copy data from ":" until "\r\n"(actual encoding stream)
+ */
+ data_size = line_breaker_loc - colon_loc; /* from ':' until "\r\n" + '\0' */
+ char *value = (char *)malloc(sizeof(char) * (data_size + 1));
+ if (value == NULL) {
+ _DEBUG_ERROR("[encoding_util] malloc error !!\n");
+
+ if (*de_src != NULL)
+ free(*de_src);
+
+ if (de_temp != NULL)
+ free(de_temp);
+
+ return 0;
+ }
+ memset(value, 0x00, sizeof(char) * (data_size + 1));
+ memcpy(value, ++colon_loc, data_size); /* from ':' until "\r\n" */
+ value[data_size] = '\0';
+ _DEBUG_INFO("[encoding_util] data len is [%d] and value is [%s]\n\n", data_size, value);
+ /*
+ * Get encoding type using data from "ENCODING=" to ":"
+ */
+ char type_check[TYPE_CHECK_BUF_SIZE] = { 0, };
+ int type_check_size = colon_loc - start_decoding;
+ strncpy(type_check, start_decoding, type_check_size);
+ _DEBUG_INFO("[encoding_util] type check : %s\n", type_check);
+ encoding_type_e type = find_encoding_type((const char *)type_check);
+
+ /*
+ * Process decoding by passing the actual value and encoding type to decode_value()
+ */
+ de_temp_len = 0;
+ memset(de_temp, 0x00, sizeof(char) * TEMP_BUFFER_SIZE); /* todo : temporary */
+
+ res = decode_value(type, value, data_size, &de_temp, &de_temp_len);
+
+ if (res != 1) {
+ _DEBUG_ERROR("[encoding_util] decode_value error !!\n");
+
+ if (*de_src != NULL)
+ free(*de_src);
+
+ if (de_temp != NULL)
+ free(de_temp);
+
+ if (value != NULL)
+ free(value);
+
+ return 0;
+ }
+
+ /*
+ * Append decoded data to de_src
+ */
+ _DEBUG_INFO("[encoding_util] de_temp : %s\n", de_temp);
+ len = 0;
+ len = g_strlcat(*de_src, de_temp, (src_len + 1));
+ if (len >= (src_len + 1)) {
+ _DEBUG_ERROR("*de_src buffer overflow !!");
+
+ if (*de_src != NULL)
+ free(*de_src);
+
+ if (de_temp != NULL)
+ free(de_temp);
+
+ if (value != NULL)
+ free(value);
+
+ return 0;
+ }
+
+ /*
+ * find "ENCODING=" since "\r\n" agina
+ */
+ src = line_breaker_loc;
+
+ if (value != NULL)
+ free(value);
+ }
+
+ len = 0;
+ len = g_strlcat(*de_src, src, (src_len + 1));
+ if (len >= (src_len + 1)) {
+ _DEBUG_ERROR("*de_src buffer overflow !!");
+
+ if (*de_src != NULL)
+ free(*de_src);
+
+ if (de_temp != NULL)
+ free(de_temp);
+
+ return 0;
+ }
+
+ *de_src_len = strlen(*de_src);
+ _DEBUG_INFO("[encoding_util] changed src : \n%s ( %d ) \n", *de_src, *de_src_len);
+
+ if (de_temp != NULL)
+ free(de_temp);
+
+ _DEBUG_INFO("[encoding_util] End \n");
+
+ _EXTERN_FUNC_EXIT;
+
+ return 1;
+}
+
+int check_encoding_data(const char *data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (strstr(data, "ENCODING=") != NULL) {
+ _DEBUG_INFO("[encoding_util] exist encoding data !! \n");
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ } else {
+ _DEBUG_INFO("[encoding_util] not exist encoding data !! \n");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+}
+
+encoding_type_e find_encoding_type(const char *data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ _DEBUG_INFO("[encoding_util] Start !! \n");
+
+ encoding_type_e type = EN_TYPE_NONE;
+ if (strstr(data, "QUOTED-PRINTABLE") != NULL) {
+ _DEBUG_INFO("[encoding_util] type : QP\n");
+ type = EN_TYPE_QUOTED_PRINTABLE;
+ } else if (strstr(data, "BASE64") != NULL) {
+ _DEBUG_INFO("[encoding_util] type : BASE64\n");
+ type = EN_TYPE_BASE64;
+ } else {
+ _DEBUG_INFO("[encoding_util] not supported type !! \n");
+ }
+
+ _DEBUG_INFO("[encoding_util] End !! \n");
+
+ _EXTERN_FUNC_EXIT;
+
+ return type;
+}
+
+int decode_value(encoding_type_e type, const char *value, int value_size, char **decode_str, int *decode_str_len)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(value == NULL, 0, "[encoding_util] value is NULL\n");
+
+ int res = 1;
+ const char *start_pos = NULL;
+ const char *cursor = NULL;
+ int semi_cnt = 0;
+ int len = 0;
+
+ /*
+ * ex> value - =EA=B9=80;=EC=B2=A0=EC=88=98;;;\0
+ */
+ cursor = value;
+ start_pos = value;
+
+ while (*cursor != '\0') {
+ if ((*cursor != ';') && (*(cursor + 1) != '\0')) {
+ cursor++;
+ continue;
+ } else if (*cursor == ';') {
+ semi_cnt++;
+ }
+
+ int data_size = 0;
+ if (*cursor == ';')
+ data_size = cursor - start_pos;
+ else /* case of [*(cursor+1)=='\0'] */
+ data_size = cursor + 1 - start_pos;
+
+ if (data_size == 0) {
+ cursor++;
+ start_pos++;
+ } else {
+ char *temp = (char *)malloc(sizeof(char) * (value_size + 1));
+ if (temp == NULL) {
+ _DEBUG_ERROR("[encoding_util] malloc error !!");
+ return 0;
+ }
+ memset(temp, 0x00, sizeof(char) * (value_size + 1));
+ memcpy(temp, start_pos, data_size);
+
+ _DEBUG_INFO("[encoding_util] temp : %s \n", temp);
+
+ char *decoding = 0;
+ int decoding_len = 0;
+
+ switch (type) {
+ case EN_TYPE_QUOTED_PRINTABLE:
+ res = decode_qp(temp, data_size, &decoding, &decoding_len);
+ break;
+ case EN_TYPE_BASE64:
+ res = decode_base64(temp, data_size, &decoding, &decoding_len);
+ break;
+ default:
+ break;
+ }
+
+ if (temp != NULL)
+ free(temp);
+
+ _DEBUG_INFO("[encoding_util] decoding : %s ( %d )\n", decoding, decoding_len);
+
+ if (res != 1) {
+ _DEBUG_ERROR("[encoding_util] decoding error !! \n");
+
+ if (decoding != NULL)
+ free(decoding);
+
+ res = 0;
+ return res;
+ }
+
+ len = g_strlcat(*decode_str, decoding, TEMP_BUFFER_SIZE);
+ if (len >= TEMP_BUFFER_SIZE) {
+ _DEBUG_ERROR("*decode_str buffer overflow !!");
+
+ if (decoding != NULL)
+ free(decoding);
+
+ res = 0;
+ return res;
+ }
+
+ _DEBUG_INFO("[encoding_util] *decode_str : %s\n", *decode_str);
+
+ if (decoding != NULL)
+ free(decoding);
+
+ cursor++;
+ start_pos = cursor;
+ }
+
+ if (semi_cnt > 0) {
+ int len = strlen(*decode_str);
+ (*decode_str)[len] = ';';
+ _DEBUG_INFO("[encoding_util] *decode_str : %s ( %d )\n", *decode_str, strlen(*decode_str));
+ semi_cnt--;
+ }
+ }
+
+ *decode_str_len = strlen(*decode_str);
+
+ _DEBUG_INFO("[encoding_util] *decode_str : %s ( %d )\n", *decode_str, *decode_str_len);
+
+ _DEBUG_INFO("[encoding_util] End !! \n");
+
+ _EXTERN_FUNC_EXIT;
+
+ return res;
+}
+
+static int _find_base(char ch)
+{
+ _INNER_FUNC_ENTER;
+
+ int i = 0;
+ for (i = 0; i < 65; i++) {
+ if (base64_table[i] == ch) {
+ _DEBUG_TRACE("[encoding_util] End !! \n");
+ _INNER_FUNC_EXIT;
+ return i;
+ }
+ }
+
+ return -1;
+}
--- /dev/null
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <glib/gprintf.h>
+
+#include <calendar2.h>
+#include <calendar_types2.h>
+
+#include "utility/sync_util.h"
+#include "plugin/data_converter_interface.h"
+#include "encoding_util.h"
+#include "in_datastore_info_task.h"
+#include "vcalendar_string_util.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "PLUGIN_DC_VCALENDAR"
+#endif
+
+static int _free_obj_field_info(sync_agent_plugin_field_info_s * field_list, int count);
+static int _set_obj_field_info(sync_agent_plugin_field_info_s ** field_list, int count, vcalendar_field_list_s * input_list);
+static sync_agent_da_return_e _convert_service_error_to_common_error(calendar_error_e err);
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_converter(const void *agent_data, void **service_data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(agent_data == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "agent_data is NULL. FAIL !!!");
+
+ calendar_list_h calendar_list = NULL;
+ calendar_record_h temp_service_data = NULL;
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ int service_ret = CALENDAR_ERROR_NONE;
+ const char *temp_agent_data = (const char *)agent_data;
+ char *image_path = has_image_import(temp_agent_data);
+ char *temp_image_path = NULL;
+ char *token = NULL;
+ char *temp = NULL;
+
+ _DEBUG_INFO("temp_agent_data= %s", temp_agent_data);
+
+ // 1. priority converting : it should be excuted before calendar_vcalendar_parse_to_calendar
+ if (strstr(temp_agent_data, "\r\nPRIORITY:") != NULL) {
+ _DEBUG_INFO("priority is founed");
+ temp = strdup(temp_agent_data);
+ temp = replace_priority_data(temp, false);
+ temp_agent_data = temp;
+ }
+
+ // 2. if the vcalendar has until : NONE rrule, then max rrule should be converted : it should be excuted before calendar_vcalendar_parse_to_calendar
+ if (strstr(temp_agent_data, RRULE_KEYWORD) != NULL) {
+ temp = strdup(temp_agent_data);
+ temp_agent_data = replace_max_rrule_data(temp);
+ temp = NULL;
+ }
+
+ service_ret = calendar_vcalendar_parse_to_calendar(temp_agent_data, &calendar_list);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_vcalendar_parse_to_calendar() Fail! err[%d]\n", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ *service_data = NULL;
+ }
+
+ if (calendar_list == NULL) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_vcalendar_parse_to_calendar() -> temp_service_data is null, err[%d] !!", service_ret);
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto return_part;
+ }
+
+ service_ret = calendar_list_first(calendar_list);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_list_first() Fail! : err[%d]", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ }
+
+ do
+ {
+ char *uri = NULL;
+ service_ret = calendar_list_get_current_record_p(calendar_list, &temp_service_data);
+ if ((service_ret != CALENDAR_ERROR_NONE) || (temp_service_data == NULL)) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_list_get_current_record_p() Fail! : err[%d]", service_ret);
+ goto return_part;
+ }
+
+ service_ret = calendar_record_get_uri_p(temp_service_data, &uri);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_uri_p() Fail! : err[%d]", service_ret);
+ goto return_part;
+ }
+
+ if (!strncmp(uri, _calendar_todo._uri, strlen(_calendar_todo._uri))) {
+ _DEBUG_INFO("this is todo");
+ break;
+ }
+ else if (!strncmp(uri, _calendar_extended_property._uri, strlen(_calendar_extended_property._uri))) {
+ _DEBUG_INFO("this is extended");
+ continue;
+ }
+ else {
+ _DEBUG_INFO("%s is wrong uri", uri);
+ }
+ } while(calendar_list_next(calendar_list) != CALENDAR_ERROR_NO_DATA);
+
+ // 1. timezone setting : it should be excuted after calendar_vcalendar_parse_to_calendar
+ service_ret = calendar_record_set_str(temp_service_data, _calendar_todo.start_tzid, "Asia/Seoul");
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str() Fail! err[%d]\n", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ /*i think when set return fail then going throw input schedule */
+ }
+
+ service_ret = calendar_record_set_str(temp_service_data, _calendar_todo.due_tzid, "Asia/Seoul");
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str() Fail! err[%d]\n", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ /*i think when set return fail then going throw input schedule */
+ }
+
+ // 2. "no due date" setting : it should be excuted after calendar_vcalendar_parse_to_calendar
+ if (strstr((char *)temp_agent_data, MAX_DUE_DATE_KEYWORD) != NULL) {
+ _DEBUG_INFO("no due date setting");
+
+ calendar_time_s cal_time_end = { 0, };
+ service_ret = calendar_record_get_caltime(temp_service_data, _calendar_todo.due_time, &cal_time_end);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_caltime() Fail: err[%d]", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ }
+
+ cal_time_end.type = CALENDAR_TIME_UTIME;
+ cal_time_end.time.utime = CALENDAR_TODO_NO_DUE_DATE;
+ service_ret = calendar_record_set_caltime(temp_service_data, _calendar_todo.due_time, cal_time_end);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_set_caltime() Fail: err[%d]", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ }
+ }
+
+ // 3. add image info : it should be excuted after calendar_vcalendar_parse_to_calendar
+ if( image_path != NULL ) {
+ _DEBUG_INFO("image is founded. %s", image_path);
+
+ ///////////////////////////////////// S Note temporary code ////////////////////////////
+ if (strstr(image_path, "=\r\n") != NULL) {
+ temp_image_path = get_value_by_token(image_path, "/opt/usr/apps/com.samsung.smemo/data/", "=\r\n");
+ _DEBUG_INFO("temp_image_path = %s", temp_image_path);
+ token = (char *)calloc(1000, sizeof(char));
+ if (token == NULL) {
+ _DEBUG_ERROR("token calloc() is failed");
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto return_part;
+ }
+
+ snprintf(token, 1000, "%s=\r\n", temp_image_path);
+ _DEBUG_INFO("token = %s", token);
+
+ temp = get_value_by_token(image_path, token, ".png");
+
+ if (image_path) {
+ free(image_path);
+ image_path = NULL;
+ }
+
+ image_path = (char *)calloc(1000, sizeof(char));
+ if (image_path == NULL) {
+ _DEBUG_ERROR("image_path is null");
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto return_part;
+ }
+
+ snprintf(image_path, 1000, "/opt/usr/apps/com.samsung.smemo/data/%s%s.png", temp_image_path, temp);
+ _DEBUG_INFO("image_path = %s", image_path);
+ }
+ ///////////////////////////////////// S Note temporary code ////////////////////////////
+
+ calendar_record_h image_record = NULL;
+
+ service_ret = calendar_record_create(_calendar_extended_property._uri, &image_record);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_create() Fail! err[%d]\n", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ }
+
+ service_ret = calendar_record_set_str(image_record, _calendar_extended_property.key, CALENDAR_IMAGE_KEYWORD_PHOTO);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_set_str() Fail! err[%d]\n", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ }
+
+ service_ret = calendar_record_set_str(image_record, _calendar_extended_property.value, image_path);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_set_str() Fail! err[%d]\n", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ }
+
+ service_ret = calendar_record_add_child_record(temp_service_data, _calendar_todo.extended, image_record);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_add_child_record() Fail! err[%d]\n", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ }
+ }
+
+ *service_data = (void *)temp_service_data;
+ _DEBUG_INFO("calendar_vcalendar_parse_to_calendar() Success!\n");
+
+return_part:
+ _DEBUG_INFO("return part");
+
+ if (calendar_list != NULL) {
+ service_ret = calendar_list_destroy(calendar_list, false);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", service_ret);
+ }
+ calendar_list = NULL;
+ }
+ if (image_path) {
+ free(image_path);
+ image_path = NULL;
+ }
+ if (temp_image_path) {
+ free(temp_image_path);
+ temp_image_path = NULL;
+ }
+ if (token) {
+ free(token);
+ token = NULL;
+ }
+ if (temp) {
+ free(temp);
+ temp = NULL;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+sync_agent_da_return_e _vtodo_merge_new_to_old(calendar_record_h old_service_data, calendar_record_h new_service_data)
+{
+ _EXTERN_FUNC_ENTER;
+ retvm_if(old_service_data == NULL, SYNC_AGENT_DA_ERRORS, "old_service_data is NULL. FAIL !!!");
+ retvm_if(new_service_data == NULL, SYNC_AGENT_DA_ERRORS, "new_service_data is NULL. FAIL !!!");
+
+ int service_ret = 0;
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+ /*priority */
+ int priority = 0;
+ service_ret = calendar_record_get_int(new_service_data, _calendar_todo.priority, &priority);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ _DEBUG_INFO("priority= %d", priority);
+
+ service_ret = calendar_record_set_int(old_service_data, _calendar_todo.priority, priority);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_int() Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ /*description */
+ char *description = 0;
+ service_ret = calendar_record_get_str_p(new_service_data, _calendar_todo.description, &description);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str_p() Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ _DEBUG_INFO("description = %s", description);
+
+ service_ret = calendar_record_set_str(old_service_data, _calendar_todo.description, description);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str() Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ /*start time */
+ calendar_time_s task_time_start = { 0, };
+ service_ret = calendar_record_get_caltime(new_service_data, _calendar_todo.start_time, &task_time_start);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_caltime() Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_set_caltime(old_service_data, _calendar_todo.start_time, task_time_start);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_caltime() Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ /*end time */
+ calendar_time_s task_time_end = { 0, };
+ service_ret = calendar_record_get_caltime(new_service_data, _calendar_todo.due_time, &task_time_end);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_caltime() Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_set_caltime(old_service_data, _calendar_todo.due_time, task_time_end);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_caltime() Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ /* summary */
+ char *summary = 0;
+ service_ret = calendar_record_get_str_p(new_service_data, _calendar_todo.summary, &summary);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str_p() Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_set_str(old_service_data, _calendar_todo.summary, summary);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str() Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ /* location */
+ char *location = 0;
+ service_ret = calendar_record_get_str_p(new_service_data, _calendar_todo.location, &location);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str_p() Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_set_str(old_service_data, _calendar_todo.location, location);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str() Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ /* rrule */
+ int num;
+ char *text = NULL;
+ calendar_time_s caltime = {0};
+
+ service_ret = calendar_record_get_int(new_service_data, _calendar_todo.freq, &num);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(freq) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_int(old_service_data, _calendar_todo.freq, num);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_int(freq) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_int(new_service_data, _calendar_todo.range_type, &num);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(range_type) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_int(old_service_data, _calendar_todo.range_type, num);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_int(range_type) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_caltime(new_service_data, _calendar_todo.until_time, &caltime);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_caltime(until_time) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_caltime(old_service_data, _calendar_todo.until_time, caltime);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_caltime(until_time) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_int(new_service_data, _calendar_todo.count, &num);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(count) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_int(old_service_data, _calendar_todo.count, num);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_int(count) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_int(new_service_data, _calendar_todo.interval, &num);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(interval) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_int(old_service_data, _calendar_todo.interval, num);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_int(interval) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_str(new_service_data, _calendar_todo.bysecond, &text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str(bysecond) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_str(old_service_data, _calendar_todo.bysecond, text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str(bysecond) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_str(new_service_data, _calendar_todo.byminute, &text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str(byminute) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_str(old_service_data, _calendar_todo.byminute, text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str(byminute) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_str(new_service_data, _calendar_todo.byhour, &text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str(byhour) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_str(old_service_data, _calendar_todo.byhour, text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str(byhour) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_str(new_service_data, _calendar_todo.byday, &text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str(byday) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_str(old_service_data, _calendar_todo.byday, text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str(byday) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_str(new_service_data, _calendar_todo.bymonthday, &text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str(bymonthday) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_str(old_service_data, _calendar_todo.bymonthday, text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str(bymonthday) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_str(new_service_data, _calendar_todo.byyearday, &text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str(byyearday) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_str(old_service_data, _calendar_todo.byyearday, text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str(byyearday) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_str(new_service_data, _calendar_todo.byweekno, &text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str(byweekno) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_str(old_service_data, _calendar_todo.byweekno, text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str(byweekno) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_str(new_service_data, _calendar_todo.bymonth, &text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str(bymonth) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_str(old_service_data, _calendar_todo.bymonth, text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str(bymonth) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_str(new_service_data, _calendar_todo.bysetpos, &text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str(bysetpos) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_str(old_service_data, _calendar_todo.bysetpos, text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str(bysetpos) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_int(new_service_data, _calendar_todo.wkst, &num);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(wkst) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_int(old_service_data, _calendar_todo.wkst, num);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_int(wkst) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ /* alarm */
+ calendar_record_h new_alarm_record = NULL;
+ calendar_record_h old_alarm_record = NULL;
+ calendar_time_s alarm_time = {0};
+ int new_data_has_alarm = 0;
+ int old_data_has_alarm = 0;
+ int type = 0;
+ int tick = 0;
+ int tick_unit = 0;
+ int alarm_id = 0;
+ description = NULL;
+
+ service_ret = calendar_record_get_int(new_service_data, _calendar_todo.has_alarm, &new_data_has_alarm);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(has_alarm) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ _DEBUG_INFO("new_data_has_alarm = %d", new_data_has_alarm);
+
+ service_ret = calendar_record_get_int(old_service_data, _calendar_todo.has_alarm, &old_data_has_alarm);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(has_alarm) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ _DEBUG_INFO("old_data_has_alarm = %d", old_data_has_alarm);
+
+ if (new_data_has_alarm == 0 && old_data_has_alarm == 1) {
+ _DEBUG_INFO("alarm record shoud be deleted");
+
+ service_ret = calendar_record_get_child_record_at_p(old_service_data, _calendar_todo.calendar_alarm, 0, &old_alarm_record);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_child_record_at_p() Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_remove_child_record(old_service_data, _calendar_todo.calendar_alarm, old_alarm_record);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_remove_child_record() Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ }
+ else if (new_data_has_alarm == 1) {
+ service_ret = calendar_record_get_child_record_at_p(new_service_data, _calendar_todo.calendar_alarm, 0, &new_alarm_record);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_child_record_at_p(_calendar_todo.calendar_alarm) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_int(new_alarm_record, _calendar_alarm.type, &type);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(type) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_lli(new_alarm_record, _calendar_alarm.time, &alarm_time.time.utime);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(time) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_int(new_alarm_record, _calendar_alarm.tick, &tick);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(tick) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_int(new_alarm_record, _calendar_alarm.tick_unit, &tick_unit);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(tick_unit) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_str(new_alarm_record, _calendar_alarm.description, &description);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str(description) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_int(new_alarm_record, _calendar_alarm.alarm_id, &alarm_id);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(alarm_id) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ if (old_data_has_alarm == 0) {
+ _DEBUG_INFO("alarm record should be created");
+
+ service_ret = calendar_record_create(_calendar_alarm._uri, &old_alarm_record);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_create Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ }
+ else if (old_data_has_alarm == 1) {
+ _DEBUG_INFO("alarm record should be overwrited");
+
+ service_ret = calendar_record_get_child_record_at_p(old_service_data, _calendar_todo.calendar_alarm, 0, &old_alarm_record);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_child_record_at_p(_calendar_alarm._uri) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ }
+ else {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] this is an error. new_data_has_alarm = %d, old_data_has_alarm = %d", new_data_has_alarm, old_data_has_alarm);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_set_int(old_alarm_record, _calendar_alarm.type, type);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_int(type) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_set_lli(old_alarm_record, _calendar_alarm.time, alarm_time.time.utime);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_lli(time) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_set_int(old_alarm_record, _calendar_alarm.tick, tick);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_int(tick) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_set_int(old_alarm_record, _calendar_alarm.tick_unit, tick_unit);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_int(tick_unit) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_set_str(old_alarm_record, _calendar_alarm.description, description);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str(description) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_set_int(old_alarm_record, _calendar_alarm.alarm_id, alarm_id);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_int(alarm_id) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ if (old_data_has_alarm == 0) {
+ _DEBUG_INFO("alarm record should be created - add child rocord(alarm)");
+
+ service_ret = calendar_record_add_child_record(old_service_data, _calendar_todo.calendar_alarm, old_alarm_record);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_child_record_at_p(_calendar_alarm._uri) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ }
+ }
+
+ /* image is not supported Outlook sync. So, image field should be not merged (2013/01/14 concept) */
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_replace_converter(void *old_service_data, const void *agent_data, void **new_service_data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(old_service_data == NULL, SYNC_AGENT_DA_ERRORS, "old_service_data is NULL. FAIL !!!");
+ retvm_if(agent_data == NULL, SYNC_AGENT_DA_ERRORS, "agent_data is NULL. FAIL !!!");
+
+ calendar_list_h calendar_list = NULL;
+ calendar_record_h temp_new_service_data = NULL;
+ calendar_record_h temp_old_service_data = (calendar_record_h) old_service_data;
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ int service_ret = CALENDAR_ERROR_NONE;
+ const char *temp_agent_data = (const char *)agent_data;
+ char *temp = NULL;
+
+ if (temp_agent_data == NULL) {
+ _DEBUG_ERROR("inputed temp_agent_data is null");
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ _DEBUG_INFO("temp_agent_data= %s", temp_agent_data);
+
+ // 1. if the vcalendar has until : NONE rrule, then max rrule should be converted : it should be excuted before calendar_vcalendar_parse_to_calendar
+ if (strstr(temp_agent_data, RRULE_KEYWORD) != NULL) {
+ temp = strdup(temp_agent_data);
+ temp_agent_data = replace_max_rrule_data(temp);
+ temp = NULL;
+ }
+
+ // 2. priority converting : it should be excuted before calendar_vcalendar_parse_to_calendar
+ if (strstr(temp_agent_data, "\r\nPRIORITY:") != NULL) {
+ _DEBUG_INFO("priority is founed");
+ temp = strdup(temp_agent_data);
+ temp = replace_priority_data(temp, false);
+ temp_agent_data = temp;
+ }
+
+ _DEBUG_INFO("temp_agent_data= %s", temp_agent_data);
+ service_ret = calendar_vcalendar_parse_to_calendar(temp_agent_data, &calendar_list);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_vcalendar_parse_to_calendar() Fail! err[%d]\n", service_ret);
+ *new_service_data = NULL;
+ goto return_part;
+ }
+ _DEBUG_INFO("[dc_vcalendar-task_plugIn] calendar_vcalendar_parse_to_calendar() success!\n");
+
+ service_ret = calendar_list_first(calendar_list);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_list_first() Fail! : err[%d]", service_ret);
+ goto return_part;
+ }
+
+ int count = 0;
+ calendar_list_get_count(calendar_list, &count);
+ _DEBUG_INFO("count = %d", count);
+ do
+ {
+ char *uri = NULL;
+ char *key = NULL;
+ service_ret = calendar_list_get_current_record_p(calendar_list, &temp_new_service_data);
+ if ((service_ret != CALENDAR_ERROR_NONE) || (temp_new_service_data == NULL)) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_list_get_current_record_p() Fail! : err[%d]", service_ret);
+ goto return_part;
+ }
+
+ service_ret = calendar_record_get_uri_p(temp_new_service_data, &uri);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_uri_p() Fail! : err[%d]", service_ret);
+ goto return_part;
+ }
+ _DEBUG_INFO("temp_new_service_data URI = %s", uri);
+
+ if (!strncmp(uri, _calendar_todo._uri, strlen(_calendar_todo._uri))) {
+ _DEBUG_INFO("this is todo");
+ ret = _vtodo_merge_new_to_old(temp_old_service_data, temp_new_service_data);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_int() Fail! err[%d]\n", ret);
+ }
+
+ // 1. "no due date" setting : it should be excuted after calendar_vcalendar_parse_to_calendar
+ if (strstr((char *)temp_agent_data, MAX_DUE_DATE_KEYWORD) != NULL) {
+ _DEBUG_INFO("no due date setting");
+
+ calendar_time_s cal_time_end = { 0, };
+ service_ret = calendar_record_get_caltime(temp_old_service_data, _calendar_todo.due_time, &cal_time_end);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_caltime() Fail: err[%d]", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ }
+
+ cal_time_end.type = CALENDAR_TIME_UTIME;
+ cal_time_end.time.utime = CALENDAR_TODO_NO_DUE_DATE;
+ service_ret = calendar_record_set_caltime(temp_old_service_data, _calendar_todo.due_time, cal_time_end);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_set_caltime() Fail: err[%d]", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ }
+ }
+ }
+ else if (!strncmp(uri, _calendar_extended_property._uri, strlen(_calendar_extended_property._uri))) {
+ _DEBUG_INFO("this is extended");
+ ret = calendar_record_get_str(temp_new_service_data, _calendar_extended_property.key, &key);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str() Fail! : err[%d]", service_ret);
+ goto return_part;
+ }
+ _DEBUG_INFO("key = %s", key);
+ if (strncmp(key, "VERSION", strlen("VERSION"))) {
+ _DEBUG_INFO("this is extended, not VCALENDAR:VERSION extend");
+ calendar_record_add_child_record(temp_old_service_data, _calendar_todo.extended, temp_new_service_data);
+ }
+ }
+ } while(calendar_list_next(calendar_list) != CALENDAR_ERROR_NO_DATA);
+ *new_service_data = temp_old_service_data;
+
+return_part:
+ _DEBUG_INFO("return_part");
+ if (calendar_list != NULL) {
+ service_ret = calendar_list_destroy(calendar_list, false);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", service_ret);
+ }
+ calendar_list = NULL;
+ }
+ ret = _convert_service_error_to_common_error(service_ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_reverse_converter(void *service_data, void **agent_data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(service_data == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "service_data is NULL. FAIL !!!");
+
+ calendar_list_h list = NULL;
+ calendar_record_h temp_service_data = (calendar_record_h) service_data;
+ calendar_record_h image_item = (calendar_record_h) temp_service_data;
+ calendar_record_h extended_version = NULL;
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ int service_ret = CALENDAR_ERROR_NONE;
+ char *temp_agent_data = NULL;
+
+ _DEBUG_INFO("converter start");
+ service_ret = calendar_list_create(&list);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_create() Fail!: err[%d]", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto return_part;
+ }
+
+ // 1. extended vcalendar version : it should be excuted before calendar_vcalendar_make_from_records
+ service_ret = calendar_record_create(_calendar_extended_property._uri, &extended_version);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_create() Fail!: err[%d]", service_ret);
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto return_part;
+ }
+
+ service_ret = calendar_record_set_str(extended_version, _calendar_extended_property.key, "VERSION");
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_set_str() Fail!: err[%d]", service_ret);
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto return_part;
+ }
+
+ service_ret = calendar_record_set_str(extended_version, _calendar_extended_property.value, ":1.0");
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_create() Fail!: err[%d]", service_ret);
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto return_part;
+ }
+
+ service_ret = calendar_list_add(list, extended_version);
+ if (service_ret != CALENDAR_ERROR_NONE || list == NULL) {
+ _DEBUG_ERROR("calendar_list_add() Fail!: err[%d]", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto return_part;
+ }
+
+ service_ret = calendar_list_add(list, temp_service_data);
+ if (service_ret != CALENDAR_ERROR_NONE || list == NULL) {
+ _DEBUG_ERROR("calendar_list_add() Fail!: err[%d]", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto return_part;
+ }
+
+ service_ret = calendar_vcalendar_make_from_records(list, &temp_agent_data);
+ _DEBUG_INFO("temp_agent_data = %s", temp_agent_data);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_vcalendar_make_from_records() Fail!: err[%d]", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto return_part;
+ }
+
+ // 1. remove 'timezone' : after calendar_vcalendar_make_from_records
+ temp_agent_data = remove_timezone(temp_agent_data);
+ _DEBUG_INFO("temp_agent_data = %s", temp_agent_data);
+
+ // 2. image converting : it should be excuted after calendar_vcalendar_make_from_records
+ char *image_path = has_image_export(image_item);
+ if( image_path != NULL ) {
+ _DEBUG_INFO("image is founded.");
+ temp_agent_data = replace_image_data(temp_agent_data, image_path);
+ }
+
+ // 3. task priority converting : it should be excuted after calendar_vcalendar_make_from_records
+ if (strstr(temp_agent_data, "\r\nPRIORITY:") != NULL) {
+ _DEBUG_INFO("priority is founed");
+ temp_agent_data = replace_priority_data(temp_agent_data, true);
+ }
+
+ // originally, vtodo has not DTSTART, but exceptively DTSTART should be added for alarm time setting at Kies
+ // 4. DTSTART converting : it should be excuted after calendar_vcalendar_make_from_records
+ if (strstr(temp_agent_data, END_VTODO_KEYWORD) != NULL) {
+ temp_agent_data = replace_string(temp_agent_data, END_VTODO_KEYWORD, "\r\nDTSTART:20370101T090000\r\nEND:VTODO\r\n");
+ }
+
+ // originally, "NO DUE DATE" vtodo has not "DUE:xxxxxx", but exceptively DUE should be added for alarm time setting at Kies
+ // 5. DUE converting : it should be excuted after calendar_vcalendar_make_from_records
+ if (strstr(temp_agent_data, DUEDATE_KEYWORD) == NULL) {
+ temp_agent_data = replace_string(temp_agent_data, END_VTODO_KEYWORD, "\r\nDUE:20370101T090000\r\nEND:VTODO\r\n");
+ }
+
+return_part:
+ _DEBUG_INFO("return_part");
+ *agent_data = (void *)temp_agent_data;
+
+ if (list != NULL) {
+ service_ret = calendar_list_destroy(list, true);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_destroy() Fail!: err[%d]", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ }
+ }
+ _DEBUG_INFO("agent_data = %s", *agent_data);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+EXPORT_API void *sync_agent_plugin_alloc_object()
+{
+ _EXTERN_FUNC_ENTER;
+ _DEBUG_INFO("[dc_vcalendar-task_plugIn] not implement !!");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+EXPORT_API int sync_agent_plugin_free_object(void *in_object)
+{
+ _EXTERN_FUNC_ENTER;
+ _DEBUG_INFO("[dc_vcalendar-task_plugIn] not implement !!");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+EXPORT_API void *sync_agent_plugin_set_value(void *in_object, int key, char *extension_key, void *value)
+{
+ _EXTERN_FUNC_ENTER;
+ _DEBUG_INFO("[dc_vcalendar-task_plugIn] not implement !!");
+ _EXTERN_FUNC_EXIT;
+
+ return 0;
+}
+
+EXPORT_API void *sync_agent_plugin_get_value(void *in_object, int key, char *extension_key)
+{
+ _EXTERN_FUNC_ENTER;
+ _DEBUG_INFO("[dc_vcalendar-task_plugIn] not implement !!");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+EXPORT_API sync_agent_plugin_object_info_s *sync_agent_plugin_get_obj_info()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_plugin_object_info_s *obj_info = (sync_agent_plugin_object_info_s *) calloc(1, sizeof(sync_agent_plugin_object_info_s));
+ if (obj_info == NULL) {
+ _DEBUG_ERROR("CALLOC failed !!!");
+ return NULL;
+ }
+
+ obj_info->type = VCALENDAR_TYPE;
+ obj_info->version = VCALENDAR_VERSION;
+ obj_info->field_cnt = sizeof(vcalendar_field_list) / sizeof(vcalendar_field_list_s);
+
+ if (obj_info->field_cnt > 0)
+ if (_set_obj_field_info(&(obj_info->field_list), obj_info->field_cnt, vcalendar_field_list) == 0) {
+
+ if (obj_info != NULL)
+ free(obj_info);
+
+ return NULL;
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+ return obj_info;
+}
+
+
+EXPORT_API int sync_agent_plugin_free_obj_info(sync_agent_plugin_object_info_s * obj_info)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (obj_info != NULL) {
+ if (obj_info->field_cnt > 0)
+ if (_free_obj_field_info(obj_info->field_list, obj_info->field_cnt) == 0)
+ return 0;
+
+ free(obj_info);
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+ return 1;
+}
+
+static int _free_obj_field_info(sync_agent_plugin_field_info_s * field_list, int count)
+{
+ _INNER_FUNC_ENTER;
+
+ int field_count = 0;
+ sync_agent_plugin_field_info_s *child = NULL;
+
+ if (field_list != NULL) {
+ for (field_count = 0; field_count < count; field_count++) {
+ child = field_list + field_count;
+ if (child->field_child_cnt > 0)
+ if (_free_obj_field_info(child->field_child_list, child->field_child_cnt) == 0)
+ return 0;
+ }
+ free(field_list);
+ }
+
+ _INNER_FUNC_EXIT;
+
+ return 1;
+}
+
+static int _set_obj_field_info(sync_agent_plugin_field_info_s ** field_list, int count, vcalendar_field_list_s * input_list)
+{
+ _INNER_FUNC_ENTER;
+
+ int field_count = 0;
+ sync_agent_plugin_field_info_s *child = NULL;
+
+ *field_list = (sync_agent_plugin_field_info_s *) calloc(count, sizeof(sync_agent_plugin_field_info_s));
+ if (*field_list == NULL) {
+ _DEBUG_ERROR("CALLOC failed !!!");
+ return 0;
+ }
+
+ for (field_count = 0; field_count < count; field_count++) {
+ child = (*field_list) + field_count;
+ child->field_name = input_list[field_count].field_name;
+ _DEBUG_TRACE("[%s]", child->field_name);
+
+ if (input_list[field_count].field_enum == VCALENDAR_FIELD_BEGIN || input_list[field_count].field_enum == VCALENDAR_FIELD_END) {
+ child->field_child_cnt = sizeof(vcalendar_field_list_begin_end) / sizeof(vcalendar_field_list_s);
+ _DEBUG_TRACE("----------");
+ _set_obj_field_info(&(child->field_child_list), child->field_child_cnt, vcalendar_field_list_begin_end);
+ _DEBUG_TRACE("==========");
+ } else if (input_list[field_count].field_enum == VCALENDAR_FIELD_VERSION) {
+ child->field_child_cnt = sizeof(vcalendar_field_list_version) / sizeof(vcalendar_field_list_s);
+ _DEBUG_TRACE("----------");
+ _set_obj_field_info(&(child->field_child_list), child->field_child_cnt, vcalendar_field_list_version);
+ _DEBUG_TRACE("==========");
+ } else if (input_list[field_count].field_enum == VCALENDAR_FIELD_CATEGORIES) {
+ child->field_child_cnt = sizeof(vcalendar_field_list_categories) / sizeof(vcalendar_field_list_s);
+ _DEBUG_TRACE("----------");
+ _set_obj_field_info(&(child->field_child_list), child->field_child_cnt, vcalendar_field_list_categories);
+ _DEBUG_TRACE("==========");
+ } else if (input_list[field_count].field_enum == VCALENDAR_FIELD_STATUS) {
+ child->field_child_cnt = sizeof(vcalendar_field_list_status) / sizeof(vcalendar_field_list_s);
+ _DEBUG_TRACE("----------");
+ _set_obj_field_info(&(child->field_child_list), child->field_child_cnt, vcalendar_field_list_status);
+ _DEBUG_TRACE("==========");
+ }
+ }
+
+ _INNER_FUNC_EXIT;
+
+ return 1;
+}
+
+static sync_agent_da_return_e _convert_service_error_to_common_error(calendar_error_e err)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ _DEBUG_TRACE("[da_calendar_plugIn] Error Code : %d\n", err);
+
+ switch (err) {
+ case CALENDAR_ERROR_DB_RECORD_NOT_FOUND:
+ case CALENDAR_ERROR_NO_DATA:
+ ret = SYNC_AGENT_DA_ERR_NO_DATA;
+ break;
+ case CALENDAR_ERROR_OUT_OF_MEMORY:
+ ret = SYNC_AGENT_DA_ERR_MEMORY_FULL;
+ break;
+ case CALENDAR_ERROR_INVALID_PARAMETER:
+ ret = SYNC_AGENT_DA_ERR_INVALID_CONTENT;
+ break;
+ case CALENDAR_ERROR_ITERATOR_END:
+ case CALENDAR_ERROR_NONE:
+ ret = SYNC_AGENT_DA_SUCCESS;
+ break;
+ /*
+ * CALENDAR_ERROR_DB_FAILED
+ * CALENDAR_ERROR_NOW_IN_PROGRESS
+ * CALENDAR_ERROR_ALREADY_IN_PROGRESS
+ * CALENDAR_ERROR_NOT_PERMITTED
+ */
+ default:
+ ret = SYNC_AGENT_DA_ERRORS;
+ break;
+ }
+
+ _INNER_FUNC_EXIT;
+
+ return ret;
+}
--- /dev/null
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "vcalendar_string_util.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#if 0
+// usage / rrule converting
+if (strstr(temp_agent_data, "\r\nRRULE:") != NULL) {
+ _DEBUG_INFO("rrule is founed");
+ temp_agent_data = _replace_rrule_data(temp_agent_data);
+}
+
+static char * _replace_rrule_data(char *origin)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if(origin == NULL, origin, "origin is NULL.");
+
+ char *str_new_rrule = NULL;
+ char *str_end_time = NULL;
+ char *freq_loc = NULL;
+ char *str_byday = NULL;
+ char *str_interval = NULL;
+ char *str_period_until = NULL;
+ char *str_period_count = NULL;
+ calendar_date_type_e cal_type = CALENDAR_DATE_TYPE_ONTIME;
+
+ if ((freq_loc = strstr(origin, RRULE_KEYWORD_FREQ_WEEKLY)) != NULL) {
+ _DEBUG_INFO("this is weekly data");
+ }
+ else if ((freq_loc = strstr(origin, RRULE_KEYWORD_FREQ_MONTHLY)) != NULL) {
+ _DEBUG_INFO("this is monthly data");
+ }
+ else if ((freq_loc = strstr(origin, RRULE_KEYWORD_FREQ_YEARLY)) != NULL) {
+ _DEBUG_INFO("this is yearly data");
+ }
+ else if ((freq_loc = strstr(origin, RRULE_KEYWORD_FREQ_DAILY)) != NULL) {
+ _DEBUG_INFO("this is daily data");
+ }
+ else {
+ _DEBUG_ERROR("this is an undefined rrule type. origin = %s", origin);
+ goto return_part;
+ }
+
+ char *temp_rrule = NULL;
+ if((temp_rrule = strstr(freq_loc, "RRULE:")) == NULL) {
+ _DEBUG_ERROR("temp_rrule is NULL");
+ goto return_part;
+ }
+
+ char *temp_rrule2 = NULL;
+ if((temp_rrule2 = strstr(temp_rrule, "\r\n")) == NULL) {
+ _DEBUG_ERROR("temp_rrule2 is NULL");
+ goto return_part;
+ }
+
+ char str_origin_rrule[100] = {0,};
+ int origin_rrule_length = strlen(temp_rrule) - strlen(temp_rrule2) + 2; // '2' means of '\r\n'
+ if (origin_rrule_length <= 0) {
+ _DEBUG_ERROR("origin_rrule_length <= 0");
+ goto return_part;
+ }
+
+ strncpy(str_origin_rrule, temp_rrule, origin_rrule_length);
+ _DEBUG_INFO("str_origin_rrule = %s", str_origin_rrule);
+
+ if (strstr(origin, RRULE_KEYWORD_FREQ_WEEKLY) != NULL) {
+ str_byday = get_value_by_token(freq_loc, RRULE_KEYWORD_BYDAY, ";");
+ cal_type = CALENDAR_DATE_TYPE_WEEK;
+ }
+ else if (strstr(origin, RRULE_KEYWORD_FREQ_MONTHLY) != NULL) {
+ str_byday = get_value_by_token(freq_loc, RRULE_KEYWORD_BYMONTHDAY, ";");
+ cal_type = CALENDAR_DATE_TYPE_MONTH;
+ }
+ else if (strstr(origin, RRULE_KEYWORD_FREQ_YEARLY) != NULL) {
+ str_byday = get_value_by_token(freq_loc, RRULE_KEYWORD_BYMONTHDAY, ";");
+ cal_type = CALENDAR_DATE_TYPE_YEAR;
+ }
+ else if (strstr(origin, RRULE_KEYWORD_FREQ_DAILY) != NULL) {
+ cal_type = CALENDAR_DATE_TYPE_DAY;
+ }
+ else {
+ _DEBUG_ERROR("this is an undefined rrule type. origin = %s", origin);
+ goto return_part;
+ }
+
+ if ((cal_type != CALENDAR_DATE_TYPE_DAY) && (str_byday == NULL || strlen(str_byday) <= 0)) {
+ _DEBUG_ERROR("str_byday is null");
+ goto return_part;
+ }
+
+ str_interval = get_value_by_token(freq_loc, RRULE_KEYWORD_INTERVAL, ";");
+ str_period_until = get_value_by_token(freq_loc, RRULE_KEYWORD_UNTIL, ";");
+ str_period_count = get_value_by_token(freq_loc, RRULE_KEYWORD_COUNT, ";");
+
+ if (str_interval == NULL || strlen(str_interval) <= 0) {
+ _DEBUG_ERROR("str_interval is null");
+ goto return_part;
+ }
+
+ if (str_period_until == NULL && str_period_count == NULL) {
+ str_end_time = (char *)calloc(2, sizeof(char));
+ if (str_end_time == NULL) {
+ _DEBUG_ERROR("str_end_time is null");
+ goto return_part;
+ }
+ strncpy(str_end_time, "\r\n", 2);
+ _DEBUG_INFO("endless = %s", str_end_time);
+ }
+ else if (str_period_until != NULL) {
+ str_end_time = (char *)calloc(strlen(str_period_until), sizeof(char));
+ if (str_end_time == NULL) {
+ _DEBUG_ERROR("str_end_time is null");
+ goto return_part;
+ }
+ strncpy(str_end_time, str_period_until, strlen(str_period_until));
+ _DEBUG_INFO("until = %s", str_end_time);
+ }
+ else if (str_period_count != NULL) {
+ str_end_time = (char *)calloc(strlen(str_period_count)+1, sizeof(char));
+ if (str_end_time == NULL) {
+ _DEBUG_ERROR("str_end_time is null");
+ goto return_part;
+ }
+ snprintf(str_end_time, strlen(str_period_count)+1, "#%s", str_period_count);
+ _DEBUG_INFO("count = %s", str_end_time);
+ }
+ else {
+ _DEBUG_ERROR("there is an error");
+ goto return_part;
+ }
+
+ int new_rrule_length = 0;
+ if (strstr(origin, RRULE_KEYWORD_FREQ_WEEKLY) != NULL) {
+ new_rrule_length = strlen("RRULE:W") + strlen(str_interval) + strlen(" ") + strlen(str_byday) + strlen(" ") + strlen(str_end_time) + 1;
+ }
+ else if (strstr(origin, RRULE_KEYWORD_FREQ_MONTHLY) != NULL) {
+ new_rrule_length = strlen("RRULE:MD") + strlen(str_interval) + strlen(" ") + strlen(str_byday) + strlen(" ") + strlen(str_end_time) + 1;
+ }
+ else if (strstr(origin, RRULE_KEYWORD_FREQ_YEARLY) != NULL) {
+ new_rrule_length = strlen("RRULE:YD") + strlen(str_interval) + strlen(" ") + strlen(str_end_time) + 1;
+ }
+ else if (strstr(origin, RRULE_KEYWORD_FREQ_DAILY) != NULL) {
+ new_rrule_length = strlen("RRULE:D") + strlen(str_interval) + strlen(" ") + strlen(str_end_time) + 1;
+ }
+ else {
+ _DEBUG_ERROR("this is an undefined rrule type. origin = %s", origin);
+ goto return_part;
+ }
+
+ if (new_rrule_length <= 0) {
+ _DEBUG_ERROR("new_rrule_length(%d) <= 0", new_rrule_length);
+ goto return_part;
+ }
+
+ str_new_rrule = (char *)calloc(new_rrule_length, sizeof(char));
+ if (str_new_rrule == NULL) {
+ _DEBUG_ERROR("str_new_rrule calloc failed");
+ goto return_part;
+ }
+
+ if (strstr(origin, RRULE_KEYWORD_FREQ_WEEKLY) != NULL) {
+ snprintf(str_new_rrule, new_rrule_length, "RRULE:W%s %s %s", str_interval, str_byday, str_end_time);
+ }
+ else if (strstr(origin, RRULE_KEYWORD_FREQ_MONTHLY) != NULL) {
+ snprintf(str_new_rrule, new_rrule_length, "RRULE:MD%s %s %s", str_interval, str_byday, str_end_time);
+ }
+ else if (strstr(origin, RRULE_KEYWORD_FREQ_YEARLY) != NULL) {
+ snprintf(str_new_rrule, new_rrule_length, "RRULE:YD%s %s", str_interval, str_end_time);
+ }
+ else if (strstr(origin, RRULE_KEYWORD_FREQ_DAILY) != NULL) {
+ snprintf(str_new_rrule, new_rrule_length, "RRULE:D%s %s", str_interval, str_end_time);
+ }
+ else {
+ _DEBUG_ERROR("this is an undefined rrule type. origin = %s", origin);
+ goto return_part;
+ }
+
+ _DEBUG_INFO("str_new_rrule = %s", str_new_rrule);
+ _DEBUG_INFO("str_origin_rrule = %s", str_origin_rrule);
+
+ char *new_agent_data = replace_string(origin, str_origin_rrule, str_new_rrule);
+ origin = NULL;
+ origin = new_agent_data;
+
+return_part:
+
+ if (str_interval) {
+ free(str_interval);
+ str_interval = NULL;
+ }
+ if (str_byday) {
+ free(str_byday);
+ str_byday = NULL;
+ }
+ if (str_period_until) {
+ free(str_period_until);
+ str_period_until = NULL;
+ }
+ if (str_period_count) {
+ free(str_period_count);
+ str_period_count = NULL;
+ }
+ if (str_end_time) {
+ free(str_end_time);
+ str_end_time = NULL;
+ }
+ if (str_new_rrule) {
+ free(str_new_rrule);
+ str_new_rrule = NULL;
+ }
+
+ _DEBUG_INFO("origin = %s", origin);
+ _INNER_FUNC_EXIT;
+ return origin;
+}
+
+// usage / alarm converting
+if (strstr(temp_agent_data, "\r\nBEGIN:VALARM") != NULL) {
+ _DEBUG_INFO("alarm is founed");
+ temp_agent_data = _replace_alarm_data(temp_agent_data);
+}
+
+static char * _replace_alarm_data(char *origin)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if(origin == NULL, origin, "origin is NULL.");
+
+ int interval = 0;
+ char *str_new_alarm = NULL;
+ char *freq_loc = NULL;
+ char *str_trigger = NULL;
+ char *str_customized_trigger = NULL;
+ char *str_interval = NULL;
+ calendar_date_type_e cal_type = CALENDAR_DATE_TYPE_ONTIME;
+
+ if ((freq_loc = strstr(origin, BEGIN_ALARM_KEYWORD)) == NULL) {
+ _DEBUG_ERROR("there is not trigger data");
+ goto return_part;
+ }
+
+ char *temp = NULL;
+ if((temp = strstr(freq_loc, "BEGIN:VALARM\r\n")) == NULL) {
+ _DEBUG_ERROR("temp is NULL");
+ goto return_part;
+ }
+
+ char *temp2 = NULL;
+ if((temp2 = strstr(temp, "END:VALARM\r\n")) == NULL) {
+ _DEBUG_ERROR("temp2 is NULL");
+ goto return_part;
+ }
+
+ char str_origin_alarm[100] = {0,};
+ int origin_alarm_length = strlen(temp) - strlen(temp2) + 12; // '12' means of "END:VALARM\r\n"
+ if (origin_alarm_length <= 0) {
+ _DEBUG_ERROR("origin_alarm_length <= 0");
+ goto return_part;
+ }
+
+ strncpy(str_origin_alarm, temp, origin_alarm_length);
+ _DEBUG_INFO("str_origin_alarm = %s", str_origin_alarm);
+
+ // case 1. "TRIGGER;VALUE=DATE-TIME:" is an alarm that created by user
+ str_customized_trigger = _get_value_by_token(freq_loc, "TRIGGER;VALUE=DATE-TIME:", "\r\n");
+ if (str_customized_trigger != NULL) {
+ _DEBUG_INFO("str_customized_trigger is founded. str_customized_trigger = %s", str_customized_trigger);
+
+ str_new_alarm = (char *)calloc(30, sizeof(char));
+ if (str_new_alarm == NULL) {
+ _DEBUG_ERROR("new_date_time is null");
+ goto return_part;
+ }
+
+ snprintf(str_new_alarm, 30, "AALARM:%s\r\n", str_customized_trigger);
+ _DEBUG_INFO("str_new_alarm = %s", str_new_alarm);
+ char *new_agent_data = _replace_string(origin, str_origin_alarm, str_new_alarm);
+ origin = NULL;
+ origin = new_agent_data;
+ goto return_part;
+ }
+
+ // case 2. "TRIGGER:" is a normal alarm
+ str_trigger = _get_value_by_token(freq_loc, "TRIGGER:", "\r\n");
+ if (str_trigger == NULL || strlen(str_trigger) <= 0) {
+ _DEBUG_ERROR("str_trigger is null");
+ goto return_part;
+ }
+
+ char *temp_alarm = NULL;
+ char *temp_alarm2 = NULL;
+ if((temp_alarm = strstr(str_trigger, "P0W")) != NULL) {
+ cal_type = CALENDAR_DATE_TYPE_ONTIME;
+ interval = 0;
+ }
+ else if((temp_alarm = strstr(str_trigger, "PT")) != NULL) {
+ if((temp_alarm2 = strstr(temp_alarm, "H")) != NULL) {
+ cal_type = CALENDAR_DATE_TYPE_HOUR;
+ str_interval = _get_value_by_token(str_trigger, "PT", "H");
+ interval = atoi(str_interval);
+ }
+ else if((temp_alarm2 = strstr(temp_alarm, "M")) != NULL) {
+ cal_type = CALENDAR_DATE_TYPE_MINUTE;
+ str_interval = _get_value_by_token(str_trigger, "PT", "M");
+ interval = atoi(str_interval);
+ }
+ else {
+ _DEBUG_ERROR("wrong type, temp_alarm = %s", temp_alarm);
+ goto return_part;
+ }
+ }
+ else if((temp_alarm = strstr(str_trigger, "P")) != NULL) {
+ if((temp_alarm2 = strstr(temp_alarm, "D")) != NULL) {
+ cal_type = CALENDAR_DATE_TYPE_DAY;
+ str_interval = _get_value_by_token(str_trigger, "P", "D");
+ interval = atoi(str_interval);
+ }
+ else if((temp_alarm2 = strstr(temp_alarm, "W")) != NULL) {
+ cal_type = CALENDAR_DATE_TYPE_WEEK;
+ str_interval = _get_value_by_token(str_trigger, "P", "W");
+ interval = atoi(str_interval);
+ }
+ else {
+ _DEBUG_ERROR("wrong type, temp_alarm = %s", temp_alarm);
+ goto return_part;
+ }
+ }
+ else {
+ _DEBUG_ERROR("wrong type, temp_alarm = %s", temp_alarm);
+ goto return_part;
+ }
+
+ str_new_alarm = _calculate_date_time(origin, interval, cal_type);
+ if (str_new_alarm == NULL || strlen(str_new_alarm) <= 0) {
+ _DEBUG_ERROR("str_new_alarm is null");
+ goto return_part;
+ }
+
+ _DEBUG_INFO("str_new_alarm = %s", str_new_alarm);
+ _DEBUG_INFO("str_origin_alarm = %s", str_origin_alarm);
+
+ char *new_agent_data = _replace_string(origin, str_origin_alarm, str_new_alarm);
+ origin = NULL;
+ origin = new_agent_data;
+
+return_part:
+
+ if (str_trigger) {
+ free(str_trigger);
+ str_trigger = NULL;
+ }
+ if (str_customized_trigger) {
+ free(str_customized_trigger);
+ str_customized_trigger = NULL;
+ }
+ if (str_new_alarm) {
+ free(str_new_alarm);
+ str_new_alarm = NULL;
+ }
+ if (str_interval) {
+ free(str_interval);
+ str_interval = NULL;
+ }
+
+ _INNER_FUNC_EXIT;
+ _DEBUG_INFO("origin = %s", origin);
+ return origin;
+}
+
+
+static char * _calculate_date_time(char *origin, int value, calendar_date_type_e type)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if(origin == NULL, NULL, "origin is NULL");
+
+ _DEBUG_INFO("origin = %s", origin);
+ _DEBUG_INFO("value = %d", value);
+
+ UCalendar *ucal = NULL;
+ char *start_time = NULL;
+ char *new_date_time = NULL;
+ char *start_date_loc = NULL;
+ if ((start_date_loc = strstr(origin, DTSTART_KEYWORD)) == NULL) {
+ _DEBUG_ERROR("start_date_loc is null");
+ goto return_part;
+ }
+
+ char str_year[5] = {0,};
+ char str_month[3] = {0,};
+ char str_date[3] = {0,};
+ char str_hour[3] = {0,};
+ char str_minute[3] = {0,};
+ char str_second[3] = {0,};
+
+ /* example) 20130124T000000Z\r\n = 2013 01 24 T 00 00 00 Z \r\n */
+ strncpy(str_year, start_date_loc + strlen(DTSTART_KEYWORD), 4);
+ strncpy(str_month, start_date_loc + strlen(DTSTART_KEYWORD) + 4, 2);
+ strncpy(str_date, start_date_loc + strlen(DTSTART_KEYWORD) + 4 + 2, 2);
+ strncpy(str_hour, start_date_loc + strlen(DTSTART_KEYWORD) + 4 + 2 + 2 + 1, 2);
+ strncpy(str_minute, start_date_loc + strlen(DTSTART_KEYWORD) + 4 + 2 + 2 + 1 + 2, 2);
+ strncpy(str_second, start_date_loc + strlen(DTSTART_KEYWORD) + 4 + 2 + 2 + 1 + 2 + 2, 2);
+
+ int year = atoi(str_year);
+ int month = atoi(str_month);
+ int date = atoi(str_date);
+ int hour = atoi(str_hour);
+ int minute = atoi(str_minute);
+ int second = atoi(str_second);
+ long long int date_time = 0;
+
+ start_time = (char *)calloc(20, sizeof(char));
+ if (start_time == NULL) {
+ _DEBUG_ERROR("start_time is null");
+ goto return_part;
+ }
+
+ snprintf(start_time, 20, "%04d%02d%02dT%02d%02d%02dZ\r\n", year, month, date, hour, minute, second);
+ _DEBUG_INFO("start_time = %s", start_time);
+
+ UErrorCode status = U_ZERO_ERROR;
+ ucal = ucal_open(0, -1, uloc_getDefault(), UCAL_TRADITIONAL, &status);
+ if (U_FAILURE(status)) {
+ _DEBUG_ERROR("ucal_open failed (%s)", u_errorName(status));
+ goto return_part;
+ }
+
+ ucal_setAttribute(ucal, UCAL_LENIENT, 1);
+ ucal_setDateTime(ucal, year, month - 1, date, hour, minute, second, &status);
+ date_time = ucal_getMillis(ucal, &status);
+
+ switch (type) {
+ case CALENDAR_DATE_TYPE_ONTIME:
+ _DEBUG_INFO("CALENDAR_DATE_TYPE_ONTIME");
+ date_time = date_time / 1000;
+ break;
+ case CALENDAR_DATE_TYPE_WEEK:
+ _DEBUG_INFO("CALENDAR_DATE_TYPE_WEEK");
+ date_time = date_time / 1000;
+ date_time = date_time - (value*60*60*24*7);
+ break;
+ case CALENDAR_DATE_TYPE_DAY:
+ _DEBUG_INFO("CALENDAR_DATE_TYPE_DAY");
+ date_time = date_time / 1000;
+ date_time = date_time - (value*60*60*24);
+ break;
+ case CALENDAR_DATE_TYPE_HOUR:
+ _DEBUG_INFO("CALENDAR_DATE_TYPE_HOUR");
+ date_time = date_time / 1000;
+ date_time = date_time - (value*60*60);
+ break;
+ case CALENDAR_DATE_TYPE_MINUTE:
+ _DEBUG_INFO("CALENDAR_DATE_TYPE_MINUTE");
+ date_time = date_time / 1000;
+ date_time = date_time - (value*60);
+ break;
+ default:
+ _DEBUG_ERROR("%d is not supported type", type);
+ goto return_part;
+ break;
+ }
+
+ if (U_FAILURE(status)) {
+ _DEBUG_ERROR("ucal_setDateTime failed (%s)", u_errorName(status));
+ goto return_part;
+ }
+
+ ucal_setMillis(ucal, (date_time * 1000), &status);
+
+ year = month = date = hour = minute = second = 0;
+ year = ucal_get(ucal, UCAL_YEAR, &status);
+ month = ucal_get(ucal, UCAL_MONTH, &status) + 1;
+ date = ucal_get(ucal, UCAL_DATE, &status);
+ hour = ucal_get(ucal, UCAL_HOUR_OF_DAY, &status);
+ minute = ucal_get(ucal, UCAL_MINUTE, &status);
+ second = ucal_get(ucal, UCAL_SECOND, &status);
+
+ new_date_time = (char *)calloc(30, sizeof(char));
+ if (new_date_time == NULL) {
+ _DEBUG_ERROR("new_date_time is null");
+ goto return_part;
+ }
+
+ snprintf(new_date_time, 30, "AALARM:%04d%02d%02dT%02d%02d%02dZ\r\n", year, month, date, hour, minute, second);
+ _DEBUG_INFO("new_date_time = %s", new_date_time);
+
+return_part:
+ _DEBUG_INFO("return_part");
+
+ if(start_time) {
+ free(start_time);
+ start_time = NULL;
+ }
+ if(ucal) {
+ ucal_close(ucal);
+ ucal = NULL;
+ }
+
+ _INNER_FUNC_EXIT;
+ return new_date_time;
+}
+
+#endif
+
+char * get_value_by_token(const char *src, const char *token, const char *end_of_token)
+{
+ _INNER_FUNC_ENTER;
+ if (src == NULL || strlen(src) <= 0) {
+ _DEBUG_ERROR("src is null");
+ return NULL;
+ }
+
+ char *token_loc = NULL;
+ char *str_output = NULL;
+
+ if ((token_loc = strstr(src, token)) != NULL) {
+ char *str_temp = strstr(token_loc, end_of_token);
+ if (str_temp != NULL) {
+ _DEBUG_INFO("token = %s", token);
+ _DEBUG_INFO("str_temp = %s", str_temp);
+ int ret_str_length = strlen(token_loc) - strlen(token) - strlen(str_temp);
+ if (ret_str_length <= 0) {
+ _DEBUG_ERROR("ret_str_length(%d) <= 0", ret_str_length);
+ goto return_part;
+ }
+ str_output = (char *)calloc(ret_str_length, sizeof(char));
+ if (str_output == NULL) {
+ _DEBUG_ERROR("calloc failed");
+ goto return_part;
+ }
+ memcpy(str_output, token_loc + strlen(token), ret_str_length);
+ }
+ }
+
+return_part:
+ _INNER_FUNC_EXIT;
+ return str_output;
+}
+
+char * replace_string(char *origin, const char *src, const char *dest)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((origin == NULL || strlen(origin) <= 0), NULL, "origin is NULL");
+ retvm_if((src == NULL || strlen(src) <= 0), NULL, "src is NULL");
+ retvm_if((dest == NULL || strlen(dest) <= 0), NULL, "dest is NULL");
+
+ _DEBUG_INFO("origin = %s", origin);
+ _DEBUG_INFO("src = %s", src);
+ _DEBUG_INFO("dest = %s", dest);
+
+ char *str_top = NULL;
+
+ if ((str_top = strstr(origin, src)) == NULL) {
+ _DEBUG_INFO("%s is not founed", src);
+ return origin;
+ }
+
+ int top_length = strlen(origin) - strlen(str_top);
+ int middle_length = strlen(dest);
+ int down_length = strlen(origin) - top_length - strlen(src);
+ int new_str_length = top_length + middle_length + down_length + 1;
+ if (new_str_length <= 0) {
+ _DEBUG_ERROR("new_str_length(%d) <= 0", new_str_length);
+ return origin;
+ }
+ char *new_str = (char *)calloc(new_str_length, sizeof(char));
+ if (new_str == NULL) {
+ _DEBUG_ERROR("calloc is failed.");
+ return origin;
+ }
+
+ memset(new_str, 0, new_str_length);
+ memcpy(new_str, origin, top_length);
+ memcpy(new_str + top_length, dest, middle_length);
+ memcpy(new_str + top_length + middle_length, origin + top_length + strlen(src), down_length);
+
+ if (origin != NULL) {
+ free(origin);
+ origin = NULL;
+ }
+
+ _DEBUG_INFO("new_str = %s", new_str);
+ _INNER_FUNC_EXIT;
+ return new_str;
+}
+
+char * remove_timezone(char *origin)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if((origin == NULL || strlen(origin) <= 0), NULL, "origin is NULL");
+
+ _DEBUG_INFO("origin = %s", origin);
+
+ char *str_timezone = NULL;
+ char *str_temp = NULL;
+
+ if ((str_temp = strstr(origin, "\r\nDTSTART;TZID=")) != NULL) {
+ _DEBUG_INFO("str_temp = %s", str_temp);
+ str_timezone = get_value_by_token(str_temp, "\r\nDTSTART", ":");
+ _DEBUG_INFO("str_timezone = %s", str_timezone);
+ strcat(str_timezone, ":");
+ _DEBUG_INFO("str_timezone = %s", str_timezone);
+ origin = replace_string(origin, str_timezone, ":");
+
+ if (str_timezone)
+ free(str_timezone);
+ str_timezone = NULL;
+ }
+
+ if ((str_temp = strstr(origin, "\r\nDUE;TZID=")) != NULL) {
+ _DEBUG_INFO("str_temp = %s", str_temp);
+ str_timezone = get_value_by_token(str_temp, "\r\nDUE", ":");
+ _DEBUG_INFO("str_timezone = %s", str_timezone);
+ strcat(str_timezone, ":");
+ _DEBUG_INFO("str_timezone = %s", str_timezone);
+ origin = replace_string(origin, str_timezone, ":");
+
+ if (str_timezone)
+ free(str_timezone);
+ str_timezone = NULL;
+ }
+
+ _DEBUG_INFO("origin = %s", origin);
+ _INNER_FUNC_EXIT;
+ return origin;
+}
+
+void insert_allday_data(const char *origin, calendar_record_h calendar_record)
+{
+ _INNER_FUNC_ENTER;
+ retm_if((origin == NULL || strlen(origin) <= 0), "origin is NULL");
+ retm_if(calendar_record == NULL, "calendar_record is NULL");
+
+ int service_ret = CALENDAR_ERROR_NONE;
+ char *uri = NULL;
+
+ service_ret = calendar_record_get_uri_p(calendar_record, &uri);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_uri_p() Fail! : err[%d]", service_ret);
+ goto return_part;
+ }
+
+ if (strncmp(uri, _calendar_todo._uri, strlen(_calendar_todo._uri))) {
+ _DEBUG_ERROR("this is not todo");
+ goto return_part;
+ }
+
+ calendar_time_s cal_time_start = { 0, };
+ calendar_time_s cal_time_end = { 0, };
+ int year = 0;
+ int month = 0;
+ int day = 0;
+
+ service_ret = calendar_record_get_caltime(calendar_record, _calendar_todo.start_time, &cal_time_start);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_caltime() Fail: err[%d]", service_ret);
+ goto return_part;
+ }
+
+ char *start_date_loc = NULL;
+ if ((start_date_loc = strstr(origin, DTSTART_KEYWORD)) == NULL) {
+ _DEBUG_ERROR("start_date_loc is null");
+ goto return_part;
+ }
+
+ char str_year_start[5] = {0,};
+ char str_month_start[3] = {0,};
+ char str_date_start[3] = {0,};
+
+ /* example) 20130124T000000Z\r\n = 2013 01 24 T 00 00 00 Z \r\n */
+ strncpy(str_year_start, start_date_loc + strlen(DTSTART_KEYWORD), 4);
+ strncpy(str_month_start, start_date_loc + strlen(DTSTART_KEYWORD) + 4, 2);
+ strncpy(str_date_start, start_date_loc + strlen(DTSTART_KEYWORD) + 4 + 2, 2);
+
+ year = atoi(str_year_start);
+ month = atoi(str_month_start);
+ day = atoi(str_date_start);
+
+ _DEBUG_INFO("start time : year = %d, month = %d, day = %d", year, month, day);
+ cal_time_start.type = CALENDAR_TIME_LOCALTIME;
+ cal_time_start.time.date.year = year;
+ cal_time_start.time.date.month = month;
+ cal_time_start.time.date.mday = day;
+
+ service_ret = calendar_record_set_caltime(calendar_record, _calendar_todo.start_time, cal_time_start);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_set_caltime() Fail: err[%d]", service_ret);
+ goto return_part;
+ }
+
+ service_ret = calendar_record_get_caltime(calendar_record, _calendar_todo.due_time, &cal_time_end);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_caltime() Fail: err[%d]", service_ret);
+ goto return_part;
+ }
+
+ char *end_date_loc = NULL;
+ if ((end_date_loc = strstr(origin, DTEND_KEYWORD)) == NULL) {
+ _DEBUG_ERROR("end_date_loc is null");
+ goto return_part;
+ }
+
+ char str_year_end[5] = {0,};
+ char str_month_end[3] = {0,};
+ char str_date_end[3] = {0,};
+
+ /* example) 20130124T000000Z\r\n = 2013 01 24 T 00 00 00 Z \r\n */
+ strncpy(str_year_end, end_date_loc + strlen(DTEND_KEYWORD), 4);
+ strncpy(str_month_end, end_date_loc + strlen(DTEND_KEYWORD) + 4, 2);
+ strncpy(str_date_end, end_date_loc + strlen(DTEND_KEYWORD) + 4 + 2, 2);
+
+ year = atoi(str_year_end);
+ month = atoi(str_month_end);
+ day = atoi(str_date_end);
+
+ _DEBUG_INFO("end time : year = %d, month = %d, day = %d", year, month, day);
+ cal_time_end.type = CALENDAR_TIME_LOCALTIME;
+ cal_time_end.time.date.year = year;
+ cal_time_end.time.date.month = month;
+ cal_time_end.time.date.mday = day;
+
+ service_ret = calendar_record_set_caltime(calendar_record, _calendar_todo.due_time, cal_time_end);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_set_caltime() Fail: err[%d]", service_ret);
+ goto return_part;
+ }
+
+return_part:
+ _INNER_FUNC_EXIT;
+ return;
+}
+
+EXPORT_API char * has_image_import(const char *origin)
+{
+ _INNER_FUNC_ENTER;
+
+ char *temp_image_path = NULL;
+ char *image_path = NULL;
+
+ if (strstr(origin, IMAGE_KEYWORD_PREFIX_PHOTO) == NULL && strstr(origin, IMAGE_KEYWORD_PREFIX_SNOTE) == NULL) {
+ _DEBUG_INFO("this calendar has not an image");
+ goto return_part;
+ }
+
+ temp_image_path = get_value_by_token(origin, IMAGE_KEYWORD_BEGIN_PATH, IMAGE_KEYWORD_END_PATH);
+
+ if (strstr(temp_image_path, INTERNAL_MEMORY_CONVERTED) != NULL) {
+ image_path = replace_string(temp_image_path, INTERNAL_MEMORY_CONVERTED, INTERNAL_MEMORY_ORIGIN);
+ }
+ else if (strstr(temp_image_path, EXTERNAL_MEMORY_CONVERTED) != NULL) {
+ image_path = replace_string(temp_image_path, EXTERNAL_MEMORY_CONVERTED, EXTERNAL_MEMORY_ORIGIN);
+ }
+ else if (strstr(temp_image_path, SNOTE_MEMORY_ORIGIN) != NULL) {
+ image_path = strdup(temp_image_path);
+ }
+ else {
+ _DEBUG_ERROR("there is an error. origin = %s", origin);
+ goto return_part;
+ }
+
+return_part:
+ if (image_path)
+ _DEBUG_INFO("image_path = %s", image_path);
+ _INNER_FUNC_EXIT;
+ return image_path;
+}
+
+EXPORT_API char * has_image_export(calendar_record_h cal_record)
+{
+ _INNER_FUNC_ENTER;
+
+ calendar_record_h image_record = NULL;
+ unsigned int child_record_count = 0;
+ int i = 0;
+ int service_ret = CALENDAR_ERROR_NONE;
+ char *image_key = NULL;
+ char *image_path = NULL;
+
+ char *uri = NULL;
+ service_ret = calendar_record_get_uri_p(cal_record, &uri);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_uri_p() Fail! : err[%d]", service_ret);
+ goto return_part;
+ }
+ _DEBUG_INFO("uri = %s", uri);
+ _DEBUG_INFO("_calendar_todo.uri = %s", _calendar_todo._uri);
+
+ service_ret = calendar_record_get_child_record_count(cal_record, _calendar_todo.extended, &child_record_count);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_child_record_count() Fail: err[%d]", service_ret);
+ goto return_part;
+ }
+
+ for (i = 0; i < child_record_count; i++) {
+ service_ret = calendar_record_get_child_record_at_p(cal_record, _calendar_todo.extended, i, &image_record);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_child_record_at_p() Fail: err[%d]", service_ret);
+ goto return_part;
+ }
+
+ service_ret = calendar_record_get_str_p(image_record, _calendar_extended_property.key, &image_key);
+ if (service_ret != CALENDAR_ERROR_NONE || image_key == NULL || strlen(image_key) <= 0) {
+ _DEBUG_ERROR("calendar_record_get_str_p is failed(%d)", service_ret);
+ goto return_part;
+ }
+
+ if (strcmp(image_key, CALENDAR_IMAGE_KEYWORD_SNOTE) == 0 || strcmp(image_key, CALENDAR_IMAGE_KEYWORD_PHOTO) == 0) {
+ _DEBUG_INFO("image is founded. image_key = %s", image_key);
+ service_ret = calendar_record_get_str(image_record, _calendar_extended_property.value, &image_path);
+ if (service_ret != CALENDAR_ERROR_NONE || image_path == NULL || strlen(image_path) <= 0) {
+ _DEBUG_ERROR("calendar_record_get_str_p is failed(%d)", service_ret);
+ image_path = NULL;
+ goto return_part;
+ }
+ _DEBUG_INFO("image_path = %s", image_path);
+ continue;
+ }
+ }
+
+return_part:
+ _INNER_FUNC_EXIT;
+ return image_path;
+}
+
+char * replace_max_rrule_data(char *origin)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if(origin == NULL, origin, "origin is NULL.");
+
+ char *temp = NULL;
+ char *temp_rrule = NULL;
+ char *str_old_rrule = NULL;
+ char *str_new_rrule = NULL;
+
+ if ((temp = strstr(origin, RRULE_KEYWORD)) == NULL) {
+ _DEBUG_INFO("this vcalendar hasn't rrule data");
+ goto return_part;
+ }
+
+ str_old_rrule = get_value_by_token(temp+2, "RRULE:", "\r\n");// '2' means strlen("\r\n")
+ if (str_old_rrule == NULL) {
+ _DEBUG_ERROR("str_old_rrule is null");
+ goto return_part;
+ }
+
+ if (strstr(str_old_rrule, MAX_RRULE_DATE_KEYWORD) == NULL) {
+ _DEBUG_INFO("this vcalendar has rrule data, But it's not until=NONE rrule");
+ goto return_part;
+ }
+ _DEBUG_INFO("this vcalendar has until=NONE rrule");
+
+ temp_rrule = get_value_by_token(temp, RRULE_KEYWORD, MAX_RRULE_DATE_KEYWORD);
+ if (temp_rrule == NULL) {
+ _DEBUG_ERROR("temp_rrule is null");
+ goto return_part;
+ }
+
+ str_new_rrule = (char *)calloc(strlen(temp_rrule)+2, sizeof(char));
+ if (str_new_rrule == NULL) {
+ _DEBUG_ERROR("str_new_rrule calloc failed");
+ goto return_part;
+ }
+
+ // every eternal rrule data must have '#0' at the end of string (Calendar-Svc recommend)
+ snprintf(str_new_rrule, strlen(temp_rrule)+2, "%s#0", temp_rrule);
+ origin = replace_string(origin, str_old_rrule, str_new_rrule);
+
+return_part:
+ if(str_old_rrule) {
+ free(str_old_rrule);
+ str_old_rrule = NULL;
+ }
+ if(str_new_rrule) {
+ free(str_new_rrule);
+ str_new_rrule = NULL;
+ }
+ _INNER_FUNC_EXIT;
+ _DEBUG_INFO("origin = %s", origin);
+ return origin;
+}
+
+char * replace_image_data(char *origin, char *image_path)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if(origin == NULL, origin, "origin is NULL.");
+ retvm_if(image_path == NULL, origin, "image_path is NULL.");
+
+ int image_path_length = 500;
+ char *str_temp_image_info = NULL;
+ char *str_image_info = NULL;
+ char *str_image_tag = NULL;
+
+ _DEBUG_INFO("origin = %s", origin);
+ _DEBUG_INFO("image_path = %s", image_path);
+
+ if (strstr(image_path, INTERNAL_MEMORY_ORIGIN) != NULL) {
+ str_temp_image_info = replace_string(image_path, INTERNAL_MEMORY_ORIGIN, INTERNAL_MEMORY_CONVERTED);
+ str_image_tag = strdup("X-SS-ATTACH-IMAGE");
+ }
+ else if (strstr(image_path, EXTERNAL_MEMORY_ORIGIN) != NULL) {
+ str_temp_image_info = replace_string(image_path, EXTERNAL_MEMORY_ORIGIN, EXTERNAL_MEMORY_CONVERTED);
+ str_image_tag = strdup("X-SS-ATTACH-IMAGE");
+ }
+ else if (strstr(image_path, SNOTE_MEMORY_ORIGIN) != NULL) {
+ str_temp_image_info = strdup(image_path);
+ //str_image_tag = strdup("X-SS-ATTACH-SNOTE");
+ str_image_tag = strdup("X-SS-ATTACH-IMAGE");
+ }
+ else {
+ _DEBUG_ERROR("there is an error. image_path = %s", image_path);
+ goto return_part;
+ }
+
+ if (strstr(origin, END_VTODO_KEYWORD) == NULL) {
+ _DEBUG_ERROR("this data is wrong format. origin = %s", origin);
+ goto return_part;
+ }
+
+ if (image_path_length <= 0) {
+ _DEBUG_ERROR("image_path_length(%d) <= 0", image_path_length);
+ goto return_part;
+ }
+ str_image_info = (char *)calloc(image_path_length, sizeof(char));
+ if (str_image_info == NULL) {
+ _DEBUG_ERROR("str_image_info calloc failed");
+ goto return_part;
+ }
+
+ snprintf(str_image_info, image_path_length, "\r\n%s;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:NAME=3Dnull=3BPATH=3D%s=3BDATE=3D%s", str_image_tag, str_temp_image_info, END_VTODO_KEYWORD);
+
+ char *new_agent_data = replace_string(origin, END_VTODO_KEYWORD, str_image_info);
+ origin = NULL;
+ origin = new_agent_data;
+
+return_part:
+
+ if (str_image_info) {
+ free(str_image_info);
+ str_image_info = NULL;
+ }
+ if (str_image_tag) {
+ free(str_image_tag);
+ str_image_tag = NULL;
+ }
+ if (str_temp_image_info) {
+ free(str_temp_image_info);
+ str_temp_image_info = NULL;
+ }
+
+ _INNER_FUNC_EXIT;
+ _DEBUG_INFO("origin = %s", origin);
+ return origin;
+}
+
+// SLP Phone = high:2, normal:4 low:8 NONE:1
+// Kies = high : 1 normal : 2 low : 3
+char * replace_priority_data(char *origin, bool is_phone_to_kies)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if(origin == NULL, origin, "origin is NULL.");
+ _DEBUG_INFO("origin = %s", origin);
+
+ if (is_phone_to_kies) {
+ _DEBUG_INFO("phone to kies converting");
+ if (strstr(origin, "\r\nPRIORITY:2") != NULL) {
+ // high priority
+ origin = replace_string(origin, "\r\nPRIORITY:2", "\r\nPRIORITY:1");
+ }
+ else if (strstr(origin, "\r\nPRIORITY:4") != NULL) {
+ // normal priority
+ origin = replace_string(origin, "\r\nPRIORITY:4", "\r\nPRIORITY:2");
+ }
+ else if (strstr(origin, "\r\nPRIORITY:8") != NULL) {
+ // low priority
+ origin = replace_string(origin, "\r\nPRIORITY:8", "\r\nPRIORITY:3");
+ }
+ else {
+ _DEBUG_ERROR("there is an error. origin = %s", origin);
+ goto return_part;
+ }
+ }
+ else {
+ _DEBUG_INFO("kies to phone converting");
+ if (strstr(origin, "\r\nPRIORITY:1") != NULL) {
+ // high priority
+ origin = replace_string(origin, "\r\nPRIORITY:1", "\r\nPRIORITY:2");
+ }
+ else if (strstr(origin, "\r\nPRIORITY:2") != NULL) {
+ // normal priority
+ origin = replace_string(origin, "\r\nPRIORITY:2", "\r\nPRIORITY:4");
+ }
+ else if (strstr(origin, "\r\nPRIORITY:3") != NULL) {
+ // low priority
+ origin = replace_string(origin, "\r\nPRIORITY:3", "\r\nPRIORITY:8");
+ }
+ else {
+ _DEBUG_ERROR("there is an error. origin = %s", origin);
+ goto return_part;
+ }
+ }
+
+return_part:
+
+ _INNER_FUNC_EXIT;
+ _DEBUG_INFO("origin = %s", origin);
+ return origin;
+}
+
# calendar
calendar-service2
glib-2.0
+ icu-i18n
dlog)
#############################################
--- /dev/null
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IN_VCALENDAR_STRING_UTIL_H_
+#define IN_VCALENDAR_STRING_UTIL_H_
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <glib/gprintf.h>
+
+#include <calendar2.h>
+#include <calendar_types2.h>
+#include <unicode/ucal.h>
+#include <unicode/ustring.h>
+#include <unicode/ustdio.h>
+#include <unicode/udat.h>
+#include <sys/types.h>
+
+#include "utility/sync_util.h"
+#include "data-adapter/error.h"
+
+typedef enum cal_date_type {
+ CALENDAR_DATE_TYPE_ONTIME = 0,
+ CALENDAR_DATE_TYPE_YEAR,
+ CALENDAR_DATE_TYPE_MONTH,
+ CALENDAR_DATE_TYPE_WEEK,
+ CALENDAR_DATE_TYPE_DAY,
+ CALENDAR_DATE_TYPE_HOUR,
+ CALENDAR_DATE_TYPE_MINUTE,
+ CALENDAR_DATE_TYPE_SECOND,
+} calendar_date_type_e;
+
+typedef enum cal_exdate_type {
+ CALENDAR_EXDATE_TYPE_NONE = 0,
+ CALENDAR_EXDATE_TYPE_DELETED,
+ CALENDAR_EXDATE_TYPE_UPDATED,
+} calendar_exdate_type_e;
+
+typedef struct sync_agent_calendar_exdate_s sync_agent_calendar_exdate_t;
+
+struct sync_agent_calendar_exdate_s {
+ calendar_exdate_type_e exdate_type;
+ int exdate_count;
+ GList *exdate_list;
+};
+
+#define RRULE_KEYWORD "\r\nRRULE:"
+#define RRULE_KEYWORD_FREQ_DAILY "\r\nRRULE:FREQ=DAILY"
+#define RRULE_KEYWORD_FREQ_WEEKLY "\r\nRRULE:FREQ=WEEKLY"
+#define RRULE_KEYWORD_FREQ_MONTHLY "\r\nRRULE:FREQ=MONTHLY"
+#define RRULE_KEYWORD_FREQ_YEARLY "\r\nRRULE:FREQ=YEARLY"
+#define RRULE_KEYWORD_INTERVAL "INTERVAL="
+#define RRULE_KEYWORD_BYDAY "BYDAY="
+#define RRULE_KEYWORD_BYMONTH "BYMONTH="
+#define RRULE_KEYWORD_BYMONTHDAY "BYMONTHDAY="
+#define RRULE_KEYWORD_UNTIL "UNTIL="
+#define RRULE_KEYWORD_COUNT "COUNT="
+#define DTSTART_KEYWORD "\r\nDTSTART"
+#define DTEND_KEYWORD "\r\nDTEND"
+#define BEGIN_ALARM_KEYWORD "\r\nBEGIN:VALARM"
+#define AALARM_KEYWORD "\r\nAALARM"
+#define END_VEVENT_KEYWORD "\r\nEND:VEVENT\r\n"
+#define SUMMARY_KEYWORD "\r\nSUMMARY:"
+#define MAX_RRULE_DATE_KEYWORD "20361231T000000Z"
+#define MAX_DUE_DATE_KEYWORD "\r\nDUE:20381231T000000Z\r\n" // refer to calendar info (min ~ max date)
+#define EXTYPE_DELETE_KEYWORD "X-EXTYPE:1"
+#define EXTYPE_UPDATE_KEYWORD "X-EXTYPE:2"
+#define CR_EXTYPE_DELETE_KEYWORD "\r\nX-EXTYPE:1" // carrige return + EXTYPE_DELETE_KEYWORD
+#define IMPORT_EXTYPE_DELETE_KEYWORD "\r\nX-EXTYPE:1\r\nEXDATE:"
+#define EXDATE_KEYWORD "\r\nEXDATE:"
+
+#define CALENDAR_IMAGE_KEYWORD_SNOTE "snote" // refer to Cal-svc.h (calendar\include)
+#define CALENDAR_IMAGE_KEYWORD_PHOTO "photo" // refer to Cal-svc.h (calendar\include)
+#define IMAGE_KEYWORD_PREFIX_SNOTE "\r\nX-SS-ATTACH-SNOTE;"
+#define IMAGE_KEYWORD_PREFIX_PHOTO "\r\nX-SS-ATTACH-IMAGE;"
+#define IMAGE_KEYWORD_BEGIN_PATH "PATH=3D"
+#define IMAGE_KEYWORD_END_PATH "=3bDATE=3D\r\n"
+
+#define INTERNAL_MEMORY_ORIGIN "/opt/usr/media"
+#define INTERNAL_MEMORY_CONVERTED "Internal=3a"
+#define EXTERNAL_MEMORY_ORIGIN "/opt/storage/sdcard"
+#define EXTERNAL_MEMORY_CONVERTED "External=3a"
+#define SNOTE_MEMORY_ORIGIN "/opt/usr/apps/com.samsung.smemo/data/"
+
+#define EXDATE_LENGTH 16 // length of "20130211T000000Z"
+
+
+char * get_value_by_token(const char *src, const char *token, const char *end_of_token);
+char * replace_string(char *origin, const char *src, const char *dest);
+char * remove_timezone(char *origin);
+char * insert_exdate_data(const char *origin, sync_agent_calendar_exdate_t *exdate_struct, int index);
+void insert_allday_data(const char *origin, calendar_record_h calendar_record);
+char * has_image_import(const char *origin);
+char * has_image_export(calendar_record_h cal_record);
+void get_exdate_data(calendar_record_h cal_record, sync_agent_calendar_exdate_t *exdate_struct);
+char * replace_max_rrule_data(char *origin);
+char * replace_image_data(char *origin, char *image_path);
+sync_agent_da_return_e replace_exdate_data(const char *origin, calendar_record_h calendar_record);
+
+#endif /* IN_VCALENDAR_STRING_UTIL_H_ */
/*edited code for line beaker */
char *colon_loc_temp = colon_loc;
while (line_breaker_loc == NULL) {
- if(colon_loc_temp == NULL) {
- _DEBUG_ERROR("[encoding_util] colon_loc_temp is NULL !!\n");
- if(de_temp != NULL)
- free(de_temp);
- if (*de_src != NULL)
- free(*de_src);
- return 0;
- }
line_breaker_loc = strstr(colon_loc_temp, line_breaker); /* find "\r\n"'s location */
if (line_breaker_loc > colon_loc_temp && !strncmp(line_breaker_loc - 1, "=", 1)) {
colon_loc_temp = line_breaker_loc + 1;
#include <stdlib.h>
#include <glib/gprintf.h>
-#include "encoding_util.h"
-#ifdef old_api
-#include "calendar-svc-provider.h"
-#else
#include <calendar2.h>
#include <calendar_types2.h>
-#endif
-
-#include "in_datastore_info_vcalendar.h"
-/* for log */
#include "utility/sync_util.h"
-
#include "plugin/data_converter_interface.h"
+#include "encoding_util.h"
+#include "in_datastore_info_vcalendar.h"
+#include "vcalendar_string_util.h"
#ifndef EXPORT_API
#define EXPORT_API __attribute__ ((visibility("default")))
static int _free_obj_field_info(sync_agent_plugin_field_info_s * field_list, int count);
static int _set_obj_field_info(sync_agent_plugin_field_info_s ** field_list, int count, vcalendar_field_list_s * input_list);
-#ifdef old_api
-static sync_agent_da_return_e _convert_service_error_to_common_error(cal_error err);
-#else
static sync_agent_da_return_e _convert_service_error_to_common_error(calendar_error_e err);
-#endif
-#ifdef old_api
EXPORT_API sync_agent_da_return_e sync_agent_plugin_converter(const void *agent_data, void **service_data)
{
_EXTERN_FUNC_ENTER;
retvm_if(agent_data == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "agent_data is NULL. FAIL !!!");
- _DEBUG_INFO("[dc_vcalendar_plugIn] Start !!");
-
- sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
- int err = 0;
- cal_struct *temp_service_data = 0;
+ calendar_list_h calendar_list = NULL;
+ calendar_record_h temp_service_data = NULL;
const char *temp_agent_data = (const char *)agent_data;
+ char *image_path = has_image_import(temp_agent_data);
+ char *temp_image_path = NULL;
+ char *token = NULL;
+ char *temp = NULL;
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ int service_ret = CALENDAR_ERROR_NONE;
+ _DEBUG_INFO("temp_agent_data= %s", temp_agent_data);
- /* Temporary fix for KIES vCalendar X-ALLDAY tag : START */
- int allday = 0;
- if (strstr((char *)agent_data, "\r\nX-ALLDAY:SET") != NULL)
- allday = 1;
- /* Temporary fix for KIES vCalendar X-ALLDAY tag : END */
-
- if (temp_agent_data == NULL) {
- _DEBUG_ERROR("inputed temp_agent_data is null");
- return SYNC_AGENT_DA_ERRORS;
+ // 1. if the vcalendar has until : NONE rrule, then max rrule should be converted : it should be excuted before calendar_vcalendar_parse_to_calendar
+ if (strstr(temp_agent_data, RRULE_KEYWORD) != NULL) {
+ temp = strdup(temp_agent_data);
+ temp_agent_data = replace_max_rrule_data(temp);
+ temp = NULL;
}
- /*using new interface */
- GList *l, *schedules = NULL;
- err = calendar_svc_read_schedules(temp_agent_data, &schedules);
- if (err < CAL_SUCCESS) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_svc_read_schedules() Fail! err[%d]\n", err);
- ret = _convert_service_error_to_common_error(err);
+
+ service_ret = calendar_vcalendar_parse_to_calendar(temp_agent_data, &calendar_list);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_vcalendar_parse_to_calendar() Fail! err[%d]\n", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
*service_data = NULL;
- } else {
- if (schedules == NULL) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_svc_read_schedules() -> temp_service_data is null, err[%d] !!", err);
- return SYNC_AGENT_DA_ERRORS;
- }
- temp_service_data = schedules->data;
+ }
- err = calendar_svc_struct_set_str(temp_service_data, CALS_VALUE_TXT_DTSTART_TZID, "Asia/Seoul");
- if (err != CAL_SUCCESS) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_svc_struct_set_str() Fail! err[%d]\n", err);
- /*i think when set return fail then going throw input schesule */
- }
+ if (calendar_list == NULL) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_vcalendar_parse_to_calendar() -> temp_service_data is null, err[%d] !!", service_ret);
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto return_part;
+ }
+
+ service_ret = calendar_list_first(calendar_list);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_list_first() Fail! : err[%d]", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ }
- err = calendar_svc_struct_set_str(temp_service_data, CALS_VALUE_TXT_DTEND_TZID, "Asia/Seoul");
- if (err != CAL_SUCCESS) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_svc_struct_set_str() Fail! err[%d]\n", err);
- /*i think when set return fail then going throw input schesule */
+ do
+ {
+ char *uri = NULL;
+ service_ret = calendar_list_get_current_record_p(calendar_list, &temp_service_data);
+ if ((service_ret != CALENDAR_ERROR_NONE) || (temp_service_data == NULL)) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_list_get_current_record_p() Fail! : err[%d]", service_ret);
+ goto return_part;
}
- /* Temporary fix for KIES vCalendar X-ALLDAY tag : START */
-// if (allday) {
-// cal_struct *item = (cal_struct *) temp_service_data;
-//
-// _DEBUG_INFO(" CAL_VALUE_INT_ALL_DAY_EVENT = %d ", calendar_svc_struct_get_int(item, CAL_VALUE_INT_ALL_DAY_EVENT));
-//
-// if (!calendar_svc_struct_get_int(item, CAL_VALUE_INT_ALL_DAY_EVENT)) {
-// _DEBUG_INFO("[Debug] X-ALLDAY flag set in vCalendar, but not in calendar service structure after conversion !!!");
-// calendar_svc_struct_set_int(item, CAL_VALUE_INT_ALL_DAY_EVENT, 1);
-// }
-// }
- /* Temporary fix for KIES vCalendar X-ALLDAY tag : END */
-
- *service_data = (void *)temp_service_data;
- _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_svc_read_schedules() Success!\n");
-
- /*remove another calendar */
- l = schedules;
- l = g_list_next(l);
- while (l) {
- cal_struct *item = l->data;
- if (item == NULL) {
- l = g_list_next(l);
- continue;
- }
- l = g_list_next(l);
+ service_ret = calendar_record_get_uri_p(temp_service_data, &uri);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_uri_p() Fail! : err[%d]", service_ret);
+ goto return_part;
+ }
- calendar_svc_struct_free(&item);
+ if (!strncmp(uri, _calendar_event._uri, strlen(_calendar_event._uri))) {
+ _DEBUG_INFO("this is event");
+ break;
}
- }
+ else if (!strncmp(uri, _calendar_extended_property._uri, strlen(_calendar_extended_property._uri))) {
+ _DEBUG_INFO("this is extended");
+ continue;
+ }
+ else {
+ _DEBUG_INFO("%s is wrong uri", uri);
+ }
+ } while(calendar_list_next(calendar_list) != CALENDAR_ERROR_NO_DATA);
- _DEBUG_INFO("[dc_vcalendar_plugIn] End !!");
+ // 1. timezone setting : it should be excuted after calendar_vcalendar_parse_to_calendar
+ service_ret = calendar_record_set_str(temp_service_data, _calendar_event.start_tzid, "Asia/Seoul");
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_str() Fail! err[%d]\n", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ /*i think when set return fail then going throw input schedule */
+ }
- _EXTERN_FUNC_EXIT;
+ service_ret = calendar_record_set_str(temp_service_data, _calendar_event.end_tzid, "Asia/Seoul");
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_str() Fail! err[%d]\n", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ /*i think when set return fail then going throw input schedule */
+ }
- return ret;
-}
-#else
-EXPORT_API sync_agent_da_return_e sync_agent_plugin_converter(const void *agent_data, void **service_data)
-{
- _EXTERN_FUNC_ENTER;
+ // 2. "all day" setting : it should be excuted after calendar_vcalendar_parse_to_calendar
+ if (strstr((char *)agent_data, "\r\nX-ALLDAY:SET") != NULL) {
+ insert_allday_data((char *)agent_data, temp_service_data);
+ }
- retvm_if(agent_data == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "agent_data is NULL. FAIL !!!");
+ // 3. add image info : it should be excuted after calendar_vcalendar_parse_to_calendar
+ if( image_path != NULL ) {
+ _DEBUG_INFO("image is founded. %s", image_path);
+
+ ///////////////////////////////////// S Note temporary code ////////////////////////////
+ if (strstr(image_path, "=\r\n") != NULL) {
+ temp_image_path = get_value_by_token(image_path, "/opt/usr/apps/com.samsung.smemo/data/", "=\r\n");
+ _DEBUG_INFO("temp_image_path = %s", temp_image_path);
+ token = (char *)calloc(1000, sizeof(char));
+ if (token == NULL) {
+ _DEBUG_ERROR("token calloc() is failed");
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto return_part;
+ }
- _DEBUG_INFO("[dc_vcalendar_plugIn] Start !!");
+ snprintf(token, 1000, "%s=\r\n", temp_image_path);
+ _DEBUG_INFO("token = %s", token);
- sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
- int service_ret = CALENDAR_ERROR_NONE;
- calendar_record_h temp_service_data = NULL;
- const char *temp_agent_data = (const char *)agent_data;
+ temp = get_value_by_token(image_path, token, ".png");
- /* Temporary fix for KIES vCalendar X-ALLDAY tag : START */
- int allday = 0;
- if (strstr((char *)agent_data, "\r\nX-ALLDAY:SET") != NULL)
- allday = 1;
- /* Temporary fix for KIES vCalendar X-ALLDAY tag : END */
+ if (image_path) {
+ free(image_path);
+ image_path = NULL;
+ }
- if (temp_agent_data == NULL) {
- _DEBUG_ERROR("inputed temp_agent_data is null");
- return SYNC_AGENT_DA_ERRORS;
- }
- /*using new interface */
- calendar_list_h schedules = NULL;
+ image_path = (char *)calloc(1000, sizeof(char));
+ if (image_path == NULL) {
+ _DEBUG_ERROR("image_path is null");
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto return_part;
+ }
- service_ret = calendar_vcalendar_parse_to_calendar(temp_agent_data, &schedules);
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_vcalendar_parse_to_calendar() Fail! err[%d]\n", service_ret);
- ret = _convert_service_error_to_common_error(service_ret);
- *service_data = NULL;
- } else {
- if (schedules == NULL) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_vcalendar_parse_to_calendar() -> temp_service_data is null, err[%d] !!", service_ret);
- return SYNC_AGENT_DA_ERRORS;
+ snprintf(image_path, 1000, "/opt/usr/apps/com.samsung.smemo/data/%s%s.png", temp_image_path, temp);
+ _DEBUG_INFO("image_path = %s", image_path);
}
+ ///////////////////////////////////// S Note temporary code ////////////////////////////
- service_ret = calendar_list_first(schedules);
+ calendar_record_h image_record = NULL;
+
+ service_ret = calendar_record_create(_calendar_extended_property._uri, &image_record);
if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_list_first() Fail! : err[%d]", service_ret);
+ _DEBUG_ERROR("calendar_record_create() Fail! err[%d]\n", service_ret);
ret = _convert_service_error_to_common_error(service_ret);
}
- service_ret = calendar_list_get_current_record_p(schedules, &temp_service_data);
- if ((service_ret != CALENDAR_ERROR_NONE) && (temp_service_data == NULL)) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_list_get_current_record_p() Fail! : err[%d]", service_ret);
+ service_ret = calendar_record_set_str(image_record, _calendar_extended_property.key, CALENDAR_IMAGE_KEYWORD_PHOTO);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_set_str() Fail! err[%d]\n", service_ret);
ret = _convert_service_error_to_common_error(service_ret);
}
- service_ret = calendar_record_set_str(temp_service_data, _calendar_event.start_tzid, "Asia/Seoul");
+ service_ret = calendar_record_set_str(image_record, _calendar_extended_property.value, image_path);
if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_str() Fail! err[%d]\n", service_ret);
+ _DEBUG_ERROR("calendar_record_set_str() Fail! err[%d]\n", service_ret);
ret = _convert_service_error_to_common_error(service_ret);
- /*i think when set return fail then going throw input schedule */
}
- service_ret = calendar_record_set_str(temp_service_data, _calendar_event.end_tzid, "Asia/Seoul");
+ service_ret = calendar_record_add_child_record(temp_service_data, _calendar_event.extended, image_record);
if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_str() Fail! err[%d]\n", service_ret);
+ _DEBUG_ERROR("calendar_record_add_child_record() Fail! err[%d]\n", service_ret);
ret = _convert_service_error_to_common_error(service_ret);
- /*i think when set return fail then going throw input schedule */
- }
-
- *service_data = (void *)temp_service_data;
-
- _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_vcalendar_parse_to_calendar() Success!\n");
- if (schedules != NULL) {
- service_ret = calendar_list_destroy(schedules, false);
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", service_ret);
- }
- schedules = NULL;
}
}
- _DEBUG_INFO("[dc_vcalendar_plugIn] End !!");
-
- _EXTERN_FUNC_EXIT;
+ *service_data = (void *)temp_service_data;
+ _DEBUG_INFO("calendar_vcalendar_parse_to_calendar() Success!\n");
- return ret;
-}
-#endif
+return_part:
+ _DEBUG_INFO("return part");
-#ifdef old_api
-EXPORT_API sync_agent_da_return_e sync_agent_plugin_replace_converter(void *old_service_data, const void *agent_data, void **new_service_data)
-{
- _EXTERN_FUNC_ENTER;
-
- retvm_if(old_service_data == NULL, SYNC_AGENT_DA_ERRORS, "old_service_data is NULL. FAIL !!!");
- retvm_if(agent_data == NULL, SYNC_AGENT_DA_ERRORS, "agent_data is NULL. FAIL !!!");
-
- _DEBUG_INFO("[dc_vcalendar_plugIn] Start !!");
-
- sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
- int err = 0;
- cal_struct *temp_new_service_data = 0;
- cal_struct *temp_old_service_data = (cal_struct *) old_service_data;
- const char *temp_agent_data = (const char *)agent_data;
-
- /* Temporary fix for KIES vCalendar X-ALLDAY tag : START */
- int allday = 0;
-
- if (strstr((char *)agent_data, "\r\nX-ALLDAY:SET") != NULL)
- allday = 1;
- /* Temporary fix for KIES vCalendar X-ALLDAY tag : END */
-
- if (temp_agent_data == NULL) {
- _DEBUG_ERROR("inputed temp_agent_data is null");
- return SYNC_AGENT_DA_ERRORS;
- }
-
- /* convert */
- _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_svc_read_schedules !!");
-
- /*using new interface */
- GList *l, *schedules = NULL;
- err = calendar_svc_read_schedules(temp_agent_data, &schedules);
- if (err < CAL_SUCCESS) {
- _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_svc_read_schedules() Fail!\n");
- ret = _convert_service_error_to_common_error(err);
- *new_service_data = 0;
- } else {
- _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_svc_read_schedules() success!\n");
- temp_new_service_data = schedules->data;
-
- /*index moving */
- int n_cal_struct_index = calendar_svc_struct_get_int(temp_old_service_data, CAL_VALUE_INT_INDEX);
- err = calendar_svc_struct_set_int(temp_new_service_data, CAL_VALUE_INT_INDEX, n_cal_struct_index);
- if (err != CAL_SUCCESS) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_svc_struct_set_int() Fail! err[%d]\n", err);
- return SYNC_AGENT_DA_ERRORS;
- }
-
- err = calendar_svc_struct_set_str(temp_new_service_data, CALS_VALUE_TXT_DTSTART_TZID, "Asia/Seoul");
- if (err != CAL_SUCCESS) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_svc_struct_set_str() Fail! err[%d]\n", err);
- /*i think when set return fail then going throw input schesule */
- }
- /* Temporary fix for KIES vCalendar X-ALLDAY tag : START */
-// if (allday) {
-// cal_struct *item = (cal_struct *) temp_new_service_data;
-//
-// _DEBUG_INFO(" CAL_VALUE_INT_ALL_DAY_EVENT = %d ", calendar_svc_struct_get_int(item, CAL_VALUE_INT_ALL_DAY_EVENT));
-//
-// if (!calendar_svc_struct_get_int(item, CAL_VALUE_INT_ALL_DAY_EVENT)) {
-// _DEBUG_INFO("[Debug] X-ALLDAY flag set in vCalendar, but not in calendar service structure after conversion !!!");
-// calendar_svc_struct_set_int(item, CAL_VALUE_INT_ALL_DAY_EVENT, 1);
-// }
-// }
- /* Temporary fix for KIES vCalendar X-ALLDAY tag : END */
-
- /*remove another calendar */
- l = schedules;
- l = g_list_next(l);
- while (l) {
- cal_struct *item = l->data;
- if (item == NULL) {
- l = g_list_next(l);
- continue;
- }
- l = g_list_next(l);
-
- calendar_svc_struct_free(&item);
+ if (calendar_list != NULL) {
+ service_ret = calendar_list_destroy(calendar_list, false);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", service_ret);
}
-
- _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_svc_read_schedules() Success!\n");
- *new_service_data = (void *)temp_new_service_data;
+ calendar_list = NULL;
+ }
+ if (image_path) {
+ free(image_path);
+ image_path = NULL;
+ }
+ if (temp_image_path) {
+ free(temp_image_path);
+ temp_image_path = NULL;
+ }
+ if (token) {
+ free(token);
+ token = NULL;
+ }
+ if (temp) {
+ free(temp);
+ temp = NULL;
}
-
- /* memory free */
- if (temp_old_service_data != NULL)
- calendar_svc_struct_free(&temp_old_service_data);
-
- _DEBUG_INFO("[dc_vcalendar_plugIn] End !!");
_EXTERN_FUNC_EXIT;
-
return ret;
}
-#else
-sync_agent_da_return_e _temp_merge_record_new_to_old(calendar_record_h old_service_data, calendar_record_h new_service_data)
+sync_agent_da_return_e _vevent_merge_new_to_old(calendar_record_h old_service_data, calendar_record_h new_service_data)
{
_EXTERN_FUNC_ENTER;
retvm_if(old_service_data == NULL, SYNC_AGENT_DA_ERRORS, "old_service_data is NULL. FAIL !!!");
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
/*description */
- char *description = 0;
+ char *description = NULL;
service_ret = calendar_record_get_str_p(new_service_data, _calendar_event.description, &description);
if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get() Fail! err[%d]\n", service_ret);
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_str_p() Fail! err[%d]\n", service_ret);
return SYNC_AGENT_DA_ERRORS;
}
service_ret = calendar_record_set_str(old_service_data, _calendar_event.description, description);
if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set() Fail! err[%d]\n", service_ret);
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_str() Fail! err[%d]\n", service_ret);
return SYNC_AGENT_DA_ERRORS;
}
- /*st time */
+ /* start time */
calendar_time_s cal_time_st = { 0, };
service_ret = calendar_record_get_caltime(new_service_data, _calendar_event.start_time, &cal_time_st);
if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get() Fail! err[%d]\n", service_ret);
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_caltime() Fail! err[%d]\n", service_ret);
return SYNC_AGENT_DA_ERRORS;
}
service_ret = calendar_record_set_caltime(old_service_data, _calendar_event.start_time, cal_time_st);
if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set() Fail! err[%d]\n", service_ret);
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_caltime() Fail! err[%d]\n", service_ret);
return SYNC_AGENT_DA_ERRORS;
}
- /*end time */
+ /* end time */
calendar_time_s cal_time_ed = { 0, };
service_ret = calendar_record_get_caltime(new_service_data, _calendar_event.end_time, &cal_time_ed);
if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get() Fail! err[%d]\n", service_ret);
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_caltime() Fail! err[%d]\n", service_ret);
return SYNC_AGENT_DA_ERRORS;
}
service_ret = calendar_record_set_caltime(old_service_data, _calendar_event.end_time, cal_time_ed);
if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set() Fail! err[%d]\n", service_ret);
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_caltime() Fail! err[%d]\n", service_ret);
return SYNC_AGENT_DA_ERRORS;
}
- /*summary time */
+ /* summary */
char *summary = 0;
service_ret = calendar_record_get_str_p(new_service_data, _calendar_event.summary, &summary);
if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get() Fail! err[%d]\n", service_ret);
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_str_p() Fail! err[%d]\n", service_ret);
return SYNC_AGENT_DA_ERRORS;
}
service_ret = calendar_record_set_str(old_service_data, _calendar_event.summary, summary);
if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set() Fail! err[%d]\n", service_ret);
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_str() Fail! err[%d]\n", service_ret);
return SYNC_AGENT_DA_ERRORS;
}
- /*location time */
+ /* location */
char *location = 0;
service_ret = calendar_record_get_str_p(new_service_data, _calendar_event.location, &location);
if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get() Fail! err[%d]\n", service_ret);
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_str_p() Fail! err[%d]\n", service_ret);
return SYNC_AGENT_DA_ERRORS;
}
service_ret = calendar_record_set_str(old_service_data, _calendar_event.location, location);
if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set() Fail! err[%d]\n", service_ret);
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_str() Fail! err[%d]\n", service_ret);
return SYNC_AGENT_DA_ERRORS;
}
- _EXTERN_FUNC_EXIT;
- return ret;
-}
+ /* rrule */
+ int num = 0;
+ char *text = NULL;
+ calendar_time_s caltime = {0};
-EXPORT_API sync_agent_da_return_e sync_agent_plugin_replace_converter(void *old_service_data, const void *agent_data, void **new_service_data)
-{
- _EXTERN_FUNC_ENTER;
+ service_ret = calendar_record_get_int(new_service_data, _calendar_event.freq, &num);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_int(freq) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_int(old_service_data, _calendar_event.freq, num);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_int(freq) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
- retvm_if(old_service_data == NULL, SYNC_AGENT_DA_ERRORS, "old_service_data is NULL. FAIL !!!");
- retvm_if(agent_data == NULL, SYNC_AGENT_DA_ERRORS, "agent_data is NULL. FAIL !!!");
+ service_ret = calendar_record_get_int(new_service_data, _calendar_event.range_type, &num);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_int(range_type) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_int(old_service_data, _calendar_event.range_type, num);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_int(range_type) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
- _DEBUG_INFO("[dc_vcalendar_plugIn] Start !!");
+ service_ret = calendar_record_get_caltime(new_service_data, _calendar_event.until_time, &caltime);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_caltime(until_time) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_caltime(old_service_data, _calendar_event.until_time, caltime);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_caltime(until_time) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
- sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
- int service_ret = CALENDAR_ERROR_NONE;
- calendar_record_h temp_new_service_data = NULL;
- calendar_record_h temp_old_service_data = (calendar_record_h) old_service_data;
- const char *temp_agent_data = (const char *)agent_data;
+ service_ret = calendar_record_get_int(new_service_data, _calendar_event.count, &num);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_int(count) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_int(old_service_data, _calendar_event.count, num);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_int(count) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
- /* Temporary fix for KIES vCalendar X-ALLDAY tag : START */
- int allday = 0;
+ service_ret = calendar_record_get_int(new_service_data, _calendar_event.interval, &num);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_int(interval) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_int(old_service_data, _calendar_event.interval, num);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_int(interval) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
- if (strstr((char *)agent_data, "\r\nX-ALLDAY:SET") != NULL)
- allday = 1;
- /* Temporary fix for KIES vCalendar X-ALLDAY tag : END */
+ service_ret = calendar_record_get_str(new_service_data, _calendar_event.bysecond, &text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_str(bysecond) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_str(old_service_data, _calendar_event.bysecond, text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_str(bysecond) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
- if (temp_agent_data == NULL) {
- _DEBUG_ERROR("inputed temp_agent_data is null");
+ service_ret = calendar_record_get_str(new_service_data, _calendar_event.byminute, &text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_str(byminute) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_str(old_service_data, _calendar_event.byminute, text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_str(byminute) Fail! err[%d]\n", service_ret);
return SYNC_AGENT_DA_ERRORS;
}
- /* convert */
- _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_svc_read_schedules !!");
+ service_ret = calendar_record_get_str(new_service_data, _calendar_event.byhour, &text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_str(byhour) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_str(old_service_data, _calendar_event.byhour, text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_str(byhour) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
- /*using new interface */
- calendar_list_h schedules = NULL;
- service_ret = calendar_vcalendar_parse_to_calendar(temp_agent_data, &schedules);
+ service_ret = calendar_record_get_str(new_service_data, _calendar_event.byday, &text);
if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_vcalendar_parse_to_calendar() Fail! err[%d]\n", service_ret);
- ret = _convert_service_error_to_common_error(service_ret);
- *new_service_data = NULL;
- } else {
- _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_vcalendar_parse_to_calendar() success!\n");
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_str(byday) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_str(old_service_data, _calendar_event.byday, text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_str(byday) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_str(new_service_data, _calendar_event.bymonthday, &text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_str(bymonthday) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_str(old_service_data, _calendar_event.bymonthday, text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_str(bymonthday) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_str(new_service_data, _calendar_event.byyearday, &text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_str(byyearday) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_str(old_service_data, _calendar_event.byyearday, text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_str(byyearday) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
- service_ret = calendar_list_first(schedules);
+ service_ret = calendar_record_get_str(new_service_data, _calendar_event.byweekno, &text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_str(byweekno) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_str(old_service_data, _calendar_event.byweekno, text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_str(byweekno) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_str(new_service_data, _calendar_event.bymonth, &text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_str(bymonth) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_str(old_service_data, _calendar_event.bymonth, text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_str(bymonth) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_str(new_service_data, _calendar_event.bysetpos, &text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_str(bysetpos) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_str(old_service_data, _calendar_event.bysetpos, text);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_str(bysetpos) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_int(new_service_data, _calendar_event.wkst, &num);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_int(wkst) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ service_ret = calendar_record_set_int(old_service_data, _calendar_event.wkst, num);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_int(wkst) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ /* alarm */
+ calendar_record_h new_alarm_record = NULL;
+ calendar_record_h old_alarm_record = NULL;
+ calendar_time_s alarm_time = {0};
+ int new_data_has_alarm = 0;
+ int old_data_has_alarm = 0;
+ int type = 0;
+ int tick = 0;
+ int tick_unit = 0;
+ int alarm_id = 0;
+ description = NULL;
+
+ service_ret = calendar_record_get_int(new_service_data, _calendar_event.has_alarm, &new_data_has_alarm);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_int(has_alarm) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ _DEBUG_INFO("new_data_has_alarm = %d", new_data_has_alarm);
+
+ service_ret = calendar_record_get_int(old_service_data, _calendar_event.has_alarm, &old_data_has_alarm);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_int(has_alarm) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ _DEBUG_INFO("old_data_has_alarm = %d", old_data_has_alarm);
+
+ if (new_data_has_alarm == 0 && old_data_has_alarm == 1) {
+ _DEBUG_INFO("alarm record shoud be deleted");
+
+ service_ret = calendar_record_get_child_record_at_p(old_service_data, _calendar_event.calendar_alarm, 0, &old_alarm_record);
if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_list_first() Fail! : err[%d]", service_ret);
- ret = _convert_service_error_to_common_error(service_ret);
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_child_record_at_p() Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
}
- service_ret = calendar_list_get_current_record_p(schedules, &temp_new_service_data);
- if ((service_ret != CALENDAR_ERROR_NONE) && (temp_new_service_data == NULL)) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_list_get_current_record_p() Fail! : err[%d]", service_ret);
- ret = _convert_service_error_to_common_error(service_ret);
+ service_ret = calendar_record_remove_child_record(old_service_data, _calendar_event.calendar_alarm, old_alarm_record);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_remove_child_record() Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ }
+ else if (new_data_has_alarm == 1) {
+ service_ret = calendar_record_get_child_record_at_p(new_service_data, _calendar_event.calendar_alarm, 0, &new_alarm_record);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_child_record_at_p(_calendar_event.calendar_alarm) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
}
- /*index moving */
-// int n_cal_struct_index = 0;
-// service_ret = calendar_record_get_int(temp_old_service_data, _calendar_event.id, &n_cal_struct_index);
-// if (service_ret != CALENDAR_ERROR_NONE) {
-// _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_int() Fail! err[%d]\n", service_ret);
-// }
-//
-// service_ret = calendar_record_set_int(temp_new_service_data, _calendar_event.id, n_cal_struct_index);
-// if (service_ret != CALENDAR_ERROR_NONE) {
-// _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_int() Fail! err[%d]\n", service_ret);
-// return SYNC_AGENT_DA_ERRORS;
-// }
-
- ret = _temp_merge_record_new_to_old(temp_old_service_data, temp_new_service_data);
- if (ret != SYNC_AGENT_DA_SUCCESS) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_int() Fail! err[%d]\n", ret);
- /*i think when set return fail then going throw input schedule */
+ service_ret = calendar_record_get_int(new_alarm_record, _calendar_alarm.type, &type);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_int(type) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
}
-// service_ret = calendar_record_set_str(temp_new_service_data, _calendar_event.start_tzid, "Asia/Seoul");
-// if (service_ret != CALENDAR_ERROR_NONE) {
-// _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_str() Fail! err[%d]\n", service_ret);
-// /*i think when set return fail then going throw input schedule*/
-// }
- *new_service_data = temp_old_service_data;
- }
+ service_ret = calendar_record_get_lli(new_alarm_record, _calendar_alarm.time, &alarm_time.time.utime);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_lli(time) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
- _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_vcalendar_parse_to_calendar() Success!\n");
- if (schedules != NULL) {
- service_ret = calendar_list_destroy(schedules, false);
+ service_ret = calendar_record_get_int(new_alarm_record, _calendar_alarm.tick, &tick);
if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", service_ret);
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_int(tick) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_int(new_alarm_record, _calendar_alarm.tick_unit, &tick_unit);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_int(tick_unit) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_str(new_alarm_record, _calendar_alarm.description, &description);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_str(description) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_get_int(new_alarm_record, _calendar_alarm.alarm_id, &alarm_id);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_int(alarm_id) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ if (old_data_has_alarm == 0) {
+ _DEBUG_INFO("alarm record should be created");
+
+ service_ret = calendar_record_create(_calendar_alarm._uri, &old_alarm_record);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_create Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ }
+ else if (old_data_has_alarm == 1) {
+ _DEBUG_INFO("alarm record should be overwrited");
+
+ service_ret = calendar_record_get_child_record_at_p(old_service_data, _calendar_event.calendar_alarm, 0, &old_alarm_record);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_child_record_at_p(_calendar_alarm._uri) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+ }
+ else {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] this is an error. new_data_has_alarm = %d, old_data_has_alarm = %d", new_data_has_alarm, old_data_has_alarm);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_set_int(old_alarm_record, _calendar_alarm.type, type);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_int(type) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_set_lli(old_alarm_record, _calendar_alarm.time, alarm_time.time.utime);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_lli(time) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_set_int(old_alarm_record, _calendar_alarm.tick, tick);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_int(tick) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_set_int(old_alarm_record, _calendar_alarm.tick_unit, tick_unit);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_int(tick_unit) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_set_str(old_alarm_record, _calendar_alarm.description, description);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_str(description) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ service_ret = calendar_record_set_int(old_alarm_record, _calendar_alarm.alarm_id, alarm_id);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_int(alarm_id) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
+
+ if (old_data_has_alarm == 0) {
+ _DEBUG_INFO("alarm record should be created - add child rocord(alarm)");
+
+ service_ret = calendar_record_add_child_record(old_service_data, _calendar_event.calendar_alarm, old_alarm_record);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_add_child_record(calendar_alarm) Fail! err[%d]\n", service_ret);
+ return SYNC_AGENT_DA_ERRORS;
+ }
}
- schedules = NULL;
}
- _DEBUG_INFO("[dc_vcalendar_plugIn] End !!");
+ /* image is not supported Outlook sync. So, image field should be not merged (2013/01/14 concept) */
_EXTERN_FUNC_EXIT;
-
return ret;
}
-#endif
-#ifdef old_api
-EXPORT_API sync_agent_da_return_e sync_agent_plugin_reverse_converter(void *service_data, void **agent_data)
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_replace_converter(void *old_service_data, const void *agent_data, void **new_service_data)
{
_EXTERN_FUNC_ENTER;
- retvm_if(service_data == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "service_data is NULL. FAIL !!!");
-
- _DEBUG_INFO("[dc_vcalendar_plugIn] Start !!");
+ retvm_if(old_service_data == NULL, SYNC_AGENT_DA_ERRORS, "old_service_data is NULL. FAIL !!!");
+ retvm_if(agent_data == NULL, SYNC_AGENT_DA_ERRORS, "agent_data is NULL. FAIL !!!");
+ calendar_list_h calendar_list = NULL;
+ calendar_record_h temp_new_service_data = NULL;
+ calendar_record_h temp_old_service_data = (calendar_record_h) old_service_data;
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
- int err = 0;
- char *temp_agent_data = 0;
- cal_struct *temp_service_data = (cal_struct *) service_data;
- int len = 0;
-
- /* Temporary fix for KIES vCalendar X-ALLDAY/RRULE/LAST MODIFIED tag : START */
- int allday = 0;
- char rrule[30];
- memset(rrule, 0, 30);
-
- cal_struct *item = (cal_struct *) temp_service_data;
-
- _DEBUG_INFO("before calendar_svc_write_schedules");
- if (CALS_TIME_LOCALTIME == calendar_svc_struct_get_int(item, CALS_VALUE_INT_DTSTART_TYPE)) {
- _DEBUG_INFO("[Debug] Found X-ALLDAY flag set in calendar service structure before conversion !!!");
- allday = 1;
- }
-
- /* calendar service say it is supported */
-// if (calendar_svc_struct_get_int(item, CAL_VALUE_INT_REPEAT_TERM) != CAL_REPEAT_NONE) {
-//
-// char repeat_end_date[16 + 1] = { 0 };
-// char week_day_string[16 + 1] = { 0 };
-//
-// struct tm *tm = calendar_svc_struct_get_tm(item, CAL_VALUE_GMT_REPEAT_END_DATE, CAL_TZ_FLAG_LOCAL);
-//
-// memset(repeat_end_date, 0, 17);
-//
-// snprintf(repeat_end_date, sizeof(repeat_end_date), "%04ld%02d%02dT%02d%02d%02dZ", tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
-//
-// _DEBUG_INFO(" repeat_end_date = %s ", repeat_end_date);
-//
-// char str[50];
-// memset(str, 0, 50);
-//
-// switch (calendar_svc_struct_get_int(item, CAL_VALUE_INT_REPEAT_TERM)) {
-// case CAL_REPEAT_EVERY_DAY:
-// snprintf(str, sizeof(str), "D%d %s", calendar_svc_struct_get_int(item, CAL_VALUE_INT_REPEAT_INTERVAL), repeat_end_date);
-// break;
-//
-// case CAL_REPEAT_EVERY_WEEK:
-// case CAL_REPEAT_EVERY_WEEKDAYS:{
-// struct tm *tm_start = calendar_svc_struct_get_tm(item, CAL_VALUE_GMT_START_DATE_TIME, CAL_TZ_FLAG_LOCAL);
-//
-// char *date_string[7] = { "SU", "MO", "TU", "WE", "TH", "FR", "SA" };
-//
-// struct tm temp;
-// time_t t = timegm(tm_start);
-// gmtime_r(&t, &temp);
-//
-// if (temp.tm_wday < 0 || temp.tm_wday > 6) {
-// } else {
-// snprintf(week_day_string, 3, date_string[temp.tm_wday]);
-// }
-//
-// snprintf(str, sizeof(str), "W%d %s %s", calendar_svc_struct_get_int(item, CAL_VALUE_INT_REPEAT_INTERVAL), week_day_string, repeat_end_date);
-// }
-// break;
-//
-// case CAL_REPEAT_EVERY_MONTH:
-// case CAL_REPEAT_EVERY_MONTH_DAY:
-// snprintf(str, sizeof(str), "MD%d %s", calendar_svc_struct_get_int(item, CAL_VALUE_INT_REPEAT_INTERVAL), repeat_end_date);
-// break;
-//
-// case CAL_REPEAT_EVERY_YEAR:
-// case CAL_REPEAT_EVERY_YEAR_DAY:
-// snprintf(str, sizeof(str), "YM%d %s", calendar_svc_struct_get_int(item, CAL_VALUE_INT_REPEAT_INTERVAL), repeat_end_date);
-// break;
-//
-// default:
-// break;
-// }
-//
-// len = g_strlcat(rrule, "\r\nRRULE:", sizeof(rrule));
-// len = g_strlcat(rrule, str, sizeof(rrule));
-//
-// if (len >= sizeof(rrule)) {
-// _DEBUG_ERROR("rrule buffer overflow !!");
-// /* todo : exception handling */
-// }
-//
-// _DEBUG_INFO(" rrule = %s ", rrule);
-// }
-
- /* Temporary fix for KIES vCalendar X-ALLDAY/RRULE tag : END */
-
- /* Reverse_Converter */
- /*new */
- _DEBUG_INFO("before calendar_svc_write_schedules");
- GList *list = g_list_append(NULL, temp_service_data);
- err = calendar_svc_write_schedules(list, &temp_agent_data);
- _DEBUG_INFO("after calendar_svc_write_schedules");
-// free(list);
- /*old */
-// err = calendar_svc_util_convert_event_to_vcs(temp_service_data, &temp_agent_data, &size);
- if (err < CAL_SUCCESS) {
- _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_svc_util_convert_event_to_vcs() Fail!\n");
- ret = _convert_service_error_to_common_error(err);
- *agent_data = 0;
- } else {
- /* Temporary fix for KIES vCalendar X-ALLDAY/RRULE tag : START */
- if (strstr(temp_agent_data, "\r\nX-ALLDAY:SET") == NULL && allday) {
- char *vevent_loc = strstr(temp_agent_data, "\r\nEND:VEVENT");
- if (vevent_loc != NULL) {
- len = 0;
- int mod_data_len = strlen(temp_agent_data) + strlen("\r\nX-ALLDAY:SET") + 1;
- char *mod_data = (char *)calloc(mod_data_len, sizeof(char));
- if (mod_data == NULL) {
- _DEBUG_ERROR("mod_data is null");
- ret = SYNC_AGENT_DA_ERRORS;
- *agent_data = 0;
- return ret;
- }
-
- strncpy(mod_data, temp_agent_data, vevent_loc - temp_agent_data);
-
- len = g_strlcat(mod_data, "\r\nX-ALLDAY:SET", mod_data_len);
- len = g_strlcat(mod_data, vevent_loc, mod_data_len);
-
- if (len >= mod_data_len) {
- _DEBUG_ERROR("mod_data buffer overflow !!");
- /* todo : exception handling */
- }
+ int service_ret = CALENDAR_ERROR_NONE;
+ const char *temp_agent_data = (const char *)agent_data;
+ char *temp = NULL;
- free(temp_agent_data);
- temp_agent_data = mod_data;
- }
- char *dtstart_loc = strstr(temp_agent_data, "\r\nDTSTART:");
- if (dtstart_loc != NULL) {
- char *dtstart_z_loc = dtstart_loc + 25;
- if (!strncmp(dtstart_z_loc, "Z", 1))
- strncpy(dtstart_z_loc, "\r\r\n", 4);
- }
- char *dtend_loc = strstr(temp_agent_data, "\r\nDTEND:");
- if (dtend_loc != NULL) {
- char *dtend_z_loc = dtend_loc + 23;
- if (!strncmp(dtend_z_loc, "Z", 1))
- strncpy(dtend_z_loc, "\r\r\n", 4);
- }
- }
+ if (temp_agent_data == NULL) {
+ _DEBUG_ERROR("inputed temp_agent_data is null");
+ _EXTERN_FUNC_EXIT;
+ return SYNC_AGENT_DA_ERRORS;
+ }
- if (strstr(temp_agent_data, "\r\nRRULE:") == NULL) {
- char *category_loc = strstr(temp_agent_data, "\r\nCATEGORIES:");
- if (category_loc != NULL) {
- len = 0;
- int mod_data_len = strlen(temp_agent_data) + strlen(rrule) + 1;
- char *mod_data = (char *)calloc(mod_data_len, sizeof(char));
- if (mod_data == NULL) {
- _DEBUG_ERROR("mod_data is null");
- ret = SYNC_AGENT_DA_ERRORS;
- *agent_data = 0;
- return ret;
- }
-
- strncpy(mod_data, temp_agent_data, category_loc - temp_agent_data);
-
- len = g_strlcat(mod_data, rrule, mod_data_len);
- len = g_strlcat(mod_data, category_loc, mod_data_len);
-
- if (len >= mod_data_len) {
- _DEBUG_ERROR("mod_data buffer overflow !!");
- /* todo : exception handling */
- }
+ _DEBUG_INFO("temp_agent_data = %s", temp_agent_data);
- free(temp_agent_data);
- temp_agent_data = mod_data;
- }
+ // 1. if the vcalendar has IMPORT_EXTYPE_DELETE_KEYWORD, then this vcalendar has an EXDATE data : it should be excuted before calendar_vcalendar_parse_to_calendar
+ // in case of 'exdate', exdate set to parent event and 'RETURN' this API
+ if (strstr(temp_agent_data, IMPORT_EXTYPE_DELETE_KEYWORD) != NULL) {
+ if (replace_exdate_data(temp_agent_data, temp_old_service_data) == SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_INFO("replace_exdate_data() success");
+ *new_service_data = temp_old_service_data;
+ goto return_part;
}
+ }
- /* Temporary fix for KIES vCalendar X-ALLDAY/RRULE tag : END */
- _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_svc_util_convert_event_to_vcs() Success!\n");
- *agent_data = (void *)temp_agent_data;
+ // 2. if the vcalendar has until : NONE rrule, then max rrule should be converted : it should be excuted before calendar_vcalendar_parse_to_calendar
+ if (strstr(temp_agent_data, RRULE_KEYWORD) != NULL) {
+ temp = strdup(temp_agent_data);
+ temp_agent_data = replace_max_rrule_data(temp);
+ temp = NULL;
}
- /* memory free */
- _DEBUG_INFO("temp service data free");
- if (temp_service_data != NULL)
- calendar_svc_struct_free(&temp_service_data);
+ service_ret = calendar_vcalendar_parse_to_calendar(temp_agent_data, &calendar_list);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_vcalendar_parse_to_calendar() Fail! err[%d]\n", service_ret);
+ *new_service_data = NULL;
+ goto return_part;
+ }
- _DEBUG_INFO("[dc_vcalendar_plugIn] End !!");
+ service_ret = calendar_list_first(calendar_list);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_list_first() Fail! : err[%d]", service_ret);
+ goto return_part;
+ }
- _EXTERN_FUNC_EXIT;
+ int count = 0;
+ calendar_list_get_count(calendar_list, &count);
+ _DEBUG_INFO("count = %d", count);
+ do
+ {
+ char *uri = NULL;
+ char *key = NULL;
+ service_ret = calendar_list_get_current_record_p(calendar_list, &temp_new_service_data);
+ if ((service_ret != CALENDAR_ERROR_NONE) || (temp_new_service_data == NULL)) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_list_get_current_record_p() Fail! : err[%d]", service_ret);
+ goto return_part;
+ }
+
+ service_ret = calendar_record_get_uri_p(temp_new_service_data, &uri);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_uri_p() Fail! : err[%d]", service_ret);
+ goto return_part;
+ }
+ _DEBUG_INFO("temp_new_service_data URI = %s", uri);
+
+ if (!strncmp(uri, _calendar_event._uri, strlen(_calendar_event._uri))) {
+ _DEBUG_INFO("this is event");
+ ret = _vevent_merge_new_to_old(temp_old_service_data, temp_new_service_data);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_int() Fail! err[%d]\n", ret);
+ }
+ // 1. "all day" setting : it should be excuted after calendar_vcalendar_parse_to_calendar
+ if (strstr((char *)temp_agent_data, "\r\nX-ALLDAY:SET") != NULL) {
+ insert_allday_data((char *)temp_agent_data, temp_old_service_data);
+ }
+ }
+ else if (!strncmp(uri, _calendar_extended_property._uri, strlen(_calendar_extended_property._uri))) {
+ _DEBUG_INFO("this is extended");
+ ret = calendar_record_get_str(temp_new_service_data, _calendar_extended_property.key, &key);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_str() Fail! : err[%d]", service_ret);
+ goto return_part;
+ }
+ _DEBUG_INFO("key = %s", key);
+ if (strncmp(key, "VERSION", strlen("VERSION"))) {
+ _DEBUG_INFO("this is extended, not VCALENDAR:VERSION extend");
+ calendar_record_add_child_record(temp_old_service_data, _calendar_event.extended, temp_new_service_data);
+ }
+ }
+ } while(calendar_list_next(calendar_list) != CALENDAR_ERROR_NO_DATA);
+ *new_service_data = temp_old_service_data;
+
+return_part:
+ _DEBUG_INFO("return_part");
+ if (calendar_list != NULL) {
+ service_ret = calendar_list_destroy(calendar_list, false);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", service_ret);
+ }
+ calendar_list = NULL;
+ }
+ ret = _convert_service_error_to_common_error(service_ret);
+ _EXTERN_FUNC_EXIT;
return ret;
}
-#else
+
EXPORT_API sync_agent_da_return_e sync_agent_plugin_reverse_converter(void *service_data, void **agent_data)
{
_EXTERN_FUNC_ENTER;
retvm_if(service_data == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "service_data is NULL. FAIL !!!");
- _DEBUG_INFO("[dc_vcalendar_plugIn] Start !!");
-
- sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
- int service_ret = CALENDAR_ERROR_NONE;
- char *temp_agent_data = NULL;
+ calendar_list_h list = NULL;
calendar_record_h temp_service_data = (calendar_record_h) service_data;
- int len = 0;
-
- /* Temporary fix for KIES vCalendar X-ALLDAY/RRULE/LAST MODIFIED tag : START */
- int allday = 0;
- char rrule[30];
- memset(rrule, 0, 30);
-
calendar_record_h item = (calendar_record_h) temp_service_data;
- calendar_list_h list = NULL;
+ calendar_record_h image_item = (calendar_record_h) temp_service_data;
+ calendar_record_h extended_version = NULL;
calendar_time_s cal_start_time = { 0, };
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ sync_agent_calendar_exdate_t *exdate_struct = NULL;
+ int service_ret = CALENDAR_ERROR_NONE;
+ char *temp_agent_data = NULL;
+ char *child_str = NULL;
+ char *agent_copied_str = NULL;
- _DEBUG_INFO("before calendar_svc_write_schedules");
+ _DEBUG_INFO("converter start");
service_ret = calendar_record_get_caltime(item, _calendar_event.start_time, &cal_start_time);
if (service_ret != CALENDAR_ERROR_NONE) {
_DEBUG_ERROR("calendar_record_get_caltime() Fail: err[%d]", service_ret);
ret = SYNC_AGENT_DA_ERRORS;
- *agent_data = NULL;
- } else {
- if (cal_start_time.type == CALENDAR_TIME_LOCALTIME) {
- _DEBUG_INFO("[Debug] Found X-ALLDAY flag set in calendar service structure before conversion !!!");
- allday = 1;
+ goto return_part;
+ }
+
+ // 1. "all day" setting : it should be excuted before calendar_vcalendar_make_from_records
+ if (cal_start_time.type == CALENDAR_TIME_LOCALTIME) {
+ calendar_record_h extended_allday = NULL;
+ service_ret = calendar_record_create(_calendar_extended_property._uri, &extended_allday);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_create() Fail!: err[%d]", service_ret);
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto return_part;
+ }
+ service_ret = calendar_record_set_str(extended_allday, _calendar_extended_property.key, "X-ALLDAY");
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_set_str() Fail!: err[%d]", service_ret);
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto return_part;
+ }
+ service_ret = calendar_record_set_str(extended_allday, _calendar_extended_property.value, ":SET");
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_set_str() Fail!: err[%d]", service_ret);
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto return_part;
+ }
+ service_ret = calendar_record_add_child_record(temp_service_data, _calendar_event.extended, extended_allday);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_add_child_record() Fail!: err[%d]", service_ret);
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto return_part;
}
}
- /* Temporary fix for KIES vCalendar X-ALLDAY/RRULE tag : END */
+ // 2. "EXTYPE" setting, '1' means deleted, '2' means updated : it should be excuted before calendar_vcalendar_make_from_records
+ exdate_struct = (sync_agent_calendar_exdate_t *)calloc(1, sizeof(sync_agent_calendar_exdate_t));
+ if (exdate_struct == NULL) {
+ _DEBUG_ERROR("exdate_struct calloc fail");
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto return_part;
+ }
+ get_exdate_data(temp_service_data, exdate_struct);
+
+ // 3. extended vcalendar version : it should be excuted before calendar_vcalendar_make_from_records
+ service_ret = calendar_record_create(_calendar_extended_property._uri, &extended_version);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_create() Fail!: err[%d]", service_ret);
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto return_part;
+ }
+
+ service_ret = calendar_record_set_str(extended_version, _calendar_extended_property.key, "VERSION");
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_set_str() Fail!: err[%d]", service_ret);
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto return_part;
+ }
+
+ service_ret = calendar_record_set_str(extended_version, _calendar_extended_property.value, ":1.0");
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_create() Fail!: err[%d]", service_ret);
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto return_part;
+ }
- /* Reverse_Converter */
- /*new */
service_ret = calendar_list_create(&list);
if (service_ret != CALENDAR_ERROR_NONE) {
_DEBUG_ERROR("calendar_list_create() Fail!: err[%d]", service_ret);
ret = _convert_service_error_to_common_error(service_ret);
- *agent_data = NULL;
+ goto return_part;
+ }
+ service_ret = calendar_list_add(list, extended_version);
+ if (service_ret != CALENDAR_ERROR_NONE || list == NULL) {
+ _DEBUG_ERROR("calendar_list_add() Fail!: err[%d]", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto return_part;
}
- _DEBUG_INFO("before calendar_svc_write_schedules");
service_ret = calendar_list_add(list, temp_service_data);
- if (service_ret != CALENDAR_ERROR_NONE) {
+ if (service_ret != CALENDAR_ERROR_NONE || list == NULL) {
_DEBUG_ERROR("calendar_list_add() Fail!: err[%d]", service_ret);
ret = _convert_service_error_to_common_error(service_ret);
- *agent_data = NULL;
+ goto return_part;
}
- if (list != NULL) {
- service_ret = calendar_vcalendar_make_from_records(list, &temp_agent_data);
- _DEBUG_INFO("after calendar_vcalendar_make_from_records");
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("calendar_vcalendar_make_from_records() Fail!: err[%d]", service_ret);
- ret = _convert_service_error_to_common_error(service_ret);
- *agent_data = NULL;
- } else {
- /* Temporary fix for KIES vCalendar X-ALLDAY/RRULE tag : START */
- if (strstr(temp_agent_data, "\r\nX-ALLDAY:SET") == NULL && allday) {
- char *vevent_loc = strstr(temp_agent_data, "\r\nEND:VEVENT");
- if (vevent_loc != NULL) {
- len = 0;
- int mod_data_len = strlen(temp_agent_data) + strlen("\r\nX-ALLDAY:SET") + 1;
- char *mod_data = (char *)calloc(mod_data_len, sizeof(char));
- if (mod_data == NULL) {
- _DEBUG_ERROR("mod_data is null");
- ret = SYNC_AGENT_DA_ERRORS;
- *agent_data = NULL;
-
- service_ret = calendar_list_destroy(list, true);
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("calendar_list_destroy() Fail!: err[%d]", service_ret);
- ret = _convert_service_error_to_common_error(service_ret);
- }
-
- return ret;
- }
-
- strncpy(mod_data, temp_agent_data, vevent_loc - temp_agent_data);
-
- len = g_strlcat(mod_data, "\r\nX-ALLDAY:SET", mod_data_len);
- len = g_strlcat(mod_data, vevent_loc, mod_data_len);
-
- if (len >= mod_data_len) {
- _DEBUG_ERROR("mod_data buffer overflow !!");
- /* todo : exception handling */
- }
-
- free(temp_agent_data);
- temp_agent_data = mod_data;
- }
- char *dtstart_loc = strstr(temp_agent_data, "\r\nDTSTART:");
- if (dtstart_loc != NULL) {
- char *dtstart_z_loc = dtstart_loc + 25;
- if (!strncmp(dtstart_z_loc, "Z", 1))
- strncpy(dtstart_z_loc, "\r\r\n", 3);
- }
- char *dtend_loc = strstr(temp_agent_data, "\r\nDTEND:");
- if (dtend_loc != NULL) {
- char *dtend_z_loc = dtend_loc + 23;
- if (!strncmp(dtend_z_loc, "Z", 1))
- strncpy(dtend_z_loc, "\r\r\n", 3);
- }
+ char *exdate = NULL;
+ service_ret = calendar_record_get_str(temp_service_data, _calendar_event.exdate, &exdate);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_create() Fail!: err[%d]", service_ret);
+ goto return_part;
+ }
+ _DEBUG_INFO("exdate = %s", exdate);
+
+ service_ret = calendar_vcalendar_make_from_records(list, &temp_agent_data);
+ _DEBUG_INFO("temp_agent_data = %s", temp_agent_data);
+
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_vcalendar_make_from_records() Fail!: err[%d]", service_ret);
+ ret = _convert_service_error_to_common_error(service_ret);
+ goto return_part;
+ }
+
+ // 1. remove 'timezone' : after calendar_vcalendar_make_from_records
+ _DEBUG_INFO("temp_agent_data = %s", temp_agent_data);
+ temp_agent_data = remove_timezone(temp_agent_data);
+ _DEBUG_INFO("temp_agent_data = %s", temp_agent_data);
+
+ // 2. image converting : after calendar_vcalendar_make_from_records
+ char *image_path = has_image_export(image_item);
+ if (image_path != NULL) {
+ _DEBUG_INFO("image is founded.");
+ temp_agent_data = replace_image_data(temp_agent_data, image_path);
+ }
+
+ // 3. exdate converting : after calendar_vcalendar_make_from_records
+ char *new_temp_agent_data = NULL;
+ if (exdate_struct->exdate_type != CALENDAR_EXDATE_TYPE_NONE) {
+ int index=0;
+ int exdate_count = exdate_struct->exdate_count;
+ _DEBUG_INFO("exdate_count = %d", exdate_count);
+
+ agent_copied_str = strdup(temp_agent_data);
+ for (index=0; index<exdate_count; index++) {
+ child_str = insert_exdate_data(agent_copied_str, exdate_struct, index);
+ _DEBUG_INFO("index = %d, child_str = %s", index, child_str);
+
+
+
+ new_temp_agent_data = (char *)calloc(2000, sizeof(char));
+ if (new_temp_agent_data == NULL) {
+ _DEBUG_ERROR("new_temp_agent_data calloc failed");
+ goto return_part;
+ }
+ _DEBUG_INFO("aaaa");
+ int child_str_length = strlen(child_str);
+ _DEBUG_INFO("child_str_length = %d", child_str_length);
+ snprintf(new_temp_agent_data, 2000, "%s%s%04d%s", temp_agent_data, "0000", child_str_length, child_str);
+ _DEBUG_INFO("new_temp_agent_data = %s", new_temp_agent_data);
+ if (temp_agent_data) {
+ free(temp_agent_data);
+ temp_agent_data = NULL;
+ }
+ temp_agent_data = new_temp_agent_data;
+ _DEBUG_INFO("temp_agent_data = %s", temp_agent_data);
+ }
+ _DEBUG_INFO("temp_agent_data = %s", temp_agent_data);
+
+ // remove EXTYPE & EXDATE at parent event
+ if (strstr(temp_agent_data, "\r\nX-EXTYPE:1") != NULL) {
+ temp_agent_data = replace_string(temp_agent_data, "\r\nX-EXTYPE:1", "\r\nUID:000000000000000000000000000000000000000000000000");
+ }
+ else if (strstr(temp_agent_data, "\r\nX-EXTYPE:2") != NULL) {
+ temp_agent_data = replace_string(temp_agent_data, "\r\nX-EXTYPE:2", "\r\nUID:000000000000000000000000000000000000000000000000");
+ }
+ else
+ ;//nothing, this vcalendar has not extype data.
+
+ /*_DEBUG_INFO("temp_agent_data = %s", temp_agent_data);
+ char *old_str = NULL;
+ char *new_str = NULL;
+ if ((old_str = strstr(temp_agent_data, EXDATE_KEYWORD)) != NULL) {
+ _DEBUG_INFO("old_str = %s", old_str);
+ if ((new_str = strstr(old_str+2, "\r\n")) != NULL) {
+ _DEBUG_INFO("new_str = %s", new_str);
+ temp_agent_data = replace_string(temp_agent_data, old_str, new_str);
}
+ }*/
- if (strstr(temp_agent_data, "\r\nRRULE:") == NULL) {
- char *category_loc = strstr(temp_agent_data, "\r\nCATEGORIES:");
- if (category_loc != NULL) {
- len = 0;
- int mod_data_len = strlen(temp_agent_data) + strlen(rrule) + 1;
- char *mod_data = (char *)calloc(mod_data_len, sizeof(char));
- if (mod_data == NULL) {
- _DEBUG_ERROR("mod_data is null");
- ret = SYNC_AGENT_DA_ERRORS;
- *agent_data = 0;
-
- service_ret = calendar_list_destroy(list, true);
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("calendar_list_destroy() Fail!: err[%d]", service_ret);
- ret = _convert_service_error_to_common_error(service_ret);
- }
-
- return ret;
- }
-
- strncpy(mod_data, temp_agent_data, category_loc - temp_agent_data);
-
- len = g_strlcat(mod_data, rrule, mod_data_len);
- len = g_strlcat(mod_data, category_loc, mod_data_len);
-
- if (len >= mod_data_len) {
- _DEBUG_ERROR("mod_data buffer overflow !!");
- /* todo : exception handling */
- }
-
- free(temp_agent_data);
- temp_agent_data = mod_data;
- }
+
+
+
+ _DEBUG_INFO("temp_agent_data = %s", temp_agent_data);
+ char *old_str = NULL;
+ char *new_str = NULL;
+ if ((old_str = strstr(temp_agent_data, EXDATE_KEYWORD)) != NULL) {
+ _DEBUG_INFO("old_str = %s", old_str);
+ if ((new_str = strstr(old_str+2, AALARM_KEYWORD)) != NULL) {
+ _DEBUG_INFO("new_str = %s", new_str);
+ temp_agent_data = replace_string(temp_agent_data, old_str, new_str);
+ }
+ else if ((new_str = strstr(old_str+2, CR_EXTYPE_DELETE_KEYWORD)) != NULL) {
+ _DEBUG_INFO("new_str = %s", new_str);
+ temp_agent_data = replace_string(temp_agent_data, old_str, new_str);
}
- /* Temporary fix for KIES vCalendar X-ALLDAY/RRULE tag : END */
- _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_svc_util_convert_event_to_vcs() Success!\n");
- *agent_data = (void *)temp_agent_data;
+ else
+ ;
}
+ _DEBUG_INFO("aaaaaaaaaaaaa temp_agent_data = %s", temp_agent_data);
+ }
+
+return_part:
+ _DEBUG_INFO("return_part");
+ *agent_data = (void *)temp_agent_data;
+
+ if (list != NULL) {
service_ret = calendar_list_destroy(list, true);
if (service_ret != CALENDAR_ERROR_NONE) {
_DEBUG_ERROR("calendar_list_destroy() Fail!: err[%d]", service_ret);
ret = _convert_service_error_to_common_error(service_ret);
}
}
-
- _DEBUG_INFO("[dc_vcalendar_plugIn] End !!");
-
+ if (exdate_struct->exdate_list) {
+ g_list_free(exdate_struct->exdate_list);
+ exdate_struct->exdate_list = NULL;
+ }
+ _DEBUG_INFO("agent_data = %s", *agent_data);
_EXTERN_FUNC_EXIT;
-
return ret;
}
-#endif
EXPORT_API void *sync_agent_plugin_alloc_object()
{
_EXTERN_FUNC_ENTER;
-
- _DEBUG_INFO("[dc_vcard_plugIn] not implement !!");
-
+ _DEBUG_INFO("[dc_vcalendar_plugIn] not implement !!");
_EXTERN_FUNC_EXIT;
-
return 0;
}
EXPORT_API int sync_agent_plugin_free_object(void *in_object)
{
_EXTERN_FUNC_ENTER;
-
- _DEBUG_INFO("[dc_vcard_plugIn] not implement !!");
-
+ _DEBUG_INFO("[dc_vcalendar_plugIn] not implement !!");
_EXTERN_FUNC_EXIT;
-
return 0;
}
EXPORT_API void *sync_agent_plugin_set_value(void *in_object, int key, char *extension_key, void *value)
{
_EXTERN_FUNC_ENTER;
-
- _DEBUG_INFO("[dc_vcard_plugIn] not implement !!");
-
+ _DEBUG_INFO("[dc_vcalendar_plugIn] not implement !!");
_EXTERN_FUNC_EXIT;
-
return 0;
}
EXPORT_API void *sync_agent_plugin_get_value(void *in_object, int key, char *extension_key)
{
_EXTERN_FUNC_ENTER;
-
- _DEBUG_INFO("[dc_vcard_plugIn] not implement !!");
-
+ _DEBUG_INFO("[dc_vcalendar_plugIn] not implement !!");
_EXTERN_FUNC_EXIT;
-
return 0;
}
return 1;
}
-#ifdef old_api
-static sync_agent_da_return_e _convert_service_error_to_common_error(cal_error err)
-{
- _INNER_FUNC_ENTER;
-
- sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
- _DEBUG_TRACE("[da_calendar_plugIn] Error Code : %d\n", err);
-
- switch (err) {
- case CAL_ERR_DB_LOCK: /* -204 */
- ret = SYNC_AGENT_DA_ERR_LOCKED;
- break;
- case CAL_ERR_DB_RECORD_NOT_FOUND: /* -203 */
- case CAL_ERR_NO_DATA: /* -3 */
- ret = SYNC_AGENT_DA_ERR_NO_DATA;
- break;
- case CAL_ERR_DB_NOT_OPENED: /* -201 */
- ret = SYNC_AGENT_DA_ERR_OPEN_FAILED;
- break;
- case CAL_ERR_OUT_OF_MEMORY: /* -8 */
- ret = SYNC_AGENT_DA_ERR_MEMORY_FULL;
- break;
- case CAL_ERR_ALREADY_EXIST: /* -7 */
- ret = SYNC_AGENT_DA_ERR_ALREADY_EXIST;
- break;
- case CAL_ERR_EVENT_START_DATE: /* -405 */
- case CAL_ERR_EVENT_END_DATE: /* -404 */
- case CAL_ERR_EVENT_REPEAT_END_DATE: /* -403 */
- case CAL_ERR_EVENT_DURATION: /* -402 */
- case CAL_ERR_EVENT_REPEAT_DURATION_TOO_SHORT: /* -401 */
- case CAL_ERR_INVALID_DATA_TYPE: /* -301 */
- case CAL_ERR_ARG_NULL: /* -5 */
- case CAL_ERR_ARG_INVALID: /* -4 */
- ret = SYNC_AGENT_DA_ERR_INVALID_CONTENT;
- break;
- case CAL_ERR_FINISH_ITER: /* -2 */
- case CAL_SUCCESS: /* 0 */
- case CAL_TRUE: /* 1 */
- ret = SYNC_AGENT_DA_SUCCESS;
- break;
- /*
- * CAL_ERR_DB_FAILED: -202,
- * CAL_ERR_VCONF_FAILED: -102,
- * CAL_ERR_VOBJECT_FAILED: -101,
- * CAL_ERR_EXCEEDED_LIMIT: -9,
- * CAL_ERR_ENV_INVALID: -6, CAL_ERR_FAIL: -1,
- */
- default:
- ret = SYNC_AGENT_DA_ERRORS;
- break;
- }
-
- _INNER_FUNC_EXIT;
-
- return ret;
-}
-#else
static sync_agent_da_return_e _convert_service_error_to_common_error(calendar_error_e err)
{
_INNER_FUNC_ENTER;
return ret;
}
-#endif
--- /dev/null
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "vcalendar_string_util.h"
+
+#define DATE_TIME_LENGTH 16
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#if 0
+// usage / rrule converting
+if (strstr(temp_agent_data, "\r\nRRULE:") != NULL) {
+ _DEBUG_INFO("rrule is founed");
+ temp_agent_data = _replace_rrule_data(temp_agent_data);
+}
+
+static char * _replace_rrule_data(char *origin)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if(origin == NULL, origin, "origin is NULL.");
+
+ char *str_new_rrule = NULL;
+ char *str_end_time = NULL;
+ char *freq_loc = NULL;
+ char *str_byday = NULL;
+ char *str_interval = NULL;
+ char *str_period_until = NULL;
+ char *str_period_count = NULL;
+ calendar_date_type_e cal_type = CALENDAR_DATE_TYPE_ONTIME;
+
+ if ((freq_loc = strstr(origin, RRULE_KEYWORD_FREQ_WEEKLY)) != NULL) {
+ _DEBUG_INFO("this is weekly data");
+ }
+ else if ((freq_loc = strstr(origin, RRULE_KEYWORD_FREQ_MONTHLY)) != NULL) {
+ _DEBUG_INFO("this is monthly data");
+ }
+ else if ((freq_loc = strstr(origin, RRULE_KEYWORD_FREQ_YEARLY)) != NULL) {
+ _DEBUG_INFO("this is yearly data");
+ }
+ else if ((freq_loc = strstr(origin, RRULE_KEYWORD_FREQ_DAILY)) != NULL) {
+ _DEBUG_INFO("this is daily data");
+ }
+ else {
+ _DEBUG_ERROR("this is an undefined rrule type. origin = %s", origin);
+ goto return_part;
+ }
+
+ char *temp_rrule = NULL;
+ if((temp_rrule = strstr(freq_loc, "RRULE:")) == NULL) {
+ _DEBUG_ERROR("temp_rrule is NULL");
+ goto return_part;
+ }
+
+ char *temp_rrule2 = NULL;
+ if((temp_rrule2 = strstr(temp_rrule, "\r\n")) == NULL) {
+ _DEBUG_ERROR("temp_rrule2 is NULL");
+ goto return_part;
+ }
+
+ char str_origin_rrule[100] = {0,};
+ int origin_rrule_length = strlen(temp_rrule) - strlen(temp_rrule2) + 2; // '2' means of '\r\n'
+ if (origin_rrule_length <= 0) {
+ _DEBUG_ERROR("origin_rrule_length <= 0");
+ goto return_part;
+ }
+
+ strncpy(str_origin_rrule, temp_rrule, origin_rrule_length);
+ _DEBUG_INFO("str_origin_rrule = %s", str_origin_rrule);
+
+ if (strstr(origin, RRULE_KEYWORD_FREQ_WEEKLY) != NULL) {
+ str_byday = get_value_by_token(freq_loc, RRULE_KEYWORD_BYDAY, ";");
+ cal_type = CALENDAR_DATE_TYPE_WEEK;
+ }
+ else if (strstr(origin, RRULE_KEYWORD_FREQ_MONTHLY) != NULL) {
+ str_byday = get_value_by_token(freq_loc, RRULE_KEYWORD_BYMONTHDAY, ";");
+ cal_type = CALENDAR_DATE_TYPE_MONTH;
+ }
+ else if (strstr(origin, RRULE_KEYWORD_FREQ_YEARLY) != NULL) {
+ str_byday = get_value_by_token(freq_loc, RRULE_KEYWORD_BYMONTHDAY, ";");
+ cal_type = CALENDAR_DATE_TYPE_YEAR;
+ }
+ else if (strstr(origin, RRULE_KEYWORD_FREQ_DAILY) != NULL) {
+ cal_type = CALENDAR_DATE_TYPE_DAY;
+ }
+ else {
+ _DEBUG_ERROR("this is an undefined rrule type. origin = %s", origin);
+ goto return_part;
+ }
+
+ if ((cal_type != CALENDAR_DATE_TYPE_DAY) && (str_byday == NULL || strlen(str_byday) <= 0)) {
+ _DEBUG_ERROR("str_byday is null");
+ goto return_part;
+ }
+
+ str_interval = get_value_by_token(freq_loc, RRULE_KEYWORD_INTERVAL, ";");
+ str_period_until = get_value_by_token(freq_loc, RRULE_KEYWORD_UNTIL, ";");
+ str_period_count = get_value_by_token(freq_loc, RRULE_KEYWORD_COUNT, ";");
+
+ if (str_interval == NULL || strlen(str_interval) <= 0) {
+ _DEBUG_ERROR("str_interval is null");
+ goto return_part;
+ }
+
+ if (str_period_until == NULL && str_period_count == NULL) {
+ str_end_time = (char *)calloc(2, sizeof(char));
+ if (str_end_time == NULL) {
+ _DEBUG_ERROR("str_end_time is null");
+ goto return_part;
+ }
+ strncpy(str_end_time, "\r\n", 2);
+ _DEBUG_INFO("endless = %s", str_end_time);
+ }
+ else if (str_period_until != NULL) {
+ str_end_time = (char *)calloc(strlen(str_period_until), sizeof(char));
+ if (str_end_time == NULL) {
+ _DEBUG_ERROR("str_end_time is null");
+ goto return_part;
+ }
+ strncpy(str_end_time, str_period_until, strlen(str_period_until));
+ _DEBUG_INFO("until = %s", str_end_time);
+ }
+ else if (str_period_count != NULL) {
+ str_end_time = (char *)calloc(strlen(str_period_count)+1, sizeof(char));
+ if (str_end_time == NULL) {
+ _DEBUG_ERROR("str_end_time is null");
+ goto return_part;
+ }
+ snprintf(str_end_time, strlen(str_period_count)+1, "#%s", str_period_count);
+ _DEBUG_INFO("count = %s", str_end_time);
+ }
+ else {
+ _DEBUG_ERROR("there is an error");
+ goto return_part;
+ }
+
+ int new_rrule_length = 0;
+ if (strstr(origin, RRULE_KEYWORD_FREQ_WEEKLY) != NULL) {
+ new_rrule_length = strlen("RRULE:W") + strlen(str_interval) + strlen(" ") + strlen(str_byday) + strlen(" ") + strlen(str_end_time) + 1;
+ }
+ else if (strstr(origin, RRULE_KEYWORD_FREQ_MONTHLY) != NULL) {
+ new_rrule_length = strlen("RRULE:MD") + strlen(str_interval) + strlen(" ") + strlen(str_byday) + strlen(" ") + strlen(str_end_time) + 1;
+ }
+ else if (strstr(origin, RRULE_KEYWORD_FREQ_YEARLY) != NULL) {
+ new_rrule_length = strlen("RRULE:YD") + strlen(str_interval) + strlen(" ") + strlen(str_end_time) + 1;
+ }
+ else if (strstr(origin, RRULE_KEYWORD_FREQ_DAILY) != NULL) {
+ new_rrule_length = strlen("RRULE:D") + strlen(str_interval) + strlen(" ") + strlen(str_end_time) + 1;
+ }
+ else {
+ _DEBUG_ERROR("this is an undefined rrule type. origin = %s", origin);
+ goto return_part;
+ }
+
+ if (new_rrule_length <= 0) {
+ _DEBUG_ERROR("new_rrule_length(%d) <= 0", new_rrule_length);
+ goto return_part;
+ }
+
+ str_new_rrule = (char *)calloc(new_rrule_length, sizeof(char));
+ if (str_new_rrule == NULL) {
+ _DEBUG_ERROR("str_new_rrule calloc failed");
+ goto return_part;
+ }
+
+ if (strstr(origin, RRULE_KEYWORD_FREQ_WEEKLY) != NULL) {
+ snprintf(str_new_rrule, new_rrule_length, "RRULE:W%s %s %s", str_interval, str_byday, str_end_time);
+ }
+ else if (strstr(origin, RRULE_KEYWORD_FREQ_MONTHLY) != NULL) {
+ snprintf(str_new_rrule, new_rrule_length, "RRULE:MD%s %s %s", str_interval, str_byday, str_end_time);
+ }
+ else if (strstr(origin, RRULE_KEYWORD_FREQ_YEARLY) != NULL) {
+ snprintf(str_new_rrule, new_rrule_length, "RRULE:YD%s %s", str_interval, str_end_time);
+ }
+ else if (strstr(origin, RRULE_KEYWORD_FREQ_DAILY) != NULL) {
+ snprintf(str_new_rrule, new_rrule_length, "RRULE:D%s %s", str_interval, str_end_time);
+ }
+ else {
+ _DEBUG_ERROR("this is an undefined rrule type. origin = %s", origin);
+ goto return_part;
+ }
+
+ _DEBUG_INFO("str_new_rrule = %s", str_new_rrule);
+ _DEBUG_INFO("str_origin_rrule = %s", str_origin_rrule);
+
+ char *new_agent_data = replace_string(origin, str_origin_rrule, str_new_rrule);
+ origin = NULL;
+ origin = new_agent_data;
+
+return_part:
+
+ if (str_interval) {
+ free(str_interval);
+ str_interval = NULL;
+ }
+ if (str_byday) {
+ free(str_byday);
+ str_byday = NULL;
+ }
+ if (str_period_until) {
+ free(str_period_until);
+ str_period_until = NULL;
+ }
+ if (str_period_count) {
+ free(str_period_count);
+ str_period_count = NULL;
+ }
+ if (str_end_time) {
+ free(str_end_time);
+ str_end_time = NULL;
+ }
+ if (str_new_rrule) {
+ free(str_new_rrule);
+ str_new_rrule = NULL;
+ }
+
+ _DEBUG_INFO("origin = %s", origin);
+ _INNER_FUNC_EXIT;
+ return origin;
+}
+
+// usage / alarm converting
+if (strstr(temp_agent_data, "\r\nBEGIN:VALARM") != NULL) {
+ _DEBUG_INFO("alarm is founed");
+ temp_agent_data = _replace_alarm_data(temp_agent_data);
+}
+
+static char * _replace_alarm_data(char *origin)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if(origin == NULL, origin, "origin is NULL.");
+
+ int interval = 0;
+ char *str_new_alarm = NULL;
+ char *freq_loc = NULL;
+ char *str_trigger = NULL;
+ char *str_customized_trigger = NULL;
+ char *str_interval = NULL;
+ calendar_date_type_e cal_type = CALENDAR_DATE_TYPE_ONTIME;
+
+ if ((freq_loc = strstr(origin, BEGIN_ALARM_KEYWORD)) == NULL) {
+ _DEBUG_ERROR("there is not trigger data");
+ goto return_part;
+ }
+
+ char *temp = NULL;
+ if((temp = strstr(freq_loc, "BEGIN:VALARM\r\n")) == NULL) {
+ _DEBUG_ERROR("temp is NULL");
+ goto return_part;
+ }
+
+ char *temp2 = NULL;
+ if((temp2 = strstr(temp, "END:VALARM\r\n")) == NULL) {
+ _DEBUG_ERROR("temp2 is NULL");
+ goto return_part;
+ }
+
+ char str_origin_alarm[100] = {0,};
+ int origin_alarm_length = strlen(temp) - strlen(temp2) + 12; // '12' means of "END:VALARM\r\n"
+ if (origin_alarm_length <= 0) {
+ _DEBUG_ERROR("origin_alarm_length <= 0");
+ goto return_part;
+ }
+
+ strncpy(str_origin_alarm, temp, origin_alarm_length);
+ _DEBUG_INFO("str_origin_alarm = %s", str_origin_alarm);
+
+ // case 1. "TRIGGER;VALUE=DATE-TIME:" is an alarm that created by user
+ str_customized_trigger = _get_value_by_token(freq_loc, "TRIGGER;VALUE=DATE-TIME:", "\r\n");
+ if (str_customized_trigger != NULL) {
+ _DEBUG_INFO("str_customized_trigger is founded. str_customized_trigger = %s", str_customized_trigger);
+
+ str_new_alarm = (char *)calloc(30, sizeof(char));
+ if (str_new_alarm == NULL) {
+ _DEBUG_ERROR("new_date_time is null");
+ goto return_part;
+ }
+
+ snprintf(str_new_alarm, 30, "AALARM:%s\r\n", str_customized_trigger);
+ _DEBUG_INFO("str_new_alarm = %s", str_new_alarm);
+ char *new_agent_data = _replace_string(origin, str_origin_alarm, str_new_alarm);
+ origin = NULL;
+ origin = new_agent_data;
+ goto return_part;
+ }
+
+ // case 2. "TRIGGER:" is a normal alarm
+ str_trigger = _get_value_by_token(freq_loc, "TRIGGER:", "\r\n");
+ if (str_trigger == NULL || strlen(str_trigger) <= 0) {
+ _DEBUG_ERROR("str_trigger is null");
+ goto return_part;
+ }
+
+ char *temp_alarm = NULL;
+ char *temp_alarm2 = NULL;
+ if((temp_alarm = strstr(str_trigger, "P0W")) != NULL) {
+ cal_type = CALENDAR_DATE_TYPE_ONTIME;
+ interval = 0;
+ }
+ else if((temp_alarm = strstr(str_trigger, "PT")) != NULL) {
+ if((temp_alarm2 = strstr(temp_alarm, "H")) != NULL) {
+ cal_type = CALENDAR_DATE_TYPE_HOUR;
+ str_interval = _get_value_by_token(str_trigger, "PT", "H");
+ interval = atoi(str_interval);
+ }
+ else if((temp_alarm2 = strstr(temp_alarm, "M")) != NULL) {
+ cal_type = CALENDAR_DATE_TYPE_MINUTE;
+ str_interval = _get_value_by_token(str_trigger, "PT", "M");
+ interval = atoi(str_interval);
+ }
+ else {
+ _DEBUG_ERROR("wrong type, temp_alarm = %s", temp_alarm);
+ goto return_part;
+ }
+ }
+ else if((temp_alarm = strstr(str_trigger, "P")) != NULL) {
+ if((temp_alarm2 = strstr(temp_alarm, "D")) != NULL) {
+ cal_type = CALENDAR_DATE_TYPE_DAY;
+ str_interval = _get_value_by_token(str_trigger, "P", "D");
+ interval = atoi(str_interval);
+ }
+ else if((temp_alarm2 = strstr(temp_alarm, "W")) != NULL) {
+ cal_type = CALENDAR_DATE_TYPE_WEEK;
+ str_interval = _get_value_by_token(str_trigger, "P", "W");
+ interval = atoi(str_interval);
+ }
+ else {
+ _DEBUG_ERROR("wrong type, temp_alarm = %s", temp_alarm);
+ goto return_part;
+ }
+ }
+ else {
+ _DEBUG_ERROR("wrong type, temp_alarm = %s", temp_alarm);
+ goto return_part;
+ }
+
+ str_new_alarm = _calculate_date_time(origin, interval, cal_type);
+ if (str_new_alarm == NULL || strlen(str_new_alarm) <= 0) {
+ _DEBUG_ERROR("str_new_alarm is null");
+ goto return_part;
+ }
+
+ _DEBUG_INFO("str_new_alarm = %s", str_new_alarm);
+ _DEBUG_INFO("str_origin_alarm = %s", str_origin_alarm);
+
+ char *new_agent_data = _replace_string(origin, str_origin_alarm, str_new_alarm);
+ origin = NULL;
+ origin = new_agent_data;
+
+return_part:
+
+ if (str_trigger) {
+ free(str_trigger);
+ str_trigger = NULL;
+ }
+ if (str_customized_trigger) {
+ free(str_customized_trigger);
+ str_customized_trigger = NULL;
+ }
+ if (str_new_alarm) {
+ free(str_new_alarm);
+ str_new_alarm = NULL;
+ }
+ if (str_interval) {
+ free(str_interval);
+ str_interval = NULL;
+ }
+
+ _INNER_FUNC_EXIT;
+ _DEBUG_INFO("origin = %s", origin);
+ return origin;
+}
+
+
+static char * _calculate_date_time(char *origin, int value, calendar_date_type_e type)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if(origin == NULL, NULL, "origin is NULL");
+
+ _DEBUG_INFO("origin = %s", origin);
+ _DEBUG_INFO("value = %d", value);
+
+ UCalendar *ucal = NULL;
+ char *start_time = NULL;
+ char *new_date_time = NULL;
+ char *start_date_loc = NULL;
+ if ((start_date_loc = strstr(origin, DTSTART_KEYWORD)) == NULL) {
+ _DEBUG_ERROR("start_date_loc is null");
+ goto return_part;
+ }
+
+ char str_year[5] = {0,};
+ char str_month[3] = {0,};
+ char str_date[3] = {0,};
+ char str_hour[3] = {0,};
+ char str_minute[3] = {0,};
+ char str_second[3] = {0,};
+
+ /* example) 20130124T000000Z\r\n = 2013 01 24 T 00 00 00 Z \r\n */
+ strncpy(str_year, start_date_loc + strlen(DTSTART_KEYWORD), 4);
+ strncpy(str_month, start_date_loc + strlen(DTSTART_KEYWORD) + 4, 2);
+ strncpy(str_date, start_date_loc + strlen(DTSTART_KEYWORD) + 4 + 2, 2);
+ strncpy(str_hour, start_date_loc + strlen(DTSTART_KEYWORD) + 4 + 2 + 2 + 1, 2);
+ strncpy(str_minute, start_date_loc + strlen(DTSTART_KEYWORD) + 4 + 2 + 2 + 1 + 2, 2);
+ strncpy(str_second, start_date_loc + strlen(DTSTART_KEYWORD) + 4 + 2 + 2 + 1 + 2 + 2, 2);
+
+ int year = atoi(str_year);
+ int month = atoi(str_month);
+ int date = atoi(str_date);
+ int hour = atoi(str_hour);
+ int minute = atoi(str_minute);
+ int second = atoi(str_second);
+ long long int date_time = 0;
+
+ start_time = (char *)calloc(20, sizeof(char));
+ if (start_time == NULL) {
+ _DEBUG_ERROR("start_time is null");
+ goto return_part;
+ }
+
+ snprintf(start_time, 20, "%04d%02d%02dT%02d%02d%02dZ\r\n", year, month, date, hour, minute, second);
+ _DEBUG_INFO("start_time = %s", start_time);
+
+ UErrorCode status = U_ZERO_ERROR;
+ ucal = ucal_open(0, -1, uloc_getDefault(), UCAL_TRADITIONAL, &status);
+ if (U_FAILURE(status)) {
+ _DEBUG_ERROR("ucal_open failed (%s)", u_errorName(status));
+ goto return_part;
+ }
+
+ ucal_setAttribute(ucal, UCAL_LENIENT, 1);
+ ucal_setDateTime(ucal, year, month - 1, date, hour, minute, second, &status);
+ date_time = ucal_getMillis(ucal, &status);
+
+ switch (type) {
+ case CALENDAR_DATE_TYPE_ONTIME:
+ _DEBUG_INFO("CALENDAR_DATE_TYPE_ONTIME");
+ date_time = date_time / 1000;
+ break;
+ case CALENDAR_DATE_TYPE_WEEK:
+ _DEBUG_INFO("CALENDAR_DATE_TYPE_WEEK");
+ date_time = date_time / 1000;
+ date_time = date_time - (value*60*60*24*7);
+ break;
+ case CALENDAR_DATE_TYPE_DAY:
+ _DEBUG_INFO("CALENDAR_DATE_TYPE_DAY");
+ date_time = date_time / 1000;
+ date_time = date_time - (value*60*60*24);
+ break;
+ case CALENDAR_DATE_TYPE_HOUR:
+ _DEBUG_INFO("CALENDAR_DATE_TYPE_HOUR");
+ date_time = date_time / 1000;
+ date_time = date_time - (value*60*60);
+ break;
+ case CALENDAR_DATE_TYPE_MINUTE:
+ _DEBUG_INFO("CALENDAR_DATE_TYPE_MINUTE");
+ date_time = date_time / 1000;
+ date_time = date_time - (value*60);
+ break;
+ default:
+ _DEBUG_ERROR("%d is not supported type", type);
+ goto return_part;
+ break;
+ }
+
+ if (U_FAILURE(status)) {
+ _DEBUG_ERROR("ucal_setDateTime failed (%s)", u_errorName(status));
+ goto return_part;
+ }
+
+ ucal_setMillis(ucal, (date_time * 1000), &status);
+
+ year = month = date = hour = minute = second = 0;
+ year = ucal_get(ucal, UCAL_YEAR, &status);
+ month = ucal_get(ucal, UCAL_MONTH, &status) + 1;
+ date = ucal_get(ucal, UCAL_DATE, &status);
+ hour = ucal_get(ucal, UCAL_HOUR_OF_DAY, &status);
+ minute = ucal_get(ucal, UCAL_MINUTE, &status);
+ second = ucal_get(ucal, UCAL_SECOND, &status);
+
+ new_date_time = (char *)calloc(30, sizeof(char));
+ if (new_date_time == NULL) {
+ _DEBUG_ERROR("new_date_time is null");
+ goto return_part;
+ }
+
+ snprintf(new_date_time, 30, "AALARM:%04d%02d%02dT%02d%02d%02dZ\r\n", year, month, date, hour, minute, second);
+ _DEBUG_INFO("new_date_time = %s", new_date_time);
+
+return_part:
+ _DEBUG_INFO("return_part");
+
+ if(start_time) {
+ free(start_time);
+ start_time = NULL;
+ }
+ if(ucal) {
+ ucal_close(ucal);
+ ucal = NULL;
+ }
+
+ _INNER_FUNC_EXIT;
+ return new_date_time;
+}
+
+#endif
+
+char * get_value_by_token(const char *src, const char *token, const char *end_of_token)
+{
+ _INNER_FUNC_ENTER;
+ if (src == NULL || strlen(src) <= 0) {
+ _DEBUG_ERROR("src is null");
+ return NULL;
+ }
+
+ char *token_loc = NULL;
+ char *str_output = NULL;
+
+ if ((token_loc = strstr(src, token)) != NULL) {
+ char *str_temp = strstr(token_loc, end_of_token);
+ if (str_temp != NULL) {
+ _DEBUG_INFO("token_loc = %s", token_loc);
+ _DEBUG_INFO("token = %s", token);
+ _DEBUG_INFO("str_temp = %s", str_temp);
+ int ret_str_length = strlen(token_loc) - strlen(token) - strlen(str_temp);
+ if (ret_str_length <= 0) {
+ _DEBUG_ERROR("ret_str_length(%d) <= 0", ret_str_length);
+ goto return_part;
+ }
+ str_output = (char *)calloc(ret_str_length, sizeof(char));
+ if (str_output == NULL) {
+ _DEBUG_ERROR("calloc failed");
+ goto return_part;
+ }
+ memcpy(str_output, token_loc + strlen(token), ret_str_length);
+ }
+ }
+
+return_part:
+ _INNER_FUNC_EXIT;
+ return str_output;
+}
+
+char * replace_string(char *origin, const char *src, const char *dest)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((origin == NULL || strlen(origin) <= 0), NULL, "origin is NULL");
+ retvm_if((src == NULL || strlen(src) <= 0), NULL, "src is NULL");
+ retvm_if((dest == NULL || strlen(dest) <= 0), NULL, "dest is NULL");
+
+ _DEBUG_INFO("origin = %s", origin);
+ _DEBUG_INFO("src = %s", src);
+ _DEBUG_INFO("dest = %s", dest);
+
+ char *str_top = NULL;
+
+ if ((str_top = strstr(origin, src)) == NULL) {
+ _DEBUG_INFO("%s is not founed", src);
+ return origin;
+ }
+
+ int top_length = strlen(origin) - strlen(str_top);
+ int middle_length = strlen(dest);
+ int down_length = strlen(origin) - top_length - strlen(src);
+ int new_str_length = top_length + middle_length + down_length + 1;
+ if (new_str_length <= 0) {
+ _DEBUG_ERROR("new_str_length(%d) <= 0", new_str_length);
+ return origin;
+ }
+ char *new_str = (char *)calloc(new_str_length, sizeof(char));
+ if (new_str == NULL) {
+ _DEBUG_ERROR("calloc is failed.");
+ return origin;
+ }
+
+ memset(new_str, 0, new_str_length);
+ memcpy(new_str, origin, top_length);
+ memcpy(new_str + top_length, dest, middle_length);
+ memcpy(new_str + top_length + middle_length, origin + top_length + strlen(src), down_length);
+
+ if (origin != NULL) {
+ free(origin);
+ origin = NULL;
+ }
+
+ _DEBUG_INFO("new_str = %s", new_str);
+ _INNER_FUNC_EXIT;
+ return new_str;
+}
+
+char * remove_timezone(char *origin)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if((origin == NULL || strlen(origin) <= 0), NULL, "origin is NULL");
+
+ _DEBUG_INFO("origin = %s", origin);
+
+ char *str_timezone = NULL;
+ char *str_temp = NULL;
+
+ if ((str_temp = strstr(origin, "\r\nDTSTART;TZID=")) != NULL) {
+ _DEBUG_INFO("str_temp = %s", str_temp);
+ str_timezone = get_value_by_token(str_temp, "\r\nDTSTART", ":");
+ _DEBUG_INFO("str_timezone = %s", str_timezone);
+ strcat(str_timezone, ":");
+ _DEBUG_INFO("str_timezone = %s", str_timezone);
+ origin = replace_string(origin, str_timezone, ":");
+
+ if (str_timezone)
+ free(str_timezone);
+ str_timezone = NULL;
+ }
+
+ if ((str_temp = strstr(origin, "\r\nDTEND;TZID=")) != NULL) {
+ _DEBUG_INFO("str_temp = %s", str_temp);
+ str_timezone = get_value_by_token(str_temp, "\r\nDTEND", ":");
+ _DEBUG_INFO("str_timezone = %s", str_timezone);
+ strcat(str_timezone, ":");
+ _DEBUG_INFO("str_timezone = %s", str_timezone);
+ origin = replace_string(origin, str_timezone, ":");
+
+ if (str_timezone)
+ free(str_timezone);
+ str_timezone = NULL;
+ }
+
+ _DEBUG_INFO("origin = %s", origin);
+ _INNER_FUNC_EXIT;
+ return origin;
+}
+
+char * insert_exdate_data(const char *origin, sync_agent_calendar_exdate_t *exdate_struct, int index)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if((origin == NULL || strlen(origin) <= 0), NULL, "origin is NULL");
+ retvm_if(exdate_struct == NULL, NULL, "exdate_struct is NULL");
+ retvm_if(index < 0, NULL, "index < 0");
+
+ char *old_str = NULL;
+ char *new_str = NULL;
+ // 1. copy from parent vcalendar string
+ char *str_child_vcalendar = strdup((char *)(origin));
+
+ if (exdate_struct->exdate_type != CALENDAR_EXDATE_TYPE_DELETED && exdate_struct->exdate_type != CALENDAR_EXDATE_TYPE_UPDATED) {
+ _DEBUG_ERROR("exdate_type(%d) is wrong", exdate_struct->exdate_type);
+ goto return_part;
+ }
+
+ _DEBUG_INFO("origin = %s", origin);
+ _DEBUG_INFO("cal_exdate_type = %d", exdate_struct->exdate_type);
+
+ if (exdate_struct->exdate_type == CALENDAR_EXDATE_TYPE_DELETED) {
+ _DEBUG_INFO("delete");
+ // 2. remove SUMMARY / RRULE / ALARM / EXDATE
+ // 2-1. remove 'SUMMARY'
+ if ((old_str = strstr(str_child_vcalendar, SUMMARY_KEYWORD)) != NULL) {
+ _DEBUG_INFO("summary keyword");
+ _DEBUG_INFO("old_str = %s", old_str);
+ if ((new_str = strstr(old_str+2, "\r\n")) != NULL) {
+ _DEBUG_INFO("new_str = %s", new_str);
+ str_child_vcalendar = replace_string(str_child_vcalendar, old_str, new_str);
+ _DEBUG_INFO("str_child_vcalendar = %s", str_child_vcalendar);
+ }
+ }
+
+ // 2-2. remove 'RRULE'
+ if ((old_str = strstr(str_child_vcalendar, RRULE_KEYWORD)) != NULL) {
+ _DEBUG_INFO("rrule keyword");
+ _DEBUG_INFO("old_str = %s", old_str);
+ if ((new_str = strstr(old_str+2, "\r\n")) != NULL) {
+ _DEBUG_INFO("new_str = %s", new_str);
+ str_child_vcalendar = replace_string(str_child_vcalendar, old_str, new_str);
+ _DEBUG_INFO("str_child_vcalendar = %s", str_child_vcalendar);
+ }
+ }
+
+ // 2-3. remove 'ALARM'
+ if ((old_str = strstr(str_child_vcalendar, AALARM_KEYWORD)) != NULL) {
+ _DEBUG_INFO("alarm keyword");
+ _DEBUG_INFO("old_str = %s", old_str);
+ if ((new_str = strstr(old_str+2, "\r\n")) != NULL) {
+ _DEBUG_INFO("new_str = %s", new_str);
+ str_child_vcalendar = replace_string(str_child_vcalendar, old_str, new_str);
+ _DEBUG_INFO("str_child_vcalendar = %s", str_child_vcalendar);
+ }
+ }
+
+ // 2-4. remove 'EXDATE' array
+ if ((old_str = strstr(str_child_vcalendar, EXDATE_KEYWORD)) != NULL) {
+ _DEBUG_INFO("exdate keyword");
+ _DEBUG_INFO("old_str = %s", old_str);
+ if ((new_str = strstr(old_str+2, "\r\nX-EXTYPE:1")) != NULL) {
+ _DEBUG_INFO("new_str = %s", new_str);
+ str_child_vcalendar = replace_string(str_child_vcalendar, old_str, new_str);
+ _DEBUG_INFO("str_child_vcalendar = %s", str_child_vcalendar);
+ }
+ }
+
+ // 3. change DTSTART / DTEND
+ // example ) DTSTART:20130125T000000Z / DTEND:20130125T003000Z / EXDATE:20130201T000000Z => DTSTART:20130201T000000Z / DTEND:20130201T003000Z
+ // 3-1. change DTSTART : DTSTART = EXDATE
+ char *temp = NULL;
+ if ((temp = strstr(str_child_vcalendar, DTSTART_KEYWORD)) != NULL) {
+ _DEBUG_INFO("start keyword");
+ _DEBUG_INFO("temp = %s", temp );
+
+ old_str = get_value_by_token(temp + 2, "DTSTART:", "\r\n");// '2' means strlen("\r\n")
+ if (old_str == NULL) {
+ _DEBUG_ERROR("old_str is null");
+ goto return_part;
+ }
+ _DEBUG_INFO("old_str = %s", old_str);
+ new_str = (char*)g_list_nth_data(exdate_struct->exdate_list, index);
+ if (new_str == NULL) {
+ _DEBUG_ERROR("new_str is NULL");
+ goto return_part;
+ }
+ _DEBUG_INFO("new_str = %s", new_str);
+ str_child_vcalendar = replace_string(str_child_vcalendar, old_str, new_str);
+ _DEBUG_INFO("str_child_vcalendar = %s", str_child_vcalendar);
+ }
+
+ // 3-2. change DTEND : DTEND = date of EXDATE + time of origin DTEND
+ temp = NULL;
+ if ((temp = strstr(str_child_vcalendar, DTEND_KEYWORD)) != NULL) {
+ _DEBUG_INFO("end keyword");
+ _DEBUG_INFO("temp = %s", temp );
+
+ old_str = get_value_by_token(temp + 2, "DTEND:", "\r\n");// '2' means strlen("\r\n")
+ if (old_str == NULL) {
+ _DEBUG_ERROR("old_str is null");
+ goto return_part;
+ }
+ _DEBUG_INFO("old_str = %s", old_str);
+ char *exdate_str = (char*)g_list_nth_data(exdate_struct->exdate_list, index);
+ if (exdate_str == NULL) {
+ _DEBUG_ERROR("exdate_str is NULL");
+ goto return_part;
+ }
+ _DEBUG_INFO("exdate_str = %s", exdate_str);
+ new_str = (char *)calloc(strlen(exdate_str), sizeof(char));
+ if (new_str == NULL) {
+ _DEBUG_ERROR("new_str calloc failed");
+ goto return_part;
+ }
+
+ memcpy(new_str, exdate_str, 8);
+ memcpy(new_str + 8, old_str + 8, 8);
+ _DEBUG_INFO("new_str = %s", new_str);
+ str_child_vcalendar = replace_string(str_child_vcalendar, old_str, new_str);
+ _DEBUG_INFO("str_child_vcalendar = %s", str_child_vcalendar);
+ if (new_str) {
+ free(new_str);
+ new_str = NULL;
+ }
+ _DEBUG_INFO("str_child_vcalendar = %s", str_child_vcalendar);
+ }
+
+ // 4. insert EXDATE
+ if ((temp = strstr(str_child_vcalendar, END_VEVENT_KEYWORD)) != NULL) {
+ _DEBUG_INFO("EXTYPE keyword");
+ _DEBUG_INFO("temp = %s", temp);
+
+ char *exdate_str = (char*)g_list_nth_data(exdate_struct->exdate_list, index);
+ if (exdate_str == NULL) {
+ _DEBUG_ERROR("exdate_str is NULL");
+ goto return_part;
+ }
+ _DEBUG_INFO("exdate_str = %s", exdate_str);
+
+ new_str = (char *)calloc(100, sizeof(char));
+ if (new_str == NULL) {
+ _DEBUG_ERROR("new_str calloc failed");
+ goto return_part;
+ }
+ _DEBUG_INFO("str_child_vcalendar = %s", str_child_vcalendar);
+ char *str_end_vevent = "\r\nEND:VEVENT";
+ snprintf(new_str, 100, "%s%s%s", EXDATE_KEYWORD, exdate_str, str_end_vevent);
+ _DEBUG_INFO("new_str = %s", new_str);
+ str_child_vcalendar = replace_string(str_child_vcalendar, str_end_vevent, new_str);
+ _DEBUG_INFO("str_child_vcalendar = %s", str_child_vcalendar);
+ if (new_str) {
+ free(new_str);
+ new_str = NULL;
+ }
+ _DEBUG_INFO("str_child_vcalendar = %s", str_child_vcalendar);
+ }
+
+ if ((temp = strstr(str_child_vcalendar, EXTYPE_DELETE_KEYWORD)) != NULL) {
+ str_child_vcalendar = replace_string(str_child_vcalendar, EXTYPE_DELETE_KEYWORD, "UID:000000000000000000000000000000000000000000000000\r\nX-EXTYPE:1");
+ _DEBUG_INFO("str_child_vcalendar = %s", str_child_vcalendar);
+ }
+ }
+ else if (exdate_struct->exdate_type == CALENDAR_EXDATE_TYPE_UPDATED) {
+ _DEBUG_INFO("update");
+ // 2. remove RRULE / EXDATE
+ // 2-1. remove 'RRULE'
+ if ((old_str = strstr(str_child_vcalendar, RRULE_KEYWORD)) != NULL) {
+ _DEBUG_INFO("rrule keyword");
+ _DEBUG_INFO("old_str = %s", old_str);
+ if ((new_str = strstr(old_str+2, "\r\n")) != NULL) {
+ _DEBUG_INFO("new_str = %s", new_str);
+ str_child_vcalendar = replace_string(str_child_vcalendar, old_str, new_str);
+ _DEBUG_INFO("str_child_vcalendar = %s", str_child_vcalendar);
+ }
+ }
+
+ // 2-2. remove 'EXDATE' array
+ if ((old_str = strstr(str_child_vcalendar, EXDATE_KEYWORD)) != NULL) {
+ _DEBUG_INFO("exdate keyword");
+ _DEBUG_INFO("old_str = %s", old_str);
+ if ((new_str = strstr(old_str+2, "\r\n")) != NULL) {
+ _DEBUG_INFO("new_str = %s", new_str);
+ str_child_vcalendar = replace_string(str_child_vcalendar, old_str, new_str);
+ _DEBUG_INFO("str_child_vcalendar = %s", str_child_vcalendar);
+ }
+ }
+
+ // 3. change DTSTART / DTEND
+ // example ) DTSTART:20130125T000000Z / DTEND:20130125T003000Z / EXDATE:20130201T000000Z => DTSTART:20130201T000000Z / DTEND:20130201T003000Z
+ // 3-1. change DTSTART : DTSTART = EXDATE
+ char *temp = NULL;
+ if ((temp = strstr(str_child_vcalendar, DTSTART_KEYWORD)) != NULL) {
+ _DEBUG_INFO("start keyword");
+ _DEBUG_INFO("temp = %s", temp );
+
+ old_str = get_value_by_token(temp + 2, "DTSTART:", "\r\n");// '2' means strlen("\r\n")
+ if (old_str == NULL) {
+ _DEBUG_ERROR("old_str is null");
+ goto return_part;
+ }
+ _DEBUG_INFO("old_str = %s", old_str);
+ new_str = (char*)g_list_nth_data(exdate_struct->exdate_list, index);
+ if (new_str == NULL) {
+ _DEBUG_ERROR("new_str is NULL");
+ goto return_part;
+ }
+ _DEBUG_INFO("new_str = %s", new_str);
+ str_child_vcalendar = replace_string(str_child_vcalendar, old_str, new_str);
+ _DEBUG_INFO("str_child_vcalendar = %s", str_child_vcalendar);
+ }
+
+ // 3-2. change DTEND : DTEND = date of EXDATE + time of origin DTEND
+ temp = NULL;
+ if ((temp = strstr(str_child_vcalendar, DTEND_KEYWORD)) != NULL) {
+ _DEBUG_INFO("end keyword");
+ _DEBUG_INFO("temp = %s", temp );
+
+ old_str = get_value_by_token(temp + 2, "DTEND:", "\r\n");// '2' means strlen("\r\n")
+ if (old_str == NULL) {
+ _DEBUG_ERROR("old_str is null");
+ goto return_part;
+ }
+ _DEBUG_INFO("old_str = %s", old_str);
+ char *exdate_str = (char*)g_list_nth_data(exdate_struct->exdate_list, index);
+ if (exdate_str == NULL) {
+ _DEBUG_ERROR("exdate_str is NULL");
+ goto return_part;
+ }
+ _DEBUG_INFO("exdate_str = %s", exdate_str);
+ new_str = (char *)calloc(strlen(exdate_str), sizeof(char));
+ if (new_str == NULL) {
+ _DEBUG_ERROR("new_str calloc failed");
+ goto return_part;
+ }
+
+ memcpy(new_str, exdate_str, 8);
+ memcpy(new_str + 8, old_str + 8, 8);
+ _DEBUG_INFO("new_str = %s", new_str);
+ str_child_vcalendar = replace_string(str_child_vcalendar, old_str, new_str);
+ _DEBUG_INFO("str_child_vcalendar = %s", str_child_vcalendar);
+ if (new_str) {
+ free(new_str);
+ new_str = NULL;
+ }
+ _DEBUG_INFO("str_child_vcalendar = %s", str_child_vcalendar);
+ }
+
+ // 4. insert EXDATE
+ if ((temp = strstr(str_child_vcalendar, END_VEVENT_KEYWORD)) != NULL) {
+ _DEBUG_INFO("EXTYPE keyword");
+ _DEBUG_INFO("temp = %s", temp);
+
+ char *exdate_str = (char*)g_list_nth_data(exdate_struct->exdate_list, index);
+ if (exdate_str == NULL) {
+ _DEBUG_ERROR("exdate_str is NULL");
+ goto return_part;
+ }
+ _DEBUG_INFO("exdate_str = %s", exdate_str);
+
+ new_str = (char *)calloc(100, sizeof(char));
+ if (new_str == NULL) {
+ _DEBUG_ERROR("new_str calloc failed");
+ goto return_part;
+ }
+ _DEBUG_INFO("str_child_vcalendar = %s", str_child_vcalendar);
+ char *str_end_vevent = "\r\nEND:VEVENT";
+ snprintf(new_str, 100, "%s%s%s", EXDATE_KEYWORD, exdate_str, str_end_vevent);
+ _DEBUG_INFO("new_str = %s", new_str);
+ str_child_vcalendar = replace_string(str_child_vcalendar, str_end_vevent, new_str);
+ _DEBUG_INFO("str_child_vcalendar = %s", str_child_vcalendar);
+ if (new_str) {
+ free(new_str);
+ new_str = NULL;
+ }
+ _DEBUG_INFO("str_child_vcalendar = %s", str_child_vcalendar);
+ }
+
+ if ((temp = strstr(str_child_vcalendar, EXTYPE_UPDATE_KEYWORD)) != NULL) {
+ str_child_vcalendar = replace_string(str_child_vcalendar, EXTYPE_UPDATE_KEYWORD, "UID:000000000000000000000000000000000000000000000000\r\nX-EXTYPE:2");
+ _DEBUG_INFO("str_child_vcalendar = %s", str_child_vcalendar);
+ }
+ }
+ else {
+ _DEBUG_INFO("cal_exdate_type(%d) is wrong type", exdate_struct->exdate_type);
+ }
+
+return_part:
+ _INNER_FUNC_EXIT;
+ _DEBUG_INFO("last str_child_vcalendar = %s", str_child_vcalendar);
+ return str_child_vcalendar;
+}
+
+void insert_allday_data(const char *origin, calendar_record_h calendar_record)
+{
+ _INNER_FUNC_ENTER;
+ retm_if((origin == NULL || strlen(origin) <= 0), "origin is NULL");
+ retm_if(calendar_record == NULL, "calendar_record is NULL");
+
+ int service_ret = CALENDAR_ERROR_NONE;
+ char *uri = NULL;
+
+ service_ret = calendar_record_get_uri_p(calendar_record, &uri);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_uri_p() Fail! : err[%d]", service_ret);
+ goto return_part;
+ }
+
+ if (strncmp(uri, _calendar_event._uri, strlen(_calendar_event._uri))) {
+ _DEBUG_ERROR("this is not event");
+ goto return_part;
+ }
+
+ calendar_time_s cal_time_start = { 0, };
+ calendar_time_s cal_time_end = { 0, };
+ int year = 0;
+ int month = 0;
+ int day = 0;
+
+ service_ret = calendar_record_get_caltime(calendar_record, _calendar_event.start_time, &cal_time_start);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_caltime() Fail: err[%d]", service_ret);
+ goto return_part;
+ }
+
+ char *start_date_loc = NULL;
+ if ((start_date_loc = strstr(origin, DTSTART_KEYWORD)) == NULL) {
+ _DEBUG_ERROR("start_date_loc is null");
+ goto return_part;
+ }
+
+ char str_year_start[5] = {0,};
+ char str_month_start[3] = {0,};
+ char str_date_start[3] = {0,};
+
+ /* example) 20130124T000000Z\r\n = 2013 01 24 T 00 00 00 Z \r\n */
+ strncpy(str_year_start, start_date_loc + strlen(DTSTART_KEYWORD), 4);
+ strncpy(str_month_start, start_date_loc + strlen(DTSTART_KEYWORD) + 4, 2);
+ strncpy(str_date_start, start_date_loc + strlen(DTSTART_KEYWORD) + 4 + 2, 2);
+
+ year = atoi(str_year_start);
+ month = atoi(str_month_start);
+ day = atoi(str_date_start);
+
+ _DEBUG_INFO("start time : year = %d, month = %d, day = %d", year, month, day);
+ cal_time_start.type = CALENDAR_TIME_LOCALTIME;
+ cal_time_start.time.date.year = year;
+ cal_time_start.time.date.month = month;
+ cal_time_start.time.date.mday = day;
+
+ service_ret = calendar_record_set_caltime(calendar_record, _calendar_event.start_time, cal_time_start);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_set_caltime() Fail: err[%d]", service_ret);
+ goto return_part;
+ }
+
+ service_ret = calendar_record_get_caltime(calendar_record, _calendar_event.end_time, &cal_time_end);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_caltime() Fail: err[%d]", service_ret);
+ goto return_part;
+ }
+
+ char *end_date_loc = NULL;
+ if ((end_date_loc = strstr(origin, DTEND_KEYWORD)) == NULL) {
+ _DEBUG_ERROR("end_date_loc is null");
+ goto return_part;
+ }
+
+ char str_year_end[5] = {0,};
+ char str_month_end[3] = {0,};
+ char str_date_end[3] = {0,};
+
+ /* example) 20130124T000000Z\r\n = 2013 01 24 T 00 00 00 Z \r\n */
+ strncpy(str_year_end, end_date_loc + strlen(DTEND_KEYWORD), 4);
+ strncpy(str_month_end, end_date_loc + strlen(DTEND_KEYWORD) + 4, 2);
+ strncpy(str_date_end, end_date_loc + strlen(DTEND_KEYWORD) + 4 + 2, 2);
+
+ year = atoi(str_year_end);
+ month = atoi(str_month_end);
+ day = atoi(str_date_end);
+
+ _DEBUG_INFO("end time : year = %d, month = %d, day = %d", year, month, day);
+ cal_time_end.type = CALENDAR_TIME_LOCALTIME;
+ cal_time_end.time.date.year = year;
+ cal_time_end.time.date.month = month;
+ cal_time_end.time.date.mday = day;
+
+ service_ret = calendar_record_set_caltime(calendar_record, _calendar_event.end_time, cal_time_end);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_set_caltime() Fail: err[%d]", service_ret);
+ goto return_part;
+ }
+
+return_part:
+ _INNER_FUNC_EXIT;
+ return;
+}
+
+EXPORT_API char * has_image_import(const char *origin)
+{
+ _INNER_FUNC_ENTER;
+
+ char *temp_image_path = NULL;
+ char *image_path = NULL;
+
+ if (strstr(origin, IMAGE_KEYWORD_PREFIX_PHOTO) == NULL && strstr(origin, IMAGE_KEYWORD_PREFIX_SNOTE) == NULL) {
+ _DEBUG_INFO("this calendar has not an image");
+ goto return_part;
+ }
+
+ temp_image_path = get_value_by_token(origin, IMAGE_KEYWORD_BEGIN_PATH, IMAGE_KEYWORD_END_PATH);
+
+ if (strstr(temp_image_path, INTERNAL_MEMORY_CONVERTED) != NULL) {
+ image_path = replace_string(temp_image_path, INTERNAL_MEMORY_CONVERTED, INTERNAL_MEMORY_ORIGIN);
+ }
+ else if (strstr(temp_image_path, EXTERNAL_MEMORY_CONVERTED) != NULL) {
+ image_path = replace_string(temp_image_path, EXTERNAL_MEMORY_CONVERTED, EXTERNAL_MEMORY_ORIGIN);
+ }
+ else if (strstr(temp_image_path, SNOTE_MEMORY_ORIGIN) != NULL) {
+ image_path = strdup(temp_image_path);
+ }
+ else {
+ _DEBUG_ERROR("there is an error. origin = %s", origin);
+ goto return_part;
+ }
+
+return_part:
+ if (image_path)
+ _DEBUG_INFO("image_path = %s", image_path);
+ _INNER_FUNC_EXIT;
+ return image_path;
+}
+
+EXPORT_API char * has_image_export(calendar_record_h cal_record)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if(cal_record == NULL, NULL, "cal_record is NULL");
+
+ calendar_record_h image_record = NULL;
+ unsigned int child_record_count = 0;
+ int i = 0;
+ int service_ret = CALENDAR_ERROR_NONE;
+ char *image_key = NULL;
+ char *image_path = NULL;
+
+ char *uri = NULL;
+ service_ret = calendar_record_get_uri_p(cal_record, &uri);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_uri_p() Fail! : err[%d]", service_ret);
+ goto return_part;
+ }
+ _DEBUG_INFO("uri = %s", uri);
+ _DEBUG_INFO("_calendar_event.uri = %s", _calendar_event._uri);
+
+ service_ret = calendar_record_get_child_record_count(cal_record, _calendar_event.extended, &child_record_count);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_child_record_count() Fail: err[%d]", service_ret);
+ goto return_part;
+ }
+
+ for (i = 0; i < child_record_count; i++) {
+ service_ret = calendar_record_get_child_record_at_p(cal_record, _calendar_event.extended, i, &image_record);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_child_record_at_p() Fail: err[%d]", service_ret);
+ goto return_part;
+ }
+
+ service_ret = calendar_record_get_str_p(image_record, _calendar_extended_property.key, &image_key);
+ if (service_ret != CALENDAR_ERROR_NONE || image_key == NULL || strlen(image_key) <= 0) {
+ _DEBUG_ERROR("calendar_record_get_str_p is failed(%d)", service_ret);
+ goto return_part;
+ }
+
+ if (strcmp(image_key, CALENDAR_IMAGE_KEYWORD_SNOTE) == 0 || strcmp(image_key, CALENDAR_IMAGE_KEYWORD_PHOTO) == 0) {
+ _DEBUG_INFO("image is founded. image_key = %s", image_key);
+ service_ret = calendar_record_get_str(image_record, _calendar_extended_property.value, &image_path);
+ if (service_ret != CALENDAR_ERROR_NONE || image_path == NULL || strlen(image_path) <= 0) {
+ _DEBUG_ERROR("calendar_record_get_str_p is failed(%d)", service_ret);
+ image_path = NULL;
+ goto return_part;
+ }
+ _DEBUG_INFO("image_path = %s", image_path);
+ continue;
+ }
+ }
+
+return_part:
+ _INNER_FUNC_EXIT;
+ return image_path;
+}
+
+// "EXTYPE" setting, '1' means deleted, '2' means updated : it should be excuted before calendar_vcalendar_make_from_records
+void get_exdate_data(calendar_record_h cal_record, sync_agent_calendar_exdate_t *exdate_struct)
+{
+ _INNER_FUNC_ENTER;
+ retm_if(cal_record == NULL, "cal_record is NULL");
+ retm_if(exdate_struct == NULL, "exdate_struct is NULL");
+
+ calendar_record_h extended_exdate = NULL;
+ char *exdate = NULL;
+ char *recurrence_id = NULL;
+ int service_ret = CALENDAR_ERROR_NONE;
+ int original_event_id = 0;
+
+ exdate_struct->exdate_type = CALENDAR_EXDATE_TYPE_NONE;
+
+
+ char *uri = NULL;
+ service_ret = calendar_record_get_uri_p(cal_record, &uri);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_uri_p() Fail! : err[%d]", service_ret);
+ goto return_part;
+ }
+ _DEBUG_INFO("uri = %s", uri);
+
+ // 1. delete : if 'exdate' value is exist, there are deleted item.
+ service_ret = calendar_record_get_str(cal_record, _calendar_event.exdate, &exdate);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_create() Fail!: err[%d]", service_ret);
+ goto return_part;
+ }
+ _DEBUG_INFO("exdate = %s", exdate);
+
+ if (exdate != NULL && strlen(exdate) > 0) {
+ _DEBUG_INFO("EXTYPE:DELETE setting start");
+ service_ret = calendar_record_create(_calendar_extended_property._uri, &extended_exdate);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_create() Fail!: err[%d]", service_ret);
+ goto return_part;
+ }
+ service_ret = calendar_record_set_str(extended_exdate, _calendar_extended_property.key, "X-EXTYPE");
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_set_str() Fail!: err[%d]", service_ret);
+ goto return_part;
+ }
+ service_ret = calendar_record_set_str(extended_exdate, _calendar_extended_property.value, ":1");
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_set_str() Fail!: err[%d]", service_ret);
+ goto return_part;
+ }
+ service_ret = calendar_record_add_child_record(cal_record, _calendar_event.extended, extended_exdate);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_add_child_record() Fail!: err[%d]", service_ret);
+ goto return_part;
+ }
+
+ exdate_struct->exdate_type = CALENDAR_EXDATE_TYPE_DELETED;
+ char *str_exdate_loc = NULL;
+ int exdate_count = 0;
+ int exdate_loc = 0;
+ while (exdate_loc < strlen(exdate)) {
+ _DEBUG_INFO("111111111111 exdate_loc = %d", exdate_loc);
+ _DEBUG_INFO("111111111111 strlen(exdate) = %d", strlen(exdate));
+ int one_exdate_length = 0;
+ if ((str_exdate_loc = strstr(exdate + exdate_loc, ",")) != NULL) {
+ one_exdate_length = strlen(exdate) - strlen(str_exdate_loc) - (exdate_count*(DATE_TIME_LENGTH+1));
+ }
+ else {
+ one_exdate_length = strlen(exdate) - exdate_loc;
+ }
+ _DEBUG_INFO("str_exdate_loc = %s", str_exdate_loc);
+ if (one_exdate_length <= 0) {
+ _DEBUG_ERROR("one_exdate_length (%d) <= 0", one_exdate_length);
+ continue;
+ }
+ char *str_one_exdate = (char *)calloc(one_exdate_length, sizeof(char));
+ if (str_one_exdate == NULL) {
+ _DEBUG_ERROR("str_one_exdate calloc is failed.");
+ continue;
+ }
+ memcpy(str_one_exdate, exdate + exdate_loc, one_exdate_length);
+ exdate_loc += (one_exdate_length+1); // '1' meaning of ',' length
+ exdate_struct->exdate_list = g_list_append(exdate_struct->exdate_list, str_one_exdate);
+ exdate_count++;
+ _DEBUG_INFO("str_one_exdate = %s", str_one_exdate);
+ _DEBUG_INFO("one_exdate_length = %d", one_exdate_length);
+ _DEBUG_INFO("exdate_loc = %d", exdate_loc);
+ _DEBUG_INFO("exdate_count = %d\n\n", exdate_count);
+ }
+
+ _DEBUG_INFO("exdate_loc = %d", exdate_loc);
+ _DEBUG_INFO("exdate_count = %d", exdate_count);
+ exdate_struct->exdate_count = exdate_count;
+ _DEBUG_INFO("EXTYPE:DELETE setting end");
+ }
+
+ _DEBUG_INFO("222222222");
+ // 2. update : if 'origianl_event_id' and 'recurrence_id' value are exist, there are updated item.
+ service_ret = calendar_record_get_int(cal_record, _calendar_event.original_event_id, &original_event_id);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_create() Fail!: err[%d]", service_ret);
+ goto return_part;
+ }
+ _DEBUG_INFO("original_event_id = %d", original_event_id);
+
+ service_ret = calendar_record_get_str(cal_record, _calendar_event.recurrence_id, &recurrence_id);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_list_create() Fail!: err[%d]", service_ret);
+ goto return_part;
+ }
+ _DEBUG_INFO("recurrence_id = %s", recurrence_id);
+
+ if (original_event_id > 0 && recurrence_id != NULL && strlen(recurrence_id) > 0) {
+ _DEBUG_INFO("EXTYPE:UPDATE setting start");
+ service_ret = calendar_record_create(_calendar_extended_property._uri, &extended_exdate);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_create() Fail!: err[%d]", service_ret);
+ goto return_part;
+ }
+ service_ret = calendar_record_set_str(extended_exdate, _calendar_extended_property.key, "X-EXTYPE");
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_set_str() Fail!: err[%d]", service_ret);
+ goto return_part;
+ }
+ service_ret = calendar_record_set_str(extended_exdate, _calendar_extended_property.value, ":2");
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_set_str() Fail!: err[%d]", service_ret);
+ goto return_part;
+ }
+ service_ret = calendar_record_add_child_record(cal_record, _calendar_event.extended, extended_exdate);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_add_child_record() Fail!: err[%d]", service_ret);
+ goto return_part;
+ }
+ exdate_struct->exdate_type = CALENDAR_EXDATE_TYPE_UPDATED;
+ _DEBUG_INFO("EXTYPE:UPDATE setting end");
+ }
+
+return_part:
+ _INNER_FUNC_EXIT;
+ return;
+}
+
+char * replace_max_rrule_data(char *origin)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if(origin == NULL, origin, "origin is NULL.");
+
+ char *temp = NULL;
+ char *temp_rrule = NULL;
+ char *str_old_rrule = NULL;
+ char *str_new_rrule = NULL;
+
+ if ((temp = strstr(origin, RRULE_KEYWORD)) == NULL) {
+ _DEBUG_INFO("this vcalendar hasn't rrule data");
+ goto return_part;
+ }
+
+ str_old_rrule = get_value_by_token(temp + 2, "RRULE:", "\r\n");// '2' means strlen("\r\n")
+ if (str_old_rrule == NULL) {
+ _DEBUG_ERROR("str_old_rrule is null");
+ goto return_part;
+ }
+
+ if (strstr(str_old_rrule, MAX_RRULE_DATE_KEYWORD) == NULL) {
+ _DEBUG_INFO("this vcalendar has rrule data, But it's not until=NONE rrule");
+ goto return_part;
+ }
+ _DEBUG_INFO("this vcalendar has until=NONE rrule");
+
+ temp_rrule = get_value_by_token(temp, RRULE_KEYWORD, MAX_RRULE_DATE_KEYWORD);
+ if (temp_rrule == NULL) {
+ _DEBUG_ERROR("temp_rrule is null");
+ goto return_part;
+ }
+
+ str_new_rrule = (char *)calloc(strlen(temp_rrule) + 2, sizeof(char));
+ if (str_new_rrule == NULL) {
+ _DEBUG_ERROR("str_new_rrule calloc failed");
+ goto return_part;
+ }
+
+ // every eternal rrule data must have '#0' at the end of string (Calendar-Svc recommend)
+ snprintf(str_new_rrule, strlen(temp_rrule) + 2, "%s#0", temp_rrule);
+ origin = replace_string(origin, str_old_rrule, str_new_rrule);
+
+return_part:
+ if(str_old_rrule) {
+ free(str_old_rrule);
+ str_old_rrule = NULL;
+ }
+ if(str_new_rrule) {
+ free(str_new_rrule);
+ str_new_rrule = NULL;
+ }
+ if(temp_rrule) {
+ free(temp_rrule);
+ temp_rrule = NULL;
+ }
+ _INNER_FUNC_EXIT;
+ _DEBUG_INFO("origin = %s", origin);
+ return origin;
+}
+
+char * replace_image_data(char *origin, char *image_path)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if(origin == NULL, origin, "origin is NULL.");
+ retvm_if(image_path == NULL, origin, "image_path is NULL.");
+
+ int image_path_length = 500;
+ char *str_temp_image_info = NULL;
+ char *str_image_info = NULL;
+ char *str_image_tag = NULL;
+
+ _DEBUG_INFO("origin = %s", origin);
+ _DEBUG_INFO("image_path = %s", image_path);
+
+ if (strstr(image_path, INTERNAL_MEMORY_ORIGIN) != NULL) {
+ str_temp_image_info = replace_string(image_path, INTERNAL_MEMORY_ORIGIN, INTERNAL_MEMORY_CONVERTED);
+ str_image_tag = strdup("X-SS-ATTACH-IMAGE");
+ }
+ else if (strstr(image_path, EXTERNAL_MEMORY_ORIGIN) != NULL) {
+ str_temp_image_info = replace_string(image_path, EXTERNAL_MEMORY_ORIGIN, EXTERNAL_MEMORY_CONVERTED);
+ str_image_tag = strdup("X-SS-ATTACH-IMAGE");
+ }
+ else if (strstr(image_path, SNOTE_MEMORY_ORIGIN) != NULL) {
+ str_temp_image_info = strdup(image_path);
+ //str_image_tag = strdup("X-SS-ATTACH-SNOTE");
+ str_image_tag = strdup("X-SS-ATTACH-IMAGE");
+ }
+ else {
+ _DEBUG_ERROR("there is an error. image_path = %s", image_path);
+ goto return_part;
+ }
+
+ if (strstr(origin, END_VEVENT_KEYWORD) == NULL) {
+ _DEBUG_ERROR("this data is wrong format. origin = %s", origin);
+ goto return_part;
+ }
+
+ if (image_path_length <= 0) {
+ _DEBUG_ERROR("image_path_length(%d) <= 0", image_path_length);
+ goto return_part;
+ }
+ str_image_info = (char *)calloc(image_path_length, sizeof(char));
+ if (str_image_info == NULL) {
+ _DEBUG_ERROR("str_image_info calloc failed");
+ goto return_part;
+ }
+
+ snprintf(str_image_info, image_path_length, "\r\n%s;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:NAME=3Dnull=3BPATH=3D%s=3BDATE=3D%s", str_image_tag, str_temp_image_info, END_VEVENT_KEYWORD);
+
+ char *new_agent_data = replace_string(origin, END_VEVENT_KEYWORD, str_image_info);
+ origin = NULL;
+ origin = new_agent_data;
+
+return_part:
+
+ if (str_image_info) {
+ free(str_image_info);
+ str_image_info = NULL;
+ }
+ if (str_image_tag) {
+ free(str_image_tag);
+ str_image_tag = NULL;
+ }
+ if (str_temp_image_info) {
+ free(str_temp_image_info);
+ str_temp_image_info = NULL;
+ }
+
+ _INNER_FUNC_EXIT;
+ _DEBUG_INFO("origin = %s", origin);
+ return origin;
+}
+
+// exdate string format like as "20130211T000000Z,20130211T000000Z,20130211T000000Z"
+sync_agent_da_return_e replace_exdate_data(const char *origin, calendar_record_h calendar_record)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if(origin == NULL, SYNC_AGENT_DA_ERRORS, "origin is NULL.");
+ retvm_if(calendar_record == NULL, SYNC_AGENT_DA_ERRORS, "calendar_record is NULL");
+
+ char *str_exdata_loc = NULL;
+ char *old_exdate_str = NULL;
+ char *new_exdate_str = NULL;
+ char *new_one_exdate_str = NULL;
+ int exdate_length = 0;
+ int service_ret = CALENDAR_ERROR_NONE;
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+ if ((str_exdata_loc = strstr(origin, IMPORT_EXTYPE_DELETE_KEYWORD)) == NULL) {
+ _DEBUG_ERROR("this vcalendar has not exdate data");
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto return_part;
+ }
+
+ new_one_exdate_str = get_value_by_token(str_exdata_loc + 2, "EXDATE:", "\r\n");
+ _DEBUG_INFO("new_one_exdate_str = %s", new_one_exdate_str);
+
+ service_ret = calendar_record_get_str(calendar_record, _calendar_event.exdate, &old_exdate_str);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_set_str() Fail! err[%d]\n", service_ret);
+ goto return_part;
+ }
+
+ _DEBUG_INFO("old_exdate_str = %s", old_exdate_str);
+ int old_exdate_str_length = 0;
+ if (old_exdate_str == NULL)
+ old_exdate_str_length = 0;
+ else
+ old_exdate_str_length = strlen(old_exdate_str);
+
+ exdate_length = old_exdate_str_length + strlen(new_one_exdate_str) + 2;
+ _DEBUG_INFO("exdate_length = %d", exdate_length);
+ new_exdate_str = (char *)calloc(exdate_length, sizeof(char));
+ if (new_exdate_str == NULL) {
+ _DEBUG_ERROR("new_exdate_str calloc failed");
+ goto return_part;
+ }
+
+ if (old_exdate_str == NULL)
+ snprintf(new_exdate_str, exdate_length, "%s", new_one_exdate_str);
+ else
+ snprintf(new_exdate_str, exdate_length, "%s,%s", old_exdate_str, new_one_exdate_str);
+
+ _DEBUG_INFO("new_exdate_str = %s", new_exdate_str);
+
+ service_ret = calendar_record_set_str(calendar_record, _calendar_event.exdate, new_exdate_str);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_set_str() Fail! err[%d]\n", service_ret);
+ goto return_part;
+ }
+
+return_part:
+ if(new_one_exdate_str) {
+ free(new_one_exdate_str);
+ new_one_exdate_str = NULL;
+ }
+ if(new_exdate_str) {
+ free(new_exdate_str);
+ new_exdate_str = NULL;
+ }
+ _INNER_FUNC_EXIT;
+ return ret;
+}
all:
- gcc -o oma-ds-client oma_ds_client.c `pkg-config --cflags --libs glib-2.0` `pkg-config --cflags --libs dlog` `pkg-config --cflags --libs sync-agent` `pkg-config --cflags --libs libwbxml2`
+ gcc -o oma-ds-client oma_ds_client.c `pkg-config --cflags --libs sync-agent`
clean:
rm -rf oma-ds-client
\ No newline at end of file
int profile_id = 0;
- char *profileDirName = "Sync1";
- char *profileName = "Funambol";
- char *addr = "http://my.funambol.com/sync";
- char *id = "scotest2";
- char *password = "sprc123";
- char *syncMode = "Manual"; //Push, Manual, Periodic
- char *syncType = "Full"; //Full, Update both, Update to server, Update to phone, Refresh from server, Refresh from phone
- char *interval = "5 minutes"; //5 minutes, 15 minutes, 1 hour, 4 hours, 12 hours, 1 day, 1 week
+ char *profileName = "Orange";
+ char *addr = "http://oma-ds.ftgroup-devices.com/ftsync/sync/";
+ char *id = "guest";
+ char *password = "guest";
+ sync_agent_ds_sync_mode_e syncMode = SYNC_AGENT_SYNC_MODE_MANUAL;
+ sync_agent_ds_sync_type_e syncType = SYNC_AGENT_SYNC_TYPE_FULL_SYNC;
+ sync_agent_ds_sync_interval_e interval = SYNC_AGENT_SYNC_INTERVAL_5_MINUTES;
ds_profile_h profile_h = NULL;
return FALSE;
}
// set profile name
- result = sync_agent_ds_set_profile_name(profile_h, profileDirName, profileName);
+ result = sync_agent_ds_set_profile_name(profile_h, profileName);
if (result == SYNC_AGENT_DS_FAIL) {
_DEBUG_ERROR("failed to set profile name!");
return FALSE;
return FALSE;
}
// set sync_category
- sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CONTACT, 1, "Contacts", "card", NULL, NULL);
+ sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CONTACT, 1, SYNC_AGENT_SRC_URI_CONTACT, "./Address", NULL, NULL);
if (result == SYNC_AGENT_DS_FAIL) {
_DEBUG_ERROR("failed to set sync category!");
return FALSE;
}
- sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CALENDAR, 0, "Organizer", "cal", NULL, NULL);
+ sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CALENDAR, 0, SYNC_AGENT_SRC_URI_CALENDAR, "./Event", NULL, NULL);
if (result == SYNC_AGENT_DS_FAIL) {
_DEBUG_ERROR("failed to set sync category!");
return FALSE;
int profile_id = 0;
/* add first profile */
- char *profileDirName = "Sync1";
char *profileName = "Funambol";
char *addr = "http://my.funambol.com/sync";
char *id = "scotest2";
char *password = "sprc123";
- char *syncMode = "Manual"; //Push, Manual, Periodic
- char *syncType = "Full"; //Full, Update both, Update to server, Update to phone, Refresh from server, Refresh from phone
- char *interval = "5 minutes"; //5 minutes, 15 minutes, 1 hour, 4 hours, 12 hours, 1 day, 1 week
+ sync_agent_ds_sync_mode_e syncMode = SYNC_AGENT_SYNC_MODE_MANUAL;
+ sync_agent_ds_sync_type_e syncType = SYNC_AGENT_SYNC_TYPE_FULL_SYNC;
+ sync_agent_ds_sync_interval_e interval = SYNC_AGENT_SYNC_INTERVAL_15_MINUTES;
ds_profile_h profile_h = NULL;
return FALSE;
}
// set profile name
- result = sync_agent_ds_set_profile_name(profile_h, profileDirName, profileName);
+ result = sync_agent_ds_set_profile_name(profile_h, profileName);
if (result == SYNC_AGENT_DS_FAIL) {
_DEBUG_ERROR("failed to set profile name!");
return FALSE;
return FALSE;
}
// set sync_category
- sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CONTACT, 1, "Contacts", "card", NULL, NULL);
+ sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CONTACT, 1, SYNC_AGENT_SRC_URI_CONTACT, "card", NULL, NULL);
if (result == SYNC_AGENT_DS_FAIL) {
_DEBUG_ERROR("failed to set sync category!");
return FALSE;
}
- sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CALENDAR, 0, "Organizer", "cal", NULL, NULL);
+ sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CALENDAR, 0, SYNC_AGENT_SRC_URI_CALENDAR, "cal", NULL, NULL);
if (result == SYNC_AGENT_DS_FAIL) {
_DEBUG_ERROR("failed to set sync category!");
return FALSE;
sync_agent_ds_free_profile_info(profile_h);
/* add second profile */
- profileDirName = "Sync2";
profileName = "Everdroid";
addr = "http://www.everdroid.com/sync/server";
id = "test_samsung";
password = "123456";
- syncMode = "Manual"; //Push, Manual, Periodic
- syncType = "Full"; //Full, Update both, Update to server, Update to phone, Refresh from server, Refresh from phone
- interval = "5 minutes"; //5 minutes, 15 minutes, 1 hour, 4 hours, 12 hours, 1 day, 1 week
+ syncMode = SYNC_AGENT_SYNC_MODE_PERIODIC;
+ syncType = SYNC_AGENT_SYNC_TYPE_UPDATE_TO_SERVER;
+ interval = SYNC_AGENT_SYNC_INTERVAL_12_HOURS;
// allocate memory for profile info
result = sync_agent_ds_create_profile_info(&profile_h);
return FALSE;
}
// set profile name
- result = sync_agent_ds_set_profile_name(profile_h, profileDirName, profileName);
+ result = sync_agent_ds_set_profile_name(profile_h, profileName);
if (result == SYNC_AGENT_DS_FAIL) {
_DEBUG_ERROR("failed to set profile name!");
return FALSE;
return FALSE;
}
// set sync_category
- sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CONTACT, 1, "Contacts", "card", NULL, NULL);
+ sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CONTACT, 1, SYNC_AGENT_SRC_URI_CONTACT, "card", NULL, NULL);
if (result == SYNC_AGENT_DS_FAIL) {
_DEBUG_ERROR("failed to set sync category!");
return FALSE;
}
- sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CALENDAR, 0, "Organizer", "cal", NULL, NULL);
+ sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CALENDAR, 0, SYNC_AGENT_SRC_URI_CALENDAR, "cal", NULL, NULL);
if (result == SYNC_AGENT_DS_FAIL) {
_DEBUG_ERROR("failed to set sync category!");
return FALSE;
char *addr = "http://my.funambol.com/sync";
char *id = "scotest2";
char *password = "sprc123";
- char *syncMode = "Manual"; //Push, Manual, Periodic
- char *syncType = "Full"; //Full, Update both, Update to server, Update to phone, Refresh from server, Refresh from phone
- char *interval = "5 minutes"; //5 minutes, 15 minutes, 1 hour, 4 hours, 12 hours, 1 day, 1 week
+ sync_agent_ds_sync_mode_e syncMode = SYNC_AGENT_SYNC_MODE_PERIODIC;
+ sync_agent_ds_sync_type_e syncType = SYNC_AGENT_SYNC_TYPE_REFRESH_FROM_SERVER;
+ sync_agent_ds_sync_interval_e interval = SYNC_AGENT_SYNC_INTERVAL_15_MINUTES;
ds_profile_h profile_h = NULL;
_DEBUG_ERROR("failed to create profile info!");
return FALSE;
}
+ result = sync_agent_ds_set_profile_dir_name(profile_h, profileDirName);
// set profile name
- result = sync_agent_ds_set_profile_name(profile_h, profileDirName, profileName);
+ result = sync_agent_ds_set_profile_name(profile_h, profileName);
if (result == SYNC_AGENT_DS_FAIL) {
_DEBUG_ERROR("failed to set profile name!");
return FALSE;
return FALSE;
}
// allocate memory for sync_category
- sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CONTACT, 0, "Contacts", "card", NULL, NULL);
+ sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CONTACT, 0, SYNC_AGENT_SRC_URI_CONTACT, "card", NULL, NULL);
if (result == SYNC_AGENT_DS_FAIL) {
_DEBUG_ERROR("failed to set sync category!");
return FALSE;
}
- sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CALENDAR, 1, "Organizer", "cal", NULL, NULL);
+ sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CALENDAR, 1, SYNC_AGENT_SRC_URI_CALENDAR, "cal", NULL, NULL);
if (result == SYNC_AGENT_DS_FAIL) {
_DEBUG_ERROR("failed to set sync category!");
return FALSE;
return FALSE;
}
// set profile name
- result = sync_agent_ds_set_profile_name(profile_h, profileDirName, NULL);
+ result = sync_agent_ds_set_profile_dir_name(profile_h, profileDirName);
if (result == SYNC_AGENT_DS_FAIL) {
_DEBUG_ERROR("failed to set profile name!");
return FALSE;
ds_profile_h profile_h = NULL;
char *profileDirName = "Sync1";
-
- char *profileDirName1 = NULL;
char *profileName = NULL;
sync_agent_ds_server_info server_info = { NULL };
- sync_agent_ds_sync_info sync_info = { NULL };
+ sync_agent_ds_sync_info sync_info = { 0, };
GList *category_list = NULL;
int category_count = 0;
}
// 1. get profile dir/name
- result = sync_agent_ds_get_profile_name(profile_h, &profileDirName1, &profileName);
+ result = sync_agent_ds_get_profile_name(profile_h, &profileName);
if (result == SYNC_AGENT_DS_SUCCESS) {
_DEBUG_VERBOSE("Success to get profile name!");
- _DEBUG_VERBOSE("profileDirame = %s", profileDirName1);
_DEBUG_VERBOSE("get_profileName = %s", profileName);
is_test_successful = TRUE;
} else {
result = sync_agent_ds_get_sync_info(profile_h, &sync_info);
if (result == SYNC_AGENT_DS_SUCCESS) {
_DEBUG_VERBOSE("Success to get sync info!");
- _DEBUG_VERBOSE("syncMode = %s", sync_info.syncMode);
- _DEBUG_VERBOSE("syncType = %s", sync_info.syncType);
- _DEBUG_VERBOSE("interval = %s", sync_info.interval);
+ _DEBUG_VERBOSE("sync_mode = %d", sync_info.sync_mode);
+ _DEBUG_VERBOSE("sync_type = %d", sync_info.sync_type);
+ _DEBUG_VERBOSE("interval = %d", sync_info.interval);
is_test_successful = TRUE;
} else {
_DEBUG_VERBOSE("Failed to get sync info!");
category_info = (sync_agent_ds_service_info *) g_list_nth_data(category_list, i);
_DEBUG_VERBOSE("category[%d]->enabled = %d", i, category_info->enabled);
- _DEBUG_VERBOSE("category[%d]->srcURI = %s", i, category_info->srcURI);
- _DEBUG_VERBOSE("category[%d]->tgtURI = %s", i, category_info->tgtURI);
+ _DEBUG_VERBOSE("category[%d]->src_uri = %d", i, category_info->src_uri);
+ _DEBUG_VERBOSE("category[%d]->tgt_uri = %s", i, category_info->tgt_uri);
_DEBUG_VERBOSE("category[%d]->id = %s", i, category_info->id);
_DEBUG_VERBOSE("category[%d]->password = %s", i, category_info->password);
}
}
// free profile information
- g_free(profileDirName1);
g_free(profileName);
g_free(server_info.addr);
g_free(server_info.id);
g_free(server_info.password);
- g_free(sync_info.syncMode);
- g_free(sync_info.syncType);
- g_free(sync_info.interval);
-
g_list_free(category_list);
sync_agent_ds_free_profile_info(profile_h);
GList *iter = NULL;
ds_profile_h profile_h = NULL;
- char *profileDirName1 = NULL;
char *profileName = NULL;
sync_agent_ds_server_info server_info = { NULL };
- sync_agent_ds_sync_info sync_info = { NULL };
+ sync_agent_ds_sync_info sync_info = { 0, };
GList *category_list = NULL;
int category_count = 0;
profile_h = (ds_profile_h) iter->data;
// 1. get profile dir/name
- result = sync_agent_ds_get_profile_name(profile_h, &profileDirName1, &profileName);
+ result = sync_agent_ds_get_profile_name(profile_h, &profileName);
if (result == SYNC_AGENT_DS_SUCCESS) {
_DEBUG_VERBOSE("Success to get profile name!");
- _DEBUG_VERBOSE("profileDirame = %s", profileDirName1);
_DEBUG_VERBOSE("get_profileName = %s", profileName);
is_test_successful = TRUE;
} else {
result = sync_agent_ds_get_sync_info(profile_h, &sync_info);
if (result == SYNC_AGENT_DS_SUCCESS) {
_DEBUG_VERBOSE("Success to get sync info!");
- _DEBUG_VERBOSE("syncMode = %s", sync_info.syncMode);
- _DEBUG_VERBOSE("syncType = %s", sync_info.syncType);
- _DEBUG_VERBOSE("interval = %s", sync_info.interval);
+ _DEBUG_VERBOSE("sync_mode = %d", sync_info.sync_mode);
+ _DEBUG_VERBOSE("sync_type = %d", sync_info.sync_type);
+ _DEBUG_VERBOSE("interval = %d", sync_info.interval);
is_test_successful = TRUE;
} else {
_DEBUG_VERBOSE("Failed to get sync info!");
category_info = (sync_agent_ds_service_info *) g_list_nth_data(category_list, i);
_DEBUG_VERBOSE("category[%d]->enabled = %d", i, category_info->enabled);
- _DEBUG_VERBOSE("category[%d]->srcURI = %s", i, category_info->srcURI);
- _DEBUG_VERBOSE("category[%d]->tgtURI = %s", i, category_info->tgtURI);
+ _DEBUG_VERBOSE("category[%d]->src_uri = %d", i, category_info->src_uri);
+ _DEBUG_VERBOSE("category[%d]->tgt_uri = %s", i, category_info->tgt_uri);
_DEBUG_VERBOSE("category[%d]->id = %s", i, category_info->id);
_DEBUG_VERBOSE("category[%d]->password = %s", i, category_info->password);
}
}
// free profile information
- g_free(profileDirName1);
g_free(profileName);
g_free(server_info.addr);
g_free(server_info.id);
g_free(server_info.password);
- g_free(sync_info.syncMode);
- g_free(sync_info.syncType);
- g_free(sync_info.interval);
-
g_list_free(category_list);
}
_EXTERN_FUNC_ENTER;
char *profileDirName = NULL;
- char *sync_type = NULL;
+ int sync_type = 0;
char *progress = NULL;
char *error = NULL;
sync_agent_get_event_data_param(request, &error);
_DEBUG_VERBOSE("profileDirName = %s\n", profileDirName);
- _DEBUG_VERBOSE("sync_type = %s\n", sync_type);
+ _DEBUG_VERBOSE("sync_type = %d\n", sync_type);
_DEBUG_VERBOSE("progress = %s\n", progress);
_DEBUG_VERBOSE("error = %s\n", error);
g_free(profileDirName);
- g_free(sync_type);
+ //g_free(sync_type);
g_free(progress);
if (request != NULL) {
_EXTERN_FUNC_ENTER;
char *profileDirName = NULL;
- char *syncType = NULL;
+ int sync_type = 0;
char *uri = NULL;
char *progressStatus = NULL;
char *operationType = NULL;
sync_agent_get_event_data_param(request, &profileDirName);
_DEBUG_VERBOSE("profileDirName = %s", profileDirName);
- sync_agent_get_event_data_param(request, &syncType);
- _DEBUG_VERBOSE("syncType = %s", syncType);
+ sync_agent_get_event_data_param(request, &sync_type);
+ _DEBUG_VERBOSE("sync_type = %d", sync_type);
sync_agent_get_event_data_param(request, &uri);
_DEBUG_VERBOSE("uri = %s", uri);
sync_agent_get_event_data_param(request, &progressStatus);
_DEBUG_VERBOSE("syncedPerDb = %d", syncedPerDb);
g_free(profileDirName);
- g_free(syncType);
+ //g_free(syncType);
g_free(uri);
g_free(progressStatus);
g_free(operationType);
if (request != NULL) {
- if (request->size != NULL)
+ if (request->size != NULL) {
g_free(request->size);
+ request->size = NULL;
+ }
g_free(request);
+ request = NULL;
}
_EXTERN_FUNC_EXIT;
guint result;
// signal(SIGPIPE, _pipe_handler);
+ sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
- sync_agent_ds_error_e ds_err = sync_agent_ds_init();
+ ds_err = sync_agent_ds_init();
if (ds_err != SYNC_AGENT_DS_SUCCESS) {
- _DEBUG_ERROR("failed to init oma ds");
+ _DEBUG_ERROR("sync_agent_ds_init() failed!!");
+
+ _EXTERN_FUNC_EXIT;
return -1;
}
- int noti_type = 1;
- sync_agent_event_error_e err = sync_agent_set_noti_callback(noti_type, _session_process_noti_cb, NULL);
- if (err != SYNC_AGENT_EVENT_SUCCESS) {
- _DEBUG_ERROR("failed sync_agent_set_noti_callback()");
+ ds_err = sync_agent_ds_set_noti_callback(SYNC_AGENT_DS_SYNC_SESSION, _session_process_noti_cb, NULL);
+ if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_ds_set_noti_callback() failed!!");
+
+ _EXTERN_FUNC_EXIT;
return -1;
}
- noti_type = 2;
- err = sync_agent_set_noti_callback(noti_type, _process_update_noti_cb, NULL);
- if (err != SYNC_AGENT_EVENT_SUCCESS)
- _DEBUG_ERROR("failed sync_agent_set_noti_callback()");
+ ds_err = sync_agent_ds_set_noti_callback(SYNC_AGENT_DS_SYNC_PROCESS, _process_update_noti_cb, NULL);
+ if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_ds_set_noti_callback() failed!!");
+
+ _EXTERN_FUNC_EXIT;
+ return -1;
+ }
/* Creates a new GIOChannel from std input */
stdin_channel = g_io_channel_unix_new(0);
ds_err = sync_agent_ds_deinit();
if (ds_err != SYNC_AGENT_DS_SUCCESS) {
_DEBUG_ERROR("failed to init oma ds");
+
+ _EXTERN_FUNC_EXIT;
return -1;
}
Version: 0.1.1
Release: 1
Group: TO_BE/FILLED_IN
-License: Apache License, Version 2.0
+License: Samsung Proprietary License
Source0: %{name}-%{version}.tar.gz
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig