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 Fetch framework items according to given query in GList form
301 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
302 sync_agent_da_get_item_list_query_s query;
303 GList *item_list = NULL;
305 query.option = SYNC_AGENT_DA_GET_ITEM_LIST_OPTION_ACCOUNT_ID;
306 query.item_type_id = FW_CONTACT;
308 ret = sync_agent_get_item_list(accoutn_id, &query, &item_list);
309 if (ret != SYNC_AGENT_DA_SUCCESS) {
314 * @param[in] account_id account id of items desired to get
315 * @param[in] query sync_agent_da_get_item_list_query_s type of query for fetch operation
316 * @param[out] list list of framework item instance fetched
317 * @return operation result
318 * @retval SYNC_AGENT_DA_SUCCESS success
319 * @retval error_value fail
321 sync_agent_da_return_e sync_agent_get_item_list(int account_id, sync_agent_da_get_item_list_query_s * query, GList ** list);
324 * @brief Get framework item id according to given query
328 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
329 sync_agent_da_get_item_id_query_s query;
330 char *item_id = NULL;
332 query.service_id = service_item_id;
333 query.account_id = account_id;
334 query.item_type_id = FW_CONTACT;
336 da_err = sync_agent_get_item_id(&query, &item_id);
337 if (ret != SYNC_AGENT_DA_SUCCESS) {
342 * @param[in] query sync_agent_da_get_item_id_query_s type of query for fetch operation
343 * @param[out] item_id id of framework item instance requested
344 * @return operation result
345 * @retval SYNC_AGENT_DA_SUCCESS success
346 * @retval error_value fail
348 sync_agent_da_return_e sync_agent_get_item_id(sync_agent_da_get_item_id_query_s * query, char **item_id);
351 * @brief Get framework item ids according to given query in GList form
355 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
356 sync_agent_da_get_item_id_list_query_s query;
357 GList *item_id_list = NULL;
359 query.option = SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_ITEM_TYPE_ID;
360 query.account_id = account_id;
361 query.item_type_id = FW_CONTACT;
362 query.operation_id = SYNC_AGENT_DA_CHANGE_OPERATION_DELETE;
365 da_err = sync_agent_get_item_id_list(&query, &item_id_list);
366 if (ret != SYNC_AGENT_DA_SUCCESS) {
371 * @param[in] query sync_agent_da_get_item_id_list_query_s type of query for fetch operation
372 * @param[out] list list of framework item id fetched
373 * @return operation result
374 * @retval SYNC_AGENT_DA_SUCCESS success
375 * @retval error_value fail
377 sync_agent_da_return_e sync_agent_get_item_id_list(sync_agent_da_get_item_id_list_query_s * query, GList ** list);
380 * @brief Free framework item instance provided
384 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
385 sync_agent_da_item_s *item = NULL;
387 ret = sync_agent_get_item(item_id, &item);
388 if (ret != SYNC_AGENT_DA_SUCCESS) {
394 ret = sync_agent_free_item(item);
396 if (ret != SYNC_AGENT_DA_SUCCESS) {
401 * @param[in] sync_agent_item framework item instance to free
402 * @return operation result
403 * @retval SYNC_AGENT_DA_SUCCESS success
404 * @retval error_value fail
406 sync_agent_da_return_e sync_agent_free_item(sync_agent_da_item_s * sync_agent_item);
409 * @brief Free framework items provided in GList form
413 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
414 sync_agent_da_get_item_list_query_s query;
415 GList *item_list = NULL;
417 query.option = SYNC_AGENT_DA_GET_ITEM_LIST_OPTION_ACCOUNT_ID;
418 query.item_type_id = FW_CONTACT;
420 ret = sync_agent_get_item_list(accoutn_id, &query, &item_list);
421 if (ret != SYNC_AGENT_DA_SUCCESS) {
427 ret = sync_agent_free_item_list(item_list);
428 if (ret != SYNC_AGENT_DA_SUCCESS) {
433 * @param[in] list framework item instance list to free
434 * @return operation result
435 * @retval SYNC_AGENT_DA_SUCCESS success
436 * @retval error_value fail
438 sync_agent_da_return_e sync_agent_free_item_list(GList * list);
441 * @brief Free framework item id provided
445 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
446 sync_agent_da_get_item_id_query_s query;
447 char *item_id = NULL;
449 query.service_id = service_item_id;
450 query.account_id = account_id;
451 query.item_type_id = FW_CONTACT;
453 da_err = sync_agent_get_item_id(&query, &item_id);
454 if (ret != SYNC_AGENT_DA_SUCCESS) {
460 ret = sync_agent_free_item_id(item_id);
461 if (ret != SYNC_AGENT_DA_SUCCESS) {
466 * @param[in] item_id framework item id to free
467 * @return operation result
468 * @retval SYNC_AGENT_DA_SUCCESS success
469 * @retval error_value fail
471 sync_agent_da_return_e sync_agent_free_item_id(char *item_id);
474 * @brief Free framework item id list provided in GList form
478 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
479 sync_agent_da_get_item_id_list_query_s query;
480 GList *item_id_list = NULL;
482 query.option = SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_ITEM_TYPE_ID;
483 query.account_id = account_id;
484 query.item_type_id = FW_CONTACT;
485 query.operation_id = SYNC_AGENT_DA_CHANGE_OPERATION_DELETE;
488 da_err = sync_agent_get_item_id_list(&query, &item_id_list);
489 if (ret != SYNC_AGENT_DA_SUCCESS) {
495 ret = sync_agent_free_item_id_list(item_id_list);
496 if (ret != SYNC_AGENT_DA_SUCCESS) {
501 * @param[in] list framework item id list to free
502 * @return operation result
503 * @retval SYNC_AGENT_DA_SUCCESS success
504 * @retval error_value fail
506 sync_agent_da_return_e sync_agent_free_item_id_list(GList * list);
509 * @brief get item count in item table where service type
510 * @param[in] data_store_id item's service type
511 * @param[out] item_count item count for service id
512 * @return operation result
513 * @retval SYNC_AGENT_DA_SUCCESS success
514 * @retval error_value fail
516 sync_agent_da_return_e sync_agent_get_item_count(int data_store_id, int *item_count);
524 #endif /* __cplusplus */
525 #endif /* INTERFACE_ITEM_H_ */