Tizen 2.1 base
[platform/core/system/sync-agent.git] / include / data-adapter / interface_last_anchor.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_LAST_ANCHOR_H_
19 #define INTERFACE_LAST_ANCHOR_H_
20
21 #include "error.h"
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif                          /* __cplusplus */
26
27 /**
28  * @file                interface_last_anchor.h
29  * @brief
30  */
31
32 /** @addtogroup data_adapter
33  *      @{
34  */
35
36 /**
37  * @brief       Structure of framework last anchor instance
38  */
39         typedef struct {
40                 int account_id;
41                         /**< F/W account id */
42                 int data_store_id;
43                                 /**< service data connector plug-in id described in F/W config file  */
44                 char *last_anchor_server;
45                                         /**< last anchor that server has */
46                 char *last_anchor_client;
47                                         /**< last anchor that client has */
48                 char *access_name;
49                                 /**< name of accessor */
50         } sync_agent_da_last_anchor_s;
51
52 /**
53  * @brief       Enumerations of option used to fetch framework last anchor instance
54  */
55         typedef enum {
56                 SYNC_AGENT_DA_GET_LAST_ANCHOR_LIST_OPTION_ITEM_TYPE_ID,
57                                                                 /**< get last anchor by item type id */
58         } sync_agent_da_get_last_anchor_list_option_e;
59
60 /**
61  * @brief       Structure of query used to fetch list of framework last anchor
62  */
63         typedef struct {
64                 sync_agent_da_get_last_anchor_list_option_e option;     /**< sync_agent_da_get_last_anchor_list_option_e type of option */
65                 int account_id;
66                         /**< F/W account id - SYNC_AGENT_DA_GET_LAST_ANCHOR_LIST_OPTION_ITEM_TYPE_ID */
67                 int item_type_id;
68                                 /**< F/W item type id - SYNC_AGENT_DA_GET_LAST_ANCHOR_LIST_OPTION_ITEM_TYPE_ID */
69         } sync_agent_da_get_last_anchor_list_query_s;
70
71 /**
72  * @brief                       Create initialized framework last anchor instance
73  * @par Usage:
74  * @code
75  
76  sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
77  sync_agent_da_last_anchor_s *anchor;
78  
79  ret = sync_agent_create_last_anchor(&anchor);
80  if (ret != SYNC_AGENT_DA_SUCCESS) {
81         ...
82  }
83  
84  * @endcode
85  * @param[out]  sync_agent_last_anchor                          sync_agent_da_last_anchor_s type of last anchor instance newly initialied
86  * @return              operation result
87  * @retval              SYNC_AGENT_DA_SUCCESS           success
88  * @retval              error_value                                     fail
89  * @return              operation result
90  * @retval              SYNC_AGENT_DA_SUCCESS           success
91  * @retval              error_value                                     fail
92  */
93         sync_agent_da_return_e sync_agent_create_last_anchor(sync_agent_da_last_anchor_s ** sync_agent_last_anchor);
94
95 /**
96  * @brief                       Add framework last anchor instance into frameowrk db
97  * @par Usage:
98  * @code
99  
100  sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
101  sync_agent_da_last_anchor_s *anchor;
102  
103  ret = sync_agent_create_last_anchor(&anchor);
104  if (ret != SYNC_AGENT_DA_SUCCESS) {
105         ...
106  }
107
108  ...
109
110  ret = sync_agent_add_last_anchor(anchor);
111  if (ret != SYNC_AGENT_DA_SUCCESS) {
112         ...
113  }
114  
115  * @endcode
116  * @param[in]           sync_agent_last_anchor                          sync_agent_da_last_anchor_s type of last anchor instance to add into framework
117  * @return              operation result
118  * @retval              SYNC_AGENT_DA_SUCCESS           success
119  * @retval              error_value                                     fail
120  */
121         sync_agent_da_return_e sync_agent_add_last_anchor(sync_agent_da_last_anchor_s * sync_agent_last_anchor);
122
123 /**
124  * @brief                       Update framework last anchor on framework db
125  * @par Usage:
126  * @code
127  
128  sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
129  sync_agent_da_get_last_anchor_list_query_s query;
130  GList *anchor_list = NULL;
131
132  query.option = SYNC_AGENT_DA_GET_LAST_ANCHOR_LIST_OPTION_ITEM_TYPE_ID;
133  query.account_id = account_id;
134  query.item_type_id = FW_CONTACT;
135  
136  ret = sync_agent_get_last_anchor_list(&query, &anchor_list);
137  if (ret != SYNC_AGENT_DA_SUCCESS) {
138         ...
139  }
140
141  ...
142  
143  ret = sync_agent_update_last_anchor((sync_agent_da_last_anchor_s *)(anchor_list->data));
144  if (ret != SYNC_AGENT_DA_SUCCESS) {
145         ...
146  }
147
148  * @endcode
149  * @param[in]           sync_agent_last_anchor                          sync_agent_da_last_anchor_s type of last anchor instance to update into framework
150  * @return              operation result
151  * @retval              SYNC_AGENT_DA_SUCCESS           success
152  * @retval              error_value                                     fail
153  */
154         sync_agent_da_return_e sync_agent_update_last_anchor(sync_agent_da_last_anchor_s * sync_agent_last_anchor);
155
156 /**
157  * @brief                       Fetch framework last anchor from framework db
158  * @par Usage:
159  * @code
160  
161  sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
162  sync_agent_da_get_last_anchor_list_query_s query;
163  GList *anchor_list = NULL;
164
165  query.option = SYNC_AGENT_DA_GET_LAST_ANCHOR_LIST_OPTION_ITEM_TYPE_ID;
166  query.account_id = account_id;
167  query.item_type_id = FW_CONTACT;
168  
169  ret = sync_agent_get_last_anchor_list(&query, &anchor_list);
170  if (ret != SYNC_AGENT_DA_SUCCESS) {
171         ...
172  }
173  
174  * @endcode
175  * @param[in]           query                                                   sync_agent_da_get_last_anchor_list_query_s type of query to apply to fetch operation
176  * @param[out]  list                                                            GList type of list which will be filled with last anchor instances fetched
177  * @return              operation result
178  * @retval              SYNC_AGENT_DA_SUCCESS           success
179  * @retval              error_value                                     fail
180  */
181         sync_agent_da_return_e sync_agent_get_last_anchor_list(sync_agent_da_get_last_anchor_list_query_s * query, GList ** list);
182
183 /**
184  * @brief                       Free framework last anchor fetched from framework db
185  * @par Usage:
186  * @code
187  
188  sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
189  sync_agent_da_last_anchor_s *anchor;
190  
191  ret = sync_agent_create_last_anchor(&anchor);
192  if (ret != SYNC_AGENT_DA_SUCCESS) {
193         ...
194  }
195
196  ...
197
198  ret = sync_agent_free_last_anchor(anchor);
199  if (ret != SYNC_AGENT_DA_SUCCESS) {
200         ...
201  }
202  
203  * @endcode
204  * @param[in]           sync_agent_last_anchor                          sync_agent_da_last_anchor_s type of last anchor item to free
205  * @return              operation result
206  * @retval              SYNC_AGENT_DA_SUCCESS           success
207  * @retval              error_value                                     fail
208  */
209         sync_agent_da_return_e sync_agent_free_last_anchor(sync_agent_da_last_anchor_s * sync_agent_last_anchor);
210
211 /**
212  *      @}
213  */
214
215 #ifdef __cplusplus
216 }
217 #endif                          /* __cplusplus */
218 #endif                          /* INTERFACE_LAST_ANCHOR_H_ */