+sync-agent (0.1.87) unstable; urgency=low
+
+ * 1. PLM P130412-7652 : oma-dm-agent BS patch.
+ * Git: magnolia/framework/system/sync-agent
+ * Tag: sync-agent_0.1.87
+
+ -- Taehwan Gil <th1128.gil@samsung.com> Sun, 14 Apr 2013 13:49:44 +0900
+
+sync-agent (0.1.86) unstable; urgency=low
+
+ * 1. PLM P130408-0763 : W0 rrule patch.
+ * 2. PLM P130408-0729 : calendar_book.id patch.
+ * 3. PLM P130408-0745 : CALENDAR_ALARM_TIME_UNIT_SPECIFIC setting value patch.
+ * 4. PLM P130408-0777 : GMT-based timezone value patch.
+ * 5. adding enum - FOTA update result popup.
+ * Git: magnolia/framework/system/sync-agent
+ * Tag: sync-agent_0.1.86
+
+ -- Juhaki Park <juhaki.park@samsung.com> Fri, 12 Apr 2013 14:17:59 +0900
+
+sync-agent (0.1.85) unstable; urgency=low
+
+ * 1. updated exdate sync > delete another date > DB is not updated
+ * 2. Stack area is broken. (PLM:P130404-5476)
+ * Git: magnolia/framework/system/sync-agent
+ * Tag: sync-agent_0.1.85
+
+ -- sanghyukko <sanghyuk.ko@samsung.com> Fri, 05 Apr 2013 22:25:59 +0900
+
+sync-agent (0.1.84) unstable; urgency=low
+
+ * 1. Prevent 44317 fix.
+ * 2. Add an Exception handle for Exdate item.
+ * 3. Prevent 32978 fix.
+ * 4. Prevent 41907 fix.
+ * 5. When launching oma-ds-agent, daemon status check.
+ * 6. network status checking patch for GCF.
+ * Git: magnolia/framework/system/sync-agent
+ * Tag: sync-agent_0.1.84
+
+ -- Juhaki Park <juhaki.park@samsung.com> Thu, 4 Apr 2013 20:31:53 +0900
+
+sync-agent (0.1.83) unstable; urgency=low
+
+ * 1. A new API that goto_if() API is added
+ * 2. Add sim contact sync funtion(Add, Update, Delete)
+ * 3. Removing deleted Exdate item when the updated exdate item is created
+ * 4. Apply requirements of Calendar Svc
+ * 5. delta.tar decompress for FOTA update-agent
+ * Git: magnolia/framework/system/sync-agent
+ * Tag: sync-agent_0.1.83
+
+ -- WooJin Yun <suhoangel9@samsung.com> Fri, 29 Mar 2013 17:51:53 +0900
+
sync-agent (0.1.82) unstable; urgency=low
- * 1. debug log add
- * 2. remove log, daemon check api added
- * Git: framework/system/sync-agent
+ * 1. Adding a new DB field for Calendar Exdate Sync
+ * - Adding a 'parent_service_id' field to DB
+ * - Adding a function for updating 'parent_service_id' of the parent item.
+ * - Apply when the parent item is deleted, it's child items also to be deleted
+ * - Adding a function to get child item id list by using its parent item id
+ * - Adding an exception handle for exdate items when calendar DB is changed
+ * - Apply to include exdate items when calendar/count and calendar/load
+ * 2. When profile gets, input param changed.
+ * 3. Add Sim contact sync funtion
+ * Git: magnolia/framework/system/sync-agent
* Tag: sync-agent_0.1.82
- -- sanghyukko <sanghyuk.ko@samsung.com> Mon, 01 Apr 2013 14:57:49 +0900
+ -- WooJin Yun <suhoangel9@samsung.com> Wed, 20 Mar 2013 19:37:20 +0900
sync-agent (0.1.81) unstable; urgency=low
- * 1. When profile gets, input param changed
- * Git: framework/system/sync-agent
+ * 1. Add Calendar Exdate Sync
+ - apply EXDATE:DELETE about calendar/load
+ - apply EXDATE:UPDATE about calendar/sync/load
+ * 2. Fix PLM Defect : P130309-1516
+ * - Task write sync is not operated from Mobile to KIES at PC
+ * 3. Fix PLM Defect : P130309-1516
+ * - Calendar Sync is not operated
+ * Git: magnolia/framework/system/sync-agent
* Tag: sync-agent_0.1.81
- -- sanghyukko <sanghyuk.ko@samsung.com> Wed, 20 Mar 2013 17:45:24 +0900
+ -- WooJin Yun <suhoangel9@samsung.com> Thu, 14 Mar 2013 15:46:29 +0900
sync-agent (0.1.80) unstable; urgency=low
- * 1. when profile info gets, return value changed.
- * Git: framework/system/sync-agent
+ * 1. Fix prevent defect (8EA).
+ * 2. Task load vcalendar is changed.
+ * 3. When profile info gets, return value changed.
+ * 4. Calendar Exdate(UPDATE) Sync : fix some exdate items loss problems
+ * 5. Add Function for count of EXDATE items
+ * Git: magnolia/framework/system/sync-agent
* Tag: sync-agent_0.1.80
- -- sanghyuk.ko <sanghyuk.ko@samsung.com> Fri, 08 Mar 2013 09:39:45 +0900
+ -- WooJin Yun <suhoangel9@samsung.com> Thu, 07 Mar 2013 21:38:21 +0900
-sync-agent (0.1.79) precise; urgency=low
+sync-agent (0.1.79) unstable; urgency=low
- * 1. sync_interval enum type added
- * Git: framework/system/sync-agent
+ * 1. Fixed for prevent. (3EA)
+ * 2. Add FOTA polling fucntion
+ * 3. Fixed for prevent. (6EA)
+ * 4. sync_interval enum type added
+ * Git: magnolia/framework/system/sync-agent
* Tag: sync-agent_0.1.79
- -- sanghyukko <sanghyuk.ko@samsung.com> Thu, 28 Feb 2013 17:09:45 +0900
+ -- WooJin Yun <suhoangel9@samsung.com> Thu, 28 Feb 2013 16:32:28 +0900
sync-agent (0.1.78) unstable; urgency=low
- * 1. profile_dir_name create automatically.
- * 2. sync_mode, sync_type src_uri enum type added
- * Git: framework/system/sync-agent
+ * 1. Fixed that profile_dir_name create automatically
+ * 2. Fixed for prevent. (13EA)
+ * 3. sync_agent.pc file updated
+ * 4. sync_mode, sync_type src_uri enum type added
+ * 5. Calendar Exdate(UPDATE) Sync
+ * Git: magnolia/framework/system/sync-agent
* Tag: sync-agent_0.1.78
- -- sanghyukko <sanghyuk.ko@samsung.com> Tue, 26 Feb 2013 17:16:02 +0900
+ -- sanghyukko <sanghyuk.ko@samsung.com> Tue, 26 Feb 2013 19:55:32 +0900
sync-agent (0.1.77) unstable; urgency=low
- * 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
+ * 1. Calendar Exdate(Delete) Import Sync
+ * 2. Added oma_ds_agent launch/kill at sync-agent
+ * 3. Adjust Contact Bulk API(Update)
+ * 4. Calendar Exdate(Delete) Sync
+ * 5. Fix prevent issues (3EA)
+ * 6. Fix prevent issue (1EA)
+ * 7. g_type_init added.
+ * 8. Fixed prevent issues. (14 EA)
+ * 9. Calendar Exdate(UPDATE) Sync
+ * 10. sync_agent rsa merge patch
+ * Git: magnolia/framework/system/sync-agent
* Tag: sync-agent_0.1.77
- -- sanghyukko <sanghyuk.ko@samsung.com> Thu, 21 Feb 2013 14:34:49 +0900
+ -- WooJin Yun <suhoangel9@samsung.com> Thu, 21 Feb 2013 16:16:34 +0900
sync-agent (0.1.76) unstable; urgency=low
* @brief Structure of framework item instance
*/
typedef struct {
- char *item_id;
- /**< F/W item id */
- int data_store_id;
- /**< service data connector pluIn's ID described in F/W config file */
- int account_id;
- /**< F/W account id */
- char *folder_id;/**< F/W folder id */
- char *service_id;
- /**< service item id */
- char *access_name;
- /**< name of accessor */
+ char *item_id; /**< F/W item id */
+ int data_store_id; /**< service data connector pluIn's ID described in F/W config file */
+ int account_id; /**< F/W account id */
+ char *folder_id; /**< F/W folder id */
+ char *service_id; /**< service item id */
+ char *parent_service_id; /**< parent F/W item id for exdate items => normal item : NULL / exdate parent item : -1 / exdate child item : parent service id */
+ char *access_name; /**< name of accessor */
} sync_agent_da_item_s;
/**
sync_agent_da_return_e sync_agent_get_item_count(int data_store_id, int *item_count);
/**
+ * @brief get updated exdate item id list in item table where service type
+ * @param[in] fw_id item's framework id
+ * @param[in] list list as returned updated exdate item_id list
+ * @return sync_agent_da_return_e
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval error value fail
+
+ */
+ sync_agent_da_return_e sync_agent_get_updated_exdate_item_id_list(char *fw_id, GList ** list);
+
+/**
* @}
*/
* @brief Structure of framework service item instance
*/
typedef struct {
- char *item_id; /** service item id */
+ char *item_id; /** service item id */
int content_type; /** content type of service item */
- int account_id; /** service account id */
+ int account_id; /** service account id */
char *folder_id; /** service folder id to which service item mapped to */
- char *access_name; /** name of accessor */
+ char *parent_id; /** parent service id to which service item mapped to */
+ char *access_name; /** name of accessor */
const void *data; /** void pointer type of service data */
} sync_agent_da_service_item_s;
*/
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 Update calendar exdate:updated 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_add_updated_exdate_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] parent_id id of framework parent service item instance desired to update
+ * @param[in] child_id id of framework child 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_add_updated_exdate_item(sync_agent_da_service_item_s * service_item, char *parent_id, char *child_id, bool update_changelog);
+ /**
+ * @brief Update calendar exdate:updated parent item
+ * @par Usage:
+ * @code
+
+ sync_agent_construct_exdate_parent_item(service_item);
+
+ * @endcode
+ * @param[in] service_item parent servic item id
+ * @return void
+ */
+ void sync_agent_construct_exdate_parent_item(int content_type, char *parent_service_id);
+
+
/**
* @brief Delete framework service item instance from frameowrk db
* @par Usage:
* @code
sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+int count
-ret = sync_agent_delete_service_bulk_item(item_id, true);
+ret = sync_agent_delete_service_bulk_item(item_id, count, true);
if (ret != SYNC_AGENT_DA_SUCCESS) {
...
}
* @endcode
* @param[in] item_id id of framework service item instance desired to delete
+* @param[in] count count of id
* @param[in] update_changelog option specifying whether use of changelog for sync history
* @return operation result
* @retval SYNC_AGENT_DA_SUCCESS success
int sync_agent_get_used_service_item_count(int content_type);
/**
+ * @brief Get calendar exdate item count
+ * @par Usage:
+ * @code
+ int count = 0;
+
+ count = sync_agent_get_deleted_exdate_item_count(FW_CALENDAR);
+ if (count == 0) {
+ ...
+ } else {
+ ...
+ }
+
+ * @endcode
+ * @param[in] content_type service type - service data connector plug-in's ID described in F/W config file
+ * @return operation result
+ * @retval current item count success
+ * @retval error value fail
+ */
+ int sync_agent_get_deleted_exdate_item_count(int content_type);
+
+/**
+ * @brief Get calendar exdate item count
+ * @par Usage:
+ * @code
+
+sync_agent_is_exist_exdate_item(FW_CALENDAR, fw_parent_id, child_vcalendar)
+
+ * @endcode
+ * @param[in] content_type service type - service data connector plug-in's ID described in F/W config file
+ * @return operation result
+ * @retval current item count success
+ * @retval error value fail
+ */
+ sync_agent_da_return_e sync_agent_is_exist_exdate_item(int content_type, const char *fw_parent_id, const char *child_vcalendar);
+
+/**
* @brief Get item used count for folder
* @par Usage:
* @code
char *sync_agent_get_service_folder_id(char *folder_id);
/**
+ * @brief Get max name length of sim contact
+ * @par Usage:
+ * @code
+
+ int length = 0;
+
+ length = sync_agent_get_sim_contact_info_max_name_length(FW_CONTACT_SIM);
+ if (length == 0) {
+ ...
+ } else {
+ ...
+ }
+
+ * @endcode
+ * @param[in] content_type service type - service data connector plug-in's ID described in F/W config file
+ * @return operation result
+ * @retval current item count success
+ * @retval error value fail
+ */
+ int sync_agent_get_sim_contact_info_max_name_length(int content_type);
+
+/**
+ * @brief Get max number length of sim contact
+ * @par Usage:
+ * @code
+
+ int length = 0;
+
+ length = sync_agent_get_sim_contact_info_max_number_length(FW_CONTACT_SIM);
+ if (length == 0) {
+ ...
+ } else {
+ ...
+ }
+
+ * @endcode
+ * @param[in] content_type service type - service data connector plug-in's ID described in F/W config file
+ * @return operation result
+ * @retval current item count success
+ * @retval error value fail
+ */
+ int sync_agent_get_sim_contact_info_max_number_length(int content_type);
+
+/**
+ * @brief Get max email length of sim contact
+ * @par Usage:
+ * @code
+
+ int length = 0;
+
+ length = sync_agent_get_sim_contact_info_max_email_length(FW_CONTACT_SIM);
+ if (length == 0) {
+ ...
+ } else {
+ ...
+ }
+
+ * @endcode
+ * @param[in] content_type service type - service data connector plug-in's ID described in F/W config file
+ * @return operation result
+ * @retval current item count success
+ * @retval error value fail
+ */
+ int sync_agent_get_sim_contact_info_max_email_length(int content_type);
+
+/**
+ * @brief Get empty count of sim contact
+ * @par Usage:
+ * @code
+
+ int count = 0;
+
+ count = sync_agent_get_sim_contact_empty_count(FW_CONTACT_SIM);
+ if (count == 0) {
+ ...
+ } else {
+ ...
+ }
+
+ * @endcode
+ * @param[in] content_type service type - service data connector plug-in's ID described in F/W config file
+ * @return operation result
+ * @retval current item count success
+ * @retval error value fail
+ */
+ int sync_agent_get_sim_contact_empty_count(int content_type);
+
+/**
+ * @brief Get empty number count of sim contact
+ * @par Usage:
+ * @code
+
+ int count = 0;
+
+ count = sync_agent_get_sim_contact_number_empty_count(FW_CONTACT_SIM);
+ if (count == 0) {
+ ...
+ } else {
+ ...
+ }
+
+ * @endcode
+ * @param[in] content_type service type - service data connector plug-in's ID described in F/W config file
+ * @return operation result
+ * @retval current item count success
+ * @retval error value fail
+ */
+ int sync_agent_get_sim_contact_empty_number_count(int content_type);
+
+/**
+ * @brief Get empty email count of sim contact
+ * @par Usage:
+ * @code
+
+ int count = 0;
+
+ count = sync_agent_get_sim_contact_email_empty_count(FW_CONTACT_SIM);
+ if (count == 0) {
+ ...
+ } else {
+ ...
+ }
+
+ * @endcode
+ * @param[in] content_type service type - service data connector plug-in's ID described in F/W config file
+ * @return operation result
+ * @retval current item count success
+ * @retval error value fail
+ */
+ int sync_agent_get_sim_contact_empty_email_count(int content_type);
+
+/**
+ * @brief Get addressbook ID of sim contact
+ * @par Usage:
+ * @code
+
+ int addressbook_id = 0;
+
+ addressbook_id = sync_agent_get_sim_contact_adressbook_id(FW_CONTACT_SIM);
+ if (addressbook_id == 0) {
+ ...
+ } else {
+ ...
+ }
+
+ * @endcode
+ * @param[in] content_type service type - service data connector plug-in's ID described in F/W config file
+ * @return operation result
+ * @retval current item count success
+ * @retval error value fail
+ */
+ int sync_agent_get_sim_contact_addressbook_id(int content_type);
+
+/**
+ * @brief Get item ID of sim contact
+ * @par Usage:
+ * @code
+
+ GList *item_id = NULL;
+ ...
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ int sim_addressbook_id = 0;
+
+ ret = sync_agent_get_sim_contact_item_id(FW_CONTACT_SIM, sim_addressbook_id, &item_id);
+ if (ret == SYNC_AGENT_DA_ERRORS) {
+ ...
+ } else {
+ ...
+ }
+
+ * @endcode
+ * @param[in] content_type service type - service data connector plug-in's ID described in F/W config file
+ * @param[in] addressbook_id addressbook id of sim contact
+ * @param[out] item_id item id list of sim contacts
+ * @return operation result
+ * @retval current item count success
+ * @retval error value fail
+ */
+ sync_agent_da_return_e sync_agent_get_sim_contact_item_id(int content_type, int sim_addressbook_id, GList **item_id);
+
+/**
+ * @brief Get item ID of sim contact
+ * @par Usage:
+ * @code
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ char *data = NULL;
+ int item_id;
+
+ ret = sync_agent_get_sim_contact_item(FW_CONTACT_SIM, item_id, &data);
+ if (ret == SYNC_AGENT_DA_ERRORS) {
+ ...
+ } else {
+ ...
+ }
+
+ * @endcode
+ * @param[in] content_type service type - service data connector plug-in's ID described in F/W config file
+ * @param[in] item_id item id of sim contact
+ * @param[out] content_type data of sim contact
+ * @return operation result
+ * @retval current item count success
+ * @retval error value fail
+ */
+ sync_agent_da_return_e sync_agent_get_sim_contact_item(int content_type, int item_id, char **data);
+
+/**
+ * @brief Add sim contact
+ * @par Usage:
+ * @code
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ char *data;
+ int sim_addressbook_id;
+ int *item_id = NULL;
+
+ ret = sync_agent_delete_sim_contact_item(FW_CONTACT_SIM, sim_addressbook_id, &item_id, data);
+ if (ret == SYNC_AGENT_DA_ERRORS) {
+ ...
+ } else {
+ ...
+ }
+
+ * @endcode
+ * @param[in] content_type service type - service data connector plug-in's ID described in F/W config file
+ * @param[in] addressbook_id addressbook id of sim contact
+ * @param[out] item_id item id of sim contact
+ * @param[in] content_type data of sim contact
+ * @return operation result
+ * @retval current item count success
+ * @retval error value fail
+ */
+ sync_agent_da_return_e sync_agent_add_sim_contact_item(int content_type, int sim_addressbook_id, int **item_id, char *data);
+
+/**
+ * @brief Delete sim contact
+ * @par Usage:
+ * @code
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ char *data;
+ int item_id;
+
+ ret = sync_agent_delete_sim_contact_item(FW_CONTACT_SIM, item_id, data);
+ if (ret == SYNC_AGENT_DA_ERRORS) {
+ ...
+ } else {
+ ...
+ }
+
+ * @endcode
+ * @param[in] content_type service type - service data connector plug-in's ID described in F/W config file
+ * @param[in] item_id item id of sim contact
+ * @param[in] content_type data of sim contact
+ * @return operation result
+ * @retval current item count success
+ * @retval error value fail
+ */
+ sync_agent_da_return_e sync_agent_write_sim_contact_item(int content_type, int item_id, char *data);
+
+
+/**
+ * @brief Delete sim contact
+ * @par Usage:
+ * @code
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ int item_id;
+
+ ret = sync_agent_delete_sim_contact_item(FW_CONTACT_SIM, item_id);
+ if (ret == SYNC_AGENT_DA_ERRORS) {
+ ...
+ } else {
+ ...
+ }
+
+ * @endcode
+ * @param[in] content_type service type - service data connector plug-in's ID described in F/W config file
+ * @param[in] item_id item id of sim contact
+ * @return operation result
+ * @retval current item count success
+ * @retval error value fail
+ */
+ sync_agent_da_return_e sync_agent_delete_sim_contact_item(int content_type, int item_id);
+
+/**
* @}
*/
int sync_agent_plugin_get_used_item_count(void);
/**
+ * API to get exdate item count for EXDATE TYPE data of calendar
+ *
+ * @return current_item_count on success, negative value on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_deleted_exdate_item_count()
+ *
+ */
+ int sync_agent_plugin_get_deleted_exdate_item_count(void);
+
+/**
+ * API to get exdate item count for EXDATE TYPE data of calendar
+ *
+ * @return current_item_count on success, negative value on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_is_exist_exdate_item()
+ *
+ */
+ sync_agent_da_return_e sync_agent_plugin_is_exist_exdate_item(const char *fw_parent_id, const char *child_vcalendar);
+
+/**
+ * API to update the exdate parent item data of calendar
+ *
+ * @return void
+ *
+ *
+ * @see sync_agent_plugin_construct_exdate_parent_item()
+ *
+ */
+ void sync_agent_plugin_construct_exdate_parent_item(char *parent_service_id);
+
+
+/**
* API to get item used count for folder
*
* @param[in] account_id service account id
void sync_agent_plugin_set_callback_get_account_id_list(sync_agent_get_account_id_list_cb_plugin callback);
/**
+ * API to set callback function to handle child item delete from storage
+ *
+ * @param[in] callback callback function - this function is provided from sync-agent-framework
+ *
+ * @par Since:
+ *
+ *
+ * @see data_connector_resource.h
+ *
+ */
+ void sync_agent_plugin_set_callback_delete_child_item(sync_agent_del_child_item_cb_plugin callback);
+
+/**
* API to get max item count per folder
*
* @param[in] folder_type folder type provided plugin
int sync_agent_plugin_get_is_support_feature(int feature);
/**
+ * API to get max name length of sim card
+ *
+ * @return max name length or default value
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_info_sim_contact_max_name_length()
+ *
+ */
+
+int sync_agent_plugin_get_info_sim_contact_max_name_length(void);
+
+/**
+ * API to get max number length of sim card
+ *
+ * @return max number length or default value
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_info_sim_contact_max_name_length()
+ *
+ */
+
+int sync_agent_plugin_get_info_sim_contact_max_number_length(void);
+
+/**
+ * API to get max email length of sim card
+ *
+ * @return max email length or default value
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_info_sim_contact_max_name_length()
+ *
+ */
+
+int sync_agent_plugin_get_info_sim_contact_max_email_length(void);
+
+/**
+ * API to get empty count of sim card
+ *
+ * @return get empty count
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_sim_contact_empty_count()
+ *
+ */
+
+int sync_agent_plugin_get_info_sim_contact_empty_count(void);
+
+/**
+ * API to get empty number count of sim card
+ *
+ * @return get empty number count
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_sim_contact_empty_number_count()
+ *
+ */
+
+int sync_agent_plugin_get_info_sim_contact_empty_number_count(void);
+
+/**
+ * API to get empty email count of sim card
+ *
+ * @return get empty email count
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_sim_contact_empty_email_count()
+ *
+ */
+
+int sync_agent_plugin_get_info_sim_contact_empty_email_count(void);
+
+/**
+ * API to get addressbook ID of sim card
+ *
+ * @return get addressbook ID
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_info_sim_contact_addressbook_id()
+ *
+ */
+
+int sync_agent_plugin_get_info_sim_contact_addressbook_id(void);
+
+/**
+ * API to get contact item ID of sim card
+ *
+ * @param[in] addressbook id of sim contact
+ * @param[out] contact item ID of sim card
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_info_sim_contact_item_id()
+ *
+ */
+
+sync_agent_da_return_e sync_agent_plugin_get_info_sim_contact_item_id(int sim_addressbook_id, GList **item_id);
+
+/**
+ * API to get contact item ID of sim card
+ *
+ * @param[in] contact item ID of sim card
+ * @param[out] data of sim contact
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_info_sim_contact_item()
+ *
+ */
+
+sync_agent_da_return_e sync_agent_plugin_get_info_sim_contact_item(int item_id, char **data);
+
+/**
+ * API to delete sim contact
+ *
+ * @param[in] contact addressbook ID of sim card
+ * @param[out] contact item ID of sim card
+ * @param[in] data of sim contact
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_add_sim_contact_item()
+ *
+ */
+
+sync_agent_da_return_e sync_agent_plugin_add_sim_contact_item(int sim_addressbook_id, int **item_id, char *data);
+
+/**
+ * API to delete sim contact
+ *
+ * @param[in] sim contact id
+ * @param[in] sim contact data
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_write_sim_contact_item()
+ *
+ */
+
+sync_agent_da_return_e sync_agent_plugin_write_sim_contact_item(int item_id, char *data);
+
+/**
+ * API to delete sim contact
+ *
+ * @param[in] sim contact ID
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_delete_sim_contact_item()
+ *
+ */
+
+sync_agent_da_return_e sync_agent_plugin_delete_sim_contact_item(int item_id);
+
+/**
* @}
*/
#ifdef __cplusplus
* Structure of Item ID Node - Linked List
*/
struct sync_agent_plugin_item_node_s {
- char *item_id;
- /**< item id */
- struct sync_agent_plugin_item_node_s *next;
- /**< next pointer */
+ char *item_id; /**< item id */
+ char *parent_item_id; /**< parent item id for exdate items*/
+ struct sync_agent_plugin_item_node_s *next; /**< next pointer */
};
typedef struct sync_agent_plugin_item_node_s sync_agent_plugin_item_node_s;
* @param[in] account_id service account id
* @param[in] index possible mapping one service account with multiple sync-agent-framework account, so need index of sync-agent-framework account.
* @param[in] item_id service item id
+ * @param[in] parent_id parent service item id
* @param[in] item_type service type - service data connector plugin's id described in sync-agent-framework config xml file
* @param[in] folder_id service folder id
* @param[in] folder_type folder type defined in data-connector plugin
* @see sync_agent_plugin_set_callback_add_item(sync_agent_add_item_cb_plugin)
*
*/
- typedef int (*sync_agent_add_item_cb_plugin) (int account_id, int index, char *item_id, int item_type, char *folder_id, int folder_type);
+ typedef int (*sync_agent_add_item_cb_plugin) (int account_id, int index, char *item_id, char *parent_id, int item_type, char *folder_id, int folder_type);
/**
* Function which is called at some plugin (calendar, contact, memo) when existing item is deleted to the service
*/
typedef int (*sync_agent_del_item_cb_plugin) (int account_id, int index, char *item_id, int item_type);
+
/**
* Function which is called at some plugin (calendar, contact, memo) when existing item is updated to the service
*
* @param[in] account_id service account id
* @param[in] index possible mapping one service account with multiple sync-agent-framework account, so need index of sync-agent-framework account.
* @param[in] item_id service item id
+ * @param[in] parent_id parent service item id
* @param[in] item_type service type - service data connector plugin's id described in sync-agent-framework config xml file
*
* @return 1 on success, 0 on error
* @see sync_agent_plugin_set_callback_update_item(sync_agent_update_item_cb_plugin)
*
*/
- typedef int (*sync_agent_update_item_cb_plugin) (int account_id, int index, char *item_id, int item_type);
+ typedef int (*sync_agent_update_item_cb_plugin) (int account_id, int index, char *item_id, char *parent_id, int item_type);
/**
* Function which is called at some plugin (calendar, contact, memo) when need service account id list concerned of service_type
typedef int *(*sync_agent_get_account_id_list_cb_plugin) (int service_type, int *cnt);
/**
+ * Function which is called at calendar when existing child item is deleted to the service
+ *
+ * @param[in] parent_id parent_service_id
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_set_callback_delete_child_item(sync_agent_del_child_item_cb_plugin)
+ *
+ */
+ typedef int (*sync_agent_del_child_item_cb_plugin) (char *parent_id, char *child_id);
+
+/**
* @}
*/
sync_agent_util_compress_result_e sync_agent_uncompress(sync_agent_util_compress_type_e type, const char *input_file_path, const char *output_direcory_path);
/**
+ * API to decompress compressed file in specific format
+ *
+ * @par Usage:
+ * @code
+ sync_agent_util_compress_type_e type = SYNC_AGENT_UTIL_COMPRESS_TYPE_TAR;
+ char *input_path = NULL;
+ char *output_path = NULL;
+ ...
+ result = sync_agent_ua_uncompress(type, input_path, output_path);
+ if (result != SYNC_AGENT_UTIL_COMPRESS_SUCCESS) {
+ // error handling
+ ...
+ }
+ *
+ * @endcode
+ *
+ * @param[in] type type of compress in sync_agent_util_compress_type_e type of value
+ * @param[in] input_file_path compressed file path to decompress
+ * @param[in] output_direcory_path path to Update-Agent put decompressed folder
+ *
+ * @return SYNC_AGENT_UTIL_COMPRESS_SUCCESS on success, SYNC_AGENT_UTIL_COMPRESS_FAIL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_ua_uncompress(sync_agent_util_compress_type_e, const char *, const char *)
+ *
+ */
+ sync_agent_util_compress_result_e sync_agent_ua_uncompress(sync_agent_util_compress_type_e type, const char *input_file_path, const char *output_direcory_path);
+
+/**
* @}
*/
return (ret); \
} \
} while (0)
+#define goto_if(expr, fmt, arg...) \
+ do { \
+ if (expr) { \
+ _DEBUG_ERROR(fmt, ##arg); \
+ goto return_part; \
+ } \
+ } while (0)
/**
* API to daemonize client agent
Name: sync-agent
Summary: Sync agent FW Library
-Version: 0.1.82
+Version: 0.1.87
Release: 1
Group: TO_BE/FILLED_IN
License: Apache License, Version 2.0
BuildRequires: pkgconfig(capi-network-connection)
BuildRequires: pkgconfig(capi-network-serial)
BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(appsvc)
BuildRequires: pkgconfig(dlog)
BuildRequires: libgcrypt-devel
BuildRequires: cmake
%description devel
Development files for %{name}
-
#%package -n common-private-plugins
#Summary: Common Private Plugins
#Group: TO_BE_FILLED
#%description -n common-private-plugins
#common private plugins for sync-agent
-
%package -n common-public-plugins
Summary: Common Public Plugins
Group: TO_BE_FILLED
if (account_info != NULL) {
if (account_info->email != NULL)
free(account_info->email);
-
+ account_info->email = NULL;
free(account_info);
+ account_info = NULL;
}
-
_EXTERN_FUNC_EXIT;
}
"create table item_tbl"
"("
"item_id varchar(64) not null,"
- "data_store_id integer not null," "account_id integer not null," "folder_id varchar(64) not null," "service_id varchar(20) not null," "last_update date not null default current_timestamp," "access_name varchar(64) not null,"
+ "data_store_id integer not null," "account_id integer not null," "folder_id varchar(64) not null," "service_id varchar(20) not null," "parent_service_id varchar(64) default null," "last_update date not null default current_timestamp," "access_name varchar(64) not null,"
"constraint item_tbl_pk primary key(item_id)," "constraint item_tbl_account_id_fk foreign key(account_id) references account_tbl(account_id)," "constraint itme_tbl_folder_id_fk foreign key(folder_id) references folder_tbl(folder_id),"
"constraint item_tbl_uk unique(data_store_id, account_id, service_id)" ");",
return SYNC_AGENT_DA_ERR_PRIMARY_KEY_NOT_UNIQUE;
}
- char *query = "insert into item_tbl (item_id, data_store_id, account_id, folder_id, service_id, access_name) values (?, ?, ?, ?, ?, ?)";
+ char *query = "insert into item_tbl (item_id, data_store_id, account_id, folder_id, service_id, parent_service_id, access_name) values (?, ?, ?, ?, ?, ?, ?)";
stmt = __query_prepare(daci_handler, query, strlen(query));
if (stmt == NULL) {
_stmt_bind_int(daci_handler, stmt, 3, item[i].account_id);
__stmt_bind_text(daci_handler, stmt, 4, item[i].folder_id);
__stmt_bind_text(daci_handler, stmt, 5, item[i].service_id);
- __stmt_bind_text(daci_handler, stmt, 6, item[i].access_name);
+ __stmt_bind_text(daci_handler, stmt, 6, item[i].parent_service_id);
+ __stmt_bind_text(daci_handler, stmt, 7, item[i].access_name);
ret = __stmt_write_step(daci_handler, stmt);
if ((ret != SYNC_AGENT_DA_ERR_MORE_DATA) && (ret != SYNC_AGENT_DA_SUCCESS)) {
}
__stmt_finalize(daci_handler, stmt);
-
_EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+sync_agent_da_return_e da_update_item(SYNC_AGENT_DA_HANDLER * daci_handler, char *fw_id, char *parent_id)
+{
+ _EXTERN_FUNC_ENTER;
+ retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+ retvm_if(fw_id == NULL, SYNC_AGENT_DA_ERRORS, "fw_id is NULL !!");
+ retvm_if(parent_id == NULL, SYNC_AGENT_DA_ERRORS, "parent_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), "update item_tbl set parent_service_id = %s where item_id = %s", parent_id, fw_id);
+ _DEBUG_INFO("query = %s", query);
+ stmt = __query_prepare(daci_handler, query, strlen(query));
+ if (stmt == NULL) {
+ _DEBUG_ERROR("stmt is null");
+ ret = SYNC_AGENT_DA_ERR_QUERY_FAILED;
+ goto return_part;
+ }
+
+ ret = __stmt_write_step(daci_handler, stmt);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("__stmt_write_step() failed !!");
+ goto return_part;
+ }
+ __stmt_finalize(daci_handler, stmt);
+return_part:
+ _DEBUG_INFO("return_part");
+ _EXTERN_FUNC_EXIT;
return ret;
}
}
}
- char *query = "insert into item_tbl (item_id, data_store_id, account_id, folder_id, service_id, access_name) values (?, ?, ?, ?, ?, ?)";
+ char *query = "insert into item_tbl (item_id, data_store_id, account_id, folder_id, service_id, parent_service_id, access_name) values (?, ?, ?, ?, ?, ?, ?)";
stmt = __query_prepare(daci_handler, query, strlen(query));
if (stmt == NULL) {
_stmt_bind_int(daci_handler, stmt, 3, item[i].account_id);
__stmt_bind_text(daci_handler, stmt, 4, item[i].folder_id);
__stmt_bind_text(daci_handler, stmt, 5, item[i].service_id);
- __stmt_bind_text(daci_handler, stmt, 6, item[i].access_name);
+ __stmt_bind_text(daci_handler, stmt, 6, item[i].parent_service_id);
+ __stmt_bind_text(daci_handler, stmt, 7, item[i].access_name);
ret = __stmt_write_step(daci_handler, stmt);
if ((ret != SYNC_AGENT_DA_ERR_MORE_DATA) && (ret != SYNC_AGENT_DA_SUCCESS)) {
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
daci_stmt stmt = 0;
char query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = {0,};
+ char *service_id = NULL;
- snprintf(query, sizeof(query), "delete from item_tbl where item_id = %s", itemId);
- //for test
- //_DEBUG_INFO("query = [%s]", query);
+ snprintf(query, sizeof(query), "select service_id from item_tbl where item_id = %s", itemId);
+ stmt = __query_prepare(daci_handler, query, strlen(query));
+ if (stmt == NULL) {
+ _DEBUG_ERROR("stmt is null");
+ return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+ }
+ if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA)
+ service_id = _stmt_column_text(stmt, 0);
+ _DEBUG_INFO("[da_delete_item_by_Item_id] service_id = %s", service_id);
+ __stmt_finalize(daci_handler, stmt);
+ SYNC_AGENT_DA_MEMORY_SET(query);
+
+ snprintf(query, sizeof(query), "delete from item_tbl where parent_service_id = %s", service_id);
stmt = __query_prepare(daci_handler, query, strlen(query));
- if (stmt == NULL)
+ if (stmt == NULL) {
+ _DEBUG_ERROR("stmt is null");
return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+ }
+ _DEBUG_INFO("[da_delete_item_by_Item_id] before __stmt_write_step()");
ret = __stmt_write_step(daci_handler, stmt);
__stmt_finalize(daci_handler, stmt);
+ SYNC_AGENT_DA_MEMORY_SET(query);
- _EXTERN_FUNC_EXIT;
+ snprintf(query, sizeof(query), "delete from item_tbl where item_id = %s", itemId);
+ stmt = __query_prepare(daci_handler, query, strlen(query));
+ if (stmt == NULL) {
+ _DEBUG_ERROR("stmt is null");
+ return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+ }
+
+ ret = __stmt_write_step(daci_handler, stmt);
+ __stmt_finalize(daci_handler, stmt);
+ _EXTERN_FUNC_EXIT;
return ret;
}
}
sync_agent_free_memory_item_info(item_info, count);
-
_EXTERN_FUNC_EXIT;
-
return __stmt_finalize(daci_handler, stmt);
DACI_FINISH:
-
sync_agent_free_memory_item_info(item_info, count);
-
if (stmt != NULL)
__stmt_finalize(daci_handler, stmt);
-
return SYNC_AGENT_DA_ERR_QUERY_FAILED;
}
+
+sync_agent_da_return_e da_delete_all_child_item(SYNC_AGENT_DA_HANDLER * daci_handler, char *parent_service_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER 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), "delete from item_tbl where parent_service_id = %s", parent_service_id);
+ _DEBUG_INFO("query = %s", query);
+
+ stmt = __query_prepare(daci_handler, query, strlen(query));
+ if (stmt == NULL) {
+ _DEBUG_ERROR("stmt is null");
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto return_part;
+ }
+
+ ret = __stmt_write_step(daci_handler, stmt);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("__stmt_write_step failed");
+ goto return_part;
+ }
+ __stmt_finalize(daci_handler, stmt);
+
+ return_part:
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+sync_agent_da_return_e da_delete_child_item(SYNC_AGENT_DA_HANDLER * daci_handler, char *parent_service_id, char *child_service_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER 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), "delete from item_tbl where parent_service_id = %s and service_id = %s", parent_service_id, child_service_id);
+ _DEBUG_INFO("query = %s", query);
+
+ stmt = __query_prepare(daci_handler, query, strlen(query));
+ if (stmt == NULL) {
+ _DEBUG_ERROR("stmt is null");
+ ret = SYNC_AGENT_DA_ERRORS;
+ goto return_part;
+ }
+
+ ret = __stmt_write_step(daci_handler, stmt);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("__stmt_write_step failed");
+ goto return_part;
+ }
+ __stmt_finalize(daci_handler, stmt);
+
+ return_part:
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
sync_agent_da_return_e da_delete_item_by_item_type_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int item_type_id)
{
_EXTERN_FUNC_ENTER;
__stmt_finalize(daci_handler, stmt);
}
-
_EXTERN_FUNC_EXIT;
-
return item_id;
}
item->account_id = __stmt_column_int(stmt, 2);
item->folder_id = _stmt_column_text(stmt, 3);
item->service_id = _stmt_column_text(stmt, 4);
- item->access_name = _stmt_column_text(stmt, 6);
+ item->parent_service_id = _stmt_column_text(stmt, 5);
+ item->access_name = _stmt_column_text(stmt, 7);
}
__stmt_finalize(daci_handler, stmt);
}
(*sync_agent_item)->account_id = __stmt_column_int(stmt, 2);
(*sync_agent_item)->folder_id = _stmt_column_text(stmt, 3);
(*sync_agent_item)->service_id = _stmt_column_text(stmt, 4);
- (*sync_agent_item)->access_name = _stmt_column_text(stmt, 6);
+ (*sync_agent_item)->parent_service_id = _stmt_column_text(stmt, 5);
+ (*sync_agent_item)->access_name = _stmt_column_text(stmt, 7);
}
__stmt_finalize(daci_handler, stmt);
}
char *new_table = 0;
int row_count = 0;
int col_count = 0;
- int index = 6;
+ int index = 7;
int i = 0;
char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
if (new_table == NULL)
return item;
-// snprintf(g_daci_query, sizeof(g_daci_query), "select item_id, data_store_id, account_id, folder_id, service_id, access_name from item_tbl where account_id = %d and data_store_id = %d", accountId, itemTypeId);
snprintf(g_daci_query, sizeof(g_daci_query),
- "select item.item_id, item.data_store_id, item.account_id, item.folder_id, item.service_id, item.access_name " "from item_tbl as item " "left join %s as changelog " "using (item_id) "
+ "select item.item_id, item.data_store_id, item.account_id, item.folder_id, item.service_id, item.parent_service_id, item.access_name " "from item_tbl as item " "left join %s as changelog " "using (item_id) "
"where item.account_id = %d and item.data_store_id = %d and (changelog.operation_id is null or changelog.operation_id != 303)", new_table, account_id, itemTypeId);
_DEBUG_INFO("g_daci_query = %s", g_daci_query);
index++;
item[i].service_id = SYNC_AGENT_DA_STRDUP(result[index]);
index++;
+ item[i].parent_service_id = SYNC_AGENT_DA_STRDUP(result[index]);
+ index++;
item[i].access_name = SYNC_AGENT_DA_STRDUP(result[index]);
index++;
}
char *new_table = 0;
int row_count = 0;
int col_count = 0;
- int index = 6;
+ int index = 7;
int i = 0;
char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
// snprintf(g_daci_query, sizeof(g_daci_query), "select item_id, data_store_id, account_id, folder_id, service_id, access_name from item_tbl where account_id = %d and data_store_id = %d", accountId, itemTypeId);
snprintf(g_daci_query, sizeof(g_daci_query),
- "select item.item_id, item.data_store_id, item.account_id, item.folder_id, item.service_id, item.access_name " "from item_tbl as item " "left join %s as changelog " "using (item_id) "
+ "select item.item_id, item.data_store_id, item.account_id, item.folder_id, item.service_id, item.parent_service_id, item.access_name " "from item_tbl as item " "left join %s as changelog " "using (item_id) "
"where item.account_id = %d and item.data_store_id = %d and (changelog.operation_id is null or changelog.operation_id != 303)", new_table, account_id, item_type_id);
_DEBUG_INFO("g_daci_query = %s", g_daci_query);
index++;
item->service_id = SYNC_AGENT_DA_STRDUP(result[index]);
index++;
+ item->parent_service_id = SYNC_AGENT_DA_STRDUP(result[index]);
+ index++;
item->access_name = SYNC_AGENT_DA_STRDUP(result[index]);
index++;
if (result != NULL) {
__free_table(result);
}
- /* memory free */
- SYNC_AGENT_DA_MEMORY_FREE(new_table);
+ SYNC_AGENT_DA_MEMORY_FREE(new_table);
_EXTERN_FUNC_EXIT;
-
return ret;
}
return SYNC_AGENT_DA_SUCCESS;
}
+sync_agent_da_return_e da_get_updated_exdate_item_id_list(SYNC_AGENT_DA_HANDLER *daci_handler, char *fw_id, GList ** list)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+ retvm_if(fw_id == NULL, SYNC_AGENT_DA_ERRORS, "fw_id is NULL !!");
+
+ char **result = 0;
+ char *parent_service_id = NULL;
+ char *item_id;
+ char query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = {0, };
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ int row_count = 0;
+ int col_count = 0;
+ int index = 1;
+ int i = 0;
+ daci_stmt stmt = 0;
+
+ snprintf(query, sizeof(query), "select service_id from item_tbl where item_id = %s", fw_id);
+ _DEBUG_INFO("query : %s", query);
+ stmt = __query_prepare(daci_handler, query, strlen(query));
+ if (stmt != NULL) {
+ ret = _stmt_read_step(daci_handler, stmt);
+ if (ret == SYNC_AGENT_DA_ERR_MORE_DATA)
+ parent_service_id = _stmt_column_text(stmt, 0);
+ else {
+ _DEBUG_ERROR("_stmt_read_step() failed");
+ __stmt_finalize(daci_handler, stmt);
+ goto return_part;
+ }
+ __stmt_finalize(daci_handler, stmt);
+ }
+ SYNC_AGENT_DA_MEMORY_SET(query);
+
+ snprintf(query, sizeof(query), "select item_id from item_tbl where parent_service_id = \'%s\'", parent_service_id);
+ _DEBUG_INFO("query : %s", query);
+
+ ret = _get_table(daci_handler, query, &result, &row_count, &col_count);
+ if ((ret == SYNC_AGENT_DA_SUCCESS) && (row_count != 0) && (result != 0)) {
+ for (i = 0; i < row_count; i++) {
+ item_id = NULL;
+ item_id = SYNC_AGENT_DA_STRDUP(result[index]);
+ index++;
+ *list = g_list_append(*list, item_id);
+ }
+ }
+
+ if (result != NULL) {
+ __free_table(result);
+ }
+
+return_part:
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
int _busy_handler(void *pData, int count)
{
*/
/**
- * @brief Insert item into item_tbl - currently unused function
+ * @brief Insert item into item_tbl
* @param[in] daci_handler sqlite3 handler pointer about thread
* @param[in] item array of item info
* @param[in] count count of item info
/**
* @brief Insert item into item_tbl
+ * @param[in] daci_handler sqlite3 handler pointer about thread
+ * @param[in] fw_id framework id
+ * @param[in] parent_id parent service id of fw_id item
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_update_item(SYNC_AGENT_DA_HANDLER * daci_handler, char *fw_id, char *parent_id);
+
+/**
+ * @brief Insert item into item_tbl
* @param[in] daci_handler sqlite3 handler pointer about thread
* @param[in] item array of item info
* @param[in] count count of item info
sync_agent_da_return_e da_delete_item_by_item_type_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int item_type_id);
/**
+ * @brief Delete child item from item_tbl by parent service id
+ * @param[in] daci_handler sqlite3 handler pointer about thread
+ * @param[in] parent_service_id parent service id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_all_child_item(SYNC_AGENT_DA_HANDLER * daci_handler, char *parent_service_id);
+
+/**
+ * @brief Delete child item from item_tbl by parent service id
+ * @param[in] daci_handler sqlite3 handler pointer about thread
+ * @param[in] parent_service_id parent service id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_child_item(SYNC_AGENT_DA_HANDLER * daci_handler, char *parent_service_id, char *child_service_id);
+
+
+/**
* @brief Delete item from item_tbl by account id and item type id
* @param[in] daci_handler sqlite3 handler pointer about thread
* @param[in] account_id account id
* @retval error value fail
*/
sync_agent_da_return_e da_get_item_count_by_datastore_id(SYNC_AGENT_DA_HANDLER *daci_handler, int data_store_id, int fw_account_id, int *item_count);
+
+/*
+ * @brief get updated_exdate_item count with parent item's framework id
+ * @param[in] daci_handler sqlite3 handler pointer about thread
+ * @param[in] fw_id framework id of the parent item
+ * @param[in] list list as returned updated exdate item_id list
+ * @return sync_agent_da_return_e
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval error value fail
+ */
+sync_agent_da_return_e da_get_updated_exdate_item_id_list(SYNC_AGENT_DA_HANDLER *daci_handler, char *fw_id, GList ** list);
+
/*
* =============================================================================================================================
* Testing
return da_add_item(daci_handler, item, count);
}
+sync_agent_da_return_e da_update_item_internal(char *fw_id, char *parent_id)
+{
+ _EXTERN_FUNC_ENTER;
+ retvm_if(fw_id == NULL, SYNC_AGENT_DA_ERRORS, "fw_id is NULL !!");
+ retvm_if(parent_id == NULL, SYNC_AGENT_DA_ERRORS, "parent_id is NULL !!");
+
+ 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__);
+ return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return da_update_item(daci_handler, fw_id, parent_id);
+}
+
+
sync_agent_da_return_e sync_agent_add_item_new(sync_agent_da_item_s * item, int count, char **item_id)
{
_EXTERN_FUNC_ENTER;
return da_delete_item_by_item_type_id(daci_handler, account_id, item_type_id);
}
+sync_agent_da_return_e da_delete_all_child_item_internal(char *parent_service_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ 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__);
+ return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return da_delete_all_child_item(daci_handler, parent_service_id);
+}
+
+sync_agent_da_return_e da_delete_child_item_internal(char *parent_service_id, char *child_service_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ 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__);
+ return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return da_delete_child_item(daci_handler, parent_service_id, child_service_id);
+}
+
+
sync_agent_da_return_e da_delete_item_and_changelog_by_item_type_id_internal(int account_id, int item_type_id)
{
_EXTERN_FUNC_ENTER;
/* For test log */
__print_agentDBHashTableLog();
#endif
+ pthread_mutex_unlock(agent_db_handler_mgr->daci_handlerTable_mutex);
+ _EXTERN_FUNC_EXIT;
+ return ret;
addagentHandler:
pthread_mutex_unlock(agent_db_handler_mgr->daci_handlerTable_mutex);
-
+ if(key_copy != NULL) {
+ free(key_copy);
+ }
_EXTERN_FUNC_EXIT;
-
return ret;
}
sync_agent_da_folder_s *da_get_item_mapping_service_id_by_folder_id_internal(int account_id, char *folder_id, int *count);
/**
- * @brief Insert item into item_tbl - currently unused function
+ * @brief Insert item into item_tbl
* @param[in] item array of item info
* @param[in] count count of item info
* @return Operation result
sync_agent_da_return_e da_add_item_internal(sync_agent_da_item_s * item, int count);
/**
+ * @brief Update item into item_tbl
+ * @param[in] fw_id framework id
+ * @param[in] parent_id parent service id of fw_id item
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_update_item_internal(char *fw_id, char *parent_id);
+
+/**
* @brief Insert item into item_tbl
* @param[in] item array of item info
* @param[in] count count of item info
sync_agent_da_return_e da_delete_item_by_item_type_id_internal(int account_id, int item_type_id);
/**
+ * @brief Delete child item from item_tbl by parent service id
+ * @param[in] parent_service_id parent service id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_all_child_item_internal(char *parent_service_id);
+
+/**
+ * @brief Delete child item from item_tbl by parent service id
+ * @param[in] parent_service_id parent service id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_child_item_internal(char *parent_service_id, char *child_service_id);
+
+
+
+/**
* @brief Delete item from item_tbl by account id and item type id and row that checked delete from changelog tbl
* @param[in] account_id account id
* @param[in] item_type_id item type id
/*
* insert item table
*/
- plugin_get_changed_item_for_folder_add_cb func_get_changed_item_for_folder_add = plugin_get_function_get_chaned_item_for_folder_add(service_type);
- plugin_get_changed_item_for_folder_update_cb func_get_changed_item_for_folder_update = plugin_get_function_get_chaned_item_for_folder_update(service_type);
+ plugin_get_changed_item_for_folder_add_cb func_get_changed_item_for_folder_add = plugin_get_function_get_changed_item_for_folder_add(service_type);
+ plugin_get_changed_item_for_folder_update_cb func_get_changed_item_for_folder_update = plugin_get_function_get_changed_item_for_folder_update(service_type);
int service_account_id = acc_get_service_account_id(service_type, fw_account_id);
_DEBUG_INFO("service_account_id : %d", service_account_id);
item.folder_id = fw_folder_id_list[i];
item.data_store_id = service_type;
item.service_id = cursor_ptr->item_id;
+ item.parent_service_id = cursor_ptr->parent_item_id;
item.access_name = "DACI";
sync_agent_da_return_e ret = da_add_item_internal(&item, 1);
sync_agent_plugin_item_node_s *temp = cursor_ptr;
cursor_ptr = cursor_ptr->next;
free(temp->item_id);
+ free(temp->parent_item_id);
free(temp);
if (fw_item_id_list[y] != NULL) {
item.folder_id = fw_folder_id_list[i];
item.data_store_id = service_type;
item.service_id = cursor_ptr->item_id;
+ item.parent_service_id = cursor_ptr->parent_item_id;
item.access_name = "DACI";
sync_agent_da_return_e ret = da_add_item_internal(&item, 1);
sync_agent_plugin_item_node_s *temp = cursor_ptr;
cursor_ptr = cursor_ptr->next;
free(temp->item_id);
+ free(temp->parent_item_id);
free(temp);
if (fw_item_id_list[y] != NULL) {
/*
* Construct Item & changelog table
*/
- plugin_get_changed_item_for_folder_add_cb func_get_changed_item_for_folder_add = plugin_get_function_get_chaned_item_for_folder_add(service_type);
+ plugin_get_changed_item_for_folder_add_cb func_get_changed_item_for_folder_add = plugin_get_function_get_changed_item_for_folder_add(service_type);
int service_account_id = acc_get_service_account_id(service_type, fw_account_id);
_DEBUG_INFO("service_account_id : %d", service_account_id);
if (fw_item_id_list != NULL) {
int k = 0;
for (; k < item_cnt; k++) {
+ sync_agent_da_item_s item;
char *service_item_id = cursor_ptr->item_id;
_DEBUG_INFO("service_item_id[%d] : %s", k, service_item_id);
_DEBUG_INFO("fw_item_id : %s", fw_item_id_list[k]);
- da_changelog_add_item_internal(fw_account_id, fw_item_id_list[k], cursor_ptr->item_id, service_type, fw_folder_id_list[i]);
+ item.item_id = fw_item_id_list[k];
+ item.data_store_id = service_type;
+ item.account_id = fw_account_id;
+ item.folder_id = fw_folder_id_list[i];
+ item.service_id = cursor_ptr->item_id;
+ item.parent_service_id = cursor_ptr->parent_item_id;
+ da_changelog_add_item_internal(&item);
sync_agent_plugin_item_node_s *temp = cursor_ptr;
cursor_ptr = cursor_ptr->next;
int fw_change_point = _get_serivce_change_point(fw_account_id, service_type);
_DEBUG_TRACE("fw_last_change_point : %d", fw_change_point);
- plugin_get_changed_item_for_folder_add_cb func_get_changed_item_for_folder_add = plugin_get_function_get_chaned_item_for_folder_add(service_type);
- plugin_get_changed_item_for_folder_delete_cb func_get_changed_item_for_folder_del = plugin_get_function_get_chaned_item_for_folder_delete(service_type);
- plugin_get_changed_item_for_folder_update_cb func_get_changed_item_for_folder_update = plugin_get_function_get_chaned_item_for_folder_update(service_type);
+ plugin_get_changed_item_for_folder_add_cb func_get_changed_item_for_folder_add = plugin_get_function_get_changed_item_for_folder_add(service_type);
+ plugin_get_changed_item_for_folder_delete_cb func_get_changed_item_for_folder_del = plugin_get_function_get_changed_item_for_folder_delete(service_type);
+ plugin_get_changed_item_for_folder_update_cb func_get_changed_item_for_folder_update = plugin_get_function_get_changed_item_for_folder_update(service_type);
/*
* todo Get fw_folder_id list in the service
int y = 0;
if (fw_item_id_list != NULL) {
for (; y < added_item_cnt; y++) {
- da_changelog_add_item_internal(fw_account_id, fw_item_id_list[y], cursor_ptr->item_id, service_type, fw_folder_id_list[i]);
+ sync_agent_da_item_s item;
+ item.item_id = fw_item_id_list[y];
+ item.data_store_id = service_type;
+ item.account_id = fw_account_id;
+ item.folder_id = fw_folder_id_list[i];
+ item.service_id = cursor_ptr->item_id;
+ item.parent_service_id = cursor_ptr->parent_item_id;
+ da_changelog_add_item_internal(&item);
sync_agent_plugin_item_node_s *temp = cursor_ptr;
cursor_ptr = cursor_ptr->next;
free(temp->item_id);
char *fw_item_id = da_get_item_id_internal(fw_account_id, cursor_ptr->item_id, service_type);
if (fw_item_id == NULL) {
- da_changelog_add_item_internal(fw_account_id, fw_item_id_list[y], cursor_ptr->item_id, service_type, fw_folder_id_list[i]);
+ sync_agent_da_item_s item;
+ item.item_id = fw_item_id_list[y];
+ item.data_store_id = service_type;
+ item.account_id = fw_account_id;
+ item.folder_id = fw_folder_id_list[i];
+ item.service_id = cursor_ptr->item_id;
+ item.parent_service_id = cursor_ptr->parent_item_id;
+ da_changelog_add_item_internal(&item);
} else {
da_changelog_update_item_internal(fw_account_id, fw_item_id, service_type);
}
static pthread_mutex_t change_lock;
-int da_handle_add_item(int service_account_id, int index, char *service_item_id, int item_type, char *service_folder_id, int folder_type)
+int da_handle_add_item(int service_account_id, int index, char *service_item_id, char *parent_service_item_id, int item_type, char *service_folder_id, int folder_type)
{
_EXTERN_FUNC_ENTER;
_DEBUG_INFO("itemType : %d", item_type);
_DEBUG_INFO("service_folderID : %s", service_folder_id);
_DEBUG_INFO("folderType : %d", folder_type);
+ _DEBUG_INFO("parent_service_item_id : %s", parent_service_item_id);
sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
sync_agent_da_return_e open_ret = SYNC_AGENT_DA_SUCCESS;
goto DACI_FINISH;
}
- /*
- * add item
- */
+ // add item
item.account_id = fw_account_id;
item.item_id = fw_item_id;
item.folder_id = fw_folder_id;
item.data_store_id = item_type;
item.service_id = service_item_id;
+ item.parent_service_id = parent_service_item_id;
item.access_name = "DACI_ChangeLog";
ret = da_add_item_internal(&item, 1);
goto DACI_FINISH;
}
- /*
- * add change log
- */
- item_changelog.item_id = fw_item_id;
- item_changelog.operation_id = 301;
- item_changelog.status = "SYNC_REQUIRED";
- item_changelog.access_name = "DACI_ChangeLog";
+ // add change log (only for normal item not calendar exdate item)
+ if (parent_service_item_id == NULL) {
+ item_changelog.item_id = fw_item_id;
+ item_changelog.operation_id = 301;
+ item_changelog.status = "SYNC_REQUIRED";
+ item_changelog.access_name = "DACI_ChangeLog";
- ret = da_add_item_changelog_wrapper(fw_account_id, &item_changelog, 1);
- if (ret != SYNC_AGENT_DA_SUCCESS) {
- _DEBUG_ERROR("Failed to Add Item changelog : %d", ret);
- goto DACI_FINISH;
+ ret = da_add_item_changelog_wrapper(fw_account_id, &item_changelog, 1);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("Failed to Add Item changelog : %d", ret);
+ goto DACI_FINISH;
+ }
}
DACI_FINISH:
return ret;
}
-int da_handle_update_item(int service_account_id, int index, char *service_item_id, int item_type)
+int da_handle_update_item(int service_account_id, int index, char *service_item_id, char *parent_service_item_id, int item_type)
{
_EXTERN_FUNC_ENTER;
_DEBUG_INFO("service_accountID : %d", service_account_id);
_DEBUG_INFO("service_itemID : %s", service_item_id);
_DEBUG_INFO("itemType : %d", item_type);
+ _DEBUG_INFO("parent_service_item_id : %s", parent_service_item_id);
sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
sync_agent_da_return_e open_ret = SYNC_AGENT_DA_SUCCESS;
}
}
+ // update parent_id (only for Calendar exdate item)
+ if (parent_service_item_id != NULL) {
+ ret = da_update_item_internal(fw_item_id, parent_service_item_id);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("da_update_item_internal failed");
+ goto DACI_FINISH;
+ }
+ }
+
DACI_FINISH:
- /*open test */
+ _DEBUG_INFO("return_part");
daci_res = sync_agent_end_transaction(SYNC_AGENT_DA_TRANSACTION_COMMIT);
if (daci_res != SYNC_AGENT_DA_SUCCESS) {
_DEBUG_ERROR("sync_agent_end_transaction fail");
}
_EXTERN_FUNC_EXIT;
-
return ret;
}
-int da_changelog_add_item_internal(int fw_account_id, char *fw_item_id, char *service_item_id, int item_type, char *fw_folder_id)
+int da_changelog_add_item_internal(sync_agent_da_item_s *item)
{
_EXTERN_FUNC_ENTER;
- retvm_if(fw_item_id == NULL, 0, "fw item id is NULL !!");
- retvm_if(service_item_id == NULL, 0, "service item id is NULL !!");
- retvm_if(fw_folder_id == NULL, 0, "fw folder id is NULL !!");
+ retvm_if(item == NULL, 0, "fw item id is NULL !!");
/*
* TODO : 1. Need to Null check parameter
* 4. generate item luid
* 5. add item & change log
*/
- _DEBUG_INFO("fw_account_id : %d", fw_account_id);
- _DEBUG_INFO("fw_item_id : %s", fw_item_id);
- _DEBUG_INFO("service_item_id : %s", service_item_id);
- _DEBUG_INFO("itemType : %d", item_type);
- _DEBUG_INFO("fw_folder_id : %s", fw_folder_id);
+ _DEBUG_INFO("item_id : %s", item->item_id);
+ _DEBUG_INFO("data_store_id : %d", item->data_store_id);
+ _DEBUG_INFO("account_id : %d", item->account_id);
+ _DEBUG_INFO("folder_id : %s", item->folder_id);
+ _DEBUG_INFO("service_id : %s", item->service_id);
+ _DEBUG_INFO("parent_service_id : %s", item->parent_service_id);
sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
-
- sync_agent_da_item_s item;
sync_agent_da_item_changelog_s item_changelog;
- /*
- * check whether the item is included
- */
-
- /*
- char *item_id = sync_agent_get_item_id(fw_account_id, service_item_id, itemType);
- if (item_id != NULL) {
- _DEBUG_ERROR("Item already exists : %s", item_id);
- goto DACI_FINISH;
- }
- */
-
- /*
- * add item
- */
- item.account_id = fw_account_id;
- item.item_id = fw_item_id;
- item.folder_id = fw_folder_id;
- item.data_store_id = item_type;
- item.service_id = service_item_id;
- item.access_name = "DACI_ChangeLog";
-
- ret = da_add_item_internal(&item, 1);
+ // add item
+ item->access_name = "DACI_ChangeLog";
+ ret = da_add_item_internal(item, 1);
if (ret != SYNC_AGENT_DA_SUCCESS) {
_DEBUG_ERROR("add item failed return : %d", ret);
goto DACI_FINISH;
}
- /*
- * add change log
- */
- item_changelog.item_id = fw_item_id;
+ // add change log
+ item_changelog.item_id = item->item_id;
item_changelog.operation_id = 301;
item_changelog.status = "SYNC_REQUIRED";
item_changelog.access_name = "DACI_ChangeLog";
- ret = da_add_item_changelog_wrapper(fw_account_id, &item_changelog, 1);
+ ret = da_add_item_changelog_wrapper(item->account_id, &item_changelog, 1);
if (ret != SYNC_AGENT_DA_SUCCESS) {
_DEBUG_ERROR("add item changelog failed return : %d", ret);
goto DACI_FINISH;
}
DACI_FINISH:
- /*
- if (item_id != NULL) {
- free(item_id);
- }
- */
-
_EXTERN_FUNC_EXIT;
-
return ret;
}
sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
sync_agent_da_item_changelog_s item_changelog;
- /*
- * check whether the item is included
- */
-
- /*
- char *item_id = sync_agent_get_item_id(fw_account_id, service_item_id, itemType);
- if (item_id != NULL) {
- _DEBUG_ERROR("Item already exists : %s", item_id);
- goto DACI_FINISH;
- }
- */
-
- /*
- * add item
- */
+ // 1. add item
ret = sync_agent_add_item_new(sync_agent_item, 1, item_id);
if (ret != SYNC_AGENT_DA_SUCCESS) {
_DEBUG_ERROR("add item failed return : %d", ret);
goto DACI_FINISH;
}
- /*
- * add change log
- */
+ // 2. add change log
item_changelog.item_id = *item_id;
item_changelog.operation_id = 301;
item_changelog.status = "SYNC_REQUIRED";
}
DACI_FINISH:
- /*
- if (item_id != NULL) {
- free(item_id);
- }
- */
-
_EXTERN_FUNC_EXIT;
-
return ret;
}
return ret;
}
+
+int da_handle_del_child_item(char *parent_service_id, char *child_service_id)
+{
+ _EXTERN_FUNC_ENTER;
+ retvm_if(parent_service_id == NULL, 0, "parent_service_id is NULL!!");
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ // If child_service_id is null, it means that all child item should be deleted.
+ if (child_service_id) {
+ _DEBUG_INFO("parent id = %s, child id = %s", parent_service_id, child_service_id);
+ ret = da_delete_child_item_internal(parent_service_id, child_service_id);
+ goto_if(ret != SYNC_AGENT_DA_SUCCESS, "da_delete_child_item_internal() failed");
+ }
+ else {
+ sync_agent_da_return_e open_ret = sync_agent_open_agent();
+ _DEBUG_INFO("Done Open Agent DB : %d", open_ret);
+
+ sync_agent_da_return_e daci_res = sync_agent_begin_transaction();
+ if (daci_res != SYNC_AGENT_DA_SUCCESS) { _DEBUG_ERROR("sync_agent_begin_transaction fail"); }
+
+ ret = da_delete_all_child_item_internal(parent_service_id);
+ if (ret != SYNC_AGENT_DA_SUCCESS) { _DEBUG_ERROR("da_delete_all_child_item_internal() failed"); }
+
+ daci_res = sync_agent_end_transaction(SYNC_AGENT_DA_TRANSACTION_COMMIT);
+ if (daci_res != SYNC_AGENT_DA_SUCCESS) { _DEBUG_ERROR("sync_agent_end_transaction fail"); }
+
+ open_ret = sync_agent_close_agent();
+ _DEBUG_INFO("Done Close Agent DB : %d", open_ret);
+ }
+
+return_part:
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
* @param[in] fw_folder_id sync-agent-framework folder id
* @return 1 on success, otherwise a negative error value
*/
- int da_changelog_add_item_internal(int fw_account_id, char *fw_item_id, char *service_item_id, int item_type, char *fw_folder_id);
+int da_changelog_add_item_internal(sync_agent_da_item_s *item);
+
/**
* @brief Handling added item to service storage, update sync-agent-framework item & change log table
* @remarks This function is called when the new item is added to the service storage. data connector plugin developer use this function.
* @param[in] service_account_id service account id
* @param[in] index possible mapping one service account with multiple sync-agent-framework account, so need index of sync-agent-framework account.
- * @param[in] service_item_id added service item id
+ * @param[in] service_item_id added service item id
+ * @param[in] parent_service_item_id parent service id of the added service item id (only Calendar exdate item)
* @param[in] item_type service type - service data connector plugin's id described in sync-agent-framework config file
* @param[in] service_folder_id service folder id
* @param[in] folder_type folder type defined in data connector plugin
* @return 1 on success, otherwise a negative error value.
* @see sync_agent_changelog_add_item()
*/
-int da_handle_add_item(int service_account_id, int index, char *service_item_id, int item_type, char *service_folder_id, int folder_type);
+int da_handle_add_item(int service_account_id, int index, char *service_item_id, char *parent_service_item_id, int item_type, char *service_folder_id, int folder_type);
/**
* @brief Handling deleted item from service storage, update sync-agent-framework item & change log table
* @param[in] service_account_id service account id
* @param[in] index possible mapping one service account with multiple sync-agent-framework account, so need index of sync-agent-framework account
* @param[in] service_item_id added service item id
+ * @param[in] parent_service_item_id parent service id of the added service item id (only Calendar exdate item)
* @param[in] item_type service type - service data connector pluIn's ID described in F/W config file
* @return 1 on success, otherwise a negative error value.
* @see sync_agent_changelog_update_item()
*/
-int da_handle_update_item(int service_account_id, int index, char *service_item_id, int item_type);
+int da_handle_update_item(int service_account_id, int index, char *service_item_id, char *parent_service_item_id, int item_type);
+
+/**
+ * @brief Handling delete child item from service storage, update sync-agent-framework item & change log table
+ * @remarks This function is called when the item is deleted from the service storage. data connector plugin developer use this function.
+ * @param[in] parent_id parent service id
+ * @return 1 on success, otherwise a negative error value.
+ * @see sync_agent_changelog_delete_item()
+ */
+int da_handle_del_child_item(char *parent_service_id, char *child_service_id);
/**
* @}
SYNC_AGENT_DA_MEMORY_FREE(item[i].item_id);
SYNC_AGENT_DA_MEMORY_FREE(item[i].folder_id);
SYNC_AGENT_DA_MEMORY_FREE(item[i].service_id);
+ SYNC_AGENT_DA_MEMORY_FREE(item[i].parent_service_id);
SYNC_AGENT_DA_MEMORY_FREE(item[i].access_name);
}
SYNC_AGENT_DA_MEMORY_FREE(item);
_DEBUG_ERROR("sync_agent_folder is NULL !!");
return SYNC_AGENT_DA_ERRORS;
}
-
_EXTERN_FUNC_EXIT;
-
return SYNC_AGENT_DA_SUCCESS;
}
}
_EXTERN_FUNC_EXIT;
-
return ret;
}
_DEBUG_ERROR("folder id is NULL !!");
return SYNC_AGENT_DA_ERRORS;;
}
-
_EXTERN_FUNC_EXIT;
-
return SYNC_AGENT_DA_SUCCESS;
}
_DEBUG_ERROR("list is NULL !!");
return SYNC_AGENT_DA_ERRORS;
}
-
_EXTERN_FUNC_EXIT;
-
return ret;
}
}
_EXTERN_FUNC_EXIT;
-
return SYNC_AGENT_DA_SUCCESS;
}
EXPORT_API sync_agent_da_return_e sync_agent_add_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;
-
-// item_id = (char **) calloc(count, sizeof(char *));
-// if (item_id == NULL) {
-// _DEBUG_ERROR("calloc failed !!");
-// }
-//
-// for (i; i < count; i++) {
-// if (use_changelog == 1) {
-// ret = sync_agent_changelog_add_item_new(sync_agent_item, item_id);
-// } else {
-// ret = sync_agent_add_item_new(sync_agent_item, count, item_id);
-// }
-//
-// if (ret != SYNC_AGENT_DA_SUCCESS) {
-// _DEBUG_ERROR("add item failed !!");
-// return ret;
-// }
-// }
-
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 !!");
+ _DEBUG_ERROR("sync_agent_changelog_add_item_new() 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 !!");
+ _DEBUG_ERROR("sync_agent_add_item_new() failed !!");
}
}
_EXTERN_FUNC_EXIT;
-
return ret;
}
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 !!");
+ _DEBUG_ERROR("sync_agent_changelog_add_item_new() 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 !!");
+ _DEBUG_ERROR("sync_agent_add_item_new() failed !!");
}
}
if (sync_agent_item != NULL) {
if (sync_agent_item->item_id != NULL)
free(sync_agent_item->item_id);
+ sync_agent_item->item_id = NULL;
if (sync_agent_item->folder_id != NULL)
free(sync_agent_item->folder_id);
+ sync_agent_item->folder_id = NULL;
if (sync_agent_item->service_id != NULL)
free(sync_agent_item->service_id);
+ sync_agent_item->service_id = NULL;
+
+ if (sync_agent_item->parent_service_id != NULL)
+ free(sync_agent_item->parent_service_id);
+ sync_agent_item->parent_service_id = NULL;
if (sync_agent_item->access_name != NULL)
free(sync_agent_item->access_name);
+ sync_agent_item->access_name = NULL;
free(sync_agent_item);
+ sync_agent_item = NULL;
} else {
_DEBUG_ERROR("sync_agent_item is NULL !!");
return SYNC_AGENT_DA_ERRORS;
}
-
_EXTERN_FUNC_EXIT;
-
return SYNC_AGENT_DA_SUCCESS;
}
_DEBUG_ERROR("list is NULL !!");
return SYNC_AGENT_DA_ERRORS;
}
-
_EXTERN_FUNC_EXIT;
-
return ret;
}
if (item_id != NULL) {
free(item_id);
+ item_id = NULL;
} else {
_DEBUG_ERROR("item id is NULL !!");
return SYNC_AGENT_DA_ERRORS;;
}
_EXTERN_FUNC_EXIT;
-
return SYNC_AGENT_DA_SUCCESS;
}
return ret;
}
}
-
g_list_free(list);
} else {
_DEBUG_INFO("list is NULL !!");
return ret;
}
-
_EXTERN_FUNC_EXIT;
-
return ret;
}
+
EXPORT_API sync_agent_da_return_e sync_agent_get_item_count(int data_store_id, int *item_count)
{
_EXTERN_FUNC_ENTER;
_EXTERN_FUNC_EXIT;
return ret;
}
+
+EXPORT_API sync_agent_da_return_e sync_agent_get_updated_exdate_item_id_list(char *fw_id, GList ** list)
+{
+ _EXTERN_FUNC_ENTER;
+ retvm_if(fw_id == NULL, SYNC_AGENT_DA_ERRORS, "fw_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);
+ goto_if(daci_handler == NULL, "daci_handler is null");
+
+ ret = da_get_updated_exdate_item_id_list(daci_handler, fw_id, list);
+ goto_if(ret != SYNC_AGENT_DA_SUCCESS, "da_get_updated_exdate_item_id_list() failed, ret = [%d]", ret);
+
+return_part:
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
}
_EXTERN_FUNC_EXIT;
-
return SYNC_AGENT_DA_SUCCESS;
}
if (service_item != NULL) {
if (service_item->item_id != NULL)
free(service_item->item_id);
-
+ service_item->item_id = NULL;
+ if (service_item->parent_id != NULL)
+ free(service_item->parent_id);
+ service_item->parent_id = NULL;
if (service_item->folder_id != NULL)
free(service_item->folder_id);
-
+ service_item->folder_id = NULL;
if (service_item->access_name != NULL)
free(service_item->access_name);
-
+ service_item->access_name = NULL;
if (service_item->data != NULL)
free((void *)(service_item->data));
-
+ service_item->data = NULL;
free(service_item);
+ service_item = NULL;
} else {
_DEBUG_ERROR("service_item is NULL !!");
return SYNC_AGENT_DA_ERRORS;
}
_EXTERN_FUNC_EXIT;
-
return SYNC_AGENT_DA_SUCCESS;
}
_DEBUG_ERROR("service_folder is NULL !!");
return SYNC_AGENT_DA_ERRORS;
}
-
_EXTERN_FUNC_EXIT;
-
return SYNC_AGENT_DA_SUCCESS;
}
fw_item->item_id = g_strdup(service_item->item_id);
fw_item->folder_id = g_strdup(service_item->folder_id);
fw_item->service_id = g_strdup(service_item_id);
+ fw_item->parent_service_id = g_strdup(service_item->parent_id);
fw_item->access_name = g_strdup(service_item->access_name);
ret = sync_agent_add_item(fw_item, item_id, update_changelog);
}
/**************** 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);
} 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);
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->parent_service_id = g_strdup(service_item->parent_id);
+ _DEBUG_INFO("fw_item->parent_service_id = %s", fw_item->parent_service_id);
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);
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) {
}
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;
}
return ret;
}
+EXPORT_API sync_agent_da_return_e sync_agent_add_updated_exdate_item(sync_agent_da_service_item_s * service_item, char *parent_id, char *child_id, bool update_changelog)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(service_item == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_service_item_s is NULL !!");
+ retvm_if(parent_id == NULL, SYNC_AGENT_DA_ERRORS, "parent_id is NULL !!");
+
+ _DEBUG_INFO("account_id : %d", service_item->account_id);
+ _DEBUG_INFO("folder_id : %s", service_item->folder_id);
+ _DEBUG_INFO("parent_id : %s", parent_id);
+ _DEBUG_INFO("child_id : %s", child_id);
+ _DEBUG_INFO("service_item->item_id : %s", service_item->item_id);
+ _DEBUG_INFO("data : %s", (char *)service_item->data);
+
+ char *service_folder_id = NULL;
+ char *service_parent_item_id = NULL;
+ void *service_data = NULL;
+ void *new_service_data = NULL;
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ int service_account_id = 0;
+ plugin_get_item_cb func_get_item;
+ plugin_replace_converter_cb func_replace_converter;
+
+ 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);
+ service_folder_id = sync_agent_get_service_folder_id(service_item->folder_id);
+ _DEBUG_INFO("service_folder_id : %s", service_folder_id);
+ service_parent_item_id = sync_agent_get_service_item_id(parent_id);
+ _DEBUG_INFO("service_parent_item_id : %s", service_parent_item_id);
+
+ /* 4. call plugIn dataconnector */
+ func_get_item = plugin_get_function_get_item(service_item->content_type);
+ if (func_get_item == NULL) {
+ _DEBUG_ERROR("%d", __LINE__);
+ ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
+ goto return_part;
+ }
+
+ ret = func_get_item(service_account_id, service_folder_id, service_parent_item_id, &service_data);
+ goto_if(ret != SYNC_AGENT_DA_SUCCESS, "func_get_item() failed, ret = [%d]", ret);
+
+ /* 5. checking whether the item exist or not*/
+ ret = sync_agent_is_exist_exdate_item(service_item->content_type, service_parent_item_id, (char *)service_item->data);
+ if (ret == SYNC_AGENT_DA_ERR_ALREADY_EXIST) {
+ _DEBUG_INFO("SYNC_AGENT_DA_ERR_ALREADY_EXIST");
+ ret = SYNC_AGENT_DA_SUCCESS;
+ goto return_part;
+ }
+
+ /* 6. call plugIn dataconverter */
+ 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("%d", __LINE__);
+ ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
+ goto return_part;
+ }
+
+ ret = func_replace_converter(service_data, service_item->data, &new_service_data);
+ goto_if(ret != SYNC_AGENT_DA_SUCCESS, "func_replace_converter() failed, ret = [%d]", ret);
+
+
+ //////////////////////////////////////// construct the parent item ////////////////////////////////
+ // All child item of parent item whose has original_event_id as service_id field should be deleted before callback_add_item()
+ // Requesting by Calendar Svc Team (2013-03-26 tw123.kim & iamjs.kim)
+ sync_agent_construct_exdate_parent_item(service_item->content_type, service_parent_item_id);
+
+return_part:
+ _DEBUG_INFO("return_part");
+ if (service_folder_id != NULL){
+ free(service_folder_id);
+ service_folder_id = NULL;
+ }
+ if (new_service_data != NULL){
+ free(new_service_data);
+ new_service_data = NULL;
+ }
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
EXPORT_API sync_agent_da_return_e sync_agent_delete_service_item(char *item_id, bool update_changelog)
{
_EXTERN_FUNC_ENTER;
_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);
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);
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
int service_account_id = 0;
-/* char **folder_id_list = NULL;
- int folder_id_list_cnt = 0;
- char *service_item_id = NULL;*/
plugin_delete_all_items_cb func_del_all_items;
/* 1. get service account id */
service_account_id = acc_get_service_account_id(query->content_type, query->account_id);
_DEBUG_INFO("[sync_agent_query_delete_service_items] service_acount_id : %d", service_account_id);
-/* //2. get folder id list for account id
- folder_id_list = DACI_Get_Folder_Folder_Id_List_By_Account_Id(account_id, &folder_id_list_cnt);
- _DEBUG_INFO("[sync_agent_query_delete_service_items] folder_id_list_cnt : %d", folder_id_list_cnt);
-
- //3. get service item id
- service_item_id = sync_agent_get_service_item_id(item_id);
- _DEBUG_INFO("[sync_agent_query_delete_service_items] service_item_id : %s", service_item_id);*/
-
/* 2. call plugIn dataconnector */
func_del_all_items = plugin_get_function_del_all_items(query->content_type);
_DEBUG_INFO("[sync_agent_query_delete_service_items] success func_del_all_items()\n");
}
- /* memory free */
-/* if (service_folder_id !=NULL)
- free(service_folder_id);
-
- if (service_item_id != NULL)
- free(service_item_id);*/
-
_EXTERN_FUNC_EXIT;
-
return ret;
}
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
sync_agent_da_item_s *fw_item = NULL;
int service_account_id = 0;
+ int parent_id = -1;
char *service_folder_id = NULL;
char *service_item_id = NULL;
void *service_data = NULL;
(*service_item)->folder_id = g_strdup(fw_item->folder_id);
(*service_item)->access_name = g_strdup(fw_item->access_name);
- DACI_FINISH:
+ // in case of exdate item (only Calendar), The framework id of it's parent should be alloc to service_item->parent_id
+ if (fw_item->parent_service_id != NULL) {
+ parent_id = atoi(fw_item->parent_service_id);
+ _DEBUG_INFO("parent_id = %d", parent_id);
+ if (parent_id >= 0)
+ (*service_item)->parent_id = da_get_item_id_internal((*service_item)->account_id, fw_item->parent_service_id, (*service_item)->content_type);
+ }
+
+DACI_FINISH:
- /* memory free */
if (fw_item != NULL)
sync_agent_free_item(fw_item);
+ fw_item = NULL;
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 used_count;
}
+EXPORT_API int sync_agent_get_deleted_exdate_item_count(int content_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ plugin_get_deleted_exdate_item_count func_get_used_count = plugin_get_function_get_deleted_exdate_item_count(content_type);
+ retvm_if(func_get_used_count == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_get_deleted_exdate_item_count !!");
+
+ /* 1. call plugIn dataconnector */
+ int used_count = func_get_used_count();
+ if (used_count <= -1) {
+ _DEBUG_INFO("[sync_agent_get_deleted_exdate_item_count] failed pFunc_Get_Used_Count()\n");
+ } else {
+ _DEBUG_INFO("[sync_agent_get_deleted_exdate_item_count] success pFunc_Get_Used_Count() : %d\n", used_count);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return used_count;
+}
+
+EXPORT_API void sync_agent_construct_exdate_parent_item(int content_type, char *parent_service_id)
+{
+ _EXTERN_FUNC_ENTER;
+ retm_if(parent_service_id == NULL, "parent_service_id is NULL !!");
+
+ plugin_construct_exdate_parent_item func_construct_exdate_parent_item = plugin_function_construct_exdate_parent_item(content_type);
+ goto_if(func_construct_exdate_parent_item == NULL, "cannot get plugin_construct_exdate_parent_item !!");
+ func_construct_exdate_parent_item(parent_service_id);
+
+return_part:
+ _EXTERN_FUNC_EXIT;
+ return;
+}
+
+
+EXPORT_API sync_agent_da_return_e sync_agent_is_exist_exdate_item(int content_type, const char *fw_parent_id, const char *child_vcalendar)
+{
+ _EXTERN_FUNC_ENTER;
+
+ plugin_is_exist_exdate_item func_is_exist_exdate_item = plugin_function_is_exist_exdate_item(content_type);
+ retvm_if(func_is_exist_exdate_item == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_is_exist_exdate_item !!");
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ ret = func_is_exist_exdate_item(fw_parent_id, child_vcalendar);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
EXPORT_API int sync_agent_get_used_service_item_count_for_folder(int content_type, int account_id, char *folder_id)
{
_EXTERN_FUNC_ENTER;
return da_get_folder_service_id(daci_handler, folder_id);
}
+
+EXPORT_API int sync_agent_get_sim_contact_info_max_name_length(int content_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ plugin_get_info_sim_contact_max_name_length_cb func_get_info_sim_contact_max_name_length = plugin_get_function_get_info_sim_contact_max_name_length(content_type);
+ retvm_if(func_get_info_sim_contact_max_name_length == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_get_info_sim_contact_max_name_length_cb !!");
+
+ int maxNameLength = func_get_info_sim_contact_max_name_length();
+
+ _EXTERN_FUNC_EXIT;
+ return maxNameLength;
+}
+
+EXPORT_API int sync_agent_get_sim_contact_info_max_number_length(int content_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ plugin_get_info_sim_contact_max_number_length_cb func_get_info_sim_contact_max_number_length = plugin_get_function_get_info_sim_contact_max_number_length(content_type);
+ retvm_if(func_get_info_sim_contact_max_number_length == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_get_info_sim_contact_max_number_length_cb !!");
+
+ int maxNumberLength = func_get_info_sim_contact_max_number_length();
+
+ _EXTERN_FUNC_EXIT;
+ return maxNumberLength;
+}
+
+EXPORT_API int sync_agent_get_sim_contact_info_max_email_length(int content_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ plugin_get_info_sim_contact_max_email_length_cb func_get_info_sim_contact_max_email_length = plugin_get_function_get_info_sim_contact_max_email_length(content_type);
+ retvm_if(func_get_info_sim_contact_max_email_length == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_get_info_sim_contact_max_email_length_cb !!");
+
+ int maxEmailLength = func_get_info_sim_contact_max_email_length();
+
+ _EXTERN_FUNC_EXIT;
+ return maxEmailLength;
+}
+
+EXPORT_API int sync_agent_get_sim_contact_empty_count(int content_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ plugin_get_info_sim_contact_empty_count_cb func_get_info_sim_contact_empty_count = plugin_get_function_get_info_sim_contact_empty_count(content_type);
+ retvm_if(func_get_info_sim_contact_empty_count == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_get_info_sim_contact_empty_count_cb !!");
+
+ int emptyCount = func_get_info_sim_contact_empty_count();
+
+ _EXTERN_FUNC_EXIT;
+ return emptyCount;
+}
+
+EXPORT_API int sync_agent_get_sim_contact_empty_number_count(int content_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ plugin_get_info_sim_contact_empty_number_count_cb func_get_info_sim_contact_empty_number_count = plugin_get_function_get_info_sim_contact_empty_number_count(content_type);
+ retvm_if(func_get_info_sim_contact_empty_number_count == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_get_info_sim_contact_empty_number_count_cb !!");
+
+ int emptyNumberCount = func_get_info_sim_contact_empty_number_count();
+
+ _EXTERN_FUNC_EXIT;
+ return emptyNumberCount;
+}
+
+EXPORT_API int sync_agent_get_sim_contact_empty_email_count(int content_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ plugin_get_info_sim_contact_empty_email_count_cb func_get_info_sim_contact_empty_email_count = plugin_get_function_get_info_sim_contact_empty_email_count(content_type);
+ retvm_if(func_get_info_sim_contact_empty_email_count == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_get_info_sim_contact_empty_email_count_cb !!");
+
+ int emptyEmailCount = func_get_info_sim_contact_empty_email_count();
+
+ _EXTERN_FUNC_EXIT;
+ return emptyEmailCount;
+}
+
+EXPORT_API int sync_agent_get_sim_contact_addressbook_id(int content_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ plugin_get_info_sim_contact_addressbook_id_cb func_get_info_sim_contact_addressbook_id = plugin_get_function_get_info_sim_contact_addressbook_id(content_type);
+ retvm_if(func_get_info_sim_contact_addressbook_id == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_get_info_sim_contact_addressbook_id !!");
+
+ int simContactAddressbookId = func_get_info_sim_contact_addressbook_id();
+
+ _EXTERN_FUNC_EXIT;
+ return simContactAddressbookId;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_get_sim_contact_item_id(int content_type, int sim_addressbook_id, GList **item_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_da_return_e da_ret = SYNC_AGENT_DA_SUCCESS;
+
+ plugin_get_info_sim_contact_item_id_cb func_get_info_sim_contact_item_id = plugin_get_function_get_info_sim_contact_item_id(content_type);
+ retvm_if(func_get_info_sim_contact_item_id == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get func_get_info_sim_contact_item_id !!");
+
+ GList *item_id_list = NULL;
+ da_ret = func_get_info_sim_contact_item_id(sim_addressbook_id, &item_id_list);
+ if (da_ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("func_get_info_sim_contact_item_id() fail, da_ret[%d]", da_ret);
+ }
+ *item_id = item_id_list;
+
+ _EXTERN_FUNC_EXIT;
+ return da_ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_get_sim_contact_item(int content_type, int item_id, char **data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_da_return_e da_ret = SYNC_AGENT_DA_SUCCESS;
+
+ plugin_get_info_sim_contact_item_cb func_get_info_sim_contact_item = plugin_get_function_get_info_sim_contact_item(content_type);
+ retvm_if(func_get_info_sim_contact_item == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get func_get_info_sim_contact_item !!");
+
+ char *item_data = NULL;
+ da_ret = func_get_info_sim_contact_item(item_id, &item_data);
+ if (da_ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("func_get_info_sim_contact_item() fail, da_ret[%d]", da_ret);
+ }
+ *data = item_data;
+
+ _EXTERN_FUNC_EXIT;
+ return da_ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_add_sim_contact_item(int content_type, int sim_addressbook_id, int **item_id, char *data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_da_return_e da_ret = SYNC_AGENT_DA_SUCCESS;
+
+ plugin_add_sim_contact_item_cb func_add_sim_contact_item = plugin_get_function_add_sim_contact_item(content_type);
+ retvm_if(func_add_sim_contact_item == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get func_add_sim_contact_item !!");
+
+ int *item_id_tmp = NULL;
+ da_ret = func_add_sim_contact_item(sim_addressbook_id, &item_id_tmp, data);
+ if (da_ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("func_add_sim_contact_item() fail, da_ret[%d]", da_ret);
+ }
+
+ *item_id = item_id_tmp;
+
+ _EXTERN_FUNC_EXIT;
+ return da_ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_write_sim_contact_item(int content_type, int item_id, char *data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_da_return_e da_ret = SYNC_AGENT_DA_SUCCESS;
+
+ plugin_write_sim_contact_item_cb func_write_sim_contact_item = plugin_get_function_write_sim_contact_item(content_type);
+ retvm_if(func_write_sim_contact_item == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get func_write_sim_contact_item !!");
+
+ da_ret = func_write_sim_contact_item(item_id, data);
+ if (da_ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("func_write_sim_contact_item() fail, da_ret[%d]", da_ret);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return da_ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_delete_sim_contact_item(int content_type, int item_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_da_return_e da_ret = SYNC_AGENT_DA_SUCCESS;
+
+ plugin_delete_sim_contact_item_cb func_delete_sim_contact_item = plugin_get_function_delete_sim_contact_item(content_type);
+ retvm_if(func_delete_sim_contact_item == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get func_delete_sim_contact_item !!");
+
+ da_ret = func_delete_sim_contact_item(item_id);
+ if (da_ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("func_delete_sim_contact_item() fail, da_ret[%d]", da_ret);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return da_ret;
+}
+
sync_agent_dm_mo_error_e err_code = dm_get_mo(mo_path, root_node, option);
_DEBUG_INFO("mo_path : %s", mo_path);
+ if(err_code == SYNC_AGENT_DM_MO_FAIL) {
+ return err_code;
+ }
/*
* Recursive Call
*/
sync_agent_dm_mo_error_e err_code = dm_mo_get_node_wraper(mo_path, mo_node);
if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
_DEBUG_ERROR("Failed to dm_mo_get_node_wraper : [%d]", err_code);
+ if( err_code == SYNC_AGENT_DM_MO_FAIL) {
+ if( *mo_node != NULL ) {
+ sync_agent_free_mo_item(*mo_node);
+ }
+ }
return err_code;
}
err_code = dm_mo_get_node_from_id_wraper(iter->parent_id, &mo_parent_node);
if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
_DEBUG_ERROR("Failed to dm_mo_get_parent mo: [%d]", err_code);
+ if(mo_parent_node != NULL) {
+ free(mo_parent_node);
+ }
return SYNC_AGENT_DM_MO_FAIL;
}
int parent_id = -1;
char *mo_acl_value = NULL;
int isSearch_value = 0;
int isExist_all = 0;
- char *mo_server_id = NULL;
int server_id_length = 0;
char *ptr_sev_id = NULL;
/* search acl command and server_id */
char *ptr_cmd = strstr(mo_acl_value, command_str);
while (ptr_cmd != NULL) {
+ char *mo_server_id = NULL;
_DEBUG_INFO("########## Operation Start ###########");
_DEBUG_INFO("ptr_cmd = %s\n", ptr_cmd);
if (strcmp(mo_server_id, server_id) == 0) {
_DEBUG_INFO("====> Search ACL Server_id");
isSearch_value = 2;
+
+ if (mo_server_id != NULL) {
+ free(mo_server_id);
+ mo_server_id = NULL;
+ }
+
break;
} else if (strcmp(mo_server_id, "*") == 0) {
_DEBUG_INFO("Exist All Format");
}
/* prepare next value check */
- if (ptr_sev_id != NULL)
+ if (ptr_sev_id != NULL) {
ptr_cmd = strstr(ptr_sev_id, command_str);
- else
+ } else {
ptr_cmd = NULL;
+ }
if (mo_server_id != NULL) {
free(mo_server_id);
}
}
- if (mo_server_id != NULL) {
- free(mo_server_id);
- mo_server_id = NULL;
- }
if (mo_node != NULL)
dm_free_mo(mo_node, 1);
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;
}
retm_if(engine_controller == NULL, "ec_engine_controller_t is NULL !!");
- pthread_create(&(engine_controller->thread_id), NULL, (ec_thread_start_routine_cb) _engine_controller_logic, (void *)engine_controller);
+ int status_thread_create = 0;
+ status_thread_create = pthread_create(&(engine_controller->thread_id), NULL, (ec_thread_start_routine_cb) _engine_controller_logic, (void *)engine_controller);
+ if(status_thread_create != 0) {
+ _DEBUG_WARNING("pthread_create [%d]", status_thread_create );
+ _EXTERN_FUNC_EXIT;
+ return;
+ }
+
pthread_detach(engine_controller->thread_id);
_EXTERN_FUNC_EXIT;
retm_if(engine_controller_receiver == NULL, "ec_engine_controller_receiver_t is NULL !!");
/* TODO */
- pthread_create(&(engine_controller_receiver->thread_id), NULL, (ec_thread_start_routine_cb) _engine_controller_receiver_logic, (void *)engine_controller_receiver);
+ int status_thread_create = 0;
+ status_thread_create = pthread_create(&(engine_controller_receiver->thread_id), NULL, (ec_thread_start_routine_cb) _engine_controller_receiver_logic, (void *)engine_controller_receiver);
+ if(status_thread_create != 0) {
+ _DEBUG_WARNING("pthread_create [%d]", status_thread_create );
+ _EXTERN_FUNC_EXIT;
+ return;
+ }
+
pthread_detach(engine_controller_receiver->thread_id);
_EXTERN_FUNC_EXIT;
/* sync_agent_ec_boolean is_dynamic, sync_agent_ec_int dynamic_case, sync_agent_ec_int child_index */
sync_agent_ec_error_e ec_error = SYNC_AGENT_EC_OK;
sync_agent_ec_boolean new_entity = false;
+ ec_progress_blocking_entity_t *entity = NULL;
va_list ap;
va_start(ap, child_depth);
va_start(ap, child_depth);
/* find progress blocking entity */
- ec_progress_blocking_entity_t *entity = _queuing_rule_spec_get_progress_blocking_entity(rule, root_task_spec_id);
+ entity = _queuing_rule_spec_get_progress_blocking_entity(rule, root_task_spec_id);
if (entity == NULL) {
entity = ec_progress_blocking_entity_new(root_task_spec_id, rule);
if (entity == NULL) {
}
return_part:
+ if (new_entity) {
+ if(entity != NULL) {
+ ec_progress_blocking_entity_free(entity);
+ }
+ }
+
_EXTERN_FUNC_EXIT;
return ec_error;
if (fp != NULL)
fclose(fp);
return SYNC_AGENT_EVENT_FAIL;
+ } else {
+ memset(event_spec, 0, sizeof(event_spec_s));
}
char description[1000];
_DEBUG_ERROR("CALLOC failed !!!");
free(noti_spec_bag);
return SYNC_AGENT_EVENT_FAIL;
+ } else {
+ memset(noti_spec, 0, sizeof(noti_spec_s));
}
char description[1000] = { 0, };
if (type == SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER) {
/* get data */
memcpy(data, iter->data, sizeof(int));
+ _DEBUG_INFO("sync_agent_get_event_data_param_int - data: [%d]",*data);
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");
}
+ _DEBUG_INFO("sync_agent_get_event_data_param_int - iter->event_num: [%d]", iter->event_num);
+ _DEBUG_INFO("sync_agent_get_event_data_param_int - *(iter->size): [ox%x]", *(iter->size));
+ _DEBUG_INFO("sync_agent_get_event_data_param_int - *(iter->data): [0x%x]", *(iter->data));
+
/* setting for next */
*(iter->size) -= 1;
_DEBUG_INFO("sync_agent_run_event_handler() start\n");
- pthread_create(&event_handler_thread_id, 0, _event_listener, 0);
+ int status_thread_create = 0;
+ status_thread_create = pthread_create(&event_handler_thread_id, 0, _event_listener, 0);
+ if(status_thread_create != 0) {
+ _DEBUG_WARNING("pthread_create [%d]", status_thread_create );
+ _EXTERN_FUNC_EXIT;
+ return SYNC_AGENT_EVENT_FAIL;
+ }
*thread_id = event_handler_thread_id;
signal(SIGPIPE, SIG_IGN);
- int client_sockfd;
+ int client_sockfd = -1;
int state;
socklen_t client_len;
struct sockaddr_un clientaddr, serveraddr;
}
client_len = sizeof(clientaddr);
+ _DEBUG_INFO("_event_listener - client_len: [%d]",client_len);
if ((_event_server_socket_id = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
return NULL;
}
while (1) {
_DEBUG_TRACE("In EventHandler loop=\n");
- char inbuf[EVENT_MAX_STREAM_SIZE + 1];
- char outbuf[EVENT_MAX_STREAM_SIZE + 1];
+ char * inbuf = NULL;
+ char * outbuf = NULL;
+ inbuf = (char*)malloc(sizeof(char)*(EVENT_MAX_STREAM_SIZE + 1));
+ if(inbuf == NULL) {
+ _DEBUG_ERROR("inbuf malloc failed!!");
+ goto error;
+ }
+
+ outbuf= (char*)malloc(sizeof(char)*(EVENT_MAX_STREAM_SIZE + 1));
+ if(outbuf == NULL) {
+ _DEBUG_ERROR("outbuf malloc failed!!");
+ goto error;
+ }
+
memset(inbuf, 0x00, EVENT_MAX_STREAM_SIZE + 1);
memset(outbuf, 0x00, EVENT_MAX_STREAM_SIZE + 1);
sync_agent_event_data_s request;
sync_agent_event_data_s response;
+
request.data = inbuf;
response.data = outbuf;
event_init_event_data_iter(&request);
event_init_event_data_iter(&response);
client_sockfd = accept(_event_server_socket_id, (struct sockaddr *)&clientaddr, &client_len);
+
if (client_sockfd < 0) {
_DEBUG_ERROR("socket accept() failed !!");
- return NULL;
+ goto error;
}
_DEBUG_TRACE("accept() was called\n");
+ _DEBUG_INFO("_event_listener - client_sockfd: [%d]",client_sockfd);
result = read(client_sockfd, (void *)inbuf, EVENT_MAX_STREAM_SIZE);
if (result <= 0 || result > EVENT_MAX_STREAM_SIZE) {
_DEBUG_ERROR("read failed !!");
- close(client_sockfd);
- return NULL;
+ goto error;
}
- if (strlen(inbuf) <= 0 || strlen(inbuf) > EVENT_MAX_STREAM_SIZE) {
- _DEBUG_ERROR("socket data read : size OUT OF BOUND !!");
- close(client_sockfd);
- return NULL;
+/*
+ _DEBUG_INFO("read result [%d]", result);
+
+ int print_i = 0;
+ for( print_i = 0; print_i < result ; print_i++)
+ {
+ _DEBUG_INFO(" 0x%x ", inbuf[print_i]);
}
+ _DEBUG_INFO("request.event_num [%d]", request.event_num);
+ _DEBUG_INFO("request.size [ox%x]", *(request.size));
+ _DEBUG_INFO("request.data [0x%x]", *(request.data));
+*/
int 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);
- /*
- * need synchronous response case
- */
+
+ // need synchronous response case
event_type_e event_type = event_get_event_type(event_num);
if (event_type == EVENT_TYPE_NEED_RESPONSE) {
if (event_get_event_data_element_size(&response) > 0) {
}
}
- close(client_sockfd);
+ error:
+
+ if (inbuf) {
+ free(inbuf);
+ inbuf = NULL;
+ }
+
+ if (outbuf) {
+ free(outbuf);
+ outbuf = NULL;
+ }
+
+ if (client_sockfd >= 0 )
+ close(client_sockfd);
}
_INNER_FUNC_EXIT;
NOTI_DOWNLOAD_INFO,
/* Fumo UI Util Noti */
- NOTI_ENGINE_START,
- NOTI_ENGINE_FAIL = 5,
+ NOTI_ENGINE_START = 4,
+ NOTI_ENGINE_FAIL,
NOTI_WIFI_ONLY_DOWNLOAD_FAIL,
NOTI_MEMORY_FULL,
NOTI_OVER_BIG_SIZE,
NOTI_ALERT_SINGLE_CHOICE,
NOTI_ALERT_MULTIPLE_CHOICE,
+ NOTI_POLL_INTERACTION = 15,
+ NOTI_UPDATE_RESULT,
NOTI_NUM
} sync_agent_dm_noti_e;
PUSH_NOT_SPECIFIED = 0,
PUSH_BACKGROUND,
PUSH_INFORMATIVE,
- PUSH_INTERACTION
+ PUSH_INTERACTION,
+ POLL_INTERACTION
} sync_agent_dm_push_type;
EXPORT_API sync_agent_dm_error_e sync_agent_dm_push_init()
sync_agent_ds_error_e result = SYNC_AGENT_DS_SUCCESS;
sync_agent_init_error_e init_error = SYNC_AGENT_INIT_SUCCESS;
int ret = -1;
- int pid = -1;
+ int pid = -1;
_DEBUG_INFO("before sysman_get_pid");
pid = sysman_get_pid("/usr/bin/oma-ds-agent");
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();
static int inotify_fd;
static int inotify_wd;
static int gsource_id;
+static int creat_notify_fd = -1;
static gboolean _agent_noti_listener(GIOChannel * p_src, GIOCondition cond, gpointer p_data);
_DEBUG_TRACE("%s file is not exist !!");
}
- int fd = creat(communication_path, S_IRWXU | S_IRWXG | S_IRWXO);
- if (fd < 0) {
+ creat_notify_fd = creat(communication_path, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (creat_notify_fd < 0) {
_DEBUG_ERROR("creat() failed !!");
return SYNC_AGENT_EVENT_FAIL;
} else {
inotify_fd = inotify_init();
if (inotify_fd == -1) {
_DEBUG_ERROR("inotify_init() failed !!");
- return SYNC_AGENT_EVENT_FAIL;
+ goto error;
+ //return SYNC_AGENT_EVENT_FAIL;
}
/* change file's attribute */
result = fcntl(inotify_fd, F_SETFD, FD_CLOEXEC);
if (result == -1) {
_DEBUG_ERROR("fcntl() failed !!");
- return SYNC_AGENT_EVENT_FAIL;
+ goto error;
+ //return SYNC_AGENT_EVENT_FAIL;
}
result = fcntl(inotify_fd, F_SETFL, O_NONBLOCK);
if (result == -1) {
_DEBUG_ERROR("fcntl() failed !!");
- return SYNC_AGENT_EVENT_FAIL;
+ goto error;
+ //return SYNC_AGENT_EVENT_FAIL;
}
/* add a watch to an initialized inotify instance */
inotify_wd = inotify_add_watch(inotify_fd, communication_path, IN_CLOSE_WRITE);
if (inotify_wd == -1) {
_DEBUG_ERROR("inotify_add_watch() failed !!");
- return SYNC_AGENT_EVENT_FAIL;
+ goto error;
+ //return SYNC_AGENT_EVENT_FAIL;
}
/* create a new GIOChannel given a file descriptor */
gio_channel = g_io_channel_unix_new(inotify_fd);
if (gio_channel == NULL) {
_DEBUG_ERROR("g_io_channel_unix_new() failed !!");
- return SYNC_AGENT_EVENT_FAIL;
+ goto error;
+ //return SYNC_AGENT_EVENT_FAIL;
}
/* turn on nonblocking mode */
_EXTERN_FUNC_EXIT;
return SYNC_AGENT_EVENT_SUCCESS;
+
+error: // prevent 32978
+ if (creat_notify_fd < 0) {
+ _DEBUG_INFO("creat_notify_fd < 0 ");
+ } else {
+ _DEBUG_INFO("creat_notify_fd >= 0 : close(creat_notify_fd)");
+ close(creat_notify_fd);
+ creat_notify_fd = -1;
+ }
+
+ if (sync_agent_is_existing_fs(communication_path)) {
+ _DEBUG_TRACE("%s file is exist !!");
+ if (unlink(communication_path) == -1) {
+ _DEBUG_ERROR("unlink failed ( %s ), ERROR NUM [%d] !!", communication_path, errno);
+ _EXTERN_FUNC_EXIT;
+ return SYNC_AGENT_EVENT_FAIL;
+ } else {
+ _DEBUG_TRACE("unlink success !!");
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return SYNC_AGENT_EVENT_FAIL;
}
EXPORT_API sync_agent_event_error_e sync_agent_stop_noti_listener()
{
_EXTERN_FUNC_ENTER;
+ if (creat_notify_fd < 0) {
+ _DEBUG_INFO("creat_notify_fd < 0 ");
+ } else {
+ _DEBUG_INFO("creat_notify_fd >= 0 : close(creat_notify_fd)");
+ close(creat_notify_fd);
+ creat_notify_fd = -1;
+ }
inotify_rm_watch(inotify_fd, inotify_wd);
close(inotify_fd);
retm_if(event == NULL, "sync_agent_event_data_s is NULL !!");
event->size = event->data;
+ _DEBUG_INFO("event_init_event_data_iter - event->size :[%x]",event->size);
event->data = event->data + 1;
-
+ _DEBUG_INFO("event_init_event_data_iter - event->data :[%x]",event->data);
_EXTERN_FUNC_EXIT;
}
ret = sync_agent_read_file(file_path, &required_contents, FS_BUFFER_SIZE, &read_file_size, &isFinal);
if (ret != 1) {
_DEBUG_ERROR("sync_agent_read_file() Fail\n");
+ ret = 0;
goto return_part;
}
sync_agent_free_file(&required_contents);
_EXTERN_FUNC_EXIT;
+ return ret;
return_part:
+ if (real_md5_word != NULL) {
+ free(real_md5_word);
+ real_md5_word = NULL;
+ }
+ _DEBUG_INFO("Free Part");
+ sync_agent_free_file(&required_contents);
+
+ _EXTERN_FUNC_EXIT;
return ret;
}
if (plugIn_dc_repository[i].handle_change_noti) {
plugin_set_callback_add_item_cb func_point_set_callback_add_item = plugin_get_function_set_callback_add_item(plugIn_id);
plugin_set_callback_delete_item_cb func_point_set_callback_delete_item = plugin_get_function_set_callback_delete_item(plugIn_id);
+ plugin_set_callback_delete_child_item_cb func_point_set_callback_delete_child_item = plugin_get_function_set_callback_delete_child_item(plugIn_id);
plugin_set_callback_update_item_cb func_point_set_callback_update_item = plugin_get_function_data_connector_set_callback_update_item(plugIn_id);
plugin_set_callback_get_account_id_list_cb func_point_set_callback_get_account_id_list = plugin_get_function_set_callback_get_account_id_list(plugIn_id);
plugin_start_listening_change_noti_cb func_point_start_listening_change_noti = plugin_get_function_start_listening_change_noti(plugIn_id);
}
func_point_set_callback_add_item(da_handle_add_item);
func_point_set_callback_delete_item(da_handle_del_item);
+ func_point_set_callback_delete_child_item(da_handle_del_child_item);
func_point_set_callback_update_item(da_handle_update_item);
func_point_set_callback_get_account_id_list(acc_get_service_account_id_list);
sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
void *session = NULL;
+ _DEBUG_INFO("na_plugin_id [%d]", na_plugin_id);
int err = na_create_session_info(&session);
if (err != 1) {
void *session = NULL;
void *msg = NULL;
int try_again_cnt = 0;
+ _DEBUG_INFO("na_plugin_id [%d]", na_plugin_id);
/* check current network status */
if (plugin_use_network(na_plugin_id) == 1) {
backup_send_head_info_list = g_list_append(backup_send_head_info_list, header_item_info);
} else {
_DEBUG_ERROR("key is NULL !!");
- header_item_info->key = NULL;
- header_item_info->value = NULL;
+ //header_item_info->key = NULL;
+ //header_item_info->value = NULL;
+ free(header_item_info);
+ header_item_info = NULL;
}
/*backup_send_head_info_list = g_list_append(backup_send_head_info_list, header_item_info); */
+ /*
if (header_item_info->key != NULL) {
if (strcmp(header_item_info->key, "Range") == 0)
_DEBUG_INFO("[Before] key : %s, value : %s", header_item_info->key, header_item_info->value);
}
+ */
}
/* send_msg */
func_set.func_get_folder = dlsym(plugin_handle, "sync_agent_plugin_get_folder");
func_set.func_execute = dlsym(plugin_handle, "sync_agent_plugin_execute");
func_set.func_get_used_item_cnt = dlsym(plugin_handle, "sync_agent_plugin_get_used_item_count");
+ func_set.func_get_deleted_exdate_item_cnt = dlsym(plugin_handle, "sync_agent_plugin_get_deleted_exdate_item_count");
+ func_set.func_is_exist_exdate_item = dlsym(plugin_handle, "sync_agent_plugin_is_exist_exdate_item");
+ func_set.func_construct_exdate_parent_item = dlsym(plugin_handle, "sync_agent_plugin_construct_exdate_parent_item");
func_set.func_get_used_cnt_for_folder = dlsym(plugin_handle, "sync_agent_plugin_get_used_item_count_for_folder");
func_set.func_get_folder_id_list = dlsym(plugin_handle, "sync_agent_plugin_get_folder_id_list");
func_set.func_get_account_id_list = dlsym(plugin_handle, "sync_agent_plugin_get_account_id_list");
func_set.func_start_listening_change_noti = dlsym(plugin_handle, "sync_agent_plugin_start_listening_change_noti");
func_set.func_set_callback_add_item = dlsym(plugin_handle, "sync_agent_plugin_set_callback_add_item");
func_set.func_set_callback_delete_item = dlsym(plugin_handle, "sync_agent_plugin_set_callback_delete_item");
+ func_set.func_set_callback_delete_child_item = dlsym(plugin_handle, "sync_agent_plugin_set_callback_delete_child_item");
func_set.func_set_callback_update_item = dlsym(plugin_handle, "sync_agent_plugin_set_callback_update_item");
func_set.func_set_callback_get_account_id_list = dlsym(plugin_handle, "sync_agent_plugin_set_callback_get_account_id_list");
func_set.func_get_max_item_count = dlsym(plugin_handle, "sync_agent_plugin_get_max_item_count");
func_set.func_get_max_field_count = dlsym(plugin_handle, "sync_agent_plugin_get_max_field_count");
func_set.func_get_field_value = dlsym(plugin_handle, "sync_agent_plugin_get_field_value");
func_set.func_get_is_support_feature = dlsym(plugin_handle, "sync_agent_plugin_get_is_support_feature");
+ func_set.func_get_info_sim_contact_max_name_length = dlsym(plugin_handle, "sync_agent_plugin_get_info_sim_contact_max_name_length");
+ func_set.func_get_info_sim_contact_max_number_length = dlsym(plugin_handle, "sync_agent_plugin_get_info_sim_contact_max_number_length");
+ func_set.func_get_info_sim_contact_max_email_length = dlsym(plugin_handle, "sync_agent_plugin_get_info_sim_contact_max_email_length");
+ func_set.func_get_info_sim_contact_empty_count = dlsym(plugin_handle, "sync_agent_plugin_get_info_sim_contact_empty_count");
+ func_set.func_get_info_sim_contact_empty_number_count = dlsym(plugin_handle, "sync_agent_plugin_get_info_sim_contact_empty_number_count");
+ func_set.func_get_info_sim_contact_empty_email_count = dlsym(plugin_handle, "sync_agent_plugin_get_info_sim_contact_empty_email_count");
+ func_set.func_get_info_sim_contact_addressbook_id = dlsym(plugin_handle, "sync_agent_plugin_get_info_sim_contact_addressbook_id");
+ func_set.func_get_info_sim_contact_item_id = dlsym(plugin_handle, "sync_agent_plugin_get_info_sim_contact_item_id");
+ func_set.func_get_info_sim_contact_item = dlsym(plugin_handle, "sync_agent_plugin_get_info_sim_contact_item");
+ func_set.func_add_sim_contact_item = dlsym(plugin_handle, "sync_agent_plugin_add_sim_contact_item");
+ func_set.func_write_sim_contact_item = dlsym(plugin_handle, "sync_agent_plugin_write_sim_contact_item");
+ func_set.func_delete_sim_contact_item = dlsym(plugin_handle, "sync_agent_plugin_delete_sim_contact_item");
_EXTERN_FUNC_EXIT;
-
return func_set;
}
}
+plugin_get_deleted_exdate_item_count plugin_get_function_get_deleted_exdate_item_count(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_get_deleted_exdate_item_cnt;
+}
+
+plugin_is_exist_exdate_item plugin_function_is_exist_exdate_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_is_exist_exdate_item;
+}
+
+plugin_construct_exdate_parent_item plugin_function_construct_exdate_parent_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_construct_exdate_parent_item;
+}
+
plugin_get_used_count_for_folder_cb plugin_get_function_get_used_count_for_folder(int plugin_id)
{
_EXTERN_FUNC_ENTER;
return plugin_repository[index].func_set.func_restore_service_items_from_file;
}
-plugin_get_changed_item_for_folder_add_cb plugin_get_function_get_chaned_item_for_folder_add(int plugin_id)
+plugin_get_changed_item_for_folder_add_cb plugin_get_function_get_changed_item_for_folder_add(int plugin_id)
{
_EXTERN_FUNC_ENTER;
return plugin_repository[index].func_set.func_get_chaned_item_for_folder_add;
}
-plugin_get_changed_item_for_folder_delete_cb plugin_get_function_get_chaned_item_for_folder_delete(int plugin_id)
+plugin_get_changed_item_for_folder_delete_cb plugin_get_function_get_changed_item_for_folder_delete(int plugin_id)
{
_EXTERN_FUNC_ENTER;
return plugin_repository[index].func_set.func_get_chaned_item_for_folder_delete;
}
-plugin_get_changed_item_for_folder_update_cb plugin_get_function_get_chaned_item_for_folder_update(int plugin_id)
+plugin_get_changed_item_for_folder_update_cb plugin_get_function_get_changed_item_for_folder_update(int plugin_id)
{
_EXTERN_FUNC_ENTER;
return plugin_repository[index].func_set.func_set_callback_get_account_id_list;
}
+plugin_set_callback_delete_child_item_cb plugin_get_function_set_callback_delete_child_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_set_callback_delete_child_item;
+}
+
plugin_get_max_item_count_cb plugin_get_function_get_max_item_count(int plugin_id)
{
_EXTERN_FUNC_ENTER;
return plugin_repository[index].func_set.func_get_is_support_feature;
}
+plugin_get_info_sim_contact_max_name_length_cb plugin_get_function_get_info_sim_contact_max_name_length(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_get_info_sim_contact_max_name_length;
+}
+
+plugin_get_info_sim_contact_max_number_length_cb plugin_get_function_get_info_sim_contact_max_number_length(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_get_info_sim_contact_max_number_length;
+}
+
+plugin_get_info_sim_contact_max_email_length_cb plugin_get_function_get_info_sim_contact_max_email_length(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_get_info_sim_contact_max_email_length;
+}
+
+plugin_get_info_sim_contact_empty_count_cb plugin_get_function_get_info_sim_contact_empty_count(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_get_info_sim_contact_empty_count;
+}
+
+plugin_get_info_sim_contact_empty_number_count_cb plugin_get_function_get_info_sim_contact_empty_number_count(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_get_info_sim_contact_empty_number_count;
+}
+
+plugin_get_info_sim_contact_empty_email_count_cb plugin_get_function_get_info_sim_contact_empty_email_count(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_get_info_sim_contact_empty_email_count;
+}
+
+plugin_get_info_sim_contact_addressbook_id_cb plugin_get_function_get_info_sim_contact_addressbook_id(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_get_info_sim_contact_addressbook_id;
+}
+
+plugin_get_info_sim_contact_item_id_cb plugin_get_function_get_info_sim_contact_item_id(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_get_info_sim_contact_item_id;
+}
+
+plugin_get_info_sim_contact_item_cb plugin_get_function_get_info_sim_contact_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_get_info_sim_contact_item;
+}
+
+plugin_add_sim_contact_item_cb plugin_get_function_add_sim_contact_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_sim_contact_item;
+}
+
+plugin_write_sim_contact_item_cb plugin_get_function_write_sim_contact_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_write_sim_contact_item;
+}
+
+plugin_delete_sim_contact_item_cb plugin_get_function_delete_sim_contact_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_sim_contact_item;
+}
+
static int _find_data_connector_plugin(int plugin_id)
{
_INNER_FUNC_ENTER;
#include "error.h"
#include "struct.h"
+#include <glib.h>
+
#include "plugin/data_connector_resource.h"
#include "data-adapter/error.h"
typedef int (*plugin_get_used_item_count_cb) (void);
/**
+ * @brief Prototype of plugin function for getting item used count
+ * @return calendar exdate_item_count on success, negative value on error
+ */
+typedef int (*plugin_get_deleted_exdate_item_count) (void);
+
+/**
+ * @brief Prototype of plugin function for checking whether exdate item exist
+ * @return calendar exdate_item_count on success, negative value on error
+ */
+typedef int (*plugin_is_exist_exdate_item) (const char *fw_parent_id, const char *child_vcalendar);
+
+/**
+ * @brief Prototype of plugin function for updating the exdate parent item
+ * @return void
+ */
+typedef void (*plugin_construct_exdate_parent_item) (char *parent_service_id);
+
+
+/**
* @brief Prototype of plugin function for getting item used count for folder
* @param[in] account_id service account id
* @param[in] folder_id service folder id
*/
typedef void (*plugin_set_callback_get_account_id_list_cb) (sync_agent_get_account_id_list_cb_plugin callback);
+/**
+ * @brief Prototype of plugin function for setting callback function to handle child item delete from storage
+ * @param[in] callback callback function - this function is provided from sync-agent-framework
+ */
+typedef void (*plugin_set_callback_delete_child_item_cb) (sync_agent_del_child_item_cb_plugin callback);
+
+
/********************* Get Meta Info ******************/
/**
typedef int (*plugin_get_is_support_feature_cb) (int feature);
/**
+ * @brief Prototype of plugin function for get max name length of sim contact
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef int (*plugin_get_info_sim_contact_max_name_length_cb) (void);
+
+/**
+ * @brief Prototype of plugin function for get max number length of sim contact
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef int (*plugin_get_info_sim_contact_max_number_length_cb) (void);
+
+/**
+ * @brief Prototype of plugin function for get max email length of sim contact
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef int (*plugin_get_info_sim_contact_max_email_length_cb) (void);
+
+/**
+ * @brief Prototype of plugin function for get empty count of sim contact
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef int (*plugin_get_info_sim_contact_empty_count_cb) (void);
+
+/**
+ * @brief Prototype of plugin function for get empty number count of sim contact
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef int (*plugin_get_info_sim_contact_empty_number_count_cb) (void);
+
+/**
+ * @brief Prototype of plugin function for get empty email count of sim contact
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef int (*plugin_get_info_sim_contact_empty_email_count_cb) (void);
+
+/**
+ * @brief Prototype of plugin function for get addressbook id of sim contact
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef int (*plugin_get_info_sim_contact_addressbook_id_cb) (void);
+
+/**
+ * @brief Prototype of plugin function for get item id of sim contact
+ * @param[out] item id of sim contact provided data-connector plugin
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_get_info_sim_contact_item_id_cb) (int sim_addressbook_id, GList **item_id);
+
+/**
+ * @brief Prototype of plugin function for get data of sim contact
+ * @param[out] item id of sim contact provided data-connector plugin
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_get_info_sim_contact_item_cb) (int item_id, char **data);
+
+/**
+ * @brief Prototype of plugin function for add sim contact
+ * @param[out] item id of sim contact provided data-connector plugin
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_add_sim_contact_item_cb) (int sim_addressbook_id, int **item_id, char *data);
+
+/**
+ * @brief Prototype of plugin function for write sim contact
+ * @param[out] item id of sim contact provided data-connector plugin
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_write_sim_contact_item_cb) (int item_id, char *data);
+
+/**
+ * @brief Prototype of plugin function for delete sim contact
+ * @param[out] item id of sim contact provided data-connector plugin
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_delete_sim_contact_item_cb) (int item_id);
+
+/**
* @brief Structure for data-connector plugin function pointer set
*/
typedef struct {
plugin_get_folder_cb func_get_folder; /**< function pointer of plugin_get_folder_cb */
plugin_execute_cb func_execute; /**< function pointer of plugin_execute_cb */
plugin_get_used_item_count_cb func_get_used_item_cnt; /**< function pointer of plugin_get_used_item_count_cb */
+ plugin_get_deleted_exdate_item_count func_get_deleted_exdate_item_cnt; /**< function pointer of plugin_get_deleted_exdate_item_count_cb */
+ plugin_is_exist_exdate_item func_is_exist_exdate_item; /**< function pointer of plugin_is_exist_exdate_item */
+ plugin_construct_exdate_parent_item func_construct_exdate_parent_item; /**< function pointer of plugin_construct_exdate_parent_item */
plugin_get_used_count_for_folder_cb func_get_used_cnt_for_folder; /**< function pointer of plugin_get_used_count_for_folder_cb */
plugin_backup_service_items_to_file_cb func_backup_service_items_to_file; /**< function pointer of plugin_backup_service_items_to_file_cb */
plugin_restore_service_items_from_file_cb func_restore_service_items_from_file; /**< function pointer of plugin_restore_service_items_from_file_cb */
-
plugin_get_folder_id_list_cb func_get_folder_id_list; /**< function pointer of plugin_get_folder_id_list_cb */
plugin_get_account_id_list_cb func_get_account_id_list; /**< function pointer of plugin_get_account_id_list_cb */
plugin_get_changed_item_for_folder_add_cb func_get_chaned_item_for_folder_add; /**< function pointer of plugin_get_changed_item_for_folder_add_cb */
plugin_start_listening_change_noti_cb func_start_listening_change_noti; /**< function pointer of plugin_start_listening_change_noti_cb */
plugin_set_callback_add_item_cb func_set_callback_add_item; /**< function pointer of plugin_set_callback_add_item_cb */
plugin_set_callback_delete_item_cb func_set_callback_delete_item; /**< function pointer of plugin_set_callback_delete_item_cb */
+ plugin_set_callback_delete_child_item_cb func_set_callback_delete_child_item; /**< function pointer of plugin_set_callback_delete_item_cb */
plugin_set_callback_update_item_cb func_set_callback_update_item; /**< function pointer of plugin_set_callback_update_item_cb */
plugin_set_callback_get_account_id_list_cb func_set_callback_get_account_id_list; /**< function pointer of plugin_set_callback_get_account_id_list_cb */
plugin_get_max_item_count_cb func_get_max_item_count; /**< function pointer of plugin_get_max_item_count_cb */
plugin_get_max_field_count_cb func_get_max_field_count; /**< function pointer of plugin_get_max_field_count_cb */
plugin_get_field_value_cb func_get_field_value; /**< function pointer of plugin_get_field_value_cb */
plugin_get_is_support_feature_cb func_get_is_support_feature; /**< function pointer of plugin_get_is_support_feature_cb */
+ plugin_get_info_sim_contact_max_name_length_cb func_get_info_sim_contact_max_name_length; /**< function pointer of plugin_get_info_sim_contact_max_name_length_cb */
+ plugin_get_info_sim_contact_max_number_length_cb func_get_info_sim_contact_max_number_length; /**< function pointer of plugin_get_info_sim_contact_max_number_length_cb */
+ plugin_get_info_sim_contact_max_email_length_cb func_get_info_sim_contact_max_email_length; /**< function pointer of plugin_get_info_sim_contact_max_email_length_cb */
+ plugin_get_info_sim_contact_empty_count_cb func_get_info_sim_contact_empty_count; /**< function pointer of plugin_get_info_sim_contact_empty_count_cb */
+ plugin_get_info_sim_contact_empty_number_count_cb func_get_info_sim_contact_empty_number_count; /**< function pointer of plugin_get_info_sim_contact_empty_number_count_cb */
+ plugin_get_info_sim_contact_empty_email_count_cb func_get_info_sim_contact_empty_email_count; /**< function pointer of plugin_get_info_sim_contact_empty_email_count_cb */
+ plugin_get_info_sim_contact_addressbook_id_cb func_get_info_sim_contact_addressbook_id; /**< function pointer of plugin_get_info_sim_contact_addressbook_id_cb */
+ plugin_get_info_sim_contact_item_id_cb func_get_info_sim_contact_item_id; /**< function pointer of plugin_get_info_sim_contact_item_id_cb */
+ plugin_get_info_sim_contact_item_cb func_get_info_sim_contact_item; /**< function pointer of plugin_get_info_sim_contact_item_cb */
+ plugin_add_sim_contact_item_cb func_add_sim_contact_item; /**< function pointer of plugin_add_sim_contact_item_cb */
+ plugin_write_sim_contact_item_cb func_write_sim_contact_item; /**< function pointer of plugin_write_sim_contact_item_cb */
+ plugin_delete_sim_contact_item_cb func_delete_sim_contact_item; /**< function pointer of plugin_delete_sim_contact_item_cb */
} plugin_data_connector_func_set_s;
/**
plugin_get_used_item_count_cb plugin_get_function_get_used_item_count(int plugin_id);
/**
+ * @brief Get function pointer of plugin_get_deleted_exdate_item_count_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_deleted_exdate_item_count_cb on success, NULL on error
+ */
+plugin_get_deleted_exdate_item_count plugin_get_function_get_deleted_exdate_item_count(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_function_is_exist_exdate_item
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_function_is_exist_exdate_item on success, NULL on error
+ */
+plugin_is_exist_exdate_item plugin_function_is_exist_exdate_item(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_function_construct_exdate_parent_item
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_function_construct_exdate_parent_item on success, NULL on error
+ */
+plugin_construct_exdate_parent_item plugin_function_construct_exdate_parent_item(int plugin_id);
+
+
+/**
* @brief Get function pointer of plugin_get_used_count_for_folder_cb
* @param[in] plugin_id data-connector plugin id
* @return function pointer of plugin_get_used_count_for_folder_cb on success, NULL on error
* @param[in] plugin_id data-connector plugin id
* @return function pointer of plugin_get_changed_item_for_folder_add_cb on success, NULL on error
*/
-plugin_get_changed_item_for_folder_add_cb plugin_get_function_get_chaned_item_for_folder_add(int plugin_id);
+plugin_get_changed_item_for_folder_add_cb plugin_get_function_get_changed_item_for_folder_add(int plugin_id);
/**
* @brief Get function pointer of plugin_get_changed_item_for_folder_delete_cb
* @param[in] plugin_id data-connector plugin id
* @return function pointer of plugin_get_changed_item_for_folder_delete_cb on success, NULL on error
*/
-plugin_get_changed_item_for_folder_delete_cb plugin_get_function_get_chaned_item_for_folder_delete(int plugin_id);
+plugin_get_changed_item_for_folder_delete_cb plugin_get_function_get_changed_item_for_folder_delete(int plugin_id);
/**
* @brief Get function pointer of plugin_get_changed_item_for_folder_update_cb
* @param[in] plugin_id data-connector plugin id
* @return function pointer of plugin_get_changed_item_for_folder_update_cb on success, NULL on error
*/
-plugin_get_changed_item_for_folder_update_cb plugin_get_function_get_chaned_item_for_folder_update(int plugin_id);
+plugin_get_changed_item_for_folder_update_cb plugin_get_function_get_changed_item_for_folder_update(int plugin_id);
/**
* @brief Get function pointer of plugin_get_last_change_point_cb
plugin_set_callback_delete_item_cb plugin_get_function_set_callback_delete_item(int plugin_id);
/**
+ * @brief Get function pointer of plugin_set_callback_delete_child_item_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_set_callback_delete_child_item_cb on success, NULL on error
+ */
+plugin_set_callback_delete_child_item_cb plugin_get_function_set_callback_delete_child_item(int plugin_id);
+
+
+/**
* @brief Get function pointer of plugin_set_callback_update_item_cb
* @param[in] plugin_id data-connector plugin id
* @return function pointer of plugin_set_callback_update_item_cb on success, NULL on error
plugin_get_is_support_feature_cb plugin_get_function_get_is_support_feature(int plugin_id);
/**
+ * @brief Get function pointer of plugin_get_info_sim_contact_max_name_length_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_info_sim_contact_max_name_length_cb on success, NULL on error
+ */
+plugin_get_info_sim_contact_max_name_length_cb plugin_get_function_get_info_sim_contact_max_name_length(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_info_sim_contact_max_number_length_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_info_sim_contact_max_number_length_cb on success, NULL on error
+ */
+plugin_get_info_sim_contact_max_number_length_cb plugin_get_function_get_info_sim_contact_max_number_length(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_info_sim_contact_max_email_length_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_info_sim_contact_max_email_length_cb on success, NULL on error
+ */
+plugin_get_info_sim_contact_max_email_length_cb plugin_get_function_get_info_sim_contact_max_email_length(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_info_sim_contact_empty_count_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_info_sim_contact_empty_count_cb on success, NULL on error
+ */
+plugin_get_info_sim_contact_empty_count_cb plugin_get_function_get_info_sim_contact_empty_count(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_info_sim_contact_empty_number_count_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_info_sim_contact_empty_number_count_cb on success, NULL on error
+ */
+plugin_get_info_sim_contact_empty_number_count_cb plugin_get_function_get_info_sim_contact_empty_number_count(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_info_sim_contact_empty_email_count_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_info_sim_contact_empty_email_count_cb on success, NULL on error
+ */
+plugin_get_info_sim_contact_empty_email_count_cb plugin_get_function_get_info_sim_contact_empty_email_count(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_info_sim_contact_addressbook_id_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_info_sim_contact_addressbook_id_cb on success, NULL on error
+ */
+plugin_get_info_sim_contact_addressbook_id_cb plugin_get_function_get_info_sim_contact_addressbook_id(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_info_sim_contact_item_id_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_info_sim_contact_item_id_cb on success, NULL on error
+ */
+plugin_get_info_sim_contact_item_id_cb plugin_get_function_get_info_sim_contact_item_id(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_info_sim_contact_item_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_info_sim_contact_item_cb on success, NULL on error
+ */
+plugin_get_info_sim_contact_item_cb plugin_get_function_get_info_sim_contact_item(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_add_sim_contact_item_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_add_sim_contact_item_cb on success, NULL on error
+ */
+plugin_add_sim_contact_item_cb plugin_get_function_add_sim_contact_item(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_write_sim_contact_item_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_write_sim_contact_item_cb on success, NULL on error
+ */
+plugin_write_sim_contact_item_cb plugin_get_function_write_sim_contact_item(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_delete_sim_contact_item_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_delete_sim_contact_item_cb on success, NULL on error
+ */
+plugin_delete_sim_contact_item_cb plugin_get_function_delete_sim_contact_item(int plugin_id);
+
+/**
* @}
*/
return SYNC_AGENT_UTIL_COMPRESS_FAIL;
}
+
+
+EXPORT_API sync_agent_util_compress_result_e sync_agent_ua_uncompress(sync_agent_util_compress_type_e type, const char *input_file_path, const char *output_direcory_path)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (input_file_path == NULL || output_direcory_path == NULL) {
+ return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+ }
+
+ if (!sync_agent_is_existing_fs(input_file_path)) {
+ _DEBUG_ERROR("tar input file not existing !!");
+ return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+ }
+
+ char *command = NULL;
+
+ switch (type) {
+ case SYNC_AGENT_UTIL_COMPRESS_TYPE_TAR:
+ {
+ int command_len = strlen("tar xvfp ") + strlen(input_file_path) + strlen(" -C ") + strlen(output_direcory_path) +strlen(" delta.ua")+ 1;
+ int len = 0;
+ command = (char *)calloc(command_len, sizeof(char));
+ if (command == NULL)
+ return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+
+ len = g_strlcat(command, "tar xvfp ", command_len);
+ len = g_strlcat(command, input_file_path, command_len);
+ len = g_strlcat(command, " -C ", command_len);
+ len = g_strlcat(command, output_direcory_path, command_len);
+ len = g_strlcat(command, " delta.ua", command_len);
+
+ if (len >= command_len) {
+ _DEBUG_ERROR("command buffer overflow !!");
+ free(command);
+ return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+ }
+
+ int pid = fork();
+ if (pid == -1) {
+ _DEBUG_ERROR("Fork failed to create a process");
+ free(command);
+ return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+ } else if (pid == 0) {
+ char *argv[4];
+
+ argv[0] = "sh";
+ argv[1] = "-c";
+ argv[2] = command;
+ argv[3] = 0;
+
+ execv("/bin/sh", argv);
+
+ abort();
+ }
+
+ int status = 0;
+ do {
+ if (waitpid(pid, &status, 0) == -1) {
+ if (errno != EINTR) {
+ free(command);
+ //_EXTERN_FUNC_EXIT;
+ //return SYNC_AGENT_UTIL_COMPRESS_SUCCESS;
+ _DEBUG_INFO("dalta.ua command success!!");
+ goto TAR_MV_EXECUTE;
+ } else {
+ free(command);
+ //return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+ _DEBUG_INFO("dalta.ua command failed!!");
+ goto TAR_MV_EXECUTE;
+ }
+ }
+ } while (1);
+ }
+ break;
+ case SYNC_AGENT_UTIL_COMPRESS_TYPE_ZIP:
+ {
+ /*
+ * Not yet support
+ */
+ }
+ break;
+ default:
+ _DEBUG_ERROR("Not support compress type!!");
+ break;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+
+
+TAR_MV_EXECUTE:
+ {
+ int command_len = strlen("mv ") + strlen(input_file_path) + strlen(" ") + strlen(output_direcory_path) +strlen("/delta.tar")+ 1;
+ int len = 0;
+ command = (char *)calloc(command_len, sizeof(char));
+ if (command == NULL)
+ return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+
+ len = g_strlcat(command, "mv ", command_len);
+ len = g_strlcat(command, input_file_path, command_len);
+ len = g_strlcat(command, " ", command_len);
+ len = g_strlcat(command, output_direcory_path, command_len);
+ len = g_strlcat(command, "/delta.tar", command_len);
+
+ if (len >= command_len) {
+ _DEBUG_ERROR("command buffer overflow !!");
+ free(command);
+ return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+ }
+
+ int pid = fork();
+ if (pid == -1) {
+ _DEBUG_ERROR("Fork failed to create a process");
+ free(command);
+ return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+ } else if (pid == 0) {
+ char *argv[4];
+
+ argv[0] = "sh";
+ argv[1] = "-c";
+ argv[2] = command;
+ argv[3] = 0;
+
+ execv("/bin/sh", argv);
+
+ abort();
+ }
+
+ int status = 0;
+ do {
+ if (waitpid(pid, &status, 0) == -1) {
+ if (errno != EINTR) {
+ free(command);
+ _EXTERN_FUNC_EXIT;
+ return SYNC_AGENT_UTIL_COMPRESS_SUCCESS;
+ } else {
+ free(command);
+ return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+ }
+ }
+ } while (1);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+}
pthread_cond_init(&loop_cond, NULL); /* TODO : error handling if return value is not 0, fail logic */
pthread_mutex_lock(&loop_mutex);
- pthread_create(&main_loop_thread_id, 0, _main_loop_rutine, 0);
+ int status_thread_create = 0;
+ status_thread_create = pthread_create(&main_loop_thread_id, 0, _main_loop_rutine, 0);
+ if(status_thread_create != 0) {
+ _DEBUG_WARNING("pthread_create [%d]", status_thread_create );
+ pthread_mutex_unlock(&loop_mutex);
+ _EXTERN_FUNC_EXIT;
+ return;
+ }
do {
pthread_cond_wait(&loop_cond, &loop_mutex);
} while (loop == NULL);
#define FW_CALENDAR 1
#define FW_MEMO 2
#define FW_CONTENT_COUNT 3
-#define FW_TASK 11
+#define FW_TASK 10
#define MAX_ACCOUNT_COUNT 20
static const char *agent_name = 0;
#endif
#define FW_CALENDAR 1 /* plugIn-Id */
+#define EXTYPE_UPDATE_KEYWORD "X-EXTYPE:2"
static sync_agent_util_async_queue_s *queue;
-
static int latest_calendar_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 sync_agent_del_child_item_cb_plugin callback_delete_child_item;
static void _set_is_noti_from_me(int set_flag);
-
static int __get_is_noti_from_me(void);
-
+static char * _get_value_by_token(const char *src, const char *token, const char *end_of_token);
static void _process_calendar_change(const char *view_uri, void *user_data);
-
static void *_rutine_calendar_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_calendar_id(/*account_capability_type_e*/const char* capability_type, account_capability_state_e capability_value, void *user_data);
-
+static bool __is_calendar_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 int _get_exdate_count(calendar_query_h query);
-
-
+static int _get_deleted_exdate_item_count(calendar_query_h query);
+static int _add_updated_exdate_item(int service_account_id, int index, char *parent_service_item_id, char *service_folder_id);
+static sync_agent_da_return_e _process_exdate_item(calendar_record_h calendar_record);
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);
-
typedef struct account_id {
int account_id;
struct account_id *next;
} account_id_s;
-//static void _calendar_db_result_cb(int error, void *user_data)
-//{
-// _INNER_FUNC_ENTER;
-// _DEBUG_TRACE("error = %d", error);
-// _INNER_FUNC_EXIT;
-//}
-
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;
+ int service_ret = CALENDAR_ERROR_NONE;
unsigned int ids[1];
calendar_query_h query = NULL;
// start pre condition
service_ret = calendar_query_create(_calendar_event._uri, &query);
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] in calendar_query_create Fail!\n");
- ret = _convert_service_error_to_common_error(service_ret);
- goto DACI_FINISH;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_query_create() Fail!: err[%d]", service_ret);
+
service_ret = calendar_filter_create(_calendar_event._uri, &filter);
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] in calendar_filter_create Fail!\n");
- ret = _convert_service_error_to_common_error(service_ret);
- goto DACI_FINISH;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_filter_create() Fail!: err[%d]", service_ret);
+
service_ret = calendar_filter_add_int(filter, _calendar_event.calendar_book_id, CALENDAR_MATCH_EQUAL, folder_id);
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] in calendar_filter_add_int Fail!\n");
- ret = _convert_service_error_to_common_error(service_ret);
- goto DACI_FINISH;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_filter_add_int() Fail!: err[%d]", service_ret);
// end pre condition
service_ret = calendar_query_set_filter(query, filter);
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] in calendar_query_set_filter Fail!\n");
- ret = _convert_service_error_to_common_error(service_ret);
- goto DACI_FINISH;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_query_set_filter() Fail!: err[%d]", service_ret);
ids[0] = _calendar_event.id;
service_ret = calendar_query_set_projection(query, ids, 1);
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] in calendar_query_set_projection Fail!\n");
- ret = _convert_service_error_to_common_error(service_ret);
- goto DACI_FINISH;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_query_set_projection() Fail!: err[%d]", service_ret);
service_ret = calendar_db_get_records_with_query(query, 0, 0, &list);
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] in calendar_db_get_records_with_query Fail!\n");
- ret = _convert_service_error_to_common_error(service_ret);
- goto DACI_FINISH;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_db_get_records_with_query() Fail!: err[%d]", service_ret);
+
service_ret = calendar_list_get_count(list, count);
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] in calendar_list_get_count Fail!\n");
- ret = _convert_service_error_to_common_error(service_ret);
- goto DACI_FINISH;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_list_get_count() Fail!: err[%d]", service_ret);
+
_DEBUG_INFO("count(%d)", *count);
service_ret = calendar_list_first(list);
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] in calendar_list_get_count Fail!\n");
- ret = _convert_service_error_to_common_error(service_ret);
- goto DACI_FINISH;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_list_first() Fail!: err[%d]", service_ret);
- DACI_FINISH:
+ return_part:
+ ret = _convert_service_error_to_common_error(service_ret);
calendar_filter_destroy(filter);
calendar_query_destroy(query);
*item_list = list;
- return ret;
_INNER_FUNC_EXIT;
+ return ret;
}
static sync_agent_da_return_e _get_service_folder_list_by_account_id(int account_id, calendar_list_h * item_list, int *count)
// start pre condition
service_ret = calendar_query_create(_calendar_book._uri, &query);
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] in calendar_query_create Fail!\n");
- ret = _convert_service_error_to_common_error(service_ret);
- goto DACI_FINISH;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_query_create() Fail!: err[%d]", service_ret);
+
service_ret = calendar_filter_create(_calendar_book._uri, &filter);
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] in calendar_filter_create Fail!\n");
- ret = _convert_service_error_to_common_error(service_ret);
- goto DACI_FINISH;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_filter_create() Fail!: err[%d]", service_ret);
+
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_calendar_plugIn] in calendar_filter_add_int Fail!\n");
- ret = _convert_service_error_to_common_error(service_ret);
- goto DACI_FINISH;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_filter_add_int() Fail!: err[%d]", service_ret);
// end pre condition
service_ret = calendar_query_set_filter(query, filter);
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] in calendar_query_set_filter Fail!\n");
- ret = _convert_service_error_to_common_error(service_ret);
- goto DACI_FINISH;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_query_set_filter() Fail!: err[%d]", service_ret);
ids[0] = _calendar_book.id;
service_ret = calendar_query_set_projection(query, ids, 1);
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] in calendar_query_set_projection Fail!\n");
- ret = _convert_service_error_to_common_error(service_ret);
- goto DACI_FINISH;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_query_set_projection() Fail!: err[%d]", service_ret);
service_ret = calendar_db_get_records_with_query(query, 0, 0, &list);
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] in calendar_db_get_records_with_query Fail!\n");
- ret = _convert_service_error_to_common_error(service_ret);
- goto DACI_FINISH;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_db_get_records_with_query() Fail!: err[%d]", service_ret);
+
service_ret = calendar_list_get_count(list, count);
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] in calendar_list_get_count Fail!\n");
- ret = _convert_service_error_to_common_error(service_ret);
- goto DACI_FINISH;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_list_get_count() Fail!: err[%d]", service_ret);
_DEBUG_INFO("count(%d)", *count);
service_ret = calendar_list_first(list);
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] in calendar_list_get_count Fail!\n");
- ret = _convert_service_error_to_common_error(service_ret);
- goto DACI_FINISH;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_list_first() Fail!: err[%d]", service_ret);
- DACI_FINISH:
+ return_part:
+ ret = _convert_service_error_to_common_error(service_ret);
calendar_filter_destroy(filter);
calendar_query_destroy(query);
*item_list = list;
- return ret;
_INNER_FUNC_EXIT;
+ return ret;
}
-static int _get_exdate_count(calendar_query_h query)
+static int _get_deleted_exdate_item_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;
+ int service_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;
- }
+ service_ret = calendar_db_get_records_with_query(query, 0, 0, &list);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_db_get_records_with_query() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_list_first(list);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_list_first() Fail!: err[%d]", service_ret);
int index = 0;
do
{
- ret = calendar_list_get_current_record_p(list, &calendar_record);
- if (ret != CALENDAR_ERROR_NONE || calendar_record == NULL) {
+ service_ret = calendar_list_get_current_record_p(list, &calendar_record);
+ if (service_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;
- }
+ service_ret = calendar_record_get_str(calendar_record, _calendar_event.exdate, &exdate);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_record_get_str() Fail!: err[%d]", service_ret);
+
_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;
- }
+ goto_if(array_exdate == NULL, "array_exdate is NULL");
int array_length = 0;
array_length = g_strv_length(array_exdate);
} while (calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
return_part:
- _DEBUG_INFO("return_part");
- _DEBUG_INFO("exdate_count = %d", exdate_count);
+ _DEBUG_INFO("total exdate_count = %d", exdate_count);
calendar_list_destroy(list, false);
calendar_filter_destroy(filter);
_EXTERN_FUNC_EXIT;
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
int err = calendar_connect();
- //int err = calendar_connect_on_thread();
+
if (err != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] calendar_connect Fail!\n");
+ _DEBUG_ERROR("[calendar] calendar_connect Fail!\n");
ret = _convert_service_error_to_common_error(err);
} else {
- _DEBUG_INFO("[da_calendar_plugIn] calendar_connect Success!\n");
+ _DEBUG_INFO("[calendar] calendar_connect Success!\n");
}
_EXTERN_FUNC_EXIT;
-
return ret;
}
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_calendar_plugIn] calendar_disconnect Fail!\n");
+ _DEBUG_ERROR("[calendar] calendar_disconnect Fail!\n");
ret = _convert_service_error_to_common_error(err);
} else {
- _DEBUG_INFO("[da_calendar_plugIn] calendar_disconnect Success!\n");
+ _DEBUG_INFO("[calendar] calendar_disconnect Success!\n");
}
_EXTERN_FUNC_EXIT;
-
return ret;
}
_EXTERN_FUNC_ENTER;
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
-
- _DEBUG_INFO("[da_calendar_plugIn] not anymore need to transaction");
-
+ _DEBUG_INFO("[calendar] not anymore need to transaction");
_set_is_noti_from_me(1);
_EXTERN_FUNC_EXIT;
-
return ret;
}
{
_EXTERN_FUNC_ENTER;
- _DEBUG_INFO("[da_calendar_plugIn] SLP Calendar Service is not supported Rollback Operation!\n");
+ _DEBUG_INFO("[calendar] SLP Calendar Service is not supported Rollback Operation!\n");
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
- _DEBUG_INFO("[da_calendar_plugIn] in calendar Success!\n");
+ _DEBUG_INFO("[calendar] in calendar Success!\n");
if (is_storage_changed == 0) {
_DEBUG_INFO("calendar storaged was not Changed!!");
_set_is_noti_from_me(0);
}
is_storage_changed = 0;
- _DEBUG_INFO("[da_calendar_plugIn] not anymore need to transaction, is_success : [%d]", is_success);
+ _DEBUG_INFO("[calendar] not anymore need to transaction, is_success : [%d]", is_success);
_EXTERN_FUNC_EXIT;
return ret;
int un_type = 0;
memcpy(&un_type, item, 4);
int int_folder_id = atoi(folder_id);
- _DEBUG_INFO("[da_calendar_plugIn] calendar type %d, in %d, folder id [%d]", un_type, item, int_folder_id);
+ _DEBUG_INFO("[calendar] 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_event.calendar_book_id, int_folder_id);
ret = SYNC_AGENT_DA_ERRORS;
goto DACI_FINISH;
}
- _DEBUG_INFO("[da_calendar_plugIn] calendar_svc_struct_set_int(folder %d) return [%d]!\n", atoi(folder_id), service_ret);
+ _DEBUG_INFO("[calendar] calendar_svc_struct_set_int(folder %d) return [%d]!\n", atoi(folder_id), service_ret);
/* add item */
int slp_cal_info_id = 0;
*item_id = 0;
goto DACI_FINISH;
} else {
- _DEBUG_INFO("[da_calendar_plugIn] calendar_svc_insert() Success!");
+ _DEBUG_INFO("[calendar] 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:
- /* memory free */
-// if (item != NULL){
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;
}
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 !!!");
+ retvm_if(data == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "data is NULL. FAIL !!!");
- sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
- int err = 0;
calendar_record_h item = (calendar_record_h) data;
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ int service_ret = CALENDAR_ERROR_NONE;
int int_folder_id = atoi(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);
- ret = SYNC_AGENT_DA_ERRORS;
- goto DACI_FINISH;
+ // exception handler for EXDATE item
+ if(_process_exdate_item(item) == SYNC_AGENT_DA_ERR_ITEM_READ_ONLY) {
+ _DEBUG_INFO("this is a updated exdate item. it should be not done calendar_db_update_record(). so just return.");
+ goto return_part;
}
- err = calendar_db_update_record(item);
- if (err != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] calendar_svc_update() Fail!\n");
- ret = _convert_service_error_to_common_error(err);
- } else {
- _DEBUG_INFO("[da_calendar_plugIn] calendar_svc_update() Success!");
- is_storage_changed = 1;
- }
+ service_ret = calendar_record_set_int(item, _calendar_event.calendar_book_id, int_folder_id);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_record_set_int() Fail!: err[%d]", service_ret);
- DACI_FINISH:
+ service_ret = calendar_db_update_record(item);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_db_update_record() Fail!: err[%d]", service_ret);
+
+ _DEBUG_INFO("[calendar] calendar_svc_update() Success!");
+ is_storage_changed = 1;
+
+return_part:
+ ret = _convert_service_error_to_common_error(service_ret);
if (item != NULL) {
- calendar_record_destroy(item, false);
- if (err != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("calendar_record_destroy() Fail! : err = %d", err);
+ service_ret = calendar_record_destroy(item, false);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_destroy() Fail! : service_ret = %d", service_ret);
}
item = NULL;
}
_EXTERN_FUNC_EXIT;
-
return ret;
}
int err = calendar_db_delete_record(_calendar_event._uri, atoi(item_id));
if (err != CALENDAR_ERROR_NONE) {
- _DEBUG_INFO("[da_calendar_plugIn] calendar_svc_delete() Fail!");
+ _DEBUG_INFO("[calendar] calendar_svc_delete() Fail!");
ret = _convert_service_error_to_common_error(err);
} else {
- _DEBUG_INFO("[da_calendar_plugIn] calendar_svc_delete() Success!");
+ _DEBUG_INFO("[calendar] calendar_svc_delete() Success!");
is_storage_changed = 1;
}
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_calendar_plugIn] folder id list cnt : %d", folder_id_list_cnt);
+ _DEBUG_INFO("[calendar] folder id list cnt : %d", folder_id_list_cnt);
if (folder_type_list != NULL) {
cfree(folder_type_list);
folder_type_list = NULL;
}
+ if (folder_id_list != NULL) {
+ free(folder_id_list);
+ folder_id_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_calendar_plugIn] folder id : %d\n", int_folder_id);
+ _DEBUG_INFO("[calendar] 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) {
event = NULL;
service_ret = calendar_list_get_current_record_p(event_list, &event);
if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] in calendar_list_get_current_record_p Fail!\n");
+ _DEBUG_ERROR("[calendar] 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_event.id, &item_id);
if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] in calendar_record_get_int Fail!\n");
+ _DEBUG_ERROR("[calendar] in calendar_record_get_int Fail!\n");
ret = _convert_service_error_to_common_error(service_ret);
continue;
}
- _DEBUG_INFO("[da_calendar_plugIn] item id : %d\n", item_id);
+ _DEBUG_INFO("[calendar] item id : %d\n", item_id);
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);
+ _DEBUG_ERROR("[calendar] calendar_svc_delete(%d) Fail!\n", item_id);
ret = _convert_service_error_to_common_error(err);
goto DACI_FINISH;
} else {
- _DEBUG_INFO("[da_calendar_plugIn] calendar_svc_delete(%d) Success!\n", item_id);
+ _DEBUG_INFO("[calendar] calendar_svc_delete(%d) Success!\n", item_id);
is_storage_changed = 1;
}
for (cnt = 0; cnt < folder_id_list_cnt; cnt++) {
if (folder_id_list[cnt] != NULL) {
free(folder_id_list[cnt]);
- _DEBUG_INFO("[da_calendar_plugIn] folder id free !! \n");
+ _DEBUG_INFO("[calendar] folder id free !! \n");
}
}
cfree(folder_id_list);
- _DEBUG_INFO("[da_calendar_plugIn] folder id list free !! \n");
+ _DEBUG_INFO("[calendar] folder id list free !! \n");
}
if (folder_type_list != NULL) {
cfree(folder_type_list);
}
_EXTERN_FUNC_EXIT;
-
return ret;
}
/* get item */
err = calendar_db_get_record(_calendar_event._uri, atoi(item_id), &item);
if (err != CALENDAR_ERROR_NONE) {
- _DEBUG_INFO("[da_calendar_plugIn] calendar_db_get_record() Fail!\n");
+ _DEBUG_INFO("[calendar] calendar_db_get_record() Fail!\n");
ret = _convert_service_error_to_common_error(err);
*data = 0;
} else {
- _DEBUG_INFO("[da_calendar_plugIn] calendar_svc_get() Success!\n");
+ _DEBUG_INFO("[calendar] calendar_svc_get() Success!\n");
*data = (void *)item;
}
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;
+ int service_ret = CALENDAR_ERROR_NONE;
calendar_record_h folder = 0;
/* new service struct */
calendar_record_create(_calendar_book._uri, &folder);
if (folder == NULL) {
- _DEBUG_INFO("[da_calendar_plugIn] calendar_svc_struct_new() Fail!\n");
+ _DEBUG_INFO("[calendar] 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;
- }
+ service_ret = calendar_record_set_int(folder, _calendar_book.account_id, account_id);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_record_set_int() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_set_int(folder, _calendar_book.visibility, 1);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_record_set_int() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_set_str(folder, _calendar_book.name, folder_name);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_record_set_str() Fail!: err[%d]", service_ret);
/* 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_calendar_plugIn] calendar_svc_insert() Fail!\n");
- ret = _convert_service_error_to_common_error(cal_ret);
+ service_ret = calendar_db_insert_record(folder, &service_folder_item_id);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_INFO("[calendar] calendar_svc_insert() Fail!\n");
*folder_id = 0;
} else {
- _DEBUG_INFO("[da_calendar_plugIn] calendar_svc_insert() Success!");
+ _DEBUG_INFO("[calendar] calendar_svc_insert() Success!");
*folder_id = g_strdup_printf("%d", service_folder_item_id);
is_storage_changed = 1;
}
- DACI_FINISH:
- /* memory free */
+
+return_part:
+ ret = _convert_service_error_to_common_error(service_ret);
if (folder != NULL) {
calendar_record_destroy(folder, false);
- if (err != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("calendar_record_destroy() Fail! : err = %d", err);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_destroy() Fail! : service_ret = %d", service_ret);
}
folder = NULL;
}
/* 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, err[%d]", err);
+ _DEBUG_INFO("[calendar] 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");
+ _DEBUG_INFO("[calendar] calendar_svc_delete() Success!\n");
calendar_db_clean_after_sync(atoi(folder_id), 0);
is_storage_changed = 1;
}
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
int err = 0;
calendar_record_h folder = 0;
+ int task_folder_id = atoi(folder_id);
+ _DEBUG_INFO("[calendar] task_folder_id : %d\n", task_folder_id);
- /* get item */
- int calendar_folder_id = atoi(folder_id);
- _DEBUG_INFO("[da_calendar_plugIn] calendar_folder_id : %d\n", calendar_folder_id);
- err = calendar_db_get_record(_calendar_book._uri, calendar_folder_id, &folder);
+ 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");
+ _DEBUG_INFO("[calendar] 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");
+ goto return_part;
+ }
+
+ _DEBUG_INFO("[calendar] contacts_svc_get_addressbook() Success!\n");
+
+ *out_folder_name = 0;
+ err = calendar_record_get_str(folder, _calendar_book.name, out_folder_name);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_INFO("[calendar] calendar_record_get_str() Fail!\n");
+ ret = _convert_service_error_to_common_error(err);
*out_folder_name = 0;
- calendar_record_get_str(folder, _calendar_book.name, out_folder_name);
- *out_folder_type = DEFAULT_CALENDAR_FOLDER;
+ *out_folder_type = -1;
+ goto return_part;
}
- /* memory free */
+ *out_folder_type = DEFAULT_CALENDAR_FOLDER;
+
+return_part:
if (folder != NULL) {
calendar_record_destroy(folder, false);
if (err != CALENDAR_ERROR_NONE) {
folder = NULL;
}
_EXTERN_FUNC_EXIT;
-
return ret;
}
{
_EXTERN_FUNC_ENTER;
- _DEBUG_INFO("[da_calendar_plugIn] service is not supported execute. \n");
+ _DEBUG_INFO("[calendar] service is not supported execute. \n");
*result = 0;
_EXTERN_FUNC_EXIT;
{
_EXTERN_FUNC_ENTER;
+ int used_cnt = 0;
+ int deleted_exdate_count = 0;
+
+ int err = calendar_db_get_count(_calendar_event._uri, &used_cnt);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_INFO("[calendar] calendar_db_get_count() Fail\n");
+ } else {
+ _DEBUG_INFO("[calendar] used_count = %d\n", used_cnt);
+ deleted_exdate_count = sync_agent_plugin_get_deleted_exdate_item_count();
+ used_cnt += deleted_exdate_count;
+ }
+
+ _DEBUG_INFO("[calendar] used_count = %d\n", used_cnt);
+ _EXTERN_FUNC_EXIT;
+ return used_cnt;
+}
+
+EXPORT_API int sync_agent_plugin_get_deleted_exdate_item_count()
+{
+ _EXTERN_FUNC_ENTER;
+
calendar_filter_h filter = NULL;
calendar_query_h query = NULL;
- int used_cnt = 0;
int exdate_parent_count = 0;
int deleted_exdate_count = 0;
- int err = CALENDAR_ERROR_NONE;
+ int service_ret = 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;
- }
+ // check exdate count
+ service_ret = calendar_query_create(_calendar_event._uri, &query);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_query_create() Fail!: err[%d]", service_ret);
- _DEBUG_INFO("[da_calendar_plugIn] used_count = %d\n", used_cnt);
+ service_ret = calendar_filter_create(_calendar_event._uri, &filter);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_filter_create() Fail!: err[%d]", service_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;
- }
+ service_ret = calendar_filter_add_str(filter, _calendar_event.exdate, CALENDAR_MATCH_EXISTS, "");
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_filter_add_str() Fail!: err[%d]", service_ret);
- _DEBUG_INFO("exdate_parent_count = %d\n", exdate_parent_count);
+ service_ret = calendar_query_set_filter(query, filter);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_query_set_filter() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_db_get_count_with_query(query, &exdate_parent_count);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_db_get_count_with_query() Fail!: err[%d]", service_ret);
+ _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);
+ deleted_exdate_count = _get_deleted_exdate_item_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;
+ return deleted_exdate_count;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_is_exist_exdate_item(const char *fw_parent_id, const char *child_vcalendar)
+{
+ _EXTERN_FUNC_ENTER;
+ retvm_if(fw_parent_id == NULL, SYNC_AGENT_DA_ERRORS, "fw_parent_id is NULL. FAIL !!!");
+ retvm_if(child_vcalendar == NULL, SYNC_AGENT_DA_ERRORS, "child_vcalendar is NULL. FAIL !!!");
+ _DEBUG_INFO("fw_parent_id = %s", fw_parent_id);
+
+ const char *updated_exdate_token = "\r\nX-EXTYPE:2\r\nEXDATE:";
+ const char *exdate_token = "EXDATE:";
+ char *temp = NULL;
+ char *updated_exdate = NULL;
+ int ret = SYNC_AGENT_DA_ERRORS;
+ int service_ret = CALENDAR_ERROR_NONE;
+ calendar_filter_h filter = NULL;
+ calendar_query_h query = NULL;
+
+ temp = strstr(child_vcalendar, updated_exdate_token);
+ goto_if(temp == NULL, "this vcalendar has not exdate data");
+
+ updated_exdate = _get_value_by_token(temp + strlen(updated_exdate_token) - strlen(exdate_token), exdate_token, "\r\n");
+ _DEBUG_INFO("updated_exdate = %s", updated_exdate);
+ goto_if(updated_exdate == NULL, "updated_exdate is null");
+
+ int matched_count = 0;
+ service_ret = calendar_query_create(_calendar_event._uri, &query);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_query_create() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_filter_create(_calendar_event._uri, &filter);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_filter_create() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_filter_add_str(filter, _calendar_event.recurrence_id, CALENDAR_MATCH_EXACTLY, updated_exdate);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_filter_add_str() Fail!: err[%d]", service_ret);
+
+ ret = calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_AND);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_filter_add_operator() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_filter_add_int(filter, _calendar_event.original_event_id, CALENDAR_MATCH_EQUAL, atoi(fw_parent_id));
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_filter_add_str() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_query_set_filter(query, filter);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_query_set_filter() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_db_get_count_with_query(query, &matched_count);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_db_get_count_with_query() Fail!: err[%d]", service_ret);
+ _DEBUG_INFO("matched_count = %d", matched_count);
+
+ if (matched_count > 0) {
+ _DEBUG_INFO("this item already exist");
+ ret = SYNC_AGENT_DA_ERR_ALREADY_EXIST;
+ goto return_part;
+ }
+ _DEBUG_INFO("this item is not exist. it's a new item.");
+ ret = SYNC_AGENT_DA_SUCCESS;
+
+return_part:
+ if(updated_exdate) {
+ free(updated_exdate);
+ updated_exdate = NULL;
+ }
+ calendar_filter_destroy(filter);
+ calendar_query_destroy(query);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+EXPORT_API void sync_agent_plugin_construct_exdate_parent_item(char *parent_service_id)
+{
+ _EXTERN_FUNC_ENTER;
+ retm_if(parent_service_id == NULL, "parent_service_id is NULL. FAIL !!!");
+ _DEBUG_INFO("parent_service_id = %s", parent_service_id);
+
+ calendar_record_h item = 0;
+ int service_ret = CALENDAR_ERROR_NONE;
+
+ service_ret = calendar_db_get_record(_calendar_event._uri, atoi(parent_service_id), &item);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[claendar] calendar_db_get_record() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_db_update_record(item);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_db_update_record() Fail!: err[%d]", service_ret);
+ _DEBUG_INFO("[calendar] calendar_svc_update() Success!");
+
+return_part:
+ _EXTERN_FUNC_EXIT;
+ return;
}
EXPORT_API int sync_agent_plugin_get_used_item_count_for_folder(int account_id, char *folder_id)
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_event._uri, &query);
- 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));
- ret = calendar_query_set_filter(query, filter);
+ int service_ret = CALENDAR_ERROR_NONE;
+
+ service_ret = calendar_query_create(_calendar_event._uri, &query);
+ service_ret = calendar_filter_create(_calendar_event._uri, &filter);
+ service_ret = calendar_filter_add_int(filter, _calendar_event.calendar_book_id, CALENDAR_MATCH_EQUAL, atoi(folder_id));
+ service_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_calendar_plugIn] calendar_db_get_count() Fail\n");
+ service_ret = calendar_db_get_count_with_query(query, &used_cnt);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("[calendar] 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);
+ _DEBUG_INFO("[calendar] calendar_db_get_count() Success\n");
+ _DEBUG_INFO("[calendar] used_count = %d\n", used_cnt);
}
if (filter != NULL)
calendar_query_destroy(query);
_EXTERN_FUNC_EXIT;
-
return used_cnt;
}
{
_EXTERN_FUNC_ENTER;
- char **folder_id_list = 0;
+ 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;
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;
+ folder_id_list = NULL;
+ goto return_part;
}
+
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;
+ goto return_part;
}
*folder_type_list = (int *)calloc(count, sizeof(int));
if (*folder_type_list == NULL) {
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;
+ goto return_part;
}
- /* 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);
+ int int_folder_id = 0;
+ calendar_record_h event = NULL;
+ err = calendar_record_create(_calendar_event._uri, &event);
+ if ((err != CALENDAR_ERROR_NONE) && (event == NULL)) {
+ _DEBUG_ERROR("calendar_record_create() Fail! : err = %d", err);
+ break;
+ }
+
+ err = calendar_record_get_int(event, _calendar_event.calendar_book_id, &int_folder_id);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_int() 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);
}
- /* memory free */
+
+return_part:
+ _DEBUG_INFO("return_part");
if (service_folder_list != NULL) {
err = calendar_list_destroy(service_folder_list, true);
if (err != CALENDAR_ERROR_NONE) {
service_folder_list = NULL;
}
_EXTERN_FUNC_EXIT;
-
return folder_id_list;
}
{
_EXTERN_FUNC_ENTER;
- _DEBUG_INFO("[da_calendar_plugIn] start!!\n");
+ _DEBUG_INFO("[calendar] start!!\n");
int error_code = account_connect();
error_code = account_disconnect();
- _DEBUG_INFO("[da_calendar_plugIn] end!!\n");
+ _DEBUG_INFO("[calendar] end!!\n");
_EXTERN_FUNC_EXIT;
{
_EXTERN_FUNC_ENTER;
- _DEBUG_INFO("[da_calendar_plugIn] account_id : %d\n", account_id);
- _DEBUG_INFO("[da_calendar_plugIn] folder_id : %s\n", folder_id);
- _DEBUG_INFO("[da_calendar_plugIn] changepoint : %d\n", changepoint);
- sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ _DEBUG_INFO("[calendar] account_id : %d\n", account_id);
+ _DEBUG_INFO("[calendar] folder_id : %s\n", folder_id);
+ _DEBUG_INFO("[calendar] changepoint : %d\n", changepoint);
+
int calendarTimeStamp = changepoint;
int current_change_point = 0;
int temp_folder_id = atoi(folder_id);
- int service_ret = 0;
+ int service_ret = CALENDAR_ERROR_NONE;
sync_agent_plugin_item_node_s *root_ptr = 0;
sync_agent_plugin_item_node_s *cursor_ptr = 0;
calendar_record_h changed_event = NULL;
service_ret = calendar_db_get_changes_by_version(_calendar_event._uri, temp_folder_id, calendarTimeStamp, &service_changed_list, ¤t_change_point);
- _DEBUG_INFO("[da_calendar_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;
- }
+ _DEBUG_INFO("[calendar] 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);
+ goto_if((service_ret != CALENDAR_ERROR_NONE) && (service_changed_list == NULL), "[calendar] calendar_db_get_changes_by_version() Fail!: err[%d]", service_ret);
int list_count = 0;
service_ret = calendar_list_get_count(service_changed_list, &list_count);
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] in calendar_list_get_count Fail!\n");
- ret = _convert_service_error_to_common_error(service_ret);
- goto DACI_FINISH;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_list_get_count() Fail!: err[%d]", service_ret);
- _DEBUG_INFO("[da_calendar_plugIn] in calendar_list_get_count [%d]!", list_count);
+ _DEBUG_INFO("[calendar] in calendar_list_get_count [%d]!", list_count);
if (list_count <= 0) {
-// ret =SYNC_AGENT_DA_ERR_NO_DATA;
- goto DACI_FINISH;
+ goto return_part;
}
-// 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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_list_first() Fail!: err[%d]", service_ret);
- _DEBUG_INFO("[da_calendar_plugIn] calendar_svc_iter_next service_ret : %d\n", service_ret);
+ _DEBUG_INFO("[calendar] 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_event);
- if ((service_ret != CALENDAR_ERROR_NONE) && (changed_event == NULL)) {
- _DEBUG_ERROR("calendar_list_get_current_record_p() Fail! : err = %d", service_ret);
- ret = SYNC_AGENT_DA_ERRORS;
- goto DACI_FINISH;
- }
+ goto_if((service_ret != CALENDAR_ERROR_NONE) && (changed_event == NULL), "[calendar] calendar_list_get_current_record_p() Fail!: err[%d]", service_ret);
+
int type = 0;
service_ret = calendar_record_get_int(changed_event, _calendar_updated_info.modified_status, &type);
if (service_ret != CALENDAR_ERROR_NONE) {
break;
}
- _DEBUG_INFO("[da_calendar_plugIn] type is [%d]", type);
+ _DEBUG_INFO("[calendar] type is [%d]", type);
if (type == CALENDAR_EVENT_MODIFIED_STATUS_INSERTED) {
int calendar_id = 0;
service_ret = calendar_record_get_int(changed_event, _calendar_updated_info.id, &calendar_id);
_DEBUG_ERROR("calendar_record_get_int() Fail!: err = %d", service_ret);
break;
}
- _DEBUG_INFO("[da_calendar_plugIn] calendar id is [%d]", calendar_id);
+ _DEBUG_INFO("[calendar] calendar id is [%d]", calendar_id);
char *calendar_id_str = g_strdup_printf("%d", calendar_id);
- _DEBUG_INFO("[da_calendar_plugIn] CALS_UPDATED_TYPE_INSERTED : [%s]\n", calendar_id_str);
+ _DEBUG_INFO("[calendar] CALS_UPDATED_TYPE_INSERTED : [%s]\n", calendar_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 !!!");
+ if (service_changed_list != NULL) {
+ calendar_list_destroy(service_changed_list, true);
+ service_changed_list = NULL;
+ }
return NULL;
}
root_ptr->item_id = calendar_id_str;
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 !!!");
+ if (service_changed_list != NULL) {
+ calendar_list_destroy(service_changed_list, true);
+ service_changed_list = NULL;
+ }
+ if (root_ptr) {
+ free(root_ptr);
+ root_ptr = NULL;
+ }
return NULL;
}
cursor_ptr->next->item_id = calendar_id_str;
chagned_count++;
}
-
- /*if list can successfully free child than dont need this free */
-// if (changed_event != NULL)
-// calendar_record_destroy(changed_event, true);
} while (calendar_list_next(service_changed_list) != CALENDAR_ERROR_NO_DATA);
- DACI_FINISH:
-
+ return_part:
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;
}
{
_EXTERN_FUNC_ENTER;
- _DEBUG_INFO("[da_calendar_plugIn] account_id : %d\n", account_id);
- _DEBUG_INFO("[da_calendar_plugIn] folder_id : %s\n", folder_id);
- _DEBUG_INFO("[da_calendar_plugIn] changepoint : %d\n", change_point);
+ _DEBUG_INFO("[calendar] account_id : %d\n", account_id);
+ _DEBUG_INFO("[calendar] folder_id : %s\n", folder_id);
+ _DEBUG_INFO("[calendar] changepoint : %d\n", change_point);
int current_change_point = 0;
int calendar_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;
+ int service_ret = CALENDAR_ERROR_NONE;
+
sync_agent_plugin_item_node_s *root_ptr = 0;
sync_agent_plugin_item_node_s *cursor_ptr = 0;
int chagned_count = 0;
calendar_record_h changed_event = NULL;
service_ret = calendar_db_get_changes_by_version(_calendar_event._uri, temp_folder_id, calendar_time_stamp, &service_changed_list, ¤t_change_point);
- _DEBUG_INFO("[da_calendar_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;
- }
+ _DEBUG_INFO("[calendar] 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);
+ goto_if((service_ret != CALENDAR_ERROR_NONE) && (service_changed_list == NULL), "[calendar] calendar_db_get_changes_by_version() Fail!: err[%d]", service_ret);
int list_count = 0;
service_ret = calendar_list_get_count(service_changed_list, &list_count);
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] in calendar_list_get_count Fail!\n");
- ret = _convert_service_error_to_common_error(service_ret);
- goto DACI_FINISH;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_list_get_count() Fail!: err[%d]", service_ret);
- _DEBUG_INFO("[da_calendar_plugIn] in calendar_list_get_count [%d]!", list_count);
+ _DEBUG_INFO("[calendar] in calendar_list_get_count [%d]!", list_count);
if (list_count <= 0) {
- goto DACI_FINISH;
+ goto return_part;
}
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_calendar_plugIn] service_ret : %d\n", service_ret);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_list_first() Fail!: err[%d]", service_ret);
do {
service_ret = calendar_list_get_current_record_p(service_changed_list, &changed_event);
- if ((service_ret != CALENDAR_ERROR_NONE) && (changed_event == NULL)) {
- _DEBUG_ERROR("calendar_list_get_current_record_p() Fail! : err = %d", service_ret);
- ret = SYNC_AGENT_DA_ERRORS;
- goto DACI_FINISH;
- }
+ goto_if((service_ret != CALENDAR_ERROR_NONE) && (changed_event == NULL), "[calendar] calendar_list_get_current_record_p() Fail!: err[%d]", service_ret);
int type = 0;
service_ret = calendar_record_get_int(changed_event, _calendar_updated_info.modified_status, &type);
break;
}
char *calendar_id_str = g_strdup_printf("%d", calendar_id);
- _DEBUG_INFO("[da_calendar_plugIn] CALS_UPDATED_TYPE_DELETED : [%s]\n", calendar_id_str);
+ _DEBUG_INFO("[calendar] CALS_UPDATED_TYPE_DELETED : [%s]\n", calendar_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 !!!");
+ if (service_changed_list != NULL) {
+ calendar_list_destroy(service_changed_list, true);
+ service_changed_list = NULL;
+ }
return NULL;
}
root_ptr->item_id = calendar_id_str;
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 !!!");
+ if (service_changed_list != NULL) {
+ calendar_list_destroy(service_changed_list, true);
+ service_changed_list = NULL;
+ }
+ if (root_ptr) {
+ free(root_ptr);
+ root_ptr = NULL;
+ }
return NULL;
}
cursor_ptr->next->item_id = calendar_id_str;
chagned_count++;
}
-
- /*if list can successfully free child than dont need this free */
-// if (changed_event != NULL)
-// calendar_record_destroy(changed_event, true);
} while (calendar_list_next(service_changed_list) != CALENDAR_ERROR_NO_DATA);
- DACI_FINISH:
-
+ return_part:
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;
}
{
_EXTERN_FUNC_ENTER;
- _DEBUG_INFO("\n[da_calendar_plugIn] account_id : %d\n", account_id);
- _DEBUG_INFO("[da_calendar_plugIn] folder_id : %s\n", folder_id);
- _DEBUG_INFO("[da_calendar_plugIn] changepoint : %d\n", change_point);
- sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ _DEBUG_INFO("\n[calendar] account_id : %d\n", account_id);
+ _DEBUG_INFO("[calendar] folder_id : %s\n", folder_id);
+ _DEBUG_INFO("[calendar] changepoint : %d\n", change_point);
+
int calendar_time_stamp = change_point;
int temp_folder_id = atoi(folder_id);
- int service_ret = 0;
+ int service_ret = CALENDAR_ERROR_NONE;
calendar_list_h service_changed_list = 0;
calendar_record_h changed_event = NULL;
- sync_agent_plugin_item_node_s *root_ptr = 0;
- sync_agent_plugin_item_node_s *cursor_ptr = 0;
+ sync_agent_plugin_item_node_s *root_ptr = NULL;
+ sync_agent_plugin_item_node_s *cursor_ptr = NULL;
int chagned_count = 0;
int current_change_point = 0;
service_ret = calendar_db_get_changes_by_version(_calendar_event._uri, temp_folder_id, calendar_time_stamp, &service_changed_list, ¤t_change_point);
- _DEBUG_INFO("[da_calendar_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;
- }
+ _DEBUG_INFO("[calendar] 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);
+ goto_if((service_ret != CALENDAR_ERROR_NONE) && (service_changed_list == NULL), "[calendar] calendar_db_get_changes_by_version() Fail!: err[%d]", service_ret);
int list_count = 0;
service_ret = calendar_list_get_count(service_changed_list, &list_count);
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[da_calendar_plugIn] in calendar_list_get_count Fail!\n");
- ret = _convert_service_error_to_common_error(service_ret);
- goto DACI_FINISH;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_list_get_count() Fail!: err[%d]", service_ret);
- _DEBUG_INFO("[da_calendar_plugIn] in calendar_list_get_count [%d]!", list_count);
+ _DEBUG_INFO("[calendar] in calendar_list_get_count [%d]!", list_count);
if (list_count <= 0) {
- goto DACI_FINISH;
+ goto return_part;
}
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_record_get_child_record_count() Fail!: err[%d]", service_ret);
- _DEBUG_INFO("[da_calendar_plugIn] service_ret : %d\n", service_ret);
+ _DEBUG_INFO("[calendar] service_ret : %d\n", service_ret);
do {
service_ret = calendar_list_get_current_record_p(service_changed_list, &changed_event);
- if ((service_ret != CALENDAR_ERROR_NONE) && (changed_event == NULL)) {
- _DEBUG_ERROR("calendar_list_get_current_record_p() Fail! : err = %d", service_ret);
- ret = SYNC_AGENT_DA_ERRORS;
- goto DACI_FINISH;
- }
+ goto_if((service_ret != CALENDAR_ERROR_NONE) && (changed_event == NULL), "[calendar] calendar_record_get_child_record_count() Fail!: err[%d]", service_ret);
+
int type = 0;
service_ret = calendar_record_get_int(changed_event, _calendar_updated_info.modified_status, &type);
if (service_ret != CALENDAR_ERROR_NONE) {
break;
}
char *calendar_id_str = g_strdup_printf("%d", calendar_id);
- _DEBUG_INFO("[da_calendar_plugIn] CALS_UPDATED_TYPE_MODIFIED : [%s]\n", calendar_id_str);
+ _DEBUG_INFO("[calendar] CALS_UPDATED_TYPE_MODIFIED : [%s]\n", calendar_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 !!!");
+ if (service_changed_list != NULL) {
+ calendar_list_destroy(service_changed_list, true);
+ service_changed_list = NULL;
+ }
return NULL;
}
root_ptr->item_id = calendar_id_str;
- root_ptr->next = 0;
+ root_ptr->next = NULL;
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 !!!");
+ if (service_changed_list != NULL) {
+ calendar_list_destroy(service_changed_list, true);
+ service_changed_list = NULL;
+ }
+ if (root_ptr) {
+ free(root_ptr);
+ root_ptr = NULL;
+ }
return NULL;
}
cursor_ptr->next->item_id = calendar_id_str;
- cursor_ptr->next->next = 0;
+ cursor_ptr->next->next = NULL;
cursor_ptr = cursor_ptr->next;
}
-
chagned_count++;
- }
+ // end of normal calendar
- /*if list can successfully free child than dont need this free */
-// if (changed_event != NULL)
-// calendar_record_destroy(changed_event, true);
- } while (calendar_list_next(service_changed_list) != CALENDAR_ERROR_NO_DATA);
+ // Check whether this calendar have updated exdate child
+ calendar_record_h cal_record = NULL;
+ unsigned int updated_exdate_count = 0;
+ service_ret = calendar_db_get_record(_calendar_event._uri, calendar_id, &cal_record);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_db_get_record() Fail!: err[%d]", service_ret);
- DACI_FINISH:
+ service_ret = calendar_record_get_child_record_count(cal_record, _calendar_event.exception, &updated_exdate_count);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_record_get_child_record_count() Fail!: err[%d]", service_ret);
+ _DEBUG_INFO("updated_exdate_count(%d)", updated_exdate_count);
+
+ if (updated_exdate_count > 0) {
+ cursor_ptr->parent_item_id = g_strdup("-1"); // parent_item_id of the parent item should be set to "-1"
+ }
+ int index = 0;
+ for (index = 0; index < updated_exdate_count; index++) {
+ calendar_record_h updated_exdate_record = NULL;
+ int child_service_id = 0;
+ int original_event_id = 0;
+ char *recurrence_id = NULL;
+
+ service_ret = calendar_record_get_child_record_at_p(cal_record, _calendar_event.exception, index, &updated_exdate_record);
+ goto_if(service_ret != CALENDAR_ERROR_NONE || updated_exdate_record == NULL, "[calendar] calendar_record_get_child_record_at_p() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_get_int(updated_exdate_record, _calendar_event.id, &child_service_id);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_record_get_int() Fail!: err[%d]", service_ret);
+ _DEBUG_INFO("child_service_id = %d", child_service_id);
+
+ service_ret = calendar_record_get_int(updated_exdate_record, _calendar_event.original_event_id, &original_event_id);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_record_get_int() Fail!: err[%d]", service_ret);
+ _DEBUG_INFO("original_event_id = %d", original_event_id);
+
+ service_ret = calendar_record_get_str(updated_exdate_record, _calendar_event.recurrence_id, &recurrence_id);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[calendar] calendar_record_get_str() Fail!: err[%d]", service_ret);
+ _DEBUG_INFO("recurrence_id = %s", recurrence_id);
+
+ service_ret = calendar_record_set_str(updated_exdate_record, _calendar_event.exdate, NULL);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_set_str() Fail!: err[%d]", service_ret);
+
+ if (original_event_id >= 0 && recurrence_id != NULL && strlen(recurrence_id) > 0) {
+ 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 !!!");
+ if (service_changed_list != NULL) {
+ calendar_list_destroy(service_changed_list, true);
+ service_changed_list = NULL;
+ }
+ if (root_ptr) {
+ free(root_ptr);
+ root_ptr = NULL;
+ }
+ return NULL;
+ }
+ cursor_ptr->next->item_id = g_strdup_printf("%d", child_service_id);
+ cursor_ptr->next->parent_item_id = g_strdup_printf("%d", original_event_id);
+ cursor_ptr->next->next = NULL;
+ cursor_ptr = cursor_ptr->next;
+ chagned_count++;
+ }
+ }
+ // end of child calendar
+ }
+ } while (calendar_list_next(service_changed_list) != CALENDAR_ERROR_NO_DATA);
+
+ return_part:
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;
}
_EXTERN_FUNC_EXIT;
}
+EXPORT_API void sync_agent_plugin_set_callback_delete_child_item(sync_agent_del_child_item_cb_plugin callback)
+{
+ _EXTERN_FUNC_ENTER;
+ callback_delete_child_item = callback;
+ _EXTERN_FUNC_EXIT;
+}
+
EXPORT_API int sync_agent_plugin_get_max_item_count(int folder_type)
{
_EXTERN_FUNC_ENTER;
_INNER_FUNC_ENTER;
if (pthread_mutex_lock(&lockx)) {
- _DEBUG_ERROR("[da_calendar_plugIn] pthread_mutex_lock error");
+ _DEBUG_ERROR("[calendar] pthread_mutex_lock error");
}
is_noti_from_me = set_flag;
if (pthread_mutex_unlock(&lockx)) {
- _DEBUG_ERROR("[da_calendar_plugIn] pthread_mutex_unlock error");
+ _DEBUG_ERROR("[calendar] pthread_mutex_unlock error");
}
_INNER_FUNC_EXIT;
return is_noti_from_me;
}
-void _process_calendar_change(const char *view_uri, void *user_data)
+static 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;
+ }
- _DEBUG_TRACE("[da_calendar_plugIn] detected calendar storage changed\n");
+ 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) {
+ int ret_str_length = strlen(token_loc) - strlen(token) - strlen(str_temp);
+ if (ret_str_length <= 0) {
+ _DEBUG_ERROR("token_loc = %s", token_loc);
+ _DEBUG_ERROR("token = %s", token);
+ _DEBUG_ERROR("str_temp = %s", str_temp);
+ _DEBUG_ERROR("ret_str_length(%d) <= 0", ret_str_length);
+ goto return_part;
+ }
+ str_output = (char *)calloc(ret_str_length, sizeof(char));
+ goto_if(str_output == NULL, "str_output is NULL");
+
+ memcpy(str_output, token_loc + strlen(token), ret_str_length);
+ }
+ }
+
+return_part:
+ _INNER_FUNC_EXIT;
+ return str_output;
+}
+
+void _process_calendar_change(const char *view_uri, void *user_data)
+{
+ _INNER_FUNC_ENTER;
+ _DEBUG_TRACE("[calendar] detected calendar storage changed\n");
int from_Me = __get_is_noti_from_me();
if (from_Me == 1) {
_set_is_noti_from_me(0);
- _DEBUG_TRACE("[da_calendar_plugIn] This noti is from Me!! so will be ignored!!\n");
+ _DEBUG_TRACE("[calendar] This noti is from Me!! so will be ignored!!\n");
return;
}
if (sync_agent_async_queue_length(queue) < 1) {
sync_agent_send_msg_async_queue(queue, (void *)calendarVersion);
_DEBUG_INFO("fw_async_queue_length = %d", sync_agent_async_queue_length(queue));
+ } else {
+ _DEBUG_INFO("send_msg_failed... sync_agent_async_queue_length(queue) >= 1");
+ if(calendarVersion != NULL) {
+ free(calendarVersion);
+ calendarVersion = NULL;
+ }
}
_INNER_FUNC_EXIT;
{
_INNER_FUNC_ENTER;
- _DEBUG_TRACE("[da_calendar_plugIn] Start __rutine_Calendar_Change (create thread)\n");
+ _DEBUG_TRACE("[calendar] Start __rutine_Calendar_Change (create thread)\n");
/*
* Create Queue
int i = 0;
for (; i < account_list_count; i++) {
int calendar_account_id = account_list[i];
- _DEBUG_TRACE("[da_calendar_plugIn] calendar_account_id : %d, count : %d\n", calendar_account_id, account_list_count);
- _DEBUG_TRACE("[da_calendar_plugIn] Before calendar_svc_event_get_changes : %d\n", calendar_version);
+ _DEBUG_TRACE("[calendar] calendar_account_id : %d, count : %d\n", calendar_account_id, account_list_count);
+ _DEBUG_TRACE("[calendar] Before calendar_svc_event_get_changes : %d\n", calendar_version);
/*get folder id */
int folder_list_count = 0;
_DEBUG_ERROR("calendar_list_get_count() Fail! : err = %d", service_ret);
break;
}
- _DEBUG_TRACE("[da_calendar_plugIn] folder_list_count : %d", folder_list_count);
+ _DEBUG_TRACE("[calendar] folder_list_count : %d", folder_list_count);
do {
switch (type) {
case CALENDAR_EVENT_MODIFIED_STATUS_INSERTED:
{
+ _DEBUG_INFO("[calendar] Calendar Inserted!\n");
char calendar_folder_id_str[12];
snprintf(calendar_folder_id_str, sizeof(calendar_folder_id_str), "%d", calendar_folder_id);
- _DEBUG_TRACE("[da_calendar_plugIn] Calendar Inserted!\n");
- _DEBUG_TRACE("[da_calendar_plugIn] calendar folder id : %s\n", calendar_folder_id_str);
- int result = callback_add_item(account_list[i], i, calendar_id_str, FW_CALENDAR, calendar_folder_id_str, 0);
+ _DEBUG_INFO("[calendar] calendar folder id : %s\n", calendar_folder_id_str);
+ int result = callback_add_item(account_list[i], i, calendar_id_str, NULL, FW_CALENDAR, calendar_folder_id_str, 0);
if (!result)
- _DEBUG_TRACE("[da_calendar_plugIn] Failed to call SA_EH_Add_Item() \n");
- else
- _DEBUG_TRACE("[da_calendar_plugIn] Success to call SA_EH_Add_Item() \n");
-
+ _DEBUG_ERROR("[calendar] Failed to call SA_EH_Add_Item() \n");
}
break;
case CALENDAR_EVENT_MODIFIED_STATUS_UPDATED:
{
- _DEBUG_TRACE("[da_calendar_plugIn] Calendar Updated!\n");
- int result = callback_update_item(account_list[i], i, calendar_id_str, FW_CALENDAR);
+ _DEBUG_INFO("[calendar] Calendar Updated!\n");
+ char *parend_id = NULL;
+ int exdate_count = 0;
+ char calendar_folder_id_str[12];
+
+ snprintf(calendar_folder_id_str, sizeof(calendar_folder_id_str), "%d", calendar_folder_id);
+ _DEBUG_INFO("[calendar] calendar folder id : %s\n", calendar_folder_id_str);
+
+ exdate_count = _add_updated_exdate_item(account_list[i], i, calendar_id_str, calendar_folder_id_str);
+ if (exdate_count > 0) {
+ parend_id = g_strdup("-1");
+ }
+
+ int result = callback_update_item(account_list[i], i, calendar_id_str, parend_id, FW_CALENDAR);
if (!result)
- _DEBUG_TRACE("[da_calendar_plugIn] Failed to call callback_del_item() \n");
+ _DEBUG_ERROR("[calendar] Failed to call callback_update_item() \n");
}
break;
case CALENDAR_EVENT_MODIFIED_STATUS_DELETED:
{
- _DEBUG_TRACE("[da_calendar_plugIn] Calendar Deleted!\n");
+ _DEBUG_INFO("[calendar] Calendar Deleted!\n");
int result = callback_del_item(account_list[i], i, calendar_id_str, FW_CALENDAR);
if (!result)
- _DEBUG_TRACE("[da_calendar_plugIn] Failed to call callback_del_item() \n");
+ _DEBUG_ERROR("[calendar] Failed to call callback_del_item() \n");
}
break;
default:
- _DEBUG_TRACE("[da_calendar_plugIn] cached Another Calendar Change Noti!\n");
+ _DEBUG_INFO("[calendar] cached Another Calendar 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) {
}
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 */
+ } while (calendar_list_next(folder_list) != CALENDAR_ERROR_NO_DATA);
_DEBUG_TRACE("folder list free");
if (folder_list != NULL) {
}
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_calendar_plugIn] End __rutine_Calendar_Change (create thread)\n");
-
+ _DEBUG_TRACE("[calendar] End __rutine_Calendar_Change (create thread)\n");
_INNER_FUNC_EXIT;
-
return 0;
}
_INNER_FUNC_ENTER;
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
- _DEBUG_TRACE("[da_calendar_plugIn] Error Code : %d\n", err);
+ _DEBUG_TRACE("[calendar] Error Code : %d\n", err);
switch (err) {
+ case CALENDAR_ERROR_NONE:
+ ret = SYNC_AGENT_DA_SUCCESS;
+ break;
+
case CALENDAR_ERROR_INVALID_PARAMETER: /* -4 */
ret = SYNC_AGENT_DA_ERR_INVALID_CONTENT;
break;
}
_INNER_FUNC_EXIT;
-
return ret;
}
return has_contact;
}
-static bool __is_calendar_id(/*account_capability_type_e*/const char* capability_type, account_capability_state_e capability_value, void *user_data)
+static bool __is_calendar_id(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;
_INNER_FUNC_EXIT;
return TRUE;
}
+
+static int _add_updated_exdate_item(int service_account_id, int index, char *parent_service_item_id, char *service_folder_id)
+{
+ _EXTERN_FUNC_ENTER;
+ retvm_if(parent_service_item_id == NULL, 0, "parent_service_item_id is NULL !!");
+
+ // Check whether this calendar have updated exdate child
+ calendar_record_h cal_record = NULL;
+ unsigned int exception_count = 0;
+ int result = 0;
+ int service_ret = 0;
+ int updated_exdate_count = 0;
+
+ service_ret = calendar_db_get_record(_calendar_event._uri, atoi(parent_service_item_id), &cal_record);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_db_get_record() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_get_child_record_count(cal_record, _calendar_event.exception, &exception_count);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_child_record_count() Fail!: err[%d]", service_ret);
+
+ _DEBUG_INFO("exception_count = %d, parent_service_item_id = %s", exception_count, parent_service_item_id);
+ goto_if(exception_count <= 0, "exception_count <= 0");
+
+ // All child item of parent item whose has original_event_id as service_id field should be deleted before callback_add_item()
+ // Requesting by Calendar Svc Team (2013-03-26 tw123.kim & iamjs.kim)
+ result = callback_delete_child_item(parent_service_item_id, NULL);
+ if (!result)
+ _DEBUG_ERROR("Failed to call callback_delete_child_item() \n");
+
+ int exdate_index = 0;
+ for (exdate_index = 0; exdate_index < exception_count; exdate_index++) {
+ calendar_record_h updated_exdate_record = NULL;
+ int child_service_id = 0;
+ int original_event_id = 0;
+ char *recurrence_id = NULL;
+
+ service_ret = calendar_record_get_child_record_at_p(cal_record, _calendar_event.exception, exdate_index, &updated_exdate_record);
+ goto_if(service_ret != CALENDAR_ERROR_NONE || updated_exdate_record == NULL, "calendar_record_get_child_record_at_p() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_get_int(updated_exdate_record, _calendar_event.id, &child_service_id);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_int() Fail!: err[%d]", service_ret);
+
+ char *child_id = g_strdup_printf("%d", child_service_id);
+ _DEBUG_INFO("child_id = %s", child_id);
+
+ service_ret = calendar_record_get_int(updated_exdate_record, _calendar_event.original_event_id, &original_event_id);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_int() Fail!: err[%d]", service_ret);
+ _DEBUG_INFO("original_event_id = %d", original_event_id);
+
+ service_ret = calendar_record_get_str(updated_exdate_record, _calendar_event.recurrence_id, &recurrence_id);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_str() Fail!: err[%d]", service_ret);
+ _DEBUG_INFO("recurrence_id = %s", recurrence_id);
+
+ service_ret = calendar_record_set_str(updated_exdate_record, _calendar_event.exdate, NULL);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_set_str() Fail!: err[%d]", service_ret);
+
+ if (original_event_id >= 0 && recurrence_id != NULL && strlen(recurrence_id) > 0) {
+ char *parent_id = strdup(parent_service_item_id);
+ result = callback_add_item(service_account_id, index, child_id, parent_id, FW_CALENDAR, service_folder_id, 0);
+ if (!result)
+ _DEBUG_ERROR("Failed to call SA_EH_Add_Item() \n");
+ else {
+ _DEBUG_INFO("Success to call SA_EH_Add_Item() \n");
+ updated_exdate_count++;
+ }
+ }
+ }
+
+return_part:
+ _DEBUG_INFO("updated_exdate_count = %d", updated_exdate_count);
+ _INNER_FUNC_EXIT;
+ return updated_exdate_count;
+}
+
+static sync_agent_da_return_e _process_exdate_item(calendar_record_h calendar_record)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if(calendar_record == NULL, SYNC_AGENT_DA_ERRORS, "calendar_record is NULL !!");
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ int service_ret = CALENDAR_ERROR_NONE;
+ gchar **array_delete_exdate = NULL;
+ GList *matched_item_list = NULL;
+
+ // case 1 : updated exdate item doesn't need to calendar_db_update_record(), so just return this API
+ char *check_exdate_update = NULL;
+ service_ret = calendar_record_get_str(calendar_record, _calendar_event.recurrence_id, &check_exdate_update);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_str() Fail!: err[%d]", service_ret);
+
+ if (check_exdate_update != NULL && g_strcmp0(check_exdate_update, EXTYPE_UPDATE_KEYWORD) == 0) {
+ // this is a updated exdate item. it should be not done calendar_db_update_record(). so just return
+ ret = SYNC_AGENT_DA_ERR_ITEM_READ_ONLY;
+ goto return_part;
+ }
+
+ // case 2 : the parent item which has updated exdate items, it should be got DB changing callback function
+ unsigned int exception_count = 0;
+ service_ret = calendar_record_get_child_record_count(calendar_record, _calendar_event.exception, &exception_count);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_child_record_count() Fail!: err[%d]", service_ret);
+ _DEBUG_INFO("exception_count(%d)", exception_count);
+
+ if (exception_count <= 0) {
+ _DEBUG_INFO("this record has not updated exdate item. so just return");
+ goto return_part;
+ }
+
+ _DEBUG_INFO("this is a parent item of updated exdate items. it should be got DB changing callback function");
+ _set_is_noti_from_me(0);
+
+ // case 3 : updated exdate items which exist at the same date of deleted exdate items, should be deleted
+ // 3-1 : get the deleted exdate items
+ char *exdate = NULL;
+ service_ret = calendar_record_get_str(calendar_record, _calendar_event.exdate, &exdate);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_str() Fail!: err[%d]", service_ret);
+
+ _DEBUG_INFO("exdate = %s", exdate);
+ if (exdate == NULL) {
+ goto return_part;
+ }
+
+ array_delete_exdate = g_strsplit(exdate, ",", -1);
+ goto_if(array_delete_exdate == NULL, "array_delete_exdate is NULL");
+
+ // 3-2 : get the updated exdate items, After that check whether same date exist, or not.
+ int updated_index = 0;
+ for (updated_index = 0; updated_index < exception_count; updated_index++) {
+ calendar_record_h updated_exdate_record = NULL;
+ char *recurrence_id = NULL;
+ int deleted_index = 0;
+
+ service_ret = calendar_record_get_child_record_at_p(calendar_record, _calendar_event.exception, updated_index, &updated_exdate_record);
+ goto_if(service_ret != CALENDAR_ERROR_NONE || updated_exdate_record == NULL, "calendar_record_get_child_record_at_p() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_get_str(updated_exdate_record, _calendar_event.recurrence_id, &recurrence_id);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_str() Fail!: err[%d]", service_ret);
+ _DEBUG_INFO("updated_index = %d, recurrence_id = %s", updated_index, recurrence_id);
+
+ for (deleted_index = 0; array_delete_exdate[deleted_index] != NULL; deleted_index++) {
+ _DEBUG_INFO("one_exdate = %s, deleted_index = %d", array_delete_exdate[deleted_index], deleted_index);
+ if (strcmp(recurrence_id, array_delete_exdate[deleted_index]) == 0) {
+ _DEBUG_INFO("matched date = %s", array_delete_exdate[deleted_index]);
+ matched_item_list = g_list_append(matched_item_list, updated_exdate_record);
+ }
+ }
+ }
+
+ // 3-3 : delete the matched items
+ int parent_service_item_id = 0;
+ service_ret = calendar_record_get_int(calendar_record, _calendar_event.id, &parent_service_item_id);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_int() Fail!: err[%d]", service_ret);
+
+ char *parent_id = g_strdup_printf("%d", parent_service_item_id);
+ _DEBUG_INFO("parent_service_item_id = %s", parent_id);
+
+ int matched_count = g_list_length(matched_item_list);
+ _DEBUG_INFO("matched_count = %d", matched_count);
+
+ int matched_index = 0;
+ for (matched_index = 0; matched_index < matched_count; matched_index++) {
+ calendar_record_h record = (calendar_record_h)g_list_nth_data(matched_item_list, matched_index);
+ int child_service_id = 0;
+
+ service_ret = calendar_record_remove_child_record(calendar_record, _calendar_event.exception, record);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_remove_child_record() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_get_int(record, _calendar_event.id, &child_service_id);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_int() Fail!: err[%d]", service_ret);
+
+ char *child_id = g_strdup_printf("%d", child_service_id);
+ _DEBUG_INFO("child_id for deleting = %s, index = %d", child_id, matched_index);
+
+ ret = callback_delete_child_item(parent_id, child_id);
+ if (!ret)
+ _DEBUG_ERROR("Failed to call callback_delete_child_item() \n");
+ }
+
+return_part:
+ if(array_delete_exdate) {
+ g_strfreev(array_delete_exdate);
+ array_delete_exdate = NULL;
+ }
+ if(matched_item_list) {
+ g_list_free(matched_item_list);
+ matched_item_list = NULL;
+ }
+ _INNER_FUNC_EXIT;
+ return ret;
+}
{
_EXTERN_FUNC_ENTER;
- retvm_if(file_path == NULL, SYNC_AGENT_DA_ERRORS, "file_path is NULL. FAIL !!!");
-//
-// sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
-// int err = 0;
-// FILE *file = 0;
-// int cur_size = 0;
-// CTSvalue *plog = 0; /* plog */
-//
-// /* open call log : from file text */
-// file = fopen(BACKUP_PATH, "r");
-// if (file == NULL) {
-// _DEBUG_INFO("[da_call_log_plugIn] fopen fail\n");
-// return SYNC_AGENT_DA_ERRORS;
-// }
-//
-// /* delete call log from contact service database */
-// _del_all_calllogs();
-//
-// while (1) {
-// dc_plog_list_s plog_list;
-// char temp_number[100] = { 0 };
-// char temp_extra_data2[1024] = { 0 };
-//
-// /* read call log : from file text */
-// cur_size = fscanf(file, "%100s %d %d %d %d %1024s ", temp_number, &(plog_list.related_id), &(plog_list.log_time), &(plog_list.log_type), &(plog_list.extra_data1), temp_extra_data2);
-//
-// if (cur_size == -1) {
-// _DEBUG_INFO("[da_call_log_plugIn] fscanf fail\n");
-// ret = SYNC_AGENT_DA_ERRORS;
-// goto DACI_FINISH;
-// }
-//
-// plog = contacts_svc_value_new(CTS_VALUE_PHONELOG);
-// if (plog == NULL) {
-// _DEBUG_INFO("[da_call_log_plugIn] memory allocation fail\n");
-// ret = SYNC_AGENT_DA_ERRORS;
-// goto DACI_FINISH;
-// }
-//
-// /* add call log to contact service database */
-// contacts_svc_value_set_str(plog, CTS_PLOG_VAL_NUMBER_STR, temp_number);
-// contacts_svc_value_set_int(plog, CTS_PLOG_VAL_RELATED_ID_INT, plog_list.related_id);
-// contacts_svc_value_set_int(plog, CTS_PLOG_VAL_LOG_TIME_INT, plog_list.log_time);
-// contacts_svc_value_set_int(plog, CTS_PLOG_VAL_LOG_TYPE_INT, plog_list.log_type);
-// contacts_svc_value_set_int(plog, CTS_PLOG_VAL_DURATION_INT, plog_list.extra_data1);
-// contacts_svc_value_set_str(plog, CTS_PLOG_VAL_SHORTMSG_STR, temp_extra_data2);
-//
-// _DEBUG_INFO("plog_list.number : %s\n", temp_number);
-// _DEBUG_INFO("plog_list.related_id : %d\n", plog_list.related_id);
-// _DEBUG_INFO("plog_list.log_time : %d\n", plog_list.log_time);
-// _DEBUG_INFO("plog_list.log_type : %d\n", plog_list.log_type);
-// _DEBUG_INFO("plog_list.extra_data1 : %d\n", plog_list.extra_data1);
-// _DEBUG_INFO("plog_list.extra_data2 : %s\n", temp_extra_data2);
-//
-// err = contacts_svc_insert_phonelog(plog);
-// if (err < CTS_SUCCESS) {
-// _DEBUG_INFO("[da_contact_plugIn] contacts_svc_insert_phonelog() Fail!\n");
-// ret = SYNC_AGENT_DA_ERRORS;
-// goto DACI_FINISH;
-// } else {
-// _DEBUG_INFO("[da_contact_plugIn] contacts_svc_insert_phonelog() Success!\n");
-//
-// /* memory free */
-// if (plog != NULL) {
-// contacts_svc_value_free(plog);
-// plog = 0;
-// }
-// }
-// }
-//
-//DACI_FINISH:
-//
-// if (file != NULL) {
-// fclose(file);
-// file = 0;
-// }
-//
-// /* memory free */
-// if (plog != NULL) {
-// contacts_svc_value_free(plog);
-// plog = 0;
-// }
+ retvm_if(file_path == NULL, SYNC_AGENT_DA_ERRORS, "[da_call_log_plugIn] file_path is NULL. FAIL !!!");
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
int err = 0;
- FILE *file = 0;
int cur_size = 0;
- contacts_record_h record = NULL;
int contact_id = 0;
+ FILE *file = NULL;
+ contacts_record_h record = NULL;
/* open call log : from file text */
file = fopen(BACKUP_PATH, "r");
if (file == NULL) {
- _DEBUG_ERROR("[da_call_log_plugIn] fopen fail\n");
+ _DEBUG_ERROR("[da_call_log_plugIn] fopen() fail");
return SYNC_AGENT_DA_ERRORS;
}
/* read call log : from file text */
cur_size = fscanf(file, "%100s %d %d %d %d %1024s ", temp_number, &(plog_list.related_id), &(plog_list.log_time), &(plog_list.log_type), &(plog_list.extra_data1), temp_extra_data2);
-
if (cur_size == -1) {
- _DEBUG_ERROR("[da_call_log_plugIn] fscanf fail\n");
- ret = SYNC_AGENT_DA_ERRORS;
+ _DEBUG_INFO("[da_call_log_plugIn] The end of file");
+ ret = SYNC_AGENT_DA_SUCCESS;
goto DACI_FINISH;
}
err = contacts_record_create(_contacts_phone_log._uri, &record);
if (err != CONTACTS_ERROR_NONE) {
- _DEBUG_ERROR("[da_call_log_plugIn] contacts_record_create Fail\n");
+ _DEBUG_ERROR("[da_call_log_plugIn] contacts_record_create() Fail, err[%d]", err);
ret = _convert_service_error_to_common_error(err);
goto DACI_FINISH;
}
contacts_record_set_int(record, _contacts_phone_log.extra_data1, plog_list.extra_data1);
contacts_record_set_str(record, _contacts_phone_log.extra_data2, temp_extra_data2);
- _DEBUG_INFO("plog_list.number : %s\n", temp_number);
- _DEBUG_INFO("plog_list.related_id : %d\n", plog_list.related_id);
- _DEBUG_INFO("plog_list.log_time : %d\n", plog_list.log_time);
- _DEBUG_INFO("plog_list.log_type : %d\n", plog_list.log_type);
- _DEBUG_INFO("plog_list.extra_data1 : %d\n", plog_list.extra_data1);
- _DEBUG_INFO("plog_list.extra_data2 : %s\n", temp_extra_data2);
+ _DEBUG_INFO("[da_contact_plugIn] plog_list.number : [%s]", temp_number);
+ _DEBUG_INFO("[da_contact_plugIn] plog_list.related_id : [%d]", plog_list.related_id);
+ _DEBUG_INFO("[da_contact_plugIn] plog_list.log_time : [%d]", plog_list.log_time);
+ _DEBUG_INFO("[da_contact_plugIn] plog_list.log_type : [%d]", plog_list.log_type);
+ _DEBUG_INFO("[da_contact_plugIn] plog_list.extra_data1 : [%d]", plog_list.extra_data1);
+ _DEBUG_INFO("[da_contact_plugIn] plog_list.extra_data2 : [%s]", temp_extra_data2);
err = contacts_db_insert_record(record, &contact_id);
if (err != CONTACTS_ERROR_NONE) {
- _DEBUG_ERROR("[da_contact_plugIn] contacts_db_insert_record() Fail!\n");
+ _DEBUG_ERROR("[da_contact_plugIn] contacts_db_insert_record() Fail, err[%d]", err);
ret = _convert_service_error_to_common_error(err);
goto DACI_FINISH;
} else {
- _DEBUG_INFO("[da_contact_plugIn] contacts_db_insert_record() Success!\n");
- _DEBUG_INFO("[da_contact_plugIn] contact_id = %d", contact_id);
+ _DEBUG_INFO("[da_contact_plugIn] contacts_db_insert_record() Success, contact_id = [%d]", contact_id);
}
}
- DACI_FINISH:
+DACI_FINISH:
+ _DEBUG_INFO("[da_contact_plugIn] DACI_FINISH");
contacts_record_destroy(record, true);
if (file != NULL) {
fclose(file);
- file = 0;
+ file = NULL;
}
_EXTERN_FUNC_EXIT;
-
return ret;
}
{
_INNER_FUNC_ENTER;
-// CTSiter *iter = 0;
-// CTSvalue *plog = 0; /*plog_list */
-//
-// contacts_svc_get_list(CTS_LIST_ALL_PLOG, &iter);
-// while (CTS_SUCCESS == contacts_svc_iter_next(iter)) {
-//
-// /* get call log */
-// plog = contacts_svc_iter_get_info(iter);
-// if (plog == NULL)
-// continue;
-//
-// int id = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_ID_INT);
-//
-// /* delete call log */
-// contacts_svc_delete_phonelog(CTS_PLOG_DEL_BY_ID, id);
-// _DEBUG_TRACE("[da_call_log_plugIn] id : %d\n", id);
-//
-// /* memory free */
-// if (plog != NULL) {
-// contacts_svc_value_free(plog);
-// plog = 0;
-// }
-// }
-//
-// /* memory free */
-// if (iter != NULL) {
-// contacts_svc_iter_remove(iter);
-// iter = 0;
-// }
-
contacts_error_e err = CONTACTS_ERROR_NONE;
contacts_list_h list = NULL;
err = contacts_db_get_all_records(_contacts_phone_log._uri, 0, 0, &list);
if (err != CONTACTS_ERROR_NONE) {
- _DEBUG_ERROR("[da_call_log_plugIn] contacts_db_get_all_records fail\n");
+ _DEBUG_ERROR("[da_call_log_plugIn] contacts_db_get_all_records() fail, err[%d]", err);
+ err = contacts_list_destroy(list, true);
+ if (err != CONTACTS_ERROR_NONE) {
+ _DEBUG_ERROR("[da_call_log_plugIn] contacts_list_destroy() fail, err[%d]", err);
+ }
return;
}
/* get call log */
err = contacts_list_get_current_record_p(list, &record);
if (err != CONTACTS_ERROR_NONE) {
- _DEBUG_ERROR("[da_call_log_plugIn] contacts_db_get_all_records fail\n");
+ _DEBUG_ERROR("[da_call_log_plugIn] contacts_list_get_current_record_p() fail, err[%d]", err);
continue;
}
int id;
err = contacts_record_get_int(record, _contacts_phone_log.id, &id);
if (err != CONTACTS_ERROR_NONE) {
- _DEBUG_ERROR("[da_call_log_plugIn] contacts_db_get_all_records fail\n");
+ _DEBUG_ERROR("[da_call_log_plugIn] contacts_record_get_int() fail, err[%d]", err);
continue;
}
- _DEBUG_TRACE("[da_call_log_plugIn] id : %d\n", id);
+ _DEBUG_TRACE("[da_call_log_plugIn] id : [%d]", id);
/* delete call log */
contacts_db_delete_record(_contacts_phone_log._uri, id);
}
/* memory free */
- contacts_list_destroy(list, true);
+ err = contacts_list_destroy(list, true);
+ if (err != CONTACTS_ERROR_NONE) {
+ _DEBUG_ERROR("[da_call_log_plugIn] contacts_list_destroy() fail, err[%d]", err);
+ }
_INNER_FUNC_EXIT;
}
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_call-log_plugIn] account_id : %d\n", account_id);
-// _DEBUG_INFO("[da_call-log_plugIn] folder_id : %s\n", folder_id);
-// _DEBUG_INFO("[da_call-log_plugIn] changepoint : %d\n", changepoint);
-//
-// sync_agent_plugin_item_node_s *root_ptr = 0;
-// sync_agent_plugin_item_node_s *cursor_ptr = 0;
-// int chagned_count = 0;
-// int current_time = time(NULL);
-//
-// CTSiter *iter = NULL;
-// CTSvalue *plog = NULL; /*plog_list */
-//
-// char *calllog_id_str = NULL;
-//
-// int result = contacts_svc_get_list(CTS_LIST_ALL_PLOG, &iter);
-// _DEBUG_INFO("result = %d", result);
-// while (CTS_SUCCESS == contacts_svc_iter_next(iter)) {
-//
-// /* get call log */
-// plog = contacts_svc_iter_get_info(iter);
-// if (plog == NULL)
-// continue;
-//
-// /*check that item is within 7 days before since at the time */
-// if (current_time - CALLOG_SYNC_PERIODIC <= contacts_svc_value_get_int(plog, CTS_LIST_PLOG_LOG_TIME_INT)) {
-// calllog_id_str = g_strdup_printf("%d", contacts_svc_value_get_int(plog, CTS_LIST_PLOG_ID_INT));
-// _DEBUG_INFO("calllog_id_str = %s", calllog_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 = calllog_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 = calllog_id_str;
-// cursor_ptr->next->next = 0;
-// cursor_ptr = cursor_ptr->next;
-// }
-//
-// chagned_count++;
-//
-// /* memory free */
-// if (plog != NULL) {
-// contacts_svc_value_free(plog);
-// plog = NULL;
-// }
-// }
-// }
-//
-// if (iter != NULL) {
-// contacts_svc_iter_remove(iter);
-// iter = 0;
-// _DEBUG_INFO("[da_contact_plugIn] contacts_svc_iter_remove !! \n");
-// }
-//
-// *changeCount = chagned_count;
- _DEBUG_INFO("[da_call-log_plugIn] account_id : %d\n", account_id);
- _DEBUG_INFO("[da_call-log_plugIn] folder_id : %s\n", folder_id);
- _DEBUG_INFO("[da_call-log_plugIn] changepoint : %d\n", changepoint);
+ _DEBUG_INFO("[da_call-log_plugIn] account_id : [%d]", account_id);
+ _DEBUG_INFO("[da_call-log_plugIn] folder_id : [%s]", folder_id);
+ _DEBUG_INFO("[da_call-log_plugIn] changepoint : [%d]", changepoint);
sync_agent_plugin_item_node_s *root_ptr = 0;
sync_agent_plugin_item_node_s *cursor_ptr = 0;
err = contacts_db_get_all_records(_contacts_phone_log._uri, 0, 0, &list);
if (err != CONTACTS_ERROR_NONE) {
- _DEBUG_ERROR("[da_call_log_plugIn] contacts_db_get_all_records fail\n");
+ _DEBUG_ERROR("[da_call_log_plugIn] contacts_db_get_all_records() fail, err[%d]", err);
+ err = contacts_list_destroy(list, true);
+ if (err != CONTACTS_ERROR_NONE) {
+ _DEBUG_ERROR("[da_call_log_plugIn] contacts_list_destroy() fail, err[%d]", err);
+ }
return NULL;
}
err = contacts_list_first(list);
while (err == CONTACTS_ERROR_NONE) {
-
contacts_record_h record = NULL;
/* get call log */
err = contacts_list_get_current_record_p(list, &record);
if (err != CONTACTS_ERROR_NONE) {
- _DEBUG_ERROR("[da_call_log_plugIn] contacts_db_get_all_records fail\n");
+ _DEBUG_ERROR("[da_call_log_plugIn] contacts_list_get_current_record_p() fail, err[%d]", err);
continue;
}
contacts_record_get_int(record, _contacts_phone_log.id, &calllog_id);
calllog_id_str = g_strdup_printf("%d", calllog_id);
- _DEBUG_INFO("calllog_id_str = %s", calllog_id_str);
+ _DEBUG_INFO("[da_call_log_plugIn] Calllog_id_str = [%s]", calllog_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 !!!");
+ _DEBUG_ERROR("[da_call_log_plugIn] Calloc failed, root_ptr is NULL");
+ err = contacts_list_destroy(list, true);
+ if (err != CONTACTS_ERROR_NONE) {
+ _DEBUG_ERROR("[da_call_log_plugIn] contacts_list_destroy() fail, err[%d]", err);
+ }
return NULL;
}
root_ptr->item_id = calllog_id_str;
} 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 !!!");
+ _DEBUG_ERROR("[da_call_log_plugIn] Calloc failed, cursor_ptr->next is NULL");
+ err = contacts_list_destroy(list, true);
+ if (err != CONTACTS_ERROR_NONE) {
+ _DEBUG_ERROR("[da_call_log_plugIn] contacts_list_destroy() fail, err[%d]", err);
+ }
+ if (root_ptr != NULL) {
+ free(root_ptr);
+ root_ptr = NULL;
+ }
return NULL;
}
cursor_ptr->next->item_id = calllog_id_str;
err = contacts_list_next(list);
}
- contacts_list_destroy(list, true);
+ err = contacts_list_destroy(list, true);
+ if (err != CONTACTS_ERROR_NONE) {
+ _DEBUG_ERROR("[da_call_log_plugIn] contacts_list_destroy() fail, err[%d]", err);
+ }
*changeCount = chagned_count;
_EXTERN_FUNC_EXIT;
-
return root_ptr;
}
static sync_agent_get_account_id_list_cb_plugin callback_get_account_id_list;
+static sync_agent_del_child_item_cb_plugin callback_delete_child_item;
+
static void _set_is_noti_from_me(int set_flag);
static int _get_is_noti_from_me(void);
{
_EXTERN_FUNC_ENTER;
-// sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
-// int err = contacts_svc_connect();
-// if (err < CTS_SUCCESS) {
-// _DEBUG_INFO("[da_contact_plugIn] in contact Fail!\n");
-// ret = _convert_service_error_to_common_error(err);
-// } else {
-// _DEBUG_INFO("[da_contact_plugIn] in contact Success!\n");
-// }
-
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
contacts_error_e err = contacts_connect2();
if (err != CONTACTS_ERROR_NONE) {
_DEBUG_ERROR("[da_contact_plugIn] in contact Fail!\n");
}
_EXTERN_FUNC_EXIT;
-
return ret;
}
{
_EXTERN_FUNC_ENTER;
-// sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
-// int err = contacts_svc_disconnect();
-// if (err < CTS_SUCCESS) {
-// _DEBUG_INFO("[da_contact_plugIn] in contact Fail!\n");
-// ret = _convert_service_error_to_common_error(err);
-// } else {
-// _DEBUG_INFO("[da_contact_plugIn] in contact Success!\n");
-// }
-
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
contacts_error_e err = contacts_disconnect2();
if (err != CONTACTS_ERROR_NONE) {
_DEBUG_ERROR("[da_contact_plugIn] in contact Fail!\n");
}
_EXTERN_FUNC_EXIT;
-
return ret;
}
{
_EXTERN_FUNC_ENTER;
-// retvm_if(folder_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;
-//
-// /* add item */
-// err = contacts_svc_insert_contact(atoi(folder_id), (CTSstruct *)item);
-// if (err < CTS_SUCCESS) {
-// _DEBUG_INFO("[da_contact_plugIn] contacts_svc_insert_contact() Fail!\n");
-// ret = _convert_service_error_to_common_error(err);
-// *item_id = 0;
-// } else {
-// _DEBUG_INFO("[da_contact_plugIn] contacts_svc_insert_contact() Success!\n");
-// *item_id = g_strdup_printf("%d", err);
-// 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, "item_id is NULL. FAIL !!!");
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
contacts_record_destroy(record, true);
_EXTERN_FUNC_EXIT;
-
return ret;
}
{
_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;
-// CTSstruct *item = 0;
-//
-// /* get item */
-// int contact_id = atoi(item_id);
-// _DEBUG_INFO("[da_contact_plugIn] contact_id : %d\n", contact_id);
-// err = contacts_svc_get_contact(contact_id, &item);
-// if (err < CTS_SUCCESS) {
-// _DEBUG_INFO("[da_contact_plugIn] contacts_svc_get_contact() Fail!\n");
-// ret = _convert_service_error_to_common_error(err);
-// *data = 0;
-// } else {
-// _DEBUG_INFO("[da_contact_plugIn] contacts_svc_get_contact() Success!\n");
-// *data = (void *)item;
-// }
-
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;
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 = contacts_svc_delete_addressbook(atoi(folder_id));
-// if (err < CTS_SUCCESS) {
-// _DEBUG_INFO("[da_contact_plugIn] contacts_svc_delete_addressbook(%s) Fail!\n", folder_id);
-// ret = _convert_service_error_to_common_error(err);
-// } else {
-// _DEBUG_INFO("[da_contact_plugIn] contacts_svc_delete_addressbook(%s) Success!\n", folder_id);
-// is_storage_changed = 1;
-// }
-
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
contacts_error_e err = CONTACTS_ERROR_NONE;
{
_EXTERN_FUNC_ENTER;
- _DEBUG_INFO("[da_contact_plugIn] Start\n");
-
-// int ret = SYNC_AGENT_DA_SUCCESS;
-// int used_cnt = contacts_svc_count(CTS_GET_ALL_CONTACT);
-// if (used_cnt < 0) {
-// _DEBUG_INFO("[da_contact_plugIn] contact_svc_count() Fail\n");
-// ret = _convert_service_error_to_common_error(used_cnt);
-// } else {
-// _DEBUG_INFO("[da_contact_plugIn] contact_svc_count() Success\n");
-// _DEBUG_INFO("[da_contact_plugIn] used_count = %d\n", used_cnt);
-// ret = used_cnt;
-// }
-
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
contacts_error_e err = CONTACTS_ERROR_NONE;
int used_cnt = 0;
retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "folder_id is NULL. FAIL !!!");
- _DEBUG_INFO("[da_contact_plugIn] Start\n");
-
-// int ret = SYNC_AGENT_DA_SUCCESS;
-// int used_cnt = contacts_svc_count_with_int(CTS_GET_COUNT_CONTACTS_IN_ADDRESSBOOK, atoi(folder_id));
-// if (used_cnt < 0) {
-// _DEBUG_INFO("[da_contact_plugIn] contacts_svc_count_with_int(%s) Fail\n", folder_id);
-// ret = _convert_service_error_to_common_error(used_cnt);
-// } else {
-// _DEBUG_INFO("[da_contact_plugIn] contacts_svc_count_with_int(%s) Success\n", folder_id);
-// _DEBUG_INFO("[da_contact_plugIn] used_count = %d\n", used_cnt);
-// ret = used_cnt;
-// }
-
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
contacts_error_e err = CONTACTS_ERROR_NONE;
int used_cnt = 0;
{
_EXTERN_FUNC_ENTER;
-// char **folder_id_list = 0;
-// *folder_count = 0;
-// CTSiter *iter_addressbook = 0;
-// CTSvalue *addressbook = 0;
-//
-// if (account_id == -1) {
-// folder_id_list = (char **)calloc(1, sizeof(char *));
-// if( folder_id_list == NULL ) {
-// _DEBUG_ERROR("CALLOC failed !!!");
-// return NULL;
-// }
-// *folder_type_list = (int *)calloc(1, sizeof(int));
-// if( *folder_type_list == NULL ) {
-// _DEBUG_ERROR("CALLOC failed !!!");
-// return NULL;
-// }
-//
-// folder_id_list[0] = "0";
-// *folder_count = 1;
-// (*folder_type_list)[0] = DEFAULT_CONTACT_FOLDER;
-//
-// return folder_id_list;
-// }
-//
-// folder_id_list = (char **)calloc(50, sizeof(char *));
-// if( folder_id_list == NULL ) {
-// _DEBUG_ERROR("CALLOC failed !!!");
-// return NULL;
-// }
-// *folder_type_list = (int *)calloc(50, sizeof(int));
-// if( *folder_type_list == NULL ) {
-// _DEBUG_ERROR("CALLOC failed !!!");
-// return NULL;
-// }
-//
-// int err = contacts_svc_get_list_with_int(CTS_LIST_ADDRESSBOOKS_OF_ACCOUNT_ID, account_id, &iter_addressbook);
-// err = contacts_svc_iter_next(iter_addressbook);
-// while (err == CTS_SUCCESS) {
-// addressbook = contacts_svc_iter_get_info(iter_addressbook);
-// if (addressbook != NULL) {
-// int addressbook_id = 0;
-// addressbook_id = contacts_svc_value_get_int(addressbook, CTS_LIST_ADDRESSBOOK_ID_INT);
-// char *str_addressbook_id = g_strdup_printf("%d", addressbook_id);
-// _DEBUG_INFO("[da_contact_plugIn] addressbook_id : %d\n", addressbook_id);
-//
-// folder_id_list[*folder_count] = str_addressbook_id;
-// (*folder_type_list)[*folder_count] = DEFAULT_CONTACT_FOLDER;
-// *folder_count = *folder_count + 1;
-//
-// if (addressbook != NULL)
-// contacts_svc_value_free(addressbook);
-//
-// err = contacts_svc_iter_next(iter_addressbook);
-// } else {
-// _DEBUG_INFO("[da_contact_plugIn] contacts_svc_iter_get_info() Fail!\n");
-// break;
-// }
-// }
-//
-// /* memory free */
-// if (iter_addressbook != NULL) {
-// contacts_svc_iter_remove(iter_addressbook);
-// _DEBUG_INFO("[da_contact_plugIn] contacts_svc_iter_remove !! \n");
-// }
-
char **folder_id_list = 0;
*folder_count = 0;
{
_EXTERN_FUNC_ENTER;
-// contacts_svc_begin_trans();
-// int contactVersion = contacts_svc_end_trans(1);
-
int contactVersion;
contacts_db_get_current_version(&contactVersion);
_EXTERN_FUNC_EXIT;
-
return contactVersion;
}
_EXTERN_FUNC_EXIT;
}
+EXPORT_API void sync_agent_plugin_set_callback_delete_child_item(sync_agent_del_child_item_cb_plugin callback)
+{
+ _EXTERN_FUNC_ENTER;
+ callback_delete_child_item = callback;
+ _EXTERN_FUNC_EXIT;
+}
+
EXPORT_API int sync_agent_plugin_get_max_item_count(int folder_type)
{
_EXTERN_FUNC_ENTER;
if (sync_agent_async_queue_length(queue) < 1) {
sync_agent_send_msg_async_queue(queue, (void *)contactVersion);
_DEBUG_TRACE("fw_async_queue_length = %d", sync_agent_async_queue_length(queue));
+ } else {
+ _DEBUG_INFO("send_msg_failed... sync_agent_async_queue_length(queue) >= 1");
+ if(contactVersion != NULL) {
+ free(contactVersion);
+ contactVersion = NULL;
+ }
}
_INNER_FUNC_EXIT;
{
_DEBUG_TRACE("[da_contact_plugIn] CTS_OPERATION_INSERTED\n");
- int result = callback_add_item(accountList[i], i, contact_id_str, FW_CONTACT, str_addressbook_id, 0);
+ int result = callback_add_item(accountList[i], i, contact_id_str, NULL, FW_CONTACT, str_addressbook_id, 0);
_DEBUG_TRACE("[da_contact_plugIn] ===1\n");
if (!result)
_DEBUG_ERROR("[da_contact_plugIn] Failed to call callback_add_item() \n");
_DEBUG_TRACE("[da_contact_plugIn] CTS_OPERATION_UPDATED\n");
_DEBUG_TRACE("[da_contact_plugIn] contact_id : %s\n", contact_id_str);
- int result = callback_update_item(accountList[i], i, contact_id_str, FW_CONTACT);
+ int result = callback_update_item(accountList[i], i, contact_id_str, NULL, FW_CONTACT);
if (!result)
_DEBUG_ERROR("[da_contact_plugIn] Failed to call callback_update_item() \n");
}
case LIBCURL_HTTP_POST:
curl_easy_setopt(curl, CURLOPT_POST, 1L);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, send_msg_length);
- curl_easy_setopt(curl, CURLOPT_POSTFIELDS, send_msg);
+ curl_easy_setopt(curl, CURLOPT_POSTFIELDS, (void*)send_msg);
break;
case LIBCURL_HTTP_PUT:
curl_easy_setopt(curl, CURLOPT_PUT, 1L);
static sync_agent_get_account_id_list_cb_plugin callback_get_accountidlist;
+static sync_agent_del_child_item_cb_plugin callback_delete_child_item;
+
static void _free_item_node(sync_agent_plugin_item_node_s * node);
static void _set_is_noti_from_me(int set_flag);
_EXTERN_FUNC_EXIT;
}
+EXPORT_API void sync_agent_plugin_set_callback_delete_child_item(sync_agent_del_child_item_cb_plugin callback)
+{
+ _EXTERN_FUNC_ENTER;
+ callback_delete_child_item = callback;
+ _EXTERN_FUNC_EXIT;
+}
+
/********************************** static function *******************************************/
static void _free_item_node(sync_agent_plugin_item_node_s * node)
}
pthread_t thread_process_change_id;
- pthread_create(&thread_process_change_id, 0, __rutine_memo_change, 0);
+ int status_thread_create = 0;
+ status_thread_create = pthread_create(&thread_process_change_id, 0, __rutine_memo_change, 0);
+ if(status_thread_create != 0) {
+ _DEBUG_WARNING("pthread_create [%d]", status_thread_create );
+ }
_INNER_FUNC_EXIT;
}
{
/* memo service is not supported folder */
_DEBUG_VERBOSE("[da_memo_plugIn] MEMO_OPERATION_ADD\n");
- result = callback_add_item(accountList[i], i, str_item_id, FW_MEMO, "0", 0);
+ result = callback_add_item(accountList[i], i, str_item_id, NULL, FW_MEMO, "0", 0);
if (!result) {
_DEBUG_ERROR("[da_memo_plugIn] Failed to call callback_add_item() \n");
goto DACI_FINISH;
case MEMO_OPERATION_UPDATE:
{
_DEBUG_VERBOSE("[da_memo_plugIn] MEMO_OPERATION_UPDATE\n");
- result = callback_update_item(accountList[i], i, str_item_id, FW_MEMO);
+ result = callback_update_item(accountList[i], i, str_item_id, NULL, FW_MEMO);
if (!result) {
_DEBUG_ERROR("[da_memo_plugIn] Failed to call callback_update_item() \n");
goto DACI_FINISH;
#ifndef SAMSUNG_DEVICE_INFO_H_
#define SAMSUNG_DEVICE_INFO_H_
+#define DEF_DEVDETAIL_FWV "db/SyncML/oma-dm-service/DevDetail/FwV"
+
char *slp_device_info_get_software_version();
char *slp_device_info_get_hardware_version();
char *slp_device_info_get_modem_version();
free(firmware_ver);
_DEBUG_INFO("firmware_version [%s]\n", firmware_version);
+ vconf_set_str(DEF_DEVDETAIL_FWV, firmware_version);
+
_EXTERN_FUNC_EXIT;
return firmware_version;
pmci_alarm_s *temp_add_data = (pmci_alarm_s *) add_data;
+
_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;
registered_wap_push_operation_cb(0, (void *)san_operation);
} else {
_DEBUG_ERROR("not registered registered_wap_push_operation_cb !!");
+ if(san_operation != NULL) {
+ free(san_operation);
+ san_operation = NULL;
+ }
}
_INNER_FUNC_EXIT;
#define LOG_TAG "PLUGIN_DA_TASK"
#endif
-#define FW_TASK 11
+#define FW_TASK 10
static sync_agent_util_async_queue_s *queue;
static sync_agent_get_account_id_list_cb_plugin callback_get_account_id_list;
+static sync_agent_del_child_item_cb_plugin callback_delete_child_item;
+
static void _set_is_noti_from_me(int set_flag);
static int __get_is_noti_from_me(void);
_INNER_FUNC_ENTER;
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
- int service_ret = 0;
+ int service_ret = CALENDAR_ERROR_NONE;
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_query_create() Fail!: err[%d]", service_ret);
+
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_filter_create() Fail!: err[%d]", service_ret);
+
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
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_filter_add_int() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_query_set_filter() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_query_set_projection() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_db_get_records_with_query() Fail!: err[%d]", service_ret);
+
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_list_get_count() Fail!: err[%d]", service_ret);
_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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_list_first() Fail!: err[%d]", service_ret);
- DACI_FINISH:
+ return_part:
+ ret = _convert_service_error_to_common_error(service_ret);
calendar_filter_destroy(filter);
calendar_query_destroy(query);
*item_list = list;
- return ret;
_INNER_FUNC_EXIT;
+ return ret;
}
static sync_agent_da_return_e _get_service_folder_list_by_account_id(int account_id, calendar_list_h * item_list, int *count)
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_query_create() Fail!: err[%d]", service_ret);
+
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_filter_create() Fail!: err[%d]", service_ret);
+
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
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_filter_add_int() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_query_set_filter() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_query_set_projection() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_db_get_records_with_query() Fail!: err[%d]", service_ret);
+
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_list_get_count() Fail!: err[%d]", service_ret);
_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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_list_first() Fail!: err[%d]", service_ret);
- DACI_FINISH:
+ return_part:
+ ret = _convert_service_error_to_common_error(service_ret);
calendar_filter_destroy(filter);
calendar_query_destroy(query);
*item_list = list;
- return ret;
_INNER_FUNC_EXIT;
+ return ret;
}
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");
+ _DEBUG_ERROR("[task] calendar_connect Fail!\n");
ret = _convert_service_error_to_common_error(err);
} else {
- _DEBUG_INFO("[da_task_plugIn] calendar_connect Success!\n");
+ _DEBUG_INFO("[task] calendar_connect Success!\n");
}
_EXTERN_FUNC_EXIT;
-
return ret;
}
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");
+ _DEBUG_ERROR("[task] calendar_disconnect Fail!\n");
ret = _convert_service_error_to_common_error(err);
} else {
- _DEBUG_INFO("[da_task_plugIn] calendar_disconnect Success!\n");
+ _DEBUG_INFO("[task] calendar_disconnect Success!\n");
}
_EXTERN_FUNC_EXIT;
-
return ret;
}
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);
+ _DEBUG_INFO("[task] 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);
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);
+ _DEBUG_INFO("[task] calendar_svc_struct_set_int(folder %d) return [%d]!\n", atoi(folder_id), service_ret);
/* add item */
int slp_cal_info_id = 0;
*item_id = 0;
goto DACI_FINISH;
} else {
- _DEBUG_INFO("[da_task_plugIn] calendar_svc_insert() Success!");
+ _DEBUG_INFO("[task] 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;
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;
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+ int service_ret = CALENDAR_ERROR_NONE;
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;
- }
+ service_ret = calendar_record_set_int(item, _calendar_todo.calendar_book_id, int_folder_id);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_record_set_int() Fail!: err[%d]", service_ret);
/* 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;
- }
+ service_ret = calendar_db_update_record(item);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_db_update_record() Fail!: err[%d]", service_ret);
- /* memory free */
- DACI_FINISH:
- /* memory free */
+ _DEBUG_INFO("[task] calendar_svc_update() Success!");
+ is_storage_changed = 1;
+
+ return_part:
+ ret = _convert_service_error_to_common_error(service_ret);
if (item != NULL) {
- calendar_record_destroy(item, false);
- if (err != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("calendar_record_destroy() Fail! : err = %d", err);
+ service_ret = calendar_record_destroy(item, false);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_destroy() Fail! : service_ret = %d", service_ret);
}
item = NULL;
}
_EXTERN_FUNC_EXIT;
-
return ret;
}
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!");
+ _DEBUG_INFO("[task] calendar_svc_delete() Fail!");
ret = _convert_service_error_to_common_error(err);
} else {
- _DEBUG_INFO("[da_task_plugIn] calendar_svc_delete() Success!");
+ _DEBUG_INFO("[task] calendar_svc_delete() Success!");
is_storage_changed = 1;
}
/* 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);
+ _DEBUG_INFO("[task] folder id list cnt : %d", folder_id_list_cnt);
if (folder_type_list != NULL) {
cfree(folder_type_list);
folder_type_list = NULL;
}
+ if (folder_id_list != NULL) {
+ free(folder_id_list);
+ folder_id_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);
+ _DEBUG_INFO("[task] 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) {
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");
+ _DEBUG_ERROR("[task] 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");
+ _DEBUG_ERROR("[task] 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);
+ _DEBUG_INFO("[task] 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);
+ _DEBUG_ERROR("[task] 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);
+ _DEBUG_INFO("[task] calendar_svc_delete(%d) Success!\n", item_id);
is_storage_changed = 1;
}
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");
+ _DEBUG_INFO("[task] folder id free !! \n");
}
}
cfree(folder_id_list);
- _DEBUG_INFO("[da_task_plugIn] folder id list free !! \n");
+ _DEBUG_INFO("[task] folder id list free !! \n");
}
if (folder_type_list != NULL) {
cfree(folder_type_list);
/* 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");
+ _DEBUG_INFO("[task] 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");
+ _DEBUG_INFO("[task] calendar_svc_get() Success!\n");
*data = (void *)item;
}
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;
+ int service_ret = CALENDAR_ERROR_NONE;
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");
+ _DEBUG_INFO("[task] 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;
- }
+ service_ret = calendar_record_set_int(folder, _calendar_book.account_id, account_id);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_record_set_int() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_set_int(folder, _calendar_book.visibility, 1);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_record_set_int() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_set_str(folder, _calendar_book.name, folder_name);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_record_set_str() Fail!: err[%d]", service_ret);
/* 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);
+ service_ret = calendar_db_insert_record(folder, &service_folder_item_id);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_INFO("[task] calendar_svc_insert() Fail!\n");
*folder_id = 0;
} else {
- _DEBUG_INFO("[da_task_plugIn] calendar_svc_insert() Success!");
+ _DEBUG_INFO("[task] calendar_svc_insert() Success!");
*folder_id = g_strdup_printf("%d", service_folder_item_id);
is_storage_changed = 1;
}
- DACI_FINISH:
- /* memory free */
+
+ return_part:
+ ret = _convert_service_error_to_common_error(service_ret);
if (folder != NULL) {
calendar_record_destroy(folder, false);
- if (err != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("calendar_record_destroy() Fail! : err = %d", err);
+ if (service_ret != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_destroy() Fail! : service_ret = %d", service_ret);
}
folder = NULL;
}
/* 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);
+ _DEBUG_INFO("[task] 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!");
+ _DEBUG_INFO("[task] calendar_svc_delete() Success!");
calendar_db_clean_after_sync(atoi(folder_id), 0);
is_storage_changed = 1;
}
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);
+ _DEBUG_INFO("[task] 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");
+ _DEBUG_INFO("[task] 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");
+ goto return_part;
+ }
+
+ _DEBUG_INFO("[task] contacts_svc_get_addressbook() Success!\n");
+
+ *out_folder_name = 0;
+ err = calendar_record_get_str(folder, _calendar_book.name, out_folder_name);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_INFO("[task] calendar_record_get_str() Fail!\n");
+ ret = _convert_service_error_to_common_error(err);
*out_folder_name = 0;
- calendar_record_get_str(folder, _calendar_book.name, out_folder_name);
- *out_folder_type = DEFAULT_CALENDAR_FOLDER;
+ *out_folder_type = -1;
+ goto return_part;
}
- /* memory free */
+ *out_folder_type = DEFAULT_CALENDAR_FOLDER;
+
+return_part:
if (folder != NULL) {
calendar_record_destroy(folder, false);
if (err != CALENDAR_ERROR_NONE) {
folder = NULL;
}
_EXTERN_FUNC_EXIT;
-
return ret;
}
{
_EXTERN_FUNC_ENTER;
- _DEBUG_INFO("[da_task_plugIn] service is not supported execute. \n");
+ _DEBUG_INFO("[task] service is not supported execute. \n");
*result = 0;
_EXTERN_FUNC_EXIT;
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");
+ _DEBUG_ERROR("[task] 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);
+ _DEBUG_INFO("[task] calendar_db_get_count() Success\n");
+ _DEBUG_INFO("[task] used_count = %d\n", used_cnt);
}
if (filter != NULL)
calendar_query_destroy(query);
_EXTERN_FUNC_EXIT;
-
return used_cnt;
}
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;
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;
+ folder_id_list = NULL;
+ goto return_part;
}
+
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;
+ goto return_part;
}
*folder_type_list = (int *)calloc(count, sizeof(int));
if (*folder_type_list == NULL) {
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;
+ goto return_part;
}
- /* 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);
+ int int_folder_id = 0;
+ calendar_record_h todo = NULL;
+ err = calendar_record_create(_calendar_todo._uri, &todo);
+ if ((err != CALENDAR_ERROR_NONE) && (todo == NULL)) {
+ _DEBUG_ERROR("calendar_record_create() Fail! : err = %d", err);
+ break;
+ }
+
+ err = calendar_record_get_int(todo, _calendar_todo.calendar_book_id, &int_folder_id);
+ if (err != CALENDAR_ERROR_NONE) {
+ _DEBUG_ERROR("calendar_record_get_int() 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);
}
+
+return_part:
+ _DEBUG_INFO("return_part");
if (service_folder_list != NULL) {
err = calendar_list_destroy(service_folder_list, true);
if (err != CALENDAR_ERROR_NONE) {
service_folder_list = NULL;
}
_EXTERN_FUNC_EXIT;
-
return folder_id_list;
}
{
_EXTERN_FUNC_ENTER;
- _DEBUG_INFO("[da_task_plugIn] start!!\n");
+ _DEBUG_INFO("[task] start!!\n");
int error_code = account_connect();
error_code = account_disconnect();
- _DEBUG_INFO("[da_task_plugIn] end!!\n");
+ _DEBUG_INFO("[task] end!!\n");
_EXTERN_FUNC_EXIT;
{
_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;
+ _DEBUG_INFO("[task] account_id : %d\n", account_id);
+ _DEBUG_INFO("[task] folder_id : %s\n", folder_id);
+ _DEBUG_INFO("[task] changepoint : %d\n", changepoint);
int taskTimeStamp = changepoint;
int current_change_point = 0;
int temp_folder_id = atoi(folder_id);
- int service_ret = 0;
+ int service_ret = CALENDAR_ERROR_NONE;
sync_agent_plugin_item_node_s *root_ptr = 0;
sync_agent_plugin_item_node_s *cursor_ptr = 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;
- }
+ _DEBUG_INFO("[task] 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);
+ goto_if((service_ret != CALENDAR_ERROR_NONE) && (service_changed_list == NULL), "[task] calendar_db_get_changes_by_version() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_list_get_count() Fail!: err[%d]", service_ret);
- _DEBUG_INFO("[da_task_plugIn] in calendar_list_get_count [%d]!", list_count);
+ _DEBUG_INFO("[task] 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;
+ goto return_part;
}
- _DEBUG_INFO("[da_task_plugIn] calendar_svc_iter_next service_ret : %d\n", service_ret);
+ service_ret = calendar_list_first(service_changed_list);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_list_first() Fail!: err[%d]", 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;
- }
+ goto_if((service_ret != CALENDAR_ERROR_NONE) && (changed_task == NULL), "[task] calendar_list_get_current_record_p() Fail!: err[%d]", service_ret);
+
int type = 0;
service_ret = calendar_record_get_int(changed_task, _calendar_updated_info.modified_status, &type);
if (service_ret != CALENDAR_ERROR_NONE) {
break;
}
- _DEBUG_INFO("[da_task_plugIn] type is [%d]", type);
+ _DEBUG_INFO("[task] 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);
_DEBUG_ERROR("calendar_record_get_int() Fail!: err = %d", service_ret);
break;
}
- _DEBUG_INFO("[da_task_plugIn] calendar id is [%d]", task_id);
+ _DEBUG_INFO("[task] 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);
+ _DEBUG_INFO("[task] 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 !!!");
+ if (service_changed_list != NULL) {
+ calendar_list_destroy(service_changed_list, true);
+ service_changed_list = NULL;
+ }
return NULL;
}
root_ptr->item_id = task_id_str;
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 !!!");
+ if (service_changed_list != NULL) {
+ calendar_list_destroy(service_changed_list, true);
+ service_changed_list = NULL;
+ }
+ if (root_ptr) {
+ free(root_ptr);
+ root_ptr = NULL;
+ }
return NULL;
}
cursor_ptr->next->item_id = task_id_str;
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:
-
+ return_part:
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;
}
{
_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);
+ _DEBUG_INFO("[task] account_id : %d\n", account_id);
+ _DEBUG_INFO("[task] folder_id : %s\n", folder_id);
+ _DEBUG_INFO("[task] 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;
+ int service_ret = CALENDAR_ERROR_NONE;
+
sync_agent_plugin_item_node_s *root_ptr = 0;
sync_agent_plugin_item_node_s *cursor_ptr = 0;
int chagned_count = 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;
- }
+ _DEBUG_INFO("[task] 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);
+ goto_if((service_ret != CALENDAR_ERROR_NONE) && (service_changed_list == NULL), "[task] calendar_db_get_changes_by_version() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_list_get_count() Fail!: err[%d]", service_ret);
- _DEBUG_INFO("[da_task_plugIn] in calendar_list_get_count [%d]!", list_count);
+ _DEBUG_INFO("[task] in calendar_list_get_count [%d]!", list_count);
if (list_count <= 0) {
- goto DACI_FINISH;
+ goto return_part;
}
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);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_list_first() Fail!: err[%d]", 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;
- }
+ goto_if((service_ret != CALENDAR_ERROR_NONE) && (changed_task == NULL), "[task] calendar_list_get_current_record_p() Fail!: err[%d]", service_ret);
int type = 0;
service_ret = calendar_record_get_int(changed_task, _calendar_updated_info.modified_status, &type);
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);
+ _DEBUG_INFO("[task] 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 !!!");
+ if (service_changed_list != NULL) {
+ calendar_list_destroy(service_changed_list, true);
+ service_changed_list = NULL;
+ }
return NULL;
}
root_ptr->item_id = task_id_str;
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 !!!");
+ if (service_changed_list != NULL) {
+ calendar_list_destroy(service_changed_list, true);
+ service_changed_list = NULL;
+ }
+ if (root_ptr) {
+ free(root_ptr);
+ root_ptr = NULL;
+ }
return NULL;
}
cursor_ptr->next->item_id = task_id_str;
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:
-
+ return_part:
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;
}
{
_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;
+ _DEBUG_INFO("\n[task] account_id : %d\n", account_id);
+ _DEBUG_INFO("[task] folder_id : %s\n", folder_id);
+ _DEBUG_INFO("[task] changepoint : %d\n", change_point);
+
int task_time_stamp = change_point;
int temp_folder_id = atoi(folder_id);
- int service_ret = 0;
+ int service_ret = CALENDAR_ERROR_NONE;
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;
+ sync_agent_plugin_item_node_s *root_ptr = NULL;
+ sync_agent_plugin_item_node_s *cursor_ptr = NULL;
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;
- }
+ _DEBUG_INFO("[task] 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);
+ goto_if((service_ret != CALENDAR_ERROR_NONE) && (service_changed_list == NULL), "[task] calendar_db_get_changes_by_version() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_list_get_count() Fail!: err[%d]", service_ret);
- _DEBUG_INFO("[da_task_plugIn] in calendar_list_get_count [%d]!", list_count);
+ _DEBUG_INFO("[task] in calendar_list_get_count [%d]!", list_count);
if (list_count <= 0) {
- goto DACI_FINISH;
+ goto return_part;
}
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);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[task] calendar_list_first() Fail!: err[%d]", 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;
- }
+ goto_if((service_ret != CALENDAR_ERROR_NONE) && (changed_task == NULL), "[task] calendar_list_get_current_record_p() Fail!: err[%d]", service_ret);
+
int type = 0;
service_ret = calendar_record_get_int(changed_task, _calendar_updated_info.modified_status, &type);
if (service_ret != CALENDAR_ERROR_NONE) {
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);
+ _DEBUG_INFO("[task] 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 !!!");
+ if (service_changed_list != NULL) {
+ calendar_list_destroy(service_changed_list, true);
+ service_changed_list = NULL;
+ }
return NULL;
}
root_ptr->item_id = task_id_str;
- root_ptr->next = 0;
+ root_ptr->next = NULL;
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 !!!");
+ if (service_changed_list != NULL) {
+ calendar_list_destroy(service_changed_list, true);
+ service_changed_list = NULL;
+ }
+ if (root_ptr) {
+ free(root_ptr);
+ root_ptr = NULL;
+ }
return NULL;
}
cursor_ptr->next->item_id = task_id_str;
- cursor_ptr->next->next = 0;
+ cursor_ptr->next->next = NULL;
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:
-
+ return_part:
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;
}
_EXTERN_FUNC_EXIT;
}
+EXPORT_API void sync_agent_plugin_set_callback_delete_child_item(sync_agent_del_child_item_cb_plugin callback)
+{
+ _EXTERN_FUNC_ENTER;
+ callback_delete_child_item = callback;
+ _EXTERN_FUNC_EXIT;
+}
+
EXPORT_API int sync_agent_plugin_get_max_item_count(int folder_type)
{
_EXTERN_FUNC_ENTER;
_INNER_FUNC_ENTER;
if (pthread_mutex_lock(&lockx)) {
- _DEBUG_ERROR("[da_task_plugIn] pthread_mutex_lock error");
+ _DEBUG_ERROR("[task] pthread_mutex_lock error");
}
is_noti_from_me = set_flag;
if (pthread_mutex_unlock(&lockx)) {
- _DEBUG_ERROR("[da_task_plugIn] pthread_mutex_unlock error");
+ _DEBUG_ERROR("[task] pthread_mutex_unlock error");
}
_INNER_FUNC_EXIT;
{
_INNER_FUNC_ENTER;
- _DEBUG_TRACE("[da_task_plugIn] detected task storage changed\n");
+ _DEBUG_TRACE("[task] 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");
+ _DEBUG_TRACE("[task] This noti is from Me!! so will be ignored!!\n");
return;
}
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));
+ } else {
+ _DEBUG_INFO("send_msg_failed... sync_agent_async_queue_length(queue) >= 1");
+ if(taskVersion != NULL) {
+ free(taskVersion);
+ taskVersion = NULL;
+ }
}
_INNER_FUNC_EXIT;
{
_INNER_FUNC_ENTER;
- _DEBUG_TRACE("[da_task_plugIn] Start __rutine_task_Change (create thread)\n");
+ _DEBUG_TRACE("[task] Start __rutine_task_Change (create thread)\n");
/*
* Create Queue
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);
+ _DEBUG_TRACE("[task] task_account_id : %d, count : %d\n", task_account_id, account_list_count);
+ _DEBUG_TRACE("[task] Before calendar_svc_event_get_changes : %d\n", task_version);
/*get folder id */
int folder_list_count = 0;
_DEBUG_ERROR("calendar_list_get_count() Fail! : err = %d", service_ret);
break;
}
- _DEBUG_TRACE("[da_task_plugIn] folder_list_count : %d", folder_list_count);
+ _DEBUG_TRACE("[task] folder_list_count : %d", folder_list_count);
do {
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);
+ _DEBUG_TRACE("[task] task Inserted!\n");
+ _DEBUG_TRACE("[task] task folder id : %s\n", task_folder_id_str);
+ int result = callback_add_item(account_list[i], i, task_id_str, NULL, FW_TASK, task_folder_id_str, 0);
if (!result)
- _DEBUG_TRACE("[da_task_plugIn] Failed to call SA_EH_Add_Item() \n");
+ _DEBUG_TRACE("[task] Failed to call SA_EH_Add_Item() \n");
else
- _DEBUG_TRACE("[da_task_plugIn] Success to call SA_EH_Add_Item() \n");
+ _DEBUG_TRACE("[task] 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);
+ _DEBUG_TRACE("[task] task Updated!\n");
+ int result = callback_update_item(account_list[i], i, task_id_str, NULL, FW_TASK);
if (!result)
- _DEBUG_TRACE("[da_task_plugIn] Failed to call callback_del_item() \n");
+ _DEBUG_TRACE("[task] Failed to call callback_del_item() \n");
}
break;
case CALENDAR_EVENT_MODIFIED_STATUS_DELETED:
{
- _DEBUG_TRACE("[da_task_plugIn] task Deleted!\n");
+ _DEBUG_TRACE("[task] 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");
+ _DEBUG_TRACE("[task] Failed to call callback_del_item() \n");
}
break;
default:
- _DEBUG_TRACE("[da_task_plugIn] cached Another task Change Noti!\n");
+ _DEBUG_TRACE("[task] 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) {
}
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 */
+ } while (calendar_list_next(folder_list) != CALENDAR_ERROR_NO_DATA);
_DEBUG_TRACE("folder list free");
if (folder_list != NULL) {
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");
-
+ _DEBUG_TRACE("[task] End __rutine_task_Change (create thread)\n");
_INNER_FUNC_EXIT;
-
return 0;
}
_INNER_FUNC_ENTER;
sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
- _DEBUG_TRACE("[da_task_plugIn] Error Code : %d\n", err);
+ _DEBUG_TRACE("[task] Error Code : %d\n", err);
switch (err) {
+ case CALENDAR_ERROR_NONE:
+ ret = SYNC_AGENT_DA_SUCCESS;
+ break;
+
case CALENDAR_ERROR_INVALID_PARAMETER: /* -4 */
ret = SYNC_AGENT_DA_ERR_INVALID_CONTENT;
break;
}
_INNER_FUNC_EXIT;
-
return ret;
}
#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;
+typedef enum task_date_type {
+ TASK_DATE_TYPE_ONTIME = 0,
+ TASK_DATE_TYPE_YEAR,
+ TASK_DATE_TYPE_MONTH,
+ TASK_DATE_TYPE_WEEK,
+ TASK_DATE_TYPE_DAY,
+ TASK_DATE_TYPE_HOUR,
+ TASK_DATE_TYPE_MINUTE,
+ TASK_DATE_TYPE_SECOND,
+} task_date_type_e;
#define RRULE_KEYWORD "\r\nRRULE:"
#define RRULE_KEYWORD_FREQ_DAILY "\r\nRRULE:FREQ=DAILY"
#define RRULE_KEYWORD_BYMONTHDAY "BYMONTHDAY="
#define RRULE_KEYWORD_UNTIL "UNTIL="
#define RRULE_KEYWORD_COUNT "COUNT="
-#define DTSTART_KEYWORD "\r\nDTSTART"
+#define DTSTART_KEYWORD "\r\nDTSTART:"
#define DTEND_KEYWORD "\r\nDTEND"
#define BEGIN_ALARM_KEYWORD "\r\nBEGIN:VALARM"
+#define AALARM_KEYWORD "\r\nAALARM:"
#define END_VTODO_KEYWORD "\r\nEND:VTODO\r\n"
#define DUEDATE_KEYWORD "\r\nDUE:"
-#define MAX_RRULE_DATE_KEYWORD "20361231T000000Z"
+#define MAX_RRULE_DATE_KEYWORD "20361231T"
#define MAX_DUE_DATE_KEYWORD "\r\nDUE:20381231T000000Z\r\n" // refer to calendar info (min ~ max date)
+#define MAX_MOBEX_DTSTART_KEYWORD "\r\nDTSTART:20370101T090000Z"
+#define MAX_CALENDAR_DTSTART_KEYWORD "\r\nDTSTART:20381231T000000Z"
+#define WEEKDAY_RRULE_ORIGIN_KEYWORD "\r\nRRULE:W0 "
+#define WEEKDAY_RRULE_CONVERTED_KEYWORD "\r\nRRULE:W1 MO TU WE TH FR "
+#define TIMEZONE_GMT "Etc/GMT"
#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_PREFIX_SNOTE "X-SS-ATTACH-SNOTE;"
+#define IMAGE_KEYWORD_PREFIX_PHOTO "X-SS-ATTACH-IMAGE;"
+#define CR_IMAGE_KEYWORD_PREFIX_SNOTE "\r\nX-SS-ATTACH-SNOTE;"
+#define CR_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"
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);
+long long int get_unix_time(char *str_time);
+void set_timezone(const char *origin, calendar_record_h cal_record);
+void process_no_due_date(const char *origin, calendar_record_h cal_record);
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_rrule_data(char *origin);
char * replace_image_data(char *origin, char *image_path);
char * replace_priority_data(char *origin, bool is_phone_to_kies);
// 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_agent_data = replace_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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_list_first() Fail!: err[%d]", 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;
- }
+ goto_if((service_ret != CALENDAR_ERROR_NONE) || (temp_service_data == NULL), "[vcalendar-task] calendar_list_get_current_record_p() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_uri_p() Fail!: err[%d]", service_ret);
if (!strncmp(uri, _calendar_todo._uri, strlen(_calendar_todo._uri))) {
_DEBUG_INFO("this is todo");
} 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 */
- }
+ set_timezone(temp_agent_data, temp_service_data);
// 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);
- }
- }
+ process_no_due_date(temp_agent_data, temp_service_data);
// 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 ////////////////////////////
+ ///////////////////////////////////// S Note ////////////////////////////
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");
+ temp_image_path = get_value_by_token(image_path, SNOTE_MEMORY_ORIGIN, "=\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);
+ token = g_strdup_printf("%s=\r\n", temp_image_path);
+ goto_if(token == NULL, "token is NULL");
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);
+ image_path = g_strdup_printf("%s%s%s.png", SNOTE_MEMORY_ORIGIN, temp_image_path, temp);
+ goto_if(image_path == NULL, "image_path is NULL");
_DEBUG_INFO("image_path = %s", image_path);
}
- ///////////////////////////////////// S Note temporary code ////////////////////////////
+ ///////////////////////////////////// S Note ////////////////////////////
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);
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_create() 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);
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_set_str() Fail!: err[%d]", 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);
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_set_str() Fail!: err[%d]", 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);
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_add_child_record() Fail!: err[%d]", service_ret);
}
*service_data = (void *)temp_service_data;
- _DEBUG_INFO("calendar_vcalendar_parse_to_calendar() Success!\n");
return_part:
_DEBUG_INFO("return part");
temp = NULL;
}
+ ret = _convert_service_error_to_common_error(service_ret);
_EXTERN_FUNC_EXIT;
return ret;
}
/*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);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_int() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_set_int() Fail!: err[%d]", service_ret);
/*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);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_str_p() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_set_str() Fail!: err[%d]", service_ret);
/*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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_caltime() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_set_caltime() Fail!: err[%d]", service_ret);
/*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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_caltime() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_set_caltime() Fail!: err[%d]", service_ret);
/* 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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_str_p() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_set_str() Fail!: err[%d]", service_ret);
/* 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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_str_p() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_set_str() Fail!: err[%d]", service_ret);
+#if 0
/* rrule */
int num;
char *text = NULL;
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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ _DEBUG_ERROR("[vcalendar-task] calendar_record_set_int(wkst) Fail! err[%d]\n", service_ret);
return SYNC_AGENT_DA_ERRORS;
}
+#endif
/* alarm */
calendar_record_h new_alarm_record = NULL;
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_int() Fail!: err[%d]", service_ret);
_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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_int() Fail!: err[%d]", service_ret);
_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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_child_record_at_p() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_remove_child_record() Fail!: err[%d]", service_ret);
}
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_child_record_at_p() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_int() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_lli() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_int() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_int() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_str() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_int() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_create() Fail!: err[%d]", service_ret);
}
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_child_record_at_p() Fail!: err[%d]", service_ret);
}
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);
+ _DEBUG_ERROR("[vcalendar-task] 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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_set_int() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_set_lli() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_set_int() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_set_int() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_set_str() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_set_int() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_add_child_record() Fail!: err[%d]", service_ret);
}
}
/* image is not supported Outlook sync. So, image field should be not merged (2013/01/14 concept) */
-
+return_part:
+ ret = _convert_service_error_to_common_error(service_ret);
+ _DEBUG_INFO("ret = %d", ret);
_EXTERN_FUNC_EXIT;
return ret;
}
// 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_agent_data = replace_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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_child_record_count() Fail!: err[%d]", service_ret);
if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_list_first() Fail! : err[%d]", service_ret);
+ _DEBUG_ERROR("[vcalendar-task] 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;
- }
+ goto_if((service_ret != CALENDAR_ERROR_NONE) || (temp_new_service_data == NULL), "[vcalendar-task] calendar_list_get_current_record_p() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_uri_p() Fail!: err[%d]", service_ret);
_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);
+ _DEBUG_ERROR("[vcalendar-task] 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);
- }
- }
+ // 1. timezone setting : it should be excuted after calendar_vcalendar_parse_to_calendar
+ set_timezone(temp_agent_data, temp_old_service_data);
+
+ // 2. "no due date" setting : it should be excuted after calendar_vcalendar_parse_to_calendar
+ process_no_due_date(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-task_plugIn] calendar_record_get_str() Fail! : err[%d]", service_ret);
- goto return_part;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_str() Fail!: err[%d]", service_ret);
+
_DEBUG_INFO("key = %s", key);
if (strncmp(key, "VERSION", strlen("VERSION"))) {
_DEBUG_INFO("this is extended, not VCALENDAR:VERSION extend");
_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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_list_create() Fail!: err[%d]", service_ret);
// 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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_create() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_set_str() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_set_str() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE || list == NULL, "[vcalendar-task] calendar_list_add() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE || list == NULL, "[vcalendar-task] calendar_list_add() Fail!: err[%d]", service_ret);
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);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_vcalendar_make_from_records() Fail!: err[%d]", service_ret);
- // 2. image converting : it should be excuted after calendar_vcalendar_make_from_records
+ // 1. 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
+ // 2. 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, "NO DUE DATE" vtodo has not "DUE:xxxxxx", but exceptively DUE should be added for alarm time setting at Kies
+ // 3. 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");
+ }
+
// 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");
+ if (strstr(temp_agent_data, MAX_CALENDAR_DTSTART_KEYWORD) != NULL) {
+ temp_agent_data = replace_string(temp_agent_data, MAX_CALENDAR_DTSTART_KEYWORD, MAX_MOBEX_DTSTART_KEYWORD);
}
- // 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");
+ // originally, vtodo has not DTSTART, but exceptively DTSTART should be added for alarm time setting at Kies
+ // 5. DTSTART insertconverting : it should be excuted after calendar_vcalendar_make_from_records
+ if (strstr(temp_agent_data, DTSTART_KEYWORD) == NULL) {
+ char *temp = g_strdup_printf("%s%s", MAX_MOBEX_DTSTART_KEYWORD, DUEDATE_KEYWORD);
+ if (temp != NULL)
+ temp_agent_data = replace_string(temp_agent_data, DUEDATE_KEYWORD, temp);
}
return_part:
_DEBUG_INFO("return_part");
+ ret = _convert_service_error_to_common_error(service_ret);
+ _DEBUG_INFO("ret = %d", ret);
+
*agent_data = (void *)temp_agent_data;
if (list != NULL) {
EXPORT_API void *sync_agent_plugin_alloc_object()
{
_EXTERN_FUNC_ENTER;
- _DEBUG_INFO("[dc_vcalendar-task_plugIn] not implement !!");
+ _DEBUG_INFO("[vcalendar-task] 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 !!");
+ _DEBUG_INFO("[vcalendar-task] 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 !!");
+ _DEBUG_INFO("[vcalendar-task] 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 !!");
+ _DEBUG_INFO("[vcalendar-task] not implement !!");
_EXTERN_FUNC_EXIT;
return 0;
}
char *str_interval = NULL;
char *str_period_until = NULL;
char *str_period_count = NULL;
- calendar_date_type_e cal_type = CALENDAR_DATE_TYPE_ONTIME;
+ task_date_type_e cal_type = TASK_DATE_TYPE_ONTIME;
if ((freq_loc = strstr(origin, RRULE_KEYWORD_FREQ_WEEKLY)) != NULL) {
_DEBUG_INFO("this is weekly data");
char *str_trigger = NULL;
char *str_customized_trigger = NULL;
char *str_interval = NULL;
- calendar_date_type_e cal_type = CALENDAR_DATE_TYPE_ONTIME;
+ task_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");
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);
+ char *new_agent_data = replace_string(origin, str_origin_alarm, str_new_alarm);
origin = NULL;
origin = new_agent_data;
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) {
+ if(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) {
+ else if(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 if((temp_alarm = strstr(str_trigger, "P")) != NULL) {
- if((temp_alarm2 = strstr(temp_alarm, "D")) != NULL) {
+ if(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) {
+ else if(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);
_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);
+ char *new_agent_data = replace_string(origin, str_origin_alarm, str_new_alarm);
origin = NULL;
origin = new_agent_data;
#endif
+// example) str_time = "20130124T000000Z" = 2013 01 24 T 00 00 00 Z
+long long int get_unix_time(char *str_time)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if(str_time == NULL, 0, "str_time is NULL");
+ _DEBUG_INFO("str_time = %s", str_time);
+
+ UCalendar *ucal = NULL;
+ 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,};
+
+ strncpy(str_year, str_time, 4);
+ strncpy(str_month, str_time + 4, 2);
+ strncpy(str_date, str_time + 4 + 2, 2);
+ strncpy(str_hour, str_time + 4 + 2 + 2 + 1, 2);
+ strncpy(str_minute, str_time + 4 + 2 + 2 + 1 + 2, 2);
+ strncpy(str_second, str_time + 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;
+
+ UErrorCode status = U_ZERO_ERROR;
+ UChar *tz_id = NULL;
+ tz_id = (UChar*)calloc(strlen("Etc/GMT") + 1, sizeof(UChar)); // GMT-0 base time setting
+
+ if (tz_id) {
+ ucal = ucal_open(tz_id, u_strlen(tz_id), uloc_getDefault(), UCAL_TRADITIONAL, &status);
+ u_uastrcpy(tz_id, "Etc/GMT");
+ }
+ else {
+ ucal = ucal_open(0, -1, uloc_getDefault(), UCAL_TRADITIONAL, &status);
+ }
+ goto_if(U_FAILURE(status), "ucal_open failed (%s)", u_errorName(status));
+
+ ucal_setAttribute(ucal, UCAL_LENIENT, 1);
+ ucal_setDateTime(ucal, year, month - 1, date, hour, minute, second, &status);
+ date_time = (ucal_getMillis(ucal, &status)/1000);
+ //_DEBUG_INFO("date_time = %lld", date_time);
+
+return_part:
+ _DEBUG_INFO("return_part");
+ if(ucal) {
+ ucal_close(ucal);
+ ucal = NULL;
+ }
+ if(tz_id) {
+ free(tz_id);
+ tz_id = NULL;
+ }
+ _INNER_FUNC_EXIT;
+ return date_time;
+}
+
+
char * get_value_by_token(const char *src, const char *token, const char *end_of_token)
{
_INNER_FUNC_ENTER;
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("token_loc = %s", token_loc);
+ _DEBUG_ERROR("token = %s", token);
+ _DEBUG_ERROR("str_temp = %s", str_temp);
_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;
- }
+ goto_if(str_output == NULL, "str_output is NULL");
+
memcpy(str_output, token_loc + strlen(token), ret_str_length);
}
}
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);
+ _DEBUG_ERROR("%s is not founed", src);
return origin;
}
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("top_length = %d", top_length);
+ _DEBUG_ERROR("middle_length = %d", middle_length);
+ _DEBUG_ERROR("down_length = %d", down_length);
_DEBUG_ERROR("new_str_length(%d) <= 0", new_str_length);
return origin;
}
return new_str;
}
-char * remove_timezone(char *origin)
+// PLM(P130408-0777) : In case of DTSTART / DTEND with zulu time ('Z'), GMT timezone should be set.
+EXPORT_API void set_timezone(const char *origin, calendar_record_h cal_record)
{
_INNER_FUNC_ENTER;
- retvm_if((origin == NULL || strlen(origin) <= 0), NULL, "origin is NULL");
-
- _DEBUG_INFO("origin = %s", origin);
+ retm_if(origin == NULL, "origin is NULL");
+ retm_if(cal_record == NULL, "cal_record is NULL");
- char *str_timezone = NULL;
- char *str_temp = NULL;
+ int service_ret = CALENDAR_ERROR_NONE;
+ char *temp = NULL;
+ char *str_start = 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, ":");
+ temp = strstr(origin, DTSTART_KEYWORD);
+ goto_if(temp == NULL, "origin has not DTSTART. origin = %s", origin);
- if (str_timezone)
- free(str_timezone);
- str_timezone = NULL;
- }
+ str_start = get_value_by_token(temp + 2, "DTSTART:", "\r\n");
+ goto_if(str_start == NULL, "str_start is NULL");
+ goto_if(str_start == NULL, "str_start is NULL. temp = %s", temp);
- 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 (strstr(str_start, "Z") != NULL) {
+ _DEBUG_INFO("GMT timezone setting");
+ service_ret = calendar_record_set_str(cal_record, _calendar_todo.start_tzid, TIMEZONE_GMT);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_set_str() Fail! : err[%d]", service_ret);
- if (str_timezone)
- free(str_timezone);
- str_timezone = NULL;
+ service_ret = calendar_record_set_str(cal_record, _calendar_todo.due_tzid, TIMEZONE_GMT);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_set_str() Fail! : err[%d]", service_ret);
}
- _DEBUG_INFO("origin = %s", origin);
+return_part:
+ if (str_start) {
+ free(str_start);
+ str_start = NULL;
+ }
_INNER_FUNC_EXIT;
- return origin;
+ return;
}
-void insert_allday_data(const char *origin, calendar_record_h calendar_record)
+EXPORT_API void process_no_due_date(const char *origin, calendar_record_h cal_record)
{
_INNER_FUNC_ENTER;
- retm_if((origin == NULL || strlen(origin) <= 0), "origin is NULL");
- retm_if(calendar_record == NULL, "calendar_record is NULL");
+ retm_if(origin == NULL, "origin is NULL");
+ retm_if(cal_record == NULL, "cal_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 (strstr((char *)origin, MAX_DUE_DATE_KEYWORD) != NULL) {
+ _DEBUG_INFO("no due date setting");
- if (strncmp(uri, _calendar_todo._uri, strlen(_calendar_todo._uri))) {
- _DEBUG_ERROR("this is not todo");
- goto return_part;
- }
+ calendar_time_s cal_time_end = { 0, };
+ service_ret = calendar_record_get_caltime(cal_record, _calendar_todo.due_time, &cal_time_end);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_caltime() Fail!: err[%d]", service_ret);
- calendar_time_s cal_time_start = { 0, };
- calendar_time_s cal_time_end = { 0, };
- int year = 0;
- int month = 0;
- int day = 0;
+ cal_time_end.type = CALENDAR_TIME_UTIME;
+ cal_time_end.time.utime = CALENDAR_TODO_NO_DUE_DATE;
+ service_ret = calendar_record_set_caltime(cal_record, _calendar_todo.due_time, cal_time_end);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_set_caltime() Fail!: err[%d]", service_ret);
- 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;
- }
+ int has_alarm = 0;
+ service_ret = calendar_record_get_int(cal_record, _calendar_todo.has_alarm, &has_alarm);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_int() Fail!: err[%d]", service_ret);
- char *start_date_loc = NULL;
- if ((start_date_loc = strstr(origin, DTSTART_KEYWORD)) == NULL) {
- _DEBUG_ERROR("start_date_loc is null");
- goto return_part;
- }
+ if (has_alarm == 1) {
+ char *start_date_loc = NULL;
+ if ((start_date_loc = strstr(origin, AALARM_KEYWORD)) != NULL) {
+ calendar_record_h new_alarm_record = NULL;
+ long long int utime = 0;
+ char *str_alarm = NULL;
- char str_year_start[5] = {0,};
- char str_month_start[3] = {0,};
- char str_date_start[3] = {0,};
+ str_alarm = get_value_by_token(start_date_loc+2, "AALARM:", "\r\n");
+ utime = get_unix_time(str_alarm);
+ if (str_alarm) {
+ free(str_alarm);
+ str_alarm = NULL;
+ }
- /* 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;
- }
+ service_ret = calendar_record_get_child_record_at_p(cal_record, _calendar_todo.calendar_alarm, 0, &new_alarm_record);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_get_child_record_at_p() Fail!: err[%d]", service_ret);
- char *end_date_loc = NULL;
- if ((end_date_loc = strstr(origin, DTEND_KEYWORD)) == NULL) {
- _DEBUG_ERROR("end_date_loc is null");
- goto return_part;
- }
+ service_ret = calendar_record_set_int(new_alarm_record, _calendar_alarm.tick_unit, CALENDAR_ALARM_TIME_UNIT_SPECIFIC);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_set_int() Fail!: err[%d]", service_ret);
- char str_year_end[5] = {0,};
- char str_month_end[3] = {0,};
- char str_date_end[3] = {0,};
+ service_ret = calendar_record_set_int(new_alarm_record, _calendar_alarm.type, CALENDAR_TIME_UTIME);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_set_int() Fail!: err[%d]", service_ret);
- /* 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;
+ service_ret = calendar_record_set_lli(new_alarm_record, _calendar_alarm.time, utime);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar-task] calendar_record_set_lli() Fail!: err[%d]", service_ret);
+ }
+ }
}
return_part:
return;
}
+
EXPORT_API char * has_image_import(const char *origin)
{
_INNER_FUNC_ENTER;
char *temp_image_path = NULL;
char *image_path = NULL;
+ _DEBUG_INFO("origin = %s", origin);
- if (strstr(origin, IMAGE_KEYWORD_PREFIX_PHOTO) == NULL && strstr(origin, IMAGE_KEYWORD_PREFIX_SNOTE) == NULL) {
+ if (strstr(origin, CR_IMAGE_KEYWORD_PREFIX_PHOTO) == NULL && strstr(origin, CR_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);
+ goto_if(temp_image_path == NULL, "temp_image_path is NULL");
if (strstr(temp_image_path, INTERNAL_MEMORY_CONVERTED) != NULL) {
image_path = replace_string(temp_image_path, INTERNAL_MEMORY_CONVERTED, INTERNAL_MEMORY_ORIGIN);
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;
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_uri_p() Fail!: err[%d]", service_ret);
_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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_child_record_count() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_child_record_at_p() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE || image_key == NULL || strlen(image_key) <= 0, "calendar_record_get_str_p() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE || image_path == NULL || strlen(image_path) <= 0, "calendar_record_get_str is failed(%d)", service_ret);
_DEBUG_INFO("image_path = %s", image_path);
continue;
}
return image_path;
}
-char * replace_max_rrule_data(char *origin)
+char * replace_rrule_data(char *origin)
{
_INNER_FUNC_ENTER;
retvm_if(origin == NULL, origin, "origin is NULL.");
char *str_old_rrule = NULL;
char *str_new_rrule = NULL;
- if ((temp = strstr(origin, RRULE_KEYWORD)) == NULL) {
+ temp = strstr(origin, RRULE_KEYWORD);
+ if (temp == 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");
+ // case 1 : weekdays rrule converting
+ if (strstr(origin, WEEKDAY_RRULE_ORIGIN_KEYWORD) != NULL) {
+ _DEBUG_INFO("this vcalendar has WEEKDAYS rrule data");
+
+ origin = replace_string(origin, WEEKDAY_RRULE_ORIGIN_KEYWORD, WEEKDAY_RRULE_CONVERTED_KEYWORD);
+ _DEBUG_INFO("AFTER origin = %s", origin);
goto return_part;
}
+ // case 2 : max rrule converting
+ str_old_rrule = get_value_by_token(temp+2, "RRULE:", "\r\n");// '2' means strlen("\r\n")
+ goto_if(str_old_rrule == NULL, "str_old_rrule is null");
+
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;
- }
+ goto_if(temp_rrule == NULL, "temp_rrule is null");
// 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);
+ str_new_rrule = g_strdup_printf("%s#0", temp_rrule);
+ goto_if(str_new_rrule == NULL, "str_new_rrule is null");
+ _DEBUG_INFO("str_new_rrule = %s", str_new_rrule);
+
origin = replace_string(origin, str_old_rrule, str_new_rrule);
return_part:
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;
}
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");
+ str_image_tag = strdup(IMAGE_KEYWORD_PREFIX_PHOTO);
}
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");
+ str_image_tag = strdup(IMAGE_KEYWORD_PREFIX_PHOTO);
}
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");
+ //str_image_tag = strdup(IMAGE_KEYWORD_PREFIX_SNOTE);
+ str_image_tag = strdup(IMAGE_KEYWORD_PREFIX_PHOTO);
}
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;
- }
+ goto_if(strstr(origin, END_VTODO_KEYWORD) == NULL, "this data is wrong format. origin = %s", origin);
- 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);
+ str_image_info = g_strdup_printf("\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);
+ goto_if(str_image_info == NULL, "str_image_info is null");
char *new_agent_data = replace_string(origin, END_VTODO_KEYWORD, str_image_info);
origin = NULL;
}
_INNER_FUNC_EXIT;
- _DEBUG_INFO("origin = %s", origin);
return origin;
}
return_part:
_INNER_FUNC_EXIT;
- _DEBUG_INFO("origin = %s", origin);
return origin;
}
typedef enum cal_exdate_type {
CALENDAR_EXDATE_TYPE_NONE = 0,
CALENDAR_EXDATE_TYPE_DELETED,
- CALENDAR_EXDATE_TYPE_UPDATED,
+ CALENDAR_EXDATE_TYPE_UPDATED_PARENT,
+ CALENDAR_EXDATE_TYPE_UPDATED_CHILD,
+ CALENDAR_EXDATE_TYPE_MAX,
} calendar_exdate_type_e;
typedef struct sync_agent_calendar_exdate_s sync_agent_calendar_exdate_t;
#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 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 MAX_RRULE_DATE_KEYWORD "20361231T"
+#define WEEKDAY_RRULE_ORIGIN_KEYWORD "\r\nRRULE:W0 "
+#define WEEKDAY_RRULE_CONVERTED_KEYWORD "\r\nRRULE:W1 MO TU WE TH FR "
+#define TIMEZONE_GMT "Etc/GMT"
+
+#define EXTYPE_UID_KEYWORD "\r\nUID:"
#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 CR_EXTYPE_UPDATE_KEYWORD "\r\nX-EXTYPE:2" // carrige return + EXTYPE_UPDATE_KEYWORD
#define IMPORT_EXTYPE_DELETE_KEYWORD "\r\nX-EXTYPE:1\r\nEXDATE:"
+#define IMPORT_EXTYPE_UPDATE_KEYWORD "\r\nX-EXTYPE:2\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_PREFIX_SNOTE "X-SS-ATTACH-SNOTE;"
+#define IMAGE_KEYWORD_PREFIX_PHOTO "X-SS-ATTACH-IMAGE;"
+#define CR_IMAGE_KEYWORD_PREFIX_SNOTE "\r\nX-SS-ATTACH-SNOTE;"
+#define CR_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"
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 set_timezone(const char *origin, calendar_record_h cal_record);
+char * remove_uid(char *origin);
+char * insert_exdate_data(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_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);
+void replace_deleted_exdate_data(const char *origin, calendar_record_h parent_record);
+int replace_updated_exdate_data(const char *origin, calendar_record_h parent_record);
#endif /* IN_VCALENDAR_STRING_UTIL_H_ */
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;
- 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);
+
+ _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_agent_data = replace_rrule_data(temp);
temp = NULL;
}
+ // 2. if the vcalendar has UID, remove it : it should be excuted before calendar_vcalendar_parse_to_calendar
+ if (strstr(temp_agent_data, EXTYPE_UID_KEYWORD) != NULL) {
+ temp = strdup(temp_agent_data);
+ temp_agent_data = remove_uid(temp);
+ temp = NULL;
+ _DEBUG_INFO("after remove_uid(), 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_plugIn] calendar_vcalendar_parse_to_calendar() Fail! err[%d]\n", service_ret);
+ _DEBUG_ERROR("[vcalendar] 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_plugIn] calendar_vcalendar_parse_to_calendar() -> temp_service_data is null, err[%d] !!", service_ret);
+ _DEBUG_ERROR("[vcalendar] 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);
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_list_first() Fail! : err[%d]", 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_plugIn] calendar_list_get_current_record_p() Fail! : err[%d]", service_ret);
- goto return_part;
- }
+ goto_if((service_ret != CALENDAR_ERROR_NONE) || (temp_service_data == NULL), "[vcalendar] calendar_list_get_current_record_p() Fail! : err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_uri_p() Fail! : err[%d]", service_ret);
if (!strncmp(uri, _calendar_event._uri, strlen(_calendar_event._uri))) {
_DEBUG_INFO("this is event");
} 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_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 */
- }
-
- 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 */
- }
+ set_timezone(temp_agent_data, temp_service_data);
// 2. "all day" setting : it should be excuted after calendar_vcalendar_parse_to_calendar
if (strstr((char *)agent_data, "\r\nX-ALLDAY:SET") != NULL) {
// 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 ////////////////////////////
+ ///////////////////////////////////// S Note ////////////////////////////
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");
+ temp_image_path = get_value_by_token(image_path, SNOTE_MEMORY_ORIGIN, "=\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);
+ token = g_strdup_printf("%s=\r\n", temp_image_path);
+ goto_if(token == NULL, "token is NULL");
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);
+ image_path = g_strdup_printf("%s%s%s.png", SNOTE_MEMORY_ORIGIN, temp_image_path, temp);
+ goto_if(image_path == NULL, "image_path is NULL");
_DEBUG_INFO("image_path = %s", image_path);
}
- ///////////////////////////////////// S Note temporary code ////////////////////////////
+ ///////////////////////////////////// S Note ////////////////////////////
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);
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_create() 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);
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail! : err[%d]", 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);
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail! : err[%d]", service_ret);
service_ret = calendar_record_add_child_record(temp_service_data, _calendar_event.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);
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_add_child_record() Fail! : err[%d]", service_ret);
}
*service_data = (void *)temp_service_data;
- _DEBUG_INFO("calendar_vcalendar_parse_to_calendar() Success!\n");
return_part:
_DEBUG_INFO("return part");
temp = NULL;
}
+ ret = _convert_service_error_to_common_error(service_ret);
_EXTERN_FUNC_EXIT;
return ret;
}
/*description */
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_str_p() Fail! err[%d]\n", service_ret);
- return SYNC_AGENT_DA_ERRORS;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_str_p() Fail!: err[%d]", service_ret);
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_str() Fail! err[%d]\n", service_ret);
- return SYNC_AGENT_DA_ERRORS;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail!: err[%d]", service_ret);
/* 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_caltime() Fail! err[%d]\n", service_ret);
- return SYNC_AGENT_DA_ERRORS;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_caltime() Fail!: err[%d]", service_ret);
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_caltime() Fail! err[%d]\n", service_ret);
- return SYNC_AGENT_DA_ERRORS;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_caltime() Fail!: err[%d]", service_ret);
/* 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_caltime() Fail! err[%d]\n", service_ret);
- return SYNC_AGENT_DA_ERRORS;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_caltime() Fail!: err[%d]", service_ret);
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_caltime() Fail! err[%d]\n", service_ret);
- return SYNC_AGENT_DA_ERRORS;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_caltime() Fail!: err[%d]", service_ret);
/* 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_str_p() Fail! err[%d]\n", service_ret);
- return SYNC_AGENT_DA_ERRORS;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_str_p() Fail!: err[%d]", service_ret);
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_str() Fail! err[%d]\n", service_ret);
- return SYNC_AGENT_DA_ERRORS;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail!: err[%d]", service_ret);
/* 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_str_p() Fail! err[%d]\n", service_ret);
- return SYNC_AGENT_DA_ERRORS;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_str_p() Fail!: err[%d]", service_ret);
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_str() Fail! err[%d]\n", service_ret);
- return SYNC_AGENT_DA_ERRORS;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail!: err[%d]", service_ret);
/* rrule */
int num = 0;
calendar_time_s caltime = {0};
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_int() Fail!: err[%d]", service_ret);
+ _DEBUG_INFO("new freq = %d", num);
+
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_int() Fail!: err[%d]", service_ret);
- 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;
- }
+ // in case of 'no rrule', below codes should be not executed
+ if (num != CALENDAR_RECURRENCE_NONE) {
+ _DEBUG_INFO("rrule should be overwrite");
+ service_ret = calendar_record_get_int(new_service_data, _calendar_event.range_type, &num);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_int() Fail!: err[%d]", service_ret);
- 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;
- }
+ service_ret = calendar_record_set_int(old_service_data, _calendar_event.range_type, num);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_int() Fail!: err[%d]", service_ret);
- 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;
- }
+ service_ret = calendar_record_get_caltime(new_service_data, _calendar_event.until_time, &caltime);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_caltime() Fail!: err[%d]", service_ret);
- 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;
- }
+ service_ret = calendar_record_set_caltime(old_service_data, _calendar_event.until_time, caltime);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_caltime() Fail!: err[%d]", service_ret);
- 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;
- }
+ service_ret = calendar_record_get_int(new_service_data, _calendar_event.count, &num);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_int() Fail!: err[%d]", service_ret);
- 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;
- }
+ service_ret = calendar_record_set_int(old_service_data, _calendar_event.count, num);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_int() Fail!: err[%d]", service_ret);
- 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;
- }
+ service_ret = calendar_record_get_int(new_service_data, _calendar_event.interval, &num);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_int() Fail!: err[%d]", service_ret);
- 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_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_set_int(old_service_data, _calendar_event.interval, num);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_int() Fail!: err[%d]", service_ret);
- 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.bysecond, &text);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_str() Fail!: err[%d]", service_ret);
- 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_record_set_str(old_service_data, _calendar_event.bysecond, text);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail!: err[%d]", service_ret);
- 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.byminute, &text);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_str() Fail!: err[%d]", service_ret);
- 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_set_str(old_service_data, _calendar_event.byminute, text);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail!: err[%d]", service_ret);
- 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_str(new_service_data, _calendar_event.byhour, &text);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_str() Fail!: err[%d]", service_ret);
- 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;
+ service_ret = calendar_record_set_str(old_service_data, _calendar_event.byhour, text);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_get_str(new_service_data, _calendar_event.byday, &text);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_str() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_set_str(old_service_data, _calendar_event.byday, text);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_get_str(new_service_data, _calendar_event.bymonthday, &text);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_str() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_set_str(old_service_data, _calendar_event.bymonthday, text);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_get_str(new_service_data, _calendar_event.byyearday, &text);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_str() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_set_str(old_service_data, _calendar_event.byyearday, text);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_get_str(new_service_data, _calendar_event.byweekno, &text);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_str() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_set_str(old_service_data, _calendar_event.byweekno, text);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_get_str(new_service_data, _calendar_event.bymonth, &text);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_str() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_set_str(old_service_data, _calendar_event.bymonth, text);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_get_str(new_service_data, _calendar_event.bysetpos, &text);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_str() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_set_str(old_service_data, _calendar_event.bysetpos, text);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_get_int(new_service_data, _calendar_event.wkst, &num);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_int() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_set_int(old_service_data, _calendar_event.wkst, num);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_int() Fail!: err[%d]", service_ret);
}
/* alarm */
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_int() Fail!: err[%d]", service_ret);
_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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_int() Fail!: err[%d]", service_ret);
_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_record_get_child_record_at_p() Fail! err[%d]\n", service_ret);
- return SYNC_AGENT_DA_ERRORS;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_child_record_at_p() Fail!: err[%d]", 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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_remove_child_record() Fail!: err[%d]", service_ret);
}
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_child_record_at_p() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_int() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_lli() Fail!: err[%d]", service_ret);
service_ret = calendar_record_get_int(new_alarm_record, _calendar_alarm.tick, &tick);
- if (service_ret != CALENDAR_ERROR_NONE) {
- _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_int(tick) Fail! err[%d]\n", service_ret);
- return SYNC_AGENT_DA_ERRORS;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_int() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_int() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_str() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_int() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_create() Fail!: err[%d]", service_ret);
}
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_child_record_at_p() Fail!: err[%d]", service_ret);
}
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);
+ _DEBUG_ERROR("[vcalendar] 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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_int() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_lli() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_int() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_int() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_int() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_add_child_record() Fail!: err[%d]", service_ret);
}
}
/* image is not supported Outlook sync. So, image field should be not merged (2013/01/14 concept) */
-
+return_part:
+ ret = _convert_service_error_to_common_error(service_ret);
+ _DEBUG_INFO("ret = %d", ret);
_EXTERN_FUNC_EXIT;
return ret;
}
_DEBUG_INFO("temp_agent_data = %s", temp_agent_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
+ // 1. if the vcalendar has EXTYPE, then this vcalendar has an EXDATE data : it should be excuted before calendar_vcalendar_parse_to_calendar
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;
- }
+ replace_deleted_exdate_data(temp_agent_data, temp_old_service_data);
+ _DEBUG_INFO("after replace_deleted_exdate_data(), it should be returned from this API");
+ *new_service_data = temp_old_service_data;
+ goto return_part;
}
- // 2. if the vcalendar has until : NONE rrule, then max rrule should be converted : it should be excuted before calendar_vcalendar_parse_to_calendar
+ // 2. if the vcalendar has UID, remove it : it should be excuted before calendar_vcalendar_parse_to_calendar
+ if (strstr(temp_agent_data, EXTYPE_UID_KEYWORD) != NULL) {
+ temp = strdup(temp_agent_data);
+ temp_agent_data = remove_uid(temp);
+ temp = NULL;
+ _DEBUG_INFO("after remove_uid(), temp_agent_data = %s", temp_agent_data);
+ }
+
+ // 3. 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_agent_data = replace_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_plugIn] calendar_vcalendar_parse_to_calendar() Fail! err[%d]\n", service_ret);
+ _DEBUG_ERROR("[vcalendar] calendar_vcalendar_parse_to_calendar() Fail! err[%d]\n", service_ret);
*new_service_data = NULL;
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);
- goto return_part;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_list_first() Fail!: err[%d]", service_ret);
- 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;
- }
+ goto_if((service_ret != CALENDAR_ERROR_NONE) || (temp_new_service_data == NULL), "[vcalendar] calendar_list_get_current_record_p() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_uri_p() Fail!: err[%d]", service_ret);
_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);
+ _DEBUG_ERROR("[vcalendar] calendar_record_set_int() Fail! err[%d]\n", ret);
}
// 1. "all day" setting : it should be excuted after calendar_vcalendar_parse_to_calendar
}
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;
- }
+ service_ret = calendar_record_get_str(temp_new_service_data, _calendar_extended_property.key, &key);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_str() Fail!: err[%d]", service_ret);
_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);
+
+ // 1. timezone setting : it should be excuted after calendar_vcalendar_parse_to_calendar
+ set_timezone(temp_agent_data, temp_old_service_data);
+
+ // 2. if the vcalendar has EXTYPE, then this vcalendar has an EXDATE data : it should be excuted after calendar_vcalendar_parse_to_calendar
+ // exdate update should be done after _vevent_merge_new_to_old because it's changed things apply to the temp_old_service_data
+ if (strstr(temp_agent_data, IMPORT_EXTYPE_UPDATE_KEYWORD) != NULL) {
+ int child_service_id = replace_updated_exdate_data(temp_agent_data, temp_old_service_data);
+ if ( child_service_id != -1) {
+ _DEBUG_INFO("replace_updated_exdate_data() success. in case of success, it should be returned from this API");
+ *new_service_data = g_strdup_printf("%d", child_service_id);
+ goto return_part;
+ }
+ }
+
*new_service_data = temp_old_service_data;
return_part:
_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;
- goto return_part;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_caltime() Fail!: err[%d]", service_ret);
// 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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_create() Fail!: err[%d]", service_ret);
+
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail!: err[%d]", service_ret);
+
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail!: err[%d]", service_ret);
+
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_add_child_record() Fail!: err[%d]", service_ret);
}
// 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;
- }
+ goto_if(exdate_struct == NULL, "exdate_struct is NULL");
+
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_create() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_list_create() Fail!: err[%d]", service_ret);
+
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_list_add() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_list_add() Fail!: err[%d]", service_ret);
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);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_str() Fail!: err[%d]", service_ret);
service_ret = calendar_vcalendar_make_from_records(list, &temp_agent_data);
_DEBUG_INFO("temp_agent_data = %s", temp_agent_data);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_vcalendar_make_from_records() Fail!: err[%d]", service_ret);
- 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
+ // 1. 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
+ // 2. exdate converting : after calendar_vcalendar_make_from_records
char *new_temp_agent_data = NULL;
- if (exdate_struct->exdate_type != CALENDAR_EXDATE_TYPE_NONE) {
+ if (exdate_struct->exdate_type == CALENDAR_EXDATE_TYPE_DELETED) {
int index=0;
int exdate_count = exdate_struct->exdate_count;
- _DEBUG_INFO("exdate_count = %d", exdate_count);
+ _DEBUG_INFO("deleted exdate_count = %d", exdate_count);
+ // 2-1. create child event based on parent event vcalendar
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);
+ goto_if(child_str == NULL, "child_str is NULL");
-
-
- new_temp_agent_data = (char *)calloc(2000, sizeof(char));
+ _DEBUG_INFO("index = %d, child_str = %s", index, child_str);
+ int child_str_length = strlen(child_str);
+ new_temp_agent_data = g_strdup_printf("%s%s%04d%s", temp_agent_data, "0000", child_str_length, child_str);
if (new_temp_agent_data == NULL) {
- _DEBUG_ERROR("new_temp_agent_data calloc failed");
+ _DEBUG_ERROR("new_temp_agent_data is null");
+ if (child_str) {
+ free(child_str);
+ child_str = NULL;
+ }
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;
}
+ if (child_str) {
+ free(child_str);
+ child_str = 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");
+ // 2-2. remove EXTYPE at parent event
+ if (strstr(temp_agent_data, CR_EXTYPE_DELETE_KEYWORD) != NULL) {
+ temp_agent_data = replace_string(temp_agent_data, CR_EXTYPE_DELETE_KEYWORD, "\r\nUID:000000000000000000000000000000000000000000000000");
}
- else
- ;//nothing, this vcalendar has not extype data.
- /*_DEBUG_INFO("temp_agent_data = %s", temp_agent_data);
+ // 2-3. remove EXDATE at parent event
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);
+ if ((new_str = strstr(old_str+2, "\r\nUID:")) != NULL) {
temp_agent_data = replace_string(temp_agent_data, old_str, new_str);
}
- }*/
-
-
-
-
+ }
_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);
- }
- else
- ;
+ }
+ else if (exdate_struct->exdate_type == CALENDAR_EXDATE_TYPE_UPDATED_PARENT) {
+ _DEBUG_INFO("CALENDAR_EXDATE_TYPE_UPDATED_PARENT start");
+ if (strstr(temp_agent_data, CR_EXTYPE_UPDATE_KEYWORD) != NULL) {
+ temp_agent_data = replace_string(temp_agent_data, CR_EXTYPE_UPDATE_KEYWORD, "\r\nUID:000000000000000000000000000000000000000000000000");
+ }
+ }
+ else if (exdate_struct->exdate_type == CALENDAR_EXDATE_TYPE_UPDATED_CHILD) {
+ _DEBUG_INFO("CALENDAR_EXDATE_TYPE_UPDATED_CHILD start");
+ temp_agent_data = insert_exdate_data(temp_agent_data, exdate_struct, 0);
+ if (strstr(temp_agent_data, CR_EXTYPE_UPDATE_KEYWORD) != NULL) {
+ temp_agent_data = replace_string(temp_agent_data, CR_EXTYPE_UPDATE_KEYWORD, "\r\nUID:000000000000000000000000000000000000000000000000\r\nX-EXTYPE:2");
}
-
- _DEBUG_INFO("aaaaaaaaaaaaa temp_agent_data = %s", temp_agent_data);
}
return_part:
_DEBUG_INFO("return_part");
+ ret = _convert_service_error_to_common_error(service_ret);
+ _DEBUG_INFO("ret = %d", ret);
+
*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);
+ if (list != NULL)
+ calendar_list_destroy(list, true);
+ if (exdate_struct) {
+ if (exdate_struct->exdate_list) {
+ g_list_free(exdate_struct->exdate_list);
+ exdate_struct->exdate_list = NULL;
}
+ free(exdate_struct);
+ exdate_struct = NULL;
}
- 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;
EXPORT_API void *sync_agent_plugin_alloc_object()
{
_EXTERN_FUNC_ENTER;
- _DEBUG_INFO("[dc_vcalendar_plugIn] not implement !!");
+ _DEBUG_INFO("[vcalendar] 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_plugIn] not implement !!");
+ _DEBUG_INFO("[vcalendar] 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_plugIn] not implement !!");
+ _DEBUG_INFO("[vcalendar] 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_plugIn] not implement !!");
+ _DEBUG_INFO("[vcalendar] not implement !!");
_EXTERN_FUNC_EXIT;
return 0;
}
#define EXPORT_API __attribute__ ((visibility("default")))
#endif
+
#if 0
// usage / rrule converting
if (strstr(temp_agent_data, "\r\nRRULE:") != NULL) {
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);
+ char *new_agent_data = replace_string(origin, str_origin_alarm, str_new_alarm);
origin = NULL;
origin = new_agent_data;
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) {
+ if(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) {
+ else if(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 if((temp_alarm = strstr(str_trigger, "P")) != NULL) {
- if((temp_alarm2 = strstr(temp_alarm, "D")) != NULL) {
+ if(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) {
+ else if(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);
_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);
+ char *new_agent_data = replace_string(origin, str_origin_alarm, str_new_alarm);
origin = NULL;
origin = new_agent_data;
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("token_loc = %s", token_loc);
+ _DEBUG_ERROR("token = %s", token);
+ _DEBUG_ERROR("str_temp = %s", str_temp);
_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;
- }
+ goto_if(str_output == NULL, "str_output is NULL");
+
memcpy(str_output, token_loc + strlen(token), ret_str_length);
}
}
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);
+ _DEBUG_ERROR("%s is not founed", src);
return origin;
}
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("top_length = %d", top_length);
+ _DEBUG_ERROR("middle_length = %d", middle_length);
+ _DEBUG_ERROR("down_length = %d", down_length);
_DEBUG_ERROR("new_str_length(%d) <= 0", new_str_length);
return origin;
}
return new_str;
}
-char * remove_timezone(char *origin)
+// PLM(P130408-0777) : In case of DTSTART / DTEND with zulu time ('Z'), GMT timezone should be set.
+EXPORT_API void set_timezone(const char *origin, calendar_record_h cal_record)
{
_INNER_FUNC_ENTER;
- retvm_if((origin == NULL || strlen(origin) <= 0), NULL, "origin is NULL");
+ retm_if(origin == NULL, "origin is NULL");
+ retm_if(cal_record == NULL, "cal_record is NULL");
- _DEBUG_INFO("origin = %s", origin);
+ int service_ret = CALENDAR_ERROR_NONE;
+ char *temp = NULL;
+ char *str_start = NULL;
- char *str_timezone = NULL;
- char *str_temp = NULL;
+ temp = strstr(origin, DTSTART_KEYWORD);
+ goto_if(temp == NULL, "origin has not DTSTART. origin = %s", origin);
- 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, ":");
+ str_start = get_value_by_token(temp + 2, "DTSTART:", "\r\n");
+ goto_if(str_start == NULL, "str_start is NULL. temp = %s", temp);
- if (str_timezone)
- free(str_timezone);
- str_timezone = NULL;
- }
+ if (strstr(str_start, "Z") != NULL) {
+ _DEBUG_INFO("GMT timezone setting");
+ service_ret = calendar_record_set_str(cal_record, _calendar_event.start_tzid, TIMEZONE_GMT);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail! : err[%d]", service_ret);
- 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, ":");
+ service_ret = calendar_record_set_str(cal_record, _calendar_event.end_tzid, TIMEZONE_GMT);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail! : err[%d]", service_ret);
+ }
- if (str_timezone)
- free(str_timezone);
- str_timezone = NULL;
+return_part:
+ if (str_start) {
+ free(str_start);
+ str_start = NULL;
}
+ _INNER_FUNC_EXIT;
+ return;
+}
+
+char * remove_uid(char *origin)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if((origin == NULL || strlen(origin) <= 0), NULL, "origin is NULL");
_DEBUG_INFO("origin = %s", origin);
+
+ char *str_uid = NULL;
+ char *str_uid_temp = NULL;
+ char *temp = NULL;
+
+ if ((temp = strstr(origin, EXTYPE_UID_KEYWORD)) == NULL) {
+ _DEBUG_ERROR("origin has not UID string");
+ goto return_part;
+ }
+
+ str_uid = get_value_by_token(temp+2, "UID:", "\r\n");
+ goto_if(str_uid == NULL, "str_uid is NULL");
+
+ str_uid_temp = g_strdup_printf("%s%s\r\n", EXTYPE_UID_KEYWORD, str_uid);
+ goto_if(str_uid_temp == NULL, "str_uid_temp is NULL");
+
+ origin = replace_string(origin, str_uid_temp, "\r\n");
+
+return_part:
+ if (str_uid) {
+ free(str_uid);
+ str_uid = NULL;
+ }
+ if (str_uid_temp) {
+ free(str_uid_temp);
+ str_uid_temp = NULL;
+ }
_INNER_FUNC_EXIT;
return origin;
}
-char * insert_exdate_data(const char *origin, sync_agent_calendar_exdate_t *exdate_struct, int index)
+char * insert_exdate_data(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");
// 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;
+ if (exdate_struct->exdate_type <= CALENDAR_EXDATE_TYPE_NONE && exdate_struct->exdate_type >= CALENDAR_EXDATE_TYPE_MAX) {
+ _DEBUG_ERROR("exdate_type(%d) is wrong type", exdate_struct->exdate_type);
+ goto return_part_free;
}
_DEBUG_INFO("origin = %s", origin);
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);
}
}
+ _DEBUG_INFO("after 2nd phase str_child_vcalendar = %s", str_child_vcalendar);
// 3. change DTSTART / DTEND
// example ) DTSTART:20130125T000000Z / DTEND:20130125T003000Z / EXDATE:20130201T000000Z => DTSTART:20130201T000000Z / DTEND:20130201T003000Z
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;
+ goto return_part_free;
}
- _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;
+ goto return_part_free;
}
- _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 (old_str) {
+ free(old_str);
+ old_str = NULL;
+ }
}
// 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;
+ goto return_part_free;
}
- _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;
+ goto return_part_free;
}
_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;
+ goto return_part_free;
}
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 (old_str) {
+ free(old_str);
+ old_str = NULL;
+ }
if (new_str) {
free(new_str);
new_str = NULL;
}
- _DEBUG_INFO("str_child_vcalendar = %s", str_child_vcalendar);
}
+ _DEBUG_INFO("after 3rd phase str_child_vcalendar = %s", str_child_vcalendar);
// 4. insert EXDATE
- if ((temp = strstr(str_child_vcalendar, END_VEVENT_KEYWORD)) != NULL) {
+ if (strstr(str_child_vcalendar, END_VEVENT_KEYWORD) != NULL) {
_DEBUG_INFO("EXTYPE keyword");
- _DEBUG_INFO("temp = %s", temp);
+ char *str_end_vevent = "\r\nEND:VEVENT";
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;
+ goto return_part_free;
}
- _DEBUG_INFO("exdate_str = %s", exdate_str);
- new_str = (char *)calloc(100, sizeof(char));
+ new_str = g_strdup_printf("%s%s%s", EXDATE_KEYWORD, exdate_str, str_end_vevent);
if (new_str == NULL) {
- _DEBUG_ERROR("new_str calloc failed");
- goto return_part;
+ _DEBUG_ERROR("new_str is null");
+ goto return_part_free;
}
- _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) {
+ if (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);
}
+ goto return_part_free;
}
- else if (exdate_struct->exdate_type == CALENDAR_EXDATE_TYPE_UPDATED) {
- _DEBUG_INFO("update");
- // 2. remove RRULE / EXDATE
- // 2-1. remove 'RRULE'
+ else if (exdate_struct->exdate_type == CALENDAR_EXDATE_TYPE_UPDATED_CHILD) {
+ _DEBUG_INFO("update child");
+
+ // 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-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) {
+ // 3. insert EXDATE
+ if (strstr(str_child_vcalendar, END_VEVENT_KEYWORD) != NULL) {
_DEBUG_INFO("EXTYPE keyword");
- _DEBUG_INFO("temp = %s", temp);
+ char *str_end_vevent = "\r\nEND:VEVENT";
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;
- }
+ goto_if(exdate_str == NULL, "exdate_str is NULL");
_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);
+ new_str = g_strdup_printf("%s%s%s", EXDATE_KEYWORD, exdate_str, str_end_vevent);
+ goto_if(new_str == NULL, "new_str is NULL");
+
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:
+ _DEBUG_INFO("last str_child_vcalendar = %s", str_child_vcalendar);
_INNER_FUNC_EXIT;
+ return str_child_vcalendar;
+
+return_part_free:
_DEBUG_INFO("last str_child_vcalendar = %s", str_child_vcalendar);
+ if (old_str) {
+ free(old_str);
+ old_str = NULL;
+ }
+ _INNER_FUNC_EXIT;
return str_child_vcalendar;
}
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_uri_p() Fail!: err[%d]", service_ret);
if (strncmp(uri, _calendar_event._uri, strlen(_calendar_event._uri))) {
_DEBUG_ERROR("this is not event");
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_caltime() Fail!: err[%d]", service_ret);
char *start_date_loc = NULL;
if ((start_date_loc = strstr(origin, DTSTART_KEYWORD)) == NULL) {
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_set_caltime() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_caltime() Fail!: err[%d]", service_ret);
char *end_date_loc = NULL;
if ((end_date_loc = strstr(origin, DTEND_KEYWORD)) == NULL) {
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_set_caltime() Fail!: err[%d]", service_ret);
return_part:
_INNER_FUNC_EXIT;
char *temp_image_path = NULL;
char *image_path = NULL;
+ _DEBUG_INFO("origin = %s", origin);
- if (strstr(origin, IMAGE_KEYWORD_PREFIX_PHOTO) == NULL && strstr(origin, IMAGE_KEYWORD_PREFIX_SNOTE) == NULL) {
+ if (strstr(origin, CR_IMAGE_KEYWORD_PREFIX_PHOTO) == NULL && strstr(origin, CR_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);
+ goto_if(temp_image_path == NULL, "temp_image_path is NULL");
if (strstr(temp_image_path, INTERNAL_MEMORY_CONVERTED) != NULL) {
image_path = replace_string(temp_image_path, INTERNAL_MEMORY_CONVERTED, INTERNAL_MEMORY_ORIGIN);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_uri_p() Fail!: err[%d]", service_ret);
+
_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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_child_record_count() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_child_record_at_p() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE || image_key == NULL || strlen(image_key) <= 0, "calendar_record_get_str_p() Fail!: err[%d]", service_ret);
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE || image_path == NULL || strlen(image_path) <= 0, "calendar_record_get_str() Fail!: err[%d]", service_ret);
_DEBUG_INFO("image_path = %s", image_path);
continue;
}
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;
+ char *exdate = NULL;
+ char *recurrence_id = NULL;
exdate_struct->exdate_type = CALENDAR_EXDATE_TYPE_NONE;
+ exdate_struct->exdate_count = 0;
+ exdate_struct->exdate_list = NULL;
+ service_ret = calendar_record_get_int(cal_record, _calendar_event.original_event_id, &original_event_id);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_int() Fail!: err[%d]", service_ret);
+ _DEBUG_INFO("original_event_id = %d", original_event_id);
- 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;
+ service_ret = calendar_record_get_str(cal_record, _calendar_event.recurrence_id, &recurrence_id);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_str() Fail!: err[%d]", service_ret);
+ _DEBUG_INFO("recurrence_id = %s", recurrence_id);
+
+ if (original_event_id >= 0 && recurrence_id != NULL && strlen(recurrence_id) > 0) {
+ service_ret = calendar_record_set_str(cal_record, _calendar_event.exdate, NULL);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_set_str() Fail!: err[%d]", service_ret);
}
- _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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_str() Fail!: err[%d]", service_ret);
_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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_create() Fail!: err[%d]", service_ret);
+
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_set_str() Fail!: err[%d]", service_ret);
+
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_set_str() Fail!: err[%d]", service_ret);
+
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_add_child_record() Fail!: err[%d]", service_ret);
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));
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");
+ goto return_part;
}
- _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);
+ if (original_event_id < 0 && recurrence_id == NULL ) {
+ unsigned int count = 0;
+ service_ret = calendar_record_get_child_record_count(cal_record, _calendar_event.exception, &count);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_child_record_count() Fail! err[%d]\n", service_ret);
+ if (count <=0) {
+ _DEBUG_INFO("this is a normal calendar");
+ goto return_part;
+ }
- 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);
+ _DEBUG_INFO("parent EXTYPE:UPDATE setting start");
+ exdate_struct->exdate_type = CALENDAR_EXDATE_TYPE_UPDATED_PARENT;
+ service_ret = calendar_record_create(_calendar_extended_property._uri, &extended_exdate);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_create() Fail! err[%d]\n", service_ret);
- if (original_event_id > 0 && recurrence_id != NULL && strlen(recurrence_id) > 0) {
- _DEBUG_INFO("EXTYPE:UPDATE setting start");
+ service_ret = calendar_record_set_str(extended_exdate, _calendar_extended_property.key, "X-EXTYPE");
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_set_str() Fail! err[%d]\n", service_ret);
+
+ service_ret = calendar_record_set_str(extended_exdate, _calendar_extended_property.value, ":2");
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_set_str() Fail! err[%d]\n", service_ret);
+
+ service_ret = calendar_record_add_child_record(cal_record, _calendar_event.extended, extended_exdate);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_add_child_record() Fail! err[%d]\n", service_ret);
+ }
+ else if (original_event_id >= 0 && recurrence_id != NULL && strlen(recurrence_id) > 0) {
+ _DEBUG_INFO("child EXTYPE:UPDATE setting start");
+ exdate_struct->exdate_type = CALENDAR_EXDATE_TYPE_UPDATED_CHILD;
+ exdate_struct->exdate_list = g_list_append(exdate_struct->exdate_list, recurrence_id);
+ exdate_struct->exdate_count = 1;
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_create() Fail!: err[%d]", service_ret);
+
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_set_str() Fail! err[%d]\n", service_ret);
+
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;
- }
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_set_str() Fail! err[%d]\n", service_ret);
+
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");
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_add_child_record() Fail! err[%d]\n", service_ret);
}
return_part:
return;
}
-char * replace_max_rrule_data(char *origin)
+char * replace_rrule_data(char *origin)
{
_INNER_FUNC_ENTER;
retvm_if(origin == NULL, origin, "origin is NULL.");
char *str_old_rrule = NULL;
char *str_new_rrule = NULL;
- if ((temp = strstr(origin, RRULE_KEYWORD)) == NULL) {
+ temp = strstr(origin, RRULE_KEYWORD);
+ if (temp == 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");
+ // case 1 : weekdays rrule converting
+ if (strstr(origin, WEEKDAY_RRULE_ORIGIN_KEYWORD) != NULL) {
+ _DEBUG_INFO("this vcalendar has WEEKDAYS rrule data");
+
+ origin = replace_string(origin, WEEKDAY_RRULE_ORIGIN_KEYWORD, WEEKDAY_RRULE_CONVERTED_KEYWORD);
+ _DEBUG_INFO("AFTER origin = %s", origin);
goto return_part;
}
+ // case 2 : max rrule converting
+ str_old_rrule = get_value_by_token(temp + 2, "RRULE:", "\r\n");// '2' means strlen("\r\n")
+ goto_if(str_old_rrule == NULL, "str_old_rrule is null");
+
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;
- }
+ goto_if(temp_rrule == NULL, "temp_rrule is null");
// 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);
+ str_new_rrule = g_strdup_printf("%s#0", temp_rrule);
+ goto_if(str_new_rrule == NULL, "str_new_rrule is null");
+ _DEBUG_INFO("str_new_rrule = %s", str_new_rrule);
+
origin = replace_string(origin, str_old_rrule, str_new_rrule);
return_part:
temp_rrule = NULL;
}
_INNER_FUNC_EXIT;
- _DEBUG_INFO("origin = %s", origin);
return origin;
}
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");
+ str_image_tag = strdup(IMAGE_KEYWORD_PREFIX_PHOTO);
}
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");
+ str_image_tag = strdup(IMAGE_KEYWORD_PREFIX_PHOTO);
}
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");
+ //str_image_tag = strdup(IMAGE_KEYWORD_PREFIX_SNOTE);
+ str_image_tag = strdup(IMAGE_KEYWORD_PREFIX_PHOTO);
}
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;
- }
+ goto_if(strstr(origin, END_VEVENT_KEYWORD) == NULL, "this data is wrong format. origin = %s", origin);
- 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);
+ str_image_info = g_strdup_printf("\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);
+ goto_if(str_image_info == NULL, "str_image_info is null");
char *new_agent_data = replace_string(origin, END_VEVENT_KEYWORD, str_image_info);
origin = 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)
+// exdate string format like as "20130211T000000Z,20130212T000000Z,20130213T000000Z"
+void replace_deleted_exdate_data(const char *origin, calendar_record_h parent_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");
+ retm_if(origin == NULL, "origin is NULL.");
+ retm_if(parent_record == NULL, "parent_record is NULL");
char *str_exdata_loc = NULL;
char *old_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;
- }
+ str_exdata_loc = strstr(origin, IMPORT_EXTYPE_DELETE_KEYWORD);
+ goto_if(str_exdata_loc == NULL, "this vcalendar has not exdate data");
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;
- }
+ service_ret = calendar_record_get_str(parent_record, _calendar_event.exdate, &old_exdate_str);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_set_str() Fail! err[%d]\n", service_ret);
_DEBUG_INFO("old_exdate_str = %s", old_exdate_str);
int old_exdate_str_length = 0;
- if (old_exdate_str == NULL)
+ if (old_exdate_str == NULL) {
old_exdate_str_length = 0;
- else
+ }
+ else {
old_exdate_str_length = strlen(old_exdate_str);
+ if (strstr(old_exdate_str, new_one_exdate_str) != NULL) {
+ _DEBUG_ERROR("new_one_exdate_str is already exist in old_exdate_str");
+ goto return_part;
+ }
+ }
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;
- }
+ goto_if(new_exdate_str == NULL, "new_exdate_str calloc failed, exdate_length = %d", exdate_length);
if (old_exdate_str == NULL)
snprintf(new_exdate_str, exdate_length, "%s", new_one_exdate_str);
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;
- }
+ service_ret = calendar_record_set_str(parent_record, _calendar_event.exdate, new_exdate_str);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_set_str() Fail! err[%d]\n", service_ret);
return_part:
if(new_one_exdate_str) {
new_exdate_str = NULL;
}
_INNER_FUNC_EXIT;
+ return;
+}
+
+int replace_updated_exdate_data(const char *origin, calendar_record_h parent_record)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if(origin == NULL, -1, "origin is NULL.");
+ retvm_if(parent_record == NULL, -1, "parent_record is NULL");
+
+ calendar_record_h child_record = NULL;
+ char *str_exdata_loc = NULL;
+ char *new_one_exdate_str = NULL;
+ int parent_service_id = 0;
+ int child_service_id = 0;
+ int service_ret = CALENDAR_ERROR_NONE;
+ int ret = -1;
+
+ str_exdata_loc = strstr(origin, IMPORT_EXTYPE_UPDATE_KEYWORD);
+ goto_if(str_exdata_loc == NULL, "this vcalendar has not exdate data");
+
+ 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_clone(parent_record, &child_record);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_clone() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_get_int(parent_record, _calendar_event.id, &parent_service_id);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_get_int() Fail!: err[%d]", service_ret);
+ _DEBUG_INFO("parent_service_id = %d", parent_service_id);
+
+ service_ret = calendar_record_set_int(child_record, _calendar_event.original_event_id, parent_service_id);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_set_int() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_set_str(child_record, _calendar_event.recurrence_id, new_one_exdate_str);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_set_str() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_set_str(child_record, _calendar_event.exdate, NULL);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_set_str() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_db_insert_record(child_record, &child_service_id);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_db_insert_record() Fail!: err[%d]", service_ret);
+
+ service_ret = calendar_record_destroy(child_record, true);
+ goto_if(service_ret != CALENDAR_ERROR_NONE, "calendar_record_destroy() Fail!: err[%d]", service_ret);
+ _DEBUG_INFO("child_service_id = %d", child_service_id);
+
+ ret = child_service_id;
+
+return_part:
+ if(new_one_exdate_str) {
+ free(new_one_exdate_str);
+ new_one_exdate_str = NULL;
+ }
+ if (service_ret != CALENDAR_ERROR_NONE)
+ ret = -1;
+ _INNER_FUNC_EXIT;
return ret;
}