Tizen 2.1 base
[platform/core/system/sync-agent.git] / include / data-adapter / interface_mapping.h
1 /*
2  * sync-agent
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
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
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  */
17
18 #ifndef INTERFACE_MAPPING_H_
19 #define INTERFACE_MAPPING_H_
20
21 #include "error.h"
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif                          /* __cplusplus */
26
27 /**
28  * @file                interface_mapping.h
29  * @brief
30  */
31
32 /** @addtogroup data_adapter
33  *      @{
34  */
35
36 /**
37  * @brief       Structure of framework mapping instance
38  */
39         typedef struct {
40                 int account_id; /**< F/W account id */
41                 int data_store_id;      /**< service data connector pluIn's ID described in F/W config file  */
42                 char *luid;             /**< Locally unique identifier */
43                 char *guid;             /**< Globally unique identifier */
44                 char *access_name;
45                                 /**< name of accessor */
46         } sync_agent_da_mapping_s;
47
48 /**
49  * @brief       Enumerations of option used to delete framework mapping instance
50  */
51         typedef enum {
52                 SYNC_AGENT_DA_DELETE_MAPPING_OPTION_ACCOUNT_ID,
53                                                         /**< delete mapping by account id */
54                 SYNC_AGENT_DA_DELETE_MAPPING_OPTION_LUID,               /**< delete mapping by luid */
55         } sync_agent_da_delete_mapping_option_e;
56
57 /**
58  * @brief       Structure of query used to delete framework mapping
59  */
60         typedef struct {
61                 sync_agent_da_delete_mapping_option_e option;
62                                                         /**< sync_agent_da_delete_mapping_option_e type of option */
63                 int account_id;
64                         /**< F/W account id - SYNC_AGENT_DA_DELETE_MAPPING_OPTION_ACCOUNT_ID, SYNC_AGENT_DA_DELETE_MAPPING_OPTION_LUID */
65                 char *luid;     /**< F/W luid - SYNC_AGENT_DA_DELETE_MAPPING_OPTION_LUID */
66         } sync_agent_da_delete_mapping_query_s;
67
68 /**
69  * @brief       Structure of query used to fetch framework mapping
70  */
71         typedef struct {
72                 int account_id;
73                         /**< F/W account id */
74                 char *luid;     /**< F/W luid */
75         } sync_agent_da_get_mapping_query_s;
76
77 /**
78  * @brief       Enumerations of option used to fetch list of framework mapping instance
79  */
80         typedef enum {
81                 SYNC_AGENT_DA_GET_MAPPING_LIST_OPTION_ACCOUNT_ID,
82                                                                 /**< get mapping list by account id */
83         } sync_agent_da_get_mapping_list_option_e;
84
85 /**
86  * @brief       Structure of query used to fetch list of framework mapping instance
87  */
88         typedef struct {
89                 sync_agent_da_get_mapping_list_option_e option;
90                                                         /**< sync_agent_da_get_mapping_list_option_e type of option */
91                 int account_id;
92                         /**< F/W account id - SYNC_AGENT_DA_GET_MAPPING_LIST_OPTION_ACCOUNT_ID */
93         } sync_agent_da_get_mapping_list_query_s;
94
95 /**
96  * @brief                       Create initialized framework mapping instance
97  * @par Usage:
98  * @code
99  
100  sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
101  sync_agent_da_mapping_s *mapping;
102  
103  ret = sync_agent_create_mapping(&mapping);
104  if (ret != SYNC_AGENT_DA_SUCCESS) {
105         ...
106  }
107  
108  * @endcode
109  * @param[out]  sync_agent_mapping                      sync_agent_da_mapping_s type of mapping instance newly initialied
110  * @return              operation result
111  * @retval              SYNC_AGENT_DA_SUCCESS           success
112  * @retval              error_value                                     fail
113  */
114         sync_agent_da_return_e sync_agent_create_mapping(sync_agent_da_mapping_s ** sync_agent_mapping);
115
116 /**
117  * @brief                       Add framework mapping instance into frameowrk db
118  * @par Usage:
119  * @code
120  
121  sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
122  sync_agent_da_mapping_s *mapping;
123  
124  ret = sync_agent_create_mapping(&mapping);
125  if (ret != SYNC_AGENT_DA_SUCCESS) {
126         ...
127  }
128
129  ...
130
131  ret = sync_agent_add_mapping(mapping);
132  if (ret != SYNC_AGENT_DA_SUCCESS) {
133         ...
134  }
135  
136  * @endcode
137  * @param[in]           sync_agent_mapping                      sync_agent_da_mapping_s type of mapping instance to add into framework
138  * @return              operation result
139  * @retval              SYNC_AGENT_DA_SUCCESS           success
140  * @retval              error_value                                     fail
141  */
142         sync_agent_da_return_e sync_agent_add_mapping(sync_agent_da_mapping_s * sync_agent_mapping);
143
144 /**
145  * @brief                       Delete framework mapping instance from frameowrk db
146  * @par Usage:
147  * @code
148  
149  sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
150  sync_agent_da_delete_mapping_query_s query;
151  
152  query.option = SYNC_AGENT_DA_DELETE_MAPPING_OPTION_ACCOUNT_ID;
153  query.account_id = account_id;
154
155  ret = sync_agent_delete_mapping(&query);
156  if (ret != SYNC_AGENT_DA_SUCCESS) {
157         ...
158  }
159  
160  * @endcode
161  * @param[in]           query                                           sync_agent_da_delete_mapping_query_s type of query to apply to delete operation
162  * @return              operation result
163  * @retval              SYNC_AGENT_DA_SUCCESS           success
164  * @retval              error_value                                     fail
165  */
166         sync_agent_da_return_e sync_agent_delete_mapping(sync_agent_da_delete_mapping_query_s * query);
167
168 /**
169  * @brief                       Fetch framework mapping from framework db
170  * @par Usage:
171  * @code
172  
173  sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
174  sync_agent_da_get_mapping_query_s query;
175  sync_agent_da_mapping_s *mapping = NULL;
176
177  query.account_id = account_id;
178  query.luid = framework_id;
179
180  ret = sync_agent_get_mapping(&query, &mapping);
181  if (ret != SYNC_AGENT_DA_SUCCESS) {
182         ...
183  }
184  
185  * @endcode
186  * @param[in]           query                                           sync_agent_da_get_mapping_query_s type of query to apply to fetch operation
187  * @param[out]  sync_agent_mapping                      sync_agent_da_mapping_s type of mapping instance fetched
188  * @return              operation result
189  * @retval              SYNC_AGENT_DA_SUCCESS           success
190  * @retval              error_value                                     fail
191  */
192         sync_agent_da_return_e sync_agent_get_mapping(sync_agent_da_get_mapping_query_s * query, sync_agent_da_mapping_s ** sync_agent_mapping);
193
194 /**
195  * @brief                       Fetch list of framework mapping from framework db
196  * @par Usage:
197  * @code
198  
199  sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
200  sync_agent_da_get_mapping_list_query_s query;
201  GList *mapping_list = NULL;
202
203  query.option = SYNC_AGENT_DA_GET_MAPPING_LIST_OPTION_ACCOUNT_ID;
204  query.account_id = account_id;
205
206  ret = sync_agent_get_mapping_list(&query, &mapping_list);
207  if (ret != SYNC_AGENT_DA_SUCCESS) {
208         ...
209  }
210  
211  * @endcode
212  * @param[in]           query                                           sync_agent_da_get_mapping_list_query_s type of query to apply to fetch operation
213  * @param[out]  list                                                    GList type of list which will be filled with mapping instances fetched
214  * @return              operation result
215  * @retval              SYNC_AGENT_DA_SUCCESS           success
216  * @retval              error_value                                     fail
217  */
218         sync_agent_da_return_e sync_agent_get_mapping_list(sync_agent_da_get_mapping_list_query_s * query, GList ** list);
219
220 /**
221  * @brief                       Free framework mapping fetched from framework db
222  * @par Usage:
223  * @code
224  
225  sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
226  sync_agent_da_get_mapping_query_s query;
227  sync_agent_da_mapping_s *mapping = NULL;
228
229  query.account_id = account_id;
230  query.luid = framework_id;
231
232  ret = sync_agent_get_mapping(&query, &mapping);
233  if (ret != SYNC_AGENT_DA_SUCCESS) {
234         ...
235  }
236
237  ...
238
239  ret = sync_agent_free_mapping(mapping);
240  if (ret != SYNC_AGENT_DA_SUCCESS) {
241         ...
242  }
243  
244  * @endcode
245  * @param[in]           sync_agent_mapping                      sync_agent_da_mapping_s type of mapping instance to free
246  * @return              operation result
247  * @retval              SYNC_AGENT_DA_SUCCESS           success
248  * @retval              error_value                                     fail
249  */
250         sync_agent_da_return_e sync_agent_free_mapping(sync_agent_da_mapping_s * sync_agent_mapping);
251
252 /**
253  * @brief                       Free framework list of mappint fetched from framework db
254  * @par Usage:
255  * @code
256  
257  sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
258  sync_agent_da_get_mapping_list_query_s query;
259  GList *mapping_list = NULL;
260
261  query.option = SYNC_AGENT_DA_GET_MAPPING_LIST_OPTION_ACCOUNT_ID;
262  query.account_id = account_id;
263
264  ret = sync_agent_get_mapping_list(&query, &mapping_list);
265  if (ret != SYNC_AGENT_DA_SUCCESS) {
266         ...
267  }
268
269  ...
270
271  ret = sync_agent_free_mapping_list(mapping_list);
272  if (ret != SYNC_AGENT_DA_SUCCESS) {
273         ...
274  }
275  
276  * @endcode
277  * @param[in]           list                                                    GList type of list which is filled with mapping instances to free
278  * @return              operation result
279  * @retval              SYNC_AGENT_DA_SUCCESS           success
280  * @retval              error_value                                     fail
281  */
282         sync_agent_da_return_e sync_agent_free_mapping_list(GList * list);
283
284 /**
285  * @brief                       Check whether framework has mapping information related to given account id
286  * @par Usage:
287  * @code
288  
289  int result = sync_agent_is_exist_mapping_by_account_id(account_id);
290  if (result == 1) {
291         ...
292  } else {
293         ...
294  }
295  
296  * @endcode
297  * @param[in]           account_id                                      accound id
298  * @return              checking result
299  * @retval              1                                                       exist
300  * @retval              0(or error value)                               not exist
301  */
302         int sync_agent_is_exist_mapping_by_account_id(int account_id);
303
304 /**
305  *      @}
306  */
307
308 #ifdef __cplusplus
309 }
310 #endif                          /* __cplusplus */
311 #endif                          /* INTERFACE_MAPPING_H_ */