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_SERVICE_ITEM_H_
19 #define INTERFACE_SERVICE_ITEM_H_
25 #endif /* __cplusplus */
28 * @file interface_service_item.h
29 * @brief Support to use service storage
32 /** @addtogroup data_adapter
37 * @brief Structure of framework service item instance
40 char *item_id; /** service item id */
41 int content_type; /** content type of service item */
42 int account_id; /** service account id */
43 char *folder_id; /** service folder id to which service item mapped to */
44 char *access_name; /** name of accessor */
45 const void *data; /** void pointer type of service data */
46 } sync_agent_da_service_item_s;
49 * @brief Structure of framework service folder instance
52 char *folder_id; /** service folder id */
53 char *folder_name; /** name of service folder */
54 int folder_type; /** type of service folder */
55 } sync_agent_da_service_folder_s;
58 * @brief Structure of query used to delete framework service item
61 int content_type; /**< type of content to delete */
62 int account_id; /**< id of the account desired to delete */
63 } sync_agent_da_delete_service_item_query_s;
66 * @brief Open service database
70 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
72 ret = sync_agent_open_service(FW_CONTACT);
73 if (ret != SYNC_AGENT_DA_SUCCESS) {
78 * @param[in] content_type service type - service data connector plug-in's ID described in F/W config file
79 * @return operation result
80 * @retval SYNC_AGENT_DA_SUCCESS success
81 * @retval error_value fail
83 sync_agent_da_return_e sync_agent_open_service(int content_type);
86 * @brief Close service database
90 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
92 ret = sync_agent_close_service(FW_CONTACT);
93 if (ret != SYNC_AGENT_DA_SUCCESS) {
98 * @param[in] content_type service type - service data connector plug-in's ID described in F/W config file
99 * @return operation result
100 * @retval SYNC_AGENT_DA_SUCCESS success
101 * @retval error_value fail
103 sync_agent_da_return_e sync_agent_close_service(int content_type);
106 * @brief Start transaction for service database
110 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
112 ret = sync_agent_begin_service(FW_CONTACT);
113 if (ret != SYNC_AGENT_DA_SUCCESS) {
118 * @param[in] content_type service type - service data connector plug-in's ID described in F/W config file
119 * @return operation result
120 * @retval SYNC_AGENT_DA_SUCCESS success
121 * @retval error_value fail
123 sync_agent_da_return_e sync_agent_begin_service(int content_type);
126 * @brief End transaction for service database
130 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
132 ret = sync_agent_end_service(FW_CONTACT, false); //transaction rollback by 'false'
133 if (ret != SYNC_AGENT_DA_SUCCESS) {
138 * @param[in] content_type service type - service data connector plug-in's ID described in F/W config file
139 * @param[in] is_success 1 : commit, 0 : rollback
140 * @return operation result
141 * @retval SYNC_AGENT_DA_SUCCESS success
142 * @retval error_value fail
144 sync_agent_da_return_e sync_agent_end_service(int content_type, int is_success);
147 * @brief Create initialized framework service item instance
151 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
152 sync_agent_da_service_item_s *service_item = NULL;
154 ret = sync_agent_create_service_item(&service_item);
155 if (ret != SYNC_AGENT_DA_SUCCESS) {
160 * @param[out] service_item sync_agent_da_service_item_s type of framework service item instance newly initialied
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_service_item(sync_agent_da_service_item_s ** service_item);
168 * @brief Create initialized framework service folder instance
172 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
173 sync_agent_da_service_folder_s *service_folder = NULL;
175 ret = sync_agent_create_service_folder(&service_folder);
176 if (ret != SYNC_AGENT_DA_SUCCESS) {
181 * @param[out] service_folder sync_agent_da_service_folder_s type of framework service folder instance newly initialied
182 * @return operation result
183 * @retval SYNC_AGENT_DA_SUCCESS success
184 * @retval error_value fail
186 sync_agent_da_return_e sync_agent_create_service_folder(sync_agent_da_service_folder_s ** service_folder);
189 * @brief Free framework service item instance provided
193 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
194 sync_agent_da_service_item_s *service_item = NULL;
196 ret = sync_agent_create_service_item(&service_item);
197 if (ret != SYNC_AGENT_DA_SUCCESS) {
203 ret = sync_agent_free_service_item(service_item);
204 if (ret != SYNC_AGENT_DA_SUCCESS) {
209 * @param[in] service_item sync_agent_da_service_item_s type of framework service item instance to free
210 * @return operation result
211 * @retval SYNC_AGENT_DA_SUCCESS success
212 * @retval error_value fail
214 sync_agent_da_return_e sync_agent_free_service_item(sync_agent_da_service_item_s * service_item);
217 * @brief Free framework service folder instance provided
221 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
222 sync_agent_da_service_folder_s *service_folder = NULL;
224 ret = sync_agent_create_service_folder(&service_folder);
225 if (ret != SYNC_AGENT_DA_SUCCESS) {
231 ret = sync_agent_free_service_folder(&service_folder);
232 if (ret != SYNC_AGENT_DA_SUCCESS) {
237 * @param[in] service_folder sync_agent_da_service_folder_s type of framework service folder instance to free
238 * @return operation result
239 * @retval SYNC_AGENT_DA_SUCCESS success
240 * @retval error_value fail
242 sync_agent_da_return_e sync_agent_free_service_folder(sync_agent_da_service_folder_s * service_folder);
245 * @brief Add framework service item instance into frameowrk db
249 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
250 sync_agent_da_service_item_s *service_item = NULL;
251 char *item_id = NULL;
253 ret = sync_agent_create_service_item(&service_item);
254 if (ret != SYNC_AGENT_DA_SUCCESS) {
260 ret = sync_agent_add_service_item(service_item, &item_id, true);
261 if (ret != SYNC_AGENT_DA_SUCCESS) {
266 * @param[in] service_item sync_agent_da_service_item_s type of framework service item instance to add into framework db
267 * @param[out] item_id id of framework service item instance added new
268 * @param[in] update_changelog option specifying whether use of changelog for sync history
269 * @return operation result
270 * @retval SYNC_AGENT_DA_SUCCESS success
271 * @retval error_value fail
273 sync_agent_da_return_e sync_agent_add_service_item(sync_agent_da_service_item_s * service_item, char **item_id, bool update_changelog);
277 * @brief Add framework service item instance into frameowrk db
281 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
282 sync_agent_da_service_item_s *service_item = NULL;
283 char *item_id = NULL;
285 ret = sync_agent_create_service_item(&service_item);
286 if (ret != SYNC_AGENT_DA_SUCCESS) {
292 ret = sync_agent_add_service_bulk_item(service_item, &item_id, true);
293 if (ret != SYNC_AGENT_DA_SUCCESS) {
298 * @param[in] service_item sync_agent_da_service_item_s type of framework service item instance to add into framework db
299 * @param[out] item_id id of framework service item instance added new
300 * @param[in] update_changelog option specifying whether use of changelog for sync history
301 * @return operation result
302 * @retval SYNC_AGENT_DA_SUCCESS success
303 * @retval error_value fail
305 sync_agent_da_return_e sync_agent_add_service_bulk_item(sync_agent_da_service_item_s *service_item, char **item_id, bool update_changelog);
308 * @brief Update framework service item on framework db
312 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
313 sync_agent_da_service_item_s *service_item = NULL;
315 ret = sync_agent_get_service_item(item_id, &service_item);
316 if (ret != SYNC_AGENT_DA_SUCCESS) {
322 ret = sync_agent_update_service_item(service_item, item_id, true);
323 if (ret != SYNC_AGENT_DA_SUCCESS) {
328 * @param[in] service_item sync_agent_da_service_item_s type of framework service item instance to update into framework db
329 * @param[in] item_id id of framework service item instance desired to update
330 * @param[in] update_changelog option specifying whether use of changelog for sync history
331 * @return operation result
332 * @retval SYNC_AGENT_DA_SUCCESS success
333 * @retval error_value fail
335 sync_agent_da_return_e sync_agent_update_service_item(sync_agent_da_service_item_s * service_item, char *item_id, bool update_changelog);
338 * @brief Update framework service item on framework db
342 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
343 sync_agent_da_service_item_s *service_item = NULL;
345 ret = sync_agent_get_service_item(item_id, &service_item);
346 if (ret != SYNC_AGENT_DA_SUCCESS) {
352 ret = sync_agent_update_service_bulk_item(service_item, &item_id, true);
353 if (ret != SYNC_AGENT_DA_SUCCESS) {
358 * @param[in] service_item sync_agent_da_service_item_s type of framework service item instance to update into framework db
359 * @param[in] item_id id of framework service item instance desired to update
360 * @param[in] update_changelog option specifying whether use of changelog for sync history
361 * @return operation result
362 * @retval SYNC_AGENT_DA_SUCCESS success
363 * @retval error_value fail
365 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);
368 * @brief Delete framework service item instance from frameowrk db
372 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
374 ret = sync_agent_delete_service_item(item_id, true);
375 if (ret != SYNC_AGENT_DA_SUCCESS) {
380 * @param[in] item_id id of framework service item instance desired to delete
381 * @param[in] update_changelog option specifying whether use of changelog for sync history
382 * @return operation result
383 * @retval SYNC_AGENT_DA_SUCCESS success
384 * @retval error_value fail
386 sync_agent_da_return_e sync_agent_delete_service_item(char *item_id, bool update_changelog);
389 * @brief Delete framework service item instance from frameowrk db
393 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
395 ret = sync_agent_delete_service_bulk_item(item_id, true);
396 if (ret != SYNC_AGENT_DA_SUCCESS) {
401 * @param[in] item_id id of framework service item instance desired to delete
402 * @param[in] update_changelog option specifying whether use of changelog for sync history
403 * @return operation result
404 * @retval SYNC_AGENT_DA_SUCCESS success
405 * @retval error_value fail
407 sync_agent_da_return_e sync_agent_delete_service_bulk_item(char **item_id, int count, bool update_changelog);
411 * @brief Delete framework service item instance from frameowrk db using query option
415 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
416 sync_agent_da_delete_service_item_query_s query;
418 query.content_type = FW_CONTACT;
419 query.account_id = account_id;
421 ret = sync_agent_query_delete_service_items(&query);
422 if (ret != SYNC_AGENT_DA_SUCCESS) {
427 * @param[in] query sync_agent_da_delete_service_item_query_s type of query for delete operation
428 * @return operation result
429 * @retval SYNC_AGENT_DA_SUCCESS success
430 * @retval error_value fail
432 sync_agent_da_return_e sync_agent_query_delete_service_items(sync_agent_da_delete_service_item_query_s * query);
435 * @brief Fetch framework service item from framework db
439 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
440 sync_agent_da_service_item_s *service_item = NULL;
442 ret = sync_agent_get_service_item(item_id, &service_item);
443 if (ret != SYNC_AGENT_DA_SUCCESS) {
448 * @param[in] item_id id of framework service item instance desired to get
449 * @param[out] service_item framework service item instance fetched
450 * @return operation result
451 * @retval SYNC_AGENT_DA_SUCCESS success
452 * @retval error_value fail
454 sync_agent_da_return_e sync_agent_get_service_item(char *item_id, sync_agent_da_service_item_s ** service_item);
457 * @brief Fetch framework service folder from framework db
461 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
462 sync_agent_da_service_folder_s *service_folder = NULL;
464 ret = sync_agent_get_service_folder(folder_id, &service_folder);
465 if (ret != SYNC_AGENT_DA_SUCCESS) {
470 * @param[in] folder_id id of framework service folder instance desired to get
471 * @param[out] service_folder framework service folder instance fetched
472 * @return operation result
473 * @retval SYNC_AGENT_DA_SUCCESS success
474 * @retval error_value fail
476 sync_agent_da_return_e sync_agent_get_service_folder(char *folder_id, sync_agent_da_service_folder_s ** service_folder);
479 * @brief Execute predefined operation through plug-in
483 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
484 char *msg = get_msg_body();
487 ret = sync_agent_execute_service(FW_SMS, account_id, "send_msg", msg, &result);
488 if (ret != SYNC_AGENT_DA_SUCCESS) {
493 * @param[in] content_type service type - service data connector plug-in's ID described in F/W config file
494 * @param[in] account_id F/W account id
495 * @param[in] execute_key execute key
496 * @param[in] execute_values execute values
497 * @param[out] result extension result info
498 * @return operation result
499 * @retval SYNC_AGENT_DA_SUCCESS success
500 * @retval error_value fail
502 sync_agent_da_return_e sync_agent_execute_service(int content_type, int account_id, const char *execute_key, void *execute_values, void **result);
505 * @brief Get item used count
511 count = sync_agent_get_used_service_item_count(FW_CONTACT);
519 * @param[in] content_type service type - service data connector plug-in's ID described in F/W config file
520 * @return operation result
521 * @retval current item count success
522 * @retval error value fail
524 int sync_agent_get_used_service_item_count(int content_type);
527 * @brief Get item used count for folder
533 count = sync_agent_get_used_service_item_count_for_folder(FW_CONTACT, account_id, folder_id);
541 * @param[in] content_type service type - service data connector plug-in's ID described in F/W config file
542 * @param[in] account_id F/W account id
543 * @param[in] folder_id F/W folder id
544 * @return operation result
545 * @retval current item count success
546 * @retval error value fail
548 int sync_agent_get_used_service_item_count_for_folder(int content_type, int account_id, char *folder_id);
551 * @brief Write data store items to file
555 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
557 ret = sync_agent_backup_service_items_to_file(FW_CONTACT, account_id, "/tmp/contact_backup");
558 if (ret != SYNC_AGENT_DA_SUCCESS) {
563 * @param[in] content_type service type - service data connector plug-in's ID described in F/W config file
564 * @param[in] account_id F/W account id
565 * @param[out] file_path written file path
566 * @return operation result
567 * @retval SYNC_AGENT_DA_SUCCESS success
568 * @retval error value fail
570 sync_agent_da_return_e sync_agent_backup_service_items_to_file(int content_type, int account_id, char **file_path);
573 * @brief Add file-written item to data store
577 sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
579 ret = sync_agent_restore_service_items_from_file(FW_CONTACT, account_id, "/tmp/contact_backup");
580 if (ret != SYNC_AGENT_DA_SUCCESS) {
585 * @param[in] content_type service type - service data connector plug-in's ID described in F/W config file
586 * @param[in] account_id F/W account id
587 * @param[in] file_path file path
588 * @return operation result
589 * @retval SYNC_AGENT_DA_SUCCESS success
590 * @retval error_value fail
592 sync_agent_da_return_e sync_agent_restore_service_items_from_file(int content_type, int account_id, const char *file_path);
595 * @brief Get service item id from framework service item id
599 char *item_id = NULL;
601 item_id = sync_agent_get_service_item_id(framework_item_id);
602 if (item_id != NULL) {
607 * @param[in] item_id item id
608 * @return operation result
609 * @retval service_item_id success
612 char *sync_agent_get_service_item_id(char *item_id);
615 * @brief Get service folder id from framework service folder id
619 char *folder_id = NULL;
621 folder_id = sync_agent_get_service_folder_id(framework_folder_id);
622 if (folder_id != NULL) {
627 * @param[in] folder_id folder id
628 * @return operation result
629 * @retval service_folder_id success
632 char *sync_agent_get_service_folder_id(char *folder_id);
641 #endif /* INTERFACE_SERVICE_ITEM_H_ */