3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #ifndef INTERFACE_ITEM_H_
19 #define INTERFACE_ITEM_H_
25 #endif /* __cplusplus */
28 * @file interface_item.h
32 /** @addtogroup data_adapter
37 * @brief Structure of framework item instance
43 /**< service data connector pluIn's ID described in F/W config file */
45 /**< F/W account id */
46 char *folder_id;/**< F/W folder id */
48 /**< service item id */
50 /**< name of accessor */
51 } sync_agent_da_item_s;
54 * @brief Enumerations of option used to delete framework item
57 SYNC_AGENT_DA_DELETE_ITEM_OPTION_ITEM_TYPE_ID,
58 /**< delete item by item type */
59 } sync_agent_da_delete_item_option_e;
62 * @brief Structure of query used to delete framework item
65 sync_agent_da_delete_item_option_e option;
67 /**< F/W account id - SYNC_AGENT_DA_DELETE_ITEM_OPTION_ITEM_TYPE_ID */
69 /**< F/W item type id - SYNC_AGENT_DA_DELETE_ITEM_OPTION_ITEM_TYPE_ID */
70 } sync_agent_da_delete_item_query_s;
73 * @brief Enumerations of option used to fetch framework item list
76 SYNC_AGENT_DA_GET_ITEM_LIST_OPTION_ACCOUNT_ID, /**< get item by account id */
77 SYNC_AGENT_DA_GET_ITEM_LIST_OPTION_SERVICE_ID_MAPPING,
78 /**< get item by service id */
79 } sync_agent_da_get_item_list_option_e;
82 * @brief Structure of query used to fetch framework item list
85 sync_agent_da_get_item_list_option_e option;
87 /**< F/W item type id - SYNC_AGENT_DA_ITEM_GET_LIST_OPTION_ACCOUNT_ID */
89 /**< F/W item id - SYNC_AGENT_DA_ITEM_GET_LIST_OPTION_SERVICE_ID_MAPPING */
90 } sync_agent_da_get_item_list_query_s;
93 * @brief Structure of query used to fetch framework item id
96 int account_id; /**< account id */
97 char *service_id; /**< service id */
98 int item_type_id; /**< item type */
99 } sync_agent_da_get_item_id_query_s;
102 * @brief Enumerations of option used to fetch framework item id list
105 SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_COLUMN_NAME, /**< get item by column name */
106 SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID, /**< get item by operation id */
107 SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_FOLDER_ID, /**< get item by operation id and folder id */
108 SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_ITEM_TYPE_ID, /**< get item by operation id and item type */
109 SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_ITEM_TYPE_ID, /**< get item by item type */
110 SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_ITEM_TYPE_ID_N_ACCOUNT_ID, /**< get item by item type and account id */
111 SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_FOLDER_ID_N_ACCOUNT_ID /**< get item by folder id and account id */
112 } sync_agent_da_get_item_id_list_option_e;
115 * @brief Enumerations of common column related to framework item
118 SYNC_AGENT_DA_COLUMN_NAME_ACCOUNT_ID,
119 /**< means column, account_id */
120 SYNC_AGENT_DA_COLUMN_NAME_ITEM_ID,
121 /**< means column, item_id */
122 SYNC_AGENT_DA_COLUMN_NAME_SERVICE_ID,
123 /**< means column, service_id */
124 SYNC_AGENT_DA_COLUMN_NAME_ACCESS_NAME,
125 /**< means column, access_name */
127 SYNC_AGENT_DA_COLUMN_NAME_MAX
128 /**< count of common columns */
129 } sync_agent_da_column_name_e;
132 * @brief Structure of query used to fetch framework item id list
135 sync_agent_da_get_item_id_list_option_e option;
136 sync_agent_da_column_name_e column_name;/**< Column name - SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_COLUMN_NAME */
137 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*/
138 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 */
140 /**< 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 */
142 /**< 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 */
143 } sync_agent_da_get_item_id_list_query_s;
146 * @brief Create initialized framework item instance
150 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
151 sync_agent_da_item_s *item;
153 ret = sync_agent_create_item(&item);
154 if (ret != SYNC_AGENT_DA_SUCCESS) {
159 * @remarks item in FW corresponds to entity in service layer such as conatct in Contact-service and event in Calendar-service
160 * @param[out] sync_agent_item framework item instance initialized new
161 * @return operation result
162 * @retval SYNC_AGENT_DA_SUCCESS success
163 * @retval error_value fail
165 sync_agent_da_return_e sync_agent_create_item(sync_agent_da_item_s ** sync_agent_item);
168 * @brief Add framework item instance into frameowrk db
172 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
173 sync_agent_da_item_s *item = NULL;
174 char *item_id = NULL;
176 ret = sync_agent_create_item(&item);
177 if (ret != SYNC_AGENT_DA_SUCCESS) {
183 ret = sync_agent_add_item(item, &item_id, true);
184 if (ret != SYNC_AGENT_DA_SUCCESS) {
189 * @param[in] sync_agent_item framework item instance to add
190 * @param[out] item_id id of framework item instance added new
191 * @param[in] use_changelog option specifying whether use of changelog for sync history
192 * @return operation result
193 * @retval SYNC_AGENT_DA_SUCCESS success
194 * @retval error_value fail
196 sync_agent_da_return_e sync_agent_add_item(sync_agent_da_item_s * sync_agent_item, char **item_id, int use_changelog);
199 * @brief Update framework item
203 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
204 sync_agent_da_item_s *item = NULL;
206 ret = sync_agent_get_item(item_id, &item);
207 if (ret != SYNC_AGENT_DA_SUCCESS) {
213 ret = sync_agent_update_item(item_id, true);
214 if (ret != SYNC_AGENT_DA_SUCCESS) {
219 * @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
220 * @param[in] item_id id of framework item instance desired to update
221 * @param[in] use_changelog option specifying whether use of changelog for sync history
222 * @return operation result
223 * @retval SYNC_AGENT_DA_SUCCESS success
224 * @retval error_value fail
226 sync_agent_da_return_e sync_agent_update_item(char *item_id, int use_changelog);
229 * @brief Delete framework item
233 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
235 ret = sync_agent_delete_item(item_id, true);
236 if (ret != SYNC_AGENT_DA_SUCCESS) {
241 * @param[in] item_id id of framework item instance desired to delete
242 * @param[in] use_changelog option specifying whether use of changelog for sync history
243 * @return operation result
244 * @retval SYNC_AGENT_DA_SUCCESS success
245 * @retval error_value fail
247 sync_agent_da_return_e sync_agent_delete_item(char *item_id, int use_changelog);
250 * @brief Delete framework items according to given query in GList form
254 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
255 sync_agent_da_delete_item_query_s query;
257 query_item.option = SYNC_AGENT_DA_DELETE_ITEM_OPTION_ITEM_TYPE_ID;
258 query_item.item_type_id = FW_CONTACT;
259 query_item.account_id = account_id;
261 ret = sync_agent_query_delete_item(&query);
262 if (ret != SYNC_AGENT_DA_SUCCESS) {
267 * @param[in] query sync_agent_da_delete_item_query_s type of query for delete operation
268 * @return operation result
269 * @retval SYNC_AGENT_DA_SUCCESS success
270 * @retval error_value fail
272 sync_agent_da_return_e sync_agent_query_delete_item(sync_agent_da_delete_item_query_s * query);
275 * @brief Fetch framework item instance
279 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
280 sync_agent_da_item_s *item = NULL;
282 ret = sync_agent_get_item(item_id, &item);
283 if (ret != SYNC_AGENT_DA_SUCCESS) {
288 * @param[in] item_id id of framework folder item instance desired to get
289 * @param[out] sync_agent_item framework item instance fetched
290 * @return operation result
291 * @retval SYNC_AGENT_DA_SUCCESS success
292 * @retval error_value fail
294 sync_agent_da_return_e sync_agent_get_item(char *item_id, sync_agent_da_item_s ** sync_agent_item);
297 * @brief Get data store item id
301 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
302 sync_agent_da_item_s *item = NULL;
304 ret = sync_agent_get_item_data_store_id(item_id, &item);
305 if (ret != SYNC_AGENT_DA_SUCCESS) {
310 * @param[in] item_id id of framework folder item instance desired to get
311 * @param[out] sync_agent_item framework item instance fetched
312 * @return operation result
313 * @retval SYNC_AGENT_DA_SUCCESS success
314 * @retval error_value fail
316 sync_agent_da_return_e sync_agent_get_item_data_store_id(char *item_id, sync_agent_da_item_s ** sync_agent_item);
319 * @brief Get account item id
323 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
324 sync_agent_da_item_s *item = NULL;
326 ret = sync_agent_get_item_account_id(item_id, &item);
327 if (ret != SYNC_AGENT_DA_SUCCESS) {
332 * @param[in] item_id id of framework folder item instance desired to get
333 * @param[out] sync_agent_item framework item instance fetched
334 * @return operation result
335 * @retval SYNC_AGENT_DA_SUCCESS success
336 * @retval error_value fail
338 sync_agent_da_return_e sync_agent_get_item_account_id(char *item_id, sync_agent_da_item_s ** sync_agent_item);
341 * @brief Fetch framework items according to given query in GList form
345 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
346 sync_agent_da_get_item_list_query_s query;
347 GList *item_list = NULL;
349 query.option = SYNC_AGENT_DA_GET_ITEM_LIST_OPTION_ACCOUNT_ID;
350 query.item_type_id = FW_CONTACT;
352 ret = sync_agent_get_item_list(accoutn_id, &query, &item_list);
353 if (ret != SYNC_AGENT_DA_SUCCESS) {
358 * @param[in] account_id account id of items desired to get
359 * @param[in] query sync_agent_da_get_item_list_query_s type of query for fetch operation
360 * @param[out] list list of framework item instance fetched
361 * @return operation result
362 * @retval SYNC_AGENT_DA_SUCCESS success
363 * @retval error_value fail
365 sync_agent_da_return_e sync_agent_get_item_list(int account_id, sync_agent_da_get_item_list_query_s * query, GList ** list);
368 * @brief Get framework item id according to given query
372 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
373 sync_agent_da_get_item_id_query_s query;
374 char *item_id = NULL;
376 query.service_id = service_item_id;
377 query.account_id = account_id;
378 query.item_type_id = FW_CONTACT;
380 da_err = sync_agent_get_item_id(&query, &item_id);
381 if (ret != SYNC_AGENT_DA_SUCCESS) {
386 * @param[in] query sync_agent_da_get_item_id_query_s type of query for fetch operation
387 * @param[out] item_id id of framework item instance requested
388 * @return operation result
389 * @retval SYNC_AGENT_DA_SUCCESS success
390 * @retval error_value fail
392 sync_agent_da_return_e sync_agent_get_item_id(sync_agent_da_get_item_id_query_s * query, char **item_id);
395 * @brief Get framework item ids according to given query in GList form
399 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
400 sync_agent_da_get_item_id_list_query_s query;
401 GList *item_id_list = NULL;
403 query.option = SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_ITEM_TYPE_ID;
404 query.account_id = account_id;
405 query.item_type_id = FW_CONTACT;
406 query.operation_id = SYNC_AGENT_DA_CHANGE_OPERATION_DELETE;
409 da_err = sync_agent_get_item_id_list(&query, &item_id_list);
410 if (ret != SYNC_AGENT_DA_SUCCESS) {
415 * @param[in] query sync_agent_da_get_item_id_list_query_s type of query for fetch operation
416 * @param[out] list list of framework item id fetched
417 * @return operation result
418 * @retval SYNC_AGENT_DA_SUCCESS success
419 * @retval error_value fail
421 sync_agent_da_return_e sync_agent_get_item_id_list(sync_agent_da_get_item_id_list_query_s * query, GList ** list);
424 * @brief Free framework item instance provided
428 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
429 sync_agent_da_item_s *item = NULL;
431 ret = sync_agent_get_item(item_id, &item);
432 if (ret != SYNC_AGENT_DA_SUCCESS) {
438 ret = sync_agent_free_item(item);
440 if (ret != SYNC_AGENT_DA_SUCCESS) {
445 * @param[in] sync_agent_item framework item instance to free
446 * @return operation result
447 * @retval SYNC_AGENT_DA_SUCCESS success
448 * @retval error_value fail
450 sync_agent_da_return_e sync_agent_free_item(sync_agent_da_item_s * sync_agent_item);
453 * @brief Free framework items provided in GList form
457 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
458 sync_agent_da_get_item_list_query_s query;
459 GList *item_list = NULL;
461 query.option = SYNC_AGENT_DA_GET_ITEM_LIST_OPTION_ACCOUNT_ID;
462 query.item_type_id = FW_CONTACT;
464 ret = sync_agent_get_item_list(accoutn_id, &query, &item_list);
465 if (ret != SYNC_AGENT_DA_SUCCESS) {
471 ret = sync_agent_free_item_list(item_list);
472 if (ret != SYNC_AGENT_DA_SUCCESS) {
477 * @param[in] list framework item instance list to free
478 * @return operation result
479 * @retval SYNC_AGENT_DA_SUCCESS success
480 * @retval error_value fail
482 sync_agent_da_return_e sync_agent_free_item_list(GList * list);
485 * @brief Free framework item id provided
489 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
490 sync_agent_da_get_item_id_query_s query;
491 char *item_id = NULL;
493 query.service_id = service_item_id;
494 query.account_id = account_id;
495 query.item_type_id = FW_CONTACT;
497 da_err = sync_agent_get_item_id(&query, &item_id);
498 if (ret != SYNC_AGENT_DA_SUCCESS) {
504 ret = sync_agent_free_item_id(item_id);
505 if (ret != SYNC_AGENT_DA_SUCCESS) {
510 * @param[in] item_id framework item id to free
511 * @return operation result
512 * @retval SYNC_AGENT_DA_SUCCESS success
513 * @retval error_value fail
515 sync_agent_da_return_e sync_agent_free_item_id(char *item_id);
518 * @brief Free framework item id list provided in GList form
522 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
523 sync_agent_da_get_item_id_list_query_s query;
524 GList *item_id_list = NULL;
526 query.option = SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_ITEM_TYPE_ID;
527 query.account_id = account_id;
528 query.item_type_id = FW_CONTACT;
529 query.operation_id = SYNC_AGENT_DA_CHANGE_OPERATION_DELETE;
532 da_err = sync_agent_get_item_id_list(&query, &item_id_list);
533 if (ret != SYNC_AGENT_DA_SUCCESS) {
539 ret = sync_agent_free_item_id_list(item_id_list);
540 if (ret != SYNC_AGENT_DA_SUCCESS) {
545 * @param[in] list framework item id list to free
546 * @return operation result
547 * @retval SYNC_AGENT_DA_SUCCESS success
548 * @retval error_value fail
550 sync_agent_da_return_e sync_agent_free_item_id_list(GList * list);
553 * @brief get item count in item table where service type
554 * @param[in] data_store_id item's service type
555 * @param[out] item_count item count for service id
556 * @return operation result
557 * @retval SYNC_AGENT_DA_SUCCESS success
558 * @retval error_value fail
560 sync_agent_da_return_e sync_agent_get_item_count(int data_store_id, int *item_count);
568 #endif /* __cplusplus */
569 #endif /* INTERFACE_ITEM_H_ */