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 DATA_CONNECTOR_INTERFACE_H_
19 #define DATA_CONNECTOR_INTERFACE_H_
21 #include "data-adapter/error.h"
23 #include "data_connector_resource.h"
27 #endif /* __cplusplus */
30 * @file data_connector_interface.h
31 * @brief Interface list in this header will be implemented plugIn developer.
32 * @remarks Implementation will operate sync-agent-framework data-adapter module.
35 /** @addtogroup plugin_dataconnector DataConnector Domain
41 * API to connect(open) to the service
43 * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
48 * @see sync_agent_plugin_open_service()
51 sync_agent_da_return_e sync_agent_plugin_open_service(void);
54 * API to disconnect(close) to the service
56 * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
61 * @see sync_agent_plugin_close_service()
64 sync_agent_da_return_e sync_agent_plugin_close_service(void);
67 * API to start transaction for service storage
69 * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
74 * @see sync_agent_plugin_begin_transaction()
77 sync_agent_da_return_e sync_agent_plugin_begin_transaction(void);
80 * API to end transaction for service storage
82 * @param[in] is_success flag to decide commit/rollback (1:commit, 0:rollback)
84 * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
89 * @see sync_agent_plugin_end_transaction(int)
92 sync_agent_da_return_e sync_agent_plugin_end_transaction(int is_success);
95 * API to insert item into service storage
97 * @param[in] account_id service account id
98 * @param[in] folder_id service folder id
99 * @param[in] data data to add to the service
100 * @param[in] item_id as returned by sync_agent_plugin_add_item() - success : id of the newly item added to the service, error : NULL
102 * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
107 * @see sync_agent_plugin_add_item(int, char *, void *, char **)
110 sync_agent_da_return_e sync_agent_plugin_add_item(int account_id, char *folder_id, void *data, char **item_id);
113 * API to insert item into service storage
115 * @param[in] account_id service account id
116 * @param[in] folder_id service folder id
117 * @param[in] data data to add to the service
118 * @param[in] item_id as returned by sync_agent_plugin_add_bulk_item() - success : id of the newly item added to the service, error : NULL
120 * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
125 * @see sync_agent_plugin_add_bulk_item(int, char *, void *, int **, int *)
128 sync_agent_da_return_e sync_agent_plugin_add_bulk_item(int account_id, char *folder_id, void *data, int **item_id, int *item_id_count);
131 * API to update item from service storage
133 * @param[in] account_id service account id
134 * @param[in] folder_id service folder id
135 * @param[in] item_id service item id
136 * @param[in] data data to update to the service
138 * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
143 * @see sync_agent_plugin_update_item(int, char *, char *, void *)
146 sync_agent_da_return_e sync_agent_plugin_update_item(int account_id, char *folder_id, char *item_id, void *data);
149 * API to update item from service storage
151 * @param[in] data data to update to the service
153 * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
158 * @see sync_agent_plugin_update_bulk_item(void *)
161 sync_agent_da_return_e sync_agent_plugin_update_bulk_item(void *data);
164 * API to delete item from service storage
166 * @param[in] account_id service account id
167 * @param[in] folder_id service folder id
168 * @param[in] item_id service id of item expected to be deleted
170 * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
175 * @see sync_agent_plugin_delete_item(int, char *, char *)
178 sync_agent_da_return_e sync_agent_plugin_delete_item(int account_id, char *folder_id, char *item_id);
181 * API to delete item from service storage
183 * @param[in] item_id service id of item expected to be deleted
184 * @param[in] count count of service item id expected to be deleted
186 * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
191 * @see sync_agent_plugin_delete_bulk_item(int *, int)
194 sync_agent_da_return_e sync_agent_plugin_delete_bulk_item(int *item_id, int count);
198 * API to delete all items from service storage
200 * @param[in] account_id service account id
202 * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
207 * @see sync_agent_plugin_delete_all_items(int)
210 sync_agent_da_return_e sync_agent_plugin_delete_all_items(int account_id);
213 * API to get item from service storage
215 * @param[in] account_id service account id
216 * @param[in] folder_id service folder id
217 * @param[in] item_id expected to get service item id
218 * @param[in] data as returned by sync_agent_plugin_get_item() - success : item info, error : NULL
220 * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
225 * @see sync_agent_plugin_get_item(int, char *, char *, void **)
228 sync_agent_da_return_e sync_agent_plugin_get_item(int account_id, char *folder_id, char *item_id, void **data);
231 * API to insert folder into service storage
233 * @param[in] account_id service account id
234 * @param[in] folder_name folder name
235 * @param[in] folder_type folder type
236 * @param[in] folder_id as returned by sync_agent_plugin_add_folder() - success : id of the newly folder added to the service, fail : NULL
238 * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
243 * @see sync_agent_plugin_add_folder(int, char *, int, char **)
246 sync_agent_da_return_e sync_agent_plugin_add_folder(int account_id, char *folder_name, int folder_type, char **folder_id);
249 * API to delete folder from service storage
251 * @param[in] account_id service account id
252 * @param[in] folder_id service folder id
254 * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
259 * @see sync_agent_plugin_delete_folder(int, char *)
262 sync_agent_da_return_e sync_agent_plugin_delete_folder(int account_id, char *folder_id);
265 * API to get folder info from service storage
267 * @param[in] account_id service account id
268 * @param[in] folder_id service folder id
269 * @param[in] out_folder_name as returned by sync_agent_plugin_get_folder() - success : folder name, fail : NULL
270 * @param[in] out_folder_type as returned by sync_agent_plugin_get_folder() - success : folder type, fail : -1
272 * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
277 * @see sync_agent_plugin_get_folder(int, char *, char **, int *)
280 sync_agent_da_return_e sync_agent_plugin_get_folder(int account_id, char *folder_id, char **out_folder_name, int *out_folder_type);
283 * API to execute data into service
285 * @param[in] account_id service account id
286 * @param[in] execute_key execute key
287 * @param[in] execute_values execute values
288 * @param[in] result as returned by sync_agent_plugin_execute() - extension result info
290 * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
295 * @see sync_agent_plugin_execute(int, const char *, void *, void **)
298 sync_agent_da_return_e sync_agent_plugin_execute(int account_id, const char *execute_key, void *execute_values, void **result);
301 * API to get item used count
303 * @return current_item_count on success, negative value on error
308 * @see sync_agent_plugin_get_used_item_count()
311 int sync_agent_plugin_get_used_item_count(void);
314 * API to get item used count for folder
316 * @param[in] account_id service account id
317 * @param[in] folder_id service folder id
319 * @return current_item_count on success, negative value on error
324 * @see sync_agent_plugin_get_used_item_count_for_folder(int, char *)
327 int sync_agent_plugin_get_used_item_count_for_folder(int account_id, char *folder_id);
330 * API to get folder id list of a account
332 * @param[in] account_id service account id
333 * @param[in] folder_count as returned by sync_agent_plugin_get_folder_id_list() - success : folder count, fail or not exist : 0
334 * @param[in] folder_type_list as returned by sync_agent_plugin_get_folder_id_list() - success : list, fail or not exist : NULL
336 * @return folder_id_list on success, NULL on error or not exist
341 * @see sync_agent_plugin_get_folder_id_list(int, int *, int **)
344 char **sync_agent_plugin_get_folder_id_list(int account_id, int *folder_count, int **folder_type_list);
347 * API to get all account id list that service has currently
349 * @param[in] count as returned by sync_agent_plugin_get_account_id_list() - success : count of account id, fail or not exist : 0
350 * @return account_id_list on success, NULL on fail or not exist
355 * @see sync_agent_plugin_get_account_id_list(int *)
358 int *sync_agent_plugin_get_account_id_list(int *count);
361 * API to write data store items to file
363 * @param[in] account_id service account id
364 * @param[in] file_path as returned by sync_agent_plugin_backup_service_items_to_file() - written file path
366 * @return SYNC_AGENT_DA_SUCCESS on success, minus value on error
371 * @see sync_agent_plugin_backup_service_items_to_file(int, char **)
374 sync_agent_da_return_e sync_agent_plugin_backup_service_items_to_file(int account_id, char **file_path);
377 * API to add file wrote item to data store
379 * @param[in] account_id service account id
380 * @param[in] file_path file path
382 * @return SYNC_AGENT_DA_SUCCESS on success, minus value on error
387 * @see sync_agent_plugin_restore_service_items_from_file(int, const char *)
390 sync_agent_da_return_e sync_agent_plugin_restore_service_items_from_file(int account_id, const char *file_path);
393 * API to get added item list after specific point
395 * @param[in] account_id service account id
396 * @param[in] folder_id service folder id
397 * @param[in] changepoint specific point
398 * @param[in] changeCount as returned by sync_agent_plugin_get_changed_item_for_folder_add() - success : added item count, fail or not exist : NULL
400 * @return added_item_info_list (if exist) on success, NULL on error or not exist
405 * @see sync_agent_plugin_get_changed_item_for_folder_add(int, const char *, int, int *)
408 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);
411 * API to get deleted item list after specific point
413 * @param[in] account_id service account id
414 * @param[in] folder_id service folder id
415 * @param[in] changepoint specific point
416 * @param[in] changeCount as returned by sync_agent_plugin_get_changed_item_for_folder_delete() - success : deleted item count, fail or not exist : NULL
418 * @return deleted_item_info_list (if exist) on success, NULL on error or not exist
423 * @see sync_agent_plugin_get_changed_item_for_folder_delete(int, const char *, int, int *)
426 sync_agent_plugin_item_node_s *sync_agent_plugin_get_changed_item_for_folder_delete(int account_id, const char *folder_id, int changepoint, int *changeCount);
429 * API to get updated item list after specific point
431 * @param[in] account_id service account id
432 * @param[in] folder_id service folder id
433 * @param[in] changepoint specific point
434 * @param[in] changeCount as returned by sync_agent_plugin_get_changed_item_for_folder_update() - success : updated item count, fail or not exist : NULL
436 * @return updated_item_info_list (if exist) on success, NULL on error or not exist
441 * @see sync_agent_plugin_get_changed_item_for_folder_update(int, const char *, int, int *)
444 sync_agent_plugin_item_node_s *sync_agent_plugin_get_changed_item_for_folder_update(int account_id, const char *folder_id, int changepoint, int *changeCount);
447 * API to get last storage change point information
449 * @return last storage changing point information on success, 0 on error
454 * @see sync_agent_plugin_get_last_change_point()
457 int sync_agent_plugin_get_last_change_point(void);
460 * API to check notification for the storage change
462 * @param[in] data user data
467 * @see sync_agent_plugin_start_listening_change_noti(void *)
470 void sync_agent_plugin_start_listening_change_noti(void *data);
473 * API to set callback function to handle added item to storage
475 * @param[in] callback callback function - this function is provided from sync-agent-framework
480 * @see data_connector_resource.h
483 void sync_agent_plugin_set_callback_add_item(sync_agent_add_item_cb_plugin callback);
486 * API to set callback function to handle deleted item to storage
488 * @param[in] callback callback function - this function is provided from sync-agent-framework
493 * @see data_connector_resource.h
496 void sync_agent_plugin_set_callback_delete_item(sync_agent_del_item_cb_plugin callback);
499 * API to set callback function to handle updated item to storage
501 * @param[in] callback callback function - this function is provided from sync-agent-framework
506 * @see data_connector_resource.h
509 void sync_agent_plugin_set_callback_update_item(sync_agent_update_item_cb_plugin callback);
512 * API to set callback function to get service account id list mapped sync-agent-framework account id
514 * @param[in] callback callback function - this function is provided from sync-agent-framework
519 * @see data_connector_resource.h
522 void sync_agent_plugin_set_callback_get_account_id_list(sync_agent_get_account_id_list_cb_plugin callback);
525 * API to get max item count per folder
527 * @param[in] folder_type folder type provided plugin
529 * @return max item count on success, -1 on error
534 * @see sync_agent_plugin_get_max_item_count(int)
536 int sync_agent_plugin_get_max_item_count(int folder_type);
539 * API to get service data's available field length
541 * @param[in] field_name field_name provided data-connector plugin
542 * @param[in] child_field_name child field name provided data-connector plugin
544 * @return available_field_length on success, -1 on error
549 * @see sync_agent_plugin_get_max_field_length(int, int)
552 int sync_agent_plugin_get_max_field_length(int field_name, int child_field_name);
555 * API to get service data's available field count
557 * @param[in] field_name field_name provided data-connector plugin
558 * @param[in] child_field_name child field name provided data-connector plugin
560 * @return available_field_count on success, -1 on error
565 * @see sync_agent_plugin_get_max_field_count(int, int)
568 int sync_agent_plugin_get_max_field_count(int field_name, int child_field_name);
571 * API to get service data's available field value's domain
573 * @param[in] field_name field name provided data-connector plugin
574 * @param[in] child_field_name child field name provided data-connector plugin
575 * @param[in] str_val as returned by sync_agent_plugin_get_field_value() - when domain value is string
576 * @param[in] num_val1 as returned by sync_agent_plugin_get_field_value() - when domain value is integer (ex minimum value)
577 * @param[in] num_val2 as returned by sync_agent_plugin_get_field_value() - when domain value is integer (ex maximum value)
579 * @return 1 on success, -1 on error
584 * @see sync_agent_plugin_get_field_value(int, int, char **, int *, int *)
587 int sync_agent_plugin_get_field_value(int field_name, int child_field_name, char **str_val, int *num_val1, int *num_val2);
590 * API to get service data's available field count
592 * @param[in] feature feature provided data-connector plugin
594 * @return 1 : support, 0 : not support on success, -1 on error
599 * @see sync_agent_plugin_get_is_support_feature(int)
602 int sync_agent_plugin_get_is_support_feature(int feature);
609 #endif /* __cplusplus */
610 #endif /* DATA_CONNECTOR_INTERFACE_H_ */