merge from 2.4
[platform/core/api/libaccount-service.git] / include / account_internal.h
1 /*
2  *  account
3  *
4  * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Wonyoung Lee <wy1115.lee@samsung.com>, Sungchan Kim <sungchan81.kim@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #ifndef __ACCOUNT_INTERNAL_H__
23 #define __ACCOUNT_INTERNAL_H__
24
25 #include "account-types.h"
26 #include "account.h"
27
28 #ifdef __cplusplus
29 extern "C"
30 {
31 #endif
32
33 #ifndef ACCOUNT_INTERNAL_API
34 #define ACCOUNT_INTERNAL_API __attribute__ ((visibility("default")))
35 #endif
36
37 /**
38  * @file        account_internal.h
39  * @brief       This file contains the Account API for account management.
40  */
41
42 /**
43  * @internal
44  * @brief  Deletes an account from the account database by package name.
45  *
46  * @since_tizen 2.4
47  * @privlevel  public
48  * @privilege  %http://tizen.org/privilege/account.read \n
49  *             %http://tizen.org/privilege/account.write
50  * @remarks    This API need both privileges
51  * @param[in]  package_name  The package name of account(s) to delete
52  *
53  * @return  @c 0 on success,
54  *          otherwise a negative error value
55  * @retval  #ACCOUNT_ERROR_NONE               Successful
56  * @retval  #ACCOUNT_ERROR_INVALID_PARAMETER  Invalid parameter
57  * @retval  #ACCOUNT_ERROR_DB_FAILED          Database operation failed
58  * @retval  #ACCOUNT_ERROR_PERMISSION_DENIED  DB Access fail by permission
59  * @retval  #ACCOUNT_ERROR_DATABASE_BUSY      SQLite handler is busy
60  * @retval  #ACCOUNT_ERROR_DB_NOT_OPENED      Account database did not opened
61  *
62  * @see account_connect()
63  * @see account_insert_to_db()
64  * @see account_delete_from_db_by_id()
65  * @see account_delete_from_db_by_user_name()
66  * @see account_update_to_db_by_id()
67  * @see account_update_to_db_by_user_name()
68  */
69 int account_delete_from_db_by_package_name_offline(const char *package_name);
70
71 /**
72  * @internal
73  * @brief  Updates the account details to the account database without checking provider's permission.
74  *
75  * @since_tizen 2.3
76  * @privlevel  public
77  * @privilege  %http://tizen.org/privilege/account.read \n
78  *             %http://tizen.org/privilege/account.write
79  * @remarks    This API need both privileges
80  * @param[in]  account     The account handle
81  * @param[in]  account_id  The account ID to update
82  *
83  * @return  @c 0 on success,
84  *          otherwise a negative error value
85  * @retval  #ACCOUNT_ERROR_NONE               Successful
86  * @retval  #ACCOUNT_ERROR_OUT_OF_MEMORY      Out of Memory
87  * @retval  #ACCOUNT_ERROR_INVALID_PARAMETER  Invalid parameter
88  * @retval  #ACCOUNT_ERROR_DB_FAILED          Database operation failed
89  * @retval  #ACCOUNT_ERROR_RECORD_NOT_FOUND   The account to update does not exist
90  * @retval  #ACCOUNT_ERROR_PERMISSION_DENIED  DB Access fail by permission
91  * @retval  #ACCOUNT_ERROR_DATABASE_BUSY      SQLite handler is busy
92  * @retval  #ACCOUNT_ERROR_DB_NOT_OPENED      Account database did not opened
93  *
94  * @pre  This function requires an open connection to an account service by account_connect().
95  *
96  * @see account_connect()
97  * @see account_insert_to_db()
98  * @see account_delete_from_db_by_id()
99  * @see account_delete_from_db_by_user_name()
100  * @see account_delete_from_db_by_package_name()
101  * @see account_update_to_db_by_user_name()
102  */
103 int account_update_to_db_by_id_without_permission(account_h account, int account_id);
104
105 /**
106  * @internal
107  * @brief  Sets the app ID.
108  *         It should be filled with your application ID. For example, com.tizen.testapp.
109  *
110  * @since_tizen 2.3
111  * @remarks     @a app_id is a mandatory field and does not allow duplicate app ID in the account provider database.
112  *
113  * @param[in]   account_type  The account provider handle \n
114  *                            It should be assigned by account_type_create().
115  * @param[in]   app_id        The application ID
116  *
117  * @return  @c 0 on success,
118  *          otherwise a negative error value
119  * @retval  #ACCOUNT_ERROR_NONE               Successful
120  * @retval  #ACCOUNT_ERROR_INVALID_PARAMETER  Invalid parameter
121  * @retval  #ACCOUNT_ERROR_OUT_OF_MEMORY      Out of memory
122  *
123  * @see account_type_get_app_id()
124  */
125 int account_type_set_app_id(account_type_h account_type, const char *app_id);
126
127 /**
128  * @internal
129  * @brief  Sets the service provider ID.
130  *         It should be filled with your service provider ID.
131  *
132  * @since_tizen 2.3
133  * @remarks    @a service_provider_id is a mandatory field.
134  *
135  * @param[in]  account_type         The account provider handle \n
136  *                                  It should be assigned by account_type_create().
137  * @param[in]  service_provider_id  The service provider ID
138  *
139  * @return  @c 0 on success,
140  *          otherwise a negative error value
141  * @retval  #ACCOUNT_ERROR_NONE               Successful
142  * @retval  #ACCOUNT_ERROR_INVALID_PARAMETER  Invalid parameter
143  * @retval  #ACCOUNT_ERROR_OUT_OF_MEMORY      Out of memory
144  *
145  * @see account_type_get_service_provider_id()
146  */
147 int account_type_set_service_provider_id(account_type_h account_type, const char *service_provider_id);
148
149 /**
150  * @internal
151  * @brief  Sets icon path.
152  *         It represents your service provider or an application.
153  *
154  * @since_tizen 2.3
155  * @remarks     @a icon_path is not a mandatory field. But when it is set, you can display this icon in the Add Account screen.
156  *
157  * @param[in]  account_type  The account provider handle\n
158  *                           It should be assigned by account_type_create().
159  * @param[in]  icon_path     The icon path of the application
160  *
161  * @return  @c 0 on success,
162  *          otherwise a negative error value
163  * @retval  #ACCOUNT_ERROR_NONE               Successful
164  * @retval  #ACCOUNT_ERROR_INVALID_PARAMETER  Invalid parameter
165  * @retval  #ACCOUNT_ERROR_OUT_OF_MEMORY      Out of memory
166  *
167  * @see account_type_get_icon_path()
168  */
169 int account_type_set_icon_path(account_type_h account_type, const char *icon_path);
170
171 /**
172  * @internal
173  * @brief  Sets small icon path.
174  *         It also represents your service provider or an application.
175  *
176  * @since_tizen 2.3
177  * @remarks     @a small_icon_path is not a mandatory field.
178  *
179  * @param[in]   account_type     The account provider handle \n
180  *                               It should be assigned by account_type_create().
181  * @param[in]   small_icon_path  The scaled icon of your application
182  *
183  * @return  @c 0 on success,
184  *          otherwise a negative error value
185  * @retval  #ACCOUNT_ERROR_NONE               Successful
186  * @retval  #ACCOUNT_ERROR_INVALID_PARAMETER  Invalid parameter
187  * @retval  #ACCOUNT_ERROR_OUT_OF_MEMORY      Out of memory
188  *
189  * @see account_type_get_small_icon_path()
190  */
191 int account_type_set_small_icon_path(account_type_h account_type, const char *small_icon_path);
192
193 /**
194  * @internal
195  * @brief  Sets support for multiple accounts.
196  *         It represents whether your application supports multiple accounts.
197  *
198  * @since_tizen 2.3
199  * @remarks     The default value of multiple account support is @c FALSE.
200  *
201  * @param[in]   account_type              The account provider handle \n
202  *                                        It should be assigned by account_type_create().
203  * @param[in]   multiple_account_support  Set @c TRUE if your application can support two or more accounts, \n
204  *                                        otherwise @c FALSE if your application can support only one account
205  *
206  * @return  @c 0 on success,
207  *          otherwise a negative error value
208  * @retval  #ACCOUNT_ERROR_NONE               Successful
209  * @retval  #ACCOUNT_ERROR_INVALID_PARAMETER  Invalid parameter
210  * @retval  #ACCOUNT_ERROR_OUT_OF_MEMORY      Out of memory
211  *
212  * @see account_type_get_multiple_account_support()
213  */
214 int account_type_set_multiple_account_support(account_type_h account_type, const bool multiple_account_support);
215
216 /**
217  * @internal
218  * @brief  Sets label and locale.
219  *         Label represents the name of an account provider.
220  *
221  * @since_tizen 2.3
222  * @param[in]   account_type  The account provider handle \n
223  *                            It should be assigned by account_type_create().
224  * @param[in]   label         The name of account depends on the specified locale
225  * @param[in]   locale        The locale is specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code.\n
226  *                            For example, "ko_KR" for Korean, "en_US" for American English.
227  *
228  * @return  @c 0 on success,
229  *          otherwise a negative error value
230  * @retval  #ACCOUNT_ERROR_NONE               Successful
231  * @retval  #ACCOUNT_ERROR_INVALID_PARAMETER  Invalid parameter
232  * @retval  #ACCOUNT_ERROR_OUT_OF_MEMORY      Out of memory
233  *
234  * @see account_type_get_label()
235  */
236 int account_type_set_label(account_type_h account_type, const char* label, const char* locale);
237
238 /**
239  * @internal
240  * @brief  Sets the capability.
241  *
242  * @since_tizen 2.3
243  * @param[in]   account_type      The account provider handle
244  * @param[in]   provider_feature  Th capability key of the account
245  *
246  * @return  @c 0 on success,
247  *          otherwise a negative error value
248  * @retval  #ACCOUNT_ERROR_NONE               Successful
249  * @retval  #ACCOUNT_ERROR_INVALID_PARAMETER  Invalid parameter
250  *
251  * @see account_set_capability()
252  */
253 int account_type_set_provider_feature(account_type_h account_type, const char* provider_feature);
254
255 /**
256  * @internal
257  * @brief  Inserts the account provider details to the database.
258  *
259  * @since_tizen 2.3
260  * @privlevel   public
261  * @privilege   %http://tizen.org/privilege/account.read \n
262  *              %http://tizen.org/privilege/account.write
263  * @remarks     this API need both privileges
264  * @param[in]   account_type     The account handle which is created by account_type_create() \n
265  * @param[out]  account_type_id  The account provider ID to be assigned after inserting the account provider handle
266  *
267  * @return  @c 0 on success,
268  *          otherwise a negative error value
269  * @retval  #ACCOUNT_ERROR_NONE               Successful
270  * @retval  #ACCOUNT_ERROR_INVALID_PARAMETER  Invalid parameter
271  * @retval  #ACCOUNT_ERROR_DB_FAILED          Database operation failed
272  * @retval  #ACCOUNT_ERROR_PERMISSION_DENIED  DB Access fail by permission
273  * @retval  #ACCOUNT_ERROR_DATABASE_BUSY      SQLite handler is busy
274  * @retval  #ACCOUNT_ERROR_DB_NOT_OPENED      Account database did not opened
275  *
276  * @pre   This function requires an open connection to an account service by account_connect().
277  * @post  account_disconnect() is recommended after insertion.
278  *
279  * @see account_connect()
280  * @see account_disconnect()
281  */
282 int account_type_insert_to_db(account_type_h account_type, int* account_type_id);
283
284 /**
285  * @internal
286  * @brief  Updates the account details to the account database.
287  *
288  * @since_tizen 2.3
289  * @privlevel   public
290  * @privilege   %http://tizen.org/privilege/account.read \n
291  *              %http://tizen.org/privilege/account.write
292  * @remarks     this API need both privileges
293  * @param[in]   account_type  The account handle which is created by account_type_create() \n
294  * @param[in]   app_id        The application ID of the account provider
295  *
296  * @return  @c 0 on success,
297  *          otherwise a negative error value
298  * @retval  #ACCOUNT_ERROR_NONE               Successful
299  * @retval  #ACCOUNT_ERROR_INVALID_PARAMETER  Invalid parameter
300  * @retval  #ACCOUNT_ERROR_DB_FAILED          Database operation failed
301  * @retval  #ACCOUNT_ERROR_PERMISSION_DENIED  DB Access fail by permission
302  * @retval  #ACCOUNT_ERROR_DATABASE_BUSY      SQLite handler is busy
303  *
304  * @pre   This function requires an open connection to an account service by account_connect().
305  * @post  account_disconnect() is recommended after update.
306  *
307  * @see account_connect()
308  * @see account_disconnect()
309  */
310 int account_type_update_to_db_by_app_id(const account_type_h account_type, const char* app_id);
311
312 /**
313  * @internal
314  * @brief  Deletes the account provider from the account database by application ID.
315  *
316  * @since_tizen 2.3
317  * @privlevel   public
318  * @privilege   %http://tizen.org/privilege/account.read \n
319  *              %http://tizen.org/privilege/account.write
320  * @remarks     this API need both privileges
321  * @param[in]   app_id  The application ID of account provider to be deleted
322  *
323  * @return  @c 0 on success,
324  *          otherwise a negative error value
325  * @retval  #ACCOUNT_ERROR_NONE               Successful
326  * @retval  #ACCOUNT_ERROR_INVALID_PARAMETER  Invalid parameter
327  * @retval  #ACCOUNT_ERROR_DB_FAILED          Database operation failed
328  * @retval  #ACCOUNT_ERROR_PERMISSION_DENIED  DB Access fail by permission
329  * @retval  #ACCOUNT_ERROR_DATABASE_BUSY      SQLite handler is busy
330  * @retval  #ACCOUNT_ERROR_DB_NOT_OPENED      Account database did not opened
331  *
332  * @pre  This function requires an open connection to an account service by account_connect().
333  *
334  * @see account_connect()
335  * @see account_disconnect()
336  */
337 int account_type_delete_by_app_id(const char* app_id);
338
339 /**
340  * @internal
341  * @brief       Start to subscribe account event through the given callback function
342  *
343  * @param[in]   account_subscribe       The account subscription handle
344  * @param[in]   cb_func When an account is removed from account database. It will be called with event message and account id.
345  * @param[in]   user_data user_data will be delivered to cb_func
346  *
347  * @return      0 on success, otherwise a negative error value.
348  * @retval      #ACCOUNT_ERROR_NONE Successful
349  * @retval      #ACCOUNT_ERROR_EVENT_SUBSCRIPTION_FAIL Subscription fail
350  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
351  *
352  * @see account_unsubscribe_notification()
353  * @see account_subscribe_notification()
354  */
355 int account_subscribe_notification_ex(account_subscribe_h account_subscribe, account_event_cb cb_func, void* user_data);
356
357 /**
358  * @internal
359  * @brief       Start to subscribe account event through the given callback function
360  *
361  * @param[in]   account_subscribe       The account subscription handle
362  * @param[in]   cb_func When an account is removed from account database. It will be called with event message and account id.
363  * @param[in]   user_data user_data will be delivered to cb_func
364  *
365  * @return      0 on success, otherwise a negative error value.
366  * @retval      #ACCOUNT_ERROR_NONE Successful
367  * @retval      #ACCOUNT_ERROR_EVENT_SUBSCRIPTION_FAIL Subscription fail
368  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
369  *
370  * @see account_unsubscribe_notification()
371  * @see account_subscribe_notification()
372  */
373 int account_unsubscribe_notification_ex(account_subscribe_h account_subscribe);
374
375 /**
376  * @internal
377  * @brief  Gets the count of accounts whose secrect state is visible in the account database.
378  * @since_tizen 2.3
379  *
380  * @privlevel   public
381  * @privilege   %http://tizen.org/privilege/account.read
382  * @param[out]  count  The out parameter for count of all accounts
383  *
384  * @return  @c 0 on success,
385  *          otherwise a negative error value
386  * @retval  #ACCOUNT_ERROR_NONE       Successful
387  * @retval  #ACCOUNT_ERROR_DB_FAILED  Database operation failed
388  * @retval  #ACCOUNT_ERROR_ACCESS_DENIED DB Access fail by permission
389  *
390  * @pre  This function requires an open connection to an account service by account_connect().
391  *
392  */
393 int account_get_total_count_from_db_ex(int *count);
394
395 /*offline apis*/
396 int account_type_insert_to_db_offline(account_type_h account_type, int* account_type_id);
397
398 int account_type_delete_by_app_id_offline(const char* app_id);
399
400 /**
401 * @}
402 */
403
404 #ifdef __cplusplus
405 }
406 #endif
407
408 #endif /* __ACCOUNT_INTERNAL_H__ */