/* * sync-agent * Copyright (c) 2012 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef INTERFACE_ITEM_H_ #define INTERFACE_ITEM_H_ #include "error.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** * @file interface_item.h * @brief */ /** @addtogroup data_adapter * @{ */ /** * @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 *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; /** * @brief Enumerations of option used to delete framework item */ typedef enum { SYNC_AGENT_DA_DELETE_ITEM_OPTION_ITEM_TYPE_ID, /**< delete item by item type */ } sync_agent_da_delete_item_option_e; /** * @brief Structure of query used to delete framework item */ typedef struct { sync_agent_da_delete_item_option_e option; int account_id; /**< F/W account id - SYNC_AGENT_DA_DELETE_ITEM_OPTION_ITEM_TYPE_ID */ int item_type_id; /**< F/W item type id - SYNC_AGENT_DA_DELETE_ITEM_OPTION_ITEM_TYPE_ID */ } sync_agent_da_delete_item_query_s; /** * @brief Enumerations of option used to fetch framework item list */ typedef enum { SYNC_AGENT_DA_GET_ITEM_LIST_OPTION_ACCOUNT_ID, /**< get item by account id */ SYNC_AGENT_DA_GET_ITEM_LIST_OPTION_SERVICE_ID_MAPPING, /**< get item by service id */ } sync_agent_da_get_item_list_option_e; /** * @brief Structure of query used to fetch framework item list */ typedef struct { sync_agent_da_get_item_list_option_e option; int item_type_id; /**< F/W item type id - SYNC_AGENT_DA_ITEM_GET_LIST_OPTION_ACCOUNT_ID */ char *item_id; /**< F/W item id - SYNC_AGENT_DA_ITEM_GET_LIST_OPTION_SERVICE_ID_MAPPING */ } sync_agent_da_get_item_list_query_s; /** * @brief Structure of query used to fetch framework item id */ typedef struct { int account_id; /**< account id */ char *service_id; /**< service id */ int item_type_id; /**< item type */ } sync_agent_da_get_item_id_query_s; /** * @brief Enumerations of option used to fetch framework item id list */ typedef enum { SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_COLUMN_NAME, /**< get item by column name */ SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID, /**< get item by operation id */ SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_FOLDER_ID, /**< get item by operation id and folder id */ SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_ITEM_TYPE_ID, /**< get item by operation id and item type */ SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_ITEM_TYPE_ID, /**< get item by item type */ SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_ITEM_TYPE_ID_N_ACCOUNT_ID, /**< get item by item type and account id */ SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_FOLDER_ID_N_ACCOUNT_ID /**< get item by folder id and account id */ } sync_agent_da_get_item_id_list_option_e; /** * @brief Enumerations of common column related to framework item */ typedef enum { SYNC_AGENT_DA_COLUMN_NAME_ACCOUNT_ID, /**< means column, account_id */ SYNC_AGENT_DA_COLUMN_NAME_ITEM_ID, /**< means column, item_id */ SYNC_AGENT_DA_COLUMN_NAME_SERVICE_ID, /**< means column, service_id */ SYNC_AGENT_DA_COLUMN_NAME_ACCESS_NAME, /**< means column, access_name */ SYNC_AGENT_DA_COLUMN_NAME_MAX /**< count of common columns */ } sync_agent_da_column_name_e; /** * @brief Structure of query used to fetch framework item id list */ typedef struct { sync_agent_da_get_item_id_list_option_e option; sync_agent_da_column_name_e column_name;/**< Column name - SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_COLUMN_NAME */ int operation_id; /**< F/W operation id - SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID, SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_FOLDER_ID, SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_ITEM_TYPE_ID*/ char *folder_id;/**< F/W folder id - SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_COLUMN_NAME, SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_FOLDER_ID */ int account_id; /**< F/W account id - SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID, SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_FOLDER_ID, SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_ITEM_TYPE_ID, SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_ITEM_TYPE_ID_N_ACCOUNT_ID */ int item_type_id; /**< F/W item type id - SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_FOLDER_ID, SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_ITEM_TYPE_ID, SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_ITEM_TYPE_ID, SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_ITEM_TYPE_ID_N_ACCOUNT_ID */ } sync_agent_da_get_item_id_list_query_s; /** * @brief Create initialized framework item instance * @par Usage: * @code sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS; sync_agent_da_item_s *item; ret = sync_agent_create_item(&item); if (ret != SYNC_AGENT_DA_SUCCESS) { ... } * @endcode * @remarks item in FW corresponds to entity in service layer such as conatct in Contact-service and event in Calendar-service * @param[out] sync_agent_item framework item instance initialized new * @return operation result * @retval SYNC_AGENT_DA_SUCCESS success * @retval error_value fail */ sync_agent_da_return_e sync_agent_create_item(sync_agent_da_item_s ** sync_agent_item); /** * @brief Add framework item instance into frameowrk db * @par Usage: * @code sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS; sync_agent_da_item_s *item = NULL; char *item_id = NULL; ret = sync_agent_create_item(&item); if (ret != SYNC_AGENT_DA_SUCCESS) { ... } ... ret = sync_agent_add_item(item, &item_id, true); if (ret != SYNC_AGENT_DA_SUCCESS) { ... } * @endcode * @param[in] sync_agent_item framework item instance to add * @param[out] item_id id of framework item instance added new * @param[in] use_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_item(sync_agent_da_item_s * sync_agent_item, char **item_id, int use_changelog); /** * @brief Update framework item * @par Usage: * @code sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS; sync_agent_da_item_s *item = NULL; ret = sync_agent_get_item(item_id, &item); if (ret != SYNC_AGENT_DA_SUCCESS) { ... } ... ret = sync_agent_update_item(item_id, true); if (ret != SYNC_AGENT_DA_SUCCESS) { ... } * @endcode * @remarks Framework item is just mapped to service item so just has mapping information. Means it doesn't have real service data, and mapping information which framework item has just need to be updated * @param[in] item_id id of framework item instance desired to update * @param[in] use_changelog option specifying whether use of changelog for sync history * @return operation result * @retval SYNC_AGENT_DA_SUCCESS success * @retval error_value fail */ sync_agent_da_return_e sync_agent_update_item(char *item_id, int use_changelog); /** * @brief Delete framework item * @par Usage: * @code sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS; ret = sync_agent_delete_item(item_id, true); if (ret != SYNC_AGENT_DA_SUCCESS) { ... } * @endcode * @param[in] item_id id of framework item instance desired to delete * @param[in] use_changelog option specifying whether use of changelog for sync history * @return operation result * @retval SYNC_AGENT_DA_SUCCESS success * @retval error_value fail */ sync_agent_da_return_e sync_agent_delete_item(char *item_id, int use_changelog); /** * @brief Delete framework items according to given query in GList form * @par Usage: * @code sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS; sync_agent_da_delete_item_query_s query; query_item.option = SYNC_AGENT_DA_DELETE_ITEM_OPTION_ITEM_TYPE_ID; query_item.item_type_id = FW_CONTACT; query_item.account_id = account_id; ret = sync_agent_query_delete_item(&query); if (ret != SYNC_AGENT_DA_SUCCESS) { ... } * @endcode * @param[in] query sync_agent_da_delete_item_query_s type of query for delete operation * @return operation result * @retval SYNC_AGENT_DA_SUCCESS success * @retval error_value fail */ sync_agent_da_return_e sync_agent_query_delete_item(sync_agent_da_delete_item_query_s * query); /** * @brief Fetch framework item instance * @par Usage: * @code sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS; sync_agent_da_item_s *item = NULL; ret = sync_agent_get_item(item_id, &item); if (ret != SYNC_AGENT_DA_SUCCESS) { ... } * @endcode * @param[in] item_id id of framework folder item instance desired to get * @param[out] sync_agent_item framework item instance fetched * @return operation result * @retval SYNC_AGENT_DA_SUCCESS success * @retval error_value fail */ sync_agent_da_return_e sync_agent_get_item(char *item_id, sync_agent_da_item_s ** sync_agent_item); /** * @brief Get data store item id * @par Usage: * @code sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS; sync_agent_da_item_s *item = NULL; ret = sync_agent_get_item_data_store_id(item_id, &item); if (ret != SYNC_AGENT_DA_SUCCESS) { ... } * @endcode * @param[in] item_id id of framework folder item instance desired to get * @param[out] sync_agent_item framework item instance fetched * @return operation result * @retval SYNC_AGENT_DA_SUCCESS success * @retval error_value fail */ sync_agent_da_return_e sync_agent_get_item_data_store_id(char *item_id, sync_agent_da_item_s ** sync_agent_item); /** * @brief Get account item id * @par Usage: * @code sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS; sync_agent_da_item_s *item = NULL; ret = sync_agent_get_item_account_id(item_id, &item); if (ret != SYNC_AGENT_DA_SUCCESS) { ... } * @endcode * @param[in] item_id id of framework folder item instance desired to get * @param[out] sync_agent_item framework item instance fetched * @return operation result * @retval SYNC_AGENT_DA_SUCCESS success * @retval error_value fail */ sync_agent_da_return_e sync_agent_get_item_account_id(char *item_id, sync_agent_da_item_s ** sync_agent_item); /** * @brief Fetch framework items according to given query in GList form * @par Usage: * @code sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS; sync_agent_da_get_item_list_query_s query; GList *item_list = NULL; query.option = SYNC_AGENT_DA_GET_ITEM_LIST_OPTION_ACCOUNT_ID; query.item_type_id = FW_CONTACT; ret = sync_agent_get_item_list(accoutn_id, &query, &item_list); if (ret != SYNC_AGENT_DA_SUCCESS) { ... } * @endcode * @param[in] account_id account id of items desired to get * @param[in] query sync_agent_da_get_item_list_query_s type of query for fetch operation * @param[out] list list of framework item instance fetched * @return operation result * @retval SYNC_AGENT_DA_SUCCESS success * @retval error_value fail */ sync_agent_da_return_e sync_agent_get_item_list(int account_id, sync_agent_da_get_item_list_query_s * query, GList ** list); /** * @brief Get framework item id according to given query * @par Usage: * @code sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS; sync_agent_da_get_item_id_query_s query; char *item_id = NULL; query.service_id = service_item_id; query.account_id = account_id; query.item_type_id = FW_CONTACT; da_err = sync_agent_get_item_id(&query, &item_id); if (ret != SYNC_AGENT_DA_SUCCESS) { ... } * @endcode * @param[in] query sync_agent_da_get_item_id_query_s type of query for fetch operation * @param[out] item_id id of framework item instance requested * @return operation result * @retval SYNC_AGENT_DA_SUCCESS success * @retval error_value fail */ sync_agent_da_return_e sync_agent_get_item_id(sync_agent_da_get_item_id_query_s * query, char **item_id); /** * @brief Get framework item ids according to given query in GList form * @par Usage: * @code sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS; sync_agent_da_get_item_id_list_query_s query; GList *item_id_list = NULL; query.option = SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_ITEM_TYPE_ID; query.account_id = account_id; query.item_type_id = FW_CONTACT; query.operation_id = SYNC_AGENT_DA_CHANGE_OPERATION_DELETE; da_err = sync_agent_get_item_id_list(&query, &item_id_list); if (ret != SYNC_AGENT_DA_SUCCESS) { ... } * @endcode * @param[in] query sync_agent_da_get_item_id_list_query_s type of query for fetch operation * @param[out] list list of framework item id fetched * @return operation result * @retval SYNC_AGENT_DA_SUCCESS success * @retval error_value fail */ sync_agent_da_return_e sync_agent_get_item_id_list(sync_agent_da_get_item_id_list_query_s * query, GList ** list); /** * @brief Free framework item instance provided * @par Usage: * @code sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS; sync_agent_da_item_s *item = NULL; ret = sync_agent_get_item(item_id, &item); if (ret != SYNC_AGENT_DA_SUCCESS) { ... } ... ret = sync_agent_free_item(item); if (ret != SYNC_AGENT_DA_SUCCESS) { ... } * @endcode * @param[in] sync_agent_item framework item instance to free * @return operation result * @retval SYNC_AGENT_DA_SUCCESS success * @retval error_value fail */ sync_agent_da_return_e sync_agent_free_item(sync_agent_da_item_s * sync_agent_item); /** * @brief Free framework items provided in GList form * @par Usage: * @code sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS; sync_agent_da_get_item_list_query_s query; GList *item_list = NULL; query.option = SYNC_AGENT_DA_GET_ITEM_LIST_OPTION_ACCOUNT_ID; query.item_type_id = FW_CONTACT; ret = sync_agent_get_item_list(accoutn_id, &query, &item_list); if (ret != SYNC_AGENT_DA_SUCCESS) { ... } ... ret = sync_agent_free_item_list(item_list); if (ret != SYNC_AGENT_DA_SUCCESS) { ... } * @endcode * @param[in] list framework item instance list to free * @return operation result * @retval SYNC_AGENT_DA_SUCCESS success * @retval error_value fail */ sync_agent_da_return_e sync_agent_free_item_list(GList * list); /** * @brief Free framework item id provided * @par Usage: * @code sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS; sync_agent_da_get_item_id_query_s query; char *item_id = NULL; query.service_id = service_item_id; query.account_id = account_id; query.item_type_id = FW_CONTACT; da_err = sync_agent_get_item_id(&query, &item_id); if (ret != SYNC_AGENT_DA_SUCCESS) { ... } ... ret = sync_agent_free_item_id(item_id); if (ret != SYNC_AGENT_DA_SUCCESS) { ... } * @endcode * @param[in] item_id framework item id to free * @return operation result * @retval SYNC_AGENT_DA_SUCCESS success * @retval error_value fail */ sync_agent_da_return_e sync_agent_free_item_id(char *item_id); /** * @brief Free framework item id list provided in GList form * @par Usage: * @code sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS; sync_agent_da_get_item_id_list_query_s query; GList *item_id_list = NULL; query.option = SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_ITEM_TYPE_ID; query.account_id = account_id; query.item_type_id = FW_CONTACT; query.operation_id = SYNC_AGENT_DA_CHANGE_OPERATION_DELETE; da_err = sync_agent_get_item_id_list(&query, &item_id_list); if (ret != SYNC_AGENT_DA_SUCCESS) { ... } ... ret = sync_agent_free_item_id_list(item_id_list); if (ret != SYNC_AGENT_DA_SUCCESS) { ... } * @endcode * @param[in] list framework item id list to free * @return operation result * @retval SYNC_AGENT_DA_SUCCESS success * @retval error_value fail */ sync_agent_da_return_e sync_agent_free_item_id_list(GList * list); /** * @brief get item count in item table where service type * @param[in] data_store_id item's service type * @param[out] item_count item count for service id * @return operation result * @retval SYNC_AGENT_DA_SUCCESS success * @retval error_value fail */ 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); /** * @} */ #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* INTERFACE_ITEM_H_ */