e5d28884727735a94eb3d8df6dbb75612f2c1f08
[framework/pim/libaccounts-svc.git] / include / account.h
1 /*
2  * libaccounts-svc
3  *
4  * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Tarun Kumar <tarun.kr@samsung.com>, Sukumar Moharana <msukumar@samsung.com>, Wonyoung Lee <wy1115.lee@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_H__
23 #define __ACCOUNT_H__
24
25 #include <stdlib.h>
26 #include <stdio.h>
27 #include <glib.h>
28 #include <account-types.h>
29 #include <account-error.h>
30
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #endif
35
36 /**
37  * @file        account.h
38  * @brief       This file contains the Account API for account management
39  */
40
41 /**
42  * @addtogroup CAPI_SOCIAL_ACCOUNT_MODULE
43  * @{
44  */
45
46 /**
47  * @brief       Called once for each account from database
48  *
49  * @param[in]   account The account handle
50  * @param[in]   user_data The user data passed from the foreach function
51  *
52  * @return @c true to continue with the next iteration of the loop or @c false to break out of the loop.
53  *
54  * @pre account_foreach_account_from_db(), account_query_account_by_account_id(), account_query_account_by_user_name() or account_query_account_by_package_name() invoke this callback.
55  *
56  * @see account_foreach_account_from_db()
57  * @see account_query_account_by_account_id()
58  * @see account_query_account_by_user_name()
59  * @see account_query_account_by_package_name()
60  */
61 typedef bool (*account_cb)(account_h account, void *user_data);
62
63
64 /**
65  * @brief       Called once for each capability of account from database
66  *
67  * @param[in]   capability_type The capability type
68  * @param[in]   capability_state The capability state
69  * @param[in]   user_data The user data passed from the foreach function
70  *
71  * @return @c true to continue with the next iteration of the loop or @c false to break out of the loop.
72  *
73  * @pre account_query_capability_by_account_id() invokes this callback.
74  *
75  * @see account_query_capability_by_account_id()
76  */
77 typedef bool (*capability_cb)(account_capability_type_e capability_type, account_capability_state_e capability_state, void *user_data);
78
79
80 /**
81  * @brief       Connects to the account database.
82  *
83  * @return      0 on success, otherwise a negative error value.
84  * @retval      #ACCOUNT_ERROR_NONE Successful
85  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
86  *
87  * @see account_disconnect()
88  */
89 int account_connect(void);
90
91
92 /**
93  * @brief       Disconnects from account database.
94  *
95  * @return      0 on success, otherwise a negative error value.
96  * @retval      #ACCOUNT_ERROR_NONE Successful
97  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
98  *
99  * @see account_connect()
100  */
101 int account_disconnect(void);
102
103
104 /**
105  * @brief       Creates a handle to the account.
106  *
107  * @remarks     @a account must be released with account_destroy() by you. \n
108  *  The created handle is not added to the account database until account_insert_to_db() is called.
109  *
110  * @param[in]   account The account handle
111  *
112  * @return      0 on success, otherwise a negative error value.
113  * @retval      #ACCOUNT_ERROR_NONE Successful
114  * @retval      #ACCOUNT_ERROR_OUT_OF_MEMORY Out of Memory
115  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
116  *
117  * @see account_destroy()
118  */
119 int account_create(account_h *account);
120
121
122 /**
123  * @brief       Destroys the account handle and releases all its resources.
124  *
125  * @param[in]   account The account handle
126  *
127  * @return      0 on success, otherwise a negative error value.
128  * @retval      #ACCOUNT_ERROR_NONE     Successful
129  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
130  *
131  * @see account_create()
132  */
133 int account_destroy(account_h account);
134
135
136 /**
137  * @brief       Inserts the account details to the account database.
138  *
139  * @param[in]   account The account handle
140  * @param[out]  account_db_id The account ID to be assigned to a account
141  *
142  * @return      0 on success, otherwise a negative error value.
143  * @retval      #ACCOUNT_ERROR_NONE Successful
144  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
145  * @retval      #ACCOUNT_ERROR_DB_FAILED  Database operation failed
146  *
147  * @pre This function requires an open connection to account service by account_connect().
148  *
149  * @see account_connect()
150  * @see account_delete_from_db_by_id()
151  * @see account_delete_from_db_by_user_name()
152  * @see account_delete_from_db_by_package_name()
153  * @see account_update_to_db_by_id()
154  * @see account_update_to_db_by_user_name()
155  */
156 int account_insert_to_db(account_h account, int *account_db_id);
157
158
159 /**
160  * @brief       Deletes the account from the account database by accound DB ID.
161  *
162  * @param[in]   account_db_id The account ID to delete
163  *
164  * @return      0 on success, otherwise a negative error value.
165  * @retval      #ACCOUNT_ERROR_NONE Successful
166  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
167  * @retval      #ACCOUNT_ERROR_DB_FAILED  Database operation failed
168  *
169  * @pre This function requires an open connection to account service by account_connect()
170  *
171  * @see account_connect()
172  * @see account_insert_to_db()
173  * @see account_delete_from_db_by_user_name()
174  * @see account_delete_from_db_by_package_name()
175  * @see account_update_to_db_by_id()
176  * @see account_update_to_db_by_user_name()
177  */
178 int account_delete_from_db_by_id(int account_db_id);
179
180
181 /**
182  * @brief       Deletes the account from the account database by user name.
183  *
184  * @param[in]   user_name The user name of account to delete
185  * @param[in]   package_name The package name of account to delete
186  *
187  * @return      0 on success, otherwise a negative error value.
188  * @retval      #ACCOUNT_ERROR_NONE Successful
189  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
190  * @retval      #ACCOUNT_ERROR_DB_FAILED  Database operation failed
191  *
192  * @pre This function requires an open connection to account service by account_connect()
193  *
194  * @see account_connect()
195  * @see account_insert_to_db()
196  * @see account_delete_from_db_by_id()
197  * @see account_delete_from_db_by_package_name()
198  * @see account_update_to_db_by_id()
199  * @see account_update_to_db_by_user_name()
200  */
201 int account_delete_from_db_by_user_name(char *user_name, char *package_name);
202
203
204 /**
205  * @brief       Deletes the account from the account database by package name.
206  *
207  * @param[in]   package_name The package name of account(s) to delete
208  *
209  * @return      0 on success, otherwise a negative error value.
210  * @retval      #ACCOUNT_ERROR_NONE Successful
211  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
212  * @retval      #ACCOUNT_ERROR_DB_FAILED  Database operation failed
213  *
214  * @pre This function requires an open connection to account service by account_connect()
215  *
216  * @see account_connect()
217  * @see account_insert_to_db()
218  * @see account_delete_from_db_by_id()
219  * @see account_delete_from_db_by_user_name()
220  * @see account_update_to_db_by_id()
221  * @see account_update_to_db_by_user_name()
222  */
223 int account_delete_from_db_by_package_name(char *package_name);
224
225
226 /**
227  * @brief       Updates the account details to the account database.
228  *
229  * @param[in]   account The account handle
230  * @param[in]   account_id The account ID to update
231  *
232  * @return      0 on success, otherwise a negative error value.
233  * @retval      #ACCOUNT_ERROR_NONE Successful
234  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
235  * @retval      #ACCOUNT_ERROR_DB_FAILED  Database operation failed
236  *
237  * @pre This function requires an open connection to account service by account_connect()
238  *
239  * @see account_connect()
240  * @see account_insert_to_db()
241  * @see account_delete_from_db_by_id()
242  * @see account_delete_from_db_by_user_name()
243  * @see account_delete_from_db_by_package_name()
244  * @see account_update_to_db_by_user_name()
245  */
246 int account_update_to_db_by_id(account_h account, int account_id);
247
248
249 /**
250  * @brief       Updates the account details to the account database.
251  *
252  * @param[in]   account The account handle
253  * @param[in]   user_name The user name of account to update
254  * @param[in]   package_name The package name for the user name
255  *
256  * @return      0 on success, otherwise a negative error value.
257  * @retval      #ACCOUNT_ERROR_NONE Successful
258  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
259  * @retval      #ACCOUNT_ERROR_DB_FAILED  Database operation failed
260  *
261  * @pre This function requires an open connection to account service by account_connect()
262  *
263  * @see account_connect()
264  * @see account_insert_to_db()
265  * @see account_delete_from_db_by_id()
266  * @see account_delete_from_db_by_user_name()
267  * @see account_delete_from_db_by_package_name()
268  * @see account_update_to_db_by_id()
269  *
270  */
271 int account_update_to_db_by_user_name(account_h account, const char *user_name, const char *package_name);
272
273 /**
274  * @brief       Gets the account id of account.
275  *
276  *
277  * @param[in]   account The account handle
278  * @param[out]  account_id The account id of account
279  *
280  * @return      0 on success, otherwise a negative error value.
281  * @retval      #ACCOUNT_ERROR_NONE Successful
282  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
283  *
284  */
285 int account_get_account_id(account_h account, int *account_id);
286
287
288 /**
289  * @brief       Gets the user name of account.
290  *
291  * @remarks     @a user_name must be released with free() by you.
292  *
293  * @param[in]   account The account handle
294  * @param[out]  user_name The user name of account
295  *
296  * @return      0 on success, otherwise a negative error value.
297  * @retval      #ACCOUNT_ERROR_NONE Successful
298  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
299  * @retval      #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
300  *
301  * @see account_set_user_name()
302  */
303 int account_get_user_name(account_h account, char **user_name);
304
305
306 /**
307  * @brief       Sets the user name of account.
308  *
309  * @param[in]   account The account handle
310  * @param[in]   user_name The string to set as user name
311  *
312  * @return      0 on success, otherwise a negative error value.
313  * @retval      #ACCOUNT_ERROR_NONE Successful
314  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
315  *
316  * @see account_get_user_name()
317  */
318 int account_set_user_name(account_h account, const char *user_name);
319
320
321 /**
322  * @brief       Gets the display name of account.
323  *
324  * @remarks     @a display_name must be released with free() by you.
325  *
326  * @param[in]   account The account handle
327  * @param[out]  display_name The display name of account
328  *
329  * @return      0 on success, otherwise a negative error value.
330  * @retval      #ACCOUNT_ERROR_NONE Successful
331  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
332  * @retval      #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
333  *
334  * @see account_get_display_name()
335  */
336 int account_get_display_name(account_h account, char **display_name);
337
338
339 /**
340  * @brief       Sets the display name of account.
341  *
342  * @param[in]   account The account handle
343  * @param[in]   display_name The text string to set as the display name
344  *
345  * @return      0 on success, otherwise a negative error value.
346  * @retval      #ACCOUNT_ERROR_NONE Successful
347  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
348  *
349  * @see account_get_display_name()
350  */
351 int account_set_display_name(account_h account, const char *display_name);
352
353
354 /**
355  * @brief       Gets the capability detail of account.
356  *
357  * @param[in]   account The account handle
358  * @param[in]   callback The callback function
359  * @param[in]   user_data The user data to be passed to the callback function
360  *
361  * @return      0 on success, otherwise a negative error value.
362  * @retval      #ACCOUNT_ERROR_NONE Successful
363  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
364  *
365  * @see account_set_capability()
366  */
367 int account_get_capability(account_h account, capability_cb cb_func, void *user_data);
368
369
370 /**
371  * @brief       Sets the capability.
372  *
373  * @param[in]   account The account handle
374  * @param[in]   capability_type The capability type
375  * @param[in]   capability_state The capability state
376  *
377  * @return      0 on success, otherwise a negative error value.
378  * @retval      #ACCOUNT_ERROR_NONE Successful
379  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
380  *
381  * @see account_get_capability()
382  */
383 int account_set_capability(account_h account, account_capability_type_e capability_type, account_capability_state_e capability_state);
384
385
386 /**
387  * @brief       Gets the icon path.
388  *
389  * @remarks     @a icon_path must be released with free() by you.
390  *
391  * @param[in]   account The account handle
392  * @param[out]  icon_path The icon path
393  *
394  * @return      0 on success, otherwise a negative error value.
395  * @retval      #ACCOUNT_ERROR_NONE Successful
396  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
397  * @retval      #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
398  *
399  * @see account_set_icon_path()
400  */
401 int account_get_icon_path(account_h account, char **icon_path);
402
403
404 /**
405  * @brief       Sets the icon path.
406  *
407  * @param[in]   account The account handle
408  * @param[in]   icon_path The text string to set as a icon path
409  *
410  * @return      0 on success, otherwise a negative error value.
411  * @retval      #ACCOUNT_ERROR_NONE Successful
412  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
413  *
414  * @see account_get_icon_path()
415  */
416 int account_set_icon_path(account_h account, const char *icon_path);
417
418
419 /**
420  * @brief       Gets the domain name.
421  *
422  * @remarks     @a domain_name must be released with free() by you.
423  *
424  * @param[in]   account The account handle
425  * @param[out]  domain_name The domain name
426  *
427  * @return      0 on success, otherwise a negative error value.
428  * @retval      #ACCOUNT_ERROR_NONE Successful
429  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
430  * @retval      #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
431  *
432  * @see account_set_domain_name()
433  */
434 int account_get_domain_name(account_h account, char **domain_name);
435
436
437 /**
438  * @brief       Sets the domain name.
439  *
440  * @param[in]   account The account handle
441  * @param[in]   domain_name The text string to set as a domain name
442  *
443  * @return      0 on success, otherwise a negative error value.
444  * @retval      #ACCOUNT_ERROR_NONE Successful
445  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
446  *
447  * @see account_get_domain_name()
448  */
449 int account_set_domain_name(account_h account, const char *domain_name);
450
451
452 /**
453  * @brief       Gets the email address.
454  *
455  * @remarks     @a email_address must be released with free() by you.
456  *
457  * @param[in]   account The account handle
458  * @param[out]  email_address The email address
459  *
460  * @return      0 on success, otherwise a negative error value.
461  * @retval      #ACCOUNT_ERROR_NONE Successful
462  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
463  * @retval      #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
464  *
465  * @see account_set_email_address()
466  */
467 int account_get_email_address(account_h account, char **email_address);
468
469
470 /**
471  * @brief       Sets the email address.
472  *
473  * @param[in]   account The account handle
474  * @param[in]   email_address The text string to set as a email address
475  *
476  * @return      0 on success, otherwise a negative error value.
477  * @retval      #ACCOUNT_ERROR_NONE Successful
478  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
479  *
480  * @see account_get_email_addres()
481  */
482 int account_set_email_address(account_h account, const char *email_address);
483
484
485 /**
486  * @brief       Gets the package name.
487  *
488  * @remarks     @a package_name must be released with free() by you.
489  *
490  * @param[in]   account The account handle
491  * @param[out]  package_name The package name
492  *
493  * @return      0 on success, otherwise a negative error value.
494  * @retval      #ACCOUNT_ERROR_NONE Successful
495  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
496  * @retval      #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
497  *
498  * @see account_set_package_name()
499  */
500 int account_get_package_name(account_h account, char **package_name);
501
502
503 /**
504  * @brief       Sets the package name.
505  *
506  * @param[in]   account The account handle
507  * @param[in]   package_name The text string to set as a package name
508  *
509  * @return      0 on success, otherwise a negative error value.
510  * @retval      #ACCOUNT_ERROR_NONE Successful
511  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
512  *
513  * @see account_get_email_addres()
514  */
515 int account_set_package_name(account_h account, const char *package_name);
516
517
518 /**
519  * @brief       Gets the access token.
520  *
521  * @remarks     @a access_token must be released with free() by you.
522  *
523  * @param[in]   account The account handle
524  * @param[out]  access_token The access token
525  *
526  * @return      0 on success, otherwise a negative error value.
527  * @retval      #ACCOUNT_ERROR_NONE Successful
528  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
529  * @retval      #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
530  *
531  * @see account_set_access_token()
532  */
533 int account_get_access_token(account_h account, char **access_token);
534
535
536 /**
537  * @brief       Set the access token.
538  *
539  * @param[in]   account The account handle
540  * @param[in]   access_token The text string to set as a access token
541  *
542  * @return      0 on success, otherwise a negative error value.
543  * @retval      #ACCOUNT_ERROR_NONE Successful
544  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
545  *
546  * @see account_get_access_token()
547  */
548 int account_set_access_token(account_h account, const char *access_token);
549
550
551 /**
552  * @brief       Gets the user text.
553  *
554  * @remarks     @a user_text must be released with free() by you.
555  *
556  * @param[in]   account The account handle
557  * @param[in]   user_text_index The index of the user text (range: 0 ~ 4)
558  * @param[out]  user_text The user text
559  *
560  * @return      0 on success, otherwise a negative error value.
561  * @retval      #ACCOUNT_ERROR_NONE Successful
562  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
563  * @retval      #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
564  *
565  * @see account_set_user_text()
566  */
567 int account_get_user_text(account_h account, int user_text_index, char **user_text);
568
569
570 /**
571  * @brief       Sets the user text.
572  *
573  * @param[in]   account The account handle
574  * @param[in]   user_text_index The index of the user text (must be in range from 0 to 4)
575  * @param[in]   user_text The text string to set as a user txt
576  *
577  * @return      0 on success, otherwise a negative error value.
578  * @retval      #ACCOUNT_ERROR_NONE Successful
579  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
580  *
581  * @see account_get_user_text()
582  */
583 int account_set_user_text(account_h account, int user_text_index, const char *user_text);
584
585
586 /**
587  * @brief       Gets the user integer.
588  *
589  * @param[in]   account The account handle
590  * @param[in]   user_int_index The index of the user integer (must be in range from 0 to 4)
591  * @param[out]  user_integer The user interger
592  *
593  * @return      0 on success, otherwise a negative error value.
594  * @retval      #ACCOUNT_ERROR_NONE Successful
595  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
596  *
597  * @see account_set_user_int()
598  */
599 int account_get_user_int(account_h account, int user_int_index, int *user_integer);
600
601
602 /**
603  * @brief       Set the user integer.
604  *
605  * @param[in]   account The account handle
606  * @param[in]   user_int_index The index of the user integer (must be in range from 0 to 4)
607  * @param[in]   user_integer The integer to set as user integer
608  *
609  * @return      0 on success, otherwise a negative error value.
610  * @retval      #ACCOUNT_ERROR_NONE Successful
611  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
612  *
613  * @see account_get_user_int()
614  */
615 int account_set_user_int(account_h account, int user_int_index, int user_integer);
616
617
618 /**
619  * @brief       Gets the auth type.
620  *
621  * @param[in]   account The account handle
622  * @param[out]  auth_type The auth type
623  *
624  * @return      0 on success, otherwise a negative error value.
625  * @retval      #ACCOUNT_ERROR_NONE Successful
626  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
627  *
628  * @see account_set_auth_type()
629  */
630 int account_get_auth_type(account_h account, account_auth_type_e *auth_type);
631
632
633 /**
634  * @brief       Sets the auth type.
635  *
636  * @param[in]   account The account handle
637  * @param[in]   auth_type Integer to be set as auth type
638  *
639  * @return      0 on success, otherwise a negative error value.
640  * @retval      #ACCOUNT_ERROR_NONE Successful
641  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
642  *
643  * @see account_get_auth_type()
644  */
645 int account_set_auth_type(account_h account, const account_auth_type_e auth_type);
646
647
648 /**
649  * @brief       Gets the secret.
650  *
651  * @param[in]   account The account handle
652  * @param[out]  secret The secret
653  *
654  * @return      0 on success, otherwise a negative error value.
655  * @retval      #ACCOUNT_ERROR_NONE Successful
656  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
657  *
658  * @see account_set_secret()
659  */
660 int account_get_secret(account_h account, account_secrecy_state_e *secret);
661
662
663 /**
664  * @brief       Sets the secret.
665  *
666  * @param[in]   account The account handle
667  * @param[in]   secret Secrecy to be set
668  *
669  * @return      0 on success, otherwise a negative error value.
670  * @retval      #ACCOUNT_ERROR_NONE Successful
671  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
672  *
673  * @see account_get_secret()
674  */
675 int account_set_secret(account_h account, const account_secrecy_state_e secret);
676
677
678 /**
679  * @brief       Gets the source.
680  *
681  * @remarks     @a user_text must be released with free() by you.
682  *
683  * @param[in]   account The account handle
684  * @param[out]  source The source
685  *
686  * @return      0 on success, otherwise a negative error value.
687  * @retval      #ACCOUNT_ERROR_NONE Successful
688  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
689  * @retval      #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
690  *
691  * @see account_set_source()
692  */
693 int account_get_source(account_h account, char **source);
694
695
696 /**
697  * @brief       Sets the source.
698  *
699  * @param[in]   account The account handle
700  * @param[in]   source The text string to set as a source
701  *
702  * @return      0 on success, otherwise a negative error value.
703  * @retval      #ACCOUNT_ERROR_NONE Successful
704  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
705  *
706  * @see account_get_source()
707  */
708 int account_set_source(account_h account, const char *source);
709
710
711 /**
712  * @brief       Retrieves all accounts details by invoking the given callback function iteratively.
713  *
714  * @param[in]   callback The callback function to invoke
715  * @param[in]   user_data The user data to be passed to the callback function
716  *
717  * @return      0 on success, otherwise a negative error value.
718  * @retval      #ACCOUNT_ERROR_NONE Successful
719  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
720  * @retval      #ACCOUNT_ERROR_DB_FAILED Database operation failed
721  *
722  * @pre This function requires an open connection to account service by account_connect().
723  * @post        This function invokes account_cb().
724  *
725  * @see account_connect()
726  * @see account_query_account_by_account_id()
727  * @see account_query_account_by_user_name()
728  * @see account_query_account_by_package_name()
729  * @see account_query_account_by_capability()
730  */
731 int account_foreach_account_from_db(account_cb callback, void *user_data);
732
733
734 /**
735  * @brief       Retrieves all accounts with the account database ID.
736  *
737  * @param[in]   account_db_id The account database ID to search
738  * @param[out] account account handle
739  *
740  * @return      0 on success, otherwise a negative error value.
741  * @retval      #ACCOUNT_ERROR_NONE Successful
742  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
743  * @retval      #ACCOUNT_ERROR_DB_FAILED Database operation failed
744  *
745  * @pre This function requires an open connection to account service by account_connect().
746  * @post        This function invokes account_cb().
747  *
748  * @see account_connect()
749  * @see account_query_account_by_account_id()
750  * @see account_query_account_by_user_name()
751  * @see account_query_account_by_package_name()
752  * @see account_query_account_by_capability()
753  */
754 int account_query_account_by_account_id(int account_db_id, account_h *account);
755
756 /**
757  * @brief       Retrieves all accounts with the user name.
758  *
759  * @param[in]   callback The callback function to invoke
760  * @param[in]   user_name The user name to search
761  * @param[in]   user_data The user data to be passed to the callback function
762  *
763  * @return      0 on success, otherwise a negative error value.
764  * @retval      #ACCOUNT_ERROR_NONE Successful
765  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
766  * @retval      #ACCOUNT_ERROR_DB_FAILED Database operation failed
767  *
768  * @pre This function requires an open connection to account service by account_connect().
769  * @post        This function invokes account_cb().
770  *
771  * @see account_connect()
772  * @see account_foreach_account_from_db()
773  * @see account_query_account_by_account_id()
774  * @see account_query_account_by_package_name()
775  * @see account_query_account_by_capability()
776  *
777  */
778 int account_query_account_by_user_name(account_cb callback, const char* user_name, void* user_data);
779
780 /**
781  * @brief       Retrieves all accounts with the package name.
782  *
783  * @param[in]   callback The callback function to invoke
784  * @param[in]   package_name The package name to search
785  * @param[in]   user_data The user data to be passed to the callback function
786  *
787  * @return      0 on success, otherwise a negative error value.
788  * @retval      #ACCOUNT_ERROR_NONE Successful
789  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
790  * @retval      #ACCOUNT_ERROR_DB_FAILED Database operation failed
791  *
792  * @pre This function requires an open connection to account service by account_connect().
793  * @post        This function invokes account_cb().
794  *
795  * @see account_connect()
796  * @see account_foreach_account_from_db()
797  * @see account_query_account_by_account_id()
798  * @see account_query_account_by_user_name()
799  * @see account_query_account_by_capability()
800  */
801 int account_query_account_by_package_name(account_cb callback, const char *package_name, void *user_data);
802
803 /**
804  * @brief       Retrieves all accounts with the capability.
805  *
806  * @param[in]   callback The callback function to invoke
807  * @param[in]   capability_type The capablity type to search
808  * @param[in]   capability_value The capablity value to search
809  * @param[in]   user_data The user data to be passed to the callback function
810  *
811  * @return      0 on success, otherwise a negative error value.
812  * @retval      #ACCOUNT_ERROR_NONE Successful
813  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
814  * @retval      #ACCOUNT_ERROR_DB_FAILED Database operation failed
815  *
816  * @pre This function requires an open connection to account service by account_connect().
817  * @post        This function invokes account_cb().
818  *
819  * @see account_connect()
820  * @see account_foreach_account_from_db()
821  * @see account_query_account_by_account_id()
822  * @see account_query_account_by_user_name()
823  * @see account_query_account_by_package_name()
824  */
825 int account_query_account_by_capability(account_cb callback, account_capability_type_e capability_type, account_capability_state_e capability_value, void *user_data);
826
827 /**
828  * @brief       Retrieves all capabilities with the account database ID.
829  *
830  * @param[in]   callback The callback function to invoke
831  * @param[in]   account_db_id The account database ID to search
832  * @param[in]   user_data The user data to be passed to the callback function
833  *
834  * @return      0 on success, otherwise a negative error value.
835  * @retval      #ACCOUNT_ERROR_NONE Successful
836  * @retval      #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
837  * @retval      #ACCOUNT_ERROR_DB_FAILED Database operation failed
838  *
839  * @pre This function requires an open connection to account service by account_connect().
840  * @post        This function invokes capability_cb().
841  *
842  * @see account_connect()
843  * @see account_get_capability()
844  * @see account_set_capability()
845  */
846 int account_query_capability_by_account_id(capability_cb callback, int account_db_id, void *user_data);
847
848
849 /**
850  * @brief       Retrieves number of account in the account database.
851  *
852  * @param[out] out parameter for number of all accounts
853  *
854  * @return      0 on success, otherwise a negative error value.
855  * @retval      #ACCOUNT_ERROR_NONE Successful
856  * @retval      #ACCOUNT_ERROR_DB_FAILED Database operation failed
857  *
858  * @pre This function requires an open connection to account service by account_connect().
859  *
860  * @see account_connect()
861  */
862 int account_get_total_count_from_db(int *count);
863
864
865 /**
866 * @}
867 */
868
869
870 #ifdef __cplusplus
871 }
872 #endif
873
874 #endif /* __ACCOUNT_H__ */