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 ACCOUNT_MANAGER_H_
19 #define ACCOUNT_MANAGER_H_
25 #endif /* __cplusplus */
29 * @brief Support to use framework Account module
32 /** @addtogroup account
37 * @brief Enumerations of error codes for Account module
40 SYNC_AGENT_ACC_SUCCESS,
41 /**< when account operation is succeed */
42 SYNC_AGENT_ACC_FAIL, /**< when account operation is failed */
43 SYNC_AGENT_ACC_EMPTY, /**< when account is not exist */
44 SYNC_AGENT_ACC_CHANGED
45 /**< when account storage changed */
46 } sync_agent_acc_error_e;
49 * @brief Structure of Framework Account instance
52 int account_id; /**< account id */
53 char *email; /**< e-mail address */
54 char *password; /**< password */
55 int enable; /**< state flag */
56 char *access_name; /**< access name */
57 } sync_agent_fw_account_s;
60 * @brief Enumerations of Account query type
63 ACCOUNT_QUERY_BY_NONE, /**< type of no query */
64 ACCOUNT_QUERY_BY_ACCESS_NAME, /**< type by access name */
65 ACCOUNT_QUERY_BY_SERVICE_TYPE, /**< type by service */
66 ACCOUNT_QUERY_BY_SERVICE_TYPE_SERVICE_ID_INDEX, /**< type by service id */
67 } sync_agent_fw_account_query_type_e;
70 * @brief Structure of Framework Account query instance
73 sync_agent_fw_account_query_type_e query; /**< type of query */
74 char *access_name; /**< access name */
75 int service_type; /**< service type */
76 int service_account_id; /**< service account id */
77 int index; /**< index */
78 int fw_account_id; /**< framework account id */
79 } sync_agent_fw_account_query_s;
82 * @brief Create sync_agent_fw_account_s struct
86 sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
87 sync_agent_fw_account_s *fw_account = NULL;
89 account_err = sync_agent_create_fw_account(&fw_account);
90 if (account_err != SYNC_AGENT_ACC_SUCCESS) {
95 * @param[out] account instance of framework account info
96 * @return SYNC_AGENT_ACC_SUCCESS on success, otherwise a error value.
97 * @retval SYNC_AGENT_ACC_SUCCESS Successful
98 * @retval SYNC_AGENT_ACC_FAIL When memory allocation is failed
100 sync_agent_acc_error_e sync_agent_create_fw_account(sync_agent_fw_account_s ** account);
103 * @brief Register a new account to SyncAgent
108 sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
110 account_err = sync_agent_add_fw_account(fw_account, &account_id);
111 if (account_err != SYNC_AGENT_ACC_SUCCESS) {
116 * @param[in] account instance of framework account info
117 * @param[out] account_id framework account id
118 * @return SYNC_AGENT_ACC_SUCCESS on success, otherwise a error value.
119 * @retval SYNC_AGENT_ACC_SUCCESS Successful
120 * @retval SYNC_AGENT_ACC_FAIL When add account is failed
122 sync_agent_acc_error_e sync_agent_add_fw_account(sync_agent_fw_account_s * account, int *account_id);
125 * @brief Update account info
129 sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
131 account_err = sync_agent_update_fw_account(fw_account);
132 if (account_err != SYNC_AGENT_ACC_SUCCESS) {
137 * @param[in] account instance of framework account info
138 * @return SYNC_AGENT_ACC_SUCCESS on success, otherwise a error value.
139 * @retval SYNC_AGENT_ACC_SUCCESS Successful
140 * @retval SYNC_AGENT_ACC_FAIL When update account is failed
142 sync_agent_acc_error_e sync_agent_update_fw_account(sync_agent_fw_account_s * account);
145 * @brief Delete account
149 sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
151 account_err = sync_agent_delete_fw_account(account_id);
152 if (account_err != SYNC_AGENT_ACC_SUCCESS) {
157 * @param[in] account_id framework account id
158 * @return SYNC_AGENT_ACC_SUCCESS on success, otherwise a error value.
159 * @retval SYNC_AGENT_ACC_SUCCESS Successful
160 * @retval SYNC_AGENT_ACC_FAIL When update account is failed
162 sync_agent_acc_error_e sync_agent_delete_fw_account(int account_id);
165 * @brief Get account info
169 sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
170 sync_agent_fw_account_s *fw_account = NULL;
172 account_err = sync_agent_get_fw_account(account_id, &fw_account);
173 if (account_err != SYNC_AGENT_ACC_SUCCESS) {
178 * @param[in] account_id framework account id
179 * @param[out] account instance of framework account info
180 * @return SYNC_AGENT_ACC_SUCCESS on success, otherwise a error value.
181 * @retval SYNC_AGENT_ACC_SUCCESS Successful
182 * @retval SYNC_AGENT_ACC_FAIL when update account is failed
184 sync_agent_acc_error_e sync_agent_get_fw_account(int account_id, sync_agent_fw_account_s ** account);
187 * @brief Get account info by query
191 sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
192 sync_agent_fw_account_query_s query;
193 GList *account_info_list = NULL;
195 query.query = ACCOUNT_QUERY_BY_SERVICE_TYPE;
196 query.service_type = FW_CONTACT;
198 account_err = sync_agent_query_fw_account(&query, &account_info_list);
199 if (account_err != SYNC_AGENT_ACC_SUCCESS)
204 * @param[in] query instance of framework account query
205 * @param[out] list list of instance of framework account info
206 * @return SYNC_AGENT_ACC_SUCCESS on success, otherwise a error value.
207 * @retval SYNC_AGENT_ACC_SUCCESS Successful
208 * @retval SYNC_AGENT_ACC_FAIL when update account is failed
210 sync_agent_acc_error_e sync_agent_query_fw_account(sync_agent_fw_account_query_s * query, GList ** list);
213 * @brief Free sync_agent_fw_account_s struct
217 sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
218 sync_agent_fw_account_s *fw_account = NULL;
220 account_err = sync_agent_get_fw_account(account_id, &fw_account);
222 sync_agent_free_fw_account(fw_account);
225 * @param[in] fw_account instance of framework account info
227 void sync_agent_free_fw_account(sync_agent_fw_account_s * fw_account);
230 * @brief Free list of sync_agent_fw_account_s struct
234 sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
235 sync_agent_fw_account_query_s query;
236 GList *account_info_list = NULL;
238 query.query = ACCOUNT_QUERY_BY_SERVICE_TYPE;
239 query.service_type = 1;
241 account_err = sync_agent_query_fw_account(&query, &account_info_list);
243 sync_agent_free_fw_account_list(account_info_list);
246 * @param[in] list list of instance of framework account info
248 void sync_agent_free_fw_account_list(GList * list);
256 #endif /* __cplusplus */
257 #endif /* ACCOUNT_MANAGER_H_ */