summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKibum Kim <kb0929.kim@samsung.com>2012-01-07 00:42:30 +0900
committerKibum Kim <kb0929.kim@samsung.com>2012-01-07 00:42:30 +0900
commit9dc895cff369b90eac117149860365ef33139889 (patch)
treec0f869e0776ec77a4ff482788e300bc8a2e985f1
parente0ca36eef24c43274d4a5375cd492c0cdcbec878 (diff)
downloadcontacts-9dc895cff369b90eac117149860365ef33139889.tar.gz
contacts-9dc895cff369b90eac117149860365ef33139889.tar.bz2
contacts-9dc895cff369b90eac117149860365ef33139889.zip
Git init
-rwxr-xr-xAUTHORS2
-rwxr-xr-xCMakeLists.txt90
-rwxr-xr-xLICENSE206
-rwxr-xr-xcapi-social-contacts.pc.in15
-rwxr-xr-xdebian/README0
-rwxr-xr-xdebian/capi-social-contacts-dev.install4
-rwxr-xr-xdebian/capi-social-contacts-dev.postinst1
-rwxr-xr-xdebian/capi-social-contacts.install1
-rwxr-xr-xdebian/capi-social-contacts.postinst1
-rw-r--r--debian/changelog13
-rwxr-xr-xdebian/compat1
-rwxr-xr-xdebian/control22
-rwxr-xr-xdebian/rules65
-rwxr-xr-xinclude/contacts.h206
-rwxr-xr-xinclude/contacts_address.h171
-rwxr-xr-xinclude/contacts_company.h104
-rwxr-xr-xinclude/contacts_contact.h803
-rwxr-xr-xinclude/contacts_email.h167
-rwxr-xr-xinclude/contacts_event.h105
-rwxr-xr-xinclude/contacts_group.h262
-rwxr-xr-xinclude/contacts_messenger.h162
-rwxr-xr-xinclude/contacts_name.h112
-rwxr-xr-xinclude/contacts_nickname.h136
-rwxr-xr-xinclude/contacts_number.h197
-rwxr-xr-xinclude/contacts_private.h434
-rwxr-xr-xinclude/contacts_relatedgroup.h128
-rwxr-xr-xinclude/contacts_search.h190
-rwxr-xr-xinclude/contacts_types.h582
-rwxr-xr-xinclude/contacts_web.h169
-rwxr-xr-xpackaging/capi-social-contacts.spec54
-rwxr-xr-xsrc/contacts.c158
-rwxr-xr-xsrc/contacts_address.c206
-rwxr-xr-xsrc/contacts_company.c125
-rwxr-xr-xsrc/contacts_contact.c1057
-rwxr-xr-xsrc/contacts_email.c153
-rwxr-xr-xsrc/contacts_event.c95
-rwxr-xr-xsrc/contacts_group.c258
-rwxr-xr-xsrc/contacts_messenger.c154
-rwxr-xr-xsrc/contacts_name.c134
-rwxr-xr-xsrc/contacts_nickname.c128
-rwxr-xr-xsrc/contacts_number.c181
-rwxr-xr-xsrc/contacts_private.c80
-rwxr-xr-xsrc/contacts_relatedgroup.c105
-rwxr-xr-xsrc/contacts_search.c325
-rwxr-xr-xsrc/contacts_web.c155
45 files changed, 7717 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100755
index 0000000..5ebcb3f
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,2 @@
+Jonghoon Lim <j.h.lim@samsung.com>
+Jongchul Park <jc0204.park@samsung.com> \ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755
index 0000000..147a4c3
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,90 @@
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(fw_name "capi-social-contacts")
+
+PROJECT(${fw_name})
+
+SET(CMAKE_INSTALL_PREFIX /usr)
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+SET(INC_DIR include)
+INCLUDE_DIRECTORIES(${INC_DIR})
+
+SET(dependents "dlog contacts-service glib-2.0")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_name} REQUIRED ${dependents})
+FOREACH(flag ${${fw_name}_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+
+IF("${ARCH}" STREQUAL "arm")
+ ADD_DEFINITIONS("-DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DTIZEN_DEBUG")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib")
+
+aux_source_directory(src SOURCES)
+ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
+
+TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
+
+INSTALL(TARGETS ${fw_name} DESTINATION lib)
+INSTALL(
+ DIRECTORY ${INC_DIR}/ DESTINATION include/social
+ FILES_MATCHING
+ PATTERN "*_private.h" EXCLUDE
+ PATTERN "${INC_DIR}/*.h"
+ )
+
+SET(PC_NAME ${fw_name})
+SET(PC_REQUIRED ${dependents})
+SET(PC_LDFLAGS -l${fw_name})
+SET(PC_CFLAGS -I\${includedir}/social)
+
+CONFIGURE_FILE(
+ ${fw_name}.pc.in
+ ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
+ @ONLY
+)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig)
+
+#ADD_SUBDIRECTORY(test)
+
+IF(UNIX)
+
+ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
+ADD_CUSTOM_COMMAND(
+ DEPENDS clean
+ COMMENT "distribution clean"
+ COMMAND find
+ ARGS .
+ -not -name config.cmake -and \(
+ -name tester.c -or
+ -name Testing -or
+ -name CMakeFiles -or
+ -name cmake.depends -or
+ -name cmake.check_depends -or
+ -name CMakeCache.txt -or
+ -name cmake.check_cache -or
+ -name *.cmake -or
+ -name Makefile -or
+ -name core -or
+ -name core.* -or
+ -name gmon.out -or
+ -name install_manifest.txt -or
+ -name *.pc -or
+ -name *~ \)
+ | grep -v TC | xargs rm -rf
+ TARGET distclean
+ VERBATIM
+)
+
+ENDIF(UNIX)
+
diff --git a/LICENSE b/LICENSE
new file mode 100755
index 0000000..bbe9d02
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,206 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+
diff --git a/capi-social-contacts.pc.in b/capi-social-contacts.pc.in
new file mode 100755
index 0000000..d48ca91
--- /dev/null
+++ b/capi-social-contacts.pc.in
@@ -0,0 +1,15 @@
+
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=/usr/lib
+includedir=/usr/include/social
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir} @PC_CFLAGS@
+
diff --git a/debian/README b/debian/README
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/debian/README
diff --git a/debian/capi-social-contacts-dev.install b/debian/capi-social-contacts-dev.install
new file mode 100755
index 0000000..761a28b
--- /dev/null
+++ b/debian/capi-social-contacts-dev.install
@@ -0,0 +1,4 @@
+/usr/include/*
+/usr/include/*/*
+/usr/lib/pkgconfig/*.pc
+
diff --git a/debian/capi-social-contacts-dev.postinst b/debian/capi-social-contacts-dev.postinst
new file mode 100755
index 0000000..1a24852
--- /dev/null
+++ b/debian/capi-social-contacts-dev.postinst
@@ -0,0 +1 @@
+#!/bin/sh
diff --git a/debian/capi-social-contacts.install b/debian/capi-social-contacts.install
new file mode 100755
index 0000000..4a755a4
--- /dev/null
+++ b/debian/capi-social-contacts.install
@@ -0,0 +1 @@
+/usr/lib/lib*.so*
diff --git a/debian/capi-social-contacts.postinst b/debian/capi-social-contacts.postinst
new file mode 100755
index 0000000..1a24852
--- /dev/null
+++ b/debian/capi-social-contacts.postinst
@@ -0,0 +1 @@
+#!/bin/sh
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..b172d94
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,13 @@
+capi-social-contacts (0.1.1-23) unstable; urgency=low
+
+ * version updated
+ * Git: api/contacts
+ * Tag: capi-social-contacts_0.1.1-23
+
+ -- Jonghoon Lim <j.h.lim@samsung.com> Thu, 15 Dec 2011 13:36:54 +0900
+
+capi-social-contacts (0.0.1-1) unstable; urgency=low
+
+ * Initial release.
+
+ -- Jonghoon Lim <j.h.lim@samsung.com> Wed, 07 Dec 2011 12:43:44 +0900
diff --git a/debian/compat b/debian/compat
new file mode 100755
index 0000000..7ed6ff8
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100755
index 0000000..da1ef02
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,22 @@
+
+Source: capi-social-contacts
+Section: libs
+Priority: extra
+Maintainer: Jongchul Park <jc0204.park@samsung.com>, Jonghoon Lim <j.h.lim@samsung.com>
+Build-Depends: debhelper (>= 5), dlog-dev, libcontacts-service-dev, libglib2.0-dev, capi-base-common-dev
+
+Package: capi-social-contacts
+Architecture: any
+Depends: ${shilbs:Depends}, ${misc:Depends}
+Description: Contacts library in Tizen Native API
+
+Package: capi-social-contacts-dev
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, capi-social-contacts (= ${Source-Version}), dlog-dev, libcontacts-service-dev, libglib2.0-dev, capi-base-common-dev
+Description: Contacts library in Tizen Native API (DEV)
+
+Package: capi-social-contacts-dbg
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, capi-social-contacts (= ${Source-Version})
+Description: Contacts library in Tizen Native API (DBG)
+
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..af730d0
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,65 @@
+#!/usr/bin/make -f
+
+CFLAGS = -Wall -g
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+else
+ CFLAGS += -O2
+endif
+CMAKE_ROOT_DIR ?= $(CURDIR)
+CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+ mkdir -p $(CMAKE_BUILD_DIR) && cd $(CMAKE_BUILD_DIR) && cmake ..
+ touch configure-stamp
+
+
+build: build-stamp
+build-stamp: configure-stamp
+ dh_testdir
+ cd $(CMAKE_BUILD_DIR) && $(MAKE)
+ touch $@
+
+clean:
+ cd $(CMAKE_ROOT_DIR)
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp configure-stamp
+ rm -f
+ rm -rf $(CMAKE_BUILD_DIR)
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ cd $(CMAKE_BUILD_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+binary-indep: build install
+
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installchangelogs
+ dh_installdocs
+ dh_installexamples
+ dh_install --sourcedir=debian/tmp
+ dh_installman
+ dh_link
+ dh_strip --dbg-package=capi-social-contacts-dbg
+ dh_fixperms
+ 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/contacts.h b/include/contacts.h
new file mode 100755
index 0000000..2f299ff
--- /dev/null
+++ b/include/contacts.h
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_SOCIAL_CONTACTS_H__
+#define __TIZEN_SOCIAL_CONTACTS_H__
+
+#include <contacts_address.h>
+#include <contacts_company.h>
+#include <contacts_email.h>
+#include <contacts_event.h>
+#include <contacts_group.h>
+#include <contacts_messenger.h>
+#include <contacts_name.h>
+#include <contacts_nickname.h>
+#include <contacts_number.h>
+#include <contacts_contact.h>
+#include <contacts_relatedgroup.h>
+#include <contacts_search.h>
+#include <contacts_types.h>
+#include <contacts_web.h>
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_MODULE
+ * @{
+ */
+
+/**
+ * @brief Connects to the contacts service.
+ *
+ * @remarks Connection opening is necessary to access the contacts database such as fetching, inserting, or updating contacts.\n
+ * The execution of contacts_connect() and contacts_disconnect() could slow down your application so you are recommended not to call them frequently.
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @see contacts_disconnect()
+ *
+ */
+int contacts_connect(void);
+
+/**
+ * @brief Disconnects the contacts service.
+ *
+ * @remarks If there is no opened connection, this function returns #CONTACTS_ERROR_DB_FAILED.
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @see contacts_connect()
+ *
+ */
+int contacts_disconnect(void);
+
+/**
+ * @brief Gets the contacts database version.
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @see contacts_connect()
+ * @see contact_query_contact_by_version()
+ */
+int contacts_get_db_version(int* contacts_db_version);
+
+/**
+ * @brief Registers a callback function to be invoked when the contacts changes.
+ *
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @pre This function requires an open connection to the contacts service by contacts_connect().
+ * @post contacts_db_changed_cb() will be invoked when a contact changes.
+ *
+ * @see contacts_db_changed_cb()
+ * @see contact_query_contact_by_version()
+ * @see contacts_remove_contact_db_changed_cb()
+ * @see contact_insert_to_db()
+ * @see contact_update_to_db()
+ * @see contact_delete_from_db()
+ */
+int contacts_add_contact_db_changed_cb(contacts_db_changed_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ *
+ * @param[in] callback The callback function to unregister
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contacts_db_changed_cb()
+ * @see contacts_add_contact_db_changed_cb()
+ */
+int contacts_remove_contact_db_changed_cb(contacts_db_changed_cb callback);
+
+/**
+ * @brief Registers a callback function to be invoked when the favorite contacts changes.
+ *
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @pre This function requires an open connection to the contacts service by contacts_connect().
+ * @post contacts_db_changed_cb() will be invoked when a contact changes.
+ *
+ * @see contacts_db_changed_cb()
+ * @see contact_query_contact_by_version()
+ * @see contacts_remove_favorite_db_changed_cb()
+ * @see contact_set_favorite_to_db()
+ * @see contact_insert_to_db()
+ * @see contact_update_to_db()
+ * @see contact_delete_from_db()
+ * @see contact_set_favorite()
+ */
+int contacts_add_favorite_db_changed_cb(contacts_db_changed_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ *
+ * @param[in] callback The callback function to unregister
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contacts_db_changed_cb()
+ * @see contacts_add_favorite_db_changed_cb()
+ */
+int contacts_remove_favorite_db_changed_cb(contacts_db_changed_cb callback);
+
+/**
+ * @brief Registers a callback function to be invoked when the favorite contacts changes.
+ *
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @pre This function requires an open connection to the contacts service by contacts_connect().
+ * @post contacts_db_changed_cb() will be invoked when a contact changes.
+ *
+ * @see contacts_db_changed_cb()
+ * @see contacts_remove_group_db_changed_cb()
+ * @see contacts_group_insert_to_db()
+ * @see contacts_group_update_to_db()
+ * @see contacts_group_delete_from_db()
+ */
+int contacts_add_group_db_changed_cb(contacts_db_changed_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ *
+ * @param[in] callback The callback function to unregister
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contacts_db_changed_cb()
+ * @see contacts_add_group_db_changed_cb()
+ */
+int contacts_remove_group_db_changed_cb(contacts_db_changed_cb callback);
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_SOCIAL_CONTACTS_H__ */
+
diff --git a/include/contacts_address.h b/include/contacts_address.h
new file mode 100755
index 0000000..f272608
--- /dev/null
+++ b/include/contacts_address.h
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_SOCIAL_CONTACTS_ADDRESS_H__
+#define __TIZEN_SOCIAL_CONTACTS_ADDRESS_H__
+
+#include <contacts_types.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_ADDRESS_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates a handle to the contacts address.
+ *
+ * @remarks @a address must be released with contact_address_destroy() by you. \n
+ * @a address is not added to contacts database until contact_insert_to_db() is called.
+ *
+ * @param[out] address A new contacts address handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see contact_address_destroy()
+ */
+int contact_address_create(contact_address_h *address);
+
+/**
+ * @brief Destroys the given contacts address handle.
+ *
+ *
+ * @param[in] address The contacts address handle to destroy
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_address_create()
+ */
+int contact_address_destroy(contact_address_h address);
+
+
+/**
+ * @brief Gets the address type from the contacts address handle.
+ *
+ *
+ * @param[in] address The contacts address handle
+ * @param[out] type The address type
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_address_set_type()
+ */
+int contact_address_get_type(contact_address_h address, contact_address_type_e *type);
+
+/**
+ * @brief Sets an address type to the contacts address handle.
+ *
+ * @param[in] address The contacts address handle
+ * @param[in] type The address type
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_address_get_type()
+ */
+int contact_address_set_type(contact_address_h address, contact_address_type_e type);
+
+/**
+ * @brief Gets the detail address from the contacts address handle.
+ *
+ * @remarks @a detail must be released with free() by you.
+ *
+ * @param[in] address The contacts address handle
+ * @param[in] detail_type The detail type to get
+ * @param[out] detail The detail address to be returned \n
+ * If requested data does not exist, @a detail is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_address_set_detail()
+ */
+int contact_address_get_detail(contact_address_h address, contact_address_detail_e detail_type, char **detail);
+
+/**
+ * @brief Sets an address detail to contacts address handle.
+ *
+ * @param[in] address The contacts address handle
+ * @param[in] detail_type The detail type to set
+ * @param[in] detail The detail address to be set
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_address_get_detail()
+ */
+int contact_address_set_detail(contact_address_h address, contact_address_detail_e detail_type, const char *detail);
+
+/**
+ * @brief Moves address list iterator to the next position and gets the contacts address handle.
+ *
+ * @details If the next element for the current address list exists, then the iterator is moved to the next position
+ * on the list and the contacts address handle for this position is returned.
+ * When the iterator reaches the last element of the list, all further calls will return
+ * #CONTACTS_ERROR_ITERATOR_END and @a address will remain unchanged.
+ *
+ *
+ * @param[in] address_iterator The contacts address list handle
+ * @param[out] address The handle to an contacts address, fetched from new iterator position
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_ITERATOR_END List reached end
+ *
+ * @see contact_address_iterator_has_next()
+ * @see contact_get_address_iterator()
+ */
+int contact_address_iterator_next(contact_address_iterator_h *address_iterator, contact_address_h *address);
+
+/**
+ * @brief Checks whether there is a next contacts address handle on the list.
+ *
+ *
+ * @param[in] address_iterator The contacts address list handle
+ *
+ * @return Return @c true If next element exists or @c false If next element doesn't exist
+ *
+ * @see contact_address_iterator_next()
+ * @see contact_get_address_iterator()
+ */
+bool contact_address_iterator_has_next(contact_address_iterator_h address_iterator);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_SOCIAL_CONTACTS_ADDRESS_H__ */
+
diff --git a/include/contacts_company.h b/include/contacts_company.h
new file mode 100755
index 0000000..e79207a
--- /dev/null
+++ b/include/contacts_company.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_SOCIAL_CONTACTS_COMPANY_H__
+#define __TIZEN_SOCIAL_CONTACTS_COMPANY_H__
+
+#include <contacts_types.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_COMPANY_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates a handle to the contacts company.
+ *
+ * @remarks @a company must be released with contact_company_destroy() by you. \n
+ * @a company is not added to contacts database until contact_insert_to_db() is called.
+ *
+ * @param[out] company A new contacts company handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see contact_company_destroy()
+ */
+int contact_company_create(contact_company_h *company);
+
+/**
+ * @brief Destroys the given contacts company handle.
+ *
+ * @param[in] company The contacts company handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_company_create()
+ */
+int contact_company_destroy(contact_company_h company);
+
+/**
+ * @brief Gets the company information detail from the contacts company handle.
+ *
+ * @remarks @a detail must be released with free() by you.
+ *
+ * @param[in] company The contacts company handle
+ * @param[in] detail_type The detail type of company to get
+ * @param[out] detail The detail company to be returned \n
+ * If requested data does not exist, @a detail is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_company_set_detail()
+ */
+int contact_company_get_detail(contact_company_h company, contact_company_detail_e detail_type, char **detail);
+/**
+ * @brief Sets a company information detail to the contacts company handle.
+ *
+ * @param[in] company The contacts company handle
+ * @param[in] detail_type The detail type of company to set
+ * @param[in] detail The detail company to be set
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_company_get_detail()
+ */
+int contact_company_set_detail(contact_company_h company, contact_company_detail_e detail_type, const char *detail);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_SOCIAL_CONTACTS_COMPANY_H__ */
+
diff --git a/include/contacts_contact.h b/include/contacts_contact.h
new file mode 100755
index 0000000..a2b27df
--- /dev/null
+++ b/include/contacts_contact.h
@@ -0,0 +1,803 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_SOCIAL_CONTACTS_CONTACT_H__
+#define __TIZEN_SOCIAL_CONTACTS_CONTACT_H__
+
+#include <contacts_types.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_CONTACT_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates a handle to the contact.
+ *
+ * @remarks @a contact must be released with contact_destroy() by you. \n
+ * The created handle not added to the contacts database until contact_insert_to_db() is called.
+ *
+ * @param[out] contact The contact handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_destroy()
+ */
+int contact_create(contact_h *contact);
+
+/**
+ * @brief Destroys the contact handle and releases all its resources.
+ *
+ * @param[in] contact The contact handle
+ *
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_create()
+ *
+ */
+int contact_destroy(contact_h contact);
+
+/**
+ * @brief Inserts a new contact to the contacts database.
+ *
+ * @param[in] contact The contact handle
+ * @param[out] contact_db_id The contact ID to be assigned to a new contact \n
+ * If inserting a new contact succeeds, contact ID will be assigned to a new contact,
+ * otherwise <i>contact_db_id</i> stays unchanged
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contact_update_to_db()
+ * @see contact_delete_from_db()
+ * @see contact_get_from_db()
+ */
+int contact_insert_to_db(contact_h contact, int *contact_db_id);
+
+/**
+ * @brief Deletes the contact from the contacts database.
+ *
+ * @param[in] contact_db_id The contact ID to delete
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ * @see contact_insert_to_db()
+ * @see contact_update_to_db()
+ * @see contact_get_db_id()
+ */
+int contact_delete_from_db(int contact_db_id);
+
+/**
+ * @brief Updates the contact to the contacts database.
+ * @details contact_get_db_id() is called internally to update in the contacts database
+ *
+ * @param[in] contact The contact handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contact_insert_to_db()
+ * @see contact_delete_from_db()
+ * @see contact_get_db_id()
+ */
+int contact_update_to_db(contact_h contact);
+
+/**
+ * @brief Gets the database ID for the given contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[out] contact_db_id The contact ID fetched from contacts database (default : 0) \n
+ * 0 means the contact is not in the contacts database.
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contacts_connect()
+ */
+int contact_get_db_id(contact_h contact, int *contact_db_id);
+
+/**
+ * @brief Gets the contact from the contacts database.
+ *
+ * @details This function creates a new contact handle from the contacts database by the given @a contact_db_id. \n
+ * @a contact will be created, which is filled with contact informations.
+ *
+ * @remarks @a contact must be released with contact_destroy() by you.
+ *
+ * @param[in] contact_db_id The contact ID to get from database
+ * @param[out] contact The contact handle associated with the contact ID
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contacts_connect()
+ * @see contact_destroy()
+ */
+int contact_get_from_db(int contact_db_id, contact_h *contact);
+
+/**
+ * @brief Sets the favorite to the existing contact.
+ *
+ * @param[in] contact_db_id The contact ID to set favorite
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to the contacts service by contacts_connect().
+ *
+ * @see contact_unset_favorite_to_db()
+ */
+int contact_set_favorite_to_db(int contact_db_id);
+
+/**
+ * @brief Unsets the favorite to existing contact.
+ *
+ *
+ * @param[in] contact_db_id The contact ID to unset favorite
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid contact database ID
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to the contacts service by contacts_connect().
+ *
+ * @see contacts_connect()
+ * @see contact_set_favorite_to_db()
+ *
+ */
+int contact_unset_favorite_to_db(int contact_db_id);
+
+/**
+ * @brief Gets the favorite status of the contact from the contact handle.
+ *
+ *
+ * @param[in] contact The contact handle
+ * @param[out] is_favorite @c true if the contact is a favorite, otherwise @c false ( default : @c false )
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_set_favorite()
+ */
+int contact_get_favorite(contact_h contact, bool *is_favorite);
+
+/**
+ * @brief Sets the favorite status of the contact to the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[in] is_favorite The favorite status of the contact to set
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_get_favorite()
+ */
+int contact_set_favorite(contact_h contact, bool is_favorite);
+
+/**
+ * @brief Gets the contacts name handle from the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[out] name The contacts name handle \n
+ * If a name handle has never set to the contact, it is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_set_name()
+ */
+int contact_get_name(contact_h contact, contact_name_h *name);
+
+/**
+ * @brief Sets a contacts name handle to the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[in] name The contacts name handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_get_name()
+ */
+int contact_set_name(contact_h contact, contact_name_h name);
+
+/**
+ * @brief Gets the contacts default number handle from the given contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[out] number The contacts number handle to set as the default number \n
+ * If there is no number handle, it is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_add_number()
+ */
+int contact_get_default_number(contact_h contact, contact_number_h *number);
+
+
+/**
+ * @brief Adds a contacts new number handle to the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[in] number The contacts number handle to add
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_remove_number()
+ *
+ */
+int contact_add_number(contact_h contact, contact_number_h number);
+
+/**
+ * @brief Removes the contacts number handle from the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[in] number The contacts number handle to remove
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_add_number()
+ */
+int contact_remove_number(contact_h contact, contact_number_h number);
+
+/**
+ * @brief Gets the contacts number list handle from the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[out] number_iterator The contacts number list handle \n
+ * If there is no number in the contact, it is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_add_number()
+ * @see contact_remove_number()
+ */
+int contact_get_number_iterator(contact_h contact, contact_number_iterator_h *number_iterator);
+
+/**
+ * @brief Adds a contacts new email handle to the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[in] email The contacts email handle to add
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_get_email_iterator()
+ * @see contact_remove_email()
+ *
+ */
+int contact_add_email(contact_h contact, contact_email_h email);
+
+/**
+ * @brief Removes the contacts email handle from the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[in] email The contacts email handle to delete
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ *
+ * @see contact_get_email_iterator()
+ * @see contact_add_email()
+ */
+int contact_remove_email(contact_h contact, contact_email_h email);
+
+/**
+ * @brief Gets the contacts email list handle from the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[out] email_iterator The contacts email list handle \n
+ * If there is no email in the contact, it is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_add_email()
+ * @see contact_remove_email()
+ */
+int contact_get_email_iterator(contact_h contact, contact_email_iterator_h *email_iterator);
+
+/**
+ * @brief Adds a new address to the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[in] address The new address to add
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_get_address_iterator()
+ * @see contact_remove_address()
+ */
+int contact_add_address(contact_h contact, contact_address_h address);
+
+/**
+ * @brief Removes the address from the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[in] address The address to delete
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_get_address_iterator()
+ * @see contact_add_address()
+ */
+int contact_remove_address(contact_h contact, contact_address_h address);
+
+/**
+ * @brief Gets the contacts address list handle from the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[out] address_iterator The contacts address list handle \n
+ * If there is no address in the contact, it is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_add_address()
+ * @see contact_remove_address()
+ */
+int contact_get_address_iterator(contact_h contact, contact_address_iterator_h *address_iterator);
+
+/**
+ * @brief Gets the contacts birthday handle from the contact handle.
+ *
+ *
+ * @param[in] contact The contact handle
+ * @param[out] birthday The contacts birthday handle \n
+ * If a name handle has never set to the contact, it is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_set_birthday()
+ */
+int contact_get_birthday(contact_h contact, contact_birthday_h* birthday);
+
+/**
+ * @brief Adds the contacts birthday handle to the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[in] birthday The contacts birthday handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_get_birthday()
+ */
+int contact_set_birthday(contact_h contact, contact_birthday_h birthday);
+
+/**
+ * @brief Gets the contacts company handle from the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[out] company The contacts company handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_company_create()
+ * @see contact_set_company()
+ */
+int contact_get_company(contact_h contact, contact_company_h *company);
+
+/**
+ * @brief Sets the contacts company handle to the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[in] company The contacts company handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_company_create()
+ * @see contact_get_company()
+ */
+int contact_set_company(contact_h contact, contact_company_h company);
+
+/**
+ * @brief Adds the group ID to the contact handle.
+ *
+ * @remarks @a group_db_id must exist in contacts database. \n
+ * One contact can be assigned to many groups and one group can be added to many different persons.
+ *
+ *
+ * @param[in] contact The contact handle
+ * @param[in] group_db_id The group ID in contacts database
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory error
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_NO_DATA Data not found \n
+ * @a group_db_id is not found in contacts database
+ *
+ * @see contacts_group_create()
+ * @see contact_remove_group()
+ */
+
+int contact_add_group(contact_h contact, int group_db_id);
+
+/**
+ * @brief Removes the group ID from the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[in] group_db_id The group ID in the contacts database
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_NO_DATA Data not found \n @a group_db_id is not found in the contacts database
+ * @see contacts_group_create()
+ * @see contact_add_group()
+ */
+int contact_remove_group(contact_h contact, int group_db_id);
+
+/**
+ * @brief Adds a contacts messenger handle to the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[in] messenger The contacts messenger handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_messenger_create()
+ * @see contact_remove_messenger()
+ */
+int contact_add_messenger(contact_h contact, contact_messenger_h messenger);
+
+/**
+ * @brief Removes the contacts messenger handle from the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[in] messenger The contacts messenger handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_messenger_create()
+ * @see contact_add_messenger()
+ */
+int contact_remove_messenger(contact_h contact, contact_messenger_h messenger);
+
+/**
+ * @brief Gets the contacts messenger list handle from the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[out] messenger_iterator The contacts messenger list handle \n
+ * If there is no messenger in the contact, it is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_add_messenger()
+ * @see contact_remove_messenger()
+ */
+int contact_get_messenger_iterator(contact_h contact, contact_messenger_iterator_h *messenger_iterator);
+
+/**
+ * @brief Adds a contacts nickname handle to the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[in] nickname The contacts nickname handle to add
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_nickname_create()
+ * @see contact_remove_nickname()
+ */
+int contact_add_nickname(contact_h contact, contact_nickname_h nickname);
+
+/**
+ * @brief Removes the contacts nickname handle from the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[in] nickname The contacts nickname handle to delete
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_nickname_create()
+ * @seecontact_add_nickname()
+ */
+int contact_remove_nickname(contact_h contact, contact_nickname_h nickname);
+/**
+ * @brief Gets the contacts nickname list handle from the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[out] nickname_iterator The contacts nickname list handle \n
+ * If there is no nickname in the contact, it is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_add_nickname()
+ * @see contact_remove_nickname()
+ */
+int contact_get_nickname_iterator(contact_h contact, contact_nickname_iterator_h *nickname_iterator);
+
+/**
+ * @brief Gets the contacts related group list handle from the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[out] relatedgroup_iterator The contacts related group list handle \n
+ * If there is no related group in the contact, it is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_add_group()
+ * @see contact_remove_group()
+ */
+int contact_get_relatedgroup_iterator(contact_h contact, contact_relatedgroup_iterator_h *relatedgroup_iterator);
+
+/**
+ * @brief Adds the contacts web handle to the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[in] web The contacts web handle to add
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_remove_web()
+ */
+int contact_add_web(contact_h contact, contact_web_h web);
+/**
+ * @brief Removes the contacts web handle form the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[in] web The contacts web handle to remove
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_add_web()
+ */
+int contact_remove_web(contact_h contact, contact_web_h web);
+
+/**
+ * @brief Gets the contacts web list handle from the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[out] web_iterator The contacts web list handle \n
+ * If there is no web in the contact, it is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_add_web()
+ * @see contact_remove_web()
+ */
+int contact_get_web_iterator(contact_h contact, contact_web_iterator_h *web_iterator);
+
+/**
+ * @brief Gets the image path of contact from the contact handle.
+ *
+ * @remarks @a image_path must be released with free() by you.
+ *
+ * @param[in] contact The contact handle
+ * @param[out] image_path The image path of contact \n
+ * If @a image_path does not exist, it is NULL
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_set_image()
+ */
+int contact_get_image(contact_h contact, char **image_path);
+/**
+ * @brief Sets the image path of contact to the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[in] image_path The image path of contact
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_get_image()
+ */
+int contact_set_image(contact_h contact, const char *image_path);
+
+/**
+ * @brief Gets the ringtone path from the contact handle.
+ *
+ * @remarks @a ringtone_path must be released with free() by you.
+ *
+ * @param[in] contact The contact handle
+ * @param[out] ringtone_path The ringtone path \n
+ * If @a ringtone_path does not exist, it is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_set_ringtonepath()
+ */
+int contact_get_ringtonepath(contact_h contact, char **ringtone_path);
+/**
+ * @brief Sets the ringtone path to the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[in] ringtone_path The ringtone path to set
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_get_ringtonepath()
+ */
+int contact_set_ringtonepath(contact_h contact, const char *ringtone_path);
+
+/**
+ * @brief Gets the note from the contact handle.
+ *
+ * @remarks @a note must be released with free() by you.
+ *
+ * @param[in] contact The contact handle
+ * @param[out] note The note to get \n
+ * If @a note does not exist, it is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_set_note()
+ */
+int contact_get_note(contact_h contact, char **note);
+/**
+ * @brief Sets the note to the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[in] note The note to set
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_get_note()
+ */
+int contact_set_note(contact_h contact, const char *note);
+
+
+/**
+ * @brief Gets the all contact count
+ *
+ *
+ * @param[out] count The all contact count
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contacts_connect()
+ * @see contacts_group_get_member_count_from_db()
+ */
+int contact_get_total_count_from_db(int *count);
+
+/**
+ * @brief Gets a contact handle from vCard stream
+ *
+ * @remarks @a contact must be released with contact_destroy() by you.
+ *
+ * @param[in] vcard_stream The vCard stream to convert
+ * @param[out] contact The contact handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_destroy()
+ * @see contact_get_vcard_from_contact()
+ */
+int contact_get_from_vcard(const char *vcard_stream, contact_h *contact);
+
+/**
+ * @brief Gets vCard stream from the contact handle.
+ *
+ * @remarks @a vcard_stream must be released with free() by you.
+ *
+ * @param[in] contact The contact handle
+ * @param[out] vcard_stream The vCard stream to convert \n
+ * If @a vcard_stream does not exist, it is NULL
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_get_from_vcard()
+ */
+int contact_get_vcard_from_contact(contact_h contact, char **vcard_stream);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_SOCIAL_CONTACTS_CONTACT_H__ */
+
diff --git a/include/contacts_email.h b/include/contacts_email.h
new file mode 100755
index 0000000..3522c90
--- /dev/null
+++ b/include/contacts_email.h
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_SOCIAL_CONTACTS_EMAIL_H__
+#define __TIZEN_SOCIAL_CONTACTS_EMAIL_H__
+
+#include <contacts_types.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_EMAIL_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates a handle to the contacts email.
+ *
+ * @remarks @a email must be released with contact_email_destroy() by you. \n
+ * @a email is not added to contacts database until contact_insert_to_db() is called.
+ *
+ * @param[out] email A new contacts email handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see contact_email_destroy()
+ *
+ */
+int contact_email_create(contact_email_h *email);
+
+/**
+ * @brief Destroys the handle to contacts email.
+ *
+ * @param[in] email The contacts email handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_email_create()
+ *
+ */
+int contact_email_destroy(contact_email_h email);
+
+
+/**
+ * @brief Gets the email type from the contacts email handle.
+ *
+ * @param[in] email The contacts email handle
+ * @param[out] type The email type to be returned
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see contact_email_set_type()
+ */
+int contact_email_get_type(contact_email_h email, contact_email_type_e *type);
+/**
+ * @brief Sets an email type to the contacts email handle.
+ *
+ * @param[in] email The contacts email handle
+ * @param[in] type The email type to set
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see contact_email_get_type()
+ *
+ */
+int contact_email_set_type(contact_email_h email, contact_email_type_e type);
+
+/**
+ * @brief Gets the email address from the contacts email handle.
+ *
+ *
+ * @remarks @a address must be released with free() by you.
+ * @param[in] email The contacts email handle
+ * @param[out] address The email address to be returned \n
+ * If address does not exist, @a address is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_email_set_address()
+ *
+ */
+int contact_email_get_address(contact_email_h email, char **address);
+
+/**
+ * @brief Sets an email address to the contacts email handle.
+ *
+ * @param[in] email The contacts email handle
+ * @param[in] address The email address to set
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_email_get_address()
+ *
+ */
+int contact_email_set_address(contact_email_h email, const char *address);
+
+/**
+ * @brief Moves email list iterator to the next position and gets the contacts email handle.
+ *
+ * @details If the next element for the current email address list exists, then the iterator is moved to
+ * the next position on the list and the contacts email handle for this position is returned. When the iterator reaches
+ * the last element of the list, all further calls will return #CONTACTS_ERROR_ITERATOR_END and @a email
+ * will remain unchanged.
+ *
+ * @param[in] email_iterator The handle to the contacts email list
+ * @param[out] email The handle to contacts email, fetched from new iterator position
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_ITERATOR_END List reached end
+ *
+ * @see contact_email_iterator_has_next()
+ *
+ */
+int contact_email_iterator_next(contact_email_iterator_h *email_iterator, contact_email_h *email);
+
+/**
+ * @brief Checks whether the next element of email iterator exists or not.
+ *
+ *
+ * @param[in] email_iterator The handle to the email list
+ *
+ * @return Return @c true If next element exists or @c false If next element doesn't exist
+ *
+ * @see contact_email_iterator_next()
+ */
+bool contact_email_iterator_has_next(contact_email_iterator_h email_iterator);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_SOCIAL_CONTACTS_EMAIL_H__ */
+
diff --git a/include/contacts_event.h b/include/contacts_event.h
new file mode 100755
index 0000000..da59581
--- /dev/null
+++ b/include/contacts_event.h
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_SOCIAL_CONTACTS_EVENT_H__
+#define __TIZEN_SOCIAL_CONTACTS_EVENT_H__
+
+#include <contacts_types.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_BIRTHDAY_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates a handle to contacts birthday.
+ *
+ * @remarks @a birthday must be released with contact_birthday_destroy() by you. \n
+ * @a birthday is not added to contacts database until contact_insert_to_db() is called.
+ *
+ * @param[out] birthday A new contacts birthday handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see contact_birthday_destroy()
+ */
+int contact_birthday_create(contact_birthday_h *birthday);
+
+/**
+ * @brief Destroys the handle to contacts birthday.
+ *
+ * @param[in] birthday The contacts birthday handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_birthday_create()
+ */
+int contact_birthday_destroy(contact_birthday_h birthday);
+
+
+/**
+ * @brief Gets the birthday date from the contacts birthday handle.
+ *
+ * @param[in] birthday The contacts birthday handle
+ * @param[out] year The year of birthday date
+ * @param[out] month The month of birthday date
+ * @param[out] day The day of birthday date
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_birthday_set_date()
+ */
+int contact_birthday_get_date(contact_birthday_h birthday, int *year, int *month, int *day);
+
+/**
+ * @brief Sets the birthday date to the contacts birthday handle.
+ *
+ * @param[in] birthday The contacts birthday handle
+ * @param[in] year The year of birthday date
+ * @param[in] month The month of birthday date
+ * @param[in] day The day of birthday date
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_birthday_get_date()
+ */
+int contact_birthday_set_date(contact_birthday_h birthday, int year, int month, int day);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_SOCIAL_CONTACTS_EVENT_H__ */
+
diff --git a/include/contacts_group.h b/include/contacts_group.h
new file mode 100755
index 0000000..8690a51
--- /dev/null
+++ b/include/contacts_group.h
@@ -0,0 +1,262 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_SOCIAL_CONTACTS_GROUP_H__
+#define __TIZEN_SOCIAL_CONTACTS_GROUP_H__
+
+#include <contacts_types.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_GROUP_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates a handle to contacts group.
+ *
+ * @remarks @a group must be released with contacts_group_destroy() by you.
+ * @remarks @a group is not added to contacts database until contacts_group_insert_to_db() is called.
+ *
+ * @param[out] group A new contacts group handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see contacts_group_destroy()
+ */
+int contacts_group_create(contacts_group_h *group);
+
+/**
+ * @brief Destroys the handle to contacts group.
+ *
+ * @param[in] group The contacts group handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contacts_group_create()
+ *
+ */
+int contacts_group_destroy(contacts_group_h group);
+
+/**
+ * @brief Inserts a new group to the contacts database.
+ *
+ * @param[in] group The contacts group handle
+ * @param[out] group_db_id A group ID to be assigned to the group handle \n
+ * If inserting a new group succeeds, database ID will be assigned to a new group, otherwise @a group_db_id stays unchanged
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+
+ * @see contacts_group_delete_from_db()
+ * @see contacts_group_update_to_db()
+ */
+int contacts_group_insert_to_db(contacts_group_h group, int *group_db_id);
+
+/**
+ * @brief Deletes the group from the contacts database.
+ *
+ * @param[in] group_db_id The group ID to delete
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+
+ * @see contacts_group_insert_to_db()
+ * @see contacts_group_update_to_db()
+ */
+int contacts_group_delete_from_db(int group_db_id);
+
+/**
+ * @brief Updates the group to the contacts database.
+ *
+ *
+ * @param[in] group The group handle to update
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ * @see contacts_group_insert_to_db()
+ * @see contacts_group_delete_from_db()
+ */
+int contacts_group_update_to_db(contacts_group_h group);
+
+/**
+ * @brief Gets the group from the contacts database.
+ *
+ * @details This function creates the new group handle from the contacts database by the given @a group_db_id. \n
+ * @a group will be created, which is filled with contact information.
+ *
+ * @remarks @a group must be released with contacts_group_destroy() by you.
+ *
+ * @param[in] group_db_id The group ID
+ * @param[out] group The contacts group handle associated with the group ID
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contacts_group_destroy()
+ * @see contacts_group_get_db_id()
+ */
+int contacts_group_get_from_db(int group_db_id, contacts_group_h *group);
+
+/**
+ * @brief Gets the database ID for the given contacts group handle.
+ *
+ *
+ * @param[in] group The contacts group handle
+ * @param[out] group_db_id The group ID fetched from contacts database (default : 0) \n
+ * 0 means the contact is not in the contacts database.
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contacts_group_get_from_db()
+ */
+int contacts_group_get_db_id(contacts_group_h group, int *group_db_id);
+
+/**
+ * @brief Gets the group name from the contacts group handle.
+ *
+ * @remarks @a name must be released with free() by you.
+ *
+ * @param[in] group The contacts group handle
+ * @param[out] name The group name \n
+ * If @a name does not exist, it is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contacts_group_set_name()
+ *
+ */
+int contacts_group_get_name(contacts_group_h group, char **name);
+
+/**
+ * @brief Sets a group name to the contacts group handle.
+ *
+ *
+ * @param[in] group The contacts group handle
+ * @param[in] name A group name
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see contacts_group_get_name()
+ *
+ */
+int contacts_group_set_name(contacts_group_h group, const char *name);
+
+/**
+ * @brief Gets the ringtone path from the contacts group handle.
+ *
+ * @remarks @a ringtonepath must be released with free() by you.
+ *
+ * @param[in] group The contacts group handle
+ * @param[out] ringtonepath The ringtone path \n
+ * If @a ringtonepath does not exist, it is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contacts_group_set_ringtonepath()
+ */
+int contacts_group_get_ringtonepath(contacts_group_h group, char **ringtonepath);
+
+/**
+ * @brief Sets a ringtone path to the contacts group handle.
+ *
+ * @param[in] group The contacts group handle
+ * @param[in] ringtonepath The ringtone path
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see contacts_group_get_ringtonepath()
+ */
+int contacts_group_set_ringtonepath(contacts_group_h group, const char *ringtonepath);
+
+/**
+ * @brief Gets the number of contact belonging to the contacts group handle.
+ *
+ *
+ * @param[in] group The contacts group handle
+ * @param[out] count The number of contact belonging to the contacts group handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contact_get_total_count_from_db()
+ */
+int contacts_group_get_member_count_from_db(contacts_group_h group, int *count);
+
+/**
+ * @brief Retrieves all groups by invoking the given callback function iteratively.
+ *
+ *
+ * @param[in] callback The callback function to be called
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to Contacts Service by contacts_connect().
+ * @post This function invokes contacts_foreach_group_cb().
+ * @see contacts_foreach_group_cb()
+ */
+int contacts_group_foreach_group_from_db(contacts_foreach_group_cb callback, void *user_data);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_SOCIAL_CONTACTS_GROUP_H__ */
+
diff --git a/include/contacts_messenger.h b/include/contacts_messenger.h
new file mode 100755
index 0000000..4720d73
--- /dev/null
+++ b/include/contacts_messenger.h
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_SOCIAL_CONTACTS_MESSENGER_H__
+#define __TIZEN_SOCIAL_CONTACTS_MESSENGER_H__
+
+#include <contacts_types.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_MESSENGER_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates a handle to contacts messenger.
+ *
+ * @remarks @a messenger must be released with contact_messenger_destroy() by you.
+ * @remarks @a messenger is not added to contacts database until contact_insert_to_db() is called.
+ *
+ * @param[out] messenger A new contacts messenger handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see contact_messenger_destroy()
+ */
+int contact_messenger_create(contact_messenger_h *messenger);
+
+/**
+ * @brief Destroys the handle to contacts messenger handle.
+ *
+ * @param[in] messenger The contacts messenger handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_messenger_create()
+ */
+int contact_messenger_destroy(contact_messenger_h messenger);
+
+
+/**
+ * @brief Gets the messenger ID from the contacts messenger handle.
+ *
+ * @remarks @a id must be released with free() by you.
+ *
+ * @param[in] messenger The contacts messenger handle
+ * @param[out] id The ID returned as string. \n
+ * If @a id does not exist, it is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_messenger_set_id()
+ */
+int contact_messenger_get_id(contact_messenger_h messenger, char **id);
+
+/**
+ * @brief Sets a messenger ID to the contacts messenger handle.
+ *
+ * @remarks @a id must be released with free() by you.
+ *
+ * @param[in] messenger The contacts messenger handle
+ * @param[in] id The ID to set
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see contact_messenger_get_id()
+ */
+int contact_messenger_set_id(contact_messenger_h messenger, const char *id);
+
+/**
+ * @brief Gets the messenger type from the contacts messenger handle.
+ *
+ *
+ * @param[in] messenger The contacts messenger handle
+ * @param[out] type The messenger type
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see contact_messenger_set_type()
+ */
+int contact_messenger_get_type(contact_messenger_h messenger, contact_messenger_type_e *type);
+
+/**
+ * @brief Sets a messenger type to the contacts messenger handle.
+ *
+ * @param[in] messenger The contacts messenger handle
+ * @param[in] type The messenger type
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see contact_messenger_get_type()
+ */
+int contact_messenger_set_type(contact_messenger_h messenger, contact_messenger_type_e type);
+
+/**
+ * @brief Moves the messenger iterator to the next position and gets a contacts messenger handle.
+ *
+ * @details If the next element for the current messenger list exists, then the iterator is moved to the next
+ * position on the list and the contacts messenger handle for this position is returned. When the iterator reaches the last
+ * element of the list, all further calls will return #CONTACTS_ERROR_ITERATOR_END and @a messenger will
+ * remain unchanged.
+ *
+ * @param[in] messenger_iterator The handle to the contacts messenger list
+ * @param[in] messenger The handle to a contacts messenger, fetched from new iterator position
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_ITERATOR_END List reached end
+ * @see contact_messenger_iterator_has_next()
+ */
+int contact_messenger_iterator_next(contact_messenger_iterator_h *messenger_iterator, contact_messenger_h *messenger);
+
+/**
+ * @brief Checks whether there is a next contacts messenger handle on the list.
+ *
+ *
+ * @param[in] messenger_iterator The contacts message list handle
+ *
+ * @return Return @c true If next element exists or @c false If nest element doesn't exist
+ * @see contact_messenger_iterator_next()
+ */
+bool contact_messenger_iterator_has_next(contact_messenger_iterator_h messenger_iterator);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_SOCIAL_CONTACTS_MESSENGER_H__ */
+
diff --git a/include/contacts_name.h b/include/contacts_name.h
new file mode 100755
index 0000000..e6a2fdc
--- /dev/null
+++ b/include/contacts_name.h
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_SOCIAL_CONTACTS_NAME_H__
+#define __TIZEN_SOCIAL_CONTACTS_NAME_H__
+
+#include <contacts_types.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_NAME_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates a handle to contacts name.
+ *
+ * @remarks @a name must be released with contact_name_destroy() by you. \n
+ * @a name is not added to contacts database until contact_insert_to_db() is called.
+ *
+ *
+ * @param[out] name A new contacts name handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see contact_name_destroy()
+ *
+ */
+int contact_name_create(contact_name_h *name);
+
+/**
+ * @brief Destroys the handle to contacts name.
+ *
+ *
+ * @param[in] name The contacts name handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ *
+ * @see contact_name_create()
+ *
+ */
+int contact_name_destroy(contact_name_h name);
+
+/**
+ * @brief Gets the contact name detail from the contacts name handle.
+ *
+ * @remarks @a detail must be released with free() by you.
+ *
+ * @param[in] name The contacts name handle
+ * @param[in] detail_type The type of detail name to get
+ * @param[out] detail The detail name to be returned \n
+ * If requested data does not exist, @a detail is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_name_set_detail()
+ *
+ */
+int contact_name_get_detail(contact_name_h name, contact_name_detail_e detail_type, char **detail);
+
+/**
+ * @brief Sets a contact name detail to the contacts name handle.
+ *
+ * @param[in] name The contacts name handle
+ * @param[in] detail_type The type of detail name to set
+ * @param[in] detail The detail name to set
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_name_get_detail()
+ *
+ */
+int contact_name_set_detail(contact_name_h name, contact_name_detail_e detail_type, const char* detail);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_SOCIAL_CONTACTS_NAME_H__ */
+
diff --git a/include/contacts_nickname.h b/include/contacts_nickname.h
new file mode 100755
index 0000000..a6fd716
--- /dev/null
+++ b/include/contacts_nickname.h
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_SOCIAL_CONTACTS_NICKNAME_H__
+#define __TIZEN_SOCIAL_CONTACTS_NICKNAME_H__
+
+
+#include <contacts_types.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_NICKNAME_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates a handle to contacts nickname.
+ *
+ * @remarks @a nickname must be released with contact_nickname_destroy() by you. \n
+ * @a nickname is not added to contacts database until contact_insert_to_db() is called.
+ *
+ * @param[out] nickname A new contacts nickname handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see contact_nickname_destroy()
+ */
+int contact_nickname_create(contact_nickname_h *nickname);
+
+/**
+ * @brief Destroys the handle to contacts nickname.
+ *
+ *
+ * @param[in] nickname The contacts nickname handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_nickname_create()
+ */
+int contact_nickname_destroy(contact_nickname_h nickname);
+
+/**
+ * @brief Gets the nickname from the contacts nickname handle.
+ *
+ *
+ * @remarks @c data must be released with free() by you.
+ *
+ * @param[in] nickname The contacts nickname handle
+ * @param[out] data The nickname fetched from the contacts nickname handle \n
+ * If data does not exist, @a data is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_nickname_set_nickname()
+ */
+int contact_nickname_get_nickname(contact_nickname_h nickname, char **data);
+
+/**
+ * @brief Sets a nickname to the contacts nickname handle.
+ *
+ *
+ * @param[in] nickname The contacts nickname handle
+ * @param[in] data The nickname to be set
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_nickname_get_nickname()
+ */
+int contact_nickname_set_nickname(contact_nickname_h nickname, const char *data);
+
+/**
+ * @brief Moves nickname iterator to the next position and gets a contacts nickname handle.
+ *
+ * @details If next element for current nickname list exists than the iterator is moved to next position on the list
+ * and the contacts nickname handle from this position is returned. When the iterator reaches the last element, all further calls will return
+ * #CONTACTS_ERROR_ITERATOR_END and @a nickname will stay unchanged.
+ *
+ * @param[in] nickname_iterator The contacts nickname list handle
+ * @param[out] nickname The nickname fetched from new iterator position
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_ITERATOR_END List reached end
+ *
+ * @see contact_nickname_iterator_has_next()
+ */
+int contact_nickname_iterator_next(contact_nickname_iterator_h *nickname_iterator, contact_nickname_h *nickname);
+
+/**
+ * @brief Checks whether the next element of nickname iterator exists or not.
+ *
+ * @param[in] nickname_iterator The contacts nickname list handle
+ *
+ * @return Return @c true If the next element exists or @c false If the next element doesn't exist
+ * @see contact_nickname_iterator_next()
+ */
+bool contact_nickname_iterator_has_next(contact_nickname_iterator_h nickname_iterator);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_SOCIAL_CONTACTS_NICKNAME_H__ */
+
diff --git a/include/contacts_number.h b/include/contacts_number.h
new file mode 100755
index 0000000..4023176
--- /dev/null
+++ b/include/contacts_number.h
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_SOCIAL_CONTACTS_NUMBER_H__
+#define __TIZEN_SOCIAL_CONTACTS_NUMBER_H__
+
+
+#include <contacts_types.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_NUMBER_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates a handle to contacts number.
+ *
+ * @remarks @a number must be released with contact_number_destroy() by you. \n
+ * @a number is not added to contacts database until contact_insert_to_db() is called.
+ *
+ * @param[out] number A new contacts number handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see contact_number_destroy()
+ */
+int contact_number_create(contact_number_h *number);
+
+/**
+ * @brief Destroys the handle to contacts number.
+ *
+ *
+ * @param[in] number The contacts number handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_number_create()
+ */
+int contact_number_destroy(contact_number_h number);
+
+/**
+ * @brief Gets the number type from the contacts number handle.
+ *
+ *
+ * @param[in] number The contacts number handle
+ * @param[out] type The type of number to get
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_number_set_type()
+ */
+int contact_number_get_type(contact_number_h number, contact_number_type_e *type);
+
+/**
+ * @brief Sets a number type to the contacts number handle.
+ *
+ * @param[in] number The contacts number handle
+ * @param[in] type The type of number to set
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_number_get_type()
+ */
+int contact_number_set_type(contact_number_h number, contact_number_type_e type);
+
+/**
+ * @brief Gets the default status of the phone number from the contacts number handle.
+ *
+ *
+ * @param[in] number The contacts number handle
+ * @param[out] is_default @c true if the number is the default phone number of a contact, otherwise @c false \n
+ * (default : @c false)
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_number_set_default()
+ */
+int contact_number_get_default(contact_number_h number, bool *is_default);
+
+/**
+ * @brief Sets a default status of the phone number to the contacts number handle.
+ *
+ *
+ * @param[in] number The contacts number handle
+ * @param[in] is_default The default status of the phone number to set
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_number_get_default()
+ */
+int contact_number_set_default(contact_number_h number, bool is_default);
+
+/**
+ * @brief Gets the number from the contacts number handle.
+ *
+ * @remarks @a phone_number must be released with free() by you.
+ *
+ * @param[in] number The contacts number handle
+ * @param[out] phone_number The phone number \n
+ * If phone_number does not exist, @a phone_number is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_number_set_number()
+ */
+int contact_number_get_number(contact_number_h number, char **phone_number);
+
+/**
+ * @brief Sets a number to the contacts number handle.
+ *
+ *
+ * @param[in] number The contacts number handle
+ * @param[out] phone_number The phone number
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_number_get_number()
+ */
+int contact_number_set_number(contact_number_h number, const char *phone_number);
+
+/**
+ * @brief Moves the number iterator to the next position and gets a contacts number handle.
+
+ *
+ * @details If the next element for the current number list exists, then the iterator is moved to the next position on the list
+ * and the contacts number handle for this position is returned. When the iterator reaches the last element of the list, all further
+ * calls will return CONTACTS_ERROR_ITERATOR_END and @a number will remain unchanged.
+ *
+ * @param[in] number_iterator The handle to the contacts number list
+ * @param[out] number The handle to a contacts number, fetched from new iterator position
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_ITERATOR_END List reached end
+ *
+ * @see contact_number_iterator_has_next()
+ */
+int contact_number_iterator_next(contact_number_iterator_h *number_iterator, contact_number_h *number);
+
+/**
+ * @brief Checks whether the next element of number iterator exists or not.
+ *
+ * @param[in] number_iterator The contacts number iterator
+ *
+ * @return @c true If the next element exists or @c false If the next element doesn't exist
+ *
+ * @see contact_number_iterator_next()
+ */
+bool contact_number_iterator_has_next(contact_number_iterator_h number_iterator);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_SOCIAL_CONTACTS_NUMBER_H__ */
+
diff --git a/include/contacts_private.h b/include/contacts_private.h
new file mode 100755
index 0000000..5b83d74
--- /dev/null
+++ b/include/contacts_private.h
@@ -0,0 +1,434 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_SOCIAL_CONTACTS_INTERNAL_H__
+#define __TIZEN_SOCIAL_CONTACTS_INTERNAL_H__
+
+#include <contacts_types.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @internal
+ * @brief Enumerations for contacts subscribe callback types.
+ */
+typedef enum
+{
+ CONTACTS_DB_CHANGED_CB_TYPE_CONTACT, /**< Callback for contact */
+ CONTACTS_DB_CHANGED_CB_TYPE_CALLLOG, /**< Callback for call log */
+ CONTACTS_DB_CHANGED_CB_TYPE_FAVORITE, /**< Callback for favorite */
+ CONTACTS_DB_CHANGED_CB_TYPE_GROUP /**< Callback for group */
+} contacts_db_changed_cb_type_e;
+
+/**
+ * @internal
+ */
+typedef struct {
+ int v_type:16;
+ bool embedded;
+ bool deleted;
+ bool uid_changed;
+ bool img_changed;
+ bool full_img_changed;
+ bool ringtone_changed;
+ bool note_changed;
+ bool is_favorite;
+ int id;
+ int created_time;
+ int account_id;
+ char *uid;
+ char *img_path;
+ char *full_img_path;
+ char *ringtone_path;
+ char *note;
+}_contacts_base_s; //CTS_BASE_VAL_
+
+/**
+ * @internal
+ */
+typedef struct {
+ int i_type;
+ int* stmt;
+}_contacts_iter;
+
+/**
+ * @internal
+ */
+typedef struct {
+ int v_type:16;
+ bool embedded;
+ bool deleted;
+ bool is_changed;
+ int id;
+ char* first;
+ char* last;
+ char* addition;
+ char* display;
+ char* prefix;
+ char* suffix;
+}_contact_name_s; //CTS_NAME_VAL_
+
+/**
+ * @internal
+ */
+typedef struct {
+ int v_type:16;
+ bool embedded;
+ bool deleted;
+ int id;
+ char* name;
+ char* department;
+ char* jot_title;
+ char* assistant_name;
+ }_contact_company_s;//CTS_COMPANY_VAL_
+
+/**
+ * @internal
+ */
+typedef struct {
+ int s_type;
+ _contacts_base_s *base;
+ _contact_name_s *name;
+ GSList *numbers;
+ GSList *emails;
+ GSList *grouprelations;
+ GSList *events;
+ GSList *messengers;
+ GSList *postal_addrs;
+ GSList *web_addrs;
+ GSList *nicknames;
+ _contact_company_s *company;
+ int default_num;
+ int default_email;
+ GSList *extended_values;
+ char *vcard_img;
+ int vcard_img_type;
+}_contact_s; //cts_struct_field
+
+/**
+ * @internal
+ */
+typedef struct {
+ int v_type:16;
+ bool embedded;
+ bool deleted;
+ bool is_default;
+ bool is_favorite;
+ int id;
+ int type;
+ char* number;
+ char* added_type;
+ }_contact_number_s; //CTS_NUM_VAL_
+
+/**
+ * @internal
+ */
+typedef struct {
+ int v_type:16;
+ bool embedded;
+ bool deleted;
+ bool is_default;
+ int id;
+ int type;
+ char* email_addr;
+ }_contact_email_s; //CTS_EMAIL_VAL_
+
+/**
+ * @internal
+ */
+typedef struct {
+ int v_type:16;
+ bool embedded;
+ bool deleted;
+ int id;
+ int type;
+ char* url;
+}_contact_web_s; //CTS_WEB_VAL_
+
+/**
+ * @internal
+ */
+typedef struct {
+ int v_type:16;
+ bool embedded;
+ bool deleted;
+ bool is_default;
+ int id;
+ int type;
+ char* pobox;
+ char* postalcode;
+ char* region;
+ char* locality;
+ char* street;
+ char* extended;
+ char* country;
+ }_contact_address_s; //CTS_POSTAL_VAL_
+
+/**
+ * @internal
+ */
+typedef struct {
+ int v_type:16;
+ bool embedded;
+ bool deleted;
+ int id;
+ int type;
+ int date;
+ }_contact_birthday_s;//CTS_EVENT_VAL_
+
+/**
+ * @internal
+ */
+typedef struct {
+ int v_type:16;
+ bool embedded;
+ bool deleted;
+ int id;
+ int type;
+ char *im_id;
+}_contact_messenger_s;//CTS_MESSENGER_VAL_
+
+/**
+ * @internal
+ */
+typedef struct {
+ int v_type:16;
+ bool embedded;
+ bool deleted;
+ int id;
+ char* nick;
+ }_contact_nickname_s; //CTS_NICKNAME_VAL_
+
+/**
+ * @internal
+ */
+typedef struct {
+ int v_type:16;
+ bool embedded;
+ bool deleted;
+ bool should_sync;
+ int id;
+ int type;
+ int sync_time;
+ char *name;
+ char *login_id;
+}_contacts_account_s; //CTS_ACCOUNT_VAL_
+
+/**
+ * @internal
+ */
+typedef struct {
+ int v_type:16;
+ bool embedded;
+ bool deleted;
+ int id;
+ int type;
+ int data1;
+ char* data2;
+ char* data3;
+ char* data4;
+ char* data5;
+ char* data6;
+ char* data7;
+ char* data8;
+ char* data9;
+ char* data10;
+}_contacts_extend_s;//EXTENDVALUE
+
+/**
+ * @internal
+ */
+typedef struct {
+ int v_type:16;
+ bool embedded;
+ bool img_loaded;
+ int id;
+ int num_type;
+ char *first_name;
+ char *last_name;
+ char *display_name;
+ char *number;
+ char *img_path;
+ int log_time;
+ int log_type;
+ int extra_data1; /* duration, message_id */
+ char *extra_data2; /*short message*/
+ int related_id; /* contact id */
+}_calllog_index_s;//CTS_LIST_PLOG_
+
+/**
+ * @internal
+ */
+typedef struct {
+ int v_type:16;
+ bool embedded;
+ int id;
+ char *img_path;
+ char *first;
+ char *last;
+ char *display;
+ char *connect;
+ char *normalize;
+}_contact_index_s;//CTS_LIST_CONTACT_
+
+/**
+ * @internal
+ */
+typedef struct {
+ int v_type:16;
+ bool embedded;
+ bool img_loaded;
+ int id;
+ int acc_id;
+ char *img_path;
+ char *first;
+ char *last;
+ char *display;
+ char *connect;
+ char *normalize;
+}_contact_number_index_s;//CTS_LIST_CONTACT_
+
+/**
+ * @internal
+ */
+typedef struct {
+ int v_type:16;
+ bool embedded;
+ bool img_loaded;
+ int id;
+ int acc_id;
+ char *img_path;
+ char *first;
+ char *last;
+ char *display;
+ char *connect;
+ char *normalize;
+}_contact_email_index_s;//CTS_LIST_CONTACT_
+
+typedef struct {
+ int v_type:16;
+ bool embedded;
+ int changed_type:8;
+ int id;
+ int changed_time;
+}_contacts_changed_index_s;//CTS_LIST_CHANGE_
+
+/**
+ * @internal
+ */
+typedef struct {
+ int v_type:16;
+ bool embedded;
+ bool deleted;
+ int id;
+ int account_id;
+ char *name;
+ char *ringtone_path;
+// char *image_path;
+}_contacts_group_index_s; //CTS_GROUP_VAL_ or CTS_GROUPREL_VAL_
+
+/**
+ * @internal
+ */
+typedef struct {
+ int v_type:16;
+ bool embedded;
+ bool deleted;
+ int id;
+ int account_id;
+ char *name;
+ char *ringtone_path;
+// char *image_path;
+}_contacts_group_s; //CTS_GROUP_VAL_ or CTS_GROUPREL_VAL_
+
+/**
+ * @internal
+ */
+typedef struct {
+ int v_type:16;
+ bool embedded;
+ char *name;
+ char *number;
+}_contacts_sdn_index_s;//SDNLIST
+
+/**
+ * @internal
+ */
+typedef struct {
+ int v_type:16;
+ bool embedded;
+ int id;
+ char *name;
+}_contacts_account_index_s;//CTS_LIST_ACCOUNT_
+
+/**
+ * @internal
+ */
+typedef struct {
+ int v_type:16;
+ bool embedded;
+ int id;
+ char *name;
+}_contacts_numtype_index_s;//CUSTOMNUMTYPELIST
+
+/**
+ * @internal
+ */
+typedef struct {
+ int v_type:16;
+ bool embedded;
+ bool img_loaded;
+ int id;
+ int contact_id;
+ char *first;
+ char *last;
+ char *display;
+ char *number;
+ char *img_path;
+ int num_type;
+ int speeddial;
+}_contacts_favorite_index_s;//CTS_LIST_FAVORITE_
+
+/**
+ * @internal
+ */
+typedef struct GSList contacts_iterator_s;
+
+#define _contacts_safe_free(_srcx_) { if(NULL != _srcx_) free(_srcx_); }
+#define _contacts_safe_strdup(_srcx_) (NULL != _srcx_) ? strdup(_srcx_):NULL
+#define _contacts_safe_str(_srcx_) (NULL != _srcx_) ? _srcx_:""
+
+#define _contacts_free_strdup(_desty_, _srcx_) \
+ { \
+ if(_desty_) { free(_desty_); _desty_=NULL; }\
+ if(_srcx_) _desty_ = strdup(_srcx_); \
+ }
+
+void _contacts_set_query_person_struct(contact_query_name_s* contact, CTSvalue* value);
+void _contacts_free_query_preson_struct_member_only(contact_query_name_s* person);
+void _contacts_free_query_preson_struct_all(gpointer data, gpointer user_data);
+GSList* _contacts_gslist_next_until_not_deleted(GSList* list);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_SOCIAL_CONTACTS_INTERNAL_H__ */
+
diff --git a/include/contacts_relatedgroup.h b/include/contacts_relatedgroup.h
new file mode 100755
index 0000000..0bbd690
--- /dev/null
+++ b/include/contacts_relatedgroup.h
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_SOCIAL_CONTACTS_RELATEDGROUP_H__
+#define __TIZEN_SOCIAL_CONTACTS_RELATEDGROUP_H__
+
+
+#include <contacts_types.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_RELATEDGROUP_MODULE
+ * @{
+ */
+
+/**
+ * @brief Gets the related group name from the contacts group handle.
+ *
+ * @remarks @a name must be released with free() by you.
+ *
+ * @param[in] relatedgroup The contacts group handle
+ * @param[out] name The fetched related group name \n
+ * If @a name does not exist, it is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ *
+ */
+int contact_relatedgroup_get_name(contact_relatedgroup_h relatedgroup, char **name);
+
+/**
+ * @brief Gets the ringtone path from the contacts group handle.
+ *
+ * @remarks @a ringtone_path must be released with free() by you.
+ *
+ * @param[in] relatedgroup The contacts group handle
+ * @param[out] ringtone_path The ringtone path \n
+ * If @a ringtone_path does not exist, it is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ *
+ */
+int contact_relatedgroup_get_ringtonepath(contact_relatedgroup_h relatedgroup, char **ringtone_path);
+
+/**
+ * @brief Gets the group database ID from contacts group handle.
+ *
+ *
+ * @param[in] relatedgroup The contacts group handle
+ * @param[out] group_db_id The group ID fetched from contacts group handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contacts_group_get_from_db()
+ */
+int contact_relatedgroup_get_group_db_id(contact_relatedgroup_h relatedgroup, int *group_db_id);
+
+/**
+ * @brief Moves the related group list iterator to the next position and gets the contacts group handle.
+ *
+ * @details If the next element for the current related group list exists, then the iterator is moved to the next position
+ * on the list and the contacts related group handle for this position is returned. When the iterator reaches the last element of the
+ * list, all further calls will return #CONTACTS_ERROR_ITERATOR_END and @a relatedgroup will remain unchanged.
+ *
+ * @param[in] relatedgroup_iterator The handle to the related group list
+ * @param[out] relatedgroup The contacts group handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_ITERATOR_END List reached end
+ *
+ * @see contact_relatedgroup_iterator_has_next()
+ */
+int contact_relatedgroup_iterator_next(contact_relatedgroup_iterator_h *relatedgroup_iterator, contact_relatedgroup_h *relatedgroup);
+
+
+/**
+ * @brief Checks whether the next element of the related group iterator exists or not.
+ *
+ *
+ * @param[in] relatedgroup_iterator The handle to the related group list
+ *
+ * @return @c true If the next element exists or @c false If the next element doesn't exist
+ * @see contact_relatedgroup_iterator_next()
+ */
+bool contact_relatedgroup_iterator_has_next(contact_relatedgroup_iterator_h relatedgroup_iterator);
+
+
+
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __TIZEN_SOCIAL_CONTACTS_RELATEDGROUP_H__ */
+
diff --git a/include/contacts_search.h b/include/contacts_search.h
new file mode 100755
index 0000000..56a587d
--- /dev/null
+++ b/include/contacts_search.h
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_SOCIAL_CONTACTS_SEARCH_H__
+#define __TIZEN_SOCIAL_CONTACTS_SEARCH_H__
+
+#include <contacts_types.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_CONTACT_MODULE
+ * @{
+ */
+
+/**
+ * @brief Retrieves all contacts 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 #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ * @post This function invokes contact_foreach_query_name_cb().
+ * @see contact_foreach_query_name_cb()
+ * @see contacts_connect()
+ *
+ */
+int contact_foreach_contact_from_db(contact_foreach_query_name_cb callback, void *user_data);
+
+
+/**
+ * @brief Retrieves all favorite contacts by invoking the given callback function
+ *
+ * @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 #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ * @post This function invokes contact_foreach_favorites_cb().
+ *
+ * @see contact_foreach_favorites_cb()
+ */
+int contact_foreach_favorite_contact_from_db(contact_foreach_favorites_cb callback, void *user_data);
+
+/**
+ * @brief Retrieves all contacts with the given name.
+ *
+ *
+ * @param[in] callback The callback function to invoke
+ * @param[in] name_to_find The name for 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 #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ * @post This function invokes contact_foreach_query_name_cb().
+ * @see contacts_connect()
+ * @see contact_foreach_query_name_cb()
+ *
+ */
+int contact_query_contact_by_name(contact_foreach_query_name_cb callback, const char *name_to_find, void *user_data);
+
+/**
+ * @brief Retrieves all contacts with the given group contacts database ID.
+ *
+ *
+ *
+ * @param[in] callback The callback function to invoke
+ * @param[out] group_db_id The group contacts database ID to filter
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ * @post This function invokes contact_foreach_query_name_cb().
+ *
+ * @see contacts_connect()
+ * @see contact_foreach_query_name_cb()
+ */
+int contact_query_contact_by_group(contact_foreach_query_name_cb callback, int group_db_id, void *user_data);
+
+/**
+ * @brief Retrieves all contacts with the given number.
+ *
+ *
+ * @param[in] callback The callback function to invoke
+ * @param[in] number_to_find The number to filter
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ * @post This function invokes contact_foreach_query_number_cb().
+ * @see contacts_connect()
+ * @see contact_foreach_query_number_cb()
+ *
+ */
+int contact_query_contact_by_number(contact_foreach_query_number_cb callback, const char *number_to_find, void *user_data);
+
+/**
+ * @brief Retrieves all contacts with the given email address.
+ *
+ *
+ * @param[in] callback The callback function to invoke
+ * @param[in] email_to_find The email address to filter
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ *
+ * @pre This function requires an open connection to Contacts Service by contacts_connect()
+ * @post This function invokes contact_foreach_query_email_cb().
+ * @see contacts_connect()
+ * @see contact_foreach_query_email_cb()
+ */
+int contact_query_contact_by_email(contact_foreach_query_email_cb callback, const char *email_to_find, void *user_data);
+
+/**
+ * @brief Retrieves all contacts with the contacts database version.
+ *
+ * @details This function will find all changed contacts since the given @a contacts_db_version
+ *
+ *
+ * @param[in] callback The callback function to invoke
+ * @param[in] contacts_db_version The contacts database version to filter
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ * @post This function invokes contact_foreach_query_version_cb()
+ * @see contacts_connect()
+ * @see contact_foreach_query_version_cb()
+ */
+int contact_query_contact_by_version(contact_foreach_query_version_cb callback, int contacts_db_version, void *user_data);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __TIZEN_SOCIAL_CONTACTS_SEARCH_H__ */
+
+
diff --git a/include/contacts_types.h b/include/contacts_types.h
new file mode 100755
index 0000000..4bb7648
--- /dev/null
+++ b/include/contacts_types.h
@@ -0,0 +1,582 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_SOCIAL_CONTACTS_TYPES_H__
+#define __TIZEN_SOCIAL_CONTACTS_TYPES_H__
+
+#include <stdbool.h>
+#include <tizen.h>
+#include <time.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumerations of contacts error type.
+ */
+typedef enum
+{
+ CONTACTS_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ CONTACTS_ERROR_DB_FAILED = TIZEN_ERROR_SOCIAL_CLASS | 0x62, /**< Database operation failure */
+ CONTACTS_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ CONTACTS_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ CONTACTS_ERROR_NO_DATA = TIZEN_ERROR_SOCIAL_CLASS | 0x63, /**< Requested data does not exist */
+ CONTACTS_ERROR_ITERATOR_END = TIZEN_ERROR_SOCIAL_CLASS | 0x64 /**< List reached end */
+} contacts_error_e;
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_CONTACT_MODULE
+ * @{
+ */
+/**
+ * @brief Enumerations of contacts types for query change.
+ */
+typedef enum
+{
+ CONTACT_QUERY_CHANGE_TYPE_UPDATED, /**< Contact has been updated */
+ CONTACT_QUERY_CHANGE_TYPE_DELETED, /**< Contact hes been deleted */
+ CONTACT_QUERY_CHANGE_TYPE_INSERTED /**< New contact has been added */
+} contact_query_change_type_e;
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_NUMBER_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumerations for contacts number types.
+ */
+typedef enum
+{
+ CONTACT_NUMBER_TYPE_NONE = 0, /**< Number without specified type */
+ CONTACT_NUMBER_TYPE_HOME = 1<<0, /**< Telephone number associated with a residence */
+ CONTACT_NUMBER_TYPE_WORK = 1<<1, /**< Telephone number associated with a place of work */
+ CONTACT_NUMBER_TYPE_VOICE = 1<<2, /**< Voice telephone number */
+ CONTACT_NUMBER_TYPE_FAX = 1<<3, /**< Facsimile (Fax Machine) telephone number */
+ CONTACT_NUMBER_TYPE_MSG = 1<<4, /**< Telephone number with voice messaging support */
+ CONTACT_NUMBER_TYPE_CELL = 1<<5, /**< Cellular telephone number */
+ CONTACT_NUMBER_TYPE_PAGER = 1<<6, /**< Paging device telephone number */
+ CONTACT_NUMBER_TYPE_BBS = 1<<7, /**< Bulletin board system telephone number */
+ CONTACT_NUMBER_TYPE_MODEM = 1<<8, /**< Number associated with MODEM device */
+ CONTACT_NUMBER_TYPE_CAR = 1<<9, /**< Car-phone telephone number */
+ CONTACT_NUMBER_TYPE_ISDN = 1<<10, /**< ISDN line number */
+ CONTACT_NUMBER_TYPE_VIDEO = 1<<11, /**< Video conferencing telephone number */
+ CONTACT_NUMBER_TYPE_PCS = 1<<12, /**< Personal communication services telephone number */
+
+ CONTACT_NUMBER_TYPE_ASSISTANT = 1<<30, /**< Additional type for assistant telephone number */
+ CONTACT_NUMBER_TYPE_CUSTOM = 1<<31, /**< Custom number type */
+} contact_number_type_e;
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_EMAIL_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumerations for contacts email types.
+ */
+typedef enum
+{
+ CONTACT_EMAIL_TYPE_NONE, /**< Email address without specified type */
+ CONTACT_EMAIL_TYPE_HOME, /**< Home (private) email address */
+ CONTACT_EMAIL_TYPE_WORK, /**< Work (company) email address */
+} contact_email_type_e;
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_ADDRESS_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumerations for contacts address types.
+ */
+typedef enum
+{
+ CONTACT_ADDRESS_TYPE_NONE, /**< Address without specified type */
+ CONTACT_ADDRESS_TYPE_HOME, /**< Home address */
+ CONTACT_ADDRESS_TYPE_WORK /**< Work place address */
+} contact_address_type_e;
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_MESSENGER_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumerations for contacts messenger service types.
+ */
+typedef enum
+{
+ CONTACT_MESSENGER_TYPE_NONE, /**< None */
+ CONTACT_MESSENGER_TYPE_GOOGLE, /**< Google chat */
+ CONTACT_MESSENGER_TYPE_WLM, /**< Windows Live Meeting */
+ CONTACT_MESSENGER_TYPE_YAHOO, /**< Yahoo Messenger */
+ CONTACT_MESSENGER_TYPE_FACEBOOK, /**< Facebook chat */
+ CONTACT_MESSENGER_TYPE_ICQ, /**< ICQ */
+ CONTACT_MESSENGER_TYPE_AIM, /**< AOL Instant Messenger */
+ CONTACT_MESSENGER_TYPE_QQ /**< QQ Messenger */
+} contact_messenger_type_e;
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_WEB_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumerations for contacts web address types.
+ */
+typedef enum
+{
+ CONTACT_WEB_TYPE_NONE, /**< Web address without specified type */
+ CONTACT_WEB_TYPE_HOME, /**< Private site (homepage) address */
+ CONTACT_WEB_TYPE_WORK, /**< Company site address */
+} contact_web_type_e;
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when contacts changes.
+ *
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see contacts_add_contact_db_changed_cb()
+ */
+typedef void (*contacts_db_changed_cb)(void *user_data);
+
+/**
+ * @}
+ */
+
+/**
+ * @brief The contacts contact handle.
+ * @ingroup CAPI_SOCIAL_CONTACTS_CONTACT_MODULE
+ */
+typedef struct _contact_s* contact_h;
+
+/**
+ * @brief The contacts name handle.
+ * @ingroup CAPI_SOCIAL_CONTACTS_NAME_MODULE
+ */
+typedef struct _contact_name_s* contact_name_h;
+
+/**
+ * @brief The contacts number handle.
+ * @ingroup CAPI_SOCIAL_CONTACTS_NUMBER_MODULE
+ */
+typedef struct _contact_number_s* contact_number_h;
+
+/**
+ * @brief The contacts email handle.
+ * @ingroup CAPI_SOCIAL_CONTACTS_EMAIL_MODULE
+ */
+typedef struct _contact_email_s* contact_email_h;
+
+/**
+ * @brief The contacts address handle.
+ * @ingroup CAPI_SOCIAL_CONTACTS_ADDRESS_MODULE
+ */
+typedef struct _contact_address_s* contact_address_h;
+
+/**
+ * @brief The contacts birthday handle.
+ * @ingroup CAPI_SOCIAL_CONTACTS_BIRTHDAY_MODULE
+ */
+typedef struct _contact_birthday_s* contact_birthday_h;
+
+/**
+ * @brief The contacts company handle.
+ * @ingroup CAPI_SOCIAL_CONTACTS_COMPANY_MODULE
+ */
+typedef struct _contact_company_s* contact_company_h;
+
+/**
+ * @brief The contacts messenger handle.
+ * @ingroup CAPI_SOCIAL_CONTACTS_MESSENGER_MODULE
+ */
+typedef struct _contact_messenger_s* contact_messenger_h;
+
+/**
+ * @brief The contacts nickname handle.
+ * @ingroup CAPI_SOCIAL_CONTACTS_NICKNAME_MODULE
+ */
+typedef struct _contact_nickname_s* contact_nickname_h;
+
+/**
+ * @brief The contacts group handle.
+ * @ingroup CAPI_SOCIAL_CONTACTS_RELATEDGROUP_MODULE
+ */
+typedef struct _contacts_group_s* contact_relatedgroup_h;
+
+/**
+ * @brief The contacts web handle.
+ * @ingroup CAPI_SOCIAL_CONTACTS_WEB_MODULE
+ */
+typedef struct _contact_web_s* contact_web_h;
+
+/**
+ * @brief The contacts group handle.
+ * @ingroup CAPI_SOCIAL_CONTACTS_GROUP_MODULE
+ */
+typedef struct _contacts_group_s* contacts_group_h;
+
+/**
+ * @brief The structure of contact in search results.
+ *
+ *
+ * @see contact_foreach_query_name_cb()
+ */
+typedef struct {
+ int contact_db_id; /**< Contact's database id*/
+ char* first_name; /**< Contact's first name (also known as given name) */
+ char* last_name; /**< Contact's last name (also known as family name) */
+ char* display_name; /**< Display name (how contact's name should be presented) */
+ char* contact_image_path; /**< Path to persons picture */
+}contact_query_name_s;
+
+
+/**
+ * @brief The structure of number in search results.
+ *
+ * @see contact_foreach_query_number_cb()
+ */
+typedef struct
+{
+ int contact_db_id; /**< Contact's id in database */
+ char* first_name; /**< Contact's first name (also known as given name) */
+ char* last_name; /**< Contact's last name (also known as family name) */
+ char* display_name; /**< Display name (how contact's name should be presented) */
+ char* phone_number; /**< Phone number string */
+ char* contact_image_path; /**< Path to image with contact's picture */
+} contact_query_number_s;
+
+/**
+ * @brief The structure of email in search results.
+ *
+ * @see contact_foreach_query_email_cb()
+ */
+typedef struct
+{
+ int contact_db_id; /**< Contact's id in database */
+ char* first_name; /**< Contact's first name (also known as given name) */
+ char* last_name; /**< Contact's last name (also known as family name) */
+ char* display_name; /**< Display name (how contact's name should be presented) */
+ char* email_address; /**< Email address string */
+ char* contact_image_path; /**< Path to image with contact's picture */
+} contact_query_email_s;
+
+/**
+ * @brief The structure of group in search results.
+ * @see contacts_foreach_group_cb()
+ */
+typedef struct
+{
+ int group_db_id; /**< Group database id */
+ char* group_name; /**< Group name */
+} contacts_query_group_s;
+
+/**
+ * @brief The structure of favorite in search results.
+ * @see contact_foreach_favorites_cb()
+ */
+typedef struct
+{
+ int contact_db_id; /**< Contact's id in database */
+ char* first_name; /**< Contact's first name (also known as given name) */
+ char* last_name; /**< Contact's last name (also known as family name) */
+ char* display_name; /**< Display name (how contact's name should be presented) */
+ char* contact_image_path; /**< Path to image with contact's picture */
+ contact_number_type_e phone_type; /**< Phone number type (i.e.: work, cell) */
+ char* phone_number; /**< Phone number */
+} contact_query_favorite_s;
+
+/**
+ * @brief The structure of changed contact in search results.
+ * @see contact_foreach_query_version_cb()
+ */
+typedef struct
+{
+ int contact_db_id; /**< Id of changed contact */
+ contact_query_change_type_e changed_type; /**< Type of change */
+ int contacts_db_version; /**< Contacts database version of this contact */
+} contact_query_version_s;
+
+/**
+ * @ingroup CAPI_SOCIAL_CONTACTS_CONTACT_MODULE
+ * @brief The callback function to get the contact searched by name.
+ *
+ * @param[in] query_name The contact queried by name
+ * @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 contact_query_contact_by_name() will invoke this callback.
+ *
+ * @see contact_query_contact_by_name()
+ *
+ */
+typedef bool (*contact_foreach_query_name_cb)(contact_query_name_s *query_name, void *user_data);
+
+/**
+ * @ingroup CAPI_SOCIAL_CONTACTS_CONTACT_MODULE
+ * @brief The callback function to get the contacts searched by number.
+ *
+ * @param[in] query_number The contact queried by number
+ * @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 contact_query_contact_by_number() will invoke this callback.
+ *
+ * @see contact_query_contact_by_number()
+ */
+typedef bool (*contact_foreach_query_number_cb)(contact_query_number_s *query_number, void *user_data);
+
+/**
+ * @ingroup CAPI_SOCIAL_CONTACTS_CONTACT_MODULE
+ * @brief The callback function to get the contacts searched by email.
+ *
+ * @param[in] query_email The contact queried by email
+ * @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 contact_query_contact_by_email() will invoke this callback.
+ *
+ * @see contact_query_contact_by_email()
+ */
+typedef bool (*contact_foreach_query_email_cb)(contact_query_email_s *query_email, void *user_data);
+
+/**
+ * @ingroup CAPI_SOCIAL_CONTACTS_CONTACT_MODULE
+ * @brief The callback function to get the contacts after the specific timestamp.
+ *
+ * @param[in] query_time_last_modified The contact queried by time last modified
+ * @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 contact_query_contact_by_version() will invoke this callback.
+ *
+ * @see contact_query_contact_by_version()
+ */
+typedef bool (*contact_foreach_query_version_cb)(contact_query_version_s *query_time_last_modified, void *user_data);
+
+
+/**
+ * @ingroup CAPI_SOCIAL_CONTACTS_CONTACT_MODULE
+ * @brief The callback function to get the contacts searched by favorite.
+ *
+ * @param[in] query_favorite The contact queried by favorite
+ * @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 contact_foreach_favorite_contact_from_db() will invoke this callback.
+ *
+ * @see contact_foreach_favorite_contact_from_db()
+ *
+ */
+typedef bool (*contact_foreach_favorites_cb)(contact_query_favorite_s *query_favorite, void *user_data);
+
+/**
+ * @ingroup CAPI_SOCIAL_CONTACTS_GROUP_MODULE
+ * @brief The callback function to get the contacts searched by group.
+ *
+ * @param[in] query_group The group
+ * @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 contacts_group_foreach_group_from_db() will invoke this callback.
+ *
+ * @see contacts_group_foreach_group_from_db()
+ */
+typedef bool (*contacts_foreach_group_cb)(contacts_query_group_s *query_group, void *user_data);
+
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_CONTACT_MODULE
+ * @{
+ */
+
+/**
+ * @brief The contacts number list handle.
+ * @see contact_get_number_iterator()
+ * @see contact_number_iterator_next()
+ * @see contact_number_iterator_has_next()
+ */
+typedef struct contacts_iterator_s* contact_number_iterator_h;
+
+/**
+ * @brief The contacts email list handle.
+ * @see contact_get_email_iterator()
+ * @see contact_email_iterator_next()
+ * @see contact_email_iterator_has_next()
+ */
+typedef struct contacts_iterator_s* contact_email_iterator_h;
+
+/**
+ * @brief The contacts address list handle.
+ * @see contact_get_address_iterator()
+ * @see contact_address_iterator_next()
+ * @see contact_address_iterator_has_next()
+ */
+typedef struct contacts_iterator_s* contact_address_iterator_h;
+
+/**
+ * @brief The contacts messenger list handle.
+ * @see contact_get_messenger_iterator()
+ * @see contact_messenger_iterator_next()
+ * @see contact_messenger_iterator_has_next()
+ */
+typedef struct contacts_iterator_s* contact_messenger_iterator_h;
+
+/**
+ * @brief The contacts nickname list handle.
+ * @see contact_get_nickname_iterator()
+ * @see contact_nickname_iterator_next()
+ * @see contact_nickname_iterator_has_next()
+ */
+typedef struct contacts_iterator_s* contact_nickname_iterator_h;
+
+/**
+ * @brief The contacts related group list handle.
+ * @see contact_get_relatedgroup_iterator()
+ * @see contact_relatedgroup_iterator_next()
+ * @see contact_relatedgroup_iterator_has_next()
+ */
+typedef struct contacts_iterator_s* contact_relatedgroup_iterator_h;
+
+/**
+ * @brief The contacts web list handle.
+ * @see contact_get_web_iterator()
+ * @see contact_web_iterator_next()
+ * @see contact_web_iterator_has_next()
+ */
+typedef struct contacts_iterator_s* contact_web_iterator_h;
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_NAME_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumerations for contacts name detail types.
+ */
+typedef enum
+{
+ CONTACT_NAME_DETAIL_DISPLAY, /**< Display string \n Defines how to display contact's name */
+ CONTACT_NAME_DETAIL_FIRST, /**< First name */
+ CONTACT_NAME_DETAIL_LAST, /**< Last name */
+ CONTACT_NAME_DETAIL_MIDDLE, /**< Middle name */
+ CONTACT_NAME_DETAIL_SUFFIX, /**< Suffix */
+ CONTACT_NAME_DETAIL_TITLE /**< Title */
+} contact_name_detail_e;
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_ADDRESS_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumerations for contacts address detail types.
+ */
+typedef enum
+{
+ CONTACT_ADDRESS_DETAIL_POBOX, /**< P.O. Box */
+ CONTACT_ADDRESS_DETAIL_POSTALCODE, /**< Postal code */
+ CONTACT_ADDRESS_DETAIL_REGION, /**< Region */
+ CONTACT_ADDRESS_DETAIL_LOCALITY, /**< Locality (City) */
+ CONTACT_ADDRESS_DETAIL_STREET, /**< Street */
+ CONTACT_ADDRESS_DETAIL_EXTENDED, /**< Extended information */
+ CONTACT_ADDRESS_DETAIL_COUNTRY /**< Country */
+} contact_address_detail_e;
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_COMPANY_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumerations for contacts company detail types.
+ */
+typedef enum
+{
+ CONTACT_COMPANY_DETAIL_NAME, /**< Company name */
+ CONTACT_COMPANY_DETAIL_DEPARTMENT, /**< Company department */
+ CONTACT_COMPANY_DETAIL_JOBTITLE, /**< Job title */
+ CONTACT_COMPANY_DETAIL_ASSISTANT /**< Assistant name */
+} contact_company_detail_e;
+
+
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_SOCIAL_CONTACTS_TYPES_H__ */
diff --git a/include/contacts_web.h b/include/contacts_web.h
new file mode 100755
index 0000000..8cb51cc
--- /dev/null
+++ b/include/contacts_web.h
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_SOCIAL_CONTACTS_WEB_H__
+#define __TIZEN_SOCIAL_CONTACTS_WEB_H__
+
+
+#include <contacts_types.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_WEB_MODULE
+ * @{
+ */
+
+
+
+/**
+ * @brief Creates a handle to contacts web.
+ *
+ * @remarks @a web must be released with contact_web_destroy() by you. \n
+ * @a web is not added to contacts database until contact_insert_to_db() is called.
+ *
+ * @param[out] web A new contacts web handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see contact_web_destroy()
+ */
+int contact_web_create(contact_web_h *web);
+
+/**
+ * @brief Destroys the contacts web handle.
+ *
+ *
+ * @param[in] web The contacts web handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_web_create()
+ */
+int contact_web_destroy(contact_web_h web);
+
+
+/**
+ * @brief Gets the web type from the contacts web handle.
+ *
+
+ * @param[in] web The contacts web handle
+ * @param[out] type The web type to get
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see contact_web_set_type()
+ */
+int contact_web_get_type(contact_web_h web, contact_web_type_e *type);
+
+/**
+ * @brief Sets a web type to the contacts web handle.
+ *
+ *
+ * @param[in] web The contacts web handle
+ * @param[in] type The web type to set
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see contact_web_get_type()
+ */
+int contact_web_set_type(contact_web_h web, contact_web_type_e type);
+
+/**
+ * @brief Gets the web address from the contacts web handle.
+ *
+ * @remarks @a address must be released with free() by you.
+ *
+ * @param[in] web The contacts web handle
+ * @param[out] address The web address to get \n
+ * If @a address does not exist, it is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_web_set_address()
+ */
+int contact_web_get_address(contact_web_h web, char **address);
+
+/**
+ * @brief Sets a web address to the contacts web handle.
+ *
+ * @param[in] web The contacts web handle
+ * @param[in] address The web address to set
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see contact_web_get_address()
+ *
+ */
+int contact_web_set_address(contact_web_h web, const char *address);
+
+/**
+ * @brief Moves the web list iterator to the next position and gets the contacts web handle.
+ *
+ * @details If the next element for the current web list exists, then the iterator is moved to the next position on the list
+ * and the contacts web handle for this position is returned. When the iterator reaches the last element of the list, all further calls
+ * will return #CONTACTS_ERROR_ITERATOR_END and @a web will remain unchanged.
+ *
+ * @param[in] web_iterator The contacts web list handle
+ * @param[out] web The handle to a contacts web, fetched from new iterator position
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_ITERATOR_END List reached end
+ *
+ * @see contact_web_iterator_has_next()
+ */
+int contact_web_iterator_next(contact_web_iterator_h *web_iterator, contact_web_h *web);
+
+/**
+ * @brief Checks whether the next element of the web iterator exists or not.
+ *
+ * @param[in] web_iterator The contacts web list handle
+ *
+ * @return @c true If the next element exists or @c false If the next element doesn't exist
+ *
+ * @see contact_web_iterator_next()
+ *
+ */
+bool contact_web_iterator_has_next(contact_web_iterator_h web_iterator);
+
+
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_SOCIAL_CONTACTS_WEB_H__ */
+
diff --git a/packaging/capi-social-contacts.spec b/packaging/capi-social-contacts.spec
new file mode 100755
index 0000000..63aef36
--- /dev/null
+++ b/packaging/capi-social-contacts.spec
@@ -0,0 +1,54 @@
+Name: capi-social-contacts
+Summary: Contacts library in Tizen Native API
+Version: 0.0.1
+Release: 1
+Group: TO_BE/FILLED_IN
+License: TO BE FILLED IN
+Source0: %{name}-%{version}.tar.gz
+BuildRequires: cmake
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(contacts-service)
+BuildRequires: pkgconfig(capi-base-common)
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description
+
+
+%package devel
+Summary: Contacts library in Tizen Native API (Development)
+Group: TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+
+
+
+%prep
+%setup -q
+
+
+%build
+cmake . -DCMAKE_INSTALL_PREFIX=/usr
+
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+
+%files
+%{_libdir}/libcapi-social-contacts.so
+
+%files devel
+%{_includedir}/social/*.h
+%{_libdir}/pkgconfig/*.pc
+
+
diff --git a/src/contacts.c b/src/contacts.c
new file mode 100755
index 0000000..db041f4
--- /dev/null
+++ b/src/contacts.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <tizen.h>
+#include <stdlib.h>
+#include <contacts.h>
+#include <contacts-svc.h>
+#include <contacts_private.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "TIZEN_N_CONTACTS"
+#define LOG_MODE (1)
+
+int contacts_connect(void)
+{
+ if(contacts_svc_connect() == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+}
+
+int contacts_disconnect(void)
+{
+ if(contacts_svc_disconnect() == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+}
+
+int contacts_get_db_version(int* contacts_db_version)
+{
+ if(contacts_db_version == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_begin_trans() != CTS_SUCCESS) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+
+ *contacts_db_version = contacts_svc_end_trans(true);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contacts_add_contact_db_changed_cb(contacts_db_changed_cb callback, void *user_data)
+{
+ if(callback == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_subscribe_change(CTS_SUBSCRIBE_CONTACT_CHANGE, callback, user_data) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contacts_remove_contact_db_changed_cb(contacts_db_changed_cb callback)
+{
+ if(callback == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_unsubscribe_change(CTS_SUBSCRIBE_CONTACT_CHANGE, callback) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contacts_add_favorite_db_changed_cb(contacts_db_changed_cb callback, void *user_data)
+{
+ if(callback == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_subscribe_change(CTS_SUBSCRIBE_FAVORITE_CHANGE, callback, user_data) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contacts_remove_favorite_db_changed_cb(contacts_db_changed_cb callback)
+{
+ if(callback == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_unsubscribe_change(CTS_SUBSCRIBE_FAVORITE_CHANGE, callback) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contacts_add_group_db_changed_cb(contacts_db_changed_cb callback, void *user_data)
+{
+ if(callback == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_subscribe_change(CTS_SUBSCRIBE_GROUP_CHANGE, callback, user_data) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contacts_remove_group_db_changed_cb(contacts_db_changed_cb callback)
+{
+ if(callback == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_unsubscribe_change(CTS_SUBSCRIBE_GROUP_CHANGE, callback) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
diff --git a/src/contacts_address.c b/src/contacts_address.c
new file mode 100755
index 0000000..bb7f23e
--- /dev/null
+++ b/src/contacts_address.c
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <tizen.h>
+#include <contacts.h>
+#include <contacts_address.h>
+#include <contacts-svc.h>
+#include <contacts_private.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "TIZEN_N_CONTACTS"
+#define LOG_MODE (1)
+
+int contact_address_create(contact_address_h* address)
+{
+ if(address == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSvalue* ret = contacts_svc_value_new(CTS_VALUE_POSTAL);
+ if(ret == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+
+ *address = (contact_address_h)ret;
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_address_destroy(contact_address_h address)
+{
+ if(address == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ if(contacts_svc_value_free((CTSvalue*)address) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_address_get_type(contact_address_h address, contact_address_type_e* type)
+{
+ if(type == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSvalue * CTSaddress = (CTSvalue *)address;
+ *type = contacts_svc_value_get_int(CTSaddress, CTS_POSTAL_VAL_TYPE_INT);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_address_set_type(contact_address_h address, contact_address_type_e type)
+{
+ if(address == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSvalue * CTSaddress = (CTSvalue *)address;
+ contacts_svc_value_set_int(CTSaddress, CTS_POSTAL_VAL_TYPE_INT, type);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_address_get_detail(contact_address_h address, contact_address_detail_e detail_type, char** data)
+{
+ if(address == NULL || data == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *data = NULL;
+ CTSvalue * CTSaddress = (CTSvalue *)address;
+ switch(detail_type)
+ {
+ case CONTACT_ADDRESS_DETAIL_POBOX:
+ *data = _contacts_safe_strdup(contacts_svc_value_get_str(CTSaddress, CTS_POSTAL_VAL_POBOX_STR));
+ break;
+ case CONTACT_ADDRESS_DETAIL_POSTALCODE:
+ *data = _contacts_safe_strdup(contacts_svc_value_get_str(CTSaddress, CTS_POSTAL_VAL_POSTALCODE_STR));
+ break;
+ case CONTACT_ADDRESS_DETAIL_REGION:
+ *data = _contacts_safe_strdup(contacts_svc_value_get_str(CTSaddress, CTS_POSTAL_VAL_REGION_STR));
+ break;
+ case CONTACT_ADDRESS_DETAIL_LOCALITY:
+ *data = _contacts_safe_strdup(contacts_svc_value_get_str(CTSaddress, CTS_POSTAL_VAL_LOCALITY_STR));
+ break;
+ case CONTACT_ADDRESS_DETAIL_STREET:
+ *data = _contacts_safe_strdup(contacts_svc_value_get_str(CTSaddress, CTS_POSTAL_VAL_STREET_STR));
+ break;
+ case CONTACT_ADDRESS_DETAIL_EXTENDED:
+ *data = _contacts_safe_strdup(contacts_svc_value_get_str(CTSaddress, CTS_POSTAL_VAL_EXTENDED_STR));
+ break;
+ case CONTACT_ADDRESS_DETAIL_COUNTRY:
+ *data = _contacts_safe_strdup(contacts_svc_value_get_str(CTSaddress, CTS_POSTAL_VAL_COUNTRY_STR));
+ break;
+ default:
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ break;
+ }
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_address_set_detail(contact_address_h address, contact_address_detail_e detail_type, const char* data)
+{
+ if(address == NULL || data == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSvalue * CTSaddress = (CTSvalue *)address;
+ int ret = CTS_ERR_ARG_INVALID;
+ switch(detail_type)
+ {
+ case CONTACT_ADDRESS_DETAIL_POBOX:
+ ret=contacts_svc_value_set_str(CTSaddress, CTS_POSTAL_VAL_POBOX_STR,data);
+ break;
+ case CONTACT_ADDRESS_DETAIL_POSTALCODE:
+ ret=contacts_svc_value_set_str(CTSaddress, CTS_POSTAL_VAL_POSTALCODE_STR,data);
+ break;
+ case CONTACT_ADDRESS_DETAIL_REGION:
+ ret=contacts_svc_value_set_str(CTSaddress, CTS_POSTAL_VAL_REGION_STR,data);
+ break;
+ case CONTACT_ADDRESS_DETAIL_LOCALITY:
+ ret=contacts_svc_value_set_str(CTSaddress, CTS_POSTAL_VAL_LOCALITY_STR,data);
+ break;
+ case CONTACT_ADDRESS_DETAIL_STREET:
+ ret=contacts_svc_value_set_str(CTSaddress, CTS_POSTAL_VAL_STREET_STR,data);
+ break;
+ case CONTACT_ADDRESS_DETAIL_EXTENDED:
+ ret=contacts_svc_value_set_str(CTSaddress, CTS_POSTAL_VAL_EXTENDED_STR,data);
+ break;
+ case CONTACT_ADDRESS_DETAIL_COUNTRY:
+ ret=contacts_svc_value_set_str(CTSaddress, CTS_POSTAL_VAL_COUNTRY_STR,data);
+ break;
+ }
+ if(ret == CTS_SUCCESS)
+ return CONTACTS_ERROR_NONE;
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_address_iterator_next(contact_address_iterator_h* address_iterator, contact_address_h* address)
+{
+ if(address_iterator == NULL || address == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *address = NULL;
+ GSList* gslist = (GSList*)*address_iterator;
+ gslist = _contacts_gslist_next_until_not_deleted(gslist);
+ if(gslist != NULL)
+ {
+ *address = (contact_address_h)(gslist)->data;
+ gslist = g_slist_next(gslist);
+ *address_iterator = (contact_address_iterator_h)gslist;
+ return CONTACTS_ERROR_NONE;
+ }
+ *address_iterator = NULL;
+ return CONTACTS_ERROR_ITERATOR_END;
+}
+
+bool contact_address_iterator_has_next(contact_address_iterator_h address_iterator)
+{
+ if(address_iterator == NULL) {
+ return false;
+ }
+
+ GSList* gslist = (GSList*)address_iterator;
+ CTSvalue* value = (CTSvalue*)gslist->data;
+ if(value == NULL) {
+ return false;
+ }
+ gslist = _contacts_gslist_next_until_not_deleted(gslist);
+ if(gslist == NULL) {
+ return false;
+ }
+
+ return true;
+}
+
diff --git a/src/contacts_company.c b/src/contacts_company.c
new file mode 100755
index 0000000..7bdcd17
--- /dev/null
+++ b/src/contacts_company.c
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <tizen.h>
+#include <contacts.h>
+#include <contacts-svc.h>
+#include <contacts_private.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "TIZEN_N_CONTACTS"
+#define LOG_MODE (1)
+
+int contact_company_create(contact_company_h* company)
+{
+ if(company == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSvalue* ret = contacts_svc_value_new(CTS_VALUE_COMPANY);
+ if(ret == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ *company = (contact_company_h)ret;
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_company_destroy(contact_company_h company)
+{
+ if(company == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_value_free((CTSvalue*)company) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_company_get_detail(contact_company_h company, contact_company_detail_e detail_type, char** data)
+{
+ if(company == NULL || data == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSvalue * CTScompany = (CTSvalue *)company;
+ *data = NULL;
+ switch(detail_type)
+ {
+ case CONTACT_COMPANY_DETAIL_NAME:
+ *data= _contacts_safe_strdup(contacts_svc_value_get_str(CTScompany, CTS_COMPANY_VAL_NAME_STR));
+ break;
+ case CONTACT_COMPANY_DETAIL_DEPARTMENT:
+ *data = _contacts_safe_strdup(contacts_svc_value_get_str(CTScompany, CTS_COMPANY_VAL_DEPARTMENT_STR));
+ break;
+ case CONTACT_COMPANY_DETAIL_JOBTITLE:
+ *data = _contacts_safe_strdup(contacts_svc_value_get_str(CTScompany, CTS_COMPANY_VAL_JOB_TITLE_STR));
+ break;
+ case CONTACT_COMPANY_DETAIL_ASSISTANT:
+ *data = _contacts_safe_strdup(contacts_svc_value_get_str(CTScompany, CTS_COMPANY_VAL_ASSISTANT_NAME_STR));
+ break;
+ default:
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ break;
+ }
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_company_set_detail(contact_company_h company, contact_company_detail_e detail_type, const char* data)
+{
+ if(company == NULL || data == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSvalue * CTScompany = (CTSvalue *)company;
+ int ret = CTS_ERR_ARG_INVALID;
+ switch(detail_type)
+ {
+ case CONTACT_COMPANY_DETAIL_NAME:
+ ret= contacts_svc_value_set_str(CTScompany, CTS_COMPANY_VAL_NAME_STR,data);
+ break;
+ case CONTACT_COMPANY_DETAIL_DEPARTMENT:
+ ret=contacts_svc_value_set_str(CTScompany, CTS_COMPANY_VAL_DEPARTMENT_STR,data);
+ break;
+ case CONTACT_COMPANY_DETAIL_JOBTITLE:
+ ret=contacts_svc_value_set_str(CTScompany, CTS_COMPANY_VAL_JOB_TITLE_STR,data);
+ break;
+ case CONTACT_COMPANY_DETAIL_ASSISTANT:
+ ret=contacts_svc_value_set_str(CTScompany, CTS_COMPANY_VAL_ASSISTANT_NAME_STR,data);
+ break;
+ }
+ if(ret == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
diff --git a/src/contacts_contact.c b/src/contacts_contact.c
new file mode 100755
index 0000000..a8901a0
--- /dev/null
+++ b/src/contacts_contact.c
@@ -0,0 +1,1057 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <tizen.h>
+#include <contacts.h>
+#include <contacts-svc.h>
+#include <contacts_private.h>
+#include <string.h>
+#include <stdlib.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "TIZEN_N_CONTACTS"
+#define LOG_MODE (1)
+
+int contact_create(contact_h* contact)
+{
+ if(contact == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSstruct* ret_val = contacts_svc_struct_new(CTS_STRUCT_CONTACT);
+ if(ret_val == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+
+ *contact = (contact_h)ret_val;
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_destroy(contact_h contact)
+{
+ if(contact == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_struct_free((CTSstruct*)contact) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_insert_to_db(contact_h contact, int *db_id)
+{
+ if(contact == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ int contact_index = -1;
+ contact_index = contacts_svc_insert_contact(0, (CTSstruct*)contact);
+ if(contact_index < 0) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+ if(db_id != NULL) {
+ *db_id = contact_index;
+ }
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_delete_from_db(int db_id)
+{
+ if(db_id < 0) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = CTS_SUCCESS;
+ if((ret=contacts_svc_delete_contact(db_id)) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ } else if(ret == CTS_ERR_DB_FAILED || ret == CTS_ERR_DB_NOT_OPENED || ret == CTS_ERR_DB_RECORD_NOT_FOUND) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_update_to_db(contact_h contact)
+{
+ if(contact == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = CTS_SUCCESS;
+ if((ret=contacts_svc_update_contact((CTSstruct*)contact)) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ } else if(ret == CTS_ERR_DB_FAILED || ret == CTS_ERR_DB_NOT_OPENED || ret == CTS_ERR_DB_RECORD_NOT_FOUND) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_get_from_db(int db_id, contact_h* contact)
+{
+ if(contact == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = CTS_SUCCESS;
+ if((ret=contacts_svc_get_contact(db_id, (CTSstruct**)contact)) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ } else if(ret == CTS_ERR_DB_FAILED || ret == CTS_ERR_DB_NOT_OPENED || ret == CTS_ERR_DB_RECORD_NOT_FOUND) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_get_db_id(contact_h contact, int* db_id)
+{
+ if(contact == NULL || db_id == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ int ret = 0;
+ *db_id = 0;
+ CTSvalue* base = NULL;
+ if((ret = contacts_svc_struct_get_value((CTSstruct*)contact, CTS_CF_BASE_INFO_VALUE, &base)) != CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+ *db_id = contacts_svc_value_get_int(base, CTS_BASE_VAL_ID_INT);
+ if(*db_id < 0) {
+ *db_id = 0;
+ }
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_add_group(contact_h contact, int group_db_id)
+{
+ if(contact == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ bool need_to_free = false;
+ GSList *cursor = NULL;
+ int ret = CONTACTS_ERROR_INVALID_PARAMETER;
+
+ contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_GROUPREL_LIST, &cursor);
+ if(cursor == NULL) {
+ need_to_free = true;
+ }
+ CTSvalue* group = NULL;
+ contacts_connect();
+ if(contacts_svc_get_group(group_db_id, &group) != CONTACTS_ERROR_NONE) {
+ LOGE("[%s] CONTACTS_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CONTACTS_ERROR_NO_DATA);
+ return CONTACTS_ERROR_NO_DATA;
+ }
+ contacts_disconnect();
+ CTSvalue* relatedgroup = contacts_svc_value_new(CTS_VALUE_GROUP_RELATION);
+ if(relatedgroup == NULL) {
+ contacts_svc_value_free(group);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ contacts_svc_value_set_int(relatedgroup, CTS_GROUPREL_VAL_ID_INT, group_db_id);
+ ((_contacts_group_s*)relatedgroup)->name = _contacts_safe_strdup(contacts_svc_value_get_str(group, CTS_GROUP_VAL_NAME_STR));
+ ((_contacts_group_s*)relatedgroup)->ringtone_path = _contacts_safe_strdup(contacts_svc_value_get_str(group, CTS_GROUP_VAL_RINGTONE_STR));
+
+ cursor = g_slist_append((GSList*)cursor, relatedgroup);
+ if(contacts_svc_struct_store_list((CTSstruct*)contact, CTS_CF_GROUPREL_LIST, cursor) == CTS_SUCCESS) {
+ ret = CONTACTS_ERROR_NONE;
+ }
+ if(need_to_free == true) {
+ g_slist_free((GSList*)cursor);
+ }
+ contacts_svc_value_free(group);
+ contacts_svc_value_free(relatedgroup);
+ return ret;
+}
+
+int contact_remove_group(contact_h contact, int group_db_id)
+{
+ if(contact == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = CONTACTS_ERROR_INVALID_PARAMETER;
+ GSList *group_relation_list = NULL;
+ GSList *cursor = NULL;
+ contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_GROUPREL_LIST, &group_relation_list);
+ if(group_relation_list == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CONTACTS_ERROR_NO_DATA);
+ return CONTACTS_ERROR_NO_DATA;
+ }
+ cursor = group_relation_list;
+ for(;cursor;cursor=g_slist_next(cursor)) {
+ if(group_db_id == contacts_svc_value_get_int((CTSvalue*)cursor->data, CTS_GROUPREL_VAL_ID_INT)) {
+ contacts_svc_value_set_bool((CTSvalue*)cursor->data, CTS_GROUPREL_VAL_DELETE_BOOL, true);
+ break;
+ }
+ }
+
+ if(contacts_svc_struct_store_list((CTSstruct*)contact, CTS_CF_GROUPREL_LIST, group_relation_list) == CTS_SUCCESS) {
+ ret = CONTACTS_ERROR_NONE;
+ }
+
+ if(ret == CONTACTS_ERROR_INVALID_PARAMETER) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ }
+ return ret;
+}
+
+int contact_get_name(contact_h contact, contact_name_h* name)
+{
+ if(contact == NULL || name == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ *name = NULL;
+ int ret = CTS_SUCCESS;
+ if((ret=contacts_svc_struct_get_value((CTSstruct*)contact, CTS_CF_NAME_VALUE, (CTSvalue**)name)) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ } else if(ret == CTS_ERR_NO_DATA) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_set_name(contact_h contact, contact_name_h name)
+{
+ if(contact == NULL || name == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_struct_store_value((CTSstruct*)contact, CTS_CF_NAME_VALUE, (CTSvalue*)name) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_get_default_number(contact_h contact, contact_number_h* number)
+{
+ if(contact == NULL || number == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ *number = NULL;
+ GSList *cursor = NULL;
+ contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_NUMBER_LIST, &cursor);
+
+ for(;cursor;cursor=g_slist_next(cursor)) {
+ if(contacts_svc_value_get_bool((CTSvalue*)cursor->data, CTS_NUM_VAL_DEFAULT_BOOL) == true) {
+ *number = (contact_number_h)cursor->data;
+ return CONTACTS_ERROR_NONE;
+ }
+ }
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_add_number(contact_h contact, contact_number_h number)
+{
+ if(contact == NULL || number == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ GSList *cursor = NULL;
+ contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_NUMBER_LIST, &cursor);
+ int ret = 0;
+ bool need_to_free = false;
+ if(cursor == NULL) {
+ need_to_free = true;
+ }
+
+ cursor = g_slist_append((GSList*)cursor, number);
+ if(contacts_svc_struct_store_list((CTSstruct*)contact, CTS_CF_NUMBER_LIST, cursor) == CTS_SUCCESS) {
+ ret = CONTACTS_ERROR_NONE;
+ } else {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ ret = CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ if(need_to_free == true) {
+ g_slist_free((GSList*)cursor);
+ }
+ return ret;
+}
+
+int contact_remove_number(contact_h contact, contact_number_h number)
+{
+ if(contact == NULL || number == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ GSList *cursor = NULL;
+ contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_NUMBER_LIST, &cursor);
+
+ for(;cursor;cursor=g_slist_next(cursor)) {
+ if((CTSvalue*)cursor->data == (CTSvalue*)number) {
+ contacts_svc_value_set_bool((CTSvalue*)cursor->data, CTS_NUM_VAL_DELETE_BOOL, true);
+ return CONTACTS_ERROR_NONE;
+ }
+ }
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_get_number_iterator(contact_h contact, contact_number_iterator_h* number_iterator)
+{
+ if(contact == NULL || number_iterator == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ *number_iterator = NULL;
+ int ret = CTS_SUCCESS;
+ if((ret = contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_NUMBER_LIST, (GSList**)number_iterator)) == CTS_SUCCESS){
+ return CONTACTS_ERROR_NONE;
+ } else if(ret == CTS_ERR_NO_DATA) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_add_email(contact_h contact, contact_email_h email)
+{
+ if(contact == NULL || email == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ GSList *cursor = NULL;
+ contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_EMAIL_LIST, &cursor);
+ int ret = 0;
+ bool need_to_free = false;
+ if(cursor == NULL) {
+ need_to_free = true;
+ }
+
+ cursor = g_slist_append((GSList*)cursor, email);
+
+ if(contacts_svc_struct_store_list((CTSstruct*)contact, CTS_CF_EMAIL_LIST, cursor) == CTS_SUCCESS) {
+ ret = CONTACTS_ERROR_NONE;
+ } else {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ ret = CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(need_to_free == true) {
+ g_slist_free((GSList*)cursor);
+ }
+ return ret;
+}
+
+int contact_remove_email(contact_h contact, contact_email_h email)
+{
+ if(contact == NULL || email == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ GSList *cursor = NULL;
+ contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_EMAIL_LIST, &cursor);
+
+ for(;cursor;cursor=g_slist_next(cursor)) {
+ if((CTSvalue*)cursor->data == (CTSvalue*)email) {
+ contacts_svc_value_set_bool((CTSvalue*)cursor->data, CTS_EMAIL_VAL_DELETE_BOOL, true);
+ return CONTACTS_ERROR_NONE;
+ }
+ }
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_get_email_iterator(contact_h contact, contact_email_iterator_h* email_iterator)
+{
+ if(contact == NULL || email_iterator == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ *email_iterator = NULL;
+ int ret = CTS_SUCCESS;
+ if((ret = contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_EMAIL_LIST, (GSList**)email_iterator)) == CTS_SUCCESS){
+ return CONTACTS_ERROR_NONE;
+ } else if(ret == CTS_ERR_NO_DATA) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_add_address(contact_h contact, contact_address_h address)
+{
+ if(contact == NULL || address == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ GSList *cursor = NULL;
+ contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_POSTAL_ADDR_LIST, &cursor);
+ int ret = 0;
+ bool need_to_free = false;
+ if(cursor == NULL) {
+ need_to_free = true;
+ }
+
+ cursor = g_slist_append((GSList*)cursor, address);
+
+ if(contacts_svc_struct_store_list((CTSstruct*)contact, CTS_CF_POSTAL_ADDR_LIST, cursor) == CTS_SUCCESS) {
+ ret = CONTACTS_ERROR_NONE;
+ } else {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ ret = CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(need_to_free == true) {
+ g_slist_free((GSList*)cursor);
+ }
+ return ret;
+}
+
+int contact_remove_address(contact_h contact, contact_address_h address)
+{
+ if(contact == NULL || address == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ GSList *cursor = NULL;
+ contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_POSTAL_ADDR_LIST, &cursor);
+
+ for(;cursor;cursor=g_slist_next(cursor)) {
+ if((CTSvalue*)cursor->data == (CTSvalue*)address) {
+ contacts_svc_value_set_bool((CTSvalue*)cursor->data, CTS_POSTAL_VAL_DELETE_BOOL, true);
+ return CONTACTS_ERROR_NONE;
+ }
+ }
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_get_address_iterator(contact_h contact, contact_address_iterator_h* address_iterator)
+{
+ if(contact == NULL || address_iterator == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ *address_iterator = NULL;
+ int ret = CTS_SUCCESS;
+ if((ret = contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_POSTAL_ADDR_LIST, (GSList**)address_iterator)) == CTS_SUCCESS){
+ return CONTACTS_ERROR_NONE;
+ } else if(ret == CTS_ERR_NO_DATA) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_get_company(contact_h contact, contact_company_h* company)
+{
+ if(contact == NULL || company == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_struct_get_value((CTSstruct*)contact, CTS_CF_COMPANY_VALUE, (CTSvalue**)company) == CTS_SUCCESS){
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_set_company(contact_h contact, contact_company_h company)
+{
+ if(contact == NULL || company == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_struct_store_value((CTSstruct*)contact, CTS_CF_COMPANY_VALUE, (CTSvalue*)company) == CTS_SUCCESS){
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_get_birthday(contact_h contact, contact_birthday_h* birthday)
+{
+ if(contact == NULL || birthday == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ *birthday = NULL;
+ GSList *cursor = NULL;
+ contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_EVENT_LIST, &cursor);
+ if(cursor == NULL) {
+ return CONTACTS_ERROR_NONE;
+ }
+ *birthday = (contact_birthday_h)cursor->data;
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_set_birthday(contact_h contact, contact_birthday_h birthday)
+{
+ if(contact == NULL || birthday == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ GSList *cursor = NULL;
+ contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_EVENT_LIST, &cursor);
+ int ret = 0;
+ bool need_to_free = false;
+ if(cursor == NULL) {
+ need_to_free = true;
+ } else {
+ if((contact_birthday_h)cursor->data != birthday) {
+ contacts_svc_value_set_bool((CTSvalue*)cursor->data, CTS_EVENT_VAL_DELETE_BOOL, true);
+ }
+ }
+
+ cursor = g_slist_append((GSList*)cursor, birthday);
+
+
+ if(contacts_svc_struct_store_list((CTSstruct*)contact, CTS_CF_EVENT_LIST, cursor) == CTS_SUCCESS) {
+ ret = CONTACTS_ERROR_NONE;
+ } else {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ ret = CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(need_to_free == true) {
+ g_slist_free((GSList*)cursor);
+ }
+
+ return ret;
+}
+
+int contact_add_messenger(contact_h contact, contact_messenger_h messenger)
+{
+ if(contact == NULL || messenger == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ GSList *cursor = NULL;
+ contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_MESSENGER_LIST, &cursor);
+ int ret = 0;
+ bool need_to_free = false;
+ if(cursor == NULL) {
+ need_to_free = true;
+ }
+
+ cursor = g_slist_append((GSList*)cursor, messenger);
+
+ if(contacts_svc_struct_store_list((CTSstruct*)contact, CTS_CF_MESSENGER_LIST, cursor) == CTS_SUCCESS) {
+ ret = CONTACTS_ERROR_NONE;
+ } else {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ ret = CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(need_to_free == true) {
+ g_slist_free((GSList*)cursor);
+ }
+ return ret;
+}
+
+int contact_remove_messenger(contact_h contact, contact_messenger_h messenger)
+{
+ if(contact == NULL || messenger == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ GSList *cursor = NULL;
+ contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_MESSENGER_LIST, &cursor);
+
+ for(;cursor;cursor=g_slist_next(cursor)) {
+ if((CTSvalue*)cursor->data == (CTSvalue*)messenger) {
+ contacts_svc_value_set_bool((CTSvalue*)cursor->data, CTS_MESSENGER_VAL_DELETE_BOOL, true);
+ return CONTACTS_ERROR_NONE;
+ }
+ }
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_get_messenger_iterator(contact_h contact, contact_messenger_iterator_h* messenger_iterator)
+{
+ if(contact == NULL || messenger_iterator == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = CTS_SUCCESS;
+ if((ret = contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_MESSENGER_LIST, (GSList**)messenger_iterator)) == CTS_SUCCESS){
+ return CONTACTS_ERROR_NONE;
+ } else if(ret == CTS_ERR_NO_DATA) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_add_nickname(contact_h contact, contact_nickname_h nickname)
+{
+ if(contact == NULL || nickname == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ GSList *cursor = NULL;
+ contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_NICKNAME_LIST, &cursor);
+ int ret = 0;
+ bool need_to_free = false;
+ if(cursor == NULL) {
+ need_to_free = true;
+ }
+
+ cursor = g_slist_append((GSList*)cursor, nickname);
+
+ if(contacts_svc_struct_store_list((CTSstruct*)contact, CTS_CF_NICKNAME_LIST, cursor) == CTS_SUCCESS) {
+ ret = CONTACTS_ERROR_NONE;
+ } else {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ ret = CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(need_to_free == true) {
+ g_slist_free((GSList*)cursor);
+ }
+
+ return ret;
+}
+
+int contact_remove_nickname(contact_h contact, contact_nickname_h nickname)
+{
+ if(contact == NULL || nickname == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ GSList *cursor = NULL;
+ contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_NICKNAME_LIST, &cursor);
+
+ for(;cursor;cursor=g_slist_next(cursor)) {
+ if((CTSvalue*)cursor->data == (CTSvalue*)nickname) {
+ contacts_svc_value_set_bool((CTSvalue*)cursor->data, CTS_NICKNAME_VAL_DELETE_BOOL, true);
+ return CONTACTS_ERROR_NONE;
+ }
+ }
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_get_nickname_iterator(contact_h contact, contact_nickname_iterator_h* nickname_iterator)
+{
+ if(contact == NULL || nickname_iterator == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = CTS_SUCCESS;
+ if((ret = contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_NICKNAME_LIST, (GSList**)nickname_iterator)) == CTS_SUCCESS){
+ return CONTACTS_ERROR_NONE;
+ } else if(ret == CTS_ERR_NO_DATA) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_add_web(contact_h contact, contact_web_h web)
+{
+ if(contact == NULL || web == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ GSList *cursor = NULL;
+ contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_WEB_ADDR_LIST, &cursor);
+ int ret = 0;
+ bool need_to_free = false;
+ if(cursor == NULL) {
+ need_to_free = true;
+ }
+
+ cursor = g_slist_append((GSList*)cursor, web);
+
+ if(contacts_svc_struct_store_list((CTSstruct*)contact, CTS_CF_WEB_ADDR_LIST, cursor) == CTS_SUCCESS) {
+ ret = CONTACTS_ERROR_NONE;
+ } else {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ ret = CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(need_to_free == true) {
+ g_slist_free((GSList*)cursor);
+ }
+ return ret;
+}
+
+int contact_remove_web(contact_h contact, contact_web_h web)
+{
+ if(contact == NULL || web == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ GSList *cursor = NULL;
+ contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_WEB_ADDR_LIST, &cursor);
+
+ for(;cursor;cursor=g_slist_next(cursor)) {
+ if((CTSvalue*)cursor->data == (CTSvalue*)web) {
+ contacts_svc_value_set_bool((CTSvalue*)cursor->data, CTS_WEB_VAL_DELETE_BOOL, true);
+ return CONTACTS_ERROR_NONE;
+ }
+ }
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_get_web_iterator(contact_h contact, contact_web_iterator_h* web_iterator)
+{
+ if(contact == NULL || web_iterator == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = CTS_SUCCESS;
+ if((ret = contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_WEB_ADDR_LIST, (GSList**)web_iterator)) == CTS_SUCCESS){
+ return CONTACTS_ERROR_NONE;
+ } else if(ret == CTS_ERR_NO_DATA) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_get_relatedgroup_iterator(contact_h contact, contact_relatedgroup_iterator_h* relatedgroup_iterator)
+{
+ if(contact == NULL || relatedgroup_iterator == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = CTS_SUCCESS;
+ if((ret = contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_GROUPREL_LIST, (GSList**)relatedgroup_iterator)) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ } else if(ret == CTS_ERR_NO_DATA) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_set_image(contact_h contact, const char* src_img)
+{
+ if(contact == NULL || src_img == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ int ret = CONTACTS_ERROR_INVALID_PARAMETER;
+ int ret_temp = 0;
+ CTSvalue* base = NULL;
+ if((ret_temp = contacts_svc_struct_get_value((CTSstruct*)contact, CTS_CF_BASE_INFO_VALUE, &base)) != CTS_SUCCESS) {
+ if(ret_temp == CTS_ERR_NO_DATA) {
+ base = contacts_svc_value_new(CTS_VALUE_CONTACT_BASE_INFO);
+ contacts_svc_value_set_str(base, CTS_BASE_VAL_IMG_PATH_STR, src_img);
+ if(contacts_svc_struct_store_value((CTSstruct *)contact, CTS_CF_BASE_INFO_VALUE, base) == CTS_SUCCESS) {
+ ret = CONTACTS_ERROR_NONE;
+ }
+ contacts_svc_value_free(base);
+ }
+ } else {
+ if(contacts_svc_value_set_str(base, CTS_BASE_VAL_IMG_PATH_STR, src_img) == CTS_SUCCESS) {
+ ret = CONTACTS_ERROR_NONE;
+ }
+ }
+
+ if(ret == CONTACTS_ERROR_INVALID_PARAMETER) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ }
+ return ret;
+}
+
+int contact_get_image(contact_h contact, char** img_path)
+{
+ if(contact == NULL || img_path == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *img_path = NULL;
+ CTSvalue* base = NULL;
+ if(contacts_svc_struct_get_value((CTSstruct*)contact, CTS_CF_BASE_INFO_VALUE, &base) != CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ *img_path = _contacts_safe_strdup(contacts_svc_value_get_str(base, CTS_BASE_VAL_IMG_PATH_STR));
+ return CONTACTS_ERROR_NONE;
+}
+
+
+int contact_get_ringtonepath(contact_h contact, char** ringtone_path)
+{
+ if(contact == NULL || ringtone_path == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *ringtone_path = NULL;
+ CTSvalue* base = NULL;
+ if(contacts_svc_struct_get_value((CTSstruct*)contact, CTS_CF_BASE_INFO_VALUE, &base) != CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ *ringtone_path = _contacts_safe_strdup(contacts_svc_value_get_str(base, CTS_BASE_VAL_RINGTONE_PATH_STR));
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_set_ringtonepath(contact_h contact, const char* ringtone_path)
+{
+ if(contact == NULL || ringtone_path == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ int ret = CTS_SUCCESS;
+ CTSvalue* base = NULL;
+ if((ret = contacts_svc_struct_get_value((CTSstruct*)contact, CTS_CF_BASE_INFO_VALUE, &base)) != CTS_SUCCESS) {
+ if(ret == CTS_ERR_NO_DATA) {
+ base = contacts_svc_value_new(CTS_VALUE_CONTACT_BASE_INFO);
+ contacts_svc_value_set_str(base, CTS_BASE_VAL_RINGTONE_PATH_STR, ringtone_path);
+ ret = contacts_svc_struct_store_value((CTSstruct *)contact, CTS_CF_BASE_INFO_VALUE, base);
+ contacts_svc_value_free(base);
+ } else {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ } else {
+ ret = contacts_svc_value_set_str(base, CTS_BASE_VAL_RINGTONE_PATH_STR, ringtone_path);
+ }
+
+ if(ret == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+
+int contact_get_note(contact_h contact, char** note)
+{
+ if(contact == NULL || note == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *note = NULL;
+ CTSvalue* base = NULL;
+ if(contacts_svc_struct_get_value((CTSstruct*)contact, CTS_CF_BASE_INFO_VALUE, &base) != CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ *note = _contacts_safe_strdup(contacts_svc_value_get_str(base, CTS_BASE_VAL_NOTE_STR));
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_set_note(contact_h contact, const char* note)
+{
+ if(contact == NULL || note == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ int ret = CTS_SUCCESS;
+ CTSvalue* base = NULL;
+ if((ret = contacts_svc_struct_get_value((CTSstruct*)contact, CTS_CF_BASE_INFO_VALUE, &base)) != CTS_SUCCESS) {
+ if(ret == CTS_ERR_NO_DATA) {
+ base = contacts_svc_value_new(CTS_VALUE_CONTACT_BASE_INFO);
+ contacts_svc_value_set_str(base, CTS_BASE_VAL_NOTE_STR, note);
+ ret = contacts_svc_struct_store_value((CTSstruct *)contact, CTS_CF_BASE_INFO_VALUE, base);
+ contacts_svc_value_free(base);
+ } else {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ } else {
+ ret = contacts_svc_value_set_str(base, CTS_BASE_VAL_NOTE_STR, note);
+ }
+
+ if(ret == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+
+int contact_get_total_count_from_db(int* count)
+{
+ if(count == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *count = contacts_svc_count(CTS_GET_ALL_CONTACT);
+ return CONTACTS_ERROR_NONE;
+}
+
+
+
+int contact_get_from_vcard(const char *vcard_stream, contact_h *contact)
+{
+ if(vcard_stream == NULL || contact == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_get_contact_from_vcard((const void*)vcard_stream, (CTSstruct**)contact) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_get_vcard_from_contact(contact_h contact, char **vcard_stream)
+{
+ if(vcard_stream == NULL || contact == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_get_vcard_from_contact((const CTSstruct*)contact, vcard_stream) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_set_favorite_to_db(int contact_db_id)
+{
+ if(contact_db_id <= 0) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(CTS_SUCCESS == contacts_svc_set_favorite(CTS_FAVOR_CONTACT, contact_db_id)) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+}
+
+int contact_unset_favorite_to_db(int contact_db_id)
+{
+ if(contact_db_id <= 0) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(CTS_SUCCESS == contacts_svc_unset_favorite(CTS_FAVOR_CONTACT, contact_db_id)) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+}
+
+int contact_get_favorite(contact_h contact, bool *is_favorite)
+{
+ if(contact == NULL || is_favorite == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ *is_favorite = false;
+ CTSvalue* base = NULL;
+ if(contacts_svc_struct_get_value((CTSstruct*)contact, CTS_CF_BASE_INFO_VALUE, &base) != CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ *is_favorite = contacts_svc_value_get_bool(base, CTS_BASE_VAL_FAVORITE_BOOL);
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_set_favorite(contact_h contact, bool is_favorite)
+{
+ if(contact == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = CTS_SUCCESS;
+ CTSvalue* base = NULL;
+ if((ret = contacts_svc_struct_get_value((CTSstruct*)contact, CTS_CF_BASE_INFO_VALUE, &base)) != CTS_SUCCESS) {
+ if(ret == CTS_ERR_NO_DATA) {
+ base = contacts_svc_value_new(CTS_VALUE_CONTACT_BASE_INFO);
+ contacts_svc_value_set_bool(base, CTS_BASE_VAL_FAVORITE_BOOL, is_favorite);
+ ret = contacts_svc_struct_store_value((CTSstruct *)contact, CTS_CF_BASE_INFO_VALUE, base);
+ contacts_svc_value_free(base);
+ } else {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ } else {
+ ret = contacts_svc_value_set_bool(base, CTS_BASE_VAL_FAVORITE_BOOL, is_favorite);
+ }
+
+ if(ret == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
diff --git a/src/contacts_email.c b/src/contacts_email.c
new file mode 100755
index 0000000..8edf26b
--- /dev/null
+++ b/src/contacts_email.c
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <tizen.h>
+#include <contacts.h>
+#include <contacts-svc.h>
+#include <contacts_private.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "TIZEN_N_CONTACTS"
+#define LOG_MODE (1)
+
+int contact_email_create(contact_email_h* email)
+{
+ if(email == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSvalue* ret = contacts_svc_value_new(CTS_VALUE_EMAIL);
+ if(ret == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ *email = (contact_email_h)ret;
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_email_destroy(contact_email_h email)
+{
+ if(email == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_value_free((CTSvalue*)email) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+
+int contact_email_get_type(contact_email_h email, contact_email_type_e* type)
+{
+ if(email == NULL || type == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSvalue * CTSemail = (CTSvalue *)email;
+ *type = contacts_svc_value_get_int(CTSemail, CTS_EMAIL_VAL_TYPE_INT);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_email_set_type(contact_email_h email, contact_email_type_e type)
+{
+ if(email == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSvalue * CTSemail = (CTSvalue *)email;
+ contacts_svc_value_set_int(CTSemail, CTS_NUM_VAL_TYPE_INT, type);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_email_get_address(contact_email_h email, char** address)
+{
+ if(email == NULL || address == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *address = NULL;
+ CTSvalue * CTSemail = (CTSvalue *)email;
+ *address = _contacts_safe_strdup(contacts_svc_value_get_str(CTSemail, CTS_EMAIL_VAL_ADDR_STR));
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_email_set_address(contact_email_h email, const char* address)
+{
+ if(email == NULL || address == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSvalue * CTSemail = (CTSvalue *)email;
+ contacts_svc_value_set_str(CTSemail, CTS_EMAIL_VAL_ADDR_STR,address);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+
+int contact_email_iterator_next(contact_email_iterator_h* email_iterator, contact_email_h* email)
+{
+ if(email_iterator == NULL || email == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *email = NULL;
+ GSList* gslist = (GSList*)*email_iterator;
+ gslist = _contacts_gslist_next_until_not_deleted(gslist);
+ if(gslist != NULL)
+ {
+ *email = (contact_email_h)(gslist)->data;
+ gslist = g_slist_next(gslist);
+ *email_iterator = (contact_email_iterator_h)gslist;
+ return CONTACTS_ERROR_NONE;
+ }
+ *email_iterator = NULL;
+ return CONTACTS_ERROR_ITERATOR_END;
+}
+
+bool contact_email_iterator_has_next(contact_email_iterator_h email_iterator)
+{
+ if(email_iterator == NULL) {
+ return false;
+ }
+
+ GSList* gslist = (GSList*)email_iterator;
+ CTSvalue* value = (CTSvalue*)gslist->data;
+ if(value == NULL) {
+ return false;
+ }
+ gslist = _contacts_gslist_next_until_not_deleted(gslist);
+ if(gslist == NULL) {
+ return false;
+ }
+
+ return true;
+}
+
diff --git a/src/contacts_event.c b/src/contacts_event.c
new file mode 100755
index 0000000..dd51aa7
--- /dev/null
+++ b/src/contacts_event.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <tizen.h>
+#include <contacts.h>
+#include <contacts-svc.h>
+#include <stdlib.h>
+#include <contacts_private.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "TIZEN_N_CONTACTS"
+#define LOG_MODE (1)
+
+int contact_birthday_create(contact_birthday_h* birthday)
+{
+ if(birthday == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSvalue* ret = contacts_svc_value_new(CTS_VALUE_EVENT);
+ if(ret == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ contacts_svc_value_set_int(ret, CTS_EVENT_VAL_TYPE_INT, CTS_EVENT_TYPE_BIRTH);
+ *birthday = (contact_birthday_h)ret;
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_birthday_destroy(contact_birthday_h birthday)
+{
+ if(birthday == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_value_free((CTSvalue*)birthday) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+
+int contact_birthday_get_date(contact_birthday_h birthday, int *year, int *month, int *day)
+{
+ if(birthday == NULL || year == NULL || month == NULL || day == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ CTSvalue * CTSevent = (CTSvalue *)birthday;
+ int date = contacts_svc_value_get_int(CTSevent, CTS_EVENT_VAL_DATE_INT);
+ if(date == 0) {
+ *year = *month = *day = 0;
+ } else {
+ *year = date / 10000;
+ *month = date % 10000 / 100;
+ *day = date % 100;
+ }
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_birthday_set_date(contact_birthday_h birthday, int year, int month, int day)
+{
+ if(birthday == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSvalue * CTSevent = (CTSvalue *)birthday;
+ contacts_svc_value_set_int(CTSevent, CTS_EVENT_VAL_DATE_INT, year*10000 + month*100 + day);
+
+ return CONTACTS_ERROR_NONE;
+}
+
diff --git a/src/contacts_group.c b/src/contacts_group.c
new file mode 100755
index 0000000..ba86f14
--- /dev/null
+++ b/src/contacts_group.c
@@ -0,0 +1,258 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <tizen.h>
+#include <contacts.h>
+#include <contacts-svc.h>
+#include <contacts_private.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "TIZEN_N_CONTACTS"
+#define LOG_MODE (1)
+
+int contacts_group_create(contacts_group_h* group)
+{
+ if(group == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ CTSvalue* ret = contacts_svc_value_new(CTS_VALUE_GROUP);
+ if(ret == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ *group = (contacts_group_h)ret;
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contacts_group_destroy(contacts_group_h group)
+{
+ if(group == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_value_free((CTSvalue*)group) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contacts_group_insert_to_db(contacts_group_h group, int* db_id)
+{
+ if(group == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ int group_index = contacts_svc_insert_group(0, (CTSvalue*)group);
+ if(group_index < 0) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+ if(db_id != NULL)
+ *db_id = group_index;
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contacts_group_update_to_db(contacts_group_h group)
+{
+ if(group == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = CTS_SUCCESS;
+ if((ret=contacts_svc_update_group((CTSvalue*)group)) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ } else if(ret == CTS_ERR_DB_FAILED || ret == CTS_ERR_DB_NOT_OPENED || ret == CTS_ERR_DB_RECORD_NOT_FOUND) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contacts_group_delete_from_db(int db_id)
+{
+ if(db_id < 0) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = CTS_SUCCESS;
+ if((ret=contacts_svc_delete_group(db_id)) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ } else if(ret == CTS_ERR_DB_FAILED || ret == CTS_ERR_DB_NOT_OPENED || ret == CTS_ERR_DB_RECORD_NOT_FOUND) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contacts_group_get_db_id(contacts_group_h group, int* db_id)
+{
+ if(group == NULL || db_id == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *db_id = contacts_svc_value_get_int((CTSvalue*)group, CTS_GROUP_VAL_ID_INT);
+ if(*db_id < 0) {
+ *db_id = 0;
+ }
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contacts_group_get_from_db(int db_id, contacts_group_h* group)
+{
+ if(group == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = CTS_SUCCESS;
+ if((ret=contacts_svc_get_group(db_id, (CTSvalue**)group)) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ } else if(ret == CTS_ERR_DB_FAILED || ret == CTS_ERR_DB_NOT_OPENED || ret == CTS_ERR_DB_RECORD_NOT_FOUND) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contacts_group_get_name(contacts_group_h group, char** name)
+{
+ if(group == NULL || name == NULL)
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ *name = NULL;
+ *name = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)group, CTS_GROUP_VAL_NAME_STR));
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contacts_group_set_name(contacts_group_h group, const char* name)
+{
+ if(group == NULL || name == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_value_set_str((CTSvalue*)group, CTS_GROUP_VAL_NAME_STR, name) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+
+int contacts_group_get_ringtonepath(contacts_group_h group, char** ringtonepath)
+{
+ if(ringtonepath == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *ringtonepath = NULL;
+ *ringtonepath = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)group, CTS_GROUP_VAL_RINGTONE_STR));
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contacts_group_set_ringtonepath(contacts_group_h group, const char* ringtonepath)
+{
+ if(group == NULL || ringtonepath == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_value_set_str((CTSvalue*)group, CTS_GROUP_VAL_RINGTONE_STR, ringtonepath) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contacts_group_get_member_count_from_db(contacts_group_h group, int* count)
+{
+ if(count == NULL || group == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ int group_id = contacts_svc_value_get_int((CTSvalue*)group, CTS_GROUP_VAL_ID_INT);
+ if(group_id < 0) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *count = contacts_svc_count_with_int(CTS_GET_COUNT_CONTACTS_IN_GROUP, group_id);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contacts_group_foreach_group_from_db(contacts_foreach_group_cb cb, void* user_data)
+{
+ if(cb == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSiter *iter = NULL;
+ int func_ret = 0;
+ if(CTS_SUCCESS != contacts_svc_get_list(CTS_LIST_ALL_GROUP, &iter)) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+
+ while(CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue* foreach_data = contacts_svc_iter_get_info(iter);
+ if(foreach_data == NULL) {
+ break;
+ }
+
+ contacts_query_group_s query_data;
+ query_data.group_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_GROUP_ID_INT);
+ query_data.group_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_GROUP_NAME_STR));
+
+ func_ret = cb(&query_data, user_data);
+
+ contacts_svc_value_free(foreach_data);
+ _contacts_safe_free(query_data.group_name);
+
+ if(func_ret == 0) {
+ break;
+ }
+ }
+
+ contacts_svc_iter_remove(iter);
+ return CONTACTS_ERROR_NONE;
+}
+
diff --git a/src/contacts_messenger.c b/src/contacts_messenger.c
new file mode 100755
index 0000000..777ef22
--- /dev/null
+++ b/src/contacts_messenger.c
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <tizen.h>
+#include <contacts.h>
+#include <contacts-svc.h>
+#include <stdlib.h>
+#include <contacts_private.h>
+#include <string.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "TIZEN_N_CONTACTS"
+#define LOG_MODE (1)
+
+int contact_messenger_create(contact_messenger_h* messenger)
+{
+ if(messenger == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSvalue* ret = contacts_svc_value_new(CTS_VALUE_MESSENGER);
+ if(ret == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ *messenger = (contact_messenger_h)ret;
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_messenger_destroy(contact_messenger_h messenger)
+{
+ if(messenger == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ if(contacts_svc_value_free((CTSvalue*)messenger) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_messenger_get_id(contact_messenger_h messenger, char** id)
+{
+ if(messenger == NULL || id == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *id = NULL;
+ *id = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)messenger, CTS_MESSENGER_VAL_IM_ID_STR));
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_messenger_set_id(contact_messenger_h messenger, const char* id)
+{
+ if(messenger == NULL || id == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_value_set_str((CTSvalue*)messenger, CTS_MESSENGER_VAL_IM_ID_STR, id) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_messenger_get_type(contact_messenger_h messenger, contact_messenger_type_e *type)
+{
+ if(messenger == NULL || type == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ *type = contacts_svc_value_get_int((CTSvalue*)messenger, CTS_MESSENGER_VAL_TYPE_INT);
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_messenger_set_type(contact_messenger_h messenger, contact_messenger_type_e type)
+{
+ if(messenger == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_value_set_int((CTSvalue*)messenger, CTS_MESSENGER_VAL_TYPE_INT, type) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_messenger_iterator_next(contact_messenger_iterator_h* messenger_iterator, contact_messenger_h* messenger)
+{
+ if(messenger_iterator == NULL || messenger == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *messenger = NULL;
+ GSList* gslist = (GSList*)*messenger_iterator;
+ gslist = _contacts_gslist_next_until_not_deleted(gslist);
+ if(gslist != NULL)
+ {
+ *messenger = (contact_messenger_h)(gslist)->data;
+ gslist = g_slist_next(gslist);
+ *messenger_iterator = (contact_messenger_iterator_h)gslist;
+ return CONTACTS_ERROR_NONE;
+ }
+ *messenger_iterator = NULL;
+ return CONTACTS_ERROR_ITERATOR_END;
+}
+
+bool contact_messenger_iterator_has_next(contact_messenger_iterator_h messenger_iterator)
+{
+ if(messenger_iterator == NULL) {
+ return false;
+ }
+
+ GSList* gslist = (GSList*)messenger_iterator;
+ CTSvalue* value = (CTSvalue*)gslist->data;
+ if(value == NULL) {
+ return false;
+ }
+ gslist = _contacts_gslist_next_until_not_deleted(gslist);
+ if(gslist == NULL) {
+ return false;
+ }
+
+ return true;
+}
+
diff --git a/src/contacts_name.c b/src/contacts_name.c
new file mode 100755
index 0000000..5b7ef93
--- /dev/null
+++ b/src/contacts_name.c
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <tizen.h>
+#include <contacts.h>
+#include <contacts-svc.h>
+#include <contacts_private.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "TIZEN_N_CONTACTS"
+#define LOG_MODE (1)
+
+int contact_name_create(contact_name_h* name)
+{
+ if(name == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSvalue* ret = contacts_svc_value_new(CTS_VALUE_NAME);
+ if(ret == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ *name = (contact_name_h)ret;
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_name_destroy(contact_name_h name)
+{
+ if(name == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_value_free((CTSvalue*)name) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_name_get_detail(contact_name_h name, contact_name_detail_e detail_type, char** data)
+{
+ if(name == NULL || data == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *data = NULL;
+ switch(detail_type)
+ {
+ case CONTACT_NAME_DETAIL_DISPLAY:
+ *data = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)name, CTS_NAME_VAL_DISPLAY_STR));
+ break;
+ case CONTACT_NAME_DETAIL_FIRST:
+ *data = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)name, CTS_NAME_VAL_FIRST_STR));
+ break;
+ case CONTACT_NAME_DETAIL_LAST:
+ *data = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)name, CTS_NAME_VAL_LAST_STR));
+ break;
+ case CONTACT_NAME_DETAIL_MIDDLE:
+ *data = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)name, CTS_NAME_VAL_ADDITION_STR));
+ break;
+ case CONTACT_NAME_DETAIL_SUFFIX:
+ *data = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)name, CTS_NAME_VAL_SUFFIX_STR));
+ break;
+ case CONTACT_NAME_DETAIL_TITLE:
+ *data = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)name, CTS_NAME_VAL_PREFIX_STR));
+ break;
+ default:
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ break;
+ }
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_name_set_detail(contact_name_h name, contact_name_detail_e detail_type, const char* data)
+{
+ if(name == NULL || data == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ int ret = CTS_ERR_ARG_INVALID;
+ switch(detail_type)
+ {
+ case CONTACT_NAME_DETAIL_DISPLAY:
+ ret = contacts_svc_value_set_str((CTSvalue*)name, CTS_NAME_VAL_DISPLAY_STR, data);
+ break;
+ case CONTACT_NAME_DETAIL_FIRST:
+ ret = contacts_svc_value_set_str((CTSvalue*)name, CTS_NAME_VAL_FIRST_STR, data);
+ break;
+ case CONTACT_NAME_DETAIL_LAST:
+ ret = contacts_svc_value_set_str((CTSvalue*)name, CTS_NAME_VAL_LAST_STR, data);
+ break;
+ case CONTACT_NAME_DETAIL_MIDDLE:
+ ret = contacts_svc_value_set_str((CTSvalue*)name, CTS_NAME_VAL_ADDITION_STR, data);
+ break;
+ case CONTACT_NAME_DETAIL_SUFFIX:
+ ret = contacts_svc_value_set_str((CTSvalue*)name, CTS_NAME_VAL_SUFFIX_STR, data);
+ break;
+ case CONTACT_NAME_DETAIL_TITLE:
+ ret = contacts_svc_value_set_str((CTSvalue*)name, CTS_NAME_VAL_PREFIX_STR, data);
+ break;
+ }
+ if(ret == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
diff --git a/src/contacts_nickname.c b/src/contacts_nickname.c
new file mode 100755
index 0000000..64436ad
--- /dev/null
+++ b/src/contacts_nickname.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <tizen.h>
+#include <contacts.h>
+#include <contacts-svc.h>
+#include <stdlib.h>
+#include <contacts_private.h>
+#include <string.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "TIZEN_N_CONTACTS"
+#define LOG_MODE (1)
+
+int contact_nickname_create(contact_nickname_h* nickname)
+{
+ if(nickname == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSvalue* ret = contacts_svc_value_new(CTS_VALUE_NICKNAME);
+ if(ret == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ *nickname = (contact_nickname_h)ret;
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_nickname_destroy(contact_nickname_h nickname)
+{
+ if(nickname == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_value_free((CTSvalue*)nickname) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_nickname_get_nickname(contact_nickname_h nickname, char** data)
+{
+ if(nickname == NULL || data == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *data = NULL;
+ *data = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)nickname, CTS_NICKNAME_VAL_NAME_STR));
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_nickname_set_nickname(contact_nickname_h nickname, const char* data)
+{
+ if(nickname == NULL || data == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_value_set_str((CTSvalue*)nickname, CTS_NICKNAME_VAL_NAME_STR, data) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_nickname_iterator_next(contact_nickname_iterator_h* nickname_iterator, contact_nickname_h* nickname)
+{
+ if(nickname_iterator == NULL || nickname == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *nickname = NULL;
+ GSList* gslist = (GSList*)*nickname_iterator;
+ gslist = _contacts_gslist_next_until_not_deleted(gslist);
+ if(gslist != NULL)
+ {
+ *nickname = (contact_nickname_h)(gslist)->data;
+ gslist = g_slist_next(gslist);
+ *nickname_iterator = (contact_nickname_iterator_h)gslist;
+ return CONTACTS_ERROR_NONE;
+ }
+ *nickname_iterator = NULL;
+ return CONTACTS_ERROR_ITERATOR_END;
+}
+
+bool contact_nickname_iterator_has_next(contact_nickname_iterator_h nickname_iterator)
+{
+ if(nickname_iterator == NULL) {
+ return false;
+ }
+
+ GSList* gslist = (GSList*)nickname_iterator;
+ CTSvalue* value = (CTSvalue*)gslist->data;
+ if(value == NULL) {
+ return false;
+ }
+ gslist = _contacts_gslist_next_until_not_deleted(gslist);
+ if(gslist == NULL) {
+ return false;
+ }
+
+ return true;
+}
+
diff --git a/src/contacts_number.c b/src/contacts_number.c
new file mode 100755
index 0000000..408f056
--- /dev/null
+++ b/src/contacts_number.c
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <tizen.h>
+#include <contacts.h>
+#include <contacts-svc.h>
+#include <contacts_private.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "TIZEN_N_CONTACTS"
+#define LOG_MODE (1)
+
+int contact_number_create(contact_number_h* number)
+{
+ if(number == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSvalue* ret = contacts_svc_value_new(CTS_VALUE_NUMBER);
+ if(ret == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ *number = (contact_number_h)ret;
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_number_destroy(contact_number_h number)
+{
+ if(number == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_value_free((CTSvalue*)number) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_number_get_type(contact_number_h number, contact_number_type_e* type)
+{
+ if(number == NULL || type == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *type = contacts_svc_value_get_int((CTSvalue*)number, CTS_NUM_VAL_TYPE_INT);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_number_set_type(contact_number_h number, contact_number_type_e type)
+{
+ if(number == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_value_set_int((CTSvalue*)number, CTS_NUM_VAL_TYPE_INT, type) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+
+int contact_number_get_default(contact_number_h number, bool* is_default)
+{
+ if(number == NULL || is_default == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *is_default = contacts_svc_value_get_bool((CTSvalue*)number, CTS_NUM_VAL_DEFAULT_BOOL);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_number_set_default(contact_number_h number, bool is_default)
+{
+ if(number == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_value_set_bool((CTSvalue*)number, CTS_NUM_VAL_DEFAULT_BOOL, is_default) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+
+int contact_number_get_number(contact_number_h number, char** phone_number)
+{
+ if(number == NULL || phone_number == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *phone_number = NULL;
+ *phone_number = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)number, CTS_NUM_VAL_NUMBER_STR));
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_number_set_number(contact_number_h number, const char* phone_number)
+{
+ if(number == NULL || phone_number == NULL)
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+
+ if(contacts_svc_value_set_str((CTSvalue*)number, CTS_NUM_VAL_NUMBER_STR, phone_number) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_number_iterator_next(contact_number_iterator_h* number_iterator, contact_number_h* number)
+{
+ if(number_iterator == NULL || number == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ *number = NULL;
+ GSList* gslist = (GSList*)*number_iterator;
+ gslist = _contacts_gslist_next_until_not_deleted(gslist);
+ if(gslist != NULL)
+ {
+ *number = (contact_number_h)(gslist)->data;
+ gslist = g_slist_next(gslist);
+ *number_iterator = (contact_number_iterator_h)gslist;
+ return CONTACTS_ERROR_NONE;
+ }
+ *number_iterator = NULL;
+ return CONTACTS_ERROR_ITERATOR_END;
+}
+
+bool contact_number_iterator_has_next(contact_number_iterator_h number_iterator)
+{
+ if(number_iterator == NULL) {
+ return false;
+ }
+
+ GSList* gslist = (GSList*)number_iterator;
+ CTSvalue* value = (CTSvalue*)gslist->data;
+ if(value == NULL) {
+ return false;
+ }
+ gslist = _contacts_gslist_next_until_not_deleted(gslist);
+ if(gslist == NULL) {
+ return false;
+ }
+
+ return true;
+}
+
diff --git a/src/contacts_private.c b/src/contacts_private.c
new file mode 100755
index 0000000..23cf4ae
--- /dev/null
+++ b/src/contacts_private.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <tizen.h>
+#include <contacts.h>
+#include <contacts-svc.h>
+#include <contacts_private.h>
+#include <stdlib.h>
+#include <string.h>
+
+void _contacts_set_query_person_struct(contact_query_name_s* contact, CTSvalue* value)
+{
+ contact->contact_db_id = contacts_svc_value_get_int(value, CTS_LIST_CONTACT_ID_INT);
+ contact->first_name = _contacts_safe_strdup(contacts_svc_value_get_str(value, CTS_LIST_CONTACT_FIRST_STR));
+ contact->last_name = _contacts_safe_strdup(contacts_svc_value_get_str(value, CTS_LIST_CONTACT_LAST_STR));
+ contact->display_name = _contacts_safe_strdup(contacts_svc_value_get_str(value, CTS_LIST_CONTACT_DISPLAY_STR));
+ contact->contact_image_path = _contacts_safe_strdup(contacts_svc_value_get_str(value, CTS_LIST_CONTACT_IMG_PATH_STR));
+}
+
+void _contacts_free_query_preson_struct_member_only(contact_query_name_s* person)
+{
+ person->contact_db_id = -1;
+ _contacts_safe_free(person->first_name);
+ _contacts_safe_free(person->last_name);
+ _contacts_safe_free(person->display_name);
+ _contacts_safe_free(person->contact_image_path);
+}
+
+void _contacts_free_query_preson_struct_all(gpointer data, gpointer user_data)
+{
+ if(data == NULL)
+ return;
+ contact_query_name_s* person = (contact_query_name_s*)data;
+ person->contact_db_id = -1;
+ _contacts_safe_free(person->first_name);
+ _contacts_safe_free(person->last_name);
+ _contacts_safe_free(person->display_name);
+ _contacts_safe_free(person->contact_image_path);
+ _contacts_safe_free(data);
+}
+
+GSList* _contacts_gslist_next_until_not_deleted(GSList* list)
+{
+ if(list == NULL)
+ return NULL;
+
+ GSList* gslist = list;
+ CTSvalue* value = gslist->data;
+ if(value == NULL)
+ return NULL;
+ while( (contacts_svc_value_get_bool(value, CTS_NUM_VAL_DELETE_BOOL) == true) &&
+ (gslist != NULL) ) {
+ gslist = g_slist_next(gslist);
+ if(gslist != NULL) {
+ value = gslist->data;
+ /* codes below is for SVACE passed */
+ if(value == NULL) {
+ gslist = NULL;
+ break;
+ }
+ }
+ }
+
+ return gslist;
+}
+
diff --git a/src/contacts_relatedgroup.c b/src/contacts_relatedgroup.c
new file mode 100755
index 0000000..3bcf2d0
--- /dev/null
+++ b/src/contacts_relatedgroup.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <tizen.h>
+#include <contacts.h>
+#include <contacts-svc.h>
+#include <contacts_private.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "TIZEN_N_CONTACTS"
+#define LOG_MODE (1)
+
+int contact_relatedgroup_get_name(contact_relatedgroup_h relatedgroup, char** name)
+{
+ if(relatedgroup == NULL || name == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *name = NULL;
+ *name = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)relatedgroup, CTS_GROUPREL_VAL_NAME_STR));
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_relatedgroup_get_ringtonepath(contact_relatedgroup_h relatedgroup, char** ringtonepath)
+{
+ if(relatedgroup == NULL || ringtonepath == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *ringtonepath = NULL;
+ *ringtonepath = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)relatedgroup, CTS_GROUPREL_VAL_RINGTONE_STR));
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_relatedgroup_get_group_db_id(contact_relatedgroup_h relatedgroup, int *group_db_id)
+{
+ if(relatedgroup == NULL || group_db_id == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *group_db_id = contacts_svc_value_get_int((CTSvalue*)relatedgroup, CTS_GROUPREL_VAL_ID_INT);
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_relatedgroup_iterator_next(contact_relatedgroup_iterator_h* relatedgroup_iterator, contact_relatedgroup_h* relatedgroup)
+{
+ if(relatedgroup_iterator == NULL || relatedgroup == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *relatedgroup = NULL;
+ GSList* gslist = (GSList*)*relatedgroup_iterator;
+ gslist = _contacts_gslist_next_until_not_deleted(gslist);
+ if(gslist != NULL)
+ {
+ *relatedgroup = (contact_relatedgroup_h)(gslist)->data;
+ gslist = g_slist_next(gslist);
+ *relatedgroup_iterator = (contact_relatedgroup_iterator_h)gslist;
+ return CONTACTS_ERROR_NONE;
+ }
+ *relatedgroup_iterator = NULL;
+ return CONTACTS_ERROR_ITERATOR_END;
+}
+
+bool contact_relatedgroup_iterator_has_next(contact_relatedgroup_iterator_h relatedgroup_iterator)
+{
+ if(relatedgroup_iterator == NULL) {
+ return false;
+ }
+
+ GSList* gslist = (GSList*)relatedgroup_iterator;
+ CTSvalue* value = (CTSvalue*)gslist->data;
+ if(value == NULL) {
+ return false;
+ }
+ gslist = _contacts_gslist_next_until_not_deleted(gslist);
+ if(gslist == NULL) {
+ return false;
+ }
+
+ return true;
+}
+
diff --git a/src/contacts_search.c b/src/contacts_search.c
new file mode 100755
index 0000000..f854c26
--- /dev/null
+++ b/src/contacts_search.c
@@ -0,0 +1,325 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <tizen.h>
+#include <stdlib.h>
+#include <contacts.h>
+#include <contacts-svc.h>
+#include <contacts_private.h>
+#include <string.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "TIZEN_N_CONTACTS"
+#define LOG_MODE (1)
+
+int contact_foreach_contact_from_db(contact_foreach_query_name_cb cb, void* user_data)
+{
+ if(cb == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSiter *iter = NULL;
+ int func_ret = 0;
+ if(CTS_SUCCESS != contacts_svc_get_list(CTS_LIST_ALL_CONTACT, &iter)) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+
+ GSList *contactlist = NULL;
+ while(CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue* foreach_data = contacts_svc_iter_get_info(iter);
+
+ contact_query_name_s *query_data = NULL;
+ query_data = malloc(sizeof(contact_query_name_s));
+ if(query_data == NULL) {
+ g_slist_foreach(contactlist, _contacts_free_query_preson_struct_all, NULL);
+ g_slist_free(contactlist);
+ contacts_svc_value_free(foreach_data);
+ contacts_svc_iter_remove(iter);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ _contacts_set_query_person_struct(query_data, foreach_data);
+ contactlist = g_slist_append(contactlist, query_data);
+
+ contacts_svc_value_free(foreach_data);
+ }
+
+ contacts_svc_iter_remove(iter);
+ GSList *cursor = contactlist;
+ for(;cursor;cursor=g_slist_next(cursor)) {
+ func_ret = cb((contact_query_name_s*)cursor->data, user_data);
+ if(func_ret == false) {
+ break;
+ }
+ }
+ g_slist_foreach(contactlist, _contacts_free_query_preson_struct_all, NULL);
+ g_slist_free(contactlist);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_foreach_favorite_contact_from_db(contact_foreach_favorites_cb cb, void* user_data)
+{
+ if(cb == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSiter *iter = NULL;
+ int func_ret = 0;
+ if(CTS_SUCCESS != contacts_svc_get_list(CTS_LIST_ALL_CONTACT_FAVORITE, &iter)) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+
+ while(CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue* foreach_data = contacts_svc_iter_get_info(iter);
+ if(foreach_data == NULL) {
+ break;
+ }
+
+ contact_query_favorite_s query_data;
+ query_data.contact_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_SHORTCUT_CONTACT_ID_INT);
+ query_data.first_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_SHORTCUT_FIRST_NAME_STR));
+ query_data.last_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_SHORTCUT_LAST_NAME_STR));
+ query_data.display_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_SHORTCUT_DISPLAY_NAME_STR));
+ query_data.contact_image_path = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_SHORTCUT_IMG_PATH_STR));
+ query_data.phone_type = contacts_svc_value_get_int(foreach_data, CTS_LIST_SHORTCUT_NUMBER_TYPE_INT);
+ query_data.phone_number = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_SHORTCUT_NUMBER_STR));
+
+ func_ret = cb(&query_data, user_data);
+
+ contacts_svc_value_free(foreach_data);
+
+ _contacts_safe_free(query_data.first_name);
+ _contacts_safe_free(query_data.last_name);
+ _contacts_safe_free(query_data.display_name);
+ _contacts_safe_free(query_data.contact_image_path);
+ _contacts_safe_free(query_data.phone_number);
+
+ if(func_ret == 0) {
+ break;
+ }
+ }
+ contacts_svc_iter_remove(iter);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_query_contact_by_name(contact_foreach_query_name_cb cb, const char* name_to_find, void* user_data)
+{
+ if(cb == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSiter *iter = NULL;
+ int func_ret = 0;
+ if(CTS_SUCCESS != contacts_svc_get_list_with_str(CTS_LIST_CONTACTS_WITH_NAME, name_to_find, &iter)) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+
+ while(CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue* foreach_data = contacts_svc_iter_get_info(iter);
+ if(foreach_data == NULL) {
+ break;
+ }
+
+ contact_query_name_s query_data;
+ _contacts_set_query_person_struct(&query_data, foreach_data);
+
+ func_ret = cb(&query_data, user_data);
+
+ contacts_svc_value_free(foreach_data);
+ _contacts_free_query_preson_struct_member_only(&query_data);
+
+ if(func_ret == 0) {
+ break;
+ }
+ }
+ contacts_svc_iter_remove(iter);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_query_contact_by_group(contact_foreach_query_name_cb cb, int group_id, void* user_data)
+{
+ if(cb == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSiter *iter = NULL;
+ int func_ret = 0;
+ if(CTS_SUCCESS != contacts_svc_get_list_with_int(CTS_LIST_MEMBERS_OF_GROUP_ID, group_id, &iter)) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+
+ while(CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue* foreach_data = contacts_svc_iter_get_info(iter);
+ if(foreach_data == NULL) {
+ break;
+ }
+
+ contact_query_name_s query_data;
+ _contacts_set_query_person_struct(&query_data, foreach_data);
+
+ func_ret = cb(&query_data, user_data);
+
+ contacts_svc_value_free(foreach_data);
+ _contacts_free_query_preson_struct_member_only(&query_data);
+
+ if(func_ret == 0) {
+ break;
+ }
+ }
+ contacts_svc_iter_remove(iter);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_query_contact_by_email(contact_foreach_query_email_cb cb, const char* email_to_find, void* user_data)
+{
+ if(cb == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSiter *iter = NULL;
+ int func_ret = 0;
+ if(CTS_SUCCESS != contacts_svc_get_list_with_str(CTS_LIST_EMAILINFOS_WITH_EMAIL, email_to_find, &iter)) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+
+ while(CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue* foreach_data = contacts_svc_iter_get_info(iter);
+ if(foreach_data == NULL) {
+ break;
+ }
+
+ contact_query_email_s query_data;
+ query_data.contact_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_NUM_CONTACT_ID_INT);
+ query_data.first_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_EMAIL_CONTACT_FIRST_STR));
+ query_data.last_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_EMAIL_CONTACT_LAST_STR));
+ query_data.display_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_EMAIL_CONTACT_DISPLAY_STR));
+ query_data.email_address = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_EMAIL_ADDR_STR));
+ query_data.contact_image_path = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_EMAIL_CONTACT_IMG_PATH_STR));
+
+ func_ret = cb(&query_data, user_data);
+
+ contacts_svc_value_free(foreach_data);
+ _contacts_safe_free(query_data.first_name);
+ _contacts_safe_free(query_data.last_name);
+ _contacts_safe_free(query_data.display_name);
+ _contacts_safe_free(query_data.email_address);
+ _contacts_safe_free(query_data.contact_image_path);
+
+ if(func_ret == 0) {
+ break;
+ }
+ }
+ contacts_svc_iter_remove(iter);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_query_contact_by_number(contact_foreach_query_number_cb cb, const char* number_to_find, void* user_data)
+{
+ if(cb == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSiter *iter = NULL;
+ int func_ret = 0;
+ if(CTS_SUCCESS != contacts_svc_get_list_with_str(CTS_LIST_NUMBERINFOS_WITH_NUM, number_to_find, &iter)) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+
+ while(CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue* foreach_data = contacts_svc_iter_get_info(iter);
+ if(foreach_data == NULL) {
+ break;
+ }
+
+ contact_query_number_s query_data;
+ query_data.contact_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_NUM_CONTACT_ID_INT);
+ query_data.first_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_NUM_CONTACT_FIRST_STR));
+ query_data.last_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_NUM_CONTACT_LAST_STR));
+ query_data.display_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_NUM_CONTACT_DISPLAY_STR));
+ query_data.phone_number = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_NUM_NUMBER_STR));
+ query_data.contact_image_path = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_NUM_CONTACT_IMG_PATH_STR));
+
+ func_ret = cb(&query_data, user_data);
+
+ contacts_svc_value_free(foreach_data);
+ _contacts_safe_free(query_data.first_name);
+ _contacts_safe_free(query_data.last_name);
+ _contacts_safe_free(query_data.display_name);
+ _contacts_safe_free(query_data.phone_number);
+ _contacts_safe_free(query_data.contact_image_path);
+
+ if(func_ret == 0) {
+ break;
+ }
+ }
+ contacts_svc_iter_remove(iter);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_query_contact_by_version(contact_foreach_query_version_cb cb, int contacts_db_version, void* user_data)
+{
+ if(cb == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSiter *iter = NULL;
+ int func_ret = 0;
+ if(CTS_SUCCESS != contacts_svc_get_updated_contacts(0, contacts_db_version, &iter)) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+
+ while(CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue* foreach_data = contacts_svc_iter_get_info(iter);
+ if(foreach_data == NULL) {
+ break;
+ }
+
+ contact_query_version_s query_data;
+ query_data.contact_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_CHANGE_ID_INT);
+ query_data.changed_type = contacts_svc_value_get_int(foreach_data, CTS_LIST_CHANGE_TYPE_INT);
+ query_data.contacts_db_version = contacts_svc_value_get_int(foreach_data, CTS_LIST_CHANGE_VER_INT);
+
+ func_ret = cb(&query_data, user_data);
+
+ contacts_svc_value_free(foreach_data);
+
+ if(func_ret == 0) {
+ break;
+ }
+ }
+ contacts_svc_iter_remove(iter);
+
+ return CONTACTS_ERROR_NONE;
+}
+
diff --git a/src/contacts_web.c b/src/contacts_web.c
new file mode 100755
index 0000000..5ddcc1c
--- /dev/null
+++ b/src/contacts_web.c
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <tizen.h>
+#include <contacts.h>
+#include <contacts-svc.h>
+#include <stdlib.h>
+#include <contacts_private.h>
+#include <string.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "TIZEN_N_CONTACTS"
+#define LOG_MODE (1)
+
+int contact_web_create(contact_web_h* web)
+{
+ if(web == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ CTSvalue* ret = contacts_svc_value_new(CTS_VALUE_WEB);
+ if(ret == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ *web = (contact_web_h)ret;
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_web_destroy(contact_web_h web)
+{
+ if(web == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_value_free((CTSvalue*)web) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_web_get_type(contact_web_h web, contact_web_type_e* type)
+{
+ if(web == NULL || type == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *type = contacts_svc_value_get_int((CTSvalue*)web, CTS_WEB_VAL_TYPE_INT);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_web_set_type(contact_web_h web, contact_web_type_e type)
+{
+ if(web == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_value_set_int((CTSvalue*)web, CTS_WEB_VAL_TYPE_INT, type) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_web_get_address(contact_web_h web, char** address)
+{
+ if(web == NULL || address == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *address = NULL;
+ *address = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)web, CTS_WEB_VAL_ADDR_STR));
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_web_set_address(contact_web_h web, const char* address)
+{
+ if(web == NULL || address == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(contacts_svc_value_set_str((CTSvalue*)web, CTS_WEB_VAL_ADDR_STR, address) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contact_web_iterator_next(contact_web_iterator_h* web_iterator, contact_web_h* web)
+{
+ if(web_iterator == NULL || web == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ *web = NULL;
+ GSList* gslist = (GSList*)*web_iterator;
+ gslist = _contacts_gslist_next_until_not_deleted(gslist);
+ if(gslist != NULL)
+ {
+ *web = (contact_web_h)(gslist)->data;
+ gslist = g_slist_next(gslist);
+ *web_iterator = (contact_web_iterator_h)gslist;
+ return CONTACTS_ERROR_NONE;
+ }
+ *web_iterator = NULL;
+ return CONTACTS_ERROR_ITERATOR_END;
+}
+
+bool contact_web_iterator_has_next(contact_web_iterator_h web_iterator)
+{
+ if(web_iterator == NULL) {
+ return false;
+ }
+
+ GSList* gslist = (GSList*)web_iterator;
+ CTSvalue* value = (CTSvalue*)gslist->data;
+ if(value == NULL) {
+ return false;
+ }
+ gslist = _contacts_gslist_next_until_not_deleted(gslist);
+ if(gslist == NULL) {
+ return false;
+ }
+
+ return true;
+}
+