summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjk7744.park <jk7744.park@samsung.com>2015-09-14 22:13:06 +0900
committerjk7744.park <jk7744.park@samsung.com>2015-09-14 22:13:06 +0900
commitb3f05b473791106b358b509929807a630bf4a42b (patch)
treeaa2d439fa871b9f305de67f21afa7524284220ba
parente0c4390d5bf1138e549a3c9ec801b3050c33b3ef (diff)
downloadlibaccounts-svc-b3f05b473791106b358b509929807a630bf4a42b.tar.gz
libaccounts-svc-b3f05b473791106b358b509929807a630bf4a42b.tar.bz2
libaccounts-svc-b3f05b473791106b358b509929807a630bf4a42b.zip
-rwxr-xr-xAUTHORS2
-rwxr-xr-xCMakeLists.txt48
-rwxr-xr-xINSTALL33
-rwxr-xr-xLICENSE206
-rwxr-xr-xaccounts-svc.pc.in13
-rw-r--r--doc/account_manager_doc.h44
-rwxr-xr-xinclude/account-error.h79
-rwxr-xr-xinclude/account-private.h383
-rwxr-xr-xinclude/account-types.h261
-rwxr-xr-xinclude/account.h2036
-rwxr-xr-xinclude/account_PG.h1236
-rw-r--r--include/account_internal.h81
-rwxr-xr-xlibaccounts-svc.manifest19
-rwxr-xr-xpackaging/libaccounts-svc.spec115
-rwxr-xr-xsrc/account.c7345
-rwxr-xr-xsrc/utc-account.c8276
16 files changed, 20177 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100755
index 0000000..910b427
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,2 @@
+Wonyoung Lee <wy1115.lee@samsung.com>
+Sungchan Kim <sungchan81.kim@samsung.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755
index 0000000..80e0958
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,48 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(accounts-svc C)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(LIBDIR "\${prefix}/lib")
+SET(INCLUDEDIR "\${prefix}/include ")
+SET(VERSION_MAJOR 0)
+SET(VERSION "${VERSION_MAJOR}.2.97")
+
+SET(SRCS
+src/account.c
+)
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED sqlite3 dlog db-util glib-2.0 capi-base-common vconf pkgmgr-info aul libsmack)
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall")
+SET(CMAKE_LDFLAGS "-Wl,-zdefs")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"")
+ADD_DEFINITIONS("-DSLP_DEBUG")
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+
+CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib/accounts-svc)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib)
+INSTALL(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION lib/pkgconfig)
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/account.h DESTINATION include)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/account-error.h DESTINATION include)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/account-types.h DESTINATION include)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/account_internal.h DESTINATION include)
+
+#ADD_SUBDIRECTORY(test)
diff --git a/INSTALL b/INSTALL
new file mode 100755
index 0000000..ddf4e78
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,33 @@
+1. make the build directory
+
+ ex)
+
+ $ mkdir build
+
+
+2. change the working directory to the build directory
+
+ ex)
+
+ $ cd build
+
+
+3. run 'cmake'
+
+ $ cmake ${SOURCE_DIR} -DCMAKE_INSTALL_PREFIX=/usr
+
+ ex)
+
+ $ cmake .. -DCMAKE_INSTALL_PREFIX=/usr
+
+ or
+
+ $ cmake ..
+
+
+4. make & make install
+
+ ex)
+
+ $ make -j 2 && make install
+
diff --git a/LICENSE b/LICENSE
new file mode 100755
index 0000000..f94008a
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,206 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+
diff --git a/accounts-svc.pc.in b/accounts-svc.pc.in
new file mode 100755
index 0000000..969d7bb
--- /dev/null
+++ b/accounts-svc.pc.in
@@ -0,0 +1,13 @@
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: accounts-svc
+Description: Account DB library
+Version: @VERSION@
+Requires: capi-base-common
+Libs: -L${libdir} -laccounts-svc
+Cflags: -I${includedir}
diff --git a/doc/account_manager_doc.h b/doc/account_manager_doc.h
new file mode 100644
index 0000000..68d9ce3
--- /dev/null
+++ b/doc/account_manager_doc.h
@@ -0,0 +1,44 @@
+/*
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Wonyoung Lee <wy1115.lee@samsung.com>, Sungchan Kim <sungchan81.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __ACCOUNT_H__
+#define __ACCOUNT_H__
+
+/**
+ * @defgroup CAPI_ACCOUNT_MANAGER_MODULE Account Manager
+ * @ingroup CAPI_SOCIAL_FRAMEWORK
+ * @brief The account APIs provide CRUD (Create, Read, Update, Delete) account management functionality.
+ *
+ * @section CAPI_ACCOUNT_MANAGER_HEADER Required Header
+ * \#include <account.h>
+ *
+ * @section CAPI_ACCOUNT_MANAGER_MODULE_OVERVIEW Overview
+ * The account APIs is separated into two major sections:
+ * 1. Registering an account provider while an application is installed. This information will be used for the Add account screen.
+ * 2. Adding an account information when an application signs in successfully to share the account information to the Tizen system. This information will be shown in the Tizen settings account menu.
+
+ * The APIs of both of the sections consist of the following functionality:
+ * - Create an account or account provider
+ * - Update an account or account provider(Only available for the creator)
+ * - Delete an account or account provider(Only available for the creator)
+ * - Read an account or account provider with some filter
+*/
+
+#endif /* __ACCOUNT_H__ */
diff --git a/include/account-error.h b/include/account-error.h
new file mode 100755
index 0000000..592b214
--- /dev/null
+++ b/include/account-error.h
@@ -0,0 +1,79 @@
+/*
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Wonyoung Lee <wy1115.lee@samsung.com>, Sungchan Kim <sungchan81.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __ACCOUNT_ERROR_H__
+#define __ACCOUNT_ERROR_H__
+
+#include <tizen.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @addtogroup CAPI_ACCOUNT_MANAGER_MODULE
+ * @{
+ */
+
+/**
+ * @file account-error.h
+ * @brief This file contains ACCOUNT error definitions.
+ */
+
+//#define TIZEN_ERROR_ACCOUNT_CLASS SLP_ERROR_ACCOUNT | 0x90
+
+/**
+ * @brief Enumerations of error codes for ACCOUNT APIs.
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ ACCOUNT_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ ACCOUNT_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ ACCOUNT_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+
+ ACCOUNT_ERROR_DUPLICATED = TIZEN_ERROR_ACCOUNT | 0x01, /**< Same user name exists in your application */
+ ACCOUNT_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< Empty data */
+
+ ACCOUNT_ERROR_RECORD_NOT_FOUND = TIZEN_ERROR_ACCOUNT | 0x03, /**< Related record does not exist */
+ ACCOUNT_ERROR_DB_FAILED = TIZEN_ERROR_ACCOUNT | 0x04, /**< DB operation failed */
+ ACCOUNT_ERROR_DB_NOT_OPENED = TIZEN_ERROR_ACCOUNT | 0x05, /**< DB is not connected */
+ ACCOUNT_ERROR_QUERY_SYNTAX_ERROR = TIZEN_ERROR_ACCOUNT | 0x06, /**< DB query syntax error */
+ ACCOUNT_ERROR_ITERATOR_END = TIZEN_ERROR_ACCOUNT | 0x07, /**< Iterator has reached the end */
+ ACCOUNT_ERROR_NOTI_FAILED = TIZEN_ERROR_ACCOUNT | 0x08, /**< Notification failed */
+ ACCOUNT_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+ ACCOUNT_ERROR_XML_PARSE_FAILED = TIZEN_ERROR_ACCOUNT | 0x0a, /**< XML parse failed */
+ ACCOUNT_ERROR_XML_FILE_NOT_FOUND = TIZEN_ERROR_ACCOUNT | 0x0b, /**< XML file does not exist */
+ ACCOUNT_ERROR_EVENT_SUBSCRIPTION_FAIL = TIZEN_ERROR_ACCOUNT | 0x0c, /**< Subscription failed */
+ ACCOUNT_ERROR_NOT_REGISTERED_PROVIDER = TIZEN_ERROR_ACCOUNT | 0x0d, /**< Account provider is not registered */
+ ACCOUNT_ERROR_NOT_ALLOW_MULTIPLE = TIZEN_ERROR_ACCOUNT | 0x0e, /**< Multiple accounts are not supported */
+ ACCOUNT_ERROR_DATABASE_BUSY = TIZEN_ERROR_ACCOUNT | 0x10, /**< SQLite busy handler expired */
+} account_error_e;
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ACCOUNT_ERROR_H__*/
diff --git a/include/account-private.h b/include/account-private.h
new file mode 100755
index 0000000..766faef
--- /dev/null
+++ b/include/account-private.h
@@ -0,0 +1,383 @@
+/*
+ * account
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Wonyoung Lee <wy1115.lee@samsung.com>, Sungchan Kim <sungchan81.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __ACCOUNT_PRIVATE_TYPES_H__
+#define __ACCOUNT_PRIVATE_TYPES_H__
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <glib.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "ACCOUNT"
+
+#define ACCOUNT_VERBOSE(fmt, arg...) \
+ LOGD(": " fmt "\n", ##arg);
+#define ACCOUNT_DEBUG(fmt, arg...) \
+ LOGD(": " fmt "\n", ##arg);
+#define ACCOUNT_ERROR(fmt, arg...) \
+ LOGE(": " fmt "\n", ##arg);
+#define ACCOUNT_FATAL(fmt, arg...) \
+ LOGF(": " fmt "\n", ##arg);
+#define ACCOUNT_SLOGD(fmt, arg...) \
+ SECURE_LOGD(": " fmt "\n", ##arg);
+#define ACCOUNT_SLOGI(fmt, arg...) \
+ SECURE_LOGI(": " fmt "\n", ##arg);
+#define ACCOUNT_SLOGE(fmt, arg...) \
+ SECURE_LOGE(": " fmt "\n", ##arg);
+
+#define ACCOUNT_RETURN_VAL(eval, expr, ret_val, X)\
+ if (!(eval)) \
+{\
+ expr; \
+ return ret_val;\
+} else {;}
+
+#define ACCOUNT_SNPRINTF(dest,size,format,arg...) \
+ do { \
+ snprintf(dest,size-1,format,##arg); \
+ }while(0)
+ /* If the same pointer is passed to free twice, known as a double free. To avoid this, set pointers to
+NULL after passing them to free: free(NULL) is safe (it does nothing).
+ */
+
+#define ACCOUNT_MEMSET(dest,value,size) \
+ do { \
+ memset(dest,value,size); \
+ }while(0)
+
+#define ACCOUNT_CATCH_ERROR(eval, expr, error_val, X) \
+ if (!(eval)) \
+{\
+ expr; \
+ error_code = (error_val);\
+ goto CATCH;\
+} else {;}
+
+#define _ACCOUNT_FREE(ptr) \
+ if (ptr != NULL) { \
+ free(ptr); \
+ ptr = NULL; \
+ } \
+
+
+#define _ACCOUNT_GFREE(ptr) \
+ if (ptr != NULL) { \
+ g_free(ptr); \
+ ptr = NULL; \
+ } \
+
+#define ACCOUNT_DB_NAME "/opt/usr/dbspace/.account.db"
+#define ACCOUNT_TABLE "account"
+#define CAPABILITY_TABLE "capability"
+#define ACCOUNT_CUSTOM_TABLE "account_custom"
+#define ACCOUNT_TYPE_TABLE "account_type"
+#define LABEL_TABLE "label"
+#define PROVIDER_FEATURE_TABLE "provider_feature"
+#define ACCOUNT_SQLITE_SEQ "sqlite_sequence"
+#define ACCOUNT_SQL_LEN_MAX 1024
+#define ACCOUNT_TABLE_TOTAL_COUNT 6
+
+#define FACEBOOK_PKG_NAME "com.samsung.facebook"
+#define EMAIL_PKG_NAME "email-setting-efl"
+#define EXCHANGE_PKG_NAME "activesync-ui"
+#define IMS_SERVICE_PKG_NAME "ims-service"
+#define SAMSUNGACCOUNTFRONT_PKG_NAME "com.samsung.samsung-account-front"
+//#define SAMSUNGACCOUNT_PKG_NAME "gr47by21a5.SamsungAccount"
+#define SAMSUNGACCOUNT_PKG_NAME "com.samsung.samsungaccount"
+#define CHATON_PKG_NAME "xnq5eh9vop.ChatON"
+#define DROPBOX_PKG_NAME "com.samsung.dropbox"
+#define SYNCHRONISE_PKG_NAME "setting-synchronise-efl"
+
+#define USER_TXT_CNT 5
+#define USER_INT_CNT 5
+
+
+/* account uri list */
+#define ACCOUNT_DATA_SERVICE_PROVIDER "http://tizen.org/account/data/service_provider"
+#define ACCOUNT_OPERATION_SIGNIN_OLD "http://tizen.org/account/operation/signin"
+
+// private account operation type
+#define ACCOUNT_OPERATION_FMM "http://tizen.org/account/operation/fmm"
+#define ACCOUNT_OPERATION_MYACCOUNT "http://tizen.org/account/operation/signin_from_myaccount"
+// End of private account operation type
+
+#define ACCOUNT_SUPPORTS_CAPABILITY_POST "http://tizen.org/account/capability/post"
+#define ACCOUNT_SUPPORTS_CAPABILITY_VOIP "http://tizen.org/account/capability/voip"
+#define ACCOUNT_SUPPORTS_CAPABILITY_SAMSUNG_APPS "http://tizen.org/account/capability/samsungapps"
+#define ACCOUNT_SUPPORTS_CAPABILITY_TASK "http://tizen.org/account/capability/task"
+#define ACCOUNT_SUPPORTS_CAPABILITY_MOBILE_TRACKER "http://tizen.org/account/capability/mobiletracker"
+#define ACCOUNT_SUPPORTS_CAPABILITY_S_NOTE "http://tizen.org/account/capability/snote"
+#define ACCOUNT_SUPPORTS_CAPABILITY_GALLERY "http://tizen.org/account/capability/gallery"
+#define ACCOUNT_SUPPORTS_CAPABILITY_MEMO "http://tizen.org/account/capability/memo"
+#define ACCOUNT_SUPPORTS_CAPABILITY_CHAT "http://tizen.org/account/capability/chat"
+#define ACCOUNT_SUPPORTS_CAPABILITY_BOOKMARK "http://tizen.org/account/capability/bookmark"
+#define ACCOUNT_SUPPORTS_CAPABILITY_SYNCHRONISE "http://tizen.org/account/capability/synchronise"
+#define ACCOUNT_SUPPORTS_CAPABILITY_TIZEN_EMAIL "http://tizen.org/account/capability/tizen_email"
+#define ACCOUNT_SUPPORTS_CAPABILITY_INTERNET "http://tizen.org/account/capability/internet"
+#define ACCOUNT_SUPPORTS_CAPABILITY_DOCOMO_SCHEDULE_MEMO "http://tizen.org/account/capability/docomo"
+/* end of account uri list */
+
+typedef struct _account_s
+{
+ int id;
+ char* user_name;
+ char* email_address;
+ char* display_name;
+ char* icon_path;
+ char* source;
+ char* package_name;
+ char* access_token;
+ char* domain_name; /*< domain name [Ex: google, facebook, twitter, samsung, ...] */
+ int auth_type;
+ int secret;
+ int sync_support;
+ int user_data_int[USER_INT_CNT];
+ char* user_data_txt[USER_TXT_CNT];
+ GSList* capablity_list;
+ GList* account_list;
+ GSList* custom_list;
+}account_s;
+
+typedef struct _capability_s
+{
+ int id;
+ char* type;
+ int value;
+ char* package_name;
+ char* user_name;
+ int account_id;
+}account_capability_s;
+
+
+typedef struct _account_custom_s
+{
+ int account_id;
+ char* app_id;
+ char* key;
+ char* value;
+}account_custom_s;
+
+typedef struct _account_type_s
+{
+ int id;
+ char* app_id;
+ char* service_provider_id;
+ char* icon_path;
+ char* small_icon_path;
+ bool multiple_account_support;
+ GSList* label_list;
+ GList* account_type_list;
+ GSList* provider_feature_list;
+}account_type_s;
+
+
+typedef struct _label_s
+{
+ char* app_id;
+ char* label;
+ char* locale;
+}label_s;
+
+typedef struct _provider_feature_s
+{
+ char* key;
+ char* app_id;
+}provider_feature_s;
+
+typedef struct _account_subscribe_s
+{
+ account_event_cb account_subscription_callback;
+ void* user_data;
+}account_subscribe_s;
+
+/**
+ * @brief Enumarations for account handle fields.
+ */
+
+typedef enum {
+ ACCOUNT_FIELD_NONE = -1,
+ ACCOUNT_FIELD_ID,
+ ACCOUNT_FIELD_USER_NAME,
+ ACCOUNT_FIELD_EMAIL_ADDRESS,
+ ACCOUNT_FIELD_DISPLAY_NAME,
+ ACCOUNT_FIELD_ICON_PATH,
+ ACCOUNT_FIELD_SOURCE,
+ ACCOUNT_FIELD_PACKAGE_NAME,
+ ACCOUNT_FIELD_ACCESS_TOKEN,
+ ACCOUNT_FIELD_DOMAIN_NAME,
+ ACCOUNT_FIELD_AUTH_TYPE,
+ ACCOUNT_FIELD_SECRET,
+ ACCOUNT_FIELD_SYNC_SUPPORT,
+ ACCOUNT_FIELD_USER_TEXT_0,
+ ACCOUNT_FIELD_USER_TEXT_1,
+ ACCOUNT_FIELD_USER_TEXT_2,
+ ACCOUNT_FIELD_USER_TEXT_3,
+ ACCOUNT_FIELD_USER_TEXT_4,
+ ACCOUNT_FIELD_USER_INT_0,
+ ACCOUNT_FIELD_USER_INT_1,
+ ACCOUNT_FIELD_USER_INT_2,
+ ACCOUNT_FIELD_USER_INT_3,
+ ACCOUNT_FIELD_USER_INT_4,
+ ACCOUNT_DB_FIELD_END,
+} ACCOUNT_DB_IDX;
+
+/**
+ * @brief Enumarations for capability fields.
+ */
+
+typedef enum {
+ CAPABILITY_FIELD_NONE = -1,
+ CAPABILITY_FIELD_ID,
+ CAPABILITY_FIELD_KEY,
+ CAPABILITY_FIELD_VALUE,
+ CAPABILITY_FIELD_PACKAGE_NAME,
+ CAPABILITY_FIELD_USER_NAME,
+ CAPABILITY_FIELD_ACCOUNT_ID,
+ CAPABILITY_FIELD_END,
+}CAPABILITY_DB_IDX;
+
+
+typedef enum {
+ ACCOUNT_CUSTOM_FIELD_NONE = -1,
+ ACCOUNT_CUSTOM_FIELD_ACCOUNT_ID,
+ ACCOUNT_CUSTOM_FIELD_APP_ID,
+ ACCOUNT_CUSTOM_FIELD_KEY,
+ ACCOUNT_CUSTOM_FIELD_VALUE,
+ ACCOUNT_CUSTOM_FIELD_END,
+}ACCOUNT_CUSTOM_DB_IDX;
+
+typedef enum {
+ ACCOUNT_TYPE_FIELD_NONE = -1,
+ ACCOUNT_TYPE_FIELD_ID,
+ ACCOUNT_TYPE_FIELD_APP_ID,
+ ACCOUNT_TYPE_FIELD_SERVICE_PROVIDER_ID,
+ ACCOUNT_TYPE_FIELD_ICON_PATH,
+ ACCOUNT_TYPE_FIELD_SMALL_ICON_PATH,
+ ACCOUNT_TYPE_FIELD_MULTIPLE_ACCOUNT_SUPPORT,
+ ACCOUNT_TYPE_FIELD_END,
+}ACCOUNT_TYPE_DB_IDX;
+
+typedef enum {
+ LABEL_FIELD_NONE = -1,
+ LABEL_FIELD_APP_ID,
+ LABEL_FIELD_LABEL,
+ LABEL_FIELD_LOCALE,
+ LABEL_FIELD_END,
+}LABEL_DB_IDX;
+
+typedef enum {
+ PROVIDER_FEATURE_FIELD_NONE = -1,
+ PROVIDER_FEATURE_FIELD_APP_ID,
+ PROVIDER_FEATURE_FIELD_KEY,
+ PROVIDER_FEATURE_FIELD_END,
+}PROVIDER_FEATURE_DB_IDX;
+
+typedef sqlite3_stmt* account_stmt;
+
+//ACCOUNT_TABLE
+#define ACCOUNT_SCHEMA "create table account \n"\
+ "(\n"\
+"_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
+"user_name TEXT, "\
+"email_address TEXT, "\
+"display_name TEXT, "\
+"icon_path TEXT, "\
+"source TEXT, "\
+"package_name TEXT, "\
+"access_token TEXT, "\
+"domain_name TEXT, "\
+"auth_type INTEGER, "\
+"secret INTEGER, "\
+"sync_support INTEGER, "\
+"txt_custom0 TEXT, "\
+"txt_custom1 TEXT, "\
+"txt_custom2 TEXT, "\
+"txt_custom3 TEXT, "\
+"txt_custom4 TEXT, "\
+"int_custom0 INTEGER, "\
+"int_custom1 INTEGER, "\
+"int_custom2 INTEGER, "\
+"int_custom3 INTEGER, "\
+"int_custom4 INTEGER "\
+");"
+
+//CAPABILITY_TABLE
+#define CAPABILITY_SCHEMA "create table capability \n"\
+ "(\n"\
+"_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
+"key TEXT, "\
+"value INTEGER, "\
+"package_name TEXT, "\
+"user_name TEXT, "\
+"account_id INTEGER "\
+");"
+
+//ACCOUNT_CUSTOM_TABLE
+#define ACCOUNT_CUSTOM_SCHEMA "create table account_custom \n"\
+ "(\n"\
+"AccountId INTEGER, "\
+"AppId TEXT, "\
+"Key TEXT, "\
+"Value TEXT "\
+");"
+
+//ACCOUNT_TYPE_TABLE
+#define ACCOUNT_TYPE_SCHEMA "create table account_type \n"\
+ "(\n"\
+"_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
+"AppId TEXT, "\
+"ServiceProviderId TEXT, "\
+"IconPath TEXT, "\
+"SmallIconPath TEXT, "\
+"MultipleAccountSupport INTEGER "\
+");"
+
+//LABEL_TABLE
+#define LABEL_SCHEMA "create table label \n"\
+ "(\n"\
+"AppId TEXT, "\
+"Label TEXT, "\
+"Locale TEXT"\
+");"
+
+//PROVIDER_FEATURE_TABLE
+#define PROVIDER_FEATURE_SCHEMA "create table provider_feature \n"\
+ "(\n"\
+"app_id TEXT, "\
+"key TEXT "\
+");"
+
+typedef struct GSList account_iterator_s;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SLP_ACCOUNT_PRIVATE_TYPES_H__*/
diff --git a/include/account-types.h b/include/account-types.h
new file mode 100755
index 0000000..5eb582f
--- /dev/null
+++ b/include/account-types.h
@@ -0,0 +1,261 @@
+/*
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Wonyoung Lee <wy1115.lee@samsung.com>, Sungchan Kim <sungchan81.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __ACCOUNT_TYPES_H__
+#define __ACCOUNT_TYPES_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+/**
+ * @addtogroup CAPI_ACCOUNT_MANAGER_MODULE
+ * @{
+ */
+
+/**
+ * @file account-types.h
+ * @ingroup CAPI_ACCOUNT
+ * @brief This file defines common types and enums of ACCOUNT.
+ */
+
+/**
+ * @brief Enumeration for the state of capability.
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ ACCOUNT_CAPABILITY_STATE_INVALID = 0, /**< Account capability is invalid */
+ ACCOUNT_CAPABILITY_DISABLED, /**< Account capability is disabled */
+ ACCOUNT_CAPABILITY_ENABLED, /**< Account capability is enabled */
+ ACCOUNT_CAPABILITY_STATE_MAX
+}
+account_capability_state_e;
+
+/**
+ * @brief Enumeration for the state of account secrecy.
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ ACCOUNT_SECRECY_INVALID = 0, /**< Account secrecy is invalid */
+ ACCOUNT_SECRECY_INVISIBLE, /**< Account is not visible */
+ ACCOUNT_SECRECY_VISIBLE, /**< Account is visible */
+ ACCOUNT_SECRECY_MAX
+}
+account_secrecy_state_e;
+
+/**
+ * @brief Enumeration for the account sync status.
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ ACCOUNT_SYNC_INVALID = 0, /**< Account sync is invalid */
+ ACCOUNT_SYNC_NOT_SUPPORT, /**< Account sync not supported */
+ ACCOUNT_SYNC_STATUS_OFF, /**< Account sync supported but all synchronization functionalities are off */
+ ACCOUNT_SYNC_STATUS_IDLE, /**< Account sync support and sync status is idle */
+ ACCOUNT_SYNC_STATUS_RUNNING, /**< Account sync support and sync status is running */
+ ACCOUNT_SUPPORTS_SYNC, /**< NOT USED, WILL BE REMOVED TO PREVENT BUILD ERROR */
+ ACCOUNT_NOT_SUPPORTS_SYNC, /**< NOT USED, WILL BE REMOVED TO PREVENT BUILD ERROR */
+ ACCOUNT_SYNC_MAX
+}
+account_sync_state_e;
+
+/**
+ * @brief Enumeration for the account auth type.
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ ACCOUNT_AUTH_TYPE_INVALID = 0, /**< Auth type is invalid */
+ ACCOUNT_AUTH_TYPE_XAUTH, /**< XAuth type */
+ ACCOUNT_AUTH_TYPE_OAUTH, /**< OAuth type */
+ ACCOUNT_AUTH_TYPE_CLIENT_LOGIN, /**< Client-Login type */
+ ACCOUNT_AUTH_TYPE_MAX
+}account_auth_type_e;
+
+/**
+ * @brief The structure type for the Account handle.
+ * @since_tizen 2.3
+ */
+typedef struct account_s* account_h;
+
+/**
+ * @brief The structure type for the Account provider handle.
+ * @since_tizen 2.3
+ */
+typedef struct account_type_s* account_type_h;
+
+/**
+ * @brief The structure type for the Account handle.
+ * @since_tizen 2.3
+ */
+typedef struct label_s* label_h;
+
+
+/**
+ * @brief The structure type for the Account subscribe handle.
+ * @since_tizen 2.3
+ */
+typedef struct account_subscribe_s* account_subscribe_h;
+
+/**
+ * @brief The insert notification type.
+ * @since_tizen 2.3
+ * @remarks When the account database is changed, You can distinguish one event type from the other which are set for subscribing notification.
+ *
+ * @see account_subscribe_notification()
+ */
+#define ACCOUNT_NOTI_NAME_INSERT "insert"
+
+/**
+ * @brief The update notification type.
+ * @since_tizen 2.3
+ * @remarks When the account database is changed, You can distinguish one event type from the other which are set for subscribing notification.
+ *
+ * @see account_subscribe_notification()
+ */
+#define ACCOUNT_NOTI_NAME_UPDATE "update"
+
+/**
+ * @brief The delete notification type.
+ * @since_tizen 2.3
+ * @remarks When the account database is changed, You can distinguish one event type from the other which are set for subscribing notification.
+ *
+ * @see account_subscribe_notification()
+ */
+#define ACCOUNT_NOTI_NAME_DELETE "delete"
+
+/**
+ * @brief The sync_update notification type.
+ * @since_tizen 2.3
+ * @remarks When the account database is changed, You can distinguish one event type from the other which are set for subscribing notification.
+ *
+ * @see account_subscribe_notification()
+ */
+#define ACCOUNT_NOTI_NAME_SYNC_UPDATE "sync_update"
+
+
+/**
+ * @brief This is a key of app_control_h’s extra data. The value of the key is a user account name.
+ * @since_tizen 2.3
+ * @remarks You can retrieve the value like this, app_control_get_extra_data(app_control, ACCOUNT_DATA_USERNAME, &username).\n
+ This value will be sent with ACCOUNT_OPERATION_VIEW.
+ */
+#define ACCOUNT_DATA_USERNAME "http://tizen.org/account/data/username"
+
+/**
+ * @brief This is a key of app_control_h’s extra data. The value of the key is account DB ID of the user’s account information.
+ * @since_tizen 2.3
+ * @remarks You can retrieve the value like this, app_control_get_extra_data(app_control, ACCOUNT_DATA_ID, &id).\n
+ This value will be sent with ACCOUNT_OPERATION_VIEW.
+ */
+#define ACCOUNT_DATA_ID "http://tizen.org/appcontrol/data/account/id"
+
+/**
+ * @brief This is an application launch operation name.
+ * @since_tizen 2.3
+ * @remarks This operation will be sent when a user selects your account in add account view.
+ */
+#define ACCOUNT_OPERATION_SIGNIN "http://tizen.org/appcontrol/operation/account/add"
+
+/**
+ * @brief This is an application launch operation name.
+ * @since_tizen 2.3
+ * @remarks This operation will be sent when a user selects your account in account list view.
+ */
+#define ACCOUNT_OPERATION_VIEW "http://tizen.org/appcontrol/operation/account/configure"
+
+/**
+ * @brief This is contact capability string.
+ * @since_tizen 2.3
+ * @remarks If your provider service has contact information and contact information is provided another application, register this capability through manifest file.
+ */
+#define ACCOUNT_SUPPORTS_CAPABILITY_CONTACT "http://tizen.org/account/capability/contact"
+
+/**
+ * @brief This is calendar capability string.
+ * @since_tizen 2.3
+ * @remarks If your provider service has calendar information and calendar information is provided another application, register this capability through manifest file.
+ */
+#define ACCOUNT_SUPPORTS_CAPABILITY_CALENDAR "http://tizen.org/account/capability/calendar"
+
+/**
+ * @brief This is email capability string.
+ * @since_tizen 2.3
+ * @remarks If your provider service have email service and email is provided another application, register this capability through manifest file.
+ */
+#define ACCOUNT_SUPPORTS_CAPABILITY_EMAIL "http://tizen.org/account/capability/email"
+
+/**
+ * @brief This is photo capability string.
+ * @since_tizen 2.3
+ * @remarks If your provider service has photo and photo is provided another application, register this capability through manifest file.
+ */
+#define ACCOUNT_SUPPORTS_CAPABILITY_PHOTO "http://tizen.org/account/capability/photo"
+
+/**
+ * @brief This is video capability string.
+ * @since_tizen 2.3
+ * @remarks If your provider service has video and video is provided another application, register this capability through manifest file.
+ */
+#define ACCOUNT_SUPPORTS_CAPABILITY_VIDEO "http://tizen.org/account/capability/video"
+
+/**
+ * @brief This is music capability string.
+ * @since_tizen 2.3
+ * @remarks If your provider service has music and music is provided another application, register this capability through manifest file.
+ */
+#define ACCOUNT_SUPPORTS_CAPABILITY_MUSIC "http://tizen.org/account/capability/music"
+
+/**
+ * @brief This is document capability string.
+ * @since_tizen 2.3
+ * @remarks If your provider service has document and document is provided another application, register this capability through manifest file.
+ */
+#define ACCOUNT_SUPPORTS_CAPABILITY_DOCUMENT "http://tizen.org/account/capability/document"
+
+/**
+ * @brief This is message capability string.
+ * @since_tizen 2.3
+ * @remarks This capability will be exploited to use SMS, MMS.
+ */
+#define ACCOUNT_SUPPORTS_CAPABILITY_MESSAGE "http://tizen.org/account/capability/message"
+
+/**
+ * @brief This is game capability string.
+ * @since_tizen 2.3
+ * @remarks This capability will be exploited to use game data.
+ */
+#define ACCOUNT_SUPPORTS_CAPABILITY_GAME "http://tizen.org/account/capability/game"
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ACCOUNT_TYPES_H__*/
+
diff --git a/include/account.h b/include/account.h
new file mode 100755
index 0000000..fefd4fe
--- /dev/null
+++ b/include/account.h
@@ -0,0 +1,2036 @@
+/*
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Wonyoung Lee <wy1115.lee@samsung.com>, Sungchan Kim <sungchan81.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __ACCOUNT_H__
+#define __ACCOUNT_H__
+
+#include <account-types.h>
+#include <account-error.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#ifndef ACCOUNT_API
+#define ACCOUNT_API __attribute__ ((visibility("default")))
+#endif
+
+/**
+ * @file account.h
+ * @brief This file contains the Account API for account management.
+ */
+
+/**
+ * @addtogroup CAPI_ACCOUNT_MANAGER_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called once for each account from the database.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[in] user_data The user data passed from the foreach function
+ *
+ * @return @c true to continue with the next iteration of the loop, \n
+ * otherwise @c false to break out of the loop
+ *
+ * @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() must be called.
+ *
+ * @see account_foreach_account_from_db()
+ * @see account_query_account_by_account_id()
+ * @see account_query_account_by_user_name()
+ * @see account_query_account_by_package_name()
+ */
+typedef bool (*account_cb)(account_h account, void *user_data);
+
+/**
+ * @brief Called once for each capability of an account in the database.
+ *
+ * @since_tizen 2.3
+ * @param[in] capability_type The capability type
+ * @param[in] capability_state The capability state
+ * @param[in] user_data The user data passed from the foreach function
+ *
+ * @return @c true to continue with the next iteration of the loop, \n
+ * otherwise @c false to break out of the loop
+ *
+ * @pre account_query_capability_by_account_id() must be called.
+ *
+ * @see account_query_capability_by_account_id()
+ */
+typedef bool (*capability_cb)(const char* capability_type, account_capability_state_e capability_state, void *user_data);
+
+/**
+ * @brief Called once for each custom data of an account in the database.
+ *
+ * @since_tizen 2.3
+ * @param[in] key The user custom key
+ * @param[in] value The user custom value of the specific key
+ * @param[in] user_data The user data passed
+ *
+ * @return @c true to continue with the next iteration of the loop, \n
+ * otherwise @c false to break out of the loop
+ *
+ * @pre account_query_capability_by_account_id() must be called.
+ *
+ * @see account_query_capability_by_account_id()
+ */
+typedef bool (*account_custom_cb)(char* key, char* value, void *user_data);
+
+
+/**
+ * @brief Called once for each account provider in the database.
+ *
+ * @since_tizen 2.3
+ * @param[in] account_type The account provider handle
+ * @param[in] user_data The user data passed
+ *
+ * @return @c true to continue with the next iteration of the loop, \n
+ * otherwise @c false to break out of the loop
+ *
+ * @pre account_type_foreach_account_type_from_db(), account_type_query_by_provider_feature() must be called.
+ *
+ * @see account_type_foreach_account_type_from_db()
+ * @see account_type_query_by_provider_feature()
+ */
+typedef bool (*account_type_cb)(account_type_h account_type, void *user_data);
+
+
+/**
+ * @brief Called once for each account label.
+ *
+ * @since_tizen 2.3
+ * @param[in] app_id The application ID
+ * @param[in] label The name of the account depends on the specified locale
+ * @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
+ * For example, "ko_KR" for Korean, "en_US" for American English.
+ * @param[in] user_data The user data passed
+ *
+ * @return @c true to continue with the next iteration of the loop, \n
+ * otherwise @c false to break out of the loop
+ *
+ * @pre account_type_get_label(), account_type_query_label_by_app_id() must be called.
+ *
+ * @see account_type_get_label()
+ * @see account_type_query_label_by_app_id()
+ */
+typedef bool (*account_label_cb)(char* app_id, char* label, char* locale, void *user_data);
+
+
+/**
+ * @brief Called once for each capability of an account provider in the database.
+ *
+ * @since_tizen 2.3
+ * @param[in] app_id The application ID
+ * @param[in] key The user custom key
+ * @param[in] user_data The user data passed
+ *
+ * @return @c true to continue with the next iteration of the loop, \n
+ * otherwise @c false to break out of the loop
+ *
+ * @pre account_type_query_provider_feature_by_app_id(), account_type_get_provider_feature_all() must be called.
+ *
+ * @see account_type_query_provider_feature_by_app_id()
+ * @see account_type_get_provider_feature_all()
+ */
+typedef bool (*provider_feature_cb)(char* app_id, char* key, void* user_data);
+
+
+/**
+ * @brief Called once when an event occurs.
+ *
+ * @since_tizen 2.3
+ * @param[in] event_type The account event type
+ * @param[in] account_id The account ID to update
+ * @param[in] user_data The user data passed
+ *
+ * @return @c true to continue with the next iteration of the loop, \n
+ * otherwise @c false to break out of the loop
+ *
+ * @pre account_subscribe_notification() must be called.
+ *
+ * @see account_subscribe_notification()
+ */
+typedef bool (*account_event_cb)(const char* event_type, int account_id, void* user_data);
+
+
+/**
+ * @brief Connects to the account database by readwrite mode.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read \n
+ * %http://tizen.org/privilege/account.write
+ * @remarks this API need both privileges
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_DB_NOT_OPENED DB is not connected
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @see account_disconnect()
+ */
+ACCOUNT_API int account_connect(void);
+
+
+/**
+ * @brief Connects to the account database by readonly mode.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_DB_NOT_OPENED DB is not connected
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @see account_disconnect()
+ */
+ACCOUNT_API int account_connect_readonly(void);
+
+
+/**
+ * @brief Disconnects from the account database.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ * @retval #ACCOUNT_ERROR_DATABASE_BUSY SQLite busy handler expired
+ *
+ * @see account_connect()
+ */
+ACCOUNT_API int account_disconnect(void);
+
+
+/**
+ * @brief Creates a handle to the account.
+ *
+ * @since_tizen 2.3
+ * @remarks Release @a account using account_destroy().
+ * @remarks The created handle is not added to the account database until account_insert_to_db() is called.
+ *
+ * @param[in] account The account handle
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_OUT_OF_MEMORY Out of Memory
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_destroy()
+ */
+ACCOUNT_API int account_create(account_h *account);
+
+
+/**
+ * @brief Destroys the account handle and releases all its resources.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_create()
+ */
+ACCOUNT_API int account_destroy(account_h account);
+
+
+/**
+ * @brief Inserts the account details to the account database.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read \n
+ * %http://tizen.org/privilege/account.write
+ * @remarks this API need both privileges
+ * @param[in] account The account handle
+ * @param[out] account_db_id The account ID to be assigned to an account
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_DUPLICATED Same user name exists in your application
+ * @retval #ACCOUNT_ERROR_NOT_ALLOW_MULTIPLE Tried to add an account in spite of multiple false accounts
+ * @retval #ACCOUNT_ERROR_NOT_REGISTERED_PROVIDER Tried to add an account though you did not register the account provider in manifest
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ *
+ * @see account_connect()
+ * @see account_delete_from_db_by_id()
+ * @see account_delete_from_db_by_user_name()
+ * @see account_delete_from_db_by_package_name()
+ * @see account_update_to_db_by_id()
+ * @see account_update_to_db_by_user_name()
+ */
+ACCOUNT_API int account_insert_to_db(account_h account, int *account_db_id);
+
+
+/**
+ * @brief Deletes an account from the account database by account DB ID.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read \n
+ * %http://tizen.org/privilege/account.write
+ * @remarks this API need both privileges
+ * @param[in] account_db_id The account ID to delete
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED The account owner is different from the caller or DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ *
+ * @see account_connect()
+ * @see account_insert_to_db()
+ * @see account_delete_from_db_by_user_name()
+ * @see account_delete_from_db_by_package_name()
+ * @see account_update_to_db_by_id()
+ * @see account_update_to_db_by_user_name()
+ */
+ACCOUNT_API int account_delete_from_db_by_id(int account_db_id);
+
+
+/**
+ * @brief Deletes an account from the account database by user name.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read \n
+ * %http://tizen.org/privilege/account.write
+ * @remarks this API need both privileges
+ * @param[in] user_name The user name of the account to delete
+ * @param[in] package_name The package name of the account to delete
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ *
+ * @see account_connect()
+ * @see account_insert_to_db()
+ * @see account_delete_from_db_by_id()
+ * @see account_delete_from_db_by_package_name()
+ * @see account_update_to_db_by_id()
+ * @see account_update_to_db_by_user_name()
+ */
+ACCOUNT_API int account_delete_from_db_by_user_name(char *user_name, char *package_name);
+
+
+/**
+ * @brief Deletes an account from the account database by package name.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read \n
+ * %http://tizen.org/privilege/account.write
+ * @remarks this API need both privileges
+ * @param[in] package_name The package name of account(s) to delete
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ *
+ * @see account_connect()
+ * @see account_insert_to_db()
+ * @see account_delete_from_db_by_id()
+ * @see account_delete_from_db_by_user_name()
+ * @see account_update_to_db_by_id()
+ * @see account_update_to_db_by_user_name()
+ */
+ACCOUNT_API int account_delete_from_db_by_package_name(const char *package_name);
+
+
+/**
+ * @brief Updates the account details to the account database.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read \n
+ * %http://tizen.org/privilege/account.write
+ * @remarks this API need both privileges
+ * @param[in] account The account handle
+ * @param[in] account_id The account ID to update
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_RECORD_NOT_FOUND The account to update does not exist
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ *
+ * @see account_connect()
+ * @see account_insert_to_db()
+ * @see account_delete_from_db_by_id()
+ * @see account_delete_from_db_by_user_name()
+ * @see account_delete_from_db_by_package_name()
+ * @see account_update_to_db_by_user_name()
+ */
+ACCOUNT_API int account_update_to_db_by_id(account_h account, int account_id);
+
+
+/**
+ * @brief Updates the account details to the account database without checking provider's permission.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read \n
+ * %http://tizen.org/privilege/account.write
+ * @remarks this API need both privileges
+ * @param[in] account The account handle
+ * @param[in] account_id The account ID to update
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_RECORD_NOT_FOUND The account to update does not exist
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ *
+ * @see account_connect()
+ * @see account_insert_to_db()
+ * @see account_delete_from_db_by_id()
+ * @see account_delete_from_db_by_user_name()
+ * @see account_delete_from_db_by_package_name()
+ * @see account_update_to_db_by_user_name()
+ */
+ACCOUNT_API int account_update_to_db_by_id_ex(account_h account, int account_id);
+
+/**
+ * @brief Updates the account details to the account database.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read \n
+ * %http://tizen.org/privilege/account.write
+ * @remarks this API need both privileges
+ * @param[in] account The account handle
+ * @param[in] user_name The user name of the account to update
+ * @param[in] package_name The package name for the user name
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_RECORD_NOT_FOUND The account to update does not exist
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ *
+ * @see account_connect()
+ * @see account_insert_to_db()
+ * @see account_delete_from_db_by_id()
+ * @see account_delete_from_db_by_user_name()
+ * @see account_delete_from_db_by_package_name()
+ * @see account_update_to_db_by_id()
+ *
+ */
+ACCOUNT_API int account_update_to_db_by_user_name(account_h account, const char *user_name, const char *package_name);
+
+/**
+ * @brief Gets the ID of an account.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[out] account_id The account ID
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+ACCOUNT_API int account_get_account_id(account_h account, int *account_id);
+
+/**
+ * @brief Gets the user name of an account.
+ *
+ * @since_tizen 2.3
+ * @remarks You must release @a user_name using free().
+ *
+ * @param[in] account The account handle
+ * @param[out] user_name The user name of the account
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see account_set_user_name()
+ */
+ACCOUNT_API int account_get_user_name(account_h account, char **user_name);
+
+
+/**
+ * @brief Sets the user name of an account.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[in] user_name The string to set as user name
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_get_user_name()
+ */
+ACCOUNT_API int account_set_user_name(account_h account, const char *user_name);
+
+
+/**
+ * @brief Gets the display name of an account.
+ *
+ * @since_tizen 2.3
+ * @remarks You must release @a display_name using free().
+ *
+ * @param[in] account The account handle
+ * @param[out] display_name The display name of the account
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see account_get_display_name()
+ */
+ACCOUNT_API int account_get_display_name(account_h account, char **display_name);
+
+
+/**
+ * @brief Sets the display name of an account.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[in] display_name The text string to set as the display name
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_get_display_name()
+ */
+ACCOUNT_API int account_set_display_name(account_h account, const char *display_name);
+
+/**
+ * @brief Gets the capability detail of an account.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[in] capability_type The capability type to get the capability value
+ * @param[out] capability_value The capability value (on/off) of the specified capability_type
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_RECORD_NOT_FOUND There is no given capability_type in the account
+ *
+ * @see account_set_capability()
+ */
+ACCOUNT_API int account_get_capability(account_h account, const char* capability_type, account_capability_state_e* capability_value);
+
+/**
+ * @brief Gets all the capabilities of an account.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[in] callback The callback function
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_set_capability()
+ */
+ACCOUNT_API int account_get_capability_all(account_h account, capability_cb callback, void *user_data);
+
+/**
+ * @brief Sets the capability.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[in] capability_type The capability type
+ * @param[in] capability_state The capability state
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_get_capability()
+ */
+ACCOUNT_API int account_set_capability(account_h account, const char* capability_type, account_capability_state_e capability_state);
+
+
+/**
+ * @brief Gets the icon path.
+ *
+ * @since_tizen 2.3
+ * @remarks You must release @a icon_path using free().
+ *
+ * @param[in] account The account handle
+ * @param[out] icon_path The icon path
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see account_set_icon_path()
+ */
+ACCOUNT_API int account_get_icon_path(account_h account, char **icon_path);
+
+
+/**
+ * @brief Sets the icon path.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[in] icon_path The text string to set as the icon path
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_get_icon_path()
+ */
+ACCOUNT_API int account_set_icon_path(account_h account, const char *icon_path);
+
+
+/**
+ * @brief Gets the domain name.
+ *
+ * @since_tizen 2.3
+ * @remarks You must release @a domain_name using free().
+ *
+ * @param[in] account The account handle
+ * @param[out] domain_name The domain name
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see account_set_domain_name()
+ */
+ACCOUNT_API int account_get_domain_name(account_h account, char **domain_name);
+
+
+/**
+ * @brief Sets the domain name.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[in] domain_name The text string to set as the domain name
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_get_domain_name()
+ */
+ACCOUNT_API int account_set_domain_name(account_h account, const char *domain_name);
+
+
+/**
+ * @brief Gets the email address.
+ *
+ * @since_tizen 2.3
+ * @remarks You must release @a email_address using free().
+ *
+ * @param[in] account The account handle
+ * @param[out] email_address The email address
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see account_set_email_address()
+ */
+ACCOUNT_API int account_get_email_address(account_h account, char **email_address);
+
+
+/**
+ * @brief Sets the email address.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[in] email_address The text string to set as the email address
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_get_email_address()
+ */
+ACCOUNT_API int account_set_email_address(account_h account, const char *email_address);
+
+
+/**
+ * @brief Gets the package name.
+ *
+ * @since_tizen 2.3
+ * @remarks You must release @a package_name using free().
+ *
+ * @param[in] account The account handle
+ * @param[out] package_name The package name
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see account_set_package_name()
+ */
+ACCOUNT_API int account_get_package_name(account_h account, char **package_name);
+
+
+/**
+ * @brief Sets the package name.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[in] package_name The text string to set as the package name
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_get_email_address()
+ */
+ACCOUNT_API int account_set_package_name(account_h account, const char *package_name);
+
+
+/**
+ * @brief Gets the access token.
+ *
+ * @since_tizen 2.3
+ * @remarks You must release @a access_token using free().
+ *
+ * @param[in] account The account handle
+ * @param[out] access_token The access token
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see account_set_access_token()
+ */
+ACCOUNT_API int account_get_access_token(account_h account, char **access_token);
+
+
+/**
+ * @brief Sets the access token.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[in] access_token The text string to set as the access token
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_get_access_token()
+ */
+ACCOUNT_API int account_set_access_token(account_h account, const char *access_token);
+
+
+/**
+ * @brief Gets the user text.
+ *
+ * @since_tizen 2.3
+ * @remarks You must release @a user_text using free().
+ *
+ * @param[in] account The account handle
+ * @param[in] user_text_index The index of the user text (range: 0 ~ 4)
+ * @param[out] user_text The user text
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see account_set_user_text()
+ */
+ACCOUNT_API int account_get_user_text(account_h account, int user_text_index, char **user_text);
+
+
+/**
+ * @brief Sets the user text.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[in] user_text_index The index of the user text (must be in range from @c 0 to @c 4)
+ * @param[in] user_text The text string to set as the user text
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_get_user_text()
+ */
+ACCOUNT_API int account_set_user_text(account_h account, int user_text_index, const char *user_text);
+
+
+/**
+ * @brief Gets the user integer.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[in] user_int_index The index of the user integer (must be in range from @c 0 to @c 4)
+ * @param[out] user_integer The user integer
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_set_user_int()
+ */
+ACCOUNT_API int account_get_user_int(account_h account, int user_int_index, int *user_integer);
+
+
+/**
+ * @brief Sets the user integer.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[in] user_int_index The index of the user integer (must be in range from @c 0 to @c 4)
+ * @param[in] user_integer The integer to set as the user integer
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_get_user_int()
+ */
+ACCOUNT_API int account_set_user_int(account_h account, int user_int_index, int user_integer);
+
+
+/**
+ * @brief Gets the auth type.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[out] auth_type The auth type
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_set_auth_type()
+ */
+ACCOUNT_API int account_get_auth_type(account_h account, account_auth_type_e *auth_type);
+
+
+/**
+ * @brief Sets the auth type.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[in] auth_type The integer to be set as the auth type
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_get_auth_type()
+ */
+ACCOUNT_API int account_set_auth_type(account_h account, const account_auth_type_e auth_type);
+
+
+/**
+ * @brief Gets the secret.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[out] secret The secret
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_set_secret()
+ */
+ACCOUNT_API int account_get_secret(account_h account, account_secrecy_state_e *secret);
+
+
+/**
+ * @brief Sets the secret.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[in] secret The secrecy to be set
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_get_secret()
+ */
+ACCOUNT_API int account_set_secret(account_h account, const account_secrecy_state_e secret);
+
+/**
+ * @brief Gets the sync support.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[out] sync_support The sync support
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_set_sync_support()
+ */
+ACCOUNT_API int account_get_sync_support(account_h account, account_sync_state_e *sync_support);
+
+
+/**
+ * @brief Sets the sync support.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[in] sync_support The sync state to be set
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_get_sync_support()
+ */
+ACCOUNT_API int account_set_sync_support(account_h account, const account_sync_state_e sync_support);
+
+
+/**
+ * @brief Gets the source.
+ *
+ * @since_tizen 2.3
+ * @remarks You must release @a user_text using free().
+ *
+ * @param[in] account The account handle
+ * @param[out] source The source
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see account_set_source()
+ */
+ACCOUNT_API int account_get_source(account_h account, char **source);
+
+
+/**
+ * @brief Sets the source.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[in] source The text string to set as the source
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_get_source()
+ */
+ACCOUNT_API int account_set_source(account_h account, const char *source);
+
+/**
+ * @brief Sets the custom.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[in] key The user custom key for the specific value
+ * @param[in] value The user custom value about the given key
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_get_custom()
+ */
+ACCOUNT_API int account_set_custom(account_h account, const char* key, const char* value);
+
+/**
+ * @brief Gets the user specific custom text of an account key.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[in] key The key to retrieve custom text
+ * @param[out] value The text of the given key
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_RECORD_NOT_FOUND There is no given capability type in the account
+ *
+ * @see account_set_custom()
+ */
+ACCOUNT_API int account_get_custom(account_h account, const char* key, char** value);
+
+
+/**
+ * @brief Gets all the user custom texts of an account.
+ *
+ * @since_tizen 2.3
+ * @param[in] account The account handle
+ * @param[in] callback The callback function to retrieve all custom text \n
+ * The callback function gives the key and value.
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_set_custom()
+ */
+ACCOUNT_API int account_get_custom_all(account_h account, account_custom_cb callback, void* user_data);
+
+/**
+ * @brief Retrieves all accounts details by invoking the given callback function iteratively.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ * @retval #ACCOUNT_ERROR_RECORD_NOT_FOUND Related record does not exist
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ * @post This function invokes account_cb().
+ *
+ * @see account_connect()
+ * @see account_query_account_by_account_id()
+ * @see account_query_account_by_user_name()
+ * @see account_query_account_by_package_name()
+ * @see account_query_account_by_capability()
+ */
+ACCOUNT_API int account_foreach_account_from_db(account_cb callback, void *user_data);
+
+
+/**
+ * @brief Retrieve an account with the account ID.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read
+ * @param[in] account_db_id The account database ID to search
+ * @param[out] account The account handle \n
+ * Must be allocated by account_create() and freed after using by account_destroy().
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ *
+ * @see account_connect()
+ * @see account_query_account_by_user_name()
+ * @see account_query_account_by_package_name()
+ * @see account_query_account_by_capability()
+ */
+ACCOUNT_API int account_query_account_by_account_id(int account_db_id, account_h *account);
+
+/**
+ * @brief Retrieves all accounts with the user name.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_name The user name to search
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ * @post This function invokes account_cb().
+ *
+ * @see account_connect()
+ * @see account_foreach_account_from_db()
+ * @see account_query_account_by_account_id()
+ * @see account_query_account_by_package_name()
+ * @see account_query_account_by_capability()
+ *
+ */
+ACCOUNT_API int account_query_account_by_user_name(account_cb callback, const char* user_name, void* user_data);
+
+/**
+ * @brief Retrieves all accounts with the package name.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read
+ * @param[in] callback The callback function to invoke
+ * @param[in] package_name The package name to search
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ * @post This function invokes account_cb().
+ *
+ * @see account_connect()
+ * @see account_foreach_account_from_db()
+ * @see account_query_account_by_account_id()
+ * @see account_query_account_by_user_name()
+ * @see account_query_account_by_capability()
+ */
+ACCOUNT_API int account_query_account_by_package_name(account_cb callback, const char *package_name, void *user_data);
+
+/**
+ * @brief Retrieves all accounts with the capability type and capability value.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read
+ * @param[in] callback The callback function to invoke
+ * @param[in] capability_type The capability type to search
+ * @param[in] capability_value The capability value to search
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ * @post This function invokes account_cb().
+ *
+ * @see account_connect()
+ * @see account_foreach_account_from_db()
+ * @see account_query_account_by_account_id()
+ * @see account_query_account_by_user_name()
+ * @see account_query_account_by_package_name()
+ */
+ACCOUNT_API int account_query_account_by_capability(account_cb callback, const char* capability_type, account_capability_state_e capability_value, void *user_data);
+
+/**
+ * @brief Retrieves all accounts with the capability type.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read
+ * @param[in] callback The callback function to invoke
+ * @param[in] capability_type The capability type to search
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ * @post This function invokes account_cb().
+ *
+ * @see account_connect()
+ * @see account_foreach_account_from_db()
+ * @see account_query_account_by_account_id()
+ * @see account_query_account_by_user_name()
+ * @see account_query_account_by_package_name()
+ */
+ACCOUNT_API int account_query_account_by_capability_type(account_cb callback, const char* capability_type, void* user_data);
+
+/**
+ * @brief Retrieves all capabilities with the account database ID.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read
+ * @param[in] callback The callback function to invoke
+ * @param[in] account_db_id The account database ID to search
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ * @post This function invokes capability_cb().
+ *
+ * @see account_connect()
+ * @see account_get_capability()
+ * @see account_set_capability()
+ */
+ACCOUNT_API int account_query_capability_by_account_id(capability_cb callback, int account_db_id, void *user_data);
+
+
+/**
+ * @brief Gets the count of accounts in the account database.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read
+ * @param[out] count The out parameter for count of all accounts
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ *
+ * @see account_connect()
+ */
+ACCOUNT_API int account_get_total_count_from_db(int *count);
+
+/**
+ * @brief Updates the sync status of an account with the given account ID.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read \n
+ * %http://tizen.org/privilege/account.write
+ * @remarks this API need both privileges
+ * @param[in] account_db_id The account ID for which sync status needs to be changed
+ * @param[in] sync_status The new sync status
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ *
+ * @see account_connect()
+ */
+ACCOUNT_API int account_update_sync_status_by_id(int account_db_id, const account_sync_state_e sync_status);
+
+
+/* Account type API */
+
+
+/**
+ * @brief Creates a handle to the account provider.
+ *
+ * @since_tizen 2.3
+ * @remarks You must release @a account_type handle using account_type_destroy().\n
+ *
+ * @param[in] account_type The account provider handle
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_OUT_OF_MEMORY Out of Memory
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_type_destroy()
+ */
+ACCOUNT_API int account_type_create(account_type_h *account_type);
+
+/**
+ * @brief Destroys the account provider handle and releases all its resources.
+ *
+ * @since_tizen 2.3
+ *
+ * @remarks When you get @a account_type_h using account_type_create(), you must release the handle using account_destroy() to avoid the memory leak.
+ *
+ * @param[in] account_type The account provider handle
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_type_create()
+ */
+ACCOUNT_API int account_type_destroy(account_type_h account_type);
+
+/**
+ * @internal
+ * @brief Sets the app ID.
+ * It should be filled with your application ID. For example, com.tizen.testapp.
+ *
+ * @since_tizen 2.3
+ * @remarks @a app_id is a mandatory field and does not allow duplicate app ID in the account provider database.
+ *
+ * @param[in] account_type The account provider handle \n
+ * It should be assigned by account_type_create().
+ * @param[in] app_id The application ID
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see account_type_get_app_id()
+ */
+ACCOUNT_API int account_type_set_app_id(account_type_h account_type, const char *app_id);
+
+/**
+ * @internal
+ * @brief Sets the service provider ID.
+ * It should be filled with your service provider ID.
+ *
+ * @since_tizen 2.3
+ * @remarks @a service_provider_id is a mandatory field.
+ *
+ * @param[in] account_type The account provider handle \n
+ * It should be assigned by account_type_create().
+ * @param[in] service_provider_id The service provider ID
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see account_type_get_service_provider_id()
+ */
+ACCOUNT_API int account_type_set_service_provider_id(account_type_h account_type, const char *service_provider_id);
+
+/**
+ * @internal
+ * @brief Sets icon path.
+ * It represents your service provider or an application.
+ *
+ * @since_tizen 2.3
+ * @remarks @a icon_path is not a mandatory field. But when it is set, you can display this icon in the Add Account screen.
+ *
+ * @param[in] account_type The account provider handle\n
+ * It should be assigned by account_type_create().
+ * @param[in] icon_path The icon path of the application
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see account_type_get_icon_path()
+ */
+ACCOUNT_API int account_type_set_icon_path(account_type_h account_type, const char *icon_path);
+
+/**
+ * @internal
+ * @brief Sets small icon path.
+ * It also represents your service provider or an application.
+ *
+ * @since_tizen 2.3
+ * @remarks @a small_icon_path is not a mandatory field.
+ *
+ * @param[in] account_type The account provider handle \n
+ * It should be assigned by account_type_create().
+ * @param[in] small_icon_path The scaled icon of your application
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see account_type_get_small_icon_path()
+ */
+ACCOUNT_API int account_type_set_small_icon_path(account_type_h account_type, const char *small_icon_path);
+
+/**
+ * @internal
+ * @brief Sets support for multiple accounts.
+ * It represents whether your application supports multiple accounts.
+ *
+ * @since_tizen 2.3
+ * @remarks The default value of multiple account support is @c FALSE.
+ *
+ * @param[in] account_type The account provider handle \n
+ * It should be assigned by account_type_create().
+ * @param[in] multiple_account_support Set @c TRUE if your application can support two or more accounts, \n
+ * otherwise @c FALSE if your application can support only one account
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see account_type_get_multiple_account_support()
+ */
+ACCOUNT_API int account_type_set_multiple_account_support(account_type_h account_type, const bool multiple_account_support);
+
+/**
+ * @internal
+ * @brief Sets label and locale.
+ * Label represents the name of an account provider.
+ *
+ * @since_tizen 2.3
+ * @param[in] account_type The account provider handle \n
+ * It should be assigned by account_type_create().
+ * @param[in] label The name of account depends on the specified locale
+ * @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
+ * For example, "ko_KR" for Korean, "en_US" for American English.
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see account_type_get_label()
+ */
+ACCOUNT_API int account_type_set_label(account_type_h account_type, const char* label, const char* locale);
+
+/**
+ * @internal
+ * @brief Sets the capability.
+ *
+ * @since_tizen 2.3
+ * @param[in] account_type The account provider handle
+ * @param[in] provider_feature Th capability key of the account
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_set_capability()
+ */
+ACCOUNT_API int account_type_set_provider_feature(account_type_h account_type, const char* provider_feature);
+
+/**
+ * @brief Retrieves capability information with your application ID.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read
+ * @param[in] callback The callback function carries the capability name of an app ID
+ * @param[in] app_id The application ID to search
+ * @param[in] user_data The user data \n
+ * If you have your private data to carry into callback function, then you can use it.
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ *
+ * @see account_connect()
+ * @see account_disconnect()
+ */
+ACCOUNT_API int account_type_query_provider_feature_by_app_id(provider_feature_cb callback, const char* app_id, void *user_data );
+
+/**
+ * @brief Checks whether the given application ID supports the capability.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read
+ * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
+ * @param[in] app_id The application ID
+ * @param[in] capability The capability \n
+ * For example, ACCOUNT_SUPPORTS_CAPABILITY_CONTACT or "http://tizen.org/account/capability/contact"
+ *
+ * @return @c TRUE if the application supports the given capability, \n
+ * otherwise @c FALSE if the application does not support the given capability
+ * @retval @c TRUE means the application supports the given capability
+ * @retval @c FALSE means the application does not support the given capability
+ * @exception #ACCOUNT_ERROR_NONE Successful
+ * @exception #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #ACCOUNT_ERROR_RECORD_NOT_FOUND Related record does not exist
+ * @exception #ACCOUNT_ERROR_PERMISSION_DENIED DB access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ *
+ * @see account_connect()
+ * @see account_disconnect()
+ */
+ACCOUNT_API bool account_type_query_supported_feature(const char* app_id, const char* capability);
+
+/**
+ * @brief Gets the application ID of an account provider.
+ *
+ * @since_tizen 2.3
+ * @remarks You must release @a app_id using free().
+ *
+ * @param[in] account_type The account provider handle \n
+ * It should be given by account_type_query_* functions or account_type_foreach_account_type_from_db().
+ * @param[out] app_id The application ID of an account provider item
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see account_type_foreach_account_type_from_db()
+ * @see account_type_query_by_app_id()
+ */
+ACCOUNT_API int account_type_get_app_id(account_type_h account_type, char **app_id);
+
+/**
+ * @brief Gets the service provider ID of an account provider.
+ *
+ * @since_tizen 2.3
+ * @remarks You must release @a service_provider_id using free().
+ *
+ * @param[in] account_type The account provider handle \n
+ * It should be given by account_type_query_* functions or account_type_foreach_account_type_from_db().
+ * @param[out] service_provider_id The service provider text ID of an account provider item
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see account_type_foreach_account_type_from_db()
+ * @see account_type_query_by_app_id()
+ */
+ACCOUNT_API int account_type_get_service_provider_id(account_type_h account_type, char **service_provider_id);
+
+/**
+ * @brief Gets the icon path of an account provider.
+ *
+ * @since_tizen 2.3
+ * @remarks You must release @a icon_path using free().
+ *
+ * @param[in] account_type The account provider handle \n
+ * It should be given by account_type_query_* functions or account_type_foreach_account_type_from_db().
+ * @param[out] icon_path The icon path of the account provider item
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see account_type_foreach_account_type_from_db()
+ * @see account_type_query_by_app_id()
+ */
+ACCOUNT_API int account_type_get_icon_path(account_type_h account_type, char **icon_path);
+
+/**
+ * @brief Gets the small icon path of an account provider.
+ *
+ * @since_tizen 2.3
+ * @remarks You must release @a small_icon_path using free().
+ *
+ * @param[in] account_type The account provider handle\n
+ * It should be given by account_type_query_* functions or account_type_foreach_account_type_from_db().
+ * @param[out] small_icon_path The small icon path of the account provider item
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see account_type_foreach_account_type_from_db()
+ * @see account_type_query_by_app_id()
+ */
+ACCOUNT_API int account_type_get_small_icon_path(account_type_h account_type, char **small_icon_path);
+
+/**
+ * @brief Checks whether the given account provider supports multiple accounts.
+ *
+ * @since_tizen 2.3
+ * @param[in] account_type The account provider handle \n
+ * It should be given by account_type_query_* functions or account_type_foreach_account_type_from_db.
+ * @param[out] multiple_account_support The flag indicating support for multiple accounts accounts\n
+ * TRUE or FALSE.
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see account_type_foreach_account_type_from_db()
+ * @see account_type_query_by_app_id()
+ */
+ACCOUNT_API int account_type_get_multiple_account_support(account_type_h account_type, int *multiple_account_support);
+
+/**
+ * @brief Gets capability information with the given account provider handle.
+ *
+ * @since_tizen 2.3
+ * @param[in] account_type The account provider handle\n
+ * It should be given by account_type_query_* functions or account_type_foreach_account_type_from_db().
+ * @param[in] callback The callback function that carries the capability name of the app ID
+ * @param[in] user_data The user data \n
+ * If you have your private data to carry into callback function, then you can use it.
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ *
+ * @see account_connect()
+ * @see account_disconnect()
+ */
+ACCOUNT_API int account_type_get_provider_feature_all(account_type_h account_type, provider_feature_cb callback, void* user_data);
+
+/**
+ * @brief Gets the specific label information detail of an account provider.
+ *
+ * @since_tizen 2.3
+ * @param[in] account_type The account provider handle\n
+ * It should be given by account_type_query_* functions or account_type_foreach_account_type_from_db().
+ * @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
+ * For example, "ko_KR" or "ko-kr" for Korean, "en_US" or "en-us" for American English.
+ * @param[out] label The label text given for the locale
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_RECORD_NOT_FOUND No label for the given locale
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_type_foreach_account_type_from_db()
+ * @see account_type_query_by_app_id()
+ */
+
+ACCOUNT_API int account_type_get_label_by_locale(account_type_h account_type, const char* locale, char** label);
+
+/**
+ * @brief Gets the label information detail of an account provider.
+ *
+ * @since_tizen 2.3
+ * @param[in] account_type The account provider handle\n
+ * It should be given by account_type_query_* functions or account_type_foreach_account_type_from_db().
+ * @param[in] callback The callback function carrying the label information
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_type_foreach_account_type_from_db()
+ * @see account_type_query_by_app_id()
+ */
+ACCOUNT_API int account_type_get_label(account_type_h account_type, account_label_cb callback, void *user_data);
+
+/**
+ * @internal
+ * @brief Inserts the account provider details to the database.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read \n
+ * %http://tizen.org/privilege/account.write
+ * @remarks this API need both privileges
+ * @param[in] account_type The account handle which is created by account_type_create() \n
+ * @param[out] account_type_id The account provider ID to be assigned after inserting the account provider handle
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ * @post account_disconnect() is recommended after insertion.
+ *
+ * @see account_connect()
+ * @see account_disconnect()
+ */
+ACCOUNT_API int account_type_insert_to_db(account_type_h account_type, int* account_type_id);
+
+/**
+ * @internal
+ * @brief Updates the account details to the account database.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read \n
+ * %http://tizen.org/privilege/account.write
+ * @remarks this API need both privileges
+ * @param[in] account_type The account handle which is created by account_type_create() \n
+ * @param[in] app_id The application ID of the account provider
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ * @post account_disconnect() is recommended after update.
+ *
+ * @see account_connect()
+ * @see account_disconnect()
+ */
+ACCOUNT_API int account_type_update_to_db_by_app_id(const account_type_h account_type, const char* app_id);
+
+/**
+ * @internal
+ * @brief Deletes the account provider from the account database by application ID.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read \n
+ * %http://tizen.org/privilege/account.write
+ * @remarks this API need both privileges
+ * @param[in] app_id The application ID of account provider to be deleted
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ *
+ * @see account_connect()
+ * @see account_disconnect()
+ */
+ACCOUNT_API int account_type_delete_by_app_id(const char* app_id);
+
+/**
+ * @brief Retrieves the label information with your application ID.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read
+ * @param[in] callback The callback function that carries label_h for label information \n
+ * label_h contains label info as parameter.
+ * @param[in] app_id The application ID to search
+ * @param[in] user_data The user data \n
+ * If you have your private data to carry into callback function, then you can use it.
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ *
+ * @see account_connect()
+ * @see account_type_query_by_app_id()
+ * @see account_type_foreach_account_type_from_db()
+ * @see account_disconnect()
+ */
+ACCOUNT_API int account_type_query_label_by_app_id(account_label_cb callback, const char* app_id, void *user_data );
+
+/**
+ * @brief Retrieves the account provider information with your application ID.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read
+ * @param[in] app_id The application ID to search
+ * @param[out] account_type The account handle which is created by account_type_create()
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_RECORD_NOT_FOUND Queried data does not exist
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ *
+ * @see account_connect()
+ * @see account_type_create()
+ * @see account_type_get_app_id()
+ * @see account_type_get_service_provider_id()
+ * @see account_type_get_icon_path()
+ * @see account_type_get_small_icon_path()
+ * @see account_type_get_multiple_account_support()
+ * @see account_type_get_label()
+ * @see account_type_destroy()
+ */
+ACCOUNT_API int account_type_query_by_app_id(const char* app_id, account_type_h *account_type);
+
+/**
+ * @brief Retrieves all account priovider information.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read
+ * @param[in] callback The account provider information \n
+ * You can get the account information through account_type_get_* with the carried account_type_handle.
+ * @param[in] user_data The user data \n
+ * It will be carried through your callback function.
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ *
+ * @see account_connect()
+ * @see account_type_create()
+ * @see account_type_get_app_id()
+ * @see account_type_get_service_provider_id()
+ * @see account_type_get_icon_path()
+ * @see account_type_get_small_icon_path()
+ * @see account_type_get_multiple_account_support()
+ * @see account_type_get_label()
+ * @see account_type_destroy()
+ */
+ACCOUNT_API int account_type_foreach_account_type_from_db(account_type_cb callback, void *user_data);
+
+/**
+ * @brief Retrieves the label information with the given application ID and locale.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read
+ * @param[in] app_id The application ID
+ * @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
+ * For example, "ko_KR" or "ko-kr" for Korean, "en_US" or "en-us" for American English.
+ * @param[out] label The label text corresponding app_id and locale \n
+ * It must be free text.
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ *
+ * @see account_connect()
+ */
+ACCOUNT_API int account_type_query_label_by_locale(const char* app_id, const char* locale, char** label);
+
+/**
+ * @brief Retrieves account provider information with the capability name.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read
+ * @param[in] callback The callback function to retrieve account provider information
+ * @param[in] key The capability value to search account provider \n
+ * For example, ACCOUNT_SUPPORTS_CAPABILITY_CONTACT or "http://tizen.org/account/capability/contact"
+ * @param[in] user_data If you have your private data to carry into callback function, then you can use it
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_RECORD_NOT_FOUND Record not found
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ *
+ * @see account_connect()
+ */
+ACCOUNT_API int account_type_query_by_provider_feature(account_type_cb callback, const char* key, void* user_data);
+
+/**
+ * @brief Checks whether the given app_id exists in the account provider DB.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read
+ * @param[in] app_id The application ID to check
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_RECORD_NOT_FOUND Record not found
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid app ID
+ * @retval #ACCOUNT_ERROR_PERMISSION_DENIED DB Access fail by permission
+ *
+ * @pre This function requires an open connection to an account service by account_connect().
+ *
+ * @see account_type_query_by_app_id()
+ */
+ACCOUNT_API int account_type_query_app_id_exist(const char* app_id);
+
+
+
+/* End of account provider API */
+
+/**
+ * @brief Creates a handle for the account event subscription.
+ *
+ * @since_tizen 2.3
+ * @remarks You must release @a account_subscribe handle using account_unsubscribe_notification().
+ *
+ * @param[in] account_subscribe The account subscription handle
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_OUT_OF_MEMORY Out of Memory
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_unsubscribe_notification()
+ * @see account_subscribe_notification()
+ */
+ACCOUNT_API int account_subscribe_create(account_subscribe_h* account_subscribe);
+
+/**
+ * @brief Starts to subscribe account event through the given callback function.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read
+ * @param[in] account_subscribe The account subscription handle
+ * @param[in] callback The callback function that is called when an account is removed and a data of account is updated from the account database \n
+ * It will be called with event message and account ID.
+ * @param[in] user_data The user_data that is delivered to callback
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_EVENT_SUBSCRIPTION_FAIL Subscription fail
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @pre account_subscribe_create()
+ *
+ * @see account_unsubscribe_notification()
+ * @see account_subscribe_notification()
+ */
+ACCOUNT_API int account_subscribe_notification(account_subscribe_h account_subscribe, account_event_cb callback, void* user_data);
+
+/**
+ * @brief Destroys the account subscribe handle and releases all its resources.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/account.read
+ * @remarks You must call @a account_unsubscribe_notification when you do not need to subscribe account event.
+ *
+ * @param[in] account_subscribe The account subscription handle
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ACCOUNT_ERROR_EVENT_SUBSCRIPTION_FAIL Unsubscription failed
+ *
+ * @see account_create()
+ */
+ACCOUNT_API int account_unsubscribe_notification(account_subscribe_h account_subscribe);
+/**
+* @}
+*/
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ACCOUNT_H__ */
diff --git a/include/account_PG.h b/include/account_PG.h
new file mode 100755
index 0000000..c24c8c5
--- /dev/null
+++ b/include/account_PG.h
@@ -0,0 +1,1236 @@
+/*
+ * Account
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Wonyoung Lee <wy1115.lee@samsung.com>, Sungchan Kim <sungchan81.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ *
+ * @ingroup SLP_PG
+ * @defgroup Account_PG Account
+
+
+<h1 class="pg">Introduction</h1>
+ <h2 class="pg">Purpose of this document</h2>
+
+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.
+
+ <h2 class="pg">Scope</h2>
+
+The scope of this document is limited to Account API usage.
+
+
+<h1 class="pg">Account Architecture</h1>
+ <h2 class="pg"> Overview</h2>
+
+Account is responsible for inserting, deleting, and updating Account data in order to accommodate the needs for application's Account data.
+Users can access Account data without knowing DB schema, SQLite, relations of data
+
+<h1 class="pg">Account Features</h1>
+ - Similar to Sqlite3
+ - Handle information of Account
+
+ <h2 class="pg">Similar to Sqlite3</h2>
+Account API is similar to Sqlite3.
+
+ <h2 class="pg">Handle information of Account</h2>
+Account supports to insert/update/delete/get/set/query information of Account.
+The Information of Account includes user name, package name, email, access token, icon path, source, display name, capability informatio etc.
+
+<h1 class="pg">Account API Description</h1>
+
+you can refer @ref ACCOUNT_SVC
+
+<h1 class="pg">Sample Code</h1>
+
+ <h2 class="pg">Connect to Account Database</h2>
+
+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
+
+@code
+int account_connect(void);
+
+int account_disconnect(void);
+@endcode
+
+ <h2 class="pg">Insert information of account</h2>
+
+@code
+void insert_test(void)
+{
+ int ret = -1;
+ account_h account;
+
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_create(&account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_user_name(account, "tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "Tarun Kumar");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "Samsung electronics");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_email_address(account, "tarun@gmail.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_package_name(account, "com.samsung.twiter");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_icon_path(account, "icon-path");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_access_token(account, "ACCESSTOKEN");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_auth_type( account, ACCOUNT_AUTH_TYPE_OAUTH );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_secret( account, ACCOUNT_SECRECY_INVISIBLE );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_source(account, "URUSA inc.");
+
+ int i;
+
+ for(i=0;i<USER_TXT_CNT;i++)
+ {
+ ret = account_set_user_text(account, i, "user txt");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+
+ }
+
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ ret = account_set_user_int(account, i, 888);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+ }
+
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_CONTACT, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_CALENDAR, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_PHOTO, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_VIDEO, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_EMAIL, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_STATUS_POST, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_VOIP, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_SAMSUNG_APPS, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_MOBILE_TRACKER, ACCOUNT_CAPABILITY_ENABLED);
+
+ int account_id = -1;
+ ret = account_insert_to_db(account, &account_id);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ return;
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ return;
+}
+@endcode
+
+ <h2 class="pg">Get account by id</h2>
+
+@code
+bool _capability_get_callback(const char* capability_type, account_capability_state_e capability_value, void* user_data)
+{
+ char* test_type = capability_type;
+ int test_value = capability_value;
+
+ SECURE_LOGD("_capability_get_callback test_type = : %s\n", test_type);
+ SECURE_LOGD("_capability_get_callback test_value = : %d\n", test_value);
+ return TRUE;
+}
+
+static void _account_free_text(char *text)
+{
+ if (text) {
+ free(text);
+ text = NULL;
+ }
+}
+
+void get_account_by_id(int account_id)
+{
+ int ret = - 1;
+ account_h account;
+
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_query_account_by_account_id(account_id, &account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ char *test_text = NULL;
+
+ account_get_user_name(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_display_name(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_email_address(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_icon_path(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_source(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_package_name(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_domain_name(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_access_token(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ int i;
+
+ for(i=0;i<USER_TXT_CNT;i++)
+ {
+ _account_free_text(test_text);
+
+ account_get_user_text(handle, i, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+ }
+
+ int test_int = -1;
+
+ account_auth_type_e auth_type;
+ account_get_auth_type(handle, &auth_type);
+ SECURE_LOGD("account_get_auth_type : %d\n", auth_type);
+
+ account_secrecy_state_e secret;
+ account_get_secret(handle, &secret);
+ SECURE_LOGD("account_get_secret : %d\n", secret);
+
+ account_sync_state_e sync_support;
+ account_get_sync_support(handle, &sync_support);
+ SECURE_LOGD("account_get_sync_support : %d\n", sync_support);
+
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ test_int = -1;
+ account_get_user_int(handle, i, &test_int);
+ SECURE_LOGD("_account_get_callback : %d\n", test_int);
+ }
+
+ account_get_capability(handle, _capability_get_callback, NULL);
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+}
+@endcode
+
+
+ <h2 class="pg">Get account list by user name</h2>
+
+@code
+static void _account_free_text(char *text)
+{
+ if (text) {
+ free(text);
+ text = NULL;
+ }
+}
+
+bool _account_get_callback(account_h handle, void* user_data)
+{
+ SECURE_LOGD("_account_get_callback\n");
+
+ char *test_text = NULL;
+
+ account_get_user_name(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_display_name(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_email_address(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_icon_path(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_source(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_package_name(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_domain_name(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_access_token(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ int i;
+
+ for(i=0;i<USER_TXT_CNT;i++)
+ {
+ _account_free_text(test_text);
+
+ account_get_user_text(handle, i, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+ }
+
+ int test_int = -1;
+
+ account_auth_type_e auth_type;
+ account_get_auth_type(handle, &auth_type);
+ SECURE_LOGD("account_get_auth_type : %d\n", auth_type);
+
+ account_secrecy_state_e secret;
+ account_get_secret(handle, &secret);
+ SECURE_LOGD("account_get_secret : %d\n", secret);
+
+ account_sync_state_e sync_support;
+ account_get_sync_support(handle, &sync_support);
+ SECURE_LOGD("account_get_sync_support : %d\n", sync_support);
+
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ test_int = -1;
+ account_get_user_int(handle, i, &test_int);
+ SECURE_LOGD("_account_get_callback : %d\n", test_int);
+ }
+
+ account_get_capability(handle, _capability_get_callback, NULL);
+
+ return TRUE;
+}
+
+
+void get_account_list_by_user_name(char * user_name)
+{
+ int ret = - 1;
+ account_h account;
+
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_query_account_by_user_name(_account_get_callback, user_name, NULL);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+}
+@endcode
+
+ <h2 class="pg">Get account list by package name</h2>
+
+@code
+static void _account_free_text(char *text)
+{
+ if (text) {
+ free(text);
+ text = NULL;
+ }
+}
+
+bool _account_get_callback(account_h handle, void* user_data)
+{
+ SECURE_LOGD("_account_get_callback\n");
+
+ char *test_text = NULL;
+
+ account_get_user_name(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_display_name(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_email_address(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_icon_path(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_source(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_package_name(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_domain_name(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_access_token(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ int i;
+
+ for(i=0;i<USER_TXT_CNT;i++)
+ {
+ _account_free_text(test_text);
+
+ account_get_user_text(handle, i, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+ }
+
+ int test_int = -1;
+
+ account_auth_type_e auth_type;
+ account_get_auth_type(handle, &auth_type);
+ SECURE_LOGD("account_get_auth_type : %d\n", auth_type);
+
+ account_secrecy_state_e secret;
+ account_get_secret(handle, &secret);
+ SECURE_LOGD("account_get_secret : %d\n", secret);
+
+ account_sync_state_e sync_support;
+ account_get_sync_support(handle, &sync_support);
+ SECURE_LOGD("account_get_sync_support : %d\n", sync_support);
+
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ test_int = -1;
+ account_get_user_int(handle, i, &test_int);
+ SECURE_LOGD("_account_get_callback : %d\n", test_int);
+ }
+
+ account_get_capability(handle, _capability_get_callback, NULL);
+
+ return TRUE;
+}
+
+void get_account_list_by_package_name(char * package_name)
+{
+ int ret = - 1;
+ account_h account;
+
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_query_account_by_package_name(_account_get_callback, package_name, NULL);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+}
+@endcode
+
+ <h2 class="pg">Get all account list</h2>
+
+@code
+static void _account_free_text(char *text)
+{
+ if (text) {
+ free(text);
+ text = NULL;
+ }
+}
+
+bool _account_get_callback(account_h handle, void* user_data)
+{
+ SECURE_LOGD("_account_get_callback\n");
+
+ char *test_text = NULL;
+
+ account_get_user_name(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_display_name(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_email_address(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_icon_path(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_source(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_package_name(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_domain_name(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_access_token(handle, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+
+ int i;
+
+ for(i=0;i<USER_TXT_CNT;i++)
+ {
+ _account_free_text(test_text);
+
+ account_get_user_text(handle, i, &test_text);
+ SECURE_LOGD("_account_get_callback : %s\n", test_text);
+ }
+
+ int test_int = -1;
+
+ account_auth_type_e auth_type;
+ account_get_auth_type(handle, &auth_type);
+ SECURE_LOGD("account_get_auth_type : %d\n", auth_type);
+
+ account_secrecy_state_e secret;
+ account_get_secret(handle, &secret);
+ SECURE_LOGD("account_get_secret : %d\n", secret);
+
+ account_sync_state_e sync_support;
+ account_get_sync_support(handle, &sync_support);
+ SECURE_LOGD("account_get_sync_support : %d\n", sync_support);
+
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ test_int = -1;
+ account_get_user_int(handle, i, &test_int);
+ SECURE_LOGD("_account_get_callback : %d\n", test_int);
+ }
+
+ account_get_capability(handle, _capability_get_callback, NULL);
+
+ return TRUE;
+}
+
+void get_all_account()
+{
+ int ret = - 1;
+ account_h account;
+
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_foreach_account_from_db(_account_get_callback, NULL);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+}
+@endcode
+
+ <h2 class="pg">Update information of account by account id</h2>
+
+@code
+void update_accont_by_id(int account_id)
+{
+ int ret = -1;
+ account_h account;
+
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_create(&account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_user_name(account, "update-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "update-Tarun Kumar");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "update-Samsung electronics");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_email_address(account, "update-tarun@gmail.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_package_name(account, "update-com.samsung.twiter");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_icon_path(account, "update-icon-path");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_access_token(account, "update-ACCESSTOKEN");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_auth_type( account, ACCOUNT_AUTH_TYPE_OAUTH );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_secret( account, ACCOUNT_SECRECY_INVISIBLE );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_source(account, "update-URUSA inc.");
+
+ int i;
+
+ for(i=0;i<USER_TXT_CNT;i++)
+ {
+ ret = account_set_user_text(account, i, "update-user txt");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+
+ }
+
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ ret = account_set_user_int(account, i, 999);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+ }
+
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_CONTACT, ACCOUNT_CAPABILITY_DISABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_CALENDAR, ACCOUNT_CAPABILITY_DISABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_PHOTO, ACCOUNT_CAPABILITY_DISABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_VIDEO, ACCOUNT_CAPABILITY_DISABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_EMAIL, ACCOUNT_CAPABILITY_DISABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_STATUS_POST, ACCOUNT_CAPABILITY_DISABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_VOIP, ACCOUNT_CAPABILITY_DISABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_SAMSUNG_APPS, ACCOUNT_CAPABILITY_DISABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_MOBILE_TRACKER, ACCOUNT_CAPABILITY_DISABLED);
+
+ ret = account_update_to_db_by_id(account, account_id);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ return;
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+}
+@endcode
+
+ <h2 class="pg">Update information of account by user name</h2>
+
+@code
+void update_accont_by_user_name(char *user_name, char *package_name)
+{
+ int ret = -1;
+ account_h account;
+
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_create(&account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_user_name(account, "update-tarun.kr");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "update-Tarun Kumar");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "update-Samsung electronics");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_email_address(account, "update-tarun@gmail.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_package_name(account, "update-com.samsung.twiter");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_icon_path(account, "update-icon-path");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_access_token(account, "update-ACCESSTOKEN");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_auth_type( account, ACCOUNT_AUTH_TYPE_OAUTH );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_secret( account, ACCOUNT_SECRECY_INVISIBLE );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_source(account, "update-URUSA inc.");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ int i;
+
+ for(i=0;i<USER_TXT_CNT;i++)
+ {
+ ret = account_set_user_text(account, i, "update-user txt");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+
+ }
+
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ ret = account_set_user_int(account, i, 999);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+ }
+
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_CONTACT, ACCOUNT_CAPABILITY_DISABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_CALENDAR, ACCOUNT_CAPABILITY_DISABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_PHOTO, ACCOUNT_CAPABILITY_DISABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_VIDEO, ACCOUNT_CAPABILITY_DISABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_EMAIL, ACCOUNT_CAPABILITY_DISABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_STATUS_POST, ACCOUNT_CAPABILITY_DISABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_VOIP, ACCOUNT_CAPABILITY_DISABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_SAMSUNG_APPS, ACCOUNT_CAPABILITY_DISABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_MOBILE_TRACKER, ACCOUNT_CAPABILITY_DISABLED);
+
+ ret = account_update_to_db_by_user_name(account, user_name, package_name);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ return;
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+}
+@endcode
+
+ <h2 class="pg">Delete account by id </h2>
+
+@code
+void delete_account_by_id(int account_id)
+{
+ int ret = -1;
+
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_delete(account_id);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return;
+}
+@endcode
+
+ <h2 class="pg">Update sync status by id </h2>
+
+@code
+void update_sync_status_by_id(int account_id, const account_sync_state_e sync_status)
+{
+ int ret = -1;
+
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_update_sync_status_by_id(account_id, sync_status);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return;
+}
+@endcode
+
+ <h2 class="pg">Delete account by user name </h2>
+
+@code
+void delete_account_by_user_name(char *user_name, char *package_name)
+{
+ int ret = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_delete_from_db_by_user_name(user_name, package_name);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d \n", __LINE__, ret);
+ }
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return;
+}
+@endcode
+
+ <h2 class="pg">Delete account by package name </h2>
+
+@code
+void delete_account_by_package_name(char *package_name)
+{
+ int ret = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_delete_from_db_by_package_name(package_name);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d \n", __LINE__, ret);
+ }
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return;
+}
+@endcode
+
+ <h2 class="pg">Get account insert dbus notification </h2>
+
+@code
+void notify_account_insert()
+{
+ DBusMessage* msg;
+ DBusConnection* conn;
+ DBusError err;
+
+ SECURE_LOGD("Listening for signals\n");
+
+ dbus_error_init(&err);
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
+ if (dbus_error_is_set(&err)) {
+ dbus_error_free(&err);
+ }
+ if (NULL == conn) {
+ exit(1);
+ }
+
+ dbus_bus_add_match(conn, "type='signal',interface='account.signal.Type'", &err);
+ dbus_connection_flush(conn);
+ if (dbus_error_is_set(&err)) {
+ exit(1);
+ }
+ SECURE_LOGD("Match rule sent\n");
+
+ while (true) {
+
+ dbus_connection_read_write(conn, 0);
+ msg = dbus_connection_pop_message(conn);
+
+ if (NULL == msg) {
+ sleep(1);
+ continue;
+ }
+
+ if (dbus_message_is_signal(msg, ACCOUNT_DBUS_SIGNAL_INTERFACE, ACCOUNT_DBUS_NOTI_NAME_INSERT)) {
+ SECURE_LOGD("Got Signal with name insert\n");
+ }
+
+ dbus_message_unref(msg);
+ }
+ dbus_connection_close(conn);
+}
+@endcode
+
+ <h2 class="pg">Get account update dbus notification </h2>
+
+@code
+void notify_account_update()
+{
+ DBusMessage* msg;
+ DBusConnection* conn;
+ DBusError err;
+
+ SECURE_LOGD("Listening for signals\n");
+
+
+ dbus_error_init(&err);
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
+ if (dbus_error_is_set(&err)) {
+ dbus_error_free(&err);
+ }
+ if (NULL == conn) {
+ exit(1);
+ }
+
+ dbus_bus_add_match(conn, "type='signal',interface='account.signal.Type'", &err);
+ dbus_connection_flush(conn);
+ if (dbus_error_is_set(&err)) {
+ exit(1);
+ }
+ SECURE_LOGD("Match rule sent\n");
+
+ while (true) {
+
+ dbus_connection_read_write(conn, 0);
+ msg = dbus_connection_pop_message(conn);
+
+ if (NULL == msg) {
+ sleep(1);
+ continue;
+ }
+
+ if (dbus_message_is_signal(msg, ACCOUNT_DBUS_SIGNAL_INTERFACE, ACCOUNT_DBUS_NOTI_NAME_UPDATE)) {
+ SECURE_LOGD("Got Signal with name update\n");
+ }
+
+ dbus_message_unref(msg);
+ }
+ dbus_connection_close(conn);
+}
+@endcode
+
+ <h2 class="pg">Get account delete dbus notification </h2>
+
+@code
+void notify_account_delete()
+{
+ DBusMessage* msg;
+ DBusConnection* conn;
+ DBusError err;
+
+ SECURE_LOGD("Listening for signals\n");
+
+
+ dbus_error_init(&err);
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
+ if (dbus_error_is_set(&err)) {
+ dbus_error_free(&err);
+ }
+ if (NULL == conn) {
+ exit(1);
+ }
+
+ dbus_bus_add_match(conn, "type='signal',interface='account.signal.Type'", &err);
+ dbus_connection_flush(conn);
+ if (dbus_error_is_set(&err)) {
+ exit(1);
+ }
+ SECURE_LOGD("Match rule sent\n");
+
+ while (true) {
+
+ dbus_connection_read_write(conn, 0);
+ msg = dbus_connection_pop_message(conn);
+
+ if (NULL == msg) {
+ sleep(1);
+ continue;
+ }
+
+ if (dbus_message_is_signal(msg, ACCOUNT_DBUS_SIGNAL_INTERFACE, ACCOUNT_DBUS_NOTI_NAME_DELETE)) {
+ SECURE_LOGD("Got Signal with name delete\n");
+ }
+
+ dbus_message_unref(msg);
+ }
+ dbus_connection_close(conn);
+}
+@endcode
+
+ <h2 class="pg">Get capability by acccount id</h2>
+
+@code
+bool _capability_get_callback(const char* capability_type, account_capability_state_e capability_value, void* user_data)
+{
+ char* test_type = capability_type;
+ int test_value = capability_value;
+
+ SECURE_LOGD("_capability_get_callback test_type = : %s\n", test_type);
+ SECURE_LOGD("_capability_get_callback test_value = : %d\n", test_value);
+ return TRUE;
+}
+
+void capability_by_account_id(int account_id)
+{
+ int ret = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_query_capability_by_account_id(_capability_get_callback, account_id, NULL);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d \n", __LINE__, ret);
+ }
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ SECURE_LOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return;
+}
+@endcode
+ * @}
+ */
+
diff --git a/include/account_internal.h b/include/account_internal.h
new file mode 100644
index 0000000..7b77e47
--- /dev/null
+++ b/include/account_internal.h
@@ -0,0 +1,81 @@
+/*
+ * account
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __ACCOUNT_INTERNAL_H__
+#define __ACCOUNT_INTERNAL_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#ifndef ACCOUNT_INTERNAL_API
+#define ACCOUNT_INTERNAL_API __attribute__ ((visibility("default")))
+#endif
+
+/**
+ * @file account_internal.h
+ * @brief This file contains the Account API for account management.
+ */
+
+/**
+ * @internal
+ * @brief Start to subscribe account event through the given callback function
+ *
+ * @param[in] account_subscribe The account subscription handle
+ * @param[in] cb_func When an account is removed from account database. It will be called with event message and account id.
+ * @param[in] user_data user_data will be delivered to cb_func
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_EVENT_SUBSCRIPTION_FAIL Subscription fail
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_unsubscribe_notification()
+ * @see account_subscribe_notification()
+ */
+ACCOUNT_API int account_subscribe_notification_ex(account_subscribe_h account_subscribe, account_event_cb cb_func, void* user_data);
+
+/**
+ * @internal
+ * @brief Start to subscribe account event through the given callback function
+ *
+ * @param[in] account_subscribe The account subscription handle
+ * @param[in] cb_func When an account is removed from account database. It will be called with event message and account id.
+ * @param[in] user_data user_data will be delivered to cb_func
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ACCOUNT_ERROR_NONE Successful
+ * @retval #ACCOUNT_ERROR_EVENT_SUBSCRIPTION_FAIL Subscription fail
+ * @retval #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_unsubscribe_notification()
+ * @see account_subscribe_notification()
+ */
+ACCOUNT_API int account_unsubscribe_notification_ex(account_subscribe_h account_subscribe);
+
+/**
+* @}
+*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ACCOUNT_INTERNAL_H__ */
diff --git a/libaccounts-svc.manifest b/libaccounts-svc.manifest
new file mode 100755
index 0000000..d3b333c
--- /dev/null
+++ b/libaccounts-svc.manifest
@@ -0,0 +1,19 @@
+<manifest>
+ <define>
+ <domain name="libaccounts-svc"/>
+ <provide>
+ <label name="libaccounts-svc::db"/>
+ <label name="libaccounts-svc::check_read"/>
+ </provide>
+ <request>
+ <smack request="libaccounts-svc::db" type="rw" />
+ </request>
+ </define>
+ <request>
+ <domain name="libaccounts-svc"/>
+ </request>
+ <assign>
+ <filesystem path="/usr/lib/libaccounts-svc.so.0" label="_" />
+ <filesystem path="/usr/lib/libaccounts-svc.so.0.2.97" label="_" />
+ </assign>
+</manifest>
diff --git a/packaging/libaccounts-svc.spec b/packaging/libaccounts-svc.spec
new file mode 100755
index 0000000..2deac97
--- /dev/null
+++ b/packaging/libaccounts-svc.spec
@@ -0,0 +1,115 @@
+
+Name: libaccounts-svc
+Summary: Account DB library
+Version: 0.2.113
+Release: 1
+Group: TO_BE/FILLED_IN
+License: Apache-2.0
+Source0: libaccounts-svc-%{version}.tar.gz
+
+BuildRequires: cmake
+BuildRequires: pkgconfig(sqlite3)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(db-util)
+BuildRequires: pkgconfig(capi-base-common)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(pkgmgr-info)
+BuildRequires: pkgconfig(aul)
+BuildRequires: pkgconfig(libsmack)
+
+Requires(post): /sbin/ldconfig
+Requires(post): /usr/bin/sqlite3
+Requires(postun): /sbin/ldconfig
+
+%description
+Account DB libraryXB-Public-Package: no
+
+%package devel
+Summary: Development files for %{name}
+Group: Development/Libraries
+Requires: %{name} = %{version}-%{release}
+%description devel
+Development files for %{name}
+
+%prep
+%setup -q
+
+%build
+export CFLAGS+=" -Wextra -Wcast-align -Wcast-qual -Wshadow -Wwrite-strings -Wswitch-default"
+export CXXFLAGS+=" -Wextra -Wcast-align -Wcast-qual -Wshadow -Wwrite-strings -Wswitch-default -Wnon-virtual-dtor -Wno-c++0x-compat"
+#export CFLAGS+=" -Wno-array-bounds -Wno-ignored-qualifiers"
+export CFLAGS+=" -Wno-unused-parameter -Wno-empty-body"
+export CXXFLAGS+=" -Wno-unused-parameter -Wno-empty-body"
+
+export CFLAGS+=" -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-strict-aliasing -fno-unroll-loops -fsigned-char -fstrict-overflow -fno-common"
+export CXXFLAGS+=" -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-strict-aliasing -fno-unroll-loops -fsigned-char -fstrict-overflow"
+
+export CFLAGS="${CFLAGS} -fPIC -fvisibility=hidden"
+cmake . -DCMAKE_INSTALL_PREFIX=/usr
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+rm -rf %{buildroot}/usr/lib/accounts-svc
+
+%post
+/sbin/ldconfig
+if [ ! -d /opt/usr/dbspace ]
+then
+ mkdir -p /opt/usr/dbspace
+fi
+if [ ! -f /opt/usr/dbspace/.account.db ]
+#rm -rf /opt/usr/dbspace/.account.db*
+then
+ sqlite3 /opt/usr/dbspace/.account.db 'PRAGMA journal_mode = PERSIST;
+ CREATE TABLE if not exists label (AppId TEXT, Label TEXT, Locale TEXT);
+ CREATE TABLE if not exists account_type (_id INTEGER PRIMARY KEY AUTOINCREMENT, AppId TEXT,
+ ServiceProviderId TEXT, IconPath TEXT, SmallIconPath TEXT, MultipleAccountSupport INT);
+ CREATE TABLE if not exists account_custom (AccountId INTEGER, AppId TEXT, Key TEXT, Value TEXT);
+ CREATE TABLE if not exists account (_id INTEGER PRIMARY KEY AUTOINCREMENT, user_name TEXT, email_address TEXT, display_name TEXT, icon_path TEXT,
+ source TEXT, package_name TEXT, access_token TEXT, domain_name TEXT, auth_type INTEGER, secret INTEGER, sync_support INTEGER,
+ txt_custom0 TEXT, txt_custom1 TEXT, txt_custom2 TEXT, txt_custom3 TEXT, txt_custom4 TEXT,
+ int_custom0 INTEGER, int_custom1 INTEGER, int_custom2 INTEGER, int_custom3 INTEGER, int_custom4 INTEGER);
+ CREATE TABLE if not exists capability (_id INTEGER PRIMARY KEY AUTOINCREMENT, key TEXT, value INTEGER,
+ package_name TEXT, user_name TEXT, account_id INTEGER, FOREIGN KEY (account_id) REFERENCES account(_id));
+ CREATE TABLE if not exists provider_feature (app_id TEXT, key TEXT);
+'
+fi
+
+mkdir -p /opt/usr/share/account
+chown 0:5000 /opt/usr/dbspace/.account.db
+chown 0:5000 /opt/usr/dbspace/.account.db-journal
+
+chmod 664 /opt/usr/dbspace/.account.db
+chmod 664 /opt/usr/dbspace/.account.db-journal
+
+#set message key value to NULL
+#vconftool set -t string db/account/msg '' -g 6514
+vconftool set -t string db/account/msg '' -s libaccounts-svc -g 6514
+
+#smack labeling
+if [ -f /usr/lib/rpm-plugins/msm.so ]
+then
+ chsmack -a 'libaccounts-svc::db' /opt/usr/dbspace/.account.db-journal
+ chsmack -a 'libaccounts-svc::db' /opt/usr/dbspace/.account.db
+fi
+
+
+%postun -p /sbin/ldconfig
+
+
+
+%files
+%manifest libaccounts-svc.manifest
+%defattr(-,root,root,-)
+%{_libdir}/*.so.*
+
+%files devel
+%defattr(-,root,root,-)
+%{_libdir}/*.so
+%{_libdir}/pkgconfig/accounts-svc.pc
+%{_includedir}/*.h
diff --git a/src/account.c b/src/account.c
new file mode 100755
index 0000000..3aa01c5
--- /dev/null
+++ b/src/account.c
@@ -0,0 +1,7345 @@
+/*
+ * account
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Wonyoung Lee <wy1115.lee@samsung.com>, Sungchan Kim <sungchan81.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <account.h>
+#include <glib.h>
+#include <db-util.h>
+#include <pthread.h>
+#include <account-private.h>
+#include <vconf.h>
+#include "account_internal.h"
+
+#define SAMSUNG_ACCOUNT_MANAGER
+
+#include <pkgmgr-info.h>
+#include <aul.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/smack.h>
+
+#define EAS_CMDLINE "/usr/bin/eas-engine"
+#define EMAIL_SERVICE_CMDLINE "/usr/bin/email-service"
+#define IMS_ENGINE_CMDLINE "/usr/bin/ims-srv"
+#define IMS_AGENT_CMDLINE "/usr/bin/ims-agent"
+#define MDM_SERVER_CMDLINE "/usr/bin/mdm-server"
+
+#define RCS_APPID "com.samsung.rcs-im"
+#define IMS_SERVICE_APPID "ims-service"
+#define ACTIVESYNC_APPID "activesync-ui"
+#define EMAIL_APPID "email-setting-efl"
+#define SYNCHRONISE_APPID "setting-synchronise-efl"
+#define DS_AGENT_CMDLINE "/usr/bin/oma-ds-agent"
+
+#define FACEBOOK_SDK_APPID "com.samsung.facebook-service"
+#define FACEBOOK_APPID "com.samsung.facebook"
+
+#define ACCOUNT_DB_OPEN_READONLY 0
+#define ACCOUNT_DB_OPEN_READWRITE 1
+
+static sqlite3* g_hAccountDB = NULL;
+static int g_refCntDB = 0;
+pthread_mutex_t account_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+static char *_account_get_text(const char *text_data);
+static int _account_gslist_free(GSList* list);
+static int _account_glist_free(GList* list);
+static const char *_account_query_table_column_text(account_stmt pStmt, int pos);
+static int _account_insert_custom(account_s *account, int account_id);
+static int _account_update_custom(account_s *account, int account_id);
+static int _account_query_custom_by_account_id(account_custom_cb callback, int account_id, void *user_data );
+static int _account_type_update_provider_feature(account_type_s *account_type, const char* app_id);
+
+int _account_get_current_appid_cb(const pkgmgrinfo_appinfo_h handle, void *user_data)
+{
+ char* appid = NULL;
+ char* item = NULL;
+ GSList** appid_list = (GSList**)user_data;
+ int pkgmgr_ret = -1;
+
+ pkgmgr_ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
+
+ if( pkgmgr_ret != PMINFO_R_OK ){
+ ACCOUNT_DEBUG("pkgmgrinfo_appinfo_get_appid(%d)", pkgmgr_ret);
+ }
+
+ item = _account_get_text(appid);
+ *appid_list = g_slist_append(*appid_list, item);
+
+ return 0;
+}
+
+static inline int __read_proc(const char *path, char *buf, int size)
+{
+ int fd = 0, ret = 0;
+
+ if (buf == NULL || path == NULL) {
+ ACCOUNT_ERROR("path and buffer is mandatory\n");
+ return -1;
+ }
+
+ fd = open(path, O_RDONLY);
+ if (fd < 0) {
+ ACCOUNT_ERROR("fd open error(%d)\n", fd);
+ return -1;
+ }
+
+ ret = read(fd, buf, size - 1);
+ if (ret <= 0) {
+ ACCOUNT_ERROR("fd read error(%d)\n", fd);
+ close(fd);
+ return -1;
+ } else
+ buf[ret] = 0;
+
+ close(fd);
+
+ return ret;
+}
+
+char *_account_get_proc_cmdline_bypid(int pid)
+{
+ char buf[128];
+ int ret = 0;
+
+ ACCOUNT_SNPRINTF(buf, sizeof(buf), "/proc/%d/cmdline", pid);
+ ret = __read_proc(buf, buf, sizeof(buf));
+ if (ret <= 0) {
+ ACCOUNT_DEBUG("No proc directory (%d)\n", pid);
+ return NULL;
+ }
+
+ return strdup(buf);
+}
+
+
+static char* _account_get_current_appid()
+{
+ int ret=0, pid=0;
+ char appid[128]={0,};
+ char* appid_ret = NULL;
+
+ pid = getpid();
+ ret = aul_app_get_appid_bypid(pid, appid, sizeof(appid));
+
+ if(ret < 0){
+ ACCOUNT_ERROR("fail to get current appid\n");
+ }
+
+ /* SLP platform core exception */
+ if(strlen(appid) == 0){
+ char* cmdline = NULL;
+ cmdline = _account_get_proc_cmdline_bypid(pid);
+ ACCOUNT_SLOGD("cmdline (%s)!!!!!!\n", cmdline);
+ if(!g_strcmp0(cmdline, EAS_CMDLINE)) {
+ appid_ret = _account_get_text(ACTIVESYNC_APPID);
+ _ACCOUNT_FREE(cmdline);
+ return appid_ret;
+ } else if (!g_strcmp0(cmdline, EMAIL_SERVICE_CMDLINE) || !g_strcmp0(cmdline, MDM_SERVER_CMDLINE)) {
+ appid_ret = _account_get_text(EMAIL_APPID);
+ _ACCOUNT_FREE(cmdline);
+ return appid_ret;
+ } else if (!g_strcmp0(cmdline, IMS_ENGINE_CMDLINE) || !g_strcmp0(cmdline, IMS_AGENT_CMDLINE)) {
+ if(account_type_query_app_id_exist(RCS_APPID)==ACCOUNT_ERROR_NONE){
+ appid_ret = _account_get_text(RCS_APPID);
+ } else if(account_type_query_app_id_exist(IMS_SERVICE_APPID)==ACCOUNT_ERROR_NONE){
+ appid_ret = _account_get_text(IMS_SERVICE_APPID);
+ } else {
+ appid_ret = _account_get_text(RCS_APPID);
+ }
+ _ACCOUNT_FREE(cmdline);
+ return appid_ret;
+ } else if (!g_strcmp0(cmdline, DS_AGENT_CMDLINE)) {
+ appid_ret = _account_get_text(SYNCHRONISE_APPID);
+ _ACCOUNT_FREE(cmdline);
+ return appid_ret;
+ } else {
+ ACCOUNT_DEBUG("No app id\n");
+ _ACCOUNT_FREE(cmdline);
+ return NULL;
+ }
+ }
+
+ /* temporary exception */
+ if(!g_strcmp0(appid, "com.samsung.gallery")){
+ appid_ret = _account_get_text("com.samsung.facebook");
+ } else if(!g_strcmp0(appid, FACEBOOK_SDK_APPID)){
+ appid_ret = _account_get_text(FACEBOOK_APPID);
+ } else {
+ appid_ret = _account_get_text(appid);
+ }
+
+ return appid_ret;
+}
+
+static int _account_check_account_type_with_appid_group(const char* appid, char** verified_appid)
+{
+ int error_code = ACCOUNT_ERROR_NOT_REGISTERED_PROVIDER;
+ pkgmgrinfo_appinfo_h ahandle=NULL;
+ pkgmgrinfo_pkginfo_h phandle=NULL;
+ char* package_id = NULL;
+ GSList* appid_list = NULL;
+ GSList* iter = NULL;
+
+ if(!appid){
+ ACCOUNT_ERROR("input param is null\n");
+ return ACCOUNT_ERROR_NOT_REGISTERED_PROVIDER;
+ }
+
+ if(!verified_appid){
+ ACCOUNT_ERROR("output param is null\n");
+ return ACCOUNT_ERROR_NOT_REGISTERED_PROVIDER;
+ }
+
+ if(!strcmp(appid, "com.samsung.setting")){
+ ACCOUNT_DEBUG("Setting exception\n");
+ *verified_appid = _account_get_text("com.samsung.setting");
+ return ACCOUNT_ERROR_NONE;
+ }
+
+ if(!strcmp(appid, "com.samsung.samsung-account-front")){
+ ACCOUNT_DEBUG("Setting exception\n");
+ *verified_appid = _account_get_text("com.samsung.samsung-account-front");
+ return ACCOUNT_ERROR_NONE;
+ }
+
+ if(!strcmp(appid, IMS_SERVICE_APPID) || !strcmp(appid, RCS_APPID)){
+ ACCOUNT_DEBUG("ims service exception\n");
+ *verified_appid = _account_get_text(appid);
+ return ACCOUNT_ERROR_NONE;
+ }
+
+ /* Get app id family which is stored in account database */
+ int pkgmgr_ret = -1;
+ pkgmgr_ret = pkgmgrinfo_appinfo_get_appinfo(appid, &ahandle);
+ if( pkgmgr_ret != PMINFO_R_OK ){
+ ACCOUNT_DEBUG("pkgmgrinfo_appinfo_get_appinfo(%d)", pkgmgr_ret);
+ }
+ pkgmgr_ret = pkgmgrinfo_appinfo_get_pkgid(ahandle, &package_id);
+ if( pkgmgr_ret != PMINFO_R_OK ){
+ ACCOUNT_DEBUG("pkgmgrinfo_appinfo_get_pkgid(%d)", pkgmgr_ret);
+ }
+ pkgmgr_ret = pkgmgrinfo_pkginfo_get_pkginfo(package_id, &phandle);
+ if( pkgmgr_ret != PMINFO_R_OK ){
+ ACCOUNT_DEBUG("pkgmgrinfo_pkginfo_get_pkginfo(%d)", pkgmgr_ret);
+ }
+ pkgmgr_ret = pkgmgrinfo_appinfo_get_list(phandle, PMINFO_ALL_APP, _account_get_current_appid_cb, (void *)&appid_list);
+ if( pkgmgr_ret != PMINFO_R_OK ){
+ ACCOUNT_DEBUG("pkgmgrinfo_appinfo_get_list(%d)", pkgmgr_ret);
+ }
+
+ /* Compare current app id with the stored app id family */
+ for(iter=appid_list;iter!=NULL;iter=g_slist_next(iter)){
+ char* tmp = (char*)iter->data;
+ if(tmp) {
+ if(account_type_query_app_id_exist(tmp) == ACCOUNT_ERROR_NONE) {
+ *verified_appid = _account_get_text(tmp);
+ error_code = ACCOUNT_ERROR_NONE;
+ _ACCOUNT_FREE(tmp);
+ if( *verified_appid == NULL ) {
+ ACCOUNT_ERROR("Memory Allocation Failed");
+ error_code = ACCOUNT_ERROR_OUT_OF_MEMORY;
+ }
+ break;
+ } else {
+ ACCOUNT_SLOGD("not matched owner group app id(%s), current appid(%s)\n", tmp, appid);
+ }
+ }
+ _ACCOUNT_FREE(tmp);
+ }
+
+ g_slist_free(appid_list);
+ pkgmgr_ret = pkgmgrinfo_pkginfo_destroy_pkginfo(phandle);
+ if( pkgmgr_ret != PMINFO_R_OK ){
+ ACCOUNT_DEBUG("pkgmgrinfo_pkginfo_destroy_pkginfo(%d)", pkgmgr_ret);
+ }
+
+ pkgmgr_ret = pkgmgrinfo_appinfo_destroy_appinfo(ahandle);
+ if( pkgmgr_ret != PMINFO_R_OK ){
+ ACCOUNT_DEBUG("pkgmgrinfo_appinfo_destroy_appinfo(%d)", pkgmgr_ret);
+ }
+
+ return error_code;
+}
+
+static int _account_check_appid_group_with_package_name(const char* appid, char* package_name)
+{
+ int error_code = ACCOUNT_ERROR_PERMISSION_DENIED;
+ pkgmgrinfo_appinfo_h ahandle=NULL;
+ pkgmgrinfo_pkginfo_h phandle=NULL;
+ char* package_id = NULL;
+ GSList* appid_list = NULL;
+ GSList* iter = NULL;
+
+ if(!appid){
+ ACCOUNT_ERROR("input param -appid is null\n");
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if(!package_name){
+ ACCOUNT_ERROR("input param - package name is null\n");
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ /* ims-service Exception */
+ if ( strcmp(appid, "ims-service") == 0 && strcmp(package_name, "ims-service") == 0 ) {
+ ACCOUNT_DEBUG("ims exception."); // TODO: NEED TO REMOVE, debug log.
+ return ACCOUNT_ERROR_NONE;
+ }
+
+ /* Get app id family which is stored in account database */
+ int pkgmgr_ret = -1;
+ pkgmgr_ret = pkgmgrinfo_appinfo_get_appinfo(appid, &ahandle);
+ if( pkgmgr_ret != PMINFO_R_OK ){
+ ACCOUNT_DEBUG("pkgmgrinfo_appinfo_get_appinfo(%d)", pkgmgr_ret);
+ }
+ pkgmgr_ret = pkgmgrinfo_appinfo_get_pkgid(ahandle, &package_id);
+ if( pkgmgr_ret != PMINFO_R_OK ){
+ ACCOUNT_DEBUG("pkgmgrinfo_appinfo_get_pkgid(%d)", pkgmgr_ret);
+ }
+ pkgmgr_ret = pkgmgrinfo_pkginfo_get_pkginfo(package_id, &phandle);
+ if( pkgmgr_ret != PMINFO_R_OK ){
+ ACCOUNT_DEBUG("pkgmgrinfo_pkginfo_get_pkginfo(%d)", pkgmgr_ret);
+ }
+ pkgmgr_ret = pkgmgrinfo_appinfo_get_list(phandle, PMINFO_ALL_APP, _account_get_current_appid_cb, (void *)&appid_list);
+ if( pkgmgr_ret != PMINFO_R_OK ){
+ ACCOUNT_DEBUG("pkgmgrinfo_appinfo_get_list(%d)", pkgmgr_ret);
+ }
+
+ /* Compare current app id with the stored app id family */
+ for(iter=appid_list;iter!=NULL;iter=g_slist_next(iter)){
+ char* tmp = (char*)iter->data;
+ if(tmp) {
+ //ACCOUNT_ERROR("tmp(%s)package_name(%s)\n\n", tmp, package_name); // TODO: NEED TO REMOVE, debug log.
+ if( strcmp(tmp, package_name) == 0) {
+ error_code = ACCOUNT_ERROR_NONE;
+ _ACCOUNT_FREE(tmp);
+ break;
+ } else if ( strcmp(tmp, SAMSUNGACCOUNTFRONT_PKG_NAME) == 0 &&
+ strcmp(package_name, SAMSUNGACCOUNT_PKG_NAME) == 0 ) {
+ /* Samung Account Exception */
+ error_code = ACCOUNT_ERROR_NONE;
+ _ACCOUNT_FREE(tmp);
+ break;
+ } else {
+ ACCOUNT_SLOGD("not matched owner group app id(%s), current appid(%s)\n", tmp, appid);
+ }
+ }
+ _ACCOUNT_FREE(tmp);
+ }
+
+ g_slist_free(appid_list);
+ pkgmgr_ret = pkgmgrinfo_pkginfo_destroy_pkginfo(phandle);
+ if( pkgmgr_ret != PMINFO_R_OK ){
+ ACCOUNT_DEBUG("pkgmgrinfo_pkginfo_destroy_pkginfo(%d)", pkgmgr_ret);
+ }
+
+ pkgmgr_ret = pkgmgrinfo_appinfo_destroy_appinfo(ahandle);
+ if( pkgmgr_ret != PMINFO_R_OK ){
+ ACCOUNT_DEBUG("pkgmgrinfo_appinfo_destroy_appinfo(%d)", pkgmgr_ret);
+ }
+
+ return error_code;
+}
+
+static const char *_account_db_err_msg()
+{
+ return sqlite3_errmsg(g_hAccountDB);
+}
+
+static int _account_db_err_code()
+{
+ return sqlite3_errcode(g_hAccountDB);
+}
+
+static void _account_insert_delete_update_notification_send(char *noti_name)
+{
+ if (!noti_name) {
+ ACCOUNT_ERROR("Noti Name is NULL!!!!!!\n");
+ return;
+ }
+
+ ACCOUNT_DEBUG("noti_type = %s", noti_name);
+
+ if (vconf_set_str(VCONFKEY_ACCOUNT_MSG_STR, noti_name) != 0) {
+ ACCOUNT_ERROR("Vconf MSG Str set FAILED !!!!!!\n");;
+ }
+}
+
+static int _account_get_record_count(char* query)
+{
+ int rc = -1;
+ int ncount = 0;
+ account_stmt pStmt = NULL;
+
+ if(!query){
+ ACCOUNT_ERROR("NULL query\n");
+ return ACCOUNT_ERROR_QUERY_SYNTAX_ERROR;
+ }
+
+ if(!g_hAccountDB){
+ ACCOUNT_ERROR("DB is not opened\n");
+ return ACCOUNT_ERROR_DB_NOT_OPENED;
+ }
+
+ rc = sqlite3_prepare_v2(g_hAccountDB, query, strlen(query), &pStmt, NULL);
+
+ if (SQLITE_BUSY == rc){
+ ACCOUNT_ERROR("sqlite3_prepare_v2() failed(%d, %s).", rc, _account_db_err_msg());
+ sqlite3_finalize(pStmt);
+ return ACCOUNT_ERROR_DATABASE_BUSY;
+ } else if (SQLITE_OK != rc) {
+ ACCOUNT_ERROR("sqlite3_prepare_v2() failed(%d, %s).", rc, _account_db_err_msg());
+ sqlite3_finalize(pStmt);
+ return ACCOUNT_ERROR_DB_FAILED;
+ }
+
+ rc = sqlite3_step(pStmt);
+ if (SQLITE_BUSY == rc) {
+ ACCOUNT_ERROR("sqlite3_step() failed(%d, %s).", rc, _account_db_err_msg());
+ sqlite3_finalize(pStmt);
+ return ACCOUNT_ERROR_DATABASE_BUSY;
+ } else if (SQLITE_ROW != rc) {
+ ACCOUNT_ERROR("sqlite3_step() failed(%d, %s).", rc, _account_db_err_msg());
+ sqlite3_finalize(pStmt);
+ return ACCOUNT_ERROR_DB_FAILED;
+ }
+
+ ncount = sqlite3_column_int(pStmt, 0);
+
+ sqlite3_finalize(pStmt);
+
+ return ncount;
+}
+
+static int _account_execute_query(const char *query)
+{
+ int rc = -1;
+ char* pszErrorMsg = NULL;
+
+ if(!query){
+ ACCOUNT_ERROR("NULL query\n");
+ return ACCOUNT_ERROR_QUERY_SYNTAX_ERROR;
+ }
+
+ if(!g_hAccountDB){
+ ACCOUNT_ERROR("DB is not opened\n");
+ return ACCOUNT_ERROR_DB_NOT_OPENED;
+ }
+
+ rc = sqlite3_exec(g_hAccountDB, query, NULL, NULL, &pszErrorMsg);
+ if (SQLITE_OK != rc) {
+ ACCOUNT_ERROR("sqlite3_exec rc(%d) query(%s) failed(%s).", rc, query, pszErrorMsg);
+ sqlite3_free(pszErrorMsg);
+ }
+
+ return rc;
+}
+
+static int _account_begin_transaction(void)
+{
+ int ret = -1;
+
+ ret = _account_execute_query("BEGIN IMMEDIATE TRANSACTION");
+
+ if (ret == SQLITE_BUSY){
+ ACCOUNT_ERROR(" sqlite3 busy = %d", ret);
+ return ACCOUNT_ERROR_DATABASE_BUSY;
+ } else if(ret != SQLITE_OK) {
+ ACCOUNT_ERROR("_account_svc_begin_transaction fail :: %d", ret);
+ return ACCOUNT_ERROR_DB_FAILED;
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_end_transaction(bool is_success)
+{
+ int ret = -1;
+
+ if (is_success == true) {
+ ret = _account_execute_query("COMMIT TRANSACTION");
+ } else {
+ ret = _account_execute_query("ROLLBACK TRANSACTION");
+ }
+
+ if(ret == SQLITE_PERM){
+ ACCOUNT_ERROR("Account permission denied :: %d", ret);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ if (ret == SQLITE_BUSY){
+ ACCOUNT_DEBUG(" sqlite3 busy = %d", ret);
+ return ACCOUNT_ERROR_DATABASE_BUSY;
+ }
+
+ if (ret != SQLITE_OK) {
+ ACCOUNT_ERROR("_account_svc_end_transaction fail :: %d", ret);
+ return ACCOUNT_ERROR_DB_FAILED;
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static bool _account_check_add_more_account(const char* app_id)
+{
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0;
+
+ ACCOUNT_RETURN_VAL((app_id != 0), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("APP ID IS NULL"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT COUNT(*) FROM %s WHERE AppId = '%s' and MultipleAccountSupport = 1", ACCOUNT_TYPE_TABLE, app_id);
+ rc = _account_get_record_count(query);
+
+ /* multiple account support case */
+ if(rc > 0) {
+ ACCOUNT_SLOGD("app id (%s) supports multiple account. rc(%d)\n", app_id, rc);
+ return TRUE;
+ }
+
+ /* multiple account not support case */
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT COUNT(*) FROM %s WHERE package_name = '%s'", ACCOUNT_TABLE, app_id);
+ rc = _account_get_record_count(query);
+
+ if(rc <= 0) {
+ ACCOUNT_SLOGD("app id (%s) supports single account. and there is no account of the app id\n", app_id);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static int _account_create_all_tables(void)
+{
+ int rc = -1;
+ int error_code = ACCOUNT_ERROR_NONE;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+
+ ACCOUNT_DEBUG("create all table - BEGIN");
+ ACCOUNT_MEMSET(query, 0, sizeof(query));
+
+ /*Create the account table*/
+ ACCOUNT_SNPRINTF(query, sizeof(query), "select count(*) from sqlite_master where name in ('%s')", ACCOUNT_TABLE);
+ rc = _account_get_record_count(query);
+ if (rc <= 0) {
+ rc = _account_execute_query(ACCOUNT_SCHEMA);
+ if(rc == SQLITE_BUSY) return ACCOUNT_ERROR_DATABASE_BUSY;
+ ACCOUNT_RETURN_VAL((SQLITE_OK == rc), {}, ACCOUNT_ERROR_DB_FAILED, ("_account_execute_query(%s) failed(%d, %s).\n", ACCOUNT_SCHEMA, rc, _account_db_err_msg()));
+ }
+
+ /*Create capability table*/
+ ACCOUNT_MEMSET(query, 0, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "select count(*) from sqlite_master where name in ('%s')", CAPABILITY_TABLE);
+ rc = _account_get_record_count(query);
+ if (rc <= 0) {
+ rc = _account_execute_query(CAPABILITY_SCHEMA);
+ if(rc == SQLITE_BUSY) return ACCOUNT_ERROR_DATABASE_BUSY;
+ ACCOUNT_RETURN_VAL((SQLITE_OK == rc), {}, ACCOUNT_ERROR_DB_FAILED, ("_account_execute_query(%s) failed(%d, %s).\n", CAPABILITY_SCHEMA, rc, _account_db_err_msg()));
+ }
+
+ /* Create account custom table */
+ ACCOUNT_MEMSET(query, 0, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "select count(*) from sqlite_master where name in ('%s')", ACCOUNT_CUSTOM_TABLE);
+ rc = _account_get_record_count(query);
+ if (rc <= 0) {
+ rc = _account_execute_query(ACCOUNT_CUSTOM_SCHEMA);
+ if(rc == SQLITE_BUSY) return ACCOUNT_ERROR_DATABASE_BUSY;
+ ACCOUNT_RETURN_VAL((SQLITE_OK == rc), {}, ACCOUNT_ERROR_DB_FAILED, ("_account_execute_query(%s) failed(%d, %s).\n", query, rc, _account_db_err_msg()));
+ }
+
+ /* Create account type table */
+ ACCOUNT_MEMSET(query, 0, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "select count(*) from sqlite_master where name in ('%s')", ACCOUNT_TYPE_TABLE);
+ rc = _account_get_record_count(query);
+ if (rc <= 0) {
+ rc = _account_execute_query(ACCOUNT_TYPE_SCHEMA);
+ if(rc == SQLITE_BUSY) return ACCOUNT_ERROR_DATABASE_BUSY;
+ ACCOUNT_RETURN_VAL((SQLITE_OK == rc), {}, ACCOUNT_ERROR_DB_FAILED, ("_account_execute_query(%s) failed(%d, %s).\n", ACCOUNT_TYPE_SCHEMA, rc, _account_db_err_msg()));
+ }
+
+ /* Create label table */
+ ACCOUNT_MEMSET(query, 0, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "select count(*) from sqlite_master where name in ('%s')", LABEL_TABLE);
+ rc = _account_get_record_count(query);
+ if (rc <= 0) {
+ rc = _account_execute_query(LABEL_SCHEMA);
+ if(rc == SQLITE_BUSY) return ACCOUNT_ERROR_DATABASE_BUSY;
+ ACCOUNT_RETURN_VAL((SQLITE_OK == rc), {}, ACCOUNT_ERROR_DB_FAILED, ("_account_execute_query(%s) failed(%d, %s).\n", LABEL_SCHEMA, rc, _account_db_err_msg()));
+ }
+
+ /* Create account feature table */
+ ACCOUNT_MEMSET(query, 0, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "select count(*) from sqlite_master where name in ('%s')", PROVIDER_FEATURE_TABLE);
+ rc = _account_get_record_count(query);
+ if (rc <= 0) {
+ rc = _account_execute_query(PROVIDER_FEATURE_SCHEMA);
+ if(rc == SQLITE_BUSY) return ACCOUNT_ERROR_DATABASE_BUSY;
+ ACCOUNT_RETURN_VAL((SQLITE_OK == rc), {}, ACCOUNT_ERROR_DB_FAILED, ("_account_execute_query(%s) failed(%d, %s).\n", PROVIDER_FEATURE_SCHEMA, rc, _account_db_err_msg()));
+ }
+
+ ACCOUNT_DEBUG("create all table - END");
+ return error_code;
+}
+
+static int _account_check_is_all_table_exists()
+{
+ int rc = 0;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0,};
+ ACCOUNT_MEMSET(query, 0, sizeof(query));
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "select count(*) from sqlite_master where name in ('%s', '%s', '%s', '%s', '%s', '%s')",
+ ACCOUNT_TABLE, CAPABILITY_TABLE, ACCOUNT_CUSTOM_TABLE, ACCOUNT_TYPE_TABLE, LABEL_TABLE, PROVIDER_FEATURE_TABLE);
+ rc = _account_get_record_count(query);
+
+ if (rc != ACCOUNT_TABLE_TOTAL_COUNT) {
+ ACCOUNT_ERROR("Table count is not matched rc=%d\n", rc);
+ }
+
+ return rc;
+}
+
+static int _account_db_open(int mode)
+{
+ int rc = 0;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+
+ if (!g_hAccountDB) {
+ if(mode == ACCOUNT_DB_OPEN_READWRITE)
+ rc = db_util_open(ACCOUNT_DB_NAME, &g_hAccountDB, DB_UTIL_REGISTER_HOOK_METHOD);
+ else if(mode == ACCOUNT_DB_OPEN_READONLY)
+ rc = db_util_open_with_options(ACCOUNT_DB_NAME, &g_hAccountDB, SQLITE_OPEN_READONLY, NULL);
+ else
+ return ACCOUNT_ERROR_DB_NOT_OPENED;
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ ACCOUNT_RETURN_VAL((rc != SQLITE_PERM), {}, ACCOUNT_ERROR_PERMISSION_DENIED, ("Account permission denied rc : %d", rc));
+ ACCOUNT_RETURN_VAL((rc == SQLITE_OK), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected. rc : %d", rc));
+ g_refCntDB++;
+ } else {
+ g_refCntDB++;
+ }
+
+ ACCOUNT_RETURN_VAL((rc == SQLITE_OK), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("busy handler fail. rc : %d", rc));
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_db_close(void)
+{
+ int rc = 0;
+ int ret = -1;
+
+ if (g_hAccountDB) {
+ if (g_refCntDB > 0) {
+ g_refCntDB--;
+ }
+ if (g_refCntDB == 0) {
+ rc = db_util_close(g_hAccountDB);
+ if( rc == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(SQLITE_PERM)");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ } else if ( rc == SQLITE_BUSY ){
+ ACCOUNT_ERROR( "database busy");
+ return ACCOUNT_ERROR_DATABASE_BUSY;
+ }
+ ACCOUNT_RETURN_VAL((rc == SQLITE_OK), {}, ACCOUNT_ERROR_DB_FAILED, ("The database isn't connected. rc : %d", rc));
+ g_hAccountDB = NULL;
+ }
+ ret = ACCOUNT_ERROR_NONE;
+ } else {
+ ACCOUNT_ERROR( "_account_svc_db_close: No handle(). refcnt=%d ", g_refCntDB);
+ ret = ACCOUNT_ERROR_DB_FAILED;
+ }
+
+ return ret;
+}
+
+static int _account_connect(int mode)
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ pthread_mutex_lock(&account_mutex);
+
+ error_code = _account_db_open(mode);
+ if (ACCOUNT_ERROR_NONE != error_code) {
+ ACCOUNT_ERROR("The database isn't connected.\n");
+ pthread_mutex_unlock(&account_mutex);
+
+ if(error_code == ACCOUNT_ERROR_PERMISSION_DENIED)
+ return error_code;
+ else
+ return ACCOUNT_ERROR_DB_NOT_OPENED;
+ }
+
+ int rc = _account_check_is_all_table_exists();
+
+ if ( rc < 0 ){
+ pthread_mutex_unlock(&account_mutex);
+ ACCOUNT_ERROR("rc(%d)", rc);
+ return rc;
+ } else if (rc == ACCOUNT_TABLE_TOTAL_COUNT){
+ // do nothing
+ ACCOUNT_DEBUG("Tables OK");
+ } else {
+ error_code = _account_create_all_tables();
+ }
+
+ pthread_mutex_unlock(&account_mutex);
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_connect (void)
+{
+ return _account_connect(ACCOUNT_DB_OPEN_READWRITE);
+}
+
+ACCOUNT_API int account_connect_readonly (void)
+{
+ return _account_connect(ACCOUNT_DB_OPEN_READONLY);
+}
+
+static int _account_disconnect(void)
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ pthread_mutex_lock(&account_mutex);
+
+ error_code = _account_db_close();
+ pthread_mutex_unlock(&account_mutex);
+
+ return error_code;
+}
+
+ACCOUNT_API int account_disconnect (void)
+{
+ return _account_disconnect();
+}
+
+static int _account_free_capability_items(account_capability_s *data)
+{
+ _ACCOUNT_FREE(data->type);
+ _ACCOUNT_FREE(data->package_name);
+ _ACCOUNT_FREE(data->user_name);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_custom_item_free(account_custom_s *data)
+{
+ _ACCOUNT_FREE(data->app_id);
+ _ACCOUNT_FREE(data->key);
+ _ACCOUNT_FREE(data->value);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_custom_gslist_free(GSList* list)
+{
+ if(!list){
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ GSList* iter;
+
+ for (iter = list; iter != NULL; iter = g_slist_next(iter)) {
+ account_custom_s *custom_data = (account_custom_s*)iter->data;
+ _account_custom_item_free(custom_data);
+ _ACCOUNT_FREE(custom_data);
+ }
+
+ g_slist_free(list);
+ list = NULL;
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_free_account_items(account_s *data)
+{
+ _ACCOUNT_FREE(data->user_name);
+ _ACCOUNT_FREE(data->email_address);
+ _ACCOUNT_FREE(data->display_name);
+ _ACCOUNT_FREE(data->icon_path);
+ _ACCOUNT_FREE(data->source);
+ _ACCOUNT_FREE(data->package_name);
+ _ACCOUNT_FREE(data->domain_name);
+ _ACCOUNT_FREE(data->access_token);
+
+ int i;
+ for(i=0;i<USER_TXT_CNT;i++)
+ _ACCOUNT_FREE(data->user_data_txt[i]);
+
+ _account_gslist_free(data->capablity_list);
+ _account_glist_free(data->account_list);
+ _account_custom_gslist_free(data->custom_list);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_gslist_free(GSList* list)
+{
+ if(!list){
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ GSList* iter;
+
+ for (iter = list; iter != NULL; iter = g_slist_next(iter)) {
+ account_capability_s *cap_data = (account_capability_s*)iter->data;
+ _account_free_capability_items(cap_data);
+ _ACCOUNT_FREE(cap_data);
+ }
+
+ g_slist_free(list);
+ list = NULL;
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_glist_free(GList* list)
+{
+ if(!list){
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ GList* iter;
+
+ for (iter = list; iter != NULL; iter = g_list_next(iter)) {
+ account_s *account_record = (account_s*)iter->data;
+ _account_free_account_items(account_record);
+ _ACCOUNT_FREE(account_record);
+ }
+
+ g_list_free(list);
+ list = NULL;
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static gboolean _account_check_duplicated(account_s *data)
+{
+#if 0
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int count = 0;
+
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "select count(*) from %s where user_name='%s' and package_name='%s'"
+ , ACCOUNT_TABLE, data->user_name, data->package_name);
+
+ count = _account_get_record_count(query);
+ if (count > 0) {
+ ACCOUNT_SLOGI("_account_check_duplicated : duplicated %d account(s) exist!, user_name=%s, domain_name=%s\n",
+ count, data->user_name, data->domain_name );
+ return TRUE;
+ }
+#endif
+ return FALSE;
+
+}
+
+static int _account_get_next_sequence(const char *pszName)
+{
+ int rc = 0;
+ account_stmt pStmt = NULL;
+ int max_seq = 0;
+ char szQuery[ACCOUNT_SQL_LEN_MAX] = {0,};
+
+ ACCOUNT_MEMSET(szQuery, 0x00, sizeof(szQuery));
+ ACCOUNT_SNPRINTF(szQuery, sizeof(szQuery), "SELECT max(seq) FROM %s where name = '%s' ", ACCOUNT_SQLITE_SEQ, pszName);
+ rc = sqlite3_prepare_v2(g_hAccountDB, szQuery, strlen(szQuery), &pStmt, NULL);
+ if (SQLITE_OK != rc) {
+ ACCOUNT_SLOGE("sqlite3_prepare_v2() failed(%d, %s).", rc, _account_db_err_msg());
+ sqlite3_finalize(pStmt);
+ return ACCOUNT_ERROR_DB_FAILED;
+ }
+
+ rc = sqlite3_step(pStmt);
+ max_seq = sqlite3_column_int(pStmt, 0);
+ max_seq++;
+
+ /*Finalize Statement*/
+ rc = sqlite3_finalize(pStmt);
+ pStmt = NULL;
+
+ return max_seq;
+}
+
+static account_stmt _account_prepare_query(char *query)
+{
+ int rc = -1;
+ account_stmt pStmt = NULL;
+
+ ACCOUNT_RETURN_VAL((query != NULL), {}, NULL, ("query is NULL"));
+
+ rc = sqlite3_prepare_v2(g_hAccountDB, query, strlen(query), &pStmt, NULL);
+
+ ACCOUNT_RETURN_VAL((SQLITE_OK == rc), {}, NULL, ("sqlite3_prepare_v2(%s) failed(%s).", query, _account_db_err_msg()));
+
+ return pStmt;
+}
+
+static int _account_query_bind_int(account_stmt pStmt, int pos, int num)
+{
+ if(!pStmt){
+ ACCOUNT_ERROR("statement is null");
+ return -1;
+ }
+
+ if(pos < 0){
+ ACCOUNT_ERROR("invalid pos");
+ return -1;
+ }
+
+ return sqlite3_bind_int(pStmt, pos, num);
+}
+
+static int _account_query_bind_text(account_stmt pStmt, int pos, const char *str)
+{
+ if(!pStmt){
+ ACCOUNT_ERROR("statement is null");
+ return -1;
+ }
+
+ if(str)
+ return sqlite3_bind_text(pStmt, pos, (const char*)str, strlen(str), SQLITE_STATIC);
+ else
+ return sqlite3_bind_null(pStmt, pos);
+}
+
+static int _account_convert_account_to_sql(account_s *account, account_stmt hstmt, char *sql_value)
+{
+ int count = 1;
+
+ /*Caution : Keep insert query orders.*/
+
+ /* 1. user name*/
+ _account_query_bind_text(hstmt, count++, (char*)account->user_name);
+
+ /* 2. email address*/
+ _account_query_bind_text(hstmt, count++, (char*)account->email_address);
+
+ /* 3. display name*/
+ _account_query_bind_text(hstmt, count++, (char*)account->display_name);
+
+ /* 4. icon path*/
+ _account_query_bind_text(hstmt, count++, (char*)account->icon_path);
+
+ /* 5. source*/
+ _account_query_bind_text(hstmt, count++, (char*)account->source);
+
+ /* 6. package name*/
+ _account_query_bind_text(hstmt, count++, (char*)account->package_name);
+
+ /* 7. access token*/
+ _account_query_bind_text(hstmt, count++, (char*)account->access_token);
+
+ /* 8. domain name*/
+ _account_query_bind_text(hstmt, count++, (char*)account->domain_name);
+
+ /* 9. auth type*/
+ _account_query_bind_int(hstmt, count++, account->auth_type);
+
+ /* 10. secret */
+ _account_query_bind_int(hstmt, count++, account->secret);
+
+ /* 11. sync_support */
+ _account_query_bind_int(hstmt, count++, account->sync_support);
+
+ int i;
+
+ /* 12. user text*/
+ for(i=0; i< USER_TXT_CNT; i++)
+ _account_query_bind_text(hstmt, count++, (char*)account->user_data_txt[i]);
+
+ /* 13. user integer */
+ for(i=0; i< USER_INT_CNT; i++)
+ _account_query_bind_int(hstmt, count++, account->user_data_int[i]);
+
+ return count;
+}
+
+static int _account_query_finalize(account_stmt pStmt)
+{
+ int rc = -1;
+
+ if (!pStmt) {
+ ACCOUNT_ERROR( "pStmt is NULL");
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ rc = sqlite3_finalize(pStmt);
+ if (rc == SQLITE_BUSY){
+ ACCOUNT_ERROR(" sqlite3 busy = %d", rc);
+ return ACCOUNT_ERROR_DATABASE_BUSY;
+ } else if (rc != SQLITE_OK) {
+ ACCOUNT_ERROR( "sqlite3_finalize fail, rc : %d, db_error : %s\n", rc, _account_db_err_msg());
+ return ACCOUNT_ERROR_DB_FAILED;
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_query_step(account_stmt pStmt)
+{
+ if(!pStmt){
+ ACCOUNT_ERROR( "pStmt is NULL");
+ return -1;
+ }
+
+ return sqlite3_step(pStmt);
+}
+
+static int _account_execute_insert_query(account_s *account)
+{
+ int rc = 0;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+
+ /* check whether app id exist in account type db */
+
+ if (!account->user_name && !account->display_name && !account->email_address) {
+ ACCOUNT_ERROR("Mandetory fields is NULL. At least one field is required among username, display name, email address\n");
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "INSERT INTO %s( user_name, email_address , display_name , icon_path , source , package_name , "
+ "access_token , domain_name , auth_type , secret , sync_support , txt_custom0, txt_custom1, txt_custom2, txt_custom3, txt_custom4, "
+ "int_custom0, int_custom1, int_custom2, int_custom3, int_custom4, txt_custom0 ) values " // to do urusa
+ "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? , ?, ?)", ACCOUNT_TABLE);
+
+ hstmt = _account_prepare_query(query);
+ ACCOUNT_RETURN_VAL((hstmt != NULL), {}, ACCOUNT_ERROR_DB_FAILED, ("_account_prepare_query() failed(%s).\n", _account_db_err_msg()));
+
+ _account_convert_account_to_sql(account, hstmt, query);
+
+ rc = _account_query_step(hstmt);
+ if (rc != SQLITE_DONE) {
+ ACCOUNT_ERROR( "account_db_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+
+ if( _account_db_err_code() == SQLITE_PERM )
+ error_code = ACCOUNT_ERROR_PERMISSION_DENIED;
+ else
+ error_code = ACCOUNT_ERROR_DB_FAILED;
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ return error_code;
+}
+
+static int _account_insert_capability(account_s *account, int account_id)
+{
+ int rc, count = 1;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ account_stmt hstmt = NULL;
+
+ ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL"));
+
+ if (g_slist_length( account->capablity_list)==0) {
+ ACCOUNT_DEBUG( "_account_insert_capability, no capability\n");
+ return ACCOUNT_ERROR_NONE;
+ }
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT COUNT(*) from %s where _id=%d", ACCOUNT_TABLE, account_id);
+
+ rc = _account_get_record_count(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ if (rc <= 0) {
+ return ACCOUNT_ERROR_RECORD_NOT_FOUND;
+ }
+
+ /* insert query*/
+
+ GSList *iter;
+
+ for (iter = account->capablity_list; iter != NULL; iter = g_slist_next(iter)) {
+ int ret;
+ count = 1;
+
+ account_capability_s* cap_data = NULL;
+ cap_data = (account_capability_s*)iter->data;
+
+ ACCOUNT_SLOGD("cap_data->type = %s, cap_data->value = %d \n", cap_data->type, cap_data->value);
+
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "INSERT INTO %s(key, value, package_name, user_name, account_id) VALUES "
+ "(?, ?, ?, ?, ?) ", CAPABILITY_TABLE);
+ hstmt = _account_prepare_query(query);
+
+ ACCOUNT_RETURN_VAL((hstmt != NULL), {}, ACCOUNT_ERROR_DB_FAILED, ("_account_prepare_query() failed(%s).\n", _account_db_err_msg()));
+
+ ret = _account_query_bind_text(hstmt, count++, cap_data->type);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+ ret = _account_query_bind_int(hstmt, count++, cap_data->value);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Integer binding fail"));
+ ret = _account_query_bind_text(hstmt, count++, (char*)account->package_name);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+ ret = _account_query_bind_text(hstmt, count++, (char*)account->user_name);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+ ret = _account_query_bind_int(hstmt, count++, (int)account_id);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Integer binding fail"));
+
+ rc = _account_query_step(hstmt);
+
+ if (rc != SQLITE_DONE) {
+ ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+ break;
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_update_capability(account_s *account, int account_id)
+{
+ int rc, count = 1;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ account_stmt hstmt = NULL;
+
+ ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL"));
+
+ if (g_slist_length( account->capablity_list)==0) {
+ ACCOUNT_ERROR( "_account_update_capability, no capability\n");
+ return ACCOUNT_ERROR_NONE;
+ }
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT COUNT(*) from %s where _id=%d", ACCOUNT_TABLE, account_id);
+
+ rc = _account_get_record_count(query);
+
+ if (rc <= 0) {
+ ACCOUNT_SLOGI( "_account_update_capability : related account item is not existed rc=%d , %s", rc, _account_db_err_msg());
+ return ACCOUNT_ERROR_RECORD_NOT_FOUND;
+ }
+
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s WHERE account_id=? ", CAPABILITY_TABLE);
+ hstmt = _account_prepare_query(query);
+ count = 1;
+ _account_query_bind_int(hstmt, count++, (int)account_id);
+ rc = _account_query_step(hstmt);
+
+ if (rc != SQLITE_DONE) {
+ ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+ return ACCOUNT_ERROR_DB_FAILED;
+ }
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ GSList *iter;
+
+ for (iter = account->capablity_list; iter != NULL; iter = g_slist_next(iter)) {
+ int ret;
+ count = 1;
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "INSERT INTO %s(key, value, package_name, user_name, account_id) VALUES "
+ "(?, ?, ?, ?, ?) ", CAPABILITY_TABLE);
+
+ hstmt = _account_prepare_query(query);
+
+ ACCOUNT_RETURN_VAL((hstmt != NULL), {}, ACCOUNT_ERROR_DB_FAILED, ("_account_prepare_query() failed(%s).\n", _account_db_err_msg()));
+
+ account_capability_s* cap_data = NULL;
+ cap_data = (account_capability_s*)iter->data;
+
+ ret = _account_query_bind_text(hstmt, count++, cap_data->type);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+ ret = _account_query_bind_int(hstmt, count++, cap_data->value);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Integer binding fail"));
+ ret = _account_query_bind_text(hstmt, count++, (char*)account->package_name);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+ ret = _account_query_bind_text(hstmt, count++, (char*)account->user_name);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+ ret = _account_query_bind_int(hstmt, count++, (int)account_id);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Integer binding fail"));
+
+ rc = _account_query_step(hstmt);
+
+ if (rc != SQLITE_DONE) {
+ ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+ break;
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_update_capability_by_user_name(account_s *account, const char *user_name, const char *package_name )
+{
+ int rc, count = 1;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ account_stmt hstmt = NULL;
+
+ ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL"));
+
+ if (g_slist_length( account->capablity_list)==0) {
+ ACCOUNT_ERROR( "_account_update_capability_by_user_name, no capability\n");
+ return ACCOUNT_ERROR_NONE;
+ }
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT COUNT(*) from %s where package_name= '%s' and user_name='%s'", ACCOUNT_TABLE, package_name, user_name);
+
+ rc = _account_get_record_count(query);
+
+ if (rc <= 0) {
+ ACCOUNT_SLOGI( "_account_update_capability_by_user_name : related account item is not existed rc=%d , %s ", rc, _account_db_err_msg());
+ return ACCOUNT_ERROR_RECORD_NOT_FOUND;
+ }
+
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s WHERE package_name=? and user_name=? ", CAPABILITY_TABLE);
+ hstmt = _account_prepare_query(query);
+ count = 1;
+ _account_query_bind_text(hstmt, count++, (char*)account->package_name);
+ _account_query_bind_text(hstmt, count++, (char*)account->user_name);
+ rc = _account_query_step(hstmt);
+ if (rc != SQLITE_DONE) {
+ ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+ return ACCOUNT_ERROR_DB_FAILED;
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ GSList* iter;
+
+ for (iter = account->capablity_list; iter != NULL; iter = g_slist_next(iter)) {
+ int ret;
+ count = 1;
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "INSERT INTO %s(key, value, package_name, user_name, account_id) VALUES "
+ "(?, ?, ?, ?, ?) ", CAPABILITY_TABLE);
+
+ hstmt = _account_prepare_query(query);
+
+ ACCOUNT_RETURN_VAL((hstmt != NULL), {}, ACCOUNT_ERROR_DB_FAILED, ("_account_prepare_query() failed(%s).\n", _account_db_err_msg()));
+
+ account_capability_s* cap_data = NULL;
+ cap_data = (account_capability_s*)iter->data;
+
+ ret = _account_query_bind_text(hstmt, count++, cap_data->type);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+ ret = _account_query_bind_int(hstmt, count++, cap_data->value);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Integer binding fail"));
+ ret = _account_query_bind_text(hstmt, count++, (char*)account->package_name);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+ ret = _account_query_bind_text(hstmt, count++, (char*)account->user_name);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+ ret = _account_query_bind_int(hstmt, count++, (int)account->id);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Integer binding fail"));
+
+ rc = _account_query_step(hstmt);
+
+ if (rc != SQLITE_DONE) {
+ ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+ break;
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_query_table_column_int(account_stmt pStmt, int pos)
+{
+ if(!pStmt){
+ ACCOUNT_ERROR("statement is null");
+ return -1;
+ }
+
+ if(pos < 0){
+ ACCOUNT_ERROR("invalid pos");
+ return -1;
+ }
+
+ return sqlite3_column_int(pStmt, pos);
+}
+
+static const char *_account_query_table_column_text(account_stmt pStmt, int pos)
+{
+ if(!pStmt){
+ ACCOUNT_ERROR("statement is null");
+ return NULL;
+ }
+
+ if(pos < 0){
+ ACCOUNT_ERROR("invalid pos");
+ return NULL;
+ }
+
+ return (const char *)sqlite3_column_text(pStmt, pos);
+}
+
+static void _account_db_data_to_text(const char *textbuf, char **output)
+{
+ if (textbuf && strlen(textbuf)>0) {
+ if (*output) {
+ free(*output);
+ *output = NULL;
+ }
+ *output = strdup(textbuf);
+ }
+}
+
+static void _account_convert_column_to_account(account_stmt hstmt, account_s *account_record)
+{
+ const char *textbuf = NULL;
+
+ account_record->id = _account_query_table_column_int(hstmt, ACCOUNT_FIELD_ID);
+
+ textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_USER_NAME);
+ _account_db_data_to_text(textbuf, &(account_record->user_name));
+
+ textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_EMAIL_ADDRESS);
+ _account_db_data_to_text(textbuf, &(account_record->email_address));
+
+ textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_DISPLAY_NAME);
+ _account_db_data_to_text(textbuf, &(account_record->display_name));
+
+ textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_ICON_PATH);
+ _account_db_data_to_text(textbuf, &(account_record->icon_path));
+
+ textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_SOURCE);
+ _account_db_data_to_text(textbuf, &(account_record->source));
+
+ textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_PACKAGE_NAME);
+ _account_db_data_to_text(textbuf, &(account_record->package_name));
+
+ textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_ACCESS_TOKEN);
+ _account_db_data_to_text(textbuf, &(account_record->access_token));
+
+ textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_DOMAIN_NAME);
+ _account_db_data_to_text(textbuf, &(account_record->domain_name));
+
+ account_record->auth_type = _account_query_table_column_int(hstmt, ACCOUNT_FIELD_AUTH_TYPE);
+
+ account_record->secret = _account_query_table_column_int(hstmt, ACCOUNT_FIELD_SECRET);
+
+ account_record->sync_support = _account_query_table_column_int(hstmt, ACCOUNT_FIELD_SYNC_SUPPORT);
+
+ textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_USER_TEXT_0);
+ _account_db_data_to_text(textbuf, &(account_record->user_data_txt[0]));
+
+ textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_USER_TEXT_1);
+ _account_db_data_to_text(textbuf, &(account_record->user_data_txt[1]));
+
+ textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_USER_TEXT_2);
+ _account_db_data_to_text(textbuf, &(account_record->user_data_txt[2]));
+
+ textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_USER_TEXT_3);
+ _account_db_data_to_text(textbuf, &(account_record->user_data_txt[3]));
+
+ textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_USER_TEXT_4);
+ _account_db_data_to_text(textbuf, &(account_record->user_data_txt[4]));
+
+ account_record->user_data_int[0] = _account_query_table_column_int(hstmt, ACCOUNT_FIELD_USER_INT_0);
+ account_record->user_data_int[1] = _account_query_table_column_int(hstmt, ACCOUNT_FIELD_USER_INT_1);
+ account_record->user_data_int[2] = _account_query_table_column_int(hstmt, ACCOUNT_FIELD_USER_INT_2);
+ account_record->user_data_int[3] = _account_query_table_column_int(hstmt, ACCOUNT_FIELD_USER_INT_3);
+ account_record->user_data_int[4] = _account_query_table_column_int(hstmt, ACCOUNT_FIELD_USER_INT_4);
+}
+
+static void _account_convert_column_to_capability(account_stmt hstmt, account_capability_s *capability_record)
+{
+ const char *textbuf = NULL;
+
+ capability_record->id = _account_query_table_column_int(hstmt, CAPABILITY_FIELD_ID);
+
+ textbuf = _account_query_table_column_text(hstmt, CAPABILITY_FIELD_KEY);
+ _account_db_data_to_text(textbuf, &(capability_record->type));
+
+ capability_record->value = _account_query_table_column_int(hstmt, CAPABILITY_FIELD_VALUE);
+
+ textbuf = _account_query_table_column_text(hstmt, CAPABILITY_FIELD_PACKAGE_NAME);
+ _account_db_data_to_text(textbuf, &(capability_record->package_name));
+
+ textbuf = _account_query_table_column_text(hstmt, CAPABILITY_FIELD_USER_NAME);
+ _account_db_data_to_text(textbuf, &(capability_record->user_name));
+
+ capability_record->account_id = _account_query_table_column_int(hstmt, CAPABILITY_FIELD_ACCOUNT_ID);
+}
+
+static void _account_convert_column_to_custom(account_stmt hstmt, account_custom_s *custom_record)
+{
+ const char *textbuf = NULL;
+
+ custom_record->account_id = _account_query_table_column_int(hstmt, ACCOUNT_CUSTOM_FIELD_ACCOUNT_ID);
+
+ textbuf = _account_query_table_column_text(hstmt, ACCOUNT_CUSTOM_FIELD_APP_ID);
+ _account_db_data_to_text(textbuf, &(custom_record->app_id));
+
+ textbuf = _account_query_table_column_text(hstmt, ACCOUNT_CUSTOM_FIELD_KEY);
+ _account_db_data_to_text(textbuf, &(custom_record->key));
+
+ textbuf = _account_query_table_column_text(hstmt, ACCOUNT_CUSTOM_FIELD_VALUE);
+ _account_db_data_to_text(textbuf, &(custom_record->value));
+}
+
+bool _account_get_capability_text_cb(const char* capability_type, account_capability_state_e capability_value, void *user_data)
+{
+ account_s *data = (account_s*)user_data;
+
+ account_capability_s *cap_data = (account_capability_s*)malloc(sizeof(account_capability_s));
+
+ if (cap_data == NULL)
+ return FALSE;
+ ACCOUNT_MEMSET(cap_data, 0, sizeof(account_capability_s));
+
+ cap_data->type = _account_get_text(capability_type);
+ cap_data->value = capability_value;
+
+ data->capablity_list = g_slist_append(data->capablity_list, (gpointer)cap_data);
+
+ return TRUE;
+}
+
+
+bool _account_get_custom_text_cb(char* key, char* value, void *user_data)
+{
+ account_s *data = (account_s*)user_data;
+
+ account_custom_s *custom_data = (account_custom_s*)malloc(sizeof(account_custom_s));
+
+ if (custom_data == NULL) {
+ ACCOUNT_DEBUG("_account_get_custom_text_cb :: malloc fail\n");
+ return FALSE;
+ }
+ ACCOUNT_MEMSET(custom_data, 0, sizeof(account_custom_s));
+
+ custom_data->account_id = data->id;
+ custom_data->app_id = _account_get_text(data->package_name);
+ custom_data->key = _account_get_text(key);
+ custom_data->value = _account_get_text(value);
+
+ data->custom_list = g_slist_append(data->custom_list, (gpointer)custom_data);
+
+ return TRUE;
+}
+
+
+static char *_account_get_text(const char *text_data)
+{
+ char *text_value = NULL;
+
+ if (text_data != NULL) {
+ text_value = strdup(text_data);
+ }
+ return text_value;
+}
+
+static int _account_compare_old_record_by_user_name(account_s *new_account, const char* user_name, const char* package_name)
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0;
+ account_s *old_account = NULL;
+
+ ACCOUNT_RETURN_VAL((new_account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT IS NULL"));
+ ACCOUNT_RETURN_VAL((user_name != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("USER NAME IS NULL"));
+ ACCOUNT_RETURN_VAL((package_name != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("PACKAGE NAME IS NULL"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+
+ old_account = (account_s*)calloc(1, sizeof(account_s));
+ if(!old_account) {
+ ACCOUNT_FATAL("Memory alloc fail\n");
+ return ACCOUNT_ERROR_OUT_OF_MEMORY;
+ }
+
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE user_name = '%s' and package_name='%s'", ACCOUNT_TABLE, user_name, package_name);
+ hstmt = _account_prepare_query(query);
+
+ rc = _account_query_step(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
+
+ while (rc == SQLITE_ROW) {
+ _account_convert_column_to_account(hstmt, old_account);
+ rc = _account_query_step(hstmt);
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_CATCH_ERROR((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ // get capability
+ error_code = account_query_capability_by_account_id(_account_get_capability_text_cb, old_account->id, (void*)old_account);
+ ACCOUNT_CATCH_ERROR((error_code == ACCOUNT_ERROR_NONE), {}, error_code, ("account_query_capability_by_account_id error"));
+
+ // get custom text
+ error_code = _account_query_custom_by_account_id(_account_get_custom_text_cb, old_account->id, (void*)old_account);
+ ACCOUNT_CATCH_ERROR((error_code == ACCOUNT_ERROR_NONE), {}, error_code, ("_account_query_custom_by_account_id error"));
+
+ // compare
+ new_account->id = old_account->id;
+
+ //user name
+ if(!new_account->user_name) {
+ if(old_account->user_name)
+ new_account->user_name = _account_get_text(old_account->user_name);
+ }
+
+ // display name
+ if(!new_account->display_name) {
+ if(old_account->display_name)
+ new_account->display_name = _account_get_text(old_account->display_name);
+ }
+
+ // email address
+ if(!new_account->email_address) {
+ if(old_account->email_address)
+ new_account->email_address = _account_get_text(old_account->email_address);
+ }
+
+ // domain name
+ if(!new_account->domain_name) {
+ if(old_account->domain_name)
+ new_account->domain_name = _account_get_text(old_account->domain_name);
+ }
+
+ // icon path
+ if(!new_account->icon_path) {
+ if(old_account->icon_path)
+ new_account->icon_path = _account_get_text(old_account->icon_path);
+ }
+
+ // source
+ if(!new_account->source) {
+ if(old_account->source)
+ new_account->source = _account_get_text(old_account->source);
+ }
+
+ _ACCOUNT_FREE(new_account->package_name);
+ new_account->package_name = _account_get_text(old_account->package_name);
+
+ // access token
+ if(!new_account->access_token) {
+ if(old_account->access_token)
+ new_account->access_token = _account_get_text(old_account->access_token);
+ }
+
+ // user text
+ int i;
+ for(i=0;i<USER_TXT_CNT;i++) {
+ if(!new_account->user_data_txt[i]) {
+ if(old_account->user_data_txt[i])
+ new_account->user_data_txt[i] = _account_get_text(old_account->user_data_txt[i]);
+ }
+ }
+
+ // auth type
+ if(new_account->auth_type == ACCOUNT_AUTH_TYPE_INVALID) {
+ new_account->auth_type = old_account->auth_type;
+ }
+
+ //secret
+ if(new_account->secret== ACCOUNT_SECRECY_INVALID) {
+ new_account->secret = old_account->secret;
+ }
+
+ // sync support
+ if(new_account->sync_support == ACCOUNT_SYNC_INVALID) {
+ new_account->sync_support = old_account->sync_support;
+ }
+
+ // user int
+ for(i=0;i<USER_INT_CNT;i++) {
+ if(new_account->user_data_int[i] == 0) {
+ new_account->user_data_int[i] = old_account->user_data_int[i];
+ }
+ }
+
+ // capability
+
+ // user custom table
+
+
+
+ CATCH:
+ if (old_account) {
+ _account_free_account_items(old_account);
+ _ACCOUNT_FREE(old_account);
+ }
+
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+
+
+static int _account_update_account_by_user_name(account_s *account, const char *user_name, const char *package_name)
+{
+ int rc = 0, binding_count = 0, count = 0;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+
+ ACCOUNT_RETURN_VAL((user_name != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("user_name is NULL.\n"));
+ ACCOUNT_RETURN_VAL((package_name!= NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("package_name is NULL.\n"));
+
+ char* current_appid = NULL;
+ char* verified_appid = NULL;
+
+ current_appid = _account_get_current_appid();
+ error_code = _account_check_account_type_with_appid_group(current_appid, &verified_appid);
+
+ _ACCOUNT_FREE(current_appid);
+ _ACCOUNT_FREE(verified_appid);
+
+ if(error_code != ACCOUNT_ERROR_NONE){
+ ACCOUNT_ERROR("No permission to update\n");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ _account_compare_old_record_by_user_name(account, user_name, package_name);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ if (!account->package_name) {
+ ACCOUNT_ERROR("Package name is mandetory field, it can not be NULL!!!!\n");
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!account->user_name && !account->display_name && !account->email_address) {
+ ACCOUNT_ERROR("One field should be set among user name, display name, email address\n");
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT COUNT(*) FROM %s WHERE user_name='%s' and package_name='%s'"
+ , ACCOUNT_TABLE, user_name, package_name);
+
+ count = _account_get_record_count(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ if (count <= 0) {
+ ACCOUNT_SLOGI("_account_update_account_by_user_name : The account not exist!, count = %d, user_name=%s, package_name=%s\n",
+ count, user_name, package_name);
+ return ACCOUNT_ERROR_RECORD_NOT_FOUND;
+ }
+
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "UPDATE %s SET user_name=?, email_address =?, display_name =?, "
+ "icon_path =?, source =?, package_name =? , access_token =?, domain_name =?, auth_type =?, secret =?, sync_support =?,"
+ "txt_custom0=?, txt_custom1=?, txt_custom2=?, txt_custom3=?, txt_custom4=?, "
+ "int_custom0=?, int_custom1=?, int_custom2=?, int_custom3=?, int_custom4=? WHERE user_name=? and package_name=? ", ACCOUNT_TABLE);
+
+ hstmt = _account_prepare_query(query);
+ if( _account_db_err_code() == SQLITE_PERM ){
+ _account_end_transaction(FALSE);
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ ACCOUNT_RETURN_VAL((hstmt != NULL), {}, ACCOUNT_ERROR_DB_FAILED, ("_account_svc_query_prepare() failed(%s).\n", _account_db_err_msg()));
+
+ binding_count = _account_convert_account_to_sql(account, hstmt, query);
+
+ _account_query_bind_text(hstmt, binding_count++, user_name);
+ _account_query_bind_text(hstmt, binding_count++, package_name);
+ rc = _account_query_step(hstmt);
+ if (rc != SQLITE_DONE) {
+ ACCOUNT_ERROR( "account_db_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+ }
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ /*update capability*/
+ error_code = _account_update_capability_by_user_name(account, user_name, package_name);
+
+ /* update custom */
+ error_code = _account_update_custom(account, account->id);
+
+ return error_code;
+}
+
+ACCOUNT_API int account_insert_to_db(account_h account, int *account_id)
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ int ret_transaction = 0;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+ ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL"));
+ ACCOUNT_RETURN_VAL((account_id != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT ID POINTER IS NULL"));
+
+ account_s *data = (account_s*)account;
+ ACCOUNT_SLOGD("(%s)-(%d) account_insert_to_db: begin_transaction.\n", __FUNCTION__, __LINE__);
+
+ pthread_mutex_lock(&account_mutex);
+
+ /* transaction control required*/
+ ret_transaction = _account_begin_transaction();
+
+ if(_account_db_err_code() == SQLITE_PERM){
+ pthread_mutex_unlock(&account_mutex);
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ if (ret_transaction == ACCOUNT_ERROR_DATABASE_BUSY) {
+ ACCOUNT_ERROR("account insert:_account_begin_transaction fail %d\n", ret_transaction);
+ pthread_mutex_unlock(&account_mutex);
+ return ACCOUNT_ERROR_DATABASE_BUSY;
+ }else if (ret_transaction != ACCOUNT_ERROR_NONE) {
+ ACCOUNT_ERROR("account insert:_account_begin_transaction fail %d\n", ret_transaction);
+ pthread_mutex_unlock(&account_mutex);
+ return ret_transaction;
+ }
+
+ if (_account_check_duplicated(data)) {
+ ret_transaction = _account_end_transaction(FALSE);
+ ACCOUNT_DEBUG("Duplicated, rollback insert query(%x)!!!!\n", ret_transaction);
+ *account_id = -1;
+ pthread_mutex_unlock(&account_mutex);
+ return ACCOUNT_ERROR_DUPLICATED;
+ } else {
+ *account_id = _account_get_next_sequence(ACCOUNT_TABLE);
+
+ char* appid = NULL;
+ appid = _account_get_current_appid();
+
+ if(!appid){
+ // API caller cannot be recognized
+ ret_transaction = _account_end_transaction(FALSE);
+ ACCOUNT_ERROR("App id is not registered in account type DB, transaction ret (%x)!!!!\n", ret_transaction);
+ pthread_mutex_unlock(&account_mutex);
+ return ACCOUNT_ERROR_NOT_REGISTERED_PROVIDER;
+ }
+
+ char* verified_appid = NULL;
+ error_code = _account_check_account_type_with_appid_group(appid, &verified_appid);
+ if(error_code != ACCOUNT_ERROR_NONE){
+ ret_transaction = _account_end_transaction(FALSE);
+ ACCOUNT_ERROR("App id is not registered in account type DB, transaction ret (%x)!!!!\n", ret_transaction);
+ _ACCOUNT_FREE(verified_appid);
+ _ACCOUNT_FREE(appid);
+ pthread_mutex_unlock(&account_mutex);
+ return error_code;
+ }
+
+ _ACCOUNT_FREE(appid);
+
+ if(verified_appid){
+ if(!_account_check_add_more_account(verified_appid)) {
+ ret_transaction = _account_end_transaction(FALSE);
+ ACCOUNT_ERROR("No more account cannot be added, transaction ret (%x)!!!!\n", ret_transaction);
+ pthread_mutex_unlock(&account_mutex);
+ _ACCOUNT_FREE(verified_appid);
+ return ACCOUNT_ERROR_NOT_ALLOW_MULTIPLE;
+ }
+
+ _ACCOUNT_FREE(data->package_name);
+ data->package_name = _account_get_text(verified_appid);
+ _ACCOUNT_FREE(verified_appid);
+ if(!data->package_name) {
+ ACCOUNT_ERROR("Memory Allocation Failed");
+ return ACCOUNT_ERROR_OUT_OF_MEMORY;
+ }
+ }
+
+#ifdef SAMSUNG_ACCOUNT_MANAGER
+ if(!strcmp(data->package_name,SAMSUNGACCOUNT_PKG_NAME)){
+ //temporary feature for samsung account domain
+ int ret = -1;
+ ret = account_set_domain_name(account, "Samsung");
+ if(ret != ACCOUNT_ERROR_NONE) {
+ ACCOUNT_DEBUG("set_domain error(%x)!!!!\n", ret);
+ }
+ }
+#endif
+
+ if(!_account_check_add_more_account(data->package_name)) {
+ ret_transaction = _account_end_transaction(FALSE);
+ ACCOUNT_ERROR("No more account cannot be added, transaction ret (%x)!!!!\n", ret_transaction);
+ pthread_mutex_unlock(&account_mutex);
+ return ACCOUNT_ERROR_NOT_ALLOW_MULTIPLE;
+ }
+
+ error_code = _account_execute_insert_query(data);
+
+ if (error_code != ACCOUNT_ERROR_NONE) {
+ ret_transaction = _account_end_transaction(FALSE);
+ ACCOUNT_ERROR("INSERT account fail, rollback insert query(%x)!!!!\n", ret_transaction);
+ *account_id = -1;
+ pthread_mutex_unlock(&account_mutex);
+ return error_code;
+ }
+ }
+
+ error_code = _account_insert_capability(data, *account_id);
+ if (error_code != ACCOUNT_ERROR_NONE) {
+ ret_transaction = _account_end_transaction(FALSE);
+ ACCOUNT_ERROR("INSERT capability fail, rollback insert capability query(%x)!!!!\n", ret_transaction);
+ *account_id = -1;
+ pthread_mutex_unlock(&account_mutex);
+ return error_code;
+ }
+
+ error_code = _account_insert_custom(data, *account_id);
+ if (error_code != ACCOUNT_ERROR_NONE) {
+ ret_transaction = _account_end_transaction(FALSE);
+ ACCOUNT_ERROR("INSERT custom fail, rollback insert capability query(%x)!!!!\n", ret_transaction);
+ *account_id = -1;
+ pthread_mutex_unlock(&account_mutex);
+ return error_code;
+ }
+
+ pthread_mutex_unlock(&account_mutex);
+ _account_end_transaction(TRUE);
+ ACCOUNT_SLOGD("(%s)-(%d) account _end_transaction.\n", __FUNCTION__, __LINE__);
+
+ char buf[64]={0,};
+ ACCOUNT_SNPRINTF(buf, sizeof(buf), "%s:%d", ACCOUNT_NOTI_NAME_INSERT, *account_id);
+ _account_insert_delete_update_notification_send(buf);
+ ACCOUNT_SLOGD("(%s)-(%d) account _notification_send.\n", __FUNCTION__, __LINE__);
+
+ return ACCOUNT_ERROR_NONE;
+
+}
+
+ACCOUNT_API int account_create(account_h *account)
+{
+ if (!account) {
+ ACCOUNT_SLOGE("(%s)-(%d) account is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)malloc(sizeof(account_s));
+
+ if (data == NULL) {
+ ACCOUNT_FATAL("Memory Allocation Failed");
+ return ACCOUNT_ERROR_OUT_OF_MEMORY;
+ }
+ ACCOUNT_MEMSET(data, 0, sizeof(account_s));
+
+ /*Setting account as visible by default*/
+ data->secret = ACCOUNT_SECRECY_VISIBLE;
+
+ /*Setting account as not supporting sync by default*/
+ data->sync_support = ACCOUNT_SYNC_NOT_SUPPORT;
+
+ *account = (account_h)data;
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_set_user_name(account_h account, const char *user_name)
+{
+ if (!account) {
+ ACCOUNT_SLOGE("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!user_name) {
+ ACCOUNT_SLOGE("(%s)-(%d) user_name is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)account;
+
+ _ACCOUNT_FREE(data->user_name);
+ data->user_name = _account_get_text(user_name);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_set_display_name(account_h account, const char *display_name)
+{
+ if (!account) {
+ ACCOUNT_SLOGE("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!display_name) {
+ ACCOUNT_SLOGE("(%s)-(%d) display_name is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)account;
+
+ _ACCOUNT_FREE(data->display_name);
+ data->display_name = _account_get_text(display_name);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_set_email_address(account_h account, const char *email_address)
+{
+ if (!account) {
+ ACCOUNT_SLOGE("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!email_address) {
+ ACCOUNT_SLOGE("(%s)-(%d) email_address is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)account;
+
+ _ACCOUNT_FREE(data->email_address);
+ data->email_address = _account_get_text(email_address);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_set_icon_path(account_h account, const char *icon_path)
+{
+ if (!account) {
+ ACCOUNT_SLOGE("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!icon_path) {
+ ACCOUNT_SLOGE("(%s)-(%d) icon_path is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)account;
+
+ _ACCOUNT_FREE(data->icon_path);
+ data->icon_path = _account_get_text(icon_path);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_set_source(account_h account, const char *source)
+{
+ if (!account) {
+ ACCOUNT_SLOGE("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!source) {
+ ACCOUNT_SLOGE("(%s)-(%d) source is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+ account_s *data = (account_s*)account;
+
+ _ACCOUNT_FREE(data->source);
+ data->source = _account_get_text(source);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_set_package_name(account_h account, const char *package_name)
+{
+ if (!account) {
+ ACCOUNT_SLOGE("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!package_name) {
+ ACCOUNT_SLOGE("(%s)-(%d) package_name is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)account;
+
+ _ACCOUNT_FREE(data->package_name);
+ data->package_name = _account_get_text(package_name);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_set_domain_name(account_h account, const char *domain_name)
+{
+ if (!account) {
+ ACCOUNT_SLOGE("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!domain_name) {
+ ACCOUNT_SLOGE("(%s)-(%d) domain_name is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+ account_s *data = (account_s*)account;
+
+ _ACCOUNT_FREE(data->domain_name);
+ data->domain_name = _account_get_text(domain_name);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_set_access_token(account_h account, const char *access_token)
+{
+ if (!account) {
+ ACCOUNT_SLOGE("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!access_token) {
+ ACCOUNT_SLOGE("(%s)-(%d) access_token is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)account;
+
+ _ACCOUNT_FREE(data->access_token);
+ data->access_token = _account_get_text(access_token);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_set_user_text(account_h account, int idx, const char *user_txt)
+{
+ if (!account) {
+ ACCOUNT_SLOGE("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!user_txt) {
+ ACCOUNT_SLOGE("(%s)-(%d) user_txt is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+ if (idx >= USER_TXT_CNT || idx < 0) {
+ ACCOUNT_SLOGE("(%s)-(%d) index rage should be between 0-4.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)account;
+
+ _ACCOUNT_FREE(data->user_data_txt[idx]);
+ data->user_data_txt[idx] = _account_get_text(user_txt);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_set_custom(account_h account, const char* key, const char* value)
+{
+ if (!account) {
+ ACCOUNT_SLOGE("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!key) {
+ ACCOUNT_SLOGE("(%s)-(%d) key is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!value) {
+ ACCOUNT_SLOGE("(%s)-(%d) value is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)account;
+
+ GSList *iter;
+ bool b_is_new = TRUE;
+
+ for (iter = data->custom_list; iter != NULL; iter = g_slist_next(iter)) {
+
+ account_custom_s* custom_data = NULL;
+ custom_data = (account_custom_s*)iter->data;
+ ACCOUNT_SLOGD( "account_custom_s->key = %s, account_custom_s->value = %s \n", custom_data->key, custom_data->value);
+
+ if(!strcmp(custom_data->key, key)) {
+ _ACCOUNT_FREE(custom_data->value);
+ custom_data->value = _account_get_text(value);
+ b_is_new = FALSE;
+ }
+ }
+
+ if(b_is_new) {
+ account_custom_s* custom_data = (account_custom_s*)malloc(sizeof(account_custom_s));
+
+ if (custom_data == NULL) {
+ return ACCOUNT_ERROR_OUT_OF_MEMORY;
+ }
+ ACCOUNT_MEMSET(custom_data, 0, sizeof(account_custom_s));
+ custom_data->account_id = data->id;
+ custom_data->app_id = _account_get_text(data->package_name);
+ custom_data->key = _account_get_text(key);
+ custom_data->value = _account_get_text(value);
+ data->custom_list = g_slist_append(data->custom_list, (gpointer)custom_data);
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_set_auth_type(account_h account, const account_auth_type_e auth_type)
+{
+ ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__));
+
+ if ( ((int)auth_type < 0) || (auth_type > ACCOUNT_AUTH_TYPE_MAX) ) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)account;
+
+ data->auth_type = (int)auth_type;
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_set_secret(account_h account, const account_secrecy_state_e secret)
+{
+ ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__));
+
+ if ( ((int)secret < 0) || (secret > ACCOUNT_SECRECY_MAX)) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)account;
+
+ data->secret = (int)secret;
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_set_sync_support(account_h account, const account_sync_state_e sync_support)
+{
+ ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__));
+
+ if ( ((int)sync_support < 0) || (sync_support > ACCOUNT_SYNC_MAX)) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)account;
+
+ data->sync_support= (int)sync_support;
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_set_user_int(account_h account, int idx, const int user_int)
+{
+ if (!account) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (idx >= USER_INT_CNT ||idx < 0) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)account;
+
+ data->user_data_int[idx] = user_int;
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_set_capability(account_h account, const char* capability_type, account_capability_state_e capability_value)
+{
+ ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("account handle is null"));
+ ACCOUNT_RETURN_VAL((capability_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("capability_type is null"));
+
+ if ((capability_value != ACCOUNT_CAPABILITY_DISABLED) && (capability_value != ACCOUNT_CAPABILITY_ENABLED)) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)account;
+
+ GSList *iter = NULL;
+ bool b_is_new = TRUE;
+
+ for(iter = data->capablity_list; iter != NULL; iter = g_slist_next(iter)) {
+ account_capability_s *cap_data = NULL;
+ cap_data = (account_capability_s*)iter->data;
+
+ if(!strcmp(cap_data->type, capability_type)) {
+ cap_data->value = capability_value;
+ b_is_new = FALSE;
+ break;
+ }
+ }
+
+ if(b_is_new) {
+ account_capability_s* cap_data = (account_capability_s*)malloc(sizeof(account_capability_s));
+
+ if (cap_data == NULL)
+ return ACCOUNT_ERROR_OUT_OF_MEMORY;
+ ACCOUNT_MEMSET(cap_data, 0, sizeof(account_capability_s));
+
+ cap_data->type = _account_get_text(capability_type);
+ cap_data->value = capability_value;
+ data->capablity_list = g_slist_append(data->capablity_list, (gpointer)cap_data);
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_get_user_name(account_h account, char **user_name)
+{
+ if (!account) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!user_name) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)account;
+
+ (*user_name) = NULL;
+ *user_name = _account_get_text(data->user_name);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_get_display_name(account_h account, char **display_name)
+{
+ if (!account) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!display_name) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)account;
+
+ (*display_name) = NULL;
+
+ *display_name = _account_get_text(data->display_name);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_get_email_address(account_h account,char **email_address)
+{
+ if (!account) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!email_address) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)account;
+
+ (*email_address) = NULL;
+
+ *email_address = _account_get_text(data->email_address);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_get_icon_path(account_h account, char **icon_path)
+{
+ if (!account) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!icon_path) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)account;
+
+ (*icon_path) = NULL;
+
+ *icon_path = _account_get_text(data->icon_path);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_get_source(account_h account, char **source)
+{
+ if (!account) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!source) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)account;
+
+ (*source) = NULL;
+
+ *source = _account_get_text(data->source);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_get_package_name(account_h account, char **package_name)
+{
+ if (!account) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!package_name) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)account;
+
+ (*package_name) = NULL;
+
+ *package_name = _account_get_text(data->package_name);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_get_domain_name(account_h account, char **domain_name)
+{
+ if (!account) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!domain_name) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)account;
+
+ (*domain_name) = NULL;
+
+ *domain_name = _account_get_text(data->domain_name);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_get_access_token(account_h account, char **access_token)
+{
+ if (!account) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!access_token) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)account;
+
+ (*access_token) = NULL;
+
+ *access_token = _account_get_text(data->access_token);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_get_user_text(account_h account, int user_text_index, char **text)
+{
+ if (!account) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!text) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+ ACCOUNT_RETURN_VAL((user_text_index >=0 && user_text_index < USER_TXT_CNT ), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("INVALID USER TEXT INDEX"));
+
+ account_s *data = (account_s*)account;
+
+ (*text) = NULL;
+
+ *text = _account_get_text(data->user_data_txt[user_text_index]);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_get_auth_type(account_h account, account_auth_type_e *auth_type)
+{
+ if (!account) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+ if (!auth_type) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s* data = (account_s*)account;
+
+ *auth_type = data->auth_type;
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_get_secret(account_h account, account_secrecy_state_e *secret)
+{
+ if (!account) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+ if (!secret) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s* data = (account_s*)account;
+
+ *secret = data->secret;
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_get_sync_support(account_h account, account_sync_state_e *sync_support)
+{
+ if (!account) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+ if (!sync_support) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s* data = (account_s*)account;
+
+ *sync_support = data->sync_support;
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_get_account_id(account_h account, int *account_id)
+{
+ if (!account) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+ if (!account_id) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)account;
+
+ *account_id = data->id;
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_get_user_int(account_h account, int user_int_index, int *integer)
+{
+ if (!account) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ ACCOUNT_RETURN_VAL((user_int_index >=0 && user_int_index < USER_TXT_CNT ), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("INVALID USER TEXT INDEX"));
+
+ if (!integer) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_s *data = (account_s*)account;
+
+ *integer = data->user_data_int[user_int_index];
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_get_capability(account_h account, const char* capability_type, account_capability_state_e* capability_value)
+{
+ ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL"));
+ ACCOUNT_RETURN_VAL((capability_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("capability_type is NULL"));
+ ACCOUNT_RETURN_VAL((capability_value != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("capability_value is NULL"));
+
+ GSList *iter;
+ account_s *data = (account_s*)account;
+
+ for (iter = data->capablity_list; iter != NULL; iter = g_slist_next(iter)) {
+ account_capability_s *cap_data = NULL;
+
+ cap_data = (account_capability_s*)iter->data;
+
+ if(!strcmp(capability_type, cap_data->type)) {
+ *capability_value = cap_data->value;
+ return ACCOUNT_ERROR_NONE;
+ }
+ }
+
+ return ACCOUNT_ERROR_RECORD_NOT_FOUND;
+}
+
+ACCOUNT_API int account_get_capability_all(account_h account, capability_cb callback, void *user_data)
+{
+ ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL"));
+ ACCOUNT_RETURN_VAL((callback != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("NO CALLBACK FUNCTION"));
+
+ GSList *iter;
+ account_s *data = (account_s*)account;
+
+ for (iter = data->capablity_list; iter != NULL; iter = g_slist_next(iter)) {
+ account_capability_s *cap_data = NULL;
+
+ cap_data = (account_capability_s*)iter->data;
+
+ if(callback(cap_data->type, cap_data->value, user_data)!=TRUE){
+ return ACCOUNT_ERROR_NONE;
+ }
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_get_custom(account_h account, const char* key, char** value)
+{
+ ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL"));
+ ACCOUNT_RETURN_VAL((key != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("NO KEY TO REQUEST"));
+ ACCOUNT_RETURN_VAL((value != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("VALUE POINTER IS NULL"));
+
+ GSList *iter;
+ account_s *data = (account_s*)account;
+
+ for (iter = data->custom_list; iter != NULL; iter = g_slist_next(iter)) {
+ account_custom_s *custom_data = NULL;
+
+ custom_data = (account_custom_s*)iter->data;
+
+ if(!strcmp(key, custom_data->key)) {
+ (*value) = NULL;
+ *value = _account_get_text(custom_data->value);
+ return ACCOUNT_ERROR_NONE;
+ }
+ }
+
+ return ACCOUNT_ERROR_RECORD_NOT_FOUND;
+}
+
+ACCOUNT_API int account_get_custom_all(account_h account, account_custom_cb callback, void* user_data)
+{
+ ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL"));
+ ACCOUNT_RETURN_VAL((callback != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("NO CALLBACK FUNCTION"));
+
+ GSList *iter;
+ account_s *data = (account_s*)account;
+
+ for (iter = data->custom_list; iter != NULL; iter = g_slist_next(iter)) {
+ bool cb_ret = FALSE;
+ account_custom_s *custom_data = NULL;
+
+ custom_data = (account_custom_s*)iter->data;
+
+ cb_ret = callback(custom_data->key, custom_data->value, user_data);
+ if(!cb_ret) {
+ break;
+ }
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_query_capability_by_account_id(capability_cb callback, int account_id, void *user_data )
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((account_id > 0), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT INDEX IS LESS THAN 0"));
+ ACCOUNT_RETURN_VAL((callback != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("NO CALLBACK FUNCTION"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE account_id = %d", CAPABILITY_TABLE, account_id);
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ rc = _account_query_step(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
+
+ account_capability_s* capability_record = NULL;
+
+ while (rc == SQLITE_ROW) {
+ bool cb_ret = FALSE;
+ capability_record = (account_capability_s*) malloc(sizeof(account_capability_s));
+
+ if (capability_record == NULL) {
+ ACCOUNT_FATAL("malloc Failed");
+ break;
+ }
+
+ ACCOUNT_MEMSET(capability_record, 0x00, sizeof(account_capability_s));
+
+ _account_convert_column_to_capability(hstmt, capability_record);
+
+ cb_ret = callback(capability_record->type, capability_record->value, user_data);
+
+ _account_free_capability_items(capability_record);
+ _ACCOUNT_FREE(capability_record);
+
+ ACCOUNT_CATCH_ERROR(cb_ret == TRUE, {}, ACCOUNT_ERROR_NONE, ("Callback func returs FALSE, its iteration is stopped!!!!\n"));
+
+ rc = _account_query_step(hstmt);
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ error_code = ACCOUNT_ERROR_NONE;
+
+CATCH:
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+
+ pthread_mutex_unlock(&account_mutex);
+ return error_code;
+}
+
+static int _account_compare_old_record(account_s *new_account, int account_id)
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0;
+ account_s *old_account = NULL;
+
+ ACCOUNT_RETURN_VAL((account_id > 0), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT INDEX IS LESS THAN 0"));
+ ACCOUNT_RETURN_VAL((new_account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT IS NULL"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+
+ old_account = (account_s*)calloc(1, sizeof(account_s));
+ ACCOUNT_RETURN_VAL((old_account != NULL), {}, ACCOUNT_ERROR_OUT_OF_MEMORY,("Memory Allocation Failed"));
+
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE _id = %d", ACCOUNT_TABLE, account_id);
+ hstmt = _account_prepare_query(query);
+
+ rc = _account_query_step(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
+
+ while (rc == SQLITE_ROW) {
+ _account_convert_column_to_account(hstmt, old_account);
+ rc = _account_query_step(hstmt);
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_CATCH_ERROR((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ // get capability
+ error_code = account_query_capability_by_account_id(_account_get_capability_text_cb, old_account->id, (void*)old_account);
+ ACCOUNT_CATCH_ERROR((error_code == ACCOUNT_ERROR_NONE), {}, error_code, ("account_query_capability_by_account_id error"));
+
+ // get custom text
+ error_code = _account_query_custom_by_account_id(_account_get_custom_text_cb, old_account->id, (void*)old_account);
+ ACCOUNT_CATCH_ERROR((error_code == ACCOUNT_ERROR_NONE), {}, error_code, ("_account_query_custom_by_account_id error"));
+
+ // compare
+
+ new_account->id = old_account->id;
+
+ //user name
+ if(!new_account->user_name) {
+ if(old_account->user_name)
+ new_account->user_name = _account_get_text(old_account->user_name);
+ }
+
+ // display name
+ if(!new_account->display_name) {
+ if(old_account->display_name)
+ new_account->display_name = _account_get_text(old_account->display_name);
+ }
+
+ // email address
+ if(!new_account->email_address) {
+ if(old_account->email_address)
+ new_account->email_address = _account_get_text(old_account->email_address);
+ }
+
+ // domain name
+ if(!new_account->domain_name) {
+ if(old_account->domain_name)
+ new_account->domain_name = _account_get_text(old_account->domain_name);
+ }
+
+ // icon path
+ if(!new_account->icon_path) {
+ if(old_account->icon_path)
+ new_account->icon_path = _account_get_text(old_account->icon_path);
+ }
+
+ // source
+ if(!new_account->source) {
+ if(old_account->source)
+ new_account->source = _account_get_text(old_account->source);
+ }
+
+ _ACCOUNT_FREE(new_account->package_name);
+ new_account->package_name = _account_get_text(old_account->package_name);
+
+ // access token
+ if(!new_account->access_token) {
+ if(old_account->access_token)
+ new_account->access_token = _account_get_text(old_account->access_token);
+ }
+
+ // user text
+ int i;
+ for(i=0;i<USER_TXT_CNT;i++) {
+ if(!new_account->user_data_txt[i]) {
+ if(old_account->user_data_txt[i])
+ new_account->user_data_txt[i] = _account_get_text(old_account->user_data_txt[i]);
+ }
+ }
+
+ // auth type
+ if(new_account->auth_type == ACCOUNT_AUTH_TYPE_INVALID) {
+ new_account->auth_type = old_account->auth_type;
+ }
+
+ //secret
+ if(new_account->secret== ACCOUNT_SECRECY_INVALID) {
+ new_account->secret = old_account->secret;
+ }
+
+ // sync support
+ if(new_account->sync_support == ACCOUNT_SYNC_INVALID) {
+ new_account->sync_support = old_account->sync_support;
+ }
+
+ // user int
+ for(i=0;i<USER_INT_CNT;i++) {
+ if(new_account->user_data_int[i] == 0) {
+ new_account->user_data_int[i] = old_account->user_data_int[i];
+ }
+ }
+
+ // capability
+
+ // user custom table
+
+
+
+ CATCH:
+ if (old_account) {
+ _account_free_account_items(old_account);
+ _ACCOUNT_FREE(old_account);
+ }
+
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_get_package_name_from_account_id(int account_id, char **package_name)
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0;
+ account_s *old_account = NULL;
+
+ ACCOUNT_RETURN_VAL((account_id > 0), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT INDEX IS LESS THAN 0"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+
+ old_account = (account_s*)calloc(1, sizeof(account_s));
+ ACCOUNT_RETURN_VAL((old_account != NULL), {}, ACCOUNT_ERROR_OUT_OF_MEMORY,("Memory Allocation Failed"));
+
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE _id = %d", ACCOUNT_TABLE, account_id);
+ hstmt = _account_prepare_query(query);
+
+ rc = _account_query_step(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
+
+ while (rc == SQLITE_ROW) {
+ _account_convert_column_to_account(hstmt, old_account);
+ rc = _account_query_step(hstmt);
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_CATCH_ERROR((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ // get package name.
+ *package_name = _account_get_text(old_account->package_name);
+
+
+ CATCH:
+ if (old_account) {
+ _account_free_account_items(old_account);
+ _ACCOUNT_FREE(old_account);
+ }
+
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+
+ return error_code;
+
+}
+
+static int _account_update_account(account_s *account, int account_id)
+{
+ int rc = 0, binding_count =0;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int error_code = ACCOUNT_ERROR_NONE, count=0, ret_transaction = 0;
+ account_stmt hstmt = NULL;
+
+ if (!account->package_name) {
+ ACCOUNT_ERROR("Package name is mandetory field, it can not be NULL!!!!\n");
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ /* Check permission of requested appid */
+ char* current_appid = NULL;
+ char *package_name = NULL;
+
+ current_appid = _account_get_current_appid();
+ error_code = _account_get_package_name_from_account_id(account_id, &package_name);
+
+ if(error_code != ACCOUNT_ERROR_NONE || package_name == NULL){
+ ACCOUNT_ERROR("No package name with account_id\n");
+ _ACCOUNT_FREE(current_appid);
+ _ACCOUNT_FREE(package_name);
+ return ACCOUNT_ERROR_RECORD_NOT_FOUND;
+ }
+
+ error_code = _account_check_appid_group_with_package_name(current_appid, package_name);
+ ACCOUNT_DEBUG( "UPDATE:account_id[%d],current_appid[%s]package_name[%s]", account_id, current_appid, package_name); // TODO: remove the log later.
+
+ _ACCOUNT_FREE(current_appid);
+ _ACCOUNT_FREE(package_name);
+
+ if(error_code != ACCOUNT_ERROR_NONE){
+ ACCOUNT_ERROR("No permission to update\n");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ _account_compare_old_record(account, account_id);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ } else if( _account_db_err_code() == SQLITE_BUSY ){
+ ACCOUNT_ERROR( "database busy(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_DATABASE_BUSY;
+ }
+
+ if (!account->user_name && !account->display_name && !account->email_address) {
+ ACCOUNT_ERROR("One field should be set among user name, display name, email address\n");
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT COUNT(*) FROM %s WHERE _id = %d ", ACCOUNT_TABLE, account_id);
+
+ count = _account_get_record_count(query);
+ if (count <= 0) {
+ ACCOUNT_DEBUG(" Account record not found, count = %d\n", count);
+ return ACCOUNT_ERROR_RECORD_NOT_FOUND;
+ }
+
+ /* transaction control required*/
+ ret_transaction = _account_begin_transaction();
+ if( ret_transaction == ACCOUNT_ERROR_DATABASE_BUSY ){
+ ACCOUNT_ERROR( "database busy(%s)", _account_db_err_msg());
+ pthread_mutex_unlock(&account_mutex);
+ return ACCOUNT_ERROR_DATABASE_BUSY;
+ }
+
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "UPDATE %s SET user_name=?, email_address =?, display_name =?, "
+ "icon_path =?, source =?, package_name =? , access_token =?, domain_name =?, auth_type =?, secret =?, sync_support =?,"
+ "txt_custom0=?, txt_custom1=?, txt_custom2=?, txt_custom3=?, txt_custom4=?, "
+ "int_custom0=?, int_custom1=?, int_custom2=?, int_custom3=?, int_custom4=? WHERE _id=? ", ACCOUNT_TABLE);
+
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ret_transaction = _account_end_transaction(FALSE);
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ ACCOUNT_RETURN_VAL((hstmt != NULL), {}, ACCOUNT_ERROR_DB_FAILED, ("_account_svc_query_prepare() failed(%s)(%x).\n", _account_db_err_msg(), _account_end_transaction(FALSE)));
+
+ binding_count = _account_convert_account_to_sql(account, hstmt, query);
+ _account_query_bind_int(hstmt, binding_count++, account_id);
+
+ rc = _account_query_step(hstmt);
+ if (rc != SQLITE_DONE) {
+ ACCOUNT_SLOGE( "account_db_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ /*update capability*/
+ error_code = _account_update_capability(account, account_id);
+ if(error_code != ACCOUNT_ERROR_NONE && error_code!= ACCOUNT_ERROR_RECORD_NOT_FOUND){
+ ret_transaction = _account_end_transaction(FALSE);
+ ACCOUNT_ERROR("update capability Failed, trying to roll back(%x) !!!\n", ret_transaction);
+ return error_code;
+ }
+
+ /* update custom */
+ error_code = _account_update_custom(account, account_id);
+ if(error_code != ACCOUNT_ERROR_NONE && error_code!= ACCOUNT_ERROR_RECORD_NOT_FOUND){
+ ret_transaction = _account_end_transaction(FALSE);
+ ACCOUNT_ERROR("update capability Failed, trying to roll back(%x) !!!\n", ret_transaction);
+ return error_code;
+ }
+
+ ret_transaction = _account_end_transaction(TRUE);
+
+ return error_code;
+}
+
+
+static int _account_update_account_ex(account_s *account, int account_id)
+{
+ int rc = 0, binding_count =0;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int error_code = ACCOUNT_ERROR_NONE, count=0, ret_transaction = 0;
+ account_stmt hstmt = NULL;
+
+ if (!account->package_name) {
+ ACCOUNT_ERROR("Package name is mandetory field, it can not be NULL!!!!\n");
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ _account_compare_old_record(account, account_id);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ if (!account->user_name && !account->display_name && !account->email_address) {
+ ACCOUNT_ERROR("One field should be set among user name, display name, email address\n");
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT COUNT(*) FROM %s WHERE _id = %d ", ACCOUNT_TABLE, account_id);
+
+ count = _account_get_record_count(query);
+ if (count <= 0) {
+ ACCOUNT_DEBUG(" Account record not found, count = %d\n", count);
+ return ACCOUNT_ERROR_RECORD_NOT_FOUND;
+ }
+
+ /* transaction control required*/
+ ret_transaction = _account_begin_transaction();
+ if( ret_transaction == ACCOUNT_ERROR_DATABASE_BUSY ){
+ ACCOUNT_ERROR( "database busy(%s)", _account_db_err_msg());
+ pthread_mutex_unlock(&account_mutex);
+ return ACCOUNT_ERROR_DATABASE_BUSY;
+ }
+
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "UPDATE %s SET user_name=?, email_address =?, display_name =?, "
+ "icon_path =?, source =?, package_name =? , access_token =?, domain_name =?, auth_type =?, secret =?, sync_support =?,"
+ "txt_custom0=?, txt_custom1=?, txt_custom2=?, txt_custom3=?, txt_custom4=?, "
+ "int_custom0=?, int_custom1=?, int_custom2=?, int_custom3=?, int_custom4=? WHERE _id=? ", ACCOUNT_TABLE);
+
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ret_transaction = _account_end_transaction(FALSE);
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ ACCOUNT_RETURN_VAL((hstmt != NULL), {}, ACCOUNT_ERROR_DB_FAILED, ("_account_svc_query_prepare() failed(%s)(%x).\n", _account_db_err_msg(), _account_end_transaction(FALSE)));
+
+ binding_count = _account_convert_account_to_sql(account, hstmt, query);
+ _account_query_bind_int(hstmt, binding_count++, account_id);
+
+ rc = _account_query_step(hstmt);
+ if (rc != SQLITE_DONE) {
+ ACCOUNT_SLOGE( "account_db_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ /*update capability*/
+ error_code = _account_update_capability(account, account_id);
+ if(error_code != ACCOUNT_ERROR_NONE && error_code!= ACCOUNT_ERROR_RECORD_NOT_FOUND){
+ ret_transaction = _account_end_transaction(FALSE);
+ ACCOUNT_ERROR("update capability Failed, trying to roll back(%x) !!!\n", ret_transaction);
+ return error_code;
+ }
+
+ /* update custom */
+ error_code = _account_update_custom(account, account_id);
+ if(error_code != ACCOUNT_ERROR_NONE && error_code!= ACCOUNT_ERROR_RECORD_NOT_FOUND){
+ ret_transaction = _account_end_transaction(FALSE);
+ ACCOUNT_ERROR("update capability Failed, trying to roll back(%x) !!!\n", ret_transaction);
+ return error_code;
+ }
+
+ ret_transaction = _account_end_transaction(TRUE);
+
+ return error_code;
+}
+
+
+ACCOUNT_API int account_update_to_db_by_id(const account_h account, int account_id)
+{
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("DATA IS NULL"));
+ ACCOUNT_RETURN_VAL((account_id > 0), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Account id is not valid"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_s* data = (account_s*)account;
+
+ pthread_mutex_lock(&account_mutex);
+
+ error_code = _account_update_account(data, account_id);
+
+ if(error_code != ACCOUNT_ERROR_NONE) {
+ pthread_mutex_unlock(&account_mutex);
+ return error_code;
+ }
+
+ pthread_mutex_unlock(&account_mutex);
+
+ char buf[64]={0,};
+ ACCOUNT_SNPRINTF(buf, sizeof(buf), "%s:%d", ACCOUNT_NOTI_NAME_UPDATE, account_id);
+ _account_insert_delete_update_notification_send(buf);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_update_to_db_by_id_ex(const account_h account, int account_id)
+{
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("DATA IS NULL"));
+ ACCOUNT_RETURN_VAL((account_id > 0), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Account id is not valid"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_s* data = (account_s*)account;
+
+ pthread_mutex_lock(&account_mutex);
+
+ error_code = _account_update_account_ex(data, account_id);
+
+ if(error_code != ACCOUNT_ERROR_NONE) {
+ pthread_mutex_unlock(&account_mutex);
+ return error_code;
+ }
+
+ pthread_mutex_unlock(&account_mutex);
+
+ char buf[64]={0,};
+ ACCOUNT_SNPRINTF(buf, sizeof(buf), "%s:%d", ACCOUNT_NOTI_NAME_UPDATE, account_id);
+ _account_insert_delete_update_notification_send(buf);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+
+ACCOUNT_API int account_update_to_db_by_user_name(account_h account, const char *user_name, const char *package_name)
+{
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("DATA IS NULL"));
+ ACCOUNT_RETURN_VAL((user_name != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("USER NAME IS NULL"));
+ ACCOUNT_RETURN_VAL((package_name != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("PACKAGE NAME IS NULL"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_s *data = (account_s*)account;
+
+ pthread_mutex_lock(&account_mutex);
+
+ error_code = _account_update_account_by_user_name(data, user_name, package_name);
+
+ pthread_mutex_unlock(&account_mutex);
+
+ char buf[64]={0,};
+ ACCOUNT_SNPRINTF(buf, sizeof(buf), "%s:%d", ACCOUNT_NOTI_NAME_UPDATE, data->id);
+ _account_insert_delete_update_notification_send(buf);
+
+ return error_code;
+}
+
+ACCOUNT_API int account_foreach_account_from_db(account_cb callback, void *user_data)
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0;
+ GList *account_list = NULL;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((callback != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT INFO IS NULL"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s ", ACCOUNT_TABLE);
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ rc = _account_query_step(hstmt);
+
+ account_s *account_record = NULL;
+
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
+
+ int k=0;
+ while(rc == SQLITE_ROW) {
+ account_record = (account_s*) malloc(sizeof(account_s));
+
+ if (account_record == NULL) {
+ ACCOUNT_FATAL("malloc Failed");
+ break;
+ }
+
+ ACCOUNT_MEMSET(account_record, 0x00, sizeof(account_s));
+ _account_convert_column_to_account(hstmt, account_record);
+ account_list = g_list_append(account_list, account_record);
+ rc = _account_query_step(hstmt);
+ k++;
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {_account_glist_free(account_list);}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ GList* iter;
+ k = 0;
+ for (iter = account_list; iter != NULL; iter = g_list_next(iter)) {
+ account_s *account = NULL;
+ account = (account_s*)iter->data;
+ account_query_capability_by_account_id(_account_get_capability_text_cb, account->id, (void*)account);
+ _account_query_custom_by_account_id(_account_get_custom_text_cb, account->id, (void*)account);
+ callback((account_h)account, user_data);
+ k++;
+ }
+
+ error_code = ACCOUNT_ERROR_NONE;
+
+CATCH:
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+ if (account_list) {
+ _account_glist_free(account_list);
+ account_list = NULL;
+ }
+
+ return error_code;
+}
+
+ACCOUNT_API int account_update_sync_status_by_id(int account_db_id, const account_sync_state_e sync_status)
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0;
+ int count =1;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((account_db_id > 0), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT INDEX IS LESS THAN 0"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+ if ( ((int)sync_status < 0) || (sync_status > ACCOUNT_SYNC_MAX) ) {
+ ACCOUNT_SLOGE("(%s)-(%d) sync_status is less than 0 or more than enum max.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ pthread_mutex_lock(&account_mutex);
+
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT COUNT(*) from %s where _id=%d", ACCOUNT_TABLE, account_db_id);
+
+ rc = _account_get_record_count(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ pthread_mutex_unlock(&account_mutex);
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ if (rc <= 0) {
+ ACCOUNT_SLOGE( "account_update_sync_status_by_id : related account item is not existed rc=%d , %s", rc, _account_db_err_msg());
+ pthread_mutex_unlock(&account_mutex);
+ return ACCOUNT_ERROR_RECORD_NOT_FOUND;
+ }
+
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "UPDATE %s SET sync_support=? WHERE _id = %d", ACCOUNT_TABLE, account_db_id);
+ hstmt = _account_prepare_query(query);
+
+ _account_query_bind_int(hstmt, count, (int)sync_status);
+
+ rc = _account_query_step(hstmt);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ pthread_mutex_unlock(&account_mutex);
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_DONE, {}, ACCOUNT_ERROR_DB_FAILED,
+ ("account_db_query_step() failed(%d, %s)", rc, _account_db_err_msg()));
+
+ rc = _account_query_finalize(hstmt);
+ if (rc != ACCOUNT_ERROR_NONE) {
+ ACCOUNT_ERROR("_account_query_finalize error");
+ pthread_mutex_unlock(&account_mutex);
+ return rc;
+ }
+ char buf[64]={0,};
+ ACCOUNT_SNPRINTF(buf, sizeof(buf), "%s:%d", ACCOUNT_NOTI_NAME_SYNC_UPDATE, account_db_id);
+ _account_insert_delete_update_notification_send(buf);
+
+ hstmt = NULL;
+ error_code = ACCOUNT_ERROR_NONE;
+
+CATCH:
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ pthread_mutex_unlock(&account_mutex);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+
+ pthread_mutex_unlock(&account_mutex);
+ return error_code;
+}
+
+ACCOUNT_API int account_query_account_by_account_id(int account_db_id, account_h *account)
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((account_db_id > 0), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT INDEX IS LESS THAN 0"));
+ ACCOUNT_RETURN_VAL((*account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT IS NULL"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE _id = %d", ACCOUNT_TABLE, account_db_id);
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ rc = _account_query_step(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
+
+ account_s *account_record = (account_s *)(*account);
+
+ while (rc == SQLITE_ROW) {
+ _account_convert_column_to_account(hstmt, account_record);
+ rc = _account_query_step(hstmt);
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+
+ account_query_capability_by_account_id(_account_get_capability_text_cb, account_record->id, (void*)account_record);
+ _account_query_custom_by_account_id(_account_get_custom_text_cb, account_record->id, (void*)account_record);
+
+ hstmt = NULL;
+ error_code = ACCOUNT_ERROR_NONE;
+
+CATCH:
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+
+ pthread_mutex_unlock(&account_mutex);
+ return error_code;
+}
+
+ACCOUNT_API int account_query_account_by_user_name(account_cb callback, const char *user_name, void *user_data)
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((user_name != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("USER NAME IS NULL"));
+ ACCOUNT_RETURN_VAL((callback != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("CALL BACK IS NULL"));
+
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE user_name = ?", ACCOUNT_TABLE);
+
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ int binding_count = 1;
+ _account_query_bind_text(hstmt, binding_count++, user_name);
+
+ rc = _account_query_step(hstmt);
+
+ account_s *account_head = NULL;
+
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
+
+ int tmp = 0;
+
+ account_head = (account_s*) malloc(sizeof(account_s));
+ if (account_head == NULL) {
+ ACCOUNT_FATAL("malloc Failed");
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+ return ACCOUNT_ERROR_OUT_OF_MEMORY;
+ }
+ ACCOUNT_MEMSET(account_head, 0x00, sizeof(account_s));
+
+ while (rc == SQLITE_ROW) {
+ account_s* account_record = NULL;
+
+ account_record = (account_s*) malloc(sizeof(account_s));
+
+ if (account_record == NULL) {
+ ACCOUNT_FATAL("malloc Failed");
+ break;
+ }
+ ACCOUNT_MEMSET(account_record, 0x00, sizeof(account_s));
+
+ _account_convert_column_to_account(hstmt, account_record);
+
+ account_head->account_list = g_list_append(account_head->account_list, account_record);
+
+ rc = _account_query_step(hstmt);
+ tmp++;
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_CATCH_ERROR((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ GList *iter;
+
+
+ tmp = g_list_length(account_head->account_list);
+
+ for (iter = account_head->account_list; iter != NULL; iter = g_list_next(iter)) {
+ account_h account;
+ account = (account_h)iter->data;
+
+ account_s *testaccount = (account_s*)account;
+
+ account_query_capability_by_account_id(_account_get_capability_text_cb, testaccount->id, (void*)testaccount);
+ _account_query_custom_by_account_id(_account_get_custom_text_cb, testaccount->id, (void*)testaccount);
+
+ ACCOUNT_CATCH_ERROR(callback(account, user_data) == TRUE, {}, ACCOUNT_ERROR_NONE, ("callback returns false, it is stopped.\n"));
+ }
+
+ error_code = ACCOUNT_ERROR_NONE;
+
+CATCH:
+ if (account_head) {
+ if (account_head->account_list) {
+ _account_glist_free(account_head->account_list);
+ account_head->account_list = NULL;
+ _account_free_account_items(account_head);
+ }
+ _ACCOUNT_FREE(account_head);
+ }
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+
+ pthread_mutex_unlock(&account_mutex);
+ return error_code;
+}
+
+ACCOUNT_API int account_query_account_by_capability(account_cb callback, const char* capability_type, account_capability_state_e capability_value, void* user_data)
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((capability_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("capability_type IS NULL"));
+
+ if (((int)capability_value < 0) || (capability_value > ACCOUNT_CAPABILITY_STATE_MAX)) {
+ ACCOUNT_SLOGE("(%s)-(%d) capability_value is not equal to 0 or 1.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ ACCOUNT_RETURN_VAL((callback != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("CALL BACK IS NULL"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE _id IN (SELECT account_id from %s WHERE key=? AND value=?)", ACCOUNT_TABLE, CAPABILITY_TABLE);
+
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ int binding_count = 1;
+ _account_query_bind_text(hstmt, binding_count++, capability_type);
+ _account_query_bind_int(hstmt, binding_count++, (int)capability_value);
+
+ rc = _account_query_step(hstmt);
+
+ account_s* account_head = NULL;
+
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
+
+ int tmp = 0;
+
+ account_head = (account_s*) malloc(sizeof(account_s));
+ if (account_head == NULL) {
+ ACCOUNT_FATAL("malloc Failed");
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+ return ACCOUNT_ERROR_OUT_OF_MEMORY;
+ }
+ ACCOUNT_MEMSET(account_head, 0x00, sizeof(account_s));
+
+ while (rc == SQLITE_ROW) {
+ account_s* account_record = NULL;
+
+ account_record = (account_s*) malloc(sizeof(account_s));
+
+ if (account_record == NULL) {
+ ACCOUNT_FATAL("malloc Failed");
+ break;
+ }
+ ACCOUNT_MEMSET(account_record, 0x00, sizeof(account_s));
+
+ _account_convert_column_to_account(hstmt, account_record);
+
+ account_head->account_list = g_list_append(account_head->account_list, account_record);
+
+ rc = _account_query_step(hstmt);
+ tmp++;
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_CATCH_ERROR((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ GList *iter;
+
+
+ tmp = g_list_length(account_head->account_list);
+
+ for (iter = account_head->account_list; iter != NULL; iter = g_list_next(iter)) {
+ account_h account = NULL;
+ account = (account_h)iter->data;
+ account_s* testaccount = (account_s*)account;
+
+ account_query_capability_by_account_id(_account_get_capability_text_cb, testaccount->id, (void*)testaccount);
+ _account_query_custom_by_account_id(_account_get_custom_text_cb, testaccount->id, (void*)testaccount);
+
+ ACCOUNT_CATCH_ERROR(callback(account, user_data) == TRUE, {}, ACCOUNT_ERROR_NONE, ("callback returns false, it is stopped.\n"));
+ }
+
+
+ error_code = ACCOUNT_ERROR_NONE;
+
+CATCH:
+ if (account_head) {
+ if (account_head->account_list) {
+ _account_glist_free(account_head->account_list);
+ account_head->account_list = NULL;
+ _account_free_account_items(account_head);
+ }
+ _ACCOUNT_FREE(account_head);
+ }
+
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+
+ pthread_mutex_unlock(&account_mutex);
+ return error_code;
+}
+
+ACCOUNT_API int account_query_account_by_capability_type(account_cb callback, const char* capability_type, void* user_data)
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((capability_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("capability_type IS NULL"));
+ ACCOUNT_RETURN_VAL((callback != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("CALL BACK IS NULL"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE _id IN (SELECT account_id from %s WHERE key=?)", ACCOUNT_TABLE, CAPABILITY_TABLE);
+
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ int binding_count = 1;
+ _account_query_bind_text(hstmt, binding_count++, capability_type);
+
+ rc = _account_query_step(hstmt);
+
+ account_s* account_head = NULL;
+
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
+
+ int tmp = 0;
+
+ account_head = (account_s*) malloc(sizeof(account_s));
+ if (account_head == NULL) {
+ ACCOUNT_FATAL("malloc Failed");
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+ return ACCOUNT_ERROR_OUT_OF_MEMORY;
+ }
+ ACCOUNT_MEMSET(account_head, 0x00, sizeof(account_s));
+
+ while (rc == SQLITE_ROW) {
+ account_s* account_record = NULL;
+
+ account_record = (account_s*) malloc(sizeof(account_s));
+
+ if (account_record == NULL) {
+ ACCOUNT_FATAL("malloc Failed");
+ break;
+ }
+ ACCOUNT_MEMSET(account_record, 0x00, sizeof(account_s));
+
+ _account_convert_column_to_account(hstmt, account_record);
+
+ account_head->account_list = g_list_append(account_head->account_list, account_record);
+
+ rc = _account_query_step(hstmt);
+ tmp++;
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_CATCH_ERROR((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ GList *iter;
+
+
+ tmp = g_list_length(account_head->account_list);
+
+ for (iter = account_head->account_list; iter != NULL; iter = g_list_next(iter)) {
+ account_h account = NULL;
+ account = (account_h)iter->data;
+ account_s* testaccount = (account_s*)account;
+
+ account_query_capability_by_account_id(_account_get_capability_text_cb, testaccount->id, (void*)testaccount);
+ _account_query_custom_by_account_id(_account_get_custom_text_cb, testaccount->id, (void*)testaccount);
+
+ ACCOUNT_CATCH_ERROR(callback(account, user_data) == TRUE, {}, ACCOUNT_ERROR_NONE, ("The record isn't found.\n"));
+
+ }
+
+ error_code = ACCOUNT_ERROR_NONE;
+
+CATCH:
+ if (account_head) {
+ if (account_head->account_list) {
+ _account_glist_free(account_head->account_list);
+ account_head->account_list = NULL;
+ _account_free_account_items(account_head);
+ }
+ _ACCOUNT_FREE(account_head);
+ }
+
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+
+ pthread_mutex_unlock(&account_mutex);
+ return error_code;
+}
+
+ACCOUNT_API int account_query_account_by_package_name(account_cb callback, const char* package_name, void* user_data)
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((package_name != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("PACKAGE NAME IS NULL"));
+ ACCOUNT_RETURN_VAL((callback != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("CALL BACK IS NULL"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE package_name=?", ACCOUNT_TABLE);
+
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ int binding_count = 1;
+ _account_query_bind_text(hstmt, binding_count++, package_name);
+
+ rc = _account_query_step(hstmt);
+
+ account_s* account_head = NULL;
+
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.(%s)\n", package_name));
+
+ int tmp = 0;
+
+ account_head = (account_s*) malloc(sizeof(account_s));
+ if (account_head == NULL) {
+ ACCOUNT_FATAL("malloc Failed");
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+ return ACCOUNT_ERROR_OUT_OF_MEMORY;
+ }
+ ACCOUNT_MEMSET(account_head, 0x00, sizeof(account_s));
+
+ while (rc == SQLITE_ROW) {
+ account_s* account_record = NULL;
+
+ account_record = (account_s*) malloc(sizeof(account_s));
+
+ if (account_record == NULL) {
+ ACCOUNT_FATAL("malloc Failed");
+ break;
+ }
+ ACCOUNT_MEMSET(account_record, 0x00, sizeof(account_s));
+
+ _account_convert_column_to_account(hstmt, account_record);
+
+ account_head->account_list = g_list_append(account_head->account_list, account_record);
+
+ rc = _account_query_step(hstmt);
+ tmp++;
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_CATCH_ERROR((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ GList *iter;
+
+ tmp = g_list_length(account_head->account_list);
+
+ for (iter = account_head->account_list; iter != NULL; iter = g_list_next(iter)) {
+ account_h account = NULL;
+ account = (account_h)iter->data;
+
+ account_s* testaccount = (account_s*)account;
+
+ account_query_capability_by_account_id(_account_get_capability_text_cb, testaccount->id, (void*)testaccount);
+ _account_query_custom_by_account_id(_account_get_custom_text_cb, testaccount->id, (void*)testaccount);
+
+ ACCOUNT_CATCH_ERROR(callback(account, user_data) == TRUE, {}, ACCOUNT_ERROR_NONE, ("The record isn't found.\n"));
+
+ }
+
+ error_code = ACCOUNT_ERROR_NONE;
+
+CATCH:
+ if (account_head) {
+ if (account_head->account_list) {
+ _account_glist_free(account_head->account_list);
+ account_head->account_list = NULL;
+ _account_free_account_items(account_head);
+ }
+ _ACCOUNT_FREE(account_head);
+ }
+
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+
+ pthread_mutex_unlock(&account_mutex);
+ return error_code;
+}
+
+ACCOUNT_API int account_delete(int account_id)
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0;
+ int ret_transaction = 0;
+ bool is_success = FALSE;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+
+ int count = -1;
+ /* Check requested ID to delete */
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT COUNT(*) FROM %s WHERE _id=%d", ACCOUNT_TABLE, account_id);
+
+ count = _account_get_record_count(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ pthread_mutex_unlock(&account_mutex);
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ if (count <= 0) {
+ ACCOUNT_ERROR("account id(%d) is not exist. count(%d)\n", account_id, count);
+ return ACCOUNT_ERROR_RECORD_NOT_FOUND;
+ }
+
+ /* Check permission of requested appid */
+ char* current_appid = NULL;
+ char *package_name = NULL;
+
+ current_appid = _account_get_current_appid();
+
+ error_code = _account_get_package_name_from_account_id(account_id, &package_name);
+
+ if(error_code != ACCOUNT_ERROR_NONE){
+ ACCOUNT_ERROR("No package name with account_id\n");
+ _ACCOUNT_FREE(current_appid);
+ _ACCOUNT_FREE(package_name);
+ return ACCOUNT_ERROR_RECORD_NOT_FOUND;
+ }
+ ACCOUNT_DEBUG( "DELETE:account_id[%d],current_appid[%s]package_name[%s]", account_id, current_appid, package_name);
+
+ error_code = _account_check_appid_group_with_package_name(current_appid, package_name);
+
+ _ACCOUNT_FREE(current_appid);
+ _ACCOUNT_FREE(package_name);
+
+ if(error_code != ACCOUNT_ERROR_NONE){
+ ACCOUNT_ERROR("No permission to delete\n");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ /* transaction control required*/
+ ret_transaction = _account_begin_transaction();
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ pthread_mutex_unlock(&account_mutex);
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ if( ret_transaction == ACCOUNT_ERROR_DATABASE_BUSY ){
+ ACCOUNT_ERROR( "database busy(%s)", _account_db_err_msg());
+ pthread_mutex_unlock(&account_mutex);
+ return ACCOUNT_ERROR_DATABASE_BUSY;
+ }
+
+ if (ret_transaction != ACCOUNT_ERROR_NONE) {
+ ACCOUNT_ERROR("account_delete:_account_begin_transaction fail %d\n", ret_transaction);
+ pthread_mutex_unlock(&account_mutex);
+ return ret_transaction;
+ }
+
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s WHERE account_id = %d", CAPABILITY_TABLE, account_id);
+
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ pthread_mutex_unlock(&account_mutex);
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ ACCOUNT_CATCH_ERROR(hstmt != NULL, {}, ACCOUNT_ERROR_DB_FAILED,
+ ("_account_svc_query_prepare(%s) failed(%s).\n", query, _account_db_err_msg()));
+
+ rc = _account_query_step(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_DONE, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
+
+ rc = _account_query_finalize(hstmt);
+
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ ACCOUNT_MEMSET(query, 0, sizeof(query));
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s WHERE _id = %d", ACCOUNT_TABLE, account_id);
+
+ hstmt = _account_prepare_query(query);
+ ACCOUNT_CATCH_ERROR(hstmt != NULL, {}, ACCOUNT_ERROR_DB_FAILED,
+ ("_account_svc_query_prepare(%s) failed(%s).\n", query, _account_db_err_msg()));
+
+ rc = _account_query_step(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_DONE, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found. id=%d, rc=%d\n", account_id, rc));
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ /* delete custom data */
+ ACCOUNT_MEMSET(query, 0, sizeof(query));
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s WHERE AccountId = %d", ACCOUNT_CUSTOM_TABLE, account_id);
+
+ hstmt = _account_prepare_query(query);
+
+ ACCOUNT_CATCH_ERROR(hstmt != NULL, {}, ACCOUNT_ERROR_DB_FAILED,
+ ("_account_svc_query_prepare(%s) failed(%s).\n", query, _account_db_err_msg()));
+
+ rc = _account_query_step(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_DONE, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found. id=%d, rc=%d\n", account_id, rc));
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == ACCOUNT_ERROR_NONE, {}, rc, ("finalize error", account_id, rc));
+ hstmt = NULL;
+
+ is_success = TRUE;
+
+CATCH:
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ if(rc != ACCOUNT_ERROR_NONE ){
+ ACCOUNT_ERROR("rc (%d)", rc);
+ is_success = FALSE;
+ }
+
+ hstmt = NULL;
+ }
+
+ ret_transaction = _account_end_transaction(is_success);
+
+ if (ret_transaction != ACCOUNT_ERROR_NONE) {
+ ACCOUNT_ERROR("account_delete:_account_end_transaction fail %d, is_success=%d\n", ret_transaction, is_success);
+ } else {
+ if (is_success == true) {
+ char buf[64]={0,};
+ ACCOUNT_SNPRINTF(buf, sizeof(buf), "%s:%d", ACCOUNT_NOTI_NAME_DELETE, account_id);
+ _account_insert_delete_update_notification_send(buf);
+ }
+ }
+
+ pthread_mutex_unlock(&account_mutex);
+
+ return error_code;
+
+}
+
+ACCOUNT_API int account_delete_from_db_by_id(int account_db_id)
+{
+ ACCOUNT_RETURN_VAL((account_db_id > 0), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT ID IS LESS THAN ZERO."));
+
+ return account_delete(account_db_id);
+}
+
+static int _account_query_account_by_username_and_package(const char* username, const char* package_name, account_h *account)
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0;
+ int binding_count = 1;
+
+ ACCOUNT_RETURN_VAL((username != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("username IS NULL"));
+ ACCOUNT_RETURN_VAL((package_name != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("package_name IS NULL"));
+ ACCOUNT_RETURN_VAL((*account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT IS NULL"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE user_name = ? and package_name = ?", ACCOUNT_TABLE);
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ _account_query_bind_text(hstmt, binding_count++, username);
+ _account_query_bind_text(hstmt, binding_count++, package_name);
+
+ rc = _account_query_step(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
+
+ account_s *account_record = (account_s *)(*account);
+
+ while (rc == SQLITE_ROW) {
+ _account_convert_column_to_account(hstmt, account_record);
+ rc = _account_query_step(hstmt);
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ account_query_capability_by_account_id(_account_get_capability_text_cb, account_record->id, (void*)account_record);
+ _account_query_custom_by_account_id(_account_get_custom_text_cb, account_record->id, (void*)account_record);
+
+ hstmt = NULL;
+ error_code = ACCOUNT_ERROR_NONE;
+
+CATCH:
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+
+ pthread_mutex_unlock(&account_mutex);
+ return error_code;
+}
+
+ACCOUNT_API int account_delete_from_db_by_user_name(char *user_name, char *package_name)
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0;
+ int ret_transaction = 0;
+ bool is_success = FALSE;
+ account_h account = NULL;
+ int binding_count = 1;
+ int account_id = -1;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((user_name != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("user_name is null!"));
+ ACCOUNT_RETURN_VAL((package_name != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("package_name is null!"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+
+ rc = account_create(&account);
+ rc = _account_query_account_by_username_and_package(user_name, package_name, &account);
+
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ account_destroy(account);
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ rc = account_get_account_id(account, &account_id);
+
+ rc = account_destroy(account);
+
+ /* transaction control required*/
+ ret_transaction = _account_begin_transaction();
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ pthread_mutex_unlock(&account_mutex);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ if( ret_transaction == ACCOUNT_ERROR_DATABASE_BUSY ){
+ ACCOUNT_ERROR( "database busy(%s)", _account_db_err_msg());
+ pthread_mutex_unlock(&account_mutex);
+ return ACCOUNT_ERROR_DATABASE_BUSY;
+ }else if (ret_transaction != ACCOUNT_ERROR_NONE) {
+ ACCOUNT_ERROR("account_delete:_account_begin_transaction fail %d\n", ret_transaction);
+ pthread_mutex_unlock(&account_mutex);
+ return ret_transaction;
+ }
+
+ /* delete custom data */
+ ACCOUNT_MEMSET(query, 0, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s WHERE AccountId = ?", ACCOUNT_CUSTOM_TABLE);
+
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ _account_end_transaction(FALSE);
+ pthread_mutex_unlock(&account_mutex);
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ ACCOUNT_CATCH_ERROR(hstmt != NULL, {}, ACCOUNT_ERROR_DB_FAILED,
+ ("_account_svc_query_prepare(%s) failed(%s).\n", query, _account_db_err_msg()));
+
+ _account_query_bind_int(hstmt, binding_count++, account_id);
+
+ rc = _account_query_step(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_DONE, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ /* delete capability */
+ ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s WHERE user_name = ? and package_name = ?", CAPABILITY_TABLE);
+
+ hstmt = _account_prepare_query(query);
+
+ ACCOUNT_CATCH_ERROR(hstmt != NULL, {}, ACCOUNT_ERROR_DB_FAILED,
+ ("_account_svc_query_prepare(%s) failed(%s).\n", query, _account_db_err_msg()));
+
+ binding_count = 1;
+ _account_query_bind_text(hstmt, binding_count++, user_name);
+ _account_query_bind_text(hstmt, binding_count++, package_name);
+
+ rc = _account_query_step(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_DONE, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ ACCOUNT_MEMSET(query, 0, sizeof(query));
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s WHERE user_name = ? and package_name = ?", ACCOUNT_TABLE);
+
+ hstmt = _account_prepare_query(query);
+ ACCOUNT_CATCH_ERROR(hstmt != NULL, {}, ACCOUNT_ERROR_DB_FAILED,
+ ("_account_svc_query_prepare(%s) failed(%s).\n", query, _account_db_err_msg()));
+
+ binding_count = 1;
+ _account_query_bind_text(hstmt, binding_count++, user_name);
+ _account_query_bind_text(hstmt, binding_count++, package_name);
+
+ rc = _account_query_step(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_DONE, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found. user_name=%s, package_name=%s, rc=%d\n", user_name, package_name, rc));
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ is_success = TRUE;
+
+ hstmt = NULL;
+
+CATCH:
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+
+ ret_transaction = _account_end_transaction(is_success);
+
+ if (ret_transaction != ACCOUNT_ERROR_NONE) {
+ ACCOUNT_ERROR("account_svc_delete:_account_svc_end_transaction fail %d, is_success=%d\n", ret_transaction, is_success);
+ } else {
+ if (is_success == true) {
+ char buf[64]={0,};
+ ACCOUNT_SNPRINTF(buf, sizeof(buf), "%s:%d", ACCOUNT_NOTI_NAME_DELETE, account_id);
+ _account_insert_delete_update_notification_send(buf);
+ }
+ }
+
+ pthread_mutex_unlock(&account_mutex);
+
+ return error_code;
+}
+
+static bool _account_delete_from_db_by_package_name_cb(account_h account, void *user_data)
+{
+ GSList **account_id_list = (GSList**)user_data;
+ int account_id = 0;
+ char id_buf[10] ={0,};
+ char* tmp_ptr = NULL;
+
+ account_get_account_id(account, &account_id);
+ ACCOUNT_SNPRINTF(id_buf, sizeof(id_buf), "%d", account_id);
+
+ tmp_ptr = strdup(id_buf);
+
+ ACCOUNT_SLOGD("id = %s", id_buf);
+
+ *account_id_list = g_slist_append(*account_id_list, tmp_ptr);
+
+ return TRUE;
+}
+
+ACCOUNT_API int account_delete_from_db_by_package_name(const char *package_name)
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0;
+ int ret_transaction = 0;
+ bool is_success = FALSE;
+ int binding_count = 1;
+ GSList *account_id_list = NULL;
+ int ret = -1;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((package_name != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("package_name is null!"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+
+ ret = account_query_account_by_package_name(_account_delete_from_db_by_package_name_cb, package_name, (void*)&account_id_list);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ if(ret != ACCOUNT_ERROR_NONE){
+ return ret;
+ }
+
+ /* transaction control required*/
+ ret_transaction = _account_begin_transaction();
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ pthread_mutex_unlock(&account_mutex);
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ if( ret_transaction == ACCOUNT_ERROR_DATABASE_BUSY ){
+ ACCOUNT_ERROR( "database busy(%s)", _account_db_err_msg());
+ pthread_mutex_unlock(&account_mutex);
+ return ACCOUNT_ERROR_DATABASE_BUSY;
+ }else if (ret_transaction != ACCOUNT_ERROR_NONE) {
+ ACCOUNT_ERROR("account_delete:_account_begin_transaction fail %d\n", ret_transaction);
+ pthread_mutex_unlock(&account_mutex);
+ return ret_transaction;
+ }
+
+ /* delete custom table */
+ ACCOUNT_MEMSET(query, 0, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s WHERE AppId = ?", ACCOUNT_CUSTOM_TABLE);
+
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ _account_end_transaction(FALSE);
+ pthread_mutex_unlock(&account_mutex);
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ ACCOUNT_CATCH_ERROR(hstmt != NULL, {}, ACCOUNT_ERROR_DB_FAILED,
+ ("_account_svc_query_prepare(%s) failed(%s).\n", query, _account_db_err_msg()));
+
+ binding_count = 1;
+ _account_query_bind_text(hstmt, binding_count++, package_name);
+
+ rc = _account_query_step(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_DONE, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ /* delete capability table */
+ ACCOUNT_MEMSET(query, 0, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s WHERE package_name = ?", CAPABILITY_TABLE);
+
+ hstmt = _account_prepare_query(query);
+
+ ACCOUNT_CATCH_ERROR(hstmt != NULL, {}, ACCOUNT_ERROR_DB_FAILED,
+ ("_account_svc_query_prepare(%s) failed(%s).\n", query, _account_db_err_msg()));
+
+ binding_count = 1;
+ _account_query_bind_text(hstmt, binding_count++, package_name);
+
+ rc = _account_query_step(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_DONE, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ /* delete account table */
+ ACCOUNT_MEMSET(query, 0, sizeof(query));
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s WHERE package_name = ?", ACCOUNT_TABLE);
+
+ hstmt = _account_prepare_query(query);
+ ACCOUNT_CATCH_ERROR(hstmt != NULL, {}, ACCOUNT_ERROR_DB_FAILED,
+ ("_account_svc_query_prepare(%s) failed(%s).\n", query, _account_db_err_msg()));
+
+ binding_count = 1;
+ _account_query_bind_text(hstmt, binding_count++, package_name);
+
+ rc = _account_query_step(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_DONE, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found. package_name=%s, rc=%d\n", package_name, rc));
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ is_success = TRUE;
+
+ hstmt = NULL;
+
+CATCH:
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+
+ ret_transaction = _account_end_transaction(is_success);
+
+ if (ret_transaction != ACCOUNT_ERROR_NONE) {
+ ACCOUNT_ERROR("account_delete:_account_end_transaction fail %d, is_success=%d\n", ret_transaction, is_success);
+ } else {
+ if (is_success == true) {
+ GSList* iter;
+ for (iter = account_id_list; iter != NULL; iter = g_slist_next(iter)) {
+ char* p_tmpid = NULL;
+ p_tmpid = (char*)iter->data;
+ char buf[64]={0,};
+ ACCOUNT_SNPRINTF(buf, sizeof(buf), "%s:%s", ACCOUNT_NOTI_NAME_DELETE, p_tmpid);
+ ACCOUNT_SLOGD("%s", buf);
+ _account_insert_delete_update_notification_send(buf);
+ _ACCOUNT_FREE(p_tmpid);
+ }
+ g_slist_free(account_id_list);
+ }
+ }
+
+ pthread_mutex_unlock(&account_mutex);
+
+ return error_code;
+}
+
+ACCOUNT_API int account_get_total_count_from_db(int *count)
+{
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ if (!count) {
+ ACCOUNT_SLOGE("(%s)-(%d) count is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if(!g_hAccountDB){
+ ACCOUNT_ERROR("DB is not opened\n");
+ return ACCOUNT_ERROR_DB_NOT_OPENED;
+ }
+
+ char query[1024] = {0, };
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "select count(*) from %s", ACCOUNT_TABLE);
+
+ *count = _account_get_record_count(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ pthread_mutex_unlock(&account_mutex);
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ int rc = -1;
+ int ncount = 0;
+ account_stmt pStmt = NULL;
+
+ rc = sqlite3_prepare_v2(g_hAccountDB, query, strlen(query), &pStmt, NULL);
+ if (SQLITE_OK != rc) {
+ ACCOUNT_SLOGE("sqlite3_prepare_v2() failed(%d, %s).", rc, _account_db_err_msg());
+ sqlite3_finalize(pStmt);
+ return ACCOUNT_ERROR_DB_FAILED;
+ }
+
+ rc = sqlite3_step(pStmt);
+ if (SQLITE_ROW != rc) {
+ ACCOUNT_ERROR("[ERROR] sqlite3_step() failed\n");
+ sqlite3_finalize(pStmt);
+ return ACCOUNT_ERROR_RECORD_NOT_FOUND;
+ }
+
+ ncount = sqlite3_column_int(pStmt, 0);
+
+ *count = ncount;
+
+ sqlite3_finalize(pStmt);
+
+ if (ncount < 0) {
+ ACCOUNT_ERROR("[ERROR] Number of account : %d, End", ncount);
+ return ACCOUNT_ERROR_DB_FAILED;
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_destroy(account_h account)
+{
+ account_s *data = (account_s*)account;
+
+ ACCOUNT_RETURN_VAL((data != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Account handle is null!"));
+
+ _account_free_account_items(data);
+ _ACCOUNT_FREE(data);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_type_free_label_items(label_s *data)
+{
+ _ACCOUNT_FREE(data->app_id);
+ _ACCOUNT_FREE(data->label);
+ _ACCOUNT_FREE(data->locale);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_type_free_feature_items(provider_feature_s *data)
+{
+ _ACCOUNT_FREE(data->app_id);
+ _ACCOUNT_FREE(data->key);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_type_gslist_free(GSList* list)
+{
+ ACCOUNT_RETURN_VAL((list != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("GSlist is NULL"));
+
+ GSList* iter;
+
+ for (iter = list; iter != NULL; iter = g_slist_next(iter)) {
+ label_s *label_data = (label_s*)iter->data;
+ _account_type_free_label_items(label_data);
+ _ACCOUNT_FREE(label_data);
+ }
+
+ g_slist_free(list);
+ list = NULL;
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_type_item_free(account_type_s *data)
+{
+ _ACCOUNT_FREE(data->app_id);
+ _ACCOUNT_FREE(data->service_provider_id);
+ _ACCOUNT_FREE(data->icon_path);
+ _ACCOUNT_FREE(data->small_icon_path);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_type_glist_free(GList* list)
+{
+ ACCOUNT_RETURN_VAL((list != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Glist is NULL"));
+
+ GList* iter;
+
+ for (iter = list; iter != NULL; iter = g_list_next(iter)) {
+ account_type_s *account_type_record = (account_type_s*)iter->data;
+ _account_type_item_free(account_type_record);
+ _ACCOUNT_FREE(account_type_record);
+ }
+
+ g_list_free(list);
+ list = NULL;
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_type_free_account_type_items(account_type_s *data)
+{
+ _account_type_item_free(data);
+
+ _account_type_gslist_free(data->label_list);
+ _account_type_glist_free(data->account_type_list);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_type_create(account_type_h *account_type)
+{
+ if (!account_type) {
+ ACCOUNT_SLOGE("(%s)-(%d) account type handle is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_type_s *data = (account_type_s*)malloc(sizeof(account_type_s));
+
+ if (data == NULL) {
+ ACCOUNT_ERROR("Memory Allocation Failed");
+ return ACCOUNT_ERROR_OUT_OF_MEMORY;
+ }
+
+ ACCOUNT_MEMSET(data, 0, sizeof(account_type_s));
+
+ *account_type = (account_type_h)data;
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_type_destroy(account_type_h account_type)
+{
+ account_type_s *data = (account_type_s*)account_type;
+
+ ACCOUNT_RETURN_VAL((data != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Account type handle is null!"));
+
+ _account_type_free_account_type_items(data);
+ _ACCOUNT_FREE(data);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+//app_id mandatory field
+ACCOUNT_API int account_type_set_app_id(account_type_h account_type, const char *app_id)
+{
+ if (!account_type) {
+ ACCOUNT_SLOGE("(%s)-(%d) account_type handle is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!app_id) {
+ ACCOUNT_SLOGE("(%s)-(%d) app_id is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_type_s *data = (account_type_s*)account_type;
+
+ _ACCOUNT_FREE(data->app_id);
+ data->app_id = _account_get_text(app_id);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+//service_provider_id mandatory field
+ACCOUNT_API int account_type_set_service_provider_id(account_type_h account_type, const char *service_provider_id)
+{
+ if (!account_type) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!service_provider_id) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_type_s *data = (account_type_s*)account_type;
+
+ _ACCOUNT_FREE(data->service_provider_id);
+ data->service_provider_id = _account_get_text(service_provider_id);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_type_set_icon_path(account_type_h account_type, const char *icon_path)
+{
+ if (!account_type) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!icon_path) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_type_s *data = (account_type_s*)account_type;
+
+ _ACCOUNT_FREE(data->icon_path);
+ data->icon_path = _account_get_text(icon_path);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_type_set_small_icon_path(account_type_h account_type, const char *small_icon_path)
+{
+ if (!account_type) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!small_icon_path) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_type_s *data = (account_type_s*)account_type;
+
+ _ACCOUNT_FREE(data->small_icon_path);
+ data->small_icon_path = _account_get_text(small_icon_path);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_type_set_multiple_account_support(account_type_h account_type, const bool multiple_account_support)
+{
+ ACCOUNT_RETURN_VAL((account_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__));
+
+ account_type_s *data = (account_type_s*)account_type;
+
+ data->multiple_account_support = multiple_account_support;
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+// unset?
+ACCOUNT_API int account_type_set_label(account_type_h account_type, const char* label, const char* locale)
+{
+ if (!account_type) {
+ ACCOUNT_SLOGE("(%s)-(%d) account_type handle is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if(!label || !locale) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_type_s *data = (account_type_s*)account_type;
+ label_s *label_data = (label_s*)malloc(sizeof(label_s));
+
+ if (label_data == NULL) {
+ return ACCOUNT_ERROR_OUT_OF_MEMORY;
+ }
+ ACCOUNT_MEMSET(label_data, 0, sizeof(label_s));
+
+ label_data->label = _account_get_text(label);
+ label_data->locale = _account_get_text(locale);
+
+ data->label_list = g_slist_append(data->label_list, (gpointer)label_data);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_type_get_app_id(account_type_h account_type, char **app_id)
+{
+ if (!account_type) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!app_id) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_type_s *data = (account_type_s*)account_type;
+
+ (*app_id) = NULL;
+ *app_id = _account_get_text(data->app_id);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_type_get_service_provider_id(account_type_h account_type, char **service_provider_id)
+{
+ if (!account_type) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!service_provider_id) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_type_s *data = (account_type_s*)account_type;
+
+ (*service_provider_id) = NULL;
+ *service_provider_id = _account_get_text(data->service_provider_id);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_type_get_icon_path(account_type_h account_type, char **icon_path)
+{
+ if (!account_type) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!icon_path) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_type_s *data = (account_type_s*)account_type;
+
+ (*icon_path) = NULL;
+ *icon_path = _account_get_text(data->icon_path);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_type_get_small_icon_path(account_type_h account_type, char **small_icon_path)
+{
+ if (!account_type) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!small_icon_path) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_type_s *data = (account_type_s*)account_type;
+
+ (*small_icon_path) = NULL;
+ *small_icon_path = _account_get_text(data->small_icon_path);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_type_get_multiple_account_support(account_type_h account_type, int *multiple_account_support)
+{
+ if (!account_type) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+ if (!multiple_account_support) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_type_s *data = (account_type_s*)account_type;
+
+ *multiple_account_support = data->multiple_account_support;
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_type_get_label_by_locale(account_type_h account_type, const char* locale, char** label)
+{
+ ACCOUNT_RETURN_VAL((account_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL"));
+ ACCOUNT_RETURN_VAL((label != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("INVALID PARAMETER"));
+
+ GSList *iter;
+ account_type_s *data = (account_type_s*)account_type;
+
+ for (iter = data->label_list; iter != NULL; iter = g_slist_next(iter)) {
+ label_s *label_data = NULL;
+
+ label_data = (label_s*)iter->data;
+
+ *label = NULL;
+
+ if(!strcmp(locale, label_data->locale)) {
+ *label = _account_get_text(label_data->label);
+ return ACCOUNT_ERROR_NONE;
+ }
+ gchar** tokens = g_strsplit(locale, "-", 2);
+ if(tokens != NULL) {
+ if((char*)(tokens[1]) != NULL) {
+ char* upper_token = g_ascii_strup(tokens[1], strlen(tokens[1]));
+ if(upper_token != NULL) {
+ char* converted_locale = g_strdup_printf("%s_%s", tokens[0], upper_token);
+ if(!strcmp(converted_locale, label_data->locale)) {
+ _ACCOUNT_FREE(converted_locale);
+ _ACCOUNT_FREE(upper_token);
+ g_strfreev(tokens);
+ *label = _account_get_text(label_data->label);
+ return ACCOUNT_ERROR_NONE;
+ }
+ _ACCOUNT_FREE(converted_locale);
+ }
+ _ACCOUNT_FREE(upper_token);
+ }
+ }
+ g_strfreev(tokens);
+ }
+
+ return ACCOUNT_ERROR_RECORD_NOT_FOUND;
+}
+
+ACCOUNT_API int account_type_get_label(account_type_h account_type, account_label_cb callback, void *user_data)
+{
+ ACCOUNT_RETURN_VAL((account_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL"));
+ ACCOUNT_RETURN_VAL((callback != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("NO CALLBACK FUNCTION"));
+
+ GSList *iter;
+ account_type_s *data = (account_type_s*)account_type;
+
+ for (iter = data->label_list; iter != NULL; iter = g_slist_next(iter)) {
+ label_s *label_data = NULL;
+
+ label_data = (label_s*)iter->data;
+
+ if(callback(label_data->app_id, label_data->label, label_data->locale, user_data)!=TRUE) {
+ ACCOUNT_DEBUG("Callback func returs FALSE, its iteration is stopped!!!!\n");
+ return ACCOUNT_ERROR_NONE;
+ }
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static gboolean _account_type_check_duplicated(account_type_s *data)
+{
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int count = 0;
+
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT COUNT(*) FROM %s WHERE AppId='%s'"
+ , ACCOUNT_TYPE_TABLE, data->app_id);
+
+ count = _account_get_record_count(query);
+ if (count > 0) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static int _account_type_convert_account_to_sql(account_type_s *account_type, account_stmt hstmt, char *sql_value)
+{
+ int count = 1;
+
+ /*Caution : Keep insert query orders.*/
+
+ /* 1. app id*/
+ _account_query_bind_text(hstmt, count++, (char*)account_type->app_id);
+
+ /* 2. service provider id*/
+ _account_query_bind_text(hstmt, count++, (char*)account_type->service_provider_id);
+
+ /* 3. icon path*/
+ _account_query_bind_text(hstmt, count++, (char*)account_type->icon_path);
+
+ /* 4. small icon path*/
+ _account_query_bind_text(hstmt, count++, (char*)account_type->small_icon_path);
+
+ /* 5. multiple accont support*/
+ _account_query_bind_int(hstmt, count++, account_type->multiple_account_support);
+
+ return count;
+}
+
+
+static int _account_type_execute_insert_query(account_type_s *account_type)
+{
+ int rc = 0;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+
+ /* check mandatory field */
+ // app id & service provider id
+ if (!account_type->app_id) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "INSERT INTO %s( AppId, ServiceProviderId , IconPath , SmallIconPath , MultipleAccountSupport ) values "
+ "(?, ?, ?, ?, ?)", ACCOUNT_TYPE_TABLE);
+
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ } else if( _account_db_err_code() == SQLITE_BUSY ){
+ ACCOUNT_ERROR( "Database Busy(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_DATABASE_BUSY;
+ }
+
+ ACCOUNT_RETURN_VAL((hstmt != NULL), {}, ACCOUNT_ERROR_DB_FAILED, ("_account_prepare_query() failed(%s).\n", _account_db_err_msg()));
+
+ _account_type_convert_account_to_sql(account_type, hstmt, query);
+
+ rc = _account_query_step(hstmt);
+ if (rc == SQLITE_BUSY) {
+ ACCOUNT_ERROR( "account_db_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+ error_code = ACCOUNT_ERROR_DATABASE_BUSY;
+ } else if (rc != SQLITE_DONE) {
+ ACCOUNT_ERROR( "account_db_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+ error_code = ACCOUNT_ERROR_DB_FAILED;
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ return error_code;
+}
+
+static int _account_type_insert_label(account_type_s *account_type)
+{
+ int rc, count = 1;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ account_stmt hstmt = NULL;
+
+ ACCOUNT_RETURN_VAL((account_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL"));
+
+ if (g_slist_length( account_type->label_list)==0) {
+ ACCOUNT_ERROR( "_account_type_insert_label, no label\n");
+ return ACCOUNT_ERROR_NONE;
+ }
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT COUNT(*) from %s where AppId = '%s'", ACCOUNT_TYPE_TABLE, account_type->app_id);
+
+ rc = _account_get_record_count(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ if (rc <= 0) {
+ return ACCOUNT_ERROR_RECORD_NOT_FOUND;
+ }
+
+ /* insert query*/
+ GSList *iter;
+
+ for (iter = account_type->label_list; iter != NULL; iter = g_slist_next(iter)) {
+ int ret;
+ count = 1;
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "INSERT INTO %s(AppId, Label, Locale) VALUES "
+ "(?, ?, ?) ", LABEL_TABLE);
+
+ hstmt = _account_prepare_query(query);
+
+ ACCOUNT_RETURN_VAL((hstmt != NULL), {}, ACCOUNT_ERROR_DB_FAILED, ("_account_prepare_query() failed(%s).\n", _account_db_err_msg()));
+
+ label_s* label_data = NULL;
+ label_data = (label_s*)iter->data;
+
+ ret = _account_query_bind_text(hstmt, count++, account_type->app_id);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+ ret = _account_query_bind_text(hstmt, count++, label_data->label);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+ ret = _account_query_bind_text(hstmt, count++, (char*)label_data->locale);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+
+ rc = _account_query_step(hstmt);
+
+ if (rc != SQLITE_DONE) {
+ ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+ break;
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static void _account_type_convert_column_to_provider_feature(account_stmt hstmt, provider_feature_s *feature_record)
+{
+ const char *textbuf = NULL;
+
+ textbuf = _account_query_table_column_text(hstmt, PROVIDER_FEATURE_FIELD_APP_ID);
+ _account_db_data_to_text(textbuf, &(feature_record->app_id));
+
+ textbuf = _account_query_table_column_text(hstmt, PROVIDER_FEATURE_FIELD_KEY);
+ _account_db_data_to_text(textbuf, &(feature_record->key));
+
+}
+
+ACCOUNT_API int account_type_query_provider_feature_by_app_id(provider_feature_cb callback, const char* app_id, void *user_data )
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0, binding_count = 1;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((app_id != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("APP ID IS NULL"));
+ ACCOUNT_RETURN_VAL((callback != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("NO CALLBACK FUNCTION"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE app_id = ?", PROVIDER_FEATURE_TABLE);
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ _account_query_bind_text(hstmt, binding_count++, app_id);
+
+ rc = _account_query_step(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
+
+ provider_feature_s* feature_record = NULL;
+
+ while (rc == SQLITE_ROW) {
+ bool cb_ret = FALSE;
+ feature_record = (provider_feature_s*) malloc(sizeof(provider_feature_s));
+
+ if (feature_record == NULL) {
+ ACCOUNT_FATAL("malloc Failed");
+ break;
+ }
+
+ ACCOUNT_MEMSET(feature_record, 0x00, sizeof(provider_feature_s));
+
+ _account_type_convert_column_to_provider_feature(hstmt, feature_record);
+
+ cb_ret = callback(feature_record->app_id, feature_record->key, user_data);
+
+ _account_type_free_feature_items(feature_record);
+ _ACCOUNT_FREE(feature_record);
+
+ ACCOUNT_CATCH_ERROR(cb_ret == TRUE, {}, ACCOUNT_ERROR_NONE, ("Callback func returs FALSE, its iteration is stopped!!!!\n"));
+
+ rc = _account_query_step(hstmt);
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ error_code = ACCOUNT_ERROR_NONE;
+
+CATCH:
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+
+ pthread_mutex_unlock(&account_mutex);
+ return error_code;
+}
+
+ACCOUNT_API bool account_type_query_supported_feature(const char* app_id, const char* capability)
+{
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int record_count = 0;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ set_last_result(ACCOUNT_ERROR_PERMISSION_DENIED);
+ return false;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ set_last_result(ACCOUNT_ERROR_PERMISSION_DENIED);
+ return false;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ set_last_result(ACCOUNT_ERROR_PERMISSION_DENIED);
+ return false;
+ }
+ close(fd);
+ }
+
+ if (app_id == NULL || capability == NULL) {
+ set_last_result(ACCOUNT_ERROR_INVALID_PARAMETER);
+ return false;
+ }
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT COUNT(*) FROM %s where app_id='%s' and key='%s'", PROVIDER_FEATURE_TABLE, app_id, capability);
+
+ record_count = _account_get_record_count(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ set_last_result(ACCOUNT_ERROR_PERMISSION_DENIED);
+ return false;
+ }
+
+ if (record_count <= 0) {
+ set_last_result(ACCOUNT_ERROR_RECORD_NOT_FOUND);
+ return false;
+ }
+
+ set_last_result(ACCOUNT_ERROR_NONE);
+ return true;
+
+}
+
+
+ACCOUNT_API int account_type_get_provider_feature_all(account_type_h account_type, provider_feature_cb callback, void* user_data)
+{
+ ACCOUNT_RETURN_VAL((account_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL"));
+ ACCOUNT_RETURN_VAL((callback != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("NO CALLBACK FUNCTION"));
+
+ GSList *iter;
+ account_type_s *data = (account_type_s*)account_type;
+
+ for (iter = data->provider_feature_list; iter != NULL; iter = g_slist_next(iter)) {
+ provider_feature_s *feature_data = NULL;
+
+ feature_data = (provider_feature_s*)iter->data;
+
+ if(callback(feature_data->app_id, feature_data->key, user_data)!=TRUE) {
+ ACCOUNT_DEBUG("Callback func returs FALSE, its iteration is stopped!!!!\n");
+ return ACCOUNT_ERROR_NONE;
+ }
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_type_set_provider_feature(account_type_h account_type, const char* provider_feature)
+{
+ ACCOUNT_RETURN_VAL((account_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("account type handle is null"));
+ ACCOUNT_RETURN_VAL((provider_feature != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("provider_feature is null"));
+
+ account_type_s *data = (account_type_s*)account_type;
+
+ GSList *iter = NULL;
+ bool b_is_new = TRUE;
+
+ for(iter = data->provider_feature_list; iter != NULL; iter = g_slist_next(iter)) {
+ provider_feature_s *feature_data = NULL;
+ feature_data = (provider_feature_s*)iter->data;
+
+ if(!strcmp(feature_data->key, provider_feature)) {
+ b_is_new = FALSE;
+ break;
+ }
+ }
+
+ if(b_is_new) {
+ provider_feature_s* feature_data = (provider_feature_s*)malloc(sizeof(provider_feature_s));
+
+ if (feature_data == NULL)
+ return ACCOUNT_ERROR_OUT_OF_MEMORY;
+ ACCOUNT_MEMSET(feature_data, 0, sizeof(provider_feature_s));
+
+ feature_data->key = _account_get_text(provider_feature);
+ data->provider_feature_list = g_slist_append(data->provider_feature_list, (gpointer)feature_data);
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_type_insert_provider_feature(account_type_s *account_type, const char* app_id)
+{
+ int rc, count = 1;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ account_stmt hstmt = NULL;
+
+ ACCOUNT_RETURN_VAL((account_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL"));
+ ACCOUNT_RETURN_VAL((app_id != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("APP ID IS NULL"));
+
+ if (g_slist_length( account_type->provider_feature_list)==0) {
+ ACCOUNT_ERROR( "no capability\n");
+ return ACCOUNT_ERROR_NONE;
+ }
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT COUNT(*) from %s where AppId='%s'", ACCOUNT_TYPE_TABLE, app_id);
+
+ rc = _account_get_record_count(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ if (rc <= 0) {
+ ACCOUNT_SLOGI( "related account type item is not existed rc=%d , %s", rc, _account_db_err_msg());
+ return ACCOUNT_ERROR_RECORD_NOT_FOUND;
+ }
+
+ /* insert query*/
+
+ GSList *iter;
+
+ for (iter = account_type->provider_feature_list; iter != NULL; iter = g_slist_next(iter)) {
+ int ret;
+ count = 1;
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "INSERT INTO %s(app_id, key) VALUES "
+ "(?, ?) ", PROVIDER_FEATURE_TABLE);
+
+ hstmt = _account_prepare_query(query);
+
+ ACCOUNT_RETURN_VAL((hstmt != NULL), {}, ACCOUNT_ERROR_DB_FAILED, ("_account_prepare_query() failed(%s).\n", _account_db_err_msg()));
+
+ provider_feature_s* feature_data = NULL;
+ feature_data = (provider_feature_s*)iter->data;
+
+ ret = _account_query_bind_text(hstmt, count++, app_id);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+ ret = _account_query_bind_text(hstmt, count++, feature_data->key);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Integer binding fail"));
+
+ rc = _account_query_step(hstmt);
+
+ if (rc != SQLITE_DONE) {
+ ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+ break;
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_type_insert_to_db(account_type_h account_type, int* account_type_id)
+{
+ int error_code = ACCOUNT_ERROR_NONE, ret_transaction = 0;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+ ACCOUNT_RETURN_VAL((account_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT TYPE HANDLE IS NULL"));
+ ACCOUNT_RETURN_VAL((account_type_id != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT TYPE ID POINTER IS NULL"));
+
+ account_type_s *data = (account_type_s*)account_type;
+
+ pthread_mutex_lock(&account_mutex);
+
+
+ /* transaction control required*/
+ ret_transaction = _account_begin_transaction();
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ pthread_mutex_unlock(&account_mutex);
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ if( ret_transaction == ACCOUNT_ERROR_DATABASE_BUSY ){
+ ACCOUNT_ERROR( "database busy(%s)", _account_db_err_msg());
+ pthread_mutex_unlock(&account_mutex);
+ return ACCOUNT_ERROR_DATABASE_BUSY;
+ } else if (ret_transaction != ACCOUNT_ERROR_NONE) {
+ ACCOUNT_ERROR("_account_begin_transaction fail %d\n", ret_transaction);
+ pthread_mutex_unlock(&account_mutex);
+ return ret_transaction;
+ }
+
+ if (_account_type_check_duplicated(data)) {
+ ret_transaction = _account_end_transaction(FALSE);
+ ACCOUNT_ERROR("Duplicated, rollback insert query(%x)!!!!\n", ret_transaction);
+ *account_type_id = -1;
+ pthread_mutex_unlock(&account_mutex);
+ return ACCOUNT_ERROR_DUPLICATED;
+ } else {
+ *account_type_id = _account_get_next_sequence(ACCOUNT_TYPE_TABLE);
+
+ error_code = _account_type_execute_insert_query(data);
+
+ if (error_code != ACCOUNT_ERROR_NONE){
+ error_code = ACCOUNT_ERROR_DUPLICATED;
+ ret_transaction = _account_end_transaction(FALSE);
+ ACCOUNT_ERROR("Insert fail, rollback insert query(%x)!!!!\n", ret_transaction);
+ *account_type_id = -1;
+ pthread_mutex_unlock(&account_mutex);
+ return error_code;
+ }
+ }
+
+ error_code = _account_type_insert_provider_feature(data, data->app_id);
+ if(error_code != ACCOUNT_ERROR_NONE) {
+ ret_transaction = _account_end_transaction(FALSE);
+ ACCOUNT_ERROR("Insert provider feature fail(%x), rollback insert query(%x)!!!!\n", error_code, ret_transaction);
+ pthread_mutex_unlock(&account_mutex);
+ return error_code;
+ }
+ error_code = _account_type_insert_label(data);
+ if(error_code != ACCOUNT_ERROR_NONE) {
+ ret_transaction = _account_end_transaction(FALSE);
+ ACCOUNT_ERROR("Insert label fail(%x), rollback insert query(%x)!!!!\n", error_code, ret_transaction);
+ pthread_mutex_unlock(&account_mutex);
+ return error_code;
+ }
+
+ ret_transaction = _account_end_transaction(TRUE);
+
+ pthread_mutex_unlock(&account_mutex);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_type_update_provider_feature(account_type_s *account_type, const char* app_id)
+{
+ int rc, count = 1;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ account_stmt hstmt = NULL;
+
+ ACCOUNT_RETURN_VAL((account_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL"));
+
+ if (g_slist_length( account_type->provider_feature_list)==0) {
+ ACCOUNT_ERROR( "no feature\n");
+ return ACCOUNT_ERROR_NONE;
+ }
+
+ ACCOUNT_DEBUG( "app id", app_id);
+
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s WHERE app_id=? ", PROVIDER_FEATURE_TABLE);
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ count = 1;
+ _account_query_bind_text(hstmt, count++, app_id);
+ rc = _account_query_step(hstmt);
+
+ if (rc != SQLITE_DONE) {
+ ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+ return ACCOUNT_ERROR_DB_FAILED;
+ }
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ GSList *iter;
+
+ for (iter = account_type->provider_feature_list; iter != NULL; iter = g_slist_next(iter)) {
+ int ret;
+ count = 1;
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "INSERT INTO %s(app_id, key) VALUES "
+ "(?, ?) ", PROVIDER_FEATURE_TABLE);
+
+ hstmt = _account_prepare_query(query);
+
+ ACCOUNT_RETURN_VAL((hstmt != NULL), {}, ACCOUNT_ERROR_DB_FAILED, ("_account_prepare_query() failed(%s).\n", _account_db_err_msg()));
+
+ provider_feature_s* feature_data = NULL;
+ feature_data = (provider_feature_s*)iter->data;
+
+ ret = _account_query_bind_text(hstmt, count++, account_type->app_id);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+ ret = _account_query_bind_text(hstmt, count++, feature_data->key);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+
+ rc = _account_query_step(hstmt);
+
+ if (rc != SQLITE_DONE) {
+ ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+ break;
+ }
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_type_update_label(account_type_s *account_type, const char* app_id)
+{
+ int rc, count = 1;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ account_stmt hstmt = NULL;
+
+ ACCOUNT_RETURN_VAL((account_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL"));
+
+ if (g_slist_length( account_type->label_list)==0) {
+ return ACCOUNT_ERROR_NONE;
+ }
+
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s WHERE AppId=? ", LABEL_TABLE);
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ count = 1;
+ _account_query_bind_text(hstmt, count++, app_id);
+ rc = _account_query_step(hstmt);
+
+ if (rc != SQLITE_DONE) {
+ ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+ return ACCOUNT_ERROR_DB_FAILED;
+ }
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ GSList *iter;
+
+ for (iter = account_type->label_list; iter != NULL; iter = g_slist_next(iter)) {
+ int ret;
+ count = 1;
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "INSERT INTO %s(AppId, Label, Locale) VALUES "
+ "(?, ?, ?) ", LABEL_TABLE);
+
+ hstmt = _account_prepare_query(query);
+
+ ACCOUNT_RETURN_VAL((hstmt != NULL), {}, ACCOUNT_ERROR_DB_FAILED, ("_account_prepare_query() failed(%s).\n", _account_db_err_msg()));
+
+ label_s* label_data = NULL;
+ label_data = (label_s*)iter->data;
+
+ ret = _account_query_bind_text(hstmt, count++, account_type->app_id);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+ ret = _account_query_bind_text(hstmt, count++, label_data->label);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+ ret = _account_query_bind_text(hstmt, count++, label_data->locale);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+
+ rc = _account_query_step(hstmt);
+
+ if (rc != SQLITE_DONE) {
+ ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+ break;
+ }
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+
+static int _account_type_update_account(account_type_s *account_type, const char* app_id)
+{
+ int rc = 0, binding_count =1;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+
+ if (!account_type->app_id) {
+ ACCOUNT_ERROR("app id is mandetory field, it can not be NULL!!!!\n");
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "UPDATE %s SET AppId=?, ServiceProviderId=?, IconPath=?, "
+ "SmallIconPath=?, MultipleAccountSupport=? WHERE AppId=? ", ACCOUNT_TYPE_TABLE);
+
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ } else if (_account_db_err_code() == SQLITE_BUSY){
+ ACCOUNT_ERROR( "database busy(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_DATABASE_BUSY;
+ }
+
+ ACCOUNT_RETURN_VAL((hstmt != NULL), {}, ACCOUNT_ERROR_DB_FAILED, ("_account_svc_query_prepare() failed(%s).\n", _account_db_err_msg()));
+
+ binding_count = _account_type_convert_account_to_sql(account_type, hstmt, query);
+ _account_query_bind_text(hstmt, binding_count++, app_id);
+
+ rc = _account_query_step(hstmt);
+ if (rc != SQLITE_DONE) {
+ ACCOUNT_ERROR( "account_db_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ /*update label*/
+ error_code = _account_type_update_label(account_type, app_id);
+ /* update provider feature */
+ error_code = _account_type_update_provider_feature(account_type, app_id);
+
+ return error_code;
+}
+
+ACCOUNT_API int account_type_update_to_db_by_app_id(account_type_h account_type, const char* app_id)
+{
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((account_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("DATA IS NULL"));
+ ACCOUNT_RETURN_VAL((app_id != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("APP ID IS NULL"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_type_s* data = (account_type_s*)account_type;
+
+ pthread_mutex_lock(&account_mutex);
+
+ error_code = _account_type_update_account(data, app_id);
+
+ pthread_mutex_unlock(&account_mutex);
+
+ return error_code;
+}
+
+ACCOUNT_API int account_type_delete_by_app_id(const char* app_id)
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0, count = -1;
+ int ret_transaction = 0;
+ int binding_count = 1;
+ bool is_success = FALSE;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+ ACCOUNT_RETURN_VAL((app_id != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("The database isn't connected."));
+
+ /* Check requested ID to delete */
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT COUNT(*) FROM %s WHERE AppId = '%s'", ACCOUNT_TYPE_TABLE, app_id);
+
+ count = _account_get_record_count(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ if (count <= 0) {
+ ACCOUNT_SLOGE("app id(%s) is not exist. count(%d)\n", app_id, count);
+ return ACCOUNT_ERROR_RECORD_NOT_FOUND;
+ }
+
+ /* transaction control required*/
+ ret_transaction = _account_begin_transaction();
+
+ if( ret_transaction == ACCOUNT_ERROR_DATABASE_BUSY ){
+ ACCOUNT_ERROR( "database busy(%s)", _account_db_err_msg());
+ pthread_mutex_unlock(&account_mutex);
+ return ACCOUNT_ERROR_DATABASE_BUSY;
+ }else if (ret_transaction != ACCOUNT_ERROR_NONE) {
+ ACCOUNT_ERROR("account_delete:_account_begin_transaction fail %d\n", ret_transaction);
+ pthread_mutex_unlock(&account_mutex);
+ return ret_transaction;
+ }
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s WHERE AppId = ?", LABEL_TABLE);
+
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ pthread_mutex_unlock(&account_mutex);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ ACCOUNT_CATCH_ERROR(hstmt != NULL, {}, ACCOUNT_ERROR_DB_FAILED,
+ ("_account_svc_query_prepare(%s) failed(%s).\n", query, _account_db_err_msg()));
+
+ _account_query_bind_text(hstmt, binding_count++, app_id);
+
+ rc = _account_query_step(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_DONE, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ binding_count = 1;
+ ACCOUNT_MEMSET(query, 0, sizeof(query));
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s WHERE app_id = ? ", PROVIDER_FEATURE_TABLE);
+
+ hstmt = _account_prepare_query(query);
+ ACCOUNT_CATCH_ERROR(hstmt != NULL, {}, ACCOUNT_ERROR_DB_FAILED,
+ ("_account_svc_query_prepare(%s) failed(%s).\n", query, _account_db_err_msg()));
+
+ _account_query_bind_text(hstmt, binding_count++, app_id);
+
+ rc = _account_query_step(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_DONE, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found. AppId=%s, rc=%d\n", app_id, rc));
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ is_success = TRUE;
+
+ hstmt = NULL;
+
+ binding_count = 1;
+ ACCOUNT_MEMSET(query, 0, sizeof(query));
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s WHERE AppId = ? ", ACCOUNT_TYPE_TABLE);
+
+ hstmt = _account_prepare_query(query);
+ ACCOUNT_CATCH_ERROR(hstmt != NULL, {}, ACCOUNT_ERROR_DB_FAILED,
+ ("_account_svc_query_prepare(%s) failed(%s).\n", query, _account_db_err_msg()));
+
+ _account_query_bind_text(hstmt, binding_count++, app_id);
+
+ rc = _account_query_step(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_DONE, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found. AppId=%s, rc=%d\n", app_id, rc));
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ is_success = TRUE;
+
+ hstmt = NULL;
+
+ CATCH:
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+
+ ret_transaction = _account_end_transaction(is_success);
+
+ if (ret_transaction != ACCOUNT_ERROR_NONE) {
+ ACCOUNT_ERROR("account_svc_delete:_account_svc_end_transaction fail %d, is_success=%d\n", ret_transaction, is_success);
+ }
+
+ pthread_mutex_unlock(&account_mutex);
+
+ return error_code;
+}
+
+static void _account_type_convert_column_to_account_type(account_stmt hstmt, account_type_s *account_type_record)
+{
+ const char *textbuf = NULL;
+
+ account_type_record->id = _account_query_table_column_int(hstmt, ACCOUNT_TYPE_FIELD_ID);
+
+ textbuf = _account_query_table_column_text(hstmt, ACCOUNT_TYPE_FIELD_APP_ID);
+ _account_db_data_to_text(textbuf, &(account_type_record->app_id));
+
+ textbuf = _account_query_table_column_text(hstmt, ACCOUNT_TYPE_FIELD_SERVICE_PROVIDER_ID);
+ _account_db_data_to_text(textbuf, &(account_type_record->service_provider_id));
+
+ textbuf = _account_query_table_column_text(hstmt, ACCOUNT_TYPE_FIELD_ICON_PATH);
+ _account_db_data_to_text(textbuf, &(account_type_record->icon_path));
+
+ textbuf = _account_query_table_column_text(hstmt, ACCOUNT_TYPE_FIELD_SMALL_ICON_PATH);
+ _account_db_data_to_text(textbuf, &(account_type_record->small_icon_path));
+
+ account_type_record->multiple_account_support = _account_query_table_column_int(hstmt, ACCOUNT_TYPE_FIELD_MULTIPLE_ACCOUNT_SUPPORT);
+
+}
+
+static void _account_type_convert_column_to_label(account_stmt hstmt, label_s *label_record)
+{
+ const char *textbuf = NULL;
+
+ textbuf = _account_query_table_column_text(hstmt, LABEL_FIELD_APP_ID);
+ _account_db_data_to_text(textbuf, &(label_record->app_id));
+
+ textbuf = _account_query_table_column_text(hstmt, LABEL_FIELD_LABEL);
+ _account_db_data_to_text(textbuf, &(label_record->label));
+
+ textbuf = _account_query_table_column_text(hstmt, LABEL_FIELD_LOCALE);
+ _account_db_data_to_text(textbuf, &(label_record->locale));
+
+}
+
+ACCOUNT_API int account_type_query_label_by_app_id(account_label_cb callback, const char* app_id, void *user_data )
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0, binding_count = 1;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((app_id != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("APP ID IS NULL"));
+ ACCOUNT_RETURN_VAL((callback != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("NO CALLBACK FUNCTION"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE AppId = ?", LABEL_TABLE);
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ _account_query_bind_text(hstmt, binding_count++, app_id);
+
+ rc = _account_query_step(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
+
+ label_s* label_record = NULL;
+
+ while (rc == SQLITE_ROW) {
+ bool cb_ret = FALSE;
+ label_record = (label_s*) malloc(sizeof(label_s));
+
+ if (label_record == NULL) {
+ ACCOUNT_FATAL("malloc Failed");
+ break;
+ }
+
+ ACCOUNT_MEMSET(label_record, 0x00, sizeof(label_s));
+
+ _account_type_convert_column_to_label(hstmt, label_record);
+
+ cb_ret = callback(label_record->app_id, label_record->label , label_record->locale, user_data);
+
+ _account_type_free_label_items(label_record);
+ _ACCOUNT_FREE(label_record);
+
+ ACCOUNT_CATCH_ERROR(cb_ret == TRUE, {}, ACCOUNT_ERROR_NONE, ("Callback func returs FALSE, its iteration is stopped!!!!\n"));
+
+ rc = _account_query_step(hstmt);
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ error_code = ACCOUNT_ERROR_NONE;
+
+CATCH:
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+
+ pthread_mutex_unlock(&account_mutex);
+ return error_code;
+}
+
+int _account_type_label_get_app_id(label_h label, char **app_id)
+{
+ if (!label) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!app_id) {
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ label_s *data = (label_s*)label;
+
+ (*app_id) = NULL;
+
+ *app_id = _account_get_text(data->app_id);
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+bool _account_get_label_text_cb(char* app_id, char* label, char* locale, void *user_data)
+{
+ account_type_s *data = (account_type_s*)user_data;
+
+ label_s *label_data = (label_s*)malloc(sizeof(label_s));
+
+ if (label_data == NULL) {
+ ACCOUNT_FATAL("_account_get_label_text_cb : MALLOC FAIL\n");
+ return FALSE;
+ }
+ ACCOUNT_MEMSET(label_data, 0, sizeof(label_s));
+
+ label_data->app_id = _account_get_text(app_id);
+ label_data->label = _account_get_text(label);
+ label_data->locale = _account_get_text(locale);
+
+ data->label_list = g_slist_append(data->label_list, (gpointer)label_data);
+
+ return TRUE;
+}
+
+bool _account_get_provider_feature_cb(char* app_id, char* key, void* user_data)
+{
+ account_type_s *data = (account_type_s*)user_data;
+
+ provider_feature_s *feature_data = (provider_feature_s*)malloc(sizeof(provider_feature_s));
+
+ if (feature_data == NULL) {
+ ACCOUNT_FATAL("_account_get_provider_feature_cb : MALLOC FAIL\n");
+ return FALSE;
+ }
+ ACCOUNT_MEMSET(feature_data, 0, sizeof(provider_feature_s));
+
+ feature_data->app_id = _account_get_text(app_id);
+ feature_data->key = _account_get_text(key);
+
+ data->provider_feature_list = g_slist_append(data->provider_feature_list, (gpointer)feature_data);
+
+ return TRUE;
+}
+
+ACCOUNT_API int account_type_query_by_app_id(const char* app_id, account_type_h *account_type)
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0, binding_count = 1;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((app_id != 0), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("APP ID IS NULL"));
+ ACCOUNT_RETURN_VAL((*account_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT TYPE IS NULL"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE AppId = ?", ACCOUNT_TYPE_TABLE);
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ _account_query_bind_text(hstmt, binding_count++, app_id);
+
+ rc = _account_query_step(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
+
+ account_type_s *account_type_record = (account_type_s *)(*account_type);
+
+ while (rc == SQLITE_ROW) {
+ _account_type_convert_column_to_account_type(hstmt, account_type_record);
+ rc = _account_query_step(hstmt);
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ account_type_query_label_by_app_id(_account_get_label_text_cb, app_id, (void*)account_type_record);
+ account_type_query_provider_feature_by_app_id(_account_get_provider_feature_cb, app_id,(void*)account_type_record);
+
+ hstmt = NULL;
+ error_code = ACCOUNT_ERROR_NONE;
+
+ CATCH:
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+
+ pthread_mutex_unlock(&account_mutex);
+ return error_code;
+}
+
+ACCOUNT_API int account_type_query_app_id_exist(const char* app_id)
+{
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((app_id != 0), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("APP ID IS NULL"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT COUNT(*) FROM %s WHERE AppId = '%s'", ACCOUNT_TYPE_TABLE, app_id);
+ rc = _account_get_record_count(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ if (rc <= 0) {
+ return ACCOUNT_ERROR_RECORD_NOT_FOUND;
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_type_query_by_provider_feature(account_type_cb callback, const char* key, void* user_data)
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0;
+ GList *account_type_list = NULL;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((key != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("capability_type IS NULL"));
+ ACCOUNT_RETURN_VAL((callback != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("CALL BACK IS NULL"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE AppId IN (SELECT app_id from %s WHERE key=?)", ACCOUNT_TYPE_TABLE, PROVIDER_FEATURE_TABLE);
+
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ int binding_count = 1;
+ _account_query_bind_text(hstmt, binding_count++, key);
+
+ rc = _account_query_step(hstmt);
+
+ account_type_s *account_type_record = NULL;
+
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
+
+ int k=0;
+ while(rc == SQLITE_ROW) {
+ account_type_record = (account_type_s*) malloc(sizeof(account_type_s));
+
+ if (account_type_record == NULL) {
+ ACCOUNT_FATAL("malloc Failed");
+ break;
+ }
+
+ ACCOUNT_MEMSET(account_type_record, 0x00, sizeof(account_type_s));
+ _account_type_convert_column_to_account_type(hstmt, account_type_record);
+ account_type_list = g_list_append(account_type_list, account_type_record);
+ rc = _account_query_step(hstmt);
+ k++;
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {_account_type_glist_free(account_type_list);}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ GList* iter;
+ k = 0;
+ for (iter = account_type_list; iter != NULL; iter = g_list_next(iter)) {
+ account_type_s *account_type = NULL;
+ account_type = (account_type_s*)iter->data;
+ account_type_query_label_by_app_id(_account_get_label_text_cb,account_type->app_id,(void*)account_type);
+ account_type_query_provider_feature_by_app_id(_account_get_provider_feature_cb, account_type->app_id,(void*)account_type);
+ //cb_func((account_type_h)account_type, user_data);
+ ACCOUNT_CATCH_ERROR(callback((account_type_h)account_type, user_data) == TRUE, {}, ACCOUNT_ERROR_NONE, ("Callback func returs FALSE, its iteration is stopped!!!!\n"));
+ k++;
+ }
+
+ error_code = ACCOUNT_ERROR_NONE;
+
+CATCH:
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+ if (account_type_list) {
+ _account_type_glist_free(account_type_list);
+ account_type_list = NULL;
+ }
+
+ return error_code;
+}
+
+
+ACCOUNT_API int account_type_foreach_account_type_from_db(account_type_cb callback, void *user_data)
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0;
+ GList *account_type_list = NULL;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((callback != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT INFO IS NULL"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s ", ACCOUNT_TYPE_TABLE);
+ hstmt = _account_prepare_query(query);
+
+ rc = _account_query_step(hstmt);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ account_type_s *account_type_record = NULL;
+
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
+
+ int k=0;
+ while(rc == SQLITE_ROW) {
+ account_type_record = (account_type_s*) malloc(sizeof(account_type_s));
+
+ if (account_type_record == NULL) {
+ ACCOUNT_FATAL("malloc Failed");
+ break;
+ }
+
+ ACCOUNT_MEMSET(account_type_record, 0x00, sizeof(account_type_s));
+ _account_type_convert_column_to_account_type(hstmt, account_type_record);
+ account_type_list = g_list_append(account_type_list, account_type_record);
+ rc = _account_query_step(hstmt);
+ k++;
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {_account_type_glist_free(account_type_list);}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ GList* iter;
+ k = 0;
+ for (iter = account_type_list; iter != NULL; iter = g_list_next(iter)) {
+ account_type_s *account_type = NULL;
+ account_type = (account_type_s*)iter->data;
+ account_type_query_label_by_app_id(_account_get_label_text_cb,account_type->app_id,(void*)account_type);
+ account_type_query_provider_feature_by_app_id(_account_get_provider_feature_cb, account_type->app_id,(void*)account_type);
+ callback((account_type_h)account_type, user_data);
+ k++;
+ }
+
+ error_code = ACCOUNT_ERROR_NONE;
+
+CATCH:
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+ if (account_type_list) {
+ _account_type_glist_free(account_type_list);
+ account_type_list = NULL;
+ }
+
+ return error_code;
+}
+
+// output parameter label must be free
+ACCOUNT_API int account_type_query_label_by_locale(const char* app_id, const char* locale, char** label)
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0, binding_count = 1;
+
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+ char* converted_locale = NULL;
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((app_id != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("NO APP ID"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+ ACCOUNT_RETURN_VAL((label != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("label char is null"));
+ ACCOUNT_RETURN_VAL((locale != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("locale char is null"));
+
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+
+ converted_locale = _account_get_text(locale);
+ gchar** tokens = g_strsplit(converted_locale, "-", 2);
+
+ if(tokens != NULL) {
+ if((char*)(tokens[1]) != NULL) {
+ char* upper_token = g_ascii_strup(tokens[1], strlen(tokens[1]));
+ if(upper_token != NULL) {
+ _ACCOUNT_FREE(converted_locale);
+ converted_locale = g_strdup_printf("%s_%s", tokens[0], upper_token);
+ }
+ _ACCOUNT_FREE(upper_token);
+ }
+ }
+ g_strfreev(tokens);
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE AppId = ? AND Locale = '%s' ", LABEL_TABLE, converted_locale);
+ _ACCOUNT_FREE(converted_locale);
+
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ _account_query_bind_text(hstmt, binding_count++, app_id);
+
+ rc = _account_query_step(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
+
+ label_s* label_record = NULL;
+
+ while (rc == SQLITE_ROW) {
+ label_record = (label_s*) malloc(sizeof(label_s));
+
+ if (label_record == NULL) {
+ ACCOUNT_FATAL("malloc Failed");
+ break;
+ }
+
+ ACCOUNT_MEMSET(label_record, 0x00, sizeof(label_s));
+
+ _account_type_convert_column_to_label(hstmt,label_record);
+
+ _ACCOUNT_FREE(*label);
+ *label = _account_get_text(label_record->label);
+
+ _account_type_free_label_items(label_record);
+ _ACCOUNT_FREE(label_record);
+
+ rc = _account_query_step(hstmt);
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ error_code = ACCOUNT_ERROR_NONE;
+
+ CATCH:
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+
+ pthread_mutex_unlock(&account_mutex);
+ return error_code;
+}
+
+static int _account_insert_custom(account_s *account, int account_id)
+{
+ int rc, count = 1;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ account_stmt hstmt = NULL;
+
+ ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL"));
+
+ if (g_slist_length( account->custom_list)==0) {
+ ACCOUNT_DEBUG( "_account_insert_custom, no custom data\n");
+ return ACCOUNT_ERROR_NONE;
+ }
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT COUNT(*) from %s where _id=%d", ACCOUNT_TABLE, account_id);
+
+ rc = _account_get_record_count(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%d, %s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ if (rc <= 0) {
+ ACCOUNT_SLOGE( "_account_insert_custom : related account item is not existed rc=%d , %s", rc, _account_db_err_msg());
+ return ACCOUNT_ERROR_RECORD_NOT_FOUND;
+ }
+
+ /* insert query*/
+
+ GSList *iter;
+
+ for (iter = account->custom_list; iter != NULL; iter = g_slist_next(iter)) {
+ int ret;
+ count = 1;
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "INSERT INTO %s (AccountId, AppId, Key, Value) VALUES "
+ "(?, ?, ?, ?) ", ACCOUNT_CUSTOM_TABLE);
+
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ ACCOUNT_RETURN_VAL((hstmt != NULL), {}, ACCOUNT_ERROR_DB_FAILED, ("_account_prepare_query() failed(%s).\n", _account_db_err_msg()));
+
+ account_custom_s* custom_data = NULL;
+ custom_data = (account_custom_s*)iter->data;
+
+ ret = _account_query_bind_int(hstmt, count++, account_id);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Int binding fail"));
+ ret = _account_query_bind_text(hstmt, count++, account->package_name);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+ ret = _account_query_bind_text(hstmt, count++, (char*)custom_data->key);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+ ret = _account_query_bind_text(hstmt, count++, (char*)custom_data->value);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+
+ rc = _account_query_step(hstmt);
+
+ if (rc != SQLITE_DONE) {
+ ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+ break;
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_update_custom(account_s *account, int account_id)
+{
+ int rc, count = 1;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ account_stmt hstmt = NULL;
+
+ ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL"));
+
+ if (g_slist_length( account->custom_list)==0) {
+ ACCOUNT_DEBUG( "_account_update_custom, no custom data\n");
+ return ACCOUNT_ERROR_NONE;
+ }
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT COUNT(*) from %s where _id=%d", ACCOUNT_TABLE, account_id);
+
+ rc = _account_get_record_count(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ pthread_mutex_unlock(&account_mutex);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ } else if( _account_db_err_code() == SQLITE_BUSY ){
+ ACCOUNT_ERROR( "database busy(%s)", _account_db_err_msg());
+ pthread_mutex_unlock(&account_mutex);
+ return ACCOUNT_ERROR_DATABASE_BUSY;
+ }
+
+ if (rc <= 0) {
+ ACCOUNT_SLOGE( "_account_update_custom : related account item is not existed rc=%d , %s", rc, _account_db_err_msg());
+ return ACCOUNT_ERROR_RECORD_NOT_FOUND;
+ }
+
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s WHERE AccountId=? ", ACCOUNT_CUSTOM_TABLE);
+ hstmt = _account_prepare_query(query);
+ count = 1;
+ _account_query_bind_int(hstmt, count++, (int)account_id);
+ rc = _account_query_step(hstmt);
+
+ if (rc == SQLITE_BUSY) {
+ ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+ return ACCOUNT_ERROR_DATABASE_BUSY;
+ } else if (rc != SQLITE_DONE) {
+ ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+ return ACCOUNT_ERROR_DB_FAILED;
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ GSList *iter;
+
+ for (iter = account->custom_list; iter != NULL; iter = g_slist_next(iter)) {
+ int ret;
+ count = 1;
+ ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+ ACCOUNT_SNPRINTF(query, sizeof(query), "INSERT INTO %s(AccountId, AppId, Key, Value) VALUES "
+ "(?, ?, ?, ?) ", ACCOUNT_CUSTOM_TABLE);
+
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ ACCOUNT_RETURN_VAL((hstmt != NULL), {}, ACCOUNT_ERROR_DB_FAILED, ("_account_prepare_query() failed(%s).\n", _account_db_err_msg()));
+
+ account_custom_s* custom_data = NULL;
+ custom_data = (account_custom_s*)iter->data;
+
+ ret = _account_query_bind_int(hstmt, count++, (int)account_id);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Int binding fail"));
+ ret = _account_query_bind_text(hstmt, count++, (char*)account->package_name);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+ ret = _account_query_bind_text(hstmt, count++, (char*)custom_data->key);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+ ret = _account_query_bind_text(hstmt, count++, (char*)custom_data->value);
+ ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Text binding fail"));
+
+ rc = _account_query_step(hstmt);
+
+ if (rc != SQLITE_DONE) {
+ ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+ break;
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_query_custom_by_account_id(account_custom_cb callback, int account_id, void *user_data )
+{
+ int error_code = ACCOUNT_ERROR_NONE;
+ account_stmt hstmt = NULL;
+ char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+ int rc = 0;
+
+ ACCOUNT_RETURN_VAL((account_id > 0), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT INDEX IS LESS THAN 0"));
+ ACCOUNT_RETURN_VAL((callback != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("NO CALLBACK FUNCTION"));
+ ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
+
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE AccountId = %d", ACCOUNT_CUSTOM_TABLE, account_id);
+ hstmt = _account_prepare_query(query);
+
+ if( _account_db_err_code() == SQLITE_PERM ){
+ ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg());
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ rc = _account_query_step(hstmt);
+
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
+
+ account_custom_s* custom_record = NULL;
+
+ while (rc == SQLITE_ROW) {
+ bool cb_ret = FALSE;
+ custom_record = (account_custom_s*) malloc(sizeof(account_custom_s));
+
+ if (custom_record == NULL) {
+ ACCOUNT_FATAL("malloc Failed");
+ break;
+ }
+
+ ACCOUNT_MEMSET(custom_record, 0x00, sizeof(account_custom_s));
+
+ _account_convert_column_to_custom(hstmt, custom_record);
+
+ cb_ret = callback(custom_record->key, custom_record->value, user_data);
+
+ _account_custom_item_free(custom_record);
+ _ACCOUNT_FREE(custom_record);
+
+ ACCOUNT_CATCH_ERROR(cb_ret == TRUE, {}, ACCOUNT_ERROR_NONE, ("Callback func returs FALSE, its iteration is stopped!!!!\n"));
+
+ rc = _account_query_step(hstmt);
+ }
+
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+
+ error_code = ACCOUNT_ERROR_NONE;
+
+CATCH:
+ if (hstmt != NULL) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+
+ pthread_mutex_unlock(&account_mutex);
+ return error_code;
+}
+
+static void _account_subscribe_vconf_callback(keynode_t *key, void *user_data)
+{
+ account_subscribe_s* tmp = (account_subscribe_s*)user_data;
+ char *msg = NULL, *vconf_key = NULL;
+ char *key_name = NULL;
+ char event_msg[256] ={0, };
+ int account_id = -1;
+
+ if(!key) {
+ ACCOUNT_ERROR("No subscribtion msg !!!!!\n");
+ return;
+ }
+
+ if(!tmp) {
+ ACCOUNT_ERROR("user data required\n");
+ return;
+ }
+
+ key_name = vconf_keynode_get_name(key);
+ if( key_name == NULL ) {
+ ACCOUNT_ERROR("vconf_keynode_get_name(key) fail\n");
+ return;
+ }
+
+ if(!memcmp(key_name, VCONFKEY_ACCOUNT_MSG_STR, strlen(VCONFKEY_ACCOUNT_MSG_STR)))
+ {
+ vconf_key = vconf_keynode_get_str(key);
+
+ if( vconf_key == NULL){
+ ACCOUNT_ERROR("vconf key is NULL.\n");
+ return;
+ }
+ msg = strdup(vconf_key);
+
+ char* event_type = NULL;
+ char* id = NULL;
+ char* ptr = NULL;
+
+ event_type = strtok_r(msg, ":", &ptr);
+ id = strtok_r(NULL, ":", &ptr);
+
+ ACCOUNT_SLOGD("msg(%s), event_type(%s), id(%s)", msg, event_type, id);
+
+ ACCOUNT_SNPRINTF(event_msg,sizeof(event_msg),"%s", event_type);
+
+ account_id = atoi(id);
+
+ if(tmp->account_subscription_callback)
+ tmp->account_subscription_callback(event_msg, account_id, tmp->user_data);
+ }
+
+ _ACCOUNT_FREE(msg);
+
+}
+
+static void _account_subscribe_vconf_callback_ex(keynode_t *key, void *user_data)
+{
+ account_subscribe_s* tmp = (account_subscribe_s*)user_data;
+ char *msg = NULL, *vconf_key = NULL;
+ char *key_name = NULL;
+ char event_msg[256] ={0, };
+ int account_id = -1;
+
+ if(!key) {
+ ACCOUNT_ERROR("No subscribtion msg !!!!!\n");
+ return;
+ }
+
+ if(!tmp) {
+ ACCOUNT_ERROR("user data required\n");
+ return;
+ }
+
+ key_name = vconf_keynode_get_name(key);
+ if( key_name == NULL ) {
+ ACCOUNT_ERROR("vconf_keynode_get_name(key) fail\n");
+ return;
+ }
+
+ if(!memcmp(key_name, VCONFKEY_ACCOUNT_MSG_STR, strlen(VCONFKEY_ACCOUNT_MSG_STR)))
+ {
+ vconf_key = vconf_keynode_get_str(key);
+
+ if( vconf_key == NULL){
+ ACCOUNT_ERROR("vconf key is NULL.\n");
+ return;
+ }
+ msg = strdup(vconf_key);
+
+ char* event_type = NULL;
+ char* id = NULL;
+ char* ptr = NULL;
+ event_type = strtok_r(msg, ":", &ptr);
+ id = strtok_r(NULL, ":", &ptr);
+ ACCOUNT_SLOGD("msg(%s), event_type(%s), id(%s)", msg, event_type, id);
+
+ ACCOUNT_SNPRINTF(event_msg,sizeof(event_msg),"%s", event_type);
+ account_id = atoi(id);
+
+ if(tmp->account_subscription_callback)
+ tmp->account_subscription_callback(event_msg, account_id, tmp->user_data);
+ }
+
+ _ACCOUNT_FREE(msg);
+}
+
+ACCOUNT_API int account_subscribe_create(account_subscribe_h* account_subscribe)
+{
+ if (!account_subscribe) {
+ ACCOUNT_SLOGE("account is NULL.\n", __FUNCTION__, __LINE__);
+ return ACCOUNT_ERROR_INVALID_PARAMETER;
+ }
+
+ account_subscribe_s *data = (account_subscribe_s*)calloc(1,sizeof(account_subscribe_s));
+
+ if(!data) {
+ ACCOUNT_FATAL("OUT OF MEMORY\n");
+ return ACCOUNT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *account_subscribe = (account_subscribe_h)data;
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_subscribe_notification(account_subscribe_h account_subscribe, account_event_cb callback, void* user_data)
+{
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((account_subscribe != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("(%s)-(%d) account subscribe handle is NULL.\n", __FUNCTION__, __LINE__));
+
+ account_subscribe_s* tmp =(account_subscribe_s*)account_subscribe;
+
+ tmp->account_subscription_callback = callback;
+ tmp->user_data = user_data;
+
+ int ret = -1;
+ ret = vconf_notify_key_changed(VCONFKEY_ACCOUNT_MSG_STR,
+ (vconf_callback_fn)_account_subscribe_vconf_callback,
+ (void*)tmp);
+
+ ACCOUNT_SLOGI("vconf_notify_key_changed ret = %d", ret);
+
+ if(ret != VCONF_OK) {
+ ACCOUNT_ERROR("Vconf Subscription Failed ret = %d", ret);
+ return ACCOUNT_ERROR_EVENT_SUBSCRIPTION_FAIL;
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_API int account_unsubscribe_notification(account_subscribe_h account_subscribe)
+{
+ int res;
+ int process_uid = getuid();
+ char subject_label[SMACK_LABEL_LEN + 1] = {0,};
+
+ if(process_uid != 0) {
+ int fd = open("/proc/self/attr/current", O_RDONLY);
+ if(fd < 0)
+ {
+ ACCOUNT_ERROR("file open fail :: /proc/self/attr/current");
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = read(fd, subject_label, SMACK_LABEL_LEN);
+ if(res < 0)
+ {
+ ACCOUNT_ERROR("file read fail :: /proc/self/attr/current");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ res = smack_have_access(subject_label, "libaccounts-svc::check_read", "r");
+ if(res != 1) {
+ ACCOUNT_ERROR("Account permission denied :: This API can not be used without account.read privilege");
+ close(fd);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ close(fd);
+ }
+
+ ACCOUNT_RETURN_VAL((account_subscribe != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("(%s)-(%d) account subscribe handle is NULL.\n", __FUNCTION__, __LINE__));
+
+ account_subscribe_s* tmp =(account_subscribe_s*)account_subscribe;
+
+ _ACCOUNT_FREE(tmp);
+
+ if (vconf_ignore_key_changed(VCONFKEY_ACCOUNT_MSG_STR,
+ (vconf_callback_fn)_account_subscribe_vconf_callback) != 0) {
+ ACCOUNT_ERROR("Vconf Subscription Failed !!!!!\n");
+ return ACCOUNT_ERROR_EVENT_SUBSCRIPTION_FAIL;
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
+
+
+ACCOUNT_INTERNAL_API int account_subscribe_notification_ex(account_subscribe_h account_subscribe, account_event_cb callback, void* user_data)
+{
+ ACCOUNT_RETURN_VAL((account_subscribe != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("(%s)-(%d) account subscribe handle is NULL.\n", __FUNCTION__, __LINE__));
+
+ account_subscribe_s* tmp =(account_subscribe_s*)account_subscribe;
+ tmp->account_subscription_callback = callback;
+ tmp->user_data = user_data;
+
+ int ret = -1;
+ ret = vconf_notify_key_changed(VCONFKEY_ACCOUNT_MSG_STR,
+ (vconf_callback_fn)_account_subscribe_vconf_callback_ex,
+ (void*)tmp);
+ ACCOUNT_SLOGI("vconf_notify_key_changed ret = %d", ret);
+
+ if(ret != VCONF_OK) {
+ ACCOUNT_ERROR("Vconf Subscription Failed ret = %d", ret);
+ return ACCOUNT_ERROR_EVENT_SUBSCRIPTION_FAIL;
+ }
+ return ACCOUNT_ERROR_NONE;
+}
+
+ACCOUNT_INTERNAL_API int account_unsubscribe_notification_ex(account_subscribe_h account_subscribe)
+{
+ ACCOUNT_RETURN_VAL((account_subscribe != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("(%s)-(%d) account subscribe handle is NULL.\n", __FUNCTION__, __LINE__));
+ account_subscribe_s* tmp =(account_subscribe_s*)account_subscribe;
+
+ _ACCOUNT_FREE(tmp);
+
+ if (vconf_ignore_key_changed(VCONFKEY_ACCOUNT_MSG_STR,
+ (vconf_callback_fn)_account_subscribe_vconf_callback_ex) != 0) {
+ ACCOUNT_ERROR("Vconf Subscription Failed !!!!!\n");
+ return ACCOUNT_ERROR_EVENT_SUBSCRIPTION_FAIL;
+ }
+
+ return ACCOUNT_ERROR_NONE;
+}
diff --git a/src/utc-account.c b/src/utc-account.c
new file mode 100755
index 0000000..85de29c
--- /dev/null
+++ b/src/utc-account.c
@@ -0,0 +1,8276 @@
+/*
+ * utc-account
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Wonyoung Lee <wy1115.lee@samsung.com>, Sungchan Kim <sungchan81.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include "account.h"
+#include "account-private.h"
+#include <string.h>
+//#include <dbus/dbus.h>
+
+int account_id = 0;
+
+static void _account_free_text(char *text)
+{
+ if (text) {
+ free(text);
+ text = NULL;
+ }
+}
+
+bool _capability_get_callback(const char* capability_type, account_capability_state_e capability_value, void* user_data)
+{
+ char* test_type = (char*)capability_type;
+ int test_value = capability_value;
+
+ ACCOUNT_SLOGD("_capability_get_callback test_type = : %s\n", test_type);
+ ACCOUNT_SLOGD("_capability_get_callback test_value = : %d\n", test_value);
+ return TRUE;
+}
+
+int _account_get_account_info(account_h handle)
+{
+ ACCOUNT_SLOGD("_account_get_callback\n");
+
+ char *test_text = NULL;
+
+ account_get_user_name(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_display_name(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_email_address(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_icon_path(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_source(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_package_name(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_domain_name(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_access_token(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+
+
+ int i;
+
+ for(i=0;i<USER_TXT_CNT;i++)
+ {
+ _account_free_text(test_text);
+
+ account_get_user_text(handle, i, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+ }
+
+ int test_int = -1;
+
+ account_auth_type_e auth_type;
+ account_get_auth_type(handle, &auth_type);
+ ACCOUNT_SLOGD("account_get_auth_type : %d\n", auth_type);
+
+ account_secrecy_state_e secret;
+ account_get_secret(handle, &secret);
+ ACCOUNT_SLOGD("account_get_secret : %d\n", secret);
+
+ account_sync_state_e sync_support;
+ account_get_sync_support(handle, &sync_support);
+ ACCOUNT_SLOGD("account_get_sync_support : %d\n", sync_support);
+
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ test_int = -1;
+ account_get_user_int(handle, i, &test_int);
+ ACCOUNT_SLOGD("_account_get_callback : %d\n", test_int);
+ }
+
+ account_get_capability_all(handle, _capability_get_callback, NULL);
+
+ return 0;
+}
+
+
+bool _account_get_callback(account_h handle, void* user_data)
+{
+ ACCOUNT_SLOGD("_account_get_callback\n");
+
+ char *test_text = NULL;
+
+ account_get_user_name(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_display_name(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_email_address(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_icon_path(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_source(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_package_name(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_domain_name(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_access_token(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+
+ int i;
+
+ for(i=0;i<USER_TXT_CNT;i++)
+ {
+ _account_free_text(test_text);
+
+ account_get_user_text(handle, i, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+ }
+
+ int test_int = -1;
+
+ account_auth_type_e auth_type;
+ account_get_auth_type(handle, &auth_type);
+ ACCOUNT_SLOGD("account_get_auth_type : %d\n", auth_type);
+
+ account_secrecy_state_e secret;
+ account_get_secret(handle, &secret);
+ ACCOUNT_SLOGD("account_get_secret : %d\n", secret);
+
+ account_sync_state_e sync_support;
+ account_get_sync_support(handle, &sync_support);
+ ACCOUNT_SLOGD("account_get_sync_support : %d\n", sync_support);
+
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ test_int = -1;
+ account_get_user_int(handle, i, &test_int);
+ ACCOUNT_SLOGD("_account_get_callback : %d\n", test_int);
+ }
+
+ account_get_capability_all(handle, _capability_get_callback, NULL);
+
+ return TRUE;
+}
+
+static int _account_insert_test_new(void)
+{
+ int ret = -1;
+
+ account_h account = NULL;
+ int temp_int = -1;
+
+ ret = account_connect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ char temp[128];
+ memset(temp, 0x00, sizeof(temp));
+
+ ret = account_create(&account);
+ ACCOUNT_SLOGD("account_set_user_name: Enter User Name to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_user_name(account, temp);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ memset(temp, 0x00, sizeof(temp));
+ ACCOUNT_SLOGD("account_set_display_name: Enter display Name to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_display_name(account, temp);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ memset(temp, 0x00, sizeof(temp));
+ ACCOUNT_SLOGD("account_set_domain_name: Enter domain Name to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_domain_name(account, temp);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ memset(temp, 0x00, sizeof(temp));
+ ACCOUNT_SLOGD("account_set_email_address: Enter email Name to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+ ret = account_set_email_address(account, temp);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ memset(temp, 0x00, sizeof(temp));
+ ACCOUNT_SLOGD("account_set_package_name: Enter package Name to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_package_name(account, temp);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ memset(temp, 0x00, sizeof(temp));
+ ACCOUNT_SLOGD("account_set_icon_path: Enter icon path to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_icon_path(account, temp);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ memset(temp, 0x00, sizeof(temp));
+
+ ACCOUNT_SLOGD("account_set_access_token: Enter access token to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_access_token(account, temp);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ memset(temp, 0x00, sizeof(temp));
+ ACCOUNT_SLOGD("account_set_auth_type: Enter auth type to be set \n");
+ if (scanf("%d", &temp_int) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_auth_type( account, temp_int );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ temp_int = -1;
+ ACCOUNT_SLOGD("account_set_secret: Enter secret to be set \n");
+ if (scanf("%d", &temp_int) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_secret( account, temp_int );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ temp_int = -1;
+ ACCOUNT_SLOGD("account_set_sync_support: Enter sync support state \n");
+ if (scanf("%d", &temp_int) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_sync_support( account, temp_int );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ memset(temp, 0x00, sizeof(temp));
+ ACCOUNT_SLOGD("account_set_source: Enter source to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+ ret = account_set_source(account, temp);
+
+ int i;
+
+ for(i=0;i<USER_TXT_CNT;i++)
+ {
+ memset(temp, 0x00, sizeof(temp));
+ ACCOUNT_SLOGD("account_set_user_text [%d]: Enter user text to be set \n", i);
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+ ret = account_set_user_text(account, i, temp);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+
+ }
+
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ temp_int = -1;
+ ACCOUNT_SLOGD("account_set_user_int [%d]: Enter user int to be set \n", i);
+ if (scanf("%d", &temp_int) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+ ret = account_set_user_int(account, i, temp_int);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+ }
+
+ int cap_key = -1;
+ int cap_value = -1;
+ int want_to_enter_more_cap = 1;
+ while (want_to_enter_more_cap){
+ ACCOUNT_SLOGD("account_set_capability: Enter capability key to set \n");
+ if (scanf("%d", &cap_key) != 1) {
+ ACCOUNT_SLOGD("Scanf Failed!!!\n");
+ exit(0);
+ }
+ ACCOUNT_SLOGD("account_set_capability: Enter capability value to set \n");
+ if (scanf("%d", &cap_value) != 1 ) {
+ ACCOUNT_SLOGD("Scanf Failed!!!\n");
+ exit(0);
+ }
+ ret = account_set_capability(account, ACCOUNT_SUPPORTS_CAPABILITY_TIZEN_EMAIL, cap_value);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ACCOUNT_SLOGD("account_set_capability: Want to set more capabilitiy key value then enter 1 else 0 \n");
+ if (scanf("%d", &temp_int) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+ if (temp_int == 1)
+ want_to_enter_more_cap = 1;
+ else
+ want_to_enter_more_cap = 0;
+ }
+ int account_id = -1;
+ ret = account_insert_to_db(account, &account_id);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return -1;
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return account_id;
+}
+
+#if 0
+static int _account_insert_test(void)
+{
+ int ret = -1;
+
+ account_h account = NULL;
+
+ ACCOUNT_SLOGD("account_connect returns %d\n", ret);
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p\n", account);
+
+ ret = account_set_user_name(account, "wy1115.lee");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "Wonyoung Lee");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "Samsung electronics");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_email_address(account, "urusa77@gmail.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_package_name(account, "com.samsung.account");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_icon_path(account, "icon-path");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_access_token(account, "ACCESSTOKEN");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_auth_type( account, ACCOUNT_AUTH_TYPE_OAUTH );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_secret( account, ACCOUNT_SECRECY_INVISIBLE);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_source(account, "URUSA inc.");
+
+ int i;
+
+ for(i=0;i<USER_TXT_CNT;i++)
+ {
+ ret = account_set_user_text(account, i, "user txt");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+
+ }
+
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ ret = account_set_user_int(account, i, 888);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+ }
+
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_CONTACT, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_CALENDAR, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_PHOTO, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_VIDEO, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_EMAIL, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_STATUS_POST, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_VOIP, ACCOUNT_CAPABILITY_ENABLED);
+ //ret = account_set_capability(account, ACCOUNT_CAPABILITY_IM, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_SAMSUNG_APPS, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_MOBILE_TRACKER, ACCOUNT_CAPABILITY_ENABLED);
+
+ int account_id = -1;
+ ret = account_insert_to_db(account, &account_id);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ return -1;
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account=NULL;
+
+ ACCOUNT_SLOGD("account_connect returns %d\n", ret);
+
+ ret = account_create(&account);
+
+ account_query_account_by_account_id(account_id, &account);
+ _account_get_account_info(account);
+
+ account_query_capability_by_account_id(_capability_get_callback, account_id, NULL);
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+
+ account=NULL;
+
+ ACCOUNT_SLOGD("account_connect returns %d\n", ret);
+
+ ret = account_create(&account);
+
+ account_query_account_by_user_name(_account_get_callback, "usernamed-wy1115", NULL);
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ return account_id;
+}
+#endif
+
+static int _account_update_test_new_by_user_name(char *user_name, char *package_name)
+{
+ int ret = -1;
+
+ account_h account = NULL;
+ int temp_int = -1;
+
+ char temp[128];
+ memset(temp, 0x00, sizeof(temp));
+ ret = account_connect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_create(&account);
+ ACCOUNT_SLOGD("account_set_user_name: Enter User Name to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_user_name(account, temp);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ memset(temp, 0x00, sizeof(temp));
+
+ ACCOUNT_SLOGD("account_set_display_name: Enter display Name to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_display_name(account, temp);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ memset(temp, 0x00, sizeof(temp));
+
+ ACCOUNT_SLOGD("account_set_domain_name: Enter domain Name to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_domain_name(account, temp);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ memset(temp, 0x00, sizeof(temp));
+
+ ACCOUNT_SLOGD("account_set_email_address: Enter email Name to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+ ret = account_set_email_address(account, temp);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ memset(temp, 0x00, sizeof(temp));
+
+ ACCOUNT_SLOGD("account_set_package_name: Enter package Name to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_package_name(account, temp);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ memset(temp, 0x00, sizeof(temp));
+
+ ACCOUNT_SLOGD("account_set_icon_path: Enter icon path to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_icon_path(account, temp);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ memset(temp, 0x00, sizeof(temp));
+
+ ACCOUNT_SLOGD("account_set_access_token: Enter access token to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_access_token(account, temp);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ memset(temp, 0x00, sizeof(temp));
+
+ ACCOUNT_SLOGD("account_set_auth_type: Enter auth type to be set \n");
+ if (scanf("%d", &temp_int) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_auth_type( account, temp_int );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ temp_int = -1;
+ ACCOUNT_SLOGD("account_set_secret: Enter secret to be set \n");
+ if (scanf("%d", &temp_int) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_secret( account, temp_int );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ temp_int = -1;
+ ACCOUNT_SLOGD("account_set_sync_support: Enter sync support state \n");
+ if (scanf("%d", &temp_int) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_sync_support( account, temp_int );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ memset(temp, 0x00, sizeof(temp));
+
+ ACCOUNT_SLOGD("account_set_source: Enter source to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+ ret = account_set_source(account, temp);
+
+ int i;
+
+ for(i=0;i<USER_TXT_CNT;i++)
+ {
+ memset(temp, 0x00, sizeof(temp));
+
+ ACCOUNT_SLOGD("account_set_user_text [%d]: Enter user text to be set \n", i);
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+ ret = account_set_user_text(account, i, temp);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+
+ }
+
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ temp_int = -1;
+ ACCOUNT_SLOGD("account_set_user_int [%d]: Enter user int to be set \n", i);
+ if (scanf("%d", &temp_int) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+ ret = account_set_user_int(account, i, temp_int);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+ }
+
+ int cap_key = -1;
+ int cap_value = -1;
+ int want_to_enter_more_cap = 1;
+ while (want_to_enter_more_cap){
+ ACCOUNT_SLOGD("account_set_capability: Enter capability key to set \n");
+ if (scanf("%d", &cap_key) != 1 ) {
+ ACCOUNT_SLOGD("Scanf Failed!!!\n");
+ exit(0);
+ }
+ ACCOUNT_SLOGD("account_set_capability: Enter capability value to set \n");
+ if (scanf("%d", &cap_value) != 1) {
+ ACCOUNT_SLOGD("Scanf Failed!!!\n");
+ exit(0);
+ }
+ ret = account_set_capability(account, ACCOUNT_SUPPORTS_CAPABILITY_TIZEN_EMAIL, cap_value);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ACCOUNT_SLOGD("account_set_capability: Want to set more capabilitiy key value then enter 1 else 0 \n");
+ if (scanf("%d", &temp_int) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+ if (temp_int == 1)
+ want_to_enter_more_cap = 1;
+ else
+ want_to_enter_more_cap = 0;
+ }
+
+
+ ret = account_update_to_db_by_user_name(account, user_name, package_name);
+
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ return ret;
+
+}
+
+
+static int _account_update_test_new(int account_id)
+{
+
+ int ret = -1;
+
+ account_h account = NULL;
+ int temp_int = -1;
+
+ char temp[128];
+ memset(temp, 0x00, sizeof(temp));
+ ret = account_connect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+
+ ret = account_create(&account);
+ ACCOUNT_SLOGD("account_set_user_name: Enter User Name to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_user_name(account, temp);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ memset(temp, 0x00, sizeof(temp));
+
+ ACCOUNT_SLOGD("account_set_display_name: Enter display Name to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_display_name(account, temp);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ memset(temp, 0x00, sizeof(temp));
+ ACCOUNT_SLOGD("account_set_domain_name: Enter domain Name to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_domain_name(account, temp);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ memset(temp, 0x00, sizeof(temp));
+ ACCOUNT_SLOGD("account_set_email_address: Enter email Name to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+ ret = account_set_email_address(account, temp);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ memset(temp, 0x00, sizeof(temp));
+
+ ACCOUNT_SLOGD("account_set_package_name: Enter package Name to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_package_name(account, temp);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ memset(temp, 0x00, sizeof(temp));
+
+ ACCOUNT_SLOGD("account_set_icon_path: Enter icon path to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_icon_path(account, temp);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ memset(temp, 0x00, sizeof(temp));
+
+ ACCOUNT_SLOGD("account_set_access_token: Enter access token to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_access_token(account, temp);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ memset(temp, 0x00, sizeof(temp));
+
+ ACCOUNT_SLOGD("account_set_auth_type: Enter auth type to be set \n");
+ if (scanf("%d", &temp_int) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_auth_type( account, temp_int );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ temp_int = -1;
+ ACCOUNT_SLOGD("account_set_secret: Enter secret to be set \n");
+ if (scanf("%d", &temp_int) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_secret( account, temp_int );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ temp_int = -1;
+ ACCOUNT_SLOGD("account_set_sync_support: Enter sync support state \n");
+ if (scanf("%d", &temp_int) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+
+ ret = account_set_sync_support( account, temp_int );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ memset(temp, 0x00, sizeof(temp));
+
+ ACCOUNT_SLOGD("account_set_source: Enter source to be set \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+ ret = account_set_source(account, temp);
+
+ int i;
+
+ for(i=0;i<USER_TXT_CNT;i++)
+ {
+ memset(temp, 0x00, sizeof(temp));
+
+ ACCOUNT_SLOGD("account_set_user_text [%d]: Enter user text to be set \n", i);
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+ ret = account_set_user_text(account, i, temp);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+
+ }
+
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ temp_int = -1;
+ ACCOUNT_SLOGD("account_set_user_int [%d]: Enter user int to be set \n", i);
+ if (scanf("%d", &temp_int) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+ ret = account_set_user_int(account, i, temp_int);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+ }
+
+ int cap_key = -1;
+ int cap_value = -1;
+ int want_to_enter_more_cap = 1;
+ while (want_to_enter_more_cap){
+ ACCOUNT_SLOGD("account_set_capability: Enter capability key to set \n");
+ if (scanf("%d", &cap_key) != 1) {
+ ACCOUNT_SLOGD("Scanf Failed!!!\n");
+ exit(0);
+ }
+ ACCOUNT_SLOGD("account_set_capability: Enter capability value to set \n");
+ if (scanf("%d", &cap_value) != 1) {
+ ACCOUNT_SLOGD("Scanf Failed!!!\n");
+ exit(0);
+ }
+ ret = account_set_capability(account, ACCOUNT_SUPPORTS_CAPABILITY_TIZEN_EMAIL, cap_value);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ACCOUNT_SLOGD("account_set_capability: Want to set more capabilitiy key value then enter 1 else 0 \n");
+ if (scanf("%d", &temp_int) != 1) {
+ ACCOUNT_SLOGD("scanf Failed !!!! \n");
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ return ret;
+ }
+ if (temp_int == 1)
+ want_to_enter_more_cap = 1;
+ else
+ want_to_enter_more_cap = 0;
+ }
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ return ret;
+}
+
+#if 0
+static int _account_update_test(int account_id)
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+
+ ret = account_create(&account);
+
+ ret = account_set_user_name(account, "updated-wy1115");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "updated-Wonyoung Lee");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "updated-Samsung Facebook");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_email_address(account, "updated-urusa77@gmail.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_package_name(account, "updated-com.samsung.account");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_icon_path(account, "updated-icon-path");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_access_token(account, "updated-ACCESSTOKEN");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_auth_type( account, ACCOUNT_AUTH_TYPE_OAUTH );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_secret( account, ACCOUNT_SECRECY_INVISIBLE);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_source(account, "updated-URUSA inc.");
+
+ int i;
+
+ for(i=0;i<USER_TXT_CNT;i++)
+ {
+ ret = account_set_user_text(account, i, "updated-user txt");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+
+ }
+
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ ret = account_set_user_int(account, i, 111);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+ }
+
+
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_PHOTO, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_VIDEO, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_STATUS_POST, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_SAMSUNG_APPS, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_MOBILE_TRACKER, ACCOUNT_CAPABILITY_ENABLED);
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ return ret;
+
+}
+
+static int _account_update_test_by_username()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+
+ ret = account_create(&account);
+
+ ret = account_set_user_name(account, "usernamed-wy1115");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "usernamed-Wonyoung Lee");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "usernamed-Samsung Facebook");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_email_address(account, "usernamed-urusa77@gmail.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_package_name(account, "usernamed-com.samsung.account");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_icon_path(account, "usernamed-icon-path");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_access_token(account, "usernamed-ACCESSTOKEN");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_auth_type( account, ACCOUNT_AUTH_TYPE_OAUTH );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_secret( account, ACCOUNT_SECRECY_INVISIBLE);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_source(account, "updated-URUSA inc.");
+
+ int i;
+
+ for(i=0;i<USER_TXT_CNT;i++)
+ {
+ ret = account_set_user_text(account, i, "usernamed-user txt");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+
+ }
+
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ ret = account_set_user_int(account, i, 111);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+ }
+
+
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_PHOTO, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_VIDEO, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_VOIP, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_SAMSUNG_APPS, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_CAPABILITY_STATUS_POST, ACCOUNT_CAPABILITY_ENABLED);
+
+ ret = account_update_to_db_by_user_name(account, "updated-wy1115", "updated-com.samsung.account");
+
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ return ret;
+
+}
+
+static int _account_test_capability()
+{
+ GSList* list = NULL;
+ GSList* iter = NULL;
+ int glist_len = 0;
+
+ list = g_slist_append(list, strdup("test 1"));
+ list = g_slist_append(list, strdup("test 2"));
+ list = g_slist_append(list, strdup("test 3"));
+ list = g_slist_append(list, strdup("test 4"));
+ list = g_slist_append(list, strdup("test 5"));
+ list = g_slist_append(list, strdup("test 6"));
+
+ glist_len = g_slist_length( list );
+
+ int capability_count = g_slist_length( list );
+
+ int binding_bufsize = 2+2*(capability_count*2)+1;
+
+ int binding_buf_index = 0;
+ char* binding_buf = (char*)malloc(sizeof(char)*binding_bufsize);
+
+ memset(binding_buf, 0, sizeof(char)*binding_bufsize);
+
+ binding_buf[binding_buf_index++]='(';
+
+ ACCOUNT_SLOGD("(%d)Binding buf = %s\n", __LINE__,binding_buf);
+
+ int i;
+
+ for(i=0;i<capability_count;i++)
+ {
+ /*snprintf(binding_buf+binding_buf_index, strlen(binding_buf)+2, "%s?,", binding_buf);*/
+ binding_buf[binding_buf_index++]='?';
+ if(i != capability_count -1)
+ binding_buf[binding_buf_index++]=',';
+ ACCOUNT_SLOGD("(%d)Binding buf = %s\n", __LINE__,binding_buf);
+ }
+
+ binding_buf[binding_buf_index]=')';
+
+ ACCOUNT_SLOGD("(%d)Binding buf = %s\n", __LINE__,binding_buf);
+
+ ACCOUNT_SLOGD("Length %d\n", glist_len);
+
+ for (iter = list; iter != NULL; iter = g_slist_next(iter))
+ {
+ char* capa;
+ capa = (char *)iter->data;
+ ACCOUNT_SLOGD("%s\n", (char *)iter->data);
+ g_free(capa);
+ }
+
+
+ g_slist_free(list);
+ g_free(binding_buf);
+ return 0;
+}
+#endif
+
+static int utc1_account_insert()
+{
+
+ int ret = -1;
+ account_h account = NULL;
+ int account_id = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p, ret = %d \n", account, ret);
+
+ ret = account_insert_to_db(account, &account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return account_id;
+}
+
+static int utc2_account_insert()
+{
+
+ int ret = -1;
+ account_h account = NULL;
+ int account_id = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p, ret = %d \n", account, ret);
+
+ ret = account_set_user_name(account, NULL);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_insert_to_db(account, &account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return account_id;
+}
+
+
+
+
+static int utc3_account_insert()
+{
+
+ int ret = -1;
+ account_h account = NULL;
+ int account_id = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p, ret = %d \n", account, ret);
+
+ ret = account_set_user_name(account, "11111111111111111111111111111111111 \
+ 2222222222222222222222222222222222222222222222222 \
+ 3333333333333333333333333333333333333333333333333\
+ 4444444444444444444444444444444444444444444444444\
+ 5555555555555555555555555555555555555555555555555\
+ 666666666666666666666666666666666666666666666666\
+ 777777777777777777777777777777777777777777777777\
+ 888888888888888888888888888888888888888888888888\
+ 99999999999999999999999999999999999999999999999\
+ 111111111111111111111111111111111111111111111111\
+ 22222222222222222222222222222222222222222222222\
+ 333333333333333333333333333333333333333333333\
+ 444444444444444444444444444444444444444444\
+ 444444444444444444444444444444444444444444444444\
+ 555555555555555555555555555555555555555555555555 \
+ 66666666666666666666666666666666666666666666666666\
+ 777777777777777777777777777777777777777777777777779999999999999999999999999999999999999999\
+ 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\
+ 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_insert_to_db(account, &account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return account_id;
+}
+
+static int utc4_account_insert()
+{
+
+ int ret = -1;
+ account_h account = NULL;
+ int account_id = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p, ret = %d \n", account, ret);
+
+ ret = account_set_user_name(account, "tarun.kr");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, NULL);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_insert_to_db(account, &account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return account_id;
+}
+
+static int utc5_account_insert()
+{
+
+ int ret = -1;
+ account_h account = NULL;
+ int account_id = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p, ret = %d \n", account, ret);
+
+ ret = account_set_user_name(account, "tarun.kr");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "tarun kumar");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, NULL);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_insert_to_db(account, &account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return account_id;
+}
+
+static int utc6_account_insert()
+{
+
+ int ret = -1;
+ account_h account = NULL;
+ int account_id = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p, ret = %d \n", account, ret);
+
+ ret = account_set_user_name(account, "tarun.kr");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "tarun kumar");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "Samsung");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_insert_to_db(account, &account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return account_id;
+}
+
+static int utc7_account_insert()
+{
+
+ int ret = -1;
+ account_h account = NULL;
+ int account_id = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p, ret = %d \n", account, ret);
+
+ ret = account_set_user_name(account, "tarun.kr");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "tarun kumar");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "Samsung");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_email_address(account, NULL);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_insert_to_db(account, &account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return account_id;
+}
+
+static int utc8_account_insert()
+{
+
+ int ret = -1;
+ account_h account = NULL;
+ int account_id = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p, ret = %d \n", account, ret);
+
+ ret = account_set_user_name(account, "tarun.kr");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "tarun kumar");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "Samsung");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_email_address(account, "tarun.kr@samsung.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_insert_to_db(account, &account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return account_id;
+}
+
+static int utc9_account_insert()
+{
+
+ int ret = -1;
+ account_h account = NULL;
+ int account_id = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p, ret = %d \n", account, ret);
+
+ ret = account_set_user_name(account, "tarun.kr");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "tarun kumar");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "Samsung");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_email_address(account, "tarun.kr@samsung.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_package_name(account, NULL);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_insert_to_db(account, &account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return account_id;
+}
+
+static int utc10_account_insert()
+{
+
+ int ret = -1;
+ account_h account = NULL;
+ int account_id = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p, ret = %d \n", account, ret);
+
+ ret = account_set_user_name(account, "tarun.kr");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "tarun kumar");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "Samsung");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_email_address(account, "tarun.kr@samsung.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_package_name(account, "com.samsung.accounts");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_insert_to_db(account, &account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return account_id;
+}
+
+static int utc11_account_insert()
+{
+
+ int ret = -1;
+ account_h account = NULL;
+ int account_id = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p, ret = %d \n", account, ret);
+
+ ret = account_set_user_name(account, "tarun.kr");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "tarun kumar");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "Samsung");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_email_address(account, "tarun.kr@samsung.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_package_name(account, "com.samsung.accounts");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_icon_path(account, NULL);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_insert_to_db(account, &account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return account_id;
+}
+
+static int utc12_account_insert()
+{
+
+ int ret = -1;
+ account_h account = NULL;
+ int account_id = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p, ret = %d \n", account, ret);
+
+ ret = account_set_user_name(account, "tarun.kr");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "tarun kumar");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "Samsung");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_email_address(account, "tarun.kr@samsung.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_package_name(account, "com.samsung.accounts");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_icon_path(account, "/test/test.jpg");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_insert_to_db(account, &account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return account_id;
+}
+
+static int utc13_account_insert()
+{
+
+ int ret = -1;
+ account_h account = NULL;
+ int account_id = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p, ret = %d \n", account, ret);
+
+ ret = account_set_user_name(account, "tarun.kr");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "tarun kumar");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "Samsung");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_email_address(account, "tarun.kr@samsung.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_package_name(account, "com.samsung.accounts");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_icon_path(account, "/test/test.jpg");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_access_token(account, NULL);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+
+ ret = account_insert_to_db(account, &account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return account_id;
+}
+
+static int utc14_account_insert()
+{
+
+ int ret = -1;
+ account_h account = NULL;
+ int account_id = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p, ret = %d \n", account, ret);
+
+ ret = account_set_user_name(account, "tarun.kr");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "tarun kumar");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "Samsung");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_email_address(account, "tarun.kr@samsung.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_package_name(account, "com.samsung.accounts");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_icon_path(account, "/test/test.jpg");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_access_token(account, "xxxx/yyyy/zzzz/-&abc");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+
+ ret = account_insert_to_db(account, &account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return account_id;
+}
+
+static int utc15_account_insert()
+{
+
+ int ret = -1;
+ account_h account = NULL;
+ int account_id = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p, ret = %d \n", account, ret);
+
+ ret = account_set_user_name(account, "tarun.kr");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "tarun kumar");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "Samsung");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_email_address(account, "tarun.kr@samsung.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_package_name(account, "com.samsung.accounts");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_icon_path(account, "/test/test.jpg");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_access_token(account, "xxxx/yyyy/zzzz/-&abc");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_auth_type( account, ACCOUNT_AUTH_TYPE_OAUTH );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_secret( account, ACCOUNT_SECRECY_INVISIBLE);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_insert_to_db(account, &account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return account_id;
+}
+
+static int utc16_account_insert()
+{
+
+ int ret = -1;
+ account_h account = NULL;
+ int account_id = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p, ret = %d \n", account, ret);
+
+ ret = account_set_user_name(account, "tarun.kr");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "tarun kumar");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "Samsung");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_email_address(account, "tarun.kr@samsung.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_package_name(account, "com.samsung.accounts");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_icon_path(account, "/test/test.jpg");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_access_token(account, "xxxx/yyyy/zzzz/-&abc");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_auth_type( account, ACCOUNT_AUTH_TYPE_OAUTH );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_secret( account, ACCOUNT_SECRECY_INVISIBLE);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_insert_to_db(account, &account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return account_id;
+}
+
+static int utc17_account_insert()
+{
+
+ int ret = -1;
+ account_h account = NULL;
+ int account_id = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p, ret = %d \n", account, ret);
+
+ ret = account_set_user_name(account, "tarun.kr");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "tarun kumar");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "Samsung");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_email_address(account, "tarun.kr@samsung.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_package_name(account, "com.samsung.accounts");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_icon_path(account, "/test/test.jpg");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_access_token(account, "xxxx/yyyy/zzzz/-&abc");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_auth_type( account, ACCOUNT_AUTH_TYPE_OAUTH );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_secret( account, ACCOUNT_SECRECY_INVISIBLE);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_source(account, NULL);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_insert_to_db(account, &account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return account_id;
+}
+
+static int utc18_account_insert()
+{
+
+ int ret = -1;
+ account_h account = NULL;
+ int account_id = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p, ret = %d \n", account, ret);
+
+ ret = account_set_user_name(account, "tarun.kr");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "tarun kumar");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "Samsung");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_email_address(account, "tarun.kr@samsung.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_package_name(account, "com.samsung.accounts");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_icon_path(account, "/test/test.jpg");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_access_token(account, "xxxx/yyyy/zzzz/-&abc");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_auth_type( account, ACCOUNT_AUTH_TYPE_OAUTH );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_secret( account, ACCOUNT_SECRECY_INVISIBLE);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_source(account, "URUSA inc.");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_insert_to_db(account, &account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return account_id;
+}
+
+static int utc19_account_insert()
+{
+
+ int ret = -1;
+ account_h account = NULL;
+ int account_id = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p, ret = %d \n", account, ret);
+
+ ret = account_set_user_name(account, "tarun.kr");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "tarun kumar");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "Samsung");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_email_address(account, "tarun.kr@samsung.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_package_name(account, "com.samsung.accounts");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_icon_path(account, "/test/test.jpg");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_access_token(account, "xxxx/yyyy/zzzz/-&abc");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_auth_type( account, ACCOUNT_AUTH_TYPE_OAUTH );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_secret( account, ACCOUNT_SECRECY_INVISIBLE);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_source(account, "URUSA inc.");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ int i;
+
+ for(i=0; i<USER_TXT_CNT; i++)
+ {
+ ret = account_set_user_text(account, i, NULL);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+
+ }
+ ret = account_insert_to_db(account, &account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return account_id;
+}
+
+static int utc20_account_insert()
+{
+
+ int ret = -1;
+ account_h account = NULL;
+ int account_id = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p, ret = %d \n", account, ret);
+
+ ret = account_set_user_name(account, "tarun.kr");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "tarun kumar");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "Samsung");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_email_address(account, "tarun.kr@samsung.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_package_name(account, "com.samsung.accounts");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_icon_path(account, "/test/test.jpg");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_access_token(account, "xxxx/yyyy/zzzz/-&abc");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_auth_type( account, ACCOUNT_AUTH_TYPE_OAUTH );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_secret( account, ACCOUNT_SECRECY_INVISIBLE);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_source(account, "URUSA inc.");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ int i;
+
+ for(i=0; i<USER_TXT_CNT; i++)
+ {
+ ret = account_set_user_text(account, i, "user txt");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+
+ }
+ ret = account_insert_to_db(account, &account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return account_id;
+}
+
+static int utc21_account_insert()
+{
+
+ int ret = -1;
+ account_h account = NULL;
+ int account_id = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p, ret = %d \n", account, ret);
+
+ ret = account_set_user_name(account, "tarun.kr");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "tarun kumar");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "Samsung");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_email_address(account, "tarun.kr@samsung.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_package_name(account, "com.samsung.accounts");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_icon_path(account, "/test/test.jpg");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_access_token(account, "xxxx/yyyy/zzzz/-&abc");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_auth_type( account, ACCOUNT_AUTH_TYPE_OAUTH );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_secret( account, ACCOUNT_SECRECY_INVISIBLE);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_source(account, "URUSA inc.");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ int i;
+
+ for(i=0; i<USER_TXT_CNT; i++)
+ {
+ ret = account_set_user_text(account, i, "user txt");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+
+ }
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ ret = account_set_user_int(account, i, 000);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+ }
+ ret = account_insert_to_db(account, &account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return account_id;
+}
+
+static int utc22_account_insert()
+{
+
+ int ret = -1;
+ account_h account = NULL;
+ int account_id = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p, ret = %d \n", account, ret);
+
+ ret = account_set_user_name(account, "tarun.kr");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "tarun kumar");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "Samsung");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_email_address(account, "tarun.kr@samsung.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_package_name(account, "com.samsung.accounts");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_icon_path(account, "/test/test.jpg");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_access_token(account, "xxxx/yyyy/zzzz/-&abc");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_auth_type( account, ACCOUNT_AUTH_TYPE_OAUTH );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_secret( account, ACCOUNT_SECRECY_INVISIBLE);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_source(account, "URUSA inc.");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ int i;
+
+ for(i=0; i<USER_TXT_CNT; i++)
+ {
+ ret = account_set_user_text(account, i, "user txt");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+
+ }
+
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ ret = account_set_user_int(account, i, 888);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+ }
+ ret = account_insert_to_db(account, &account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return account_id;
+}
+
+static int utc23_account_insert()
+{
+
+ int ret = -1;
+ account_h account = NULL;
+ int account_id = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ ACCOUNT_SLOGD("account = %p, ret = %d \n", account, ret);
+
+ ret = account_set_user_name(account, "tarun.kr");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_display_name(account, "tarun kumar");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_domain_name(account, "Samsung");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_email_address(account, "tarun.kr@samsung.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_package_name(account, "com.samsung.accounts");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_icon_path(account, "/test/test.jpg");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_access_token(account, "xxxx/yyyy/zzzz/-&abc");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_auth_type( account, ACCOUNT_AUTH_TYPE_OAUTH );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_secret( account, ACCOUNT_SECRECY_INVISIBLE);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_set_source(account, "URUSA inc.");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ int i;
+
+ for(i=0; i<USER_TXT_CNT; i++)
+ {
+ ret = account_set_user_text(account, i, "user txt");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+
+ }
+
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ ret = account_set_user_int(account, i, 888);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+ }
+
+ ret = account_set_capability(account, ACCOUNT_SUPPORTS_CAPABILITY_CONTACT, ACCOUNT_CAPABILITY_ENABLED);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_capability(account, ACCOUNT_SUPPORTS_CAPABILITY_POST, ACCOUNT_CAPABILITY_ENABLED);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_insert_to_db(account, &account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p , account_id = %d\n", __LINE__, ret, account, account_id);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return account_id;
+}
+
+static int utc1_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_update_to_db_by_id(account, 0);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc2_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_update_to_db_by_id(account, -999);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc3_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_update_to_db_by_id(account, 555);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc4_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, NULL);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc5_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, "updated-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc6_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, "updated-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_display_name(account, NULL);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc7_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, "updated-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_display_name(account, "updated-tarun kumar");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc8_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, "updated-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_display_name(account, "updated-tarun kumar");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_domain_name(account, NULL);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_domain_name(account, NULL);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+static int utc9_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, "updated-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_display_name(account, "updated-tarun kumar");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_domain_name(account, "updated-Samsung Facebook");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc10_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, "updated-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_display_name(account, "updated-tarun kumar");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_domain_name(account, "updated-Samsung Facebook");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_email_address(account, NULL);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc11_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, "updated-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_display_name(account, "updated-tarun kumar");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_domain_name(account, "updated-Samsung Facebook");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_email_address(account, "updated-urusa77@gmail.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc12_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, "updated-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_display_name(account, "updated-tarun kumar");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_domain_name(account, "updated-Samsung Facebook");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_email_address(account, "updated-urusa77@gmail.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_package_name(account, NULL);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc13_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, "updated-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_display_name(account, "updated-tarun kumar");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_domain_name(account, "updated-Samsung Facebook");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_email_address(account, "updated-urusa77@gmail.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_package_name(account, "updated-com.samsung.account");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc14_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, "updated-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_display_name(account, "updated-tarun kumar");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_domain_name(account, "updated-Samsung Facebook");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_email_address(account, "updated-urusa77@gmail.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_package_name(account, "updated-com.samsung.account");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_icon_path(account, NULL);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc15_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, "updated-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_display_name(account, "updated-tarun kumar");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_domain_name(account, "updated-Samsung Facebook");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_email_address(account, "updated-urusa77@gmail.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_package_name(account, "updated-com.samsung.account");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_icon_path(account, "updated-icon-path");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc16_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, "updated-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_display_name(account, "updated-tarun kumar");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_domain_name(account, "updated-Samsung Facebook");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_email_address(account, "updated-urusa77@gmail.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_package_name(account, "updated-com.samsung.account");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_icon_path(account, "updated-icon-path");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_access_token(account, NULL);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc17_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, "updated-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_display_name(account, "updated-tarun kumar");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_domain_name(account, "updated-Samsung Facebook");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_email_address(account, "updated-urusa77@gmail.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_package_name(account, "updated-com.samsung.account");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_icon_path(account, "updated-icon-path");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_access_token(account, "updated-ACCESSTOKEN");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc18_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, "updated-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_display_name(account, "updated-tarun kumar");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_domain_name(account, "updated-Samsung Facebook");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_email_address(account, "updated-urusa77@gmail.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_package_name(account, "updated-com.samsung.account");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_icon_path(account, "updated-icon-path");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_access_token(account, "updated-ACCESSTOKEN");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_auth_type( account, ACCOUNT_AUTH_TYPE_OAUTH );
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_secret( account, ACCOUNT_SECRECY_INVISIBLE);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc19_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, "updated-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_display_name(account, "updated-tarun kumar");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_domain_name(account, "updated-Samsung Facebook");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_email_address(account, "updated-urusa77@gmail.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_package_name(account, "updated-com.samsung.account");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_icon_path(account, "updated-icon-path");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_access_token(account, "updated-ACCESSTOKEN");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_source(account, NULL);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc20_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, "updated-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_display_name(account, "updated-tarun kumar");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_domain_name(account, "updated-Samsung Facebook");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_email_address(account, "updated-urusa77@gmail.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_package_name(account, "updated-com.samsung.account");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_icon_path(account, "updated-icon-path");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_access_token(account, "updated-ACCESSTOKEN");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_source(account, "updated-URUSA inc.");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc21_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, "updated-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_display_name(account, "updated-tarun kumar");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_domain_name(account, "updated-Samsung Facebook");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_email_address(account, "updated-urusa77@gmail.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_package_name(account, "updated-com.samsung.account");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_icon_path(account, "updated-icon-path");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_access_token(account, "updated-ACCESSTOKEN");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_source(account, "updated-URUSA inc.");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ int i;
+
+ for(i=0;i<USER_TXT_CNT;i++)
+ {
+ ret = account_set_user_text(account, i, NULL);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+
+ }
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc22_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, "updated-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_display_name(account, "updated-tarun kumar");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_domain_name(account, "updated-Samsung Facebook");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_email_address(account, "updated-urusa77@gmail.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_package_name(account, "updated-com.samsung.account");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_icon_path(account, "updated-icon-path");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_access_token(account, "updated-ACCESSTOKEN");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_source(account, "updated-URUSA inc.");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ int i;
+ for(i=0;i<USER_TXT_CNT;i++)
+ {
+ ret = account_set_user_text(account, i, "updated-user txt");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+
+ }
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc23_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, "updated-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_display_name(account, "updated-tarun kumar");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_domain_name(account, "updated-Samsung Facebook");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_email_address(account, "updated-urusa77@gmail.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_package_name(account, "updated-com.samsung.account");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_icon_path(account, "updated-icon-path");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_access_token(account, "updated-ACCESSTOKEN");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_source(account, "updated-URUSA inc.");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ int i;
+ for(i=0;i<USER_TXT_CNT;i++)
+ {
+ ret = account_set_user_text(account, i, "updated-user txt");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+
+ }
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ ret = account_set_user_int(account, i, -111);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+ }
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc24_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, "updated-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_display_name(account, "updated-tarun kumar");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_domain_name(account, "updated-Samsung Facebook");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_email_address(account, "updated-urusa77@gmail.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_package_name(account, "updated-com.samsung.account");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_icon_path(account, "updated-icon-path");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_access_token(account, "updated-ACCESSTOKEN");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_source(account, "updated-URUSA inc.");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ int i;
+ for(i=0;i<USER_TXT_CNT;i++)
+ {
+ ret = account_set_user_text(account, i, "updated-user txt");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+
+ }
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ ret = account_set_user_int(account, i, 0);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+ }
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc25_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, "updated-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_display_name(account, "updated-tarun kumar");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_domain_name(account, "updated-Samsung Facebook");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_email_address(account, "updated-urusa77@gmail.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_package_name(account, "updated-com.samsung.account");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_icon_path(account, "updated-icon-path");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_access_token(account, "updated-ACCESSTOKEN");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_source(account, "updated-URUSA inc.");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ int i;
+ for(i=0;i<USER_TXT_CNT;i++)
+ {
+ ret = account_set_user_text(account, i, "updated-user txt");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+
+ }
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ ret = account_set_user_int(account, i, 111);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+ }
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc26_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, "updated-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_display_name(account, "updated-tarun kumar");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_domain_name(account, "updated-Samsung Facebook");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_email_address(account, "updated-urusa77@gmail.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_package_name(account, "updated-com.samsung.account");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_icon_path(account, "updated-icon-path");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_access_token(account, "updated-ACCESSTOKEN");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_source(account, "updated-URUSA inc.");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ int i;
+ for(i=0;i<USER_TXT_CNT;i++)
+ {
+ ret = account_set_user_text(account, i, "updated-user txt");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+
+ }
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ ret = account_set_user_int(account, i, 111);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+ }
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc27_account_update()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ account_set_user_name(account, "updated-tarun.kr");
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_display_name(account, "updated-tarun kumar");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_domain_name(account, "updated-Samsung Facebook");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_email_address(account, "updated-urusa77@gmail.com");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_package_name(account, "updated-com.samsung.account");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_icon_path(account, "updated-icon-path");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_access_token(account, "updated-ACCESSTOKEN");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_set_source(account, "updated-URUSA inc.");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ int i;
+ for(i=0;i<USER_TXT_CNT;i++)
+ {
+ ret = account_set_user_text(account, i, "updated-user txt");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+
+ }
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ ret = account_set_user_int(account, i, 111);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p, i=%d\n", __LINE__, ret, account, i);
+ }
+ }
+ ret = account_set_capability(account, ACCOUNT_SUPPORTS_CAPABILITY_CONTACT, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_SUPPORTS_CAPABILITY_CALENDAR, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_SUPPORTS_CAPABILITY_PHOTO, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_SUPPORTS_CAPABILITY_VIDEO, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_SUPPORTS_CAPABILITY_EMAIL, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_SUPPORTS_CAPABILITY_POST, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_SUPPORTS_CAPABILITY_VOIP, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_SUPPORTS_CAPABILITY_SAMSUNG_APPS, ACCOUNT_CAPABILITY_ENABLED);
+ ret = account_set_capability(account, ACCOUNT_SUPPORTS_CAPABILITY_MOBILE_TRACKER, ACCOUNT_CAPABILITY_ENABLED);
+
+ ret = account_update_to_db_by_id(account, account_id);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+bool _utc1_account_get_callback(account_h handle, void* user_data)
+{
+ ACCOUNT_SLOGD("_account_get_callback handle = %s , user_data = %s \n", (char *)handle, (char *)user_data);
+
+ char *test_text = NULL;
+
+ account_get_user_name(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_display_name(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_email_address(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_icon_path(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_source(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_package_name(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_domain_name(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+
+ _account_free_text(test_text);
+
+ account_get_access_token(handle, &test_text);
+ ACCOUNT_SLOGD("_account_get_callback : %s\n", test_text);
+ _account_free_text(test_text);
+
+ int i=0, test_int=0;
+
+ account_auth_type_e auth_type;
+ account_get_auth_type(handle, &auth_type);
+ ACCOUNT_SLOGD("account_get_auth_type : %d\n", auth_type);
+
+ account_secrecy_state_e secret;
+ account_get_secret(handle, &secret);
+ ACCOUNT_SLOGD("account_get_secret : %d\n", secret);
+
+ account_sync_state_e sync_support;
+ account_get_sync_support(handle, &sync_support);
+ ACCOUNT_SLOGD("account_get_sync_support : %d\n", sync_support);
+
+ for(i=0;i<USER_INT_CNT;i++)
+ {
+ account_get_user_int(handle, i, &test_int);
+ ACCOUNT_SLOGD("_account_get_callback : %d\n", test_int);
+ }
+
+ account_get_capability_all(handle, _capability_get_callback, NULL);
+
+ return TRUE;
+}
+
+
+static int utc1_get_account_by_id()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_query_account_by_account_id(account_id, &account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ _account_get_account_info(account);
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc2_get_account_by_id()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_create(&account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_query_account_by_account_id(account_id, &account);
+
+ _account_get_account_info(account);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_destroy(account);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc1_get_account_by_user_name()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_query_account_by_user_name(_account_get_callback, "usernamed-wy1115", NULL);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc2_get_account_by_user_name()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ char *user_data = "test user_data";
+
+ ret = account_query_account_by_user_name(_account_get_callback, "usernamed-wy1115", (void *)user_data);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc1_get_account_by_capability()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_query_account_by_capability(_account_get_callback, ACCOUNT_SUPPORTS_CAPABILITY_PHOTO, ACCOUNT_CAPABILITY_ENABLED, NULL);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc2_get_account_by_capability()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_query_account_by_capability(_account_get_callback, ACCOUNT_SUPPORTS_CAPABILITY_PHOTO, ACCOUNT_CAPABILITY_DISABLED, NULL);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc3_get_account_by_capability()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_query_account_by_capability(_account_get_callback, ACCOUNT_SUPPORTS_CAPABILITY_PHOTO, -1, NULL);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc4_get_account_by_capability()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_query_account_by_capability(_account_get_callback, ACCOUNT_SUPPORTS_CAPABILITY_PHOTO, ACCOUNT_CAPABILITY_DISABLED, NULL);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc5_get_account_by_capability()
+{
+ int ret = - 1;
+
+ account_h account = NULL;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_query_account_by_capability(_account_get_callback, ACCOUNT_SUPPORTS_CAPABILITY_PHOTO, -1, NULL);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, account=%p\n", __LINE__, ret, account);
+ }
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc1_get_all_accounts()
+{
+ int ret = - 1;
+
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_foreach_account_from_db(_account_get_callback, NULL);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+static int utc2_get_all_accounts()
+{
+ int ret = - 1;
+
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ char *user_data = "test user_data";
+
+ ret = account_foreach_account_from_db(_account_get_callback, (void *)user_data);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d \n", __LINE__, ret);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d \n", __LINE__, ret);
+ }
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ return 1;
+}
+
+bool _utc_capability_get_callback(const char* capability_type, account_capability_state_e capability_value, void* user_data)
+{
+ char* test_type = (char*)capability_type;
+ int test_value = capability_value;
+
+ ACCOUNT_SLOGD("_capability_get_callback test_type = : %s\n", test_type);
+ ACCOUNT_SLOGD("_capability_get_callback test_value = : %d\n", test_value);
+ return TRUE;
+
+}
+
+static int utc1_account_get_capability_by_account_id()
+{
+ int ret = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_query_capability_by_account_id(_utc_capability_get_callback, account_id, NULL);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d,\n", __LINE__, ret);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, \n", __LINE__, ret);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return 1;
+}
+
+static int utc2_account_get_capability_by_account_id()
+{
+ int ret = -1;
+
+ char *user_data = "test user_data";
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_query_capability_by_account_id(_utc_capability_get_callback, account_id, (void *)user_data);
+
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, \n", __LINE__, ret);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return 1;
+}
+
+static int utc_account_delete_by_id()
+{
+ int ret = -1;
+
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_delete_from_db_by_id(account_id);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d, \n", __LINE__, ret);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return 1;
+}
+
+static int utc_account_delete_by_user_name()
+{
+ int ret = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_delete_from_db_by_user_name("usernamed-wy1115", "usernamed-com.samsung.account");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d \n", __LINE__, ret);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d \n", __LINE__, ret);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return 1;
+}
+
+static int utc_account_delete_by_package_name()
+{
+ int ret = -1;
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_delete_from_db_by_package_name("usernamed-com.samsung.account");
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d\n", __LINE__, ret);
+ }
+ else
+ {
+ ACCOUNT_SLOGD("(%d)-[Account-else loop] ret = %d\n", __LINE__, ret);
+ }
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return 1;
+}
+
+static int utc_account_update_sync_status_by_id()
+{
+ int ret = -1;
+
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_update_sync_status_by_id(account_id, ACCOUNT_SYNC_STATUS_IDLE);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return ret;
+}
+
+static int utc_account_get_application_capability_support()
+{
+ int ret = -1;
+ bool test = false;
+
+ ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_get_application_capability_support("com.samsung.facebook", ACCOUNT_SUPPORTS_CAPABILITY_CONTACT, &test);
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ return ret;
+}
+
+static int utc_account_get_and_update()
+{
+ int ret = -1;
+ account_h account = NULL;
+
+ ret = account_connect();
+ ACCOUNT_SLOGD("%s(%d) ret=%x\n", __FUNCTION__, __LINE__, ret);
+
+ ret = account_create(&account);
+ ACCOUNT_SLOGD("%s(%d) ret=%x\n", __FUNCTION__, __LINE__, ret);
+
+ ret = account_query_account_by_account_id( 2, &account);
+ ACCOUNT_SLOGD("%s(%d) ret=%x\n", __FUNCTION__, __LINE__, ret);
+
+ ret = account_set_access_token(account, "ACCESSSSSSSSSSSSSSSSSSSFASFASDGDSFFASDFASFDSDGAASDFASDGDFDFGAFASDFASFASDFASASGSGASDFASFSADDSGASGASGGASDFASDFASGSAASDFAAAG");
+ ACCOUNT_SLOGD("%s(%d) ret=%x\n", __FUNCTION__, __LINE__, ret);
+
+ ret = account_update_to_db_by_id( account, 2);
+ ACCOUNT_SLOGD("%s(%d) ret=%x\n", __FUNCTION__, __LINE__, ret);
+
+ ret = account_destroy(account);
+ ACCOUNT_SLOGD("%s(%d) ret=%x\n", __FUNCTION__, __LINE__, ret);
+
+ ret = account_disconnect();
+ ACCOUNT_SLOGD("%s(%d) ret=%x\n", __FUNCTION__, __LINE__, ret);
+
+ return 1;
+}
+
+int main(int argc, char** argv)
+{
+#if 0
+ utc_notify_account_insert_update_delete();
+#else
+ int account_id = -1;
+ int cap_key = -1;
+ int cap_value = -1;
+ int user_resp = 0;
+ char temp[128];
+ memset(temp, 0x00, sizeof(temp));
+
+ ACCOUNT_SLOGD("\n\n**************************** Account Unit Test case Execution Suite ************************************ \n\n");
+ ACCOUNT_SLOGD("1. Press 1 for account insert test \n");
+ ACCOUNT_SLOGD("2. Press 2 for account update test \n");
+ ACCOUNT_SLOGD("3. Press 3 for account delete test \n");
+ ACCOUNT_SLOGD("4. Press 4 for query account test \n");
+ if (scanf("%d", &user_resp) != 1) {
+ ACCOUNT_SLOGD("Scanf Failed!!!\n");
+ exit(0);
+ }
+
+ if (user_resp == 1) {
+ ACCOUNT_SLOGD("In Account Insert Test Mode \n");
+ account_id = _account_insert_test_new();
+ if(account_id > 0)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] account insert test Success!! account id = %d\n", __LINE__, account_id);
+ }
+ utc_account_get_and_update();
+ } else if (user_resp == 2) {
+ ACCOUNT_SLOGD("In Account Update Test Mode \n");
+ ACCOUNT_SLOGD("1. Press 1 to upadte account by id test \n");
+ ACCOUNT_SLOGD("2. Press 2 for update account by user name test \n");
+ if (scanf("%d", &user_resp) != 1) {
+ ACCOUNT_SLOGD("Scanf Failed!!!\n");
+ exit(0);
+ }
+ if (user_resp == 1) {
+ ACCOUNT_SLOGD("Enter Account Id to be Updated \n");
+ if (scanf("%d", &account_id) != 1){
+ ACCOUNT_SLOGD("Scanf Failed!!!\n");
+ exit(0);
+ }
+ if (_account_update_test_new(account_id) == ACCOUNT_ERROR_NONE)
+ ACCOUNT_SLOGD("Account update Success \n");
+ else
+ ACCOUNT_SLOGD("Account update Failed \n");
+ } else if (user_resp == 2) {
+ ACCOUNT_SLOGD("Enter Account user name to be Updated \n");
+ memset(temp, 0x00, sizeof(temp));
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("Scanf Failed!!!\n");
+ exit(0);
+ }
+ char temp2[128];
+ memset(temp2, 0x00, sizeof(temp2));
+ ACCOUNT_SLOGD("Enter Account package name to be Updated \n");
+ if (scanf("%s", temp2) != 1) {
+ ACCOUNT_SLOGD("Scanf Failed!!!\n");
+ exit(0);
+ }
+ if (_account_update_test_new_by_user_name(temp, temp2) == ACCOUNT_ERROR_NONE)
+ ACCOUNT_SLOGD("Account update Success \n");
+ else
+ ACCOUNT_SLOGD("Account update Failed \n");
+ } else {
+ ACCOUNT_SLOGD("Wrong info entered \n");
+ exit(0);
+ }
+ } else if (user_resp == 3) {
+ ACCOUNT_SLOGD("In Account Delete Test Mode \n");
+ ACCOUNT_SLOGD("1. Press 1 to delete account by id test \n");
+ ACCOUNT_SLOGD("2. Press 2 to delete account by user name test \n");
+ ACCOUNT_SLOGD("3. Press 3 to delete account by package name test \n");
+ if (scanf("%d", &user_resp) != 1) {
+ ACCOUNT_SLOGD("Scanf Failed!!!\n");
+ exit(0);
+ }
+ if (user_resp == 1) {
+ ACCOUNT_SLOGD("Enter Account Id to be Deleted \n");
+ if (scanf("%d", &account_id) != 1) {
+ ACCOUNT_SLOGD("Scanf Failed!!!\n");
+ exit(0);
+ }
+ int ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ if (account_delete_from_db_by_id(account_id) == ACCOUNT_ERROR_NONE)
+ ACCOUNT_SLOGD("Account delete Success \n");
+ else
+ ACCOUNT_SLOGD("Account delete Failed \n");
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ } else if (user_resp == 2) {
+ ACCOUNT_SLOGD("Enter Account user name to be Deleted \n");
+ memset(temp, 0x00, sizeof(temp));
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("Scanf Failed!!!\n");
+ exit(0);
+ }
+ char temp2[128];
+ memset(temp2, 0x00, sizeof(temp2));
+ ACCOUNT_SLOGD("Enter Account package name to be Deleted \n");
+ if (scanf("%s", temp2) != 1) {
+ ACCOUNT_SLOGD("Scanf Failed!!!\n");
+ exit(0);
+ }
+ int ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ if (account_delete_from_db_by_user_name(temp, temp2) == ACCOUNT_ERROR_NONE)
+ ACCOUNT_SLOGD("Account delete Success \n");
+ else
+ ACCOUNT_SLOGD("Account delete Failed \n");
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ } else if (user_resp == 3) {
+ ACCOUNT_SLOGD("Enter Account package name to be Deleted \n");
+ memset(temp, 0x00, sizeof(temp));
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("Scanf Failed!!!\n");
+ exit(0);
+ }
+ int ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ if (account_delete_from_db_by_package_name(temp) == ACCOUNT_ERROR_NONE )
+ ACCOUNT_SLOGD("Account delete Success \n");
+ else
+ ACCOUNT_SLOGD("Account delete Failed \n");
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+
+ } else {
+ ACCOUNT_SLOGD("Wrong info entered \n");
+ exit(0);
+ }
+
+ } else if (user_resp == 4) {
+ ACCOUNT_SLOGD("In Account Query Test Mode \n");
+ ACCOUNT_SLOGD("1. Press 1 to Query account by id test \n");
+ ACCOUNT_SLOGD("2. Press 2 to Query account by user name test \n");
+ ACCOUNT_SLOGD("3. Press 3 to Query account by package name test \n");
+ ACCOUNT_SLOGD("4. Press 4 to Query account by capability test \n");
+ if (scanf("%d", &user_resp) != 1) {
+ ACCOUNT_SLOGD("Scanf Failed!!!\n");
+ exit(0);
+ }
+ if (user_resp == 1) {
+ ACCOUNT_SLOGD("Enter Account Id to be Queried \n");
+ if (scanf("%d", &account_id) != 1) {
+ ACCOUNT_SLOGD("Scanf Failed!!!\n");
+ exit(0);
+ }
+ account_h account = NULL;
+ account_connect();
+ account_create(&account);
+ if (account_query_account_by_account_id(account_id, &account) == ACCOUNT_ERROR_NONE)
+ ACCOUNT_SLOGD("Account Queried Successfully \n");
+ else
+ ACCOUNT_SLOGD("Account Queried failed \n");
+ account_destroy(account);
+ account_disconnect();
+ } else if (user_resp == 2) {
+ ACCOUNT_SLOGD("Enter Account user name to be Queried \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("Scanf Failed!!!\n");
+ exit(0);
+ }
+ int ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ if (account_query_account_by_user_name(_account_get_callback, temp, NULL) == ACCOUNT_ERROR_NONE)
+ ACCOUNT_SLOGD("Account Queried Successfully \n");
+ else
+ ACCOUNT_SLOGD("Account Queried failed \n");
+
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ } else if (user_resp == 3) {
+ ACCOUNT_SLOGD("Enter Account package name to be Queried \n");
+ if (scanf("%s", temp) != 1) {
+ ACCOUNT_SLOGD("Scanf Failed!!!\n");
+ exit(0);
+ }
+ int ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d\n", __LINE__, ret);
+ }
+ if (account_query_account_by_package_name(_account_get_callback, temp, NULL) == ACCOUNT_ERROR_NONE)
+ ACCOUNT_SLOGD("Account Queried Successfully \n");
+ else
+ ACCOUNT_SLOGD("Account Queried failed \n");
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ } else if (user_resp == 4) {
+ ACCOUNT_SLOGD("Enter Account capability key to be Queried \n");
+ if (scanf("%d", &cap_key) != 1) {
+ ACCOUNT_SLOGD("Scanf Failed!!!\n");
+ exit(0);
+ }
+ ACCOUNT_SLOGD("Enter Account capability key's value to be Queried \n");
+ if (scanf("%d", &cap_value) != 1) {
+ ACCOUNT_SLOGD("Scanf Failed!!!\n");
+ exit(0);
+ }
+ int ret = account_connect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d\n", __LINE__, ret);
+ }
+ if (account_query_account_by_capability(_account_get_callback, ACCOUNT_SUPPORTS_CAPABILITY_PHOTO, cap_value, NULL) == ACCOUNT_ERROR_NONE)
+ ACCOUNT_SLOGD("Account Queried Successfully \n");
+ else
+ ACCOUNT_SLOGD("Account Queried failed \n");
+ ret = account_disconnect();
+ if(ret != ACCOUNT_ERROR_NONE)
+ {
+ ACCOUNT_SLOGD("(%d)-[Account] ret = %d, \n", __LINE__, ret);
+ }
+ } else {
+ ACCOUNT_SLOGD("Wrong info entered \n");
+ exit(0);
+ }
+
+ } else {
+ ACCOUNT_SLOGD("Wrong info entered \n");
+ exit(0);
+ }
+
+ //utc calls
+#if 1
+ //utc insert
+ utc1_account_insert();
+ utc2_account_insert();
+ utc3_account_insert();
+ utc4_account_insert();
+ utc5_account_insert();
+ utc6_account_insert();
+ utc7_account_insert();
+ utc8_account_insert();
+ utc9_account_insert();
+ utc10_account_insert();
+ utc11_account_insert();
+ utc12_account_insert();
+ utc13_account_insert();
+ utc14_account_insert();
+ utc15_account_insert();
+ utc16_account_insert();
+ utc17_account_insert();
+ utc18_account_insert();
+ utc19_account_insert();
+ utc20_account_insert();
+ utc21_account_insert();
+ utc22_account_insert();
+ utc23_account_insert();
+#endif
+
+ //utc update
+#if 1
+ utc1_account_update();
+ utc2_account_update();
+ utc3_account_update();
+ utc4_account_update();
+ utc5_account_update();
+ utc6_account_update();
+ utc7_account_update();
+ utc8_account_update();
+ utc9_account_update();
+ utc10_account_update();
+ utc11_account_update();
+ utc12_account_update();
+ utc13_account_update();
+ utc14_account_update();
+ utc15_account_update();
+ utc16_account_update();
+ utc17_account_update();
+ utc18_account_update();
+ utc19_account_update();
+ utc20_account_update();
+ utc21_account_update();
+ utc22_account_update();
+ utc23_account_update();
+ utc24_account_update();
+ utc25_account_update();
+ utc26_account_update();
+ utc27_account_update();
+#endif
+
+ //utc get account by id
+#if 1
+ utc1_get_account_by_id();
+ utc2_get_account_by_id();
+#endif
+
+ //utc get account by user name
+#if 1
+ utc1_get_account_by_user_name();
+ utc2_get_account_by_user_name();
+#endif
+
+ //utc get account by capability
+#if 1
+ utc1_get_account_by_capability();
+ utc2_get_account_by_capability();
+ utc3_get_account_by_capability();
+ utc4_get_account_by_capability();
+ utc5_get_account_by_capability();
+#endif
+
+ //utc get all accounts
+#if 1
+ utc1_get_all_accounts();
+ utc2_get_all_accounts();
+#endif
+
+ //utc get capability by account id
+#if 1
+ utc1_account_get_capability_by_account_id();
+ utc2_account_get_capability_by_account_id();
+#endif
+
+ //utc update sync status by id
+#if 1
+ utc_account_update_sync_status_by_id();
+#endif
+
+ //utc get application capability support
+#if 1
+ utc_account_get_application_capability_support();
+#endif
+
+#if 1
+ utc_account_delete_by_id();
+ utc_account_delete_by_user_name();
+ utc_account_delete_by_package_name();
+#endif
+
+#endif
+
+ return 0;
+}
+