upload tizen1.0 source
authorKim Kibum <kb0929.kim@samsung.com>
Sun, 29 Apr 2012 08:01:07 +0000 (17:01 +0900)
committerKim Kibum <kb0929.kim@samsung.com>
Sun, 29 Apr 2012 08:01:07 +0000 (17:01 +0900)
20 files changed:
CMakeLists.txt [new file with mode: 0755]
LICENSE [new file with mode: 0755]
NOTICE [new file with mode: 0755]
accounts-svc.pc.in [new file with mode: 0755]
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0755]
debian/control [new file with mode: 0755]
debian/copyright [new file with mode: 0755]
debian/dirs [new file with mode: 0755]
debian/docs [new file with mode: 0755]
debian/libaccounts-svc-0.install.in [new file with mode: 0755]
debian/libaccounts-svc-0.postinst [new file with mode: 0755]
debian/libaccounts-svc-dev.install.in [new file with mode: 0755]
debian/rules [new file with mode: 0755]
include/account-error.h [new file with mode: 0755]
include/account-private.h [new file with mode: 0755]
include/account-types.h [new file with mode: 0755]
include/account.h [new file with mode: 0755]
packaging/libaccounts-svc.spec [new file with mode: 0755]
src/account.c [new file with mode: 0755]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..291cc67
--- /dev/null
@@ -0,0 +1,46 @@
+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}.0.73")
+
+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)
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+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)
+
diff --git a/LICENSE b/LICENSE
new file mode 100755 (executable)
index 0000000..bae7f54
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,204 @@
+Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+                                 Apache License\r
+                           Version 2.0, January 2004\r
+                        http://www.apache.org/licenses/\r
+\r
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+   1. Definitions.\r
+\r
+      "License" shall mean the terms and conditions for use, reproduction,\r
+      and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+      "Licensor" shall mean the copyright owner or entity authorized by\r
+      the copyright owner that is granting the License.\r
+\r
+      "Legal Entity" shall mean the union of the acting entity and all\r
+      other entities that control, are controlled by, or are under common\r
+      control with that entity. For the purposes of this definition,\r
+      "control" means (i) the power, direct or indirect, to cause the\r
+      direction or management of such entity, whether by contract or\r
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+      outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+      "You" (or "Your") shall mean an individual or Legal Entity\r
+      exercising permissions granted by this License.\r
+\r
+      "Source" form shall mean the preferred form for making modifications,\r
+      including but not limited to software source code, documentation\r
+      source, and configuration files.\r
+\r
+      "Object" form shall mean any form resulting from mechanical\r
+      transformation or translation of a Source form, including but\r
+      not limited to compiled object code, generated documentation,\r
+      and conversions to other media types.\r
+\r
+      "Work" shall mean the work of authorship, whether in Source or\r
+      Object form, made available under the License, as indicated by a\r
+      copyright notice that is included in or attached to the work\r
+      (an example is provided in the Appendix below).\r
+\r
+      "Derivative Works" shall mean any work, whether in Source or Object\r
+      form, that is based on (or derived from) the Work and for which the\r
+      editorial revisions, annotations, elaborations, or other modifications\r
+      represent, as a whole, an original work of authorship. For the purposes\r
+      of this License, Derivative Works shall not include works that remain\r
+      separable from, or merely link (or bind by name) to the interfaces of,\r
+      the Work and Derivative Works thereof.\r
+\r
+      "Contribution" shall mean any work of authorship, including\r
+      the original version of the Work and any modifications or additions\r
+      to that Work or Derivative Works thereof, that is intentionally\r
+      submitted to Licensor for inclusion in the Work by the copyright owner\r
+      or by an individual or Legal Entity authorized to submit on behalf of\r
+      the copyright owner. For the purposes of this definition, "submitted"\r
+      means any form of electronic, verbal, or written communication sent\r
+      to the Licensor or its representatives, including but not limited to\r
+      communication on electronic mailing lists, source code control systems,\r
+      and issue tracking systems that are managed by, or on behalf of, the\r
+      Licensor for the purpose of discussing and improving the Work, but\r
+      excluding communication that is conspicuously marked or otherwise\r
+      designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+      "Contributor" shall mean Licensor and any individual or Legal Entity\r
+      on behalf of whom a Contribution has been received by Licensor and\r
+      subsequently incorporated within the Work.\r
+\r
+   2. Grant of Copyright License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      copyright license to reproduce, prepare Derivative Works of,\r
+      publicly display, publicly perform, sublicense, and distribute the\r
+      Work and such Derivative Works in Source or Object form.\r
+\r
+   3. Grant of Patent License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      (except as stated in this section) patent license to make, have made,\r
+      use, offer to sell, sell, import, and otherwise transfer the Work,\r
+      where such license applies only to those patent claims licensable\r
+      by such Contributor that are necessarily infringed by their\r
+      Contribution(s) alone or by combination of their Contribution(s)\r
+      with the Work to which such Contribution(s) was submitted. If You\r
+      institute patent litigation against any entity (including a\r
+      cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+      or a Contribution incorporated within the Work constitutes direct\r
+      or contributory patent infringement, then any patent licenses\r
+      granted to You under this License for that Work shall terminate\r
+      as of the date such litigation is filed.\r
+\r
+   4. Redistribution. You may reproduce and distribute copies of the\r
+      Work or Derivative Works thereof in any medium, with or without\r
+      modifications, and in Source or Object form, provided that You\r
+      meet the following conditions:\r
+\r
+      (a) You must give any other recipients of the Work or\r
+          Derivative Works a copy of this License; and\r
+\r
+      (b) You must cause any modified files to carry prominent notices\r
+          stating that You changed the files; and\r
+\r
+      (c) You must retain, in the Source form of any Derivative Works\r
+          that You distribute, all copyright, patent, trademark, and\r
+          attribution notices from the Source form of the Work,\r
+          excluding those notices that do not pertain to any part of\r
+          the Derivative Works; and\r
+\r
+      (d) If the Work includes a "NOTICE" text file as part of its\r
+          distribution, then any Derivative Works that You distribute must\r
+          include a readable copy of the attribution notices contained\r
+          within such NOTICE file, excluding those notices that do not\r
+          pertain to any part of the Derivative Works, in at least one\r
+          of the following places: within a NOTICE text file distributed\r
+          as part of the Derivative Works; within the Source form or\r
+          documentation, if provided along with the Derivative Works; or,\r
+          within a display generated by the Derivative Works, if and\r
+          wherever such third-party notices normally appear. The contents\r
+          of the NOTICE file are for informational purposes only and\r
+          do not modify the License. You may add Your own attribution\r
+          notices within Derivative Works that You distribute, alongside\r
+          or as an addendum to the NOTICE text from the Work, provided\r
+          that such additional attribution notices cannot be construed\r
+          as modifying the License.\r
+\r
+      You may add Your own copyright statement to Your modifications and\r
+      may provide additional or different license terms and conditions\r
+      for use, reproduction, or distribution of Your modifications, or\r
+      for any such Derivative Works as a whole, provided Your use,\r
+      reproduction, and distribution of the Work otherwise complies with\r
+      the conditions stated in this License.\r
+\r
+   5. Submission of Contributions. Unless You explicitly state otherwise,\r
+      any Contribution intentionally submitted for inclusion in the Work\r
+      by You to the Licensor shall be under the terms and conditions of\r
+      this License, without any additional terms or conditions.\r
+      Notwithstanding the above, nothing herein shall supersede or modify\r
+      the terms of any separate license agreement you may have executed\r
+      with Licensor regarding such Contributions.\r
+\r
+   6. Trademarks. This License does not grant permission to use the trade\r
+      names, trademarks, service marks, or product names of the Licensor,\r
+      except as required for reasonable and customary use in describing the\r
+      origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+   7. Disclaimer of Warranty. Unless required by applicable law or\r
+      agreed to in writing, Licensor provides the Work (and each\r
+      Contributor provides its Contributions) on an "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+      implied, including, without limitation, any warranties or conditions\r
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+      PARTICULAR PURPOSE. You are solely responsible for determining the\r
+      appropriateness of using or redistributing the Work and assume any\r
+      risks associated with Your exercise of permissions under this License.\r
+\r
+   8. Limitation of Liability. In no event and under no legal theory,\r
+      whether in tort (including negligence), contract, or otherwise,\r
+      unless required by applicable law (such as deliberate and grossly\r
+      negligent acts) or agreed to in writing, shall any Contributor be\r
+      liable to You for damages, including any direct, indirect, special,\r
+      incidental, or consequential damages of any character arising as a\r
+      result of this License or out of the use or inability to use the\r
+      Work (including but not limited to damages for loss of goodwill,\r
+      work stoppage, computer failure or malfunction, or any and all\r
+      other commercial damages or losses), even if such Contributor\r
+      has been advised of the possibility of such damages.\r
+\r
+   9. Accepting Warranty or Additional Liability. While redistributing\r
+      the Work or Derivative Works thereof, You may choose to offer,\r
+      and charge a fee for, acceptance of support, warranty, indemnity,\r
+      or other liability obligations and/or rights consistent with this\r
+      License. However, in accepting such obligations, You may act only\r
+      on Your own behalf and on Your sole responsibility, not on behalf\r
+      of any other Contributor, and only if You agree to indemnify,\r
+      defend, and hold each Contributor harmless for any liability\r
+      incurred by, or claims asserted against, such Contributor by reason\r
+      of your accepting any such warranty or additional liability.\r
+\r
+   END OF TERMS AND CONDITIONS\r
+\r
+   APPENDIX: How to apply the Apache License to your work.\r
+\r
+      To apply the Apache License to your work, attach the following\r
+      boilerplate notice, with the fields enclosed by brackets "[]"\r
+      replaced with your own identifying information. (Don't include\r
+      the brackets!)  The text should be enclosed in the appropriate\r
+      comment syntax for the file format. We also recommend that a\r
+      file or class name and description of purpose be included on the\r
+      same "printed page" as the copyright notice for easier\r
+      identification within third-party archives.\r
+\r
+   Copyright [yyyy] [name of copyright owner]\r
+\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
diff --git a/NOTICE b/NOTICE
new file mode 100755 (executable)
index 0000000..4c49449
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1 @@
+Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
diff --git a/accounts-svc.pc.in b/accounts-svc.pc.in
new file mode 100755 (executable)
index 0000000..fdc61f8
--- /dev/null
@@ -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: sqlite3 dlog db-util glib-2.0 capi-base-common
+Libs: -L${libdir} -laccounts-svc
+Cflags: -I${includedir}
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..ebb53b4
--- /dev/null
@@ -0,0 +1,8 @@
+libaccounts-svc (0.0.73) unstable; urgency=low
+
+  * Release
+  * Git: pkgs/l/libaccounts-svc
+  * Tag: libaccounts-svc_0.0.73
+
+ -- Wonyoung Lee <wy1115.lee@samsung.com>  Fri, 27 Apr 2012 08:52:17 +0900
+
diff --git a/debian/compat b/debian/compat
new file mode 100755 (executable)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100755 (executable)
index 0000000..c1ca48b
--- /dev/null
@@ -0,0 +1,26 @@
+Source: libaccounts-svc
+Section: devel
+Priority: extra
+Maintainer: Wonyoung Lee <wy1115.lee@samsung.com>
+Uploaders: Wonyoung Lee <wy1115.lee@samsung.com>
+Build-Depends: debhelper (>= 5), dlog-dev, libslp-db-util-dev, libglib2.0-dev, capi-base-common-dev
+Standards-Version: 0.1.0
+
+Package: libaccounts-svc-dev
+Section: libs
+Architecture: any
+Depends: libaccounts-svc-0 (= ${Source-Version}), dlog-dev, libglib2.0-dev, libslp-db-util-dev, capi-base-common-dev
+Description: Account DB library
+XB-Public-Package: no
+
+Package: libaccounts-svc-0
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Account DB library
+
+Package: libaccounts-svc-dbg
+Section: debug
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, libaccounts-svc-0 (= ${Source-Version})
+Description: Account DB library (unstripped)
diff --git a/debian/copyright b/debian/copyright
new file mode 100755 (executable)
index 0000000..4f93c69
--- /dev/null
@@ -0,0 +1,7 @@
+Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the Apache License version 2.0.
+
+The full text of the Apache 2.0 can be found in
+/usr/share/common-licenses.
diff --git a/debian/dirs b/debian/dirs
new file mode 100755 (executable)
index 0000000..ca882bb
--- /dev/null
@@ -0,0 +1,2 @@
+usr/bin
+usr/sbin
diff --git a/debian/docs b/debian/docs
new file mode 100755 (executable)
index 0000000..a0f0008
--- /dev/null
@@ -0,0 +1 @@
+CMakeLists.txt
diff --git a/debian/libaccounts-svc-0.install.in b/debian/libaccounts-svc-0.install.in
new file mode 100755 (executable)
index 0000000..bf766f0
--- /dev/null
@@ -0,0 +1 @@
+@PREFIX@/lib/*.so*
diff --git a/debian/libaccounts-svc-0.postinst b/debian/libaccounts-svc-0.postinst
new file mode 100755 (executable)
index 0000000..b901b53
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/sh
+if [ ! -d /opt/dbspace ]
+then
+       mkdir -p /opt/dbspace
+fi
+
+if [ ! -f /opt/dbspace/.account.db ]
+       rm -rf /opt/dbspace/.account.db*
+then
+       sqlite3 /opt/dbspace/.account.db 'PRAGMA journal_mode = PERSIST;
+        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, 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 INTEGER, value INTEGER, package_name TEXT, user_name TEXT, account_id INTEGER);'
+fi
+
+
+if [ ${USER} == "root" ]
+then
+       if [ -f /opt/dbspace/.account.db ]
+       then
+               chown 5000:5000 /opt/dbspace/.account.db
+       fi
+
+       if [ -f /opt/dbspace/.account.db-journal ]
+       then
+               chown 5000:5000 /opt/dbspace/.account.db-journal
+       fi
+fi
+
+if [ -f /opt/dbspace/.account.db ]
+then
+       chmod 660 /opt/dbspace/.account.db
+fi
+
+if [ -f /opt/dbspace/.account.db-journal ]
+then
+       chmod 660 /opt/dbspace/.account.db-journal
+fi
diff --git a/debian/libaccounts-svc-dev.install.in b/debian/libaccounts-svc-dev.install.in
new file mode 100755 (executable)
index 0000000..0f2a4da
--- /dev/null
@@ -0,0 +1,2 @@
+@PREFIX@/include/*
+@PREFIX@/lib/pkgconfig/*.pc
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..30c5355
--- /dev/null
@@ -0,0 +1,135 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+CFLAGS ?= -Wall -g
+CXXFLAGS ?=  -Wall -g
+LDFLAGS ?= 
+PREFIX ?= /usr
+DATADIR ?= /opt
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+       CFLAGS += -O0
+       CXXFLAGS += -O0
+else
+       CFLAGS += -O2
+       CXXFLAGS += -O2
+endif
+
+LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed
+
+#CMAKE_TMP_DIR = $(CURDIR)/cmake_tmp
+
+
+configure: configure-stamp
+configure-stamp:
+       dh_testdir
+       # Add here commands to configure the package.
+#      mkdir -p $(CMAKE_TMP_DIR);
+       CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" cmake . -DCMAKE_INSTALL_PREFIX=$(PREFIX)
+
+       touch configure-stamp
+
+build: build-stamp
+
+build-stamp: configure-stamp 
+       dh_testdir
+
+       # Add here commands to compile the package.
+       $(MAKE)
+       #docbook-to-man debian/wavplayer.sgml > wavplayer.1
+
+       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+               cat $$f > $${f%.in}; \
+               sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
+               sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
+       done
+
+
+       touch $@
+
+clean:
+       dh_testdir
+       dh_testroot
+       rm -f build-stamp configure-stamp
+
+       # Add here commands to clean up after the build process.
+       -$(MAKE) clean
+       #rm -rf $(CMAKE_TMP_DIR)
+
+       rm -rf CMakeCache.txt
+       #rm -rf test/CMakeCache.txt
+       rm -rf CMakeFiles
+       #rm -rf test/CMakeFiles
+       rm -rf cmake_install.cmake
+       #rm -rf test/cmake_install.cmake 
+       rm -rf Makefile
+       #rm -rf test/Makefile
+       rm -rf install_manifest.txt
+       rm -rf *.so
+       rm -rf *.edj
+       #rm -rf test/*.edj
+       #rm -rf test/testlibqp
+       rm -rf *.desktop
+       rm -rf *.pc
+       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+               rm -f $${f%.in}; \
+       done
+
+       dh_clean 
+
+install: build
+       dh_testdir
+       dh_testroot
+       dh_clean -k 
+       dh_installdirs
+
+       # Add here commands to install the package into debian/wavplayer.
+       $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+       dh_testdir
+       dh_testroot
+       dh_installchangelogs 
+       dh_installdocs
+       dh_installexamples
+       dh_install --sourcedir=debian/tmp
+#      dh_installmenu
+#      dh_installdebconf       
+#      dh_installlogrotate
+#      dh_installemacsen
+#      dh_installpam
+#      dh_installmime
+#      dh_python
+#      dh_installinit
+#      dh_installcron
+#      dh_installinfo
+       dh_installman
+       dh_link
+#      dh_strip
+       dh_strip --dbg-package=libaccounts-svc-dbg
+       dh_compress
+       dh_fixperms
+#      dh_perl
+       dh_makeshlibs
+       dh_installdeb
+       dh_shlibdeps
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/include/account-error.h b/include/account-error.h
new file mode 100755 (executable)
index 0000000..4a0c529
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * libaccounts-svc
+ *
+ * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Tarun Kumar <tarun.kr@samsung.com>, Sukumar Moharana <msukumar@samsung.com>, Wonyoung Lee <wy1115.lee@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_MODULE
+ * @{
+ */
+
+/**
+ * @file        account-error.h
+ * @brief      ACCOUNT error definitions.
+ */
+
+//#define TIZEN_ERROR_ACCOUNT_CLASS SLP_ERROR_SOCIAL_CLASS | 0x90
+
+/**
+ *  @brief    Enumerations of error codes for ACOUNT APIs.
+ */
+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_SOCIAL_CLASS | 0x01,
+       ACCOUNT_ERROR_NO_DATA  = TIZEN_ERROR_SOCIAL_CLASS | 0x02,
+
+       ACCOUNT_ERROR_RECORD_NOT_FOUND = TIZEN_ERROR_SOCIAL_CLASS | 0x03,
+       ACCOUNT_ERROR_DB_FAILED = TIZEN_ERROR_SOCIAL_CLASS | 0x04,
+       ACCOUNT_ERROR_DB_NOT_OPENED = TIZEN_ERROR_SOCIAL_CLASS | 0x05,
+       ACCOUNT_ERROR_QUERY_SYNTAX_ERROR = TIZEN_ERROR_SOCIAL_CLASS | 0x06,
+       ACCOUNT_ERROR_ITERATOR_END = TIZEN_ERROR_SOCIAL_CLASS | 0x07,
+
+} 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 (executable)
index 0000000..39c4825
--- /dev/null
@@ -0,0 +1,173 @@
+/*
+ * libaccounts-svc
+ *
+ * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Tarun Kumar <tarun.kr@samsung.com>, Sukumar Moharana <msukumar@samsung.com>, Wonyoung Lee <wy1115.lee@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__
+
+
+/*#include <glib.h>*/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <glib.h>
+
+#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/dbspace/.account.db"
+#define ACCOUNT_TABLE "account"
+#define CAPABILITY_TABLE "capability"
+#define ACCOUNT_SQLITE_SEQ "sqlite_sequence"
+#define ACCOUNT_SQL_LEN_MAX    1024
+#define ACCOUNT_TABLE_TOTAL_COUNT      2
+
+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                   service_type;*/ /* ACCOUNT_CATEGORY*/
+       int                     auth_type;
+       int             secret;
+       int                     user_data_int[USER_INT_CNT];
+       char*           user_data_txt[USER_TXT_CNT];
+       GSList*         capablity_list;
+       GList*          account_list;
+}account_s;
+
+typedef struct _capability_s
+{
+       int id;
+       int type;
+       int value;
+       char* package_name;
+       char* user_name;
+       int account_id;
+}account_capability_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_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 sqlite3_stmt* account_stmt;
+
+#define ACCOUNT_SCHEMA "create table %s \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, "\
+"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 "\
+");"
+
+#define CAPABILITY_SCHEMA  "create table %s \n"\
+       "(\n"\
+"_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
+"key INTEGER, "\
+"value INTEGER, "\
+"package_name TEXT, "\
+"user_name TEXT, "\
+"account_id INTEGER "\
+");"
+
+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 (executable)
index 0000000..d353c3c
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * libaccounts-svc
+ *
+ * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Tarun Kumar <tarun.kr@samsung.com>, Sukumar Moharana <msukumar@samsung.com>, Wonyoung Lee <wy1115.lee@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__
+
+#include <db-util.h>
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+/**
+ * @addtogroup CAPI_ACCOUNT_MODULE
+ * @{
+ */
+
+/**
+ * @file               account-types.h
+ * @ingroup    CAPI_ACCOUNT
+ * @brief              This file defines common types and enums of ACCOUNT.
+ */
+
+/**
+ * @brief      Enumerations for the result types of capability.
+ */
+typedef enum
+{
+       ACCOUNT_CAPABILITY_CONTACT = 1,
+       ACCOUNT_CAPABILITY_CALENDAR,
+       ACCOUNT_CAPABILITY_PHOTO,
+       ACCOUNT_CAPABILITY_VIDEO,
+       ACCOUNT_CAPABILITY_EMAIL,
+       ACCOUNT_CAPABILITY_STATUS_POST,
+       ACCOUNT_CAPABILITY_VOIP,
+       ACCOUNT_CAPABILITY_SAMSUNG_APPS,
+       ACCOUNT_CAPABILITY_MOBILE_TRACKER
+} account_capability_type_e;
+
+/**
+ * @brief      Enumerations for the state of capability.
+ */
+typedef enum
+{
+       ACCOUNT_CAPABILITY_DISABLED = 0x00,
+       ACCOUNT_CAPABILITY_ENABLED
+}
+account_capability_state_e;
+
+/**
+ * @brief      Enumerations for the state of account secrecy.
+ */
+typedef enum
+{
+       ACCOUNT_SECRECY_INVISIBLE = 0x00,
+       ACCOUNT_SECRECY_VISIBLE
+}
+account_secrecy_state_e;
+
+typedef enum
+{
+       ACCOUNT_AUTH_TYPE_XAUTH,
+       ACCOUNT_AUTH_TYPE_OAUTH,
+       ACCOUNT_AUTH_TYPE_CLIENT_LOGIN
+}account_auth_type_e;
+
+/**
+ * @brief Account handle.
+ */
+typedef struct account_s* account_h;
+
+/**
+ * @brief Account capability handle.
+ */
+typedef struct account_capability_s* account_capability_h;
+
+#define ACCOUNT_DATA_USERNAME  "http://tizen.org/account/data/username"
+#define ACCOUNT_OPERATION_SIGNIN       "http://tizen.org/account/operation/signin"
+#define ACCOUNT_OPERATION_VIEW         "http://tizen.org/account/operation/view"
+
+#define USER_TXT_CNT 5
+#define USER_INT_CNT 5
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ACCOUNT_TYPES_H__*/
+
diff --git a/include/account.h b/include/account.h
new file mode 100755 (executable)
index 0000000..e5d2888
--- /dev/null
@@ -0,0 +1,874 @@
+/*
+ * libaccounts-svc
+ *
+ * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Tarun Kumar <tarun.kr@samsung.com>, Sukumar Moharana <msukumar@samsung.com>, Wonyoung Lee <wy1115.lee@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 <stdlib.h>
+#include <stdio.h>
+#include <glib.h>
+#include <account-types.h>
+#include <account-error.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @file        account.h
+ * @brief       This file contains the Account API for account management
+ */
+
+/**
+ * @addtogroup CAPI_SOCIAL_ACCOUNT_MODULE
+ * @{
+ */
+
+/**
+ * @brief      Called once for each account from database
+ *
+ * @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 or @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() invoke this callback.
+ *
+ * @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 account from database
+ *
+ * @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 or @c false to break out of the loop.
+ *
+ * @pre account_query_capability_by_account_id() invokes this callback.
+ *
+ * @see account_query_capability_by_account_id()
+ */
+typedef bool (*capability_cb)(account_capability_type_e capability_type, account_capability_state_e capability_state, void *user_data);
+
+
+/**
+ * @brief      Connects to the account database.
+ *
+ * @return     0 on success, otherwise a negative error value.
+ * @retval     #ACCOUNT_ERROR_NONE Successful
+ * @retval     #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_disconnect()
+ */
+int account_connect(void);
+
+
+/**
+ * @brief      Disconnects from account database.
+ *
+ * @return     0 on success, otherwise a negative error value.
+ * @retval     #ACCOUNT_ERROR_NONE Successful
+ * @retval     #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_connect()
+ */
+int account_disconnect(void);
+
+
+/**
+ * @brief      Creates a handle to the account.
+ *
+ * @remarks    @a account must be released with account_destroy() by you. \n
+ *  The created handle is not added to the account database until account_insert_to_db() is called.
+ *
+ * @param[in]  account The account handle
+ *
+ * @return     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()
+ */
+int account_create(account_h *account);
+
+
+/**
+ * @brief      Destroys the account handle and releases all its resources.
+ *
+ * @param[in]  account The account handle
+ *
+ * @return     0 on success, otherwise a negative error value.
+ * @retval     #ACCOUNT_ERROR_NONE     Successful
+ * @retval     #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_create()
+ */
+int account_destroy(account_h account);
+
+
+/**
+ * @brief      Inserts the account details to the account database.
+ *
+ * @param[in]  account The account handle
+ * @param[out] account_db_id The account ID to be assigned to a account
+ *
+ * @return     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 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()
+ */
+int account_insert_to_db(account_h account, int *account_db_id);
+
+
+/**
+ * @brief      Deletes the account from the account database by accound DB ID.
+ *
+ * @param[in]  account_db_id The account ID to delete
+ *
+ * @return     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 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()
+ */
+int account_delete_from_db_by_id(int account_db_id);
+
+
+/**
+ * @brief      Deletes the account from the account database by user name.
+ *
+ * @param[in]  user_name The user name of account to delete
+ * @param[in]  package_name The package name of account to delete
+ *
+ * @return     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 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()
+ */
+int account_delete_from_db_by_user_name(char *user_name, char *package_name);
+
+
+/**
+ * @brief      Deletes the account from the account database by package name.
+ *
+ * @param[in]  package_name The package name of account(s) to delete
+ *
+ * @return     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 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()
+ */
+int account_delete_from_db_by_package_name(char *package_name);
+
+
+/**
+ * @brief      Updates the account details to the account database.
+ *
+ * @param[in]  account The account handle
+ * @param[in]  account_id The account ID to update
+ *
+ * @return     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 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()
+ */
+int account_update_to_db_by_id(account_h account, int account_id);
+
+
+/**
+ * @brief      Updates the account details to the account database.
+ *
+ * @param[in]  account The account handle
+ * @param[in]  user_name The user name of account to update
+ * @param[in]  package_name The package name for the user name
+ *
+ * @return     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 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()
+ *
+ */
+int account_update_to_db_by_user_name(account_h account, const char *user_name, const char *package_name);
+
+/**
+ * @brief      Gets the account id of account.
+ *
+ *
+ * @param[in]  account The account handle
+ * @param[out] account_id The account id of account
+ *
+ * @return     0 on success, otherwise a negative error value.
+ * @retval     #ACCOUNT_ERROR_NONE Successful
+ * @retval     #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int account_get_account_id(account_h account, int *account_id);
+
+
+/**
+ * @brief      Gets the user name of account.
+ *
+ * @remarks    @a user_name must be released with free() by you.
+ *
+ * @param[in]  account The account handle
+ * @param[out] user_name The user name of account
+ *
+ * @return     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()
+ */
+int account_get_user_name(account_h account, char **user_name);
+
+
+/**
+ * @brief      Sets the user name of account.
+ *
+ * @param[in]  account The account handle
+ * @param[in]  user_name The string to set as user name
+ *
+ * @return     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()
+ */
+int account_set_user_name(account_h account, const char *user_name);
+
+
+/**
+ * @brief      Gets the display name of account.
+ *
+ * @remarks    @a display_name must be released with free() by you.
+ *
+ * @param[in]  account The account handle
+ * @param[out] display_name The display name of account
+ *
+ * @return     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()
+ */
+int account_get_display_name(account_h account, char **display_name);
+
+
+/**
+ * @brief      Sets the display name of account.
+ *
+ * @param[in]  account The account handle
+ * @param[in]  display_name The text string to set as the display name
+ *
+ * @return     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()
+ */
+int account_set_display_name(account_h account, const char *display_name);
+
+
+/**
+ * @brief      Gets the capability detail of account.
+ *
+ * @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     0 on success, otherwise a negative error value.
+ * @retval     #ACCOUNT_ERROR_NONE Successful
+ * @retval     #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_set_capability()
+ */
+int account_get_capability(account_h account, capability_cb cb_func, void *user_data);
+
+
+/**
+ * @brief      Sets the capability.
+ *
+ * @param[in]  account The account handle
+ * @param[in]  capability_type The capability type
+ * @param[in]  capability_state The capability state
+ *
+ * @return     0 on success, otherwise a negative error value.
+ * @retval     #ACCOUNT_ERROR_NONE Successful
+ * @retval     #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_get_capability()
+ */
+int account_set_capability(account_h account, account_capability_type_e capability_type, account_capability_state_e capability_state);
+
+
+/**
+ * @brief      Gets the icon path.
+ *
+ * @remarks    @a icon_path must be released with free() by you.
+ *
+ * @param[in]  account The account handle
+ * @param[out] icon_path The icon path
+ *
+ * @return     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()
+ */
+int account_get_icon_path(account_h account, char **icon_path);
+
+
+/**
+ * @brief      Sets the icon path.
+ *
+ * @param[in]  account The account handle
+ * @param[in]  icon_path The text string to set as a icon path
+ *
+ * @return     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()
+ */
+int account_set_icon_path(account_h account, const char *icon_path);
+
+
+/**
+ * @brief      Gets the domain name.
+ *
+ * @remarks    @a domain_name must be released with free() by you.
+ *
+ * @param[in]  account The account handle
+ * @param[out] domain_name The domain name
+ *
+ * @return     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()
+ */
+int account_get_domain_name(account_h account, char **domain_name);
+
+
+/**
+ * @brief      Sets the domain name.
+ *
+ * @param[in]  account The account handle
+ * @param[in]  domain_name The text string to set as a domain name
+ *
+ * @return     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()
+ */
+int account_set_domain_name(account_h account, const char *domain_name);
+
+
+/**
+ * @brief      Gets the email address.
+ *
+ * @remarks    @a email_address must be released with free() by you.
+ *
+ * @param[in]  account The account handle
+ * @param[out] email_address The email address
+ *
+ * @return     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()
+ */
+int account_get_email_address(account_h account, char **email_address);
+
+
+/**
+ * @brief      Sets the email address.
+ *
+ * @param[in]  account The account handle
+ * @param[in]  email_address The text string to set as a email address
+ *
+ * @return     0 on success, otherwise a negative error value.
+ * @retval     #ACCOUNT_ERROR_NONE Successful
+ * @retval     #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_get_email_addres()
+ */
+int account_set_email_address(account_h account, const char *email_address);
+
+
+/**
+ * @brief      Gets the package name.
+ *
+ * @remarks    @a package_name must be released with free() by you.
+ *
+ * @param[in]  account The account handle
+ * @param[out] package_name The package name
+ *
+ * @return     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()
+ */
+int account_get_package_name(account_h account, char **package_name);
+
+
+/**
+ * @brief      Sets the package name.
+ *
+ * @param[in]  account The account handle
+ * @param[in]  package_name The text string to set as a package name
+ *
+ * @return     0 on success, otherwise a negative error value.
+ * @retval     #ACCOUNT_ERROR_NONE Successful
+ * @retval     #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_get_email_addres()
+ */
+int account_set_package_name(account_h account, const char *package_name);
+
+
+/**
+ * @brief      Gets the access token.
+ *
+ * @remarks    @a access_token must be released with free() by you.
+ *
+ * @param[in]  account The account handle
+ * @param[out] access_token The access token
+ *
+ * @return     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()
+ */
+int account_get_access_token(account_h account, char **access_token);
+
+
+/**
+ * @brief      Set the access token.
+ *
+ * @param[in]  account The account handle
+ * @param[in]  access_token The text string to set as a access token
+ *
+ * @return     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()
+ */
+int account_set_access_token(account_h account, const char *access_token);
+
+
+/**
+ * @brief      Gets the user text.
+ *
+ * @remarks    @a user_text must be released with free() by you.
+ *
+ * @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     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()
+ */
+int account_get_user_text(account_h account, int user_text_index, char **user_text);
+
+
+/**
+ * @brief      Sets the user text.
+ *
+ * @param[in]  account The account handle
+ * @param[in]  user_text_index The index of the user text (must be in range from 0 to 4)
+ * @param[in]  user_text The text string to set as a user txt
+ *
+ * @return     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()
+ */
+int account_set_user_text(account_h account, int user_text_index, const char *user_text);
+
+
+/**
+ * @brief      Gets the user integer.
+ *
+ * @param[in]  account The account handle
+ * @param[in]  user_int_index The index of the user integer (must be in range from 0 to 4)
+ * @param[out] user_integer The user interger
+ *
+ * @return     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()
+ */
+int account_get_user_int(account_h account, int user_int_index, int *user_integer);
+
+
+/**
+ * @brief      Set the user integer.
+ *
+ * @param[in]  account The account handle
+ * @param[in]  user_int_index The index of the user integer (must be in range from 0 to 4)
+ * @param[in]  user_integer The integer to set as user integer
+ *
+ * @return     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()
+ */
+int account_set_user_int(account_h account, int user_int_index, int user_integer);
+
+
+/**
+ * @brief      Gets the auth type.
+ *
+ * @param[in]  account The account handle
+ * @param[out] auth_type The auth type
+ *
+ * @return     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()
+ */
+int account_get_auth_type(account_h account, account_auth_type_e *auth_type);
+
+
+/**
+ * @brief      Sets the auth type.
+ *
+ * @param[in]  account The account handle
+ * @param[in]  auth_type Integer to be set as auth type
+ *
+ * @return     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()
+ */
+int account_set_auth_type(account_h account, const account_auth_type_e auth_type);
+
+
+/**
+ * @brief      Gets the secret.
+ *
+ * @param[in]  account The account handle
+ * @param[out] secret The secret
+ *
+ * @return     0 on success, otherwise a negative error value.
+ * @retval     #ACCOUNT_ERROR_NONE Successful
+ * @retval     #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_set_secret()
+ */
+int account_get_secret(account_h account, account_secrecy_state_e *secret);
+
+
+/**
+ * @brief      Sets the secret.
+ *
+ * @param[in]  account The account handle
+ * @param[in]  secret Secrecy to be set
+ *
+ * @return     0 on success, otherwise a negative error value.
+ * @retval     #ACCOUNT_ERROR_NONE Successful
+ * @retval     #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_get_secret()
+ */
+int account_set_secret(account_h account, const account_secrecy_state_e secret);
+
+
+/**
+ * @brief      Gets the source.
+ *
+ * @remarks    @a user_text must be released with free() by you.
+ *
+ * @param[in]  account The account handle
+ * @param[out] source The source
+ *
+ * @return     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()
+ */
+int account_get_source(account_h account, char **source);
+
+
+/**
+ * @brief      Sets the source.
+ *
+ * @param[in]  account The account handle
+ * @param[in]  source The text string to set as a source
+ *
+ * @return     0 on success, otherwise a negative error value.
+ * @retval     #ACCOUNT_ERROR_NONE Successful
+ * @retval     #ACCOUNT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see account_get_source()
+ */
+int account_set_source(account_h account, const char *source);
+
+
+/**
+ * @brief      Retrieves all accounts details by invoking the given callback function iteratively.
+ *
+ * @param[in]  callback The callback function to invoke
+ * @param[in]  user_data The user data to be passed to the callback function
+ *
+ * @return     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 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()
+ */
+int account_foreach_account_from_db(account_cb callback, void *user_data);
+
+
+/**
+ * @brief      Retrieves all accounts with the account database ID.
+ *
+ * @param[in]  account_db_id The account database ID to search
+ * @param[out] account account handle
+ *
+ * @return     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 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()
+ */
+int account_query_account_by_account_id(int account_db_id, account_h *account);
+
+/**
+ * @brief      Retrieves all accounts with the user name.
+ *
+ * @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     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 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()
+ *
+ */
+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.
+ *
+ * @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     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 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()
+ */
+int account_query_account_by_package_name(account_cb callback, const char *package_name, void *user_data);
+
+/**
+ * @brief      Retrieves all accounts with the capability.
+ *
+ * @param[in]  callback The callback function to invoke
+ * @param[in]  capability_type The capablity type to search
+ * @param[in]  capability_value The capablity value to search
+ * @param[in]  user_data The user data to be passed to the callback function
+ *
+ * @return     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 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()
+ */
+int account_query_account_by_capability(account_cb callback, account_capability_type_e capability_type, account_capability_state_e capability_value, void *user_data);
+
+/**
+ * @brief      Retrieves all capabilities with the account database ID.
+ *
+ * @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     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 account service by account_connect().
+ * @post       This function invokes capability_cb().
+ *
+ * @see account_connect()
+ * @see account_get_capability()
+ * @see account_set_capability()
+ */
+int account_query_capability_by_account_id(capability_cb callback, int account_db_id, void *user_data);
+
+
+/**
+ * @brief      Retrieves number of account in the account database.
+ *
+ * @param[out] out parameter for number of all accounts
+ *
+ * @return     0 on success, otherwise a negative error value.
+ * @retval     #ACCOUNT_ERROR_NONE Successful
+ * @retval     #ACCOUNT_ERROR_DB_FAILED Database operation failed
+ *
+ * @pre        This function requires an open connection to account service by account_connect().
+ *
+ * @see account_connect()
+ */
+int account_get_total_count_from_db(int *count);
+
+
+/**
+* @}
+*/
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ACCOUNT_H__ */
diff --git a/packaging/libaccounts-svc.spec b/packaging/libaccounts-svc.spec
new file mode 100755 (executable)
index 0000000..895cf12
--- /dev/null
@@ -0,0 +1,90 @@
+
+Name:       libaccounts-svc
+Summary:    Account DB library
+Version:    0.0.73
+Release:    1
+Group:      TO_BE/FILLED_IN
+License:    TO BE FILLED IN
+Source0:    libaccounts-svc-%{version}.tar.gz
+
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(db-util)
+BuildRequires:  pkgconfig(capi-base-common)
+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
+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/dbspace ]
+then
+        mkdir -p /opt/dbspace
+fi
+if [ ! -f /opt/dbspace/.account-svc.db ]
+rm -rf /opt/dbspace/.account-svc.db*
+then
+        sqlite3 /opt/dbspace/.account-svc.db 'PRAGMA journal_mode = PERSIST;
+        CREATE TABLE if not exists accounts (_id INTEGER PRIMARY KEY AUTOINCREMENT, email_address TEXT, user_name TEXT, display_name TEXT, icon_path TEXT,
+        service_type INTEGER, source TEXT, library_name TEXT, is_default INTEGER, domain_name TEXT,
+        key TEXT, secret TEXT, save_screen_name INTEGER, save_token INTEGER, save_user_name INTEGER,
+        save_password INTEGER, key_values TEXT, capability TEXT,
+        int_custom0 INTEGER, int_custom1 INTEGER, int_custom2 INTEGER, int_custom3 INTEGER, int_custom4 INTEGER,
+        txt_custom0 TEXT, txt_custom1 TEXT, txt_custom2 TEXT, txt_custom3 TEXT, txt_custom4 TEXT);
+        CREATE TABLE if not exists capabilities (_id INTEGER PRIMARY KEY AUTOINCREMENT, key TEXT, value TEXT, app_id INTEGER, account_id INTEGER, FOREIGN KEY (account_id) REFERENCES accounts(_id));
+        CREATE TABLE if not exists service (_service_id INTEGER PRIMARY KEY AUTOINCREMENT, service_name TEXT, library_name TEXT, version TEXT, type TEXT, icon_path TEXT, auth_type TEXT);
+        INSERT INTO service ( _service_id, service_name, library_name, version, type) values (1, "Samsung", "samsung-sso-efl", "0.0.1", "ui-gadget");
+        INSERT INTO service ( _service_id, service_name, library_name, version, type) values (3, "Google", "email-setting-efl", "0.0.1", "ui-gadget");
+        INSERT INTO service ( _service_id, service_name, library_name, version, type) values (4, "MSN", "email-setting-efl", "0.0.1", "ui-gadget");
+        CREATE TABLE if not exists feature (_feature_id INTEGER PRIMARY KEY AUTOINCREMENT, feature_name TEXT, description TEXT, service_id INTEGER, FOREIGN KEY (service_id) REFERENCES service(_service_id));'
+fi
+
+chown 5000:5000 /opt/dbspace/.account-svc.db
+chown 5000:5000 /opt/dbspace/.account-svc.db-journal
+
+chmod 660 /opt/dbspace/.account-svc.db
+chmod 660 /opt/dbspace/.account-svc.db-journal
+
+%postun -p /sbin/ldconfig
+
+
+
+
+%files
+%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 (executable)
index 0000000..0c3592f
--- /dev/null
@@ -0,0 +1,2570 @@
+/*
+ * libaccounts-svc
+ *
+ * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Tarun Kumar <tarun.kr@samsung.com>, Sukumar Moharana <msukumar@samsung.com>, Wonyoung Lee <wy1115.lee@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 <account.h>
+#include <glib.h>
+#include <db-util.h>
+#include <pthread.h>
+#include <assert.h>
+#include <account-private.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "ACCOUNT"
+
+#define ACCOUNT_DLOG_USE
+#ifdef ACCOUNT_DLOG_USE
+#define ACCOUNT_DEBUG(fmt, arg...) \
+               LOGD(": " fmt "\n", ##arg);
+#else
+#define ACCOUNT_DEBUG(fmt, arg...) \
+               printf(": " fmt "\n", ##arg);
+#endif
+
+#define ACCOUNT_RETURN_VAL(eval, expr, ret_val, X)\
+       if (!(eval)) \
+{\
+       expr; \
+       if (1)\
+       {ACCOUNT_DEBUG X;}\
+       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);\
+       if (1)\
+       {ACCOUNT_DEBUG X;}\
+       goto CATCH;\
+} else {;}
+
+
+static sqlite3* g_hAccountDB = NULL;
+static int             g_refCntDB = 0;
+pthread_mutex_t account_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+static int _account_gslist_free(GSList* list);
+static int _account_glist_free(GList* list);
+
+static const char *_account_db_err_msg()
+{
+       assert(NULL != g_hAccountDB);
+       return sqlite3_errmsg(g_hAccountDB);
+}
+
+static int _account_get_record_count(char* query)
+{
+       int rc = -1;
+       int ncount = 0;
+       account_stmt pStmt = NULL;
+
+       assert(NULL != query);
+       assert(NULL != g_hAccountDB);
+       rc = sqlite3_prepare_v2(g_hAccountDB, query, strlen(query), &pStmt, NULL);
+
+       rc = sqlite3_step(pStmt);
+       if (SQLITE_ROW != rc) {
+               ACCOUNT_DEBUG("sqlite3_step() failed(%d, %s).", rc, _account_db_err_msg());
+               sqlite3_finalize(pStmt);
+               return ACCOUNT_ERROR_DB_FAILED;
+       }
+
+       ncount = sqlite3_column_int(pStmt, 0);
+
+       ACCOUNT_DEBUG("count : %d, End", ncount);
+       sqlite3_finalize(pStmt);
+
+       return ncount;
+}
+
+static int _account_execute_query(char *query)
+{
+       int rc = -1;
+       char* pszErrorMsg = NULL;
+
+       assert(NULL != query);
+       assert(NULL != g_hAccountDB);
+
+       ACCOUNT_DEBUG("query : %s", query);
+
+       rc = sqlite3_exec(g_hAccountDB, query, NULL, NULL, &pszErrorMsg);
+       if (SQLITE_OK != rc) {
+               ACCOUNT_DEBUG("sqlite3_exec(%s) failed(%s).", 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_OK) {
+               ACCOUNT_DEBUG("_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_OK) {
+               ACCOUNT_DEBUG("_account_svc_end_transaction fail :: %d", ret);
+               return ACCOUNT_ERROR_DB_FAILED;
+       }
+
+   return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_create_all_tables(void)
+{
+       int rc = -1;
+       int error_code = ACCOUNT_ERROR_NONE;
+       char    query[ACCOUNT_SQL_LEN_MAX] = {0, };
+
+
+       ACCOUNT_MEMSET(query, 0, sizeof(query));
+
+       ACCOUNT_DEBUG("_account_create_all_tables begin");
+
+       /*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);
+       ACCOUNT_DEBUG("rc = %d \n", rc);
+
+       if (rc <= 0) {
+               ACCOUNT_MEMSET(query, 0, sizeof(query));
+               ACCOUNT_SNPRINTF(query, sizeof(query),  ACCOUNT_SCHEMA, ACCOUNT_TABLE);
+               rc = _account_execute_query(query);
+               ACCOUNT_RETURN_VAL((SQLITE_OK == rc), {}, ACCOUNT_ERROR_DB_FAILED, ("_account_execute_query(%s) failed(%d, %s).\n", query, rc, _account_db_err_msg()));
+       }
+
+       ACCOUNT_MEMSET(query, 0, sizeof(query));
+       /*Create capability table*/
+       ACCOUNT_SNPRINTF(query, sizeof(query), "select count(*) from sqlite_master where name in ('%s')", CAPABILITY_TABLE);
+       rc = _account_get_record_count(query);
+       ACCOUNT_DEBUG("rc = %d \n", rc);
+
+       if (rc <= 0) {
+               ACCOUNT_MEMSET(query, 0, sizeof(query));
+               ACCOUNT_SNPRINTF(query, sizeof(query),  CAPABILITY_SCHEMA, CAPABILITY_TABLE);
+               rc = _account_execute_query(query);
+
+               ACCOUNT_RETURN_VAL((SQLITE_OK == rc), {}, ACCOUNT_ERROR_DB_FAILED, ("_account_execute_query(%s) failed(%d, %s).\n", query, rc, _account_db_err_msg()));
+       }
+
+       return error_code;
+}
+
+
+static bool _account_check_is_all_table_exists()
+{
+       int     rc = 0;
+       char    query[ACCOUNT_SQL_LEN_MAX] = {0,};
+       ACCOUNT_MEMSET(query, 0, sizeof(query));
+
+       ACCOUNT_DEBUG("_account_check_is_all_table_exists");
+
+       ACCOUNT_SNPRINTF(query, sizeof(query), "select count(*) from sqlite_master where name in ('%s', '%s')",
+                       ACCOUNT_TABLE, CAPABILITY_TABLE);
+       rc = _account_get_record_count(query);
+       ACCOUNT_DEBUG("rc = %d \n", rc);
+
+       if (rc != ACCOUNT_TABLE_TOTAL_COUNT) {
+               ACCOUNT_DEBUG("Table count is not matched rc=%d\n", rc);
+               return FALSE;
+       }
+
+       ACCOUNT_DEBUG("END of _account_check_is_all_table_exists\n");
+
+       return TRUE;
+}
+
+static int _account_db_open(void)
+{
+       int     rc = 0;
+       bool is_success = false;
+       char query[ACCOUNT_SQL_LEN_MAX] = {0, };
+
+       ACCOUNT_MEMSET(query, 0x00, sizeof(query));
+
+       if (!g_hAccountDB) {
+               rc = db_util_open(ACCOUNT_DB_NAME, &g_hAccountDB, DB_UTIL_REGISTER_HOOK_METHOD);
+               ACCOUNT_RETURN_VAL((rc == SQLITE_OK), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected. rc : %d", rc));
+
+               g_refCntDB++;
+               is_success = true;
+               ACCOUNT_DEBUG("_account_db_open: The database connected. refcnt=%d ", g_refCntDB);
+       } else {
+               g_refCntDB++;
+               is_success = true;
+               ACCOUNT_DEBUG("The database already connected. refcnt=%d ", g_refCntDB);
+       }
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_db_close(void)
+{
+       int     rc = 0;
+
+       if (g_hAccountDB) {
+               if (g_refCntDB > 0) {
+                       g_refCntDB--;
+                       ACCOUNT_DEBUG("_account_svc_db_close: The database disconnected. refcnt=%d ", g_refCntDB);
+               }
+
+               if (g_refCntDB == 0) {
+                       rc = db_util_close(g_hAccountDB);
+                       ACCOUNT_RETURN_VAL((rc == SQLITE_OK), {}, ACCOUNT_ERROR_DB_FAILED, ("The database isn't connected. rc : %d", rc));
+
+                       g_hAccountDB = NULL;
+                       ACCOUNT_DEBUG( "_account_svc_db_close: The database disconnected really. ");
+               }
+       } else {
+               ACCOUNT_DEBUG( "_account_svc_db_close: No handle(). refcnt=%d ", g_refCntDB);
+       }
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_connect(void)
+{
+       int error_code = ACCOUNT_ERROR_NONE;
+
+       pthread_mutex_lock(&account_mutex);
+
+       ACCOUNT_DEBUG("db path = %s\n", ACCOUNT_DB_NAME);
+
+       error_code = _account_db_open();
+       if (ACCOUNT_ERROR_NONE != error_code) {
+               ACCOUNT_DEBUG("The database isn't connected.\n");
+               pthread_mutex_unlock(&account_mutex);
+               return ACCOUNT_ERROR_DB_NOT_OPENED;
+       }
+
+       if (FALSE == _account_check_is_all_table_exists())
+               error_code = _account_create_all_tables();
+
+       pthread_mutex_unlock(&account_mutex);
+       return ACCOUNT_ERROR_NONE;
+}
+
+int account_connect (void)
+{
+       return _account_connect();
+}
+
+static int _account_disconnect(void)
+{
+       int error_code = ACCOUNT_ERROR_NONE;
+
+       pthread_mutex_lock(&account_mutex);
+       ACCOUNT_DEBUG("db path = %s have been closed!!!\n", ACCOUNT_DB_NAME);
+
+       error_code = _account_db_close();
+       pthread_mutex_unlock(&account_mutex);
+
+       return error_code;
+}
+
+int account_disconnect (void)
+{
+       return _account_disconnect();
+}
+
+static int _account_free_capability_items(account_capability_s *data)
+{
+       _ACCOUNT_FREE(data->package_name);
+       _ACCOUNT_FREE(data->user_name);
+
+       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);
+
+       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);
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_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)) {
+               account_capability_s *cap_data = (account_capability_s*)iter->data;
+               _account_free_capability_items(cap_data);
+       }
+
+       g_slist_free(list);
+       list = NULL;
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_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_s *account_record = (account_s*)iter->data;
+               _account_free_account_items(account_record);
+       }
+
+       g_list_free(list);
+       list = NULL;
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+static gboolean _account_check_duplicated(account_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 user_name='%s' and domain_name='%s'"
+                       , ACCOUNT_TABLE, data->user_name, data->domain_name);
+
+       count = _account_get_record_count(query);
+       if (count > 0) {
+               ACCOUNT_DEBUG("_account_check_duplicated : duplicated %d account(s) exist!, user_name=%s, domain_name=%s\n",
+                       count, data->user_name, data->domain_name );
+               return TRUE;
+       }
+
+       return FALSE;
+}
+
+static int _account_get_next_sequence(char *pszName)
+{
+       int                     rc = 0;
+       account_stmt    pStmt = NULL;
+       int                     max_seq = 0;
+       char                    szQuery[ACCOUNT_SQL_LEN_MAX] = {0,};
+
+       ACCOUNT_DEBUG( "[Enter] pszName:%s\n", pszName);
+
+       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);
+
+       rc = sqlite3_step(pStmt);
+       max_seq = sqlite3_column_int(pStmt, 0);
+       max_seq++;
+
+       ACCOUNT_DEBUG( "sqlite3_column_int, rc=%d, max_seq=%d\n", rc, 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"));
+
+       ACCOUNT_DEBUG( "prepare query : %s", query);
+
+       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)
+{
+       assert(NULL != pStmt);
+       assert(pos > -1);
+       return sqlite3_bind_int(pStmt, pos, num);
+}
+
+static int _account_query_bind_text(account_stmt pStmt, int pos, const char *str)
+{
+       assert(NULL != pStmt);
+
+       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)
+{
+       ACCOUNT_DEBUG( "_account_convert_account_to_sql");
+       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);
+
+       int i;
+
+       /* 11. user text*/
+       for(i=0; i< USER_TXT_CNT; i++)
+               _account_query_bind_text(hstmt, count++, (char*)account->user_data_txt[i]);
+
+       /* 12. user integer     */
+       for(i=0; i< USER_INT_CNT; i++)
+               _account_query_bind_int(hstmt, count++, account->user_data_int[i]);
+
+       return count;
+}
+
+
+static void _account_query_finalize(account_stmt pStmt)
+{
+       int rc = -1;
+
+       if (!pStmt) {
+               ACCOUNT_DEBUG( "pStmt is NULL");
+               return;
+       }
+
+       rc = sqlite3_finalize(pStmt);
+       if (rc != SQLITE_OK) {
+               ACCOUNT_DEBUG( "sqlite3_finalize fail, rc : %d, db_error : %s\n", rc, _account_db_err_msg());
+       }
+
+       ACCOUNT_DEBUG( "sqlite3_finalize finish");
+}
+
+
+static int _account_query_step(account_stmt pStmt)
+{
+       assert(NULL != pStmt);
+       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;
+
+       if (!account->user_name && !account->display_name && !account->email_address) {
+               ACCOUNT_DEBUG("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 , txt_custom0, txt_custom1, txt_custom2, txt_custom3, txt_custom4, "
+                       "int_custom0, int_custom1, int_custom2, int_custom3, int_custom4, txt_custom0 ) values "
+                       "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? , ?)",     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_DEBUG( "account_db_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+               error_code = ACCOUNT_ERROR_DB_FAILED;
+       }
+
+       _account_query_finalize(hstmt);
+       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 (rc <= 0) {
+               ACCOUNT_DEBUG( "_account_insert_capability : 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->capablity_list; iter != NULL; iter = g_slist_next(iter)) {
+               int rc, 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;
+               ACCOUNT_DEBUG( "@@@@@@@@@@@@@cap_data->type = %d, cap_data->value = %d \n @@@@@@@@@@", cap_data->type, cap_data->value);
+
+               ret = _account_query_bind_int(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, ("Text 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_DEBUG( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+                       break;
+               }
+
+               _account_query_finalize(hstmt);
+               hstmt = NULL;
+
+       }
+
+       ACCOUNT_DEBUG( "_account_insert_capability() DONE\n");
+
+       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_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 (rc <= 0) {
+               ACCOUNT_DEBUG( "_account_insert_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);
+       _account_query_step(hstmt);
+       _account_query_finalize(hstmt);
+       hstmt = NULL;
+
+       GSList *iter;
+
+       for (iter = account->capablity_list; iter != NULL; iter = g_slist_next(iter)) {
+               int rc, 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_int(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, ("Text 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_DEBUG( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+                       break;
+               }
+
+               _account_query_finalize(hstmt);
+               hstmt = NULL;
+
+       }
+
+       ACCOUNT_DEBUG( "_account_insert_capability() DONE\n");
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_update_capability_by_user_name(account_s *account, char *user_name, 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_DEBUG( "_account_insert_capability, 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_DEBUG( "_account_insert_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 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);
+       _account_query_step(hstmt);
+       _account_query_finalize(hstmt);
+       hstmt = NULL;
+
+       GSList* iter;
+
+       for (iter = account->capablity_list; iter != NULL; iter = g_slist_next(iter)) {
+               int rc, 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_int(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, ("Text 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_DEBUG( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+                       break;
+               }
+
+               _account_query_finalize(hstmt);
+               hstmt = NULL;
+
+       }
+
+       ACCOUNT_DEBUG( "_account_insert_capability() DONE\n");
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+static int _account_query_table_column_int(account_stmt pStmt, int pos)
+{
+       assert(NULL != pStmt);
+       assert(pos > -1);
+       return sqlite3_column_int(pStmt, pos);
+}
+
+static char *_account_query_table_column_text(account_stmt pStmt, int pos)
+{
+       assert(NULL != pStmt);
+       assert(pos > -1);
+       return (char *)sqlite3_column_text(pStmt, pos);
+}
+
+static void _account_db_data_to_text(char *textbuf, char **output)
+{
+       if (textbuf && strlen(textbuf)>0) {
+               if (*output) {
+                       free(*output);
+                       *output = NULL;
+               }
+               *output = strdup(textbuf);
+       } else {
+               ACCOUNT_DEBUG("_account_db_data_to_text : no text");
+       }
+}
+
+static void _account_convert_column_to_account(account_stmt hstmt, account_s *account_record)
+{
+       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);
+
+       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);
+
+       ACCOUNT_DEBUG("END _account_convert_column_to_account");
+}
+
+
+static void _account_convert_column_to_capability(account_stmt hstmt, account_capability_s *capability_record)
+{
+       char *textbuf = NULL;
+
+       capability_record->id = _account_query_table_column_int(hstmt, ACCOUNT_FIELD_ID);
+
+       capability_record->type = _account_query_table_column_int(hstmt, CAPABILITY_FIELD_KEY);
+
+       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);
+
+       ACCOUNT_DEBUG("END _account_convert_column_to_capability");
+}
+
+bool _account_get_capability_text_cb(account_capability_type_e 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 = capability_type;
+       cap_data->value = capability_value;
+
+       data->capablity_list = g_slist_append(data->capablity_list, (gpointer)cap_data);
+
+       ACCOUNT_DEBUG("_account_get_capability_text_cb :: %d\n", capability_type);
+
+       return TRUE;
+}
+
+static char *_account_get_text(char *text_data)
+{
+       char *text_value = NULL;
+
+       if (text_data != NULL) {
+               text_value = strdup(text_data);
+               ACCOUNT_DEBUG("text_value = %s", text_value);
+       }
+       return text_value;
+}
+
+static int _account_update_account_by_user_name(account_s *account, char *user_name, char *package_name)
+{
+       int                             rc = 0, binding_count =0;
+       char                    query[ACCOUNT_SQL_LEN_MAX] = {0, };
+       int                             error_code = ACCOUNT_ERROR_NONE;
+       account_stmt    hstmt = NULL;
+
+       ACCOUNT_RETURN_VAL((account->user_name != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("user_name is NULL.\n"));
+       ACCOUNT_RETURN_VAL((account->email_address != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("email_address is NULL.\n"));
+
+       if (!account->user_name && !account->display_name && !account->email_address) {
+               ACCOUNT_DEBUG("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), "UPDATE %s SET user_name=?, email_address =?, display_name =?, "
+                       "icon_path =?, source =?, package_name =? , access_token =?, domain_name =?, auth_type =?, secret =?,"
+                       "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);
+       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);
+       ACCOUNT_DEBUG("_account_query_step : user_name = %s, package_name=%s\n", user_name, package_name);
+       rc = _account_query_step(hstmt);
+       ACCOUNT_DEBUG("_account_query_step return rc=%d\n", rc);
+       if (rc != SQLITE_DONE) {
+               ACCOUNT_DEBUG( "account_db_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+       }
+
+       _account_query_finalize(hstmt);
+       hstmt = NULL;
+
+       /*update capability*/
+       _account_update_capability_by_user_name(account, user_name, package_name);
+
+       return error_code;
+}
+
+int account_insert_to_db(account_h account, int *account_id)
+{
+       int ret = ACCOUNT_ERROR_NONE;
+       int             error_code = ACCOUNT_ERROR_NONE;
+
+       if(!g_hAccountDB) {
+               ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected. rc : %d", ret));
+       }
+
+       ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL"));
+
+       account_s *data = (account_s*)account;
+
+       pthread_mutex_lock(&account_mutex);
+
+       if (_account_check_duplicated(data)) {
+               error_code = ACCOUNT_ERROR_DUPLICATED;
+       } else {
+               *account_id = _account_get_next_sequence(ACCOUNT_TABLE);
+
+               error_code = _account_execute_insert_query(data);
+
+               if (error_code != ACCOUNT_ERROR_NONE)
+                       *account_id = -1;
+       }
+
+       ACCOUNT_DEBUG( "_account_execute_insert_query, insert error_code : %d", error_code);
+
+       _account_insert_capability(data, *account_id);
+
+       pthread_mutex_unlock(&account_mutex);
+
+       return ACCOUNT_ERROR_NONE;
+
+}
+
+int account_create(account_h *account)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%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)
+               return ACCOUNT_ERROR_OUT_OF_MEMORY;
+       ACCOUNT_MEMSET(data, 0, sizeof(account_s));
+
+       ACCOUNT_DEBUG("create handle=%p\n", *account);
+
+       *account = (account_h)data;
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+int account_set_user_name(account_h account, const char *user_name)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!user_name) {
+               ACCOUNT_DEBUG("(%s)-(%d) user_name is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       account_s *data = (account_s*)account;
+
+       ACCOUNT_DEBUG("account=%p\n", account);
+
+       _ACCOUNT_FREE(data->user_name);
+       data->user_name = strdup(user_name);
+
+       ACCOUNT_DEBUG("(%s)-(%d) %s, %s\n", __FUNCTION__, __LINE__ , data->user_name, user_name);
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+
+int account_set_display_name(account_h account, const char *display_name)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!display_name) {
+               ACCOUNT_DEBUG("(%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 = strdup(display_name);
+
+       ACCOUNT_DEBUG("(%s)-(%d) %s, %s\n", __FUNCTION__, __LINE__ , data->display_name, display_name);
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+int account_set_email_address(account_h account, const char *email_address)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!email_address) {
+               ACCOUNT_DEBUG("(%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 = strdup(email_address);
+
+       ACCOUNT_DEBUG("(%s)-(%d) %s, %s\n", __FUNCTION__, __LINE__ , data->email_address, email_address);
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+int account_set_icon_path(account_h account, const char *icon_path)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!icon_path) {
+               ACCOUNT_DEBUG("(%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 = strdup(icon_path);
+
+       ACCOUNT_DEBUG("(%s)-(%d) %s, %s\n", __FUNCTION__, __LINE__ , data->icon_path, icon_path);
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+
+int account_set_source(account_h account, const char *source)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!source) {
+               ACCOUNT_DEBUG("(%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 = strdup(source);
+
+       ACCOUNT_DEBUG("(%s)-(%d) %s, %s\n", __FUNCTION__, __LINE__ , data->source, source);
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+int account_set_package_name(account_h account, const char *package_name)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!package_name) {
+               ACCOUNT_DEBUG("(%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 = strdup(package_name);
+
+       ACCOUNT_DEBUG("(%s)-(%d) %s, %s\n", __FUNCTION__, __LINE__ , data->package_name, package_name);
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+
+int account_set_domain_name(account_h account, const char *domain_name)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!domain_name) {
+               ACCOUNT_DEBUG("(%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 = strdup(domain_name);
+
+       ACCOUNT_DEBUG("(%s)-(%d) %s, %s\n", __FUNCTION__, __LINE__ , data->domain_name, domain_name);
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+
+int account_set_access_token(account_h account, const char *access_token)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!access_token) {
+               ACCOUNT_DEBUG("(%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 = strdup(access_token);
+
+       ACCOUNT_DEBUG("(%s)-(%d) %s, %s\n", __FUNCTION__, __LINE__ , data->access_token, access_token);
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+int account_set_user_text(account_h account, int index, const char *user_txt)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!user_txt) {
+               ACCOUNT_DEBUG("(%s)-(%d) user_txt is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+       if (index >= USER_TXT_CNT) {
+               ACCOUNT_DEBUG("(%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[index]);
+       data->user_data_txt[index] = strdup(user_txt);
+
+       ACCOUNT_DEBUG("(%s)-(%d) %s, %s\n", __FUNCTION__, __LINE__ , data->user_data_txt[index], user_txt);
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+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 ( (auth_type < 0) || (auth_type > ACCOUNT_AUTH_TYPE_CLIENT_LOGIN)) {
+               ACCOUNT_DEBUG("(%s)-(%d) auth_type is less than 1 or more than enum max.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       account_s *data = (account_s*)account;
+
+       data->auth_type = (int)auth_type;
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+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 ( (secret < 0) || (secret > ACCOUNT_SECRECY_VISIBLE)) {
+               ACCOUNT_DEBUG("(%s)-(%d) auth_type is less than 1 or more than enum max.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       account_s *data = (account_s*)account;
+
+       data->secret = (int)secret;
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+int account_set_user_int(account_h account, int index, const int user_int)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (index >= USER_INT_CNT) {
+               ACCOUNT_DEBUG("(%s)-(%d) index rage should be between 0-4.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       account_s *data = (account_s*)account;
+
+       data->user_data_int[index] = user_int;
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+
+int account_set_capability(account_h account, account_capability_type_e capability_type, account_capability_state_e capability_value)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       if ( (capability_type < 0) || (capability_type > ACCOUNT_CAPABILITY_MOBILE_TRACKER)) {
+               ACCOUNT_DEBUG("(%s)-(%d) capability_type is less than 1 or more than enum max.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       if ((capability_value != ACCOUNT_CAPABILITY_DISABLED) && (capability_value != ACCOUNT_CAPABILITY_ENABLED)) {
+               ACCOUNT_DEBUG("(%s)-(%d) capability_value is not equal to 0 or 1.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       account_s *data = (account_s*)account;
+
+       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 = capability_type;
+       cap_data->value = capability_value;
+       data->capablity_list = g_slist_append(data->capablity_list, (gpointer)cap_data);
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+int account_get_user_name(account_h account, char **user_name)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!user_name) {
+               ACCOUNT_DEBUG("(%s)-(%d) user name is NULL.\n", __FUNCTION__, __LINE__);
+               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;
+}
+
+int account_get_display_name(account_h account, char **display_name)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!display_name) {
+               ACCOUNT_DEBUG("(%s)-(%d) display name is NULL.\n", __FUNCTION__, __LINE__);
+               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;
+}
+
+int account_get_email_address(account_h account,char **email_address)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!email_address) {
+               ACCOUNT_DEBUG("(%s)-(%d) email address is NULL.\n", __FUNCTION__, __LINE__);
+               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;
+}
+
+int  account_get_icon_path(account_h account, char **icon_path)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!icon_path) {
+               ACCOUNT_DEBUG("(%s)-(%d) icon path is NULL.\n", __FUNCTION__, __LINE__);
+               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;
+}
+
+int account_get_source(account_h account, char **source)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!source) {
+               ACCOUNT_DEBUG("(%s)-(%d) source is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       account_s *data = (account_s*)account;
+
+       (*source) = NULL;
+
+       *source = _account_get_text(data->source);
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+int account_get_package_name(account_h account, char **package_name)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!package_name) {
+               ACCOUNT_DEBUG("(%s)-(%d) package name is NULL.\n", __FUNCTION__, __LINE__);
+               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;
+}
+
+int account_get_domain_name(account_h account, char **domain_name)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!domain_name) {
+               ACCOUNT_DEBUG("(%s)-(%d) domain name is NULL.\n", __FUNCTION__, __LINE__);
+               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;
+}
+
+int account_get_access_token(account_h account, char **access_token)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!access_token) {
+               ACCOUNT_DEBUG("(%s)-(%d) access token is NULL.\n", __FUNCTION__, __LINE__);
+               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;
+}
+
+int account_get_user_text(account_h account, int user_text_index, char **text)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!text) {
+               ACCOUNT_DEBUG("(%s)-(%d) text is NULL.\n", __FUNCTION__, __LINE__);
+               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;
+}
+
+int account_get_auth_type(account_h account, account_auth_type_e *auth_type)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+       if (!auth_type) {
+               ACCOUNT_DEBUG("(%s)-(%d) auth_type is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       account_s* data = (account_s*)account;
+
+       *auth_type = data->auth_type;
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+int account_get_secret(account_h account, account_secrecy_state_e *secret)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+       if (!secret) {
+               ACCOUNT_DEBUG("(%s)-(%d) secret is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       account_s* data = (account_s*)account;
+
+       *secret = data->secret;
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+int account_get_account_id(account_h account, int *account_id)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+       if (!account_id) {
+               ACCOUNT_DEBUG("(%s)-(%d) account_id is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       account_s *data = (account_s*)account;
+
+       *account_id = data->id;
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+int account_get_user_int(account_h account, int user_int_index, int *integer)
+{
+       if (!account) {
+               ACCOUNT_DEBUG("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__);
+               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) {
+               ACCOUNT_DEBUG("(%s)-(%d) integer is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       account_s *data = (account_s*)account;
+
+       *integer = data->user_data_int[user_int_index];
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+int account_get_capability(account_h account, capability_cb cb_func, void *user_data)
+{
+       ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL"));
+       ACCOUNT_RETURN_VAL((cb_func != 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;
+
+               ACCOUNT_DEBUG("account_get_capability :: type = %d, value = %d", cap_data->type, cap_data->value);
+
+               cb_func(cap_data->type, cap_data->value, user_data);
+       }
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+int account_query_capability_by_account_id(capability_cb cb_func, 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"));
+
+       int ret = ACCOUNT_ERROR_NONE;
+
+       if (!g_hAccountDB) {
+               ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected. rc : %d", ret));
+       }
+
+       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);
+
+       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) {
+               capability_record = (account_capability_s*) malloc(sizeof(account_capability_s));
+
+               if (capability_record == NULL) {
+                       ACCOUNT_DEBUG("malloc Failed");
+                       break;
+               }
+
+               ACCOUNT_MEMSET(capability_record, 0x00, sizeof(account_capability_s));
+
+               _account_convert_column_to_capability(hstmt, capability_record);
+
+               cb_func(capability_record->type, capability_record->value, user_data);
+
+               _account_free_capability_items(capability_record);
+               _ACCOUNT_FREE(capability_record);
+
+               rc = _account_query_step(hstmt);
+       }
+
+       _account_query_finalize(hstmt);
+       hstmt = NULL;
+
+       error_code = ACCOUNT_ERROR_NONE;
+
+CATCH:
+       if (hstmt != NULL) {
+               _account_query_finalize(hstmt);
+               hstmt = NULL;
+       }
+
+       pthread_mutex_unlock(&account_mutex);
+       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;
+       account_stmt    hstmt = NULL;
+
+       ACCOUNT_RETURN_VAL((account->user_name != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("user_name is NULL.\n"));
+       ACCOUNT_RETURN_VAL((account->email_address != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("email_address is NULL.\n"));
+
+       if (!account->user_name && !account->display_name && !account->email_address) {
+               ACCOUNT_DEBUG("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), "UPDATE %s SET user_name=?, email_address =?, display_name =?, "
+                       "icon_path =?, source =?, package_name =? , access_token =?, domain_name =?, auth_type =?, secret =?,"
+                       "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);
+       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_int(hstmt, binding_count++, account_id);
+
+       rc = _account_query_step(hstmt);
+       ACCOUNT_DEBUG("_account_query_step return rc=%d\n", rc);
+       if (rc != SQLITE_DONE) {
+               ACCOUNT_DEBUG( "account_db_query_step() failed(%d, %s)", rc, _account_db_err_msg());
+       }
+
+       _account_query_finalize(hstmt);
+       hstmt = NULL;
+
+       /*update capability*/
+       _account_update_capability(account, account_id);
+
+       return error_code;
+}
+
+int account_update_to_db_by_id(const account_h account, int account_id)
+{
+       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"));
+       int     error_code = ACCOUNT_ERROR_NONE;
+       account_s* data = (account_s*)account;
+
+       int ret = ACCOUNT_ERROR_NONE;
+
+       if (!g_hAccountDB) {
+               ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected. rc : %d", ret));
+       }
+
+       pthread_mutex_lock(&account_mutex);
+
+       error_code = _account_update_account(data, account_id);
+
+       pthread_mutex_unlock(&account_mutex);
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+int account_update_to_db_by_user_name(account_h account, const char *user_name, const char *package_name)
+{
+       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"));
+
+       int     error_code = ACCOUNT_ERROR_NONE;
+       account_s *data = (account_s*)account;
+
+       int ret = ACCOUNT_ERROR_NONE;
+
+       if (!g_hAccountDB) {
+               ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected. rc : %d", ret));
+       }
+       pthread_mutex_lock(&account_mutex);
+
+       error_code = _account_update_account_by_user_name(data, (char*)user_name, (char*)package_name);
+
+       pthread_mutex_unlock(&account_mutex);
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+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;
+
+       ACCOUNT_RETURN_VAL((callback != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT INFO IS NULL"));
+
+       int ret = ACCOUNT_ERROR_NONE;
+
+       if (!g_hAccountDB) {
+               ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected. rc : %d", ret));
+       }
+
+       ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+
+       ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s ", ACCOUNT_TABLE);
+       hstmt = _account_prepare_query(query);
+
+       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_DEBUG("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);
+
+               ACCOUNT_DEBUG("##### URUSA account_record(%d) = %p\n", k, account_record);
+
+               rc = _account_query_step(hstmt);
+               k++;
+       }
+
+       _account_query_finalize(hstmt);
+       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);
+               callback((account_h)account, user_data);
+               k++;
+       }
+
+       error_code = ACCOUNT_ERROR_NONE;
+
+CATCH:
+       if (hstmt != NULL) {
+               _account_query_finalize(hstmt);
+               hstmt = NULL;
+       }
+       if (account_list) {
+               _account_glist_free(account_list);
+               account_list = NULL;
+       }
+
+       return error_code;
+}
+
+
+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;
+
+       ACCOUNT_RETURN_VAL((account_db_id > 0), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT INDEX IS LESS THAN 0"));
+
+       int ret = ACCOUNT_ERROR_NONE;
+
+       if (!g_hAccountDB) {
+               ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected. rc : %d", ret));
+       }
+
+       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);
+
+       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);
+               ACCOUNT_DEBUG("get account info by id %p\n", account_record);
+               rc = _account_query_step(hstmt);
+       }
+
+       _account_query_finalize(hstmt);
+       account_query_capability_by_account_id(_account_get_capability_text_cb, account_record->id, (void*)account_record);
+
+       hstmt = NULL;
+       error_code = ACCOUNT_ERROR_NONE;
+
+CATCH:
+       if (hstmt != NULL) {
+               _account_query_finalize(hstmt);
+               hstmt = NULL;
+       }
+
+       pthread_mutex_unlock(&account_mutex);
+       return error_code;
+}
+
+int account_query_account_by_user_name(account_cb cb_func, 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;
+
+       ACCOUNT_RETURN_VAL((user_name != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("USER NAME IS NULL"));
+
+
+       int ret = ACCOUNT_ERROR_NONE;
+
+       if (!g_hAccountDB) {
+               ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected. rc : %d", ret));
+       }
+
+       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);
+
+       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_DEBUG("malloc Failed");
+               if (hstmt != NULL) {
+                       _account_query_finalize(hstmt);
+                       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_DEBUG("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++;
+               ACCOUNT_DEBUG("DETECTED COUNT %d\n", tmp);
+       }
+
+       _account_query_finalize(hstmt);
+       hstmt = NULL;
+
+       GList *iter;
+
+
+       tmp = g_list_length(account_head->account_list);
+       ACCOUNT_DEBUG("GLIST LEN %d\n", tmp);
+
+       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_DEBUG("id = %d", testaccount->id);
+               ACCOUNT_DEBUG("user_name = %s", testaccount->user_name);
+               ACCOUNT_DEBUG("email_address = %s", testaccount->email_address);
+               ACCOUNT_DEBUG("display_name = %s", testaccount->display_name);
+               ACCOUNT_DEBUG("icon_path = %s", testaccount->icon_path);
+               ACCOUNT_DEBUG("source = %s", testaccount->source);
+               ACCOUNT_DEBUG("package_name = %s", testaccount->package_name);
+               ACCOUNT_DEBUG("access_token = %s", testaccount->access_token);
+               ACCOUNT_DEBUG("domain_name = %s", testaccount->domain_name);
+               ACCOUNT_DEBUG("auth_type = %d", testaccount->auth_type);
+               ACCOUNT_DEBUG("secret = %d", testaccount->secret);
+               ACCOUNT_DEBUG("user text = %s", testaccount->user_data_txt[0]);
+               ACCOUNT_DEBUG("user text = %s", testaccount->user_data_txt[1]);
+               ACCOUNT_DEBUG("user text = %s", testaccount->user_data_txt[2]);
+               ACCOUNT_DEBUG("user text = %s", testaccount->user_data_txt[3]);
+               ACCOUNT_DEBUG("user text = %s", testaccount->user_data_txt[4]);
+               ACCOUNT_DEBUG("user int = %d", testaccount->user_data_int[0]);
+               ACCOUNT_DEBUG("user int = %d", testaccount->user_data_int[1]);
+               ACCOUNT_DEBUG("user int = %d", testaccount->user_data_int[2]);
+               ACCOUNT_DEBUG("user int = %d", testaccount->user_data_int[3]);
+               ACCOUNT_DEBUG("user int = %d", testaccount->user_data_int[4]);
+
+               account_query_capability_by_account_id(_account_get_capability_text_cb, testaccount->id, (void*)testaccount);
+
+               ACCOUNT_DEBUG("capability_list address = %p", testaccount->capablity_list);
+
+               cb_func(account, user_data);
+
+       }
+
+       error_code = ACCOUNT_ERROR_NONE;
+
+CATCH:
+       if (hstmt != NULL) {
+               _account_query_finalize(hstmt);
+               hstmt = NULL;
+       }
+       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);
+               }
+       }
+
+       pthread_mutex_unlock(&account_mutex);
+       return error_code;
+}
+
+int account_query_account_by_capability(account_cb cb_func, account_capability_type_e 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;
+
+       if ( (capability_type < 0) || (capability_type > ACCOUNT_CAPABILITY_MOBILE_TRACKER)) {
+               ACCOUNT_DEBUG("(%s)-(%d) capability_type is less than 1 or more than enum max.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       if ((capability_value  < 0) || (capability_value > ACCOUNT_CAPABILITY_ENABLED)) {
+               ACCOUNT_DEBUG("(%s)-(%d) capability_value is not equal to 0 or 1.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       ACCOUNT_RETURN_VAL((cb_func != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("CALL BACK IS NULL"));
+
+       int ret = ACCOUNT_ERROR_NONE;
+
+       if (!g_hAccountDB) {
+               ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected. rc : %d", ret));
+       }
+
+       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);
+
+       int binding_count = 1;
+       _account_query_bind_int(hstmt, binding_count++, (int)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_DEBUG("malloc Failed");
+               if (hstmt != NULL) {
+                       _account_query_finalize(hstmt);
+                       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_DEBUG("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++;
+               ACCOUNT_DEBUG("DETECTED COUNT %d\n", tmp);
+       }
+
+       _account_query_finalize(hstmt);
+       hstmt = NULL;
+
+       GList *iter;
+
+
+       tmp = g_list_length(account_head->account_list);
+       ACCOUNT_DEBUG("GLIST LEN %d\n", tmp);
+
+       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_DEBUG("id = %d", testaccount->id);
+               ACCOUNT_DEBUG("user_name = %s", testaccount->user_name);
+               ACCOUNT_DEBUG("email_address = %s", testaccount->email_address);
+               ACCOUNT_DEBUG("display_name = %s", testaccount->display_name);
+               ACCOUNT_DEBUG("icon_path = %s", testaccount->icon_path);
+               ACCOUNT_DEBUG("source = %s", testaccount->source);
+               ACCOUNT_DEBUG("package_name = %s", testaccount->package_name);
+               ACCOUNT_DEBUG("access_token = %s", testaccount->access_token);
+               ACCOUNT_DEBUG("domain_name = %s", testaccount->domain_name);
+               ACCOUNT_DEBUG("auth_type = %d", testaccount->auth_type);
+               ACCOUNT_DEBUG("secret = %d", testaccount->secret);
+               ACCOUNT_DEBUG("user text = %s", testaccount->user_data_txt[0]);
+               ACCOUNT_DEBUG("user text = %s", testaccount->user_data_txt[1]);
+               ACCOUNT_DEBUG("user text = %s", testaccount->user_data_txt[2]);
+               ACCOUNT_DEBUG("user text = %s", testaccount->user_data_txt[3]);
+               ACCOUNT_DEBUG("user text = %s", testaccount->user_data_txt[4]);
+               ACCOUNT_DEBUG("user int = %d", testaccount->user_data_int[0]);
+               ACCOUNT_DEBUG("user int = %d", testaccount->user_data_int[1]);
+               ACCOUNT_DEBUG("user int = %d", testaccount->user_data_int[2]);
+               ACCOUNT_DEBUG("user int = %d", testaccount->user_data_int[3]);
+               ACCOUNT_DEBUG("user int = %d", testaccount->user_data_int[4]);
+
+               account_query_capability_by_account_id(_account_get_capability_text_cb, testaccount->id, (void*)testaccount);
+
+               ACCOUNT_DEBUG("capability_list address = %p", testaccount->capablity_list);
+
+               cb_func(account, user_data);
+
+       }
+
+
+       error_code = ACCOUNT_ERROR_NONE;
+
+CATCH:
+       if (hstmt != NULL) {
+               _account_query_finalize(hstmt);
+               hstmt = NULL;
+       }
+       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);
+               }
+       }
+
+       pthread_mutex_unlock(&account_mutex);
+       return error_code;
+}
+
+
+int account_query_account_by_package_name(account_cb cb_func, 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;
+
+       ACCOUNT_RETURN_VAL((package_name != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("PACKAGE NAME IS NULL"));
+       ACCOUNT_RETURN_VAL((cb_func != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("CALL BACK IS NULL"));
+
+       int ret = ACCOUNT_ERROR_NONE;
+
+       if (!g_hAccountDB) {
+               ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected. rc : %d", ret));
+       }
+
+       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);
+
+       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.\n"));
+
+       int tmp = 0;
+
+       account_head = (account_s*) malloc(sizeof(account_s));
+       if (account_head == NULL) {
+               ACCOUNT_DEBUG("malloc Failed");
+               if (hstmt != NULL) {
+                       _account_query_finalize(hstmt);
+                       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_DEBUG("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++;
+               ACCOUNT_DEBUG("DETECTED COUNT %d\n", tmp);
+       }
+
+       _account_query_finalize(hstmt);
+       hstmt = NULL;
+
+       GList *iter;
+
+
+       tmp = g_list_length(account_head->account_list);
+       ACCOUNT_DEBUG("GLIST LEN %d\n", tmp);
+
+       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_DEBUG("id = %d", testaccount->id);
+               ACCOUNT_DEBUG("user_name = %s", testaccount->user_name);
+               ACCOUNT_DEBUG("email_address = %s", testaccount->email_address);
+               ACCOUNT_DEBUG("display_name = %s", testaccount->display_name);
+               ACCOUNT_DEBUG("icon_path = %s", testaccount->icon_path);
+               ACCOUNT_DEBUG("source = %s", testaccount->source);
+               ACCOUNT_DEBUG("package_name = %s", testaccount->package_name);
+               ACCOUNT_DEBUG("access_token = %s", testaccount->access_token);
+               ACCOUNT_DEBUG("domain_name = %s", testaccount->domain_name);
+               ACCOUNT_DEBUG("auth_type = %d", testaccount->auth_type);
+               ACCOUNT_DEBUG("secret = %d", testaccount->secret);
+               ACCOUNT_DEBUG("user text = %s", testaccount->user_data_txt[0]);
+               ACCOUNT_DEBUG("user text = %s", testaccount->user_data_txt[1]);
+               ACCOUNT_DEBUG("user text = %s", testaccount->user_data_txt[2]);
+               ACCOUNT_DEBUG("user text = %s", testaccount->user_data_txt[3]);
+               ACCOUNT_DEBUG("user text = %s", testaccount->user_data_txt[4]);
+               ACCOUNT_DEBUG("user int = %d", testaccount->user_data_int[0]);
+               ACCOUNT_DEBUG("user int = %d", testaccount->user_data_int[1]);
+               ACCOUNT_DEBUG("user int = %d", testaccount->user_data_int[2]);
+               ACCOUNT_DEBUG("user int = %d", testaccount->user_data_int[3]);
+               ACCOUNT_DEBUG("user int = %d", testaccount->user_data_int[4]);
+
+               account_query_capability_by_account_id(_account_get_capability_text_cb, testaccount->id, (void*)testaccount);
+
+               ACCOUNT_DEBUG("capability_list address = %p", testaccount->capablity_list);
+
+               cb_func(account, user_data);
+
+       }
+
+       error_code = ACCOUNT_ERROR_NONE;
+
+CATCH:
+       if (hstmt != NULL) {
+               _account_query_finalize(hstmt);
+               hstmt = NULL;
+       }
+       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);
+               }
+       }
+
+       pthread_mutex_unlock(&account_mutex);
+       return error_code;
+}
+
+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, ret =0;
+       bool                    is_success = FALSE;
+
+       if (!g_hAccountDB) {
+               ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected. rc : %d", ret));
+       }
+
+       /* transaction control required*/
+       ret_transaction = _account_begin_transaction();
+
+       if (ret_transaction != ACCOUNT_ERROR_NONE) {
+               ACCOUNT_DEBUG("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 account_id = %d", CAPABILITY_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.\n"));
+
+       _account_query_finalize(hstmt);
+       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));
+
+       _account_query_finalize(hstmt);
+       is_success = TRUE;
+
+       hstmt = NULL;
+
+CATCH:
+       if (hstmt != NULL) {
+               _account_query_finalize(hstmt);
+               hstmt = NULL;
+       }
+
+       ret_transaction = _account_end_transaction(is_success);
+
+       if (ret_transaction != ACCOUNT_ERROR_NONE) {
+               ACCOUNT_DEBUG("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;
+
+}
+
+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."));
+
+       account_delete(account_db_id);
+}
+
+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, ret =0;
+       bool                    is_success = FALSE;
+
+       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!"));
+
+       if (!g_hAccountDB) {
+               ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected. rc : %d", ret));
+       }
+
+       /* transaction control required*/
+       ret_transaction = _account_begin_transaction();
+
+       if (ret_transaction != ACCOUNT_ERROR_NONE) {
+               ACCOUNT_DEBUG("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 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()));
+
+       int 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"));
+
+       _account_query_finalize(hstmt);
+       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));
+
+       _account_query_finalize(hstmt);
+       is_success = TRUE;
+
+       hstmt = NULL;
+
+CATCH:
+       if (hstmt != NULL) {
+               _account_query_finalize(hstmt);
+               hstmt = NULL;
+       }
+
+       ret_transaction = _account_end_transaction(is_success);
+
+       if (ret_transaction != ACCOUNT_ERROR_NONE) {
+               ACCOUNT_DEBUG("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;
+}
+
+int account_delete_from_db_by_package_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, ret =0;
+       bool                    is_success = FALSE;
+
+       ACCOUNT_RETURN_VAL((package_name != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("package_name is null!"));
+
+       if (!g_hAccountDB) {
+               ACCOUNT_RETURN_VAL((ret == ACCOUNT_ERROR_NONE), {}, ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected. rc : %d", ret));
+       }
+
+       /* transaction control required*/
+       ret_transaction = _account_begin_transaction();
+
+       if (ret_transaction != ACCOUNT_ERROR_NONE) {
+               ACCOUNT_DEBUG("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 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()));
+
+       int 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"));
+
+       _account_query_finalize(hstmt);
+       hstmt = NULL;
+
+       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));
+
+       _account_query_finalize(hstmt);
+       is_success = TRUE;
+
+       hstmt = NULL;
+
+CATCH:
+       if (hstmt != NULL) {
+               _account_query_finalize(hstmt);
+               hstmt = NULL;
+       }
+
+       ret_transaction = _account_end_transaction(is_success);
+
+       if (ret_transaction != ACCOUNT_ERROR_NONE) {
+               ACCOUNT_DEBUG("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;
+}
+
+int account_get_total_count_from_db(int *count)
+{
+       if (!count) {
+               ACCOUNT_DEBUG("(%s)-(%d) count is NULL.\n", __FUNCTION__, __LINE__);
+               return ACCOUNT_ERROR_INVALID_PARAMETER;
+       }
+
+       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);
+       int rc = -1;
+       int ncount = 0;
+       account_stmt pStmt = NULL;
+
+       assert(NULL != g_hAccountDB);
+       rc = sqlite3_prepare_v2(g_hAccountDB, query, strlen(query), &pStmt, NULL);
+
+       rc = sqlite3_step(pStmt);
+       if (SQLITE_ROW != rc) {
+               ACCOUNT_DEBUG("[ERROR] sqlite3_step() failed\n");
+               sqlite3_finalize(pStmt);
+               return ACCOUNT_ERROR_DB_FAILED;
+       }
+
+       ncount = sqlite3_column_int(pStmt, 0);
+
+       *count = ncount;
+
+       ACCOUNT_DEBUG("Number of account : %d", ncount);
+       sqlite3_finalize(pStmt);
+
+       if (ncount < 0) {
+               ACCOUNT_DEBUG("[ERROR] Number of account : %d, End", ncount);
+               return ACCOUNT_ERROR_DB_FAILED;
+       }
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+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_DEBUG("destroy handle=%p\n", data);
+
+       _account_free_account_items(data);
+       _ACCOUNT_FREE(data);
+
+       return ACCOUNT_ERROR_NONE;
+}
+
+