4 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Wonyoung Lee <wy1115.lee@samsung.com>, Sungchan Kim <sungchan81.kim@samsung.com>
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
25 * @defgroup Account_PG Account
28 <h1 class="pg">Introduction</h1>
29 <h2 class="pg">Purpose of this document</h2>
31 The purpose of this document is to describe how applications can use account APIs for handling Account's information. This document gives programming guidelines to application engineers and examples of using Account data.
33 <h2 class="pg">Scope</h2>
35 The scope of this document is limited to Account API usage.
38 <h1 class="pg">Account Architecture</h1>
39 <h2 class="pg"> Overview</h2>
41 Account is responsible for inserting, deleting, and updating Account data in order to accommodate the needs for application's Account data.
42 Users can access Account data without knowing DB schema, SQLite, relations of data
44 <h1 class="pg">Account Features</h1>
46 - Handle information of Account
48 <h2 class="pg">Similar to Sqlite3</h2>
49 Account API is similar to Sqlite3.
51 <h2 class="pg">Handle information of Account</h2>
52 Account supports to insert/update/delete/get/set/query information of Account.
53 The Information of Account includes user name, package name, email, access token, icon path, source, display name, capability informatio etc.
55 <h1 class="pg">Account API Description</h1>
57 you can refer @ref ACCOUNT_SVC
59 <h1 class="pg">Sample Code</h1>
61 <h2 class="pg">Connect to Account Database</h2>
63 Before using Account information from Account API, caller module should connect to the Account database, and after finishing with the account information, should disconnect from the Account database
66 int account_connect(void);
68 int account_disconnect(void);
71 <h2 class="pg">Insert information of account</h2>
74 void insert_test(void)
79 ret = account_connect();
80 if(ret != ACCOUNT_ERROR_NONE)
82 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
85 ret = account_create(&account);
86 if(ret != ACCOUNT_ERROR_NONE)
88 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
91 ret = account_set_user_name(account, "tarun.kr");
93 if(ret != ACCOUNT_ERROR_NONE)
95 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
98 ret = account_set_display_name(account, "Tarun Kumar");
100 if(ret != ACCOUNT_ERROR_NONE)
102 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
105 ret = account_set_domain_name(account, "Samsung electronics");
106 if(ret != ACCOUNT_ERROR_NONE)
108 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
111 ret = account_set_email_address(account, "tarun@gmail.com");
112 if(ret != ACCOUNT_ERROR_NONE)
114 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
117 ret = account_set_package_name(account, "com.samsung.twiter");
118 if(ret != ACCOUNT_ERROR_NONE)
120 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
123 ret = account_set_icon_path(account, "icon-path");
124 if(ret != ACCOUNT_ERROR_NONE)
126 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
129 ret = account_set_access_token(account, "ACCESSTOKEN");
130 if(ret != ACCOUNT_ERROR_NONE)
132 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
135 ret = account_set_auth_type( account, ACCOUNT_AUTH_TYPE_OAUTH );
136 if(ret != ACCOUNT_ERROR_NONE)
138 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
141 ret = account_set_secret( account, ACCOUNT_SECRECY_INVISIBLE );
142 if(ret != ACCOUNT_ERROR_NONE)
144 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
146 ret = account_set_source(account, "URUSA inc.");
150 for(i=0;i<USER_TXT_CNT;i++)
152 ret = account_set_user_text(account, i, "user txt");
153 if(ret != ACCOUNT_ERROR_NONE)
155 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
160 for(i=0;i<USER_INT_CNT;i++)
162 ret = account_set_user_int(account, i, 888);
163 if(ret != ACCOUNT_ERROR_NONE)
165 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
169 ret = account_set_capability(account, ACCOUNT_CAPABILITY_CONTACT, ACCOUNT_CAPABILITY_ENABLED);
170 ret = account_set_capability(account, ACCOUNT_CAPABILITY_CALENDAR, ACCOUNT_CAPABILITY_ENABLED);
171 ret = account_set_capability(account, ACCOUNT_CAPABILITY_PHOTO, ACCOUNT_CAPABILITY_ENABLED);
172 ret = account_set_capability(account, ACCOUNT_CAPABILITY_VIDEO, ACCOUNT_CAPABILITY_ENABLED);
173 ret = account_set_capability(account, ACCOUNT_CAPABILITY_EMAIL, ACCOUNT_CAPABILITY_ENABLED);
174 ret = account_set_capability(account, ACCOUNT_CAPABILITY_STATUS_POST, ACCOUNT_CAPABILITY_ENABLED);
175 ret = account_set_capability(account, ACCOUNT_CAPABILITY_VOIP, ACCOUNT_CAPABILITY_ENABLED);
176 ret = account_set_capability(account, ACCOUNT_CAPABILITY_SAMSUNG_APPS, ACCOUNT_CAPABILITY_ENABLED);
177 ret = account_set_capability(account, ACCOUNT_CAPABILITY_MOBILE_TRACKER, ACCOUNT_CAPABILITY_ENABLED);
180 ret = account_insert_to_db(account, &account_id);
181 if(ret != ACCOUNT_ERROR_NONE)
183 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
187 ret = account_destroy(account);
188 if(ret != ACCOUNT_ERROR_NONE)
190 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
193 ret = account_disconnect();
194 if(ret != ACCOUNT_ERROR_NONE)
196 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
203 <h2 class="pg">Get account by id</h2>
206 bool _capability_get_callback(const char* capability_type, account_capability_state_e capability_value, void* user_data)
208 char* test_type = capability_type;
209 int test_value = capability_value;
211 SECURE_LOGD("_capability_get_callback test_type = : %s\n", test_type);
212 SECURE_LOGD("_capability_get_callback test_value = : %d\n", test_value);
216 static void _account_free_text(char *text)
224 void get_account_by_id(int account_id)
229 ret = account_connect();
230 if(ret != ACCOUNT_ERROR_NONE)
232 SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
235 ret = account_create(&account);
236 if(ret != ACCOUNT_ERROR_NONE)
238 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
241 ret = account_query_account_by_account_id(account_id, &account);
242 if(ret != ACCOUNT_ERROR_NONE)
244 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
247 char *test_text = NULL;
249 account_get_user_name(handle, &test_text);
250 SECURE_LOGD("_account_get_callback : %s\n", test_text);
252 _account_free_text(test_text);
254 account_get_display_name(handle, &test_text);
255 SECURE_LOGD("_account_get_callback : %s\n", test_text);
257 _account_free_text(test_text);
259 account_get_email_address(handle, &test_text);
260 SECURE_LOGD("_account_get_callback : %s\n", test_text);
262 _account_free_text(test_text);
264 account_get_icon_path(handle, &test_text);
265 SECURE_LOGD("_account_get_callback : %s\n", test_text);
267 _account_free_text(test_text);
269 account_get_source(handle, &test_text);
270 SECURE_LOGD("_account_get_callback : %s\n", test_text);
272 _account_free_text(test_text);
274 account_get_package_name(handle, &test_text);
275 SECURE_LOGD("_account_get_callback : %s\n", test_text);
277 _account_free_text(test_text);
279 account_get_domain_name(handle, &test_text);
280 SECURE_LOGD("_account_get_callback : %s\n", test_text);
282 _account_free_text(test_text);
284 account_get_access_token(handle, &test_text);
285 SECURE_LOGD("_account_get_callback : %s\n", test_text);
289 for(i=0;i<USER_TXT_CNT;i++)
291 _account_free_text(test_text);
293 account_get_user_text(handle, i, &test_text);
294 SECURE_LOGD("_account_get_callback : %s\n", test_text);
299 account_auth_type_e auth_type;
300 account_get_auth_type(handle, &auth_type);
301 SECURE_LOGD("account_get_auth_type : %d\n", auth_type);
303 account_secrecy_state_e secret;
304 account_get_secret(handle, &secret);
305 SECURE_LOGD("account_get_secret : %d\n", secret);
307 account_sync_state_e sync_support;
308 account_get_sync_support(handle, &sync_support);
309 SECURE_LOGD("account_get_sync_support : %d\n", sync_support);
311 for(i=0;i<USER_INT_CNT;i++)
314 account_get_user_int(handle, i, &test_int);
315 SECURE_LOGD("_account_get_callback : %d\n", test_int);
318 account_get_capability(handle, _capability_get_callback, NULL);
320 ret = account_destroy(account);
321 if(ret != ACCOUNT_ERROR_NONE)
323 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
326 ret = account_disconnect();
327 if(ret != ACCOUNT_ERROR_NONE)
329 SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
335 <h2 class="pg">Get account list by user name</h2>
338 static void _account_free_text(char *text)
346 bool _account_get_callback(account_h handle, void* user_data)
348 SECURE_LOGD("_account_get_callback\n");
350 char *test_text = NULL;
352 account_get_user_name(handle, &test_text);
353 SECURE_LOGD("_account_get_callback : %s\n", test_text);
355 _account_free_text(test_text);
357 account_get_display_name(handle, &test_text);
358 SECURE_LOGD("_account_get_callback : %s\n", test_text);
360 _account_free_text(test_text);
362 account_get_email_address(handle, &test_text);
363 SECURE_LOGD("_account_get_callback : %s\n", test_text);
365 _account_free_text(test_text);
367 account_get_icon_path(handle, &test_text);
368 SECURE_LOGD("_account_get_callback : %s\n", test_text);
370 _account_free_text(test_text);
372 account_get_source(handle, &test_text);
373 SECURE_LOGD("_account_get_callback : %s\n", test_text);
375 _account_free_text(test_text);
377 account_get_package_name(handle, &test_text);
378 SECURE_LOGD("_account_get_callback : %s\n", test_text);
380 _account_free_text(test_text);
382 account_get_domain_name(handle, &test_text);
383 SECURE_LOGD("_account_get_callback : %s\n", test_text);
385 _account_free_text(test_text);
387 account_get_access_token(handle, &test_text);
388 SECURE_LOGD("_account_get_callback : %s\n", test_text);
392 for(i=0;i<USER_TXT_CNT;i++)
394 _account_free_text(test_text);
396 account_get_user_text(handle, i, &test_text);
397 SECURE_LOGD("_account_get_callback : %s\n", test_text);
402 account_auth_type_e auth_type;
403 account_get_auth_type(handle, &auth_type);
404 SECURE_LOGD("account_get_auth_type : %d\n", auth_type);
406 account_secrecy_state_e secret;
407 account_get_secret(handle, &secret);
408 SECURE_LOGD("account_get_secret : %d\n", secret);
410 account_sync_state_e sync_support;
411 account_get_sync_support(handle, &sync_support);
412 SECURE_LOGD("account_get_sync_support : %d\n", sync_support);
414 for(i=0;i<USER_INT_CNT;i++)
417 account_get_user_int(handle, i, &test_int);
418 SECURE_LOGD("_account_get_callback : %d\n", test_int);
421 account_get_capability(handle, _capability_get_callback, NULL);
427 void get_account_list_by_user_name(char * user_name)
432 ret = account_connect();
433 if(ret != ACCOUNT_ERROR_NONE)
435 SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
438 ret = account_query_account_by_user_name(_account_get_callback, user_name, NULL);
439 if(ret != ACCOUNT_ERROR_NONE)
441 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
444 ret = account_disconnect();
445 if(ret != ACCOUNT_ERROR_NONE)
447 SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
452 <h2 class="pg">Get account list by package name</h2>
455 static void _account_free_text(char *text)
463 bool _account_get_callback(account_h handle, void* user_data)
465 SECURE_LOGD("_account_get_callback\n");
467 char *test_text = NULL;
469 account_get_user_name(handle, &test_text);
470 SECURE_LOGD("_account_get_callback : %s\n", test_text);
472 _account_free_text(test_text);
474 account_get_display_name(handle, &test_text);
475 SECURE_LOGD("_account_get_callback : %s\n", test_text);
477 _account_free_text(test_text);
479 account_get_email_address(handle, &test_text);
480 SECURE_LOGD("_account_get_callback : %s\n", test_text);
482 _account_free_text(test_text);
484 account_get_icon_path(handle, &test_text);
485 SECURE_LOGD("_account_get_callback : %s\n", test_text);
487 _account_free_text(test_text);
489 account_get_source(handle, &test_text);
490 SECURE_LOGD("_account_get_callback : %s\n", test_text);
492 _account_free_text(test_text);
494 account_get_package_name(handle, &test_text);
495 SECURE_LOGD("_account_get_callback : %s\n", test_text);
497 _account_free_text(test_text);
499 account_get_domain_name(handle, &test_text);
500 SECURE_LOGD("_account_get_callback : %s\n", test_text);
502 _account_free_text(test_text);
504 account_get_access_token(handle, &test_text);
505 SECURE_LOGD("_account_get_callback : %s\n", test_text);
509 for(i=0;i<USER_TXT_CNT;i++)
511 _account_free_text(test_text);
513 account_get_user_text(handle, i, &test_text);
514 SECURE_LOGD("_account_get_callback : %s\n", test_text);
519 account_auth_type_e auth_type;
520 account_get_auth_type(handle, &auth_type);
521 SECURE_LOGD("account_get_auth_type : %d\n", auth_type);
523 account_secrecy_state_e secret;
524 account_get_secret(handle, &secret);
525 SECURE_LOGD("account_get_secret : %d\n", secret);
527 account_sync_state_e sync_support;
528 account_get_sync_support(handle, &sync_support);
529 SECURE_LOGD("account_get_sync_support : %d\n", sync_support);
531 for(i=0;i<USER_INT_CNT;i++)
534 account_get_user_int(handle, i, &test_int);
535 SECURE_LOGD("_account_get_callback : %d\n", test_int);
538 account_get_capability(handle, _capability_get_callback, NULL);
543 void get_account_list_by_package_name(char * package_name)
548 ret = account_connect();
549 if(ret != ACCOUNT_ERROR_NONE)
551 SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
554 ret = account_query_account_by_package_name(_account_get_callback, package_name, NULL);
555 if(ret != ACCOUNT_ERROR_NONE)
557 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
560 ret = account_disconnect();
561 if(ret != ACCOUNT_ERROR_NONE)
563 SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
568 <h2 class="pg">Get all account list</h2>
571 static void _account_free_text(char *text)
579 bool _account_get_callback(account_h handle, void* user_data)
581 SECURE_LOGD("_account_get_callback\n");
583 char *test_text = NULL;
585 account_get_user_name(handle, &test_text);
586 SECURE_LOGD("_account_get_callback : %s\n", test_text);
588 _account_free_text(test_text);
590 account_get_display_name(handle, &test_text);
591 SECURE_LOGD("_account_get_callback : %s\n", test_text);
593 _account_free_text(test_text);
595 account_get_email_address(handle, &test_text);
596 SECURE_LOGD("_account_get_callback : %s\n", test_text);
598 _account_free_text(test_text);
600 account_get_icon_path(handle, &test_text);
601 SECURE_LOGD("_account_get_callback : %s\n", test_text);
603 _account_free_text(test_text);
605 account_get_source(handle, &test_text);
606 SECURE_LOGD("_account_get_callback : %s\n", test_text);
608 _account_free_text(test_text);
610 account_get_package_name(handle, &test_text);
611 SECURE_LOGD("_account_get_callback : %s\n", test_text);
613 _account_free_text(test_text);
615 account_get_domain_name(handle, &test_text);
616 SECURE_LOGD("_account_get_callback : %s\n", test_text);
618 _account_free_text(test_text);
620 account_get_access_token(handle, &test_text);
621 SECURE_LOGD("_account_get_callback : %s\n", test_text);
625 for(i=0;i<USER_TXT_CNT;i++)
627 _account_free_text(test_text);
629 account_get_user_text(handle, i, &test_text);
630 SECURE_LOGD("_account_get_callback : %s\n", test_text);
635 account_auth_type_e auth_type;
636 account_get_auth_type(handle, &auth_type);
637 SECURE_LOGD("account_get_auth_type : %d\n", auth_type);
639 account_secrecy_state_e secret;
640 account_get_secret(handle, &secret);
641 SECURE_LOGD("account_get_secret : %d\n", secret);
643 account_sync_state_e sync_support;
644 account_get_sync_support(handle, &sync_support);
645 SECURE_LOGD("account_get_sync_support : %d\n", sync_support);
647 for(i=0;i<USER_INT_CNT;i++)
650 account_get_user_int(handle, i, &test_int);
651 SECURE_LOGD("_account_get_callback : %d\n", test_int);
654 account_get_capability(handle, _capability_get_callback, NULL);
659 void get_all_account()
664 ret = account_connect();
665 if(ret != ACCOUNT_ERROR_NONE)
667 SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
670 ret = account_foreach_account_from_db(_account_get_callback, NULL);
671 if(ret != ACCOUNT_ERROR_NONE)
673 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
676 ret = account_disconnect();
677 if(ret != ACCOUNT_ERROR_NONE)
679 SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
684 <h2 class="pg">Update information of account by account id</h2>
687 void update_accont_by_id(int account_id)
692 ret = account_connect();
693 if(ret != ACCOUNT_ERROR_NONE)
695 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
698 ret = account_create(&account);
699 if(ret != ACCOUNT_ERROR_NONE)
701 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
704 ret = account_set_user_name(account, "update-tarun.kr");
706 if(ret != ACCOUNT_ERROR_NONE)
708 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
711 ret = account_set_display_name(account, "update-Tarun Kumar");
712 if(ret != ACCOUNT_ERROR_NONE)
714 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
717 ret = account_set_domain_name(account, "update-Samsung electronics");
718 if(ret != ACCOUNT_ERROR_NONE)
720 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
723 ret = account_set_email_address(account, "update-tarun@gmail.com");
724 if(ret != ACCOUNT_ERROR_NONE)
726 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
729 ret = account_set_package_name(account, "update-com.samsung.twiter");
730 if(ret != ACCOUNT_ERROR_NONE)
732 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
735 ret = account_set_icon_path(account, "update-icon-path");
736 if(ret != ACCOUNT_ERROR_NONE)
738 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
741 ret = account_set_access_token(account, "update-ACCESSTOKEN");
742 if(ret != ACCOUNT_ERROR_NONE)
744 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
747 ret = account_set_auth_type( account, ACCOUNT_AUTH_TYPE_OAUTH );
748 if(ret != ACCOUNT_ERROR_NONE)
750 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
752 ret = account_set_secret( account, ACCOUNT_SECRECY_INVISIBLE );
753 if(ret != ACCOUNT_ERROR_NONE)
755 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
757 ret = account_set_source(account, "update-URUSA inc.");
761 for(i=0;i<USER_TXT_CNT;i++)
763 ret = account_set_user_text(account, i, "update-user txt");
764 if(ret != ACCOUNT_ERROR_NONE)
766 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
770 for(i=0;i<USER_INT_CNT;i++)
772 ret = account_set_user_int(account, i, 999);
773 if(ret != ACCOUNT_ERROR_NONE)
775 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
779 ret = account_set_capability(account, ACCOUNT_CAPABILITY_CONTACT, ACCOUNT_CAPABILITY_DISABLED);
780 ret = account_set_capability(account, ACCOUNT_CAPABILITY_CALENDAR, ACCOUNT_CAPABILITY_DISABLED);
781 ret = account_set_capability(account, ACCOUNT_CAPABILITY_PHOTO, ACCOUNT_CAPABILITY_DISABLED);
782 ret = account_set_capability(account, ACCOUNT_CAPABILITY_VIDEO, ACCOUNT_CAPABILITY_DISABLED);
783 ret = account_set_capability(account, ACCOUNT_CAPABILITY_EMAIL, ACCOUNT_CAPABILITY_DISABLED);
784 ret = account_set_capability(account, ACCOUNT_CAPABILITY_STATUS_POST, ACCOUNT_CAPABILITY_DISABLED);
785 ret = account_set_capability(account, ACCOUNT_CAPABILITY_VOIP, ACCOUNT_CAPABILITY_DISABLED);
786 ret = account_set_capability(account, ACCOUNT_CAPABILITY_SAMSUNG_APPS, ACCOUNT_CAPABILITY_DISABLED);
787 ret = account_set_capability(account, ACCOUNT_CAPABILITY_MOBILE_TRACKER, ACCOUNT_CAPABILITY_DISABLED);
789 ret = account_update_to_db_by_id(account, account_id);
790 if(ret != ACCOUNT_ERROR_NONE)
792 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
796 ret = account_destroy(account);
797 if(ret != ACCOUNT_ERROR_NONE)
799 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
802 ret = account_disconnect();
803 if(ret != ACCOUNT_ERROR_NONE)
805 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
810 <h2 class="pg">Update information of account by user name</h2>
813 void update_accont_by_user_name(char *user_name, char *package_name)
818 ret = account_connect();
819 if(ret != ACCOUNT_ERROR_NONE)
821 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
824 ret = account_create(&account);
825 if(ret != ACCOUNT_ERROR_NONE)
827 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
830 ret = account_set_user_name(account, "update-tarun.kr");
831 if(ret != ACCOUNT_ERROR_NONE)
833 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
836 ret = account_set_display_name(account, "update-Tarun Kumar");
837 if(ret != ACCOUNT_ERROR_NONE)
839 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
842 ret = account_set_domain_name(account, "update-Samsung electronics");
843 if(ret != ACCOUNT_ERROR_NONE)
845 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
848 ret = account_set_email_address(account, "update-tarun@gmail.com");
849 if(ret != ACCOUNT_ERROR_NONE)
851 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
854 ret = account_set_package_name(account, "update-com.samsung.twiter");
855 if(ret != ACCOUNT_ERROR_NONE)
857 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
860 ret = account_set_icon_path(account, "update-icon-path");
861 if(ret != ACCOUNT_ERROR_NONE)
863 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
866 ret = account_set_access_token(account, "update-ACCESSTOKEN");
867 if(ret != ACCOUNT_ERROR_NONE)
869 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
872 ret = account_set_auth_type( account, ACCOUNT_AUTH_TYPE_OAUTH );
873 if(ret != ACCOUNT_ERROR_NONE)
875 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
877 ret = account_set_secret( account, ACCOUNT_SECRECY_INVISIBLE );
878 if(ret != ACCOUNT_ERROR_NONE)
880 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
883 ret = account_set_source(account, "update-URUSA inc.");
884 if(ret != ACCOUNT_ERROR_NONE)
886 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
891 for(i=0;i<USER_TXT_CNT;i++)
893 ret = account_set_user_text(account, i, "update-user txt");
894 if(ret != ACCOUNT_ERROR_NONE)
896 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
900 for(i=0;i<USER_INT_CNT;i++)
902 ret = account_set_user_int(account, i, 999);
903 if(ret != ACCOUNT_ERROR_NONE)
905 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
909 ret = account_set_capability(account, ACCOUNT_CAPABILITY_CONTACT, ACCOUNT_CAPABILITY_DISABLED);
910 ret = account_set_capability(account, ACCOUNT_CAPABILITY_CALENDAR, ACCOUNT_CAPABILITY_DISABLED);
911 ret = account_set_capability(account, ACCOUNT_CAPABILITY_PHOTO, ACCOUNT_CAPABILITY_DISABLED);
912 ret = account_set_capability(account, ACCOUNT_CAPABILITY_VIDEO, ACCOUNT_CAPABILITY_DISABLED);
913 ret = account_set_capability(account, ACCOUNT_CAPABILITY_EMAIL, ACCOUNT_CAPABILITY_DISABLED);
914 ret = account_set_capability(account, ACCOUNT_CAPABILITY_STATUS_POST, ACCOUNT_CAPABILITY_DISABLED);
915 ret = account_set_capability(account, ACCOUNT_CAPABILITY_VOIP, ACCOUNT_CAPABILITY_DISABLED);
916 ret = account_set_capability(account, ACCOUNT_CAPABILITY_SAMSUNG_APPS, ACCOUNT_CAPABILITY_DISABLED);
917 ret = account_set_capability(account, ACCOUNT_CAPABILITY_MOBILE_TRACKER, ACCOUNT_CAPABILITY_DISABLED);
919 ret = account_update_to_db_by_user_name(account, user_name, package_name);
920 if(ret != ACCOUNT_ERROR_NONE)
922 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
926 ret = account_destroy(account);
927 if(ret != ACCOUNT_ERROR_NONE)
929 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
932 ret = account_disconnect();
933 if(ret != ACCOUNT_ERROR_NONE)
935 SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
940 <h2 class="pg">Delete account by id </h2>
943 void delete_account_by_id(int account_id)
947 ret = account_connect();
948 if(ret != ACCOUNT_ERROR_NONE)
950 SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
953 ret = account_delete(account_id);
954 if(ret != ACCOUNT_ERROR_NONE)
956 SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
959 ret = account_disconnect();
960 if(ret != ACCOUNT_ERROR_NONE)
962 SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
968 <h2 class="pg">Update sync status by id </h2>
971 void update_sync_status_by_id(int account_id, const account_sync_state_e sync_status)
975 ret = account_connect();
976 if(ret != ACCOUNT_ERROR_NONE)
978 SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
981 ret = account_update_sync_status_by_id(account_id, sync_status);
982 if(ret != ACCOUNT_ERROR_NONE)
984 SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
987 ret = account_disconnect();
988 if(ret != ACCOUNT_ERROR_NONE)
990 SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
996 <h2 class="pg">Delete account by user name </h2>
999 void delete_account_by_user_name(char *user_name, char *package_name)
1002 ret = account_connect();
1003 if(ret != ACCOUNT_ERROR_NONE)
1005 SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
1008 ret = account_delete_from_db_by_user_name(user_name, package_name);
1009 if(ret != ACCOUNT_ERROR_NONE)
1011 SECURE_LOGD("(%d)-[Account] ret = %d \n", __LINE__, ret);
1014 ret = account_disconnect();
1015 if(ret != ACCOUNT_ERROR_NONE)
1017 SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
1023 <h2 class="pg">Delete account by package name </h2>
1026 void delete_account_by_package_name(char *package_name)
1029 ret = account_connect();
1030 if(ret != ACCOUNT_ERROR_NONE)
1032 SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
1035 ret = account_delete_from_db_by_package_name(package_name);
1036 if(ret != ACCOUNT_ERROR_NONE)
1038 SECURE_LOGD("(%d)-[Account] ret = %d \n", __LINE__, ret);
1041 ret = account_disconnect();
1042 if(ret != ACCOUNT_ERROR_NONE)
1044 SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
1050 <h2 class="pg">Get account insert dbus notification </h2>
1053 void notify_account_insert()
1056 DBusConnection* conn;
1059 SECURE_LOGD("Listening for signals\n");
1061 dbus_error_init(&err);
1063 conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
1064 if (dbus_error_is_set(&err)) {
1065 dbus_error_free(&err);
1071 dbus_bus_add_match(conn, "type='signal',interface='account.signal.Type'", &err);
1072 dbus_connection_flush(conn);
1073 if (dbus_error_is_set(&err)) {
1076 SECURE_LOGD("Match rule sent\n");
1079 dbus_connection_read_write(conn, 0);
1080 msg = dbus_connection_pop_message(conn);
1087 if (dbus_message_is_signal(msg, ACCOUNT_DBUS_SIGNAL_INTERFACE, ACCOUNT_DBUS_NOTI_NAME_INSERT)) {
1088 SECURE_LOGD("Got Signal with name insert\n");
1091 dbus_message_unref(msg);
1093 dbus_connection_close(conn);
1097 <h2 class="pg">Get account update dbus notification </h2>
1100 void notify_account_update()
1103 DBusConnection* conn;
1106 SECURE_LOGD("Listening for signals\n");
1108 dbus_error_init(&err);
1110 conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
1111 if (dbus_error_is_set(&err)) {
1112 dbus_error_free(&err);
1118 dbus_bus_add_match(conn, "type='signal',interface='account.signal.Type'", &err);
1119 dbus_connection_flush(conn);
1120 if (dbus_error_is_set(&err)) {
1123 SECURE_LOGD("Match rule sent\n");
1126 dbus_connection_read_write(conn, 0);
1127 msg = dbus_connection_pop_message(conn);
1134 if (dbus_message_is_signal(msg, ACCOUNT_DBUS_SIGNAL_INTERFACE, ACCOUNT_DBUS_NOTI_NAME_UPDATE)) {
1135 SECURE_LOGD("Got Signal with name update\n");
1138 dbus_message_unref(msg);
1140 dbus_connection_close(conn);
1144 <h2 class="pg">Get account delete dbus notification </h2>
1147 void notify_account_delete()
1150 DBusConnection* conn;
1153 SECURE_LOGD("Listening for signals\n");
1155 dbus_error_init(&err);
1157 conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
1158 if (dbus_error_is_set(&err)) {
1159 dbus_error_free(&err);
1165 dbus_bus_add_match(conn, "type='signal',interface='account.signal.Type'", &err);
1166 dbus_connection_flush(conn);
1167 if (dbus_error_is_set(&err)) {
1170 SECURE_LOGD("Match rule sent\n");
1173 dbus_connection_read_write(conn, 0);
1174 msg = dbus_connection_pop_message(conn);
1181 if (dbus_message_is_signal(msg, ACCOUNT_DBUS_SIGNAL_INTERFACE, ACCOUNT_DBUS_NOTI_NAME_DELETE)) {
1182 SECURE_LOGD("Got Signal with name delete\n");
1185 dbus_message_unref(msg);
1187 dbus_connection_close(conn);
1191 <h2 class="pg">Get capability by acccount id</h2>
1194 bool _capability_get_callback(const char* capability_type, account_capability_state_e capability_value, void* user_data)
1196 char* test_type = capability_type;
1197 int test_value = capability_value;
1199 SECURE_LOGD("_capability_get_callback test_type = : %s\n", test_type);
1200 SECURE_LOGD("_capability_get_callback test_value = : %d\n", test_value);
1204 void capability_by_account_id(int account_id)
1207 ret = account_connect();
1208 if(ret != ACCOUNT_ERROR_NONE)
1210 SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
1213 ret = account_query_capability_by_account_id(_capability_get_callback, account_id, NULL);
1214 if(ret != ACCOUNT_ERROR_NONE)
1216 SECURE_LOGD("(%d)-[Account] ret = %d \n", __LINE__, ret);
1219 ret = account_disconnect();
1220 if(ret != ACCOUNT_ERROR_NONE)
1222 SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);