Initialize Tizen 2.3 tizen_2.3 2.3a_release submit/tizen_2.3/20140531.103845
authorSehong Na <sehong.na@samsung.com>
Sat, 31 May 2014 03:56:53 +0000 (12:56 +0900)
committerSehong Na <sehong.na@samsung.com>
Sat, 31 May 2014 03:56:53 +0000 (12:56 +0900)
198 files changed:
AUTHORS [new file with mode: 0644]
CMakeLists.txt [new file with mode: 0755]
LICENSE.APLv2 [new file with mode: 0644]
NOTICE [new file with mode: 0644]
inc/FSclAccount.h [new file with mode: 0644]
inc/FSclAccountAccessor.h [new file with mode: 0644]
inc/FSclAccountManager.h [new file with mode: 0644]
inc/FSclAccountProvider.h [new file with mode: 0644]
inc/FSclAddress.h [new file with mode: 0644]
inc/FSclAddressbook.h [new file with mode: 0644]
inc/FSclAddressbookFilter.h [new file with mode: 0644]
inc/FSclAddressbookManager.h [new file with mode: 0644]
inc/FSclAttendee.h [new file with mode: 0644]
inc/FSclCalEvent.h [new file with mode: 0644]
inc/FSclCalEventChangeInfo.h [new file with mode: 0644]
inc/FSclCalEventInstance.h [new file with mode: 0644]
inc/FSclCalTodo.h [new file with mode: 0644]
inc/FSclCalTodoChangeInfo.h [new file with mode: 0644]
inc/FSclCalendar.h [new file with mode: 0644]
inc/FSclCalendarbook.h [new file with mode: 0644]
inc/FSclCalendarbookFilter.h [new file with mode: 0644]
inc/FSclCategory.h [new file with mode: 0644]
inc/FSclCategoryChangeInfo.h [new file with mode: 0644]
inc/FSclContact.h [new file with mode: 0644]
inc/FSclContactAppLaunchData.h [new file with mode: 0644]
inc/FSclContactChangeInfo.h [new file with mode: 0644]
inc/FSclContactEvent.h [new file with mode: 0644]
inc/FSclEmail.h [new file with mode: 0644]
inc/FSclEmailContact.h [new file with mode: 0644]
inc/FSclIAccountEventListener.h [new file with mode: 0644]
inc/FSclIAddressbookChangeEventListener.h [new file with mode: 0644]
inc/FSclIAddressbookEventListener.h [new file with mode: 0644]
inc/FSclICalendarbookEventListener.h [new file with mode: 0644]
inc/FSclIRecordEventListener.h [new file with mode: 0644]
inc/FSclIRecordListener.h [new file with mode: 0644]
inc/FSclImAddress.h [new file with mode: 0644]
inc/FSclOrganization.h [new file with mode: 0644]
inc/FSclPerson.h [new file with mode: 0644]
inc/FSclPhoneNumber.h [new file with mode: 0644]
inc/FSclPhoneNumberContact.h [new file with mode: 0644]
inc/FSclRecord.h [new file with mode: 0644]
inc/FSclRecurrence.h [new file with mode: 0644]
inc/FSclRelationship.h [new file with mode: 0644]
inc/FSclReminder.h [new file with mode: 0644]
inc/FSclTypes.h [new file with mode: 0644]
inc/FSclUrl.h [new file with mode: 0644]
inc/FSclUserProfile.h [new file with mode: 0644]
inc/FSocial.h [new file with mode: 0644]
osp-social.manifest [new file with mode: 0644]
osp-social.pc.in [new file with mode: 0755]
packaging/osp-social.spec [new file with mode: 0644]
pkgmgr_account/CMakeLists.txt [new file with mode: 0755]
pkgmgr_account/src/account.cpp [new file with mode: 0644]
src/FSclAccount.cpp [new file with mode: 0644]
src/FSclAccountAccessor.cpp [new file with mode: 0644]
src/FSclAccountManager.cpp [new file with mode: 0644]
src/FSclAccountProvider.cpp [new file with mode: 0644]
src/FSclAddress.cpp [new file with mode: 0644]
src/FSclAddressbook.cpp [new file with mode: 0644]
src/FSclAddressbookFilter.cpp [new file with mode: 0644]
src/FSclAddressbookManager.cpp [new file with mode: 0644]
src/FSclAttendee.cpp [new file with mode: 0644]
src/FSclCalEvent.cpp [new file with mode: 0644]
src/FSclCalEventChangeInfo.cpp [new file with mode: 0644]
src/FSclCalEventInstance.cpp [new file with mode: 0644]
src/FSclCalTodo.cpp [new file with mode: 0644]
src/FSclCalTodoChangeInfo.cpp [new file with mode: 0644]
src/FSclCalendar.cpp [new file with mode: 0644]
src/FSclCalendarbook.cpp [new file with mode: 0644]
src/FSclCalendarbookFilter.cpp [new file with mode: 0644]
src/FSclCategory.cpp [new file with mode: 0644]
src/FSclCategoryChangeInfo.cpp [new file with mode: 0644]
src/FSclContact.cpp [new file with mode: 0644]
src/FSclContactAppLaunchData.cpp [new file with mode: 0644]
src/FSclContactChangeInfo.cpp [new file with mode: 0644]
src/FSclContactEvent.cpp [new file with mode: 0644]
src/FSclEmail.cpp [new file with mode: 0644]
src/FSclEmailContact.cpp [new file with mode: 0644]
src/FSclImAddress.cpp [new file with mode: 0644]
src/FSclOrganization.cpp [new file with mode: 0644]
src/FSclPerson.cpp [new file with mode: 0644]
src/FSclPhoneNumber.cpp [new file with mode: 0644]
src/FSclPhoneNumberContact.cpp [new file with mode: 0644]
src/FSclRecord.cpp [new file with mode: 0644]
src/FSclRecurrence.cpp [new file with mode: 0644]
src/FSclRelationship.cpp [new file with mode: 0644]
src/FSclReminder.cpp [new file with mode: 0644]
src/FSclUrl.cpp [new file with mode: 0644]
src/FSclUserProfile.cpp [new file with mode: 0644]
src/FScl_AccountAccessorImpl.cpp [new file with mode: 0644]
src/FScl_AccountAccessorImpl.h [new file with mode: 0644]
src/FScl_AccountDbChangeEvent.cpp [new file with mode: 0644]
src/FScl_AccountDbChangeEvent.h [new file with mode: 0644]
src/FScl_AccountDbChangeEventArg.cpp [new file with mode: 0644]
src/FScl_AccountDbChangeEventArg.h [new file with mode: 0644]
src/FScl_AccountDbConnector.cpp [new file with mode: 0644]
src/FScl_AccountDbConnector.h [new file with mode: 0644]
src/FScl_AccountDbMonitor.cpp [new file with mode: 0644]
src/FScl_AccountDbMonitor.h [new file with mode: 0644]
src/FScl_AccountImpl.cpp [new file with mode: 0644]
src/FScl_AccountImpl.h [new file with mode: 0644]
src/FScl_AccountManagerImpl.cpp [new file with mode: 0644]
src/FScl_AccountManagerImpl.h [new file with mode: 0644]
src/FScl_AccountManagerUtil.cpp [new file with mode: 0644]
src/FScl_AccountManagerUtil.h [new file with mode: 0644]
src/FScl_AccountProviderImpl.cpp [new file with mode: 0644]
src/FScl_AccountProviderImpl.h [new file with mode: 0644]
src/FScl_AddressImpl.cpp [new file with mode: 0644]
src/FScl_AddressImpl.h [new file with mode: 0644]
src/FScl_AddressbookFilterImpl.cpp [new file with mode: 0644]
src/FScl_AddressbookFilterImpl.h [new file with mode: 0644]
src/FScl_AddressbookImpl.cpp [new file with mode: 0644]
src/FScl_AddressbookManagerImpl.cpp [new file with mode: 0644]
src/FScl_AddressbookUtil.cpp [new file with mode: 0644]
src/FScl_AddressbookUtil.h [new file with mode: 0644]
src/FScl_CalEventChangeInfoImpl.cpp [new file with mode: 0644]
src/FScl_CalEventImpl.cpp [new file with mode: 0644]
src/FScl_CalEventInstanceImpl.cpp [new file with mode: 0644]
src/FScl_CalTodoChangeInfoImpl.cpp [new file with mode: 0644]
src/FScl_CalTodoImpl.cpp [new file with mode: 0644]
src/FScl_CalendarImpl.cpp [new file with mode: 0644]
src/FScl_CalendarbookDbChangeEvent.cpp [new file with mode: 0644]
src/FScl_CalendarbookDbChangeEvent.h [new file with mode: 0644]
src/FScl_CalendarbookDbChangeEventArg.cpp [new file with mode: 0644]
src/FScl_CalendarbookDbChangeEventArg.h [new file with mode: 0644]
src/FScl_CalendarbookDbConnector.cpp [new file with mode: 0644]
src/FScl_CalendarbookDbConnector.h [new file with mode: 0644]
src/FScl_CalendarbookDbMonitor.cpp [new file with mode: 0644]
src/FScl_CalendarbookDbMonitor.h [new file with mode: 0644]
src/FScl_CalendarbookFilterImpl.cpp [new file with mode: 0644]
src/FScl_CalendarbookFilterImpl.h [new file with mode: 0644]
src/FScl_CalendarbookImpl.cpp [new file with mode: 0644]
src/FScl_CalendarbookRecordRetrivalEvent.cpp [new file with mode: 0644]
src/FScl_CalendarbookRecordRetrivalEvent.h [new file with mode: 0644]
src/FScl_CalendarbookRecordRetrivalEventArg.cpp [new file with mode: 0644]
src/FScl_CalendarbookRecordRetrivalEventArg.h [new file with mode: 0644]
src/FScl_CalendarbookRecordRetrivalThread.cpp [new file with mode: 0644]
src/FScl_CalendarbookRecordRetrivalThread.h [new file with mode: 0644]
src/FScl_CalendarbookUtil.cpp [new file with mode: 0644]
src/FScl_CalendarbookUtil.h [new file with mode: 0644]
src/FScl_CategoryChangeInfoImpl.cpp [new file with mode: 0644]
src/FScl_CategoryChangeInfoImpl.h [new file with mode: 0644]
src/FScl_CategoryImpl.cpp [new file with mode: 0644]
src/FScl_ContactAppLaunchDataImpl.cpp [new file with mode: 0644]
src/FScl_ContactAppLaunchDataImpl.h [new file with mode: 0644]
src/FScl_ContactChangeInfoImpl.cpp [new file with mode: 0644]
src/FScl_ContactChangeInfoImpl.h [new file with mode: 0644]
src/FScl_ContactDbChangeEvent.cpp [new file with mode: 0644]
src/FScl_ContactDbChangeEvent.h [new file with mode: 0644]
src/FScl_ContactDbChangeEventArg.cpp [new file with mode: 0644]
src/FScl_ContactDbChangeEventArg.h [new file with mode: 0644]
src/FScl_ContactDbConnector.cpp [new file with mode: 0644]
src/FScl_ContactDbMonitor.cpp [new file with mode: 0644]
src/FScl_ContactDbMonitor.h [new file with mode: 0644]
src/FScl_ContactEventImpl.cpp [new file with mode: 0644]
src/FScl_ContactEventImpl.h [new file with mode: 0644]
src/FScl_ContactImpl.cpp [new file with mode: 0644]
src/FScl_EmailContactImpl.cpp [new file with mode: 0644]
src/FScl_EmailContactImpl.h [new file with mode: 0644]
src/FScl_EmailImpl.cpp [new file with mode: 0644]
src/FScl_IAccountDbChangeEventListener.h [new file with mode: 0644]
src/FScl_ICalendarbookDbChangeEventListener.h [new file with mode: 0644]
src/FScl_ImAddressImpl.cpp [new file with mode: 0644]
src/FScl_ImAddressImpl.h [new file with mode: 0644]
src/FScl_OrganizationImpl.cpp [new file with mode: 0644]
src/FScl_OrganizationImpl.h [new file with mode: 0644]
src/FScl_PersonImpl.cpp [new file with mode: 0644]
src/FScl_PersonImpl.h [new file with mode: 0644]
src/FScl_PhoneNumberContactImpl.cpp [new file with mode: 0644]
src/FScl_PhoneNumberContactImpl.h [new file with mode: 0644]
src/FScl_PhoneNumberImpl.cpp [new file with mode: 0644]
src/FScl_PhoneNumberImpl.h [new file with mode: 0644]
src/FScl_RecordImpl.cpp [new file with mode: 0644]
src/FScl_RecurrenceImpl.cpp [new file with mode: 0644]
src/FScl_RelationshipImpl.cpp [new file with mode: 0644]
src/FScl_RelationshipImpl.h [new file with mode: 0644]
src/FScl_ReminderImpl.cpp [new file with mode: 0644]
src/FScl_UrlImpl.cpp [new file with mode: 0644]
src/FScl_UrlImpl.h [new file with mode: 0644]
src/FScl_UserProfileImpl.cpp [new file with mode: 0644]
src/inc/FScl_AddressbookImpl.h [new file with mode: 0644]
src/inc/FScl_AddressbookManagerImpl.h [new file with mode: 0644]
src/inc/FScl_CalEventChangeInfoImpl.h [new file with mode: 0644]
src/inc/FScl_CalEventImpl.h [new file with mode: 0644]
src/inc/FScl_CalEventInstanceImpl.h [new file with mode: 0644]
src/inc/FScl_CalTodoChangeInfoImpl.h [new file with mode: 0644]
src/inc/FScl_CalTodoImpl.h [new file with mode: 0644]
src/inc/FScl_CalendarImpl.h [new file with mode: 0644]
src/inc/FScl_CalendarbookImpl.h [new file with mode: 0644]
src/inc/FScl_CategoryImpl.h [new file with mode: 0644]
src/inc/FScl_ContactDbConnector.h [new file with mode: 0644]
src/inc/FScl_ContactImpl.h [new file with mode: 0644]
src/inc/FScl_EmailImpl.h [new file with mode: 0644]
src/inc/FScl_IContactDbChangeEventListener.h [new file with mode: 0644]
src/inc/FScl_RecordImpl.h [new file with mode: 0644]
src/inc/FScl_RecurrenceImpl.h [new file with mode: 0644]
src/inc/FScl_ReminderImpl.h [new file with mode: 0644]
src/inc/FScl_UserProfileImpl.h [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..f32c2d5
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,3 @@
+Jaehwa Shin <jaehwa.shin at samsung dot com>
+Hosang Kim <hosang.kim at samsung dot com>
+Yoonchan Choi <yc81.choi at samsung dot com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..a8593f6
--- /dev/null
@@ -0,0 +1,188 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET(CMAKE_INSTALL_PREFIX /usr)
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+SET (this_target osp-social)
+
+SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/cmake_build_tmp/output)
+
+#INCLUDE(FindPkgConfig)
+#pkg_check_modules(pkgs REQUIRED calendar-service2)
+#pkg_check_modules(pkgs REQUIRED accounts-svc)
+
+INCLUDE_DIRECTORIES(
+       inc
+       src
+       src/inc
+       /usr/include
+       /usr/include/glib-2.0 
+       /usr/lib/glib-2.0/include
+       /usr/include/db-util
+       /usr/include/social
+       /usr/include/accounts-svc
+       /usr/include/contacts-svc
+       /usr/include/osp
+       /usr/include/osp/app
+       /usr/include/osp/base
+       /usr/include/osp/media
+       /usr/include/osp/io
+       /usr/include/osp/security
+       /usr/include/calendar-service2
+       )
+
+SET (${this_target}_SOURCE_FILES
+       src/FSclAddress.cpp
+       src/FScl_AddressImpl.cpp
+       src/FSclAddressbook.cpp
+       src/FScl_AddressbookImpl.cpp
+       src/FSclAddressbookFilter.cpp
+       src/FScl_AddressbookFilterImpl.cpp
+       src/FScl_AddressbookUtil.cpp
+       src/FSclAddressbookManager.cpp
+       src/FScl_AddressbookManagerImpl.cpp
+       src/FSclCategory.cpp
+       src/FScl_CategoryImpl.cpp
+       src/FSclContact.cpp
+       src/FScl_ContactImpl.cpp
+       src/FSclContactAppLaunchData.cpp
+       src/FScl_ContactAppLaunchDataImpl.cpp
+       src/FSclContactEvent.cpp
+       src/FScl_ContactEventImpl.cpp
+       src/FSclEmail.cpp
+       src/FScl_EmailImpl.cpp
+       src/FSclEmailContact.cpp
+       src/FScl_EmailContactImpl.cpp
+       src/FSclImAddress.cpp
+       src/FScl_ImAddressImpl.cpp
+       src/FSclPhoneNumber.cpp
+       src/FScl_PhoneNumberImpl.cpp
+       src/FSclPhoneNumberContact.cpp
+       src/FScl_PhoneNumberContactImpl.cpp
+       src/FSclRecord.cpp
+       src/FScl_RecordImpl.cpp
+       src/FSclUrl.cpp
+       src/FScl_UrlImpl.cpp
+       src/FSclCalendarbook.cpp
+       src/FScl_CalendarbookImpl.cpp
+       src/FSclReminder.cpp
+       src/FScl_ReminderImpl.cpp
+       src/FSclCalTodo.cpp
+       src/FScl_CalTodoImpl.cpp
+       src/FSclCalEvent.cpp
+       src/FScl_CalEventImpl.cpp
+       src/FSclAttendee.cpp
+       src/FSclRecurrence.cpp
+       src/FScl_RecurrenceImpl.cpp
+       src/FSclCalendar.cpp
+       src/FScl_CalendarImpl.cpp
+       src/FSclCalEventInstance.cpp
+       src/FScl_CalEventInstanceImpl.cpp
+       src/FSclCalEventChangeInfo.cpp
+       src/FScl_CalEventChangeInfoImpl.cpp
+       src/FSclCalTodoChangeInfo.cpp
+       src/FScl_CalTodoChangeInfoImpl.cpp
+       src/FSclCalendarbookFilter.cpp
+       src/FScl_CalendarbookFilterImpl.cpp
+       src/FScl_CalendarbookUtil.cpp
+       src/FScl_CalendarbookDbConnector.cpp
+       src/FScl_CalendarbookDbMonitor.cpp
+       src/FScl_CalendarbookDbChangeEvent.cpp
+       src/FScl_CalendarbookDbChangeEventArg.cpp
+       src/FScl_CalendarbookRecordRetrivalEvent.cpp
+       src/FScl_CalendarbookRecordRetrivalEventArg.cpp
+       src/FScl_CalendarbookRecordRetrivalThread.cpp
+       src/FSclContactChangeInfo.cpp
+       src/FScl_ContactChangeInfoImpl.cpp
+       src/FSclCategoryChangeInfo.cpp
+       src/FScl_CategoryChangeInfoImpl.cpp
+       src/FSclOrganization.cpp
+       src/FScl_OrganizationImpl.cpp
+       src/FSclPerson.cpp
+       src/FScl_PersonImpl.cpp
+       src/FSclRelationship.cpp
+       src/FScl_RelationshipImpl.cpp
+       src/FScl_ContactDbConnector.cpp
+       src/FScl_ContactDbMonitor.cpp
+       src/FScl_ContactDbChangeEvent.cpp
+       src/FScl_ContactDbChangeEventArg.cpp
+       src/FSclAccount.cpp
+       src/FScl_AccountImpl.cpp
+       src/FSclAccountAccessor.cpp
+       src/FScl_AccountAccessorImpl.cpp
+       src/FSclAccountManager.cpp
+       src/FScl_AccountManagerImpl.cpp
+       src/FSclAccountProvider.cpp
+       src/FScl_AccountProviderImpl.cpp
+       src/FScl_AccountManagerUtil.cpp
+       src/FScl_AccountDbChangeEvent.cpp
+       src/FScl_AccountDbChangeEventArg.cpp
+       src/FScl_AccountDbConnector.cpp
+       src/FScl_AccountDbMonitor.cpp
+       src/FSclUserProfile.cpp
+       src/FScl_UserProfileImpl.cpp
+)
+
+SET(EXTRA_CFLAGS  "${EXTRA_CFLAGS} -Wall" )
+
+## SET C COMPILER FLAGS
+SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## SET CPP COMPILER FLAGS
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
+SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## Create Library
+ADD_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+## SET LINKER FLAGS
+SET(CMAKE_SHARED_LINKER_FLAGS -Wl,--no-undefined)
+
+TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp -losp-appfw" )
+TARGET_LINK_LIBRARIES(${this_target} "-losp-image" )
+TARGET_LINK_LIBRARIES(${this_target} "-losp-uifw" )
+TARGET_LINK_LIBRARIES(${this_target} "-lglib-2.0" )
+TARGET_LINK_LIBRARIES(${this_target} "-lcalendar-service2" )
+TARGET_LINK_LIBRARIES(${this_target} "-lcontacts-service2" )
+TARGET_LINK_LIBRARIES(${this_target} "-laccounts-svc" )
+TARGET_LINK_LIBRARIES(${this_target} "-lpthread" )
+
+SET_TARGET_PROPERTIES(${this_target} 
+       PROPERTIES 
+       VERSION ${FULLVER}
+       SOVERSION ${MAJORVER}
+       CLEAN_DIRECT_OUTPUT 1
+       )
+
+ADD_CUSTOM_COMMAND(TARGET ${this_target}
+    POST_BUILD
+               COMMAND ${CMAKE_COMMAND} -E copy ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER} 
+               COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${MAJORVER}
+               COMMAND ${CMAKE_STRIP} --strip-unneeded ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}
+    COMMENT "strip ${this_target}"
+               )   
+
+INSTALL(DIRECTORY ${LIBRARY_OUTPUT_PATH}/ DESTINATION lib/osp 
+                               FILES_MATCHING PATTERN "*.so*" 
+                               PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ                                          
+                                                                               GROUP_EXECUTE GROUP_READ
+                                                                               WORLD_EXECUTE WORLD_READ)
+INSTALL(DIRECTORY ${LIBRARY_OUTPUT_PATH}/debug/ DESTINATION lib/osp/debug 
+                               FILES_MATCHING PATTERN "*.so*" 
+                               PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ                                          
+                                                                               GROUP_EXECUTE GROUP_READ
+                                                                               WORLD_EXECUTE WORLD_READ)
+
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/inc/ DESTINATION include/osp FILES_MATCHING PATTERN "*.h")
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/src/inc/ DESTINATION include/osp/social FILES_MATCHING PATTERN "*.h")
+
+SET(PC_NAME ${this_target})
+SET(PC_REQUIRED ${pc_requires})
+SET(PC_LDFLAGS -l${this_target})
+
+# pkgconfig file
+CONFIGURE_FILE(${this_target}.pc.in ${CMAKE_SOURCE_DIR}/${this_target}.pc @ONLY)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/${this_target}.pc DESTINATION lib/pkgconfig)
+
+# INCLUDE FOR BUILD & INSTALL PACKAGE MANAGER .SO
+ADD_SUBDIRECTORY(pkgmgr_account)
diff --git a/LICENSE.APLv2 b/LICENSE.APLv2
new file mode 100644 (file)
index 0000000..d645695
--- /dev/null
@@ -0,0 +1,202 @@
+
+                                 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/NOTICE b/NOTICE
new file mode 100644 (file)
index 0000000..b616854
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,3 @@
+Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE.APLv2 file for Apache License terms and conditions.
diff --git a/inc/FSclAccount.h b/inc/FSclAccount.h
new file mode 100644 (file)
index 0000000..06d4f7d
--- /dev/null
@@ -0,0 +1,182 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FSclAccount.h
+ * @brief      This is the header file for the %Account class.
+ *
+ * This header file contains the declarations of the %Account class.
+ */
+#ifndef _FSCL_ACCOUNT_H_
+#define _FSCL_ACCOUNT_H_
+
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+namespace Collection
+{
+class IMap;
+}
+}}
+
+namespace Tizen { namespace Social
+{
+class AccountProvider;
+
+/**
+ * @class      Account
+ * @brief      This class represents the account information.
+ * @since      2.1
+ *
+ * @final      This class is not intended for extension.
+ *
+ * This %Account class represents the account information.
+ */
+class _OSP_EXPORT_ Account
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class. @n
+        * It creates a fully initialized instance of the %Account class.
+        *
+        * @since               2.1
+        *
+        * @param[in]   userName                The user name
+        */
+       Account(const Tizen::Base::String& userName);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since               2.1
+        *
+        * @param[in]   rhs             An instance of %Account to copy
+        */
+       Account(const Account& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since               2.1
+        */
+       virtual ~Account(void);
+
+       /**
+        * Checks whether the value of the specified instance is equal to the value of the current instance.
+        *
+        * @since               2.1
+        *
+        * @return              @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance, @n
+        *                              else @c false
+        * @param[in]   rhs             An instance of Tizen::Base::Object to compare
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since       2.1
+        *
+        * @return      The integer value that indicates the hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the ID of an account.
+        *
+        * @since       2.1
+        *
+        * @return      The account ID
+        */
+       AccountId GetId(void) const;
+
+       /**
+        * Gets the account provider.
+        *
+        * @since       2.1
+        *
+        * @return      The account provider
+        */
+       AccountProvider GetAccountProvider(void) const;
+
+       /**
+        * Gets the user name.
+        *
+        * @since       2.1
+        *
+        * @return      The user name
+        */
+       Tizen::Base::String GetUserName(void) const;
+
+       /**
+        * Gets the extended data.
+        *
+        * @since       2.1
+        *
+        * @return              The key-value lists of the extended data, @n
+        *                              else an empty list if there is no extended data, or @c null if an exception occurs (String, String list)
+        * @remarks     The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IMap* GetExtendedDataN(void) const;
+
+       /**
+        * Sets the user name.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   userName                The user name
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c userName is an empty string.
+        */
+       result SetUserName(const Tizen::Base::String& userName);
+
+       /**
+        * Sets the extended data with the specified @c key and @c value. @n
+        * If the specified @c key already exists, the corresponding value is overwritten with the specified @c value.
+        *
+        * @since               2.1
+        *
+        * @return              An error code
+        * @param[in]   key                             The key of the extended data
+        * @param[in]   value                   The value of the extended data
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c key is an empty string.
+        */
+       result SetExtendedData(const Tizen::Base::String& key, const Tizen::Base::String& value);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since               2.1
+        *
+        * @param[in]   rhs             An instance of %Account to copy
+        */
+       Account& operator =(const Account& rhs);
+
+private:
+       friend class _AccountImpl;
+       class _AccountImpl* __pAccountImpl;
+
+}; // Account
+
+}} // Tizen::Social
+
+#endif //_FSCL_ACCOUNT_H_
diff --git a/inc/FSclAccountAccessor.h b/inc/FSclAccountAccessor.h
new file mode 100644 (file)
index 0000000..e5f9f7e
--- /dev/null
@@ -0,0 +1,265 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FSclAccountAccessor.h
+* @brief       This is the header file for the %AccountAccessor class.
+*
+* This header file contains the declarations of the %AccountAccessor class.
+*/
+#ifndef _FSCL_ACCOUNT_ACCESSOR_H_
+#define _FSCL_ACCOUNT_ACCESSOR_H_
+
+#include <unique_ptr.h>
+#include <FAppTypes.h>
+#include <FBaseObject.h>
+#include <FBaseTypes.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+
+namespace Collection
+{
+class IList;
+}
+}}
+
+namespace Tizen { namespace Social
+{
+class Account;
+class IAccountEventListener;
+
+/**
+ * @class      AccountAccessor
+ * @brief      This class provides methods for accessing accounts and account providers.
+ * @since      2.1
+ *
+ * @final      This class is not intended for extension.
+ *
+ * This %AccountAccessor class provides methods for accessing accounts and account providers.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/social/acc_manage.htm">Account Management</a>.
+ */
+class _OSP_EXPORT_ AccountAccessor
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * Sets an account change event listener that is called when an account is changed. @n
+        * To reset the event listener, @c null must be passed.
+        *
+        * @since               2.1
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/account.read
+        *
+        * @return              An error code
+        * @param[in]   pListener                               The event listener
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+        * @remarks             The platform will not take the ownership of @c pListener after this call.
+        */
+       result SetEventListener(IAccountEventListener* pListener);
+
+       /**
+        * Gets an account with the specified account ID.
+        *
+        * @since               2.1
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/account.read
+        *
+        * @return              The account with the specified @c accountId
+        * @param[in]   accountId                               The account ID
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_INVALID_ARG                   The specified @c accountId is invalid.
+        * @exception   E_OBJ_NOT_FOUND                 The specified @c accountId is not found.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Account GetAccount(AccountId accountId) const;
+
+       /**
+        * Gets accounts associated with the account provider that has the specified application ID.
+        *
+        * @since               2.1
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/account.read
+        *
+        * @return              The list of accounts, @n
+        *                              else an empty list if there is no account, or @c null if an exception occurs (@ref Account list)
+        * @param[in]   accountProviderAppId    The application ID of the account provider
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_INVALID_ARG                   The specified @c accountProviderAppId is empty.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetAccountsByAccountProviderN(const Tizen::App::AppId& accountProviderAppId) const;
+
+       /**
+        * Gets all the accounts.
+        *
+        * @since               2.1
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/account.read
+        *
+        * @return              The list of accounts, @n
+        *                              else an empty list if there is no account, or @c null if an exception occurs (@ref Account list)
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetAllAccountsN(void) const;
+
+       /**
+        * Gets an account provider with the specified application ID.
+        *
+        * @since               2.1
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/account.read
+        *
+        * @return              The account provider with the specified @c accountProviderAppId ID
+        * @param[in]   accountProviderAppId    The application ID of the account provider
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_INVALID_ARG                   The specified @c accountProviderAppId is empty.
+        * @exception   E_OBJ_NOT_FOUND                 The specified @c accountProviderAppId is not found.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       AccountProvider GetAccountProvider(const Tizen::App::AppId& accountProviderAppId) const;
+
+       /**
+        * Gets account providers that have the specified @c capability.
+        *
+        * @since               2.1
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/account.read
+        *
+        * @return              The list of account providers, @n
+        *                              else an empty list if there is no account provider, or @c null if an exception occurs (@ref AccountProvider list)
+        * @param[in]   capability                              The predefined capability or the vendor-specific capability defined as the IRI format
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_INVALID_ARG                   The specified @c capability is empty.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetAccountProvidersByCapabilityN(const Tizen::Base::String& capability) const;
+
+       /**
+        * Gets all the currently registered account providers.
+        *
+        * @since               2.1
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/account.read
+        *
+        * @return              The list of account providers, @n
+        *                              else an empty list if there is no account provider, or @c null if an exception occurs (@ref AccountProvider list)
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetAllAccountProvidersN(void) const;
+
+       /**
+        * Gets an %AccountAccessor instance.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to the %AccountAccessor instance, @n
+        *                              else @c null if it fails
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       static AccountAccessor* GetInstance(void);
+
+private:
+       //
+       // This default constructor is intentionally declared as private to implement the Singleton semantic.
+       //
+       // @since               2.1
+       //
+       AccountAccessor(void);
+
+       //
+       // This destructor is intentionally declared as private to implement the Singleton semantic.
+       //
+       // @since               2.1
+       //
+       virtual ~AccountAccessor(void);
+
+       //
+       // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       // @since               2.1
+       //
+       AccountAccessor(const AccountAccessor& rhs);
+
+       //
+       // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       // @since               2.1
+       //
+       AccountAccessor& operator =(const AccountAccessor& rhs);
+
+       //
+       // Constructs an instance of this class.
+       //
+       // @since               2.1
+       //
+       // @return              An error code
+       // @exception   E_SUCCESS                       The method is successful.
+       // @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+       //
+       result Construct(void);
+
+       //
+       // Initializes an instance of this class.
+       //
+       // @since               2.1
+       //
+       static void InitAccountAccessor(void);
+
+       //
+       // Destroys an instance of this class.
+       //
+       // @since               2.1
+       //
+       static void DestroyAccountAccessor(void);
+
+private:
+       static AccountAccessor* __pInstance;
+       friend struct std::default_delete<AccountAccessor>;
+
+       friend class _AccountAccessorImpl;
+       class _AccountAccessorImpl* __pAccountAccessorImpl;
+
+};     // AccountAccessor
+
+}}     // Tizen::Social
+
+#endif //_FSCL_ACCOUNT_ACCESSOR_H_
diff --git a/inc/FSclAccountManager.h b/inc/FSclAccountManager.h
new file mode 100644 (file)
index 0000000..e849e2f
--- /dev/null
@@ -0,0 +1,204 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FSclAccountManager.h
+* @brief       This is the header file for the %AccountManager class.
+*
+* This header file contains the declarations of the %AccountManager class.
+*/
+#ifndef _FSCL_ACCOUNT_MANAGER_H_
+#define _FSCL_ACCOUNT_MANAGER_H_
+
+#include <unique_ptr.h>
+#include <FBaseObject.h>
+#include <FBaseTypes.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+namespace Collection
+{
+class IList;
+}
+}}
+
+namespace Tizen { namespace Social
+{
+class Account;
+class AccountProvider;
+
+/**
+ * @class      AccountManager
+ * @brief      This class provides methods for managing accounts.
+ * @since      2.1
+ *
+ * @final      This class is not intended for extension.
+ *
+ * The %AccountManager class provides methods for managing accounts.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/social/acc_manage.htm">Account Management</a>.
+ */
+class _OSP_EXPORT_ AccountManager
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * Adds an account. @n
+        * The user name must be set in the account.
+        * If the account is added successfully, an account ID is newly assigned to it. @n
+        * The %AddAccount() method can be used only by an application belonging to a package of an application that registers its own account provider.
+        *
+        * @since               2.1
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/account.write
+        *
+        * @return                      An error code
+        * @param[in,out]       account                                 The account to add @n
+        *                                                                                      If this method is successful, the account ID for the added account is assigned.
+        * @exception           E_SUCCESS                               The method is successful.
+        * @exception           E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception           E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                                      - The user name is an empty string in the specified @c account.
+        *                                                                                      - The account ID is not #INVALID_ACCOUNT_ID.
+        * @exception           E_INVALID_OPERATION             Either of the following conditions has occurred:
+        *                                                                                      - The caller application does not belong to a package of an application that registers its own account provider.
+        *                                                                                      - The account has already been added with the multiple accounts support set to @c false.
+        * @exception           E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+        * @exception           E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       result AddAccount(Account& account);
+
+       /**
+        * Removes an account. @n
+        * The %RemoveAccount() method can be used only by the applications belonging to the package of the application that has registered the account provider of the specified account.
+        *
+        * @since               2.1
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/account.write
+        *
+        * @return              An error code
+        * @param[in]   accountId                               The account ID
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_INVALID_ARG                   The specified @c accountId is invalid.
+        * @exception   E_OBJ_NOT_FOUND                 The specified @c accountId does not exist.
+        * @exception   E_INVALID_OPERATION             The caller application does not belong to the package of the application that has registered the account provider of the specified account.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       result RemoveAccount(AccountId accountId);
+
+       /**
+        * Updates an account. @n
+        * The user name must be set in the account.
+        * The %UpdateAccount() method can be used only by the applications belonging to the package of the application that has registered the account provider of the specified account.
+        *
+        * @since               2.1
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/account.write
+        *
+        * @return              An error code
+        * @param[in]   account                                 The account to update
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The user name is an empty string in the specified @c account.
+        *                                                                              - The account ID is invalid.
+        * @exception   E_OBJ_NOT_FOUND                 The specified @c account does not exist.
+        * @exception   E_INVALID_OPERATION             The caller application does not belong to the package of the application that has registered the account provider of the specified account.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       result UpdateAccount(const Account& account);
+
+       /**
+        * Gets an %AccountManager instance.
+        *
+        * @since               2.1
+        *
+        * @return              A pointer to the %AccountManager instance, @n
+        *                              else @c null if it fails
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       static AccountManager* GetInstance(void);
+
+private:
+       //
+       // This default constructor is intentionally declared as private to implement the Singleton semantic.
+       //
+       // @since               2.1
+       //
+       AccountManager(void);
+
+       //
+       // This destructor is intentionally declared as private to implement the Singleton semantic.
+       //
+       // @since               2.1
+       //
+       virtual ~AccountManager(void);
+
+       //
+       // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       // @since               2.1
+       //
+       AccountManager(const AccountManager& rhs);
+
+       //
+       // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       // @since               2.1
+       //
+       AccountManager& operator =(const AccountManager& rhs);
+
+       //
+       // Constructs an instance of this class.
+       //
+       // @since               2.1
+       //
+       // @return              An error code
+       // @exception   E_SUCCESS                       The method is successful.
+       // @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+       //
+       result Construct(void);
+
+       //
+       // Initializes an instance of this class.
+       //
+       // @since               2.1
+       //
+       static void InitAccountManager(void);
+
+       //
+       // Destroys an instance of this class.
+       //
+       // @since               2.1
+       //
+       static void DestroyAccountManager(void);
+
+private:
+       static AccountManager* __pInstance;
+       friend struct std::default_delete<AccountManager>;
+
+       friend class _AccountManagerImpl;
+       class _AccountManagerImpl* __pAccountManagerImpl;
+
+};     // AccountManager
+
+}}     // Tizen::Social
+
+#endif //_FSCL_ACCOUNT_MANAGER_H_
diff --git a/inc/FSclAccountProvider.h b/inc/FSclAccountProvider.h
new file mode 100644 (file)
index 0000000..963616a
--- /dev/null
@@ -0,0 +1,173 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FSclAccountProvider.h
+ * @brief      This is the header file for the %AccountProvider class.
+ *
+ * This header file contains the declarations of the %AccountProvider class.
+ */
+#ifndef _FSCL_ACCOUNT_PROVIDER_H_
+#define _FSCL_ACCOUNT_PROVIDER_H_
+
+#include <FAppTypes.h>
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+namespace Collection
+{
+class IList;
+}
+}}
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @class      AccountProvider
+ * @brief      This class represents the account provider information.
+ * @since      2.1
+ *
+ * @final      This class is not intended for extension.
+ *
+ *  The %AccountProvider class represents the account provider information.
+ */
+class _OSP_EXPORT_ AccountProvider
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class. @n
+        * It creates a fully initialized instance of the %AccountProvider class.
+        *
+        * @since       2.1
+        */
+       AccountProvider(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since               2.1
+        *
+        * @param[in]   rhs             An instance of %AccountProvider to copy
+        */
+       AccountProvider(const AccountProvider& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.1
+        */
+       virtual ~AccountProvider(void);
+
+       /**
+        * Checks whether the value of the specified instance is equal to the value of the current instance.
+        *
+        * @since               2.1
+        *
+        * @return              @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance, @n
+        *                                      else @c false
+        * @param[in]   rhs             An instance of Tizen::Base::Object to compare
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since       2.1
+        *
+        * @return      The integer value that indicates the hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the ID of the application that has registered this account provider.
+        *
+        * @since       2.1
+        *
+        * @return      The application ID
+        */
+       Tizen::App::AppId GetAppId(void) const;
+
+       /**
+        * Gets the list of capabilities that an account provider owns.
+        *
+        * @since       2.1
+        *
+        * @return      The list of capabilities which are predefined or the vendor-specific String defined as the IRI format, @n
+        *                      else an empty list if there is no capability, or @c null if an exception occurs (String list)
+        * @remarks     The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetCapabilitiesN(void) const;
+
+       /**
+        * Gets the display name of an account provider.
+        *
+        * @since       2.1
+        *
+        * @return      The display name
+        */
+       Tizen::Base::String GetDisplayName(void) const;
+
+       /**
+        * Gets the icon path.
+        *
+        * @since       2.1
+        *
+        * @return      The icon path
+        */
+       Tizen::Base::String GetIconPath(void) const;
+
+       /**
+        * Gets the small icon path.
+        *
+        * @since       2.1
+        *
+        * @return      The small icon path
+        */
+       Tizen::Base::String GetSmallIconPath(void) const;
+
+       /**
+        * Checks whether an account provider supports multiple accounts.
+        *
+        * @since       2.1
+        *
+        * @return      @c true if the account provider supports multiple accounts, @n
+        *                      else @c false
+        */
+       bool IsMultipleAccountSupported(void) const;
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since               2.1
+        *
+        * @param[in]   rhs             An instance of %AccountProvider to copy
+        */
+       AccountProvider& operator =(const AccountProvider& rhs);
+
+private:
+       friend class _AccountProviderImpl;
+       class _AccountProviderImpl* __pAccountProviderImpl;
+
+}; // AccountProvider
+
+}} // Tizen::Social
+
+#endif //_FSCL_ACCOUNT_PROVIDER_H_
diff --git a/inc/FSclAddress.h b/inc/FSclAddress.h
new file mode 100644 (file)
index 0000000..436c197
--- /dev/null
@@ -0,0 +1,545 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FSclAddress.h
+ * @brief      This is the header file for the %Address class.
+ *
+ * This header file contains the declarations of the %Address class.
+ */
+#ifndef _FSCL_ADDRESS_H_
+#define _FSCL_ADDRESS_H_
+
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @if OSPDEPREC
+ * The maximum length of the extended field.
+ *
+ * @brief <i> [Deprecated]  </i>
+ * @deprecated This constant is deprecated because there is no limitation any more.
+ * @since      2.0
+ * @endif
+ */
+static const int MAX_ADDR_EXTENDED_LENGTH = 50;
+
+/**
+ * @if OSPDEPREC
+ * The maximum length of the street field.
+ *
+ * @brief <i> [Deprecated]  </i>
+ * @deprecated This constant is deprecated because there is no limitation any more.
+ * @since      2.0
+ * @endif
+ */
+static const int MAX_ADDR_STREET_LENGTH = 50;
+
+/**
+ * @if OSPDEPREC
+ * The maximum length of the city field.
+ *
+ * @brief <i> [Deprecated]  </i>
+ * @deprecated This constant is deprecated because there is no limitation any more.
+ * @since      2.0
+ * @endif
+ */
+static const int MAX_ADDR_CITY_LENGTH = 50;
+
+/**
+ * @if OSPDEPREC
+ * The maximum length of the state field.
+ *
+ * @brief <i> [Deprecated]  </i>
+ * @deprecated This constant is deprecated because there is no limitation any more.
+ * @since      2.0
+ * @endif
+ */
+static const int MAX_ADDR_STATE_LENGTH = 50;
+
+/**
+ * @if OSPDEPREC
+ * The maximum length of the postal code field.
+ *
+ * @brief <i> [Deprecated]  </i>
+ * @deprecated This constant is deprecated because there is no limitation any more.
+ * @since      2.0
+ * @endif
+ */
+static const int MAX_ADDR_POSTAL_CODE_LENGTH = 20;
+
+/**
+ * @if OSPDEPREC
+ * The maximum length of the country field.
+ *
+ * @brief <i> [Deprecated]  </i>
+ * @deprecated This constant is deprecated because the maximum length of the country name has been changed.
+* @since       2.0
+ * @endif
+ */
+static const int MAX_ADDR_COUNTRY_LENGTH = 20;
+
+/**
+ * @if OSPDEPREC
+ * The maximum length of the post office box number field.
+ *
+ * @brief <i> [Deprecated]  </i>
+ * @deprecated This constant is deprecated because there is no limitation any more.
+* @since       2.0
+ * @endif
+ */
+static const int MAX_ADDR_POBOXNUM_LENGTH = 20;
+
+/**
+ * @class      Address
+ * @brief      This class represents the structured address type representing the ADR type definition of a vCard.
+ *
+ * @since      2.0
+ *
+ * @final      This class is not intended for extension.
+ *
+ * The %Address class represents the structured address type representing the ADR type definition of a vCard.
+ * It is based on the MIME directory profile specification (RFC 2426).
+ * The address information consists of the country, city, state, street, post office box number, postal code, and address type.
+ * This class represents the structured address type representing the ADR type definition of a vCard.
+ * It is based on the MIME directory profile specification (RFC 2426).
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/social/addressbook_namespace.htm">Addressbook</a>.
+ */
+class _OSP_EXPORT_ Address
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class. @n
+        * It creates a fully initialized instance of the %Address class.
+        *
+        * @since       2.0
+        */
+       Address(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %Address to copy
+        */
+       Address(const Address& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~Address(void);
+
+       /**
+        * Checks whether the value of the specified instance is equal to the value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return      @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Tizen::Base::Object, @n
+        *                      else @c false
+        * @param[in]   rhs             An instance of Tizen::Base::Object to compare
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return      The integer value that indicates the hash value of the current instance of Tizen::Base::Object
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the type of the address.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility            This method has compatibility issues with OSP compatible applications. @n
+        *                           For more information, see @ref CompAddressGetTypePage "here".
+        * @endif
+        *
+        * @return      The type of the address
+        */
+       AddressType GetType(void) const;
+
+       /**
+        * @if OSPCOMPAT
+        * @page                CompAddressGetTypePage         Compatibility for GetType()
+        * @section             CompAddressGetTypePageIssueSection             Issues
+        *                                              Implementing this method in OSP compatible applications has the following issue: @n
+        *                                              -# @c ADDRESS_TYPE_CUSTOM is not supported. If the type of the address is @c ADDRESS_TYPE_CUSTOM, @c ADDRESS_TYPE_OTHER is returned instead.
+        *
+        * @section             CompAddressGetTypePageSolutionSection          Resolutions
+        *                                              The issue mentioned above has been resolved in Tizen.
+        * @endif
+        */
+
+       /**
+        * Gets the extended field of the address.
+        *
+        * @since       2.0
+        *
+        * @return      The extended field of the address
+        */
+       Tizen::Base::String GetExtended(void) const;
+
+       /**
+        * Gets the street of the address.
+        *
+        * @since       2.0
+        *
+        * @return      The street of the address
+        */
+       Tizen::Base::String GetStreet(void) const;
+
+       /**
+        * Gets the city of the address.
+        *
+        * @since       2.0
+        *
+        * @return      The city of the address
+        */
+       Tizen::Base::String GetCity(void) const;
+
+       /**
+        * Gets the state of the address.
+        *
+        * @since       2.0
+        *
+        * @return      The state of the address
+        */
+       Tizen::Base::String GetState(void) const;
+
+       /**
+        * Gets the postal code of the address.
+        *
+        * @since       2.0
+        *
+        * @return      The postal code of the address
+        */
+       Tizen::Base::String GetPostalCode(void) const;
+
+       /**
+        * Gets the country of the address.
+        *
+        * @since       2.0
+        *
+        * @return      The country of the address
+        */
+       Tizen::Base::String GetCountry(void) const;
+
+       /**
+        * Gets the post office box number of the address.
+        *
+        * @since       2.0
+        *
+        * @return      The post office box number of the address
+        */
+       Tizen::Base::String GetPostOfficeBoxNumber(void) const;
+
+       /**
+        * Sets the type of the address.
+        *
+        * @since       2.0
+        *
+        * @param[in]   type    The address type to set
+        * @see AddressType()
+        */
+       void SetType(AddressType type);
+
+       /**
+        * Sets the extended field of the address.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility       This method has compatibility issues with OSP compatible applications. @n
+        *                      For more information, see @ref CompAddressSetExtendedPage "here".
+        * @endif
+        *
+        * @return              An error code
+        * @param[in]   extended                The new extended value to set
+        * @exception   E_SUCCESS               The method is successful.
+        */
+       result SetExtended(const Tizen::Base::String& extended);
+
+       /**
+        * @if OSPCOMPAT
+        * @page                CompAddressSetExtendedPage              Compatibility for SetExtended()
+        * @section             CompAddressSetExtendedPageIssueSection          Issues
+        *                              Implementing this method in OSP compatible applications has the following issue: @n
+        *                              -# If the length of the extended address to be set is greater than @c 50 characters, @c E_INVALID_ARG is returned.
+        *
+        * @section             CompAddressSetExtendedPageSolutionSection               Resolutions
+        *                              The issue mentioned above has been resolved in Tizen.
+        * @endif
+        */
+
+       /**
+        * Sets the street of the address.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility            This method has compatibility issues with OSP compatible applications. @n
+        *                            For more information, see @ref CompAddressSetStreetPage "here".
+        * @endif
+        *
+        * @return              An error code
+        * @param[in]   street                  The new street value to set
+        * @exception   E_SUCCESS               The method is successful.
+        */
+       result SetStreet(const Tizen::Base::String& street);
+
+       /**
+        * @if OSPCOMPAT
+        * @page                CompAddressSetStreetPage                Compatibility for SetStreet()
+        * @section             CompAddressSetStreetPageIssueSection            Issues
+        *                              Implementing this method in OSP compatible applications has the following issue: @n
+        *                              -# If the length of the street to be set is greater than @c 50 characters, @c E_INVALID_ARG is returned.
+        *
+        * @section             CompAddressSetStreetPageSolutionSection         Resolutions
+        *                              The issue mentioned above has been resolved in Tizen.
+        * @endif
+        */
+
+       /**
+        * Sets the city of the address.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility     This method has compatibility issues with OSP compatible applications. @n
+        *                    For more information, see @ref CompAddressSetCityPage "here".
+        * @endif
+        *
+        * @return              An error code
+        * @param[in]   city                    The new city value to set
+        * @exception   E_SUCCESS               The method is successful.
+        */
+       result SetCity(const Tizen::Base::String& city);
+
+       /**
+        * @if OSPCOMPAT
+        * @page                CompAddressSetCityPage          Compatibility for SetCity()
+        * @section             CompAddressSetCityPageIssueSection              Issues
+        *                              Implementing this method in OSP compatible applications has the following issue: @n
+        *                              -# If the length of the city to be set is greater than @c 50 characters, @c E_INVALID_ARG is returned.
+        *
+        * @section             CompAddressSetCityPageSolutionSection           Resolutions
+        *                              The issue mentioned above has been resolved in Tizen.
+        * @endif
+        */
+
+       /**
+        * Sets the state of the address.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility     This method has compatibility issues with OSP compatible applications. @n
+        *                    For more information, see @ref CompAddressSetStatePage "here".
+        * @endif
+        *
+        * @return              An error code
+        * @param[in]   state                   The new state value to set
+        * @exception   E_SUCCESS               The method is successful.
+        */
+       result SetState(const Tizen::Base::String& state);
+
+       /**
+        * @if OSPCOMPAT
+        * @page                CompAddressSetStatePage         Compatibility for SetState()
+        * @section             CompAddressSetStatePageIssueSection             Issues
+        *                              Implementing this method in OSP compatible applications has the following issue: @n
+        *                              -# If the length of the state to be set is greater than @c 50 characters, @c E_INVALID_ARG is returned.
+        *
+        * @section             CompAddressSetStatePageSolutionSection          Resolutions
+        *                              The issue mentioned above has been resolved in Tizen.
+        * @endif
+        */
+
+       /**
+        * Sets the postal code of the address.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        *
+        * @if OSPCOMPAT
+        * @compatibility    This method has compatibility issues with OSP compatible applications. @n
+        *                   For more information, see @ref CompAddressSetPostalCodePage "here".
+        * @endif
+        *
+        * @return              An error code
+        * @param[in]   postalCode              The new postal code value to set
+        * @exception   E_SUCCESS               The method is successful.
+        */
+       result SetPostalCode(const Tizen::Base::String& postalCode);
+
+       /**
+        * @if OSPCOMPAT
+        * @page                CompAddressSetPostalCodePage            Compatibility for SetPostalCode()
+        * @section             CompAddressSetPostalCodePageIssueSection                Issues
+        *                              Implementing this method in OSP compatible applications has the following issue: @n
+        *                              -# If the length of the postal code to be set is greater than @c 20 characters, @c E_INVALID_ARG is returned.
+        *
+        * @section             CompAddressSetPostalCodePageSolutionSection             Resolutions
+        *                              The issue mentioned above has been resolved in Tizen.
+        * @endif
+        */
+
+       /**
+        * Sets the country of the address.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        *
+        * @if OSPCOMPAT
+        * @compatibility     This method has compatibility issues with OSP compatible applications. @n
+        *                    For more information, see @ref CompAddressSetCountryCodePage "here".
+        * @endif
+        *
+        * @return              An error code
+        * @param[in]   country                 The new country value to set
+        * @exception   E_SUCCESS               The method is successful.
+        */
+       result SetCountry(const Tizen::Base::String& country);
+
+       /**
+        * @if OSPCOMPAT
+        * @page                CompAddressSetCountryCodePage           Compatibility for SetCountry()
+        * @section             CompAddressSetCountryCodePageIssueSection               Issues
+        *                              Implementing this method in OSP compatible applications has the following issue: @n
+        *                              -# If the length of the country to be set is greater than @c 20 characters, @c E_INVALID_ARG is returned.
+        *
+        * @section             CompAddressSetCountryCodePageSolutionSection            Resolutions
+        *                              The issue mentioned above has been resolved in Tizen.
+        * @endif
+        */
+
+       /**
+        * Sets the post office box number of the address.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility   This method has compatibility issues with OSP compatible applications. @n
+        *                  For more information, see @ref CompAddressSetPostOfficeBoxNumberPage "here".
+        * @endif
+        *
+        * @return              An error code
+        * @param[in]   postOfficeBoxNumber     The new post office box number value to set
+        * @exception   E_SUCCESS                       The method is successful.
+        */
+       result SetPostOfficeBoxNumber(const Tizen::Base::String& postOfficeBoxNumber);
+
+       /**
+        * @if OSPCOMPAT
+        * @page                CompAddressSetPostOfficeBoxNumberPage           Compatibility for SetPostOfficeBoxNumber()
+        * @section             CompAddressSetPostOfficeBoxNumberPageIssueSection               Issues
+        *                              Implementing this method in OSP compatible applications has the following issue: @n
+        *                              -# If the length of the post office box number to be set is greater than @c 20 characters, @c E_INVALID_ARG is returned.
+        *
+        * @section             CompAddressSetPostOfficeBoxNumberPageSolutionSection            Resolutions
+        *                              The issue mentioned above has been resolved in Tizen.
+        * @endif
+        */
+
+       /**
+        * Gets the label of the address.
+        *
+        * @since       2.0
+        *
+        * @return      The address label
+        * @see SetLabel()
+        */
+       Tizen::Base::String GetLabel(void) const;
+
+       /**
+        * Sets the label of the address.
+        *
+        * @since       2.0
+        *
+        * @param[in]   label   The address label
+        * @see GetLabel()
+        */
+       void SetLabel(const Tizen::Base::String& label);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %Address to copy
+        */
+       Address& operator =(const Address& rhs);
+
+       /**
+        * Compares the specified instance of %Address with the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the data of the specified instance is equal to the data of the current instance, @n
+        *                              else @c false
+        * @param[in]   rhs             The source data
+        */
+       bool operator ==(const Address& rhs) const;
+
+       /**
+        * Compares the specified instance to the current instance for inequality.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the data of the specified instance is not equal to the data of the current instance, @n
+        *                              else @c false
+        * @param[in]   rhs             The source data
+        */
+       bool operator !=(const Address& rhs) const;
+
+private:
+       friend class _AddressImpl;
+       class _AddressImpl* __pAddressImpl;
+}; // Address
+
+}} // Tizen::Social
+
+#endif //_FSCL_ADDRESS_H_
diff --git a/inc/FSclAddressbook.h b/inc/FSclAddressbook.h
new file mode 100644 (file)
index 0000000..18cba0c
--- /dev/null
@@ -0,0 +1,1265 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FSclAddressbook.h
+* @brief       This is the header file for the %Addressbook class.
+*
+* This header file contains the declarations of the %Addressbook class.
+*/
+
+#ifndef _FSCL_ADDRESSBOOK_H_
+#define _FSCL_ADDRESSBOOK_H_
+
+#include <FBaseObject.h>
+#include <FBaseTypes.h>
+#include <FSclRecord.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+namespace Collection
+{
+class IList;
+template<class Type> class IListT;
+}
+}}
+
+namespace Tizen { namespace Social
+{
+class Category;
+class Contact;
+class UserProfile;
+class IRecordEventListener;
+class IAddressbookEventListener;
+class IAddressbookChangeEventListener;
+class IRecordEventListener;
+
+/**
+ * @class      Addressbook
+ * @brief      This class handles the address book database.
+ *
+ * @since      2.0
+ *
+ * @final      This class is not intended for extension.
+ *
+ * The %Addressbook class handles the %Addressbook database, which is a centralized database used by multiple applications to store a subset of the contact information.
+ * It also supports the categorizing of the contacts.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/social/addressbook_namespace.htm">Address Book</a>.
+ *
+ * The following example demonstrates how to use the %Addressbook class to create categories and add contacts to them.
+ *
+ * @code
+ *
+       #include <FSocial.h>
+
+       using namespace Tizen::Social;
+       using namespace Tizen::Base;
+
+       void
+       AddressbookExample::CreateExample(void)
+       {
+               result r = E_SUCCESS;
+
+               // Get default addressbook instance
+               Addressbook* pAddressbook = AddressbookManager::GetInstance()->GetAddressbookN();
+
+               // Creates and constructs a contact
+               Contact contact;
+
+               // Sets the contact's properties: first name and last name
+               contact.SetValue(CONTACT_PROPERTY_ID_FIRST_NAME , L"Thomas");
+               contact.SetValue(CONTACT_PROPERTY_ID_LAST_NAME , L"Anderson");
+
+               // Sets the contact's properties: add a phone number
+               PhoneNumber phoneNumber(PHONENUMBER_TYPE_MOBILE, L"820223459876");
+               contact.AddPhoneNumber(phoneNumber);
+
+               // Sets the contact's properties: add an address
+               Address address;
+               address.SetCountry(L"KOR");
+               address.SetCity(L"Seoul");
+               contact.AddAddress(address);
+
+               // Adds the contact to the address book (when it is added, the recordId is created)
+               r = pAddressbook->AddContact(contact);
+               if (IsFailed(r))
+               {
+                       AppLogException( "Fails to add a contact");
+
+                       delete pAddressbook;
+                       return;
+               }
+
+               // Creates and constructs a category ("Friends")
+               Category category;
+               category.SetName(L"Friends");
+
+
+               // Adds the category to the address book
+               r = pAddressbook->AddCategory(category);
+               if (IsFailed(r))
+               {
+                       delete pAddressbook;
+                       return;
+               }
+
+               // Adds the contact to the category
+               r = pAddressbook->AddMemberToCategory(category.GetRecordId(), contact.GetRecordId());
+               if (IsFailed(r))
+               {
+                       delete pAddressbook;
+                       return;
+               }
+
+               delete pAddressbook;
+       }
+ *
+ * @endcode
+ *
+ * The following example demonstrates how to use the %Addressbook class to retrieve the contacts associated with each category.
+ * @code
+ *
+       #include <FSocial.h>
+
+       using namespace Tizen::Base;
+       using namespace Tizen::Base::Collection;
+       using namespace Tizen::Social;
+
+       void
+       AddressbookExample::GetContactsExample(void)
+       {
+               result r = E_SUCCESS;
+
+               // Get default addressbook instance
+               Addressbook* pAddressbook = AddressbookManager::GetInstance()->GetAddressbookN();
+
+               // Gets all the categories.
+               IList* pCategoryList = pAddressbook->GetAllCategoriesN();
+               if (pCategoryList == null)
+               {
+                       delete pAddressbook;
+                       return;
+               }
+
+               Category* pCategory = null;
+               Contact* pContact = null;
+               IList* pContactList = null;
+               IEnumerator* pContactEnum = null;
+               String firstName;
+               String lastName;
+               IEnumerator* pCategoryEnum = pCategoryList->GetEnumeratorN();
+               while (pCategoryEnum->MoveNext() == E_SUCCESS)
+               {
+                       pCategory = static_cast<Category*>(pCategoryEnum->GetCurrent());
+
+                       // Gets all the contacts of each category.
+                       pContactList = pAddressbook->GetContactsByCategoryN(pCategory->GetRecordId());
+                       if (pContactList == null)
+                       {
+                               continue;
+                       }
+
+                       pContactEnum = pContactList->GetEnumeratorN();
+                       while (pContactEnum->MoveNext() == E_SUCCESS)
+                       {
+                               pContact = static_cast<Contact*>(pContactEnum->GetCurrent());
+
+                               //Gets the name.
+                               pContact->GetValue(CONTACT_PROPERTY_ID_FIRST_NAME, firstName);
+                               pContact->GetValue(CONTACT_PROPERTY_ID_LAST_NAME, lastName);
+
+                               // Displays the first name and last name.
+                               // ...
+                       }
+                       delete pContactEnum;
+                       pContactList->RemoveAll(true);
+                       delete pContactList;
+               }
+
+               delete pCategoryEnum;
+               pCategoryList->RemoveAll(true);
+               delete pCategoryList;
+
+               delete pAddressbook;
+       }
+
+ *
+ * @endcode
+ *
+ * The following example demonstrates how to use the %Addressbook class to search for a contact.
+ *
+ * @code
+ *
+       #include <FSocial.h>
+
+       using namespace Tizen::Base;
+       using namespace Tizen::Base::Collection;
+       using namespace Tizen::Social;
+
+       void
+       AddressbookExample::SearchExample(void)
+       {
+               result r = E_SUCCESS;
+
+               // Get default addressbook instance
+               Addressbook* pAddressbook = AddressbookManager::GetInstance()->GetAddressbookN();
+
+               //Searches contacts by name ("Anderson").
+               IList* pContactList = pAddressbook->SearchContactsByNameN(L"Anderson");
+               if (pContactList == null)
+               {
+                       delete pAddressbook;
+
+                       return;
+               }
+
+               Contact* pContact = null;
+               String firstName;
+               String lastName;
+               IEnumerator* pContactEnum = pContactList->GetEnumeratorN();
+               while (pContactEnum->MoveNext() == E_SUCCESS)
+               {
+                       pContact = static_cast<Contact*>(pContactEnum->GetCurrent());
+
+                       //Gets the contact's name.
+                       pContact->GetValue(CONTACT_PROPERTY_ID_FIRST_NAME, firstName);
+                       pContact->GetValue(CONTACT_PROPERTY_ID_LAST_NAME, lastName);
+
+                       // Displays the first name and last name.
+                       // ...
+               }
+
+               delete pContactEnum;
+               pContactList->RemoveAll(true);
+               delete pContactList;
+
+               delete pAddressbook;
+       }
+ *
+ * @endcode
+ */
+class _OSP_EXPORT_ Addressbook
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        *
+        * The object is not fully constructed after this constructor is called. @n
+        * An application must use AddressbookManager::GetAddressbookN() to get a fully constructed %Addressbook instance.
+        *
+        * @since       2.0
+        *
+        * @see AddressbookManager::GetAddressbookN()
+        *
+        * The following example demonstrates how to create an %Addressbook instance.
+        * @code
+        * result
+        * MyApplication::UpdateContact(Contact* pContact)
+        * {
+        *    Addressbook* pAddressbook = AddressbookManager::GetInstance()->GetAddressbookN();
+        *
+        *    result r = pAddressbook->UpdateContact(*pContact);
+        *
+        *    delete pAddressbook;
+        *
+        *    return r;
+        * }
+        * @endcode
+        */
+       Addressbook(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~Addressbook(void);
+
+       /**
+        * @if OSPDEPREC
+        * Initializes this instance of %Addressbook with a specified listener.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated This method and IRecordEventListener are deprecated. Instead of using this method, use AddressbookManager::GetAddressbookN() and SetEventListener().
+        *
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param[in]   pListener               The event listener to register
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @endif
+        */
+       result Construct(IRecordEventListener* pListener = null);
+
+       /**
+        * Sets the addressbook change event listener. @n
+        * The listener is called when a contact or a category has been changed.
+        * To reset the event listener, @c null must be passed.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated This method and IAddressbookEventListener are deprecated. Instead of using this method, use SetAddressbookChangeEventListener()
+        * and IAddressbookChangeEventListener.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              An error code
+        * @param[in]   pListener                               The event listener
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       result SetEventListener(IAddressbookEventListener* pListener);
+
+       /**
+        * Sets the addressbook change event listener. @n
+        * The listener is called when a contact or a category has been changed.
+        * To reset the event listener, @c null must be passed.
+        *
+        * @since       2.1
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return      An error code
+        * @param[in]   pListener                       The event listener
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error
+        */
+       result SetAddressbookChangeEventListener(IAddressbookChangeEventListener* pListener);
+
+       /**
+        * Adds a contact to the address book. @n
+        * At least one property of the contact must be set. @n
+        * If the contact has been added successfully, a contact ID is assigned to it.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An error code
+        * @param[in,out]       contact                 The contact to add
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTEDThe user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           Either of the following conditions has occurred:
+        *                                                                      - The contact ID is not #INVALID_RECORD_ID.
+        *                                                                      - The properties of the specified @c contact have not been set.
+        * @exception   E_STORAGE_FULL          The storage is insufficient.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks   The #CONTACT_PROPERTY_ID_DISPLAY_NAME and #CONTACT_PROPERTY_ID_LAST_REVISION properties cannot be set.
+        * @n @c CONTACT_PROPERTY_ID_DISPLAY_NAME is automatically generated from the first name and last name.
+        * And @c CONTACT_PROPERTY_ID_LAST_REVISION is automatically updated with the last update time.
+        */
+       result AddContact(Contact& contact);
+
+       /**
+        * Removes a contact from the address book. @n
+        * After this operation is done successfully, the ID of the Contact instance is #INVALID_RECORD_ID.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An error code
+        * @param[in,out]       contact                         The contact to remove
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   The specified @c contact is invalid.
+        * @exception   E_OBJ_NOT_FOUND         The specified @c contact does not exist.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       result RemoveContact(Contact& contact);
+
+       /**
+        * Removes a contact from the address book.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An error code
+        * @param[in]   contactId                               The contact ID
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   The specified @c contactId is invalid.
+        * @exception   E_OBJ_NOT_FOUND         The specified @c contactId does not exist.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       result RemoveContact(RecordId contactId);
+
+       /**
+        * Updates a specified contact. @n
+        * At least one property of the contact must be set.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An error code
+        * @param[in]   contact                                 The contact to update
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_OBJ_NOT_FOUND         The specified @c contact does not exist in this address book.
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The specified @c contact is invalid.
+        *                                                                              - The properties of the specified @c contact have not been set.
+        * @exception   E_STORAGE_FULL          The storage is insufficient.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        */
+       result UpdateContact(const Contact& contact);
+
+       /**
+        * Adds a category to the address book. @n
+        * If the category has been added successfully, a category ID is assigned to it.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility            This method has compatibility issues with OSP compatible applications. @n
+        *                               For more information, see @ref CompAddressbookAddCategoryPage "here".
+        * @endif
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An error code
+        * @param[in,out]       category                        The category to add
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The name of the specified @c category has not been set.
+        *                                                                              - The category ID of the specified @c category is not #INVALID_RECORD_ID.
+        *                                                                              - One of the contact members is invalid.
+        * @exception   E_STORAGE_FULL                  The storage is insufficient.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       result AddCategory(Category& category);
+
+       /**
+        * @if OSPCOMPAT
+         * @page                CompAddressbookAddCategoryPage         Compatibility for AddCategory()
+         * @section             CompAddressbookAddCategoryPageIssueSection             Issues
+        * Implementing this method in OSP compatible applications has the following issue: @n
+         * -# If there already exists a category which has the same name, @c E_OBJ_ALREADY_EXIST is returned.
+         *
+         * @section             CompAddressbookAddCategoryPageSolutionSection          Resolutions
+        * The issue mentioned above has been resolved in Tizen.
+        * @endif
+        */
+
+
+       /**
+        * Removes a category from the address book. @n
+        * If the category has been deleted successfully, the record ID of this instance is #INVALID_RECORD_ID.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An error code
+        * @param[in,out]       category                The category to remove
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTEDThe user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c category is invalid or a default category.
+        * @exception   E_OBJ_NOT_FOUND         The specified @c category does not exist in this address book.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @see         Category::IsDefault()
+        */
+       result RemoveCategory(Category& category);
+
+       /**
+        * Removes a category from the address book.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An error code
+        * @param[in]   categoryId                              The category ID
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The specified @c categoryId is invalid.
+        *                                                                              - The category specified by the @c categoryId is a default category.
+        * @exception   E_OBJ_NOT_FOUND         The specified @c categoryId does not exist in this address book.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @see         Category::IsDefault()
+        */
+       result RemoveCategory(RecordId categoryId);
+
+       /**
+        * Updates a category in the address book.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility            This method has compatibility issues with OSP compatible applications. @n
+        *                            For more information, see @ref CompAddressbookUpdateCategoryPage "here".
+        * @endif
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An error code
+        * @param[in]   category                                The category to update
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_OBJ_NOT_FOUND         The specified @c category does not exist in this address book.
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The specified @c category is invalid.
+        *                                                                              - One of the contact members is invalid.
+        * @exception   E_STORAGE_FULL          The storage is insufficient.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        */
+       result UpdateCategory(const Category& category);
+
+       /**
+        * @if OSPCOMPAT
+        * @page                CompAddressbookUpdateCategoryPage         Compatibility for UpdateCategory()
+        * @section             CompAddressbookUpdateCategoryPageIssueSection             Issues
+        * Implementing this method in OSP compatible applications has the following issue: @n
+        * -# If there already exists a category which has the same name, @c E_OBJ_ALREADY_EXIST is returned.
+        *
+        * @section             CompAddressbookAddCategoryPageSolutionSection          Resolutions
+        * The issue mentioned above has been resolved in Tizen.
+        * @endif
+        */
+
+
+       /**
+        * Gets all contacts in the addressbook. @n
+        * The contacts are ordered by display name.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The list of contacts in the addressbook, @n
+        *                              else an empty list if there is no contact, or @c null if an exception occurs (@ref Contact list)
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks
+        *                              - The specific error code can be accessed using the GetLastResult() method.
+        *                              - There is a high probability for an occurrence of an out-of-memory exception.
+        *                              If possible, check whether the exception is @c E_OUT_OF_MEMORY or not. @n
+        *                              For more information on how to handle the out-of-memory exception, refer
+        *                              <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        */
+       Tizen::Base::Collection::IList* GetAllContactsN(void) const;
+
+       /**
+        * Gets the member contacts of the specified category. @n
+        * If the specified @c category is ::INVALID_RECORD_ID, this method returns the list of contacts that are not members of any category.
+        * The contacts are ordered by display name.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The list of contacts that are members of the specified category, @n
+        *                              else an empty list if there is no contact, or @c null if an exception occurs (@ref Contact list)
+        * @param[in]   categoryId                      The category ID
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTEDThe user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c categoryId is less than ::INVALID_RECORD_ID.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks
+        *                              - The specific error code can be accessed using the GetLastResult() method.
+        *                              - There is a high probability for an occurrence of an out-of-memory exception.
+        *                              If possible, check whether the exception is @c E_OUT_OF_MEMORY or not. @n
+        *                              For more information on how to handle the out-of-memory exception, refer
+        *                              <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        */
+       Tizen::Base::Collection::IList* GetContactsByCategoryN(RecordId categoryId) const;
+
+       /**
+        * Gets contacts in the specified range in the address book. @n
+        * The contacts are ordered by display name.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The list of contacts in the specified range, @n
+        *                              else an empty list if there is no contact, or @c null if an exception occurs (@ref Contact list)
+        * @param[in]   pageNo                           The page number of the result list @n
+        *                                                                       It starts from @c 1.
+        * @param[in]   countPerPage             The maximum count of the result items on a page
+        * @exception   E_SUCCESS                        The method is successful.
+        * @exception   E_PRIVILEGE_DENIED       The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_OUT_OF_RANGE           The specified @c pageNo or @c countPerPage is less than @c 1.
+        * @exception   E_INVALID_ARG            A specified input parameter is invalid.
+        * @exception   E_SYSTEM                         The method cannot proceed due to a severe system error.
+        * @remarks
+        *                              - The specific error code can be accessed using the GetLastResult() method.
+        *                              - There is a high probability for an occurrence of an out-of-memory exception.
+        *                              If possible, check whether the exception is @c E_OUT_OF_MEMORY or not. @n
+        *                              For more information on how to handle the out-of-memory exception, refer
+        *                              <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+
+        */
+       Tizen::Base::Collection::IList* GetContactsN(int pageNo, int countPerPage) const;
+
+       /**
+        * Gets contacts that are in the specified range of the specified category. @n
+        * The contacts are ordered by display name.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The list of contacts in the specified range of the specified category, @n
+        *                              else an empty list if there is no contact, or @c null if an exception occurs (@ref Contact list)
+        * @param[in]   category                         The category
+        * @param[in]   pageNo                           The page number of the result list, which starts from @c 1
+        * @param[in]   countPerPage             The maximum count of the result items on a page
+        * @exception   E_SUCCESS                        The method is successful.
+        * @exception   E_PRIVILEGE_DENIED       The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_OUT_OF_RANGE           The specified @c pageNo or @c countPerPage is less than @c 1.
+        * @exception   E_INVALID_ARG            Either of the following conditions has occurred:
+        *                                                                       - The specified @c category is invalid.
+        *                                                                       - One of the contact members is invalid.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @remarks
+        *                              - The specific error code can be accessed using the GetLastResult() method.
+        *                              - There is a high probability for an occurrence of an out-of-memory exception.
+        *                              If possible, check whether the exception is @c E_OUT_OF_MEMORY or not. @n
+        *                              For more information on how to handle the out-of-memory exception, refer
+        *                              <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        */
+       Tizen::Base::Collection::IList* GetContactsInN(const Category& category, int pageNo, int countPerPage) const;
+
+       /**
+        * Gets the contact with the specified contact ID.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The matched contact, @n
+        *                              else @c null if no contact matches the specified contact ID
+        * @param[in]   contactId                       The contact ID
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c contactId is invalid.
+        * @exception   E_OBJ_NOT_FOUND         The specified @c contactId is not found.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Contact* GetContactN(RecordId contactId) const;
+
+       /**
+        * Gets the number of contacts in the address book.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The number of contacts in the address book, @n
+        *                              else @c -1 if an error occurs
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       int GetContactCount(void) const;
+
+       /**
+        * Adds the specified contact to the specified category.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An error code
+        * @param [in]  categoryId              The category ID
+        * @param [in]  contactId               The contact ID
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           Either of the following conditions has occurred:
+        *                                                                      - The specified contact or category does not exist.
+        *                                                                      - The specified contact and category are not in this addressbook.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @remarks If the contact is already a member of the category, this method does nothing.
+        */
+       result AddMemberToCategory(RecordId categoryId, RecordId contactId);
+
+       /**
+        * Removes the specified contact from the specified category.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An error code
+        * @param [in]  categoryId                      The category ID
+        * @param [in]  contactId                       The contact ID
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           Either of the following conditions has occurred:
+        *                                                                      - The specified contact or category does not exist.
+        *                                                                      - The specified contact and category are not in this addressbook.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @remarks If the contact is not a member of the category, this method does nothing.
+        */
+       result RemoveMemberFromCategory(RecordId categoryId, RecordId contactId);
+
+       /**
+        * Gets all the categories in the address book. @n
+        * The categories are ordered by name.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The list of categories in the address book, @n
+        *                              else an empty list if there is no category, or @c null if an exception occurs (@ref Category list)
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetAllCategoriesN(void) const;
+
+       /**
+        * Gets all the categories whose member is the specified contact. @n
+        * The categories are ordered by name.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The list of categories that have the specified contact as a member, @n
+        *                              else an empty list if there is no category, or @c null if an exception occurs (@ref Category list)
+        * @param[in] contactId         The contact ID
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c contactId is invalid.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetCategoriesByContactN(RecordId contactId) const;
+
+       /**
+        * Gets the number of categories in the address book.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The number of categories in the address book, @n
+        *                              else @c -1 if an error occurs
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       int GetCategoryCount(void) const;
+
+       /**
+        * Gets the category with the specified category ID.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The matched category, @n
+        *                              else @c null if no category matches the specified category ID
+        * @param[in]   categoryId              The category ID
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c categoryId is invalid.
+        * @exception   E_OBJ_NOT_FOUND         The specified record is not found.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Category* GetCategoryN(RecordId categoryId) const;
+
+       /**
+        * Searches the contacts whose email address contains the specified @c email string. @n
+        * The search operation is performed with a case insensitive key (param: @c email). @n
+        * The contacts are ordered by display name.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The list of all the matched contacts, @n
+        *                              else an empty list if there is no matched contact, or @c null if an exception occurs (@ref Contact list)
+        * @param[in]   email                                   The substring of the email to search
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   The specified @c email is an empty string.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks
+        *                      - The specific error code can be accessed using the GetLastResult() method.
+        *                      - There is a high probability for an occurrence of an out-of-memory exception. @n 
+        *                      If possible, check whether the exception is @c E_OUT_OF_MEMORY or not. @n 
+        *                      For more information on how to handle the out-of-memory exception, refer  
+        *                      <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        */
+       Tizen::Base::Collection::IList* SearchContactsByEmailN(const Tizen::Base::String& email) const;
+
+       /**
+        * Searches the contacts that have the specified @c name as a substring of their display name. @n
+        * The search operation is performed with a case insensitive key (param: @c name). @n
+        * The contacts are ordered by display name.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The list of all the matched contacts, @n
+        *                              else an empty list if there is no matched contact, or @c null if an exception occurs (@ref Contact list)
+        * @param[in]   name                            The substring of the name to search
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c name is an empty string.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @remarks
+        *              - The specific error code can be accessed using the GetLastResult() method.
+        *              - There is a high probability for an occurrence of an out-of-memory exception.@n If possible, check whether the exception is @c E_OUT_OF_MEMORY or not.@n
+        *                For more information on how to handle the out-of-memory exception, refer  
+        *                <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        */
+       Tizen::Base::Collection::IList* SearchContactsByNameN(const Tizen::Base::String& name) const;
+
+       /**
+        * Searches the contacts that have the specified @c phoneNumber string as a substring of one of their phone numbers. @n
+        * The %SearchContactsByPhoneNumberN() method returns the contacts whose phone number matches the value of the specified @c phoneNumber. @n
+        * The search operation is performed with a case insensitive key (param: @c phoneNumber). @n
+        * The contacts are ordered by display name.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The list of all the matched contacts, @n
+        *                              else an empty list if there is no contact, or @c null if an exception occurs (@ref Contact list)
+        * @param[in]   phoneNumber                     The substring of the phone number to search
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c phoneNumber is an empty string.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @remarks
+        *              - The specific error code can be accessed using the GetLastResult() method.
+        *              - There is a high probability for an occurrence of an out-of-memory exception. @n If possible, check whether the exception is @c E_OUT_OF_MEMORY or not. @n 
+        *                For more information on how to handle the out-of-memory exception, refer  
+        *                <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        */
+       Tizen::Base::Collection::IList* SearchContactsByPhoneNumberN(const Tizen::Base::String& phoneNumber) const;
+
+       /**
+        * Gets the latest change version of the address book.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The latest change version, @n
+        *                              else @c -1 if an exception occurs
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @see GetChangedContactsAfterN()
+        * @see GetChangedCategoriesAfterN()
+        */
+       int GetLatestVersion(void) const;
+
+       /**
+        * Gets the change information of the contacts that have been changed after the specified change version. @n
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated This method is deprecated. Instead of using this method, use GetChangedContactInfoListN().
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The list of contact change information, @n
+        *                              else an empty list if there is no changed contact, or @c null if an exception occurs (@ref ContactChangeInfo list)
+        * @param[in]   version                 The change version
+        * @param[out]  latestVersion   The latest change version among the changed contacts
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c version is invalid.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @see GetLatestVersion()
+        *
+        * The following example demonstrates how to use the %GetChangedContactsAfterN() method.
+        * @code
+        * void
+        * MyApplication::GetChangedContacts(void)
+        * {
+        *    IList* pChangedContacts = __pAddressbook->GetChangedContactsAfterN(__version, __version);
+        *
+        *    IEnumerator* pEnum = pChangedContacts->GetEnumeratorN();
+        *    while (pEnum->MoveNext() == E_SUCCESS)
+        *    {
+        *      ContactChangeInfo* pInfo = (ContactChangeInfo*) pEnum->GetCurrent();
+        *
+        *      AppLog("Contact changed: type(%d), id(%d), version(%d)", pInfo->GetChangeType(), pInfo->GetContctId(), pInfo->GetVersion());
+        *    }
+        *    delete pEnum;
+        *    pChangedContacts->RemoveAll(true);
+        *    delete pChangedContacts;
+        * }
+        * @endcode
+        */
+       Tizen::Base::Collection::IList* GetChangedContactsAfterN(int version, int& latestVersion) const;
+
+       /**
+        * Gets the change information of the contacts that have been changed after the specified change version.
+        *
+        * @since       2.1
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return      The list of contact change information, @n
+        *              else an empty list if there is no changed contact or @c null if an exception occurs (@ref ContactChangeInfo list)
+        * @param[in]   version                 The change version
+        * @param[out]  latestVersion                   The latest change version among the changed contacts
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+        * @exception   E_INVALID_ARG           The specified @c version is invalid.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error
+        * @remarks                                             The specific error code can be accessed using the GetLastResult() method.
+        * @see GetLatestVersion()
+        *
+        * The following example demonstrates how to use the %GetChangedContactInfoListN() method.
+        * @code
+        * void
+        * MyApplication::GetChangedContacts(void)
+        * {
+        *    IList* pChangedContacts = __pAddressbook->GetChangedContactInfoListN (__version, __version);
+        *
+        *    IEnumerator* pEnum = pChangedContacts->GetEnumeratorN();
+        *    while (pEnum->MoveNext() == E_SUCCESS)
+        *    {
+        *      ContactChangeInfo* pInfo = (ContactChangeInfo*) pEnum->GetCurrent();
+        *
+        *      AppLog("Contact changed: type(%d), id(%d), version(%d)", pInfo->GetChangeType(), pInfo->GetContctId(), pInfo->GetVersion());
+        *    }
+        *    delete pEnum;
+        *    pChangedContacts->RemoveAll(true);
+        *    delete pChangedContacts;
+        * }
+        * @endcode
+        */
+       Tizen::Base::Collection::IList* GetChangedContactInfoListN(int version, int& latestVersion) const;
+
+       /**
+        * Gets the change information of the categories that have been changed after the specified version.
+        *
+       * @brief <i> [Deprecated] </i>
+       * @deprecated This method is deprecated. Instead of using this method, use GetChangedCategoryInfoListN().
+       *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The list of category change information, @n
+        *                              else an empty list if there is no changed category, or @c null if an exception occurs (@ref CategoryChangeInfo list)
+        *              
+        * @param[in]   version                 The change version
+        * @param[out]  latestVersion   The latest change version among the changed categories
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c version is invalid.
+       * @exception    E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+       * @see GetLatestVersion()
+       *
+       * The following example demonstrates how to use the %GetChangedCategoriesAfterN() method.
+       * @code
+       * void
+       * MyApplication::GetChangedCategories(void)
+       * {
+       *    IList* pChangedCategories = __pAddressbook->GetChangedCategoriesAfterN(__version, __version);
+       *
+       *    IEnumerator* pEnum = pChangedCategories->GetEnumeratorN();
+       *    while (pEnum->MoveNext() == E_SUCCESS)
+       *    {
+       *      CategoryChangeInfo* pInfo = (CategoryChangeInfo*) pEnum->GetCurrent();
+       *
+       *      AppLog("Category changed: type(%d), id(%d), version(%d)", pInfo->GetChangeType(), pInfo->GetCategoryId(), pInfo->GetVersion());
+       *    }
+       *    delete pEnum;
+       *    pChangedCategories->RemoveAll(true);
+       *    delete pChangedCategories;
+       * }
+       * @endcode
+       */
+       Tizen::Base::Collection::IList* GetChangedCategoriesAfterN(int version, int& latestVersion) const;
+
+       /**
+        * Gets the change information of the categories that have been changed after the specified version.
+        *
+        * @since       2.1
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return      The list of category change information, @n
+        *              else an empty list if there is no changed category or @c null if an exception occurs (@ref CategoryChangeInfo list)
+        *
+        * @param[in]   version                 The change version
+        * @param[out]  latestVersion           The latest change version among the changed categories
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+        * @exception   E_INVALID_ARG           The specified @c version is invalid.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @see GetLatestVersion()
+        *
+        * The following example demonstrates how to use the %GetChangedCategoryInfoListN() method.
+        * @code
+        * void
+        * MyApplication::GetChangedCategories(void)
+        * {
+        *    IList* pChangedCategories = __pAddressbook->GetChangedCategoryInfoN(__version, __version);
+        *
+        *    IEnumerator* pEnum = pChangedCategories->GetEnumeratorN();
+        *    while (pEnum->MoveNext() == E_SUCCESS)
+        *    {
+        *      CategoryChangeInfo* pInfo = (CategoryChangeInfo*) pEnum->GetCurrent();
+        *
+        *      AppLog("Category changed: type(%d), id(%d), version(%d)", pInfo->GetChangeType(), pInfo->GetCategoryId(), pInfo->GetVersion());
+        *    }
+        *    delete pEnum;
+        *    pChangedCategories->RemoveAll(true);
+        *    delete pChangedCategories;
+        * }
+        * @endcode
+        */
+       Tizen::Base::Collection::IList* GetChangedCategoryInfoListN(int version, int& latestVersion) const;
+
+       /**
+        * Sets the user profile of this addressbook. @n
+        * If the user profile exists, remove the existing user profile and add a new user profile. @n
+        * To update the user profile, get the existing user profile and modify the user profile and set the modified user profile. @n
+        * To remove the user profile, @c null must be passed.
+        *
+        * @since                       2.1
+        * @privlevel           public
+        * @privilege           %http://tizen.org/privilege/userprofile.write
+        *
+        * @return              An error code
+        * @param[in]           pUserProfile    The user profile to set
+        * @exception   E_SUCCESS       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+        * @exception   E_SYSTEM        The method cannot proceed due to a severe system error.
+        */
+       result SetUserProfile(const UserProfile* pUserProfile);
+
+       /**
+        * Gets the user profile of this addressbook.
+        *
+        * @since                       2.1
+        * @privlevel           public
+        * @privilege           %http://tizen.org/privilege/userprofile.read
+        *
+        * @return              The user profile, @n
+        *                              else @c null if the user profile does not exist, or if an exception occurs
+        * @exception   E_SUCCESS       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+        * @exception   E_SYSTEM        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       UserProfile* GetUserProfileN(void) const;
+
+       /**
+        * Checks whether the user profile of this address book has been changed after the specified version or not.
+        * If the user profile does not exist, this method returns @c false.
+        *
+        * @since       2.1
+        * @privlevel           public
+        * @privilege   %http://tizen.org/privilege/userprofile.read
+        *
+        * @return     @c true if the user profile has been changed, @n
+        *              else @c false
+        * @param[in]   version                  The changed version
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED     The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+        * @exception   E_INVALID_ARG           The specified @c version is invalid.
+        * @exception   E_SYSTEM                 The method cannot proceed due to a severe system error.
+        * @remarks     The specific error code can be accessed using the GetLastResult() method.
+        * @see SetUserProfile()
+        */
+       bool IsUserProfileChangedAfter(int version) const;
+
+       /**
+        * Gets the addressbook name.
+        *
+        * @since       2.0
+        *
+        * @return              The addressbook name
+        */
+       Tizen::Base::String GetName(void) const;
+
+       /**
+        * Gets the addressbook ID.
+        *
+        * @since       2.0
+        *
+        * @return              The addressbook ID
+        */
+       AddressbookId GetId(void) const;
+
+       /**
+        * Gets the account ID associated with the addressbook.
+        *
+        * @since       2.0
+        *
+        * @return              The account ID
+        */
+       AccountId GetAccountId(void) const;
+
+       /**
+       * Adds the contacts to the addressbook.
+       *
+       * @since                2.1
+       * @privlevel    public
+       * @privilege    %http://tizen.org/privilege/contact.write
+       *
+       * @return               An error code
+       * @param[in]    contactList                             The contacts to add @n The list should contain the Contact instances.
+       * @param[out]   pContactIdList                  A pointer to the list of contact IDs that have been added successfully @n Pass @c null if the contact IDs are not necessary.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @exception    E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+       * @exception    E_INVALID_ARG                   Either of the following conditions has occurred:
+       *                                                                               - The specified @c contactList is empty.
+       *                                                                               - The specified @c contactList contains an empty contact.
+       *                                                                               - The specified @c contactList contains a contact whose ID is not ::INVALID_RECORD_ID.
+       * @exception    E_SYSTEM                                The method cannot proceed due to a severe system error.
+       * @remarks              
+       *                               - If an exception occurs during adding contacts, the changes are getting rollbacked. @n
+       *                               This method blocks the execution of the calling thread until all contacts in the list has been added to the addressbook or if an exception occurs.
+       *                               - It is recommended to call this method on any thread other than the main thread.
+       */
+       result AddContacts(const Tizen::Base::Collection::IList& contactList, Tizen::Base::Collection::IListT<RecordId>* pContactIdList = null);
+
+       /**
+       * Updates the contacts.
+       *
+       * @since                2.1
+       * @privlevel    public
+       * @privilege    %http://tizen.org/privilege/contact.write
+       *
+       * @return               An error code
+       * @param[in]    contactList                             The contacts to update @n The list should contain the Contact instances.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @exception    E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+       * @exception    E_INVALID_ARG                   Either of the following conditions has occurred:
+       *                                                                               - The specified @c contactList is empty.
+       *                                                                               - The specified @c contactList contains an empty contact.
+       *                                                                               - The specified @c contactList contains a contact whose ID is invalid.
+       * @exception    E_OBJ_NOT_FOUND                 The specified @c contact does not exist.
+       * @exception    E_SYSTEM                                The method cannot proceed due to a severe system error.
+       * @remarks              
+       *                               - If an exception occurs during updating contacts, the changes are getting rollbacked. @n
+       *                               This method blocks the execution of the calling thread until all contacts in the list has been updated or if an exception occurs.
+       *                               - It is recommended to call this method on any thread other than the main thread.
+       */
+       result UpdateContacts(const Tizen::Base::Collection::IList& contactList);
+
+       /**
+       * Removes the contacts. @n If the contact specified by a contact ID in the list does not exist, the contact ID is ignored.
+       *
+       * @since                2.1
+       * @privlevel    public
+       * @privilege    %http://tizen.org/privilege/contact.write
+       *
+       * @return               An error code
+       * @param[in]    contactIdList                   The list of contact IDs to delete
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @exception    E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+       * @exception    E_INVALID_ARG                   The specified @c contactIdList is empty or contains an invalid ID.
+       * @exception    E_SYSTEM                                The method cannot proceed due to a severe system error.
+       * @remarks              
+       *                               - If an exception occurs during removing contacts, the changes are getting rollbacked. @n
+       *                               This method blocks the execution of the calling thread until all contacts in the list has been removed or if an exception occurs.
+       *                               - It is recommended to call this method on any thread other than the main thread.
+       */
+       result RemoveContacts(const Tizen::Base::Collection::IListT<RecordId>& contactIdList);
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @since       2.0
+        */
+       Addressbook(const Addressbook& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @since       2.0
+        */
+       Addressbook& operator =(const Addressbook& rhs);
+
+private:
+       friend class _AddressbookImpl;
+       class _AddressbookImpl* __pAddressbookImpl;
+};     // Addressbook
+
+}}     // Tizen::Social
+
+#endif //_FSCL_ADDRESSBOOK_H_
diff --git a/inc/FSclAddressbookFilter.h b/inc/FSclAddressbookFilter.h
new file mode 100644 (file)
index 0000000..4601ddc
--- /dev/null
@@ -0,0 +1,266 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclAddressbookFilter.h
+ * @brief              This is the header file for the %AddressbookFilter class.
+ *
+ * This header file contains the declarations of the %AddressbookFilter class.
+ */
+#ifndef _FSCL_ADDRESSBOOK_FILTER_H_
+#define _FSCL_ADDRESSBOOK_FILTER_H_
+
+#include <FBaseTypes.h>
+#include <FBaseObject.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+class DateTime;
+}}
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @class          AddressbookFilter
+ * @brief          This class represents the condition for searching a specific item on an addressbook.
+ * 
+ * @since      2.0
+ *
+ * @final          This class is not intended for extension.
+ *
+ * The %AddressbookFilter class represents the condition for searching a specific item on an addressbook.
+ * The type of the filter decides which item is searched (such as addressbook, contacts, persons, categories). @n
+ * The filter can consist of multiple filtering expressions and conjunctive operators.
+ * A filtering expression consists of a filter property, comparison operator and value.
+ * The filter property must be an element of the enumerator that corresponds to the type of the filter. @n
+ * <table border=1>
+ * <tr>
+ *  <th> Filter type </th>
+ *  <th> Filter Property </th>
+ *  <th> Search result </th>
+ * </tr>
+ * <tr>
+ *  <td> AB_FI_TYPE_ADDRESSBOOK </td>
+ *  <td> AddressbookFilterProperty </td>
+ *  <td> A list of Addressbook </td>
+ * </tr>
+ * <tr>
+ *  <td> AB_FI_TYPE_PERSON </td>
+ *  <td> PersonFilterProperty </td>
+ *  <td> A list of Person </td>
+ * </tr>
+ * <tr>
+ *  <td> AB_FI_TYPE_CONTACT </td>
+ *  <td> ContactFilterProperty </td>
+ *  <td> A list of Contact </td>
+ * </tr>
+ * <tr>
+ *  <td> AB_FI_TYPE_CATEGORY </td>
+ *  <td> CategoryFilterProperty </td>
+ *  <td> A list of Category </td>
+ * </tr>
+ * <tr>
+ *  <td> AB_FI_TYPE_PHONE_CONTACT </td>
+ *  <td> PhoneContactFilterProperty </td>
+ *  <td> A list of PhoneNumberContact </td>
+ * </tr>
+ * <tr>
+ *  <td> AB_FI_TYPE_EMAIL_CONTACT </td>
+ *  <td> EmailContactFilterProperty </td>
+ *  <td> A list of EmailContact </td>
+ * </tr>
+ * </table>
+ *
+ * The following example demonstrates how to use the %AddressbookFilter class.
+ * @code
+  // Search condition: (addressbookId=0 OR addressbookId=1) AND (display name LIKE '%John%')
+  AddressbookFilter subFilter(AB_FI_TYPE_CONTACT);
+  subFilter.AppendInt(FI_CONJ_OP_NONE, CONTACT_FI_PR_ADDRESSBOOK_ID, FI_CMP_OP_EQUAL, 0);
+  subFilter.AppendInt(FI_CONJ_OP_OR, CONTACT_FI_PR_ADDRESSBOOK_ID, FI_CMP_OP_EQUAL, 1);
+  AddressbookFilter mainFilter(AB_FI_TYPE_CONTACT);
+  mainFilter.AppendFilter(FI_CONJ_OP_NONE, subFilter);
+  mainFilter.AppendString(FI_CONJ_OP_AND, CONTACT_FI_PR_DISPLAY_NAME, FI_STR_OP_CONTAIN, L"John");
+  AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance();
+  IList* pEventList = pAddressbookManager->SearchN(mainFilter, CONTACT_FI_PR_DISPLAY_NAME, SORT_ORDER_ASCENDING);
+
+ * @endcode
+ */
+class _OSP_EXPORT_ AddressbookFilter
+           : public Tizen::Base::Object
+{
+public:
+       /**
+        * Initializes an instance of %AddressbookFilter with the specified @c type.
+        *
+        * @since       2.0
+        *
+        * @param[in]    type       The type of the filter @n It decides the type of the item to search.
+        */
+       AddressbookFilter(AddressbookFilterType type);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~AddressbookFilter(void);
+
+       /**
+        * Checks whether the value of the specified instance is equal to the value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return        @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Tizen::Base::Object, @n
+        *                else @c false
+        * @param[in]    rhs                 An instance of Tizen::Base::Object to compare
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since       2.0
+        *
+        * @return        The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Appends the filtering expression for an integer value. @n
+        * Firstly, this method appends the conjunctive operator.
+        * Then, this method puts the filtering expression in parentheses and appends it. @n
+        * The filtering expression consists of the filter property, comparison operator, and value. 
+        * The specified @c filterProperty must be an element of the enumerator that corresponds to the type of this filter.
+        *
+        * @since       2.0
+        *
+        * @return    The error code
+        * @param[in]   conjunctiveOperator     The conjunctive operator to append the filtering expression @n 
+        *                                      If there is no filtering expression or the filter has been appended before, #FI_CONJ_OP_NONE must be used. Otherwise #FI_CONJ_OP_AND or #FI_CONJ_OP_OR can be used.
+        * @param[in]   filterProperty                  The filter property
+        * @param[in]   comparisonOperator      The comparison operator
+        * @param[in]   value                                   The integer value for comparison 
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG            Either of the following conditions has occurred:
+        *                                       - The specified @c filterProperty is not an element of the enumerator that corresponds to the type of this filter.
+        *                                       - The type of the specified @c filterProperty is not @c int.
+        *                                       - The specified @c conjuctiveOperator is invalid.
+        */
+       result AppendInt(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, int value);
+
+       /**
+        * Appends the filtering expression for a @c bool value. @n
+        * Firstly, this method appends the conjunctive operator.
+        * Then, this method puts the filtering expression in parentheses and appends it. @n
+        * The filtering expression consists of the filter property, comparison operator, and value. 
+        * The specified @c filterProperty must be an element of the enumerator that corresponds to the type of this filter.
+        *
+        * @since       2.0
+        *
+        * @return      The error code
+        * @param[in]   conjunctiveOperator     The conjunctive operator to append the filtering expression @n
+        *                                      If there is no filtering expression or the filter has been appended before, #FI_CONJ_OP_NONE must be used. Otherwise #FI_CONJ_OP_AND or #FI_CONJ_OP_OR can be used.
+        * @param[in]   filterProperty                  The filter property
+        * @param[in]   comparisonOperator      The comparison operator #FI_CMP_OP_EQUAL is only permitted
+        * @param[in]   value                                   The @c bool value for comparison 
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           Either of the following conditions has occurred:
+        *                                                                              - The specified @c filterProperty is not an element of the enumerator that corresponds to the type of this filter.
+        *                                                                              - The type of the specified @c filterProperty is not @c bool.
+        *                                                                              - The specified @c comparisonOperator is not #FI_CMP_OP_EQUAL.
+        *                                                                              - The specified @c conjuctiveOperator is invalid.
+        * @remarks  If the filtering expression is appended firstly, the @c conjunctiveOperator is ignored.
+        */
+       result AppendBool(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, bool value);
+
+       /**
+        * Appends the filtering expression for a Tizen::Base::String value. @n
+        * Firstly, this method appends the conjunctive operator.
+        * Then, this method puts the filtering expression in parentheses and appends it. @n
+        * The filtering expression consists of the filter property, comparison operator, and value. 
+        * The specified @c filterProperty must be an element of the enumerator that corresponds to the type of this filter.
+        *
+        * @since       2.0
+        *
+        * @return      The error code
+        * @param[in]   conjunctiveOperator     The conjunctive operator to append the filtering expression @n
+        *                                      If there is no filtering expression or the filter has been appended before, #FI_CONJ_OP_NONE must be used. Otherwise #FI_CONJ_OP_AND or #FI_CONJ_OP_OR can be used.
+        * @param[in]   filterProperty                  The filter property
+        * @param[in]   comparisonOperator      The comparison operator
+        * @param[in]   value                                   The Tizen::Base::String value for matching 
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           Either of the following conditions has occurred:
+        *                                                              - The specified @c filterProperty is not an element of the enumerator that corresponds to the type of this filter.
+        *                                                              - The type of the specified @c filterProperty is not Tizen::Base::String.
+        *                                                              - The specified @c conjuctiveOperator is invalid.
+        */
+       result AppendString(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterStringOperator comparisonOperator, const Tizen::Base::String& value);
+
+       /**
+        * Appends the filter. @n
+        * Firstly, this method appends the conjunctive operator.
+        * Then, this method puts the filtering expressions of the specified filter in parentheses and appends it. @n
+        * The type of the specified @c filter must be same as the type of this filter.
+        *
+        * @since       2.0
+        *
+        * @return      The error code
+        * @param[in]   conjunctiveOperator     The conjunctive operator to append the filtering expression @n 
+        *                                      If there is no filtering expression or the filter has been appended before, #FI_CONJ_OP_NONE must be used. Otherwise #FI_CONJ_OP_AND or #FI_CONJ_OP_OR can be used.
+        * @param[in]   filter                                  The filter to append
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           Either of the following conditions has occurred:
+        *                                      - The type of the specified @c filter is not same as the type of this filter.
+        *                                      - The specified @c filter is empty.
+        *                                      - The specified @c conjuctiveOperator is invalid.
+        */
+       result AppendFilter(FilterConjunctiveOperator conjunctiveOperator, const AddressbookFilter& filter);
+
+private:
+       /*
+        * This default constructor is intentionally declared as private so that only the platform can create an instance.
+        *
+        * @since       2.0
+        */
+       AddressbookFilter(void);
+
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @since       2.0
+        */
+       AddressbookFilter(const AddressbookFilter& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @since       2.0
+        */
+       AddressbookFilter & operator =(const AddressbookFilter & rhs);
+
+private:
+           friend class _AddressbookFilterImpl;
+           class _AddressbookFilterImpl* __pAddressbookFilterImpl;
+};         // AddressbookFilter
+
+}} // Tizen::Social
+
+#endif // _FSCL_ADDRESSBOOK_FILTER_H_
diff --git a/inc/FSclAddressbookManager.h b/inc/FSclAddressbookManager.h
new file mode 100644 (file)
index 0000000..7c4cbc9
--- /dev/null
@@ -0,0 +1,1404 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FSclAddressbookManager.h
+ * @brief      This is the header file for the %AddressbookManager class.
+ *
+ * This header file contains the declarations of the %AddressbookManager class.
+ */
+#ifndef _FSCL_ADDRESSBOOK_MANAGER_H_
+#define _FSCL_ADDRESSBOOK_MANAGER_H_
+
+#include <unique_ptr.h>
+#include <FBaseTypes.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FBaseByteBuffer.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Base
+{
+namespace Collection
+{
+class IList;
+template<class Type1> class IListT;
+}
+}}
+
+namespace Tizen { namespace Social
+{
+class Category;
+class Contact;
+class Person;
+class UserProfile;
+class Addressbook;
+class AddressbookFilter;
+class IAddressbookEventListener;
+class IAddressbookChangeEventListener;
+
+/**
+ * @class      AddressbookManager
+ * @brief      This class manages addressbooks and contacts in the device storage.
+ *
+ * @since      2.0
+ *
+ * @final      This class is not intended for extension.
+ *
+ * The %AddressbookManager class provides methods for managing addressbooks and contacts in the device storage.
+ */
+class _OSP_EXPORT_ AddressbookManager
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * Creates an addressbook with the specified account ID and name. @n
+        * The accountId must specify a valid account and only one addressbook can be created per account. @n
+        * The name of the addressbook must be specified and the name must be unique among existing addressbooks on the device.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An addressbook instance
+        * @param[in]   accountId       The account ID
+        * @param[in]   name            The addressbook name
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG       Either of the following conditions has occurred:
+        *                                                                      - The specified @c accountId is invalid.
+        *                                                                      - The specified @c name is an empty string.
+        * @exception   E_OBJ_ALREADY_EXIST The addressbook with the specified @c accountId or @c name already exists.
+        * @exception   E_STORAGE_FULL          The storage is insufficient.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Addressbook* CreateAddressbookN(AccountId accountId, const Tizen::Base::String& name);
+
+       /**
+        * Deletes an addressbook. @n
+        * If the addressbook has been deleted successfully,
+        * the contacts and categories that belong to the addressbook are also deleted.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An error code
+        * @param[in]   addressbookId   The addressbook ID
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           Either of the following conditions has occurred:
+        *                                                                      - The specified @c addressbookId is invalid.
+        *                                                                      - The addressbook specified by the @c addressbookId is a default addressbook.
+        * @exception   E_OBJ_NOT_FOUND     The specified @c addressbookId does not exist.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        */
+       result DeleteAddressbook(AddressbookId addressbookId);
+
+       /**
+        * Gets the addressbooks associated with the specified account ID.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return      The list of addressbooks, @n
+        *                                  else an empty list if there is no addressbook, or @c null if an exception occurs (@ref Addressbook list)
+        * @param[in]   accountId       The account ID
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c accountId is invalid.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetAddressbooksByAccountN(AccountId accountId) const;
+
+       /**
+        * Gets the list of addressbooks.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return      The list of addressbooks, @n
+        *                                  else an empty list if there is no addressbook, or @c null if an exception occurs (@ref Addressbook list)
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+        Tizen::Base::Collection::IList* GetAllAddressbooksN(void) const;
+
+       /**
+        * Gets an instance of the addressbook specified by the addressbook ID.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return      An addressbook instance
+        * @param[in]   addressbookId           The addressbook ID
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c addressbookId is invalid.
+        * @exception   E_OBJ_NOT_FOUND     The specified @c addressbookId does not exist.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+        Addressbook* GetAddressbookN(AddressbookId addressbookId = DEFAULT_ADDRESSBOOK_ID) const;
+
+        /**
+         * Sets an addressbook change event listener. @n
+         * The listener is called when a contact or a category has been changed.
+         * To reset the event listener, @c null must be passed.
+         *
+         * @brief <i> [Deprecated] </i>
+         * @deprecated This method and IAddressbookEventListener are deprecated. Instead of using this method, use SetAddressbookChangeEventListener()
+         * and IAddressbookChangeEventListener.
+         *
+         * @since      2.0
+         * @privlevel  public
+         * @privilege  %http://tizen.org/privilege/contact.read
+         *
+         * @return     An error code
+         * @param[in]  pListener       The event listener
+         * @exception  E_SUCCESS               The method is successful.
+         * @exception  E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+         * @exception  E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+         * @exception  E_SYSTEM                The method cannot proceed due to a severe system error.
+         */
+        result SetEventListener(IAddressbookEventListener* pListener);
+
+       /**
+        * Sets an addressbook change event listener. @n
+        * The listener is called when a contact or a category has been changed.
+        * To reset the event listener, @c null must be passed.
+        *
+        * @since       2.1
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return      An error code
+        * @param[in]   pListener       The event listener
+        * @exception   E_SUCCESS       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error
+        */
+        result SetAddressbookChangeEventListener(IAddressbookChangeEventListener* pListener);
+
+       /**
+        * Adds a contact to the specified addressbook. @n
+        * At least one property of the contact must have been set. @n
+        * If the contact has been added successfully, a contact ID is assigned to it.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return              An error code
+        * @param[in,out]       contact         The contact to add
+        * @param[in]           addressbookId   The addressbook ID
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           Either of the following conditions has occurred:
+        *                                                                      - The contact ID is not #INVALID_RECORD_ID.
+        *                                                                      - The properties of the specified @c contact have not been set.
+        *                                                                      - The specified @c addressbookId is invalid.
+        * @exception   E_OBJ_NOT_FOUND         The specified addressbook is not found.
+        * @exception   E_STORAGE_FULL          The storage is insufficient.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @remarks     The #CONTACT_PROPERTY_ID_DISPLAY_NAME and #CONTACT_PROPERTY_ID_LAST_REVISION
+        * properties cannot be set. @n #CONTACT_PROPERTY_ID_DISPLAY_NAME is automatically generated from the first name and
+        * the last name. And #CONTACT_PROPERTY_ID_LAST_REVISION is automatically updated with the last update time.
+        */
+       result AddContact(Contact& contact, AddressbookId addressbookId);
+
+       /**
+        * Removes a contact.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An error code
+        * @param[in]   contactId               The contact ID
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c contactId is invalid.
+        * @exception   E_OBJ_NOT_FOUND     The specified @c contactId does not exist.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        */
+       result RemoveContact(RecordId contactId);
+
+       /**
+        * Updates the specified contact. @n
+        * At least one property of the contact must have been set.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An error code
+        * @param[in]   contact                 The contact to update
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_OBJ_NOT_FOUND     The specified @c contact does not exist in this address book.
+        * @exception   E_INVALID_ARG           Either of the following conditions has occurred:
+        *                                                                      - The specified @c contact is invalid.
+        *                                                                      - The properties of the specified @c contact have not been set.
+        * @exception   E_STORAGE_FULL          The storage is insufficient.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        */
+       result UpdateContact(const Contact& contact);
+
+       /**
+        * Adds a category to the specified addressbook. @n
+        * The name of the category must have been set. @n
+        * If the category has been added successfully, a category ID is assigned to it.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An error code
+        * @param[in,out]       category        The category to add
+        * @param[in]           addressbookId   The addressbook ID
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           Either of the following conditions has occurred:
+        *                                                                      - The name of the category has not been set.
+        *                                                                      - One of the member contacts is invalid.
+        *                                                                      - The category ID of the specified @c category is not #INVALID_RECORD_ID.
+        *                                                                      - The specified @c addressbookId is invalid.
+        * @exception   E_STORAGE_FULL          The storage is insufficient.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        */
+       result AddCategory(Category& category, AddressbookId addressbookId);
+
+       /**
+        * Removes a category.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An error code
+        * @param[in]   categoryId              The category ID
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           Either of the following conditions has occurred:
+        *                                                                      - The specified @c categoryId is invalid.
+        *                                                                      - The category specified by the @c categoryId is a default category.
+        * @exception   E_OBJ_NOT_FOUND     The specified @c categoryId does not exist in this address book.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @see Category::IsDefault()
+        */
+       result RemoveCategory(RecordId categoryId);
+
+       /**
+        * Updates a category.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An error code
+        * @param[in]   category                The category to update
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_OBJ_NOT_FOUND     The specified @c category does not exist in this address book.
+        * @exception   E_INVALID_ARG           Either of the following conditions has occurred:
+        *                                                                      - The specified @c category is invalid.
+        *                                                                      - One of the contact members is invalid.
+        * @exception   E_STORAGE_FULL          The storage is insufficient.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        */
+       result UpdateCategory(const Category& category);
+
+       /**
+        * Gets all the contacts on the device. @n
+        * The contacts are ordered by display name.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The list of contacts on the device, @n
+        *                               else an empty list if there is no contact, or @c null if an exception occurs (@ref Contact list)
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks
+        *              - The specific error code can be accessed using the GetLastResult() method.
+        *              - There is a high probability for an occurrence of an out-of-memory exception.
+        *              If possible, check whether the exception is @c E_OUT_OF_MEMORY or not. @n
+        *              For more information on how to handle the out-of-memory exception, refer
+        *              <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        */
+       Tizen::Base::Collection::IList* GetAllContactsN(void) const;
+
+       /**
+        * Gets the member contacts of the specified category. @n
+        * If the specified @c categoryId is ::INVALID_RECORD_ID, this method returns the list of contacts that are not a member of any category.
+        * The contacts are ordered by display name.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The list of contacts that are members of the specified category, @n
+        *                              else an empty list if there is no contact, or @c null if an exception occurs (@ref Contact list)
+        * @param[in]   categoryId              The category ID
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c categoryId is less than ::INVALID_RECORD_ID.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks
+        *              - The specific error code can be accessed using the GetLastResult() method.
+        *              - There is a high probability for an occurrence of an out-of-memory exception.
+        *              If possible, check whether the exception is @c E_OUT_OF_MEMORY or not. @n
+        *              For more information on how to handle the out-of-memory exception, refer
+        *              <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        */
+       Tizen::Base::Collection::IList* GetContactsByCategoryN(RecordId categoryId) const;
+
+       /**
+        * Gets the contacts linked to the person specified by the person ID.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return      The list of contacts that are linked to this person, @n
+        *              else @c null if an exception occurs (@ref Contact list)
+        * @param[in]   personId                The person ID
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c personId is invalid.
+        * @exception   E_SYSTEM      The method cannot proceed due to a severe system error.
+        * @remarks     The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetContactsByPersonN(PersonId personId) const;
+
+       /**
+        * Gets the categories whose member is the person specified by the person ID. @n
+        * A person is a member of a category if a contact linked to it is a member of the category.
+        * The categories are ordered by name.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return      The list of categories that has the specified person as a member, @n
+        *              else an empty list if there is no category, or @c null if an exception occurs (@ref Category list)
+        * @param[in]   personId                The person ID
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c personId is invalid.
+        * @exception   E_SYSTEM      The method cannot proceed due to a severe system error.
+        * @remarks     The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetCategoriesByPersonN(PersonId personId) const;
+
+       /**
+        * Gets the contact with the specified contact ID.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The matched contact, @n
+        *                              else @c null if no contact matches the specified contact ID
+        * @param[in]   contactId               The contact ID
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c contactId is invalid.
+        * @exception   E_OBJ_NOT_FOUND         The specified @c contactId is not found.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Contact* GetContactN(RecordId contactId) const;
+
+       /**
+        * Gets the number of contacts in all the addressbooks.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The number of contacts in the address book, @n
+        *                              else @c -1 if an error occurs
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       int GetContactCount(void) const;
+
+       /**
+        * Adds the specified contact to the specified category.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An error code
+        * @param [in]  categoryId              The category ID
+        * @param [in]  contactId               The contact ID
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           Either of the following conditions has occurred:
+        *                                                                      - The specified contact or category does not exist.
+        *                                                                      - The specified contact and category are not in the same addressbook.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks If the contact is already a member of the category, this method does nothing.
+        */
+       result AddMemberToCategory(RecordId categoryId, RecordId contactId);
+
+       /**
+        * Removes the specified contact from the specified category.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An error code
+        * @param [in]  categoryId              The category ID
+        * @param [in]  contactId               The contact ID
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified contact or category does not exist.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks If the contact is not a member of the category, this method does nothing.
+        */
+       result RemoveMemberFromCategory(RecordId categoryId, RecordId contactId);
+
+       /**
+        * Gets all the categories on the device. @n
+        * The categories are ordered by name.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The list of categories on the device, @n
+        *                              else an empty list if there is no category, or @c null if an exception occurs (@ref Category list)
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetAllCategoriesN(void) const;
+
+       /**
+        * Gets all the categories whose member is the specified contact. @n
+        * The categories are ordered by name.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The list of categories that has the specified contact as a member, @n
+        *                              else an empty list if there is no category, or @c null if an exception occurs (@ref Category list)
+        * @param[in] contactId         The contact ID
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c contactId is invalid.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetCategoriesByContactN(RecordId contactId) const;
+
+       /**
+        * Gets the number of categories on the device.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The number of categories on the device, @n
+        *                              else @c -1 if an error occurs
+        * @exception   E_SUCCESS                   The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM                    The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       int GetCategoryCount(void) const;
+
+       /**
+        * Gets the category with the specified category ID.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The matched category, @n
+        *                              else @c null if no category matches the specified category ID
+        * @param[in]   categoryId              The category ID
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c categoryId is invalid.
+        * @exception   E_OBJ_NOT_FOUND     The specified record is not found.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Category* GetCategoryN(RecordId categoryId) const;
+
+       /**
+        * Searches the contacts whose email address contains the specified @c email string. @n
+        * The search operation is performed with a case insensitive key (param: @c email). @n
+        * The contacts are ordered by display name.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return      The list of all matched contacts, @n
+        *                              else an empty list if there is no matched contact, or @c null if an exception occurs (@ref Contact list)
+        * @param[in]   email                   The substring of the email to search
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c email is an empty string.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks
+        *              - The specific error code can be accessed using the GetLastResult() method.
+        *              - There is a high probability for an occurrence of an out-of-memory exception.
+        *              If possible, check whether the exception is @c E_OUT_OF_MEMORY or not. @n
+        *              For more information on how to handle the out-of-memory exception, refer
+        *              <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        */
+       Tizen::Base::Collection::IList* SearchContactsByEmailN(const Tizen::Base::String& email) const;
+
+       /**
+        * Searches the contacts that have the specified @c name as a substring of their display name. @n
+        * The display name is a concatenation of the first name, space, and the last name. @n
+        * The search operation is performed with a case insensitive key (param: @c name). @n
+        * The contacts are ordered by display name.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return      The list of all matched contacts, @n
+        *                              else an empty list if there is no matched contact, or @c null if an exception occurs (@ref Contact list)
+        * @param[in]   name                    The substring of the name to search
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c name is an empty string.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks
+        *              - The specific error code can be accessed using the GetLastResult() method.
+        *              - There is a high probability for an occurrence of an out-of-memory exception.
+        *              If possible, check whether the exception is @c E_OUT_OF_MEMORY or not. @n
+        *              For more information on how to handle the out-of-memory exception, refer
+        *              <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        */
+       Tizen::Base::Collection::IList* SearchContactsByNameN(const Tizen::Base::String& name) const;
+
+       /**
+        * Searches the contacts that have the specified @c phoneNumber string as a substring of one of their phone numbers. @n
+        * This method returns the contacts whose phone number match the value of the specified @c phoneNumber. @n
+        * The search operation is performed with a case insensitive key (param: @c phoneNumber). @n
+        * The contacts are ordered by display name.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return      The list of all matched contacts, @n
+        *                                  else an empty list if there is no contact, or @c null if an exception occurs (@ref Contact list)
+        * @param[in]   phoneNumber             The substring of the phone number to search
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c phoneNumber is an empty string.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @remarks
+        *              - The specific error code can be accessed using the GetLastResult() method.
+        *              - There is a high probability for an occurrence of an out-of-memory exception.
+        *              If possible, check whether the exception is @c E_OUT_OF_MEMORY or not. @n
+        *              For more information on how to handle the out-of-memory exception, refer
+        *              <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        */
+       Tizen::Base::Collection::IList* SearchContactsByPhoneNumberN(const Tizen::Base::String& phoneNumber) const;
+
+       /**
+        * Gets the latest change version.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The latest change version, @n
+        *                              else @c -1 if an exception occurs
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @see GetChangedContactsAfterN()
+        * @see GetChangedCategoriesAfterN()
+        */
+       int GetLatestVersion(void) const;
+
+       /**
+        * Gets the change information of the contacts that have been changed after the specified change version.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated This method is deprecated.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return      The list of contact change information, @n
+        *                                  else an empty list if there is no changed contact, or @c null if an exception occurs (@ref ContactChangeInfo list)
+        * @param[in]   version                 The change version
+        * @param[out]  latestVersion   The latest change version among the changed contacts
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c version is invalid.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @see GetLatestVersion()
+        * @see ContactChangeInfo
+        *
+        * The following example demonstrates how to use the %GetChangedContactsAfterN() method.
+        * @code
+        * void
+        * MyApplication::PrintChangedContacts(void)
+        * {
+        *    IList* pChangedContacts = __pAddressbookManager->GetChangedContactsAfterN(__version, __version);
+        *
+        *    IEnumerator* pEnum = pChangedContacts->GetEnumeratorN();
+        *    while (pEnum->MoveNext() == E_SUCCESS)
+        *    {
+        *      ContactChangeInfo* pInfo = static_cast<ContactChangeInfo*>(pEnum->GetCurrent());
+        *
+        *      AppLog("Contact changed: type(%d), id(%d), version(%d)", pInfo->GetChangeType(), pInfo->GetContctId(), pInfo->GetVersion());
+        *    }
+        *    delete pEnum;
+        *    pChangedContacts->RemoveAll(true);
+        *    delete pChangedContacts;
+        * }
+        * @endcode
+        */
+       Tizen::Base::Collection::IList* GetChangedContactsAfterN(int version, int& latestVersion) const;
+
+       /**
+        * Gets the change information of the categories that have been changed after the specified change version.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated This method is deprecated.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The list of category change information, @n
+        *                              else an empty list if there is no changed category, or @c null if an exception occurs (@ref CategoryChangeInfo list)
+        * @param[in]   version                         The change version
+        * @param[out]  latestVersion           The latest change version among the changed categories
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c version is invalid.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @see GetLatestVersion()
+        * @see CategoryChangeInfo
+        *
+        * The following example demonstrates how to use the %GetChangedCategoriesAfterN() method.
+        * @code
+        * void
+        * MyApplication::PrintChangedCategories(void)
+        * {
+        *    IList* pChangedCategories = __pAddressbookManager->GetChangedCategoriesAfterN(__version, __version);
+        *
+        *    IEnumerator* pEnum = pChangedCategories->GetEnumeratorN();
+        *    while (pEnum->MoveNext() == E_SUCCESS)
+        *    {
+        *      CategoryChangeInfo* pInfo = static_cast<CategoryChangeInfo*>(pEnum->GetCurrent());
+        *
+        *      AppLog("Category changed: type(%d), id(%d), version(%d)", pInfo->GetChangeType(), pInfo->GetCategoryId(), pInfo->GetVersion());
+        *    }
+        *    delete pEnum;
+        *    pChangedCategories->RemoveAll(true);
+        *    delete pChangedCategories;
+        * }
+        * @endcode
+        */
+       Tizen::Base::Collection::IList* GetChangedCategoriesAfterN(int version, int& latestVersion) const;
+
+       /**
+        * Gets the person with the specified person ID.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return      The matched person, @n
+        *                              else @c null if an exception occurs
+        * @param[in]   personId                The person ID
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c personId is invalid.
+        * @exception   E_OBJ_NOT_FOUND         The specified @c personId is not found.
+        * @exception   E_SYSTEM      The method cannot proceed due to a severe system error.
+        * @remarks     The specific error code can be accessed using the GetLastResult() method.
+        */
+       Person* GetPersonN(PersonId personId) const;
+
+       /**
+        * Removes a person. @n
+        * All the contacts linked to the person are removed, too.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An error code
+        * @param[in]   personId                The person ID
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c personId is invalid.
+        * @exception   E_OBJ_NOT_FOUND         The specified person does not exist.
+        * @exception   E_SYSTEM      The method cannot be proceed due to a severe system error.
+        */
+       result RemovePerson(PersonId personId);
+
+       /**
+        * Gets all persons on the device. @n
+        * The persons are ordered by display name.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return      The list of all persons on the device, @n
+        *              else an empty list if there is no person, or @c null if an exception occurs (@ref Person list)
+        * @exception   E_SUCCESS              The method is successful.
+        * @exception   E_PRIVILEGE_DENIED     The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM      The method cannot be proceed due to a severe system error.
+        * @remarks
+        *              - The specific error code can be accessed using the GetLastResult() method.
+        *              - There is a high probability for an occurrence of an out-of-memory exception.
+        *              If possible, check whether the exception is @c E_OUT_OF_MEMORY or not. @n
+        *              For more information on how to handle the out-of-memory exception, refer
+        *              <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        */
+       Tizen::Base::Collection::IList* GetAllPersonsN(void) const;
+
+       /**
+        * Gets the persons that are members of the specified category where a person is a member of a category if a contact linked to it is a member of the category. @n
+        * If the specified @c categoryId is ::INVALID_RECORD_ID, this method returns the persons that are not members of any category. @n
+        * The persons are ordered by display name.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return      The list of persons that are members of the specified category, @n
+        *              else an empty list if there is no person, or @c null if an exception occurs (@ref Person list)
+        * @param[in]   categoryId              The category ID
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c categoryId is invalid.
+        * @exception   E_OBJ_NOT_FOUND         The specified category does not exist.
+        * @exception   E_SYSTEM      The method cannot proceed due to a severe system error.
+        * @remarks
+        *              - The specific error code can be accessed using the GetLastResult() method.
+        *              - There is a high probability for an occurrence of an out-of-memory exception.
+        *              If possible, check whether the exception is @c E_OUT_OF_MEMORY or not. @n
+        *              For more information on how to handle the out-of-memory exception, refer
+        *              <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        */
+       Tizen::Base::Collection::IList* GetPersonsByCategoryN(RecordId categoryId) const;
+
+       /**
+        * Gets the list of favorite persons. @n
+        * The persons are ordered by display name.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return      The list of favorite persons, @n
+        *              else an empty list if there is no favorite person, or @c null if an exception occurs (@ref Person list)
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM      The method cannot proceed due to a severe system error.
+        * @remarks
+        *              - The specific error code can be accessed using the GetLastResult() method.
+        *              - There is a high probability for an occurrence of an out-of-memory exception.
+        *              If possible, check whether the exception is @c E_OUT_OF_MEMORY or not. @n
+        *              For more information on how to handle the out-of-memory exception, refer
+        *              <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        * @see SetPersonAsFavorite()
+        */
+       Tizen::Base::Collection::IList* GetFavoritePersonsN(void) const;
+
+       /**
+        * Searches the persons that contain the specified @c keyword string in its properties. @n
+        * The search operation is performed with a case insensitive key (param: @c keyword). @n
+        * The persons are ordered by display name.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return      The list of all matched persons, @n
+        *              else an empty list if there is no matched person, or @c null if an exception occurs (@ref Person list)
+        * @param[in]   keyword                 The key to search
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c keyword is an empty string.
+        * @exception   E_SYSTEM      The method cannot proceed due to a severe system error.
+        * @remarks
+        *              - The specific error code can be accessed using the GetLastResult() method.
+        *              - There is a high probability for an occurrence of an out-of-memory exception.
+        *              If possible, check whether the exception is @c E_OUT_OF_MEMORY or not. @n
+        *              For more information on how to handle the out-of-memory exception, refer
+        *              <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        */
+       Tizen::Base::Collection::IList* SearchPersonsN(const Tizen::Base::String& keyword) const;
+
+       /**
+        * Sets whether the specified person is a favorite or not.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An error code
+        * @param[in]   personId                        The person ID
+        * @param[in]   isFavorite                      Set to @c true to set the specified person as a favorite, @n
+        *                                              else @c false to set the specified person as a non-favorite
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c personId is invalid.
+        * @exception   E_OBJ_NOT_FOUND         The specified person does not exist.
+        * @exception   E_SYSTEM      The method cannot proceed due to a severe system error.
+        * @see GetFavoritePersonsN()
+        * @see Person::IsFavorite()
+        */
+       result SetPersonAsFavorite(PersonId personId, bool isFavorite = true);
+
+       /**
+        * Merges the source person with the target person. @n
+        * The following are done during merging:
+        *      - Unlinks the contacts linked to the source person.
+        *      - Links the unlinked contacts to the target person.
+        *      - Removes the source person.
+        *      - Updates information of the target person.
+        *
+        * The %MergePersons() method does nothing if the source or target person does not exist.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An error code
+        * @param[in]   sourcePersonId          The source person ID
+        * @param[in]   targetPersonId          The target person ID
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c sourcePersonId or @c targetPersonId is invalid.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        */
+        result MergePersons(PersonId sourcePersonId, PersonId targetPersonId);
+
+       /**
+        * Unlinks the specified contact from the specified person. @n
+        * The following are done during unlinking:
+        *      - Unlinks the contact specified by @c contactId.
+        *      - Creates a new person.
+        *      - Links the unlinked contact to the new person.
+        *      - Updates information of a person.
+        *
+        * It is not allowed to unlink a contact if it is the only one contact linked to a person.
+        * The %UnlinkContact() method does nothing if the contact has not been linked to the person or does not exist.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An error code
+        * @param[in]   personId                The ID of the person that the contact is unlinked from
+        * @param[in]   contactId               The contact to unlink
+        * @param[out]  newPersonId             The ID of the new person
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c personId or @c contactId is invalid.
+        * @exception   E_SYSTEM      The method cannot proceed due to a severe system error.
+        */
+        result UnlinkContact(PersonId personId, RecordId contactId, PersonId& newPersonId);
+
+       /**
+        * Searches items of the addressbook with the filter. @n
+        * The filter specifies the item type and condition for searching.
+        * The searched results are ordered by the @c propertyToSort and @c sortOrder.
+        * If the @c offset is M and the @c maxCount are N, then the first M items are omitted from the result set returned by the searching operation and the next N items are returned.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege    %http://tizen.org/privilege/contact.read
+        *
+        * @return       The list of searched results (The list of Addressbook, Person, Contact, Category, PhoneNumberContact, EmailContact), @n
+        *                 else an empty list if there is no searched result, or @c null if an exception occurs
+        * @param[in]    filter                 The filter that specifies the search condition @n If the filter is empty, all items that are specified by the type of this filter are searched.
+        * @param[in]    propertyToSort         The property for sorting @n The searched results are ordered by the values of this property.
+        * @param[in]    sortOrder              The order for sorting
+        * @param[in]    offset                 The offset of the searched results @n If this value is @c 0, it is ignored.
+        * @param[in]    maxCount               The maximum count of the searched results @n If this value is @c 0, it is ignored.
+        * @exception    E_SUCCESS              The method is successful.
+        * @exception    E_PRIVILEGE_DENIED     The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception    E_INVALID_ARG          Either of the following conditions has occurred:
+        *                                                      - The specified @c offset or @c maxCount is less than @c 0.
+        *                                                      - The specified @c propertyToSort is not an element of the enumerator that corresponds to the type of the @c filter.
+        * @exception    E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @remarks
+        *              - The specific error code can be accessed using the GetLastResult() method.
+        *              - There is a high probability for an occurrence of an out-of-memory exception.
+        *              If possible, check whether the exception is @c E_OUT_OF_MEMORY or not. @n
+        *              For more information on how to handle the out-of-memory exception, refer
+        *              <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        * @see AddressbookFilterProperty
+        * @see PersonFilterProperty
+        * @see ContactFilterProperty
+        * @see CategoryFilterProperty
+        * @see PhoneContactFilterProperty
+        * @see EmailContactFilterProperty
+        */
+       Tizen::Base::Collection::IList* SearchN(const AddressbookFilter& filter, 
+                       unsigned long propertyToSort = 0, Tizen::Base::SortOrder sortOrder = Tizen::Base::SORT_ORDER_NONE, int offset = 0, int maxCount = 0);
+
+       /**
+        * Gets the matched item count of the search results with the filter. @n
+        * The filter specifies the item type and condition for searching.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege    %http://tizen.org/privilege/contact.read
+        *
+        * @return       The count of the searched results
+        * @param[in]    filter                  The filter that specifies the search condition @n If the filter is empty, all items that are specified by the type of this filter are searched.
+        * @exception    E_SUCCESS               The method is successful.
+        * @exception    E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception    E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @see AddressbookFilterProperty
+        * @see PersonFilterProperty
+        * @see ContactFilterProperty
+        * @see CategoryFilterProperty
+        * @see PhoneContactFilterProperty
+        * @see EmailContactFilterProperty
+        */
+       int GetMatchedItemCount(const AddressbookFilter& filter);
+
+       /**
+        * Parses contacts from the specified vCard file. @n
+        * The %ParseContactsFromVcardN() method supports vCard formation 2.1 and 3.0.
+        *
+        * @since       2.0
+        *
+        * @return      The list of contacts, @n
+        *              else an empty list if there is no contact, or @c null if an exception occurs (@ref Contact list)
+        * @param[in]   vcardPath               The file path of a vCard file  
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c vcardPath is invalid.
+        * @exception   E_ILLEGAL_ACCESS        The access is denied due to insufficient permission.
+        * @exception   E_FILE_NOT_FOUND        The specified file cannot be found.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* ParseContactsFromVcardN(const Tizen::Base::String& vcardPath);
+
+       /**
+        * Exports a person to the specified vCard 3.0 file. 
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return      An error code
+        * @param[in]   person                  The person to export
+        * @param[in]   vcardPath               The file path of a vCard file
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           The specified @c person is invalid.
+        * @exception   E_ILLEGAL_ACCESS        The access is denied due to insufficient permission.
+        * @exception   E_FILE_ALREADY_EXIST    The specified file already exists.
+        * @exception   E_STORAGE_FULL                  The storage is insufficient.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        */
+       result ExportPersonToVcard(const Person& person, const Tizen::Base::String& vcardPath);
+
+       /**
+        * Exports a person list to the specified vCard 3.0 file.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return      An error code
+        * @param[in]   personList              The person list to export @n The list should contain the Person instances.
+        * @param[in]   vcardPath               The file path of a vCard file 
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           Either of the following conditions has occurred:
+        *                                                      - The specified @c personList is invalid.
+        *                                                      - The specified @c vcardPath is invalid.
+        * @exception   E_ILLEGAL_ACCESS        The access is denied due to insufficient permission.
+        * @exception   E_FILE_ALREADY_EXIST    The specified file already exists.
+        * @exception   E_STORAGE_FULL                  The storage is insufficient.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        */
+       result ExportPersonsToVcard(const Tizen::Base::Collection::IList& personList, const Tizen::Base::String& vcardPath);
+
+       /**
+        * Exports a contact to the specified vCard 3.0 file.
+        *
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param[in]   contact                 The contact to export
+        * @param[in]   vcardPath               The file path of a vCard file
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c contact is invalid.
+        * @exception   E_ILLEGAL_ACCESS        The access is denied due to insufficient permission.
+        * @exception   E_FILE_ALREADY_EXIST    The specified file already exists.
+        * @exception   E_STORAGE_FULL                  The storage is insufficient.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        */
+       result ExportContactToVcard(const Contact& contact, const Tizen::Base::String& vcardPath);
+
+       /**
+        * Exports a contact list to the specified vCard 3.0 file.
+        *
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param[in]   contactList             The contact list to export @n The list should contain Contact instances.
+        * @param[in]   vcardPath               The file path of a vCard file  
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           Either of the following conditions has occurred:
+        *                                                      - The specified @c contactList is invalid.
+        *                                                      - The specified @c vcardPath is invalid.
+        * @exception   E_ILLEGAL_ACCESS        The access is denied due to insufficient permission.
+        * @exception   E_FILE_ALREADY_EXIST    The specified file already exists.
+        * @exception   E_STORAGE_FULL                  The storage is insufficient.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        */
+       result ExportContactsToVcard(const Tizen::Base::Collection::IList& contactList, const Tizen::Base::String& vcardPath);
+
+       /**
+       * Exports a contact to a vCard format stream.
+       *
+       * @since        2.1
+       *
+       * @return               The exported vcard stream, @n
+       *                               else @c null if an exception occurs
+       * @param[in]    contact                 The contact to export
+       * @exception    E_SUCCESS               The method is successful.
+       * @exception    E_INVALID_ARG           The specified @c contact is invalid.
+       * @exception    E_SYSTEM                        The method cannot proceed due to a severe system error.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see ExportContactToVcard()
+       */
+       Tizen::Base::ByteBuffer*  ExportContactToVcardStreamN(const Contact& contact);
+
+       /**
+       * Exports a contact list to a vCard format stream.
+       *
+       * @since        2.1
+       *
+       * @return               The exported vcard stream, @n
+       *                               else @c null if an exception occurs
+       * @param[in]    contactList             The contact list to export @n The list should contain the Contact instances
+       * @exception    E_SUCCESS               The method is successful.
+       * @exception    E_INVALID_ARG           The specified @c contactList contains an invalid contact.
+       * @exception    E_SYSTEM      The method cannot proceed due to a severe system error.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see ExportContactsToVcard()
+       */
+       Tizen::Base::ByteBuffer* ExportContactsToVcardStreamN(const Tizen::Base::Collection::IList& contactList);
+
+       /**
+       * Exports a person to a vCard format stream.
+       *
+       * @since        2.1
+       * @privlevel    public
+       * @privilege    %http://tizen.org/privilege/contact.read
+       *
+       * @return               The exported vcard stream, @n
+       *                               else @c null if an exception occurs
+       * @param[in]    person                  The person to export
+       * @exception    E_SUCCESS               The method is successful.
+       * @exception    E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+       * @exception    E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+       * @exception    E_INVALID_ARG           The specified @c person is invalid.
+       * @exception    E_SYSTEM      The method cannot proceed due to a severe system error.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see ExportPersonToVcard()
+       */
+       Tizen::Base::ByteBuffer* ExportPersonToVcardStreamN(const Person& person);
+
+       /**
+       * Exports a person list to a vCard format stream.
+       *
+       * @since        2.1
+       * @privlevel    public
+       * @privilege    %http://tizen.org/privilege/contact.read
+       *
+       * @return               The exported vcard stream, @n
+       *                               else @c null if an exception occurs
+       * @param[in]    personList              The person list to export @n The list should contain the Person instances.
+       * @exception    E_SUCCESS               The method is successful.
+       * @exception    E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+       * @exception    E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+       * @exception    E_INVALID_ARG           The specified @c personList contains invalid person.
+       * @exception    E_SYSTEM      The method cannot proceed due to a severe system error.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see ExportPersonsToVcard()
+       */
+       Tizen::Base::ByteBuffer* ExportPersonsToVcardStreamN(const Tizen::Base::Collection::IList& personList);
+
+       /**
+       * Parses contacts from the specified vCard stream. @n
+       * The %ParseVcardStreamN() method supports vCard formation 2.1 and 3.0.
+       *
+       * @since        2.1
+       *
+       * @return               The list of contacts, @n
+       *                               else an empty list if there is no contact, or @c null if an exception occurs (@ref Contact list)
+       * @param[in]    vcardStream             The vCard stream
+       * @exception    E_SUCCESS               The method is successful.
+       * @exception    E_INVALID_ARG           The specified @c vcardStream is invalid.
+       * @exception    E_SYSTEM      The method cannot proceed due to a severe system error.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see ParseContactsFromVcardN()
+       */
+       Tizen::Base::Collection::IList* ParseVcardStreamN(const Tizen::Base::ByteBuffer& vcardStream);
+
+       /**
+        * Exports a user profile to a vCard format stream.
+        *
+        * @since       2.1
+        *
+        * @return      The exported vCard stream, @n
+        *               else @c null if an exception occurs
+        * @param[in]   userProfile             The user profile to export
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c userProfile is invalid.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @remarks     The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* ExportUserProfileToVcardStreamN(const UserProfile& userProfile);
+
+       /**
+        * Exports a user profile list to a vCard format stream.
+        *
+        * @since       2.1
+        *
+        * @return      The exported vCard stream, @n
+        *              else @c null if an exception occurs
+        * @param[in]   userProfileList         The user profile list to export @n The list should contain the UserProfile instances
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c userProfile is invalid.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @remarks     The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* ExportUserProfilesToVcardStreamN(const Tizen::Base::Collection::IList& userProfileList);
+
+       /**
+        * Exports a user profile to the specified vCard 3.0 file.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   userProfile              The user profile to export
+        * @param[in]   vcardPath               The file path of a vCard file
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c userProfile is invalid.
+        * @exception   E_ILLEGAL_ACCESS        The access is denied due to insufficient permission.
+        * @exception   E_FILE_ALREADY_EXIST    The specified file already exists.
+        * @exception   E_STORAGE_FULL                  The storage is insufficient.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        */
+       result ExportUserProfileToVcard(const UserProfile& userProfile, const Tizen::Base::String& vcardPath);
+
+       /**
+        * Exports a user profile list to the specified vCard 3.0 file.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   userProfileList          The user profile list to export @n The list should contain the UserProfile instances
+        * @param[in]   vcardPath               The file path of a vCard file
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           Either of the following conditions has occurred:
+        *                                                      - The specified @c userProfileList is invalid.
+        *                                                      - The specified @c vcardPath is invalid.
+        * @exception   E_ILLEGAL_ACCESS        The access is denied due to insufficient permission.
+        * @exception   E_FILE_ALREADY_EXIST    The specified file already exists.
+        * @exception   E_STORAGE_FULL                  The storage is insufficient.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        */
+       result ExportUserProfilesToVcard(const Tizen::Base::Collection::IList& userProfileList, const Tizen::Base::String& vcardPath);
+
+       /**
+        * Gets all the user profiles on the device.
+        *
+        * @since       2.1
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/userprofile.read
+        *
+        * @return      The list of all the user profiles on the device, @n
+        *              else an empty list if there is no user profile, or @c null if an exception occurs (@ref UserProfile list)
+        * @exception   E_SUCCESS              The method is successful.
+        * @exception   E_PRIVILEGE_DENIED     The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+        * @exception   E_SYSTEM      The method cannot be proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetAllUserProfilesN(void) const;
+
+       /**
+        * Gets a user profile of the address book specified by the address book ID.
+        *
+        * @since       2.1
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/userprofile.read
+        *
+        * @return      The matched user profile, @n
+        *              else @c null if an exception occurs
+        * @param[in]   addressbookId           The addressbook ID
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+        * @exception   E_INVALID_ARG           The specified @c addressbookId is invalid.
+        * @exception   E_OBJ_NOT_FOUND         The specified addressbook is not found.
+        * @exception   E_SYSTEM      The method cannot proceed due to a severe system error.
+        * @remarks     The specific error code can be accessed using the GetLastResult() method.
+        */
+       UserProfile* GetUserProfileN(AddressbookId addressbookId) const;
+
+       /**
+        * Gets an %AddressbookManager instance.
+        *
+        * @since       2.0
+        *
+        * @return              A pointer to the %AddressbookManager instance, @n
+        *                              else @c null if it fails
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       static AddressbookManager* GetInstance(void);
+
+private:
+       //
+       // This default constructor is intentionally declared as private to implement the Singleton semantic.
+       //
+       // @since       2.0
+       //
+       AddressbookManager(void);
+
+       //
+       // This destructor is intentionally declared as private to implement the Singleton semantic.
+       //
+       // @since       2.0
+       //
+       virtual ~AddressbookManager(void);
+
+       //
+       // This function is only for internal usage.
+       //
+       // @since       2.0
+       //
+       // @return      An error code
+       //
+       result Construct(void);
+
+       //
+       // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       // @since       2.0
+       //
+       AddressbookManager(const AddressbookManager& rhs);
+
+       //
+       // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+       //
+       // @since       2.0
+       //
+       AddressbookManager& operator =(const AddressbookManager& rhs);
+
+       static void InitAddressbookManager(void);
+       static void DestroyAddressbookManager(void);
+
+private:
+       static AddressbookManager* __pInstance;
+       friend struct std::default_delete< AddressbookManager >;
+
+       friend class _AddressbookManagerImpl;
+       class _AddressbookManagerImpl* __pAddressbookManagerImpl;
+}; // AddressbookManager
+
+}} // Tizen::Social
+
+#endif //_FSCL_ADDRESSBOOK_MANAGER_H_
diff --git a/inc/FSclAttendee.h b/inc/FSclAttendee.h
new file mode 100644 (file)
index 0000000..d1fa6fa
--- /dev/null
@@ -0,0 +1,301 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FSclAttendee.h
+ * @brief      This is the header file for the %Attendee class.
+ *
+ * This header file contains the declarations of the %Attendee class.
+ */
+#ifndef _FSCL_ATTENDEE_H_
+#define _FSCL_ATTENDEE_H_
+
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @class      Attendee
+ * @brief      This class represents the information of an attendee.
+ *
+ * @since      2.0
+ *
+ * @final      This class is not intended for extension.
+ *
+ * The %Attendee class represents the information of an attendee. The attendee details include a mandatory
+ * email and an optional name. In addition, the attendee has a role and status information.
+ */
+class _OSP_EXPORT_ Attendee
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * Initializes this instance of %Attendee with the specified email address.
+        *
+        * @since       2.0
+        *
+        * @param[in]   email   The email address
+        */
+       Attendee(const Tizen::Base::String& email);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %Attendee to copy
+        */
+       Attendee(const Attendee& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~Attendee(void);
+
+       /**
+        * Compares the specified Tizen::Base::Object with the current %Attendee instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the specified object equals the current %Attendee instance, @n
+        *                              else @c false
+        * @param[in]   rhs     The object instance to compare with the current object
+        * @see                 GetHashCode()
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the name of the attendee.
+        *
+        * @since       2.0
+        *
+        * @return              The name
+        */
+       Tizen::Base::String GetName(void) const;
+
+       /**
+        * Gets the email address of the attendee.
+        *
+        * @since       2.0
+        *
+        * @return              The email address
+        */
+       Tizen::Base::String GetEmail(void) const;
+
+       /**
+        * Gets the role of the attendee. @n
+        * The default value is @c #ATTENDEE_ROLE_ATTENDEE.
+        *
+        * @since       2.0
+        *
+        * @return              The role of the attendee
+        */
+       AttendeeRole GetRole(void) const;
+
+       /**
+        * Gets the status of the attendee. @n
+        * The default value is @c #ATTENDEE_STATUS_NONE.
+        *
+        * @since       2.0
+        *
+        * @return              The attendee status
+        */
+       AttendeeStatus GetStatus(void) const;
+
+       /**
+        * Sets the name.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility       This method has compatibility issues with OSP compatible applications. @n
+     *                                 For more information, see @ref CompAttendeeSetNamePage "here".
+     * @endif
+        *
+        * @return              An error code
+        * @param[in]   name                    The common name of the attendee
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c name is an empty string.
+        */
+       result SetName(const Tizen::Base::String& name);
+
+       /**
+        * @if OSPCOMPAT
+        * @page        CompAttendeeSetNamePage Compatibility for SetName()
+        * @section     CompAttendeeSetNamePageIssueSection Issues
+        *          Implementing this method in OSP compatible applications has the following issues: @n
+        *                      -# If the length of the name to be set is greater than @c 100 characters, @c E_INVALID_ARG is returned.
+        *
+        * @section     CompAttendeeSetNamePageSolutionSection Resolutions
+        *                      This issue has been resolved in Tizen. @n
+        *                      -# There is no limit for the length of the name.
+        *
+        * @endif
+        */
+
+       /**
+        * Sets the email address of the attendee. @n
+        * This is the identifier of the attendee.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility       This method has compatibility issues with OSP compatible applications. @n
+     *                                 For more information, see @ref CompAttendeeSetEmailPage "here".
+        * @endif
+        *
+        * @return              An error code
+        * @param[in]   email                   The email address
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c email is an empty string.
+        */
+       result SetEmail(const Tizen::Base::String& email);
+
+       /**
+        * @if OSPCOMPAT
+        * @page        CompAttendeeSetEmailPage Compatibility for SetEmail()
+        * @section     CompAttendeeSetEmailPageIssueSection Issues
+        *          Implementing this method in OSP compatible applications has the following issues: @n
+        *                      -# If the length of the email to be set is greater than @c 320 characters, @c E_INVALID_ARG is returned.
+        *
+        * @section     CompAttendeeSetEmailPageSolutionSection Resolutions
+        *                      This issue has been resolved in Tizen. @n
+        *                      -# There is no limit for the length of the email.
+        * @endif
+        */
+
+       /**
+        * Sets the role of the attendee. @n
+        * The default value is @c #ATTENDEE_ROLE_ATTENDEE.
+        *
+        * @since       2.0
+        *
+        * @param[in]   role    The role of the attendee @n
+        *                                              The default value is @c #ATTENDEE_ROLE_ATTENDEE.
+        */
+       void SetRole(AttendeeRole role);
+
+       /**
+        * Sets the status of the attendee. @n
+        * The default value is @c #ATTENDEE_STATUS_NONE.
+        *
+        * @since       2.0
+        *
+        * @param[in]   status  The status of the attendee @n
+        *                                              The default value is @c #ATTENDEE_STATUS_NONE.
+        */
+       void SetStatus(AttendeeStatus status);
+
+       /**
+        * Sets the phone number.
+        *
+        * @since       2.0
+        *
+        * @param[in]   phoneNumber             The phone number
+        */
+       void SetPhoneNumber(const Tizen::Base::String& phoneNumber);
+
+       /**
+        * Gets the phone number.
+        *
+        * @since       2.0
+        *
+        * @return              The phone number
+        */
+       Tizen::Base::String GetPhoneNumber(void) const;
+
+       /**
+        * Sets the person ID that is an identifier used for Addressbook APIs.
+        *
+        * @since       2.0
+        *
+        * @param[in]   personId                The person ID
+        */
+       void SetPersonId(PersonId personId);
+
+       /**
+        * Gets the person ID that is an identifier used for Addressbook APIs.
+        *
+        * @since       2.0
+        *
+        * @return              The person ID
+        */
+       PersonId GetPersonId(void) const;
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %Attendee to copy
+        */
+       Attendee& operator =(const Attendee& rhs);
+
+       /**
+        * Checks whether the data in the specified instance of %Attendee is equal to the data in the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the data in the specified instance equals the data in the current instance, @n
+        *                              else @c false
+        * @param[in]   rhs             An instance of %Attendee
+        */
+       bool operator ==(const Attendee& rhs) const;
+
+       /**
+        * Compares the specified instance of %Attendee with the current instance for inequality.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the data in the specified instance is not equal to the data in the current instance, @n
+        *                              else @c false
+        * @param[in]   rhs             An instance of %Attendee
+        */
+       bool operator !=(const Attendee& rhs) const;
+
+private:
+       Tizen::Base::String     __name;
+       Tizen::Base::String     __email;
+       Tizen::Base::String     __phoneNumber;
+       AttendeeRole    __attendeeRole;
+       AttendeeStatus  __attendeeStatus;
+       PersonId __personId;
+
+       friend class _AttendeeImpl;
+       class _AttendeeImpl* __pAttendeeImpl;
+};     // Attendee
+
+}}     // Tizen::Social
+
+#endif //_FSCL_ATTENDEE_H_
diff --git a/inc/FSclCalEvent.h b/inc/FSclCalEvent.h
new file mode 100644 (file)
index 0000000..e436b0d
--- /dev/null
@@ -0,0 +1,926 @@
+// 
+// Copyright (c) 2012 Samsung Electronics Co., Ltd. 
+// 
+// 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.
+//
+/**
+ * @file       FSclCalEvent.h
+ * @brief      This is the header file for the %CalEvent class.
+ *
+ * This header file contains the declarations of the %CalEvent class.
+ */
+#ifndef _FSCL_CAL_EVENT_H_
+#define _FSCL_CAL_EVENT_H_
+
+#include <FBaseDataType.h>
+#include <FBaseColIList.h>
+#include <FBaseString.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseDateTime.h>
+#include <FLclCalendar.h>
+#include <FSclTypes.h>
+#include <FSclRecord.h>
+#include <FSclRecurrence.h>
+#include <FSclReminder.h>
+#include <FSclAttendee.h>
+
+namespace Tizen { namespace Locales
+{
+class TimeZone;
+}}
+
+namespace Tizen { namespace Social
+{
+
+/**
+ *     @class  CalEvent
+ *     @brief  This class provides methods to manage the information of a calendar book event.
+ *
+ * @since      2.0
+ *
+ *     @final  This class is not intended for extension.
+ *
+ *     The %CalEvent class describes an occasion planned in a particular situation. @n
+ *     An event is a subset of vEvent. A %CalEvent instance includes the category, subject, description, start time, end time, location, and sensitivity.
+ *     %CalEvent also includes the recurring and reminder data. For more information, see the Recurrence, and Reminder classes.
+ *
+ *     For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/social/calevent.htm">Calendar Events</a>.
+ *
+ *     The following example demonstrates how to use the %CalEvent class.
+
+ *     @code
+ *
+       #include <FSocial.h>
+       #include <FLocales.h>
+
+       using namespace Tizen::Base;
+       using namespace Tizen::Social;
+       using namespace Tizen::Locales;
+
+       void
+       CreateCalEventWithTimeZone(void)
+       {
+               DateTime startWallTime;
+               DateTime endWallTime;
+               DateTime startUtcTime;
+               DateTime endUtcTime;
+
+               // Suppose a user set 2010/2/17 12:00:00 ~ 2010/2/17 14:00:00 in wall time for start/end time
+               startWallTime.SetValue(2010, 2, 17, 12, 0, 0);
+               endWallTime.SetValue(2010, 2, 17, 14, 0, 0);
+
+               // Gets the system time zone
+               LocaleManager localeManager;
+               localeManager.Construct();
+
+               TimeZone timeZone = localeManager.GetSystemTimeZone();
+
+               // Converts the wall time to UTC time before set start and end time of the event
+               startUtcTime = timeZone.WallTimeToUtcTime(startWallTime);
+               endUtcTime = timeZone.WallTimeToUtcTime(endWallTime);
+
+               // Creates an event
+               CalEvent event;
+
+               // Sets the values
+               event.SetTimeZone(timeZone);
+               event.SetStartAndEndTime(startUtcTime, endUtcTime);
+       }
+ *
+ * @endcode
+ *
+ *     The following example demonstrates how to use the %CalEvent class to add calendarbook all day event.
+ *     @code
+ *
+       #include <FBase.h>
+       #include <FSocial.h>
+
+       using namespace Tizen::Base;
+       using namespace Tizen::Social;
+
+       void
+       CreateAlldayEvent(void)
+       {
+
+               DateTime startWallTime;
+               DateTime endWallTime;
+
+               // Sets the start/end time for an all day event on 2013/7/17
+               // The end time for all day event must be later than the start date(RFC 5545)
+               startWallTime.SetValue(2013, 7, 17, 0, 0, 0);
+               endWallTime.SetValue(2013, 7, 18, 0, 0, 0);
+
+               // Creates an all day event
+               CalEvent event;
+               event.SetSubject(L"All day event");
+
+               event.SetAllDayEvent(true);
+               event.SetStartAndEndTime(startWallTime, endWallTime);
+       }
+ *
+ * @endcode
+ */
+class _OSP_EXPORT_ CalEvent
+       : public Record
+{
+
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.0
+        */
+       CalEvent(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %CalEvent to copy
+        */
+       CalEvent(const CalEvent& rhs);
+
+       /**
+        * This destructor overrides Tizen::Social::Record::~Record().
+        *
+        * @since       2.0
+        */
+       virtual ~CalEvent(void);
+
+       /**
+        * Compares the specified Tizen::Base::Object with the current %CalEvent instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the specified object equals the current %CalEvent instance, @n
+        *                              else @c false
+        * @param[in]   rhs     The object instance to compare with the current object
+        * @see                 GetHashCode()
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * @if OSPDEPREC
+        * Checks whether this instance is a %CalEvent instance. @n
+        * A one-time calendar event has only one instance and a recurring calendar event has more than one instance. @n
+        * Each instance of %CalEvent has its own recurrence ID.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated  This method is deprecated because %CalEvent class is not used for an event instance any more. @n
+        * Instead of using the %CalEvent class, it is recommended to use the CalEventInstance class for an event instance.
+        * @since       2.0
+        *
+        * @return              @c true if this instance is a %CalEvent instance, @n
+        *                              else @c false
+        * @endif
+        */
+       bool IsInstance(void) const;
+
+       /**
+        * @if OSPDEPREC
+        * Checks whether the calendar event has a recurring pattern.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated  This method is deprecated because %CalEvent class is not used for an event instance any more. @n
+        * Instead of using the %CalEvent class, it is recommended to use the CalEventInstance class for an event instance.
+        * @since       2.0
+        *
+        * @return              @c true if the calendar event has a recurring pattern, @n
+        *                              else @c false
+        * @endif
+        */
+       bool IsRecurring(void) const;
+
+       /**
+        * @if OSPDEPREC
+        * Gets the original calendar event ID. @n
+        * The %CalEvent instance has an original @c CalEventId, that is a record ID of its entry.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated  This method is deprecated because %CalEvent class is not used for an event instance any more. @n
+        * Instead of using the %CalEvent class, it is recommended to use the CalEventInstance class for an event instance.
+        * @since       2.0
+        *
+        * @return      The original calendar event ID, @n
+        *                      else #INVALID_RECORD_ID if the record ID is invalid
+        * @endif
+        */
+       RecordId GetOriginalCalEventId(void) const;
+
+       /**
+        * Checks whether the calendar event is an all day event.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the calendar event is an all day event, @n
+        *                              else @c false
+        */
+       bool IsAllDayEvent(void) const;
+
+       /**
+        * Sets the calendar event as an all day event.
+        *
+        * @since       2.0
+        *
+        * @param[in]   isAllDayEvent   Set to @c true to make the calendar event an all day event, @n
+        *                                                              else @c false
+        */
+       void SetAllDayEvent(bool isAllDayEvent);
+
+       /**
+        * @if OSPDEPREC
+        * Gets the globally unique ID. @n
+        * UID: globally Unique Identifier (vCalendar 1.0)
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated  This method is deprecated because a string value cannot be handled. @n
+        * Instead of using this method, it is recommended to use GetUid().
+        * @since       2.0
+        *
+        * @return              The globally unique ID
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @endif
+        */
+       Tizen::Base::ByteBuffer* GetUIDN(void) const;
+
+       /**
+        * @if OSPDEPREC
+        * Sets the globally unique ID. @n
+        * UID: globally Unique Identifier (vCalendar 1.0)
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated  This method is deprecated because a string value cannot be handled. @n
+        * Instead of using this method, it is recommended to use SetUid().
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   pUid                                    The globally unique ID
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @endif
+        */
+       result SetUID(const Tizen::Base::ByteBuffer* pUid);
+
+       /**
+        * Gets the globally unique ID. @n
+        * UID: globally Unique Identifier (vCalendar 1.0)
+        *
+        * @since       2.0
+        *
+        * @return              The globally unique ID
+        */
+       Tizen::Base::String GetUid(void) const;
+
+       /**
+        * Sets the globally unique ID. @n
+        * UID: globally Unique Identifier (vCalendar 1.0)
+        *
+        * @since       2.0
+        *
+        * @param[in]   uid                                     The globally unique ID
+        */
+       void SetUid(const Tizen::Base::String& uid);
+
+       /**
+        * Gets the calendar event status. @n
+        * The default status is #EVENT_STATUS_NONE.
+        *
+        * @since       2.0
+        *
+        * @return              The calendar event status
+        * @see                 EventStatus
+        */
+       EventStatus GetStatus(void) const;
+
+       /**
+        * Sets the calendar event status.
+        *
+        * @since       2.0
+        *
+        * @param[in]   status          The status
+        * @see                 EventStatus
+        */
+       void SetStatus(EventStatus status);
+
+       /**
+        * Gets the busy status. @n
+        * The default busy status is #BUSY_STATUS_BUSY.
+        *
+        * @since       2.0
+        *
+        * @return              The busy status
+        * @see                 BusyStatus
+        */
+       BusyStatus GetBusyStatus(void) const;
+
+       /**
+        * Sets the busy status.
+        *
+        * @since       2.0
+        *
+        * @param[in]   busyStatus              The busy status
+        * @see                 BusyStatus
+        */
+       void SetBusyStatus(BusyStatus busyStatus);
+
+       /**
+        * Gets the priority level of the calendar event. @n
+        * The default priority level is #EVENT_PRIORITY_LOW.
+        *
+        * @since       2.0
+        *
+        * @return              The priority level
+        *
+        */
+       EventPriority GetPriority(void) const;
+
+       /**
+        * Sets the priority level of the calendar event.
+        *
+        * @since       2.0
+        *
+        * @param[in]   priority        The priority level to set
+        *
+        */
+       void SetPriority(EventPriority priority);
+
+       /**
+        * Adds an attendee.
+        *
+        * @brief <i> [Compatibility] </i>
+        * @since       2.0
+        * @compatibility       This method has compatibility issues with %Tizen API versions @b prior @b to @b 2.1. @n
+        *                                      For more information, see @ref CompCalEventAddAttendeePage "here".
+        *
+        * @return              An error code
+        * @param[in]   attendee                        The attendee to add @n
+        *                                                                      The specified @c attendee must have an email address.
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c attendee is invalid. @b Since @b 2.1
+        * @exception   E_OBJ_ALREADY_EXIST     An attendee with the same email address already exists.
+        */
+       result AddAttendee(const Attendee& attendee);
+
+       /**
+        * @page        CompCalEventAddAttendeePage Compatibility for AddAttendee()
+        * @section     CompCalEventAddAttendeePageIssueSection Issues
+        *                      Implementation of this method in %Tizen API versions prior to 2.1 has the following issue: @n
+        *                      - If the email of @c attendee is empty, @c E_OBJ_ALREADY_EXIST is returned.
+        *
+        * @section     CompCalEventAddAttendeePageSolutionSection Resolutions
+        *                      The issue mentioned above is resolved in %Tizen API version 2.1.
+        *                      - If the email of @c attendee is empty, @c E_INVALID_ARG is returned.
+        */
+
+       /**
+        * Removes an attendee.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   attendee                        The attendee to remove @n
+        *                                                                      The specified @c attendee must have an email address.
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OBJ_NOT_FOUND         An attendee with the same email address is not found.
+        */
+       result RemoveAttendee(const Attendee& attendee);
+
+       /**
+        * Gets the list of attendees.
+        *
+        * @since       2.0
+        *
+        * @return              The list of attendees
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @see                 Attendee
+        */
+       Tizen::Base::Collection::IList* GetAllAttendeesN(void) const;
+
+       /**
+        * Gets the time zone.
+        *
+        * @since       2.0
+        *
+        * @return              The time zone based on the time zone ID and the start time of the %CalEvent instance
+        * @see                 Tizen::Locales::TimeZone::GetTimeZone(const Tizen::Base::String&, const Tizen::Base::DateTime&, Tizen::Locales::TimeZone&)
+        */
+       Tizen::Locales::TimeZone GetTimeZone(void) const;
+
+       /**
+        * Sets the time zone. @n
+        * Recurrence is calculated based on the time zone, thus the time zone must be set before setting a recurrence.
+        * If the time zone is not set, it is considered as Greenwich Mean Time (GMT).
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   timeZone                        The time zone to set
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_FAILURE                       The method has failed.
+        * @remarks
+        *                              - As all day events are not affected by a time zone, it is recommended not to set the time zone.
+        *                              - Only the time zone ID of the @c timeZone is set to the %CalEvent instance, and the other properties are ignored.
+        */
+       result SetTimeZone(const Tizen::Locales::TimeZone& timeZone);
+
+       /**
+        * @if OSPDEPREC
+        * Gets the recurrence ID. @n
+        * The %GetRecurrenceId() method works only for the %CalEvent instances.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated  This method is deprecated because the %CalEvent class is not used for an event instance any more. @n
+        * Instead of using the %CalEvent class, it is recommended to use the CalEventInstance class for an event instance.
+        * @since       2.0
+        *
+        * @return              The recurrence ID
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 The instance is a %CalEvent instance that does not have a recurrence ID.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @endif
+        */
+       RecurrenceId GetRecurrenceId(void) const;
+
+       /**
+        * Gets the subject of the calendar event.
+        *
+        * @since       2.0
+        *
+        * @return              The subject, @n
+        *                              else @c null if there is no subject value
+        */
+       Tizen::Base::String GetSubject(void) const;
+
+       /**
+        * Gets the description of the calendar event.
+        *
+        * @since       2.0
+        *
+        * @return              The description
+        */
+       Tizen::Base::String GetDescription(void) const;
+
+       /**
+        * Gets the start date and time of the calendar event.
+        *
+        * @since       2.0
+        *
+        * @return              An instance of Tizen::Base::DateTime that represents the start date and time
+        */
+       Tizen::Base::DateTime GetStartTime(void) const;
+
+       /**
+        * Gets the end date and time of the calendar event.
+        *
+        * @since       2.0
+        *
+        * @return              An instance of Tizen::Base::DateTime that represents the end date and time
+        */
+       Tizen::Base::DateTime GetEndTime(void) const;
+
+       /**
+        * Gets the location of the calendar event.
+        *
+        * @since       2.0
+        *
+        * @return              The location
+        */
+       Tizen::Base::String GetLocation(void) const;
+
+       /**
+        * @if OSPDEPREC
+        * Gets the category of the calendar event.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated  This method is deprecated because the category of the event is not used any more.
+        * @since       2.0
+        *
+        * @return              The category of the calendar event
+        * @endif
+        */
+       EventCategory GetCategory(void) const;
+
+       /**
+        * Gets the sensitivity of the calendar event. @n
+        * The default value is #SENSITIVITY_PUBLIC.
+        *
+        * @since       2.0
+        *
+        * @return              The sensitivity of the calendar event
+        */
+       RecordSensitivity GetSensitivity(void) const;
+
+
+       /**
+        * @if OSPDEPREC
+        * Gets the reminder for the calendar event.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated          This method is deprecated. Instead of using this method, it is recommended to use GetAllReminders().
+        * @since       2.0
+        *
+        * @return              A pointer to an instance of Reminder, @n
+        *                              else @c null if the reminder is not set
+        * @endif
+        */
+       const Reminder* GetReminder(void) const;
+
+       /**
+        * Gets the recurrence of the calendar event.
+        *
+        * @since       2.0
+        *
+        * @return              A pointer to an instance of Recurrence, @n
+        *                              else @c null if the event is not a recurring event
+        */
+       const Recurrence* GetRecurrence(void) const;
+
+       /**
+        * Gets the last updated date and time of the calendar event.
+        *
+        * @since       2.0
+        *
+        * @return              The last updated date and time
+        */
+       Tizen::Base::DateTime GetLastRevisedTime(void) const;
+
+       /**
+        * Sets the subject of the calendar event.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility       This method has compatibility issues with OSP compatible applications. @n
+        *                                      For more information, see @ref CompCalEventSetSubjectPage "here".
+        * @endif
+        *
+        * @return              An error code
+        * @param[in]   subject                         The subject of the calendar event
+        * @exception   E_SUCCESS                       The method is successful.
+        */
+       result SetSubject(const Tizen::Base::String& subject);
+
+       /**
+        * @if OSPCOMPAT
+        * @page        CompCalEventSetSubjectPage Compatibility for SetSubject()
+        * @section     CompCalEventSetSubjectPageIssueSection Issues
+        *          Implementing this method in OSP compatible applications has the following issues: @n
+        *                      -# If the length of the subject to be set is greater than @c 100 characters, @c E_INVALID_ARG is returned.
+        *
+        * @section     CompCalEventSetSubjectPageSolutionSection Resolutions
+        *                      This issue has been resolved in Tizen. @n
+        *                      -# There is no limit for the length of the subject.
+        * @endif
+        */
+
+       /**
+        * Sets the description of the current calendar event.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility       This method has compatibility issues with OSP compatible applications. @n
+        *                                      For more information, see @ref CompCalEventSetDescriptionPage "here".
+        * @endif
+        *
+        * @return              An error code
+        * @param[in]   description                     The description of the event
+        * @exception   E_SUCCESS                       The method is successful.
+        */
+       result SetDescription(const Tizen::Base::String& description);
+
+       /**
+        * @if OSPCOMPAT
+        * @page        CompCalEventSetDescriptionPage Compatibility for SetDescription()
+        * @section     CompCalEventSetDescriptionPageIssueSection Issues
+        *          Implementing this method in OSP compatible applications has the following issues: @n
+        *                      -# If the length of the description to be set is greater than @c 1000 characters, @c E_INVALID_ARG is returned.
+        *
+        * @section     CompCalEventSetDescriptionPageSolutionSection Resolutions
+        *                      This issue has been resolved in Tizen. @n
+        *                      -# There is no limit for the length of the description.
+        * @endif
+        */
+
+       /**
+        * Sets the start and end date and time of the calendar event. @n
+        * If the start date and time is not fixed, the default date and time are set. @n
+        * The default start date and time is the current date and time. @n
+        * The start date and time must be earlier than or equal to the end date and time. @n
+        * If the recurrence date is already set, this method returns an exception.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   startDateTime                   The start date and time @n Any value with a unit that is less than a second is ignored.
+        * @param[in]   endDateTime                             The end date and time @n Any value with a unit that is less than a second is ignored.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The specified @c endDateTime value is earlier than the specified @c startDateTime value.
+        *                                                                              - The specified @c startDateTime or @c endDateTime is out of the valid range. @n
+        *                                                                              The valid range of the date can be referenced from GetMaxDateTime() and GetMinDateTime().
+        * @exception   E_INVALID_CONDITION             The recurrence date is already set.
+        * @remarks             
+        *                              - The start and end time of all day events created from the base applications is the local time of the location where
+        *                              they are added. @n
+        *                              All the other events are in Coordinated Universal Time (UTC). @n
+        *                              In order to integrate it with the base applications, set the start and end time properly according to the above guidelines. @n
+        *                              If the seconds value of the start time is set, the alarm will not be fired.
+        *                              - There is no automatic time conversion based on the time zone property of the calendar event.
+        */
+       result SetStartAndEndTime(const Tizen::Base::DateTime& startDateTime, const Tizen::Base::DateTime& endDateTime);
+
+       /**
+        * Sets the location of the current calendar event.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility       This method has compatibility issues with OSP compatible applications. @n
+        *                                      For more information, see @ref CompCalEventSetLocationPage "here".
+        * @endif
+        *
+        * @return              An error code
+        * @param[in]   location                        The location of the event
+        * @exception   E_SUCCESS                       The method is successful.
+        */
+       result SetLocation(const Tizen::Base::String& location);
+
+       /**
+        * @if OSPCOMPAT
+        * @page        CompCalEventSetLocationPage Compatibility for SetLocation()
+        * @section     CompCalEventSetLocationPageIssueSection Issues
+        *          Implementing this method in OSP compatible applications has the following issues: @n
+        *                      -# If the length of the location to be set is greater than @c 100 characters, @c E_INVALID_ARG is returned.
+        *
+        * @section     CompCalEventSetLocationPageSolutionSection Resolutions
+        *                      This issue has been resolved in Tizen. @n
+        *                      -# There is no limit for the length of the location.
+        * @endif
+        */
+
+       /**
+        * @cond OSPDEPREC
+        * Sets the category of the calendar event. @n
+        * If the category is not set, the default category (#EVENT_CATEGORY_APPOINTMENT) is set.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Deprecated] [Compatibility] </i>
+        * @endif
+        * @deprecated  This method is deprecated because the category of the event is not used any more.
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility       This method has compatibility issues with OSP compatible applications. @n
+        *                                      For more information, see @ref CompCalEventSetCategoryPage "here".
+        * @endif
+        *
+        * @param[in]   category                        The category of the event
+        * @remarks             The start and end time of the anniversary and all day events created from the base applications, is the local time of the location where
+        *                              they are added.
+        *                              All the other events are Coordinated Universal Time (UTC).
+        *                              In order to integrate it with the base applications, set the start and end time properly according to the above guidelines.
+        * @endcond
+        */
+       void SetCategory(EventCategory category);
+
+       /**
+        * @if OSPCOMPAT
+        * @page                CompCalEventSetCategoryPage             Compatibility for SetCategory()
+        * @section             CompCalEventSetCategoryPageIssueSection Issues
+        *                              Implementing this method in OSP compatible applications has the following issues: @n
+        *
+        *                              -# When the anniversary category is set to the event, it is handled as an all day event even though the all day event property is not set.
+        *
+        * @section             CompCalEventSetCategoryPageSolutionSection Resolutions
+        *
+        *  This issue has been resolved in Tizen. @n
+        *  -# The category property is deprecated and it is not used any more.
+        *  In Tizen, the all day event property is set simultaneously when the anniversary category is set to the event.
+        *  If an application tries to change the all day event property of the anniversary event to @c false, it is not changed.
+        * @endif
+        */
+
+       /**
+        * Sets the sensitivity of the calendar event.
+        *
+        * @since       2.0
+        *
+        * @param[in]   sensitivity             The sensitivity of the calendar event
+        */
+       void SetSensitivity(RecordSensitivity sensitivity);
+
+       /**
+        * Sets the coordinates.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   latitude                        The latitude within the range @n The valid range is [-90.0, 90.0].
+        * @param[in]   longitude                       The longitude within the range @n The valid range is [-180.0, 180.0].
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c latitude or @c longitude is outside the valid range.
+        */
+       result SetCoordinates(double latitude, double longitude);
+
+       /**
+        * Gets the coordinates.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[out]  latitude                The latitude
+        * @param[out]  longitude               The longitude
+        */
+       void GetCoordinates(double& latitude, double& longitude) const;
+
+       /**
+        * @if OSPDEPREC
+        * Sets the reminder of the calendar event.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated          This method is deprecated. Instead of using this method, it is recommended to use AddReminder() and RemoveReminderAt().
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   pReminder                               The reminder to set, @n
+        *                                                                              else @c null to remove the previous reminder
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @endif
+        */
+       result SetReminder(const Reminder* pReminder);
+
+       /**
+        * Sets the recurrence of the calendar event. @n
+        * The recurrence rule date must be equal to the start date of the event. @n
+        * If the event start date is different than the recurrence rule date, the event start date is set to match the recurrence rule date. @n
+        * For example, if an event start date is 17/02/2010, that is Wednesday and the recurrence rule date is Thursday of every week,
+        * the event start date changes to 18/02/2010, after this method is called. @n
+        * Note that the start/end date and the time zone must be set before setting a recurrence.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility This method has compatibility issues with OSP compatible applications. @n
+        *                For more information, see @ref CompCalEventSetRecurrencePage "here".
+        * @endif
+        *
+        * @return              An error code
+        * @param[in]   pRecurrence                             The recurrence to set, @n
+        *                                                                              else @c null to remove the previous recurrence
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 The current event is a %CalEvent instance that has a recurrence ID.
+        * @exception   E_INVALID_CONDITION             Either of the following conditions has occurred:
+        *                                                                              - The recurrence rule date is earlier than the start date and time of the event.
+        *                                                                              - The recurrence rule is invalid.
+        *                                                                              - The duration of the event is too long. @n
+        *                                                                              It must be shorter than the (interval x frequency) days set for the recurrence rule.
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - When the frequency is #FREQ_WEEKLY, DayOfWeek is not set.
+        *                                                                              - When the frequency is #FREQ_MONTHLY, neither DayOfMonth nor DayOfWeek and WeekOfMonth are set.
+        *                                                                              - When the frequency is #FREQ_YEARLY, neither DayOfMonth and MonthOfYear nor DayOfWeek,
+        *                                                                                WeekOfMonth and MonthOfYear are set.
+        *                                                                              - When the frequency is #FREQ_YEARLY and MonthOfYear is @c 2, DayOfMonth is greater than @c 29 (> 29).
+        *                                                                              - When the frequency is #FREQ_YEARLY and MonthOfYear is @c 4, @c 6, @c 9 or @c 11,
+        *                                                                                DayOfMonth is greater than @c 30 (> 30).
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             If the until property of the recurrence is set too far from the event's start date, @n
+        *                              too many recurring events are generated. It is the same when the value of the recurrence count is large. @n
+        *                              The system limits the count of the recurring events that are generated by the recurrence rule of an event. @n
+        *                              In this case, some recurring events that exceed the system limitation cannot be retrieved.
+        *
+        * The following example demonstrates how to use the %SetRecurrence() method.
+        * @code
+               MyClass::SetEventRecurrence(void)
+               {
+                       result r = E_SUCCESS;
+                       Recurrence* pRecurrence = new Recurrence();
+
+                       pRecurrence->SetFrequency(FREQ_WEEKLY);
+                       pRecurrence->SetDayOfWeek(CAL_MONDAY);
+
+                       r = __pCalEvent->SetRecurrence(pRecurrence);
+
+                       delete pRecurrence;
+               }
+        * @endcode
+        */
+       result SetRecurrence(const Recurrence* pRecurrence);
+
+       /**
+        * @if OSPCOMPAT
+        * @page        CompCalEventSetRecurrencePage Compatibility for SetRecurrence()
+        * @section     CompCalEventSetRecurrencePageIssueSection Issues
+        *           Implementing this method in OSP compatible applications has the following issues: @n
+        *                      - If the category is anniversary and the frequency of recurrence is not yearly, @c E_TYPE_MISMATCH exception is returned. @n
+        *                       Yearly frequency is only accepted for the anniversary category.
+        *
+        * @section     CompCalEventSetRecurrencePageSolutionSection Resolutions
+        *                      This issue has been resolved in Tizen. @n
+        *                      -# All recurrence frequencies are accepted because the category of the event is not used any more.
+        * @endif
+        */
+
+       /**
+        * Adds a reminder.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   reminder                        The reminder to add
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        */
+       result AddReminder(const Reminder& reminder);
+
+       /**
+        * Removes a reminder at the index.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   index                           The index of the reminder to remove
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_RANGE          Either of the following conditions has occurred:
+        *                                                                      - The specified @c index is either greater than or equal to the number of reminders.
+        *                                                                      - The specified @c index is less than @c 0.
+        */
+       result RemoveReminderAt(int index);
+
+       /**
+        * Gets the list of reminders.
+        *
+        * @since       2.0
+        *
+        * @return              The list that contains Reminder instances, @n
+        *                              else an empty list if there are no reminders
+        */
+       const Tizen::Base::Collection::IList& GetAllReminders(void) const;
+
+       /**
+        * Gets the ID of the calendar to which this event belongs.
+        *
+        * @since       2.0
+        *
+        * @return              The calendar Id
+        */
+       RecordId GetCalendarId(void) const;
+
+       /**
+        * Gets the base event ID.
+        * This method returns the ID of the base recurring event for which this event is a recurrence exception.
+        *
+        * @since       2.1
+        *
+        * @return              The base event ID, if this event is an exception
+        *                              else #INVALID_RECORD_ID
+        */
+       RecordId GetBaseEventId(void) const;
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %CalEvent to copy
+        */
+       CalEvent& operator =(const CalEvent& rhs);
+
+private:
+       friend class _CalEventImpl;
+       class _CalEventImpl* __pCalEventImpl;
+};     // CalEvent
+
+}}     // Tizen::Social
+
+#endif // _FSCL_CAL_EVENT_H_
diff --git a/inc/FSclCalEventChangeInfo.h b/inc/FSclCalEventChangeInfo.h
new file mode 100644 (file)
index 0000000..13ad34c
--- /dev/null
@@ -0,0 +1,143 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+  * @file      FSclCalEventChangeInfo.h
+  * @brief     This is the header file for the %CalEventChangeInfo class.
+  *
+  * This header file contains the declarations of the %CalEventChangeInfo class.
+  */
+#ifndef _FSCL_CAL_EVENT_CHANGE_INFO_H_
+#define _FSCL_CAL_EVENT_CHANGE_INFO_H_
+
+#include <FBaseObject.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @class      CalEventChangeInfo
+ * @brief      This class represents the calendar event change information.
+ *
+ * @since      2.0
+ *
+ * @final      This class is not intended for extension.
+ *
+ *     The %CalEventChangeInfo class represents the change information of an event that is managed in the calendarbook.
+ */
+class _OSP_EXPORT_ CalEventChangeInfo
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.0
+        */
+       CalEventChangeInfo(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %CalEventChangeInfo to copy
+        */
+       CalEventChangeInfo(const CalEventChangeInfo& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~CalEventChangeInfo(void);
+
+       /**
+        * Compares the specified Tizen::Base::Object with the current %CalEventChangeInfo instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the specified object equals the current %CalEventChangeInfo instance, @n
+        *                              else @c false
+        * @param[in]   rhs     The object instance to compare with the current object
+        * @see                 GetHashCode()
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the change type.
+        *
+        * @since       2.0
+        *
+        * @return              The change type
+        */
+       RecordChangeType GetChangeType(void) const;
+
+       /**
+        * Gets the changed event ID.
+        *
+        * @since       2.0
+        *
+        * @return              The changed event ID
+        */
+       RecordId GetEventId(void) const;
+
+       /**
+        * Gets the calendar ID to which the changed event belongs.
+        *
+        * @since       2.0
+        *
+        * @return              The calendar ID to which the changed event belongs
+        */
+       RecordId GetCalendarId(void) const;
+
+       /**
+        * Gets the version of the change.
+        *
+        * @since       2.0
+        *
+        * @return              The version of the change
+        */
+       int GetVersion(void) const;
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %CalEventChangeInfo to copy
+        */
+       CalEventChangeInfo& operator =(const CalEventChangeInfo& rhs);
+
+private:
+       friend class _CalEventChangeInfoImpl;
+       class _CalEventChangeInfoImpl* __pCalEventChangeInfoImpl;
+
+};     // CalEventChangeInfo
+
+}}     // Tizen::Social
+
+#endif // _FSCL_CAL_EVENT_CHANGE_INFO_H_
+
diff --git a/inc/FSclCalEventInstance.h b/inc/FSclCalEventInstance.h
new file mode 100644 (file)
index 0000000..a439128
--- /dev/null
@@ -0,0 +1,242 @@
+// 
+// Copyright (c) 2012 Samsung Electronics Co., Ltd. 
+// 
+// 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.
+//
+/**
+ * @file       FSclCalEventInstance.h
+ * @brief      This is the header file for the %CalEventInstance class.
+ *
+ * This header file contains the declarations of the %CalEventInstance class.
+ */
+#ifndef _FSCL_CAL_EVENT_INSTANCE_H_
+#define _FSCL_CAL_EVENT_INSTANCE_H_
+
+#include <FBaseObject.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+class DateTime;
+}}
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @class      CalEventInstance
+ * @brief      This class represents the instance of a calendar book event.
+ *
+ * @since      2.0
+ *
+ * @final      This class is not intended for extension.
+ *
+ * The %CalEventInstance class represents the instance of a calendar book event.
+ */
+class _OSP_EXPORT_ CalEventInstance
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.0
+        */
+       CalEventInstance(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %CalEventInstance to copy
+        */
+       CalEventInstance(const CalEventInstance& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~CalEventInstance(void);
+
+       /**
+        * Compares the specified Tizen::Base::Object with the current %CalEventInstance instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the specified object equals the current %CalEventInstance instance, @n
+        *                              else @c false
+        * @param[in]   rhs     The object instance to compare with the current object
+        * @see                 GetHashCode()
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the original event ID.
+        *
+        * @since       2.0
+        *
+        * @return              The original event ID
+        */
+       RecordId GetOriginalEventId(void) const;
+
+       /**
+        * Gets the calendar ID.
+        *
+        * @since       2.0
+        *
+        * @return              The calendar ID
+        */
+       RecordId GetCalendarId(void) const;
+
+       /**
+        * Gets the start time.
+        *
+        * @since       2.0
+        *
+        * @return              The start time
+        */
+       Tizen::Base::DateTime GetStartTime(void) const;
+
+       /**
+        * Gets the end time.
+        *
+        * @since       2.0
+        *
+        * @return              The end time
+        */
+       Tizen::Base::DateTime GetEndTime(void) const;
+
+       /**
+        * Gets the subject.
+        *
+        * @since       2.0
+        *
+        * @return              The subject
+        */
+       Tizen::Base::String GetSubject(void) const;
+
+       /**
+        * Gets the description.
+        *
+        * @since       2.0
+        *
+        * @return              The description
+        */
+       Tizen::Base::String GetDescription(void) const;
+
+       /**
+        * Gets the location.
+        *
+        * @since       2.0
+        *
+        * @return              The location
+        */
+       Tizen::Base::String GetLocation(void) const;
+
+       /**
+        * Checks whether the original event of this instance is an all day event.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the original event of this instance is an all day event, @n
+        *                              else @c false
+        */
+       bool IsAllDayEvent(void) const;
+
+       /**
+        * Gets the busy status.
+        *
+        * @since       2.0
+        *
+        * @return              The busy status
+        */
+       BusyStatus GetBusyStatus(void) const;
+
+       /**
+        * Gets the event status.
+        *
+        * @since       2.0
+        *
+        * @return              The event status
+        */
+       EventStatus GetStatus(void) const;
+
+       /**
+        * Gets the priority.
+        *
+        * @since       2.0
+        *
+        * @return              The priority
+        */
+       EventPriority GetPriority(void) const;
+
+       /**
+        * Gets the sensitivity.
+        *
+        * @since       2.0
+        *
+        * @return              The sensitivity
+        */
+       RecordSensitivity GetSensitivity(void) const;
+
+       /**
+        * Checks whether the event instance has a recurring pattern.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the event instance has a recurring pattern, @n
+        *                              else @c false
+        */
+       bool IsRecurring(void) const;
+
+       /**
+        * Checks whether the event instance has reminders.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the event instance has reminders, @n
+        *                              else @c false
+        */
+       bool HasReminder(void) const;
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %CalEventInstance to copy
+        */
+       CalEventInstance& operator =(const CalEventInstance& rhs);
+
+private:
+       friend class _CalEventInstanceImpl;
+       class _CalEventInstanceImpl* __pCalEventInstanceImpl;
+}; // CalEventInstance
+
+}} // Tizen::Social
+
+#endif // _FSCL_CAL_EVENT_INSTANCE_H_
+
diff --git a/inc/FSclCalTodo.h b/inc/FSclCalTodo.h
new file mode 100644 (file)
index 0000000..fcd7653
--- /dev/null
@@ -0,0 +1,467 @@
+// 
+// Copyright (c) 2012 Samsung Electronics Co., Ltd. 
+// 
+// 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.
+//
+/**
+ * @file               FSclCalTodo.h
+ * @brief              This is the header file for the %CalTodo class.
+ *
+ * This header file contains the declarations of the %CalTodo class.
+ */
+#ifndef _FSCL_CAL_TODO_H_
+#define _FSCL_CAL_TODO_H_
+
+#include <FBaseDataType.h>
+#include <FSclTypes.h>
+#include <FSclRecord.h>
+#include <FSclRecurrence.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+class DateTime;
+
+namespace Collection
+{
+class IList;
+}
+}}
+
+namespace Tizen { namespace Social
+{
+
+class Reminder;
+
+/**
+ *     @class  CalTodo
+ *     @brief  This class represents the calendar book to-do information.
+ *
+ * @since      2.0
+ *
+ *     @final  This class is not intended for extension.
+ *
+ * The %CalTodo class is a subset of vTodo. An instance of %CalTodo includes the subject, description, start date, due date, location, sensitivity,
+ * priority, and status.
+ * This class represents the information of a calendar book to-do.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/social/caltodo.htm">Calendar Tasks</a>.
+ *
+ */
+class _OSP_EXPORT_ CalTodo
+       : public Record
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.0
+        */
+       CalTodo(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %CalTodo to copy
+        */
+       CalTodo(const CalTodo& rhs);
+
+       /**
+        * This destructor overrides Tizen::Social::Record::~Record().
+        *
+        * @since       2.0
+        */
+       virtual ~CalTodo(void);
+
+       /**
+        * Compares the specified Tizen::Base::Object with the current %CalTodo instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the specified object equals the current %CalTodo instance, @n
+        *                              else @c false
+        * @param[in]   rhs     The object instance to compare with the current object
+        * @see                 GetHashCode()
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the subject of the current instance of %CalTodo.
+        *
+        * @since       2.0
+        *
+        * @return              The subject
+        */
+       Tizen::Base::String GetSubject(void) const;
+
+       /**
+        * Gets the description of the current instance of %CalTodo.
+        *
+        * @since       2.0
+        *
+        * @return       The description
+        */
+       Tizen::Base::String GetDescription(void) const;
+
+       /**
+        * Gets the start date of the current instance of %CalTodo.
+        *
+        * @since       2.0
+        *
+        * @return              The start date, @n
+        *                              the minimum value of Tizen::Base::DateTime, if the start date has been not set
+        * @exception           E_SUCCESS                               The method is successful.
+        * @exception           E_DATA_NOT_FOUND                The start date has been not set.
+        * @remarks             
+        *                              - The specific error code can be accessed using the GetLastResult() method.
+        *                              - The minimum value can be acquired using Tizen::Base::DateTime::GetMinValue().
+        */
+       Tizen::Base::DateTime GetStartDate(void) const;
+
+       /**
+        * Gets the due date of the current instance of %CalTodo.
+        *
+        * @since       2.0
+        *
+        * @return              The due date, @n
+        *                              the minimum value of Tizen::Base::DateTime, if the due date has been not set
+        * @exception           E_SUCCESS                                       The method is successful.
+        * @exception           E_DATA_NOT_FOUND                        The due date has been not set.
+        * @remarks             
+        *                              - The specific error code can be accessed using the GetLastResult() method.
+        *                              - The minimum value can be acquired using Tizen::Base::DateTime::GetMinValue().
+        */
+       Tizen::Base::DateTime GetDueDate(void) const;
+
+       /**
+        * Gets the priority level of the current instance of %CalTodo. @n
+        * The default priority level is #TODO_PRIORITY_LOW.
+        *
+        * @since       2.0
+        *
+        * @return              The priority level
+        */
+       TodoPriority GetPriority(void) const;
+
+       /**
+        * Gets the status of the current instance of %CalTodo. @n
+        * The default status is #TODO_STATUS_NONE.
+        *
+        * @since       2.0
+        *
+        * @return              The to-do status
+        */
+       TodoStatus GetStatus(void) const;
+
+       /**
+        * Gets the sensitivity of the current instance of %CalTodo. @n
+        * The default value is #SENSITIVITY_PUBLIC.
+        *
+        * @since       2.0
+        *
+        * @return              The to-do sensitivity
+        */
+       RecordSensitivity GetSensitivity(void) const;
+
+       /**
+        * Gets the last updated date and time of the current instance of %CalTodo.
+        *
+        * @since       2.0
+        *
+        * @return              The last updated date and time
+        */
+       Tizen::Base::DateTime GetLastRevisedTime(void) const;
+
+       /**
+        * Sets the subject of the current instance of %CalTodo.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility       This method has compatibility issues with OSP compatible applications. @n
+        *                                      For more information, see @ref CompCalTodoSetSubjectPage "here".
+        * @endif
+        *
+        * @return              An error code
+        * @param[in]   subject                         The to-do subject
+        * @exception   E_SUCCESS                       The method is successful.
+        */
+       result SetSubject(const Tizen::Base::String& subject);
+
+       /**
+        * @if OSPCOMPAT
+        * @page        CompCalTodoSetSubjectPage Compatibility for SetSubject()
+        * @section     CompCalTodoSetSubjectPageIssueSection Issues
+        *                      Implementing this method in OSP compatible applications has the following issues: @n
+        *                      -# If the length of the subject to be set is greater than @c 100 characters, @c E_INVALID_ARG is returned.
+        *
+        * @section     CompCalTodoSetSubjectPageSolutionSection Resolutions
+        *                      This issue has been resolved in Tizen. @n
+        *                      -# There is no limit for the length of the subject.
+        * @endif
+        */
+
+       /**
+        * Sets the description of the current instance of %CalTodo.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility       This method has compatibility issues with OSP compatible applications. @n
+        *                                      For more information, see @ref CompCalTodoSetDescriptionPage "here".
+        * @endif
+        *
+        * @return              An error code
+        * @param[in]   description             The to-do description, @n
+        *                                                              else @c null to remove the existing value
+        * @exception   E_SUCCESS               The method is successful.
+        */
+       result SetDescription(const Tizen::Base::String& description);
+
+       /**
+        * @if OSPCOMPAT
+        * @page        CompCalTodoSetDescriptionPage Compatibility for SetDescription()
+        * @section     CompCalTodoSetDescriptionPageIssueSection Issues
+        *                      Implementing this method in OSP compatible applications has the following issues: @n
+        *                      -# If the length of the description to be set is greater than @c 1000 characters, @c E_INVALID_ARG is returned.
+        *
+        * @section     CompCalTodoSetDescriptionPageSolutionSection Resolutions
+        *                      This issue has been resolved in Tizen. @n
+        *                      -# There is no limit for the length of the description.
+        * @endif
+        */
+
+       /**
+        * @cond OSPDEPREC
+        * Sets the start date and due date for the current instance of %CalTodo. @n
+        * The due date must be later than or equal to the start date.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Deprecated] [Compatibility] </i>
+        * @endif
+        * @deprecated  This method is deprecated. Instead of using this method, it is recommended to use SetStartDate() and SetDueDate().
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility       This method has compatibility issues with OSP compatible applications. @n
+        *                                      For more information, see @ref CompCalTodoSetStartAndDueDatePage "here".
+        * @endif
+        *
+        * @return              An error code
+        * @param[in]   startDate                       The start date. @n Any value with a unit that is less than a second is ignored.
+        * @param[in]   dueDate                         The due date. @n Any value with a unit that is less than a second is ignored.
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           Either of the following conditions has occurred:
+        *                                                                      - The specified @c dueDate is earlier than the specified @c startDate.
+        *                                                                      - The specified @c startDate or @c dueDate is not a valid range. @n
+        *                                                                      The valid range of the date can be referenced from GetMaxDateTime() and GetMinDateTime().
+        * @endcond
+        */
+       result SetStartAndDueDate(const Tizen::Base::DateTime& startDate, const Tizen::Base::DateTime& dueDate);
+
+       /**
+        * @if OSPCOMPAT
+        * @page        CompCalTodoSetStartAndDueDatePage Compatibility for SetStartAndDueDate()
+        * @section     CompCalTodoSetStartAndDueDatePageIssueSection Issues
+        *                      Implementing this method in OSP compatible applications has the following issues: @n
+        *                      -# The start and due date cannot be unset. And if the SetStartAndDueDate() is not called, the default start and due date @n
+        *                         are set to the system time when the to-do is constructed.
+        *
+        * @section     CompCalTodoSetStartAndDueDatePageSolutionSection Resolutions
+        *                      This issue has been resolved in Tizen. @n
+        *                      -# The default start and due date of the to-do is unset.
+        * @endif
+        */
+
+       /**
+        * Sets the start date for the current instance of %CalTodo. @n
+        * If the @c startDate is the minimum value of Tizen::Base::DateTime, the start date is changed to unset. @n
+        * And if the start date is later than the due date, the due date is changed to unset.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   startDate               The start date. @n Any value with a unit that is less than a second is ignored.
+        * @exception   E_SUCCESS               The method is successful. @n
+        *                                                              The specified @c startDate is between Calendarbook::GetMaxDateTime() and Calendarbook::GetMinDateTime(). @n
+        *                                                              @c startDate is the minimum value of Tizen::Base::DateTime to unset the start date.
+        * @exception   E_INVALID_ARG   The specified @c startDate is invalid.
+        * @remarks             The minimum value can be acquired using Tizen::Base::DateTime::GetMinValue().
+        */
+       result SetStartDate(const Tizen::Base::DateTime& startDate);
+
+       /**
+        * Sets the end date for the current instance of %CalTodo. @n
+        * If the @c dueDate is the minimum value of Tizen::Base::DateTime, the due date is changed to unset. @n
+        * And if the due date is earlier than the start date, the start date is changed to unset.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   dueDate                 The due date. @n Any value with a unit that is less than a second is ignored.
+        * @exception   E_SUCCESS               The method is successful. @n
+        *                                                              The specified @c dueDate is between Calendarbook::GetMaxDateTime() and Calendarbook::GetMinDateTime(). @n
+        *                                                              @c dueDate is the minimum value of Tizen::Base::DateTime to unset the due date.
+        * @exception   E_INVALID_ARG   The specified @c dueDate is invalid.
+        * @remarks             The minimum value can be acquired using Tizen::Base::DateTime::GetMinValue().
+        */
+       result SetDueDate(const Tizen::Base::DateTime& dueDate);
+
+
+       /**
+        * Sets the priority level of the current instance of %CalTodo.
+        *
+        * @since       2.0
+        *
+        * @param[in]   priority                The priority level to set
+        */
+       void SetPriority(TodoPriority priority);
+
+       /**
+        * Sets the status of the current instance of %CalTodo.
+        *
+        * @since       2.0
+        *
+        * @param[in]   status                  The status to set
+        */
+       void SetStatus(TodoStatus status);
+
+       /**
+        * Sets the sensitivity of the current instance of %CalTodo.
+        *
+        * @since       2.0
+        *
+        * @param[in]   sensitivity             The sensitivity to set
+        */
+       void SetSensitivity(RecordSensitivity sensitivity);
+
+       /**
+        * Sets the location of the current calendar event.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   location                        The location of the event
+        */
+       void SetLocation(const Tizen::Base::String& location);
+
+       /**
+        * Gets the location of the calendar event.
+        *
+        * @since       2.0
+        *
+        * @return              The location
+        */
+       Tizen::Base::String GetLocation(void) const;
+
+       /**
+        * Sets the coordinates.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   latitude                The latitude within the range @n The valid range is [-90.0, 90.0].
+        * @param[in]   longitude               The longitude within the range @n The valid range is [-180.0, 180.0].
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c latitude or @c longitude is out of the valid range.
+        */
+       result SetCoordinates(double latitude, double longitude);
+
+       /**
+        * Gets the coordinates.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[out]  latitude                The latitude
+        * @param[out]  longitude               The longitude
+        */
+
+       void GetCoordinates(double& latitude, double& longitude) const;
+
+       /**
+        * Adds a reminder.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   reminder                        The reminder to add
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        */
+       result AddReminder(const Reminder& reminder);
+
+       /**
+        * Removes the reminder at the specified index.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   index                           The index of the reminder to remove
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_RANGE          Either of the following conditions has occurred:
+        *                                                                      - The specified @c index is either greater than or equal to the number of reminders.
+        *                                                                      - The specified @c index is less than @c 0.
+        */
+       result RemoveReminderAt(int index);
+
+       /**
+        * Gets a list of reminders.
+        *
+        * @since       2.0
+        *
+        * @return              The list that contains the Reminder instances, @n
+        *                              else an empty list if there are no reminders
+        */
+       const Tizen::Base::Collection::IList& GetAllReminders(void) const;
+
+       /**
+        * Gets the ID of the calendar to which this to-do belongs.
+        *
+        * @since       2.0
+        *
+        * @return              The calendar ID
+        */
+       RecordId GetCalendarId(void) const;
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %CalTodo to copy
+        */
+       CalTodo& operator =(const CalTodo& rhs);
+
+private:
+       friend class _CalTodoImpl;
+       class _CalTodoImpl* __pCalTodoImpl;
+};     // CalTodo
+
+}}     // Tizen::Social
+
+#endif // _FSCL_CAL_TODO_H_
diff --git a/inc/FSclCalTodoChangeInfo.h b/inc/FSclCalTodoChangeInfo.h
new file mode 100644 (file)
index 0000000..8d445a6
--- /dev/null
@@ -0,0 +1,143 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FSclCalTodoChangeInfo.h
+ * @brief      This is the header file for the %CalTodoChangeInfo class.
+ *
+ * This header file contains the declarations of the %CalTodoChangeInfo class.
+ */
+#ifndef _FSCL_CAL_TODO_CHANGE_INFO_H_
+#define _FSCL_CAL_TODO_CHANGE_INFO_H_
+
+#include <FBaseObject.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @class      CalTodoChangeInfo
+ * @brief      This class represents the calendar to-do change information.
+ *
+ * @since      2.0
+ *
+ * @final      This class is not intended for extension.
+ *
+ *     The %CalTodoChangeInfo class represents the change information of a to-do that is managed in a calendarbook.
+ */
+class _OSP_EXPORT_ CalTodoChangeInfo
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.0
+        */
+       CalTodoChangeInfo(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %CalTodoChangeInfo to copy
+        */
+       CalTodoChangeInfo(const CalTodoChangeInfo& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~CalTodoChangeInfo(void);
+
+       /**
+        * Compares the specified Tizen::Base::Object with the current %CalTodoChangeInfo instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the specified object equals the current %CalTodoChangeInfo instance, @n
+        *                              else @c false
+        * @param[in]   rhs     The object instance to compare with the current object
+        * @see                 GetHashCode()
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the change type.
+        *
+        * @since       2.0
+        *
+        * @return              The change type
+        */
+       RecordChangeType GetChangeType(void) const;
+
+       /**
+        * Gets the changed to-do ID.
+        *
+        * @since       2.0
+        *
+        * @return              The changed to-do ID
+        */
+       RecordId GetTodoId(void) const;
+
+       /**
+        * Gets the calendar ID to which the changed to-do belongs.
+        *
+        * @since       2.0
+        *
+        * @return              The calendar ID to which the changed to-do belongs
+        */
+       RecordId GetCalendarId(void) const;
+
+       /**
+        * Gets the version of the change.
+        *
+        * @since       2.0
+        *
+        * @return              The version of the change
+        */
+       int GetVersion(void) const;
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %CalTodoChangeInfo to copy
+        */
+       CalTodoChangeInfo& operator =(const CalTodoChangeInfo& rhs);
+
+private:
+       friend class _CalTodoChangeInfoImpl;
+       class _CalTodoChangeInfoImpl* __pCalTodoChangeInfoImpl;
+
+};     // CalTodoChangeInfo
+
+}}     // Tizen::Social
+
+#endif // _FSCL_CAL_TODO_CHANGE_INFO_H_
+
diff --git a/inc/FSclCalendar.h b/inc/FSclCalendar.h
new file mode 100644 (file)
index 0000000..237142e
--- /dev/null
@@ -0,0 +1,184 @@
+// 
+// Copyright (c) 2012 Samsung Electronics Co., Ltd. 
+// 
+// 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.
+//
+/**
+ * @file       FSclCalendar.h
+ * @brief      This is the header file for the %Calendar class.
+ *
+ * This header file contains the declarations of the %Calendar class.
+ */
+#ifndef _FSCL_CALENDAR_H_
+#define _FSCL_CALENDAR_H_
+
+#include <FBaseDataType.h>
+#include <FSclTypes.h>
+#include <FSclRecord.h>
+
+namespace Tizen { namespace Base
+{
+class Object;
+class String;
+}}
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @class      Calendar
+ * @brief      This class represents calendar information.
+ *
+ * @since      2.0
+ *
+ * @final      This class is not intended for extension.
+ *
+ * The %Calendar class represents calendar information. @n
+ * Multiple calendars can be created, each of which can have their own events and to-dos. An event or to-do can be retrieved using the respective calendar ID.
+ */
+class _OSP_EXPORT_ Calendar
+       : public Record
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.0
+        *
+        * @param[in]   itemType        The calendar item type to specify which kind of item the calendar can contain
+        */
+       explicit Calendar(CalendarItemType itemType);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %Calendar to copy
+        */
+       Calendar(const Calendar& rhs);
+
+       /**
+        * This destructor overrides Tizen::Social::Record::~Record().
+        *
+        * @since       2.0
+        */
+       virtual ~Calendar(void);
+
+       /**
+        * Compares the specified Tizen::Base::Object with the current %Calendar instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the specified object equals the current %Calendar instance, @n
+        *                              else @c false
+        * @param[in]   rhs     The object instance to compare with the current object
+        * @see                 GetHashCode()
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the calendar name.
+        *
+        * @since       2.0
+        *
+        * @return              The calendar name
+        */
+       Tizen::Base::String GetName(void) const;
+
+       /**
+        * Gets the calendar item type.
+        *
+        * @since       2.0
+        *
+        * @return              The calendar item type
+        */
+       CalendarItemType GetItemType(void) const;
+
+       /**
+        * Gets the account ID.
+        *
+        * @since       2.0
+        *
+        * @return              The account ID
+        */
+       AccountId GetAccountId(void) const;
+
+       /**
+        * Gets the calendar color. @n
+        * If the color has not been set, all color components are set with 0x0 and @c E_DATE_NOT_FOUND exception is returned.
+        *
+        * @since       2.0
+        *
+        * @param[out]          r                                               The red component
+        * @param[out]          g                                               The green component
+        * @param[out]          b                                               The blue component
+        * @exception           E_SUCCESS                               The method is successful.
+        * @exception           E_DATA_NOT_FOUND                The color has not been set.
+        */
+       result GetColor(byte& r, byte& g, byte& b) const;
+
+       /**
+        * Sets the calendar name.
+        *
+        * @since       2.0
+        *
+        * @param[in]   name    The calendar name
+        */
+       void SetName(const Tizen::Base::String& name);
+
+       /**
+        * Sets the calendar color.
+        *
+        * @since       2.0
+        *
+        * @param[in]           r               The red component
+        * @param[in]           g               The green component
+        * @param[in]           b               The blue component
+        */
+       void SetColor(byte r, byte g, byte b);
+
+       /**
+        * Clears the calendar color.
+        *
+        * @since       2.0
+        */
+       void ClearColor(void);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %Calendar to copy
+        */
+       Calendar& operator =(const Calendar& rhs);
+
+private:
+       friend class _CalendarImpl;
+       class _CalendarImpl* __pCalendarImpl;
+
+};     // Calendar
+
+}}     // Tizen::Social
+
+#endif // _FSCL_CALENDAR_H_
diff --git a/inc/FSclCalendarbook.h b/inc/FSclCalendarbook.h
new file mode 100644 (file)
index 0000000..552872f
--- /dev/null
@@ -0,0 +1,1310 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclCalendarbook.h
+ * @brief              This is the header file for the %Calendarbook class.
+ *
+ * This header file contains the declarations of the %Calendarbook class.
+ */
+#ifndef _FSCL_CALENDARBOOK_H_
+#define _FSCL_CALENDARBOOK_H_
+
+#include <FBaseObject.h>
+#include <FBaseDataType.h>
+#include <FSclTypes.h>
+#include <FSclCalEvent.h>
+#include <FSclCalTodo.h>
+#include <FSclIRecordEventListener.h>
+#include <FSclIRecordListener.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+class DateTime;
+namespace Collection
+{
+class IList;
+}
+}}
+
+namespace Tizen { namespace Locales
+{
+class TimeZone;
+}}
+
+
+namespace Tizen { namespace Social
+{
+
+class ICalendarbookEventListener;
+class Calendar;
+class CalEventInstance;
+class CalendarbookFilter;
+
+/**
+ * @class      Calendarbook
+ * @brief      This class manages calendar data such as events, to-dos, and calendars.
+ *
+ * @since      2.0
+ *
+ * @final      This class is not intended for extension.
+ *
+ * The %Calendarbook class manages calendar data such as events, to-dos, and calendars.
+ * The calendar book is a centralized database that is used by multiple applications to store events and to-do information.
+ * A calendar book represents the methods to read, add, remove, and update the events, to-do lists, and calendars stored in the device.
+ * The users must be notified of changes in the calendar book as multiple applications can share, change, or remove the data.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/social/calendarbook_namespace.htm">Calendar book</a>.
+ *
+ * The following example demonstrates how to use the %Calendarbook class to add calendarbook event.
+ * @code
+
+       #include <FSocial.h>
+       #include <FLocales.h>
+
+       using namespace Tizen::Social;
+       using namespace Tizen::Base;
+       using namespace Tizen::Locales;
+
+       void
+       MyCalendarbook::AddEventExample(void)
+       {
+               result r = E_SUCCESS;
+
+               DateTime startWallTime;
+               DateTime endWallTime;
+               DateTime startUtcTime;
+               DateTime endUtcTime;
+
+               // Suppose a user set 2012/7/17 12:00:00 ~ 2012/7/17 14:00:00 in wall time for start/end time
+               startWallTime.SetValue(2012, 7, 17, 12, 0, 0);
+               endWallTime.SetValue(2012, 7, 17, 14, 0, 0);
+
+               // Gets the system time zone
+               LocaleManager localeManager;
+               localeManager.Construct();
+
+               TimeZone timeZone = localeManager.GetSystemTimeZone();
+
+               // Converts the wall time to UTC time before set start and end time of the event
+               startUtcTime = timeZone.WallTimeToUtcTime(startWallTime);
+               endUtcTime = timeZone.WallTimeToUtcTime(endWallTime);
+
+               // Creates a CalEvent instance
+               CalEvent newEvent;
+               newEvent.SetSubject(L"Daily event");
+               newEvent.SetStartAndEndTime(startUtcTime, endUtcTime);
+
+               Recurrence dailyRecurrence;
+               dailyRecurrence.SetFrequency(FREQ_DAILY);
+               dailyRecurrence.SetCounts(10);
+
+               newEvent.SetRecurrence(&dailyRecurrence);
+
+               // Creates a Calendarbook instance
+               Calendarbook* pCalendarbook = new Calendarbook();
+               r = pCalendarbook->Construct();
+               if (IsFailed(r))
+               {
+                       AppLogException("initializing the calendar book has failed");
+                       delete pCalendarbook;
+                       return;
+               }
+
+               // Adds the event
+               r = pCalendarbook->AddEvent(newEvent);
+               if (IsFailed(r))
+               {
+                       AppLogException("AddEvent() has failed");
+                       delete pCalendarbook;
+                       return;
+               }
+
+               delete pCalendarbook;
+       }
+
+ * @endcode
+ *
+ * The following example demonstrates how to use the %Calendarbook class to update calendarbook event.
+ * @code
+
+       #include <FSocial.h>
+       #include <FLocales.h>
+
+       using namespace Tizen::Social;
+       using namespace Tizen::Base;
+       using namespace Tizen::Locales;
+
+       void
+       MyCalendarbook::UpdateEventExample(void)
+       {
+               result r = E_SUCCESS;
+
+               // This specificEventId should have been set as already added event record ID.
+               RecordId specificEventId = 0;
+
+               DateTime changedStartWallTime;
+               DateTime changedEndWallTime;
+               DateTime changedStartUtcTime;
+               DateTime changedEndUtcTime;
+
+               // Suppose a user set 2012/7/18 12:00:00 ~ 2012/7/18 14:00:00 in wall time for start/end time.
+               changedStartWallTime.SetValue(2012, 7, 18, 12, 0, 0);
+               changedEndWallTime.SetValue(2012, 7, 18, 14, 0, 0);
+
+               // Gets the system time zone.
+               LocaleManager localeManager;
+               localeManager.Construct();
+
+               TimeZone timeZone = localeManager.GetSystemTimeZone();
+
+               // Converts the wall time to UTC time before set start and end time of the event.
+               changedStartUtcTime = timeZone.WallTimeToUtcTime(changedStartWallTime);
+               changedEndUtcTime = timeZone.WallTimeToUtcTime(changedEndWallTime);
+
+               // Creates Calendarbook instance.
+               Calendarbook* pCalendarbook = new Calendarbook();
+               r = pCalendarbook->Construct();
+               if (IsFailed(r))
+               {
+                       AppLogException("initializing the calendar book has failed");
+                       delete pCalendarbook;
+                       return;
+               }
+
+               // Retrieves CalEvent instance.
+               CalEvent* pEvent = pCalendarbook->GetEventN(specificEventId);
+               if (pEvent == null)
+               {
+                       AppLogException("Getting the event has failed");
+                       delete pCalendarbook;
+                       return;
+               }
+
+               Recurrence recurrence(*pEvent->GetRecurrence());
+               pEvent->SetRecurrence(null);
+               pEvent->SetStartAndEndTime(changedStartUtcTime, changedEndUtcTime);
+               pEvent->SetRecurrence(&recurrence);
+
+               // Updates the event.
+               r = pCalendarbook->UpdateEvent(*pEvent);
+               if (IsFailed(r))
+               {
+                       AppLogException("UpdateEvent() has failed");
+                       delete pEvent;
+                       delete pCalendarbook;
+                       return;
+               }
+
+               delete pEvent;
+               delete pCalendarbook;
+       }
+
+ * @endcode
+ *
+ * The following example demonstrates how to use the %Calendarbook class to retrieve event instance list.
+ * @code
+
+       #include <FSocial.h>
+       #include <FLocales.h>
+
+       using namespace Tizen::Social;
+       using namespace Tizen::Base;
+       using namespace Tizen::Locales;
+       using namespace Tizen::Base::Collection;
+
+       void
+       MyCalendarbook::RetrieveEventInstanceExample(void)
+       {
+               result r = E_SUCCESS;
+
+               DateTime startRange;
+               DateTime endRange;
+               IList* pEventInstanceList = null;
+
+               DateTime startRangeWallTime;
+               DateTime endRangeWallTime;
+               DateTime startRangeUtcTime;
+               DateTime endRangeUtcTime;
+
+               // Suppose a user set 2012/7/1 00:00:00 ~ 2012/7/31 23:59:59 in wall time for start/end time.
+               startRangeWallTime.SetValue(2012, 7, 1, 0, 0, 0);
+               endRangeWallTime.SetValue(2012, 7, 31, 23, 59, 59);
+
+               // Gets the system time zone.
+               LocaleManager localeManager;
+               localeManager.Construct();
+
+               TimeZone timeZone = localeManager.GetSystemTimeZone();
+
+               // Converts the wall time to UTC time before set start and end time of the event.
+               startRangeUtcTime = timeZone.WallTimeToUtcTime(startRangeWallTime);
+               endRangeUtcTime = timeZone.WallTimeToUtcTime(endRangeWallTime);
+
+               // Creates Calendarbook instance.
+               Calendarbook* pCalendarbook = new Calendarbook();
+               r = pCalendarbook->Construct();
+               if (IsFailed(r))
+               {
+                       AppLogException("initializing the calendar book has failed");
+                       delete pCalendarbook;
+                       return;
+               }
+
+               // Gets the event instances.
+               CalendarbookFilter filter(CB_FI_TYPE_NON_ALL_DAY_EVENT_INSTANCE);
+               filter.AppendDateTime(FI_CONJ_OP_NONE, EVENT_INST_FI_PR_END_TIME, FI_CMP_OP_GREATER_THAN, startRangeUtcTime);
+               filter.AppendDateTime(FI_CONJ_OP_AND, EVENT_INST_FI_PR_START_TIME, FI_CMP_OP_LESS_THAN, endRangeUtcTime);
+
+               pEventInstanceList = pCalendarbook->SearchN(filter, EVENT_INST_FI_PR_START_TIME, SORT_ORDER_ASCENDING);
+               if (pEventInstanceList == null)
+               {
+                       AppLogException("SearchN() is failed");
+                       delete pCalendarbook;
+                       return;
+               }
+
+               IEnumerator* pEnum = pEventInstanceList->GetEnumeratorN();
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       CalEventInstance* pEventInstance = static_cast<CalEventInstance*>(pEnum->GetCurrent());
+
+                       // Reads the properties of pEventInstance.
+                       // ...
+               }
+               delete pEnum;
+
+               // Removes the first event instance of the list.
+               CalEventInstance* pExcludingEventInstance = static_cast<CalEventInstance*>(pEventInstanceList->GetAt(0));
+               r = pCalendarbook->RemoveEventInstance(*pExcludingEventInstance);
+               if (IsFailed(r))
+               {
+                       AppLogException("RemoveEventInstance() has failed");
+                       pEventInstanceList->RemoveAll(true);
+                       delete pEventInstanceList;
+                       delete pCalendarbook;
+                       return;
+               }
+
+               pEventInstanceList->RemoveAll(true);
+               delete pEventInstanceList;
+               delete pCalendarbook;
+       }
+
+ * @endcode
+ */
+
+class _OSP_EXPORT_ Calendarbook
+       : public Tizen::Base::Object
+{
+public:
+
+       /**
+        * The object is not fully constructed after this constructor is called. @n
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since       2.0
+        */
+       Calendarbook(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~Calendarbook(void);
+
+       /**
+        * @if OSPDEPREC
+        * Initializes this instance of %Calendarbook with the specified event listener.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated  This method is deprecated. Instead of using this method, it is recommended to use Construct(ICalendarbookEventListener*).
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   pListener                               The event listener to register, @n
+        *                                                                              else @c null if an event listener need not be registered
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @endif
+        */
+       result Construct(IRecordEventListener* pListener);
+
+       /**
+        * Initializes this instance of %Calendarbook.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       result Construct(void);
+
+       /**
+        * Initializes this instance of %Calendarbook with the specified event listener.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   listener                                The event listener to register
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       result Construct(ICalendarbookEventListener& listener);
+
+       /**
+        * Adds an event of the default calendar to the calendar book. @n
+        * After adding the event successfully, the event has a valid record ID.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.write
+        *
+        * @return              An error code
+        * @param[in,out]       event                                   The event to add
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   The specified @c event is invalid.
+        * @exception   E_STORAGE_FULL                  The storage is insufficient.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       result AddEvent(CalEvent& event);
+
+       /**
+        * Adds an event of the specific calendar to the calendar book. @n
+        * After adding the event successfully, the event has a valid record ID.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.write
+        *
+        * @return              An error code
+        * @param[in,out]       event                           The event to add
+        * @param[in]   calendarId                              The calendar ID
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The specified @c event is invalid.
+        *                                                                              - The specified @c calendarId is invalid.
+        *                                                                              - The specified calendar does not support a to-do item.
+        * @exception   E_OBJ_NOT_FOUND                 The specified calendar is not found.
+        * @exception   E_STORAGE_FULL                  The storage is insufficient.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       result AddEvent(CalEvent& event, RecordId calendarId);
+
+       /**
+        * Adds a to-do of the default calendar to the calendar book. @n
+        * After adding the to-do item successfully, the item has a valid record ID.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.write
+        *
+        * @return              An error code
+        * @param[in,out]       todo                            The to-do to add
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   The specified @c todo is invalid.
+        * @exception   E_STORAGE_FULL                  The storage is insufficient.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       result AddTodo(CalTodo& todo);
+
+       /**
+        * Adds a to-do of the specific calendar to the calendar book. @n
+        * After adding the to-do item successfully, the item has a valid record ID.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.write
+        *
+        * @return              An error code
+        * @param[in,out]       todo                                    The to-do to add
+        * @param[in]   calendarId                              The calendar ID
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The specified @c todo is invalid.
+        *                                                                              - The specified @c calendarId is invalid.
+        *                                                                              - The specified calendar does not support an event item.
+        * @exception   E_OBJ_NOT_FOUND                 The specified calendar is not found.
+        * @exception   E_STORAGE_FULL                  The storage is insufficient.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       result AddTodo(CalTodo& todo, RecordId calendarId);
+
+       /**
+        * Removes the specified calendar event from this calendar book. @n
+        * After removing the event successfully, the event has #INVALID_RECORD_ID.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.write
+        *
+        * @return              An error code
+        * @param[in]   event                           The calendar event to remove
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   The specified recordId is #INVALID_RECORD_ID.
+        * @exception   E_OBJ_NOT_FOUND                 The specified record is not found.
+        * @exception   E_INVALID_OPERATION             This method cannot be used for the recurrence exception of the recurring event. @n
+        *                                                                              RemoveEventInstance() should be used instead of this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       result RemoveEvent(CalEvent& event);
+
+       /**
+        * Removes the specified calendar event from this calendar book.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.write
+        *
+        * @return              An error code
+        * @param[in]   eventId                                 The calendar event ID to remove
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   The specified @c eventId is #INVALID_RECORD_ID.
+        * @exception   E_OBJ_NOT_FOUND                 The specified record is not found.
+        * @exception   E_INVALID_OPERATION             This method cannot be used for the recurrence exception of the recurring event. @n
+        *                                                                              RemoveEventInstance() should be used instead of this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       result RemoveEvent(RecordId eventId);
+
+       /**
+        * Removes the specified CalTodo instance from the calendar book. @n
+        * After removing the to-do item successfully, the item has #INVALID_RECORD_ID.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.write
+        *
+        * @return              An error code
+        * @param[in]   todo                                    The CalTodo ID to remove
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   The specified recordId is #INVALID_RECORD_ID.
+        * @exception   E_OBJ_NOT_FOUND                 The specified record is not found.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       result RemoveTodo(CalTodo& todo);
+
+       /**
+        * Removes the specified CalTodo instance from the calendar book.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.write
+        *
+        * @return              An error code
+        * @param[in]   todoId                                  The CalTodo ID to remove
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        * @exception   E_OBJ_NOT_FOUND                 The specified record is not found.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       result RemoveTodo(RecordId todoId);
+
+       /**
+        * Updates the specified calendar event to the internal data storage.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.write
+        *
+        * @return              An error code
+        * @param[in]   event                           The CalEvent instance to update
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The specified recordId is #INVALID_RECORD_ID.
+        *                                                                              - The specified @c event is not #RECORD_TYPE_EVENT.
+        *                                                                              - The specified @c event is not an entry type instance.
+        *                                                                              - The date of the event is invalid. @n
+        *                                                                              The valid range of the date can be referenced from GetMaxDateTime() and GetMinDateTime().
+        * @exception   E_OBJ_NOT_FOUND                 The specified record is not found.
+        * @exception   E_INVALID_OPERATION             This method cannot be used for the recurrence exception of the recurring event. @n
+        *                                                                              UpdateEventInstance() should be used instead of this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       result UpdateEvent(const CalEvent& event);
+
+       /**
+        * Updates the specified CalTodo instance on the internal data storage.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.write
+        *
+        * @return              An error code
+        * @param[in]   todo                                    The CalTodo instance to update
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The specified recordId is #INVALID_RECORD_ID.
+        *                                                                              - The date of the to-do item is invalid. @n
+        *                                                                              The valid range of the date can be referenced from GetMaxDateTime() and GetMinDateTime().
+        * @exception   E_OBJ_NOT_FOUND                 The specified record is not found.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       result UpdateTodo(const CalTodo& todo);
+
+       /**
+        * Gets the specified event ID that is matched with the RecordId.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.read
+        *
+        * @return              The matched event
+        * @param[in]   eventId                                 The event ID to find
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   The specified @c eventId is invalid.
+        * @exception   E_OBJ_NOT_FOUND                 The specified record is not found.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        */
+       CalEvent* GetEventN(RecordId eventId) const;
+
+       /**
+        * Gets the specified to-do after matching it with the specified record ID.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.read
+        *
+        * @return              The matched to-do
+        * @param[in]   todoId                                  The ID of the to-do to find
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   The specified @c todoId is invalid.
+        * @exception   E_OBJ_NOT_FOUND                 The specified record is not found.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        *
+        */
+       CalTodo* GetTodoN(RecordId todoId) const;
+
+       /**
+        * Gets all the to-do items in the specified time range. @n
+        * To-do items, whose due date is within the retrieving range, is retrieved.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility This method has compatibility issues with OSP compatible applications. @n
+        *                For more information, see @ref CompCalendarbookGetTodosNPage "here".
+        * @endif
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.read
+        *
+        * @return              The list of all the matched CalTodo instances, @n
+        *                              else an empty list if there is no matched to-do item @n
+        *                              The items are sorted by due date.
+        * @param[in]   start                                   The start of the time range. @n Any value with a unit that is less than a second is ignored.
+        * @param[in]   end                                             The end of the time range. @n Any value with a unit that is less than a second is ignored.
+        * @param[in]   pageNo                                  The page number of the result list @n
+        *                                                                              It starts from @c 1.
+        * @param[in]   countPerPage                    The desired maximum count of the result items per page
+        * @param[in]   status                                  The to-do status @n
+        *                                                                              If a specific status is set, the to-dos that have the specified status are returned. @n
+        *                                                                              The default status value is #TODO_STATUS_ALL, which means all the statuses are returned.
+        * @param[in]   priority                                The to-do priority @n
+        *                                                                              If a specific priority is set, the to-dos that have the specified priority are returned. @n
+        *                                                                              The default priority value is #TODO_PRIORITY_ALL that means all the priorities are returned.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The specified @c pageNo or @c countPerPage is less than @c 1.
+        *                                                                              - The start time is later than the end date.
+        *                                                                              - The start or end time is out of the valid range. @n
+        *                                                                               The valid range of the date can be referenced from GetMaxDateTime() and GetMinDateTime().
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetTodosN(const Tizen::Base::DateTime& start, const Tizen::Base::DateTime& end, int pageNo, int countPerPage, unsigned long status = TODO_STATUS_ALL,
+                                                       unsigned long priority = TODO_PRIORITY_ALL) const;
+
+       /**
+        * @if OSPCOMPAT
+        * @page        CompCalendarbookGetTodosNPage Compatibility for GetTodosN()
+        * @section     CompCalendarbookGetTodosNPageIssueSection Issues
+        *           Implementing this method in OSP compatible applications has the following issues: @n
+        *                      -# If the start date of a to-do is not in the time range of the start/end parameters, @n
+        *                      the to-do is not retrieved even though the due date is in the time range.
+        *
+        * @section     CompCalendarbookGetTodosNPageSolutionSection Resolutions
+        *                      This issue has been resolved in Tizen. @n
+        *                      -# The to-do is retrieved if the due date is in the range of the start/end parameters.
+        * @endif
+        */
+
+       /**
+        * Gets the total number of to-do items in the specified time range. @n
+        * To-do items, whose due date is within the retrieving range, is counted.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility This method has compatibility issues with OSP compatible applications. @n
+        *                For more information, see @ref CompCalendarbookGetTodoCountPage "here".
+        * @endif
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.read
+        *
+        * @return              The total number of to-dos, @n
+        *                              else @c -1 if an exception occurs
+        * @param[in]   start                                   The start of the time range. @n Any value with a unit that is less than a second is ignored.
+        * @param[in]   end                                             The end of the time range. @n Any value with a unit that is less than a second is ignored.
+        * @param[in]   status                                  The to-do status @n
+        *                                                                              If a specific status is set, the to-dos that have the specified status are returned. @n
+        *                                                                              The default status value is #TODO_STATUS_ALL, which means all the statuses are returned.
+        * @param[in]   priority                                The to-do priority @n
+        *                                                                              If a specific priority is set, the to-dos that have the specified priority are returned. @n
+        *                                                                              The default priority value is #TODO_PRIORITY_ALL that means all the priorities are returned.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The start time is later than the end date.
+        *                                                                              - The start or end time is out of the valid range. @n
+        *                                                                              The valid range of the date can be referenced from GetMaxDateTime() and GetMinDateTime().
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       int GetTodoCount(const Tizen::Base::DateTime& start, const Tizen::Base::DateTime& end, unsigned long status = TODO_STATUS_ALL, unsigned long priority = TODO_PRIORITY_ALL) const;
+
+       /**
+        * @if OSPCOMPAT
+        * @page        CompCalendarbookGetTodoCountPage Compatibility for GetTodoCount()
+        * @section     CompCalendarbookGetTodoCountPageIssueSection Issues
+        *           Implementing this method in OSP compatible applications has the following issues: @n
+        *                      -# If the start date of a to-do is not in the time range of the start/end parameters, @n
+        *                      the to-do is not counted even though the due date is in the time range.
+        *
+        * @section     CompCalendarbookGetTodoCountPageSolutionSection Resolutions
+        *                      This issue has been resolved in Tizen. @n
+        *                      -# The to-do is counted if the due date is in the range of the start/end parameters.
+        * @endif
+        */
+
+       /**
+        * @if OSPDEPREC
+        * Gets the CalEvent instances that are within the specified time range. @n
+        * The all day events are retrieved by their start and end dates in the local time zone, while all other events are retrieved by their
+        * start and end times in Coordinated Universal Time (UTC).
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated  This method is deprecated. Instead of using this method, it is recommended to use GetInstancesOfAllDayEventsN() or GetInstancesOfNonAllDayEventsN().
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.read
+        *
+        * @return              The list that contains all of the matched CalEvent instances, @n
+        *                              else an empty list if there are no matched instances, or @c null if an exception occurs @n
+        *                              The results are listed in the following order: all day events, and other events. @n
+        *                              The results with the same property of all day event are ordered by their start time.
+        * @param[in]   start                           The start of the time range. @n Any value with a unit that is less than a second is ignored.
+        * @param[in]   end                                     The end of the time range. @n Any value with a unit that is less than a second is ignored.
+        * @param[in]   timeZone                        The time zone of the specified start and end times
+        * @param[in]   pageNo                          The page number of the result list @n
+        *                                                                      It starts from @c 1.
+        * @param[in]   countPerPage            The desired maximum count of the result items per page
+        * @param[in]   category                        The event category @n
+        *                                                                      If a specific category is set, the events that have the specified category are returned. @n
+        *                                                                      The default category value is #EVENT_CATEGORY_ALL, which means all the categories are returned.
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG           Either of the following conditions has occurred:
+        *                                                                      - The specified @c pageNo or @c countPerPage is less than @c 1.
+        *                                                                      - The specified @c category is invalid.
+        *                                                                      - The start time is later than the end date.
+        *                                                                      - The start or end time is out of the valid range. @n
+        *                                                                      The valid range of the date can be referenced from GetMaxDateTime() and GetMinDateTime().
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @endif
+        */
+       Tizen::Base::Collection::IList* GetEventInstancesN(const Tizen::Base::DateTime& start, const Tizen::Base::DateTime& end,
+                                                                        const Tizen::Locales::TimeZone& timeZone, int pageNo, int countPerPage,
+                                                                        unsigned long category = EVENT_CATEGORY_ALL) const;
+
+       /**
+        * @if OSPDEPREC
+        * Gets the CalEvent instances that are within the specified time range. @n
+        * The all day events are retrieved by their start and end dates in the local time zone, while all other events are retrieved by their
+        * start and end times in Coordinated Universal Time (UTC).
+        *
+        * Although GetEventInstancesN() retrieves the data synchronously, this method returns data asynchronously using
+        * RecordListener::OnEventInstancesReceivedN(). @n
+        * It is highly recommended to use the asynchronous method because getting the event instances may take a long time.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated  This method is deprecated. Instead of using this method, it is recommended to use GetInstancesOfAllDayEventsN() or GetInstancesOfNonAllDayEventsN().
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.read
+        *
+        * @return              An error code
+        * @param[in]   start                                   The start of the time range. @n Any value with a unit that is less than a second is ignored.
+        * @param[in]   end                                             The end of the time range. @n Any value with a unit that is less than a second is ignored.
+        * @param[in]   timeZone                                The time zone of the specified start and end times
+        * @param[in]   pageNo                                  The page number of the result list @n
+        *                                                                              It starts from @c 1.
+        * @param[in]   countPerPage                    The desired maximum count of the result items per page
+        * @param[in]   category                                The event category @n
+        *                                                                              If a specific category is set, the events that have the specified @c category are returned. @n
+        *                                                                              The default category value is #EVENT_CATEGORY_ALL, which means all the categories are returned.
+        * @param[out]  reqId                                   The ID of the request
+        * @param[in]   listener                                The listener for receiving the responses of the request
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The specified @c pageNo or @c countPerPage is less than @c 1.
+        *                                                                              - The specified @c category is invalid.
+        *                                                                              - The start time is later than the end date.
+        *                                                                              - The start or end time is out of the valid range. @n
+        *                                                                              The valid range of the date can be referenced from GetMaxDateTime() and GetMinDateTime().
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             IRecordListener::OnRecordsReceivedN(), Calendarbook::GetEventInstancesN()
+        * @endif
+        */
+       result GetEventInstances(const Tizen::Base::DateTime& start, const Tizen::Base::DateTime& end,
+                                                                       const Tizen::Locales::TimeZone& timeZone, int pageNo, int countPerPage, unsigned long category,
+                                                                       RequestId& reqId,
+                                                                       const IRecordListener& listener) const;
+
+       /**
+        * Gets all the events.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.read
+        *
+        * @return              The list that contains all the CalEvent instances, @n
+        *                              else an empty list if there are no events, or @c null if an exception occurs @n
+        *                              The results are listed in the order of their event ID.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             
+        *                      - The specific error code can be accessed using the GetLastResult() method.
+        *                      - There is a high probability for an occurrence of an out-of-memory exception. If possible, check whether the exception is
+        *                      @c E_OUT_OF_MEMORY or not. For more information on how to handle the out-of-memory exception, refer
+        *                      <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        */
+       Tizen::Base::Collection::IList* GetAllEventsN(void) const;
+
+       /**
+        * Gets all the to-dos.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.read
+        *
+        * @return              The list that contains all the CalTodo instances, @n
+        *                              else an empty list if there are no to-dos, or @c null if an exception occurs @n
+        *                              The results are listed in the order of their to-do ID.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             
+        *                      - The specific error code can be accessed using the GetLastResult() method.
+        *                      - There is a high probability for an occurrence of an out-of-memory exception. If possible, check whether the exception is
+        *                      @c E_OUT_OF_MEMORY or not. For more information on how to handle the out-of-memory exception, refer
+        *                      <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        */
+       Tizen::Base::Collection::IList* GetAllTodosN(void) const;
+
+       /**
+        * Gets all the calendars.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.read
+        *
+        * @return              The list that contains all the Calendar instances, @n
+        *                              else an empty list if there are no calendars, or @c null if an exception occurs @n
+        *                              The results are listed in the order of their calendar ID.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             
+        *                      - The specific error code can be accessed using the GetLastResult() method.
+        *                      - There is a high probability for an occurrence of an out-of-memory exception. If possible, check whether the exception is
+        *                      @c E_OUT_OF_MEMORY or not. For more information on how to handle the out-of-memory exception, refer
+        *                      <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        */
+       Tizen::Base::Collection::IList* GetAllCalendarsN(void) const;
+
+       /**
+        * Gets information of all the changed events since the version.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.read
+        *
+        * @return              The list that contains the CalEventChangeInfo instances, @n
+        *                              else an empty list if there are no events, or @c null if an exception occurs @n
+        *                              The results are listed in the order of their version.
+        * @param[in]   version                                 The version
+        * @param[out]  latestVersion                   The latest change version among the changed events
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   The specified @c version is invalid.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             
+        *                      - The specific error code can be accessed using the GetLastResult() method.
+        *                      - There is a high probability for an occurrence of an out-of-memory exception. If possible, check whether the exception is
+        *                      @c E_OUT_OF_MEMORY or not. For more information on how to handle the out-of-memory exception, refer
+        *                      <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        */
+       Tizen::Base::Collection::IList* GetChangedEventsAfterN(int version, int& latestVersion) const;
+
+       /**
+        * Gets information of all the changed to-dos since the version.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.read
+        *
+        * @return              A list containing the CalTodoChangeInfo instances, @n
+        *                              else an empty list if there are no to-dos, or @c null if an exception occurs @n
+        *                              The results are listed in the order of their version.
+        * @param[in]   version                                 The version
+        * @param[out]  latestVersion                   The latest change version among the changed to-dos
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   The specified @c version is invalid.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             
+        *                      - The specific error code can be accessed using the GetLastResult() method.
+        *                      - There is a high probability for an occurrence of an out-of-memory exception. If possible, check whether the exception is
+        *                      @c E_OUT_OF_MEMORY or not. For more information on how to handle the out-of-memory exception, refer
+        *                      <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        */
+       Tizen::Base::Collection::IList* GetChangedTodosAfterN(int version, int& latestVersion) const;
+
+       /**
+        * Adds a calendar. @n
+        * After adding the calendar to the database successfully, the calendar has a valid calendar ID.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.write
+        *
+        * @return              An error code
+        * @param[in,out]       calendar                        The calendar to add
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   The calendar's recordId is not #INVALID_RECORD_ID.
+        * @exception   E_STORAGE_FULL                  The storage is insufficient.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       result AddCalendar(Calendar& calendar);
+
+       /**
+        * Adds a calendar that is associated with the specified account. @n
+        * After adding the calendar to the database successfully, the calendar has a valid calendar ID.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.write
+        *
+        * @return              An error code
+        * @param[in,out]       calendar                        The calendar to add
+        * @param[in]   accountId                               The account Id
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The calendar's recordId is not #INVALID_RECORD_ID.
+        *                                                                              - The specified @c accountId is invalid.
+        * @exception   E_OBJ_NOT_FOUND                 The specified account is not found.
+        * @exception   E_STORAGE_FULL                  The storage is insufficient.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       result AddCalendar(Calendar& calendar, AccountId accountId);
+
+       /**
+        * Removes the specified calendar.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.write
+        *
+        * @return              An error code
+        * @param[in]   calendarId                              The calendar ID to remove
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The specified @c calendarId is invalid.
+        *                                                                              - The calendar represents default calendar.
+        * @exception   E_OBJ_NOT_FOUND                 The specified calendar is not found.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       result RemoveCalendar(RecordId calendarId);
+
+       /**
+        * Updates the specified calendar.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.write
+        *
+        * @return              An error code
+        * @param[in]   calendar                                The Calendar instance to update
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The calendar's recordId is #INVALID_RECORD_ID.
+        *                                                                              - The calendar represents default calendar.
+        * @exception   E_OBJ_NOT_FOUND                 The specified calendar is not found.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       result UpdateCalendar(const Calendar& calendar);
+
+       /**
+        * Gets the calendar with the specified calendar ID.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.read
+        *
+        * @return              The matched calendar, @n 
+        *              else @c null if an exception occurs
+        * @param[in]   calendarId                              The calendar ID
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   The specified @c calendarId is invalid.
+        * @exception   E_OBJ_NOT_FOUND                 The specified calendar is not found.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Calendar* GetCalendarN(RecordId calendarId) const;
+
+       /**
+        * Removes an instance of the recurring event. @n
+        * If the event instance has been removed successfully, its start date is added as an exception date to the recurrence of its original event.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.write
+        *
+        * @return              An error code
+        * @param[in]   eventInstance                   The event instance to remove @n
+        *                                                                      The @c eventInstance must be an instance of the recurring event.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                   The instance is invalid.
+        * @exception   E_OBJ_NOT_FOUND                 The original event of the specified @c eventInstance is not found.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             The instance's start time is added to the recurrence of original event as exception date.
+        */
+       result RemoveEventInstance(const CalEventInstance& eventInstance);
+
+       /**
+        * Update the specified recurring event instance(@ref CalEventInstance). This method can be used for defining exception of the recurring event. @n
+        * In order to update an event instance, you should use copy of its original event(@ref CalEventInstance::GetOriginalEventId()). @n
+        * You can modify the properties of copy of the original event and use it as the second parameter of this method. @n
+        * (The start/end time of the original event should be set with the start/end time of the event instance.) @n
+        * This method adds the modified copy of the original event as a new event. Therefore the new event ID will be assigned to it through event's record ID @n
+        * and its existing event ID inside the modified copy of the original event will become the base event ID of the new event. @n
+        * However this method only updates the properties of the event, does not add a new event that is already added.
+        *
+        * @since       2.1
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.write
+        *
+        * @return              An error code
+        * @param[in]   eventInstance                   The event instance to update @n
+        *                                                                              The @c eventInstance must be an instance of the recurring event.
+        * @param[in,out]       event                           The modified copy of the original event @n
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method.
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The instance is invalid.
+        *                                                                              - The specified @c event is not referring to the original event.
+        * @exception   E_OBJ_NOT_FOUND                 The original event of the specified @c eventInstance is not found.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        *
+        * @code
+
+               void UpdateRecurringEventInstance(const CalEventInstance& eventInstance)
+               {
+                       CalEvent* pEvent = pCalendarbook->GetEventN(eventInstance.GetOriginalEventId());
+                       if (pEvent == null)
+                       {
+                               AppLogException("GetEventN() has failed");
+                               return;
+                       }
+
+                       // Sets the start time and end time
+                       pEvent->SetRecurrence(null);
+                       pEvent->SetStartAndEndTime(eventInstance.GetStartTime(), eventInstance.GetEndTime());
+
+                       // Modifies the properties
+                       pEvent->SetLocation(L"Meeting room on 11th floor");
+
+                       // Updates the instance
+                       result r = pCalendarbook->UpdateEventInstance(eventInstance, *pEvent);
+                       if (IsFailed(r))
+                       {
+                               AppLogException("UpdateEventInstance() has failed");
+                               delete pEvent;
+                               return;
+                       }
+
+                       delete pEvent;
+               }
+
+        * @endcode
+        */
+       result UpdateEventInstance(const CalEventInstance& eventInstance, CalEvent& event);
+
+       /**
+        * Gets the latest version of calendarbook.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.read
+        *
+        * @return              The latest version
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        */
+       int GetLatestVersion(void) const;
+
+       /**
+        * Searches items of the calendarbook with the filter. @n
+        * The filter specifies the item type and condition for searching.
+        * The searched results are ordered by the @c propertySortedBy and @c sortOrder.
+        * If the @c offset is M and the @c maxCount are N, then the first M items are omitted from the result set returned by the searching operation and the next N items are returned.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.read
+        *
+        * @return              The list of searched results (the list of CalEvent, CalTodo, Calendar, or CalEventInstance), @n
+        *                              else an empty list if there is no searched result, or @c null if an exception occurs
+        * @param[in]   filter          The filter that specifies the search condition @n If the filter is empty, all items that are specified by the type of this filter are searched.
+        * @param[in]   propertySortedBy                The property for sorting @n The searched results are ordered by the values of this property.
+        * @param[in]   sortOrder               The order for sorting
+        * @param[in]   offset                  The offset of the searched results @n If this value is @c 0, it is ignored.
+        * @param[in]   maxCount                The maximum count of the searched results @n If this value is @c 0, it is ignored.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED                              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_INVALID_ARG                           Either of the following conditions has occurred:
+        *                                                                                      - The specified @c offset or @c maxCount is less than 0.
+        *                                                                                      - The specified @c propertySortedBy is not an element of the enumerator that corresponds to the type of the specified @c filter.
+        * @exception   E_SYSTEM                                        The method cannot proceed due to a severe system error.
+        * @remarks                             
+        *                              - The specific error code can be accessed using the GetLastResult() method.
+        *                              - There is a high probability for an occurrence of an out-of-memory exception. If possible, check whether the exception is
+        *                              @c E_OUT_OF_MEMORY or not. For more information on how to handle the out-of-memory exception, refer
+        *                              <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+         * @see EventFilterProperty
+         * @see TodoFilterProperty
+         * @see CalendarFilterProperty
+         * @see EventInstanceFilterProperty
+        */
+       Tizen::Base::Collection::IList* SearchN(const CalendarbookFilter& filter, unsigned long propertySortedBy = 0, Tizen::Base::SortOrder sortOrder = Tizen::Base::SORT_ORDER_NONE,
+                       int offset = 0, int maxCount = 0) const;
+
+       /**
+        * Gets the matched item count of the search results with the filter. @n
+        * The filter specifies the item type and condition for searching.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/calendar.read
+        *
+        * @return              The count of the searched results
+        * @param[in]   filter  The filter that specifies the search condition @n If the filter is empty, all items that are specified by the type of this filter will be searched.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED                              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        */
+       int GetMatchedItemCount(const CalendarbookFilter& filter) const;
+
+       /**
+        * Parses the events from specific vCalendar file. @n
+        * The %ParseEventsFromVcalendarN() method supports to parse for vCalendar version 1.0 and 2.0 (iCalendar).
+        *
+        * @since       2.0
+        *
+        * @return              The list that contains the CalEvent instances, @n
+        *                              else an empty list if there are no events, or @c null if an exception occurs
+        * @param[in]   vCalFilePath                    The path of the vCalendar file
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The specified @c vCalFilePath is invalid.
+        * @exception   E_ILLEGAL_ACCESS                The access is denied due to insufficient permission.
+        * @exception   E_FILE_NOT_FOUND                The specified vCalendar file is not found.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             
+        *                      - The specific error code can be accessed using the GetLastResult() method.
+        *                      - There is a high probability for an occurrence of an out-of-memory exception. If possible, check whether the exception is
+        *                      @c E_OUT_OF_MEMORY or not. For more information on how to handle the out-of-memory exception, refer
+        *                      <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        */
+       static Tizen::Base::Collection::IList* ParseEventsFromVcalendarN(const Tizen::Base::String& vCalFilePath);
+
+       /**
+        * Parses the to-dos from specific vCalendar file. @n
+        * The %ParseTodosFromVcalendarN() method supports to parse for vCalendar version 1.0 and 2.0 (iCalendar).
+        *
+        * @since       2.0
+        *
+        * @return              The list that contains the CalTodo instances, @n
+        *                              else an empty list if there are no to-dos, or @c null if an exception occurs
+        * @param[in]   vCalFilePath                    The path of the vCalendar file
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The specified @c vCalFilePath is invalid.
+        * @exception   E_ILLEGAL_ACCESS                The access is denied due to insufficient permission.
+        * @exception   E_FILE_NOT_FOUND                The specified vCalendar file is not found.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             
+        *                      - The specific error code can be accessed using the GetLastResult() method.
+        *                      - There is a high probability for an occurrence of an out-of-memory exception. If possible, check whether the exception is
+        *                      @c E_OUT_OF_MEMORY or not. For more information on how to handle the out-of-memory exception, refer
+        *                      <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        */
+       static Tizen::Base::Collection::IList* ParseTodosFromVcalendarN(const Tizen::Base::String& vCalFilePath);
+
+       /**
+        * Exports the events to vCalendar 2.0 (iCalendar) file.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   eventList                               The event list to export @n The list should contain CalEvent instances.
+        * @param[in]   vCalFilePath                    The vCalendar file path
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The specified @c eventList is invalid.
+        *                                                                              - The specified @c vCalFilePath is invalid.
+        * @exception   E_ILLEGAL_ACCESS                The access of the specified @c vCalFilePath is denied due to insufficient permission.
+        * @exception   E_FILE_ALREADY_EXIST    The vCalendar file already exists.
+        * @exception   E_STORAGE_FULL                  The disk space is full.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       static result ExportEventsToVcalendar(const Tizen::Base::Collection::IList& eventList, const Tizen::Base::String& vCalFilePath);
+
+       /**
+        * Exports the to-dos to vCalendar 2.0 (iCalendar) file.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   todoList                                The to-do list to export @n The list should contain CalTodo instances.
+        * @param[in]   vCalFilePath                    The vCalendar file path
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The specified @c todoList is invalid.
+        *                                                                              - The specified @c vCalFilePath is invalid.
+        * @exception   E_ILLEGAL_ACCESS                The access of the specified @c vCalFilePath is denied due to insufficient permission.
+        * @exception   E_FILE_ALREADY_EXIST    The vCalendar file already exists.
+        * @exception   E_STORAGE_FULL                  The disk space is full.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       static result ExportTodosToVcalendar(const Tizen::Base::Collection::IList& todoList, const Tizen::Base::String& vCalFilePath);
+
+       /**
+        * Gets the maximum allowable date and time in the calendarbook (that is, "December 31 2100 23:59:59").
+        *
+        * @since       2.0
+        *
+        * @return              An instance of Tizen::Base::DateTime
+        */
+       static Tizen::Base::DateTime GetMaxDateTime(void);
+
+       /**
+        * Gets the minimum allowable date and time in the calendarbook (that is, "January 1 1900 00:00:00").
+        *
+        * @since       2.0
+        *
+        * @return              An instance of Tizen::Base::DateTime
+        */
+       static Tizen::Base::DateTime GetMinDateTime(void);
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private @n
+        * to prohibit copying of objects.
+        *
+        * @since       2.0
+        */
+       Calendarbook(const Calendarbook& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private @n
+        * to prohibit copying of objects.
+        *
+        * @since       2.0
+        */
+       Calendarbook& operator =(const Calendarbook& rhs);
+
+private:
+       friend class _CalendarbookImpl;
+       class _CalendarbookImpl* __pCalendarbookImpl;
+};     // Calendarbook
+
+}}     // Tizen::Social
+
+
+#endif // _FSCL_CALENDARBOOK_H_
diff --git a/inc/FSclCalendarbookFilter.h b/inc/FSclCalendarbookFilter.h
new file mode 100644 (file)
index 0000000..bff719a
--- /dev/null
@@ -0,0 +1,307 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclCalendarbookFilter.h
+ * @brief              This is the header file for the %CalendarbookFilter class.
+ *
+ * This header file contains the declarations of the %CalendarbookFilter class.
+ */
+#ifndef _FSCL_CALENDARBOOK_FILTER_H_
+#define _FSCL_CALENDARBOOK_FILTER_H_
+
+#include <FBaseTypes.h>
+#include <FBaseObject.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+class DateTime;
+}}
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @class      CalendarbookFilter
+ * @brief      This class represents the condition for searching a specific item on a calendarbook.
+ *
+ * @since      2.0
+ *
+ * @final              This class is not intended for extension.
+ *
+ * The %CalendarbookFilter class represents the condition for searching a specific item on a calendarbook.
+ * The type of the filter decides which item will be searched (such as events, to-dos, calendars, all day event instances, or non-all day event instances). @n
+ * The filter can consist of multiple filtering expressions and conjunctive operators.
+ * A filtering expression consists of a filter property, comparison operator and value.
+ * The filter property must be an element of the enumerator that corresponds to the type of the filter. @n
+ * <table border=1>
+ * <tr>
+ * <th> Filter type </th>
+ * <th> Filter Property </th>
+ * <th> Search result </th>
+ * </tr>
+ * <tr>
+ * <td> CB_FI_TYPE_EVENT </td>
+ * <td> EventFilterProperty </td>
+ * <td> A list of CalEvent </td>
+ * </tr>
+ * <tr>
+ * <td> CB_FI_TYPE_TODO </td>
+ * <td> TodoFilterProperty </td>
+ * <td> A list of CalTodo </td>
+ * </tr>
+ * <tr>
+ * <td> CB_FI_TYPE_CALENDAR </td>
+ * <td> CalendarFilterProperty </td>
+ * <td> A list of Calendar </td>
+ * </tr>
+ * <tr>
+ * <td> CB_FI_TYPE_ALL_DAY_EVENT_INSTANCE </td>
+ * <td> EventInstanceFilterProperty </td>
+ * <td> A list of CalEventInstance </td>
+ * </tr>
+ * <tr>
+ * <td> CB_FI_TYPE_NON_ALL_DAY_EVENT_INSTANCE </td>
+ * <td> EventInstanceFilterProperty </td>
+ * <td> A list of CalEventInstance </td>
+ * </tr>
+ * </table>
+ *
+ * The following example demonstrates how to use the %CalendarbookFilter class.
+ * @code
+ *
+       //search condition: (calendarId=3 OR calendarId=4) AND (subject LIKE '%meeting%')
+       CalendarbookFilter subFilter(CB_FILTER_TYPE_EVENT);
+       subFilter.AppendInt(FI_CONJ_OP_NONE, EVENT_FI_PR_CALENDAR_ID, FI_CMP_O_EQUAL, 3);
+       subFilter.AppendInt(FI_CONJ_OP_OR, EVENT_FI_PR_CALENDAR_ID, FI_CMP_OP_EQUAL, 4);
+
+       CalendarbookFilter mainFilter(CB_FI_TYPE_EVENT);
+       mainFilter.AppendFilter(FI_CONJ_OP_NONE, subFilter);
+       mainFilter.AppendString(FI_CONJ_OP_AND, EVENT_FI_PR_SUBJECT, FI_STR_OP_CONTAIN, L"meeting");
+
+       Calendarbook calendarbook;
+       calendarbook.Construct();
+       IList* pEventList = calendarbook.SearchN(mainFilter, EVENT_FI_PR_SUBJECT, SORT_ORDER_ASCENDING);
+
+ * @endcode
+ */
+class _OSP_EXPORT_ CalendarbookFilter
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * Initializes an instance of %CalendarbookFilter with the specified @c type.
+        *
+        * @since       2.0
+        *
+        * @param[in]   type    The type of the filter @n It decides the type of item to search.
+        */
+       explicit CalendarbookFilter(CalendarbookFilterType type);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~CalendarbookFilter(void);
+
+       /**
+        * Checks whether the value of the specified instance is equal to the value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Tizen::Base::Object, @n
+        *                                      else @c false
+        * @param[in]   rhs                     An instance of Tizen::Base::Object to compare
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Appends the filtering expression for an integer value. @n
+        * Firstly, this method appends the conjunctive operator.
+        * Then, this method puts the filtering expression in parentheses and appends it. @n
+        * The filtering expression consists of the filter property, comparison operator, and value.
+        * The specified @c filterProperty must be an element of the enumerator that corresponds to the type of this filter.
+        *
+        * @since       2.0
+        *
+        * @return              The error code
+        * @param[in]   conjunctiveOperator             The conjunctive operator to append the filtering expression @n
+        *                                                                              If there is no filtering expression or the filter has been appended before, FI_CONJ_OP_NON must be used. Otherwise FI_CONJ_OP_AND or FI_CONJ_OP_OR can be used.
+        * @param[in]   filterProperty                  The filter property
+        * @param[in]   comparisonOperator              The comparison operator
+        * @param[in]   value                                   The integer value for comparison
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The specified @c filterProperty is not an element of the enumerator that corresponds to the type of this filter.
+        *                                                                              - The specified @c filterProperty is not an integer value.
+        *                                                                              - The specified @c conjunctiveOperator is invalid.
+        */
+       result AppendInt(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, int value);
+
+       /**
+        * Appends the filtering expression for a double value. @n
+        * Firstly, this method appends the conjunctive operator.
+        * Then, this method puts the filtering expression in parentheses and appends it. @n
+        * The filtering expression consists of the filter property, comparison operator, and value.
+        * The specified @c filterProperty must be an element of the enumerator that corresponds to the type of this filter.
+        *
+        * @since       2.0
+        *
+        * @return              The error code
+        * @param[in]   conjunctiveOperator             The conjunctive operator to append the filtering expression @n
+        *                                                                              If there is no filtering expression or the filter has been appended before, FI_CONJ_OP_NON must be used. Otherwise FI_CONJ_OP_AND or FI_CONJ_OP_OR can be used.
+        * @param[in]   filterProperty                  The filter property
+        * @param[in]   comparisonOperator              The comparison operator
+        * @param[in]   value                                   The double value for comparison
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The specified @c filterProperty is not an element of the enumerator that corresponds to the type of this filter.
+        *                                                                              - The specified @c filterProperty is not a double value.
+        *                                                                              - The specified @c conjunctiveOperator is invalid.
+        */
+       result AppendDouble(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, double value);
+
+       /**
+        * Appends the filtering expression for a @c bool value. @n
+        * Firstly, this method appends the conjunctive operator.
+        * Then, this method puts the filtering expression in parentheses and appends it. @n
+        * The filtering expression consists of the filter property, comparison operator, and value.
+        * The specified @c filterProperty must be an element of the enumerator that corresponds to the type of this filter.
+        *
+        * @since       2.0
+        *
+        * @return              The error code
+        * @param[in]   conjunctiveOperator             The conjunctive operator to append the filtering expression @n
+        *                                                                              If there is no filtering expression or the filter has been appended before, FI_CONJ_OP_NON must be used. Otherwise FI_CONJ_OP_AND or FI_CONJ_OP_OR can be used.
+        * @param[in]   filterProperty                  The filter property
+        * @param[in]   comparisonOperator              The comparison operator FILTER_COMPARISON_OPERATOR_EQUAL is only permitted
+        * @param[in]   value                                   The @c bool value for comparison
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The specified @c filterProperty is not an element of the enumerator that corresponds to the type of this filter.
+        *                                                                              - The specified @c filterProperty is not a @c bool value.
+        *                                                                              - The specified @c conjunctiveOperator is invalid.
+        */
+       result AppendBool(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, bool value);
+
+       /**
+        * Appends the filtering expression for a Tizen::Base::DateTime value. @n
+        * Firstly, this method appends the conjunctive operator.
+        * Then, this method puts the filtering expression in parentheses and appends it. @n
+        * The filtering expression consists of the filter property, comparison operator, and value.
+        * The specified @c filterProperty must be an element of the enumerator that corresponds to the type of this filter.
+        *
+        * @since       2.0
+        *
+        * @return              The error code
+        * @param[in]   conjunctiveOperator             The conjunctive operator to append the filtering expression @n
+        *                                                                              If there is no filtering expression or the filter has been appended before, FI_CONJ_OP_NON must be used. Otherwise FI_CONJ_OP_AND or FI_CONJ_OP_OR can be used.
+        * @param[in]   filterProperty                  The filter property
+        * @param[in]   comparisonOperator              The comparison operator
+        * @param[in]   value                                   The Tizen::Base::DateTime value for comparison. @n Any value with a unit that is less than a second is ignored.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred: 
+        *                                                                              - The specified @c filterProperty is not an element of the enumerator that corresponds to the type of this filter. 
+        *                                                                              - The specified @c filterProperty is not a Tizen::Base::DateTime value.
+        *                                                                              - The specified @c conjunctiveOperator is invalid.
+        *                                                                              - The specified @c value is out of the valid range.
+        */
+       result AppendDateTime(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, const Tizen::Base::DateTime& value);
+
+       /**
+        * Appends the filtering expression for a Tizen::Base::String value. @n
+        * Firstly, this method appends the conjunctive operator.
+        * Then, this method puts the filtering expression in parentheses and appends it. @n
+        * The filtering expression consists of the filter property, comparison operator, and value.
+        * The specified @c filterProperty must be an element of the enumerator that corresponds to the type of this filter.
+        *
+        * @since       2.0
+        *
+        * @return              The error code
+        * @param[in]   conjunctiveOperator             The conjunctive operator to append the filtering expression @n
+        *                                                                              If there is no filtering expression or the filter has been appended before, FI_CONJ_OP_NON must be used. Otherwise FI_CONJ_OP_AND or FI_CONJ_OP_OR can be used.
+        * @param[in]   filterProperty                  The filter property
+        * @param[in]   comparisonOperator              The comparison operator
+        * @param[in]   value                                   The Tizen::Base::String value for matching
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The specified @c filterProperty is not an element of the enumerator that corresponds to the type of this filter.
+        *                                                                              - The specified @c filterProperty is not a Tizen::Base::String value.
+        *                                                                              - The specified @c conjunctiveOperator is invalid.
+        */
+       result AppendString(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterStringOperator comparisonOperator, const Tizen::Base::String& value);
+
+       /**
+        * Appends the filter. @n
+        * Firstly, this method appends the conjunctive operator.
+        * Then, this method puts the filtering expressions of the specified filter in parentheses and appends it. @n
+        * The type of the specified @c filter must be same as the type of this filter.
+        *
+        * @since       2.0
+        *
+        * @return              The error code
+        * @param[in]   conjunctiveOperator             The conjunctive operator to append the filtering expression @n
+        *                                                                              If there is no filtering expression or the filter has been appended before, FI_CONJ_OP_NON must be used. Otherwise FI_CONJ_OP_AND or FI_CONJ_OP_OR can be used.
+        * @param[in]   filter                                  The filter to append
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred:
+        *                                                                              - The type of the specified @c filter is not same as the type of this filter.
+        *                                                                              - The specified @c filter is empty.
+        *                                                                              - The specified @c conjunctiveOperator is invalid.
+        */
+       result AppendFilter(FilterConjunctiveOperator conjunctiveOperator, const CalendarbookFilter& filter);
+
+private:
+       /*
+        * This default constructor is intentionally declared as private so that only the platform can create an instance.
+        *
+        * @since       2.0
+        */
+       CalendarbookFilter(void);
+
+       /*
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @since       2.0
+        */
+       CalendarbookFilter(const CalendarbookFilter& rhs);
+
+       /*
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @since       2.0
+        */
+       CalendarbookFilter & operator =(const CalendarbookFilter & rhs);
+
+private:
+       friend class _CalendarbookFilterImpl;
+       class _CalendarbookFilterImpl* __pCalendarbookFilterImpl;
+};             // CalendarbookFilter
+
+}} // Tizen::Social
+
+#endif // _FSCL_CALENDARBOOK_FILTER_H_
diff --git a/inc/FSclCategory.h b/inc/FSclCategory.h
new file mode 100644 (file)
index 0000000..11670a9
--- /dev/null
@@ -0,0 +1,318 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FSclCategory.h
+ * @brief      This is the header file for the %Category class.
+ *
+ * This header file contains the declarations of the %Category class.
+ */
+#ifndef _FSCL_CATEGORY_H_
+#define _FSCL_CATEGORY_H_
+
+#include <FBaseResult.h>
+#include <FBaseString.h>
+#include <FSclRecord.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IMap;
+}}};
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @class      Category
+ * @brief      This class represents a category in the contact database.
+ *
+ * @since      2.0
+ *
+ * @final      This class is not intended for extension.
+ *
+ * The %Category class represents a category in the contact database. Each contact can belong to multiple categories.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/social/category.htm">Category</a>.
+ */
+class _OSP_EXPORT_ Category
+       : public Record
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.0
+        *
+        * @remarks             In order to add a new category to Addressbook, the category name needs to be set using SetName().
+        * @see                 Addressbook::AddCategory()
+        */
+       Category(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param [in]  rhs             An instance of %Category to copy
+        */
+       Category(const Category& rhs);
+
+       /**
+        * This destructor overrides Tizen::Social::Record::~Record().
+        *
+        * @since       2.0
+        */
+       virtual ~Category(void);
+
+       /**
+        * Checks whether the value of the specified instance is equal to the value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return      @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Tizen::Base::Object, @n
+        *                      else @c false
+        * @param[in]   rhs             An instance of Tizen::Base::Object to compare
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since       2.0
+        *
+        * @return      The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the addressbook ID.
+        *
+        * @since       2.0
+        *
+        * @return      The addressbook ID
+        */
+       AddressbookId GetAddressbookId(void) const;
+
+
+       /**
+        * @if OSPDEPREC
+        * Adds the specified contact to the category.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated This method is deprecated. Instead of using this method, use Addressbook::AddMemberToCategory().
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param [in]  contactId                       The contact ID
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OBJ_ALREADY_EXIST     The specified @c contactId is already a member of this category.
+        * @exception   E_INVALID_ARG           The specified @c contactId is invalid.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @endif
+        */
+       result AddMember(RecordId contactId);
+
+       /**
+        * Gets the total number of members in the category.
+        *
+        * @since       2.0
+        *
+        * @return      The number of members in the category
+        */
+       int GetMemberCount(void) const;
+
+       /**
+        * Gets the name of the category.
+        *
+        * @since       2.0
+        *
+        * @return      The name of the category
+        * @see SetName()
+        */
+       Tizen::Base::String GetName(void) const;
+
+       /**
+        * @if OSPDEPREC
+        * Checks whether the category contains the specified contact.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated This method is deprecated. Instead of using this method, use Addressbook::GetCategoriesByContactN().
+        * @since       2.0
+        *
+        * @return              @c true if the category contains the specified contact, @n
+        *                              else @c false
+        * @param [in]  contactId               The contact ID
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c contactId is invalid.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @remarks     The specific error code can be accessed using the GetLastResult() method.
+        * @endif
+        */
+       bool HasMember(RecordId contactId) const;
+
+       /**
+        * @if OSPDEPREC
+        * Removes the specified contact from the category.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated This method is deprecated. Instead of using this method, use Addressbook::RemoveMemberFromCategory().
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param [in]  contactId                       The contact ID
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c contactId is invalid.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @endif
+        */
+       result RemoveMember(RecordId contactId);
+
+       /**
+        * Sets the specified @c name for the category.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility            This method has compatibility issues with OSP compatible applications. @n
+        *                            For more information, see @ref CompCategorySetNamePage "here".
+        * @endif
+        *
+        * @return              An error code
+        * @param [in]  name                                    The category name
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The specified @c name is an empty string.
+        * @exception   E_INVALID_OPERATION     This category is a read-only category.
+        * @remarks     It is not allowed to change the name of a read-only category.
+        * @see GetName()
+        * @see IsReadOnly()
+        */
+       result SetName(const Tizen::Base::String& name);
+
+       /**
+        * @if OSPCOMPAT
+        * @page                CompCategorySetNamePage         Compatibility for SetName()
+        * @section             CompCategorySetNamePageIssueSection             Issues
+        *                              Implementing this method in OSP compatible applications has the following issue: @n
+        *                              -# If the length of the category name to be set is greater than 100 characters, @c E_INVALID_ARG is returned.
+        *                              -# if the category is a default category, @c E_INVALID_ARG is returned.
+        *
+        * @section             CompCategorySetNamePageSolutionSection          Resolutions
+        *                              The issue mentioned above has been resolved in Tizen.
+        * @endif
+       */
+
+       /**
+        * Sets the specified ringtone for the category.
+        *
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param [in]  filePath                        The file path of the ringtone
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The length of the specified @c filePath exceeds system limitations.
+        * @exception   E_FILE_NOT_FOUND        The specified file cannot be found or accessed.
+        * @see GetRingtonePath()
+        */
+       result SetRingtonePath(const Tizen::Base::String& filePath);
+
+       /**
+        * Gets the ringtone for the category.
+        *
+        * @since       2.0
+        *
+        * @return      The file path of the ringtone
+        * @see SetRingtonePath()
+        */
+       Tizen::Base::String GetRingtonePath(void) const;
+
+       /**
+        * Checks whether this category is a default category . @n
+        *
+        * @since       2.0
+        *
+        * @return     @c true if this is a default category, @n
+        *             else @c false
+        */
+       bool IsDefault(void) const;
+
+       /**
+        * Checks whether this category is read-only. @n
+        * If a category is default, it is not possible to update the category name and delete the category.
+        * However it is possible to add or remove contacts and change the thumbnail and ringtone.
+        *
+        * @since       2.1
+        *
+        * @return     @c true if this is a default category, @n
+        *             else @c false
+        */
+       bool IsReadOnly(void) const;
+
+       /**
+        * Gets the extra data.
+        *
+        * @since       2.2
+        *
+        * @return      The key-value map of the extended data where the key and value are of type Tizen::Base::String, @n
+        *              else an empty map if there is no extra data, or @c null if an exception occurs
+        * @remarks     The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IMap* GetExtraDataN(void) const;
+
+       /**
+        * Sets the thumbnail image. @n
+        * If the specified @c filePath is an empty string, the thumbnail of this category is reset.
+        *
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param[in]   filePath                The file path of the thumbnail image
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The length of the specified @c filePath exceeds system limitations.
+        * @exception   E_FILE_NOT_FOUND        The specified file cannot be found or accessed.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @see GetThumbnailPath()
+        */
+       result SetThumbnail(const Tizen::Base::String& filePath);
+
+       /**
+        * Gets the thumbnail path.
+        *
+        * @since       2.0
+        *
+        * @return     The file path of the thumbnail
+        * @remarks    If the thumbnail has not been set, an empty string is returned.
+        */
+       Tizen::Base::String GetThumbnailPath(void) const;
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param [in]  rhs             An instance of %Category to copy
+        */
+       Category& operator =(const Category& rhs);
+
+private:
+       friend class _CategoryImpl;
+       class _CategoryImpl* __pCategoryImpl;
+};     // Category
+
+}}     // Tizen::Social
+
+#endif // _FSCL_CATEGORY_H_
diff --git a/inc/FSclCategoryChangeInfo.h b/inc/FSclCategoryChangeInfo.h
new file mode 100644 (file)
index 0000000..9a22c13
--- /dev/null
@@ -0,0 +1,143 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclCategoryChangeInfo.h
+ * @brief              This is the header file for the %CategoryChangeInfo class.
+ *
+ * This header file contains the declarations of the %CategoryChangeInfo class.
+ */
+#ifndef _FSCL_CATEGORY_CHANGE_INFO_H_
+#define _FSCL_CATEGORY_CHANGE_INFO_H_
+
+#include <FBaseObject.h>
+#include <FSclTypes.h>
+#include <FSclRecord.h>
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @class      CategoryChangeInfo
+ * @brief      This class provides the category change information.
+ *
+ * @since      2.0
+ *
+ * @final      This class is not intended for extension.
+ *
+ * The %CategoryChangeInfo class provides the category change information.
+ *
+ */
+class _OSP_EXPORT_ CategoryChangeInfo
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.0
+        */
+       CategoryChangeInfo(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %CategoryChangeInfo to copy
+        */
+       CategoryChangeInfo(const CategoryChangeInfo& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~CategoryChangeInfo(void);
+
+       /**
+        * Checks whether the value of the specified instance is equal to the value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return      @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Tizen::Base::Object, @n
+        *                      else @c false
+        * @param[in]   rhs     An instance of Tizen::Base::Object to compare
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since       2.0
+        *
+        * @return      The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the addressbook ID of the changed category.
+        *
+        * @since       2.0
+        *
+        * @return      The addressbook ID
+        */
+       AddressbookId GetAddressbookId(void) const;
+
+       /**
+        * Gets the ID of the changed category.
+        *
+        * @since       2.0
+        *
+        * @return      The category ID
+        */
+       RecordId GetCategoryId(void) const;
+
+       /**
+        * Gets the version.
+        *
+        * @since       2.0
+        *
+        * @return      The version of the category
+        */
+       int GetVersion(void) const;
+
+       /**
+        * Gets the change type.
+        *
+        * @since       2.0
+        *
+        * @return      The change type
+        */
+       RecordChangeType GetChangeType(void) const;
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %CategoryChangeInfo to copy
+        */
+       CategoryChangeInfo& operator =(const CategoryChangeInfo& rhs);
+
+private:
+       friend class _CategoryChangeInfoImpl;
+       class _CategoryChangeInfoImpl* __pCategoryChangeInfoImpl;
+
+};     // CategoryChangeInfo
+
+}}     // Tizen::Social
+
+#endif // _FSCL_CATEGORY_CHANGE_INFO_H_
diff --git a/inc/FSclContact.h b/inc/FSclContact.h
new file mode 100644 (file)
index 0000000..0d6006a
--- /dev/null
@@ -0,0 +1,692 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclContact.h
+ * @brief              This is the header file for the %Contact class.
+ *
+ * This header file contains the declarations of the %Contact class.
+ */
+#ifndef _FSCL_CONTACT_H_
+#define _FSCL_CONTACT_H_
+
+#include <FBaseTypes.h>
+#include <FBaseString.h>
+#include <FBaseDateTime.h>
+#include <FBaseColIList.h>
+#include <FGrpBitmap.h>
+#include <FSclTypes.h>
+#include <FSclRecord.h>
+
+namespace Tizen { namespace Social
+{
+
+class Address;
+class PhoneNumber;
+class Email;
+class Url;
+class ImAddress;
+class Organization;
+class ContactEvent;
+class Relationship;
+class ContactAppLaunchData;
+
+/**
+ * @class      Contact
+ * @brief      This class provides a contact.
+ *
+ * @since      2.0
+ *
+ * @final      This class is not intended for extension.
+ *
+ * The %Contact class provides a contact, a record that represents the contact information of a person. It provides the properties declared in
+ * the #ContactPropertyId and #ContactMultiPropertyId enumerators. Check the descriptions for each property ID carefully to know the exact type
+ * of the property and its value. @n
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/social/contact.htm">Contact</a>.
+ *
+ * The following example demonstrates how to use the %Contact class.
+ *
+ * @code
+ *
+       #include <FSocial.h>
+
+       using namespace Tizen::Base;
+       using namespace Tizen::Base::Collection;
+       using namespace Tizen::Social;
+
+       void
+       ContactExample(void)
+       {
+               // Creates a contact
+               Contact contact;
+
+               // Sets the contact's properties
+               contact.SetValue(CONTACT_PROPERTY_ID_FIRST_NAME, L"Thomas");
+               contact.SetValue(CONTACT_PROPERTY_ID_LAST_NAME, L"A Anderson");
+
+               PhoneNumber phoneNumber(PHONENUMBER_TYPE_MOBILE, L"820223459876");
+               contact.AddPhoneNumber(phoneNumber);
+
+               // Gets the contact's properties
+               String firstName, lastName;
+               contact.GetValue(CONTACT_PROPERTY_ID_FIRST_NAME, firstName);
+               contact.GetValue(CONTACT_PROPERTY_ID_LAST_NAME, lastName);
+
+               IList* pPhoneNumberList = contact.GetValuesN(CONTACT_MPROPERTY_ID_PHONE_NUMBERS);
+               if (pPhoneNumberList != null)
+               {
+                       PhoneNumber* pPhoneNumber = null;
+                       String number;
+                       IEnumerator* pEnum = pPhoneNumberList->GetEnumeratorN();
+                       while (pEnum->MoveNext() == E_SUCCESS)
+                       {
+                               pPhoneNumber = (PhoneNumber*) pEnum->GetCurrent();
+                               number = pPhoneNumber->GetPhoneNumber();
+                               // Uses the phone number
+                               // ..
+                       }
+
+                       delete pEnum;
+                       pPhoneNumberList->RemoveAll(true);
+                       delete pPhoneNumberList;
+               }
+       }
+ *
+ * @endcode
+ *
+ */
+class _OSP_EXPORT_ Contact
+       : public Record
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.0
+        */
+       Contact(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %Contact to copy
+        */
+       Contact(const Contact& rhs);
+
+       /**
+        * This destructor overrides Tizen::Social::Record::~Record().
+        *
+        * @since       2.0
+        *
+        */
+       virtual ~Contact(void);
+
+       /**
+        * Checks whether the value of the specified instance is equal to the value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return      @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Tizen::Base::Object, @n
+        *                      else @c false
+        * @param[in]   rhs             An instance of Tizen::Base::Object to compare
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since       2.0
+        *
+        * @return      The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * @if OSPDEPREC
+        * Gets the Tizen::Graphics::Bitmap object of the thumbnail image. @n
+        * If the thumbnail is not set, @c null is returned.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated This method is deprecated. Instead of using this method, use GetThumbnailPath()
+        * @since       2.0
+        *
+        * @return              The Tizen::Graphics::Bitmap object of the thumbnail image
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @see SetThumbnail()
+        * @endif
+        */
+       Tizen::Graphics::Bitmap* GetThumbnailN(void) const;
+
+       /**
+        * Gets the thumbnail path.
+        *
+        * @since       2.0
+        *
+        * @return     The file path of the thumbnail
+        * @remarks    If the thumbnail has not been set, an empty string is returned.
+        */
+       Tizen::Base::String GetThumbnailPath(void) const;
+
+       /**
+        * Sets the thumbnail image. @n
+        * If the specified @c filePath is an empty string, the current thumbnail image is removed.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility            This method has compatibility issues with OSP compatible applications. @n
+        *                                                      For more information, see @ref CompIoPathPage "here".
+        * @endif
+        *
+        * @return      An error code
+        * @param[in]   filePath                        The file path of the thumbnail image
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The length of the specified @c filePath exceeds system limitations.
+        * @exception   E_FILE_NOT_FOUND        The specified file cannot be found or accessed.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @see GetThumbnailPath()
+        */
+       result SetThumbnail(const Tizen::Base::String& filePath);
+
+       /**
+        * Sets the value of the property having the specified ID, to the specified value.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility             This method has compatibility issues with OSP compatible applications. @n
+        *                            For more information, see @ref CompContactSetValuePage "here".
+        * @endif
+        *
+        * @return              An error code
+        * @param[in]   id                                      The ID of the property whose value is set
+        * @param[in]   value                           The new string value to set
+        * @exception   E_SUCCESS                   The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c id is #CONTACT_PROPERTY_ID_DISPLAY_NAME, @if OSPDEPREC #CONTACT_PROPERTY_ID_THUMBNAIL, or @endif
+        *                                                                      the ringtone file path (value) is invalid if @c id is #CONTACT_PROPERTY_ID_RINGTONE.
+        * @remarks             
+        *              - The #CONTACT_PROPERTY_ID_DISPLAY_NAME property cannot be set. @n
+        *              - The #CONTACT_PROPERTY_ID_RINGTONE can be set to the path string of the ringtone file. @n
+        * @if OSPDEPREC
+        *              - The #CONTACT_PROPERTY_ID_THUMBNAIL property cannot be set. @n
+        *              - In case @c id is set to #CONTACT_PROPERTY_ID_NICK_NAME, @n
+        *                              - If this contact has nicknames, the first nickname among them is set to the @c value. @n
+        *                              - If not, a new nickname is added to this contact. @n
+        *              - In case @c id is set to #CONTACT_PROPERTY_ID_NOTE, @n
+        *                              - If this contact has notes, the first note among them is set to the @c value. @n
+        *                              - If not, a new note is added to this contact. @n
+        *              - In case @c id is set to #CONTACT_PROPERTY_ID_COMPANY, @n
+        *                              - If this contact has organizations, the name value of the first organization among them is set to the @c value. @n
+        *                              - If not, a new organization is added to this contact. @n
+        *              - In case @c id is set to #CONTACT_PROPERTY_ID_JOB_TITLE, @n
+        *                              - If this contact has organizations, the job title value of the first organization among them is set to the @c value. @n
+        *                              - If not, a new organization is added to this contact. @n
+        * @endif
+        */
+       result SetValue(ContactPropertyId id, const Tizen::Base::String& value);
+
+       /**
+        * @if OSPCOMPAT
+        * @page                CompContactSetValuePage         Compatibility for SetValue()
+        * @section             CompContactSetValuePageIssueSection             Issues
+        *                              Implementing this method in OSP compatible applications has the following issues: @n
+        *                              -# If the length of the value is greater than the maximum length of the specified property, @c E_INVALID_ARG is returned.
+        *                              -# The path should begin with an allowed path prefix such as @b '/Home', @b '/Home/Share', @b '/Res', @b '/Share/[@e appid]',
+        *                                 @b '/Media', and @b '/Storagecard/Media'.
+        *
+        * @section             CompContactSetValuePageSolutionSection          Resolutions
+        * -# The first issue mentioned above has been resolved in Tizen.
+        * -# There are no specific allowed path prefixes. Applications can obtain an accessible directory path using the following methods. @n
+        *  - For accessing its own data directory, use Tizen::App::App::GetInstance()->GetAppRootPath() + L"data" @n
+        *    or Tizen::App::App::GetInstance()->GetAppDataPath().
+        *  - For accessing its own resource directory, use Tizen::App::App::GetInstance()->GetAppRootPath() + L"res". @n
+        *    or Tizen::App::App::GetInstance()->GetAppResourcePath().
+        *  - For accessing its own share directory, use Tizen::App::App::GetInstance()->GetAppRootPath() + L"share".
+        *  - For accessing the media directory, use Tizen::System::Environment::GetMediaPath().
+        *  - For accessing the external storage, use Tizen::System::Environment::GetExternalStoragePath().
+        *
+        * For more information on the path,
+        * see <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/io_overview.htm">I/O Overview</a>.
+        * @endif
+        */
+
+       /**
+        * Sets the specified value for the property having the specified ID.
+        *
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param[in]   id                              The ID of the property whose value is set
+        * @param[in]   value                   An instance of Tizen::Base::DateTime value to set
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   Either of the following conditions has occurred:
+        *                                                              - The property with the specified contact property ID is not of Tizen::Base::DateTime type.
+        *                                                              - The property is read-only.
+        * @if OSPDEPREC
+        * @remarks    
+        *              - In case @c id is set to #CONTACT_PROPERTY_ID_BIRTHDAY,
+        *                         -    If this contact has events whose types are #CONTACT_EVENT_TYPE_BIRTHDAY, the date value of the first event among them is set to the @c value.
+        *                         -    If not, a new event whose type is #CONTACT_EVENT_TYPE_BIRTHDAY is added to this contact.
+        *              - In case @c id is set to #CONTACT_PROPERTY_ID_ANNIVERSARY,
+        *                         -    If this contact has events whose types are #CONTACT_EVENT_TYPE_ANNIVERSARY, the date value of the first event among them is set to the @c value.
+        *                         -    If not, a new event whose type is #CONTACT_EVENT_TYPE_ANNIVERSARY is added to this contact.
+        * @endif
+        */
+       result SetValue(ContactPropertyId id, const Tizen::Base::DateTime& value);
+
+       /**
+        * Gets the value of the specified property.
+        *
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param[in]   id                              The property ID
+        * @param[out]  value                   The property value
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified contact property ID is not supported.
+        */
+       result GetValue(ContactPropertyId id, Tizen::Base::String& value) const;
+
+       /**
+        * Gets the value of the specified Tizen::Base::DateTime property such as birthday. @n
+        * If the %Tizen::Base::DateTime value has not been set for the specified property, the property has a value, '1899, 12, 31, 00:00:00'.
+        *
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param[in]   id                              The property ID
+        * @param[out]  value                   The property value
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified contact property ID is not supported.
+        */
+       result GetValue(ContactPropertyId id, Tizen::Base::DateTime& value) const;
+
+       /**
+        * Sets the specified phone number at the specified index.
+        *
+        * @since       2.0
+        *
+        * @return     An error code
+        * @param[in]  index          The index at which to set the value
+        * @param[in]  phoneNumber    An instance of PhoneNumber to set, @n
+        *                            else @c false
+        * @exception  E_SUCCESS      The method is successful.
+        * @exception  E_INVALID_ARG  The specified @c phoneNumber is empty.
+        * @exception  E_OUT_OF_RANGE The specified @c index is outside the bounds of the properties.
+        */
+       result SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber);
+
+       /**
+        * Sets the specified email corresponding to the specified index.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   index                           The index at which to set the value
+        * @param[in]   email                           An instance of Email
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c email is empty.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetEmailAt(int index, const Email& email);
+
+       /**
+        * Sets the specified URL corresponding to the specified index.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   index                           The index at which to set the value
+        * @param[in]   url                                     An instance of Url
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c url is empty.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetUrlAt(int index, const Url& url);
+
+       /**
+        * Sets the specified address corresponding to the specified index.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   index                           The index at which to set the value
+        * @param[in]   address                         An instance of Address
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c address is empty.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetAddressAt(int index, const Address& address);
+
+       /**
+        * Sets the specified ImAddress corresponding to the specified index.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   index                           The index at which to set the value
+        * @param[in]   imAddress                       An instance of ImAddress
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c imAddress is empty.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetImAddressAt(int index, const ImAddress& imAddress);
+
+       /**
+        * Sets the specified note corresponding to the specified index.
+        *
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param[in]   index                           The index at which to set the value
+        * @param[in]   note                            The note to set
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c note is empty.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetNoteAt(int index, const Tizen::Base::String& note);
+
+       /**
+        * Sets the specified nick name corresponding to the specified index.
+        *
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param[in]   index                           The index at which to set the value
+        * @param[in]   nickname                        The nick name to set
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c nickname is empty.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetNicknameAt(int index, const Tizen::Base::String& nickname);
+
+       /**
+        * Sets the specified event corresponding to the specified index.
+        *
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param[in]   index                           The index at which to set the value
+        * @param[in]   event                           The event to set
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The date of the specified @c event has not been set.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetEventAt(int index, const ContactEvent& event);
+
+       /**
+        * Sets the specified organization corresponding to the specified index.
+        *
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param[in]   index                           The index at which to set the value
+        * @param[in]   organization            The organization to set
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c organization is empty.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetOrganizationAt(int index, const Organization& organization);
+
+       /**
+        * Sets the specified @c relationship corresponding to the specified @c index.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   index                           The index at which to set the value
+        * @param[in]   relationship            The relationship to set
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c relationship is empty.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetRelationshipAt(int index, const Relationship& relationship);
+
+       /**
+        * Sets the app launch data at the specified index.
+        *
+        * @since       2.2
+        *
+        *
+        * @return      An error code
+        * @param[in]   index                   The index at which to set the contact app launch data
+        * @param[in]   appLaunchData           The app launch data to set
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c appLaunchData has no relevant information.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the app launch data.
+        */
+       result SetContactAppLaunchDataAt(int index, const ContactAppLaunchData& appLaunchData);
+
+       /**
+        * Gets the addressbook ID.
+        *
+        * @since       2.0
+        *
+        * @return      The addressbook ID
+        */
+       AddressbookId GetAddressbookId(void) const;
+
+       /**
+        * Gets the person ID to which this contact is linked.
+        *
+        * @since       2.0
+        *
+        * @return      The person ID
+        */
+       PersonId GetPersonId(void) const;
+
+       /**
+        * Gets the list of values belonging to the specific multi value property.
+        *
+        * @since       2.0
+        *
+        * @return      The list of values belonging to the specific multi value property
+        * @param[in]   id                              The property ID
+        * @exception   E_SUCCESS               The method is successful.
+        * @remarks     The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetValuesN(ContactMultiPropertyId id) const;
+
+       /**
+        * Adds the specified phone number to the contact.
+        *
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param[in]   phoneNumber                     The phone number to add
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c phoneNumber is empty.
+        */
+       result AddPhoneNumber(const PhoneNumber& phoneNumber);
+
+       /**
+        * Adds the specified email to the contact.
+        *
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param[in]   email                   The email address to add
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c email is empty.
+        */
+       result AddEmail(const Email& email);
+
+       /**
+        * Adds the specified URL to the contact.
+        *
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param[in]   url                             The URL to add
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c url is empty.
+        */
+       result AddUrl(const Url& url);
+
+       /**
+        * Adds the specified address to the contact.
+        *
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param[in]   address                 The address to add
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c address is empty.
+        */
+       result AddAddress(const Address& address);
+
+       /**
+        * Adds the specified instant message information to the contact.
+        *
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param[in]   imAddress               The IM address to add
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c imAddress is empty.
+        */
+       result AddImAddress(const ImAddress& imAddress);
+
+       /**
+        * Adds the specified note to the contact.
+        *
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param[in]   note                    The note to add
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c note is empty.
+        */
+       result AddNote(const Tizen::Base::String& note);
+
+       /**
+        * Adds the specified nick name to the contact.
+        *
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param[in]   nickname                The nick name to add
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c nickname is empty.
+        */
+       result AddNickname(const Tizen::Base::String& nickname);
+
+       /**
+        * Adds the specified event to the contact.
+        *
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param[in]   event                   The event to add
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The date of the specified @c event has not been set.
+        */
+       result AddEvent(const ContactEvent& event);
+
+       /**
+        * Adds the specified organization to the contact.
+        *
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param[in]   organization            The organization to add
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c organization is empty.
+        */
+       result AddOrganization(const Organization& organization);
+
+       /**
+        * Adds the specified relationship to the contact.
+        *
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param[in]   relationship            The relationship to add
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c organization is empty.
+        */
+       result AddRelationship(const Relationship& relationship);
+
+       /**
+        * Adds the specified app launch data to the contact.
+        *
+        * @since       2.2
+        *
+        * @return      An error code
+        * @param[in]   appLaunchData           The app launch data to add
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c appLaunchData has no relevant information.
+        */
+       result AddContactAppLaunchData(const ContactAppLaunchData& appLaunchData);
+
+       /**
+        * Removes the value at the specified index of the multi value property.
+        *
+        * @since       2.0
+        *
+        * @return      An error code
+        * @param[in]   id                              The property ID
+        * @param[in]   index                   The index of the value to remove
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_OUT_OF_RANGE  The specified @c index is outside the bounds of the properties.
+        */
+       result RemoveAt(ContactMultiPropertyId id, int index);
+
+       /**
+        * Checks whether this contact is a favorite.
+        *
+        * @since       2.1
+        *
+        * @return     @c true if this contact is a favorite, @n
+        *             else @c false
+        * @see SetAsFavorite()
+        */
+       bool IsFavorite(void) const;
+
+       /**
+        * Sets or unsets a contact as a favorite.
+        *
+        * @since       2.1
+        * @see IsFavorite()
+        */
+       void SetAsFavorite(bool isFavorite = true);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %Contact to copy
+        */
+       Contact& operator =(const Contact& rhs);
+
+private:
+       friend class _ContactImpl;
+       class _ContactImpl* __pContactImpl;
+
+}; // Contact
+
+}} // Tizen::Social
+
+#endif // _FSCL_CONTACT_H_
diff --git a/inc/FSclContactAppLaunchData.h b/inc/FSclContactAppLaunchData.h
new file mode 100644 (file)
index 0000000..8829ebe
--- /dev/null
@@ -0,0 +1,256 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+/**
+ * @file               FSclContactAppLaunchData.h
+ * @brief              This is the header file for the %ContactAppLaunchData class.
+ *
+ * This header file contains the declarations of the %ContactAppLaunchData class.
+ */
+
+#ifndef _FSCL_CONTACT_APP_LAUNCH_DATA_H_
+#define _FSCL_CONTACT_APP_LAUNCH_DATA_H_
+
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+
+namespace Tizen { namespace Base
+{
+namespace Collection
+{
+class IMap;
+}
+}}
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @class      ContactAppLaunchData
+ * @brief      This class provides the information required to launch an application from a contact.
+ *
+ * @since      2.1
+ *
+ * @final      This class is not intended for extension.
+ *
+ * The %ContactAppLaunchData class provides the information required to launch an application from a contact.
+ * This information consists of the application ID, operation ID, MIME type, URI, display text, and extra data.
+ */
+
+class _OSP_EXPORT_ ContactAppLaunchData
+       :public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.1
+        */
+               ContactAppLaunchData(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.1
+        *
+        * @param[in]   rhs             An instance of %ContactAppLaunchData to copy
+        */
+               ContactAppLaunchData(const ContactAppLaunchData& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.1
+        *
+        */
+       virtual ~ContactAppLaunchData(void);
+
+       /**
+        * Checks whether the value of the specified instance is equal to the value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.1
+        *
+        * @return      @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Tizen::Base::Object, @n
+        *                      else @c false
+        * @param[in]   rhs             An instance of Tizen::Base::Object to compare
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since       2.1
+        *
+        * @return      The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the display text that describes the data of the contact app launch.
+        *
+        * @since       2.1
+        *
+        * @return      The text that describes the data of the contact app launch
+        */
+       Tizen::Base::String GetDisplayText(void) const;
+
+       /**
+        * Gets the application ID.
+        *
+        * @since       2.1
+        *
+        * @return      The application ID
+        */
+       Tizen::Base::String GetAppId(void) const;
+
+       /**
+        * Gets the operation ID.
+        *
+        * @since       2.1
+        *
+        * @return      The operation ID
+        */
+       Tizen::Base::String GetOperationId(void) const;
+
+       /**
+        * Gets the URI of an application.
+        *
+        * @since       2.1
+        *
+        * @return      The URI of the application
+        */
+       Tizen::Base::String GetUri(void) const;
+
+       /**
+        * Gets the MIME type of an application.
+        *
+        * @since       2.1
+        *
+        * @return      The MIME type of the application
+        */
+       Tizen::Base::String GetMime(void) const;
+
+       /**
+        * Gets the extra data for a map.
+        *
+        * @since       2.1
+        *
+        * @return      The key-value map of the extended data where the key and value are of type Tizen::Base::String, @n
+        *                      else an empty map if there is no extra data, or @c null if an exception occurs
+        * @remarks     The specific error code can be accessed using the GetlastResult() method.
+        */
+       Tizen::Base::Collection::IMap* GetExtraDataN(void) const;
+
+       /**
+        * Sets the display text that describes the data of the contact app launch.
+        *
+        * @since               2.1
+        *
+        * @param[in]   displayText             The text that describes the data of the contact app launch
+        */
+       void SetDisplayText(const Tizen::Base::String& displayText);
+
+       /**
+        * Sets the application ID.
+        *
+        * @since               2.1
+        *
+        * @param[in]   appId           The application ID to set
+        */
+       void SetAppId(const Tizen::Base::String& appId);
+
+       /**
+        * Sets the operation ID.
+        *
+        * @since               2.1
+        *
+        * @param[in]   operationId             The operation ID to set
+        */
+       void SetOperationId(const Tizen::Base::String& operationId);
+
+       /**
+        * Sets the URI of an application.
+        *
+        * @since               2.1
+        *
+        * @param[in]   uri             The URI of the application to set
+        */
+       void SetUri(const Tizen::Base::String& uri);
+
+       /**
+        * Sets the MIME type of an application.
+        *
+        * @since       2.1
+        *
+        * @param[in]   mime    The MIME type of the application to set
+        */
+       void SetMime(const Tizen::Base::String& mime);
+
+       /**
+        * Sets the extra data to be delivered to an application.
+        *
+        * @since       2.1
+        *
+        * @param[in]   pExtraData              A pointer to the argument map of the key and value pair where the key and value are of type Tizen::Base::String @n
+        *                                                              If @c null is passed, the current extra data is removed.
+        */
+       result SetExtraData(const Tizen::Base::Collection::IMap* pExtraData);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.1
+        *
+        * @param[in]   rhs             An instance of %ContactAppLaunchData to copy
+        */
+       ContactAppLaunchData& operator =(const ContactAppLaunchData& rhs);
+
+       friend bool operator ==(const ContactAppLaunchData& lhs, const ContactAppLaunchData& rhs);
+
+private:
+       friend class _ContactAppLaunchDataImpl;
+       class _ContactAppLaunchDataImpl* __pContactAppLaunchDataImpl;
+
+}; // ContactAppLaunchData
+
+/**
+ * Compares the two specified instances of %ContactAppLaunchData for equality.
+ *
+ * @since      2.1
+ *
+ * @return             @c true if the data of the two specified instances are equal, @n
+ *                             else @c false
+ * @param[in]  lhs             An instance of %ContactAppLaunchData
+ * @param[in]  rhs             An instance of %ContactAppLaunchData
+ */
+_OSP_EXPORT_ bool operator ==(const ContactAppLaunchData& lhs, const ContactAppLaunchData& rhs);
+
+/**
+ * Compares the two specified instances of %ContactAppLaunchData for inequality.
+ *
+ * @since      2.1
+ *
+ * @return             @c true if the data of the two specified instances are not equal, @n
+ *                             else @c false
+ * @param[in]  lhs             An instance of %ContactAppLaunchData
+ * @param[in]  rhs             An instance of %ContactAppLaunchData
+ */
+_OSP_EXPORT_ bool operator !=(const ContactAppLaunchData& lhs, const ContactAppLaunchData& rhs);
+
+}} // Tizen::Social
+
+#endif // _FSCL_CONTACT_APP_LAUNCH_DATA_H_
diff --git a/inc/FSclContactChangeInfo.h b/inc/FSclContactChangeInfo.h
new file mode 100644 (file)
index 0000000..43749ae
--- /dev/null
@@ -0,0 +1,152 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclContactChangeInfo.h
+ * @brief              This is the header file for the %ContactChangeInfo class.
+ *
+ * This header file contains the declarations of the %ContactChangeInfo class.
+ */
+#ifndef _FSCL_CONTACT_CHANGE_INFO_H_
+#define _FSCL_CONTACT_CHANGE_INFO_H_
+
+#include <FBaseObject.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @class      ContactChangeInfo
+ * @brief      This class provides the contact change information.
+ *
+ * @since      2.0
+ *
+ * @final      This class is not intended for extension.
+ *
+ * The %ContactChangeInfo class provides the contact change information.
+ *
+ */
+class _OSP_EXPORT_ ContactChangeInfo
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.0
+        */
+       ContactChangeInfo(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %ContactChangeInfo to copy
+        */
+       ContactChangeInfo(const ContactChangeInfo& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~ContactChangeInfo(void);
+
+       /**
+        * Checks whether the value of the specified instance is equal to the value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return      @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Tizen::Base::Object, @n
+        *                      else @c false
+        * @param[in]   rhs     An instance of Tizen::Base::Object to compare
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since       2.0
+        *
+        * @return      The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the addressbook ID of the changed contact.
+        *
+        * @since       2.0
+        *
+        * @return      The addressbook ID
+        */
+       AddressbookId GetAddressbookId(void) const;
+
+       /**
+        * Gets the ID of the changed contact.
+        *
+        * @since       2.0
+        *
+        * @return      The contact ID
+        */
+       RecordId GetContactId(void) const;
+
+       /**
+        * Gets the version.
+        *
+        * @since       2.0
+        *
+        * @return      The version of the contact
+        */
+       int GetVersion(void) const;
+
+       /**
+        * Gets the change type.
+        *
+        * @since       2.0
+        *
+        * @return      The change type
+        */
+       RecordChangeType GetChangeType(void) const;
+
+       /**
+        * Checks whether the thumbnail has been changed.
+        *
+        * @since       2.1
+        *
+        * @return     @c true if the thumbnail has been changed, @n
+        *              else @c false
+        */
+       bool IsThumbnailChanged(void) const;
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %ContactChangeInfo to copy
+        */
+       ContactChangeInfo& operator =(const ContactChangeInfo& rhs);
+
+private:
+       friend class _ContactChangeInfoImpl;
+       class _ContactChangeInfoImpl* __pContactChangeInfoImpl;
+
+};     // ContactChangeInfo
+
+}}     // Tizen::Social
+
+#endif // _FSCL_CONTACT_CHANGE_INFO_H_
diff --git a/inc/FSclContactEvent.h b/inc/FSclContactEvent.h
new file mode 100644 (file)
index 0000000..04c74bd
--- /dev/null
@@ -0,0 +1,188 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FSclContactEvent.h
+* @brief       This is the header file for the %ContactEvent class.
+*
+* This header file contains the declarations of the %ContactEvent class.
+*/
+#ifndef _FSCL_CONTACT_EVENT_H_
+#define _FSCL_CONTACT_EVENT_H_
+
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FBaseDateTime.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+
+/**
+* @class       ContactEvent
+* @brief       This class represents an event.
+*
+* @since       2.0
+*
+* @final       This class is not intended for extension.
+*
+* The %ContactEvent class represents an event. An event consists of the event date, type, and label. 
+*
+*/
+class _OSP_EXPORT_ ContactEvent
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.0
+        */
+       ContactEvent(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs     An instance of %ContactEvent to copy
+        */
+       ContactEvent(const ContactEvent& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~ContactEvent(void);
+
+       /**
+        * Checks whether the value of the specified instance is equal to the value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return      @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Tizen::Base::Object, @n
+        *                      else @c false
+        * @param[in]   rhs             An instance of Tizen::Base::Object to compare
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return      The integer value that indicates the hash value of the current instance of Tizen::Base::Object
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the event type.
+        *
+        * @since       2.0
+        *
+        * @return      The event type
+        */
+       ContactEventType GetType(void) const;
+
+       /**
+        * Gets the event date.
+        *
+        * @since       2.0
+        *
+        * @return      The event date
+        */
+       Tizen::Base::DateTime GetDate(void) const;
+
+       /**
+        * Gets the label of an event.
+        *
+        * @since       2.0
+        *
+        * @return      The event label
+        * @see SetLabel()
+        */
+       Tizen::Base::String GetLabel(void) const;
+
+       /**
+        * Sets the event type.
+        *
+        * @since       2.0
+        *
+        * @param[in]   type    The event type
+        */
+       void SetType(ContactEventType type);
+
+       /**
+        * Sets the label of an event. 
+        *
+        * @since       2.0
+        *
+        * @param[in]   label   The event label
+        * @see GetLabel()
+        */
+       void SetLabel(const Tizen::Base::String& label);
+
+       /**
+        * Sets the event date. @n
+        * The time portion of Tizen::Base::DateTime is ignored. The default time is 00:00:00.
+        *
+        * @since       2.0
+        *
+        * @param[in]   date    The event date
+        */
+       void SetDate(const Tizen::Base::DateTime& date);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs     An instance of %ContactEvent to copy
+        */
+       ContactEvent& operator =(const ContactEvent& rhs);
+
+       /**
+        * Checks whether the data in the specified instance of %ContactEvent is equal to the data in the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the data in the specified instance equals the data in the current instance, @n
+        *                              else @c false
+        * @param[in]   rhs             An instance of %ContactEvent
+        */
+       bool operator ==(const ContactEvent& rhs) const;
+
+       /**
+        * Checks whether the data in the specified instance of %ContactEvent is not equal to the data in the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the data in the specified instance is not equal to the data in the current instance, @n
+        *                              else @c false
+        * @param[in]   rhs             An instance of %ContactEvent
+        */
+       bool operator !=(const ContactEvent& rhs) const;
+
+private:
+       friend class _ContactEventImpl;
+       class _ContactEventImpl* __pContactEventImpl;
+
+}; // ContactEvent
+
+}} // Tizen::Social
+
+#endif // _FSCL_CONTACT_EVENT_H_
diff --git a/inc/FSclEmail.h b/inc/FSclEmail.h
new file mode 100644 (file)
index 0000000..0cccec8
--- /dev/null
@@ -0,0 +1,266 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FSclEmail.h
+* @brief       This is the header file for the %Email class.
+*
+* This header file contains the declarations of the %Email class.
+*/
+#ifndef _FSCL_EMAIL_H_
+#define _FSCL_EMAIL_H_
+
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+
+/**
+* @class       Email
+* @brief       This class represents an email.
+*
+* @since       2.0
+*
+* @final       This class is not intended for extension.
+*
+* The %Email class represents an email.
+* An email consists of the email address and email type.
+*
+* The following example demonstrates how to use the %Email class.
+*
+* @code
+using namespace Tizen::Base;
+using namespace Tizen::Social;
+
+result
+MyClass::SomeMethod(void)
+{
+       result r = E_SUCCESS;
+
+       // Creates an instance of %Email
+       Email email = Email();
+
+       // Sets the email address
+       r = email.SetEmail(L"hello@Tizen.com");
+       if (IsFailed(r))
+       {
+               return r;
+       }
+
+       // Sets the email type
+       email.SetType(EMAIL_TYPE_PERSONAL);
+
+       return E_SUCCESS;
+}
+* @endcode
+*/
+class _OSP_EXPORT_ Email
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.0
+        */
+       Email(void);
+
+       /**
+        * Initializes this instance of %Email with the specified @c type and @c email. @n
+        * This constructs an instance of %Email with the specified @c type.
+        *
+        * @since       2.0
+        *
+        * @param[in]   type            The type of email
+        * @param[in]   email           The email address
+        */
+       Email(EmailType type, const Tizen::Base::String& email);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs     An instance of %Email to copy
+        */
+       Email(const Email& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~Email(void);
+
+       /**
+        * Checks whether the value of the specified instance is equal to the value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return      @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Tizen::Base::Object, @n
+        *                      else @c false
+        * @param[in]   rhs             An instance of Tizen::Base::Object to compare
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return      The integer value that indicates the hash value of the current instance of Tizen::Base::Object
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+     * Gets the type of the email.
+     *
+        * @if OSPCOMPAT
+     * @brief <i> [Compatibility] </i>
+        * @endif
+     * @since  2.0
+        * @if OSPCOMPAT
+        * @compatibility            This method has compatibility issues with OSP compatible applications. @n
+     *                           For more information, see @ref CompEmailGetTypePage "here".
+        * @endif
+     *
+     * @return The type of the email
+     */
+       EmailType GetType(void) const;
+
+       /**
+        * @if OSPCOMPAT
+     * @page                CompEmailGetTypePage         Compatibility for GetType()
+     * @section             CompEmailGetTypePageIssueSection             Issues
+        *                                              Implementing this method in OSP compatible applications has the following issue: @n
+     *                                                 -# EMAIL_TYPE_CUSTOM is not supported. If the type of the email is EMAIL_TYPE_CUSTOM, EMAIL_TYPE_OTHER is returned instead.
+     *
+     * @section             CompEmailGetTypePageSolutionSection          Resolutions
+        *                                              The issue mentioned above has been resolved in Tizen.
+        * @endif
+     */
+
+       /**
+        * Gets the email address.
+        *
+        * @since       2.0
+        *
+        * @return      The email address
+        */
+       Tizen::Base::String GetEmail(void) const;
+
+       /**
+        * Sets the type of the email.
+        *
+        * @since       2.0
+        *
+        * @param[in]   type            The type of the email to set
+        */
+       void SetType(EmailType type);
+
+       /**
+        * Sets the email address.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility            This method has compatibility issues with OSP compatible applications. @n
+        *                            For more information, see @ref CompEmailSetEmailPage "here".
+        * @endif
+        *
+        * @return              An error code
+        * @param[in]   email                   The email address
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c email address is an empty string.
+        */
+       result SetEmail(const Tizen::Base::String& email);
+
+       /**
+        * @if OSPCOMPAT
+        * @page                CompEmailSetEmailPage           Compatibility for SetEmail()
+        * @section             CompEmailSetEmailPageIssueSection               Issues
+        *                              Implementing this method in OSP compatible applications has the following issue: @n
+        *                               -# If the length of an email address to be set is greater than 100 characters, E_INVALID_ARG is returned.
+        *
+        * @section             CompEmailSetEmailPageSolutionSection            Resolutions
+        *                              The issue mentioned above has been resolved in Tizen.
+        * @endif
+        */
+
+       /**
+        * Gets the label of an email.
+        *
+        * @since       2.0
+        *
+        * @return      The email label
+        * @see SetLabel()
+        */
+       Tizen::Base::String GetLabel(void) const;
+
+       /**
+        * Sets the label of an email.
+        *
+        * @since       2.0
+        *
+        * @param[in]   label   The email label
+        * @see GetLabel()
+        */
+       void SetLabel(const Tizen::Base::String& label);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs     An instance of %Email to copy
+        */
+       Email& operator =(const Email& rhs);
+
+       /**
+        * Checks whether the value of the specified instance of %Email is equal to the value of the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the value of the specified instance of %Email equals the value of the current instance, @n
+        *                              else @c false
+        * @param[in]   rhs             An instance of %Email
+        */
+       bool operator ==(const Email& rhs) const;
+
+       /**
+        * Checks whether the value of the specified instance of %Email is not equal to the value of the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the value of the specified instance of %Email is not equal to the value of the current instance, @n
+        *                              else @c false
+        * @param[in]   rhs             An instance of %Email
+        */
+       bool operator !=(const Email& rhs) const;
+
+private:
+       friend class _EmailImpl;
+       class _EmailImpl* __pEmailImpl;
+
+}; // Email
+
+}} // Tizen::Social
+
+#endif // _FSCL_EMAIL_H_
diff --git a/inc/FSclEmailContact.h b/inc/FSclEmailContact.h
new file mode 100644 (file)
index 0000000..3307869
--- /dev/null
@@ -0,0 +1,174 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclEmailContact.h
+ * @brief              This is the header file for the %EmailContact class.
+ *
+ * This header file contains the declarations of the %EmailContact class.
+ */
+#ifndef _FSCL_EMAIL_CONTACT_H_
+#define _FSCL_EMAIL_CONTACT_H_
+
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FSclTypes.h>
+#include <FSclEmail.h>
+
+namespace Tizen { namespace Social
+{
+ /**
+ * @class      EmailContact
+ * @brief      This class provides the summarized contact information with the email.
+ *
+ * @since      2.0
+ *
+ * @final      This class is not intended for extension.
+ *
+ * The %EmailContact class provides the summarized contact information. @n
+ * This provides part of the contact information such as the ID, person ID, addressbook ID, display name, ringtone, thumbnail, and email.
+ */
+class _OSP_EXPORT_ EmailContact
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.0
+        */
+       EmailContact(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %EmailContact to copy
+        */
+       EmailContact(const EmailContact& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~EmailContact(void);
+
+       /**
+        * Checks whether the value of the specified instance is equal to the value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return      @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Tizen::Base::Object, @n
+        *                      else @c false
+        * @param[in]   rhs             An instance of Tizen::Base::Object to compare
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since       2.0
+        *
+        * @return      The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the addressbook ID.
+        *
+        * @since       2.0
+        *
+        * @return      The addressbook ID
+        */
+       AddressbookId GetAddressbookId(void) const;
+
+       /**
+        * Gets the person ID.
+        *
+        * @since       2.0
+        *
+        * @return      The person ID
+        */
+       PersonId GetPersonId(void) const;
+
+       /**
+        * Gets the contact ID.
+        *
+        * @since       2.0
+        *
+        * @return      The contact ID
+        */
+       RecordId GetContactId(void) const;
+
+       /**
+        * Gets the display name.
+        *
+        * @since       2.0
+        *
+        * @return      The display name
+        */
+       Tizen::Base::String GetDisplayName(void) const;
+
+       /**
+        * Gets the ringtone path.
+        *
+        * @since       2.0
+        *
+        * @return      The ringtone path, @n 
+        *              else an empty string if the ringtone path has not been set for this contact
+        */
+       Tizen::Base::String GetRingtonePath(void) const;
+
+       /**
+        * Gets the thumbnail path.
+        *
+        * @since       2.0
+        *
+        * @return      The thumbnail path, @n
+        *              else an empty string if the thumbnail path has not been set for this contact
+        */
+       Tizen::Base::String GetThumbnailPath(void) const;
+
+       /**
+        * Gets the email.
+        *
+        * @since       2.0
+        *
+        * @return      An Email instance
+        */
+       Email GetEmail(void) const;
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %EmailContact to copy
+        */
+       EmailContact& operator =(const EmailContact& rhs);
+
+private:
+       friend class _EmailContactImpl;
+       class _EmailContactImpl* __pEmailContactImpl;
+
+};     // EmailContact
+
+}}     // Tizen::Social
+
+#endif // _FSCL_EMAIL_CONTACT_H_
diff --git a/inc/FSclIAccountEventListener.h b/inc/FSclIAccountEventListener.h
new file mode 100644 (file)
index 0000000..465540d
--- /dev/null
@@ -0,0 +1,134 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclIAccountEventListener.h
+ * @brief              This is the header file for the %IAccountEventListener interface.
+ *
+ * This header file contains the declarations of the %IAccountEventListener interface.
+ */
+#ifndef _FSCL_IACCOUNT_EVENT_LISTENER_H_
+#define _FSCL_IACCOUNT_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Base { namespace Collection {
+class IList;
+} } }
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @interface  IAccountEventListener
+ * @brief              This interface provides a listener that receives the events associated with account changes.
+ *
+ * @since              2.1
+ *
+ * The %IAccountEventListener interface provides a listener that receives the events associated with account changes.
+ *
+ */
+class _OSP_EXPORT_ IAccountEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+
+       /**
+        * This polymorphic destructor should be overridden if required. @n
+        * This way, the destructors of the derived classes are called when the destructor of this interface is called.
+        *
+        * @since       2.1
+        */
+       virtual ~IAccountEventListener(void) {}
+
+       /**
+        * Called to notify when an account is added.
+        *
+        * @since       2.1
+        *
+        * @param[in]   accountId       The account ID of the added account
+        */
+       virtual void OnAccountAdded(AccountId accountId) = 0;
+
+       /**
+        * Called to notify when an account is updated.
+        *
+        * @since       2.1
+        *
+        * @param[in]   accountId       The account ID of the updated account
+        */
+       virtual void OnAccountUpdated(AccountId accountId) = 0;
+
+       /**
+        * Called to notify when an account is removed.
+        *
+        * @since       2.1
+        *
+        * @param[in]   accountId       The account ID of the removed account
+        */
+       virtual void OnAccountRemoved(AccountId accountId) = 0;
+
+protected:
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.1
+       //
+       virtual void IAccountEventListener_Reserved1(void){ }
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.1
+       //
+       virtual void IAccountEventListener_Reserved2(void){ }
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.1
+       //
+       virtual void IAccountEventListener_Reserved3(void){ }
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.1
+       //
+       virtual void IAccountEventListener_Reserved4(void){ }
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.1
+       //
+       virtual void IAccountEventListener_Reserved5(void){ }
+
+};     // IAccountEventListener
+
+}}     // Tizen::Social
+
+#endif // _FSCL_IACCOUNT_EVENT_LISTENER_H_
diff --git a/inc/FSclIAddressbookChangeEventListener.h b/inc/FSclIAddressbookChangeEventListener.h
new file mode 100644 (file)
index 0000000..99c3e2c
--- /dev/null
@@ -0,0 +1,148 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file     FSclIAddressbookChangeEventListener.h
+* @brief    This is the header file for the %IAddressbookChangeEventListener interface.
+*
+* This header file contains the declarations of the %IAddressbookChangeEventListener interface.
+*/
+
+#ifndef _FSCL_IADDRESSBOOK_CHANGE_EVENT_LISTENER_H_
+#define _FSCL_IADDRESSBOOK_CHANGE_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+
+namespace Tizen { namespace Base { namespace Collection {
+class IList;
+}}}
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @interface   IAddressbookChangeEventListener
+ * @brief       This interface provides a listener that receives the events associated with contact and category changes.
+ *
+ * @since       2.1
+ *
+ * The %IAddressbookChangeEventListener interface provides a listener that receives the events associated with contact and category changes.
+ *
+ */
+
+class _OSP_EXPORT_ IAddressbookChangeEventListener
+        : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+       /**
+        * This polymorphic destructor should be overridden if required. @n
+        * This way, the destructors of the derived classes are called when the destructor of this interface is called.
+        *
+        * @since       2.1
+        */
+       virtual ~IAddressbookChangeEventListener(void) {}
+
+       /**
+        * Called to notify when changes have been made to contacts. @n
+        * A list of ContactChangeInfo instances is passed.
+        *
+        * @since       2.1
+        *
+        * @param[in]   contactChangeInfoList   The list of contact change information (@ref ContactChangeInfo list)
+        * @remarks This listener method is called when the following changes have occurred: @n
+
+        *      - Contacts are added, updated, or removed
+        *      - Contacts are added/removed to/from categories
+        *
+        * The following example demonstrates how to use the %OnContactsChanged() method.
+        * @code
+        * void
+        * MyApplication::OnContactsChangedN(const IList& contactChangeInfoList)
+        * {
+        *    IEnumerator* pEnum = contactChangeInfoList.GetEnumeratorN();
+        *    while (pEnum->MoveNext() == E_SUCCESS)
+        *    {
+        *      ContactChangeInfo* pInfo = (ContactChangeInfo*) pEnum->GetCurrent();
+        *
+        *      AppLog("Contact changed: type(%d), id(%d), version(%d)", pInfo->GetChangeType(), pInfo->GetContctId(), pInfo->GetVersion());
+        *    }
+        *    delete pEnum;
+        * }
+        * @endcode
+        *
+        */
+       virtual void OnContactsChanged(const Tizen::Base::Collection::IList& contactChangeInfoList) = 0;
+
+       /**
+        * Called to notify when changes have been made to categories. @n
+        * A list of CategoryChangeInfo instances are passed.
+        *
+        * @since       2.1
+        *
+        * @param[in]   categoryChangeInfoList  The list of category change information (@ref CategoryChangeInfo list)
+        * @remarks This listener method is called when the following changes have occurred:
+        *              - Categories are added, updated, or removed
+        *
+        * The following example demonstrates how to use the %OnCategoriesChanged() method.
+        * @code
+        * void
+        * MyApplication::OnCategoriesChangedN(const IList& categoryChangeInfoList)
+        * {
+        *    IEnumerator* pEnum = categoryChangeInfoList.GetEnumeratorN();
+        *    while (pEnum->MoveNext() == E_SUCCESS)
+        *    {
+        *      CategoryChangeInfo* pInfo = (CategoryChangeInfo*) pEnum->GetCurrent();
+        *
+        *      AppLog("Category changed: type(%d), id(%d), version(%d)", pInfo->GetChangeType(), pInfo->GetCategoryId(), pInfo->GetVersion());
+        *    }
+        *    delete pEnum;
+        * }
+        * @endcode
+        *
+        */
+       virtual void OnCategoriesChanged(const Tizen::Base::Collection::IList& categoryChangeInfoList) = 0;
+
+protected:
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.1
+       //
+       virtual void IAddressbookChangeEventListener_Reserved1(void){ }
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.1
+       //
+       virtual void IAddressbookChangeEventListener_Reserved2(void){ }
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.1
+       //
+       virtual void IAddressbookChangeEventListener_Reserved3(void){ }
+};      // IAddressbookChangeEventListener
+
+}}      // Tizen::Social
+
+#endif // _FSCL_IADDRESSBOOK_CHANGE_EVENT_LISTENER_H_
diff --git a/inc/FSclIAddressbookEventListener.h b/inc/FSclIAddressbookEventListener.h
new file mode 100644 (file)
index 0000000..b154a41
--- /dev/null
@@ -0,0 +1,158 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclIAddressbookEventListener.h
+ * @brief              This is the header file for the %IAddressbookEventListener interface.
+ *
+ * This header file contains the declarations of the %IAddressbookEventListener interface.
+ */
+#ifndef _FSCL_IADDRESSBOOK_EVENT_LISTENER_H_
+#define _FSCL_IADDRESSBOOK_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+
+namespace Tizen { namespace Base { namespace Collection {
+class IList;
+} } }
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @interface  IAddressbookEventListener
+ * @brief      <i> [Deprecated] </i> This interface provides a listener that receives the events associated with contact and category changes.
+ *
+ * @deprecated This interface is deprecated. Instead of using this listener, use IAddressbookChangeEventListener.
+ * @since      2.0
+ *
+ * The %IAddressbookEventListener interface provides a listener that receives the events associated with contact and category changes.
+ *
+ */
+class _OSP_EXPORT_ IAddressbookEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+
+       /**
+        * This polymorphic destructor should be overridden if required. @n
+        * This way, the destructors of the derived classes are called when the destructor of this interface is called.
+        *
+        * @brief               <i> [Deprecated] </i>
+        * @deprecated          This method is deprecated because the %IAddressbookEventListener interface is deprecated.
+        *
+        * @since       2.0
+        */
+       virtual ~IAddressbookEventListener(void) {}
+
+       /**
+        * Called to notify when contacts are changed. @n
+        * A list of ContactChangeInfo instances is passed.
+     *
+        * @brief               <i> [Deprecated] </i>
+        * @deprecated          This method is deprecated because the %IAddressbookEventListener interface is deprecated.
+        *
+        * @since       2.0
+        *
+        * @param[in]   contactChangeInfoList   The list of contact change information (@ref ContactChangeInfo list)
+        * @remarks     This listener method is called when the following changes have occurred:
+        *                              - Contacts are added, updated, or removed
+        *                              - Contacts are added/removed to/from categories
+        *
+        * The following example demonstrates how to use the %OnContactsChanged() method.
+        * @code
+        * void
+        * MyApplication::OnContactsChangedN(const IList& contactChangeInfoList)
+        * {
+        *    IEnumerator* pEnum = contactChangeInfoList.GetEnumeratorN();
+        *    while (pEnum->MoveNext() == E_SUCCESS)
+        *    {
+        *      ContactChangeInfo* pInfo = (ContactChangeInfo*) pEnum->GetCurrent();
+        *
+        *      AppLog("Contact changed: type(%d), id(%d), version(%d)", pInfo->GetChangeType(), pInfo->GetContctId(), pInfo->GetVersion());
+        *    }
+        *    delete pEnum;
+        * }
+        * @endcode
+        *
+        */
+       virtual void OnContactsChanged(const Tizen::Base::Collection::IList& contactChangeInfoList) = 0;
+
+       /**
+        * Called to notify when categories are changed. @n
+        * A list of CategoryChangeInfo instances is passed.
+     *
+        * @brief               <i> [Deprecated] </i>
+        * @deprecated          This method is deprecated because the %IAddressbookEventListener interface is deprecated.
+        *
+        * @since       2.0
+        *
+        * @param[in]   categoryChangeInfoList  The list of category change information (@ref CategoryChangeInfo list)
+        * @remarks     This listener method is called when the following changes have occurred:
+        *                              - Categories are added, updated, or removed
+        *                              - Contacts are added/removed to/from categories
+        *
+        * The following example demonstrates how to use the %OnCategoriesChanged() method.
+        * @code
+        * void
+        * MyApplication::OnCategoriesChangedN(const IList& categoryChangeInfoList)
+        * {
+        *    IEnumerator* pEnum = categoryChangeInfoList.GetEnumeratorN();
+        *    while (pEnum->MoveNext() == E_SUCCESS)
+        *    {
+        *      CategoryChangeInfo* pInfo = (CategoryChangeInfo*) pEnum->GetCurrent();
+        *
+        *      AppLog("Category changed: type(%d), id(%d), version(%d)", pInfo->GetChangeType(), pInfo->GetCategoryId(), pInfo->GetVersion());
+        *    }
+        *    delete pEnum;
+        * }
+        * @endcode
+        *
+        */
+       virtual void OnCategoriesChanged(const Tizen::Base::Collection::IList& categoryChangeInfoList) = 0;
+
+protected:
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void IAddressbookEventListener_Reserved1(void){ }
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void IAddressbookEventListener_Reserved2(void){ }
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void IAddressbookEventListener_Reserved3(void){ }
+
+};     // IAddressbookEventListener
+
+}}     // Tizen::Social
+
+#endif // _FSCL_IADDRESSBOOK_EVENT_LISTENER_H_
diff --git a/inc/FSclICalendarbookEventListener.h b/inc/FSclICalendarbookEventListener.h
new file mode 100644 (file)
index 0000000..c4e6653
--- /dev/null
@@ -0,0 +1,107 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclICalendarbookEventListener.h
+ * @brief              This is the header file for the %ICalendarbookEventListener interface.
+ *
+ * This header file contains the declarations of the %ICalendarbookEventListener interface.
+ */
+#ifndef _FSCL_ICALENDARBOOK_EVENT_LISTENER_H_
+#define _FSCL_ICALENDARBOOK_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+}}}
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @interface  ICalendarbookEventListener
+ * @brief              This interface provides a listener that receives the events associated with the calendarbook.
+ *
+ * @since      2.0
+ *
+ * The %ICalendarbookEventListener interface provides a listener that receives the events associated with the calendarbook.
+ */
+class _OSP_EXPORT_ ICalendarbookEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+
+       /**
+        * This polymorphic destructor should be overridden if required. @n
+        * This way, the destructors of the derived classes are called when the destructor of this interface is called.
+        *
+        * @since       2.0
+        */
+       virtual ~ICalendarbookEventListener(void) {}
+
+       /**
+        * Called to notify when the calendar events are changed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   eventChangeInfoList             The list of changed event information represented by CalEventChangeInfo
+        */
+       virtual void OnCalendarEventsChanged(const Tizen::Base::Collection::IList& eventChangeInfoList) = 0;
+
+       /**
+        * Called to notify when the calendar to-dos are changed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   todoChangeInfoList              The list of changed to-do information represented by CalTodoChangeInfo
+        */
+       virtual void OnCalendarTodosChanged(const Tizen::Base::Collection::IList& todoChangeInfoList) = 0;
+       
+protected:
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void ICalendarbookEventListener_Reserved1(void) { }
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void ICalendarbookEventListener_Reserved2(void) { }
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void ICalendarbookEventListener_Reserved3(void) { }
+
+};     // ICalendarbookEventListener
+
+}}     // Tizen::Social
+
+#endif // _FSCL_ICALENDARBOOK_EVENT_LISTENER_H_
diff --git a/inc/FSclIRecordEventListener.h b/inc/FSclIRecordEventListener.h
new file mode 100644 (file)
index 0000000..681a988
--- /dev/null
@@ -0,0 +1,124 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclIRecordEventListener.h
+ * @brief              This is the header file for the %IRecordEventListener interface.
+ *
+ * This header file contains the declarations of the %IRecordEventListener interface.
+ */
+#ifndef _FSCL_IRECORD_EVENT_LISTENER_H_
+#define _FSCL_IRECORD_EVENT_LISTENER_H_
+
+#include <FSclTypes.h>
+#include <FSclRecord.h>
+#include <FBaseRtIEventListener.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+}}}
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @if OSPDEPREC
+ * @interface  IRecordEventListener
+ * @brief              <i> [Deprecated] </i> This interface provides a listener that receives the events associated with a record.
+ *
+ * @deprecated         This interface is deprecated. Instead of using this listener, use IAddressbookEventListener or ICalendarbookEventListener.
+ *
+ * @since      2.0
+ *
+ * The %IRecordEventListener interface provides a listener that receives the events associated with a record.
+ * @endif
+ */
+class _OSP_EXPORT_ IRecordEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+
+       /**
+        * @if OSPDEPREC
+        * This polymorphic destructor should be overridden if required. @n
+        * This way, the destructors of the derived classes are called when the destructor of this interface is called.
+        *
+        * @brief               <i> [Deprecated] </i>
+        * @deprecated          This method is deprecated because the %IRecordEventListener interface is deprecated. @n
+        *                                      Instead of using this listener, use IAddressbookEventListener or ICalendarbookEventListener.
+        *
+        * @since       2.0
+        * @endif
+        */
+       virtual ~IRecordEventListener(void) {}
+
+       /**
+        * @if OSPDEPREC
+        * Called to notify when a record in the data storage is changed externally.
+        *
+        * @if OSPCOMPAT
+        * @brief               <i> [Deprecated][Compatibility] </i>
+        * @endif
+        * @deprecated          This method is deprecated because the %IRecordEventListener interface is deprecated. @n
+        *                                      Instead of using this listener, use IAddressbookEventListener or ICalendarbookEventListener.
+        *
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility       This method has compatibility issues with OSP compatible applications. @n
+        *                                      For more information, see @ref CompIRecordEventListenerOnRecordChangedNPage "here".
+        * @endif
+        *
+        * @param[in]   eventType                               The operation type
+        * @param[in]   recordType                              The record type of the changed record
+        * @param[in]   record                                  The Record instance that has changed @n
+        *                                                                              If the eventType is #RECORD_REMOVED, the %Record instance only has @c recordId and @c recordType but no data. @n
+        *                                                                              When multiple records have changed (#MULTI_RECORDS_ADDED, #MULTI_RECORDS_UPDATED, #MULTI_RECORDS_REMOVED),
+        *                                                                              the %Record instance is an invalid record instance with ::INVALID_RECORD_ID.
+        * @param[in]   pUpdatedProperties              This parameter is not supported, do not use it.
+        * @param[in]   pUpdatedMultiProperties This parameter is not supported, do not use it.
+        * @endif
+        */
+       virtual void OnRecordChangedN(RecordEventType eventType, RecordType recordType, Record& record, Tizen::Base::Collection::IList* pUpdatedProperties, Tizen::Base::Collection::IList* pUpdatedMultiProperties) = 0;
+
+       /**
+        * @if OSPCOMPAT
+        * @page        CompIRecordEventListenerOnRecordChangedNPage Compatibility for OnRecordChangedN()
+        * @section     CompIRecordEventListenerOnRecordChangedNPageIssueSection Issues
+        *                      Implementation of this method has the following issue: @n
+        *                      Even in OSP compatible applications, we cannot support the following operation.
+        *                      -# If an application "A" changes a record, all the applications except "A" receive the change notification.
+        *
+        *                      In Tizen (including OSP compatible applications),
+        *                      -# If an application "A" changes a record, all the applications including "A" receive the change notification.
+        * @endif
+        */
+
+protected:
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void IRecordEventListener_Reserved1(void) { }
+
+};     // IRecordEventListener
+
+}}     // Tizen::Social
+
+#endif // _FSCL_IRECORD_EVENT_LISTENER_H_
diff --git a/inc/FSclIRecordListener.h b/inc/FSclIRecordListener.h
new file mode 100644 (file)
index 0000000..28bc520
--- /dev/null
@@ -0,0 +1,112 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FSclIRecordListener.h
+ * @brief      This is the header file for the %IRecordListener interface.
+ *
+ * This header file contains the declarations of the %IRecordListener interface.
+ */
+#ifndef _FSCL_IRECORD_LISTENER_H_
+#define _FSCL_IRECORD_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FBaseDataType.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+}}}
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @if OSPDEPREC
+ * @interface  IRecordListener
+ * @brief              <i> [Deprecated] </i> This interface represents a listener to asynchronously retrieve records from the Calendarbook or Addressbook.
+ *
+ * @deprecated         This interface is deprecated because the @ref Calendarbook::GetEventInstances method is deprecated.
+ *
+ * @since      2.0
+ *
+ * The %IRecordListener interface represents a listener to asynchronously retrieve records from the Calendarbook or Addressbook.
+ * @endif
+ */
+class _OSP_EXPORT_ IRecordListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+
+       /**
+        * @if OSPDEPREC
+        * This polymorphic destructor should be overridden if required. @n
+        * This way, the destructors of the derived classes are called when the destructor of this interface is called.
+        *
+        * @brief               <i> [Deprecated] </i>
+        * @deprecated          This method is deprecated because the %IRecordListener interface is deprecated.
+        *
+        * @since       2.0
+        * @endif
+        */
+       virtual ~IRecordListener(void) {}
+
+       /**
+        * @if OSPDEPREC
+        * Called when the requested records are retrieved.
+        *
+        * @brief               <i> [Deprecated] </i>
+        * @deprecated          This method is deprecated because the %IRecordListener interface is deprecated.
+        *
+        * @since       2.0
+        *
+        * @param[in]   reqId                           The request ID
+        * @param[in]   pRecords                        The result of a specific asynchronous method @n
+        *                                                                      The list that contains all the retrieved Record instances, @n
+        *                                                                      else an empty list if there are no retrieved records, or @c null if an exception occurs
+        * @param[in]   r                                       The result of the request
+        * @exception   E_SUCCESS                       The request is successful.
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @remarks             After using @c pRecords, the application must delete it.
+        * @see                 Calendarbook::GetEventInstances()
+        * @endif
+        */
+       virtual void OnRecordsReceivedN(RequestId reqId, Tizen::Base::Collection::IList* pRecords, result r) = 0;
+
+protected:
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void IRecordListener_Reserved1(void) { }
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void IRecordListener_Reserved2(void) { }
+
+};     // IRecordListener
+
+}}     // Tizen::Social
+
+#endif // _FSCL_IRECORD_LISTENER_H_
diff --git a/inc/FSclImAddress.h b/inc/FSclImAddress.h
new file mode 100644 (file)
index 0000000..3f4f755
--- /dev/null
@@ -0,0 +1,376 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FSclImAddress.h
+* @brief       This is the header file for the %ImAddress class.
+*
+* This header file contains the declarations of the %ImAddress class.
+*/
+#ifndef _FSCL_IM_ADDRESS_H_
+#define _FSCL_IM_ADDRESS_H_
+
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+
+namespace Tizen { namespace Social
+{
+/**
+ * @if OSPDEPREC
+ * The maximum length of the IM address property.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This constant is deprecated because there is no limitation any more.
+ * @since      2.0
+ * @endif
+ */
+static const int MAX_IM_ADDRESS_LENGTH = 100;
+
+/**
+ * @if OSPDEPREC
+ * The IM service provider name for MSN.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated         This object is provided only for backward compatibility and will be deleted in the near future.
+ *                             Use IM_ADDRESS_MSN instead of this object.
+ * @since      2.0
+ * @endif
+ */
+_OSP_EXPORT_ extern const Tizen::Base::String IM_MSN;
+
+/**
+ * @if OSPDEPREC
+ * The IM service provider name for ICQ.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated         This object is provided only for backward compatibility and will be deleted in the near future.
+ *                             Use IM_ADDRESS_ICQ instead of this object.
+ * @since      2.0
+ * @endif
+ */
+_OSP_EXPORT_ extern const Tizen::Base::String IM_ICQ;
+
+/**
+ * @if OSPDEPREC
+ * The IM service provider name for AIM.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated         This object is provided only for backward compatibility and will be deleted in the near future.
+ *                             Use IM_ADDRESS_AIM instead of this object.
+ * @since      2.0
+ * @endif
+ */
+_OSP_EXPORT_ extern const Tizen::Base::String IM_AIM;
+
+/**
+ * @if OSPDEPREC
+ * The IM service provider name for Yahoo.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated         This object is provided only for backward compatibility and will be deleted in the near future.
+ *                             Use IM_ADDRESS_YAHOO instead of this object.
+ * @since      2.0
+ * @endif
+ */
+_OSP_EXPORT_ extern const Tizen::Base::String IM_YAHOO;
+
+/**
+ * @if OSPDEPREC
+ * The IM service provider name for Jabber.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated         This object is provided only for backward compatibility and will be deleted in the near future.
+ *                             Use IM_ADDRESS_JABBER instead of this object.
+ * @since      2.0
+ * @endif
+ */
+_OSP_EXPORT_ extern const Tizen::Base::String IM_JABBER;
+
+/**
+ * @if OSPDEPREC
+ * The IM service provider name for Google talk.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated         This object is provided only for backward compatibility and will be deleted in the near future.
+ *                             Use IM_ADDRESS_GTALK instead of this object.
+ * @since      2.0
+ * @endif
+ */
+_OSP_EXPORT_ extern const Tizen::Base::String IM_GTALK;
+
+/**
+ * @if OSPDEPREC
+ * The IM service provider name for Skype.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated         This object is provided only for backward compatibility and will be deleted in the near future.
+ *                             Use IM_ADDRESS_SKYPE instead of this object.
+ * @since      2.0
+ * @endif
+ */
+_OSP_EXPORT_ extern const Tizen::Base::String IM_SKYPE;
+
+/**
+ * @if OSPDEPREC
+ * The IM service provider name for QQ.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated         This object is provided only for backward compatibility and will be deleted in the near future.
+ *                             Use IM_ADDRESS_QQ instead of this object.
+ * @since      2.0
+ * @endif
+ */
+_OSP_EXPORT_ extern const Tizen::Base::String IM_QQ;
+
+/**
+ * The IM service provider name for AIM.
+ *
+ * @since      2.0
+ */
+_OSP_EXPORT_ extern const wchar_t IM_ADDRESS_AIM[];
+
+/**
+ * The IM service provider name for Google talk.
+ *
+ * @since      2.0
+ */
+_OSP_EXPORT_ extern const wchar_t IM_ADDRESS_GOOGLE_TALK[];
+
+/**
+ * The IM service provider name for ICQ.
+ *
+ * @since      2.0
+ */
+_OSP_EXPORT_ extern const wchar_t IM_ADDRESS_ICQ[];
+
+/**
+ * The IM service provider name for Jabber.
+ *
+ * @since      2.0
+ */
+_OSP_EXPORT_ extern const wchar_t IM_ADDRESS_JABBER[];
+
+/**
+ * The IM service provider name for MSN.
+ *
+ * @since      2.0
+*/
+_OSP_EXPORT_ extern const wchar_t IM_ADDRESS_MSN[];
+
+/**
+ * The IM service provider name for QQ.
+ *
+ * @since      2.0
+ */
+_OSP_EXPORT_ extern const wchar_t IM_ADDRESS_QQ[];
+
+/**
+ * The IM service provider name for Skype.
+ *
+ * @since      2.0
+ */
+_OSP_EXPORT_ extern const wchar_t IM_ADDRESS_SKYPE[];
+
+/**
+ * The IM service provider name for Yahoo.
+ *
+ * @since      2.0
+ */
+_OSP_EXPORT_ extern const wchar_t IM_ADDRESS_YAHOO[];
+
+/**
+ * @class      ImAddress
+ * @brief      This class represents the Instant Messenger (IM) addresses.
+ *
+ * @since      2.0
+ *
+ * @final      This class is not intended for extension.
+ *
+ * The %ImAddress class represents the Instant Messenger (IM) addresses. It consists of an IM service provider name and an account.
+ */
+class _OSP_EXPORT_ ImAddress
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.0
+        */
+       ImAddress(void);
+
+       /**
+        * Initializes this instance of %ImAddress with the specified parameters. @n
+        * This constructs an instance of %ImAddress with the specified service provider name.
+        *
+        * @since       2.0
+        *
+        * @param[in]   serviceProviderName             The service provider name of the %ImAddress
+        * @param[in]   imAddress                               The IM address
+        * @see                 #IM_ADDRESS_AIM
+        * @see                 #IM_ADDRESS_GOOGLE_TALK
+        * @see                 #IM_ADDRESS_ICQ
+        * @see                 #IM_ADDRESS_JABBER
+        * @see                 #IM_ADDRESS_MSN
+        * @see                 #IM_ADDRESS_QQ
+        * @see                 #IM_ADDRESS_SKYPE
+        * @see                 #IM_ADDRESS_YAHOO
+        */
+       ImAddress(const Tizen::Base::String& serviceProviderName, const Tizen::Base::String& imAddress);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs     An instance of %ImAddress to copy
+        */
+       ImAddress(const ImAddress& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~ImAddress(void);
+
+       /**
+        * Checks whether the value of the specified instance is equal to the value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return      @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Tizen::Base::Object, @n
+        *                      else @c false
+        * @param[in]   rhs             An instance of Tizen::Base::Object to compare
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return      The integer value that indicates the hash value of the current instance of Tizen::Base::Object
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the service provider name of the IM address.
+        *
+        * @since       2.0
+        *
+        * @return              The service provider name of the IM address
+        */
+       Tizen::Base::String GetServiceProviderName(void) const;
+
+       /**
+        * Gets the IM address of the current instance of %ImAddress.
+        *
+        * @since       2.0
+        *
+        * @return              The IM address
+        */
+       Tizen::Base::String GetImAddress(void) const;
+
+       /**
+        * Sets the service provider name of the IM address.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   serviceProviderName             The service provider name of the IM address
+        * @see                 #IM_ADDRESS_AIM
+        * @see                 #IM_ADDRESS_GOOGLE_TALK
+        * @see                 #IM_ADDRESS_ICQ
+        * @see                 #IM_ADDRESS_JABBER
+        * @see                 #IM_ADDRESS_MSN
+        * @see                 #IM_ADDRESS_QQ
+        * @see                 #IM_ADDRESS_SKYPE
+        * @see                 #IM_ADDRESS_YAHOO
+        */
+       void SetServiceProviderName(const Tizen::Base::String& serviceProviderName);
+
+       /**
+        * Sets the IM address of the current instance of %ImAddress.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility     This method has compatibility issues with OSP compatible applications. @n
+        *                                        For more information, see @ref CompImAddressSetImAddressPage "here".
+        * @endif
+        *
+        * @return              An error code
+        * @param[in]   imAddress                       The IM address
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c imAddress is an empty string.
+        */
+       result SetImAddress(const Tizen::Base::String& imAddress);
+
+       /**
+        * @if OSPCOMPAT
+        * @page                CompImAddressSetImAddressPage           Compatibility for SetImAddress()
+        * @section             CompImAddressSetImAddressPageIssueSection               Issues
+        *                              Implementing this method in OSP compatible applications has the following issue: @n
+        *                              -# If the length of an IM address to be set is greater than 100 characters, @c E_INVALID_ARG is returned.
+        *
+        * @section             CompImAddressSetImAddressPageSolutionSection            Resolutions
+        *                              The issue mentioned above has been resolved in Tizen.
+        * @endif
+        */
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs     An instance of %ImAddress to copy
+        */
+       ImAddress& operator =(const ImAddress& rhs);
+
+       /**
+        * Checks whether the value of the specified instance of %ImAddress is equal to the value of the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the value of the specified instance of %ImAddress is equal to the value of the current instance, @n
+        *                              else @c false
+        * @param[in]   rhs             An instance of %ImAddress
+        */
+       bool operator ==(const ImAddress& rhs) const;
+
+       /**
+        * Checks whether the value of the specified instance of %ImAddress is not equal to the value of the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the value of the specified instance of %ImAddress is not equal to the value of the current instance, @n
+        *                              else @c false
+        * @param[in]   rhs             An instance of %ImAddress
+        */
+       bool operator !=(const ImAddress& rhs) const;
+
+private:
+       friend class _ImAddressImpl;
+       class _ImAddressImpl* __pImAddressImpl;
+
+}; // ImAddress
+
+}} // Tizen::Social
+
+#endif // _FSCL_IM_ADDRESS_H_
diff --git a/inc/FSclOrganization.h b/inc/FSclOrganization.h
new file mode 100644 (file)
index 0000000..21e168b
--- /dev/null
@@ -0,0 +1,338 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FSclOrganization.h
+ * @brief      This is the header file for the %Organization class.
+ *
+ * This header file contains the declarations of the %Organization class.
+ */
+#ifndef _FSCL_ORGANIZATION_H_
+#define _FSCL_ORGANIZATION_H_
+
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+}}
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @class      Organization
+ * @brief      This class represents the organization information.
+ *
+ * @since      2.0
+ *
+ * @final      This class is not intended for extension.
+ *
+ * The %Organization class represents the organization information of a person. @n
+ * The organization information consists of the name, job title, role, agent, and department.
+ */
+class _OSP_EXPORT_ Organization
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.0
+        */
+       Organization(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %Organization to copy
+        */
+       Organization(const Organization& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~Organization(void);
+
+       /**
+        * Checks whether the value of the specified instance is equal to the value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return      @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Tizen::Base::Object, @n
+        *                      else @c false
+        * @param[in]   rhs             An instance of Tizen::Base::Object to compare
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return      The integer value that indicates the hash value of the current instance of Tizen::Base::Object
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the organization name.
+        *
+        * @since       2.0
+        *
+        * @return      The organization name
+        */
+       Tizen::Base::String GetName(void) const;
+
+       /**
+        * Gets the job title.
+        *
+        * @since       2.0
+        *
+        * @return      The job title
+        */
+       Tizen::Base::String GetJobTitle(void) const;
+
+       /**
+        * Gets the department. 
+        *
+        * @since       2.0
+        *
+        * @return      The department
+        */
+       Tizen::Base::String GetDepartment(void) const;
+
+       /**
+        * Gets the role.
+        *
+        * @since       2.0
+        *
+        * @return      The role
+        */
+       Tizen::Base::String GetRole(void) const;
+
+       /**
+        * Gets the agent.
+        *
+        * @since       2.0
+        *
+        * @return      The agent
+        */
+       Tizen::Base::String GetAgent(void) const;
+
+       /**
+        * Gets the organization type.
+        *
+        * @since       2.1
+        *
+        * @return      The organization type
+        */
+       OrganizationType GetType(void) const;
+
+       /**
+        * Gets the label of the organization.
+        *
+        * @since       2.1
+        *
+        * @return      The organization label
+        */
+       Tizen::Base::String GetLabel(void) const;
+
+       /**
+        * Gets the location.
+        *
+        * @since       2.1
+        *
+        * @return      The location
+        */
+       Tizen::Base::String GetLocation(void) const;
+
+       /**
+        * Gets the description.
+        *
+        * @since       2.1
+        *
+        * @return      The description
+        */
+       Tizen::Base::String GetDescription(void) const;
+
+       /**
+        * Gets the phonetic name.
+        *
+        * @since       2.1
+        *
+        * @return      The phonetic name
+        */
+       Tizen::Base::String GetPhoneticName(void) const;
+
+       /**
+        * Gets the logo image path.
+        *
+        * @since       2.1
+        *
+        * @return      The logo image file path
+        */
+       Tizen::Base::String GetLogoPath(void) const;
+
+       /**
+       * Sets the name of the organization.
+       *
+       * @since        2.0
+       *
+       * @param[in]    name    The organization name
+       */
+       void SetName(const Tizen::Base::String& name);
+
+       /**
+        * Sets the job title.
+        *
+        * @since       2.0
+        *
+        * @param[in]   jobTitle        The job title
+        */
+       void SetJobTitle(const Tizen::Base::String& jobTitle);
+
+       /**
+        * Sets the department.
+        *
+        * @since       2.0
+        *
+        * @param[in]   department      The department
+        */
+       void SetDepartment(const Tizen::Base::String& department);
+
+       /**
+        * Sets the role.
+        *
+        * @since       2.0
+        *
+        * @param[in]   role    The role
+        */
+       void SetRole(const Tizen::Base::String& role);
+
+       /**
+        * Sets the agent.
+        *
+        * @since       2.0
+        *
+        * @param[in]   agent           The agent
+        */
+       void SetAgent(const Tizen::Base::String& agent);
+
+       /**
+        * Sets the organization type.
+        *
+        * @since       2.1
+        *
+        * @param[in]   type    The organization type
+        */
+       void SetType(OrganizationType type);
+
+       /**
+        * Sets the label of the organization.
+        *
+        * @since       2.1
+        *
+        * @param[in]   label   The organization label
+        */
+       void SetLabel(const Tizen::Base::String& label);
+
+       /**
+        * Sets the location.
+        *
+        * @since       2.1
+        *
+        * @param[in]   location    The location
+        */
+       void SetLocation(const Tizen::Base::String& location);
+
+       /**
+        * Sets the description.
+        *
+        * @since       2.1
+        *
+        * @param[in]   description    The description
+        */
+       void SetDescription(const Tizen::Base::String& description);
+
+       /**
+        * Sets the phonetic name.
+        *
+        * @since       2.1
+        *
+        * @param[in]   phoneticName    The phonetic name
+        */
+       void SetPhoneticName(const Tizen::Base::String& phoneticName);
+
+       /**
+        * Sets the logo image. @n
+        * If the specified @c filePath is an empty string, the current logo image is removed.
+        *
+        * @since       2.1
+        *
+        * @param[in]   filePath                        The file path of the logo image
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The length of the specified @c filePath exceeds system limitations.
+        * @exception   E_FILE_NOT_FOUND        The specified file cannot be found or accessed.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @remarks     The logo image is copied to the specific directory for logo images by the system, when the contact is added or updated.
+        *              Therefore, GetLogoPath() returns the file path to which the logo image is copied.
+        */
+       result SetLogo(const Tizen::Base::String& filePath);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %Organization to copy
+        */
+       Organization& operator =(const Organization& rhs);
+
+       /**
+        * Checks whether the data in the specified instance of %Organization is equal to the data in the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the data in the specified instance equals the data in the current instance, @n
+        *                              else @c false
+        * @param[in]   rhs             An instance of %Organization
+        */
+       bool operator ==(const Organization& rhs) const;
+
+       /**
+        * Checks whether the data in the specified instance of %Organization is not equal to the data in the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the data in the specified instance is not equal to the data in the current instance, @n
+        *                              else @c false
+        * @param[in]   rhs             An instance of %Organization
+        */
+       bool operator !=(const Organization& rhs) const;
+
+private:
+       friend class _OrganizationImpl;
+       class _OrganizationImpl* __pOrganizationImpl;
+}; // Organization
+
+}} // Tizen::Social
+
+#endif //_FSCL_ORGANIZATION_H_
diff --git a/inc/FSclPerson.h b/inc/FSclPerson.h
new file mode 100644 (file)
index 0000000..faa30cf
--- /dev/null
@@ -0,0 +1,311 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclPerson.h
+ * @brief              This is the header file for the %Person class.
+ *
+ * This header file contains the declarations of the %Person class.
+ */
+#ifndef _FSCL_PERSON_H_
+#define _FSCL_PERSON_H_
+
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FSclRecord.h>
+#include <FSclTypes.h>
+#include <FSclPhoneNumber.h>
+#include <FSclEmail.h>
+
+namespace Tizen { namespace Base
+{
+namespace Collection
+{
+template<typename Type>
+class IListT;
+}
+} }
+
+namespace Tizen { namespace Graphics
+{
+class Bitmap;
+} }
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @class      Person
+ * @brief      This class provides an aggregated contact information.
+ *
+ * @since      2.0
+ *
+ * @final      This class is not intended for extension.
+ *
+ * The %Person class provides an aggregated contact information of a person. @n 
+ * There can be more than one contact of the same person because contacts can be synchronized from multiple service providers. @n
+ * %Person has the following information of an individual. @n
+ * - Display name
+ * - Thumbnail
+ * - Ringtone 
+ * - Primary phone number
+ * - Primary email
+ *
+ * Each information is collected from contacts linked to the person. @n
+ *
+ * There is no explicit way to create a person. When a contact is added, the system creates a new person and links the contact to the person.
+ * It is possible to merge two persons into one or unlink a contact from a person.
+ */
+
+class _OSP_EXPORT_ Person
+        : public Tizen::Base::Object
+{
+public:
+        /**
+         * This destructor overrides Tizen::Base::Object::~Object().
+         *
+         * @since      2.0
+         */
+       virtual ~Person(void);
+
+       /**
+        * Checks whether the value of the specified instance is equal to the value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return     @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Tizen::Base::Object, @n
+        *             else @c false
+        * @param[in]  rhs            An instance of Tizen::Base::Object to compare
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since       2.0
+        *
+        * @return     The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the display name.
+        *
+        * @since       2.0
+        *
+        * @return     The display name
+        */
+       Tizen::Base::String GetDisplayName(void) const;
+
+       /**
+        * Checks whether this is a favorite.
+        *
+        * @since       2.0
+        *
+        * @return     @c true if this is a favorite, @n
+        *              else @c false
+        * @see SetAsFavorite()
+        */
+       bool IsFavorite(void) const;
+
+       /**
+        * Gets the thumbnail path.
+        *
+        * @since       2.0
+        *
+        * @return     The file path of the thumbnail
+        * @remarks    If the thumbnail path has not been set, an empty string is returned.
+        */
+       Tizen::Base::String GetThumbnailPath(void) const;
+
+       /**
+        * Gets the ringtone path.
+        *
+        * @since       2.0
+        *
+        * @return     The file path of the ringtone
+        * @remarks    If the ringtone path has not been set, an empty string is returned.
+        */
+       Tizen::Base::String GetRingtonePath(void) const;
+
+       /**
+        * Checks whether this has phone numbers.
+        *
+        * @since       2.0
+        *
+        * @return     @c true if this has phone numbers, @n
+        *              else @c false
+        */
+       bool HasPhoneNumber(void) const;
+
+       /**
+        * Checks whether this has emails.
+        *
+        * @since       2.0
+        *
+        * @return     @c true if this has emails, @n
+        *              else @c false
+        */
+       bool HasEmail(void) const;
+
+       /**
+        * Gets the list of account IDs, of contacts linked to the person.
+        *
+        * @since       2.0
+        *
+        * @return     The account ID list
+        * @exception  E_SUCCESS              The method is successful.
+        * @exception  E_OUT_OF_MEMORY        The memory is insufficient.
+        * @exception  E_SYSTEM                   The method cannot proceed due to a severe system error.
+        * @remarks    The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IListT<AccountId>* GetAccountIdsN(void) const;
+
+       /**
+        * Gets the ID of this person.
+        *
+        * @since       2.0
+        *
+        * @return      The person ID
+        */
+       PersonId GetId(void) const;
+
+       /**
+        * Sets whether this person is a favorite.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return      An error code
+        * @param[in]   isFavorite                      Set to @c true to set this person as a favorite, @n
+        *                                              else @c false to set this person as a non-favorite
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
+        * @see IsFavorite()
+        * @see AddressbookManager::GetFavoritePersonsN()
+        */
+       result SetAsFavorite(bool isFavorite = true);
+
+
+       /**
+        * Sets the specified phone number as the primary phone number of this person.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return     An error code
+        * @param[in]  phoneNumber                      The phone number
+        * @exception  E_SUCCESS                        The method is successful.
+        * @exception  E_PRIVILEGE_DENIED       The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception  E_INVALID_ARG            The specified @c phoneNumber is invalid.
+        * @exception  E_SYSTEM                         The method cannot proceed due to a severe system error.
+        * @see GetPrimaryPhoneNumber()
+        */
+       result SetAsPrimaryPhoneNumber(const PhoneNumber& phoneNumber);
+
+       /**
+        * Sets the specified email as the primary email of this person.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.write
+        *
+        * @return     An error code
+        * @param[in]  email                            The email
+        * @exception  E_SUCCESS                        The method is successful.
+        * @exception  E_PRIVILEGE_DENIED       The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED    The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception  E_INVALID_ARG            The specified @c phoneNumber is invalid.
+        * @exception  E_SYSTEM                         The method cannot proceed due to a severe system error.
+        * @see GetPrimaryEmail()
+        */
+       result SetAsPrimaryEmail(const Email& email);
+
+       /**
+        * Gets the primary phone number of this person.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The primary phone number @n If this instance does not have a primary email, an empty PhoneNumber instance is returned.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED            The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @see SetAsPrimaryPhoneNumber()
+        */
+       PhoneNumber GetPrimaryPhoneNumber(void) const;
+
+       /**
+        * Gets the primary email of this person.
+        *
+        * @since       2.0
+        * @privlevel   public
+        * @privilege   %http://tizen.org/privilege/contact.read
+        *
+        * @return              The primary email @n If this instance does not have a primary email, an empty Email instance is returned.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @exception   E_USER_NOT_CONSENTED            The user has blocked the application from calling this method. @b Since: @b 2.1
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @see SetAsPrimaryEmail()
+        */
+       Email GetPrimaryEmail(void) const;
+
+private:
+       /**
+        * This constructor is intentionally declared as private so that only the platform can create an instance.
+        *
+        * @since       2.0
+        */
+       Person(void);
+
+       /**
+        * This copy constructor is intentionally declared as private to prohibit copying of objects by users.
+        *
+        * @since       2.0
+        *
+        * @param[in]  rhs            An instance of %Person
+        */
+       Person(const Person& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @since       2.0
+        *
+        * @param[in]  rhs            An instance of %Person
+        */
+       Person& operator =(const Person& rhs);
+
+private:
+        friend class _PersonImpl;
+        class _PersonImpl* __pPersonImpl;
+
+        friend class _AddressbookManagerImpl;
+        friend class _AddressbookUtil;
+};     // Person
+
+}}     // Tizen::Social
+
+#endif // _FSCL_PERSON_H_
diff --git a/inc/FSclPhoneNumber.h b/inc/FSclPhoneNumber.h
new file mode 100644 (file)
index 0000000..65723e2
--- /dev/null
@@ -0,0 +1,264 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FSclPhoneNumber.h
+* @brief       This is the header file for the %PhoneNumber class.
+*
+* This header file contains the declarations of the %PhoneNumber class.
+*/
+#ifndef _FSCL_PHONE_NUMBER_H_
+#define _FSCL_PHONE_NUMBER_H_
+
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+
+/**
+* @class       PhoneNumber
+* @brief       This class stores the information of a phone number.
+*
+* @since       2.0
+*
+* @final       This class is not intended for extension.
+*
+* The %PhoneNumber class consists of the phone number and phone number type.
+*
+* The following example demonstrates how to use the %PhoneNumber class.
+*
+* @code
+using namespace Tizen::Base;
+using namespace Tizen::Social::Services;
+
+result
+MyClass::SomeMethod(void)
+{
+       result r = E_SUCCESS;
+
+       // Creates an instance of PhoneNumber
+       PhoneNumber phoneNumber = PhoneNumber();
+
+       // Sets the number
+       r = phoneNumber.SetPhoneNumber(L"010-111-2222");
+       if (IsFailed(r))
+       {
+               return r;
+       }
+
+       // Sets the type
+       phoneNumber.SetType(PHONENUMBER_TYPE_MOBILE);
+
+       return E_SUCCESS;
+}
+* @endcode
+*/
+class _OSP_EXPORT_ PhoneNumber
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.0
+        */
+       PhoneNumber(void);
+
+       /**
+        * Initializes this instance of %PhoneNumber with the specified type and phone number.
+        *
+        * @since       2.0
+        *
+        * @param[in]   type            The type of the phone number
+        * @param[in]   number          The phone number
+        */
+       PhoneNumber(PhoneNumberType type, const Tizen::Base::String& number);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %PhoneNumber to copy
+        */
+       PhoneNumber(const PhoneNumber& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~PhoneNumber(void);
+
+       /**
+        * Checks whether the value of the specified instance is equal to the value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return      @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Tizen::Base::Object, @n
+        *                      else @c false
+        * @param[in]   rhs             An instance of Tizen::Base::Object to compare
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return      The integer value that indicates the hash value of the current instance of Tizen::Base::Object
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+     * Gets the type of the phone number.
+     *
+        * @if OSPCOMPAT
+     * @brief <i> [Compatibility] </i>
+        * @endif
+     * @since  2.0
+        * @if OSPCOMPAT
+        * @compatibility            This method has compatibility issues with OSP compatible applications. @n
+     *                           For more information, see @ref CompPhoneNumberGetTypePage "here".
+        * @endif
+     *
+     * @return The type of the phone number
+     */
+       PhoneNumberType GetType(void) const;
+
+       /**
+        * @if OSPCOMPAT
+     * @page                CompPhoneNumberGetTypePage         Compatibility for GetType()
+     * @section             CompPhoneNumberGetTypePageIssueSection             Issues
+        *                                              Implementing this method in OSP compatible applications has the following issue: @n
+     *                                                 -# PHONENUMBER_TYPE_CUSTOM is not supported. If the type of the phone number is PHONENUMBER_TYPE_CUSTOM, PHONENUMBER_TYPE_OTHER is returned instead.
+     *
+     * @section             CompPhoneNumberGetTypePageSolutionSection          Resolutions
+        *                                              The issue mentioned above has been resolved in Tizen.
+        * @endif
+     */
+
+       /**
+        * Gets the phone number.
+        *
+        * @since       2.0
+        *
+        * @return      The phone number
+        */
+       Tizen::Base::String GetPhoneNumber(void) const;
+
+       /**
+        * Sets the type of the phone number.
+        *
+        * @since       2.0
+        *
+        * @param[in]   type            The type of the phone number
+        */
+       void SetType(PhoneNumberType type);
+
+       /**
+        * Sets the specified phone number.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility            This method has compatibility issues with OSP compatible applications. @n
+        *                            For more information, see @ref CompPhoneNumberSetPhoneNumberPage "here".
+        * @endif
+        *
+        * @return          An error code
+        * @param[in]   number                  The phone number to set
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c number is an empty string.
+        */
+       result SetPhoneNumber(const Tizen::Base::String& number);
+
+       /**
+        * @if OSPCOMPAT
+        * @page                CompPhoneNumberSetPhoneNumberPage               Compatibility for SetPhoneNumber()
+        * @section             CompPhoneNumberSetPhoneNumberPageIssueSection           Issues
+        *                              Implementing this method in OSP compatible applications has the following issue: @n
+        *                              -# If the length of the phone number to be set is greater than 50 characters, @c E_INVALID_ARG is returned.
+        *                              -# Only alphabets (a~z, A~Z), numbers, plus (+), asterisk (*), pound (#), and comma (,) are allowed.
+        *
+        * @section             CompPhoneNumberSetPhoneNumberPageSolutionSection                Resolutions
+        *                              The issue mentioned above has been resolved in Tizen.
+        * @endif
+        */
+
+       /**
+        * Gets the label of a phone number.
+        *
+        * @since       2.0
+        *
+        * @return      The phone number label
+        * @see SetLabel()
+        */
+       Tizen::Base::String GetLabel(void) const;
+
+       /**
+        * Sets the label of an event. 
+        *
+        * @since       2.0
+        *
+        * @param[in]   label   The phone number label
+        * @see GetLabel()
+        */
+       void SetLabel(const Tizen::Base::String& label);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs     An instance of %PhoneNumber to copy
+        */
+       PhoneNumber& operator =(const PhoneNumber& rhs);
+
+       /**
+        * Checks whether the data in the specified instance of %PhoneNumber is equal to the data in the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the data in the specified instance equals the data in the current instance, @n
+        *                              else @c false
+        * @param[in]   rhs             An instance of %PhoneNumber
+        */
+       bool operator ==(const PhoneNumber& rhs) const;
+
+       /**
+        * Checks whether the data in the specified instance of %PhoneNumber is not equal to the data in the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the data in the specified instance is not equal to the data in the current instance, @n
+        *                              else @c false
+        * @param[in]   rhs             An instance of %PhoneNumber
+        */
+       bool operator !=(const PhoneNumber& rhs) const;
+
+private:
+       friend class _PhoneNumberImpl;
+       class _PhoneNumberImpl * __pPhoneNumberImpl;
+
+}; // PhoneNumber
+
+}} // Tizen::Social
+
+#endif // _FSCL_PHONE_NUMBER_H_
diff --git a/inc/FSclPhoneNumberContact.h b/inc/FSclPhoneNumberContact.h
new file mode 100644 (file)
index 0000000..a43ccca
--- /dev/null
@@ -0,0 +1,174 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclPhoneNumberContact.h
+ * @brief              This is the header file for the %PhoneNumberContact class.
+ *
+ * This header file contains the declarations of the %PhoneNumberContact class.
+ */
+#ifndef _FSCL_PHONE_NUMBER_CONTACT_H_
+#define _FSCL_PHONE_NUMBER_CONTACT_H_
+
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FSclTypes.h>
+#include <FSclPhoneNumber.h>
+
+namespace Tizen { namespace Social
+{
+ /**
+ * @class      PhoneNumberContact
+ * @brief      This class provides the summarized contact information with the phone number.
+ *
+ * @since      2.0
+ *
+ * @final      This class is not intended for extension.
+ *
+ * The %PhoneNumberContact class provides the summarized contact information. @n
+ * This provides a part of the contact information such as the ID, person ID, addressbook ID, display name, ringtone, thumbnail, and phone number.
+ */
+class _OSP_EXPORT_ PhoneNumberContact
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.0
+        */
+       PhoneNumberContact(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %PhoneNumberContact to copy
+        */
+       PhoneNumberContact(const PhoneNumberContact& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~PhoneNumberContact(void);
+
+       /**
+        * Checks whether the value of the specified instance is equal to the value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return      @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Tizen::Base::Object, @n
+        *                      else @c false
+        * @param[in]   rhs             An instance of Tizen::Base::Object to compare
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since       2.0
+        *
+        * @return      The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the addressbook ID.
+        *
+        * @since       2.0
+        *
+        * @return      The addressbook ID
+        */
+       AddressbookId GetAddressbookId(void) const;
+
+       /**
+        * Gets the person ID.
+        *
+        * @since       2.0
+        *
+        * @return      The person ID
+        */
+       PersonId GetPersonId(void) const;
+
+       /**
+        * Gets the contact ID.
+        *
+        * @since       2.0
+        *
+        * @return      The contact ID
+        */
+       RecordId GetContactId(void) const;
+
+       /**
+        * Gets the display name.
+        *
+        * @since       2.0
+        *
+        * @return      The display name
+        */
+       Tizen::Base::String GetDisplayName(void) const;
+
+        /**
+         * Gets the ringtone path.
+         *
+         * @since      2.0
+         *
+         * @return      The ringtone path, @n
+                *              else an empty string if the ringtone path has not been set for this contact
+         */
+       Tizen::Base::String GetRingtonePath(void) const;
+
+       /**
+         * Gets the thumbnail path.
+         *
+         * @since      2.0
+         *
+         * @return      The thumbnail path, @n
+                *              else an empty string if the thumbnail path has not been set for this contact
+         */
+       Tizen::Base::String GetThumbnailPath(void) const;
+
+       /**
+        * Gets the phone number.
+        *
+        * @since       2.0
+        *
+        * @return      A PhoneNumber instance
+        */
+       PhoneNumber GetPhoneNumber(void) const;
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %PhoneNumberContact to copy
+        */
+       PhoneNumberContact& operator =(const PhoneNumberContact& rhs);
+
+private:
+       friend class _PhoneNumberContactImpl;
+       class _PhoneNumberContactImpl* __pPhoneNumberContactImpl;
+
+};     // PhoneNumberContact
+
+}}     // Tizen::Social
+
+#endif // _FSCL_PHONE_NUMBER_CONTACT_H_
diff --git a/inc/FSclRecord.h b/inc/FSclRecord.h
new file mode 100644 (file)
index 0000000..586675d
--- /dev/null
@@ -0,0 +1,128 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FSclRecord.h
+ * @brief      This is the header file for the %Record class.
+ *
+ * This header file contains the declarations of the %Record class.
+ */
+
+#ifndef _FSCL_RECORD_H_
+#define _FSCL_RECORD_H_
+
+#include <FBaseObject.h>
+#include <FBaseColIList.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @enum RecordType
+ *
+ * Defines the possible types of a record.
+ *
+ * @since      2.0
+ */
+enum RecordType
+{
+       RECORD_TYPE_CONTACT = 0x01,             /**< The contact type */
+       RECORD_TYPE_CATEGORY = 0x02,    /**< The category type */
+       RECORD_TYPE_EVENT = 0x04,               /**< The event type */
+       RECORD_TYPE_TODO = 0x08,                /**< The to-do type */
+       RECORD_TYPE_CALENDAR = 0x10             /**< The calendar type */
+};
+
+/**
+ * @class      Record
+ * @brief      This class defines the general behavior of records used in the %Social namespace.
+ *
+ * @since      2.0
+ *
+ * The %Record class defines the general behavior of records used in the Social namespace. Users cannot create an instance directly from this
+ * class. Instead, they have to instantiate the classes derived from %Record.
+ */
+class _OSP_EXPORT_ Record
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * Gets the type of the record.
+        *
+        * @since       2.0
+        *
+        * @return      The type of the record
+        */
+       RecordType GetRecordType(void) const;
+
+       /**
+        * Gets the local-wide unique ID of the current instance of %Record. @n
+        * The @c RecordId is assigned by an address book when a record is added to it. @n
+        * A newly constructed record instance has ::INVALID_RECORD_ID.
+        *
+        * @since       2.0
+        *
+        * @return      The ID of the record
+        */
+       RecordId GetRecordId(void) const;
+
+protected:
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       //
+       // Initializes this instance of %Record with the specified @c type.
+       //
+       // @since       2.0
+       //
+       // @param[in]   type    The record type
+       //
+       Record(RecordType type);
+
+       //
+       // This copy constructor is intentionally declared as private to prohibit copying of objects by users.
+       //
+       // @since       2.0
+       //
+       // @param[in]   rhs             The source instance of %Record
+       //
+       Record(const Record& rhs);
+
+       //
+       // This destructor is intentionally declared as private so that only the platform can delete an instance.
+       //
+       // @since       2.0
+       //
+       virtual ~Record(void);
+
+       //
+       // This copy assignment operator is intentionally declared as private to prohibit copying of objects by users.
+       //
+       // @since       2.0
+       //
+       // @param[in]   rhs             An instance of %Record
+       //
+       Record& operator =(const Record& rhs);
+
+private:
+       friend class _RecordImpl;
+       class _RecordImpl* __pRecordImpl;
+
+}; // Record
+
+}} // Tizen::Social
+
+#endif // _FSCL_RECORD_H_
diff --git a/inc/FSclRecurrence.h b/inc/FSclRecurrence.h
new file mode 100644 (file)
index 0000000..196d2c0
--- /dev/null
@@ -0,0 +1,557 @@
+// 
+// Copyright (c) 2012 Samsung Electronics Co., Ltd. 
+// 
+// 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.
+//
+/**
+ * @file       FSclRecurrence.h
+ * @brief      This is the header file for the %Recurrence class.
+ *
+ * This header file contains the declarations of the %Recurrence class.
+ */
+#ifndef _FSCL_RECURRENCE_H_
+#define _FSCL_RECURRENCE_H_
+
+#include <FBaseObject.h>
+#include <FBaseDataType.h>
+#include <FBaseColIListT.h>
+#include <FBaseColArrayListT.h>
+#include <FBaseDateTime.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+}}}
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @class      Recurrence
+ * @brief      This class provides methods to access the information of a %Recurrence.
+ *
+ * @since      2.0
+ *
+ * @final      This class is not intended for extension.
+ *
+ * The %Recurrence class provides methods to access the information of a %Recurrence.
+ * A CalEvent can be made a recurring event using this class. To set or get the information of a recurrence (such as the start time and recurrence
+ * pattern) use the methods of this class. The recurrence date is the start date of the %CalEvent, if they do not match.
+ *
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/social/recurrence_reminder_sensitivity.htm">Recurrence, Reminder, and Sensitivity Properties of Calendar Items</a>.
+ *
+ * @see                CalEvent::SetRecurrence()
+ *
+ * The following examples demonstrate how to use the %Recurrence class.
+ *
+ * 1. Repeat daily for 10 occurrences:
+ *
+ * @code
+
+       void
+       MyRecurrence::RepeatDayily10(void)
+       {
+               result r;
+               Recurrence* pRecurrence = new Recurrence();
+               if (IsFailed(GetLastResult()) || pRecurrence == null)
+               {
+                       AppLogException("Create instance has failed");
+               }
+               pRecurrence->SetFrequency(FREQ_DAILY);
+               r = pRecurrence->SetCounts(10);
+               if (IsFailed(r))
+               {
+                       AppLogException("Set counts has failed");
+               }
+       }
+
+ * @endcode
+ * 2. Repeat weekly until May 4, 2009:
+ *
+ * @code
+
+       void
+       MyRecurrence::RepeatDayilyUntil(void)
+       {
+               result r;
+               Recurrence* pRecurrence = new Recurrence();
+               if (IsFailed(GetLastResult()) || pRecurrence == null)
+               {
+                       AppLogException("Create instance has failed");
+               }
+               DateTime until;
+               r = until.SetValue(2009, 5, 4);
+               if (IsFailed(r))
+               {
+                       AppLogException("Set date/time has failed");
+               }
+
+               pRecurrence->SetFrequency(FREQ_WEEKLY);
+               r = pRecurrence->SetUntil(&until);
+               if (IsFailed(r))
+               {
+                       AppLogException("Set until has failed");
+               }
+       }
+
+ * @endcode
+ *
+ * 3. Repeat bi-weekly on Tuesday and Thursday until May 4, 2009:
+ * @code
+
+       void
+       MyRecurrence::RepeatByWeeklyUntil(void)
+       {
+               result r;
+               Recurrence* pRecurrence = new Recurrence();
+               if (IsFailed(GetLastResult()) || pRecurrence == null)
+               {
+                       AppLogException("Create instance has failed");
+               }
+
+               DateTime until;
+               r = until.SetValue(2009, 5, 4);
+               if (IsFailed(r))
+               {
+                       AppLogException("Set date/time has failed");
+               }
+
+               pRecurrence->SetFrequency(FREQ_WEEKLY);
+               r = pRecurrence->SetInterval(2);
+               if (IsFailed(r))
+               {
+                       AppLogException("Set interval has failed");
+               }
+
+               r = pRecurrence->SetDayOfWeek(CAL_TUESDAY | CAL_THURSDAY);
+               if (IsFailed(r))
+               {
+                       AppLogException("Set day of week has failed");
+               }
+
+               r = pRecurrence->SetUntil(&until);
+               if (IsFailed(r))
+               {
+                       AppLogException("Set until has failed");
+               }
+       }
+ * @endcode
+ *
+ * 4. Repeat monthly on the first Thursday for 10 occurrences. The week starts on Monday:
+ * @code
+
+       void
+       MyRecurrence::RepeatMonthlyUntil(void)
+       {
+               result r;
+               Recurrence* pRecurrence = new Recurrence();
+               if (IsFailed(GetLastResult()) || pRecurrence == null)
+               {
+                       AppLogException("Create instance has failed");
+               }
+
+               pRecurrence->SetFrequency(FREQ_MONTHLY);
+
+               r = pRecurrence->SetWeekStart(CAL_MONDAY);
+               if (IsFailed(r))
+               {
+                       AppLogException("Set week start has failed");
+               }
+
+               r = pRecurrence->SetDayOfWeek(CAL_THURSDAY);
+               if (IsFailed(r))
+               {
+                       AppLogException("Set day of the week has failed");
+               }
+
+               r = pRecurrence->SetWeekOfMonth(1);
+               if (IsFailed(r))
+               {
+                       AppLogException("Set week of month has failed");
+               }
+
+               r = pRecurrence->SetCounts(10);
+               if (IsFailed(r))
+               {
+                       AppLogException("Set counts has failed");
+               }
+       }
+
+ * @endcode
+ *
+ */
+class _OSP_EXPORT_ Recurrence
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class. @n
+        * This constructor sets the default values. The recurrence type is daily and recurrence interval is @c 1. @n
+        * The week start day is #CAL_MONDAY. The recurrence count is @c 1.
+        *
+        * @since       2.0
+        */
+       Recurrence(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %Recurrence to copy
+        */
+       Recurrence(const Recurrence& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~Recurrence(void);
+
+       /**
+        * Compares the specified Tizen::Base::Object with the current %Recurrence instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the specified object equals the current %Recurrence instance, @n
+        *                              else @c false
+        * @param[in]   rhs     The object instance to compare with the current object
+        * @see                 GetHashCode()
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the recurrence frequency type.
+        *
+        * @since       2.0
+        *
+        * @return              A reference to one of the @c RecurFrequency enumeration values, @n
+        *                              else #FREQ_DAILY if this property is not set
+        */
+       RecurFrequency GetFrequency(void) const;
+
+       /**
+        * Gets the recurrence interval. @n
+        * This represents the number of units between two recurrences. @n
+        * If the frequency is weekly and the recurrence interval is set to @c 2, the event occurs every two weeks.
+        *
+        * @since       2.0
+        *
+        * @return              The integer value that represents the recurrence interval, @n
+        *                              else @c 1 if this property is not set
+        */
+       int GetInterval(void) const;
+
+       /**
+        * Gets the end date and time of the recurrence.
+        *
+        * @since       2.0
+        *
+        * @return              An instance of Tizen::Base::DateTime that represents the end date and time
+        * @remarks             If this method returns @c null, get the recurrence counts using the GetCounts() method.
+        *
+        */
+       const Tizen::Base::DateTime* GetUntil(void) const;
+
+       /**
+        * Gets the number of times the event recurs.
+        *
+        * @since       2.0
+        *
+        * @return              The integer value that represents the number of recurrences
+        * @remarks             If this method returns @c 0, get the recurrence end date and time using the GetUntil() method.
+        *
+        */
+       int GetCounts(void) const;
+
+       /**
+        * Gets the first day of the week. @n
+        * The default value is #CAL_MONDAY.
+        *
+        * @since       2.0
+        *
+        * @return              The integer value that represents the first day of the week
+        *
+        */
+       CalDayOfWeek GetWeekStart(void) const;
+
+       /**
+        * Gets the day of the week when the event should recur. @n
+        * The default value is @c 0.
+        *
+        * @since       2.0
+        *
+        * @return              The integer value that represents the CalDayofWeek
+        * @remarks             The Frequency property must be obtained. If the frequency is #FREQ_WEEKLY, the return value may be a combination of days,
+        *                              like #CAL_MONDAY| #CAL_THURSDAY.
+        *
+        */
+       int GetDayOfWeek(void) const;
+
+       /**
+        * Gets the day of the month. @n
+        * The default value is @c 0.
+        *
+        * @since       2.0
+        *
+        * @return              The integer value between @c 1 and @c 31 that represents the day of the month
+        * @remarks             The Frequency property must be obtained.
+        */
+       int GetDayOfMonth(void) const;
+
+       /**
+        * Gets the week of the month. @n
+        * The default value is @c 0.
+        *
+        * @since       2.0
+        *
+        * @return              The integer value between @c 1 and @c 5 that represents the week of the month
+        * @remarks             The Frequency property must be obtained.
+        *
+        */
+       int GetWeekOfMonth(void) const;
+
+       /**
+        * Gets the month of the year. @n
+        * The default value is @c 0.
+        *
+        * @since       2.0
+        *
+        * @return              The integer value between @c 1 and @c 12 that represents the month of the year
+        * @remarks             The Frequency property must be obtained.
+        *
+        */
+       int GetMonthOfYear(void) const;
+
+       /**
+        * Sets a recurring frequency type among specific types (daily, weekly, monthly, and yearly). @n
+        * This property must be set before setting the day of the recurrence. After setting the frequency, other properties are reset to default values. @n
+        * For weekly, the day of the week must be set. @n
+        * For monthly, the day of the week and the week of the month must be set. @n
+        * For yearly, either the day of the month and the month of the year, or the day of the week, the week of the month, and the month of the year must be set.
+        *
+        * @since       2.0
+        *
+        * @param[in]   type    The recurrence type
+        *
+        */
+       void SetFrequency(RecurFrequency type);
+
+       /**
+        * Sets the interval of recurrence. @n
+        * If the frequency is weekly and the recurrence interval is set to @c 2, the event occurs every two weeks.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility       This method has compatibility issues with OSP compatible applications. @n
+     *                                 For more information, see @ref CompRecurrenceSetIntervalPage "here".
+     * @endif
+        *
+        * @return              An error code
+        * @param[in]   interval                The interval of recurrence
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c interval is less than @c 1.
+        */
+       result SetInterval(int interval);
+
+       /**
+        * @if OSPCOMPAT
+        * @page        CompRecurrenceSetIntervalPage Compatibility for SetInterval()
+        * @section     CompRecurrenceSetIntervalPageIssueSection Issues
+        *          Implementing this method in OSP compatible applications has the following issues: @n
+        *                      -# If the value of the interval to be set is greater than @c 255, @c E_INVALID_ARG is returned.
+        *
+        * @section     CompRecurrenceSetIntervalPageSolutionSection Resolutions
+        *                      This issue has been resolved in Tizen. @n
+        *                      -# There is no limit for the value of the interval.
+        * @endif
+        */
+
+       /**
+        * Sets the end date of the recurrence. @n
+        * If you want to set the event to have no end date, set the maximum date and time using the Tizen::Base::DateTime::GetMaxValue() method.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   pUntil                          The end date and time
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c pUntil is out of the valid range. @n
+        *                                                                      The valid range of the date can be referenced from GetMaxDateTime() and GetMinDateTime().
+        * @remarks             Either the until or count properties may be set. @n
+        *                              When the until property is set, the count property becomes @c 0. @n
+        *                              When the count property is set, the until property becomes @c null.
+        */
+       result SetUntil(const Tizen::Base::DateTime* pUntil);
+
+       /**
+        * Sets the number of times the event recurs.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   count                   The number of times the event recurs
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c count is less than @c 0.
+        * @remarks             Either the until or count properties may be set. @n
+        *                              When the until property is set, the count property becomes @c 0. @n
+        *                              When the count property is set, the until property becomes @c null. @n
+        */
+       result SetCounts(int count);
+
+       /**
+        * Sets the first day of the week. @n
+        * The default value is set to #CAL_MONDAY. The valid values are #CAL_SUNDAY and #CAL_MONDAY. @n
+        * This value is very important when the recurrence type is weekly and the interval is greater than @c 1. @n
+        * The weekly recurrence rule is calculated based on the week's start value.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   weekStart                               The day on which the week starts
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The specified @c weekStart is invalid.
+        */
+       result SetWeekStart(CalDayOfWeek weekStart);
+
+       /**
+        * Sets the day of the week that represents the days when the event should recur. @n
+        * The Frequency property must be set before setting this property. @n
+        * This property is valid for the following #RecurFrequency enumeration types: #FREQ_WEEKLY, #FREQ_MONTHLY, and #FREQ_YEARLY. @n
+        * The value of the @c day may be a combination of several days of a week. @n
+        * In other words, the @c day should be an item or a combination of #CalDayOfWeek, such as #CAL_SUNDAY or #CAL_MONDAY|#CAL_FRIDAY.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   day                             The integer value that represents the day of the week
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c day is invalid.
+        * @exception   E_TYPE_MISMATCH The #RecurFrequency is not #FREQ_WEEKLY, #FREQ_MONTHLY, or #FREQ_YEARLY.
+        * @remarks             After this property is set, the DayOfMonth property value is reset automatically.
+        */
+       result SetDayOfWeek(int day);
+
+       /**
+        * Sets the day of the month which indicates when the event recurs. @n
+        * The Frequency property must be set before setting this property. @n
+        * This property is valid for the following #RecurFrequency enumeration types: #FREQ_MONTHLY and #FREQ_YEARLY. @n
+        * If the day of the month is @c 31 and the frequency is monthly, the months which have only @c 30 days are not included in the recurrence instance set. @c
+        * Accordingly, with the recurrence rule, 2/29 yearly, 2/29 every four years is included in the recurrence set.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   day                                     The integer value between @c 1 and @c 31 that indicates the day of the month
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c day is either less than @c 1 or greater than @c 31.
+        * @exception   E_TYPE_MISMATCH         The #RecurFrequency is not #FREQ_MONTHLY or #FREQ_YEARLY.
+        * @remarks             After this property is set, the DayOfWeek and WeekOfMonth property value are reset automatically.
+        */
+       result SetDayOfMonth(int day);
+
+       /**
+        * Sets the week of the month. @n
+        * If the value of the week is @c 5, it is set as the last week of the month. @n
+        * This property is valid for the following #RecurFrequency enumeration types: #FREQ_MONTHLY and #FREQ_YEARLY.
+        * The Frequency property must be set before setting this property. @n
+        * When the week of the month is set, the day of the week must be set accordingly.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   week                            The integer value between @c 1 and @c 5 that represents the week of the month
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c week is either less than @c 1 or greater than @c 5.
+        * @exception   E_TYPE_MISMATCH         The #RecurFrequency is not #FREQ_MONTHLY or #FREQ_YEARLY.
+        * @remarks             After this property is set, the DayOfMonth property value is reset automatically.
+        */
+       result SetWeekOfMonth(int week);
+
+       /**
+        * Sets the month of the year. @n
+        * This property is valid for the following #RecurFrequency enumeration type: #FREQ_YEARLY. @n
+        * The Frequency property must be set before setting this property. @n
+        * When the month of the year is set, the day of the month or both the day of the week and the week of the month must be set accordingly.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   month                           The integer value between @c 1 and @c 12 that represents the month of the year
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c month is either less than @c 1 or greater than @c 12.
+        * @exception   E_TYPE_MISMATCH         The #RecurFrequency is not #FREQ_YEARLY.
+        */
+       result SetMonthOfYear(int month);
+
+       /**
+        * Adds an exception date to this event. @n
+        * The instance whose start date and time matches the exception date is excluded from the recurrence instances.
+        * If there are any changes in this recurrence, the exception dates are cleared.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   exceptionDate                   The exception date to exclude. @n Any value with a unit that is less than a second is ignored.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The specified @c exceptionDate is invalid.
+        * @exception   E_OBJ_ALREADY_EXIST             The specified @c exceptionDate already exists.
+        */
+       result AddExceptionDate(const Tizen::Base::DateTime& exceptionDate);
+
+       /**
+        * Gets the exception dates.
+        *
+        * @since       2.0
+        *
+        * @return              The list that contains the exception dates, @n
+        *                              else an empty list if there are no exception dates, or @c null if an exception occurs @n
+        *                              The results are listed in the order of date and time.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetExceptionDatesN(void) const;
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %Recurrence to copy
+        */
+       Recurrence& operator =(const Recurrence& rhs);
+
+private:
+       friend class _RecurrenceImpl;
+       class _RecurrenceImpl* __pRecurrenceImpl;
+};     // Recurrence
+
+}}     // Tizen::Social
+
+#endif // _FSCL_RECURRENCE_H_
diff --git a/inc/FSclRelationship.h b/inc/FSclRelationship.h
new file mode 100644 (file)
index 0000000..c3188aa
--- /dev/null
@@ -0,0 +1,189 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FSclRelationship.h
+* @brief       This is the header file for the %Relationship class.
+*
+* This header file contains the declarations of the %Relationship class.
+*/
+#ifndef _FSCL_RELATIONSHIP_H_
+#define _FSCL_RELATIONSHIP_H_
+
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+
+/**
+* @class       Relationship
+* @brief       This class represents a relation.
+*
+* @since       2.0
+*
+* @final       This class is not intended for extension.
+*
+* The %Relationship class represents a relation. A relation consists of the type, label, and name. 
+*
+*/
+class _OSP_EXPORT_ Relationship
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.0
+        */
+       Relationship(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs     An instance of %Relationship to copy
+        */
+       Relationship(const Relationship& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~Relationship(void);
+
+       /**
+        * Checks whether the value of the specified instance is equal to the value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return      @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Tizen::Base::Object, @n
+        *                      else @c false
+        * @param[in]   rhs             An instance of Tizen::Base::Object to compare
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return      The integer value indicates the hash value of the current instance of Tizen::Base::Object
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the relation type.
+        *
+        * @since       2.0
+        *
+        * @return      The type of the relation
+        */
+       RelationshipType GetType(void) const;
+
+       /**
+        * Gets the name of the relative.
+        *
+        * @since       2.0
+        *
+        * @return      The name of the relative
+        */
+       Tizen::Base::String GetRelativeName(void) const;
+
+       /**
+        * Gets the label of the relation.
+        *
+        * @since       2.0
+        *
+        * @return      The relation label
+        * @see SetLabel()
+        */
+       Tizen::Base::String GetLabel(void) const;
+
+       /**
+        * Sets the relation type.
+        *
+        * @since       2.0
+        *
+        * @param[in]   type            The type of the relation
+        */
+       void SetType(RelationshipType type);
+
+       /**
+        * Sets the label of the relation.
+        *
+        * @since       2.0
+        *
+        * @param[in]   label           The relation label
+        * @see GetLabel()
+        */
+       void SetLabel(const Tizen::Base::String& label);
+
+       /**
+        * Sets the name of the relative.
+        *
+        * @since       2.0
+        *
+        * @param[in]   relativeName            The name of the relative
+        */
+       void SetRelativeName(const Tizen::Base::String& relativeName);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs     An instance of %Relationship to copy
+        */
+       Relationship& operator =(const Relationship& rhs);
+
+       /**
+        * Checks whether the data in the specified instance of %Relationship is equal to the data in the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the data in the specified instance equals the data in the current instance, @n
+        *                              else @c false
+        * @param[in]   rhs             An instance of %Relationship
+        */
+       bool operator ==(const Relationship& rhs) const;
+
+       /**
+        * Checks whether the data in the specified instance of %Relationship is not equal to the data in the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the data in the specified instance is not equal to the data in the current instance, @n
+        *                              else @c false
+        * @param[in]   rhs             An instance of %Relationship
+        */
+       bool operator !=(const Relationship& rhs) const;
+
+private:
+       RelationshipType __type;
+       Tizen::Base::String __label;
+       Tizen::Base::String __name;
+
+       friend class _RelationshipImpl;
+       class _RelationshipImpl* __pRelationshipImpl;
+}; // Relationship
+
+}} // Tizen::Social
+
+#endif // _FSCL_RELATIONSHIP_H_
diff --git a/inc/FSclReminder.h b/inc/FSclReminder.h
new file mode 100644 (file)
index 0000000..d670832
--- /dev/null
@@ -0,0 +1,267 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FSclReminder.h
+ * @brief      This is the header file for the %Reminder class.
+ *
+ * This header file contains the declarations of the %Reminder class.
+ */
+#ifndef _FSCL_REMINDER_H_
+#define _FSCL_REMINDER_H_
+
+#include <FBaseString.h>
+#include <FBaseObject.h>
+#include <FBaseDataType.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Base
+{
+class DateTime;
+}}
+
+namespace Tizen { namespace Social
+{
+
+/**
+ *     @class  Reminder
+ *     @brief  This class represents the information of a reminder.
+ *
+ * @since      2.0
+ *
+ *     @final  This class is not intended for extension.
+ *
+ *     The %Reminder class represents the information of a reminder. An application uses this class to get or set the information of a reminder,
+ *     such as the reminder time or the media file to be played for a reminder.
+ *
+ *     For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/social/recurrence_reminder_sensitivity.htm">Recurrence, Reminder, and Sensitivity Properties of Calendar Items</a>.
+ *
+ */
+class _OSP_EXPORT_ Reminder
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class. @n
+        * The default values are set. @n
+        * The time offset of @c 0 minutes for a reminder is set. @n
+        * The sound file name is @c null.
+        *
+        * @since       2.0
+        */
+       Reminder(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %Reminder to copy
+        */
+       Reminder(const Reminder& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~Reminder(void);
+
+       /**
+        * Compares the specified Tizen::Base::Object with the current %Reminder instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the specified object equals the current %Reminder instance, @n
+        *                              else @c false
+        * @param[in]   rhs     The object instance to compare with the current object
+        * @see                 GetHashCode()
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * @if OSPDEPREC
+        * Gets the time offset of the reminder prior to an event time. @n
+        * For an event, the time offset is calculated as the number of minutes before the start DateTime. @n
+        * The default time offset is @c 0.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated          This method is deprecated. Instead of using this method, it is recommended to use GetTimeUnit() and GetTimeOffset().
+        *
+        * @since       2.0
+        *
+        * @return      The number of minutes
+        * @endif
+        */
+       int GetMinutesBefore(void) const;
+
+       /**
+        * Gets the sound file for the reminder. @n
+        * There is no default file name.
+        *
+        * @since       2.0
+        *
+        * @return              The file path and name
+        */
+       Tizen::Base::String GetSoundFile(void) const;
+
+       /**
+        * @if OSPDEPREC
+        * Sets the time offset of the reminder prior to an event time. @n
+        * For an event, the time offset is calculated as the number of minutes before the start DateTime.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated          This method is deprecated. Instead of using this method, it is recommended to use SetTimeOffset().
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   minutes                         The time offset in minutes
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified time offset is less than @c 0 or greater than @c 40320.
+        * @remarks             The maximum value of the time offset is @c 40320.
+        * @endif
+        */
+       result SetMinutesBefore(int minutes);
+
+       /**
+        * Sets the sound file for the reminder.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility       This method has compatibility issues with OSP compatible applications. @n
+        *                                      For more information, see @ref CompIoPathPage "here".
+        * @endif
+        *
+        * @return              An error code
+        * @param[in]   filePath                The path and name of the new sound file, @n
+        *                                                              else @c null to remove the previously set sound file
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   Either of the following conditions has occurred:
+        *                                                              - The specified @c filePath is invalid.
+        *                                                              - The specified file does not exist.
+        */
+       result SetSoundFile(const Tizen::Base::String& filePath);
+
+       /**
+        * Sets the reminder time unit and offset.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   timeUnit                        The reminder time unit
+        * @param[in]   timeOffset                      The reminder time offset
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           Either of the following conditions has occurred:
+        *                                                                      - The specified @c timeUnit is @c REMINDER_TIME_UNIT_NONE.
+        *                                                                      - The specified @c timeOffset is less than @c 0.
+        * @remarks             The time offset and absolute time are mutually exclusive. @n
+        *                              When the absolute time is set, the time unit is @c REMINDER_TIME_UNIT_NONE and offset is @c 0. @n
+        *                              When the time offset is set, the absolute time is reset.
+        */
+       result SetTimeOffset(ReminderTimeUnit timeUnit, int timeOffset);
+
+       /**
+        * Gets the reminder time unit.
+        *
+        * @since       2.0
+        *
+        * @return              The reminder time unit, @n
+        *                              else @c REMINDER_TIME_UNIT_NONE if the absolute time is set
+        */
+       ReminderTimeUnit GetTimeUnit(void) const;
+
+       /**
+        * Gets the reminder time offset in the time unit currently set to this instance.
+        *
+        * @since       2.0
+        *
+        * @return              The reminder time offset, @n
+        *                              else @c 0 if the absolute time is set
+        */
+       int GetTimeOffset(void) const;
+
+       /**
+        * Sets the reminder absolute time. @n
+        * The time is in Coordinated Universal Time (UTC).
+        *
+        * @since       2.1
+        *
+        * @return              An error code
+        * @param[in]   time                            The reminder absolute time. @n Any value with a unit that is less than a second is ignored.
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c time is out of the valid range. @n
+        *                                                                      The valid range of the time can be referenced from Calendarbook::GetMaxDateTime() and Calendarbook::GetMinDateTime().
+        * @remarks             The time offset and absolute time are mutually exclusive. @n
+        *                              When the absolute time is set, the time unit is ::REMINDER_TIME_UNIT_NONE and offset is @c 0. @n
+        *                              When the time offset is set, the absolute time is reset.
+        */
+       result SetAbsoluteTime(const Tizen::Base::DateTime& time);
+
+       /**
+        * Gets the reminder absolute time.
+        *
+        * @since       2.1
+        *
+        * @return              The reminder absolute time, @n
+        *                              else the minimum value of Tizen::Base::DateTime if the absolute time is not set
+        */
+       Tizen::Base::DateTime GetAbsoluteTime(void) const;
+
+       /**
+        * Checks whether the absolute time is set.
+        *
+        * @since       2.1
+        *
+        * @return              @c true if the absolute time is set, @n
+        *                              else @c false
+        * @remarks             The time offset and absolute time are mutually exclusive. @n
+        *                              When the absolute time is set, the time unit is ::REMINDER_TIME_UNIT_NONE and offset is @c 0. @n
+        *                              When the time offset is set, the absolute time is reset.
+        */
+       bool IsAbsolute(void) const;
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %Reminder to copy
+        */
+       Reminder& operator =(const Reminder& rhs);
+
+private:
+       Tizen::Base::String __soundFilePath;
+       ReminderTimeUnit __timeUnit;
+       int __timeOffset;
+
+       friend class _ReminderImpl;
+       class _ReminderImpl* __pReminderImpl;
+};     // Reminder
+
+}}     // Tizen::Social
+
+#endif // _FSCL_REMINDER_H_
diff --git a/inc/FSclTypes.h b/inc/FSclTypes.h
new file mode 100644 (file)
index 0000000..2274e69
--- /dev/null
@@ -0,0 +1,1087 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+//
+// 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.
+//
+
+/**
+ * @file       FSclTypes.h
+ * @brief      This is the header file for the types in the %Social namespace.
+ *
+ * This header file contains the declarations of the types in the Social namespace.
+ */
+#ifndef _FSCL_TYPES_H_
+#define _FSCL_TYPES_H_
+
+namespace Tizen { namespace Base
+{
+class DateTime;
+}}
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * A unique ID. This ID is unique within a local storage only. @n
+ * @c RecordId is assigned by the local storage (for example, Addressbook and Calendarbook) when a record is saved to the storage. @n
+ * A newly constructed record instance has ::INVALID_RECORD_ID.
+ *
+ * @since      2.0
+ */
+typedef int RecordId;
+
+/**
+ * An invalid record ID. @n
+ * The record has not been properly recorded to Addressbook.
+ *
+ * @since      2.0
+ */
+const RecordId INVALID_RECORD_ID = -1;
+
+/**
+ * A unique ID for an account. @n
+ * If an account is added successfully, an @c AccountId is automatically assigned to the account.
+ *
+ * @since      2.1
+ */
+typedef int AccountId;
+
+/**
+ * An invalid account ID.
+ *
+ * @since      2.1
+ */
+const AccountId INVALID_ACCOUNT_ID = -1;
+
+/**
+ * @typedef    RecurrenceId
+ * Defines the recurrence ID that is used to identify a specific instance of a recurring calendar component (CalEvent). @n
+ * The value type is Tizen::Base::DateTime. The property value is the effective value of the start time ("DTSTART" property) of the Recurrence instance.
+ *
+ * @since      2.0
+ */
+typedef Tizen::Base::DateTime RecurrenceId;
+
+/**
+ * @if OSPDEPREC
+ * The maximum length of the name property.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This constant is deprecated.
+ * @since      2.0
+ * @endif
+ */
+static const int MAX_ATTENDEE_NAME_LENGTH = 100;
+
+/**
+ * @if OSPDEPREC
+ * The maximum length of the email property.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This constant is deprecated.
+ * @since      2.0
+ * @endif
+ */
+static const int MAX_ATTENDEE_EMAIL_LENGTH = 320;
+
+/**
+ * @if OSPDEPREC
+ * The maximum length of the subject field.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This constant is deprecated.
+ * @since      2.0
+ * @endif
+ */
+static const int MAX_EVENT_SUBJECT_LENGTH = 100;
+
+/**
+ * @if OSPDEPREC
+ * The maximum length of the description field.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This constant is deprecated.
+ * @since      2.0
+ * @endif
+ */
+static const int MAX_EVENT_DESCRIPTION_LENGTH = 1000;
+
+/**
+ * @if OSPDEPREC
+ * The maximum length of the location field.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This constant is deprecated.
+ * @since      2.0
+ * @endif
+ */
+static const int MAX_EVENT_LOCATION_LENGTH = 100;
+
+/**
+ * @if OSPDEPREC
+ * The maximum length of the subject field.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This constant is deprecated.
+ * @since      2.0
+ * @endif
+ */
+static const int MAX_TODO_SUBJECT_LENGTH = 100;
+
+/**
+ * @if OSPDEPREC
+ * The maximum length of the description field.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This constant is deprecated.
+ * @since      2.0
+ * @endif
+ */
+static const int MAX_TODO_DESCRIPTION_LENGTH = 1000;
+
+/**
+ * @if OSPDEPREC
+ * The maximum recurrence interval value.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This constant is deprecated.
+ * @since      2.0
+ * @endif
+ */
+static const int MAX_RECURRENCE_INTERVAL_VALUE = 255;
+
+/**
+ * @if OSPDEPREC
+ * The maximum value of the reminder offset (in minutes).
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This constant is deprecated.
+ * @since      2.0
+ * @endif
+ */
+static const int MAX_REMINDER_OFFSET_VALUE = 40320;
+
+/**
+ * @if OSPDEPREC
+ * The maximum length of the name properties (first, last, nickname, and formatted names).
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This constant is deprecated because there is no limitation any more.
+ * @since      2.0
+ * @endif
+ */
+static const int MAX_CONTACT_NAME_LENGTH = 50;
+
+/**
+ * @if OSPDEPREC
+ * The maximum length of the job title property.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This constant is deprecated because there is no limitation any more.
+ * @since      2.0
+ * @endif
+ */
+static const int MAX_CONTACT_JOB_TITLE_LENGTH = 50;
+
+/**
+ * @if OSPDEPREC
+ * The maximum length of the company property.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This constant is deprecated because there is no limitation any more.
+ * @since      2.0
+ * @endif
+ */
+static const int MAX_CONTACT_COMPANY_LENGTH = 50;
+
+/**
+ * @if OSPDEPREC
+ * The maximum length of the note property.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This constant is deprecated because there is no limitation any more.
+ * @since      2.0
+ * @endif
+ */
+static const int MAX_CONTACT_NOTE_LENGTH = 100;
+
+/**
+ * @if OSPDEPREC
+ * The maximum length of the category name.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This constant is deprecated because the maximum length of the category name has been changed.
+ * @since      2.0
+ * @endif
+ */
+static const int MAX_CATEGORY_NAME_LENGTH = 20;
+
+/**
+ * @if OSPDEPREC
+ * The minimum length of the query string for searching the contacts by name.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This value is deprecated.
+ * @since      2.0
+ *
+ * @see         Addressbook::SearchContactsByNameN()
+ * @endif
+ */
+static const int MIN_NAME_QUERY_LENGTH = 1;
+
+/**
+ * @if OSPDEPREC
+ * The minimum length of the query string for searching the contacts by phone number.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This value is deprecated.
+ * @since      2.0
+ *
+ * @see         Addressbook::SearchContactsByPhoneNumberN()
+ * @endif
+ */
+static const int MIN_PHONENUMBER_QUERY_LENGTH = 4;
+
+/**
+ * @if OSPDEPREC
+ * The minimum length of the query string for searching the contacts by email.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This value is deprecated.
+ * @since      2.0
+ *
+ * @see         Addressbook::SearchContactsByEmailN()
+ * @endif
+ */
+static const int MIN_EMAIL_QUERY_LENGTH = 1;
+
+/**
+ * @if OSPDEPREC
+ * The maximum length of the email property.
+ *
+ * @brief <i> [Deprecated]  </i>
+ * @deprecated This constant is deprecated because there is no limitation any more.
+ * @since      2.0
+ * @endif
+ */
+static const int MAX_EMAIL_LENGTH = 100;
+
+/**
+ * @enum       ContactPropertyId
+ *
+ * Defines the IDs for accessing the single value type properties of Contact.
+ * @since      2.0
+ */
+enum ContactPropertyId
+{
+       CONTACT_PROPERTY_ID_FIRST_NAME = 1,                     /**< The first name property ID (String type) */
+       CONTACT_PROPERTY_ID_LAST_NAME,                          /**< The last name property ID (String type) */
+       CONTACT_PROPERTY_ID_DISPLAY_NAME,                       /**< The formatted name property ID (String type) */
+       CONTACT_PROPERTY_ID_NICK_NAME,                          /**< @if OSPDEPREC The nick name property ID (String type)
+                                                                                                        @deprecated This enum value is deprecated because there can be multiple nicknames
+                                                                                                         in a contact. Instead of using this, use ContactMultiPropertyId::CONTACT_MPROPERTY_ID_NICKNAMES. @endif */
+       CONTACT_PROPERTY_ID_THUMBNAIL,                          /**< @if OSPDEPREC The thumbnail property ID (Bitmap type)
+                                                                                                        @deprecated This enumeration value is deprecated because it is not used any longer. @endif */
+       CONTACT_PROPERTY_ID_BIRTHDAY,                           /**< @if OSPDEPREC The birthday property ID (DateTime type)
+                                                     @deprecated This enum value is deprecated because there can be multiple birthday events.
+                                                                                                        Instead of using this, use ContactMultiPropertyId::CONTACT_MPROPERTY_ID_EVENTS. @endif */
+       CONTACT_PROPERTY_ID_JOB_TITLE,                          /**< @if OSPDEPREC The job title property ID (String type)
+                                                     @deprecated This enum value is deprecated because there can be multiple organizational information.
+                                                                                                        Instead of using this, use ContactMultiPropertyId::CONTACT_MPROPERTY_ID_ORGANIZATIONS. @endif */
+       CONTACT_PROPERTY_ID_COMPANY,                            /**< @if OSPDEPREC The company property ID (String type)
+                                                                                                        @deprecated This enum value is deprecated because there can be multiple organizational information.
+                                                                                                        Instead of using this, use ContactMultiPropertyId::CONTACT_MPROPERTY_ID_ORGANIZATIONS.@endif */
+       CONTACT_PROPERTY_ID_NOTE,                                       /**< @if OSPDEPREC The note property ID (String type)
+                                                                                                        @deprecated This enum value is deprecated because there can be multiple notes
+                                                                                                        in a contact. Instead of using this, use ContactMultiPropertyId::CONTACT_MPROPERTY_ID_NOTES.@endif */
+       CONTACT_PROPERTY_ID_ANNIVERSARY,                        /**< @if OSPDEPREC The anniversary property ID (DateTime type)
+                                                                                                        @deprecated This enum value is deprecated because there can be multiple anniversary events.
+                                                                                                        Instead of using this, use ContactMultiPropertyId::CONTACT_MPROPERTY_ID_EVENTS.@endif */
+       CONTACT_PROPERTY_ID_RINGTONE,                           /**< The ringtone property ID (String type) */
+       CONTACT_PROPERTY_ID_MIDDLE_NAME,                        /**< The middle name property ID (String type) */
+       CONTACT_PROPERTY_ID_LAST_REVISION,                      /**< An ID for the calendar date and time of the last update in Coordinated Universal Time (UTC) @n     Read-only (DateTime type) */
+       CONTACT_PROPERTY_ID_NAME_PREFIX,                        /**< The name honorific prefix property ID (String type) */
+       CONTACT_PROPERTY_ID_NAME_SUFFIX,                        /**< The name honorific suffix property ID (String type) */
+       CONTACT_PROPERTY_ID_PHONETIC_FIRST_NAME,        /**< The phonetic first name property ID (String type) @b Since: @b 2.1 */
+       CONTACT_PROPERTY_ID_PHONETIC_LAST_NAME,         /**< The phonetic last name property ID (String type) @b Since: @b 2.1 */
+       CONTACT_PROPERTY_ID_PHONETIC_MIDDLE_NAME,       /**< The phonetic middle name property ID (String type) @b Since: @b 2.1 */
+       CONTACT_PROPERTY_ID_UID,                                        /**< The globally unique ID (String type) @b Since: @b 2.1 */
+};
+
+/**
+ * @enum       ContactMultiPropertyId
+ *
+ * Defines the IDs for accessing the multi-value type properties of Contact. @n
+ * The properties have several values and they are called multi-type properties.
+ * @since      2.0
+ */
+enum ContactMultiPropertyId
+{
+       CONTACT_MPROPERTY_ID_PHONE_NUMBERS,             /**< The phone number property ID (PhoneNumber class) */
+       CONTACT_MPROPERTY_ID_EMAILS,                    /**< The email property ID (Email class) */
+       CONTACT_MPROPERTY_ID_URLS,                              /**< The URL property ID (Url class) */
+       CONTACT_MPROPERTY_ID_ADDRESSES,                 /**< The address property ID (Address class) */
+       CONTACT_MPROPERTY_ID_IMADDRESSES,               /**< The Instant Message property ID (ImAddress class) */
+       CONTACT_MPROPERTY_ID_EVENTS,                    /**< The contact event property ID (ContactEvent type) */
+       CONTACT_MPROPERTY_ID_ORGANIZATIONS,             /**< The organization property ID (Organization type) */
+       CONTACT_MPROPERTY_ID_NOTES,                             /**< The note property ID (String type) */
+       CONTACT_MPROPERTY_ID_NICKNAMES,                 /**< The nickname property ID (String type) */
+       CONTACT_MPROPERTY_ID_RELATIONSHIPS,             /**< The relationship property ID (Relationship type) */
+       CONTACT_MPROPERTY_ID_APP_LAUNCH_DATA,   /**< The app launch data property ID (ContactAppLaunchData type) @b Since: @b 2.1 */
+};
+
+/**
+ * @if OSPDEPREC
+ * The number of #ContactPropertyId factors.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This constant is deprecated because it is not used any more.
+ * @since      2.0
+ * @endif
+ */
+static const int CONTACT_PROPERTY_ID_NUM = 14;
+
+/**
+ * @if OSPDEPREC
+ * The number of #ContactMultiPropertyId factors.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This constant is deprecated because it is not used any more.
+ * @since      2.0
+ * @endif
+ */
+static const int CONTACT_MPROPERTY_ID_NUM = 5;
+
+/**
+ * @enum       RecordSensitivity
+ * Defines the sensitivity type of the calendar book record. @n
+ * This value represents the access classification property of @c vCalendar and @c iCalendar.
+ *
+ * @since      2.0
+ */
+enum RecordSensitivity
+{
+       SENSITIVITY_PUBLIC,                             /**< The public sensitivity */
+       SENSITIVITY_PRIVATE,                    /**< The private sensitivity */
+       SENSITIVITY_CONFIDENTIAL                /**< The confidential sensitivity */
+};
+
+/**
+ * @enum       AttendeeRole
+ * Defines the role of the attendee.
+ * @since      2.0
+ */
+enum AttendeeRole
+{
+       ATTENDEE_ROLE_ATTENDEE,                         /**< The attendee */
+       ATTENDEE_ROLE_REQUIRED_ATTENDEE,        /**< The required attendee */
+       ATTENDEE_ROLE_ORGANIZER                         /**< The organizer */
+};
+
+/**
+ * @enum       AttendeeStatus
+ * Defines the possible status of the attendee.
+ * @since      2.0
+ */
+enum AttendeeStatus
+{
+       ATTENDEE_STATUS_NONE,                   /**< No status */
+       ATTENDEE_STATUS_NOT_RESPONDED,  /**< The not-responded status */
+       ATTENDEE_STATUS_ACCEPTED,               /**< The accepted status */
+       ATTENDEE_STATUS_DECLINED,               /**< The declined status */
+       ATTENDEE_STATUS_TENTATIVE,              /**< The tentative status */
+};
+
+/**
+ * @if OSPDEPREC
+ * @enum               EventCategory
+ * @brief       <i> [Deprecated] </i> Defines the categories to classify the event.
+ *
+ * @deprecated This enum type is deprecated because the category of the event is not used any more.
+ * @since      2.0
+ * @endif
+ */
+enum EventCategory
+{
+       EVENT_CATEGORY_APPOINTMENT = 0x00000001,                /**< @if OSPDEPREC The appointment category @endif */
+       EVENT_CATEGORY_ANNIVERSARY = 0x00000002,                /**< @if OSPDEPREC The anniversary category @endif */
+};
+
+/**
+ * @if OSPDEPREC
+ * All the event categories.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This constant is deprecated because the category of the event is not used any more.
+ * @since      2.0
+ * @endif
+ */
+static const unsigned long EVENT_CATEGORY_ALL = EVENT_CATEGORY_APPOINTMENT | EVENT_CATEGORY_ANNIVERSARY;
+
+/**
+ * @enum               EventPriority
+ * Defines the possible priority levels of the event.
+ *
+ * @since      2.0
+ */
+enum EventPriority
+{
+       EVENT_PRIORITY_LOW,              /**< The low priority */
+       EVENT_PRIORITY_NORMAL,   /**< The normal priority */
+       EVENT_PRIORITY_HIGH              /**< The high priority */
+};
+
+/**
+ * @enum               EventStatus
+ * Defines the possible statuses of the event.
+ *
+ * @since      2.0
+ */
+enum EventStatus
+{
+       EVENT_STATUS_NONE,              /**< No status  */
+       EVENT_STATUS_CONFIRMED, /**< The confirmed status       */
+       EVENT_STATUS_CANCELLED, /**< The cancelled status       */
+       EVENT_STATUS_TENTATIVE  /**< The tentative status       */
+};
+
+/**
+ * @enum               BusyStatus
+ * Defines the busy statuses of the event.
+ *
+ * @since      2.0
+ */
+enum BusyStatus
+{
+       BUSY_STATUS_FREE,                       /**< The free status */
+       BUSY_STATUS_BUSY,                       /**< The busy status */
+       BUSY_STATUS_UNAVAILABLE,        /**< The unavailable status     */
+       BUSY_STATUS_TENTATIVE           /**< The tentative status */
+};
+
+/**
+ * @enum       TodoStatus
+ * Defines the possible to-do status types.
+ *
+ * @since      2.0
+ */
+enum TodoStatus
+{
+       TODO_STATUS_NONE = 0x00000001,                          /**< No status */
+       TODO_STATUS_NEEDS_ACTION = 0x00000002,          /**< The needs action status */
+       TODO_STATUS_COMPLETED = 0x00000004,                     /**< The completed status */
+       TODO_STATUS_IN_PROCESS = 0x00000008,            /**< The in process status */
+       TODO_STATUS_CANCELLED = 0x00000010,                     /**< The cancelled status */
+};
+
+/** All the to-do statuses.
+ *
+ * @since      2.0
+ */
+static const unsigned long TODO_STATUS_ALL = TODO_STATUS_NONE | TODO_STATUS_NEEDS_ACTION | TODO_STATUS_COMPLETED |
+                                                                                        TODO_STATUS_IN_PROCESS | TODO_STATUS_CANCELLED;
+
+/**
+ * @enum       TodoPriority
+ * Defines the possible to-do priority levels.
+ *
+ * @since      2.0
+ */
+enum TodoPriority
+{
+       TODO_PRIORITY_LOW = 0x00000001,                         /**< The low priority */
+       TODO_PRIORITY_NORMAL = 0x00000002,                      /**< The normal priority */
+       TODO_PRIORITY_HIGH = 0x00000004,                        /**< The high priority */
+};
+
+/** All the to-do priorities.
+ *
+ * @since      2.0
+ */
+static const unsigned long TODO_PRIORITY_ALL = TODO_PRIORITY_LOW | TODO_PRIORITY_NORMAL | TODO_PRIORITY_HIGH;
+
+/**
+ * @if OSPDEPREC
+ * @enum RecordEventType
+ * Defines the record event types.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This enum is deprecated because IRecordEventListener interface is deprecated.
+ *
+ * @since      2.0
+ * @endif
+ */
+enum RecordEventType
+{
+       RECORD_ADDED,                   /**< @if OSPDEPREC Adding a new record @endif */
+       RECORD_UPDATED,                 /**< @if OSPDEPREC Updating a record @endif */
+       RECORD_REMOVED,                 /**< @if OSPDEPREC The removal of a record @endif */
+       ALL_RECORDS_REMOVED,    /**<
+                                                        * @if OSPDEPREC
+                                                        * The removal of all the records @n
+                                                        * @deprecated   This enum value is deprecated because it is not used any more.
+                                                        * @endif
+                                                        */
+       MULTI_RECORDS_ADDED,            /**< @if OSPDEPREC Adding multiple records @endif */
+       MULTI_RECORDS_UPDATED,          /**< @if OSPDEPREC Adding, updating, and/or removal of multiple records @endif */
+       MULTI_RECORDS_REMOVED           /**< @if OSPDEPREC The removal of multiple records @endif */
+};
+
+/**
+ * @enum       RecurFrequency
+ * Defines the recurrence frequency type.
+ *
+ * @since      2.0
+ */
+enum RecurFrequency
+{
+       FREQ_DAILY,                 /**< The daily recurrence   */
+       FREQ_WEEKLY,            /**< The weekly recurrence      */
+       FREQ_MONTHLY,           /**< The monthly recurrence     */
+       FREQ_YEARLY                 /**< The yearly recurrence  */
+};
+
+/**
+ * @enum       CalDayOfWeek
+ * Defines the day of week type.
+ *
+ * @since      2.0
+ */
+enum CalDayOfWeek
+{
+       CAL_SUNDAY = 0x0001,            /**< The day of the week is Sunday      */
+       CAL_MONDAY = 0x0002,            /**< The day of the week is Monday      */
+       CAL_TUESDAY = 0x0004,           /**< The day of the week is Tuesday     */
+       CAL_WEDNESDAY = 0x0008,         /**< The day of the week is Wednesday */
+       CAL_THURSDAY = 0x0010,          /**< The day of the week is Thursday */
+       CAL_FRIDAY = 0x0020,            /**< The day of the week is Friday      */
+       CAL_SATURDAY = 0x0040           /**< The day of the week is Saturday */
+};
+
+/**
+ * @enum       RecordChangeType
+ * Defines the change type of a Record.
+ *
+ * @since      2.0
+ */
+enum RecordChangeType
+{
+       RECORD_CHANGE_TYPE_ADDED,               /**< A record is added */
+       RECORD_CHANGE_TYPE_REMOVED,             /**< A record is removed */
+       RECORD_CHANGE_TYPE_UPDATED,             /**< A record is updated */
+};
+
+/**
+ * @enum               CalendarItemType
+ * Defines the item types to specify which kind of item the calendar can contain.
+ *
+ * @since      2.0
+ */
+enum CalendarItemType
+{
+       CALENDAR_ITEM_TYPE_EVENT_ONLY = 0x1,                    /**< The item type for an event */
+       CALENDAR_ITEM_TYPE_TODO_ONLY = 0x2,                             /**< The item type for a to-do item */
+       CALENDAR_ITEM_TYPE_EVENT_AND_TODO = 0x3                 /**< The item type for an event and a to-do item */
+};
+
+/**
+ * @enum PhoneNumberType
+ *
+ * Defines the types of phone numbers.
+ * @since      2.0
+ */
+enum PhoneNumberType
+{
+       PHONENUMBER_TYPE_HOME,          /**< The phone number type for a home telephone */
+       PHONENUMBER_TYPE_WORK,          /**< The phone number type for a work telephone */
+       PHONENUMBER_TYPE_MOBILE,        /**< The phone number type for a mobile */
+       PHONENUMBER_TYPE_HOME_FAX,      /**< The phone number type for home fax */
+       PHONENUMBER_TYPE_WORK_FAX,      /**< The phone number type for work fax */
+       PHONENUMBER_TYPE_PAGER,         /**< The phone number type for a pager */
+       PHONENUMBER_TYPE_OTHER,         /**< The phone number type for other */
+       PHONENUMBER_TYPE_CUSTOM,        /**< The custom type @n The actual type can be set in the label */
+       PHONENUMBER_TYPE_ASSISTANT      /**< The phone number type for an assistant @b Since: @b 2.1 */
+};
+
+/**
+ * @enum       ReminderTimeUnit
+ * Defines the reminder time unit.
+ *
+ * @since      2.0
+ */
+enum ReminderTimeUnit
+{
+       REMINDER_TIME_UNIT_MINUTE,              /**< The unit of time offset is minute */
+       REMINDER_TIME_UNIT_HOUR,                /**< The unit of time offset is hour */
+       REMINDER_TIME_UNIT_DAY,                 /**< The unit of time offset is day */
+       REMINDER_TIME_UNIT_WEEK,                /**< The unit of time offset is week */
+       REMINDER_TIME_UNIT_NONE,                /**< The unit of time offset is none @b Since @b 2.1 */
+};
+
+/**
+ * @enum EmailType
+ *
+ * Defines the types of emails.
+ *
+* @since       2.0
+ */
+enum EmailType
+{
+       EMAIL_TYPE_PERSONAL,    /**< The email type for personal*/
+       EMAIL_TYPE_WORK,                /**< The email type for work */
+       EMAIL_TYPE_OTHER,               /**< The email type for other */
+       EMAIL_TYPE_CUSTOM,              /**< The custom type @n The actual type can be set in the label */
+       EMAIL_TYPE_MOBILE               /**< The email type for mobile @b Since: @b 2.1 */
+};
+
+/**
+ * Defines the types of addresses.
+ *
+ * @since      2.0
+ */
+enum AddressType
+{
+       ADDRESS_TYPE_HOME,      /**< The address type for a home address */
+       ADDRESS_TYPE_WORK,      /**< The address type for a work address */
+       ADDRESS_TYPE_OTHER,     /**< The address type for other */
+       ADDRESS_TYPE_CUSTOM     /**< The custom type @n The actual type can be set in the label */
+};
+
+/**
+ * @enum ContactEventType
+ *
+ * Defines the types of events.
+ *
+ * @since      2.0
+ */
+enum ContactEventType
+{
+       CONTACT_EVENT_TYPE_BIRTHDAY,    /**< The event type for a birthday */
+       CONTACT_EVENT_TYPE_ANNIVERSARY, /**< The event type for an anniversary */
+       CONTACT_EVENT_TYPE_OTHER,               /**< The event type for other */
+       CONTACT_EVENT_TYPE_CUSTOM               /**< The custom event @n The actual type can be set in the label */
+};
+
+/**
+ * @enum UrlType
+ *
+ * Defines the types of URLs.
+ *
+ * @since      2.0
+ */
+enum UrlType
+{
+       URL_TYPE_PERSONAL,              /**< The URL type is personal */
+       URL_TYPE_WORK,                  /**< The URL type is work */
+       URL_TYPE_OTHER,                 /**< The URL type is other */
+       URL_TYPE_CUSTOM         /**< The custom type @n The actual type can be set in the label */
+};
+
+/**
+ * @enum RelationshipType
+ *
+ * Defines the types of relationships.
+ *
+ * @since      2.0
+ */
+enum RelationshipType
+{
+       CONTACT_RELATIONSHIP_TYPE_ASSISTANT,            /**< The relation type for an assistant */
+       CONTACT_RELATIONSHIP_TYPE_BROTHER,                      /**< The relation type for a brother */
+       CONTACT_RELATIONSHIP_TYPE_CHILD,                        /**< The relation type for a child */
+       CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER, /**< The relation type for a domestic partner */
+       CONTACT_RELATIONSHIP_TYPE_FATHER,                       /**< The relation type for a father */
+       CONTACT_RELATIONSHIP_TYPE_FRIEND,                       /**< The relation type for a friend */
+       CONTACT_RELATIONSHIP_TYPE_MANAGER,                      /**< The relation type for a manager */
+       CONTACT_RELATIONSHIP_TYPE_MOTHER,                       /**< The relation type for a mother */
+       CONTACT_RELATIONSHIP_TYPE_PARENT,                       /**< The relation type for a parent */
+       CONTACT_RELATIONSHIP_TYPE_PARTNER,                      /**< The relation type for a partner */
+       CONTACT_RELATIONSHIP_TYPE_REFERRED_BY,          /**< The relation type for referred-by */
+       CONTACT_RELATIONSHIP_TYPE_RELATIVE,                     /**< The relation type for a relative */
+       CONTACT_RELATIONSHIP_TYPE_SISTER,                       /**< The relation type for a sister */
+       CONTACT_RELATIONSHIP_TYPE_SPOUSE,                       /**< The relation type for a spouse */
+       CONTACT_RELATIONSHIP_TYPE_CUSTOM                        /**< The custom event @n The actual type can be set in the label */
+};
+
+/**
+ * @enum OrganizationType
+ *
+ * Defines the types of organizations.
+ *
+ * @since 2.1
+ */
+
+enum OrganizationType
+{
+       ORGANIZATION_TYPE_WORK,         /**< The organization type for work */
+       ORGANIZATION_TYPE_OTHER,        /**< The organization type for other */
+       ORGANIZATION_TYPE_CUSTOM        /**< The custom type @n The actual type can be set in the label */
+};
+
+/**
+ * @if OSPDEPREC
+ * The maximum length of the phone number property.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This constant is deprecated because there is no limitation any more.
+ * @since      2.0
+ * @endif
+ */
+static const int MAX_PHONE_NUMBER_LENGTH = 50;
+
+//This value is for internal use only. Using this value can cause behavioral,
+//security-related, and consistency-related issues in the application.
+typedef int AccountId;
+
+/**
+ * The person ID.
+ *
+ * @since      2.0
+ */
+typedef int PersonId;
+
+
+/**
+ * The addressbook ID.
+ *
+ * @since      2.0
+ */
+typedef int AddressbookId;
+
+/**
+* An invalid address book ID indicates that the address book has not been properly stored in the address book database.
+*
+* @since       2.0
+*/
+static const AddressbookId INVALID_ADDRESSBOOK_ID = -2;
+
+/**
+* The default addressbook ID.
+*
+* @since       2.0
+*/
+static const AddressbookId DEFAULT_ADDRESSBOOK_ID = 0;
+
+/**
+ * @enum FilterConjunctiveOperator
+ * Defines the conjunctive operators to compound the filtering expressions.
+ *
+ * @since      2.0
+ */
+enum FilterConjunctiveOperator
+{
+       FI_CONJ_OP_NONE,        /**< None */
+       FI_CONJ_OP_AND,         /**< AND operator */
+       FI_CONJ_OP_OR,          /**< OR operator */
+};
+
+/**
+ * @enum FilterComparisonOperator
+ * Defines the comparison operators.
+ *
+ * @since      2.0
+ */
+enum FilterComparisonOperator
+{
+       FI_CMP_OP_EQUAL,                                 /**< = operator */
+       FI_CMP_OP_LESS_THAN,                     /**< < operator */
+       FI_CMP_OP_LESS_THAN_OR_EQUAL,    /**< <= operator */
+       FI_CMP_OP_GREATER_THAN,                  /**< > operator */
+       FI_CMP_OP_GREATER_THAN_OR_EQUAL, /**< >= operator */
+       FI_CMP_OP_IS_NULL,                               /**< NULL operator */
+};
+
+/**
+ * @enum FilterStringOperator
+ * Defines the matching criteria for Strings.
+ *
+ * @since      2.0
+ */
+enum FilterStringOperator
+{
+       FI_STR_OP_EQUAL,                        /**< The operator for matching the string exactly */
+       FI_STR_OP_FULL_STRING,          /**< The operator for matching the full-string without case sensitive */
+       FI_STR_OP_START_WITH,           /**< The operator for matching the string starting with the specified keyword */
+       FI_STR_OP_END_WITH,             /**< The operator for matching the string ending with the specified keyword */
+       FI_STR_OP_CONTAIN,                      /**< The operator for matching the string containing the specified keyword */
+       FI_STR_OP_IS_NOT_NULL,      /**< The operator for matching any string(except NULL) @n The specified is ignored */
+};
+
+/**
+ * @enum AddressbookFilterType
+ * Defines the type of the filter for Addressbook.
+ *
+ * @since      2.0
+ */
+enum AddressbookFilterType
+{
+       AB_FI_TYPE_ADDRESSBOOK,         /**< The filter for the addressbooks @n AddressbookFilterProperty is only used in this type of filter @n
+                                                                        The search result with this filter is a list of Addressbook */
+       AB_FI_TYPE_PERSON,              /**< The filter for the persons @n PersonFilterProperty is only used in this type of filter @n
+                                                                        The search result with this filter is a list of Person */
+       AB_FI_TYPE_CONTACT,             /**< The filter for the contacts @n ContactFilterProperty is only used in this type of filter @n
+                                                                        The search result with this filter is a list of Contact */
+       AB_FI_TYPE_CATEGORY,            /**< The filter for the categories @n CategoryFilterProperty is only used in this type of filter @n
+                                                                        The search result with this filter is a list of Category */
+       AB_FI_TYPE_PHONE_CONTACT,       /**< The filter for the contacts with phone number @n PhoneContactFilterProperty is only used in this type of filter @n
+                                                                        The search result with this filter is a list of PhoneNumberContact */
+       AB_FI_TYPE_EMAIL_CONTACT,       /**< The filter for the contacts with email @n EmailContactFilterProperty is only used in this type of filter @n
+                                                                        The search result with this filter is a list of EmailContact */
+};
+
+/**
+ * @enum AddressbookFilterProperty
+ * Defines the property for filtering the addressbooks. @n
+ * These properties can be used to create an AddressbookFilter of #AB_FI_TYPE_ADDRESSBOOK type.
+ *
+ * @since      2.0
+ */
+enum AddressbookFilterProperty
+{
+       AB_FI_PR_ADDRESSBOOK_ID = 1,            /**< The addressbook ID: int (AddressbookId) */
+       AB_FI_PR_ACCOUNT_ID,                            /**< The account ID: int (AccountId) */
+       AB_FI_PR_NAME,                                          /**< The addressbook name: String */
+};
+
+/**
+ * @enum PersonFilterProperty
+ * Defines the property for filtering a person. @n
+ * These properties can be used to create an AddressbookFilter of #AB_FI_TYPE_PERSON type.
+ *
+ * @since      2.0
+ */
+enum PersonFilterProperty
+{
+       PERSON_FI_PR_PERSON_ID = 100,           /**< The person ID: int (RecordId) */
+       PERSON_FI_PR_DISPLAY_NAME,                      /**< The display name: String */
+       PERSON_FI_PR_HAS_PHONE,                         /**< Whether the person has phone numbers or not: bool */
+       PERSON_FI_PR_HAS_EMAIL,                         /**< Whether the person has emails or not: bool */
+       PERSON_FI_PR_IS_FAVORITE,                       /**< Whether the person is a favorite or not: bool */
+       PERSON_FI_PR_CATEGORY_ID,                       /**< The category ID: int (RecordId) */
+       PERSON_FI_PR_ADDRESSBOOK_ID,            /**< The addressbook ID: int (AddressbookId) */
+};
+
+/**
+ * @enum ContactFilterProperty
+ * Defines the property for filtering the contacts. @n
+ * These properties can be used to create an AddressbookFilter of #AB_FI_TYPE_CONTACT type.
+ *
+ * @since      2.0
+ */
+enum ContactFilterProperty
+{
+       CONTACT_FI_PR_CONTACT_ID = 200,         /**< The contact ID: int (RecordId) */
+       CONTACT_FI_PR_ADDRESSBOOK_ID,           /**< The addressbook ID: int (AddressbookId) */
+       CONTACT_FI_PR_PERSON_ID,                        /**< The person ID: int (PersonId) */
+       CONTACT_FI_PR_DISPLAY_NAME,             /**< The display name: String */
+       CONTACT_FI_PR_HAS_PHONE,                        /**< Whether the contact has phone numbers or not: bool */
+       CONTACT_FI_PR_HAS_EMAIL,                        /**< Whether the contact has emails or not: bool */
+};
+
+/**
+ * @enum CategoryFilterProperty
+ * Defines the property for filtering the categories.
+ * These properties can be used to create an AddressbookFilter of #AB_FI_TYPE_CATEGORY type.
+ *
+ * @since      2.0
+ */
+enum CategoryFilterProperty
+{
+       CATEGORY_FI_PR_CATEGORY_ID = 300,       /**< The category ID: int (RecordId) */
+       CATEGORY_FI_PR_ADDRESSBOOK_ID,          /**< The addressbook ID: int (AddressbookId) */
+       CATEGORY_FI_PR_NAME,                            /**< The category name: String */
+};
+
+/**
+ * @enum PhoneContactFilterProperty
+ * Defines the property for filtering the contacts with phone number.
+ * These properties can be used to create an AddressbookFilter of #AB_FI_TYPE_PHONE_CONTACT type.
+ *
+ * @since      2.0
+ */
+enum PhoneContactFilterProperty
+{
+       PHONE_CONTACT_FI_PR_CONTACT_ID = 400,       /**< The contact ID: int (RecordId) */
+       PHONE_CONTACT_FI_PR_ADDRESSBOOK_ID,         /**< The addressbook ID: int (AddressbookId) */
+       PHONE_CONTACT_FI_PR_PERSON_ID,              /**< The person ID: int (PersonId) */
+       PHONE_CONTACT_FI_PR_DISPLAY_NAME,           /**< The display name: String */
+       PHONE_CONTACT_FI_PR_PHONE,                  /**< The phone number: String */
+};
+
+/**
+ * @enum EmailContactFilterProperty
+ * Defines the property for filtering the contacts with email.
+ * These properties can be used to create an AddressbookFilter of #AB_FI_TYPE_EMAIL_CONTACT type.
+ *
+ * @since      2.0
+ */
+enum EmailContactFilterProperty
+{
+       EMAIL_CONTACT_FI_PR_CONTACT_ID = 500,              /**< The contact ID: int (RecordId) */
+       EMAIL_CONTACT_FI_PR_ADDRESSBOOK_ID,                /**< The addressbook ID: int (AddressbookId) */
+       EMAIL_CONTACT_FI_PR_PERSON_ID,                     /**< The person ID: int (PersonId) */
+       EMAIL_CONTACT_FI_PR_DISPLAY_NAME,                  /**< The display name: String */
+       EMAIL_CONTACT_FI_PR_EMAIL,                         /**< The email: String */
+};
+
+/**
+ * @enum        UserProfilePropertyId
+ *
+ * Defines the IDs for accessing the single value type properties of UserProfile.
+ * @since       2.1
+ */
+enum UserProfilePropertyId
+{
+       USER_PROFILE_PROPERTY_ID_FIRST_NAME = 1,                        /**< The first name property ID (String type) */
+       USER_PROFILE_PROPERTY_ID_LAST_NAME,                             /**< The last name property ID (String type) */
+       USER_PROFILE_PROPERTY_ID_MIDDLE_NAME,                           /**< The middle name property ID (String type) */
+       USER_PROFILE_PROPERTY_ID_NAME_PREFIX,                           /**< The name honorific prefix property ID (String type) */
+       USER_PROFILE_PROPERTY_ID_NAME_SUFFIX,                           /**< The name honorific suffix property ID (String type) */
+       USER_PROFILE_PROPERTY_ID_DISPLAY_NAME,                          /**< The formatted name property ID (String type) */
+       USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME,                   /**< The phonetic first name property ID (String type) */
+       USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME,                    /**< The phonetic last name property ID (String type) */
+       USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME,                  /**< The phonetic middle name property ID (String type) */
+};
+
+/**
+ * @enum        UserProfileMultiPropertyId
+ *
+ * Defines the IDs for accessing the multi-value type properties of UserProfile. @n
+ * The properties have several values and they are called multi-type properties.
+ * @since       2.1
+ */
+enum UserProfileMultiPropertyId
+{
+       USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS,           /**< The phone number property ID (PhoneNumber class) */
+       USER_PROFILE_MPROPERTY_ID_EMAILS,                  /**< The email property ID (Email class) */
+       USER_PROFILE_MPROPERTY_ID_URLS,                    /**< The URL property ID (Url class) */
+       USER_PROFILE_MPROPERTY_ID_ADDRESSES,               /**< The address property ID (Address class) */
+       USER_PROFILE_MPROPERTY_ID_IMADDRESSES,             /**< The instant message property ID (ImAddress class) */
+       USER_PROFILE_MPROPERTY_ID_EVENTS,                  /**< The contact event property ID (ContactEvent class) */
+       USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS,           /**< The organization property ID (Organization class) */
+       USER_PROFILE_MPROPERTY_ID_NOTES,                   /**< The note property ID (String type) */
+       USER_PROFILE_MPROPERTY_ID_NICKNAMES,               /**< The nickname property ID (String type) */
+       USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS,           /**< The relationship property ID (Relationship type) */
+};
+
+/**
+ * @enum CalendarbookFilterType
+ * Defines the type of the filter for Calendarbook.
+ *
+ * @since      2.0
+ */
+enum CalendarbookFilterType
+{
+       CB_FI_TYPE_EVENT,                                               /**< The filter for the event of Calendarbook @n EventFilterProperty is only used in this type of filter @n The search result with this filter is a list of CalEvent */
+       CB_FI_TYPE_TODO,                                                /**< The filter for the to-do of Calendarbook @n TodoFilterProperty is only used in this type of filter @n The search result with this filter is a list of CalTodo */
+       CB_FI_TYPE_CALENDAR,                                    /**< The filter for the calendar of Calendarbook @n CalendarFilterProperty is only used in this type of filter @n The search result with this filter is a list of Calendar */
+       CB_FI_TYPE_ALL_DAY_EVENT_INSTANCE,              /**< The filter for all day event instances of Calendarbook @n EventInstanceFilterProperty is only used in this type of filter @n The search result with this filter is a list of CalEventInstance */
+       CB_FI_TYPE_NON_ALL_DAY_EVENT_INSTANCE   /**< The filter for non-all day event instances of Calendarbook @n EventInstanceFilterProperty is only used in this type of filter @n The search result with this filter is a list of CalEventInstance */
+};
+
+/**
+ * @enum EventFilterProperty
+ * Defines the property for filtering the events. @n
+ * These properties can be used to create a CalendarbookFilter of CB_FI_TYPE_EVENT type.
+ *
+ * @since      2.0
+ */
+enum EventFilterProperty
+{
+       EVENT_FI_PR_EVENT_ID = 1,               /**< The event ID: int (RecordId) */
+       EVENT_FI_PR_CALENDAR_ID,                /**< The calendar ID: long long (RecordId) */
+       EVENT_FI_PR_SUBJECT,                    /**< The subject of the event: String */
+       EVENT_FI_PR_DESCRIPTION,                /**< The description of the event: String */
+       EVENT_FI_PR_LOCATION,                   /**< The location of the event: String */
+       EVENT_FI_PR_BUSY_STATUS,                /**< The busy status of the event: int (BusyStatus) */
+       EVENT_FI_PR_PRIORITY,                   /**< The priority of the event: int (EventPriority) */
+       EVENT_FI_PR_SENSITIVITY,                /**< The sensitivity of the event: int (RecordSensitivity) */
+       EVENT_FI_PR_STATUS,                             /**< The status of the event: int (EventStatus) */
+       EVENT_FI_PR_UID,                                /**< The uid of the event: String */
+       EVENT_FI_PR_LATITUDE,                   /**< The latitude of the event: Double */
+       EVENT_FI_PR_LONGITUDE,                  /**< The longitude of the event: Double */
+       EVENT_FI_PR_LAST_REVISED_TIME,  /**< The last revised time of the event: DateTime */
+       EVENT_FI_PR_HAS_REMINDER,               /**< Whether the event has a reminder or not: bool*/
+       EVENT_FI_PR_HAS_ATTENDEE                /**< Whether the event has an attendee or not: bool*/
+};
+
+/**
+* @enum TodoFilterProperty
+* Defines the property for filtering the to-dos. @n
+* These properties can be used to create a CalendarbookFilter of CB_FI_TYPE_TODO type.
+*
+* @since       2.0
+*/
+enum TodoFilterProperty
+{
+       TODO_FI_PR_TODO_ID = 100,                       /**< The todo ID: long long (RecordId) */
+       TODO_FI_PR_CALENDAR_ID,                         /**< The calendar ID: long long (RecordId) */
+       TODO_FI_PR_START_DATE,                          /**< The start date of the to-do: DateTime*/
+       TODO_FI_PR_DUE_DATE,                            /**< The due date of the to-do: DateTime */
+       TODO_FI_PR_SUBJECT,                                     /**< The subject of the to-do: String */
+       TODO_FI_PR_DESCRIPTION,                         /**< The description of the to-do: String */
+       TODO_FI_PR_LOCATION,                            /**< The location of the to-do: String */
+       TODO_FI_PR_PRIORITY,                            /**< The priority of the to-do: int (TodoPriority)*/
+       TODO_FI_PR_SENSITIVITY,                         /**< The sensitivity of the to-do: int (RecordSensitivity) */
+       TODO_FI_PR_STATUS,                                      /**< The status of the to-do: int (TodoStatus) */
+       TODO_FI_PR_LATITUDE,                            /**< The latitude of the to-do: double*/
+       TODO_FI_PR_LONGITUDE,                           /**< The longitude of the to-do: double*/
+       TODO_FI_PR_LAST_REVISED_TIME,           /**< The last revised time of the to-do: DateTime */
+       TODO_FI_PR_HAS_REMINDER                         /**< Whether the to-do has a reminder or not: bool*/
+};
+
+/**
+* @enum EventInstanceFilterProperty
+* Defines the property for filtering the all day event instances or non-all day event instances. @n
+* These properties can be used to create a CalendarbookFilter of CB_FI_TYPE_ALL_DAY_EVENT_INSTANCE or CB_FI_TYPE_NON_ALL_DAY_EVENT_INSTANCE type.
+*
+* @since       2.0
+*/
+enum EventInstanceFilterProperty
+{
+       EVENT_INST_FI_PR_ORIGINAL_EVENT_ID = 200,                       /**< The original event ID: int (RecordId) */
+       EVENT_INST_FI_PR_CALENDAR_ID,                                           /**< The calendar ID: int (RecordId) */
+       EVENT_INST_FI_PR_START_TIME,                                            /**< The start time of the event instance: DateTime */
+       EVENT_INST_FI_PR_END_TIME,                                                      /**< The end time of the event instance: DateTime */
+       EVENT_INST_FI_PR_SUBJECT,                                                       /**< The subject of the event instance: String */
+       EVENT_INST_FI_PR_DESCRIPTION,                                           /**< The description of the event instance: String */
+       EVENT_INST_FI_PR_LOCATION,                                                      /**< The location of the event instance: String */
+       EVENT_INST_FI_PR_BUSY_STATUS,                                           /**< The busy status of the event instance: int (BusyStatus) */
+       EVENT_INST_FI_PR_PRIORITY,                                                      /**< The priority of the event instance: int (EventPriority) */
+       EVENT_INST_FI_PR_SENSITIVITY,                                           /**< The sensitivity of the event instance: int (RecordSensitivity) */
+       EVENT_INST_FI_PR_STATUS,                                                        /**< The status of the event instance: int (EventStatus) */
+       EVENT_INST_FI_PR_LATITUDE,                                                      /**< The latitude of the event instance: Double */
+       EVENT_INST_FI_PR_LONGITUDE,                                                     /**< The latitude of the event instance: Double */
+       EVENT_INST_FI_PR_IS_RECURRING,                                          /**< Whether the event instance is a recurring event or not: bool*/
+       EVENT_INST_FI_PR_HAS_REMINDER                                           /**< Whether the event instance has a reminder or not: bool*/
+};
+
+/**
+* @enum CalendarFilterProperty
+* Defines the property for filtering the calendars. @n
+* These properties can be used to create a CalendarbookFilter of CB_FI_TYPE_CALENDAR type.
+*
+* @since       2.0
+*/
+enum CalendarFilterProperty
+{
+       CALENDAR_FI_PR_CALENDAR_ID = 400,                       /**< The calendar ID: int (RecordId) */
+       CALENDAR_FI_PR_ACCOUNT_ID,                                      /**< The account ID of the calendar: int (AccountId) */
+       CALENDAR_FI_PR_NAME,                                            /**< The name of the calendar: String */
+       CALENDAR_FI_PR_ITEM_TYPE                                        /**< The type of the calendar: int (CalendarItemType) */
+};
+
+}}     // Tizen::Social
+
+#endif // _FSCL_TYPES_H_
diff --git a/inc/FSclUrl.h b/inc/FSclUrl.h
new file mode 100644 (file)
index 0000000..ff5e280
--- /dev/null
@@ -0,0 +1,275 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FSclUrl.h
+* @brief       This is the header file for the %Url class.
+*
+* This header file contains the declarations of the %Url class.
+*/
+#ifndef _FSCL_URL_H_
+#define _FSCL_URL_H_
+
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @if OSPDEPREC
+ * The maximum length of the URL property.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This constant is deprecated because there is no limitation any more.
+ * @since      2.0
+ * @endif
+ */
+static const int MAX_URL_LENGTH = 100;
+
+/**
+* @class       Url
+* @brief       This class stores the information of a URL.
+*
+* @since       2.0
+*
+* @final       This class is not intended for extension.
+*
+* @remarks     The %Url class consists of a URL string and a URL type.
+*
+* The %Url class stores the information of a URL. @n
+* The following example demonstrates how to use the %Url class.
+*
+* @code
+using namespace Tizen::Base;
+using namespace Tizen::Social;
+
+result
+MyClass::SomeMethod(void)
+{
+       result r = E_SUCCESS;
+
+       // Creates an instance of Url
+       Url url = Url();
+
+       // Sets the URL
+       r = url.SetUrl(L"http://www.tizen.org");
+       if (IsFailed(r))
+       {
+               return r;
+       }
+
+       // Sets the type
+       url.SetType(URL_TYPE_WORK);
+
+       return E_SUCCESS;
+}
+* @endcode
+*/
+class _OSP_EXPORT_ Url
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.0
+        */
+       Url(void);
+
+       /**
+        * Initializes this instance with the specified URL string and type.
+        *
+        * @since       2.0
+        *
+        * @param[in]   type    The type of the URL
+        * @param[in]   url             The URL
+        */
+       Url(UrlType type, const Tizen::Base::String& url);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %Url to copy
+        */
+       Url(const Url& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~Url(void);
+
+       /**
+        * Checks whether the value of the specified instance is equal to the value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return      @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Tizen::Base::Object, @n
+        *                      else @c false
+        * @param[in]   rhs             An instance of Tizen::Base::Object to compare
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.0
+        *
+        * @return      The integer value that indicates the hash value of the current instance of Tizen::Base::Object
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the type of this %Url instance.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility            This method has compatibility issues with OSP compatible applications. @n
+        *                           For more information, see @ref CompUrlGetTypePage "here".
+        * @endif
+        *
+        * @return              The type of %Url
+        */
+       UrlType GetType(void) const;
+
+       /**
+        * @if OSPCOMPAT
+        * @page                CompUrlGetTypePage         Compatibility for GetType()
+        * @section             CompUrlGetTypePageIssueSection             Issues
+        *                                              Implementing this method in OSP compatible applications has the following issue: @n
+        *                                              -# URL_TYPE_CUSTOM is not supported. If the type of the url is URL_TYPE_CUSTOM, URL_TYPE_OTHER is returned instead.
+        *
+        * @section             CompUrlGetTypePageSolutionSection          Resolutions
+        *                                              The issue mentioned above has been resolved in Tizen.
+        *
+        * @endif
+        */
+
+       /**
+        * Gets the label of a URL.
+        *
+        * @since       2.0
+        *
+        * @return      The URL label
+        * @see SetLabel()
+        */
+       Tizen::Base::String GetLabel(void) const;
+
+       /**
+        * Sets the label of a URL. 
+        *
+        * @since       2.0
+        *
+        * @param[in]   label   The URL label
+        * @see GetLabel()
+        */
+       void SetLabel(const Tizen::Base::String& label);
+
+       /**
+        * Gets the URL of this %Url instance.
+        *
+        * @since       2.0
+        *
+        * @return              The URL as a string
+        */
+       Tizen::Base::String GetUrl(void) const;
+
+       /**
+        * Sets the type of this %Url instance.
+        *
+        * @since       2.0
+        *
+        * @param[in]   type    The type of %Url
+        */
+       void SetType(UrlType type);
+
+       /**
+        * Sets the URL of this %Url instance.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility            This method has compatibility issues with OSP compatible applications. @n
+        *                           For more information, see @ref CompUrlSetUrlPage "here".
+        * @endif
+        *
+        * @return              An error code
+        * @param[in]   url                             The URL
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c url is an empty string.
+        */
+       result SetUrl(const Tizen::Base::String& url);
+
+       /**
+        * @if OSPCOMPAT
+        * @page                CompUrlSetUrlPage               Compatibility for SetUrl()
+        * @section             CompUrlSetUrlPageIssueSection           Issues
+        *                              Implementing this method in OSP compatible applications has the following issue: @n
+        *                              -# If the length of a URL to be set is greater than 100 characters, @c E_INVALID_ARG is returned.
+        *
+        * @section             CompUrlSetUrlPageSolutionSection                Resolutions
+        *                              The issue mentioned above has been resolved in Tizen.
+        * @endif
+        */
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs     An instance of %Url to copy
+        */
+       Url& operator =(const Url& rhs);
+
+       /**
+        * Checks whether the specified instance is equal to the current instance.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the data of the specified instance is equal to the data of the current instance, @n
+        *                              else @c false
+        * @param[in]   rhs              The source instance of %Url
+        */
+       bool operator ==(const Url& rhs) const;
+
+       /**
+        * Compares the specified instance with the current instance for inequality.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the data of the specified instance is not equal to the data of the current instance, @n
+        *                              else @c false
+        * @param[in]   rhs             The source instance of %Url
+        */
+       bool operator !=(const Url& rhs) const;
+
+private:
+       friend class _UrlImpl;
+       class _UrlImpl* __pUrlImpl;
+}; // Url
+
+}} // Tizen::Social
+
+#endif // _FSCL_URL_H_
diff --git a/inc/FSclUserProfile.h b/inc/FSclUserProfile.h
new file mode 100644 (file)
index 0000000..a8d6191
--- /dev/null
@@ -0,0 +1,473 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FSclUserProfile.h
+* @brief               This is the header file for the %UserProfile class.
+*
+* This header file contains the declarations of the %UserProfile class.
+*/
+#ifndef _FSCL_USER_PROFILE_H_
+#define _FSCL_USER_PROFILE_H_
+
+#include <FBaseTypes.h>
+#include <FBaseObject.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+
+namespace Collection
+{
+class IList;
+}
+}}
+
+namespace Tizen { namespace Social
+{
+
+class Address;
+class PhoneNumber;
+class Email;
+class Url;
+class ImAddress;
+class Organization;
+class ContactEvent;
+class Relationship;
+
+/**
+ * @class       UserProfile
+ * @brief       This class represents the user's contact information.
+ *
+ * @since       2.1
+ *
+ * @final       This class is not intended for extension.
+ *
+ * The %UserProfile class provides the contact information of the owner of an addressbook.
+ *
+ *
+ */
+class _OSP_EXPORT_ UserProfile
+        : public Tizen::Base::Object
+{
+public:
+
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.1
+        */
+       UserProfile(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.1
+        *
+        * @param[in]   rhs             An instance of %UserProfile to copy
+        */
+    UserProfile(const UserProfile& rhs);
+
+       /**
+        * This destructor overrides Tizen::Social::Object::~Object().
+        *
+        * @since       2.1
+        *
+        */
+       virtual ~UserProfile(void);
+
+       /**
+        * Checks whether the value of the specified instance is equal to the value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.1
+        *
+        * @return      @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Tizen::Base::Object, @n
+        *              else @c false
+        * @param[in]   rhs             An instance of Tizen::Base::Object to compare
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since       2.1
+        *
+        * @return      The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the thumbnail file path.
+        *
+        * @since       2.1
+        *
+        * @return     The file path of the thumbnail
+        * @remarks    If the thumbnail has not been set, an empty string is returned.
+        */
+       Tizen::Base::String GetThumbnailPath(void) const;
+
+       /**
+        * Sets the thumbnail image. @n
+        * If the specified @c filePath is an empty string, the current thumbnail image is removed.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   filePath                The file path of the thumbnail image
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The length of the specified @c filePath exceeds system limitations.
+        * @exception   E_FILE_NOT_FOUND        The specified file cannot be found or accessed.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        * @see GetThumbnailPath()
+        */
+       result SetThumbnail(const Tizen::Base::String& filePath);
+
+       /**
+        * Sets the value of the property having a specified ID to the specified @c value.
+        *
+        *
+        * @return      An error code
+        * @param[in]   id                      The ID of the property whose value is set
+        * @param[in]   value                   The new string value to set
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified property is read-only.
+        */
+
+       result SetValue(UserProfilePropertyId id, const Tizen::Base::String& value);
+
+       /**
+        * Gets the value of the specified property.
+        *
+        * @since       2.1
+        *
+        * @return      The property value
+        * @param[in]   id                              The property ID
+        */
+       Tizen::Base::String GetValue(UserProfilePropertyId id) const;
+
+       /**
+        * Sets the specified phone number at the specified @c index.
+        *
+        * @since       2.1
+        *
+        * @return     An error code
+        * @param[in]  index            The index at which the value is set
+        * @param[in]  phoneNumber      An instance of PhoneNumber to set
+        * @exception  E_SUCCESS        The method is successful.
+        * @exception  E_INVALID_ARG    The specified @c phoneNumber is empty.
+        * @exception  E_OUT_OF_RANGE   The specified @c index is outside the bounds of the properties.
+        */
+       result SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber);
+
+       /**
+        * Sets the specified @c email corresponding to the specified @c index.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   index                   The index at which the value is set
+        * @param[in]   email                   An instance of Email
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c email is empty.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetEmailAt(int index, const Email& email);
+
+       /**
+        * Sets the specified URL corresponding to the specified @c index.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   index                   The index at which the value is set
+        * @param[in]   url                     An instance of Url
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c url is empty.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetUrlAt(int index, const Url& url);
+
+       /**
+        * Sets the specified @c address corresponding to the specified @c index.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   index                   The index at which the value is set
+        * @param[in]   address                 An instance of Address
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c address is empty.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetAddressAt(int index, const Address& address);
+
+       /**
+        * Sets the specified @c imAddress corresponding to the specified @c index.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   index                   The index at which the value is set
+        * @param[in]   imAddress               An instance of ImAddress
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c imAddress is empty.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetImAddressAt(int index, const ImAddress& imAddress);
+
+       /**
+        * Sets the specified @c note corresponding to the specified @c index.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   index                   The index at which the value is set
+        * @param[in]   note                    The note to set
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c note is empty.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetNoteAt(int index, const Tizen::Base::String& note);
+
+       /**
+        * Sets the specified nick name corresponding to the specified @c index.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   index                   The index at which the value is set
+        * @param[in]   nickname                The nick name to set
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetNicknameAt(int index, const Tizen::Base::String& nickname);
+
+       /**
+        * Sets the specified @c event corresponding to the specified @c index.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   index                   The index at which the value is set
+        * @param[in]   event                   The event to set
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c event is empty.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetEventAt(int index, const ContactEvent& event);
+
+       /**
+        * Sets the specified organization corresponding to the specified @c index.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   index                   The index at which the value is set
+        * @param[in]   organization            The organization to set
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c organization is empty.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetOrganizationAt(int index, const Organization& organization);
+
+       /**
+        * Sets the specified @c relationship corresponding to the specified @c index.
+        *
+        * @since       2.1
+        *
+        * @return     An error code
+        * @param[in]  index            The index at which the value is set
+        * @param[in]  relationship     An instance of Relationship to set
+        * @exception  E_SUCCESS        The method is successful.
+        * @exception  E_INVALID_ARG    The specified @c relationship is empty.
+        * @exception  E_OUT_OF_RANGE   The specified @c index is outside the bounds of the properties.
+        */
+       result SetRelationshipAt(int index, const Relationship& relationship);
+
+       /**
+        * Gets the addressbook ID.
+        *
+        * @since       2.1
+        *
+        * @return      The addressbook ID
+        */
+       AddressbookId GetAddressbookId(void) const;
+
+       /**
+        * Gets the list of values belonging to a specific multi value property.
+        *
+        * @since       2.1
+        *
+        * @return      The list of values belonging to the specific multi value property
+        * @param[in]   id                      The property ID
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @remarks     The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetValuesN(UserProfileMultiPropertyId id) const;
+
+       /**
+        * Adds the specified phone number to the user profile.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   phoneNumber             The phone number to add
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c phoneNumber is empty.
+        */
+       result AddPhoneNumber(const PhoneNumber& phoneNumber);
+
+       /**
+        * Adds the specified @c email to the user profile.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   email           The email address to add
+        * @exception   E_SUCCESS       The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c email is empty.
+        */
+       result AddEmail(const Email& email);
+
+       /**
+        * Adds the specified URL to the user profile.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   url             The URL to add
+        * @exception   E_SUCCESS       The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c url is empty.
+        */
+
+       result AddUrl(const Url& url);
+
+       /**
+        * Adds the specified @c address to the user profile.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   address         The address to add
+        * @exception   E_SUCCESS       The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c address is empty.
+        */
+       result AddAddress(const Address& address);
+
+       /**
+        * Adds the specified instant message information to the user profile.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   imAddress       The IM address to add
+        * @exception   E_SUCCESS       The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c imAddress is empty.
+        */
+       result AddImAddress(const ImAddress& imAddress);
+
+       /**
+        * Adds the specified @c note to the user profile.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   note                    The note to add
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c note is empty.
+        */
+       result AddNote(const Tizen::Base::String& note);
+
+       /**
+        * Adds the specified nick name to the user profile.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   nickname                The nick name to add
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c nickname is empty.
+        */
+       result AddNickname(const Tizen::Base::String& nickname);
+
+       /**
+        * Adds the specified @c event to the user profile.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   event                   The event to add
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c event is empty.
+        */
+       result AddEvent(const ContactEvent& event);
+
+       /**
+        * Adds the specified @c organization to a contact.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   organization            The organization to add
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c organization is empty.
+        */
+       result AddOrganization(const Organization& organization);
+
+       /**
+        * Adds the specified @c relationship to the user profile.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   relationship            The relationship to add
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c relationship is empty.
+        */
+       result AddRelationship(const Relationship& relationship);
+
+       /**
+        * Removes the value at the specified @c index of a multi value property.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   id                      The property ID
+        * @param[in]   index                   The index at which the value is removed
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result RemoveAt(UserProfileMultiPropertyId id, int index);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.1
+        *
+        * @param[in]   rhs             An instance of %UserProfile to copy
+        */
+       UserProfile& operator =(const UserProfile& rhs);
+
+private:
+       friend class _UserProfileImpl;
+       class _UserProfileImpl* __pUserProfileImpl;
+
+}; // UserProfile
+
+}} // Tizen::Social
+
+#endif // _FSCL_USER_PROFILE_H_
diff --git a/inc/FSocial.h b/inc/FSocial.h
new file mode 100644 (file)
index 0000000..fa1c670
--- /dev/null
@@ -0,0 +1,100 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FSocial.h
+ * @brief      This is the header file for the %Social namespace.
+ *
+ * This header file contains the declarations and descriptions of the %Social namespace.
+ */
+
+#ifndef _FSOCIAL_H_
+#define _FSOCIAL_H_
+
+// Includes
+#include <FSclAddress.h>
+#include <FSclAddressbook.h>
+#include <FSclAddressbookManager.h>
+#include <FSclAttendee.h>
+#include <FSclCalendar.h>
+#include <FSclCalendarbook.h>
+#include <FSclCalendarbookFilter.h>
+#include <FSclCalEvent.h>
+#include <FSclCalEventChangeInfo.h>
+#include <FSclCalEventInstance.h>
+#include <FSclCalTodo.h>
+#include <FSclCalTodoChangeInfo.h>
+#include <FSclCategory.h>
+#include <FSclCategoryChangeInfo.h>
+#include <FSclContact.h>
+#include <FSclContactChangeInfo.h>
+#include <FSclEmail.h>
+#include <FSclEmailContact.h>
+#include <FSclIAddressbookEventListener.h>
+#include <FSclIAddressbookChangeEventListener.h>
+#include <FSclICalendarbookEventListener.h>
+#include <FSclIRecordEventListener.h>
+#include <FSclIRecordListener.h>
+#include <FSclImAddress.h>
+#include <FSclPhoneNumber.h>
+#include <FSclPhoneNumberContact.h>
+#include <FSclRecord.h>
+#include <FSclRecurrence.h>
+#include <FSclReminder.h>
+#include <FSclUrl.h>
+#include <FSclContactEvent.h>
+#include <FSclOrganization.h>
+#include <FSclRelationship.h>
+#include <FSclContactAppLaunchData.h>
+#include <FSclPerson.h>
+#include <FSclAddressbookFilter.h>
+#include <FSclAccount.h>
+#include <FSclAccountAccessor.h>
+#include <FSclAccountManager.h>
+#include <FSclAccountProvider.h>
+#include <FSclIAccountEventListener.h>
+#include <FSclTypes.h>
+#include <FSclUserProfile.h>
+
+/**
+ * @namespace  Tizen::Social
+ * @brief              This namespace contains classes and interfaces for managing the social information of a user.
+ * @since              2.0
+ *
+ * @remarks            @b Header @b %file: @b \#include @b <FSocial.h> @n
+ *                             @b Library: @b osp-social
+ *
+ *
+ * The %Social namespace provides various classes to manage personal data, such as contacts, schedules, and accounts on a device.
+ *
+ * For more information on the %Social namespace features, see <a href="../org.tizen.native.appprogramming/html/guide/social/social_namespace.htm">Social Guide</a>.
+ *
+ * The following diagrams illustrate the relationships between the classes belonging to the %Social namespace.
+ *
+ * [Account]
+ * @image html social_account_classdiagram.png
+ *
+ * [Addressbook]
+ * @image html social_addressbook_classdiagram.png
+ *
+ * [Calendarbook]
+ * @image html social_calendarbook_using_the_apis_classdiagram.png
+ *
+ */
+namespace Tizen { namespace Social
+{
+}}  // Tizen::Social
+
+#endif // _FSOCIAL_H_
diff --git a/osp-social.manifest b/osp-social.manifest
new file mode 100644 (file)
index 0000000..ae3e6f7
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_"/>
+       </request>
+</manifest>
\ No newline at end of file
diff --git a/osp-social.pc.in b/osp-social.pc.in
new file mode 100755 (executable)
index 0000000..eb6c3b7
--- /dev/null
@@ -0,0 +1,14 @@
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=/usr/lib/osp
+includedir=/usr/include/osp
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@ 
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
+
diff --git a/packaging/osp-social.spec b/packaging/osp-social.spec
new file mode 100644 (file)
index 0000000..cbc5128
--- /dev/null
@@ -0,0 +1,113 @@
+%define debug_package %{nil}
+%define __strip /bin/true
+
+Name:          osp-social
+Summary:       osp social library
+Version:       1.2.2.0
+Release:       1
+Group:         System/Libraries
+License:       Apache License, Version 2.0
+Source0:       %{name}-%{version}.tar.gz
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(contacts-service2)
+BuildRequires:  pkgconfig(calendar-service2)
+BuildRequires:  pkgconfig(accounts-svc)
+BuildRequires:  pkgconfig(libwbxml2)
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(db-util)
+BuildRequires:  pkgconfig(osp-appfw)
+BuildRequires:  osp-appfw-internal-devel
+BuildRequires:  pkgconfig(osp-uifw)
+BuildRequires:  osp-uifw-internal-devel
+BuildRequires:  pkgconfig(osp-image)
+BuildRequires:  osp-image-internal-devel
+BuildRequires:  pkgconfig(osp-image-core)
+BuildRequires:  osp-image-core-internal-devel
+BuildRequires:  pkgconfig(pkgmgr)
+BuildRequires:  pkgconfig(pkgmgr-info)
+
+# runtime requires
+Requires: osp-appfw
+Requires: osp-image
+Requires: capi-appfw-application
+Requires: capi-appfw-package-manager
+
+%description
+osp social library
+
+%package devel
+Summary:    osp social library (Development)
+Group:      TO_BE/FILLED_IN
+Requires:   %{name} = %{version}-%{release}
+
+%description devel
+osp social library (DEV)
+
+%package internal-devel
+Summary:    osp social library (Internal)
+Group:      TO_BE/FILLED_IN
+Requires:   %{name} = %{version}-%{release}
+
+%description internal-devel
+osp social library (Internal-DEV)
+
+%package debug
+Summary:    osp social library (Development)
+Group:      TO_BE/FILLED_IN
+Requires:   %{name} = %{version}-%{release}
+
+%description debug
+osp social library (DEV)
+
+%prep
+%setup -q
+
+%build
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+
+%ifarch %{ix86}
+       ARCH=x86
+       CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_"
+       %if 0%{?simulator}
+               CXXFLAGS="$CXXFLAGS -D_OSP_EMUL_"
+       %endif
+%else
+       ARCH=arm
+       CXXFLAGS="-O2 -g -pipe -Wall -fno-exceptions -Wformat -Wformat-security -Wl,--as-needed -fmessage-length=0 -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -D__SOFTFP__ -mthumb -Wa,-mimplicit-it=thumb -funwind-tables -D_OSP_DEBUG_ -D_OSP_ARMEL_"
+%endif
+
+%if 0%{?tizen_build_binary_release_type_eng}
+       CXXFLAGS="$CXXFLAGS -D_SECURE_LOG"
+%endif
+
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DOBS=1 -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DARCH=${ARCH}
+
+# Call make instruction with smp support
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/usr/share/license
+cp %{_builddir}/%{name}-%{version}/LICENSE.APLv2  %{buildroot}/usr/share/license/%{name}
+
+%make_install
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest osp-social.manifest
+/usr/share/license/%{name}
+%{_libdir}/osp/*.so*
+/usr/etc/package-manager/parserlib/libaccount.so
+
+%files devel
+%{_includedir}/osp/*.h
+%{_libdir}/pkgconfig/osp-social.pc
+
+%files internal-devel
+%{_includedir}/osp/social/*.h
+
+%files debug
+%{_libdir}/osp/debug/*.so*
diff --git a/pkgmgr_account/CMakeLists.txt b/pkgmgr_account/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..ab7457b
--- /dev/null
@@ -0,0 +1,52 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET (this_target account)
+
+SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/cmake_build_tmp/output)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(bin_pkgs REQUIRED libxml-2.0)
+
+INCLUDE_DIRECTORIES(
+       /usr/include
+       /usr/include/glib-2.0 
+       /usr/lib/glib-2.0/include
+       /usr/include/libxml2
+       /usr/include/osp
+       /usr/include/osp/base
+       /usr/include/accounts-svc
+       )
+
+SET (${this_target}_SOURCE_FILES
+       src/account.cpp
+       )
+
+SET(EXTRA_CFLAGS  "${EXTRA_CFLAGS} -Wall" )
+
+## SET C COMPILER FLAGS
+SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## SET CPP COMPILER FLAGS
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
+SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## Create Library
+ADD_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+## SET LINKER FLAGS
+SET(CMAKE_SHARED_LINKER_FLAGS -Wl,--no-undefined)
+
+TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp -losp-appfw" )
+TARGET_LINK_LIBRARIES(${this_target} "-lxml2" )
+TARGET_LINK_LIBRARIES(${this_target} "-lglib-2.0" )
+TARGET_LINK_LIBRARIES(${this_target} "-laccounts-svc" )
+
+ADD_CUSTOM_COMMAND(TARGET ${this_target}
+    POST_BUILD
+               COMMAND ${CMAKE_COMMAND} -E copy ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}
+               COMMAND ${CMAKE_STRIP} --strip-unneeded ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}
+    COMMENT "strip ${this_target}"
+               )   
+
+INSTALL(TARGETS ${this_target} DESTINATION "etc/package-manager/parserlib")
+
diff --git a/pkgmgr_account/src/account.cpp b/pkgmgr_account/src/account.cpp
new file mode 100644 (file)
index 0000000..10cbaf9
--- /dev/null
@@ -0,0 +1,447 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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 <errno.h>
+#include <new>
+#include <unique_ptr.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <account.h>
+#include <account-types.h>
+#include <FApp.h>
+#include <FAppPkgPackageInfo.h>
+#include <FAppPkgPackageManager.h>
+#include <FAppPkg_PackageManagerImpl.h>
+#include <FBaseColIEnumerator.h>
+#include <FBaseColIList.h>
+#include <FBaseDataType.h>
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include <FBaseUtilStringTokenizer.h>
+#include <FBaseUtilStringUtil.h>
+
+#define _SysTryReturn(NID, condition, returnValue, ...)        \
+       if (!(condition)) { \
+               SysLog(NID, __VA_ARGS__); \
+               return returnValue;     \
+       } \
+       else {;}
+
+#define _SysTryCatch(NID, condition, expr, ...) \
+       if (!(condition)) { \
+               SysLog(NID, __VA_ARGS__); \
+               expr; \
+               goto CATCH;     \
+       } \
+       else {;}
+
+using namespace Tizen::App;
+using namespace Tizen::App::Package;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+
+static const xmlChar _NODE_ACCOUNT_PROVIDER[]                          = "account-provider";
+static const xmlChar _NODE_ICON[]                                                      = "icon";
+static const xmlChar _NODE_LABEL[]                                                     = "label";
+static const xmlChar _NODE_CAPABILITY[]                                                = "capability";
+
+static const xmlChar _ATTRIBUTE_APP_ID[]                                       = "appid";
+static const xmlChar _ATTRIBUTE_MULTIPLE_ACCOUNTS_SUPPORT[]    = "multiple-accounts-support";
+static const xmlChar _ATTRIBUTE_SECTION[]                                      = "section";
+static const xmlChar _ATTRIBUTE_TYPE[]                                         = "type";
+static const xmlChar _ATTRIBUTE_XML_LANG[]                                     = "xml:lang";
+
+static const xmlChar _VALUE_TRUE[]                                                     = "true";
+static const xmlChar _VALUE_ACCOUNT[]                                          = "account";
+static const xmlChar _VALUE_ACCOUNT_SMALL[]                                    = "account-small";
+static const xmlChar _VALUE_XHIGH[]                                                    = "Xhigh";
+
+static const char _DEFAULT_LOCALE[]                                                    = "default";
+
+static String __oldAccountProviderAppId;
+
+bool
+OnAccountReceived(account_h accountHandle, void* pUserData)
+{
+       SysTryReturn(NID_SCL, accountHandle != null && pUserData != null, false, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM));
+
+       String* pAccountProviderAppId = static_cast<String*> (pUserData);
+       SysTryReturn(NID_SCL, pAccountProviderAppId != null, false, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM));
+
+       // Get the account ID
+       int accountDbId = 0;
+       int ret = account_get_account_id(accountHandle, &accountDbId);
+       SysTryReturn(NID_SCL, ret == ACCOUNT_ERROR_NONE, null, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       // Set the new app ID
+       std::unique_ptr<char[]> pCharArrayAppId(_StringConverter::CopyToCharArrayN(*pAccountProviderAppId));
+       SysTryReturn(NID_SCL, pCharArrayAppId != null, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       ret = account_set_package_name(accountHandle, pCharArrayAppId.get());
+       SysTryReturn(NID_SCL, ret == ACCOUNT_ERROR_NONE, false, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM));
+
+       // Update the account
+       ret = account_update_to_db_by_id_ex(accountHandle, accountDbId);
+       SysTryReturn(NID_SCL, ret != ACCOUNT_ERROR_NOT_REGISTERED_PROVIDER, false, E_INVALID_OPERATION, "[%s] The application does not register the account provider.", GetErrorMessage(E_INVALID_OPERATION));
+       SysTryReturn(NID_SCL, ret != ACCOUNT_ERROR_PERMISSION_DENIED, false, E_INVALID_OPERATION, "[%s] The application has no permission to update this account.", GetErrorMessage(E_INVALID_OPERATION));
+       SysTryReturn(NID_SCL, ret != ACCOUNT_ERROR_RECORD_NOT_FOUND, false, E_OBJ_NOT_FOUND, "[%s] The account does not exist.", GetErrorMessage(E_OBJ_NOT_FOUND));
+       SysTryReturn(NID_SCL, ret == ACCOUNT_ERROR_NONE, false, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM));
+
+       return true;
+}
+
+result
+RegisterAccountProvider(xmlDocPtr docPtr, String& accountProviderAppId)
+{
+       SysLog(NID_SCL, "Registering the Account Provider.");
+
+       int ret = account_connect();
+       SysTryReturnResult(NID_SCL, ret == ACCOUNT_ERROR_NONE, E_SYSTEM, "A system error has occurred.");
+
+       account_type_h accountTypeHandle = null;
+       ret = account_type_create(&accountTypeHandle);
+       if (ret != ACCOUNT_ERROR_NONE || accountTypeHandle == null)
+       {
+               SysLog(NID_SCL, "Memory allocation failed.");
+               return E_OUT_OF_MEMORY;
+       }
+
+       result r = E_SUCCESS;
+
+       // Node: <account>
+       xmlNodePtr curPtr = xmlFirstElementChild(xmlDocGetRootElement(docPtr));
+       SysTryCatch(NID_SCL, curPtr != null, r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Failed to get the element.", GetErrorMessage(E_INVALID_ARG));
+
+       SysSecureLog(NID_SCL, "Node: %s", curPtr->name);
+
+       // Get the children nodes
+       curPtr = curPtr->xmlChildrenNode;
+       SysTryCatch(NID_SCL, curPtr != null, r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Failed to get the child element.", GetErrorMessage(E_INVALID_ARG));
+
+       while(curPtr != null)
+       {
+               SysSecureLog(NID_SCL, "Node: %s", curPtr->name);
+
+               // Node: <account-provider>
+               if ((!xmlStrcmp(curPtr->name, _NODE_ACCOUNT_PROVIDER)))
+               {
+                       // Attribute: appid
+                       xmlChar* pAppIdId = xmlGetProp(curPtr, _ATTRIBUTE_APP_ID);
+                       SysTryCatch(NID_SCL, pAppIdId != null, r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Failed to get the attribute.", GetErrorMessage(E_INVALID_ARG));
+
+                       SysSecureLog(NID_SCL, "Attribute: appid - %s", pAppIdId);
+                       ret = account_type_set_app_id(accountTypeHandle, reinterpret_cast<char*> (pAppIdId));
+                       SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to set the app ID.", GetErrorMessage(E_SYSTEM));
+
+                       accountProviderAppId.Clear();
+                       accountProviderAppId.Append(String(reinterpret_cast<char*> (pAppIdId)));
+
+                       // Attribute: multiple-accounts-support
+                       xmlChar* pMultipleAccountsSupport = xmlGetProp(curPtr, _ATTRIBUTE_MULTIPLE_ACCOUNTS_SUPPORT);
+                       SysTryCatch(NID_SCL, pMultipleAccountsSupport != null, r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Failed to get the attribute.", GetErrorMessage(E_INVALID_ARG));
+
+                       SysSecureLog(NID_SCL, "Attribute: multiple-accounts-support - %s", pMultipleAccountsSupport);
+                       if ((!xmlStrcmp(pMultipleAccountsSupport, _VALUE_TRUE)))
+                       {
+                               ret = account_type_set_multiple_account_support(accountTypeHandle, true);
+                               SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to set the multiple accounts support.", GetErrorMessage(E_SYSTEM));
+                       }
+                       else
+                       {
+                               ret = account_type_set_multiple_account_support(accountTypeHandle, false);
+                               SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to set the multiple accounts support.", GetErrorMessage(E_SYSTEM));
+                       }
+
+                       // Get the children nodes
+                       curPtr = curPtr->xmlChildrenNode;
+                       SysTryCatch(NID_SCL, curPtr != null, r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Failed to get the child element.", GetErrorMessage(E_INVALID_ARG));
+
+                       while (curPtr != NULL)
+                       {
+                               SysSecureLog(NID_SCL, "Node: %s", curPtr->name);
+
+                               // Node: <icon>
+                               if ((!xmlStrcmp(curPtr->name, _NODE_ICON)))
+                               {
+                                       // Attribute: section
+                                       xmlChar* pSection = xmlGetProp(curPtr, _ATTRIBUTE_SECTION);
+                                       SysTryCatch(NID_SCL, pSection != null, r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Failed to get the attribute.", GetErrorMessage(E_INVALID_ARG));
+
+                                       SysSecureLog(NID_SCL, "Attribute: section - %s", pSection);
+
+                                       if ((!xmlStrcmp(pSection, _VALUE_ACCOUNT)))
+                                       {
+                                               xmlChar* pAccountIcon = xmlNodeListGetString(docPtr, curPtr->xmlChildrenNode, 1);
+                                               SysTryCatch(NID_SCL, pAccountIcon != null, r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Failed to get the value.", GetErrorMessage(E_INVALID_ARG));
+
+                                               SysSecureLog(NID_SCL, "Node: icon - %s", pAccountIcon);
+                                               ret = account_type_set_icon_path(accountTypeHandle, reinterpret_cast<char*> (pAccountIcon));
+                                               SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to set the icon path.", GetErrorMessage(E_SYSTEM));
+                                       }
+                                       else if ((!xmlStrcmp(pSection, _VALUE_ACCOUNT_SMALL)))
+                                       {
+                                               xmlChar* pAccountSmallIcon = xmlNodeListGetString(docPtr, curPtr->xmlChildrenNode, 1);
+                                               SysTryCatch(NID_SCL, pAccountSmallIcon != null, r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Failed to get the value.", GetErrorMessage(E_INVALID_ARG));
+
+                                               SysSecureLog(NID_SCL, "Node: icon (small) - %s",  pAccountSmallIcon);
+                                               ret = account_type_set_small_icon_path(accountTypeHandle, reinterpret_cast<char*> (pAccountSmallIcon));
+                                               SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to set the small icon path.", GetErrorMessage(E_SYSTEM));
+                                       }
+                               }
+                               // Node: <label>
+                               else if ((!xmlStrcmp(curPtr->name, _NODE_LABEL)))
+                               {
+                                       SysSecureLog(NID_SCL, "Node: %s", curPtr->name);
+
+                               // Attribute: xml:lang
+                                       xmlChar* pLang = xmlNodeGetLang(curPtr);
+                                       if (pLang != null)
+                                       {
+                                               SysSecureLog(NID_SCL, "Attribute: xml:lang - %s", pLang);
+
+                                               String lang(reinterpret_cast<char*> (pLang));
+
+                                               StringTokenizer strTok(lang, L"-");
+                                               String token;
+                                               String convertedLang;
+
+                                               strTok.GetNextToken(convertedLang);
+                                               convertedLang.Append(L"_");
+
+                                               strTok.GetNextToken(token);
+                                               token.ToUpper();
+                                               convertedLang.Append(token);
+
+                                               std::unique_ptr<ByteBuffer> pConvertedLangBuf(StringUtil::StringToUtf8N(convertedLang));
+                                               SysTryCatch(NID_SCL, pConvertedLangBuf != null, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to convert String to Utf8N.", GetErrorMessage(E_SYSTEM));
+
+                                               SysSecureLog(NID_SCL, "Attribute: converted lang - %s", pConvertedLangBuf->GetPointer());
+
+                                               xmlChar* pLabel = xmlNodeListGetString(docPtr, curPtr->xmlChildrenNode, 1);
+                                               SysTryCatch(NID_SCL, pLabel != null, r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Failed to get the value.", GetErrorMessage(E_INVALID_ARG));
+
+                                               SysSecureLog(NID_SCL, "Node: label - %s", pLabel);
+                                               ret = account_type_set_label(accountTypeHandle, reinterpret_cast<char*> (pLabel), reinterpret_cast<char*> (pConvertedLangBuf->GetPointer()));
+                                               SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to set the display name.", GetErrorMessage(E_SYSTEM));
+                                       }
+                                       else
+                                       {
+                                               xmlChar* pLabel = xmlNodeListGetString(docPtr, curPtr->xmlChildrenNode, 1);
+                                               SysTryCatch(NID_SCL, pLabel != null, r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Failed to get the value.", GetErrorMessage(E_INVALID_ARG));
+
+                                               SysSecureLog(NID_SCL, "Node: label - %s",  pLabel);
+                                               ret = account_type_set_label(accountTypeHandle, reinterpret_cast<char*> (pLabel), _DEFAULT_LOCALE);
+                                               SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to set the display name.", GetErrorMessage(E_SYSTEM));
+                                       }
+                               }
+                               // Node: <capability>
+                               else if ((!xmlStrcmp(curPtr->name, _NODE_CAPABILITY)))
+                               {
+                                       SysSecureLog(NID_SCL, "Node: %s", curPtr->name);
+
+                                       xmlChar* pCapability = xmlNodeListGetString(docPtr, curPtr->xmlChildrenNode, 1);
+                                       SysTryCatch(NID_SCL, pCapability != null, r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Failed to get the value.", GetErrorMessage(E_INVALID_ARG));
+
+                                       SysSecureLog(NID_SCL, "Node: capability - %s",  pCapability);
+                                       ret = account_type_set_provider_feature(accountTypeHandle, reinterpret_cast<char*> (pCapability));
+                                       SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to set the capability.", GetErrorMessage(E_SYSTEM));
+                               }
+
+                               curPtr = curPtr->next;
+                       }
+
+                       break;
+               }
+
+               curPtr = curPtr->next;
+       }
+
+       // Insert the account type to the account DB
+       {
+               int accountTypeDbId = 0;
+               ret = account_type_insert_to_db(accountTypeHandle, &accountTypeDbId);
+               SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM));
+       }
+
+       account_type_destroy(accountTypeHandle);
+       SysTryReturnResult(NID_SCL, account_disconnect() == ACCOUNT_ERROR_NONE, E_SYSTEM, "A system error has occurred.");
+
+       return E_SUCCESS;
+
+CATCH:
+       account_type_destroy(accountTypeHandle);
+       SysTryReturnResult(NID_SCL, account_disconnect() == ACCOUNT_ERROR_NONE, E_SYSTEM, "A system error has occurred.");
+
+       return r;
+}
+
+extern "C"
+__attribute__ ((visibility("default")))
+int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr docPtr, const char* packageId)
+{
+       SysLog(NID_SCL, "PKGMGR_PARSER_PLUGIN_INSTALL");
+
+       String accountProviderAppId;
+       result r = RegisterAccountProvider(docPtr, accountProviderAppId);
+       _SysTryReturn(NID_SCL, r == E_SUCCESS, -1, "Failed to register the account provider.");
+
+       return 0;
+}
+
+extern "C"
+__attribute__ ((visibility("default")))
+int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr docPtr, const char* packageId)
+{
+       SysLog(NID_SCL, "PKGMGR_PARSER_PLUGIN_UNINSTALL");
+
+       int ret = account_connect();
+       _SysTryReturn(NID_SCL, ret == ACCOUNT_ERROR_NONE, -1, "A system error has occurred.");
+
+       // Node: <account>
+       xmlNodePtr curPtr = xmlFirstElementChild(xmlDocGetRootElement(docPtr));
+       _SysTryCatch(NID_SCL, curPtr != null, ret = -EINVAL, "Failed to get the element.");
+
+       SysSecureLog(NID_SCL, "Node: %s", curPtr->name);
+
+       // Get the children nodes
+       curPtr = curPtr->xmlChildrenNode;
+       _SysTryCatch(NID_SCL, curPtr != null, ret = -EINVAL, "Failed to get the child element.");
+
+       while(curPtr != null)
+       {
+               SysSecureLog(NID_SCL, "Node: %s", curPtr->name);
+
+               // Node: <account-provider>
+               if ((!xmlStrcmp(curPtr->name, _NODE_ACCOUNT_PROVIDER)))
+               {
+                       // Attribute: appid
+                       xmlChar* pAppIdId = xmlGetProp(curPtr, _ATTRIBUTE_APP_ID);
+                       _SysTryCatch(NID_SCL, pAppIdId != null, ret = -EINVAL, "Failed to get the attribute.");
+
+                       SysSecureLog(NID_SCL, "Attribute: appid - %s", pAppIdId);
+
+                       ret = account_delete_from_db_by_package_name(reinterpret_cast<char*> (pAppIdId));
+                       _SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, ret = -1, "A system error has occurred.");
+
+                       ret = account_type_delete_by_app_id(reinterpret_cast<char*> (pAppIdId));
+                       _SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, ret = -1, "A system error has occurred.");
+
+                       break;
+               }
+
+               curPtr = curPtr->next;
+       }
+
+       SysTryReturn(NID_SCL, account_disconnect() == ACCOUNT_ERROR_NONE, -1, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM));
+
+       return 0;
+
+CATCH:
+       SysTryReturn(NID_SCL, account_disconnect() == ACCOUNT_ERROR_NONE, -1, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM));
+
+       return ret;
+}
+
+extern "C"
+__attribute__ ((visibility("default")))
+int PKGMGR_PARSER_PLUGIN_PRE_UPGRADE(const char* packageId)
+{
+       SysLog(NID_SCL, "PKGMGR_PARSER_PLUGIN_PRE_UPGRADE");
+
+       result r = E_SUCCESS;
+
+       __oldAccountProviderAppId.Clear();
+
+       _PackageManagerImpl* pPackageManagerImpl = _PackageManagerImpl::GetInstance();
+       _SysTryReturn(NID_SCL, pPackageManagerImpl != null, -1, "Failed to get the PackageManagerImpl instance.");
+
+       String pkgId(packageId);
+       std::unique_ptr<PackageInfo> pPackageInfo(pPackageManagerImpl->GetPackageInfoN(pkgId));
+       r = GetLastResult();
+       _SysTryReturn(NID_SCL, r != E_PKG_NOT_INSTALLED, -1, "The package is not installed.");
+       _SysTryReturn(NID_SCL, pPackageInfo != null && r == E_SUCCESS, -1, "Failed to get the package information.");
+
+       std::unique_ptr<IList, AllElementsDeleter> pPackageAppInfoList(pPackageInfo->GetPackageAppInfoListN());
+       _SysTryReturn(NID_SCL, pPackageAppInfoList != null, -1, "Failed to get the application information list.");
+
+       std::unique_ptr<IEnumerator> pEnum(pPackageAppInfoList->GetEnumeratorN());
+       _SysTryReturn(NID_SCL, pEnum != null, -1, "A system error has occurred.");
+
+       int ret = account_connect();
+       _SysTryReturn(NID_SCL, ret == ACCOUNT_ERROR_NONE, -1, "A system error has occurred.");
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               PackageAppInfo* pPackageAppInfo = dynamic_cast<PackageAppInfo*> (pEnum->GetCurrent());
+               _SysTryCatch(NID_SCL, pPackageAppInfo != null, ret = -1, "A system error has occurred.");
+
+               std::unique_ptr<char[]> pCharArrayAppId(_StringConverter::CopyToCharArrayN(pPackageAppInfo->GetAppId()));
+               _SysTryCatch(NID_SCL, pCharArrayAppId != null, ret = -1, "Memory allocation failed.");
+
+               ret = account_type_delete_by_app_id(pCharArrayAppId.get());
+               if (ret == ACCOUNT_ERROR_NONE)
+               {
+                       SysLog(NID_SCL, "PKGMGR_PARSER_PLUGIN_PRE_UPGRADE: app ID - %ls", (pPackageAppInfo->GetAppId()).GetPointer());
+
+                       __oldAccountProviderAppId = pPackageAppInfo->GetAppId();
+                       break;
+               }
+       }
+
+       SysTryReturn(NID_SCL, account_disconnect() == ACCOUNT_ERROR_NONE, -1, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM));
+
+       return 0;
+
+CATCH:
+       SysTryReturn(NID_SCL, account_disconnect() == ACCOUNT_ERROR_NONE, -1, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM));
+
+       return ret;
+}
+
+extern "C"
+__attribute__ ((visibility("default")))
+int PKGMGR_PARSER_PLUGIN_UPGRADE(xmlDocPtr docPtr, const char* packageId)
+{
+       SysLog(NID_SCL, "PKGMGR_PARSER_PLUGIN_UPGRADE");
+
+       String accountProviderAppId;
+       result r = RegisterAccountProvider(docPtr, accountProviderAppId);
+       _SysTryReturn(NID_SCL, r == E_SUCCESS, -1, "Failed to register the account provider.");
+
+       int ret = account_connect();
+       _SysTryReturn(NID_SCL, ret == ACCOUNT_ERROR_NONE, -1, "A system error has occurred.");
+
+       std::unique_ptr<char[]> pCharArrayAppId(_StringConverter::CopyToCharArrayN(__oldAccountProviderAppId));
+       _SysTryCatch(NID_SCL, pCharArrayAppId != null, ret = -1, "Memory allocation failed.");
+
+       ret = account_query_account_by_package_name(OnAccountReceived, pCharArrayAppId.get(), (void*) &accountProviderAppId);
+       _SysTryCatch(NID_SCL, (ret == ACCOUNT_ERROR_NONE) || (ret == ACCOUNT_ERROR_RECORD_NOT_FOUND), ret = -1, "A system error has occurred.");
+
+       r = GetLastResult();
+       _SysTryCatch(NID_SCL, r == E_SUCCESS, ret = -1, "Failed to update accounts.");
+
+       ret = account_disconnect();
+       _SysTryReturn(NID_SCL, ret == ACCOUNT_ERROR_NONE, -1, "A system error has occurred.");
+
+       return 0;
+
+CATCH:
+       _SysTryReturn(NID_SCL, account_disconnect() == ACCOUNT_ERROR_NONE, -1, "A system error has occurred.");
+
+       return ret;
+}
diff --git a/src/FSclAccount.cpp b/src/FSclAccount.cpp
new file mode 100644 (file)
index 0000000..c0e569d
--- /dev/null
@@ -0,0 +1,128 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclAccount.cpp
+ * @brief              This is the implementation for Account class.
+ *
+ * This file contains definitions of @e Account class.
+ */
+
+#include <new>
+#include <FBaseColIMap.h>
+#include <FBaseResult.h>
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include <FSclAccount.h>
+#include "FScl_AccountImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Social
+{
+
+Account::Account(const String& userName)
+{
+       __pAccountImpl = new (std::nothrow) _AccountImpl(userName);
+       SysTryReturnVoidResult(NID_SCL, __pAccountImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+Account::Account(const Account& rhs)
+{
+       __pAccountImpl = new (std::nothrow) _AccountImpl(*rhs.__pAccountImpl);
+       SysTryReturnVoidResult(NID_SCL, __pAccountImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+Account::~Account(void)
+{
+       delete __pAccountImpl;
+}
+
+Account&
+Account::operator =(const Account& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pAccountImpl = *rhs.__pAccountImpl;
+
+       return *this;
+}
+
+bool
+Account::Equals(const Object& rhs) const
+{
+       const Account* pAccount = dynamic_cast<const Account*> (&rhs);
+
+       if (pAccount == null)
+       {
+               return false;
+       }
+
+       return __pAccountImpl->Equals(*pAccount->__pAccountImpl);
+}
+
+int
+Account::GetHashCode(void) const
+{
+       return __pAccountImpl->GetHashCode();
+}
+
+AccountId
+Account::GetId(void) const
+{
+       return __pAccountImpl->GetId();
+}
+
+AccountProvider
+Account::GetAccountProvider(void) const
+{
+       return __pAccountImpl->GetAccountProvider();
+}
+
+String
+Account::GetUserName(void) const
+{
+       return __pAccountImpl->GetUserName();
+}
+
+IMap*
+Account::GetExtendedDataN(void) const
+{
+       return __pAccountImpl->GetExtendedDataN();
+}
+
+result
+Account::SetUserName(const String& userName)
+{
+       result r = __pAccountImpl->SetUserName(userName);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Account::SetExtendedData(const String& key, const String& value)
+{
+       result r = __pAccountImpl->SetExtendedData(key, value);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+}} //Tizen::Social
diff --git a/src/FSclAccountAccessor.cpp b/src/FSclAccountAccessor.cpp
new file mode 100644 (file)
index 0000000..89f200a
--- /dev/null
@@ -0,0 +1,238 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclAccountAccessor.cpp
+ * @brief              This is the implementation for AccountAccessor class.
+ *
+ * This file contains definitions of @e AccountAccessor class.
+ */
+
+#include <new>
+#include <pthread.h>
+#include <unique_ptr.h>
+#include <FBaseResult.h>
+#include <FBaseSysLog.h>
+#include <FBaseColIList.h>
+#include <FSec_AccessController.h>
+#include <FSclAccount.h>
+#include <FSclAccountAccessor.h>
+#include <FSclAccountProvider.h>
+#include <FSclIAccountEventListener.h>
+#include "FScl_AccountAccessorImpl.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Social
+{
+
+AccountAccessor* AccountAccessor::__pInstance = null;
+
+AccountAccessor::AccountAccessor(void)
+       : __pAccountAccessorImpl(null)
+{
+       // empty body
+}
+
+AccountAccessor::~AccountAccessor(void)
+{
+       delete __pAccountAccessorImpl;
+}
+
+result
+AccountAccessor::SetEventListener(IAccountEventListener* pListener)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_ACCOUNT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+
+       SysAssertf(__pAccountAccessorImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAccountAccessorImpl->SetEventListener(pListener);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+Account
+AccountAccessor::GetAccount(AccountId accountId) const
+{
+       Account account(L"");
+
+       result r = _AccessController::CheckUserPrivilege(_PRV_ACCOUNT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, account, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+
+       SysAssertf(__pAccountAccessorImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       account = __pAccountAccessorImpl->GetAccount(accountId);
+       SysTryReturn(NID_SCL, !IsFailed(GetLastResult()), account, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return account;
+}
+
+IList*
+AccountAccessor::GetAccountsByAccountProviderN(const AppId& accountProviderAppId) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_ACCOUNT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+
+       SysAssertf(__pAccountAccessorImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAccountAccessorImpl->GetAccountsByAccountProviderN(accountProviderAppId);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+IList*
+AccountAccessor::GetAllAccountsN(void) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_ACCOUNT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+
+       SysAssertf(__pAccountAccessorImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAccountAccessorImpl->GetAllAccountsN();
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+AccountProvider
+AccountAccessor::GetAccountProvider(const AppId& accountProviderAppId) const
+{
+       AccountProvider accountProvider;
+
+       result r = _AccessController::CheckUserPrivilege(_PRV_ACCOUNT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, accountProvider, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+
+       SysAssertf(__pAccountAccessorImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       accountProvider = __pAccountAccessorImpl->GetAccountProvider(accountProviderAppId);
+       SysTryReturn(NID_SCL, !IsFailed(GetLastResult()), accountProvider, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return accountProvider;
+}
+
+IList*
+AccountAccessor::GetAccountProvidersByCapabilityN(const String& capability) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_ACCOUNT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+
+       SysAssertf(__pAccountAccessorImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAccountAccessorImpl->GetAccountProvidersByCapabilityN(capability);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+IList*
+AccountAccessor::GetAllAccountProvidersN(void) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_ACCOUNT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+
+       SysAssertf(__pAccountAccessorImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAccountAccessorImpl->GetAllAccountProvidersN();
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+AccountAccessor*
+AccountAccessor::GetInstance(void)
+{
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+       if (__pInstance == null)
+       {
+               ClearLastResult();
+
+               pthread_once(&onceBlock, InitAccountAccessor);
+
+               result r = GetLastResult();
+
+               if (IsFailed(r))
+               {
+                       onceBlock = PTHREAD_ONCE_INIT;
+               }
+       }
+
+       return __pInstance;
+}
+
+result
+AccountAccessor::Construct(void)
+{
+       SysAssertf(__pAccountAccessorImpl == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       _AccountAccessorImpl* pAccountAccessorImpl = new (std::nothrow) _AccountAccessorImpl();
+       SysTryReturnResult(NID_SCL, pAccountAccessorImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       result r = pAccountAccessorImpl->Construct();
+       SysTryCatch(NID_SCL, !IsFailed(r), , r, "[%s] Failed to construct pAccountAccessorImpl.", GetErrorMessage(r));
+
+       __pAccountAccessorImpl = pAccountAccessorImpl;
+
+       return E_SUCCESS;
+
+CATCH:
+       delete pAccountAccessorImpl;
+
+       return r;
+}
+
+void
+AccountAccessor::InitAccountAccessor(void)
+{
+       std::unique_ptr<AccountAccessor> pInstance(new (std::nothrow) AccountAccessor());
+       SysTryReturnVoidResult(NID_SCL, pInstance != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pInstance->Construct();
+       SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Failed to construct pInstance.", GetErrorMessage(r));
+
+       __pInstance = pInstance.release();
+
+       std::atexit(DestroyAccountAccessor);
+}
+
+void
+AccountAccessor::DestroyAccountAccessor(void)
+{
+       delete __pInstance;
+       __pInstance = null;
+}
+
+}}  // Tizen::Social
diff --git a/src/FSclAccountManager.cpp b/src/FSclAccountManager.cpp
new file mode 100644 (file)
index 0000000..41ed1f4
--- /dev/null
@@ -0,0 +1,167 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclAccountManager.cpp
+ * @brief              This is the implementation for AccountManager class.
+ *
+ * This file contains definitions of @e AccountManager class.
+ */
+
+#include <new>
+#include <pthread.h>
+#include <unique_ptr.h>
+#include <FBaseResult.h>
+#include <FBaseSysLog.h>
+#include <FBaseColIList.h>
+#include <FSec_AccessController.h>
+#include <FSclAccount.h>
+#include <FSclAccountManager.h>
+#include "FScl_AccountManagerImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Social
+{
+
+AccountManager* AccountManager::__pInstance = null;
+
+AccountManager::AccountManager(void)
+       : __pAccountManagerImpl(null)
+{
+       // empty body
+}
+
+AccountManager::~AccountManager(void)
+{
+       delete __pAccountManagerImpl;
+}
+
+result
+AccountManager::AddAccount(Account& account)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_ACCOUNT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+
+       SysAssertf(__pAccountManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAccountManagerImpl->AddAccount(account);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+AccountManager::RemoveAccount(AccountId accountId)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_ACCOUNT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+
+       SysAssertf(__pAccountManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAccountManagerImpl->RemoveAccount(accountId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+AccountManager::UpdateAccount(const Account& account)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_ACCOUNT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+
+       SysAssertf(__pAccountManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAccountManagerImpl->UpdateAccount(account);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+AccountManager*
+AccountManager::GetInstance(void)
+{
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+       if (__pInstance == null)
+       {
+               ClearLastResult();
+
+               pthread_once(&onceBlock, InitAccountManager);
+
+               result r = GetLastResult();
+
+               if (IsFailed(r))
+               {
+                       onceBlock = PTHREAD_ONCE_INIT;
+               }
+       }
+
+       return __pInstance;
+}
+
+result
+AccountManager::Construct(void)
+{
+       SysAssertf(__pAccountManagerImpl == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       _AccountManagerImpl* pAccountManagerImpl = new (std::nothrow) _AccountManagerImpl();
+       SysTryReturnResult(NID_SCL, pAccountManagerImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       result r = pAccountManagerImpl->Construct();
+       SysTryCatch(NID_SCL, !IsFailed(r), , r, "[%s] Failed to construct pAccountManagerImpl.", GetErrorMessage(r));
+
+       __pAccountManagerImpl = pAccountManagerImpl;
+
+       return E_SUCCESS;
+
+CATCH:
+       delete pAccountManagerImpl;
+
+       return r;
+}
+
+void
+AccountManager::InitAccountManager(void)
+{
+       std::unique_ptr<AccountManager> pInstance(new (std::nothrow) AccountManager());
+       SysTryReturnVoidResult(NID_SCL, pInstance != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pInstance->Construct();
+       SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Failed to construct pInstance.", GetErrorMessage(r));
+
+       __pInstance = pInstance.release();
+
+       std::atexit(DestroyAccountManager);
+}
+
+void
+AccountManager::DestroyAccountManager(void)
+{
+       delete __pInstance;
+       __pInstance = null;
+}
+
+}}  // Tizen::Social
diff --git a/src/FSclAccountProvider.cpp b/src/FSclAccountProvider.cpp
new file mode 100644 (file)
index 0000000..4e610a6
--- /dev/null
@@ -0,0 +1,126 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclAccountProvider.cpp
+ * @brief              This is the implementation for AccountProvider class.
+ *
+ * This file contains definitions of @e AccountProvider class.
+ */
+
+#include <new>
+#include <FBaseColIList.h>
+#include <FBaseResult.h>
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include <FSclAccountProvider.h>
+#include "FScl_AccountProviderImpl.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Social
+{
+
+AccountProvider::AccountProvider(void)
+{
+       __pAccountProviderImpl = new (std::nothrow) _AccountProviderImpl();
+       SysTryReturnVoidResult(NID_SCL, __pAccountProviderImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+}
+
+AccountProvider::AccountProvider(const AccountProvider& rhs)
+{
+       __pAccountProviderImpl = new (std::nothrow) _AccountProviderImpl();
+       SysTryReturnVoidResult(NID_SCL, __pAccountProviderImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+
+       *__pAccountProviderImpl = *rhs.__pAccountProviderImpl;
+}
+
+AccountProvider::~AccountProvider(void)
+{
+       delete __pAccountProviderImpl;
+}
+
+AccountProvider&
+AccountProvider::operator =(const AccountProvider& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pAccountProviderImpl = *rhs.__pAccountProviderImpl;
+
+       return *this;
+}
+
+bool
+AccountProvider::Equals(const Object& rhs) const
+{
+       const AccountProvider* pAccountProvider = dynamic_cast<const AccountProvider*> (&rhs);
+
+       if (pAccountProvider == null)
+       {
+               return false;
+       }
+
+       return __pAccountProviderImpl->Equals(*pAccountProvider->__pAccountProviderImpl);
+}
+
+int
+AccountProvider::GetHashCode(void) const
+{
+       return __pAccountProviderImpl->GetHashCode();
+}
+
+AppId
+AccountProvider::GetAppId(void) const
+{
+       return __pAccountProviderImpl->GetAppId();
+}
+
+IList*
+AccountProvider::GetCapabilitiesN(void) const
+{
+       return __pAccountProviderImpl->GetCapabilitiesN();
+}
+
+String
+AccountProvider::GetDisplayName(void) const
+{
+       return __pAccountProviderImpl->GetDisplayName();
+}
+
+String
+AccountProvider::GetIconPath(void) const
+{
+       return __pAccountProviderImpl->GetIconPath();
+}
+
+String
+AccountProvider::GetSmallIconPath(void) const
+{
+       return __pAccountProviderImpl->GetSmallIconPath();
+}
+
+bool
+AccountProvider::IsMultipleAccountSupported(void) const
+{
+       return __pAccountProviderImpl->IsMultipleAccountSupported();
+}
+
+}} //Tizen::Social
diff --git a/src/FSclAddress.cpp b/src/FSclAddress.cpp
new file mode 100644 (file)
index 0000000..ba9201a
--- /dev/null
@@ -0,0 +1,341 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclAddress.cpp
+ * @brief              This is the implementation for Address class.
+ *
+ * This file contains definitions of @e Address class.
+ */
+
+#include <FBaseString.h>
+#include <FSclAddress.h>
+#include <FApp_AppInfo.h>
+#include <FBaseSysLog.h>
+#include "FScl_AddressImpl.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+static const int _MAX_ADDR_COUNTRY_LENGTH_2_0 = 100;
+
+Address::Address(void)
+{
+       __pAddressImpl = new (std::nothrow) _AddressImpl();
+       SysTryReturnVoidResult(NID_SCL, __pAddressImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+Address::Address(const Address& rhs)
+{
+       __pAddressImpl = new (std::nothrow) _AddressImpl(*rhs.__pAddressImpl);
+       SysTryReturnVoidResult(NID_SCL, __pAddressImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+}
+
+Address::~Address(void)
+{
+       delete __pAddressImpl;
+}
+
+Address&
+Address::operator =(const Address& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pAddressImpl = *rhs.__pAddressImpl;
+
+       return *this;
+}
+
+bool
+Address::operator ==(const Address& rhs) const
+{
+       return *__pAddressImpl == *rhs.__pAddressImpl;
+}
+
+bool
+Address::operator !=(const Address& rhs) const
+{
+       return !(*this == rhs);
+}
+
+bool
+Address::Equals(const Object& rhs) const
+{
+       const Address* pAddress = dynamic_cast<const Address*>(&rhs);
+
+       if (pAddress == null)
+       {
+               return false;
+       }
+
+       return __pAddressImpl->Equals(*pAddress->__pAddressImpl);
+}
+
+int
+Address::GetHashCode(void) const
+{
+       return __pAddressImpl->GetHashCode();
+}
+
+AddressType
+Address::GetType(void) const
+{
+       AddressType type =  __pAddressImpl->GetType();
+
+       if (type == ADDRESS_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
+       {
+               type =  ADDRESS_TYPE_OTHER;
+       }
+
+       return type;
+}
+
+String
+Address::GetExtended(void) const
+{
+       String extended =  __pAddressImpl->GetExtended();
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if (extended.GetLength() > MAX_ADDR_EXTENDED_LENGTH)
+               {
+                       extended.SetLength(MAX_ADDR_EXTENDED_LENGTH);
+               }
+       }
+
+       return extended;
+}
+
+String
+Address::GetStreet(void) const
+{
+       String street =  __pAddressImpl->GetStreet();
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if (street.GetLength() > MAX_ADDR_STREET_LENGTH)
+               {
+                       street.SetLength(MAX_ADDR_STREET_LENGTH);
+               }
+       }
+
+       return street;
+}
+
+String
+Address::GetCity(void) const
+{
+       String city =  __pAddressImpl->GetCity();
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if (city.GetLength() > MAX_ADDR_CITY_LENGTH)
+               {
+                       city.SetLength(MAX_ADDR_CITY_LENGTH);
+               }
+       }
+
+       return city;
+}
+
+String
+Address::GetState(void) const
+{
+       String state =  __pAddressImpl->GetState();
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if (state.GetLength() > MAX_ADDR_STATE_LENGTH)
+               {
+                       state.SetLength(MAX_ADDR_STATE_LENGTH);
+               }
+       }
+
+       return state;
+}
+
+String
+Address::GetPostalCode(void) const
+{
+       String postalCode =  __pAddressImpl->GetPostalCode();
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if (postalCode.GetLength() > MAX_ADDR_POSTAL_CODE_LENGTH)
+               {
+                       postalCode.SetLength(MAX_ADDR_POSTAL_CODE_LENGTH);
+               }
+       }
+
+       return postalCode;
+}
+
+String
+Address::GetCountry(void) const
+{
+       String country =  __pAddressImpl->GetCountry();
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if (country.GetLength() > _MAX_ADDR_COUNTRY_LENGTH_2_0)
+               {
+                       country.SetLength(_MAX_ADDR_COUNTRY_LENGTH_2_0);
+               }
+       }
+
+       return country;
+}
+
+String
+Address::GetPostOfficeBoxNumber(void) const
+{
+       String postOfficeBoxNumber = __pAddressImpl->GetPostOfficeBoxNumber();
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if (postOfficeBoxNumber.GetLength() > MAX_ADDR_POBOXNUM_LENGTH)
+               {
+                       postOfficeBoxNumber.SetLength(MAX_ADDR_POBOXNUM_LENGTH);
+               }
+       }
+
+       return postOfficeBoxNumber;
+}
+
+void
+Address::SetType(AddressType type)
+{
+       return __pAddressImpl->SetType(type);
+}
+
+result
+Address::SetExtended(const String& extended)
+{
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               SysTryReturn(NID_SCL, extended.GetLength() <= MAX_ADDR_EXTENDED_LENGTH,
+                               E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The length of the value exceeds MAX_ADDR_EXTENDED_LENGTH.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       __pAddressImpl->SetExtended(extended);
+
+       return E_SUCCESS;
+}
+
+result
+Address::SetStreet(const String& street)
+{
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               SysTryReturn(NID_SCL, street.GetLength() <= MAX_ADDR_STREET_LENGTH,
+                               E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The length of the value exceeds MAX_ADDR_STREET_LENGTH.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       __pAddressImpl->SetStreet(street);
+
+       return E_SUCCESS;
+}
+
+result
+Address::SetCity(const String& city)
+{
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               SysTryReturn(NID_SCL, city.GetLength() <= MAX_ADDR_CITY_LENGTH,
+                               E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The length of the value exceeds MAX_ADDR_CITY_LENGTH.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       __pAddressImpl->SetCity(city);
+
+       return E_SUCCESS;
+}
+
+result
+Address::SetState(const String& state)
+{
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               SysTryReturn(NID_SCL, state.GetLength() <= MAX_ADDR_STATE_LENGTH,
+                               E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The length of the value exceeds MAX_ADDR_STATE_LENGTH.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       __pAddressImpl->SetState(state);
+
+       return E_SUCCESS;
+}
+
+result
+Address::SetPostalCode(const String& postalCode)
+{
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               SysTryReturn(NID_SCL, postalCode.GetLength() <= MAX_ADDR_POSTAL_CODE_LENGTH,
+                               E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The length of the value exceeds MAX_ADDR_POSTAL_CODE_LENGTH.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       __pAddressImpl->SetPostalCode(postalCode);
+
+       return E_SUCCESS;
+}
+
+result
+Address::SetCountry(const String& country)
+{
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               SysTryReturn(NID_SCL, country.GetLength() <= _MAX_ADDR_COUNTRY_LENGTH_2_0,
+                               E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The length of country exceeds the maximum length.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       __pAddressImpl->SetCountry(country);
+
+       return E_SUCCESS;
+}
+
+result
+Address::SetPostOfficeBoxNumber(const String& postOfficeBoxNumber)
+{
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               SysTryReturn(NID_SCL, postOfficeBoxNumber.GetLength() <= MAX_ADDR_POBOXNUM_LENGTH,
+                               E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The length of the value exceeds MAX_ADDR_POBOXNUM_LENGTH.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       __pAddressImpl->SetPostOfficeBoxNumber(postOfficeBoxNumber);
+
+       return E_SUCCESS;
+}
+
+String
+Address::GetLabel(void) const
+{
+       return __pAddressImpl->GetLabel();
+}
+
+void
+Address::SetLabel(const String& label)
+{
+       __pAddressImpl->SetLabel(label);
+}
+
+
+}} //Tizen::Social
diff --git a/src/FSclAddressbook.cpp b/src/FSclAddressbook.cpp
new file mode 100644 (file)
index 0000000..de65c7a
--- /dev/null
@@ -0,0 +1,652 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclAddressbook.cpp
+ * @brief              This is the implementation for Addressbook class.
+ *
+ * This file contains definitions of @e Addressbook class.
+ */
+
+#include <new>
+#include <FBaseColIList.h>
+#include <FBaseResult.h>
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include <FSclAddressbook.h>
+#include <FSclCategory.h>
+#include <FSclContact.h>
+#include <FSclUserProfile.h>
+#include <FSec_AccessController.h>
+#include "FScl_AddressbookImpl.h"
+#include "FScl_CategoryImpl.h"
+#include "FScl_ContactImpl.h"
+#include "FScl_RecordImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Social
+{
+
+Addressbook::Addressbook(void)
+       : __pAddressbookImpl(null)
+{
+       //empty body
+}
+
+Addressbook::~Addressbook(void)
+{
+       delete __pAddressbookImpl;
+}
+
+result
+Addressbook::Construct(IRecordEventListener* pListener)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAddressbookImpl == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       __pAddressbookImpl = new (std::nothrow) _AddressbookImpl();
+       SysTryReturn(NID_SCL, __pAddressbookImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = __pAddressbookImpl->Construct();
+       SysTryCatch(NID_SCL, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       if (pListener != null)
+       {
+               r = __pAddressbookImpl->SetRecordEventListener(pListener);
+               SysTryCatch(NID_SCL, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       return E_SUCCESS;
+
+CATCH:
+       delete __pAddressbookImpl;
+       __pAddressbookImpl = null;
+
+       return r;
+}
+
+result
+Addressbook::SetEventListener(IAddressbookEventListener* pListener)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookImpl->SetAddressbookEventListener(pListener);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Addressbook::SetAddressbookChangeEventListener(IAddressbookChangeEventListener* pListener)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookImpl->SetAddressbookChangeEventListener(pListener);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+String
+Addressbook::GetName(void) const
+{
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       return __pAddressbookImpl->GetName();
+}
+
+AddressbookId
+Addressbook::GetId(void) const
+{
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       return __pAddressbookImpl->GetId();
+}
+
+AccountId
+Addressbook::GetAccountId(void) const
+{
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       return __pAddressbookImpl->GetAccountId();
+}
+
+result
+Addressbook::AddContact(Contact& contact)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookImpl->AddContact(contact);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Addressbook::AddCategory(Category& category)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookImpl->AddCategory(category);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Addressbook::RemoveContact(Contact& contact)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookImpl->RemoveContact(contact);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Addressbook::RemoveContact(RecordId contactId)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookImpl->RemoveContact(contactId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Addressbook::RemoveCategory(Category& category)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookImpl->RemoveCategory(category.GetRecordId());
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _CategoryImpl::GetInstance(category)->Invalidate();
+       _RecordImpl::GetInstance(category)->SetRecordId(INVALID_RECORD_ID);
+
+       return E_SUCCESS;
+}
+
+result
+Addressbook::RemoveCategory(RecordId categoryId)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookImpl->RemoveCategory(categoryId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Addressbook::UpdateContact(const Contact& contact)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookImpl->UpdateContact(contact);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Addressbook::UpdateCategory(const Category& category)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookImpl->UpdateCategory(category);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+IList*
+Addressbook::GetAllContactsN(void) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookImpl->GetAllContactsN();
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+IList*
+Addressbook::GetContactsByCategoryN(RecordId categoryId) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookImpl->GetContactsByCategoryN(categoryId);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+result
+Addressbook::AddMemberToCategory(RecordId categoryId, RecordId contactId)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookImpl->AddMemberToCategory(categoryId, contactId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Addressbook::RemoveMemberFromCategory(RecordId categoryId, RecordId contactId)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookImpl->RemoveMemberFromCategory(categoryId, contactId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+IList*
+Addressbook::GetAllCategoriesN(void) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookImpl->GetAllCategoriesN();
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+IList*
+Addressbook::GetCategoriesByContactN(RecordId contactId) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookImpl->GetCategoriesByContactN(contactId);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+IList*
+Addressbook::GetContactsN(int pageNo, int countPerPage) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookImpl->GetContactsN(pageNo, countPerPage);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+IList*
+Addressbook::GetContactsInN(const Category& category, int pageNo, int countPerPage) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookImpl->GetContactsInN(category, pageNo, countPerPage);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+IList*
+Addressbook::SearchContactsByEmailN(const String& email) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookImpl->SearchContactsByEmailN(email);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+IList*
+Addressbook::SearchContactsByNameN(const String& name) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookImpl->SearchContactsByNameN(name);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+IList*
+Addressbook::SearchContactsByPhoneNumberN(const String& phoneNumber) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookImpl->SearchContactsByPhoneNumberN(phoneNumber);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+int
+Addressbook::GetCategoryCount(void) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, -1, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       int count = __pAddressbookImpl->GetCategoryCount();
+       SysTryReturn(NID_SCL, count != -1, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return count;
+}
+
+int
+Addressbook::GetContactCount(void) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, -1, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       int count = __pAddressbookImpl->GetContactCount();
+       SysTryReturn(NID_SCL, count != -1, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return count;
+}
+
+Contact*
+Addressbook::GetContactN(RecordId contactId) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       Contact* pContact = __pAddressbookImpl->GetContactN(contactId);
+       SysTryReturn(NID_SCL, pContact != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pContact;
+}
+
+Category*
+Addressbook::GetCategoryN(RecordId categoryId) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       Category* pCategory = __pAddressbookImpl->GetCategoryN(categoryId);
+       SysTryReturn(NID_SCL, pCategory != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pCategory;
+}
+
+int
+Addressbook::GetLatestVersion(void) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, -1, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       int latestVersion = __pAddressbookImpl->GetLatestVersion();
+       SysTryReturn(NID_SCL, latestVersion != -1, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return latestVersion;
+}
+
+IList*
+Addressbook::GetChangedContactsAfterN(int version, int& latestVersion) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookImpl->GetChangedContactsAfterN(version, latestVersion);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+IList*
+Addressbook::GetChangedCategoriesAfterN(int version, int& latestVersion) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookImpl->GetChangedCategoriesAfterN(version, latestVersion);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+IList*
+Addressbook::GetChangedContactInfoListN(int version, int& latestVersion) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookImpl->GetChangedContactInfoListN(version, latestVersion);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+IList*
+Addressbook::GetChangedCategoryInfoListN(int version, int& latestVersion) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookImpl->GetChangedCategoryInfoListN(version, latestVersion);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+result
+Addressbook::AddContacts(const IList& contactList, IListT<RecordId>* pContactIdList)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookImpl->AddContacts(contactList, pContactIdList);
+
+       return r;
+}
+
+result
+Addressbook::UpdateContacts(const IList& contactList)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookImpl->UpdateContacts(contactList);
+
+       return r;
+}
+
+result
+Addressbook::RemoveContacts(const IListT<RecordId>& contactIdList)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookImpl->RemoveContacts(contactIdList);
+
+       return r;
+}
+
+result
+Addressbook::SetUserProfile(const UserProfile* pUserProfile)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_USERPROFILE_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookImpl->SetUserProfile(pUserProfile);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+UserProfile*
+Addressbook::GetUserProfileN(void) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_USERPROFILE_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       UserProfile* pProfile = __pAddressbookImpl->GetUserProfileN();
+       SysTryReturn(NID_SCL, pProfile != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pProfile;
+}
+
+bool
+Addressbook::IsUserProfileChangedAfter(int version) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_USERPROFILE_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, false, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       bool isChanged = __pAddressbookImpl->IsUserProfileChangedAfter(version);
+       SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return isChanged;
+}
+
+}}  // Tizen::Social
diff --git a/src/FSclAddressbookFilter.cpp b/src/FSclAddressbookFilter.cpp
new file mode 100644 (file)
index 0000000..b73e4e9
--- /dev/null
@@ -0,0 +1,87 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FSclAddressbookFilter.cpp
+* @brief       This is the implementation for AddressbookFilter class.
+*
+* This file contains definitions of @e AddressbookFilter class.
+*/
+
+#include <FSclAddressbookFilter.h>
+#include <FBaseSysLog.h>
+#include "FScl_AddressbookFilterImpl.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+AddressbookFilter::AddressbookFilter(AddressbookFilterType type)
+{
+       _AddressbookFilterImpl* pAddressbookFilterImpl = new (std::nothrow) _AddressbookFilterImpl(type);
+       SysTryReturnVoidResult(NID_SCL, pAddressbookFilterImpl, E_OUT_OF_MEMORY, "[%s ] Memory allocation failed.", GetErrorMessage(GetLastResult()));
+
+       __pAddressbookFilterImpl = pAddressbookFilterImpl;
+}
+
+AddressbookFilter::~AddressbookFilter(void)
+{
+       delete __pAddressbookFilterImpl;
+}
+
+bool
+AddressbookFilter::Equals(const Tizen::Base::Object& rhs) const
+{
+       const AddressbookFilter* pAddressbookFilter = dynamic_cast<const AddressbookFilter*>(&rhs);
+       if (pAddressbookFilter == null)
+       {
+               return false;
+       }
+
+       return __pAddressbookFilterImpl->Equals(*pAddressbookFilter->__pAddressbookFilterImpl);
+}
+
+int
+AddressbookFilter::GetHashCode(void) const
+{
+       return __pAddressbookFilterImpl->GetHashCode();
+}
+
+result
+AddressbookFilter::AppendInt(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, int value)
+{
+       return __pAddressbookFilterImpl->AppendInt(conjunctiveOperator, filterProperty, comparisonOperator, value);
+}
+
+result
+AddressbookFilter::AppendBool(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, bool value)
+{
+       return __pAddressbookFilterImpl->AppendBool(conjunctiveOperator, filterProperty, comparisonOperator, value);
+}
+
+result
+AddressbookFilter::AppendString(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterStringOperator comparisonOperator, const Tizen::Base::String& value)
+{
+       return __pAddressbookFilterImpl->AppendString(conjunctiveOperator, filterProperty, comparisonOperator, value);
+}
+
+result
+AddressbookFilter::AppendFilter(FilterConjunctiveOperator conjunctiveOperator, const AddressbookFilter& filter)
+{
+       return __pAddressbookFilterImpl->AppendFilter(conjunctiveOperator, *filter.__pAddressbookFilterImpl);;
+}
+
+}} // Tizen::Social
diff --git a/src/FSclAddressbookManager.cpp b/src/FSclAddressbookManager.cpp
new file mode 100644 (file)
index 0000000..f94812d
--- /dev/null
@@ -0,0 +1,873 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclAddressbookManager.cpp
+ * @brief              This is the implementation for AddressbookManager class.
+ *
+ * This file contains definitions of @e AddressbookManager class.
+ */
+
+#include <unique_ptr.h>
+#include <pthread.h>
+#include <FBaseResult.h>
+#include <FBaseString.h>
+#include <FBaseColIList.h>
+#include <FBaseSysLog.h>
+#include <FSclContact.h>
+#include <FSclCategory.h>
+#include <FSclUserProfile.h>
+#include <FSclAddressbookManager.h>
+#include <FSec_AccessController.h>
+#include <FScl_AddressbookManagerImpl.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Social
+{
+
+AddressbookManager* AddressbookManager::__pInstance = null;
+
+AddressbookManager::AddressbookManager(void)
+       : __pAddressbookManagerImpl(null)
+{
+       //empty body
+}
+
+AddressbookManager::~AddressbookManager(void)
+{
+       delete __pAddressbookManagerImpl;
+}
+
+result
+AddressbookManager::Construct(void)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAddressbookManagerImpl == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       _AddressbookManagerImpl* pAddressbookManagerImpl = new (std::nothrow) _AddressbookManagerImpl();
+       SysTryReturnResult(NID_SCL, pAddressbookManagerImpl != null, E_OUT_OF_MEMORY, "Not enough memory.");
+
+       r = pAddressbookManagerImpl->Construct();
+       SysTryCatch(NID_SCL, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pAddressbookManagerImpl = pAddressbookManagerImpl;
+
+       return E_SUCCESS;
+
+CATCH:
+       delete pAddressbookManagerImpl;
+
+       return r;
+}
+
+result
+AddressbookManager::SetEventListener(IAddressbookEventListener* pListener)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookManagerImpl->SetEventListener(pListener);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+AddressbookManager::SetAddressbookChangeEventListener(IAddressbookChangeEventListener* pListener)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookManagerImpl->SetAddressbookChangeEventListener(pListener);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+Addressbook*
+AddressbookManager::CreateAddressbookN(AccountId accountId, const String& name)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       Addressbook* pAddressbook = __pAddressbookManagerImpl->CreateAddressbookN(accountId, name);
+       SysTryReturn(NID_SCL, pAddressbook != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pAddressbook;
+}
+
+result
+AddressbookManager::DeleteAddressbook(AddressbookId addressbookId)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookManagerImpl->DeleteAddressbook(addressbookId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+IList*
+AddressbookManager::GetAddressbooksByAccountN(AccountId accountId) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList*  pList = __pAddressbookManagerImpl->GetAddressbooksByAccountN(accountId);
+       SysTryReturn(NID_SCL, pList !=null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+IList*
+AddressbookManager::GetAllAddressbooksN(void) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookManagerImpl->GetAllAddressbooksN();
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+Addressbook*
+AddressbookManager::GetAddressbookN(AddressbookId addressbookId) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       Addressbook* pAddressbook = __pAddressbookManagerImpl->GetAddressbookN(addressbookId);
+       SysTryReturn(NID_SCL, pAddressbook != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pAddressbook;
+}
+
+result
+AddressbookManager::AddContact(Contact& contact, AddressbookId addressbookId)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookManagerImpl->AddContact(contact, addressbookId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+AddressbookManager::AddCategory(Category& category, AddressbookId addressbookId)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookManagerImpl->AddCategory(category, addressbookId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+AddressbookManager::RemoveContact(RecordId contactId)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookManagerImpl->RemoveContact(contactId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+AddressbookManager::RemoveCategory(RecordId categoryId)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookManagerImpl->RemoveCategory(categoryId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+AddressbookManager::UpdateContact(const Contact& contact)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookManagerImpl->UpdateContact(contact);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+AddressbookManager::UpdateCategory(const Category& category)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookManagerImpl->UpdateCategory(category);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+IList*
+AddressbookManager::GetAllContactsN(void) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookManagerImpl->GetAllContactsN();
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+IList*
+AddressbookManager::GetContactsByCategoryN(RecordId categoryId) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookManagerImpl->GetContactsByCategoryN(categoryId);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+IList*
+AddressbookManager::GetContactsByPersonN(PersonId personId) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookManagerImpl->GetContactsByPersonN(personId);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+result
+AddressbookManager::AddMemberToCategory(RecordId categoryId, RecordId contactId)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookManagerImpl->AddMemberToCategory(categoryId, contactId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+AddressbookManager::RemoveMemberFromCategory(RecordId categoryId, RecordId contactId)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookManagerImpl->RemoveMemberFromCategory(categoryId, contactId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+IList*
+AddressbookManager::GetAllCategoriesN(void) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookManagerImpl->GetAllCategoriesN();
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+IList*
+AddressbookManager::GetCategoriesByContactN(RecordId contactId) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookManagerImpl->GetCategoriesByContactN(contactId);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+IList*
+AddressbookManager::GetCategoriesByPersonN(PersonId personId) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookManagerImpl->GetCategoriesByPersonN(personId);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+IList*
+AddressbookManager::SearchContactsByEmailN(const String& email) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookManagerImpl->SearchContactsByEmailN(email);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+IList*
+AddressbookManager::SearchContactsByNameN(const String& name) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookManagerImpl->SearchContactsByNameN(name);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+IList*
+AddressbookManager::SearchContactsByPhoneNumberN(const String& phoneNumber) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookManagerImpl->SearchContactsByPhoneNumberN(phoneNumber);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+int
+AddressbookManager::GetCategoryCount(void) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, -1, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       int count = __pAddressbookManagerImpl->GetCategoryCount();
+       SysTryReturn(NID_SCL, count != -1, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return count;
+}
+
+int
+AddressbookManager::GetContactCount(void) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, -1, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       int count = __pAddressbookManagerImpl->GetContactCount();
+       SysTryReturn(NID_SCL, count != -1, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return count;
+}
+
+Contact*
+AddressbookManager::GetContactN(RecordId contactId) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       Contact* pContact = __pAddressbookManagerImpl->GetContactN(contactId);
+       SysTryReturn(NID_SCL, pContact != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pContact;
+}
+
+Person*
+AddressbookManager::GetPersonN(PersonId personId) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       Person* pPerson = __pAddressbookManagerImpl->GetPersonN(personId);
+       SysTryReturn(NID_SCL, pPerson != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pPerson;
+}
+Category*
+AddressbookManager::GetCategoryN(RecordId categoryId) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       Category* pCategory = __pAddressbookManagerImpl->GetCategoryN(categoryId);
+       SysTryReturn(NID_SCL, pCategory != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pCategory;
+}
+
+int
+AddressbookManager::GetLatestVersion(void) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, -1, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       int latestVersion = __pAddressbookManagerImpl->GetLatestVersion();
+       SysTryReturn(NID_SCL, latestVersion != -1, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return latestVersion;
+}
+
+IList*
+AddressbookManager::GetChangedContactsAfterN(int version, int& latestVersion) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookManagerImpl->GetChangedContactsAfterN(version, latestVersion);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+IList*
+AddressbookManager::GetChangedCategoriesAfterN(int version, int& latestVersion) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pAddressbookManagerImpl->GetChangedCategoriesAfterN(version, latestVersion);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+result
+AddressbookManager::RemovePerson(PersonId personId)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       return __pAddressbookManagerImpl->RemovePerson(personId);
+}
+
+result
+AddressbookManager::SetPersonAsFavorite(PersonId personId, bool isFavorite)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       return __pAddressbookManagerImpl->SetPersonAsFavorite(personId, isFavorite);
+}
+
+IList*
+AddressbookManager::GetAllPersonsN(void) const
+{      
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       return __pAddressbookManagerImpl->GetAllPersonsN();
+}
+
+IList*
+AddressbookManager::GetPersonsByCategoryN(RecordId categoryId) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       return __pAddressbookManagerImpl->GetPersonsByCategoryN(categoryId);
+}
+
+IList*
+AddressbookManager::GetFavoritePersonsN() const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       return __pAddressbookManagerImpl->GetFavoritePersonsN();
+}
+
+IList*
+AddressbookManager::SearchPersonsN(const Tizen::Base::String& keyword) const
+{      
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       return __pAddressbookManagerImpl->SearchPersonsN(keyword);
+}
+
+result
+AddressbookManager::MergePersons(PersonId sourcePersonId, PersonId targetPersonId)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookManagerImpl->MergePersons(sourcePersonId, targetPersonId);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return E_SUCCESS;
+}
+
+result
+AddressbookManager::UnlinkContact(PersonId personId, RecordId contactId, PersonId& newPersonId)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pAddressbookManagerImpl->UnlinkContact(personId, contactId, newPersonId);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return E_SUCCESS;
+}
+
+IList*
+AddressbookManager::SearchN(const AddressbookFilter& filter, 
+                       unsigned long propertyToSort, Tizen::Base::SortOrder sortOrder, int offset, int maxCount)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       return __pAddressbookManagerImpl->SearchN(filter, propertyToSort, sortOrder, offset, maxCount);
+}
+
+int
+AddressbookManager::GetMatchedItemCount(const AddressbookFilter& filter)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, -1, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       return __pAddressbookManagerImpl->GetMatchedItemCount(filter);
+}
+
+IList*
+AddressbookManager::ParseContactsFromVcardN(const Tizen::Base::String& vcardPath)
+{
+       return __pAddressbookManagerImpl->ParseContactsFromVcardN(vcardPath);
+}
+
+result
+AddressbookManager::ExportPersonToVcard(const Person& person, const Tizen::Base::String& vcardPath)
+{      
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       return __pAddressbookManagerImpl->ExportPersonToVcard(person, vcardPath);
+}
+
+result
+AddressbookManager::ExportPersonsToVcard(const Tizen::Base::Collection::IList& personList, const Tizen::Base::String& vcardPath)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       return __pAddressbookManagerImpl->ExportPersonsToVcard(personList, vcardPath);
+}
+
+result
+AddressbookManager::ExportContactToVcard(const Contact& contact, const Tizen::Base::String& vcardPath)
+{
+       return __pAddressbookManagerImpl->ExportContactToVcard(contact, vcardPath);
+}
+
+result
+AddressbookManager::ExportContactsToVcard(const Tizen::Base::Collection::IList& contactList, const Tizen::Base::String& vcardPath)
+{
+       return __pAddressbookManagerImpl->ExportContactsToVcard(contactList, vcardPath);
+}
+
+ByteBuffer*
+AddressbookManager::ExportContactToVcardStreamN(const Contact& contact)
+{
+       return __pAddressbookManagerImpl->ExportContactToVcardStreamN(contact);
+}
+
+ByteBuffer*
+AddressbookManager::ExportContactsToVcardStreamN(const Tizen::Base::Collection::IList& contactList)
+{
+       return __pAddressbookManagerImpl->ExportContactsToVcardStreamN(contactList);
+}
+
+ByteBuffer*
+AddressbookManager::ExportPersonToVcardStreamN(const Person& person)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       return __pAddressbookManagerImpl->ExportPersonToVcardStreamN(person);
+}
+
+ByteBuffer*
+AddressbookManager::ExportPersonsToVcardStreamN(const Tizen::Base::Collection::IList& personList)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       return __pAddressbookManagerImpl->ExportPersonsToVcardStreamN(personList);
+}
+
+IList*
+AddressbookManager::ParseVcardStreamN(const Tizen::Base::ByteBuffer& vcardStream)
+{
+       return __pAddressbookManagerImpl->ParseVcardStreamN(vcardStream);
+}
+
+Tizen::Base::ByteBuffer*
+AddressbookManager::ExportUserProfileToVcardStreamN(const UserProfile& userProfile)
+{
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       return __pAddressbookManagerImpl->ExportUserProfileToVcardStreamN(userProfile);
+}
+
+Tizen::Base::ByteBuffer*
+AddressbookManager::ExportUserProfilesToVcardStreamN(const Tizen::Base::Collection::IList& userProfileList)
+{
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       return __pAddressbookManagerImpl->ExportUserProfilesToVcardStreamN(userProfileList);
+}
+
+result
+AddressbookManager::ExportUserProfileToVcard(const UserProfile& userProfile, const Tizen::Base::String& vcardPath)
+{
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       return __pAddressbookManagerImpl->ExportUserProfileToVcard(userProfile, vcardPath);
+}
+
+result
+AddressbookManager::ExportUserProfilesToVcard(const Tizen::Base::Collection::IList& userProfileList, const Tizen::Base::String& vcardPath)
+{
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       return __pAddressbookManagerImpl->ExportUserProfilesToVcard(userProfileList, vcardPath);
+}
+
+Tizen::Base::Collection::IList*
+AddressbookManager::GetAllUserProfilesN(void) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_USERPROFILE_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       return __pAddressbookManagerImpl->GetAllUserProfilesN();
+}
+
+UserProfile*
+AddressbookManager::GetUserProfileN(AddressbookId addressbookId) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_USERPROFILE_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pAddressbookManagerImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       return __pAddressbookManagerImpl->GetUserProfileN(addressbookId);
+}
+
+AddressbookManager*
+AddressbookManager::GetInstance(void)
+{
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+       if (__pInstance == null)
+       {
+               ClearLastResult();
+
+               pthread_once(&onceBlock, InitAddressbookManager);
+
+               result r = GetLastResult();
+
+               if (IsFailed(r))
+               {
+                       onceBlock = PTHREAD_ONCE_INIT;
+               }
+       }
+
+       return __pInstance;
+}
+
+void
+AddressbookManager::InitAddressbookManager(void)
+{
+       std::unique_ptr<AddressbookManager> pInstance(new (std::nothrow) AddressbookManager());
+       SysTryReturnVoidResult(NID_SCL, pInstance, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pInstance->Construct();
+       SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pInstance = pInstance.release();
+
+       std::atexit(DestroyAddressbookManager);
+}
+
+void
+AddressbookManager::DestroyAddressbookManager(void)
+{
+       delete __pInstance;
+       __pInstance = null;
+}
+
+}}  // Tizen::Social
diff --git a/src/FSclAttendee.cpp b/src/FSclAttendee.cpp
new file mode 100644 (file)
index 0000000..506ebf8
--- /dev/null
@@ -0,0 +1,249 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclAttendee.cpp
+ * @brief              This is the implementation for Attendee class.
+ *
+ * This file contains definitions of @e Attendee class.
+ */
+
+#include <FSclAttendee.h>
+#include <FBaseResult.h>
+#include <FBaseSysLog.h>
+#include <FApp_AppInfo.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::App;
+
+namespace Tizen { namespace Social
+{
+
+Attendee::Attendee(const String& email)
+       : __email(email)
+       , __attendeeRole(ATTENDEE_ROLE_ATTENDEE)
+       , __attendeeStatus(ATTENDEE_STATUS_NONE)
+       , __personId(INVALID_RECORD_ID)
+       , __pAttendeeImpl(null)
+{
+       // empty body.
+}
+
+Attendee::Attendee(const Attendee& rhs)
+       : __name(rhs.__name)
+       , __email(rhs.__email)
+       , __phoneNumber(rhs.__phoneNumber)
+       , __attendeeRole(rhs.__attendeeRole)
+       , __attendeeStatus(rhs.__attendeeStatus)
+       , __personId(rhs.__personId)
+       , __pAttendeeImpl(null)
+{
+       // empty body.
+}
+
+Attendee::~Attendee(void)
+{
+       // empty body.
+}
+
+Attendee&
+Attendee::operator =(const Attendee& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __name = rhs.__name;
+       __email = rhs.__email;
+       __phoneNumber = rhs.__phoneNumber;
+       __attendeeRole = rhs.__attendeeRole;
+       __attendeeStatus = rhs.__attendeeStatus;
+       __personId = rhs.__personId;
+
+       return *this;
+}
+
+bool
+Attendee::operator ==(const Attendee& rhs) const
+{
+       if ((__name == rhs.__name) &&
+                       (__email == rhs.__email) &&
+                       (__phoneNumber == rhs.__phoneNumber) &&
+                       (__attendeeRole == rhs.__attendeeRole) &&
+                       (__attendeeStatus == rhs.__attendeeStatus) &&
+                       (__personId == rhs.__personId))
+       {
+               return true;
+       }
+
+       return false;
+}
+
+bool
+Attendee::operator !=(const Attendee& rhs) const
+{
+       return !(*this == rhs);
+}
+
+bool
+Attendee::Equals(const Object& rhs) const
+{
+       const Attendee* pAttendee = dynamic_cast<const Attendee*>(&rhs);
+
+       if (pAttendee == null)
+       {
+               return false;
+       }
+
+       return (*this == *pAttendee);
+}
+
+int
+Attendee::GetHashCode(void) const
+{
+       int hashCode = 17;
+
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __name.GetHashCode();
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __email.GetHashCode();
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __phoneNumber.GetHashCode();
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __attendeeRole;
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __attendeeStatus;
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __personId;
+
+       return hashCode;
+}
+
+String
+Attendee::GetName(void) const
+{
+       return __name;
+}
+
+String
+Attendee::GetEmail(void) const
+{
+       return __email;
+}
+
+AttendeeRole
+Attendee::GetRole(void) const
+{
+       return __attendeeRole;
+}
+
+AttendeeStatus
+Attendee::GetStatus(void) const
+{
+       return __attendeeStatus;
+}
+
+result
+Attendee::SetName(const String& name)
+{
+       SysTryReturnResult(NID_SCL, !name.IsEmpty(), E_INVALID_ARG, "Invalid argument is used. The name is empty.");
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               SysTryReturnResult(NID_SCL, name.GetLength() <= MAX_ATTENDEE_NAME_LENGTH,
+                           E_INVALID_ARG, "Invalid argument is used. The length of the name exceeds MAX_ATTENDEE_NAME_LENGTH.");
+       }
+
+       __name = name;
+
+       return E_SUCCESS;
+}
+
+result
+Attendee::SetEmail(const String& email)
+{
+       SysTryReturnResult(NID_SCL, !email.IsEmpty(), E_INVALID_ARG, "Invalid argument is used. The email is empty.");
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               SysTryReturnResult(NID_SCL, email.GetLength() <= MAX_ATTENDEE_EMAIL_LENGTH,
+                                       E_INVALID_ARG, "Invalid argument is used. The length of the email exceeds MAX_ATTENDEE_EMAIL_LENGTH.");
+       }
+
+       __email = email;
+
+       return E_SUCCESS;
+}
+
+void
+Attendee::SetRole(AttendeeRole role)
+{
+       switch (role)
+       {
+       case ATTENDEE_ROLE_ATTENDEE:
+               //fall through
+       case ATTENDEE_ROLE_REQUIRED_ATTENDEE:
+               //fall through
+       case ATTENDEE_ROLE_ORGANIZER:
+               __attendeeRole = role;
+               break;
+       default:
+               __attendeeRole = ATTENDEE_ROLE_ATTENDEE;
+               break;
+       }
+}
+
+void
+Attendee::SetStatus(AttendeeStatus status)
+{
+       switch (status)
+       {
+       case ATTENDEE_STATUS_NONE:
+               //fall through
+       case ATTENDEE_STATUS_NOT_RESPONDED:
+               //fall through
+       case ATTENDEE_STATUS_ACCEPTED:
+               //fall through
+       case ATTENDEE_STATUS_DECLINED:
+               //fall through
+       case ATTENDEE_STATUS_TENTATIVE:
+               __attendeeStatus = status;
+               break;
+       default:
+               __attendeeStatus = ATTENDEE_STATUS_NONE;
+               break;
+       }
+}
+
+void
+Attendee::SetPhoneNumber(const String& phoneNumber)
+{
+       __phoneNumber = phoneNumber;
+}
+
+String
+Attendee::GetPhoneNumber(void) const
+{
+       return __phoneNumber;
+}
+
+void
+Attendee::SetPersonId(PersonId personId)
+{
+       __personId = personId;
+}
+
+PersonId
+Attendee::GetPersonId(void) const
+{
+       return __personId;
+}
+
+}}     // Tizen::Social
diff --git a/src/FSclCalEvent.cpp b/src/FSclCalEvent.cpp
new file mode 100644 (file)
index 0000000..c62d9a0
--- /dev/null
@@ -0,0 +1,421 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclCalEvent.cpp
+ * @brief              This is the implementation for CalEvent class.
+ *
+ * This file contains definitions of @e CalEvent class.
+ */
+
+#include <new>
+#include <FSclCalEvent.h>
+#include <FBaseSysLog.h>
+#include "FScl_CalEventImpl.h"
+
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+CalEvent::CalEvent(void)
+       : Record(RECORD_TYPE_EVENT)
+       ,__pCalEventImpl(null)
+{
+       __pCalEventImpl = new (std::nothrow) _CalEventImpl();
+       SysTryReturnVoidResult(NID_SCL, __pCalEventImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+CalEvent::CalEvent(const CalEvent& rhs)
+       : Record(rhs)
+       ,__pCalEventImpl(null)
+{
+       __pCalEventImpl = new (std::nothrow) _CalEventImpl(*rhs.__pCalEventImpl);
+       SysTryReturnVoidResult(NID_SCL, __pCalEventImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+CalEvent::~CalEvent(void)
+{
+       delete __pCalEventImpl;
+}
+
+CalEvent&
+CalEvent::operator =(const CalEvent& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       Record::operator=(rhs);
+
+       *__pCalEventImpl = *rhs.__pCalEventImpl;
+
+       return *this;
+}
+
+bool
+CalEvent::Equals(const Object& rhs) const
+{
+       const CalEvent* pCalEvent = dynamic_cast<const CalEvent*>(&rhs);
+
+       if (pCalEvent == null)
+       {
+               return false;
+       }
+
+       return (Record::GetRecordId() == pCalEvent->GetRecordId());
+}
+
+int
+CalEvent::GetHashCode(void) const
+{
+       int hashCode = 17;
+
+       hashCode = static_cast<int>(( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ Record::GetRecordId());
+
+       return hashCode;
+}
+
+bool
+CalEvent::IsInstance(void) const
+{
+       return __pCalEventImpl->IsInstance();
+}
+
+bool
+CalEvent::IsRecurring(void) const
+{
+       return __pCalEventImpl->IsRecurring();
+}
+
+RecordId
+CalEvent::GetOriginalCalEventId(void)   const
+{
+       return __pCalEventImpl->GetOriginalCalEventId();
+}
+
+bool
+CalEvent::IsAllDayEvent(void)   const
+{
+       return __pCalEventImpl->IsAllDayEvent();
+}
+
+void
+CalEvent::SetAllDayEvent(bool isAllDayEvent)
+{
+       __pCalEventImpl->SetAllDayEvent(isAllDayEvent);
+}
+
+ByteBuffer*
+CalEvent::GetUIDN(void) const
+{
+       ByteBuffer* pByteBuffer = __pCalEventImpl->GetUIDN();
+       result r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pByteBuffer;
+}
+
+result
+CalEvent::SetUID(const ByteBuffer* pUID)
+{
+       result r = __pCalEventImpl->SetUID(pUID);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+Tizen::Base::String
+CalEvent::GetUid(void) const
+{
+       ClearLastResult();
+       return __pCalEventImpl->GetUid();
+}
+
+void
+CalEvent::SetUid(const Tizen::Base::String& uid)
+{
+       ClearLastResult();
+       __pCalEventImpl->SetUid(uid);
+}
+
+EventStatus
+CalEvent::GetStatus(void) const
+{
+       return __pCalEventImpl->GetStatus();
+}
+
+void
+CalEvent::SetStatus(EventStatus status)
+{
+       __pCalEventImpl->SetStatus(status);
+}
+
+BusyStatus
+CalEvent::GetBusyStatus(void) const
+{
+       return __pCalEventImpl->GetBusyStatus();
+}
+
+void
+CalEvent::SetBusyStatus(BusyStatus busyStatus)
+{
+       __pCalEventImpl->SetBusyStatus(busyStatus);
+}
+
+EventPriority
+CalEvent::GetPriority(void) const
+{
+       return __pCalEventImpl->GetPriority();
+}
+
+void
+CalEvent::SetPriority(EventPriority priority)
+{
+       __pCalEventImpl->SetPriority(priority);
+}
+
+result
+CalEvent::AddAttendee(const Attendee& attendee)
+{
+       result r = __pCalEventImpl->AddAttendee(attendee);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+CalEvent::RemoveAttendee(const Attendee& attendee)
+{
+       result r = __pCalEventImpl->RemoveAttendee(attendee);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+IList*
+CalEvent::GetAllAttendeesN(void) const
+{
+       IList* pList = __pCalEventImpl->GetAllAttendeesN();
+       result r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pList;
+}
+
+Tizen::Locales::TimeZone
+CalEvent::GetTimeZone(void) const
+{
+       return __pCalEventImpl->GetTimeZone();
+}
+
+result
+CalEvent::SetTimeZone(const Tizen::Locales::TimeZone& timeZone)
+{
+       return __pCalEventImpl->SetTimeZone(timeZone);
+}
+
+RecurrenceId
+CalEvent::GetRecurrenceId(void) const
+{
+       RecurrenceId recurrenceId = __pCalEventImpl->GetRecurrenceId();
+       result r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, DateTime(), r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return recurrenceId;
+}
+
+String
+CalEvent::GetSubject(void) const
+{
+       return __pCalEventImpl->GetSubject();
+}
+
+String
+CalEvent::GetDescription(void) const
+{
+       return __pCalEventImpl->GetDescription();
+}
+
+
+DateTime
+CalEvent::GetStartTime(void) const
+{
+       return __pCalEventImpl->GetStartTime();
+}
+
+DateTime
+CalEvent::GetEndTime(void) const
+{
+       return __pCalEventImpl->GetEndTime();
+}
+
+String
+CalEvent::GetLocation(void) const
+{
+       return __pCalEventImpl->GetLocation();
+}
+
+EventCategory
+CalEvent::GetCategory(void) const
+{
+       return __pCalEventImpl->GetCategory();
+}
+
+RecordSensitivity
+CalEvent::GetSensitivity(void) const
+{
+       return __pCalEventImpl->GetSensitivity();
+}
+
+
+const Reminder*
+CalEvent::GetReminder(void) const
+{
+       return __pCalEventImpl->GetReminder();
+}
+
+const Recurrence*
+CalEvent::GetRecurrence(void) const
+{
+       return __pCalEventImpl->GetRecurrence();
+}
+
+DateTime
+CalEvent::GetLastRevisedTime(void) const
+{
+       return __pCalEventImpl->GetLastRevisedTime();
+}
+
+result
+CalEvent::SetSubject(const String& subject)
+{
+       result r = __pCalEventImpl->SetSubject(subject);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+CalEvent::SetDescription(const String& description)
+{
+       result r = __pCalEventImpl->SetDescription(description);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+CalEvent::SetStartAndEndTime(const DateTime& start, const DateTime& end)
+{
+       result r = __pCalEventImpl->SetStartAndEndTime(start, end);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+CalEvent::SetLocation(const String& location)
+{
+       result r = __pCalEventImpl->SetLocation(location);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+void
+CalEvent::SetCategory(EventCategory category)
+{
+       __pCalEventImpl->SetCategory(category);
+}
+
+void
+CalEvent::SetSensitivity(RecordSensitivity sensitivity)
+{
+       __pCalEventImpl->SetSensitivity(sensitivity);
+}
+
+result
+CalEvent::SetCoordinates(double latitude, double longitude)
+{
+       result r = __pCalEventImpl->SetCoordinates(latitude, longitude);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+void
+CalEvent::GetCoordinates(double& latitude, double& longitude) const
+{
+       __pCalEventImpl->GetCoordinates(latitude, longitude);
+}
+
+result
+CalEvent::SetReminder(const Reminder* pReminder)
+{
+       result r = __pCalEventImpl->SetReminder(pReminder);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+CalEvent::SetRecurrence(const Recurrence* pRecurrence)
+{
+       result r = __pCalEventImpl->SetRecurrence(pRecurrence);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+CalEvent::AddReminder(const Reminder& reminder)
+{
+       result r = __pCalEventImpl->AddReminder(reminder);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+CalEvent::RemoveReminderAt(int index)
+{
+       result r = __pCalEventImpl->RemoveReminderAt(index);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+const IList&
+CalEvent::GetAllReminders(void) const
+{
+       return __pCalEventImpl->GetAllReminders();
+}
+
+RecordId
+CalEvent::GetCalendarId(void) const
+{
+       return __pCalEventImpl->GetCalendarId();
+}
+
+RecordId
+CalEvent::GetBaseEventId(void) const
+{
+       return __pCalEventImpl->GetBaseEventId();
+}
+
+}}     // Tizen::Social
diff --git a/src/FSclCalEventChangeInfo.cpp b/src/FSclCalEventChangeInfo.cpp
new file mode 100644 (file)
index 0000000..da28435
--- /dev/null
@@ -0,0 +1,107 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclCalEventChangeInfo.cpp
+ * @brief              This is the implementation for CalEventChangeInfo class.
+ *
+ * This file contains definitions of @e CalEventChangeInfo class.
+ */
+
+#include <new>
+#include <FBaseSysLog.h>
+#include <FSclCalEventChangeInfo.h>
+#include "FScl_CalEventChangeInfoImpl.h"
+
+namespace Tizen { namespace Social
+{
+
+const static int _INVALID_VERSION = -1;
+
+CalEventChangeInfo::CalEventChangeInfo(void)
+: __pCalEventChangeInfoImpl(null)
+{
+       __pCalEventChangeInfoImpl = new (std::nothrow) _CalEventChangeInfoImpl();
+       SysTryReturnVoidResult(NID_SCL, __pCalEventChangeInfoImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+CalEventChangeInfo::CalEventChangeInfo(const CalEventChangeInfo& rhs)
+: __pCalEventChangeInfoImpl(null)
+{
+       __pCalEventChangeInfoImpl = new (std::nothrow) _CalEventChangeInfoImpl(*(rhs.__pCalEventChangeInfoImpl));
+       SysTryReturnVoidResult(NID_SCL, __pCalEventChangeInfoImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+CalEventChangeInfo::~CalEventChangeInfo(void)
+{
+       delete __pCalEventChangeInfoImpl;
+}
+
+CalEventChangeInfo&
+CalEventChangeInfo::operator =(const CalEventChangeInfo& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pCalEventChangeInfoImpl = *rhs.__pCalEventChangeInfoImpl;
+
+       return *this;
+}
+
+bool
+CalEventChangeInfo::Equals(const Object& rhs) const
+{
+       const CalEventChangeInfo* pCalEventChangeInfo = dynamic_cast<const CalEventChangeInfo*>(&rhs);
+       if (pCalEventChangeInfo == null)
+       {
+               return false;
+       }
+
+       return __pCalEventChangeInfoImpl->Equals(*_CalEventChangeInfoImpl::GetInstance(*pCalEventChangeInfo));
+}
+
+int
+CalEventChangeInfo::GetHashCode(void) const
+{
+       return __pCalEventChangeInfoImpl->GetHashCode();
+}
+
+RecordChangeType
+CalEventChangeInfo::GetChangeType(void) const
+{
+       return __pCalEventChangeInfoImpl->GetChangeType();
+}
+
+RecordId
+CalEventChangeInfo::GetEventId(void) const
+{
+       return __pCalEventChangeInfoImpl->GetEventId();
+}
+
+RecordId
+CalEventChangeInfo::GetCalendarId(void) const
+{
+       return __pCalEventChangeInfoImpl->GetCalendarId();
+}
+
+int
+CalEventChangeInfo::GetVersion(void) const
+{
+       return __pCalEventChangeInfoImpl->GetVersion();
+}
+
+}}     // Tizen::Social
diff --git a/src/FSclCalEventInstance.cpp b/src/FSclCalEventInstance.cpp
new file mode 100644 (file)
index 0000000..09a884d
--- /dev/null
@@ -0,0 +1,168 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclCalEventInstance.cpp
+ * @brief              This is the implementation for CalEventInstance class.
+ *
+ * This file contains definitions of @e CalEventInstance class.
+ */
+
+#include <FBaseResult.h>
+#include <FBaseString.h>
+#include <FBaseDateTime.h>
+#include <FSclCalEventInstance.h>
+#include <FBaseSysLog.h>
+#include "FScl_CalEventInstanceImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social {
+
+CalEventInstance::CalEventInstance(void)
+       : __pCalEventInstanceImpl(null)
+{
+       __pCalEventInstanceImpl = new (std::nothrow) _CalEventInstanceImpl();
+       SysTryReturnVoidResult(NID_SCL, __pCalEventInstanceImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+CalEventInstance::CalEventInstance(const CalEventInstance& rhs)
+       : __pCalEventInstanceImpl(null)
+{
+       __pCalEventInstanceImpl = new (std::nothrow) _CalEventInstanceImpl(*rhs.__pCalEventInstanceImpl);
+       SysTryReturnVoidResult(NID_SCL, __pCalEventInstanceImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+CalEventInstance::~CalEventInstance(void)
+{
+       delete __pCalEventInstanceImpl;
+}
+
+CalEventInstance&
+CalEventInstance::operator =(const CalEventInstance& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pCalEventInstanceImpl = *rhs.__pCalEventInstanceImpl;
+
+       return *this;
+}
+
+bool
+CalEventInstance::Equals(const Object& rhs) const
+{
+       const CalEventInstance* pCalEventInstance = dynamic_cast<const CalEventInstance*>(&rhs);
+       if (pCalEventInstance == null)
+       {
+               return false;
+       }
+
+       return __pCalEventInstanceImpl->Equals(*_CalEventInstanceImpl::GetInstance(*pCalEventInstance));
+}
+
+int
+CalEventInstance::GetHashCode(void) const
+{
+       return __pCalEventInstanceImpl->GetHashCode();
+}
+
+RecordId
+CalEventInstance::GetOriginalEventId(void) const
+{
+       return __pCalEventInstanceImpl->GetOriginalEventId();
+}
+
+RecordId
+CalEventInstance::GetCalendarId(void) const
+{
+       return __pCalEventInstanceImpl->GetCalendarId();
+}
+
+DateTime
+CalEventInstance::GetStartTime(void) const
+{
+       return __pCalEventInstanceImpl->GetStartTime();
+}
+
+DateTime
+CalEventInstance::GetEndTime(void) const
+{
+       return __pCalEventInstanceImpl->GetEndTime();
+}
+
+String
+CalEventInstance::GetSubject(void) const
+{
+       return __pCalEventInstanceImpl->GetSubject();
+}
+
+String
+CalEventInstance::GetDescription(void) const
+{
+       return __pCalEventInstanceImpl->GetDescription();
+}
+
+String
+CalEventInstance::GetLocation(void) const
+{
+       return __pCalEventInstanceImpl->GetLocation();
+}
+
+bool
+CalEventInstance::IsAllDayEvent(void) const
+{
+       return __pCalEventInstanceImpl->IsAllDayEvent();
+}
+
+BusyStatus
+CalEventInstance::GetBusyStatus(void) const
+{
+       return __pCalEventInstanceImpl->GetBusyStatus();
+}
+
+EventStatus
+CalEventInstance::GetStatus(void) const
+{
+       return __pCalEventInstanceImpl->GetStatus();
+}
+
+EventPriority
+CalEventInstance::GetPriority(void) const
+{
+       return __pCalEventInstanceImpl->GetPriority();
+}
+
+RecordSensitivity
+CalEventInstance::GetSensitivity(void) const
+{
+       return __pCalEventInstanceImpl->GetSensitivity();
+}
+
+bool
+CalEventInstance::IsRecurring(void) const
+{
+       return __pCalEventInstanceImpl->IsRecurring();
+}
+
+bool
+CalEventInstance::HasReminder(void) const
+{
+       return __pCalEventInstanceImpl->HasReminder();
+}
+
+}} // Tizen::Social
diff --git a/src/FSclCalTodo.cpp b/src/FSclCalTodo.cpp
new file mode 100644 (file)
index 0000000..8c85e82
--- /dev/null
@@ -0,0 +1,269 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclCalTodo.cpp
+ * @brief              This is the implementation for CalTodo class.
+ *
+ * This file contains definitions of @e CalTodo class.
+ */
+
+#include <new>
+#include <FSysSystemTime.h>
+#include <FSclCalTodo.h>
+#include <FBaseSysLog.h>
+#include "FScl_CalTodoImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Social
+{
+
+CalTodo::CalTodo(void)
+       : Record(RECORD_TYPE_TODO)
+{
+       __pCalTodoImpl = new (std::nothrow) _CalTodoImpl();
+       SysTryReturnVoidResult(NID_SCL, __pCalTodoImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+CalTodo::CalTodo(const CalTodo& rhs)
+       : Record(rhs)
+       , __pCalTodoImpl(null)
+{
+       __pCalTodoImpl = new (std::nothrow) _CalTodoImpl(*rhs.__pCalTodoImpl);
+       SysTryReturnVoidResult(NID_SCL, __pCalTodoImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+CalTodo::~CalTodo(void)
+{
+       delete __pCalTodoImpl;
+}
+
+CalTodo&
+CalTodo::operator =(const CalTodo& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       Record::operator=(rhs);
+
+       *__pCalTodoImpl = *rhs.__pCalTodoImpl;
+
+       return *this;
+}
+
+bool
+CalTodo::Equals(const Object& rhs) const
+{
+       const CalTodo* pCalTodo = dynamic_cast<const CalTodo*>(&rhs);
+
+       if (pCalTodo == null)
+       {
+               return false;
+       }
+
+       return (Record::GetRecordId() == pCalTodo->GetRecordId());
+}
+
+int
+CalTodo::GetHashCode(void) const
+{
+       int hashCode = 17;
+
+       hashCode = static_cast<int>(( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ Record::GetRecordId());
+
+       return hashCode;
+}
+
+String
+CalTodo::GetSubject(void) const
+{
+       return __pCalTodoImpl->GetSubject();
+}
+
+String
+CalTodo::GetDescription(void) const
+{
+       return __pCalTodoImpl->GetDescription();
+}
+
+DateTime
+CalTodo::GetStartDate(void) const
+{
+       const DateTime& startDate = __pCalTodoImpl->GetStartDate();
+       result r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, DateTime(), r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return startDate;
+}
+
+DateTime
+CalTodo::GetDueDate(void) const
+{
+       const DateTime& dueDate = __pCalTodoImpl->GetDueDate();
+       result r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, DateTime(), r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return dueDate;
+}
+
+TodoPriority
+CalTodo::GetPriority(void) const
+{
+       return __pCalTodoImpl->GetPriority();
+}
+
+TodoStatus
+CalTodo::GetStatus(void) const
+{
+       return __pCalTodoImpl->GetStatus();
+}
+
+RecordSensitivity
+CalTodo::GetSensitivity(void) const
+{
+       return __pCalTodoImpl->GetSensitivity();
+}
+
+DateTime
+CalTodo::GetLastRevisedTime(void) const
+{
+       return __pCalTodoImpl->GetLastRevisedTime();
+}
+
+result
+CalTodo::SetSubject(const String& subject)
+{
+       result r = __pCalTodoImpl->SetSubject(subject);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+CalTodo::SetDescription(const String& description)
+{
+       result r = __pCalTodoImpl->SetDescription(description);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+CalTodo::SetStartAndDueDate(const DateTime& start, const DateTime& end)
+{
+       result r = __pCalTodoImpl->SetStartAndDueDate(start, end);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+CalTodo::SetStartDate(const DateTime& startDate)
+{
+       result r = __pCalTodoImpl->SetStartDate(startDate);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+CalTodo::SetDueDate(const DateTime& dueDate)
+{
+       result r = __pCalTodoImpl->SetDueDate(dueDate);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+void
+CalTodo::SetPriority(TodoPriority priority)
+{
+       __pCalTodoImpl->SetPriority(priority);
+}
+
+void
+CalTodo::SetStatus(TodoStatus status)
+{
+       __pCalTodoImpl->SetStatus(status);
+}
+
+void
+CalTodo::SetSensitivity(RecordSensitivity sensitivity)
+{
+       __pCalTodoImpl->SetSensitivity(sensitivity);
+}
+
+void
+CalTodo::SetLocation(const String& location)
+{
+       __pCalTodoImpl->SetLocation(location);
+}
+
+String
+CalTodo::GetLocation(void) const
+{
+       return __pCalTodoImpl->GetLocation();
+}
+
+result
+CalTodo::SetCoordinates(double latitude, double longitude)
+{
+       result r = __pCalTodoImpl->SetCoordinates(latitude, longitude);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+void
+CalTodo::GetCoordinates(double& latitude, double& longitude) const
+{
+       __pCalTodoImpl->GetCoordinates(latitude, longitude);
+}
+
+result
+CalTodo::AddReminder(const Reminder& reminder)
+{
+       result r = __pCalTodoImpl->AddReminder(reminder);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+CalTodo::RemoveReminderAt(int index)
+{
+       result r = __pCalTodoImpl->RemoveReminderAt(index);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+const IList&
+CalTodo::GetAllReminders(void) const
+{
+       return __pCalTodoImpl->GetAllReminders();
+}
+
+RecordId
+CalTodo::GetCalendarId(void) const
+{
+       return __pCalTodoImpl->GetCalendarId();
+}
+
+}}     // Tizen::Social
diff --git a/src/FSclCalTodoChangeInfo.cpp b/src/FSclCalTodoChangeInfo.cpp
new file mode 100644 (file)
index 0000000..876174b
--- /dev/null
@@ -0,0 +1,107 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclCalTodoChangeInfo.cpp
+ * @brief              This is the implementation for CalTodoChangeInfo class.
+ *
+ * This file contains definitions of @e CalTodoChangeInfo class.
+ */
+
+#include <new>
+#include <FBaseSysLog.h>
+#include <FSclCalTodoChangeInfo.h>
+#include "FScl_CalTodoChangeInfoImpl.h"
+
+namespace Tizen { namespace Social
+{
+
+const static int _INVALID_VERSION = -1;
+
+CalTodoChangeInfo::CalTodoChangeInfo(void)
+       : __pCalTodoChangeInfoImpl(null)
+{
+       __pCalTodoChangeInfoImpl = new (std::nothrow) _CalTodoChangeInfoImpl();
+       SysTryReturnVoidResult(NID_SCL, __pCalTodoChangeInfoImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+CalTodoChangeInfo::CalTodoChangeInfo(const CalTodoChangeInfo& rhs)
+       : __pCalTodoChangeInfoImpl(null)
+{
+       __pCalTodoChangeInfoImpl = new (std::nothrow) _CalTodoChangeInfoImpl(*(rhs.__pCalTodoChangeInfoImpl));
+       SysTryReturnVoidResult(NID_SCL, __pCalTodoChangeInfoImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+CalTodoChangeInfo::~CalTodoChangeInfo(void)
+{
+       delete __pCalTodoChangeInfoImpl;
+}
+
+CalTodoChangeInfo&
+CalTodoChangeInfo::operator =(const CalTodoChangeInfo& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pCalTodoChangeInfoImpl = *rhs.__pCalTodoChangeInfoImpl;
+
+       return *this;
+}
+
+bool
+CalTodoChangeInfo::Equals(const Object& rhs) const
+{
+       const CalTodoChangeInfo* pCalTodoChangeInfo = dynamic_cast<const CalTodoChangeInfo*>(&rhs);
+       if (pCalTodoChangeInfo == null)
+       {
+               return false;
+       }
+
+       return __pCalTodoChangeInfoImpl->Equals(*_CalTodoChangeInfoImpl::GetInstance(*pCalTodoChangeInfo));
+}
+
+int
+CalTodoChangeInfo::GetHashCode(void) const
+{
+       return __pCalTodoChangeInfoImpl->GetHashCode();
+}
+
+RecordChangeType
+CalTodoChangeInfo::GetChangeType(void) const
+{
+       return __pCalTodoChangeInfoImpl->GetChangeType();
+}
+
+RecordId
+CalTodoChangeInfo::GetTodoId(void) const
+{
+       return __pCalTodoChangeInfoImpl->GetTodoId();
+}
+
+RecordId
+CalTodoChangeInfo::GetCalendarId(void) const
+{
+       return __pCalTodoChangeInfoImpl->GetCalendarId();
+}
+
+int
+CalTodoChangeInfo::GetVersion(void) const
+{
+       return __pCalTodoChangeInfoImpl->GetVersion();
+}
+
+}}     // Tizen::Social
diff --git a/src/FSclCalendar.cpp b/src/FSclCalendar.cpp
new file mode 100644 (file)
index 0000000..4efe111
--- /dev/null
@@ -0,0 +1,137 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclCalendar.cpp
+ * @brief              This is the implementation for Calendar class.
+ *
+ * This file contains definitions of @e Calendar class.
+ */
+
+#include <new>
+#include <FSclCalendar.h>
+#include <FBaseSysLog.h>
+#include "FScl_CalendarImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+Calendar::Calendar(CalendarItemType itemType)
+: Record(RECORD_TYPE_CALENDAR)
+, __pCalendarImpl(null)
+{
+       __pCalendarImpl = new (std::nothrow) _CalendarImpl(itemType);
+       SysTryReturnVoidResult(NID_SCL, __pCalendarImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+Calendar::Calendar(const Calendar& rhs)
+: Record(rhs)
+, __pCalendarImpl(null)
+{
+       __pCalendarImpl = new (std::nothrow) _CalendarImpl(*rhs.__pCalendarImpl);
+       SysTryReturnVoidResult(NID_SCL, __pCalendarImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+Calendar::~Calendar(void)
+{
+       delete __pCalendarImpl;
+}
+
+Calendar&
+Calendar::operator =(const Calendar& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       Record::operator=(rhs);
+
+       *__pCalendarImpl = *rhs.__pCalendarImpl;
+
+       return *this;
+}
+
+bool
+Calendar::Equals(const Tizen::Base::Object& rhs) const
+{
+       const Calendar* pCalendar = dynamic_cast<const Calendar*>(&rhs);
+
+       if (pCalendar == null)
+       {
+               return false;
+       }
+
+       return (Record::GetRecordId() == pCalendar->GetRecordId());
+}
+
+int
+Calendar::GetHashCode(void) const
+{
+       int hashCode = 17;
+
+       hashCode = static_cast<int>(( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ Record::GetRecordId());
+
+       return hashCode;
+}
+
+String
+Calendar::GetName(void) const
+{
+       return __pCalendarImpl->GetName();
+}
+
+CalendarItemType
+Calendar::GetItemType(void) const
+{
+       return __pCalendarImpl->GetItemType();
+}
+
+AccountId
+Calendar::GetAccountId(void) const
+{
+       return __pCalendarImpl->GetAccountId();
+}
+
+result
+Calendar::GetColor(byte& red, byte& green, byte& blue) const
+{
+       result r = __pCalendarImpl->GetColor(red, green, blue);
+       SysTryReturnResult(NID_SCL, r == E_SUCCESS, r, "Propagating.");
+
+       return E_SUCCESS;
+}
+
+void
+Calendar::SetName(const Tizen::Base::String& name)
+{
+       __pCalendarImpl->SetName(name);
+}
+
+void
+Calendar::SetColor(byte red, byte green, byte blue)
+{
+       __pCalendarImpl->SetColor(red, green, blue);
+}
+
+void
+Calendar::ClearColor(void)
+{
+       __pCalendarImpl->ClearColor();
+}
+
+}}     // Tizen::Social
diff --git a/src/FSclCalendarbook.cpp b/src/FSclCalendarbook.cpp
new file mode 100644 (file)
index 0000000..450e916
--- /dev/null
@@ -0,0 +1,656 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclCalendarbook.cpp
+ * @brief              This is the implementation for Calendarbook class.
+ *
+ * This file contains definitions of @e Calendarbook class.
+ */
+
+#include <new>
+#include <FSclCalendarbook.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FScl_CalEventImpl.h"
+#include "FScl_CalTodoImpl.h"
+#include "FScl_CalendarbookImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Social
+{
+
+Calendarbook::Calendarbook(void)
+       : __pCalendarbookImpl(null)
+{
+}
+
+Calendarbook::~Calendarbook(void)
+{
+       delete __pCalendarbookImpl;
+}
+
+result
+Calendarbook::Construct(void)
+{
+       SysAssertf(__pCalendarbookImpl == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       result r = E_SUCCESS;
+       _CalendarbookImpl* pCalendarbookImpl = null;
+
+       pCalendarbookImpl = new (std::nothrow) _CalendarbookImpl();
+       SysTryReturnResult(NID_SCL, pCalendarbookImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pCalendarbookImpl->Construct();
+       SysTryCatch(NID_SCL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pCalendarbookImpl = pCalendarbookImpl;
+
+       return E_SUCCESS;
+
+CATCH:
+       delete pCalendarbookImpl;
+
+       return r;
+}
+
+result
+Calendarbook::Construct(IRecordEventListener* pListener)
+{
+       SysAssertf(__pCalendarbookImpl == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       result r = E_SUCCESS;
+       _CalendarbookImpl* pCalendarbookImpl = null;
+
+       pCalendarbookImpl = new (std::nothrow) _CalendarbookImpl();
+       SysTryReturnResult(NID_SCL, pCalendarbookImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pCalendarbookImpl->Construct(pListener);
+       SysTryCatch(NID_SCL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pCalendarbookImpl = pCalendarbookImpl;
+
+       return E_SUCCESS;
+
+CATCH:
+       delete pCalendarbookImpl;
+
+       return r;
+}
+
+result
+Calendarbook::Construct(ICalendarbookEventListener& listener)
+{
+       SysAssertf(__pCalendarbookImpl == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       result r = E_SUCCESS;
+       _CalendarbookImpl* pCalendarbookImpl = null;
+
+       pCalendarbookImpl = new (std::nothrow) _CalendarbookImpl();
+       SysTryReturnResult(NID_SCL, pCalendarbookImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pCalendarbookImpl->Construct(listener);
+       SysTryCatch(NID_SCL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pCalendarbookImpl = pCalendarbookImpl;
+
+       return E_SUCCESS;
+
+CATCH:
+       delete pCalendarbookImpl;
+
+       return r;
+}
+
+result
+Calendarbook::AddEvent(CalEvent& event)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pCalendarbookImpl->AddEvent(event);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Calendarbook::AddEvent(CalEvent& event, RecordId calendarId)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pCalendarbookImpl->AddEvent(event, calendarId);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Calendarbook::AddTodo(CalTodo& todo)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pCalendarbookImpl->AddTodo(todo);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Calendarbook::AddTodo(CalTodo& todo, RecordId calendarId)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pCalendarbookImpl->AddTodo(todo, calendarId);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Calendarbook::RemoveEvent(CalEvent& event)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pCalendarbookImpl->RemoveEvent(event);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Calendarbook::RemoveEvent(RecordId eventId)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pCalendarbookImpl->RemoveEvent(eventId);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Calendarbook::RemoveTodo(CalTodo& todo)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pCalendarbookImpl->RemoveTodo(todo);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Calendarbook::RemoveTodo(RecordId todoId)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pCalendarbookImpl->RemoveTodo(todoId);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Calendarbook::UpdateEvent(const CalEvent& event)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pCalendarbookImpl->UpdateEvent(event);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Calendarbook::UpdateTodo(const CalTodo& todo)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pCalendarbookImpl->UpdateTodo(todo);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+CalEvent*
+Calendarbook::GetEventN(RecordId eventId) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       CalEvent* pEvent = __pCalendarbookImpl->GetEventN(eventId);
+       r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pEvent;
+}
+
+CalTodo*
+Calendarbook::GetTodoN(RecordId todoId) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                               "Not yet constructed. Construct() should be called before use.");
+
+       CalTodo* pTodo = __pCalendarbookImpl->GetTodoN(todoId);
+       r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pTodo;
+}
+
+IList*
+Calendarbook::GetTodosN(const DateTime& start, const DateTime& end, int pageNo, int countPerPage, unsigned long status,
+                                               unsigned long priority) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pCalendarbookImpl->GetTodosN(start, end, pageNo, countPerPage, status, priority);
+       r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pList;
+}
+
+int
+Calendarbook::GetTodoCount(const DateTime& start, const DateTime& end, unsigned long status, unsigned long priority) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, _INVALID_COUNT, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       int count = __pCalendarbookImpl->GetTodoCount(start, end, status, priority);
+       r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, _INVALID_COUNT, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return count;
+}
+
+IList*
+Calendarbook::GetEventInstancesN(const DateTime& start, const DateTime& end,
+                                                                const Tizen::Locales::TimeZone& timeZone, int pageNo, int countPerPage,
+                                                                unsigned long category) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+       IList* pList = __pCalendarbookImpl->GetEventInstancesN(start, end, timeZone, pageNo, countPerPage, category);
+       r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pList;
+}
+
+result
+Calendarbook::GetEventInstances(const DateTime& start, const DateTime& end,
+                                                               const Tizen::Locales::TimeZone& timeZone, int pageNo, int countPerPage, unsigned long category,
+                                                               RequestId& reqId,
+                                                               const IRecordListener& listener) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pCalendarbookImpl->GetEventInstances(start, end, timeZone, pageNo, countPerPage, category, reqId, listener);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+IList*
+Calendarbook::GetAllEventsN(void) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pCalendarbookImpl->GetAllEventsN();
+       r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pList;
+}
+
+IList*
+Calendarbook::GetAllTodosN(void) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pCalendarbookImpl->GetAllTodosN();
+       r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pList;
+}
+
+IList*
+Calendarbook::GetAllCalendarsN(void) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pCalendarbookImpl->GetAllCalendarsN();
+       r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pList;
+}
+
+IList*
+Calendarbook::GetChangedEventsAfterN(int version, int& latestVersion) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pCalendarbookImpl->GetChangedEventsAfterN(version, latestVersion);
+       r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pList;
+}
+
+IList*
+Calendarbook::GetChangedTodosAfterN(int version, int& latestVersion) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pCalendarbookImpl->GetChangedTodosAfterN(version, latestVersion);
+       r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pList;
+}
+
+result
+Calendarbook::AddCalendar(Calendar& calendar)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pCalendarbookImpl->AddCalendar(calendar);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Calendarbook::AddCalendar(Calendar& calendar, AccountId accountId)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pCalendarbookImpl->AddCalendar(calendar, accountId);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Calendarbook::RemoveCalendar(RecordId calendarId)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pCalendarbookImpl->RemoveCalendar(calendarId);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Calendarbook::UpdateCalendar(const Calendar& calendar)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pCalendarbookImpl->UpdateCalendar(calendar);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+Calendar*
+Calendarbook::GetCalendarN(RecordId calendarId) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       Calendar* pCalendar = __pCalendarbookImpl->GetCalendarN(calendarId);
+       r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pCalendar;
+}
+
+result
+Calendarbook::RemoveEventInstance(const CalEventInstance& eventInstance)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pCalendarbookImpl->RemoveEventInstance(eventInstance);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Calendarbook::UpdateEventInstance(const CalEventInstance& eventInstance, CalEvent& event)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       r = __pCalendarbookImpl->UpdateEventInstance(eventInstance, event);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+int
+Calendarbook::GetLatestVersion(void) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, _INVALID_VERSION, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       int version = __pCalendarbookImpl->GetLatestVersion();
+       r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, _INVALID_VERSION, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return version;
+}
+
+IList*
+Calendarbook::SearchN(const CalendarbookFilter& filter, unsigned long propertySortedBy, SortOrder sortOrder, int offset, int maxCount) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       IList* pList = __pCalendarbookImpl->SearchN(filter, propertySortedBy, sortOrder, offset, maxCount);
+       r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pList;
+}
+
+int
+Calendarbook::GetMatchedItemCount(const CalendarbookFilter& filter) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, _INVALID_COUNT, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+       SysAssertf(__pCalendarbookImpl != null,
+                       "Not yet constructed. Construct() should be called before use.");
+
+       int count = __pCalendarbookImpl->GetMatchedItemCount(filter);
+       r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, _INVALID_COUNT, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return count;
+}
+
+IList*
+Calendarbook::ParseEventsFromVcalendarN(const String& vCalFilePath)
+{
+       IList* pList = _CalendarbookImpl::ParseEventsFromVcalendarN(vCalFilePath);
+       result r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pList;
+}
+
+IList*
+Calendarbook::ParseTodosFromVcalendarN(const String& vCalFilePath)
+{
+       IList* pList = _CalendarbookImpl::ParseTodosFromVcalendarN(vCalFilePath);
+       result r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pList;
+}
+
+result
+Calendarbook::ExportEventsToVcalendar(const IList& eventList, const String& vCalFilePath)
+{
+       result r = _CalendarbookImpl::ExportEventsToVcalendar(eventList, vCalFilePath);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Calendarbook::ExportTodosToVcalendar(const IList& todoList, const String& vCalFilePath)
+{
+       result r = _CalendarbookImpl::ExportTodosToVcalendar(todoList, vCalFilePath);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+DateTime
+Calendarbook::GetMaxDateTime(void)
+{
+       return _CalendarbookImpl::GetMaxDateTime();
+}
+DateTime
+Calendarbook::GetMinDateTime(void)
+{
+       return _CalendarbookImpl::GetMinDateTime();
+}
+
+}}     // Tizen::Social
diff --git a/src/FSclCalendarbookFilter.cpp b/src/FSclCalendarbookFilter.cpp
new file mode 100644 (file)
index 0000000..62deb7f
--- /dev/null
@@ -0,0 +1,99 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FSclCalendarbookFilter.cpp
+* @brief       This is the implementation for CalendarbookFilter class.
+*
+* This file contains definitions of @e CalendarbookFilter class.
+*/
+
+#include <FSclCalendarbookFilter.h>
+#include <FBaseSysLog.h>
+#include "FScl_CalendarbookFilterImpl.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+CalendarbookFilter::CalendarbookFilter(CalendarbookFilterType type)
+{
+       _CalendarbookFilterImpl* pCalendarbookFilterImpl = new (std::nothrow) _CalendarbookFilterImpl(type);
+       SysTryReturnVoidResult(NID_SCL, pCalendarbookFilterImpl, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __pCalendarbookFilterImpl = pCalendarbookFilterImpl;
+}
+
+CalendarbookFilter::~CalendarbookFilter(void)
+{
+       delete __pCalendarbookFilterImpl;
+}
+
+bool
+CalendarbookFilter::Equals(const Tizen::Base::Object& rhs) const
+{
+       const CalendarbookFilter* pCalendarbookFilter = dynamic_cast<const CalendarbookFilter*>(&rhs);
+       if (pCalendarbookFilter == null)
+       {
+               return false;
+       }
+
+       return __pCalendarbookFilterImpl->Equals(*pCalendarbookFilter->__pCalendarbookFilterImpl);
+}
+
+int
+CalendarbookFilter::GetHashCode(void) const
+{
+       return __pCalendarbookFilterImpl->GetHashCode();
+}
+
+result
+CalendarbookFilter::AppendInt(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, int value)
+{
+       return __pCalendarbookFilterImpl->AppendInt(conjunctiveOperator, filterProperty, comparisonOperator, value);
+}
+
+result
+CalendarbookFilter::AppendDouble(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, double value)
+{
+       return __pCalendarbookFilterImpl->AppendDouble(conjunctiveOperator, filterProperty, comparisonOperator, value);
+}
+
+result
+CalendarbookFilter::AppendBool(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, bool value)
+{
+       return __pCalendarbookFilterImpl->AppendBool(conjunctiveOperator, filterProperty, comparisonOperator, value);
+}
+
+result
+CalendarbookFilter::AppendDateTime(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, const Tizen::Base::DateTime& value)
+{
+       return __pCalendarbookFilterImpl->AppendDateTime(conjunctiveOperator, filterProperty, comparisonOperator, value);
+}
+
+result
+CalendarbookFilter::AppendString(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterStringOperator comparisonOperator, const Tizen::Base::String& value)
+{
+       return __pCalendarbookFilterImpl->AppendString(conjunctiveOperator, filterProperty, comparisonOperator, value);
+}
+
+result
+CalendarbookFilter::AppendFilter(FilterConjunctiveOperator conjunctiveOperator, const CalendarbookFilter& filter)
+{
+       return __pCalendarbookFilterImpl->AppendFilter(conjunctiveOperator, *filter.__pCalendarbookFilterImpl);;
+}
+
+}} // Tizen::Social
diff --git a/src/FSclCategory.cpp b/src/FSclCategory.cpp
new file mode 100644 (file)
index 0000000..1309df3
--- /dev/null
@@ -0,0 +1,199 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclCategory.cpp
+ * @brief              This is the implementation for Category class.
+ *
+ * This file contains definitions of @e Category class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FSclCategory.h>
+#include "FScl_CategoryImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Social
+{
+
+Category::Category(void)
+       : Record(RECORD_TYPE_CATEGORY)
+{
+       __pCategoryImpl = new (std::nothrow) _CategoryImpl();
+       SysTryReturnVoidResult(NID_SCL, __pCategoryImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+Category::Category(const Category& rhs)
+       : Record(rhs)
+{
+       __pCategoryImpl = new (std::nothrow) _CategoryImpl(*rhs.__pCategoryImpl);
+       SysTryReturnVoidResult(NID_SCL, __pCategoryImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+Category::~Category(void)
+{
+       delete __pCategoryImpl;
+}
+
+Category&
+Category::operator =(const Category& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       Record::operator =(rhs);
+
+       *__pCategoryImpl = *rhs.__pCategoryImpl;
+
+       return *this;
+}
+
+bool
+Category::Equals(const Object& rhs) const
+{
+       const Category* pCategory = dynamic_cast<const Category*>(&rhs);
+       if (pCategory == null)
+       {
+               return false;
+       }
+
+       if (GetRecordId() == INVALID_RECORD_ID)
+       {
+               return false;
+       }
+
+       if (GetRecordId() != pCategory->GetRecordId())
+       {
+               return false;
+       }
+
+       return __pCategoryImpl->Equals(*pCategory->__pCategoryImpl);
+}
+
+int
+Category::GetHashCode(void) const
+{
+       return GetRecordId();
+}
+
+AddressbookId
+Category::GetAddressbookId(void) const
+{
+       return __pCategoryImpl->GetAddressbookId();
+}
+
+result
+Category::AddMember(RecordId contactId)
+{
+       result r = __pCategoryImpl->AddMember(contactId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+int
+Category::GetMemberCount(void) const
+{
+       return __pCategoryImpl->GetMemberCount();
+}
+
+String
+Category::GetName(void) const
+{
+       return __pCategoryImpl->GetName();
+}
+
+bool
+Category::HasMember(RecordId contactId) const
+{
+       bool hasMember = __pCategoryImpl->HasMember(contactId);
+
+       result r = GetLastResult();
+       SysTryReturn(NID_SCL, !IsFailed(r), hasMember, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return hasMember;
+}
+
+result
+Category::RemoveMember(RecordId contactId)
+{
+       result r = __pCategoryImpl->RemoveMember(contactId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Category::SetName(const String& name)
+{
+       result r = __pCategoryImpl->SetName(name);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Category::SetRingtonePath(const String& filePath)
+{
+       result r = __pCategoryImpl->SetRingtonePath(filePath);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+String
+Category::GetRingtonePath(void) const
+{
+       return __pCategoryImpl->GetRingtonePath();
+}
+
+result
+Category::SetThumbnail(const String& filePath)
+{
+       result r = __pCategoryImpl->SetThumbnail(filePath);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+String
+Category::GetThumbnailPath(void) const
+{
+       return __pCategoryImpl->GetThumbnailPath();
+}
+
+bool
+Category::IsDefault(void) const
+{
+       return __pCategoryImpl->IsDefault();
+}
+
+bool
+Category::IsReadOnly(void) const
+{
+       return __pCategoryImpl->IsReadOnly();
+}
+
+IMap*
+Category::GetExtraDataN(void) const
+{
+       return __pCategoryImpl->GetExtraDataN();
+}
+
+}} // Tizen::Social
diff --git a/src/FSclCategoryChangeInfo.cpp b/src/FSclCategoryChangeInfo.cpp
new file mode 100644 (file)
index 0000000..1133d18
--- /dev/null
@@ -0,0 +1,107 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclCategoryChangeInfo.cpp
+ * @brief              This is the implementation for CategoryChangeInfo class.
+ *
+ * This file contains definitions of @e CategoryChangeInfo class.
+ */
+
+#include <new>
+#include <FBaseResult.h>
+#include <FSclCategoryChangeInfo.h>
+#include <FBaseSysLog.h>
+#include "FScl_CategoryChangeInfoImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Social
+{
+
+CategoryChangeInfo::CategoryChangeInfo(void)
+{
+       __pCategoryChangeInfoImpl = new (std::nothrow) _CategoryChangeInfoImpl();
+       SysTryReturnVoidResult(NID_SCL, __pCategoryChangeInfoImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+CategoryChangeInfo::CategoryChangeInfo(const CategoryChangeInfo& rhs)
+{
+       __pCategoryChangeInfoImpl = new (std::nothrow) _CategoryChangeInfoImpl(*rhs.__pCategoryChangeInfoImpl);
+       SysTryReturnVoidResult(NID_SCL, __pCategoryChangeInfoImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+CategoryChangeInfo::~CategoryChangeInfo(void)
+{
+       delete __pCategoryChangeInfoImpl;
+}
+
+CategoryChangeInfo&
+CategoryChangeInfo::operator =(const CategoryChangeInfo& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pCategoryChangeInfoImpl = *rhs.__pCategoryChangeInfoImpl;
+
+       return *this;
+}
+
+bool
+CategoryChangeInfo::Equals(const Object& rhs) const
+{
+       const CategoryChangeInfo* pCategoryChangeInfo = dynamic_cast<const CategoryChangeInfo*>(&rhs);
+       if (pCategoryChangeInfo == null)
+       {
+               return false;
+       }
+
+       return *__pCategoryChangeInfoImpl == *pCategoryChangeInfo->__pCategoryChangeInfoImpl;
+}
+
+int
+CategoryChangeInfo::GetHashCode(void) const
+{
+       return __pCategoryChangeInfoImpl->GetHashCode();
+}
+
+AddressbookId
+CategoryChangeInfo::GetAddressbookId(void) const
+{
+       return __pCategoryChangeInfoImpl->GetAddressbookId();
+}
+
+RecordId
+CategoryChangeInfo::GetCategoryId(void) const
+{
+       return __pCategoryChangeInfoImpl->GetCategoryId();
+}
+
+int
+CategoryChangeInfo::GetVersion(void) const
+{
+       return __pCategoryChangeInfoImpl->GetVersion();
+}
+
+RecordChangeType
+CategoryChangeInfo::GetChangeType(void) const
+{
+       return __pCategoryChangeInfoImpl->GetChangeType();
+}
+
+}} // Tizen::Social
diff --git a/src/FSclContact.cpp b/src/FSclContact.cpp
new file mode 100644 (file)
index 0000000..5b4c9b5
--- /dev/null
@@ -0,0 +1,405 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclContact.cpp
+ * @brief              This is the implementation for Profile class.
+ *
+ * This file contains definitions of @e Contact class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FSclAddress.h>
+#include <FSclPhoneNumber.h>
+#include <FSclEmail.h>
+#include <FSclUrl.h>
+#include <FSclImAddress.h>
+#include <FSclOrganization.h>
+#include <FSclContactEvent.h>
+#include <FSclRelationship.h>
+#include <FSclContactAppLaunchData.h>
+#include <FSclContact.h>
+#include "FScl_ContactImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Graphics;
+
+namespace Tizen { namespace Social
+{
+
+Contact::Contact(void)
+       : Record(RECORD_TYPE_CONTACT)
+{
+       __pContactImpl = new (std::nothrow) _ContactImpl();
+       SysTryReturnVoidResult(NID_SCL, __pContactImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+Contact::Contact(const Contact& rhs)
+       : Record(rhs)
+{
+       __pContactImpl = new (std::nothrow) _ContactImpl(*rhs.__pContactImpl);
+       SysTryReturnVoidResult(NID_SCL, __pContactImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+Contact::~Contact(void)
+{
+       delete __pContactImpl;
+}
+
+Contact&
+Contact::operator =(const Contact& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       Record::operator=(rhs);
+
+       *__pContactImpl = *rhs.__pContactImpl;
+
+       return *this;
+}
+
+bool
+Contact::Equals(const Object& rhs) const
+{
+       const Contact* pContact = dynamic_cast<const Contact*>(&rhs);
+       if (pContact == null)
+       {
+               return false;
+       }
+
+       if (GetRecordId() == INVALID_RECORD_ID)
+       {
+               return false;
+       }
+
+       if (GetRecordId() == pContact->GetRecordId())
+       {
+               return true;
+       }
+
+       return false;
+}
+
+int
+Contact::GetHashCode(void) const
+{
+       return GetRecordId();
+}
+
+PersonId
+Contact::GetPersonId(void) const
+{
+       return __pContactImpl->GetPersonId();
+}
+
+AddressbookId
+Contact::GetAddressbookId(void) const
+{
+       return __pContactImpl->GetAddressbookId();
+}
+
+Bitmap*
+Contact::GetThumbnailN(void) const
+{
+       Bitmap* pBitmap = __pContactImpl->GetThumbnailN();
+       SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pBitmap;
+}
+
+String
+Contact::GetThumbnailPath(void) const
+{
+       return  __pContactImpl->GetThumbnailPath();
+}
+
+result
+Contact::SetThumbnail(const String& filePath)
+{
+       result r = __pContactImpl->SetThumbnailPath(filePath);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::GetValue(ContactPropertyId id, String& value) const
+{
+       result r = __pContactImpl->GetValue(id, value);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::GetValue(ContactPropertyId id, DateTime& value) const
+{
+       result r = __pContactImpl->GetValue(id, value);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::SetValue(ContactPropertyId id, const String& value)
+{
+       result r = __pContactImpl->SetValue(id, value);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::SetValue(ContactPropertyId id, const DateTime& value)
+{
+       result r = __pContactImpl->SetValue(id, value);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::AddNote(const String& note)
+{
+       result r = __pContactImpl->AddNote(note);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::AddNickname(const String& nickname)
+{
+       result r = __pContactImpl->AddNickname(nickname);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::AddPhoneNumber(const PhoneNumber& phoneNumber)
+{
+       result r = __pContactImpl->AddPhoneNumber(phoneNumber);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::AddEmail(const Email& email)
+{
+       result r = __pContactImpl->AddEmail(email);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::AddUrl(const Url& url)
+{
+       result r = __pContactImpl->AddUrl(url);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::AddAddress(const Address& address)
+{
+       result r = __pContactImpl->AddAddress(address);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::AddImAddress(const ImAddress& imAddress)
+{
+       result r = __pContactImpl->AddImAddress(imAddress);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::AddOrganization(const Organization& organization)
+{
+       result r = __pContactImpl->AddOrganization(organization);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::AddEvent(const ContactEvent& event)
+{
+       result r = __pContactImpl->AddEvent(event);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::AddRelationship(const Relationship& relationship)
+{
+       result r = __pContactImpl->AddRelationship(relationship);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::AddContactAppLaunchData(const ContactAppLaunchData& appLaunchData)
+{
+       result r = __pContactImpl->AddContactAppLaunchData(appLaunchData);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::RemoveAt(ContactMultiPropertyId id, int index)
+{
+       result r = __pContactImpl->RemoveAt(id, index);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+IList*
+Contact::GetValuesN(ContactMultiPropertyId id) const
+{
+       IList* pList = __pContactImpl->GetValuesN(id);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+result
+Contact::SetNoteAt(int index, const String& note)
+{
+       result r = __pContactImpl->SetNoteAt(index, note);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::SetNicknameAt(int index, const String& nickname)
+{
+       result r = __pContactImpl->SetNicknameAt(index, nickname);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber)
+{
+       result r = __pContactImpl->SetPhoneNumberAt(index, phoneNumber);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::SetEmailAt(int index, const Email& email)
+{
+       result r = __pContactImpl->SetEmailAt(index, email);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::SetEventAt(int index, const ContactEvent& event)
+{
+       result r = __pContactImpl->SetEventAt(index, event);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::SetOrganizationAt(int index, const Organization& organization)
+{
+       result r = __pContactImpl->SetOrganizationAt(index, organization);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::SetRelationshipAt(int index, const Relationship& relationship)
+{
+       result r = __pContactImpl->SetRelationshipAt(index, relationship);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::SetUrlAt(int index, const Url& url)
+{
+       result r = __pContactImpl->SetUrlAt(index, url);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::SetAddressAt(int index, const Address& address)
+{
+       result r = __pContactImpl->SetAddressAt(index, address);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::SetImAddressAt(int index, const ImAddress& imAddress)
+{
+       result r = __pContactImpl->SetImAddressAt(index, imAddress);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Contact::SetContactAppLaunchDataAt(int index, const ContactAppLaunchData& appLaunchData)
+{
+       result r = __pContactImpl->SetContactAppLaunchDataAt(index, appLaunchData);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+bool
+Contact::IsFavorite(void) const
+{
+       return __pContactImpl->IsFavorite();
+}
+
+void
+Contact::SetAsFavorite(bool isFavorite)
+{
+       __pContactImpl->SetAsFavorite(isFavorite);
+}
+
+}} // Tizen::Social
diff --git a/src/FSclContactAppLaunchData.cpp b/src/FSclContactAppLaunchData.cpp
new file mode 100644 (file)
index 0000000..acf7a51
--- /dev/null
@@ -0,0 +1,165 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+/**
+ * @file               FSclContactAppLaunchData.cpp
+ * @brief              This is the implementation for ContactAppLaunchData class.
+ *
+ * This file contains definitions of @e ContactAppLaunchData class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FSclContactAppLaunchData.h>
+#include "FScl_ContactAppLaunchDataImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Social
+{
+
+ContactAppLaunchData::ContactAppLaunchData(void)
+{
+       __pContactAppLaunchDataImpl = new (std::nothrow) _ContactAppLaunchDataImpl();
+       SysTryReturnVoidResult(NID_SCL, __pContactAppLaunchDataImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+ContactAppLaunchData::ContactAppLaunchData(const ContactAppLaunchData& rhs)
+:__pContactAppLaunchDataImpl(null)
+{
+       __pContactAppLaunchDataImpl = new (std::nothrow) _ContactAppLaunchDataImpl(*rhs.__pContactAppLaunchDataImpl);
+       SysTryReturnVoidResult(NID_SCL, __pContactAppLaunchDataImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+ContactAppLaunchData::~ContactAppLaunchData(void)
+{
+       delete __pContactAppLaunchDataImpl;
+}
+
+ContactAppLaunchData&
+ContactAppLaunchData::operator =(const ContactAppLaunchData& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pContactAppLaunchDataImpl = *rhs.__pContactAppLaunchDataImpl;
+
+       return *this;
+}
+
+bool operator ==(const ContactAppLaunchData& lhs, const ContactAppLaunchData& rhs)
+{
+       return *lhs.__pContactAppLaunchDataImpl == *rhs.__pContactAppLaunchDataImpl;
+}
+
+bool operator !=(const ContactAppLaunchData& lhs, const ContactAppLaunchData& rhs)
+{
+       return !(lhs == rhs);
+}
+
+bool
+ContactAppLaunchData::Equals(const Object& rhs) const
+{
+       const ContactAppLaunchData* pContactAppLaunchData = dynamic_cast<const ContactAppLaunchData*>(&rhs);
+       if (pContactAppLaunchData == null)
+       {
+               return false;
+       }
+
+       return __pContactAppLaunchDataImpl->Equals(*pContactAppLaunchData->__pContactAppLaunchDataImpl);
+}
+
+int
+ContactAppLaunchData::GetHashCode(void) const
+{
+       return __pContactAppLaunchDataImpl->GetHashCode();
+}
+
+String
+ContactAppLaunchData::GetDisplayText(void) const
+{
+       return __pContactAppLaunchDataImpl->GetDisplayText();
+}
+
+String
+ContactAppLaunchData::GetAppId(void) const
+{
+       return __pContactAppLaunchDataImpl->GetAppId();
+}
+
+String
+ContactAppLaunchData::GetOperationId(void) const
+{
+       return __pContactAppLaunchDataImpl->GetOperationId();
+}
+
+String
+ContactAppLaunchData::GetUri(void) const
+{
+       return __pContactAppLaunchDataImpl->GetUri();
+}
+
+String
+ContactAppLaunchData::GetMime(void) const
+{
+       return __pContactAppLaunchDataImpl->GetMime();
+}
+
+IMap*
+ContactAppLaunchData::GetExtraDataN(void) const
+{
+       return __pContactAppLaunchDataImpl->GetExtraDataN();
+}
+
+void
+ContactAppLaunchData::SetDisplayText(const String& displayText)
+{
+       __pContactAppLaunchDataImpl->SetDisplayText(displayText);
+}
+
+void
+ContactAppLaunchData::SetAppId(const String& appId)
+{
+       __pContactAppLaunchDataImpl->SetAppId(appId);
+}
+
+void
+ContactAppLaunchData::SetOperationId(const String& operationId)
+{
+       __pContactAppLaunchDataImpl->SetOperationId(operationId);
+}
+
+void
+ContactAppLaunchData::SetUri(const String& uri)
+{
+       __pContactAppLaunchDataImpl->SetUri(uri);
+}
+
+void
+ContactAppLaunchData::SetMime(const String& mime)
+{
+       __pContactAppLaunchDataImpl->SetMime(mime);
+}
+
+result
+ContactAppLaunchData::SetExtraData(const IMap* pExtraData)
+{
+       return __pContactAppLaunchDataImpl->SetExtraData(pExtraData);
+}
+
+}} // Tizen::Social
diff --git a/src/FSclContactChangeInfo.cpp b/src/FSclContactChangeInfo.cpp
new file mode 100644 (file)
index 0000000..7629643
--- /dev/null
@@ -0,0 +1,113 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclContactChangeInfo.cpp
+ * @brief              This is the implementation for ContactChangeInfo class.
+ *
+ * This file contains definitions of @e ContactChangeInfo class.
+ */
+
+#include <new>
+#include <FBaseResult.h>
+#include <FSclContactChangeInfo.h>
+#include <FBaseSysLog.h>
+#include "FScl_ContactChangeInfoImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Social
+{
+
+ContactChangeInfo::ContactChangeInfo(void)
+{
+       __pContactChangeInfoImpl = new (std::nothrow) _ContactChangeInfoImpl();
+       SysTryReturnVoidResult(NID_SCL, __pContactChangeInfoImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+ContactChangeInfo::ContactChangeInfo(const ContactChangeInfo& rhs)
+{
+       __pContactChangeInfoImpl = new (std::nothrow) _ContactChangeInfoImpl(*rhs.__pContactChangeInfoImpl);
+       SysTryReturnVoidResult(NID_SCL, __pContactChangeInfoImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+ContactChangeInfo::~ContactChangeInfo(void)
+{
+       delete __pContactChangeInfoImpl;
+}
+
+ContactChangeInfo&
+ContactChangeInfo::operator =(const ContactChangeInfo& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pContactChangeInfoImpl = *rhs.__pContactChangeInfoImpl;
+
+       return *this;
+}
+
+bool
+ContactChangeInfo::Equals(const Object& rhs) const
+{
+       const ContactChangeInfo* pContactChangeInfo = dynamic_cast<const ContactChangeInfo*>(&rhs);
+       if (pContactChangeInfo == null)
+       {
+               return false;
+       }
+
+       return *__pContactChangeInfoImpl == *pContactChangeInfo->__pContactChangeInfoImpl;
+}
+
+int
+ContactChangeInfo::GetHashCode(void) const
+{
+       return __pContactChangeInfoImpl->GetHashCode();
+}
+
+AddressbookId
+ContactChangeInfo::GetAddressbookId(void) const
+{
+       return __pContactChangeInfoImpl->GetAddressbookId();
+}
+
+RecordId
+ContactChangeInfo::GetContactId(void) const
+{
+       return __pContactChangeInfoImpl->GetContactId();
+}
+
+int
+ContactChangeInfo::GetVersion(void) const
+{
+       return __pContactChangeInfoImpl->GetVersion();
+}
+
+RecordChangeType
+ContactChangeInfo::GetChangeType(void) const
+{
+       return __pContactChangeInfoImpl->GetChangeType();
+}
+
+bool
+ContactChangeInfo::IsThumbnailChanged(void) const
+{
+       return __pContactChangeInfoImpl->IsThumbnailChanged();
+}
+
+}} // Tizen::Social
diff --git a/src/FSclContactEvent.cpp b/src/FSclContactEvent.cpp
new file mode 100644 (file)
index 0000000..80cabdd
--- /dev/null
@@ -0,0 +1,128 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FSclContactEvent.cpp
+* @brief       This is the implementation for ContactEvent class.
+*
+* This file contains definitions of @e ContactEvent class.
+*/
+
+#include <FSclContactEvent.h>
+#include <FBaseSysLog.h>
+#include "FScl_ContactEventImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+ContactEvent::ContactEvent(void)
+{
+       __pContactEventImpl = new (std::nothrow) _ContactEventImpl();
+       SysTryReturnVoidResult(NID_SCL, __pContactEventImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+ContactEvent::ContactEvent(const ContactEvent& rhs)
+{
+       __pContactEventImpl = new (std::nothrow) _ContactEventImpl(*rhs.__pContactEventImpl);
+       SysTryReturnVoidResult(NID_SCL, __pContactEventImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+ContactEvent::~ContactEvent(void)
+{
+       delete __pContactEventImpl;
+}
+
+ContactEvent&
+ContactEvent::operator =(const ContactEvent& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pContactEventImpl = *rhs.__pContactEventImpl;
+
+       return *this;
+}
+
+bool
+ContactEvent::operator ==(const ContactEvent& rhs) const
+{
+       return *__pContactEventImpl == *rhs.__pContactEventImpl;
+}
+
+bool
+ContactEvent::operator !=(const ContactEvent& rhs) const
+{
+       return !(*this == rhs);
+}
+
+bool
+ContactEvent::Equals(const Object& rhs) const
+{
+       const ContactEvent* pContactEvent = dynamic_cast<const ContactEvent*>(&rhs);
+       if (pContactEvent == null)
+       {
+               return false;
+       }
+
+       return __pContactEventImpl->Equals(*pContactEvent->__pContactEventImpl);
+}
+
+int
+ContactEvent::GetHashCode(void) const
+{
+       return __pContactEventImpl->GetHashCode();
+}
+
+ContactEventType
+ContactEvent::GetType(void) const
+{
+       return __pContactEventImpl->GetType();
+}
+
+DateTime
+ContactEvent::GetDate(void) const
+{
+       return __pContactEventImpl->GetDate();
+}
+
+String
+ContactEvent::GetLabel(void) const
+{
+       return __pContactEventImpl->GetLabel();
+}
+
+void
+ContactEvent::SetType(ContactEventType type)
+{
+       __pContactEventImpl->SetType(type);
+}
+
+void
+ContactEvent::SetDate(const DateTime& date)
+{
+       __pContactEventImpl->SetDate(date);
+}
+
+void
+ContactEvent::SetLabel(const String& label)
+{
+       __pContactEventImpl->SetLabel(label);
+}
+
+}} // Tizen::Social
diff --git a/src/FSclEmail.cpp b/src/FSclEmail.cpp
new file mode 100644 (file)
index 0000000..f50040c
--- /dev/null
@@ -0,0 +1,159 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FSclEmail.cpp
+* @brief       This is the implementation for Email class.
+*
+* This file contains definitions of @e Email class.
+*/
+
+#include <FSclEmail.h>
+#include <FApp_AppInfo.h>
+#include <FBaseSysLog.h>
+#include "FScl_EmailImpl.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+Email::Email(void)
+{
+       __pEmailImpl = new (std::nothrow) _EmailImpl();
+       SysTryReturnVoidResult(NID_SCL, __pEmailImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+Email::Email(EmailType type, const String& email)
+{
+       __pEmailImpl = new (std::nothrow) _EmailImpl(type, email);
+       SysTryReturnVoidResult(NID_SCL, __pEmailImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+Email::Email(const Email& rhs)
+{
+       __pEmailImpl = new (std::nothrow) _EmailImpl(*rhs.__pEmailImpl);
+       SysTryReturnVoidResult(NID_SCL, __pEmailImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+Email::~Email(void)
+{
+       delete __pEmailImpl;
+}
+
+Email&
+Email::operator =(const Email& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pEmailImpl = *rhs.__pEmailImpl;
+
+       return *this;
+}
+
+bool
+Email::operator ==(const Email& rhs) const
+{
+       return *__pEmailImpl == *rhs.__pEmailImpl;
+}
+
+bool
+Email::operator !=(const Email& rhs) const
+{
+       return !(*this == rhs);
+}
+
+bool
+Email::Equals(const Object& rhs) const
+{
+       const Email* pEmail = dynamic_cast<const Email*>(&rhs);
+
+       if (pEmail == null)
+       {
+               return false;
+       }
+
+       return __pEmailImpl->Equals(*pEmail->__pEmailImpl);
+}
+
+int
+Email::GetHashCode(void) const
+{
+       return __pEmailImpl->GetHashCode();
+}
+
+EmailType
+Email::GetType(void) const
+{
+       EmailType type = __pEmailImpl->GetType();
+
+       if (type == EMAIL_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
+       {
+               type =  EMAIL_TYPE_OTHER;
+       }
+
+       return type;
+}
+
+String
+Email::GetLabel(void) const
+{
+       return __pEmailImpl->GetLabel();
+}
+
+String
+Email::GetEmail(void) const
+{
+       String email = __pEmailImpl->GetEmail();
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if (email.GetLength() > MAX_EMAIL_LENGTH)
+               {
+                       email.SetLength(MAX_EMAIL_LENGTH);
+               }
+       }
+
+       return email;
+}
+
+void
+Email::SetType(EmailType type)
+{
+       return __pEmailImpl->SetType(type);
+}
+
+void
+Email::SetLabel(const String& label)
+{
+       return __pEmailImpl->SetLabel(label);
+}
+
+result
+Email::SetEmail(const String& email)
+{
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               SysTryReturnResult(NID_SCL, email.GetLength() <= MAX_EMAIL_LENGTH, E_INVALID_ARG, "The length of the email exceeds the max length.");
+       }
+
+       return __pEmailImpl->SetEmail(email);
+}
+
+}} // Tizen::Social
diff --git a/src/FSclEmailContact.cpp b/src/FSclEmailContact.cpp
new file mode 100644 (file)
index 0000000..6647d4c
--- /dev/null
@@ -0,0 +1,123 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclEmailContact.cpp
+ * @brief              This is the implementation for EmailContact class.
+ *
+ * This file contains definitions of @e EmailContact class.
+ */
+
+#include <new>
+#include <FBaseSysLog.h>
+#include <FSclEmailContact.h>
+#include "FScl_EmailContactImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+EmailContact::EmailContact(void)
+{
+       __pEmailContactImpl = new (std::nothrow) _EmailContactImpl();
+       SysTryReturnVoidResult(NID_SCL, __pEmailContactImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]Not enough memory.");
+}
+
+EmailContact::EmailContact(const EmailContact& rhs)
+{
+       __pEmailContactImpl = new (std::nothrow) _EmailContactImpl(*rhs.__pEmailContactImpl);
+       SysTryReturnVoidResult(NID_SCL, __pEmailContactImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]Not enough memory.");
+}
+
+EmailContact::~EmailContact(void)
+{
+       delete __pEmailContactImpl;
+}
+
+EmailContact&
+EmailContact::operator =(const EmailContact& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pEmailContactImpl = *rhs.__pEmailContactImpl;
+
+       return *this;
+}
+
+bool
+EmailContact::Equals(const Object& obj) const
+{
+       const EmailContact* pEmailContact = dynamic_cast<const EmailContact*>(&obj);
+
+       if (pEmailContact == null)
+       {
+               return false;
+       }
+
+       return *__pEmailContactImpl == *pEmailContact->__pEmailContactImpl;
+}
+
+int
+EmailContact::GetHashCode(void) const
+{
+       return __pEmailContactImpl->GetHashCode();
+}
+
+PersonId
+EmailContact::GetPersonId(void) const
+{
+       return __pEmailContactImpl->GetPersonId();
+}
+
+AddressbookId
+EmailContact::GetAddressbookId(void) const
+{
+       return __pEmailContactImpl->GetAddressbookId();
+}
+
+RecordId
+EmailContact::GetContactId(void) const
+{
+       return __pEmailContactImpl->GetContactId();
+}
+
+String
+EmailContact::GetDisplayName(void) const
+{
+       return __pEmailContactImpl->GetDisplayName();
+}
+
+String
+EmailContact::GetRingtonePath(void) const
+{
+       return __pEmailContactImpl->GetRingtonePath();
+}
+
+String
+EmailContact::GetThumbnailPath(void) const
+{
+       return __pEmailContactImpl->GetThumbnailPath();
+}
+
+Email
+EmailContact::GetEmail(void) const
+{
+       return __pEmailContactImpl->GetEmail();
+}
+}}  // Tizen::Social
diff --git a/src/FSclImAddress.cpp b/src/FSclImAddress.cpp
new file mode 100644 (file)
index 0000000..298ae21
--- /dev/null
@@ -0,0 +1,140 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FSclImAddress.cpp
+* @brief       This is the implementation for ImAddress class.
+*
+* This file contains definitions of @e ImAddress class.
+*/
+
+#include <FSclImAddress.h>
+#include <FApp_AppInfo.h>
+#include <FBaseSysLog.h>
+#include "FScl_ImAddressImpl.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+ImAddress::ImAddress(void)
+{
+       __pImAddressImpl = new (std::nothrow) _ImAddressImpl();
+       SysTryReturnVoidResult(NID_SCL, __pImAddressImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+ImAddress::ImAddress(const String& serviceProviderName, const String& imAddress)
+{
+       __pImAddressImpl = new (std::nothrow) _ImAddressImpl(serviceProviderName, imAddress);
+       SysTryReturnVoidResult(NID_SCL, __pImAddressImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+ImAddress::ImAddress(const ImAddress& rhs)
+{
+       __pImAddressImpl = new (std::nothrow) _ImAddressImpl(*rhs.__pImAddressImpl);
+       SysTryReturnVoidResult(NID_SCL, __pImAddressImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+ImAddress::~ImAddress(void)
+{
+       delete __pImAddressImpl;
+}
+
+ImAddress&
+ImAddress::operator =(const ImAddress& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pImAddressImpl = *rhs.__pImAddressImpl;
+
+       return *this;
+}
+
+bool
+ImAddress::operator ==(const ImAddress& rhs) const
+{
+       return *__pImAddressImpl == *rhs.__pImAddressImpl;
+}
+
+bool
+ImAddress::operator !=(const ImAddress& rhs) const
+{
+       return !(*this  == rhs);
+}
+
+bool
+ImAddress::Equals(const Object& rhs) const
+{
+       const ImAddress* pImAddress = dynamic_cast<const ImAddress*>(&rhs);
+       if (pImAddress == null)
+       {
+               return false;
+       }
+
+       return __pImAddressImpl->Equals(*pImAddress->__pImAddressImpl);
+}
+
+int
+ImAddress::GetHashCode(void) const
+{
+       return __pImAddressImpl->GetHashCode();
+}
+
+String
+ImAddress::GetServiceProviderName(void) const
+{
+       return __pImAddressImpl->GetServiceProviderName();
+}
+
+String
+ImAddress::GetImAddress(void) const
+{
+       String imAddress = __pImAddressImpl->GetImAddress();
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if (imAddress.GetLength() > MAX_IM_ADDRESS_LENGTH)
+               {
+                       imAddress.SetLength(MAX_IM_ADDRESS_LENGTH);
+               }
+       }
+
+       return imAddress;
+}
+
+void
+ImAddress::SetServiceProviderName(const String& serviceProviderName)
+{
+       __pImAddressImpl->SetServiceProviderName(serviceProviderName);
+}
+
+result
+ImAddress::SetImAddress(const String& imAddress)
+{
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               SysTryReturn(NID_SCL, imAddress.GetLength() <= MAX_IM_ADDRESS_LENGTH,
+                               E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The length of the imAddress exceeds MAX_IM_ADDRESS_LENGTH.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       return __pImAddressImpl->SetImAddress(imAddress);
+}
+
+}} // Tizen::Social
diff --git a/src/FSclOrganization.cpp b/src/FSclOrganization.cpp
new file mode 100644 (file)
index 0000000..70b2f5b
--- /dev/null
@@ -0,0 +1,226 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FSclOrganization.cpp
+* @brief       This is the implementation for Organization class.
+*
+* This file contains definitions of @e Organization class.
+*/
+
+#include <FBaseSysLog.h>
+#include <FSclOrganization.h>
+#include <FBaseString.h>
+#include "FScl_OrganizationImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+Organization::Organization(void)
+{
+       __pOrganizationImpl = new (std::nothrow) _OrganizationImpl();
+       SysTryReturnVoidResult(NID_SCL, __pOrganizationImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+Organization::Organization(const Organization& rhs)
+:__pOrganizationImpl(null)
+{
+       __pOrganizationImpl = new (std::nothrow) _OrganizationImpl(*rhs.__pOrganizationImpl);
+       SysTryReturnVoidResult(NID_SCL, __pOrganizationImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+Organization::~Organization(void)
+{
+       delete __pOrganizationImpl;
+}
+
+Organization&
+Organization::operator =(const Organization& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pOrganizationImpl = *rhs.__pOrganizationImpl;
+
+       return *this;
+}
+
+bool
+Organization::operator ==(const Organization& rhs) const
+{
+       return *__pOrganizationImpl == *rhs.__pOrganizationImpl;
+}
+
+bool
+Organization::operator !=(const Organization& rhs) const
+{
+       return !(*this == rhs);
+}
+
+bool
+Organization::Equals(const Object& rhs) const
+{
+       const Organization* pOrganization = dynamic_cast<const Organization*>(&rhs);
+       if (pOrganization == null)
+       {
+               return false;
+       }
+
+       return __pOrganizationImpl->Equals(*pOrganization->__pOrganizationImpl);
+}
+
+int
+Organization::GetHashCode(void) const
+{
+       return __pOrganizationImpl->GetHashCode();
+}
+
+String
+Organization::GetName(void) const
+{
+       return __pOrganizationImpl->GetName();
+}
+
+String
+Organization::GetJobTitle(void) const
+{
+       return __pOrganizationImpl->GetJobTitle();
+}
+
+String
+Organization::GetDepartment(void) const
+{
+       return __pOrganizationImpl->GetDepartment();
+}
+
+String
+Organization::GetRole(void) const
+{
+       return __pOrganizationImpl->GetRole();
+}
+
+String
+Organization::GetAgent(void) const
+{
+       return __pOrganizationImpl->GetAgent();
+}
+
+OrganizationType
+Organization::GetType(void) const
+{
+       return __pOrganizationImpl->GetType();
+}
+
+String
+Organization::GetLabel(void) const
+{
+       return __pOrganizationImpl->GetLabel();
+}
+
+String
+Organization::GetLocation(void) const
+{
+       return __pOrganizationImpl->GetLocation();
+}
+
+String
+Organization::GetDescription(void) const
+{
+       return __pOrganizationImpl->GetDescription();
+}
+
+String
+Organization::GetPhoneticName(void) const
+{
+       return __pOrganizationImpl->GetPhoneticName();
+}
+
+String
+Organization::GetLogoPath(void) const
+{
+       return __pOrganizationImpl->GetLogoPath();
+}
+
+void
+Organization::SetName(const String& name)
+{
+       __pOrganizationImpl->SetName(name);
+}
+
+void
+Organization::SetJobTitle(const String& jobTitle)
+{
+       __pOrganizationImpl->SetJobTitle(jobTitle);
+}
+
+void
+Organization::SetDepartment(const String& department)
+{
+       __pOrganizationImpl->SetDepartment(department);
+}
+
+void
+Organization::SetRole(const String& role)
+{
+       __pOrganizationImpl->SetRole(role);
+}
+
+void
+Organization::SetAgent(const String& agent)
+{
+       __pOrganizationImpl->SetAgent(agent);
+}
+
+void
+Organization::SetType(OrganizationType type)
+{
+       __pOrganizationImpl->SetType(type);
+}
+
+void
+Organization::SetLabel(const String& label)
+{
+       __pOrganizationImpl->SetLabel(label);
+}
+
+void
+Organization::SetLocation(const String& location)
+{
+       __pOrganizationImpl->SetLocation(location);
+}
+
+void
+Organization::SetDescription(const String& description)
+{
+       __pOrganizationImpl->SetDescription(description);
+}
+
+void
+Organization::SetPhoneticName(const String& phoneticName)
+{
+       __pOrganizationImpl->SetPhoneticName(phoneticName);
+}
+
+result
+Organization::SetLogo(const String& filePath)
+{
+       return __pOrganizationImpl->SetLogo(filePath);
+}
+
+}} // Tizen::Social
diff --git a/src/FSclPerson.cpp b/src/FSclPerson.cpp
new file mode 100644 (file)
index 0000000..91a33fb
--- /dev/null
@@ -0,0 +1,166 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclPerson.cpp
+ * @brief              This is the implementation for Profile class.
+ *
+ * This file contains definitions of @e Person class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FSclPerson.h>
+#include <FSclPhoneNumber.h>
+#include <FSclEmail.h>
+#include <FSec_AccessController.h>
+#include "FScl_PersonImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Social
+{
+
+Person::Person(void)
+{
+       _PersonImpl* pPersonImpl = new (std::nothrow) _PersonImpl();
+       SysTryReturnVoidResult(NID_SCL, pPersonImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(GetLastResult()));
+
+       __pPersonImpl = pPersonImpl;
+}
+
+Person::~Person(void)
+{
+       delete __pPersonImpl;
+}
+
+bool
+Person::Equals(const Object& rhs) const
+{
+       const Person* pPerson = dynamic_cast<const Person*>(&rhs);
+       if (pPerson == null)
+       {
+               return false;
+       }
+
+       return __pPersonImpl->Equals(*pPerson->__pPersonImpl);;
+}
+
+int
+Person::GetHashCode(void) const
+{
+       return __pPersonImpl->GetHashCode();
+}
+
+String
+Person::GetDisplayName(void) const
+{
+       return __pPersonImpl->GetDisplayName();
+}
+
+PersonId
+Person::GetId(void) const
+{
+       return __pPersonImpl->GetId();
+}
+
+result
+Person::SetAsFavorite(bool isFavorite)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+
+       return __pPersonImpl->SetAsFavorite(isFavorite);
+}
+
+bool
+Person::IsFavorite(void) const
+{
+       return __pPersonImpl->IsFavorite();
+}
+
+String
+Person::GetThumbnailPath(void) const
+{
+       return  __pPersonImpl->GetThumbnailPath();
+}
+
+String
+Person::GetRingtonePath(void) const
+{
+       return __pPersonImpl->GetRingtonePath();
+}
+
+bool
+Person::HasPhoneNumber(void) const
+{
+       return __pPersonImpl->HasPhoneNumber();
+}
+
+bool
+Person::HasEmail(void) const
+{
+       return __pPersonImpl->HasEmail();
+}
+
+IListT<AccountId>*
+Person::GetAccountIdsN(void) const
+{
+       return __pPersonImpl->GetAccountIdsN();
+}
+
+result
+Person::SetAsPrimaryPhoneNumber(const PhoneNumber& phoneNumber)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+
+       return __pPersonImpl->SetAsPrimaryPhoneNumber(phoneNumber);     
+}
+
+result
+Person::SetAsPrimaryEmail(const Email& email)
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+
+       return __pPersonImpl->SetAsPrimaryEmail(email);
+}
+
+PhoneNumber
+Person::GetPrimaryPhoneNumber(void) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, PhoneNumber(), r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+
+       return __pPersonImpl->GetPrimaryPhoneNumber();
+}
+
+Email
+Person::GetPrimaryEmail(void) const
+{
+       result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, Email(), r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+
+       return __pPersonImpl->GetPrimaryEmail();
+}
+
+}} // Tizen::Social
diff --git a/src/FSclPhoneNumber.cpp b/src/FSclPhoneNumber.cpp
new file mode 100644 (file)
index 0000000..cff701f
--- /dev/null
@@ -0,0 +1,159 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FSclPhoneNumber.cpp
+* @brief               This is the implementation for PhoneNumber class.
+*
+* This file contains definitions of @e PhoneNumber class.
+*/
+
+#include <FSclPhoneNumber.h>
+#include <FBaseSysLog.h>
+#include <FApp_AppInfo.h>
+#include "FScl_PhoneNumberImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::App;
+
+namespace Tizen { namespace Social
+{
+
+PhoneNumber::PhoneNumber(void)
+{
+       __pPhoneNumberImpl = new (std::nothrow) _PhoneNumberImpl();
+       SysTryReturnVoidResult(NID_SCL, __pPhoneNumberImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+PhoneNumber::PhoneNumber(PhoneNumberType type, const String& number)
+{
+       __pPhoneNumberImpl = new (std::nothrow) _PhoneNumberImpl(type, number);
+       SysTryReturnVoidResult(NID_SCL, __pPhoneNumberImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+PhoneNumber::PhoneNumber(const PhoneNumber& rhs)
+{
+       __pPhoneNumberImpl = new (std::nothrow) _PhoneNumberImpl(*rhs.__pPhoneNumberImpl);
+       SysTryReturnVoidResult(NID_SCL, __pPhoneNumberImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+PhoneNumber::~PhoneNumber(void)
+{
+       delete __pPhoneNumberImpl;
+}
+
+PhoneNumber&
+PhoneNumber::operator =(const PhoneNumber& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pPhoneNumberImpl = *rhs.__pPhoneNumberImpl;
+
+       return *this;
+}
+
+bool
+PhoneNumber::operator ==(const PhoneNumber& rhs) const
+{
+       return *__pPhoneNumberImpl == *rhs.__pPhoneNumberImpl;
+}
+
+bool
+PhoneNumber::operator !=(const PhoneNumber& rhs) const
+{
+       return !(*this == rhs);
+}
+
+bool
+PhoneNumber::Equals(const Object& rhs) const
+{
+       const PhoneNumber* pPhoneNumber = dynamic_cast<const PhoneNumber*>(&rhs);
+       if (pPhoneNumber == null)
+       {
+               return false;
+       }
+
+       return *this == *pPhoneNumber;
+}
+
+int
+PhoneNumber::GetHashCode(void) const
+{
+       return __pPhoneNumberImpl->GetHashCode();
+}
+
+PhoneNumberType
+PhoneNumber::GetType(void) const
+{
+       PhoneNumberType type =  __pPhoneNumberImpl->GetType();
+       if (type == PHONENUMBER_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
+       {
+               type =  PHONENUMBER_TYPE_OTHER;
+       }
+
+       return type;
+}
+
+String
+PhoneNumber::GetLabel(void) const
+{
+       return __pPhoneNumberImpl->GetLabel();
+}
+
+String
+PhoneNumber::GetPhoneNumber(void) const
+{
+       String phoneNumber =  __pPhoneNumberImpl->GetPhoneNumber();
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if (phoneNumber.GetLength() > MAX_PHONE_NUMBER_LENGTH)
+               {
+                       phoneNumber.SetLength(MAX_PHONE_NUMBER_LENGTH);
+               }
+       }
+
+       return phoneNumber;
+}
+
+
+void
+PhoneNumber::SetType(PhoneNumberType type)
+{
+       __pPhoneNumberImpl->SetType(type);
+}
+
+void
+PhoneNumber::SetLabel(const String& label)
+{
+       __pPhoneNumberImpl->SetLabel(label);
+}
+
+result
+PhoneNumber::SetPhoneNumber(const String& number)
+{
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               SysTryReturn(NID_SCL, number.GetLength() <= MAX_PHONE_NUMBER_LENGTH,
+                               E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The length of the number exceeds MAX_PHONE_NUMBER_LENGTH.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       return __pPhoneNumberImpl->SetPhoneNumber(number);
+}
+
+}} // Tizen::Social
diff --git a/src/FSclPhoneNumberContact.cpp b/src/FSclPhoneNumberContact.cpp
new file mode 100644 (file)
index 0000000..5195eb0
--- /dev/null
@@ -0,0 +1,123 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclPhoneNumberContact.cpp
+ * @brief              This is the implementation for PhoneNumberContact class.
+ *
+ * This file contains definitions of @e PhoneNumberContact class.
+ */
+
+#include <new>
+#include <FBaseSysLog.h>
+#include <FSclPhoneNumberContact.h>
+#include "FScl_PhoneNumberContactImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+PhoneNumberContact::PhoneNumberContact(void)
+{
+       __pPhoneNumberContactImpl = new (std::nothrow) _PhoneNumberContactImpl();
+       SysTryReturnVoidResult(NID_SCL, __pPhoneNumberContactImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+PhoneNumberContact::PhoneNumberContact(const PhoneNumberContact& rhs)
+{
+       __pPhoneNumberContactImpl = new (std::nothrow) _PhoneNumberContactImpl(*rhs.__pPhoneNumberContactImpl);
+       SysTryReturnVoidResult(NID_SCL, __pPhoneNumberContactImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+PhoneNumberContact::~PhoneNumberContact(void)
+{
+       delete __pPhoneNumberContactImpl;
+}
+
+PhoneNumberContact&
+PhoneNumberContact::operator =(const PhoneNumberContact& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pPhoneNumberContactImpl = *rhs.__pPhoneNumberContactImpl;
+
+       return *this;
+}
+
+bool
+PhoneNumberContact::Equals(const Object& obj) const
+{
+       const PhoneNumberContact* pPhoneNumberContact = dynamic_cast<const PhoneNumberContact*>(&obj);
+
+       if (pPhoneNumberContact == null)
+       {
+               return false;
+       }
+
+       return *__pPhoneNumberContactImpl == *pPhoneNumberContact->__pPhoneNumberContactImpl;
+}
+
+int
+PhoneNumberContact::GetHashCode(void) const
+{
+       return __pPhoneNumberContactImpl->GetHashCode();
+}
+
+PersonId
+PhoneNumberContact::GetPersonId(void) const
+{
+       return __pPhoneNumberContactImpl->GetPersonId();
+}
+
+AddressbookId
+PhoneNumberContact::GetAddressbookId(void) const
+{
+       return __pPhoneNumberContactImpl->GetAddressbookId();
+}
+
+RecordId
+PhoneNumberContact::GetContactId(void) const
+{
+       return __pPhoneNumberContactImpl->GetContactId();
+}
+
+String
+PhoneNumberContact::GetDisplayName(void) const
+{
+       return __pPhoneNumberContactImpl->GetDisplayName();
+}
+
+String
+PhoneNumberContact::GetRingtonePath(void) const
+{
+       return __pPhoneNumberContactImpl->GetRingtonePath();
+}
+
+String
+PhoneNumberContact::GetThumbnailPath(void) const
+{
+       return __pPhoneNumberContactImpl->GetThumbnailPath();
+}
+
+PhoneNumber
+PhoneNumberContact::GetPhoneNumber(void) const
+{
+       return __pPhoneNumberContactImpl->GetPhoneNumber();
+}
+}}  // Tizen::Social
diff --git a/src/FSclRecord.cpp b/src/FSclRecord.cpp
new file mode 100644 (file)
index 0000000..743fd67
--- /dev/null
@@ -0,0 +1,72 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclRecord.cpp
+ * @brief              This is the implementation for Record class.
+ *
+ * This file contains definitions of @e Record class.
+ */
+
+#include <FSclRecord.h>
+#include <FBaseSysLog.h>
+#include "FScl_RecordImpl.h"
+
+namespace Tizen { namespace Social
+{
+
+Record::Record(RecordType type)
+{
+       __pRecordImpl = new (std::nothrow) _RecordImpl(type);
+       SysTryReturnVoidResult(NID_SCL, __pRecordImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+Record::Record(const Record& rhs)
+{
+       __pRecordImpl = new (std::nothrow) _RecordImpl(*rhs.__pRecordImpl);
+       SysTryReturnVoidResult(NID_SCL, __pRecordImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+Record&
+Record::operator =(const Record& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pRecordImpl = *rhs.__pRecordImpl;
+
+       return *this;
+}
+
+Record::~Record()
+{
+       delete __pRecordImpl;
+}
+
+RecordType
+Record::GetRecordType(void) const
+{
+       return __pRecordImpl->GetRecordType();
+}
+
+RecordId
+Record::GetRecordId(void) const
+{
+       return __pRecordImpl->GetRecordId();
+}
+
+}}  // Tizen::Social
diff --git a/src/FSclRecurrence.cpp b/src/FSclRecurrence.cpp
new file mode 100644 (file)
index 0000000..ec4a5eb
--- /dev/null
@@ -0,0 +1,237 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclRecurrence.cpp
+ * @brief              This is the implementation for Recurrence class.
+ *
+ * This file contains definitions of @e Recurrence class.
+ */
+
+#include <new>
+#include <FBaseColIList.h>
+#include <FSclRecurrence.h>
+#include <FBaseSysLog.h>
+#include "FScl_RecurrenceImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Social
+{
+
+Recurrence::Recurrence(void)
+       : __pRecurrenceImpl(null)
+{
+       __pRecurrenceImpl = new (std::nothrow) _RecurrenceImpl();
+       SysTryReturnVoidResult(NID_SCL, __pRecurrenceImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+Recurrence::Recurrence(const Recurrence& rhs)
+       : __pRecurrenceImpl(null)
+{
+       __pRecurrenceImpl = new (std::nothrow) _RecurrenceImpl(*rhs.__pRecurrenceImpl);
+       SysTryReturnVoidResult(NID_SCL, __pRecurrenceImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+Recurrence::~Recurrence(void)
+{
+       delete __pRecurrenceImpl;
+}
+
+Recurrence&
+Recurrence::operator =(const Recurrence& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pRecurrenceImpl = *rhs.__pRecurrenceImpl;
+
+       return *this;
+}
+
+bool
+Recurrence::Equals(const Object& rhs) const
+{
+       const Recurrence* pRecurrence = dynamic_cast<const Recurrence*>(&rhs);
+       if (pRecurrence == null)
+       {
+               return false;
+       }
+
+       return __pRecurrenceImpl->Equals(*_RecurrenceImpl::GetInstance(*pRecurrence));
+}
+
+int
+Recurrence::GetHashCode(void) const
+{
+       return __pRecurrenceImpl->GetHashCode();
+}
+
+RecurFrequency
+Recurrence::GetFrequency(void) const
+{
+       return __pRecurrenceImpl->GetFrequency();
+}
+
+int
+Recurrence::GetInterval(void) const
+{
+       return __pRecurrenceImpl->GetInterval();
+}
+
+const DateTime*
+Recurrence::GetUntil(void) const
+{
+       return __pRecurrenceImpl->GetUntil();
+}
+
+int
+Recurrence::GetCounts(void) const
+{
+       return __pRecurrenceImpl->GetCounts();
+}
+
+CalDayOfWeek
+Recurrence::GetWeekStart(void) const
+{
+       return __pRecurrenceImpl->GetWeekStart();
+}
+
+int
+Recurrence::GetDayOfWeek(void) const
+{
+       return __pRecurrenceImpl->GetDayOfWeek();
+}
+
+int
+Recurrence::GetDayOfMonth(void) const
+{
+       return __pRecurrenceImpl->GetDayOfMonth();
+}
+
+int
+Recurrence::GetWeekOfMonth(void) const
+{
+       return __pRecurrenceImpl->GetWeekOfMonth();
+}
+
+int
+Recurrence::GetMonthOfYear(void)const
+{
+       return __pRecurrenceImpl->GetMonthOfYear();
+}
+
+void
+Recurrence::SetFrequency(RecurFrequency type)
+{
+       __pRecurrenceImpl->SetFrequency(type);
+}
+
+result
+Recurrence::SetInterval(int interval)
+{
+       result r = __pRecurrenceImpl->SetInterval(interval);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Recurrence::SetUntil(const DateTime* pUntil)
+{
+       result r = __pRecurrenceImpl->SetUntil(pUntil);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Recurrence::SetCounts(int count)
+{
+       result r = __pRecurrenceImpl->SetCounts(count);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Recurrence::SetWeekStart(CalDayOfWeek weekStart)
+{
+       result r = __pRecurrenceImpl->SetWeekStart(weekStart);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Recurrence::SetDayOfWeek(int day)
+{
+       result r = __pRecurrenceImpl->SetDayOfWeek(day);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Recurrence::SetDayOfMonth(int day)
+{
+       result r = __pRecurrenceImpl->SetDayOfMonth(day);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Recurrence::SetWeekOfMonth(int week)
+{
+       result r = __pRecurrenceImpl->SetWeekOfMonth(week);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+
+result
+Recurrence::SetMonthOfYear(int month)
+{
+       result r = __pRecurrenceImpl->SetMonthOfYear(month);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+Recurrence::AddExceptionDate(const DateTime& exceptionDate)
+{
+       result r = __pRecurrenceImpl->AddExceptionDate(exceptionDate);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+IList*
+Recurrence::GetExceptionDatesN(void) const
+{
+       IList* pList = __pRecurrenceImpl->GetExceptionDatesN();
+       result r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pList;
+}
+
+}}     // Tizen::Social
diff --git a/src/FSclRelationship.cpp b/src/FSclRelationship.cpp
new file mode 100644 (file)
index 0000000..f050f55
--- /dev/null
@@ -0,0 +1,133 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FSclRelationship.cpp
+* @brief       This is the implementation for Relationship class.
+*
+* This file contains definitions of @e Relationship class.
+*/
+
+#include <FBaseSysLog.h>
+#include <FSclRelationship.h>
+#include "FScl_RelationshipImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+Relationship::Relationship(void)
+{
+       __pRelationshipImpl = new (std::nothrow) _RelationshipImpl();
+       SysTryReturnVoidResult(NID_SCL, __pRelationshipImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+Relationship::Relationship(const Relationship& rhs)
+{
+       __pRelationshipImpl = new (std::nothrow) _RelationshipImpl(*rhs.__pRelationshipImpl);
+       SysTryReturnVoidResult(NID_SCL, __pRelationshipImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+Relationship::~Relationship(void)
+{
+       delete __pRelationshipImpl;
+}
+
+Relationship&
+Relationship::operator =(const Relationship& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pRelationshipImpl = *rhs.__pRelationshipImpl;
+
+       return *this;
+}
+
+bool
+Relationship::operator ==(const Relationship& rhs) const
+{
+       if (__name != rhs.__name)
+       {
+               return false;
+       }
+
+       return *__pRelationshipImpl == *rhs.__pRelationshipImpl;;
+}
+
+bool
+Relationship::operator !=(const Relationship& rhs) const
+{
+       return !(*this == rhs);
+}
+
+bool
+Relationship::Equals(const Object& rhs) const
+{
+       const Relationship* pRelationship = dynamic_cast<const Relationship*>(&rhs);
+       if (pRelationship == null)
+       {
+               return false;
+       }
+
+       return *this == *pRelationship;
+}
+
+int
+Relationship::GetHashCode(void) const
+{
+       return __pRelationshipImpl->GetHashCode();
+}
+
+RelationshipType
+Relationship::GetType(void) const
+{
+       return __pRelationshipImpl->GetType();
+}
+
+String
+Relationship::GetRelativeName(void) const
+{
+       return __pRelationshipImpl->GetRelativeName();
+}
+
+String
+Relationship::GetLabel(void) const
+{
+       return __pRelationshipImpl->GetLabel();
+}
+
+void
+Relationship::SetType(RelationshipType type)
+{
+       __pRelationshipImpl->SetType(type);
+}
+
+void
+Relationship::SetRelativeName(const String& name)
+{
+       __pRelationshipImpl->SetRelativeName(name);
+}
+
+void
+Relationship::SetLabel(const String& label)
+{
+       __pRelationshipImpl->SetLabel(label);
+}
+
+}} // Tizen::Social
diff --git a/src/FSclReminder.cpp b/src/FSclReminder.cpp
new file mode 100644 (file)
index 0000000..897b3cc
--- /dev/null
@@ -0,0 +1,248 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclReminder.cpp
+ * @brief              This is the implementation for Reminder class.
+ *
+ * This file contains definitions of @e Reminder class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FBaseDateTime.h>
+#include <FIoFile.h>
+#include <FSclReminder.h>
+#include <FApp_AppInfo.h>
+#include <FIo_FileImpl.h>
+#include "FScl_ReminderImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::App;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Social
+{
+
+static const int _MINUTES_OF_HOUR = 60;
+static const int _MINUTES_OF_DAY = 1440;
+static const int _MINUTES_OF_WEEK = 10080;
+
+Reminder::Reminder(void)
+       : __timeUnit(REMINDER_TIME_UNIT_MINUTE)
+       , __timeOffset(0)
+       , __pReminderImpl(null)
+{
+       __pReminderImpl = new (std::nothrow) _ReminderImpl();
+       SysTryReturnVoidResult(NID_SCL, __pReminderImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+Reminder::Reminder(const Reminder& rhs)
+       : __soundFilePath(rhs.__soundFilePath)
+       , __timeUnit(rhs.__timeUnit)
+       , __timeOffset(rhs.__timeOffset)
+       , __pReminderImpl(null)
+{
+       __pReminderImpl = new (std::nothrow) _ReminderImpl(*rhs.__pReminderImpl);
+       SysTryReturnVoidResult(NID_SCL, __pReminderImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+Reminder::~Reminder(void)
+{
+       delete __pReminderImpl;
+}
+
+Reminder&
+Reminder::operator =(const Reminder& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __timeUnit = rhs.__timeUnit;
+       __timeOffset = rhs.__timeOffset;
+       __soundFilePath = rhs.__soundFilePath;
+       *__pReminderImpl = *rhs.__pReminderImpl;
+
+       return *this;
+}
+
+bool
+Reminder::Equals(const Object& rhs) const
+{
+       const Reminder* pReminder = dynamic_cast<const Reminder*>(&rhs);
+
+       if (pReminder == null)
+       {
+               return false;
+       }
+
+       return (__timeUnit == pReminder->__timeUnit && __timeOffset == pReminder->__timeOffset
+                       && __soundFilePath == pReminder->__soundFilePath && __pReminderImpl->Equals(*pReminder->__pReminderImpl));
+}
+
+int
+Reminder::GetHashCode(void) const
+{
+       int hashCode = 17;
+
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __timeUnit;
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __timeOffset;
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __soundFilePath.GetHashCode();
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __pReminderImpl->GetHashCode();
+
+       return hashCode;
+}
+
+int
+Reminder::GetMinutesBefore(void) const
+{
+       int minutes = 0;
+
+       switch (__timeUnit)
+       {
+       case REMINDER_TIME_UNIT_MINUTE:
+               minutes = __timeOffset;
+               break;
+       case REMINDER_TIME_UNIT_HOUR:
+               minutes = __timeOffset * _MINUTES_OF_HOUR;
+               break;
+       case REMINDER_TIME_UNIT_DAY:
+               minutes = __timeOffset * _MINUTES_OF_DAY;
+               break;
+       case REMINDER_TIME_UNIT_WEEK:
+               minutes = __timeOffset * _MINUTES_OF_WEEK;
+               break;
+       default:
+               break;
+       }
+
+       return minutes;
+}
+
+String
+Reminder::GetSoundFile(void) const
+{
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               String tmpFilePath;
+               _FileImpl::ConvertPhysicalToVirtualPath(__soundFilePath, tmpFilePath);
+
+               ClearLastResult();
+
+               return tmpFilePath;
+       }
+
+       return __soundFilePath;
+}
+
+result
+Reminder::SetMinutesBefore(int minutes)
+{
+       SysTryReturnResult(NID_SCL, minutes >= 0, E_INVALID_ARG, "Invalid argument is used. The minutes is less than 0.");
+       SysTryReturnResult(NID_SCL, minutes <= MAX_REMINDER_OFFSET_VALUE, E_INVALID_ARG, "Invalid argument is used. The minutes is greater than 40320.");
+
+       __timeUnit = REMINDER_TIME_UNIT_MINUTE;
+       __timeOffset = minutes;
+
+       __pReminderImpl->__absoluteTime = DateTime::GetMinValue();
+       __pReminderImpl->__isAbsolute = false;
+
+       return E_SUCCESS;
+}
+
+result
+Reminder::SetSoundFile(const String& filePath)
+{
+       if (filePath.IsEmpty())
+       {
+               __soundFilePath.Clear();
+       }
+       else
+       {
+               SysTryReturnResult(NID_SCL, File::IsFileExist(filePath), E_INVALID_ARG
+                                       , "Invalid argument is used. The length of the filePath exceeds the maximum length or the file path is invalid or the file does not exist.");
+
+               result r = E_SUCCESS;
+               String tmpFilePath;
+
+               if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+               {
+                       r = _FileImpl::ConvertVirtualToPhysicalPath(filePath, tmpFilePath);
+                       SysTryReturn(NID_SCL, r == E_SUCCESS, E_INVALID_ARG,  E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+               }
+               else
+               {
+                       tmpFilePath = filePath;
+               }
+
+               __soundFilePath = tmpFilePath;
+       }
+
+       return E_SUCCESS;
+}
+
+result
+Reminder::SetTimeOffset(ReminderTimeUnit timeUnit, int timeOffset)
+{
+       SysTryReturnResult(NID_SCL, timeUnit != REMINDER_TIME_UNIT_NONE, E_INVALID_ARG, "Invalid argument is used. The timeUnit is REMINDER_TIME_UNIT_NONE.");
+       SysTryReturnResult(NID_SCL, timeOffset >= 0, E_INVALID_ARG,     "Invalid argument is used. The timeOffset is less than 0.");
+
+       __timeUnit = timeUnit;
+       __timeOffset = timeOffset;
+
+       __pReminderImpl->__absoluteTime = DateTime::GetMinValue();
+       __pReminderImpl->__isAbsolute = false;
+
+       return E_SUCCESS;
+}
+
+ReminderTimeUnit
+Reminder::GetTimeUnit(void) const
+{
+       return __timeUnit;
+}
+
+int
+Reminder::GetTimeOffset(void) const
+{
+       return __timeOffset;
+}
+
+result
+Reminder::SetAbsoluteTime(const DateTime& time)
+{
+       result r = __pReminderImpl->SetAbsoluteTime(time);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __timeUnit = REMINDER_TIME_UNIT_NONE;
+       __timeOffset = 0;
+
+       return E_SUCCESS;
+}
+
+DateTime
+Reminder::GetAbsoluteTime(void) const
+{
+       return __pReminderImpl->GetAbsoluteTime();
+}
+
+bool
+Reminder::IsAbsolute(void) const
+{
+       return __pReminderImpl->IsAbsolute();
+}
+
+}}  // Tizen::Social
diff --git a/src/FSclUrl.cpp b/src/FSclUrl.cpp
new file mode 100644 (file)
index 0000000..a7fed52
--- /dev/null
@@ -0,0 +1,159 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclUrl.cpp
+ * @brief              This is the implementation for Url class.
+ *
+ * This file contains definitions of @e Url class.
+ */
+
+#include <FSclUrl.h>
+#include <FApp_AppInfo.h>
+#include <FBaseSysLog.h>
+#include "FScl_UrlImpl.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+Url::Url(void)
+{
+       __pUrlImpl = new (std::nothrow) _UrlImpl();
+       SysTryReturnVoidResult(NID_SCL, __pUrlImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+Url::Url(UrlType type, const String& url)
+{
+       __pUrlImpl = new (std::nothrow) _UrlImpl(type, url);
+       SysTryReturnVoidResult(NID_SCL, __pUrlImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+Url::Url(const Url& rhs)
+{
+       __pUrlImpl = new (std::nothrow) _UrlImpl(*rhs.__pUrlImpl);
+       SysTryReturnVoidResult(NID_SCL, __pUrlImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+Url::~Url(void)
+{
+       delete __pUrlImpl;
+}
+
+Url&
+Url::operator =(const Url& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pUrlImpl = *rhs.__pUrlImpl;
+
+       return *this;
+}
+
+bool
+Url::operator ==(const Url& rhs) const
+{
+       return *__pUrlImpl == *rhs.__pUrlImpl;
+}
+
+bool
+Url::operator !=(const Url& rhs) const
+{
+       return !(*this == rhs);
+}
+
+bool
+Url::Equals(const Object& rhs) const
+{
+       const Url* pUrl = dynamic_cast<const Url*>(&rhs);
+
+       if (pUrl == null)
+       {
+               return false;
+       }
+
+       return __pUrlImpl->Equals(*pUrl->__pUrlImpl);
+}
+
+int
+Url::GetHashCode(void) const
+{
+       return __pUrlImpl->GetHashCode();
+}
+
+UrlType
+Url::GetType(void) const
+{
+       UrlType type =  __pUrlImpl->GetType();
+
+       if (type == URL_TYPE_CUSTOM  && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
+       {
+               type =  URL_TYPE_OTHER;
+       }
+
+       return type;
+}
+
+String
+Url::GetUrl(void) const
+{
+       String url = __pUrlImpl->GetUrl();
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if (url.GetLength() > MAX_URL_LENGTH)
+               {
+                       url.SetLength(MAX_URL_LENGTH);
+               }
+       }
+
+       return url;
+}
+
+void
+Url::SetType(UrlType type)
+{
+       __pUrlImpl->SetType(type);
+}
+
+result
+Url::SetUrl(const String& url)
+{
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               SysTryReturn(NID_SCL, url.GetLength() <= MAX_URL_LENGTH, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The length of the url exceeds MAX_URL_LENGTH", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       return __pUrlImpl->SetUrl(url);
+}
+
+String
+Url::GetLabel(void) const
+{
+       return __pUrlImpl->GetLabel();
+}
+
+void
+Url::SetLabel(const String& label)
+{
+       __pUrlImpl->SetLabel(label);
+}
+
+}} // Tizen::Social
diff --git a/src/FSclUserProfile.cpp b/src/FSclUserProfile.cpp
new file mode 100644 (file)
index 0000000..8cd1e1b
--- /dev/null
@@ -0,0 +1,324 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FSclUserProfile.cpp
+ * @brief              This is the implementation for Profile class.
+ *
+ * This file contains definitions of @e UserProfile class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FSclAddress.h>
+#include <FSclPhoneNumber.h>
+#include <FSclEmail.h>
+#include <FSclUrl.h>
+#include <FSclImAddress.h>
+#include <FSclOrganization.h>
+#include <FSclContactEvent.h>
+#include <FSclRelationship.h>
+#include <FSclUserProfile.h>
+#include "FScl_UserProfileImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Graphics;
+
+namespace Tizen { namespace Social
+{
+
+UserProfile::UserProfile(void)
+{
+       __pUserProfileImpl = new (std::nothrow) _UserProfileImpl();
+       SysTryReturnVoidResult(NID_SCL, __pUserProfileImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+UserProfile::UserProfile(const UserProfile& rhs)
+{
+       __pUserProfileImpl = new (std::nothrow) _UserProfileImpl(*rhs.__pUserProfileImpl);
+       SysTryReturnVoidResult(NID_SCL, __pUserProfileImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+UserProfile::~UserProfile(void)
+{
+       delete __pUserProfileImpl;
+}
+
+UserProfile&
+UserProfile::operator =(const UserProfile& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pUserProfileImpl = *rhs.__pUserProfileImpl;
+
+       return *this;
+}
+
+bool
+UserProfile::Equals(const Object& rhs) const
+{
+       const UserProfile* pUserProfile = dynamic_cast<const UserProfile*>(&rhs);
+       if (pUserProfile == null)
+       {
+               return false;
+       }
+
+       return __pUserProfileImpl->Equals(*_UserProfileImpl::GetInstance(*pUserProfile));
+}
+
+int
+UserProfile::GetHashCode(void) const
+{
+       return __pUserProfileImpl->GetHashCode();
+}
+
+AddressbookId
+UserProfile::GetAddressbookId(void) const
+{
+       return __pUserProfileImpl->GetAddressbookId();
+}
+
+String
+UserProfile::GetThumbnailPath(void) const
+{
+       return  __pUserProfileImpl->GetThumbnailPath();
+}
+
+result
+UserProfile::SetThumbnail(const String& filePath)
+{
+       result r = __pUserProfileImpl->SetThumbnail(filePath);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+String
+UserProfile::GetValue(UserProfilePropertyId id) const
+{
+       return __pUserProfileImpl->GetValue(id);
+}
+
+result
+UserProfile::SetValue(UserProfilePropertyId id, const String& value)
+{
+       result r = __pUserProfileImpl->SetValue(id, value);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+UserProfile::AddNote(const String& note)
+{
+       result r = __pUserProfileImpl->AddNote(note);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+UserProfile::AddNickname(const String& nickname)
+{
+       result r = __pUserProfileImpl->AddNickname(nickname);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+UserProfile::AddPhoneNumber(const PhoneNumber& phoneNumber)
+{
+       result r = __pUserProfileImpl->AddPhoneNumber(phoneNumber);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+UserProfile::AddEmail(const Email& email)
+{
+       result r = __pUserProfileImpl->AddEmail(email);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+UserProfile::AddUrl(const Url& url)
+{
+       result r = __pUserProfileImpl->AddUrl(url);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+UserProfile::AddAddress(const Address& address)
+{
+       result r = __pUserProfileImpl->AddAddress(address);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+UserProfile::AddImAddress(const ImAddress& imAddress)
+{
+       result r = __pUserProfileImpl->AddImAddress(imAddress);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+UserProfile::AddOrganization(const Organization& organization)
+{
+       result r = __pUserProfileImpl->AddOrganization(organization);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+UserProfile::AddEvent(const ContactEvent& event)
+{
+       result r = __pUserProfileImpl->AddEvent(event);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+UserProfile::AddRelationship(const Relationship& relationship)
+{
+       result r = __pUserProfileImpl->AddRelationship(relationship);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+UserProfile::RemoveAt(UserProfileMultiPropertyId id, int index)
+{
+       result r = __pUserProfileImpl->RemoveAt(id, index);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+IList*
+UserProfile::GetValuesN(UserProfileMultiPropertyId id) const
+{
+       IList* pList = __pUserProfileImpl->GetValuesN(id);
+       SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+result
+UserProfile::SetNoteAt(int index, const String& note)
+{
+       result r = __pUserProfileImpl->SetNoteAt(index, note);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+UserProfile::SetNicknameAt(int index, const String& nickname)
+{
+       result r = __pUserProfileImpl->SetNicknameAt(index, nickname);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+UserProfile::SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber)
+{
+       result r = __pUserProfileImpl->SetPhoneNumberAt(index, phoneNumber);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+UserProfile::SetEmailAt(int index, const Email& email)
+{
+       result r = __pUserProfileImpl->SetEmailAt(index, email);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+UserProfile::SetEventAt(int index, const ContactEvent& event)
+{
+       result r = __pUserProfileImpl->SetEventAt(index, event);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+UserProfile::SetOrganizationAt(int index, const Organization& organization)
+{
+       result r = __pUserProfileImpl->SetOrganizationAt(index, organization);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+UserProfile::SetUrlAt(int index, const Url& url)
+{
+       result r = __pUserProfileImpl->SetUrlAt(index, url);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+UserProfile::SetAddressAt(int index, const Address& address)
+{
+       result r = __pUserProfileImpl->SetAddressAt(index, address);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+UserProfile::SetImAddressAt(int index, const ImAddress& imAddress)
+{
+       result r = __pUserProfileImpl->SetImAddressAt(index, imAddress);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+UserProfile::SetRelationshipAt(int index, const Relationship& relationship)
+{
+       result r = __pUserProfileImpl->SetRelationshipAt(index, relationship);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+}} // Tizen::Social
diff --git a/src/FScl_AccountAccessorImpl.cpp b/src/FScl_AccountAccessorImpl.cpp
new file mode 100644 (file)
index 0000000..42cb880
--- /dev/null
@@ -0,0 +1,353 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_AccountAccessorImpl.cpp
+ * @brief              This is the implementation for _AccountAccessorImpl class.
+ *
+ * This file contains definitions of @e _AccountAccessorImpl class.
+ */
+
+#include <new>
+#include <unique_ptr.h>
+#include <account.h>
+#include <FBaseColArrayList.h>
+#include <FBaseResult.h>
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include <FSclAccount.h>
+#include <FSclAccountAccessor.h>
+#include <FSclAccountProvider.h>
+#include <FSclIAccountEventListener.h>
+#include "FScl_AccountImpl.h"
+#include "FScl_AccountAccessorImpl.h"
+#include "FScl_AccountDbConnector.h"
+#include "FScl_AccountDbMonitor.h"
+#include "FScl_AccountManagerUtil.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Social
+{
+
+bool
+OnAccountReceived(account_h accountHandle, void* pUserData)
+{
+       SysTryReturn(NID_SCL, accountHandle != null && pUserData != null, false, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       ArrayList* pAccountList = static_cast<ArrayList*> (pUserData);
+
+       std::unique_ptr<Account> pAccount(_AccountManagerUtil::ConvertAccountHandleToAccountN(accountHandle));
+       SysTryReturn(NID_SCL, pAccount != null, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       result r = pAccountList->Add(pAccount.get());
+       SysTryReturn(NID_SCL, !IsFailed(r), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       pAccount.release();
+
+       return true;
+}
+
+bool
+OnAccountTypeReceived(account_type_h accountTypeHandle, void* pUserData)
+{
+       SysTryReturn(NID_SCL, accountTypeHandle != null && pUserData != null, false, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       ArrayList* pAccountProviderList = static_cast<ArrayList*> (pUserData);
+
+       std::unique_ptr<AccountProvider> pAccountProvider(_AccountManagerUtil::ConvertAccountTypeHandleToAccountProviderN(accountTypeHandle));
+       SysTryReturn(NID_SCL, pAccountProvider != null, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       result r = pAccountProviderList->Add(pAccountProvider.get());
+       SysTryReturn(NID_SCL, !IsFailed(r), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       pAccountProvider.release();
+
+       return true;
+}
+
+_AccountAccessorImpl::_AccountAccessorImpl(void)
+       : __pIAccountEventListener(null)
+{
+       // empty body
+}
+
+_AccountAccessorImpl::~_AccountAccessorImpl(void)
+{
+       // empty body
+}
+
+result
+_AccountAccessorImpl::Construct(void)
+{
+       result r = _AccountDbConnector::EnsureDbConnection();
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+_AccountAccessorImpl::SetEventListener(IAccountEventListener* pListener)
+{
+       SysTryReturn(NID_SCL, _AccountDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       result r = E_SUCCESS;
+
+       if (pListener != null)
+       {
+               if (__pIAccountEventListener == null)
+               {
+                       _AccountDbMonitor* pAccountDbMonitor = _AccountDbMonitor::GetInstance();
+                       SysTryReturn(NID_SCL, pAccountDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+                       r = pAccountDbMonitor->AddListener(*this);
+                       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+
+               __pIAccountEventListener = pListener;
+       }
+       else
+       {
+               if (__pIAccountEventListener != null)
+               {
+                       _AccountDbMonitor* pAccountDbMonitor = _AccountDbMonitor::GetInstance();
+                       SysTryReturn(NID_SCL, pAccountDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+                       r = pAccountDbMonitor->RemoveListener(*this);
+                       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+
+               __pIAccountEventListener = null;
+       }
+
+       return E_SUCCESS;
+}
+
+Account
+_AccountAccessorImpl::GetAccount(AccountId accountId) const
+{
+       ClearLastResult();
+       Account account(L"");
+
+       SysTryReturn(NID_SCL, accountId > 0, account, E_INVALID_ARG, "[%s] Invalid argument is used. The specified accountId is invalid.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _AccountDbConnector::EnsureDbConnection() == E_SUCCESS, account, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       account_h accountHandle = null;
+       Account* pAccount = null;
+
+       int ret = account_create(&accountHandle);
+       SysTryReturn(NID_SCL, ret == ACCOUNT_ERROR_NONE && accountHandle != null, account, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       ret = account_query_account_by_account_id(accountId, &accountHandle);
+       SysTryCatch(NID_SCL, ret != ACCOUNT_ERROR_RECORD_NOT_FOUND, , E_OBJ_NOT_FOUND, "[%s] The specified account is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+       SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, , E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       pAccount = _AccountManagerUtil::ConvertAccountHandleToAccountN(accountHandle);
+       SysTryCatch(NID_SCL, pAccount != null, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       account_destroy(accountHandle);
+
+       account = *pAccount;
+       delete pAccount;
+
+       return account;
+
+CATCH:
+       account_destroy(accountHandle);
+
+       return account;
+}
+
+IList*
+_AccountAccessorImpl::GetAccountsByAccountProviderN(const AppId& accountProviderAppId) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_SCL, !accountProviderAppId.IsEmpty(), null, E_INVALID_ARG, "[%s] Invalid argument is used. The specified accountProviderAppId is empty.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _AccountDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pAccountList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pAccountList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pAccountList->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       std::unique_ptr<char[]> pCharArrayAppId(_StringConverter::CopyToCharArrayN(accountProviderAppId));
+       SysTryReturn(NID_SCL, pCharArrayAppId != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       ArrayList* pTempAccountList = pAccountList.get();
+       int ret = account_query_account_by_package_name(OnAccountReceived, pCharArrayAppId.get(), (void*) pTempAccountList);
+       SysTryReturn(NID_SCL, (ret == ACCOUNT_ERROR_NONE) || (ret == ACCOUNT_ERROR_RECORD_NOT_FOUND), null, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       r = GetLastResult();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pAccountList.release();
+}
+
+IList*
+_AccountAccessorImpl::GetAllAccountsN(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_SCL, _AccountDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pAccountList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pAccountList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pAccountList->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       ArrayList* pTempAccountList = pAccountList.get();
+       int ret = account_foreach_account_from_db(OnAccountReceived, (void*) pTempAccountList);
+       SysTryReturn(NID_SCL, (ret == ACCOUNT_ERROR_NONE) || (ret == ACCOUNT_ERROR_RECORD_NOT_FOUND), null, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       r = GetLastResult();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pAccountList.release();
+}
+
+AccountProvider
+_AccountAccessorImpl::GetAccountProvider(const AppId& accountProviderAppId) const
+{
+       ClearLastResult();
+       AccountProvider accountProvider;
+
+       SysTryReturn(NID_SCL, !accountProviderAppId.IsEmpty(), accountProvider, E_INVALID_ARG, "[%s] Invalid argument is used. The specified accountProviderAppId is empty.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _AccountDbConnector::EnsureDbConnection() == E_SUCCESS, accountProvider, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       account_type_h accountTypeHandle = null;
+       AccountProvider* pAccountProvider = null;
+
+       int ret = account_type_create(&accountTypeHandle);
+       SysTryReturn(NID_SCL, ret == ACCOUNT_ERROR_NONE && accountTypeHandle != null, accountProvider, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       std::unique_ptr<char[]> pCharArrayAppId(_StringConverter::CopyToCharArrayN(accountProviderAppId));
+       SysTryCatch(NID_SCL, pCharArrayAppId != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       ret = account_type_query_by_app_id(pCharArrayAppId.get(), &accountTypeHandle);
+       SysTryCatch(NID_SCL, ret != ACCOUNT_ERROR_RECORD_NOT_FOUND, , E_OBJ_NOT_FOUND, "[%s] The specified account is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+       SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, , E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       pAccountProvider = _AccountManagerUtil::ConvertAccountTypeHandleToAccountProviderN(accountTypeHandle);
+       SysTryCatch(NID_SCL, pAccountProvider != null, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       account_type_destroy(accountTypeHandle);
+
+       accountProvider = *pAccountProvider;
+       delete pAccountProvider;
+
+       return accountProvider;
+
+CATCH:
+       account_type_destroy(accountTypeHandle);
+
+       return accountProvider;
+}
+
+IList*
+_AccountAccessorImpl::GetAccountProvidersByCapabilityN(const String& capability) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_SCL, !capability.IsEmpty(), null, E_INVALID_ARG, "[%s] Invalid argument is used. The specified capability is empty.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _AccountDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pAccountProviderList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pAccountProviderList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pAccountProviderList->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       std::unique_ptr<char[]> pCharArrayCapability(_StringConverter::CopyToCharArrayN(capability));
+       SysTryReturn(NID_SCL, pCharArrayCapability != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       ArrayList* pTempAccountProviderList = pAccountProviderList.get();
+       int ret = account_type_query_by_provider_feature(OnAccountTypeReceived, pCharArrayCapability.get(), (void*) pTempAccountProviderList);
+       SysTryReturn(NID_SCL, (ret == ACCOUNT_ERROR_NONE) || (ret == ACCOUNT_ERROR_RECORD_NOT_FOUND), null, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       r = GetLastResult();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pAccountProviderList.release();
+}
+
+IList*
+_AccountAccessorImpl::GetAllAccountProvidersN(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_SCL, _AccountDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pAccountProviderList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pAccountProviderList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pAccountProviderList->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       ArrayList* pTempAccountProviderList = pAccountProviderList.get();
+       int ret = account_type_foreach_account_type_from_db(OnAccountTypeReceived, (void*) pTempAccountProviderList);
+       SysTryReturn(NID_SCL, (ret == ACCOUNT_ERROR_NONE) || (ret == ACCOUNT_ERROR_RECORD_NOT_FOUND), null, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       r = GetLastResult();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pAccountProviderList.release();
+}
+
+_AccountAccessorImpl*
+_AccountAccessorImpl::GetInstance(AccountAccessor& accountAccessor)
+{
+       return accountAccessor.__pAccountAccessorImpl;
+}
+
+const _AccountAccessorImpl*
+_AccountAccessorImpl::GetInstance(const AccountAccessor& accountAccessor)
+{
+       return accountAccessor.__pAccountAccessorImpl;
+}
+
+void
+_AccountAccessorImpl::OnAccountAdded(AccountId accountId)
+{
+       if (__pIAccountEventListener != null)
+       {
+               __pIAccountEventListener->OnAccountAdded(accountId);
+       }
+}
+
+void
+_AccountAccessorImpl::OnAccountUpdated(AccountId accountId)
+{
+       if (__pIAccountEventListener != null)
+       {
+               __pIAccountEventListener->OnAccountUpdated(accountId);
+       }
+}
+
+void
+_AccountAccessorImpl::OnAccountRemoved(AccountId accountId)
+{
+       if (__pIAccountEventListener != null)
+       {
+               __pIAccountEventListener->OnAccountRemoved(accountId);
+       }
+}
+
+}}  // Tizen::Social
diff --git a/src/FScl_AccountAccessorImpl.h b/src/FScl_AccountAccessorImpl.h
new file mode 100644 (file)
index 0000000..bba4fb6
--- /dev/null
@@ -0,0 +1,91 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_AccountAccessorImpl.h
+ * @brief      This is the header file for the %_AccountAccessorImpl class.
+ *
+ * This header file contains the declarations of the %_AccountAccessorImpl class.
+ */
+
+#ifndef _FSCL_INTERNAL_ACCOUNT_ACCESSOR_IMPL_H_
+#define _FSCL_INTERNAL_ACCOUNT_ACCESSOR_IMPL_H_
+
+#include <account-types.h>
+#include <FAppTypes.h>
+#include <FBaseObject.h>
+#include <FBaseResult.h>
+#include <FSclTypes.h>
+#include "FScl_IAccountDbChangeEventListener.h"
+
+namespace Tizen { namespace Base {
+namespace Collection {
+class IList;
+}
+}}
+
+namespace Tizen { namespace Social
+{
+class Account;
+class AccountAccessor;
+class IAccountEventListener;
+
+class _AccountAccessorImpl
+       : public Tizen::Base::Object
+       , virtual public _IAccountDbChangeEventListener
+{
+public:
+       _AccountAccessorImpl(void);
+
+       virtual ~_AccountAccessorImpl(void);
+
+       result Construct(void);
+
+       result SetEventListener(IAccountEventListener* pListener);
+
+       Account GetAccount(AccountId accountId) const;
+
+       Tizen::Base::Collection::IList* GetAccountsByAccountProviderN(const Tizen::App::AppId& accountProviderAppId) const;
+
+       Tizen::Base::Collection::IList* GetAllAccountsN(void) const;
+
+       AccountProvider GetAccountProvider(const Tizen::App::AppId& accountProviderAppId) const;
+
+       Tizen::Base::Collection::IList* GetAccountProvidersByCapabilityN(const Tizen::Base::String& capability) const;
+
+       Tizen::Base::Collection::IList* GetAllAccountProvidersN(void) const;
+
+       static _AccountAccessorImpl* GetInstance(AccountAccessor& AccountAccessor);
+
+       static const _AccountAccessorImpl* GetInstance(const AccountAccessor& AccountAccessor);
+
+       virtual void OnAccountAdded(AccountId accountId);
+
+       virtual void OnAccountUpdated(AccountId accountId);
+
+       virtual void OnAccountRemoved(AccountId accountId);
+
+private:
+       _AccountAccessorImpl& operator =(const _AccountAccessorImpl& rhs);
+       _AccountAccessorImpl(const _AccountAccessorImpl& rhs);
+
+private:
+       IAccountEventListener* __pIAccountEventListener;
+
+};     // _AccountAccessorImpl
+
+}}  // Tizen::Social
+
+#endif //_FSCL_INTERNAL_ACCOUNT_ACCESSOR_IMPL_H_
diff --git a/src/FScl_AccountDbChangeEvent.cpp b/src/FScl_AccountDbChangeEvent.cpp
new file mode 100644 (file)
index 0000000..215d4e9
--- /dev/null
@@ -0,0 +1,93 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_AccountDbChangeEvent.cpp
+ * @brief      This is the implementation file for the _AccountDbChangeEvent class.
+ *
+ */
+
+#include <FBaseRtIEventListener.h>
+#include <FBaseRtIEventArg.h>
+#include <FBaseSysLog.h>
+#include "FScl_IAccountDbChangeEventListener.h"
+#include "FScl_AccountDbChangeEventArg.h"
+#include "FScl_AccountDbChangeEvent.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Social
+{
+
+_AccountDbChangeEvent::_AccountDbChangeEvent(void)
+{
+       // empty body
+}
+
+_AccountDbChangeEvent::~_AccountDbChangeEvent(void)
+{
+       // emtpy body
+}
+
+result
+_AccountDbChangeEvent::Construct(void)
+{
+       result r = _Event::Initialize();
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating. This is not an event-driven thread.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+void
+_AccountDbChangeEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
+{
+       _IAccountDbChangeEventListener* pEventListener = dynamic_cast<_IAccountDbChangeEventListener*>(&listener);
+       const _AccountDbChangeEventArg* pEventArg = dynamic_cast<const _AccountDbChangeEventArg*>(&arg);
+
+       if (pEventListener != null && pEventArg != null)
+       {
+               AccountId accountId = pEventArg->GetAccountId();
+               _AccountDbChangeType changeType = pEventArg->GetChangeType();
+
+               switch (changeType)
+               {
+               case _ACCOUNT_DB_CHANGE_TYPE_ADD:
+               {
+                       pEventListener->OnAccountAdded(accountId);
+                       break;
+               }
+
+               case _ACCOUNT_DB_CHANGE_TYPE_UPDATE:
+               {
+                       pEventListener->OnAccountUpdated(accountId);
+                       break;
+               }
+
+               case _ACCOUNT_DB_CHANGE_TYPE_REMOVE:
+               {
+                       pEventListener->OnAccountRemoved(accountId);
+                       break;
+               }
+
+               default:
+                       return;
+               }
+       }
+
+       return;
+}
+
+}} // Tizen::Social
diff --git a/src/FScl_AccountDbChangeEvent.h b/src/FScl_AccountDbChangeEvent.h
new file mode 100644 (file)
index 0000000..38f3a32
--- /dev/null
@@ -0,0 +1,67 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_AccountDbChangeEvent.h
+ * @brief      This is the header file for the _AccountDbChangeEvent class.
+ *
+ * This file contains the declarations of _AccountDbChangeEvent.
+ */
+
+
+#ifndef _FSCL_INTERNAL_ACCOUNT_DB_CHANGE_EVENT_H_
+#define _FSCL_INTERNAL_ACCOUNT_DB_CHANGE_EVENT_H_
+
+#include <FBaseTypes.h>
+#include <FBaseResult.h>
+#include <FBaseRt_Event.h>
+
+namespace Tizen { namespace Base { namespace Runtime
+{
+class IEventListener;
+class IEventArg;
+}}}
+
+namespace Tizen { namespace Social
+{
+
+class _AccountDbChangeEvent
+       : public Tizen::Base::Runtime::_Event
+{
+public:
+       /**
+        * This is the default constructor.
+        *
+        * @since       2.0
+        */
+       _AccountDbChangeEvent(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Runtime::_Event::~_Event().
+        *
+        * @since       2.0
+        */
+       virtual ~_AccountDbChangeEvent(void);
+
+       result Construct(void);
+
+protected:
+       virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+}; // _AccountDbChangeEvent
+
+}} // Tizen::Social
+
+#endif // _FSCL_INTERNAL_ACCOUNT_DB_CHANGE_EVENT_H_
diff --git a/src/FScl_AccountDbChangeEventArg.cpp b/src/FScl_AccountDbChangeEventArg.cpp
new file mode 100644 (file)
index 0000000..c6451f9
--- /dev/null
@@ -0,0 +1,51 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_AccountDbChangeEventArg.cpp
+ * @brief      This is the implementation file for the _AccountDbChangeEventArg class.
+ *
+ */
+
+#include <FBaseSysLog.h>
+#include "FScl_AccountDbChangeEventArg.h"
+
+namespace Tizen { namespace Social
+{
+_AccountDbChangeEventArg::_AccountDbChangeEventArg(AccountId accountId, _AccountDbChangeType changeType)
+       : __accountId(accountId)
+       , __changeType(changeType)
+{
+       // empty body
+}
+
+_AccountDbChangeEventArg::~_AccountDbChangeEventArg(void)
+{
+       // empty body
+}
+
+AccountId
+_AccountDbChangeEventArg::GetAccountId(void) const
+{
+       return __accountId;
+}
+
+_AccountDbChangeType
+_AccountDbChangeEventArg::GetChangeType(void) const
+{
+       return __changeType;
+}
+
+}}// Tizen::Social
diff --git a/src/FScl_AccountDbChangeEventArg.h b/src/FScl_AccountDbChangeEventArg.h
new file mode 100644 (file)
index 0000000..5e28db7
--- /dev/null
@@ -0,0 +1,87 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_AccountDbChangeEventArg.h
+ * @brief      This is the header file for the _AccountDbChangeEventArg class.
+ *
+ * This file contains the declarations of _AccountDbChangeEventArg.
+ */
+
+#ifndef _FSCL_INTERNAL_ACCOUNT_DB_CHANGE_EVENT_ARG_H_
+#define _FSCL_INTERNAL_ACCOUNT_DB_CHANGE_EVENT_ARG_H_
+
+#include <FBaseObject.h>
+#include <FBaseRtIEventArg.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+
+enum _AccountDbChangeType
+{
+       _ACCOUNT_DB_CHANGE_TYPE_ADD,
+       _ACCOUNT_DB_CHANGE_TYPE_UPDATE,
+       _ACCOUNT_DB_CHANGE_TYPE_REMOVE
+};
+
+class _AccountDbChangeEventArg
+       : public Tizen::Base::Object
+       , public Tizen::Base::Runtime::IEventArg
+{
+public:
+       /**
+        * Initializes this instance of %_AccountDbChangeEventArg with the specified value.
+        *
+        * @since       2.1
+        *
+        * @param[in]   value   A _AccountDbChangeType type
+        */
+       _AccountDbChangeEventArg(AccountId accountId, _AccountDbChangeType changeType);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.1
+        */
+       virtual ~_AccountDbChangeEventArg(void);
+
+       AccountId GetAccountId(void) const;
+
+       _AccountDbChangeType GetChangeType(void) const;
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @since       2.1
+        */
+       _AccountDbChangeEventArg(const _AccountDbChangeEventArg& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @since       2.1
+        */
+       _AccountDbChangeEventArg& operator =(const _AccountDbChangeEventArg& rhs);
+
+private:
+       AccountId __accountId;
+       _AccountDbChangeType __changeType;
+};
+
+}} // Tizen::Social
+
+#endif // _FSCL_INTERNAL_ACCOUNT_DB_CHANGE_EVENT_ARG_H_
diff --git a/src/FScl_AccountDbConnector.cpp b/src/FScl_AccountDbConnector.cpp
new file mode 100644 (file)
index 0000000..9855ab5
--- /dev/null
@@ -0,0 +1,117 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_AccountDbConnector.cpp
+ * @brief              This is the implementation for _AccountDbConnector class.
+ *
+ * This file contains definitions of @e _AccountDbConnector class.
+ */
+
+#include <unique_ptr.h>
+#include <pthread.h>
+#include <FBaseSysLog.h>
+#include "FScl_AccountDbConnector.h"
+
+namespace Tizen { namespace Social
+{
+
+bool _AccountDbConnector::__isAccountDbConnected = false;
+_AccountDbConnector* _AccountDbConnector::__pInstance = null;
+
+_AccountDbConnector::_AccountDbConnector(void)
+{
+}
+
+_AccountDbConnector::~_AccountDbConnector(void)
+{
+}
+
+result
+_AccountDbConnector::Connect(void)
+{
+       int ret = account_connect();
+       SysTryReturnResult(NID_SCL, ret == ACCOUNT_ERROR_NONE, E_SYSTEM, "The method cannot proceed due to a severe system error.");
+
+       return E_SUCCESS;
+}
+
+result
+_AccountDbConnector::Disconnect(void)
+{
+       int ret = account_disconnect();
+       SysTryReturnResult(NID_SCL, ret == ACCOUNT_ERROR_NONE, E_SYSTEM, "The method cannot proceed due to a severe system error.");
+
+       return E_SUCCESS;
+}
+
+result
+_AccountDbConnector::EnsureDbConnection(void)
+{
+       if (!__isAccountDbConnected)
+       {
+               _AccountDbConnector* pInstance = GetInstance();
+               SysTryReturn(NID_SCL, pInstance != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               result r = pInstance->Connect();
+               SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               __isAccountDbConnected = true;
+       }
+
+       return E_SUCCESS;
+}
+
+void
+_AccountDbConnector::InitAccountDbConnector(void)
+{
+       std::unique_ptr<_AccountDbConnector> pInstance(new (std::nothrow) _AccountDbConnector());
+       SysTryReturnVoidResult(NID_SCL, pInstance, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __pInstance = pInstance.release();
+
+       std::atexit(DestroyAccountDbConnector);
+}
+
+void
+_AccountDbConnector::DestroyAccountDbConnector(void)
+{
+       delete __pInstance;
+       __pInstance = null;
+}
+
+_AccountDbConnector*
+_AccountDbConnector::GetInstance(void)
+{
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+       if (__pInstance == null)
+       {
+               ClearLastResult();
+
+               pthread_once(&onceBlock, InitAccountDbConnector);
+
+               result r = GetLastResult();
+
+               if (IsFailed(r))
+               {
+                       onceBlock = PTHREAD_ONCE_INIT;
+               }
+       }
+
+       return __pInstance;
+}
+
+}}  // Tizen::Social
diff --git a/src/FScl_AccountDbConnector.h b/src/FScl_AccountDbConnector.h
new file mode 100644 (file)
index 0000000..41d12b8
--- /dev/null
@@ -0,0 +1,59 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_AccountDbConnector.h
+ * @brief              This is the header file for the _AccountDbConnector class.
+ *
+ * This header file contains the declarations of the _AccountDbConnector class.
+ */
+#ifndef _FSCL_INTERNAL_ACCOUNT_DB_CONNECTOR_H_
+#define _FSCL_INTERNAL_ACCOUNT_DB_CONNECTOR_H_
+
+#include <unique_ptr.h>
+#include <account.h>
+
+namespace Tizen { namespace Social
+{
+
+class _AccountDbConnector
+{
+public:
+
+       static _AccountDbConnector* GetInstance(void);
+
+       result Connect(void);
+
+       result Disconnect(void);
+
+       static result EnsureDbConnection(void);
+
+private:
+       _AccountDbConnector(void);
+
+       ~_AccountDbConnector(void);
+
+       static void InitAccountDbConnector(void);
+       static void DestroyAccountDbConnector(void);
+
+private:
+       static _AccountDbConnector* __pInstance;
+       static bool __isAccountDbConnected;
+       friend class std::default_delete< _AccountDbConnector >;
+};
+
+}} // Tizen::Social
+
+#endif //_FSCL_INTERNAL_ACCOUNT_DB_CONNECTOR_H_
diff --git a/src/FScl_AccountDbMonitor.cpp b/src/FScl_AccountDbMonitor.cpp
new file mode 100644 (file)
index 0000000..35cf7d6
--- /dev/null
@@ -0,0 +1,242 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_AccountDbMonitor.cpp
+ * @brief              This is the implementation for _AccountDbMonitor class.
+ *
+ * This file contains definitions of @e _AccountDbMonitor class.
+ */
+
+#include <new>
+#include <FBaseRtMutex.h>
+#include <FBaseSysLog.h>
+#include <FBaseColArrayListT.h>
+#include "FScl_IAccountDbChangeEventListener.h"
+#include "FScl_AccountDbChangeEvent.h"
+#include "FScl_AccountDbChangeEventArg.h"
+#include "FScl_AccountDbConnector.h"
+#include "FScl_AccountDbMonitor.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Social
+{
+
+_AccountDbMonitor* _AccountDbMonitor::__pTheInstance = null;
+
+_AccountDbMonitor::__Callback::__Callback(account_subscribe_h accountSubscribeHandle, account_event_cb callback, void* pUserData)
+       : __accountSubscribeHandle(accountSubscribeHandle)
+       , __callback(callback)
+       , __pUserData(pUserData)
+{
+       // empty body
+}
+
+result
+_AccountDbMonitor::__Callback::Register(void)
+{
+       int ret = account_subscribe_notification(__accountSubscribeHandle, __callback, __pUserData);
+       SysTryReturnResult(NID_SCL, ret == ACCOUNT_ERROR_NONE, E_SYSTEM, "The method cannot proceed due to a severe system error.");
+
+       return E_SUCCESS;
+}
+
+_AccountDbMonitor::__Callback::~__Callback(void)
+{
+       if (__accountSubscribeHandle)
+       {
+               account_unsubscribe_notification(__accountSubscribeHandle);
+       }
+}
+
+_AccountDbMonitor::_AccountDbMonitor(void)
+       : __pEvent(null)
+       , __pMutex(null)
+       , __pAccountChangeCallback(null)
+{
+       // empty body
+}
+
+_AccountDbMonitor::~_AccountDbMonitor(void)
+{
+       // empty body
+}
+
+result
+_AccountDbMonitor::Construct(void)
+{
+       SysTryReturn(NID_SCL, _AccountDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<Mutex> pMutex(new (std::nothrow) Mutex());
+       SysTryReturn(NID_SCL, pMutex != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pMutex->Create();
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       std::unique_ptr<_AccountDbChangeEvent> pEvent(new (std::nothrow) _AccountDbChangeEvent());
+       SysTryReturnResult(NID_SCL, pEvent != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pEvent->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       account_subscribe_h accountSubscribeHandle = null;
+       int ret = account_subscribe_create(&accountSubscribeHandle);
+       SysTryReturnResult(NID_SCL, ret == ACCOUNT_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       std::unique_ptr<__Callback> pAccountChangeCallback(new (std::nothrow) __Callback(accountSubscribeHandle, OnAccountChangeEventReceived, this));
+       SysTryCatch(NID_SCL, pAccountChangeCallback != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = pAccountChangeCallback->Register();
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pMutex = move(pMutex);
+       __pEvent = move(pEvent);
+       __pAccountChangeCallback = move(pAccountChangeCallback);
+
+       return E_SUCCESS;
+
+CATCH:
+       account_unsubscribe_notification(accountSubscribeHandle);
+
+       return r;
+}
+
+result
+_AccountDbMonitor::AddListener(const _IAccountDbChangeEventListener& listener)
+{
+       result r = __pMutex->Acquire();
+       SysTryReturn(NID_SCL, !IsFailed(r), E_SYSTEM, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       r = __pEvent->AddListener(listener);
+       SysTryCatch(NID_SCL, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = __pMutex->Release();
+       SysTryReturn(NID_SCL, !IsFailed(r), E_SYSTEM, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       return E_SUCCESS;
+
+CATCH:
+       r = __pMutex->Release();
+       SysTryReturn(NID_SCL, !IsFailed(r), E_SYSTEM, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       return r;
+}
+
+result
+_AccountDbMonitor::RemoveListener(const _IAccountDbChangeEventListener& listener)
+{
+       result r = __pMutex->Acquire();
+       SysTryReturn(NID_SCL, !IsFailed(r), E_SYSTEM, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       r = __pEvent->RemoveListener(listener);
+       SysTryCatch(NID_SCL, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = __pMutex->Release();
+       SysTryReturn(NID_SCL, !IsFailed(r), E_SYSTEM, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       return E_SUCCESS;
+
+CATCH:
+       r = __pMutex->Release();
+       SysTryReturn(NID_SCL, !IsFailed(r), E_SYSTEM, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       return r;
+}
+
+_AccountDbMonitor*
+_AccountDbMonitor::GetInstance(void)
+{
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+       if (__pTheInstance == null)
+       {
+               ClearLastResult();
+
+               pthread_once(&onceBlock, InitSingleton);
+
+               result r = GetLastResult();
+               if (IsFailed(r))
+               {
+                       onceBlock = PTHREAD_ONCE_INIT;
+               }
+       }
+
+       return __pTheInstance;
+}
+
+bool
+_AccountDbMonitor::OnAccountChangeEventReceived(const char* pEventType, int accountId, void* pUserData)
+{
+       SysTryReturn(NID_SCL, pEventType != null, false, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       std::unique_ptr<String> pAccountChangeEventType(new (std::nothrow) String(pEventType));
+       SysTryReturn(NID_SCL, pAccountChangeEventType != null, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       _AccountDbMonitor* pAccountDbMonitor = static_cast<_AccountDbMonitor*>(pUserData);
+       _AccountDbChangeEvent* pEvent = pAccountDbMonitor->__pEvent.get();
+
+       std::unique_ptr<_AccountDbChangeEventArg> pArg(null);
+
+       if (pAccountChangeEventType->Equals(String(ACCOUNT_NOTI_NAME_INSERT)))
+       {
+               pArg.reset(new (std::nothrow) _AccountDbChangeEventArg(accountId, _ACCOUNT_DB_CHANGE_TYPE_ADD));
+               SysTryReturn(NID_SCL, pArg != null, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+       else if (pAccountChangeEventType->Equals(String(ACCOUNT_NOTI_NAME_UPDATE)))
+       {
+               pArg.reset(new (std::nothrow) _AccountDbChangeEventArg(accountId, _ACCOUNT_DB_CHANGE_TYPE_UPDATE));
+               SysTryReturn(NID_SCL, pArg != null, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+       else if (pAccountChangeEventType->Equals(String(ACCOUNT_NOTI_NAME_DELETE)))
+       {
+               pArg.reset(new (std::nothrow) _AccountDbChangeEventArg(accountId, _ACCOUNT_DB_CHANGE_TYPE_REMOVE));
+               SysTryReturn(NID_SCL, pArg != null, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+       else
+       {
+               SysLogException(NID_SCL, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+               return false;
+       }
+
+       result r = pEvent->Fire(*pArg);
+       SysTryReturn(NID_SCL, !IsFailed(r), false, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pArg.release();
+
+       return true;
+}
+
+void
+_AccountDbMonitor::InitSingleton(void)
+{
+       std::unique_ptr<_AccountDbMonitor> pInst(new (std::nothrow) _AccountDbMonitor());
+       SysTryReturnVoidResult(NID_SCL, pInst, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pInst->Construct();
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pTheInstance = pInst.release();
+
+       std::atexit(DestroySingleton);
+}
+
+void
+_AccountDbMonitor::DestroySingleton(void)
+{
+       delete __pTheInstance;
+}
+
+}}  // Tizen::Social
diff --git a/src/FScl_AccountDbMonitor.h b/src/FScl_AccountDbMonitor.h
new file mode 100644 (file)
index 0000000..d75bbe6
--- /dev/null
@@ -0,0 +1,111 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FScl_AccountDbMonitor.h
+* @brief       This is the header file for the _AccountDbMonitor class.
+*
+* This header file contains the declarations of the _AccountDbMonitor class.
+*/
+
+#ifndef _FSCL_INTERNAL_ACCOUNT_DB_MONITOR_H_
+#define _FSCL_INTERNAL_ACCOUNT_DB_MONITOR_H_
+
+#include <new>
+#include <pthread.h>
+#include <unique_ptr.h>
+#include <account.h>
+#include <FBaseTypes.h>
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+
+namespace Tizen { namespace Base {
+
+namespace Collection
+{
+template<typename Type>
+class ArrayListT;
+}
+
+namespace Runtime
+{
+class Mutex;
+}
+
+}}
+
+namespace Tizen { namespace Social
+{
+class _IAccountDbChangeEventListener;
+class _AccountDbChangeEvent;
+
+/**
+ * @class      _AccountDbMonitor
+ * @brief      This class handles the _AccountDbMonitor operations.
+ * @since      2.1
+ */
+class _AccountDbMonitor
+       : public Tizen::Base::Object
+{
+public:
+       result AddListener(const _IAccountDbChangeEventListener& listener);
+
+       result RemoveListener(const _IAccountDbChangeEventListener& listener);
+
+       static _AccountDbMonitor* GetInstance(void);
+
+private:
+       _AccountDbMonitor(void);
+
+       virtual ~_AccountDbMonitor(void);
+
+       result Construct(void);
+
+       _AccountDbMonitor(const _AccountDbMonitor& rhs);
+
+       static bool OnAccountChangeEventReceived(const char* pEventType, int accountId, void* pUserData);
+
+       _AccountDbMonitor& operator =(const _AccountDbMonitor& rhs);
+
+       static void InitSingleton(void);
+
+       static void DestroySingleton(void);
+
+private:
+       class __Callback
+       {
+       public:
+               __Callback(account_subscribe_h accountSubscribeHandle, account_event_cb callback, void* pUserData);
+               result Register(void);
+               ~__Callback(void);
+
+       private:
+               account_subscribe_h __accountSubscribeHandle;
+               account_event_cb __callback;
+               void* __pUserData;
+       };
+
+private:
+       std::unique_ptr<_AccountDbChangeEvent> __pEvent;
+       std::unique_ptr<Tizen::Base::Runtime::Mutex> __pMutex;
+       std::unique_ptr<__Callback> __pAccountChangeCallback;
+
+       static _AccountDbMonitor* __pTheInstance;
+       friend struct std::default_delete< _AccountDbMonitor >;
+};     // _AccountDbMonitor
+
+}}  // Tizen::Social
+
+#endif //_FSCL_INTERNAL_ACCOUNT_DB_MONITOR_H_
diff --git a/src/FScl_AccountImpl.cpp b/src/FScl_AccountImpl.cpp
new file mode 100644 (file)
index 0000000..786f061
--- /dev/null
@@ -0,0 +1,304 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_AccountImpl.cpp
+ * @brief              This is the implementation for _AccountImpl class.
+ *
+ * This file contains definitions of @e _AccountImpl class.
+ */
+
+#include <new>
+#include <FBaseResult.h>
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include <FSclAccount.h>
+#include "FScl_AccountImpl.h"
+#include "FScl_AccountProviderImpl.h"
+
+#include <FBaseLog.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Social
+{
+
+_AccountImpl::_AccountImpl(const Tizen::Base::String& userName)
+       : __id(INVALID_RECORD_ID)
+{
+       std::unique_ptr<HashMap, AllElementsDeleter> pExtendedData(new (std::nothrow) HashMap());
+       SysTryReturnVoidResult(NID_SCL, pExtendedData != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pExtendedData->Construct();
+       SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Failed to construct pExtendedData.", GetErrorMessage(r));
+
+       __pExtendedData = std::move(pExtendedData);
+       __userName = userName;
+}
+
+_AccountImpl::_AccountImpl(const _AccountImpl& rhs)
+{
+       std::unique_ptr<HashMap, AllElementsDeleter> pExtendedData(new (std::nothrow) HashMap());
+       SysTryReturnVoidResult(NID_SCL, pExtendedData != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pExtendedData->Construct();
+       SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Failed to construct pExtendedData.", GetErrorMessage(r));
+
+       std::unique_ptr<IMapEnumerator> pMapEnum((rhs.__pExtendedData)->GetMapEnumeratorN());
+       SysTryReturnVoidResult(NID_SCL, pMapEnum != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<String> pKey(null);
+       std::unique_ptr<String> pVal(null);
+       String* pStr = null;
+
+       while (pMapEnum->MoveNext() == E_SUCCESS)
+       {
+               pStr = static_cast<String*> (pMapEnum->GetKey());
+               pKey.reset(new (std::nothrow) String(*pStr));
+               SysTryReturnVoidResult(NID_SCL, pKey != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pStr = static_cast<String*> (pMapEnum->GetValue());
+               pVal.reset(new (std::nothrow) String(*pStr));
+               SysTryReturnVoidResult(NID_SCL, pVal != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pExtendedData->Add(pKey.get(), pVal.get());
+               SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Propagating.", GetErrorMessage(r));
+
+               pKey.release();
+               pVal.release();
+       }
+
+       __pExtendedData = std::move(pExtendedData);
+
+       __id = rhs.__id;
+       __userName = rhs.__userName;
+       __accountProvider = rhs.__accountProvider;
+}
+
+_AccountImpl::~_AccountImpl(void)
+{
+       // empty body.
+}
+
+_AccountImpl&
+_AccountImpl::operator =(const _AccountImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       std::unique_ptr<HashMap, AllElementsDeleter> pExtendedData(new (std::nothrow) HashMap());
+       SysTryReturn(NID_SCL, pExtendedData != null, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pExtendedData->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), *this, r, "[%s] Failed to construct pExtendedData.", GetErrorMessage(r));
+
+       result prevResult = GetLastResult();
+
+       std::unique_ptr<IMapEnumerator> pMapEnum((rhs.__pExtendedData)->GetMapEnumeratorN());
+       SysTryReturn(NID_SCL, pMapEnum != null, *this, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       SetLastResult(prevResult);
+
+       std::unique_ptr<String> pKey(null);
+       std::unique_ptr<String> pVal(null);
+       String* pStr = null;
+
+       while (pMapEnum->MoveNext() == E_SUCCESS)
+       {
+               pStr = static_cast<String*> (pMapEnum->GetKey());
+               pKey.reset(new (std::nothrow) String(*pStr));
+               SysTryReturn(NID_SCL, pKey != null, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pStr = static_cast<String*> (pMapEnum->GetValue());
+               pVal.reset(new (std::nothrow) String(*pStr));
+               SysTryReturn(NID_SCL, pVal != null, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pExtendedData->Add(pKey.get(), pVal.get());
+               SysTryReturn(NID_SCL, !IsFailed(r), *this, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               pKey.release();
+               pVal.release();
+       }
+
+       __pExtendedData = std::move(pExtendedData);
+
+       __id = rhs.__id;
+       __userName = rhs.__userName;
+       __accountProvider = rhs.__accountProvider;
+
+       return *this;
+}
+
+bool
+_AccountImpl::Equals(const Object& rhs) const
+{
+       const _AccountImpl* pAccountImpl = dynamic_cast<const _AccountImpl*> (&rhs);
+       if (pAccountImpl == null)
+       {
+               return false;
+       }
+
+       if (__id != pAccountImpl->__id
+               || __userName != pAccountImpl->__userName)
+       {
+               return false;
+       }
+
+       if (*(_AccountProviderImpl::GetInstance(__accountProvider)) != *(_AccountProviderImpl::GetInstance(pAccountImpl->__accountProvider)))
+       {
+               return false;
+       }
+
+       if (!(__pExtendedData->Equals(*(pAccountImpl->__pExtendedData))))
+       {
+               return false;
+       }
+
+       return true;
+}
+
+int
+_AccountImpl::GetHashCode(void) const
+{
+       int hashCode = 0xffffffff & __id;
+       hashCode += hashCode;
+
+       return hashCode;
+}
+
+AccountId
+_AccountImpl::GetId(void) const
+{
+       return __id;
+}
+
+AccountProvider
+_AccountImpl::GetAccountProvider(void) const
+{
+       return __accountProvider;
+}
+
+String
+_AccountImpl::GetUserName(void) const
+{
+       return __userName;
+}
+
+IMap*
+_AccountImpl::GetExtendedDataN(void) const
+{
+       ClearLastResult();
+
+       std::unique_ptr<HashMap, AllElementsDeleter> pExtendedData(new (std::nothrow) HashMap());
+       SysTryReturn(NID_SCL, pExtendedData != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pExtendedData->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Failed to construct pExtendedData.", GetErrorMessage(r));
+
+       std::unique_ptr<IMapEnumerator> pMapEnum(__pExtendedData->GetMapEnumeratorN());
+       SysTryReturn(NID_SCL, pMapEnum != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<String> pKey(null);
+       std::unique_ptr<String> pVal(null);
+       String* pStr = null;
+
+       while (pMapEnum->MoveNext() == E_SUCCESS)
+       {
+               pStr = static_cast<String*> (pMapEnum->GetKey());
+               pKey.reset(new (std::nothrow) String(*pStr));
+               SysTryReturn(NID_SCL, pKey != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pStr = static_cast<String*> (pMapEnum->GetValue());
+               pVal.reset(new (std::nothrow) String(*pStr));
+               SysTryReturn(NID_SCL, pVal != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pExtendedData->Add(pKey.get(), pVal.get());
+               SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               pKey.release();
+               pVal.release();
+       }
+
+       return pExtendedData.release();
+}
+
+void
+_AccountImpl::SetId(AccountId accountId)
+{
+       __id = accountId;
+}
+
+void
+_AccountImpl::SetAccountProvider(const AccountProvider& accountProvider)
+{
+       __accountProvider = accountProvider;
+}
+
+result
+_AccountImpl::SetUserName(const String& userName)
+{
+       SysTryReturnResult(NID_SCL, !(userName.IsEmpty()), E_INVALID_ARG, "Invalid argument is used. The userName is an empty string.");
+
+       __userName = userName;
+
+       return E_SUCCESS;
+}
+
+result
+_AccountImpl::SetExtendedData(const String& key, const Tizen::Base::String& value)
+{
+       SysTryReturnResult(NID_SCL, !(key.IsEmpty()), E_INVALID_ARG, "Invalid argument is used. The key is an empty string.");
+
+       std::unique_ptr<String> pValue(new (std::nothrow) String(value));
+       SysTryReturn(NID_SCL, pValue != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       if (__pExtendedData->ContainsKey(key))
+       {
+               result r = __pExtendedData->SetValue(key, pValue.get());
+               SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               pValue.release();
+       }
+       else
+       {
+               std::unique_ptr<String> pKey(new (std::nothrow) String(key));
+               SysTryReturn(NID_SCL, pKey != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               result r = __pExtendedData->Add(pKey.get(), pValue.get());
+               SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               pKey.release();
+               pValue.release();
+       }
+
+       return E_SUCCESS;
+}
+
+const _AccountImpl*
+_AccountImpl::GetInstance(const Account& account)
+{
+       return account.__pAccountImpl;
+}
+
+_AccountImpl*
+_AccountImpl::GetInstance(Account& account)
+{
+       return account.__pAccountImpl;
+}
+
+}} //Tizen::Social
diff --git a/src/FScl_AccountImpl.h b/src/FScl_AccountImpl.h
new file mode 100644 (file)
index 0000000..273acea
--- /dev/null
@@ -0,0 +1,92 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_AccountImpl.h
+ * @brief      This is the header file for the %_AccountImpl class.
+ *
+ * This header file contains the declarations of the %_AccountImpl class.
+ */
+#ifndef _FSCL_INTERNAL_ACCOUNT_IMPL_H_
+#define _FSCL_INTERNAL_ACCOUNT_IMPL_H_
+
+#include <unique_ptr.h>
+#include <FBaseColAllElementsDeleter.h>
+#include <FBaseColHashMap.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FSclAccountProvider.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Base
+{
+namespace Collection
+{
+class IMap;
+}
+}}
+
+namespace Tizen { namespace Social
+{
+
+class Account;
+
+class _AccountImpl
+       : public Tizen::Base::Object
+{
+public:
+       _AccountImpl(const Tizen::Base::String& userName);
+
+       _AccountImpl(const _AccountImpl& rhs);
+
+       virtual ~_AccountImpl(void);
+
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       virtual int GetHashCode(void) const;
+
+       AccountId GetId(void) const;
+
+       AccountProvider GetAccountProvider(void) const;
+
+       Tizen::Base::String GetUserName(void) const;
+
+       Tizen::Base::Collection::IMap* GetExtendedDataN(void) const;
+
+       void SetId(AccountId accountId);
+
+       void SetAccountProvider(const AccountProvider& accountProvider);
+
+       result SetUserName(const Tizen::Base::String& userName);
+
+       result SetExtendedData(const Tizen::Base::String& key, const Tizen::Base::String& value);
+
+       _AccountImpl& operator =(const _AccountImpl& rhs);
+
+       static const _AccountImpl* GetInstance(const Account& account);
+
+       static _AccountImpl* GetInstance(Account& account);
+
+private:
+       AccountId __id;
+       Tizen::Base::String __userName;
+       std::unique_ptr<Tizen::Base::Collection::HashMap, Tizen::Base::Collection::AllElementsDeleter> __pExtendedData;
+       AccountProvider __accountProvider;
+
+}; // _AccountImpl
+
+}} // Tizen::Social
+
+#endif //_FSCL_INTERNAL_ACCOUNT_IMPL_H_
diff --git a/src/FScl_AccountManagerImpl.cpp b/src/FScl_AccountManagerImpl.cpp
new file mode 100644 (file)
index 0000000..741a40b
--- /dev/null
@@ -0,0 +1,179 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_AccountManagerImpl.cpp
+ * @brief              This is the implementation for _AccountManagerImpl class.
+ *
+ * This file contains definitions of @e _AccountManagerImpl class.
+ */
+
+#include <new>
+#include <unique_ptr.h>
+#include <account.h>
+#include <account-types.h>
+#include <FBaseColArrayList.h>
+#include <FBaseResult.h>
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include <FSclAccount.h>
+#include <FSclAccountManager.h>
+#include "FScl_AccountDbConnector.h"
+#include "FScl_AccountImpl.h"
+#include "FScl_AccountManagerImpl.h"
+#include "FScl_AccountManagerUtil.h"
+
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Social
+{
+
+_AccountManagerImpl::_AccountManagerImpl(void)
+{
+       // empty body
+}
+
+_AccountManagerImpl::~_AccountManagerImpl(void)
+{
+       // empty body
+}
+
+result
+_AccountManagerImpl::Construct(void)
+{
+       result r = _AccountDbConnector::EnsureDbConnection();
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+_AccountManagerImpl::AddAccount(Account& account)
+{
+       SysTryReturnResult(NID_SCL, account.GetId() == INVALID_ACCOUNT_ID, E_INVALID_ARG, "Invalid argument is used. The account ID is not INVALID_ACCOUNT_ID.");
+       SysTryReturnResult(NID_SCL, !((account.GetUserName()).IsEmpty()), E_INVALID_ARG, "Invalid argument is used. The user name is not set in the account.");
+       SysTryReturn(NID_SCL, _AccountDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       account_h accountHandle = _AccountManagerUtil::CreateAccountHandleN(account);
+       result r = GetLastResult();
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       int accountDbId = 0;
+       int ret = account_insert_to_db(accountHandle, &accountDbId);
+       SysTryCatch(NID_SCL, ret != ACCOUNT_ERROR_NOT_REGISTERED_PROVIDER, r = E_INVALID_OPERATION, E_INVALID_OPERATION, "[%s] The application does not register the account provider.", GetErrorMessage(E_INVALID_OPERATION));
+       SysTryCatch(NID_SCL, ret != ACCOUNT_ERROR_NOT_ALLOW_MULTIPLE, r = E_INVALID_OPERATION, E_INVALID_OPERATION, "[%s] The multiple accounts are not supported.", GetErrorMessage(E_INVALID_OPERATION));
+       SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       {
+               _AccountImpl* pAccountImpl = _AccountImpl::GetInstance(account);
+
+               // Set the account ID
+               pAccountImpl->SetId(accountDbId);
+
+               // Set the account provider
+               char* pTempAppId = null;
+
+               ret = account_get_package_name(accountHandle, &pTempAppId);
+               SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE && pTempAppId != null, r = E_SYSTEM, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+               std::unique_ptr<char[], _CharDeleter> pCharArrayAppId(pTempAppId);
+
+               account_type_h accountTypeHandle = null;
+               ret = account_type_create(&accountTypeHandle);
+               SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE && accountTypeHandle != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               ret = account_type_query_by_app_id(pTempAppId, &accountTypeHandle);
+               if (ret != ACCOUNT_ERROR_NONE || accountTypeHandle == null)
+               {
+                       SysLogException(NID_SCL, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+                       account_type_destroy(accountTypeHandle);
+                       account_destroy(accountHandle);
+                       return E_SYSTEM;
+               }
+
+               std::unique_ptr<AccountProvider> pAccountProvider(_AccountManagerUtil::ConvertAccountTypeHandleToAccountProviderN(accountTypeHandle));
+               SysTryCatch(NID_SCL, pAccountProvider != null, r = GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+               (_AccountImpl::GetInstance(account))->SetAccountProvider(*pAccountProvider);
+
+               account_type_destroy(accountTypeHandle);
+       }
+
+       account_destroy(accountHandle);
+
+       return E_SUCCESS;
+
+CATCH:
+       account_destroy(accountHandle);
+
+       return r;
+}
+
+result
+_AccountManagerImpl::RemoveAccount(AccountId accountId)
+{
+       SysTryReturnResult(NID_SCL, accountId > 0, E_INVALID_ARG, "Invalid argument is used. The specified accountId is invalid.");
+       SysTryReturn(NID_SCL, _AccountDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int ret = account_delete_from_db_by_id(accountId);
+       SysTryReturnResult(NID_SCL, ret != ACCOUNT_ERROR_NOT_REGISTERED_PROVIDER, E_INVALID_OPERATION, "The application does not register the account provider.");
+       SysTryReturnResult(NID_SCL, ret != ACCOUNT_ERROR_PERMISSION_DENIED, E_INVALID_OPERATION, "The application has no permission to remove this account.");
+       SysTryReturnResult(NID_SCL, ret != ACCOUNT_ERROR_RECORD_NOT_FOUND, E_OBJ_NOT_FOUND, "The specified account is not found.");
+       SysTryReturnResult(NID_SCL, ret == ACCOUNT_ERROR_NONE, E_SYSTEM, "The method cannot proceed due to a severe system error.");
+
+       return E_SUCCESS;
+}
+
+result
+_AccountManagerImpl::UpdateAccount(const Account& account)
+{
+       SysTryReturnResult(NID_SCL, account.GetId() > 0, E_INVALID_ARG, "Invalid argument is used. The specified accountId is invalid.");
+       SysTryReturnResult(NID_SCL, !((account.GetUserName()).IsEmpty()), E_INVALID_ARG, "Invalid argument is used. The user name is not set in the account.");
+       SysTryReturn(NID_SCL, _AccountDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       account_h accountHandle = _AccountManagerUtil::CreateAccountHandleN(account);
+       result r = GetLastResult();
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       int ret = account_update_to_db_by_id(accountHandle, account.GetId());
+       SysTryCatch(NID_SCL, ret != ACCOUNT_ERROR_NOT_REGISTERED_PROVIDER, r = E_INVALID_OPERATION, E_INVALID_OPERATION, "[%s] The application does not register the account provider.", GetErrorMessage(E_INVALID_OPERATION));
+       SysTryCatch(NID_SCL, ret != ACCOUNT_ERROR_PERMISSION_DENIED, r = E_INVALID_OPERATION, E_INVALID_OPERATION, "[%s] The application has no permission to update this account.", GetErrorMessage(E_INVALID_OPERATION));
+       SysTryCatch(NID_SCL, ret != ACCOUNT_ERROR_RECORD_NOT_FOUND, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The specified @c account does not exist.", GetErrorMessage(E_OBJ_NOT_FOUND));
+       SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       account_destroy(accountHandle);
+
+       return E_SUCCESS;
+
+CATCH:
+       account_destroy(accountHandle);
+
+       return r;
+}
+
+_AccountManagerImpl*
+_AccountManagerImpl::GetInstance(AccountManager& accountManager)
+{
+       return accountManager.__pAccountManagerImpl;
+}
+
+const _AccountManagerImpl*
+_AccountManagerImpl::GetInstance(const AccountManager& accountManager)
+{
+       return accountManager.__pAccountManagerImpl;
+}
+
+}}  // Tizen::Social
diff --git a/src/FScl_AccountManagerImpl.h b/src/FScl_AccountManagerImpl.h
new file mode 100644 (file)
index 0000000..5366457
--- /dev/null
@@ -0,0 +1,63 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_AccountManagerImpl.h
+ * @brief      This is the header file for the %_AccountManagerImpl class.
+ *
+ * This header file contains the declarations of the %_AccountManagerImpl class.
+ */
+
+#ifndef _FSCL_INTERNAL_ACCOUNT_MANAGER_IMPL_H_
+#define _FSCL_INTERNAL_ACCOUNT_MANAGER_IMPL_H_
+
+#include <FBaseObject.h>
+#include <FBaseResult.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+class Account;
+class AccountManager;
+
+class _AccountManagerImpl
+       : public Tizen::Base::Object
+{
+public:
+       _AccountManagerImpl(void);
+
+       virtual ~_AccountManagerImpl(void);
+
+       result Construct(void);
+
+       result AddAccount(Account& account);
+
+       result RemoveAccount(AccountId accountId);
+
+       result UpdateAccount(const Account& account);
+
+       static _AccountManagerImpl* GetInstance(AccountManager& accountManager);
+
+       static const _AccountManagerImpl* GetInstance(const AccountManager& accountManager);
+
+private:
+       _AccountManagerImpl& operator =(const _AccountManagerImpl& rhs);
+       _AccountManagerImpl(const _AccountManagerImpl& rhs);
+
+};     // _AccountManagerImpl
+
+}}  // Tizen::Social
+
+#endif //_FSCL_INTERNAL_ACCOUNT_MANAGER_IMPL_H_
diff --git a/src/FScl_AccountManagerUtil.cpp b/src/FScl_AccountManagerUtil.cpp
new file mode 100644 (file)
index 0000000..f758db2
--- /dev/null
@@ -0,0 +1,383 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_AccountManagerUtil.cpp
+ * @brief      This is implementation for the _AccountManagerUtil class.
+ *
+ * This file contains the definitions of the _AccountManagerUtil class.
+ */
+
+#include <new>
+#include <unique_ptr.h>
+#include <FAppApp.h>
+#include <FAppTypes.h>
+#include <FBaseColHashMap.h>
+#include <FBaseColIMap.h>
+#include <FBaseResult.h>
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include <FBaseUtilStringTokenizer.h>
+#include <FBase_StringConverter.h>
+#include <FLclLocale.h>
+#include <FSysSettingInfo.h>
+#include <FSclAccount.h>
+#include <FSclAccountProvider.h>
+#include <FSclTypes.h>
+#include "FScl_AccountImpl.h"
+#include "FScl_AccountManagerUtil.h"
+#include "FScl_AccountProviderImpl.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Locales;
+using namespace Tizen::System;
+
+namespace Tizen { namespace Social
+{
+
+static const wchar_t* _SETTING_LOCALE_KEY      = L"http://tizen.org/setting/locale.language";
+static const wchar_t* _DEFAULT_LOCALE          = L"default";
+static const wchar_t* _LOCALE_DELIMETER                = L"_";
+
+bool
+OnAccountTypeLabelReceived(char* pAppId, char* pLabel, char* pLocale, void* pUserData)
+{
+       if (pLabel != null)
+       {
+               String languageLocale;
+               String convertedLanguageLocale;
+
+               result r = SettingInfo::GetValue(String(_SETTING_LOCALE_KEY), languageLocale);
+               SysTryReturn(NID_SCL, !IsFailed(r), false, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               StringTokenizer strTok(languageLocale, String(_LOCALE_DELIMETER));
+               String token;
+
+               strTok.GetNextToken(token);
+               LanguageCode languageCode = Locale::StringToLanguageCode(token);
+               convertedLanguageLocale.Append(Locale::LanguageCodeToTwoLetterLanguageCodeString(languageCode));
+               convertedLanguageLocale.Append(String(_LOCALE_DELIMETER));
+
+               strTok.GetNextToken(token);
+               convertedLanguageLocale.Append(token);
+
+               String* pDisplayName = static_cast<String*> (pUserData);
+               if (convertedLanguageLocale.Equals(String(pLocale)))
+               {
+                       *pDisplayName = String(pLabel);
+               }
+               else if((String(_DEFAULT_LOCALE)).Equals(String(pLocale)) && pDisplayName->IsEmpty())
+               {
+                       *pDisplayName = String(pLabel);
+               }
+       }
+
+       return true;
+}
+
+bool
+OnAccountCustomDataReceived(char* pKey, char* pValue, void* pUserData)
+{
+       if (pKey != null && pValue != null)
+       {
+               std::unique_ptr<String> pExtendedDataKey(new (std::nothrow) String(pKey));
+               SysTryReturn(NID_SCL, pExtendedDataKey != null, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               std::unique_ptr<String> pExtendedDataValue(new (std::nothrow) String(pValue));
+               SysTryReturn(NID_SCL, pExtendedDataValue != null, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               HashMap* pExtendedData = static_cast<HashMap*> (pUserData);
+
+               result r = pExtendedData->Add(pExtendedDataKey.get(), pExtendedDataValue.get());
+               SysTryReturn(NID_SCL, !IsFailed(r), false, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               pExtendedDataKey.release();
+               pExtendedDataValue.release();
+       }
+
+       return true;
+}
+
+bool
+OnAccountProviderCapabilityReceived(char* pAppId, char* pKey, void* pUserData)
+{
+       if (pKey != null)
+       {
+               std::unique_ptr<String> pCapability(new (std::nothrow) String(pKey));
+               SysTryReturn(NID_SCL, pCapability != null, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               ArrayList* pCapabilityList = static_cast<ArrayList*> (pUserData);
+
+               result r = pCapabilityList->Add(pCapability.get());
+               SysTryReturn(NID_SCL, !IsFailed(r), false, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               pCapability.release();
+       }
+
+       return true;
+}
+
+account_h
+_AccountManagerUtil::CreateAccountHandleN(const Account account)
+{
+       ClearLastResult();
+
+       account_h accountHandle = null;
+       int ret = account_create(&accountHandle);
+       SysTryReturn(NID_SCL, ret == ACCOUNT_ERROR_NONE && accountHandle != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       // Set the user name
+       std::unique_ptr<char[]> pCharArrayUserName(_StringConverter::CopyToCharArrayN(account.GetUserName()));
+       SysTryCatch(NID_SCL, pCharArrayUserName != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       ret = account_set_user_name(accountHandle, pCharArrayUserName.get());
+       SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, , E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       // Set the package name
+       {
+               Tizen::App::App* pApp = Tizen::App::App::GetInstance();
+               SysTryCatch(NID_SCL, pApp != null, , E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+               std::unique_ptr<char[]> pCharArrayAppId(_StringConverter::CopyToCharArrayN(pApp->GetAppId()));
+               SysTryCatch(NID_SCL, pCharArrayAppId != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               ret = account_set_package_name(accountHandle, pCharArrayAppId.get());
+               SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, , E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+       }
+
+       // Set the extended data
+       {
+               std::unique_ptr<IMap, AllElementsDeleter> pExtendedData(account.GetExtendedDataN());
+               SysTryCatch(NID_SCL, pExtendedData != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               std::unique_ptr<IMapEnumerator> pMapEnum(pExtendedData->GetMapEnumeratorN());
+               SysTryCatch(NID_SCL, pMapEnum != null, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+               String* pKey = null;
+               String* pVal = null;
+
+               while (pMapEnum->MoveNext() == E_SUCCESS)
+               {
+                       pKey = static_cast<String*> (pMapEnum->GetKey());
+                       std::unique_ptr<char[]> pCharArrayKey(_StringConverter::CopyToCharArrayN(*pKey));
+                       SysTryCatch(NID_SCL, pCharArrayKey != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       pVal = static_cast<String*> (pMapEnum->GetValue());
+                       std::unique_ptr<char[]> pCharArrayVal(_StringConverter::CopyToCharArrayN(*pVal));
+                       SysTryCatch(NID_SCL, pCharArrayVal != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       ret = account_set_custom(accountHandle, pCharArrayKey.get(), pCharArrayVal.get());
+                       SysTryCatch(NID_SCL, ret != ACCOUNT_ERROR_OUT_OF_MEMORY, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+                       SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, , E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+                       pCharArrayKey.reset();
+                       pCharArrayVal.reset();
+               }
+       }
+
+       SetLastResult(E_SUCCESS);
+       return accountHandle;
+
+CATCH:
+       ret = account_destroy(accountHandle);
+       SysTryReturn(NID_SCL, ret == ACCOUNT_ERROR_NONE, null, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       return null;
+}
+
+Account*
+_AccountManagerUtil::ConvertAccountHandleToAccountN(account_h accountHandle)
+{
+       ClearLastResult();
+
+       std::unique_ptr<Account> pAccount(new (std::nothrow) Account(L""));
+       SysTryReturn(NID_SCL, pAccount != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       _AccountImpl* pAccountImpl = _AccountImpl::GetInstance(*(pAccount));
+
+       // Set the account ID
+       int accountDbId = 0;
+       int ret = account_get_account_id(accountHandle, &accountDbId);
+       SysTryReturn(NID_SCL, ret == ACCOUNT_ERROR_NONE, null, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       pAccountImpl->SetId(accountDbId);
+
+       // Set the account provider
+       char* pTempAppId = null;
+
+       ret = account_get_package_name(accountHandle, &pTempAppId);
+       SysTryReturn(NID_SCL, ret == ACCOUNT_ERROR_NONE && pTempAppId != null, null, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       std::unique_ptr<char[], _CharDeleter> pCharArrayAppId(pTempAppId);
+
+       account_type_h accountTypeHandle = null;
+       ret = account_type_create(&accountTypeHandle);
+       SysTryReturn(NID_SCL, ret == ACCOUNT_ERROR_NONE && accountTypeHandle != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       ret = account_type_query_by_app_id(pTempAppId, &accountTypeHandle);
+       if (ret != ACCOUNT_ERROR_NONE || accountTypeHandle == null)
+       {
+               SysLogException(NID_SCL, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+               account_type_destroy(accountTypeHandle);
+               return null;
+       }
+
+       std::unique_ptr<AccountProvider> pAccountProvider(ConvertAccountTypeHandleToAccountProviderN(accountTypeHandle));
+       SysTryReturn(NID_SCL, pAccountProvider != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       pAccountImpl->SetAccountProvider(*pAccountProvider);
+
+       account_type_destroy(accountTypeHandle);
+
+       // Set the user name
+       char* pTempUserName = null;
+
+       ret = account_get_user_name(accountHandle, &pTempUserName);
+       SysTryReturn(NID_SCL, ret == ACCOUNT_ERROR_NONE && pTempUserName != null, null, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       std::unique_ptr<char[], _CharDeleter> pCharArrayUserName(pTempUserName);
+
+       result r = pAccountImpl->SetUserName(pTempUserName);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       // Set the extended data
+       std::unique_ptr<HashMap, AllElementsDeleter> pExtendedData(new HashMap());
+       SysTryReturn(NID_SCL, pExtendedData != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = pExtendedData->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       ret = account_get_custom_all(accountHandle, OnAccountCustomDataReceived, pExtendedData.get());
+       SysTryReturn(NID_SCL, ret == ACCOUNT_ERROR_NONE, null, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       r = GetLastResult();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       std::unique_ptr<IMapEnumerator> pMapEnum(pExtendedData->GetMapEnumeratorN());
+       SysTryReturn(NID_SCL, pMapEnum != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       String* pKey = null;
+       String* pVal = null;
+
+       while (pMapEnum->MoveNext() == E_SUCCESS)
+       {
+               pKey = static_cast<String*> (pMapEnum->GetKey());
+               pVal = static_cast<String*> (pMapEnum->GetValue());
+
+               r = pAccountImpl->SetExtendedData(*pKey, *pVal);
+               SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       SetLastResult(E_SUCCESS);
+       return pAccount.release();
+}
+
+AccountProvider*
+_AccountManagerUtil::ConvertAccountTypeHandleToAccountProviderN(account_type_h accountTypeHandle)
+{
+       ClearLastResult();
+
+       std::unique_ptr<AccountProvider> pAccountProvider(new (std::nothrow) AccountProvider());
+       SysTryReturn(NID_SCL, pAccountProvider != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       _AccountProviderImpl* pAccountProviderImpl = _AccountProviderImpl::GetInstance(*(pAccountProvider));
+
+       // Set the app ID
+       char* pTempAppId = null;
+
+       int ret = account_type_get_app_id(accountTypeHandle, &pTempAppId);
+       SysTryReturn(NID_SCL, ret == ACCOUNT_ERROR_NONE && pTempAppId != null, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       std::unique_ptr<char[], _CharDeleter> pCharArrayAppId(pTempAppId);
+
+       pAccountProviderImpl->SetAppId(pTempAppId);
+
+       // Set the capability list
+       std::unique_ptr<ArrayList, AllElementsDeleter> pCapabilityList(new ArrayList());
+       SysTryReturn(NID_SCL, pCapabilityList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pCapabilityList->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Failed to construct pCapabilityList.", GetErrorMessage(r));
+
+       ret = account_type_query_provider_feature_by_app_id(OnAccountProviderCapabilityReceived, pCharArrayAppId.get(), pCapabilityList.get());
+       SysTryReturn(NID_SCL, ret == ACCOUNT_ERROR_NONE || ret == ACCOUNT_ERROR_RECORD_NOT_FOUND, null, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
+
+       if (pCapabilityList != null)
+       {
+               std::unique_ptr<IEnumerator> pEnum(pCapabilityList->GetEnumeratorN());
+               SysTryReturn(NID_SCL, pEnum != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+               String* pTempCapability = null;
+
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       pTempCapability = static_cast<String*> (pEnum->GetCurrent());
+
+                       r = pAccountProviderImpl->AddCapability(*pTempCapability);
+                       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+       }
+
+       // Set the display name
+       std::unique_ptr<String> pDisplayName(new (std::nothrow) String());
+       SysTryReturn(NID_SCL, pDisplayName != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       ret = account_type_get_label(accountTypeHandle, OnAccountTypeLabelReceived, pDisplayName.get());
+       SysTryReturn(NID_SCL, ret == ACCOUNT_ERROR_NONE, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       r = GetLastResult();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pAccountProviderImpl->SetDisplayName(*pDisplayName);
+
+       // Set the icon path
+       char* pTempIconPath = null;
+
+       ret = account_type_get_icon_path(accountTypeHandle, &pTempIconPath);
+       SysTryReturn(NID_SCL, ret == ACCOUNT_ERROR_NONE, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       if (pTempIconPath != null)
+       {
+               pAccountProviderImpl->SetIconPath(pTempIconPath);
+               free(pTempIconPath);
+       }
+
+       // Set the small icon path
+       char* pTempSmallIconPath = null;
+
+       ret = account_type_get_small_icon_path(accountTypeHandle, &pTempSmallIconPath);
+       SysTryReturn(NID_SCL, ret == ACCOUNT_ERROR_NONE, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       if (pTempSmallIconPath != null)
+       {
+               pAccountProviderImpl->SetSmallIconPath(pTempSmallIconPath);
+               free(pTempSmallIconPath);
+       }
+
+       // Set the multiple accounts support
+       int multipleAccountsSupport = 0;
+       ret = account_type_get_multiple_account_support(accountTypeHandle, &multipleAccountsSupport);
+       SysTryReturn(NID_SCL, ret == ACCOUNT_ERROR_NONE, null, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+
+       pAccountProviderImpl->SetMultipleAccountsSupport(multipleAccountsSupport);
+
+       SetLastResult(E_SUCCESS);
+       return pAccountProvider.release();
+}
+
+}} // Tizen::Social
diff --git a/src/FScl_AccountManagerUtil.h b/src/FScl_AccountManagerUtil.h
new file mode 100644 (file)
index 0000000..4d29aaf
--- /dev/null
@@ -0,0 +1,56 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_AccountManagerUtil.h
+ * @brief      This is the header file for the _AccountManagerUtil class.
+ *
+ * This header file contains the declarations of the _AccountManagerUtil class.
+ */
+
+#ifndef _FSCL_INTERNAL_ACCOUNT_MANAGER_UTIL_H_
+#define _FSCL_INTERNAL_ACCOUNT_MANAGER_UTIL_H_
+
+#include <account.h>
+#include <account-types.h>
+#include <FBaseDataType.h>
+
+namespace Tizen { namespace Social
+{
+
+struct _CharDeleter
+{
+    void operator()(char* pChar)
+    {
+        free(pChar);
+    }
+};
+
+class Account;
+class AccountProvider;
+
+class _AccountManagerUtil
+{
+public:
+       static account_h CreateAccountHandleN(const Account account);
+
+       static Account* ConvertAccountHandleToAccountN(account_h accountHandle);
+       static AccountProvider* ConvertAccountTypeHandleToAccountProviderN(account_type_h accountTypeHandle);
+
+};     // _AccountManagerUtil
+
+}}     // Tizen::Social
+
+#endif //_FSCL_INTERNAL_ACCOUNT_MANAGER_UTIL_H_
diff --git a/src/FScl_AccountProviderImpl.cpp b/src/FScl_AccountProviderImpl.cpp
new file mode 100644 (file)
index 0000000..6dbb410
--- /dev/null
@@ -0,0 +1,327 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_AccountProviderImpl.cpp
+ * @brief              This is the implementation for _AccountProviderImpl class.
+ *
+ * This file contains definitions of @e _AccountProviderImpl class.
+ */
+
+#include <FBaseColIList.h>
+#include <FBaseResult.h>
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include <FSclAccountProvider.h>
+#include "FScl_AccountProviderImpl.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Social
+{
+
+_AccountProviderImpl::_AccountProviderImpl(void)
+       : __isMultipleAccountSupported(false)
+{
+       std::unique_ptr<ArrayList, AllElementsDeleter> pCapabilityList(new (std::nothrow) ArrayList());
+       SysTryReturnVoidResult(NID_SCL, pCapabilityList != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pCapabilityList->Construct();
+       SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Failed to construct pCapabilityList.", GetErrorMessage(r));
+
+       __pCapabilityList = std::move(pCapabilityList);
+}
+
+_AccountProviderImpl::_AccountProviderImpl(const _AccountProviderImpl& rhs)
+{
+       std::unique_ptr<ArrayList, AllElementsDeleter> pCapabilityList(new (std::nothrow) ArrayList());
+       SysTryReturnVoidResult(NID_SCL, pCapabilityList != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pCapabilityList->Construct();
+       SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Failed to construct pCapabilityList.", GetErrorMessage(r));
+
+       std::unique_ptr<IEnumerator> pEnum(rhs.__pCapabilityList->GetEnumeratorN());
+       SysTryReturnVoidResult(NID_SCL, pEnum != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<String> pCapability(null);
+       String* pTempCapability = null;
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pTempCapability = static_cast<String*> (pEnum->GetCurrent());
+               pCapability.reset(new (std::nothrow) String(*pTempCapability));
+               SysTryReturnVoidResult(NID_SCL, pCapability != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pCapabilityList->Add(pCapability.get());
+               SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Propagating.", GetErrorMessage(r));
+
+               pCapability.release();
+       }
+
+       __pCapabilityList = std::move(pCapabilityList);
+
+       __appId = rhs.__appId;
+       __displayName = rhs.__displayName;
+       __iconPath = rhs.__iconPath;
+       __smallIconPath = rhs.__smallIconPath;
+       __isMultipleAccountSupported = rhs.__isMultipleAccountSupported;
+}
+
+_AccountProviderImpl::~_AccountProviderImpl(void)
+{
+       // empty body
+}
+
+_AccountProviderImpl&
+_AccountProviderImpl::operator =(const _AccountProviderImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pCapabilityList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pCapabilityList != null, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pCapabilityList->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), *this, r, "[%s] Failed to construct pCapabilityList.", GetErrorMessage(r));
+
+       result prevResult = GetLastResult();
+
+       std::unique_ptr<IEnumerator> pEnum(rhs.__pCapabilityList->GetEnumeratorN());
+       SysTryReturn(NID_SCL, pEnum != null, *this, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       SetLastResult(prevResult);
+
+       std::unique_ptr<String> pCapability(null);
+       String* pTempCapability = null;
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pTempCapability = static_cast<String*> (pEnum->GetCurrent());
+               pCapability.reset(new (std::nothrow) String(*pTempCapability));
+               SysTryReturn(NID_SCL, pCapability != null, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pCapabilityList->Add(pCapability.get());
+               SysTryReturn(NID_SCL, !IsFailed(r), *this, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               pCapability.release();
+       }
+
+       __pCapabilityList = std::move(pCapabilityList);
+
+       __appId = rhs.__appId;
+       __displayName = rhs.__displayName;
+       __iconPath = rhs.__iconPath;
+       __smallIconPath = rhs.__smallIconPath;
+       __isMultipleAccountSupported = rhs.__isMultipleAccountSupported;
+
+       return *this;
+}
+
+bool
+_AccountProviderImpl::operator ==(const _AccountProviderImpl& rhs) const
+{
+       if ((__appId == rhs.__appId) &&
+               (__displayName == rhs.__displayName) &&
+               (__iconPath == rhs.__iconPath) &&
+               (__smallIconPath == rhs.__smallIconPath) &&
+               (__isMultipleAccountSupported == rhs.__isMultipleAccountSupported) &&
+               (__pCapabilityList->Equals(*(rhs.__pCapabilityList))))
+       {
+               return true;
+       }
+
+       return false;
+}
+
+bool
+_AccountProviderImpl::operator !=(const _AccountProviderImpl& rhs) const
+{
+       return !(*this == rhs);
+}
+
+bool
+_AccountProviderImpl::Equals(const Object& rhs) const
+{
+       const _AccountProviderImpl* pAccountProviderImpl = dynamic_cast<const _AccountProviderImpl*> (&rhs);
+       if (pAccountProviderImpl == null)
+       {
+               return false;
+       }
+
+       if ((__appId != pAccountProviderImpl->__appId) ||
+               (__displayName != pAccountProviderImpl->__displayName) ||
+               (__iconPath != pAccountProviderImpl->__iconPath) ||
+               (__smallIconPath != pAccountProviderImpl->__smallIconPath) ||
+               (__isMultipleAccountSupported != pAccountProviderImpl->__isMultipleAccountSupported) ||
+               !(__pCapabilityList->Equals(*(pAccountProviderImpl->__pCapabilityList))))
+       {
+               return false;
+       }
+
+       return true;
+}
+
+int
+_AccountProviderImpl::GetHashCode(void) const
+{
+       int hashCode = 0;
+
+       hashCode += __appId.GetHashCode();
+       hashCode += __displayName.GetHashCode();
+
+       return hashCode;
+}
+
+result
+_AccountProviderImpl::AddCapability(const String& capability)
+{
+       std::unique_ptr<IEnumerator> pEnum(__pCapabilityList->GetEnumeratorN());
+       SysTryReturnResult(NID_SCL, pEnum != null, GetLastResult(), "Propagating.");
+
+       String* pTempCapability = null;
+       bool alreadyExist = false;
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pTempCapability = static_cast<String*> (pEnum->GetCurrent());
+               if (*pTempCapability == capability)
+               {
+                       alreadyExist = true;
+                       break;
+               }
+       }
+
+       SysTryReturnResult(NID_SCL, !alreadyExist, E_OBJ_ALREADY_EXIST, "The capability already exists.");
+
+       std::unique_ptr<String> pCapability(new (std::nothrow) String(capability));
+       SysTryReturnResult(NID_SCL, pCapability != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       result r = __pCapabilityList->Add(pCapability.get());
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pCapability.release();
+
+       return E_SUCCESS;
+}
+
+AppId
+_AccountProviderImpl::GetAppId(void) const
+{
+       return __appId;
+}
+
+IList*
+_AccountProviderImpl::GetCapabilitiesN(void) const
+{
+       ClearLastResult();
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pCapabilityList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pCapabilityList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pCapabilityList->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Failed to construct pCapabilityList.", GetErrorMessage(r));
+
+       std::unique_ptr<IEnumerator> pEnum(__pCapabilityList->GetEnumeratorN());
+       SysTryReturn(NID_SCL, pEnum != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<String> pCapability(null);
+       String* pTempCapability = null;
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pTempCapability = static_cast<String*> (pEnum->GetCurrent());
+               pCapability.reset(new (std::nothrow) String(*pTempCapability));
+               SysTryReturn(NID_SCL, pCapability != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pCapabilityList->Add(pCapability.get());
+               SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               pCapability.release();
+       }
+
+       return pCapabilityList.release();
+}
+
+String
+_AccountProviderImpl::GetDisplayName(void) const
+{
+       return __displayName;
+}
+
+String
+_AccountProviderImpl::GetIconPath(void) const
+{
+       return __iconPath;
+}
+
+String
+_AccountProviderImpl::GetSmallIconPath(void) const
+{
+       return __smallIconPath;
+}
+
+bool
+_AccountProviderImpl::IsMultipleAccountSupported(void) const
+{
+       return __isMultipleAccountSupported;
+}
+
+void
+_AccountProviderImpl::SetAppId(const AppId& appId)
+{
+       __appId = appId;
+}
+
+void
+_AccountProviderImpl::SetDisplayName(const String& displayName)
+{
+       __displayName = displayName;
+}
+
+void
+_AccountProviderImpl::SetIconPath(const String& iconPath)
+{
+       __iconPath = iconPath;
+}
+
+void
+_AccountProviderImpl::SetSmallIconPath(const String& smallIconPath)
+{
+       __smallIconPath = smallIconPath;
+}
+
+void
+_AccountProviderImpl::SetMultipleAccountsSupport(bool isSupported)
+{
+       __isMultipleAccountSupported = isSupported;
+}
+
+const _AccountProviderImpl*
+_AccountProviderImpl::GetInstance(const AccountProvider& accountProvider)
+{
+       return accountProvider.__pAccountProviderImpl;
+}
+
+_AccountProviderImpl*
+_AccountProviderImpl::GetInstance(AccountProvider& accountProvider)
+{
+       return accountProvider.__pAccountProviderImpl;
+}
+
+}} //Tizen::Social
diff --git a/src/FScl_AccountProviderImpl.h b/src/FScl_AccountProviderImpl.h
new file mode 100644 (file)
index 0000000..b1f8a21
--- /dev/null
@@ -0,0 +1,106 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_AccountProviderImpl.h
+ * @brief      This is the header file for the %_AccountProviderImpl class.
+ *
+ * This header file contains the declarations of the %_AccountProviderImpl class.
+ */
+#ifndef _FSCL_INTERNAL_ACCOUNT_PROVIDER_IMPL_H_
+#define _FSCL_INTERNAL_ACCOUNT_PROVIDER_IMPL_H_
+
+#include <unique_ptr.h>
+#include <FAppTypes.h>
+#include <FBaseColAllElementsDeleter.h>
+#include <FBaseColArrayList.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Base
+{
+namespace Collection
+{
+class IList;
+}
+}}
+
+namespace Tizen { namespace Social
+{
+
+class AccountProvider;
+
+class _AccountProviderImpl
+       : public Tizen::Base::Object
+{
+public:
+       _AccountProviderImpl(void);
+
+       _AccountProviderImpl(const _AccountProviderImpl& rhs);
+
+       virtual ~_AccountProviderImpl(void);
+
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       virtual int GetHashCode(void) const;
+
+       result AddCapability(const Tizen::Base::String& capability);
+
+       Tizen::App::AppId GetAppId(void) const;
+
+       Tizen::Base::Collection::IList* GetCapabilitiesN(void) const;
+
+       Tizen::Base::String GetDisplayName(void) const;
+
+       Tizen::Base::String GetIconPath(void) const;
+
+       Tizen::Base::String GetSmallIconPath(void) const;
+
+       bool IsMultipleAccountSupported(void) const;
+
+       void SetAppId(const Tizen::App::AppId& appId);
+
+       void SetDisplayName(const Tizen::Base::String& displayName);
+
+       void SetIconPath(const Tizen::Base::String& iconPath);
+
+       void SetSmallIconPath(const Tizen::Base::String& smallIconPath);
+
+       void SetMultipleAccountsSupport(bool isSupported);
+
+       _AccountProviderImpl& operator =(const _AccountProviderImpl& rhs);
+
+       bool operator ==(const _AccountProviderImpl& rhs) const;
+
+       bool operator !=(const _AccountProviderImpl& rhs) const;
+
+       static const _AccountProviderImpl* GetInstance(const AccountProvider& accountProvider);
+
+       static _AccountProviderImpl* GetInstance(AccountProvider& accountProvider);
+
+private:
+       Tizen::App::AppId __appId;
+       std::unique_ptr<Tizen::Base::Collection::ArrayList, Tizen::Base::Collection::AllElementsDeleter> __pCapabilityList;
+       Tizen::Base::String __displayName;
+       Tizen::Base::String __iconPath;
+       Tizen::Base::String __smallIconPath;
+       bool __isMultipleAccountSupported;
+
+}; // _AccountProviderImpl
+
+}} // Tizen::Social
+
+#endif //_FSCL_INTERNAL_ACCOUNT_PROVIDER_IMPL_H_
diff --git a/src/FScl_AddressImpl.cpp b/src/FScl_AddressImpl.cpp
new file mode 100644 (file)
index 0000000..6f0153e
--- /dev/null
@@ -0,0 +1,275 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_AddressImpl.cpp
+ * @brief              This is the implementation for _AddressImpl class.
+ *
+ * This file contains definitions of @e _AddressImpl class.
+ */
+
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include <FSclAddress.h>
+#include <FApp_AppInfo.h>
+#include "FScl_AddressImpl.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+_AddressImpl::_AddressImpl(void)
+       : __type(ADDRESS_TYPE_HOME)
+{
+       // empty body.
+}
+
+_AddressImpl::_AddressImpl(const _AddressImpl& rhs)
+{
+       __type = rhs.__type;
+       __label = rhs.__label;
+       __extended = rhs.__extended;
+       __street = rhs.__street;
+       __city = rhs.__city;
+       __state = rhs.__state;
+       __postalCode = rhs.__postalCode;
+       __country = rhs.__country;
+       __postOfficeBoxNumber = rhs.__postOfficeBoxNumber;
+}
+
+_AddressImpl::~_AddressImpl(void)
+{
+       // empty body.
+}
+
+_AddressImpl&
+_AddressImpl::operator =(const _AddressImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __type = rhs.__type;
+       __label = rhs.__label;
+       __extended = rhs.__extended;
+       __street = rhs.__street;
+       __city = rhs.__city;
+       __state = rhs.__state;
+       __postalCode = rhs.__postalCode;
+       __country = rhs.__country;
+       __postOfficeBoxNumber = rhs.__postOfficeBoxNumber;
+
+       return *this;
+}
+
+bool
+_AddressImpl::operator ==(const _AddressImpl& rhs) const
+{
+       if ((__type == rhs.__type) &&
+               (__label == rhs.__label) &&
+               (__extended == rhs.__extended) &&
+               (__street == rhs.__street) &&
+               (__city == rhs.__city) &&
+               (__state == rhs.__state) &&
+               (__postalCode == rhs.__postalCode) &&
+               (__country == rhs.__country) &&
+               (__postOfficeBoxNumber == rhs.__postOfficeBoxNumber))
+       {
+               return true;
+       }
+
+       return false;
+}
+
+bool
+_AddressImpl::operator !=(const _AddressImpl& rhs) const
+{
+       return !(*this == rhs);
+}
+
+bool
+_AddressImpl::Equals(const Object& rhs) const
+{
+       const _AddressImpl* pAddressImpl = dynamic_cast<const _AddressImpl*>(&rhs);
+
+       if (pAddressImpl == null)
+       {
+               return false;
+       }
+
+       return (*this == *pAddressImpl);
+}
+
+int
+_AddressImpl::GetHashCode(void) const
+{
+       int hashCode = 0;
+
+       hashCode = __type;
+       hashCode += __label.GetHashCode();
+       hashCode += __extended.GetHashCode();
+       hashCode += __street.GetHashCode();
+       hashCode += __city.GetHashCode();
+       hashCode += __state.GetHashCode();
+       hashCode += __postalCode.GetHashCode();
+       hashCode += __country.GetHashCode();
+       hashCode += __postOfficeBoxNumber.GetHashCode();
+
+       return hashCode;
+}
+
+AddressType
+_AddressImpl::GetType(void) const
+{
+       return __type;
+}
+
+String
+_AddressImpl::GetExtended(void) const
+{
+       return __extended;
+}
+
+String
+_AddressImpl::GetStreet(void) const
+{
+       return __street;
+}
+
+String
+_AddressImpl::GetCity(void) const
+{
+       return __city;
+}
+
+String
+_AddressImpl::GetState(void) const
+{
+       return __state;
+}
+
+String
+_AddressImpl::GetPostalCode(void) const
+{
+
+       return __postalCode;
+}
+
+String
+_AddressImpl::GetCountry(void) const
+{
+
+       return __country;
+}
+
+String
+_AddressImpl::GetPostOfficeBoxNumber(void) const
+{
+       return __postOfficeBoxNumber;
+}
+
+void
+_AddressImpl::SetType(AddressType type)
+{
+       __type = type;
+}
+
+void
+_AddressImpl::SetExtended(const String& extended)
+{
+       __extended = extended;
+}
+
+void
+_AddressImpl::SetStreet(const String& street)
+{
+       __street = street;
+}
+
+void
+_AddressImpl::SetCity(const String& city)
+{
+       __city = city;
+}
+
+void
+_AddressImpl::SetState(const String& state)
+{
+       __state = state;
+}
+
+void
+_AddressImpl::SetPostalCode(const String& postalCode)
+{
+       __postalCode = postalCode;
+}
+
+void
+_AddressImpl::SetCountry(const String& country)
+{
+       __country = country;
+}
+
+void
+_AddressImpl::SetPostOfficeBoxNumber(const String& postOfficeBoxNumber)
+{
+       __postOfficeBoxNumber = postOfficeBoxNumber;
+}
+
+String
+_AddressImpl::GetLabel(void) const
+{
+       return __label;
+}
+
+void
+_AddressImpl::SetLabel(const String& label)
+{
+       __label = label;
+}
+
+bool
+_AddressImpl::IsEmpty(void) const
+{
+       if (!__extended.IsEmpty() ||
+               !__postalCode.IsEmpty() ||
+               !__postOfficeBoxNumber.IsEmpty() ||
+               !__state.IsEmpty() ||
+               !__country.IsEmpty() ||
+               !__city.IsEmpty() ||
+               !__street.IsEmpty())
+       {
+               return false;
+       }
+
+       return true;
+}
+
+const _AddressImpl*
+_AddressImpl::GetInstance(const Address& address)
+{
+       return address.__pAddressImpl;
+}
+
+_AddressImpl*
+_AddressImpl::GetInstance(Address& address)
+{
+       return address.__pAddressImpl;
+}
+
+}} //Tizen::Social
diff --git a/src/FScl_AddressImpl.h b/src/FScl_AddressImpl.h
new file mode 100644 (file)
index 0000000..17230b0
--- /dev/null
@@ -0,0 +1,112 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_AddressImpl.h
+ * @brief      This is the header file for the %_AddressImpl class.
+ *
+ * This header file contains the declarations of the %_AddressImpl class.
+ */
+#ifndef _FSCL_INTERNAL_ADDRESS_IMPL_H_
+#define _FSCL_INTERNAL_ADDRESS_IMPL_H_
+
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+
+class Address;
+
+class _OSP_EXPORT_ _AddressImpl
+       : public Tizen::Base::Object
+{
+public:
+       _AddressImpl(void);
+
+       _AddressImpl(const _AddressImpl& rhs);
+
+       virtual ~_AddressImpl(void);
+
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       virtual int GetHashCode(void) const;
+
+       AddressType GetType(void) const;
+
+       Tizen::Base::String GetExtended(void) const;
+
+       Tizen::Base::String GetStreet(void) const;
+
+       Tizen::Base::String GetCity(void) const;
+
+       Tizen::Base::String GetState(void) const;
+
+       Tizen::Base::String GetPostalCode(void) const;
+
+       Tizen::Base::String GetCountry(void) const;
+
+       Tizen::Base::String GetPostOfficeBoxNumber(void) const;
+
+       void SetType(AddressType type);
+
+       void SetExtended(const Tizen::Base::String& extended);
+
+       void SetStreet(const Tizen::Base::String& street);
+
+       void SetCity(const Tizen::Base::String& city);
+
+       void SetState(const Tizen::Base::String& state);
+
+       void SetPostalCode(const Tizen::Base::String& postalCode);
+
+       void SetCountry(const Tizen::Base::String& country);
+
+       void SetPostOfficeBoxNumber(const Tizen::Base::String& postOfficeBoxNumber);
+
+       Tizen::Base::String GetLabel(void) const;
+
+       void SetLabel(const Tizen::Base::String& label);
+
+       _AddressImpl& operator =(const _AddressImpl& rhs);
+
+       bool IsEmpty(void) const;
+
+       bool operator ==(const _AddressImpl& rhs) const;
+
+       bool operator !=(const _AddressImpl& rhs) const;
+
+       static const _AddressImpl* GetInstance(const Address& address);
+
+       static _AddressImpl* GetInstance(Address& Address);
+
+private:
+       AddressType __type;
+       Tizen::Base::String __label;
+       Tizen::Base::String __extended;
+       Tizen::Base::String __street;
+       Tizen::Base::String __city;
+       Tizen::Base::String __state;
+       Tizen::Base::String __postalCode;
+       Tizen::Base::String __country;
+       Tizen::Base::String __postOfficeBoxNumber;
+
+}; // _AddressImpl
+
+}} // Tizen::Social
+
+#endif //_FSCL_INTERNAL_ADDRESS_IMPL_H_
diff --git a/src/FScl_AddressbookFilterImpl.cpp b/src/FScl_AddressbookFilterImpl.cpp
new file mode 100644 (file)
index 0000000..646998e
--- /dev/null
@@ -0,0 +1,444 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FScl_AddressbookFilterImpl.cpp
+* @brief       This is the implementation for _AddressbookFilterImpl class.
+*
+* This file contains definitions of @e _AddressbookFilterImpl class.
+*/
+
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FSclAddressbookFilter.h>
+#include <FBase_StringConverter.h>
+#include "FScl_AddressbookUtil.h"
+#include "FScl_AddressbookFilterImpl.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+// AB_FI_TYPE_ADDRESSBOOK
+// The entries must be ordered same as AddressbookFilterProperty
+const _AddressbookFilterImpl::__FilterPropertyInfoEntry _AddressbookFilterImpl::__addressbookFilterPropertyInfos[] =
+{
+       {AB_FI_PR_ADDRESSBOOK_ID, _contacts_address_book.id, DATA_TYPE_INT},
+       {AB_FI_PR_ACCOUNT_ID, _contacts_address_book.account_id, DATA_TYPE_INT},
+       {AB_FI_PR_NAME, _contacts_address_book.name, DATA_TYPE_STRING},
+};
+
+// AB_FI_TYPE_PERSON
+// The entries must be ordered same as PersonFilterProperty
+const _AddressbookFilterImpl::__FilterPropertyInfoEntry _AddressbookFilterImpl::__personFilterPropertyInfos[] =
+{
+       {PERSON_FI_PR_PERSON_ID, _contacts_person_grouprel.person_id, DATA_TYPE_INT},
+       {PERSON_FI_PR_DISPLAY_NAME, _contacts_person_grouprel.display_name, DATA_TYPE_STRING},
+       {PERSON_FI_PR_HAS_PHONE, _contacts_person_grouprel.has_phonenumber, DATA_TYPE_BOOL},
+       {PERSON_FI_PR_HAS_EMAIL, _contacts_person_grouprel.has_email, DATA_TYPE_BOOL},
+       {PERSON_FI_PR_IS_FAVORITE, _contacts_person_grouprel.is_favorite, DATA_TYPE_BOOL},
+       {PERSON_FI_PR_CATEGORY_ID, _contacts_person_grouprel.group_id, DATA_TYPE_INT},
+       {PERSON_FI_PR_ADDRESSBOOK_ID, _contacts_person_grouprel.address_book_id, DATA_TYPE_INT},
+};
+
+// AB_FI_TYPE_CONTACT
+// The entries must be ordered same as ContactFilterProperty
+const _AddressbookFilterImpl::__FilterPropertyInfoEntry _AddressbookFilterImpl::__contactFilterPropertyInfos[] =
+{
+       {CONTACT_FI_PR_CONTACT_ID, _contacts_contact.id, DATA_TYPE_INT},
+       {CONTACT_FI_PR_ADDRESSBOOK_ID, _contacts_contact.address_book_id, DATA_TYPE_INT},
+       {CONTACT_FI_PR_PERSON_ID, _contacts_contact.person_id, DATA_TYPE_INT},
+       {CONTACT_FI_PR_DISPLAY_NAME, _contacts_contact.display_name, DATA_TYPE_STRING},
+       {CONTACT_FI_PR_HAS_PHONE, _contacts_contact.has_phonenumber, DATA_TYPE_BOOL},
+       {CONTACT_FI_PR_HAS_EMAIL, _contacts_contact.has_email, DATA_TYPE_BOOL},
+};
+
+// AB_FI_TYPE_CATEGORY
+// The entries must be ordered same as CategoryFilterProperty
+const _AddressbookFilterImpl::__FilterPropertyInfoEntry _AddressbookFilterImpl::__categoryFilterPropertyInfos[] =
+{
+       {CATEGORY_FI_PR_CATEGORY_ID, _contacts_group.id, DATA_TYPE_INT},
+       {CATEGORY_FI_PR_ADDRESSBOOK_ID, _contacts_group.address_book_id, DATA_TYPE_INT},
+       {CATEGORY_FI_PR_NAME, _contacts_group.name, DATA_TYPE_STRING},
+};
+
+// AB_FI_TYPE_PHONE_CONTACT
+// The entries must be ordered same as PhoneContactFilterProperty
+const _AddressbookFilterImpl::__FilterPropertyInfoEntry _AddressbookFilterImpl::__phoneContactFilterPropertyInfos[] =
+{
+       {PHONE_CONTACT_FI_PR_CONTACT_ID, _contacts_contact_number.contact_id, DATA_TYPE_INT},
+       {PHONE_CONTACT_FI_PR_ADDRESSBOOK_ID, _contacts_contact_number.address_book_id, DATA_TYPE_INT},
+       {PHONE_CONTACT_FI_PR_PERSON_ID, _contacts_contact_number.person_id, DATA_TYPE_INT},
+       {PHONE_CONTACT_FI_PR_DISPLAY_NAME, _contacts_contact_number.display_name, DATA_TYPE_STRING},
+       {PHONE_CONTACT_FI_PR_PHONE, _contacts_contact_number.normalized_number, DATA_TYPE_STRING},
+};
+
+// AB_FI_TYPE_EMAIL_CONTACT
+// The entries must be ordered same as EmailContactFilterProperty
+const _AddressbookFilterImpl::__FilterPropertyInfoEntry _AddressbookFilterImpl::__emailContactFilterPropertyInfos[] =
+{
+       {EMAIL_CONTACT_FI_PR_CONTACT_ID, _contacts_contact_email.contact_id, DATA_TYPE_INT},
+       {EMAIL_CONTACT_FI_PR_ADDRESSBOOK_ID, _contacts_contact_email.address_book_id, DATA_TYPE_INT},
+       {EMAIL_CONTACT_FI_PR_PERSON_ID, _contacts_contact_email.person_id, DATA_TYPE_INT},
+       {EMAIL_CONTACT_FI_PR_DISPLAY_NAME, _contacts_contact_email.display_name, DATA_TYPE_STRING},
+       {EMAIL_CONTACT_FI_PR_EMAIL, _contacts_contact_email.email, DATA_TYPE_STRING},
+};
+
+const _AddressbookFilterImpl::__FilterInfoEntry _AddressbookFilterImpl::__filterInfos[] =
+{
+       {AB_FI_TYPE_ADDRESSBOOK, _contacts_address_book._uri, AB_FI_PR_ADDRESSBOOK_ID, sizeof(__addressbookFilterPropertyInfos)/sizeof(_AddressbookFilterImpl::__FilterPropertyInfoEntry), __addressbookFilterPropertyInfos},
+       {AB_FI_TYPE_PERSON, _contacts_person_grouprel._uri, PERSON_FI_PR_PERSON_ID, sizeof(__personFilterPropertyInfos)/sizeof(_AddressbookFilterImpl::__FilterPropertyInfoEntry), __personFilterPropertyInfos},
+       {AB_FI_TYPE_CONTACT, _contacts_contact._uri, CONTACT_FI_PR_CONTACT_ID, sizeof(__contactFilterPropertyInfos)/sizeof(_AddressbookFilterImpl::__FilterPropertyInfoEntry), __contactFilterPropertyInfos},
+       {AB_FI_TYPE_CATEGORY, _contacts_group._uri, CATEGORY_FI_PR_CATEGORY_ID, sizeof(__categoryFilterPropertyInfos)/sizeof(_AddressbookFilterImpl::__FilterPropertyInfoEntry), __categoryFilterPropertyInfos},
+       {AB_FI_TYPE_PHONE_CONTACT, _contacts_contact_number._uri, PHONE_CONTACT_FI_PR_CONTACT_ID, sizeof(__phoneContactFilterPropertyInfos)/sizeof(_AddressbookFilterImpl::__FilterPropertyInfoEntry), __phoneContactFilterPropertyInfos},
+       {AB_FI_TYPE_EMAIL_CONTACT, _contacts_contact_email._uri, EMAIL_CONTACT_FI_PR_CONTACT_ID, sizeof(__emailContactFilterPropertyInfos)/sizeof(_AddressbookFilterImpl::__FilterPropertyInfoEntry), __emailContactFilterPropertyInfos},
+};
+
+bool
+_AddressbookFilterImpl::IsValidProperty(AddressbookFilterType filterType, unsigned long property)
+{
+       int filterInfoCount = sizeof(__filterInfos)/sizeof(__FilterInfoEntry);
+
+       if (filterType < 0 || filterType > (filterInfoCount - 1))
+       {
+               return false;
+       }
+
+       unsigned long baseIndex = __filterInfos[filterType].baseIndex;
+       int propertyInfoCount = __filterInfos[filterType].propertyInfoCount;
+
+       if (property < baseIndex || property >= (baseIndex + propertyInfoCount))
+       {
+               return false;
+       }
+
+       return true;
+}
+
+// IsValidProperty must be called before calling this. If IsValidProperty returns false
+// this should not be called.
+const char*
+_AddressbookFilterImpl::GetUriFromType(AddressbookFilterType filterType)
+{
+       return __filterInfos[filterType].pViewUri;
+}
+
+// IsValidProperty must be called before calling this. If IsValidProperty returns false
+// this should not be called.
+unsigned int
+_AddressbookFilterImpl::GetViewPropertyId(AddressbookFilterType filterType, unsigned long property)
+{
+       const __FilterPropertyInfoEntry* propertyInfos = __filterInfos[filterType].propertyInfos;
+       unsigned long baseIndex = __filterInfos[filterType].baseIndex;
+
+       return propertyInfos[property - baseIndex].viewPropertyId;
+}
+
+// IsValidProperty must be called before calling this. If IsValidProperty returns false
+// this should not be called.
+__DataType
+_AddressbookFilterImpl::GetPropertyType(AddressbookFilterType filterType, unsigned long property)
+{
+       const __FilterPropertyInfoEntry* propertyInfos = __filterInfos[filterType].propertyInfos;
+       unsigned long baseIndex = __filterInfos[filterType].baseIndex;
+
+       return propertyInfos[property - baseIndex].dataType;
+}
+
+_AddressbookFilterImpl::_AddressbookFilterImpl(AddressbookFilterType type)
+       : __filterHandle(null)
+       , __filterType(type)
+       , __isEmpty(true)
+{
+       contacts_filter_h filterHandle = null;
+       const char* pUri = GetUriFromType(type);
+
+       _AddressbookUtil::InitContactViews();
+
+       int ret = contacts_filter_create(pUri, &filterHandle);
+       SysTryReturnVoidResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, "[%s ] Memory allocation failed.", GetErrorMessage(GetLastResult()));
+
+       __filterHandle = filterHandle;
+}
+
+_AddressbookFilterImpl::~_AddressbookFilterImpl(void)
+{
+       if (__filterHandle != null)
+       {
+               contacts_filter_destroy(__filterHandle);
+       }
+}
+
+bool
+_AddressbookFilterImpl::Equals(const Tizen::Base::Object& rhs) const
+{
+       const _AddressbookFilterImpl* pAddressbookFilter = dynamic_cast<const _AddressbookFilterImpl*>(&rhs);
+       if (this == pAddressbookFilter)
+       {
+               return true;
+       }
+
+       return false;
+}
+
+int
+_AddressbookFilterImpl::GetHashCode(void) const
+{
+       return (int)__filterHandle;
+}
+
+contacts_match_int_flag_e
+_AddressbookFilterImpl::GetMatchIntFlag(FilterComparisonOperator comparisonOperator)
+{
+       contacts_match_int_flag_e match = CONTACTS_MATCH_NONE;
+       switch(comparisonOperator)
+       {
+       case FI_CMP_OP_EQUAL:
+               match = CONTACTS_MATCH_EQUAL;
+               break;
+       case FI_CMP_OP_LESS_THAN:
+               match = CONTACTS_MATCH_GREATER_THAN;
+               break;
+       case FI_CMP_OP_LESS_THAN_OR_EQUAL:
+               match = CONTACTS_MATCH_GREATER_THAN_OR_EQUAL;
+               break;
+       case FI_CMP_OP_GREATER_THAN:
+               match = CONTACTS_MATCH_LESS_THAN;
+               break;
+       case FI_CMP_OP_GREATER_THAN_OR_EQUAL:
+               match = CONTACTS_MATCH_LESS_THAN_OR_EQUAL;
+               break;
+       case FI_CMP_OP_IS_NULL:
+               match = CONTACTS_MATCH_NONE;
+               break;
+       default:
+               match = CONTACTS_MATCH_NONE;
+               break;
+       };
+
+       return match;
+}
+
+contacts_match_str_flag_e
+_AddressbookFilterImpl::GetMatchStrFlag(FilterStringOperator stringOperstor)
+{
+       contacts_match_str_flag_e match = CONTACTS_MATCH_EXISTS;
+       switch(stringOperstor)
+       {
+       case FI_STR_OP_EQUAL:
+               match = CONTACTS_MATCH_EXACTLY;
+               break;
+       case FI_STR_OP_FULL_STRING:
+               match = CONTACTS_MATCH_FULLSTRING;
+               break;
+       case FI_STR_OP_START_WITH:
+               match = CONTACTS_MATCH_STARTSWITH;
+               break;
+       case FI_STR_OP_END_WITH:
+               match = CONTACTS_MATCH_ENDSWITH;
+               break;
+       case FI_STR_OP_CONTAIN:
+               match = CONTACTS_MATCH_CONTAINS;
+               break;
+       case FI_STR_OP_IS_NOT_NULL:
+               match = CONTACTS_MATCH_EXISTS;
+               break;
+       default:
+               match = CONTACTS_MATCH_EXISTS;
+               break;
+       };
+
+       return match;
+}
+
+
+result
+_AddressbookFilterImpl::AppendInt(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, int value)
+{
+       SysTryReturn(NID_SCL, IsValidProperty(__filterType, filterProperty), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified filter property is invalid.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, GetPropertyType(__filterType, filterProperty) == DATA_TYPE_INT, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The type of the specified filter property %d must be int.", GetErrorMessage(E_INVALID_ARG), filterProperty);
+       SysTryReturn(NID_SCL, !(__isEmpty && (conjunctiveOperator == FI_CONJ_OP_AND || conjunctiveOperator == FI_CONJ_OP_OR)),\
+                       E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. conjunctiveOperator %d must be FI_CONJ_OP_NONE if there is no filtering expression or filter that has been appended before",\
+                       GetErrorMessage(E_INVALID_ARG), conjunctiveOperator);
+       SysTryReturn(NID_SCL, !(!__isEmpty && (conjunctiveOperator == FI_CONJ_OP_NONE)),\
+                       E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. conjunctiveOperator %d must be either of FI_CONJ_OP_AND or FI_CONJ_OP_OR, if there is a filtering expression or filter that has been appended before.",\
+                       GetErrorMessage(E_INVALID_ARG), conjunctiveOperator);
+
+
+       unsigned int id = _AddressbookFilterImpl::GetViewPropertyId(__filterType, filterProperty);
+       contacts_match_int_flag_e match = GetMatchIntFlag(comparisonOperator);
+
+       if (!__isEmpty)
+       {
+               contacts_filter_operator_e filterOperator = conjunctiveOperator == FI_CONJ_OP_AND ? CONTACTS_FILTER_OPERATOR_AND : CONTACTS_FILTER_OPERATOR_OR;
+
+               contacts_filter_add_operator(__filterHandle, filterOperator);
+       }
+
+       int ret = contacts_filter_add_int(__filterHandle, id, match, value);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __isEmpty = false;
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookFilterImpl::AppendBool(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, bool value)
+{
+       SysTryReturn(NID_SCL, IsValidProperty(__filterType, filterProperty), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified filter property is invalid.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, GetPropertyType(__filterType, filterProperty) == DATA_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The type of the specified filter property %d must be bool.", GetErrorMessage(E_INVALID_ARG), filterProperty);
+       SysTryReturn(NID_SCL, !(__isEmpty && (conjunctiveOperator == FI_CONJ_OP_AND || conjunctiveOperator == FI_CONJ_OP_OR)),\
+                       E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. conjunctiveOperator %d must be FI_CONJ_OP_NONE if there is no filtering expression or filter that has been appended before",\
+                       GetErrorMessage(E_INVALID_ARG), conjunctiveOperator);
+       SysTryReturn(NID_SCL, !(!__isEmpty && conjunctiveOperator == FI_CONJ_OP_NONE),\
+                       E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. conjunctiveOperator %d must be either of FI_CONJ_OP_AND or FI_CONJ_OP_OR, if there is a filtering expression or filter that has been appended before.",\
+                       GetErrorMessage(E_INVALID_ARG), conjunctiveOperator);
+       SysTryReturn(NID_SCL, comparisonOperator == FI_CMP_OP_EQUAL, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. comparisonOperator %d must be FI_CMP_OP_EQUAL.", GetErrorMessage(E_INVALID_ARG), comparisonOperator);
+
+       unsigned int viewPropertyId = _AddressbookFilterImpl::GetViewPropertyId(__filterType, filterProperty);
+
+       if (!__isEmpty)
+       {
+               contacts_filter_operator_e filterOperator = conjunctiveOperator == FI_CONJ_OP_AND ? CONTACTS_FILTER_OPERATOR_AND : CONTACTS_FILTER_OPERATOR_OR;
+
+               contacts_filter_add_operator(__filterHandle, filterOperator);
+       }
+
+
+       int ret = contacts_filter_add_bool(__filterHandle, viewPropertyId, value);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __isEmpty = false;
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookFilterImpl::AppendString(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterStringOperator comparisonOperator, const Tizen::Base::String& value)
+{
+       SysTryReturn(NID_SCL, IsValidProperty(__filterType, filterProperty), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified filter property is invalid.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, GetPropertyType(__filterType, filterProperty) == DATA_TYPE_STRING, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The type of the specified filter property %d must be String.", GetErrorMessage(E_INVALID_ARG), filterProperty);
+       SysTryReturn(NID_SCL, !(__isEmpty && (conjunctiveOperator == FI_CONJ_OP_AND  || conjunctiveOperator == FI_CONJ_OP_OR)),\
+                       E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. conjunctiveOperator %d must be FI_CONJ_OP_NONE if there is no filtering expression or filter that has been appended before",\
+                       GetErrorMessage(E_INVALID_ARG), conjunctiveOperator);
+       SysTryReturn(NID_SCL, !(!__isEmpty && conjunctiveOperator == FI_CONJ_OP_NONE),\
+                       E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. conjunctiveOperator %d must be either of FI_CONJ_OP_AND or FI_CONJ_OP_OR, if there is a filtering expression or filter that has been appended before.",\
+                       GetErrorMessage(E_INVALID_ARG), conjunctiveOperator);
+
+
+       unsigned int viewPropertyId = _AddressbookFilterImpl::GetViewPropertyId(__filterType, filterProperty);
+       contacts_match_str_flag_e match = GetMatchStrFlag(comparisonOperator);
+       std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(value));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       if (!__isEmpty)
+       {
+               contacts_filter_operator_e filterOperator = conjunctiveOperator == FI_CONJ_OP_AND ? CONTACTS_FILTER_OPERATOR_AND : CONTACTS_FILTER_OPERATOR_OR;
+
+               contacts_filter_add_operator(__filterHandle, filterOperator);
+       }
+
+       int ret = CONTACTS_ERROR_NONE;
+
+       if (filterProperty == PHONE_CONTACT_FI_PR_PHONE)
+       {
+               contacts_filter_h numberHandle = null;
+               ret = contacts_filter_create(_contacts_contact_number._uri, &numberHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s ] Memory allocation failed.", GetErrorMessage(GetLastResult()));
+
+               contacts_filter_add_str(numberHandle, viewPropertyId, match, pCharArray.get());
+               contacts_filter_add_operator(numberHandle, CONTACTS_FILTER_OPERATOR_OR);
+               contacts_filter_add_str(numberHandle, _contacts_contact_number.number, match, pCharArray.get());
+
+               ret = contacts_filter_add_filter(__filterHandle, numberHandle);
+               contacts_filter_destroy(numberHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+       else
+       {
+               ret = contacts_filter_add_str(__filterHandle, viewPropertyId, match, pCharArray.get());
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       __isEmpty = false;
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookFilterImpl::AppendFilter(FilterConjunctiveOperator conjunctiveOperator, const _AddressbookFilterImpl& filter)
+{
+       SysTryReturn(NID_SCL, !filter.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified filter should not be empty.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, __filterType == filter.__filterType, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The type of the filter must be same with the type of this filter.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !(__isEmpty && (conjunctiveOperator == FI_CONJ_OP_AND || conjunctiveOperator == FI_CONJ_OP_OR)),\
+                       E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. conjunctiveOperator %d must be FI_CONJ_OP_NONE if there is no filtering expression or filter that has been appended before",\
+                       GetErrorMessage(E_INVALID_ARG), conjunctiveOperator);
+       SysTryReturn(NID_SCL, !(!__isEmpty && conjunctiveOperator == FI_CONJ_OP_NONE),\
+                       E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. conjunctiveOperator %d must be either of FI_CONJ_OP_AND or FI_CONJ_OP_OR, if there is a filtering expression or filter that has been appended before.",\
+                       GetErrorMessage(E_INVALID_ARG), conjunctiveOperator);
+
+       if (!__isEmpty)
+       {
+               contacts_filter_operator_e filterOperator = conjunctiveOperator == FI_CONJ_OP_AND ? CONTACTS_FILTER_OPERATOR_AND : CONTACTS_FILTER_OPERATOR_OR;
+               contacts_filter_add_operator(__filterHandle, filterOperator);
+       }
+
+       int ret = contacts_filter_add_filter(__filterHandle, filter.__filterHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __isEmpty = false;
+
+       return E_SUCCESS;
+}
+
+contacts_filter_h
+_AddressbookFilterImpl::GetFilterHandle(void) const
+{
+       if (!__isEmpty)
+       {
+               return __filterHandle;
+       }
+
+       return null;
+}
+
+AddressbookFilterType
+_AddressbookFilterImpl::GetType(void) const
+{
+       return __filterType;
+}
+
+bool
+_AddressbookFilterImpl::IsEmpty(void) const
+{
+       return __isEmpty;
+}
+
+const _AddressbookFilterImpl*
+_AddressbookFilterImpl::GetInstance(const AddressbookFilter& filter)
+{
+       return filter.__pAddressbookFilterImpl;
+}
+
+_AddressbookFilterImpl*
+_AddressbookFilterImpl::GetInstance(AddressbookFilter& filter)
+{
+       return filter.__pAddressbookFilterImpl;
+}
+
+}} // Tizen::Social
diff --git a/src/FScl_AddressbookFilterImpl.h b/src/FScl_AddressbookFilterImpl.h
new file mode 100644 (file)
index 0000000..016cd59
--- /dev/null
@@ -0,0 +1,123 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_AddressbookFilterImpl.h
+ * @brief              This is the header file for the %_AddressbookFilterImpl class.
+ *
+ * This header file contains the declarations of the %_AddressbookFilterImpl class.
+ */
+#ifndef _FSCL_ADDRESSBOOK_FILTER_IMPL_H_
+#define _FSCL_ADDRESSBOOK_FILTER_IMPL_H_
+
+#include <contacts.h>
+#include <FBaseTypes.h>
+#include <FSclTypes.h>
+#include <FBaseObject.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+}}
+
+namespace Tizen { namespace Social
+{
+
+class AddressbookFilter;
+
+enum __DataType
+{
+       DATA_TYPE_NONE,
+       DATA_TYPE_INT,
+       DATA_TYPE_BOOL,
+       DATA_TYPE_STRING,
+};
+
+class _OSP_EXPORT_ _AddressbookFilterImpl
+           : public Tizen::Base::Object
+{
+public:
+       _AddressbookFilterImpl(AddressbookFilterType type);
+
+       virtual ~_AddressbookFilterImpl(void);
+
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       virtual int GetHashCode(void) const;
+
+       contacts_filter_h GetFilterHandle(void) const;
+
+       AddressbookFilterType GetType(void) const;
+
+       bool IsEmpty(void) const;
+
+       result AppendInt(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, int value);
+
+       result AppendBool(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, bool value);
+
+       result AppendString(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterStringOperator comparisonOperator, const Tizen::Base::String& value);
+
+       result AppendFilter(FilterConjunctiveOperator conjunctiveOperator, const _AddressbookFilterImpl& filter);
+
+       static const char* GetUriFromType(AddressbookFilterType type);
+
+       static __DataType GetPropertyType(AddressbookFilterType type, unsigned long filterProperty);
+
+       static bool IsValidProperty(AddressbookFilterType type, unsigned long filterProperty);
+
+       static unsigned int GetViewPropertyId(AddressbookFilterType type, unsigned long filterProperty);
+
+       static const _AddressbookFilterImpl* GetInstance(const AddressbookFilter& filter);
+
+       static  _AddressbookFilterImpl* GetInstance(AddressbookFilter& filter);
+
+public:
+       struct __FilterPropertyInfoEntry
+       {
+               unsigned long propertyId;
+               unsigned long viewPropertyId;
+               __DataType dataType;
+       };
+
+       struct __FilterInfoEntry
+       {
+               unsigned long filterType;
+               const char* pViewUri;
+               unsigned long baseIndex;
+               unsigned long propertyInfoCount;
+               const __FilterPropertyInfoEntry* propertyInfos;
+       };
+
+       static const __FilterPropertyInfoEntry __addressbookFilterPropertyInfos[];
+       static const __FilterPropertyInfoEntry __personFilterPropertyInfos[];
+       static const __FilterPropertyInfoEntry __contactFilterPropertyInfos[];
+       static const __FilterPropertyInfoEntry __categoryFilterPropertyInfos[];
+       static const __FilterPropertyInfoEntry __phoneContactFilterPropertyInfos[];
+       static const __FilterPropertyInfoEntry __emailContactFilterPropertyInfos[];
+       static const __FilterInfoEntry __filterInfos[];
+
+private:
+       // get match flag
+       static contacts_match_str_flag_e GetMatchStrFlag(FilterStringOperator stringOperstor);
+       static contacts_match_int_flag_e GetMatchIntFlag(FilterComparisonOperator comparisonOperator);
+
+       contacts_filter_h __filterHandle;
+       AddressbookFilterType __filterType;
+       bool __isEmpty;
+};         // _AddressbookFilterImpl
+
+}} // Tizen::Social
+
+#endif // _FSCL_ADDRESSBOOK_FILTER_IMPL_H_
diff --git a/src/FScl_AddressbookImpl.cpp b/src/FScl_AddressbookImpl.cpp
new file mode 100644 (file)
index 0000000..e82917b
--- /dev/null
@@ -0,0 +1,2492 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_AddressbookImpl.cpp
+ * @brief              This is the implementation for _AddressbookImpl class.
+ *
+ * This file contains definitions of @e _AddressbookImpl class.
+ */
+#include <contacts.h>
+#include <unique_ptr.h>
+#include <FApp.h>
+#include <FBaseColIListT.h>
+#include <FBaseColArrayListT.h>
+#include <FBaseResult.h>
+#include <FBaseLongLong.h>
+#include <FBaseInteger.h>
+#include <FIoFile.h>
+#include <FSclContact.h>
+#include <FSclCategory.h>
+#include <FSclUserProfile.h>
+#include <FSclContactChangeInfo.h>
+#include <FSclCategoryChangeInfo.h>
+#include <FSclAddressbook.h>
+#include <FSclIAddressbookEventListener.h>
+#include <FSclIAddressbookChangeEventListener.h>
+#include <FSclIRecordEventListener.h>
+#include <FApp_AppInfo.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include "FScl_AddressbookImpl.h"
+#include "FScl_AddressbookUtil.h"
+#include "FScl_CategoryChangeInfoImpl.h"
+#include "FScl_CategoryImpl.h"
+#include "FScl_ContactChangeInfoImpl.h"
+#include "FScl_ContactDbMonitor.h"
+#include "FScl_ContactImpl.h"
+#include "FScl_RecordImpl.h"
+#include "FScl_UserProfileImpl.h"
+#include "FScl_ContactDbConnector.h"
+
+using namespace std;
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Graphics;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Social
+{
+
+_AddressbookImpl::_AddressbookImpl(void)
+       : __pIRecordEventListener(null)
+       , __pIAddressbookEventListener(null)
+       , __pIAddressbookChangeEventListener(null)
+       , __dbVersionForContact(0)
+       , __dbVersionForGroup(0)
+       , __dbVersionForRelation(0)
+       , __addressbookId(INVALID_ADDRESSBOOK_ID)
+       , __accountId(-1)
+{
+       // empty body.
+}
+
+_AddressbookImpl::~_AddressbookImpl(void)
+{
+       if (__pIAddressbookEventListener != null || __pIRecordEventListener != null || __pIAddressbookChangeEventListener != null)
+       {
+               _ContactDbMonitor* pDbMonitor = _ContactDbMonitor::GetInstance();
+               if (pDbMonitor != null)
+               {
+                       pDbMonitor->RemoveListener(*this);
+               }
+       }
+}
+
+result
+_AddressbookImpl::Construct(void)
+{
+       static AccountId accountId = 0;
+       static String name;
+
+       if (name.IsEmpty())
+       {
+               SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+               char *pName = null;
+
+               unique_ptr<ContactRecord, ContactRecordDeleter> pAbRecord(_AddressbookUtil::GetContactRecordN(_contacts_address_book._uri, DEFAULT_ADDRESSBOOK_ID));
+               SysTryReturn(NID_SCL, pAbRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+               contacts_record_get_str_p(pAbRecord.get(), _contacts_address_book.name, &pName);
+               contacts_record_get_int(pAbRecord.get(), _contacts_address_book.account_id, &accountId);
+               name = pName;
+       }
+
+       __addressbookId = DEFAULT_ADDRESSBOOK_ID;
+       __accountId = accountId;
+       __name = name;
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookImpl::SetRecordEventListener(IRecordEventListener* pListener)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       result r = E_SUCCESS;
+
+       if (pListener != null)
+       {
+               if (__pIAddressbookEventListener == null && __pIRecordEventListener == null && __pIAddressbookChangeEventListener == null)
+               {
+                       _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance();
+                       SysTryReturn(NID_SCL, pContactDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+                       r = pContactDbMonitor->AddListener(*this);
+                       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+
+               __dbVersionForContact = GetLatestVersion();
+               SysTryReturn(NID_SCL, __dbVersionForContact != -1, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+               __dbVersionForGroup = __dbVersionForContact;
+               __dbVersionForRelation = __dbVersionForContact;
+
+               __pIAddressbookEventListener = null;
+               __pIAddressbookChangeEventListener = null;
+               __pIRecordEventListener = pListener;
+       }
+       else
+       {
+               if (__pIAddressbookEventListener != null || __pIRecordEventListener != null || __pIAddressbookChangeEventListener != null)
+               {
+                       _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance();
+                       SysTryReturn(NID_SCL, pContactDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()))
+                       pContactDbMonitor->RemoveListener(*this);
+               }
+
+               __pIAddressbookEventListener = null;
+               __pIAddressbookChangeEventListener = null;
+               __pIRecordEventListener = null;
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookImpl::SetAddressbookEventListener(IAddressbookEventListener* pListener)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       result r = E_SUCCESS;
+
+       if (pListener != null)
+       {
+               if (__pIAddressbookEventListener == null && __pIRecordEventListener == null && __pIAddressbookChangeEventListener == null)
+               {
+                       _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance();
+                       SysTryReturn(NID_SCL, pContactDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+                       r = pContactDbMonitor->AddListener(*this);
+                       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+
+               __dbVersionForContact = GetLatestVersion();
+               SysTryReturn(NID_SCL, __dbVersionForContact != -1, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+               __dbVersionForGroup = __dbVersionForContact;
+               __dbVersionForRelation = __dbVersionForContact;
+
+               __pIRecordEventListener = null;
+               __pIAddressbookChangeEventListener = null;
+               __pIAddressbookEventListener = pListener;
+       }
+       else
+       {
+               if (__pIAddressbookEventListener != null || __pIRecordEventListener != null || __pIAddressbookChangeEventListener != null)
+               {
+                       _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance();
+                       SysTryReturn(NID_SCL, pContactDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+                       pContactDbMonitor->RemoveListener(*this);
+               }
+
+               __pIAddressbookEventListener = null;
+               __pIAddressbookChangeEventListener = null;
+               __pIRecordEventListener = null;
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookImpl::SetAddressbookChangeEventListener(IAddressbookChangeEventListener* pListener)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       result r = E_SUCCESS;
+
+       if (pListener != null)
+       {
+               if (__pIAddressbookEventListener == null && __pIAddressbookChangeEventListener == null && __pIRecordEventListener == null)
+               {
+                       _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance();
+                       SysTryReturn(NID_SCL, pContactDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+                       r = pContactDbMonitor->AddListener(*this);
+                       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+
+               __dbVersionForContact = GetLatestVersion();
+               SysTryReturn(NID_SCL, __dbVersionForContact != -1, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+               __dbVersionForGroup = __dbVersionForContact;
+               __dbVersionForRelation = __dbVersionForContact;
+
+               __pIRecordEventListener = null;
+               __pIAddressbookEventListener = null;
+               __pIAddressbookChangeEventListener = pListener;
+       }
+       else
+       {
+               if (__pIAddressbookEventListener != null || __pIAddressbookChangeEventListener != null || __pIRecordEventListener != null)
+               {
+                       _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance();
+                       SysTryReturn(NID_SCL, pContactDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+                       pContactDbMonitor->RemoveListener(*this);
+               }
+
+               __pIAddressbookEventListener = null;
+               __pIAddressbookChangeEventListener = null;
+               __pIRecordEventListener = null;
+       }
+
+       return E_SUCCESS;
+}
+
+void
+_AddressbookImpl::SetId(AddressbookId addressbookId)
+{
+       __addressbookId = addressbookId;
+}
+
+void
+_AddressbookImpl::SetAccountId(AccountId accountId)
+{
+       __accountId = accountId;
+}
+
+void
+_AddressbookImpl::SetName(const String& name)
+{
+       __name = name;
+}
+
+AddressbookId
+_AddressbookImpl::GetId(void) const
+{
+       return __addressbookId;
+}
+
+AccountId
+_AddressbookImpl::GetAccountId(void) const
+{
+       return __accountId;
+}
+
+String
+_AddressbookImpl::GetName(void) const
+{
+       return __name;
+}
+
+result
+_AddressbookImpl::AddContact(Contact& contact)
+{
+       if (_ContactImpl::GetInstance(contact)->IsRemoved())
+       {
+               result r = _ContactImpl::GetInstance(contact)->Invalidate();
+               SysTryReturn(NID_SCL, r == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       SysTryReturn(NID_SCL, contact.GetRecordId() == INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The ID of specified contact is not INVALID_RECORD_ID.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !_ContactImpl::GetInstance(contact)->IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified contact does not have any property.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       contacts_record_h recordHandle = _ContactImpl::GetInstance(contact)->GetContactRecordHandle();
+        contacts_record_set_int(recordHandle, _contacts_contact.address_book_id, __addressbookId);
+
+        int recordId = 0;
+        result r = _AddressbookUtil::InsertContactRecordN(recordHandle, recordId);
+        SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+        unique_ptr<ContactRecord, ContactRecordDeleter> pContactRecord(_AddressbookUtil::GetContactRecordN(_contacts_contact._uri, recordId));
+        SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       _ContactImpl::GetInstance(contact)->SetContactRecordHandle(pContactRecord.release());
+       _RecordImpl::GetInstance(contact)->SetRecordId(recordId);
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookImpl::AddCategory(Category& category)
+{
+       SysTryReturn(NID_SCL, category.GetRecordId() == INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified categoryId is not INVALID_RECORD_ID.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       contacts_record_h recordHandle = null;
+       unique_ptr<IListT<int> > pList(null);
+
+       recordHandle = _CategoryImpl::GetInstance(category)->GetRecordHandle();
+       contacts_record_set_int(recordHandle, _contacts_group.address_book_id, __addressbookId);
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               // It is not allowed to have a same name with other.
+               int count = 0;
+               char* pCharValue = null;
+               contacts_record_get_str_p(recordHandle, _contacts_group.name, &pCharValue);
+
+               __Filter<__ContactsGroup> filter;
+               filter.Construct();
+               filter.AddInt(_contacts_group.address_book_id, CONTACTS_MATCH_EQUAL, __addressbookId);
+               filter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+               filter.AddString(_contacts_group.name, CONTACTS_MATCH_EXACTLY, pCharValue);
+
+               __Query<__ContactsGroup> query;
+               query.Construct();
+               query.SetFilter(filter);
+
+               count = _AddressbookUtil::GetCountWithQuery(query);
+               SysTryReturn(NID_SCL, count >= 0, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+               SysTryReturn(NID_SCL, count == 0, E_OBJ_ALREADY_EXIST, E_OBJ_ALREADY_EXIST, "[%s] The category name is already being used by other category.", GetErrorMessage(E_OBJ_ALREADY_EXIST));
+       }
+
+        int recordId = 0;
+        result r = _AddressbookUtil::InsertContactRecordN(recordHandle, recordId);
+        SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+        unique_ptr<ContactRecord, ContactRecordDeleter> pCategoryRecord(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, recordId));
+        SysTryReturn(NID_SCL, pCategoryRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       _CategoryImpl::GetInstance(category)->SetRecordHandle(pCategoryRecord.release());
+       _RecordImpl::GetInstance(category)->SetRecordId(recordId);
+
+       pList.reset(_CategoryImpl::GetInstance(category)->GetAddedMembersN());
+       if (pList != null && pList->GetCount() > 0)
+       {
+               unique_ptr<IEnumeratorT<int> > pEnum(pList->GetEnumeratorN());
+
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       int tableId = -1;
+                       pEnum->GetCurrent(tableId);
+
+                       AddMemberToCategory(category.GetRecordId(), tableId);
+               }
+
+               _CategoryImpl::GetInstance(category)->ClearAddedMemberList();
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookImpl::RemoveContact(RecordId contactId)
+{
+       SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified contactId is invalid", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       result r = _AddressbookUtil::DeleteContactRecord(_contacts_contact._uri, contactId);
+        SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookImpl::RemoveContact(Contact& contact)
+{
+       SysTryReturn(NID_SCL, contact.GetRecordId() != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The ID of specified contact is not INVALID_RECORD_ID", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       result r = RemoveContact(contact.GetRecordId());
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _ContactImpl::GetInstance(contact)->SetAsRemoved();
+       _RecordImpl::GetInstance(contact)->SetRecordId(INVALID_RECORD_ID);
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookImpl::RemoveCategory(RecordId categoryId)
+{
+       SysTryReturn(NID_SCL, categoryId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. categoryId = %d.", GetErrorMessage(E_INVALID_ARG), categoryId);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       unique_ptr<ContactRecord, ContactRecordDeleter> pCategoryRecord(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, categoryId));
+        SysTryReturn(NID_SCL, pCategoryRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       bool isReadOnly = false;
+       contacts_record_get_bool(pCategoryRecord.get(), _contacts_group.is_read_only, &isReadOnly);
+       SysTryReturn(NID_SCL, !isReadOnly, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified category is a default category.", GetErrorMessage(E_INVALID_ARG));
+
+       result r = _AddressbookUtil::DeleteContactRecord(_contacts_group._uri, categoryId);
+        SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookImpl::UpdateContact(const Contact& contact)
+{
+       RecordId contactId = contact.GetRecordId();
+       SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !_ContactImpl::GetInstance(contact)->IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified contact does not have any property.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pContactRecord(_AddressbookUtil::GetContactRecordN(_contacts_simple_contact._uri, contactId));
+       SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int intValue = 0;
+       contacts_record_get_int(pContactRecord.get(), _contacts_simple_contact.id, &intValue);
+       SysTryReturn(NID_SCL, intValue == contactId, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The contact is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       contacts_record_h recordHandle = _ContactImpl::GetInstance(contact)->GetContactRecordHandle();
+       SysTryReturn(NID_SCL, recordHandle != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = _AddressbookUtil::UpdateContactRecord(recordHandle);
+       if (r == E_OBJ_NOT_FOUND)
+       {
+               unsigned int count = 0;
+               unsigned int count2 = 0;
+
+               contacts_record_h newRecordHandle = null;
+               int ret = contacts_db_get_record(_contacts_contact._uri, contactId, &newRecordHandle);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+               contacts_record_get_child_record_count(newRecordHandle, _contacts_contact.image, &count);
+               contacts_record_get_child_record_count(recordHandle, _contacts_contact.image, &count2);
+
+               contacts_record_h imageHandle = null;
+               contacts_record_h imageHandle2 = null;
+
+               int imageId = -1;
+               int imageId2 = -1;
+
+               for (int i = (int)count2 - 1; i >= 0; i--)
+               {
+                       contacts_record_get_child_record_at_p(recordHandle, _contacts_contact.image, i, &imageHandle);
+                       contacts_record_get_int(imageHandle, _contacts_image.id, &imageId);
+                       if (imageId == 0)
+                       {
+                               continue;
+                       }
+
+                       bool matchFound = false;
+
+                       for (unsigned int j = 0; j < count; j++)
+                       {
+                               contacts_record_get_child_record_at_p(newRecordHandle, _contacts_contact.image, i, &imageHandle2);
+                               contacts_record_get_int(imageHandle2, _contacts_image.id, &imageId2);
+                               if (imageId == imageId2)
+                               {
+                                       matchFound = true;
+                                       break;
+                               }
+                       }
+
+                       if (!matchFound)
+                       {
+                               contacts_record_remove_child_record(recordHandle, _contacts_contact.image, imageHandle);
+                       }
+               }
+
+               contacts_record_destroy(newRecordHandle, true);
+
+               contacts_record_h copyRecordHandle = CopyContactRecordHandle(recordHandle);
+               SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_h tempHandle = null;
+               contacts_record_get_child_record_count(copyRecordHandle, _contacts_contact.image, &count);
+
+               char* pCharValue = null;
+               String tempPath;
+
+               for (unsigned int i = 0; i < count; i++)
+               {
+                       contacts_record_get_child_record_at_p(copyRecordHandle, _contacts_contact.image, i, &tempHandle);
+                       contacts_record_get_str(tempHandle, _contacts_image.path, &pCharValue);
+
+                       tempPath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/temp";
+                       tempPath.Append((int)i);
+                       tempPath.Append(L".jpg");
+                       String servicePath(pCharValue);
+
+                       File::Copy(servicePath, tempPath, true);
+
+                       std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(tempPath));
+                       SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       contacts_record_set_str(tempHandle, _contacts_image.path, pCharArray.get());
+                       contacts_record_get_str(tempHandle, _contacts_image.path, &pCharValue);
+
+                       tempPath.Clear();
+               }
+
+               ret = contacts_db_replace_record(copyRecordHandle, contactId);
+               contacts_record_destroy(copyRecordHandle, true);
+
+               for (unsigned int i = 0; i < count; i++)
+               {
+                       tempPath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/temp";
+                       tempPath.Append((int)i);
+                       tempPath.Append(L".jpg");
+
+                       File::Remove(tempPath);
+
+                       tempPath.Clear();
+               }
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is insufficient.", GetErrorMessage(E_STORAGE_FULL));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       }
+       else
+       {
+               SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       pContactRecord.reset(_AddressbookUtil::GetContactRecordN(_contacts_contact._uri, contact.GetRecordId()));
+       SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       _ContactImpl::GetInstance(*const_cast<Contact*>(&contact))->SetContactRecordHandle(pContactRecord.release());
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookImpl::UpdateCategory(const Category& category)
+{
+       RecordId categoryId = category.GetRecordId();
+       SysTryReturn(NID_SCL, categoryId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified category is invalid.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !category.GetName().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified category does not have name.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pCategoryRecord(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, category.GetRecordId()));
+        SysTryReturn(NID_SCL, pCategoryRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+        int intValue = 0;
+        contacts_record_get_int(pCategoryRecord.get(), _contacts_group.id, &intValue);
+        SysTryReturn(NID_SCL, intValue == categoryId, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The category is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+        contacts_record_h recordHandle = _CategoryImpl::GetInstance(category)->GetRecordHandle();
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               int count = 0;
+               char* pCharValue = null;
+
+               contacts_record_get_str_p(recordHandle, _contacts_group.name, &pCharValue);
+               contacts_record_get_int(recordHandle, _contacts_group.id, &intValue);
+
+               __Filter<__ContactsGroup> filter1;
+               filter1.Construct();
+               filter1.AddInt(_contacts_group.address_book_id, CONTACTS_MATCH_EQUAL, __addressbookId);
+               filter1.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+               filter1.AddString(_contacts_group.name, CONTACTS_MATCH_EXACTLY, pCharValue);
+
+               __Filter<__ContactsGroup> filter2;
+               filter2.Construct();
+               filter2.AddInt(_contacts_group.id, CONTACTS_MATCH_LESS_THAN, intValue);
+               filter2.AddOperator(CONTACTS_FILTER_OPERATOR_OR);
+               filter2.AddInt(_contacts_group.id, CONTACTS_MATCH_GREATER_THAN, intValue);
+
+               filter1.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+               filter1.AddFilter(filter2);
+
+               __Query<__ContactsGroup> query;
+               query.Construct();
+               query.SetFilter(filter1);
+
+               count = _AddressbookUtil::GetCountWithQuery(query);
+               SysTryReturn(NID_SCL, count >= 0, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+               SysTryReturn(NID_SCL, count == 0, E_OBJ_ALREADY_EXIST, E_OBJ_ALREADY_EXIST, "[%s] The category name is alread being used by other category.", GetErrorMessage(E_OBJ_ALREADY_EXIST));
+       }
+
+       result r = _AddressbookUtil::UpdateContactRecord(recordHandle);
+        SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pCategoryRecord.reset(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, category.GetRecordId()));
+        SysTryReturn(NID_SCL, pCategoryRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+        _CategoryImpl::GetInstance(*const_cast<Category*>(&category))->SetRecordHandle(pCategoryRecord.release());
+
+       std::unique_ptr<IListT<int> > pList(_CategoryImpl::GetInstance(category)->GetAddedMembersN());
+       if (pList != null && pList->GetCount() > 0)
+       {
+               int tableId = -1;
+               std::unique_ptr<IEnumeratorT<int> > pEnum(pList->GetEnumeratorN());
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       pEnum->GetCurrent(tableId);
+
+                       AddMemberToCategory(category.GetRecordId(), tableId);
+               }
+
+               const_cast<_CategoryImpl*>(_CategoryImpl::GetInstance(category))->ClearAddedMemberList();
+       }
+
+       pList.reset(_CategoryImpl::GetInstance(category)->GetRemovedMembersN());
+       if (pList != null && pList->GetCount() > 0)
+       {
+               int tableId = -1;
+               std::unique_ptr<IEnumeratorT<int> > pEnum(pList->GetEnumeratorN());
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       pEnum->GetCurrent(tableId);
+
+                       RemoveMemberFromCategory(category.GetRecordId(), tableId);
+               }
+
+               const_cast<_CategoryImpl*>(_CategoryImpl::GetInstance(category))->ClearRemovedMemberList();
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookImpl::AddMemberToCategory(RecordId categoryId, RecordId contactId)
+{
+       SysTryReturn(NID_SCL, categoryId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. categoryId = %d.", GetErrorMessage(E_INVALID_ARG), categoryId);
+       SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. contactId = %d.", GetErrorMessage(E_INVALID_ARG), contactId);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int addressbookId = 0;
+       unique_ptr<ContactRecord, ContactRecordDeleter> pContactRecord(_AddressbookUtil::GetContactRecordN(_contacts_simple_contact._uri, contactId));
+        SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       contacts_record_get_int(pContactRecord.get(), _contacts_simple_contact.address_book_id, &addressbookId);
+
+       SysTryReturn(NID_SCL, addressbookId == __addressbookId, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The contact does not exist in this addresbook.", GetErrorMessage(E_INVALID_ARG));
+
+       result r = _AddressbookUtil::AddContactToCategory(categoryId, contactId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookImpl::RemoveMemberFromCategory(RecordId categoryId, RecordId contactId)
+{
+       SysTryReturn(NID_SCL, categoryId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. categoryId = %d.", GetErrorMessage(E_INVALID_ARG), categoryId);
+       SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. contactId = %d.", GetErrorMessage(E_INVALID_ARG), contactId);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int addressbookId = 0;
+       unique_ptr<ContactRecord, ContactRecordDeleter> pContactRecord(_AddressbookUtil::GetContactRecordN(_contacts_simple_contact._uri, contactId));
+       SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       contacts_record_get_int(pContactRecord.get(), _contacts_simple_contact.address_book_id, &addressbookId);
+
+       SysTryReturn(NID_SCL, addressbookId == __addressbookId, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The contact does not exist in this addresbook.", GetErrorMessage(E_INVALID_ARG));
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pCategoryRecord(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, categoryId));
+       SysTryReturn(NID_SCL, pCategoryRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       contacts_record_get_int(pCategoryRecord.get(), _contacts_group.address_book_id, &addressbookId);
+
+       SysTryReturn(NID_SCL, addressbookId == __addressbookId, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The category does not exist in this addresbook.", GetErrorMessage(E_INVALID_ARG));
+
+       result r = _AddressbookUtil::RemoveContactFromCategory(categoryId, contactId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+IList*
+_AddressbookImpl::GetAllCategoriesN(void) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       __Filter<__ContactsGroup> filter;
+       filter.Construct();
+       filter.AddInt(_contacts_group.address_book_id, CONTACTS_MATCH_EQUAL, __addressbookId);
+
+       __Query<__ContactsGroup> query;
+       query.Construct();
+       query.SetFilter(filter);
+       query.SetSort(_contacts_group.name, true);
+
+
+       IList* pCategories = _AddressbookUtil::SearchWithQueryN<__ContactsGroup, Category>(query);
+       SysTryReturn(NID_SCL, pCategories != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pCategories;
+}
+
+IList*
+_AddressbookImpl::GetCategoriesByContactN(RecordId contactId) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, null, E_INVALID_ARG, "[%s] Invalid argument is used. The specified contact is invalid.", GetErrorMessage(E_INVALID_ARG));
+
+       ClearLastResult();
+
+       __Filter<__ContactsGroupRelation> filter;
+       filter.Construct();
+       filter.AddInt(_contacts_group_relation.contact_id, CONTACTS_MATCH_EQUAL, contactId);
+
+       __Query<__ContactsGroupRelation> query;
+       query.Construct();
+       query.SetFilter(filter);
+       query.SetSort(_contacts_group_relation.name, true);
+
+       IList* pCategories = _AddressbookUtil::SearchWithQueryN<__ContactsGroupRelation, Category>(query);
+       SysTryReturn(NID_SCL, pCategories != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pCategories;
+}
+
+IList*
+_AddressbookImpl::GetAllContactsN(void) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       __Filter<__ContactsContact> filter;
+       filter.Construct();
+       filter.AddInt(_contacts_contact.address_book_id, CONTACTS_MATCH_EQUAL, __addressbookId);
+
+       __Query<__ContactsContact> query;
+       query.Construct();
+       query.SetFilter(filter);
+       query.SetSort(_contacts_contact.display_name, true);
+
+       IList* pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContact, Contact>(query);
+       SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pContacts;
+}
+
+IList*
+_AddressbookImpl::GetContactsByCategoryN(RecordId categoryId) const
+{
+       SysTryReturn(NID_SCL, categoryId >= INVALID_RECORD_ID, null, E_INVALID_ARG, "[%s] Invalid argument is used. The category ID must be greater than or equal to INVALID_RECORD_ID.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       __Filter<__ContactsContactGroupRel> filter;
+       filter.Construct();
+       if (categoryId != INVALID_RECORD_ID)
+       {
+               filter.AddInt(_contacts_contact_grouprel.group_id, CONTACTS_MATCH_EQUAL, categoryId);
+       }
+       else
+       {
+               filter.AddInt(_contacts_contact_grouprel.group_id, CONTACTS_MATCH_NONE, 0);
+       }
+
+       __Query<__ContactsContactGroupRel> query;
+       query.Construct();
+       query.SetFilter(filter);
+       query.SetSort(_contacts_contact_grouprel.display_name, true);
+
+       IList* pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContactGroupRel, Contact>(query);
+       SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pContacts;
+}
+
+IList*
+_AddressbookImpl::GetContactsN(int pageNo, int countPerPage) const
+{
+       SysTryReturn(NID_SCL, pageNo > 0 && countPerPage > 0, null, E_OUT_OF_RANGE, "[%s] pageNo(%d) or countPerPage(%d) is less than 1.", GetErrorMessage(E_OUT_OF_RANGE), pageNo, countPerPage);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int offset = (pageNo - 1)*countPerPage;
+       int limit = countPerPage;
+
+       ClearLastResult();
+
+       __Filter<__ContactsContact> filter;
+       filter.Construct();
+       filter.AddInt(_contacts_contact.address_book_id, CONTACTS_MATCH_EQUAL, __addressbookId);
+
+       __Query<__ContactsContact> query;
+       query.Construct();
+       query.SetFilter(filter);
+       query.SetSort(_contacts_contact.display_name, true);
+
+       IList* pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContact, Contact>(query, offset, limit);
+       SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pContacts;
+}
+
+IList*
+_AddressbookImpl::GetContactsInN(const Category& category, int pageNo, int countPerPage) const
+{
+       SysTryReturn(NID_SCL, category.GetRecordId() != INVALID_RECORD_ID, null, E_INVALID_ARG, "[%s] Invalid argument is used. The specified category is invalid.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, pageNo > 0 && countPerPage > 0, null, E_OUT_OF_RANGE, "[%s] pageNo(%d) or countPerPage(%d) is less than 1.", GetErrorMessage(E_OUT_OF_RANGE), pageNo, countPerPage);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int offset = (pageNo - 1)*countPerPage;
+       int limit = countPerPage;
+
+       ClearLastResult();
+
+       __Filter<__ContactsContactGroupRel> filter;
+       filter.Construct();
+       filter.AddInt(_contacts_contact_grouprel.group_id, CONTACTS_MATCH_EQUAL, category.GetRecordId());
+
+       __Query<__ContactsContactGroupRel> query;
+       query.Construct();
+       query.SetFilter(filter);
+       query.SetSort(_contacts_contact_grouprel.display_name, true);
+
+       IList* pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContactGroupRel, Contact>(query, offset, limit);
+       SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pContacts;
+}
+
+IList*
+_AddressbookImpl::SearchContactsByEmailN(const String& email) const
+{
+       SysTryReturn(NID_SCL, !email.IsEmpty(), null, E_INVALID_ARG, "[%s] Invalid argument is used. The specified email is an empty string.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               SysTryReturn(NID_SCL, email.GetLength() <= MAX_EMAIL_LENGTH, null, E_INVALID_ARG, "[%s] Invalid argument is used. The length of email is greater than MAX_EMAIL_LENGTH.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       ClearLastResult();
+
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(email));
+       SysTryReturn(NID_SCL, pCharArray != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __Filter<__ContactsContactEmail> filter;
+       filter.Construct();
+       filter.AddInt(_contacts_contact_email.address_book_id, CONTACTS_MATCH_EQUAL, __addressbookId);
+       filter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+       filter.AddString(_contacts_contact_email.email, CONTACTS_MATCH_CONTAINS, pCharArray.get());
+
+       unsigned int projectionIds[1];
+       projectionIds[0] = _contacts_contact_email.contact_id;
+
+       __Query<__ContactsContactEmail> query;
+       query.Construct();
+       query.SetProjection(projectionIds, 1);
+       query.SetFilter(filter);
+       query.SetDistinct(true);
+       query.SetSort(_contacts_contact_email.display_name, true);
+
+       IList* pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContactEmail, Contact>(query);
+       SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pContacts;
+}
+
+IList*
+_AddressbookImpl::SearchContactsByNameN(const String& name) const
+{
+       SysTryReturn(NID_SCL, !name.IsEmpty(), null, E_INVALID_ARG, "[%s] Invalid argument is used. The specified email is an empty string.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               SysTryReturn(NID_SCL, name.GetLength() <= MAX_CONTACT_NAME_LENGTH, null, E_INVALID_ARG, "[%s] Invalid argument is used. The length of name is greater than MAX_CONTACT_NAME_LENGTH.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       ClearLastResult();
+
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(name));
+       SysTryReturn(NID_SCL, pCharArray != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __Filter<__ContactsContact> filter;
+       filter.Construct();
+       filter.AddInt(_contacts_contact.address_book_id, CONTACTS_MATCH_EQUAL, __addressbookId);
+       filter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+       filter.AddString(_contacts_contact.display_name, CONTACTS_MATCH_CONTAINS, pCharArray.get());
+
+       __Query<__ContactsContact> query;
+       query.Construct();
+       query.SetFilter(filter);
+       query.SetSort(_contacts_contact.display_name, true);
+       query.SetDistinct(true);
+
+       IList* pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContact, Contact>(query);
+       SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pContacts;
+}
+
+
+IList*
+_AddressbookImpl::SearchContactsByPhoneNumberN(const String& phoneNumber) const
+{
+       SysTryReturn(NID_SCL, !phoneNumber.IsEmpty(), null, E_INVALID_ARG, "[%s] Invalid argument is used. The specified phoneNumber is an empty string.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               int count = phoneNumber.GetLength();
+               SysTryReturn(NID_SCL, count >= MIN_PHONENUMBER_QUERY_LENGTH && count <= MAX_PHONE_NUMBER_LENGTH, null, E_INVALID_ARG, "[%s] Invalid argument is used. The length of phoneNumber is shorter than MIN_PHONENUMBER_QUERY_LENGTH or greater than MAX_PHONE_NUMBER_LENGTH.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       ClearLastResult();
+
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(phoneNumber));
+       SysTryReturn(NID_SCL, pCharArray != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __Filter<__ContactsContactNumber> subFilter;
+       subFilter.Construct();
+       subFilter.AddString(_contacts_contact_number.normalized_number, CONTACTS_MATCH_CONTAINS, pCharArray.get());
+       subFilter.AddOperator(CONTACTS_FILTER_OPERATOR_OR);
+       subFilter.AddString(_contacts_contact_number.number, CONTACTS_MATCH_CONTAINS, pCharArray.get());
+
+       __Filter<__ContactsContactNumber> filter;
+       filter.Construct();
+       filter.AddInt(_contacts_contact_number.address_book_id, CONTACTS_MATCH_EQUAL, __addressbookId);
+       filter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+       filter.AddFilter(subFilter);
+
+       unsigned int projectionIds[1];
+       projectionIds[0] = _contacts_contact_number.contact_id;
+
+       __Query<__ContactsContactNumber> query;
+       query.Construct();
+       query.SetProjection(projectionIds, 1);
+       query.SetFilter(filter);
+       query.SetDistinct(true);
+       query.SetSort(_contacts_contact_number.display_name, true);
+
+       IList* pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContactNumber, Contact>(query);
+       SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pContacts;
+}
+
+int
+_AddressbookImpl::GetCategoryCount(void) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int count = -1;
+
+       ClearLastResult();
+
+       __Filter<__ContactsGroup> filter;
+       filter.Construct();
+       filter.AddInt(_contacts_group.address_book_id, CONTACTS_MATCH_EQUAL, __addressbookId);
+
+       __Query<__ContactsGroup> query;
+       query.Construct();
+       query.SetFilter(filter);
+
+       count = _AddressbookUtil::GetCountWithQuery(query);
+       SysTryReturn(NID_SCL, count >= 0, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return count;
+}
+
+int
+_AddressbookImpl::GetContactCount(void) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int count = -1;
+
+       ClearLastResult();
+
+       __Filter<__ContactsContact> filter;
+       filter.Construct();
+       filter.AddInt(_contacts_contact.address_book_id, CONTACTS_MATCH_EQUAL, __addressbookId);
+
+       __Query<__ContactsContact> query;
+       query.Construct();
+       query.SetFilter(filter);
+
+       count = _AddressbookUtil::GetCountWithQuery(query);
+       SysTryReturn(NID_SCL, count >= 0, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return count;
+}
+
+Contact*
+_AddressbookImpl::GetContactN(RecordId contactId) const
+{
+       SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, null, E_INVALID_ARG, "[%s] Invalid argument is used. contactId = %d.", GetErrorMessage(E_INVALID_ARG), contactId);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pContactRecord(_AddressbookUtil::GetContactRecordN(_contacts_contact._uri, contactId));
+       SysTryReturn(NID_SCL, pContactRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int intValue = 0;
+       contacts_record_get_int(pContactRecord.get(), _contacts_contact.id, &intValue);
+       SysTryReturn(NID_SCL, intValue == contactId, null, E_OBJ_NOT_FOUND, "[%s] The contact is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       unique_ptr<Contact> pContact(new (std::nothrow) Contact());
+       SysTryReturn(NID_SCL, pContact, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       _ContactImpl::GetInstance(*pContact)->SetContactRecordHandle(pContactRecord.release());
+       _RecordImpl::GetInstance(*pContact)->SetRecordId(intValue);
+
+       return pContact.release();
+}
+
+Category*
+_AddressbookImpl::GetCategoryN(RecordId categoryId) const
+{
+       SysTryReturn(NID_SCL, categoryId != INVALID_RECORD_ID, null, E_INVALID_ARG, "[%s] Invalid argument is used. categoryId = %d.", GetErrorMessage(E_INVALID_ARG), categoryId);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pCategoryRecord(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, categoryId));
+        SysTryReturn(NID_SCL, pCategoryRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+        int intValue = 0;
+
+        contacts_record_get_int(pCategoryRecord.get(), _contacts_group.id, &intValue);
+        SysTryReturn(NID_SCL, categoryId == intValue, null, E_OBJ_NOT_FOUND, "[%s] The category is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       unique_ptr<Category> pCategory(new (std::nothrow) Category());
+       SysTryReturn(NID_SCL, pCategory != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __Filter<__ContactsGroupRelation> filter;
+       filter.Construct();
+       filter.AddInt(_contacts_group_relation.group_id, CONTACTS_MATCH_EQUAL, categoryId);
+
+       __Query<__ContactsGroupRelation> query;
+       query.Construct();
+       query.SetFilter(filter);
+
+       int count = _AddressbookUtil::GetCountWithQuery(query);
+       SysTryReturn(NID_SCL, count >= 0, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       _CategoryImpl::GetInstance(*pCategory)->SetRecordHandle(pCategoryRecord.release());
+       _CategoryImpl::GetInstance(*pCategory)->SetMemberCount(count);
+       _RecordImpl::GetInstance(*pCategory)->SetRecordId(categoryId);
+
+       return pCategory.release();
+}
+
+int
+_AddressbookImpl::GetLatestVersion(void) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int latestVersion = -1;
+
+       ClearLastResult();
+
+       int ret = contacts_db_get_current_version(&latestVersion);
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, -1, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, -1, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return latestVersion;
+}
+
+IList*
+_AddressbookImpl::GetChangedContactsAfterN(int version, int& latestVersion) const
+{
+       SysTryReturn(NID_SCL, version >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. version %d must be greater that or equal 0.", GetErrorMessage(E_INVALID_ARG), version);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       IList* pChangedContacts = _AddressbookUtil::SearchWithVersionN<__ContactsContactUpdatedInfo, ContactChangeInfo>(__addressbookId, version, latestVersion);
+       SysTryReturn(NID_SCL, pChangedContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pChangedContacts;
+}
+
+IList*
+_AddressbookImpl::GetChangedCategoriesAfterN(int version, int& latestVersion) const
+{
+       SysTryReturn(NID_SCL, version >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. version %d must be greater that or equal 0.", GetErrorMessage(E_INVALID_ARG), version);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       int latestVersion1 = 0;
+       int latestVersion2 = 0;
+
+       std::unique_ptr<IList, AllElementsDeleter> pChangedGroups(_AddressbookUtil::SearchWithVersionN<__ContactsGroupUpdatedInfo, CategoryChangeInfo>(__addressbookId, version, latestVersion1));
+       SysTryReturn(NID_SCL, pChangedGroups != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<IList, AllElementsDeleter> pChangedRelations(_AddressbookUtil::SearchWithVersionN<__ContactsGroupRelUpdatedInfo, CategoryChangeInfo>(__addressbookId, version, latestVersion2));
+       SysTryReturn(NID_SCL, pChangedRelations != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pChangeList(new (std::nothrow) Tizen::Base::Collection::ArrayList());
+       SysTryReturn(NID_SCL, pChangeList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pChangeList->AddItems(*pChangedGroups);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = pChangeList->AddItems(*pChangedRelations);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pChangedGroups->RemoveAll(false);
+       pChangedRelations->RemoveAll(false);
+
+       latestVersion = latestVersion2 > latestVersion1 ? latestVersion2 : latestVersion1;
+
+       return pChangeList.release();
+}
+
+IList*
+_AddressbookImpl::GetChangedContactInfoListN(int version, int& latestVersion) const
+{
+       SysTryReturn(NID_SCL, version >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. version %d must be greater that or equal 0.", GetErrorMessage(E_INVALID_ARG), version);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       IList* pChangedContacts = _AddressbookUtil::SearchWithVersionN<__ContactsContactUpdatedInfo, ContactChangeInfo>(__addressbookId, version, latestVersion);
+       SysTryReturn(NID_SCL, pChangedContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pChangedContacts;
+}
+
+IList*
+_AddressbookImpl::GetChangedCategoryInfoListN(int version, int& latestVersion) const
+{
+       return GetChangedGroupsAfterN(version, latestVersion);
+}
+
+IList*
+_AddressbookImpl::GetChangedGroupsAfterN(int version, int& latestVersion) const
+{
+       SysTryReturn(NID_SCL, version >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. version %d must be greater that or equal 0.", GetErrorMessage(E_INVALID_ARG), version);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       IList* pChangedGroups = _AddressbookUtil::SearchWithVersionN<__ContactsGroupUpdatedInfo, CategoryChangeInfo>(__addressbookId, version, latestVersion);
+       SysTryReturn(NID_SCL, pChangedGroups != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pChangedGroups;
+}
+
+IList*
+_AddressbookImpl::GetChangedRelationsAfterN(int version, int& latestVersion) const
+{
+       SysTryReturn(NID_SCL, version >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. version %d must be greater that or equal 0.", GetErrorMessage(E_INVALID_ARG), version);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       IList* pChangedRelations = _AddressbookUtil::SearchWithVersionN<__ContactsGroupRelUpdatedInfo, CategoryChangeInfo>(__addressbookId, version, latestVersion);
+       SysTryReturn(NID_SCL, pChangedRelations != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pChangedRelations;
+}
+
+result
+_AddressbookImpl::AddContacts(const Tizen::Base::Collection::IList& contactList, Tizen::Base::Collection::IListT<RecordId>* pContactIdList)
+{
+       SysTryReturn(NID_SCL, contactList.GetCount() != 0, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. contactList is empty.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<IEnumerator> pContactEnum(contactList.GetEnumeratorN());
+       SysTryReturnResult(NID_SCL, pContactEnum != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       Contact* pContact = null;
+       int ret = CONTACTS_ERROR_NONE;
+       int* pContactIds = null;
+       unsigned int contactsCount = 0;
+
+       contacts_record_h recordHandle = null;
+       contacts_list_h listHandle = null;
+
+       ret = contacts_list_create(&listHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       while (pContactEnum->MoveNext() == E_SUCCESS)
+       {
+               pContact = static_cast<Contact*>(pContactEnum->GetCurrent());
+
+               if (_ContactImpl::GetInstance(*pContact)->IsEmpty())
+               {
+                       contacts_list_destroy(listHandle, false);
+                       SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. Contact is empty.", GetErrorMessage(E_INVALID_ARG));
+                       return E_INVALID_ARG;
+               }
+               if (pContact->GetRecordId() != INVALID_RECORD_ID)
+               {
+                       contacts_list_destroy(listHandle, false);
+                       SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. Contact ID is invalid.", GetErrorMessage(E_INVALID_ARG));
+                       return E_INVALID_ARG;
+               }
+
+               recordHandle = _ContactImpl::GetInstance(*pContact)->GetContactRecordHandle();
+               contacts_record_set_int(recordHandle, _contacts_contact.address_book_id, __addressbookId);
+               contacts_list_add(listHandle, recordHandle);
+       }
+
+       ret = contacts_db_insert_records(listHandle, &pContactIds, &contactsCount);
+       contacts_list_destroy(listHandle, false);
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       SysTryReturn(NID_SCL, pContactIds, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       int* pTemp = pContactIds;
+
+       if (pContactIdList != null)
+       {
+               for (unsigned int i = 0; i < contactsCount; i++)
+               {
+                       pContactIdList->Add(*pTemp);
+                       pTemp++;
+               }
+       }
+
+       free(pContactIds);
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookImpl::UpdateContacts(const Tizen::Base::Collection::IList& contactList)
+{
+       SysTryReturn(NID_SCL, contactList.GetCount() != 0, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. contactList is empty.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<IEnumerator> pContactEnum(contactList.GetEnumeratorN());
+       SysTryReturnResult(NID_SCL, pContactEnum != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       Contact* pContact = null;
+       int ret = CONTACTS_ERROR_NONE;
+       contacts_record_h recordHandle = null;
+       contacts_list_h listHandle = null;
+
+       ret = contacts_list_create(&listHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       while (pContactEnum->MoveNext() == E_SUCCESS)
+       {
+               pContact = static_cast<Contact*>(pContactEnum->GetCurrent());
+
+               if (_ContactImpl::GetInstance(*pContact)->IsEmpty())
+               {
+                       contacts_list_destroy(listHandle, false);
+                       SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. Contact is empty.", GetErrorMessage(E_INVALID_ARG));
+                       return E_INVALID_ARG;
+               }
+               if (pContact->GetRecordId() == INVALID_RECORD_ID)
+               {
+                       contacts_list_destroy(listHandle, false);
+                       SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. Contact ID is invalid.", GetErrorMessage(E_INVALID_ARG));
+                       return E_INVALID_ARG;
+               }
+
+               recordHandle = _ContactImpl::GetInstance(*pContact)->GetContactRecordHandle();
+               contacts_list_add(listHandle, recordHandle);
+       }
+
+       result r = _AddressbookUtil::UpdateContactRecords(listHandle);
+       contacts_list_destroy(listHandle, false);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookImpl::RemoveContacts(const Tizen::Base::Collection::IListT<RecordId>& contactIdList)
+{
+       SysTryReturn(NID_SCL, contactIdList.GetCount() != 0, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. contactIdList is empty.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<IEnumeratorT<RecordId> > pContactIdEnum(contactIdList.GetEnumeratorN());
+       SysTryReturnResult(NID_SCL, pContactIdEnum != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       RecordId contactId = INVALID_RECORD_ID;
+       int ret = CONTACTS_ERROR_NONE;
+       int count = contactIdList.GetCount();
+       std::unique_ptr<int[]> pRecordIds(new (std::nothrow) int[count]);
+       int* pInt = pRecordIds.get();
+       int* pTmp = pInt;
+
+       while (pContactIdEnum->MoveNext() == E_SUCCESS)
+       {
+               pContactIdEnum->GetCurrent(contactId);
+               SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. Contact id is invalid record id.", GetErrorMessage(E_INVALID_ARG));
+
+               *pTmp = contactId;
+               pTmp++;
+       }
+
+       ret = contacts_db_delete_records(_contacts_contact._uri, pInt, count);
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE || ret == CONTACTS_ERROR_NO_DATA, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookImpl::SetUserProfile(const UserProfile* pUserProfile)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int recordId = 0;
+       int existingRecordId = 0;
+       int ret = CONTACTS_ERROR_NONE;
+       result r = E_SUCCESS;
+       contacts_record_h recordHandle = null;
+
+       std::unique_ptr<UserProfile> pExistingProfile(GetUserProfileN());
+       SysTryReturn(NID_SCL, pExistingProfile != null || GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       if (pExistingProfile != null)
+       {
+               recordHandle = _UserProfileImpl::GetInstance(*pExistingProfile)->GetUserProfileHandle();
+               contacts_record_get_int(recordHandle, _contacts_my_profile.id, &existingRecordId);
+       }
+
+       if (pUserProfile != null)
+       {
+               SysTryReturn(NID_SCL, !((_UserProfileImpl::GetInstance(*pUserProfile))->IsEmpty()), E_SYSTEM, E_SYSTEM, "[%s] UserProfile is Empty.", GetErrorMessage(E_SYSTEM));
+
+               recordHandle = _UserProfileImpl::GetInstance(*pUserProfile)->GetUserProfileHandle();
+               contacts_record_get_int(recordHandle, _contacts_my_profile.id, &recordId);
+               if (recordId == 0)
+               {
+                       if (pExistingProfile != null)
+                       {
+                               r = _AddressbookUtil::DeleteContactRecord(_contacts_my_profile._uri, existingRecordId);
+                               SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+
+                       contacts_record_h newRecordHandle = null;
+                       ret = contacts_record_clone(recordHandle, &newRecordHandle);
+                       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       unique_ptr<ContactRecord, ContactRecordDeleter> pContactRecord(newRecordHandle);
+                       SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+                       ret = contacts_record_set_int(pContactRecord.get(), _contacts_my_profile.address_book_id, __addressbookId);
+                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+                       int recordId = 0;
+                       result r = _AddressbookUtil::InsertContactRecordN(pContactRecord.get(), recordId);
+                       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+               else if (recordId > 0)
+               {
+                       if (recordId == existingRecordId)
+                       {
+                               contacts_record_h newRecordHandle = null;
+                               ret = contacts_record_clone(recordHandle, &newRecordHandle);
+                               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                               result r = _AddressbookUtil::UpdateContactRecord(newRecordHandle);
+                               contacts_record_destroy(newRecordHandle, true);
+                               SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+                       else
+                       {
+                               if (pExistingProfile != null)
+                               {
+                                       r = _AddressbookUtil::DeleteContactRecord(_contacts_my_profile._uri, existingRecordId);
+                                       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+
+                               unique_ptr<ContactRecord, ContactRecordDeleter> pContactRecord(CopyMyProfileRecordHandle(recordHandle));
+                               SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+                               ret = contacts_record_set_int(pContactRecord.get(), _contacts_my_profile.address_book_id, __addressbookId);
+                               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+                               int recordId = 0;
+
+                               r = _AddressbookUtil::InsertContactRecordN(pContactRecord.get(), recordId);
+                               SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+               }
+       }
+       else
+       {
+               if (pExistingProfile != null)
+               {
+                       r = _AddressbookUtil::DeleteContactRecord(_contacts_my_profile._uri, existingRecordId);
+                       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+       }
+
+       return E_SUCCESS;
+}
+
+UserProfile*
+_AddressbookImpl::GetUserProfileN(void) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       __Filter<__ContactsUserProfile> filter;
+       filter.Construct();
+       filter.AddInt(_contacts_my_profile.address_book_id, CONTACTS_MATCH_EQUAL, __addressbookId);
+
+       __Query<__ContactsUserProfile> query;
+       query.Construct();
+       query.SetFilter(filter);
+
+       std::unique_ptr<IList, AllElementsDeleter> pUserProfilesList(_AddressbookUtil::SearchWithQueryN<__ContactsUserProfile, UserProfile>(query));
+       SysTryReturn(NID_SCL, pUserProfilesList.get() != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       SysTryReturn(NID_SCL, pUserProfilesList->GetCount() != 0, null, E_SUCCESS, "No UserProfile Set for this Addressbook.");
+       SysTryReturn(NID_SCL, pUserProfilesList->GetCount() == 1, null, E_SYSTEM, "[%s] Propagating. More than one UserProfile not allowed.", GetErrorMessage(E_SYSTEM));
+
+       UserProfile* pProfile = new (std::nothrow) UserProfile(*(static_cast<UserProfile*>(pUserProfilesList->GetAt(0))));
+       SysTryReturn(NID_SCL, pProfile != null, null, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       return pProfile;
+}
+
+bool
+_AddressbookImpl::IsUserProfileChangedAfter(int version) const
+{
+       SysTryReturn(NID_SCL, version >= 0, false, E_INVALID_ARG, "[%s] Invalid argument is used. version %d must be greater that or equal 0.", GetErrorMessage(E_INVALID_ARG), version);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       UserProfile* pExistingProfile = GetUserProfileN();
+       if (pExistingProfile == null)
+       {
+               return false;
+       }
+
+       delete pExistingProfile;
+
+       ClearLastResult();
+
+       int latestVersion = 0;
+       int count = _AddressbookUtil::GetChangedItemCountByVersion<__ContactsMyProfileUpdatedInfo>(__addressbookId, version, latestVersion);
+       SysTryReturn(NID_SCL, count >= 0, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       if (count > 0)
+       {
+               return true;
+       }
+
+       return false;
+}
+
+contacts_record_h
+_AddressbookImpl::CopyMyProfileRecordHandle(contacts_record_h srcHandle)
+{
+       ClearLastResult();
+
+       int ret = CONTACTS_ERROR_NONE;
+       int intValue = 0;
+       unsigned int count = 0;
+       unsigned int i = 0;
+       char* pCharValue = null;
+
+       contacts_record_h contactHandle = null;
+       contacts_record_h srcRecordHandle = null;
+       contacts_record_h dstRecordHandle = null;
+
+       ret = contacts_record_create(_contacts_my_profile._uri, &contactHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       // name
+       contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.name, &count);
+       if (count > 0)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.name, 0, &srcRecordHandle);
+
+               ret = contacts_record_create(_contacts_name._uri, &dstRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle nameHandle(dstRecordHandle);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_name.first, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_name.first, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_name.last, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_name.last, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_name.addition, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_name.addition, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_name.suffix, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_name.suffix, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_name.prefix, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_name.prefix, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_name.phonetic_first, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_name.phonetic_first, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_name.phonetic_middle, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_name.phonetic_middle, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_name.phonetic_last, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_name.phonetic_last, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_my_profile.name, dstRecordHandle);
+
+               nameHandle.Release();
+       }
+
+       // company
+       contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.company, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.company, i, &srcRecordHandle);
+
+               ret = contacts_record_create(_contacts_company._uri, &dstRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle companyHandle(dstRecordHandle);
+
+               contacts_record_get_int(srcRecordHandle, _contacts_company.type, &intValue);
+               contacts_record_set_int(dstRecordHandle, _contacts_company.type, intValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_company.name, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_company.name, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_company.department, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_company.department, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_company.job_title, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_company.job_title, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_company.assistant_name, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_company.assistant_name, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_company.role, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_company.role, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_company.logo, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_company.logo, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_company.location, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_company.location, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_company.description, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_company.description, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_company.phonetic_name, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_company.phonetic_name, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_my_profile.company, dstRecordHandle);
+
+               companyHandle.Release();
+       }
+
+       // note
+       contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.note, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.note, i, &srcRecordHandle);
+
+               ret = contacts_record_create(_contacts_note._uri, &dstRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle noteHandle(dstRecordHandle);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_note.note, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_note.note, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_my_profile.note, dstRecordHandle);
+
+               noteHandle.Release();
+       }
+
+       // number
+       contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.number, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.number, i, &srcRecordHandle);
+
+               ret = contacts_record_create(_contacts_number._uri, &dstRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle numberHandle(dstRecordHandle);
+
+               contacts_record_get_int(srcRecordHandle, _contacts_number.type, &intValue);
+               contacts_record_set_int(dstRecordHandle, _contacts_number.type, intValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_number.label, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_number.label, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_number.number, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_number.number, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_my_profile.number, dstRecordHandle);
+
+               numberHandle.Release();
+       }
+
+       // email
+       contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.email, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.email, i, &srcRecordHandle);
+
+               ret = contacts_record_create(_contacts_email._uri, &dstRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle emailHandle(dstRecordHandle);
+
+               contacts_record_get_int(srcRecordHandle, _contacts_email.type, &intValue);
+               contacts_record_set_int(dstRecordHandle, _contacts_email.type, intValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_email.label, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_email.label, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_email.email, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_email.email, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_my_profile.email, dstRecordHandle);
+
+               emailHandle.Release();
+
+       }
+
+       // event
+       contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.event, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.event, i, &srcRecordHandle);
+
+               ret = contacts_record_create(_contacts_event._uri, &dstRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle eventHandle(dstRecordHandle);
+
+               contacts_record_get_int(srcRecordHandle, _contacts_event.type, &intValue);
+               contacts_record_set_int(dstRecordHandle, _contacts_event.type, intValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_event.label, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_event.label, pCharValue);
+
+               contacts_record_get_int(srcRecordHandle, _contacts_event.date, &intValue);
+               contacts_record_set_int(dstRecordHandle, _contacts_event.date, intValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_my_profile.event, dstRecordHandle);
+
+               eventHandle.Release();
+       }
+
+       // im address
+       contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.messenger, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.messenger, i, &srcRecordHandle);
+
+               ret = contacts_record_create(_contacts_messenger._uri, &dstRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle imAddressHandle(dstRecordHandle);
+
+               contacts_record_get_int(srcRecordHandle, _contacts_messenger.type, &intValue);
+               contacts_record_set_int(dstRecordHandle, _contacts_messenger.type, intValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_messenger.label, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_messenger.label, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_messenger.im_id, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_messenger.im_id, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_my_profile.messenger, dstRecordHandle);
+
+               imAddressHandle.Release();
+       }
+
+       // address
+       contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.address, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.address, i, &srcRecordHandle);
+
+               ret = contacts_record_create(_contacts_address._uri, &dstRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle addressHandle(dstRecordHandle);
+
+               contacts_record_get_int(srcRecordHandle, _contacts_address.type, &intValue);
+               contacts_record_set_int(dstRecordHandle, _contacts_address.type, intValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_address.label, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_address.label, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_address.postbox, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_address.postbox, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_address.extended, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_address.extended, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_address.street, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_address.street, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_address.locality, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_address.locality, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_address.region, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_address.region, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_address.postal_code, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_address.postal_code, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_address.country, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_address.country, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_my_profile.address, dstRecordHandle);
+
+               addressHandle.Release();
+       }
+
+       // url
+       contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.url, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.url, i, &srcRecordHandle);
+
+               ret = contacts_record_create(_contacts_url._uri, &dstRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle urlHandle(dstRecordHandle);
+
+               contacts_record_get_int(srcRecordHandle, _contacts_url.type, &intValue);
+               contacts_record_set_int(dstRecordHandle, _contacts_url.type, intValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_url.label, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_url.label, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_url.url, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_url.url, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_my_profile.url, dstRecordHandle);
+
+               urlHandle.Release();
+       }
+
+       // nickname
+       contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.nickname, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.nickname, i, &srcRecordHandle);
+
+               ret = contacts_record_create(_contacts_nickname._uri, &dstRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle nicknameHandle(dstRecordHandle);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_nickname.name, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_nickname.name, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_my_profile.nickname, dstRecordHandle);
+
+               nicknameHandle.Release();
+       }
+
+       // relationship
+       contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.relationship, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.relationship, i, &srcRecordHandle);
+
+               ret = contacts_record_create(_contacts_relationship._uri, &dstRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle relationshipHandle(dstRecordHandle);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_relationship.name, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_relationship.name, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_my_profile.relationship, dstRecordHandle);
+
+               relationshipHandle.Release();
+       }
+
+       // image
+       contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.image, &count);
+
+       int recordId = 0;
+       contacts_record_get_int(srcHandle, _contacts_my_profile.id, &recordId);
+
+       if (count > 0 && recordId == 0)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.image, 0, &srcRecordHandle);
+
+               ret = contacts_record_create(_contacts_image._uri, &dstRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle imageHandle(dstRecordHandle);
+
+               contacts_record_get_int(srcRecordHandle, _contacts_image.type, &intValue);
+               contacts_record_set_int(dstRecordHandle, _contacts_image.type, intValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_image.label, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_image.label, pCharValue);
+
+               contacts_record_get_str_p(srcRecordHandle, _contacts_image.path, &pCharValue);
+               contacts_record_set_str(dstRecordHandle, _contacts_image.path, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.image, dstRecordHandle);
+
+               imageHandle.Release();
+       }
+
+       return contactHandle;
+}
+
+contacts_record_h
+_AddressbookImpl::CopyContactRecordHandle(contacts_record_h srcHandle)
+{
+       ClearLastResult();
+
+       int ret = CONTACTS_ERROR_NONE;
+       unsigned int i = 0;
+       unsigned int count = 0;
+       char* pCharValue = null;
+       int intValue = 0;
+       bool boolValue = false;
+
+       contacts_record_h contactHandle = null;
+       contacts_record_h sourceRecordHandle = null;
+       contacts_record_h destRecordHandle = null;
+
+       ret = contacts_record_create(_contacts_contact._uri, &contactHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       // favorite
+       contacts_record_get_bool(srcHandle, _contacts_contact.is_favorite, &boolValue);
+       contacts_record_set_bool(contactHandle, _contacts_contact.is_favorite, boolValue);
+
+       // uid
+       contacts_record_get_str_p(srcHandle, _contacts_contact.uid, &pCharValue);
+       contacts_record_set_str(contactHandle, _contacts_contact.uid, pCharValue);
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // name
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.name, &count);
+       if (count > 0)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.name, 0, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_name._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle nameHandle(destRecordHandle);
+
+               // 1. first
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.first, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.first, pCharValue);
+
+               // 2. last
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.last, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.last, pCharValue);
+
+               // 3. addition
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.addition, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.addition, pCharValue);
+
+               // 4. suffix
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.suffix, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.suffix, pCharValue);
+
+               // 5. prefix
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.prefix, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.prefix, pCharValue);
+
+               // 6. phonetic_first
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_first, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_first, pCharValue);
+
+               // 7. phonetic_last
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_last, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_last, pCharValue);
+
+               // 8. phonetic_middle
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_middle, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_middle, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.name, destRecordHandle);
+
+               nameHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // image
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.image, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.image, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_image._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle imageHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_image.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_image.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_image.label, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_image.label, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_image.path, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_image.path, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.image, destRecordHandle);
+
+               imageHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // company
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.company, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.company, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_company._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle companyHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_company.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_company.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.name, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.name, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.department, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.department, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.job_title, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.job_title, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.assistant_name, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.assistant_name, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.role, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.role, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.logo, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.logo, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.location, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.location, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.description, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.description, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.phonetic_name, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.phonetic_name, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.company, destRecordHandle);
+
+               companyHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // note
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.note, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.note, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_note._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle noteHandle(destRecordHandle);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_note.note, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_note.note, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.note, destRecordHandle);
+
+               noteHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // phone number
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.number, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.number, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_number._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle numberHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_number.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_number.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_number.label, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_number.label, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_number.number, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_number.number, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.number, destRecordHandle);
+
+               numberHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // email
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.email, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.email, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_email._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle emailHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_email.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_email.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_email.label, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_email.label, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_email.email, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_email.email, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.email, destRecordHandle);
+
+               emailHandle.Release();
+
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // event
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.event, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.event, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_event._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle eventHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_event.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_event.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_event.label, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_event.label, pCharValue);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_event.date, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_event.date, intValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.event, destRecordHandle);
+
+               eventHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // im address
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.messenger, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.messenger, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_messenger._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle imAddressHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_messenger.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_messenger.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_messenger.label, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_messenger.label, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_messenger.im_id, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_messenger.im_id, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.messenger, destRecordHandle);
+
+               imAddressHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // address
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.address, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.address, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_address._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle addressHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_address.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_address.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.label, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.label, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.postbox, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.postbox, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.extended, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.extended, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.street, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.street, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.locality, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.locality, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.region, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.region, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.postal_code, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.postal_code, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.country, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.country, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.address, destRecordHandle);
+
+               addressHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // url
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.url, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.url, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_url._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle urlHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_url.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_url.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_url.label, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_url.label, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_url.url, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_url.url, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.url, destRecordHandle);
+
+               urlHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // nickname
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.nickname, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.nickname, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_nickname._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle nicknameHandle(destRecordHandle);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_nickname.name, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_nickname.name, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.nickname, destRecordHandle);
+
+               nicknameHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // relationship
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.relationship, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.relationship, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_relationship._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle relationshipHandle(destRecordHandle);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_relationship.name, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_relationship.name, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.relationship, destRecordHandle);
+
+               relationshipHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // app launch data
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.profile, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.profile, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_profile._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle profileHandle(destRecordHandle);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.text, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.text, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.uid, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.uid, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.app_id, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.app_id, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.service_operation, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.service_operation, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.uri, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.uri, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.category, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.category, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.mime, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.mime, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.extra_data, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.extra_data, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.profile, destRecordHandle);
+
+               profileHandle.Release();
+       }
+
+       return contactHandle;
+}
+
+void
+_AddressbookImpl::OnContactChanged(void)
+{
+       if (__pIRecordEventListener == null && __pIAddressbookChangeEventListener == null && __pIAddressbookEventListener == null)
+       {
+               return;
+       }
+
+       std::unique_ptr<IList, AllElementsDeleter> pChangedContactList(GetChangedContactsAfterN(__dbVersionForContact, __dbVersionForContact));
+       SysTryReturnVoidResult(NID_SCL, pChangedContactList != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       if (pChangedContactList->GetCount() > 0)
+       {
+               if (__pIAddressbookEventListener != null)
+               {
+                       __pIAddressbookEventListener->OnContactsChanged(*pChangedContactList);
+               }
+               else if (__pIAddressbookChangeEventListener != null)
+               {
+                       __pIAddressbookChangeEventListener->OnContactsChanged(*pChangedContactList);
+               }
+               else
+               {
+                       RecordEventType recordEventType = RECORD_ADDED;
+                       std::unique_ptr<IEnumerator> pEnum(pChangedContactList->GetEnumeratorN());
+                       std::unique_ptr<Contact> pContact(null);
+
+                       while (pEnum->MoveNext() == E_SUCCESS)
+                       {
+                               ContactChangeInfo* pContactChagneInfo = static_cast<ContactChangeInfo*>(pEnum->GetCurrent());
+
+                               if (pContactChagneInfo->GetChangeType() == RECORD_CHANGE_TYPE_ADDED)
+                               {
+                                       recordEventType = RECORD_ADDED;
+                                       pContact.reset(GetContactN(pContactChagneInfo->GetContactId()));
+                                       if (pContact == null)
+                                       {
+                                               if (GetLastResult() == E_OBJ_NOT_FOUND)
+                                               {
+                                                       continue;
+                                               }
+                                               else
+                                               {
+                                                       break;
+                                               }
+                                       }
+                               }
+                               else if (pContactChagneInfo->GetChangeType() == RECORD_CHANGE_TYPE_UPDATED)
+                               {
+                                       recordEventType = RECORD_UPDATED;
+                                       pContact.reset(GetContactN(pContactChagneInfo->GetContactId()));
+                                       if (pContact == null)
+                                       {
+                                               if (GetLastResult() == E_OBJ_NOT_FOUND)
+                                               {
+                                                       continue;
+                                               }
+                                               else
+                                               {
+                                                       break;
+                                               }
+                                       }
+                               }
+                               else
+                               {
+                                       recordEventType = RECORD_REMOVED;
+                                       pContact.reset(new (std::nothrow) Contact());
+                                       if (pContact == null)
+                                       {
+                                               SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+                                               break;
+                                       }
+
+                                       _RecordImpl::GetInstance(*pContact)->SetRecordId(pContactChagneInfo->GetContactId());
+                               }
+
+                               __pIRecordEventListener->OnRecordChangedN(recordEventType, RECORD_TYPE_CONTACT, *pContact, null, null);
+                       }
+               }
+
+       }
+}
+
+void
+_AddressbookImpl::OnCategoryChanged(void)
+{
+       if (__pIRecordEventListener == null && __pIAddressbookChangeEventListener == null && __pIAddressbookEventListener == null)
+       {
+               return;
+       }
+
+       std::unique_ptr<IList, AllElementsDeleter> pChangedCategoryList(GetChangedGroupsAfterN(__dbVersionForGroup, __dbVersionForGroup));
+       SysTryReturnVoidResult(NID_SCL, pChangedCategoryList != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       if (pChangedCategoryList->GetCount() > 0)
+       {
+               if (__pIAddressbookEventListener != null)
+               {
+                       __pIAddressbookEventListener->OnCategoriesChanged(*pChangedCategoryList);
+               }
+               else if (__pIAddressbookChangeEventListener != null)
+               {
+                       __pIAddressbookChangeEventListener->OnCategoriesChanged(*pChangedCategoryList);
+               }
+               else
+               {
+                       RecordEventType recordEventType = RECORD_ADDED;
+                       std::unique_ptr<IEnumerator> pEnum(pChangedCategoryList->GetEnumeratorN());
+                       std::unique_ptr<Category> pCategory(null);
+
+                       while (pEnum->MoveNext() == E_SUCCESS)
+                       {
+                               CategoryChangeInfo* pCategoryChagneInfo = static_cast<CategoryChangeInfo*>(pEnum->GetCurrent());
+
+                               if (pCategoryChagneInfo->GetChangeType() == RECORD_CHANGE_TYPE_ADDED)
+                               {
+                                       recordEventType = RECORD_ADDED;
+                                       pCategory.reset(GetCategoryN(pCategoryChagneInfo->GetCategoryId()));
+                                       if (pCategory == null)
+                                       {
+                                               if (GetLastResult() == E_OBJ_NOT_FOUND)
+                                               {
+                                                       continue;
+                                               }
+                                               else
+                                               {
+                                                       break;
+                                               }
+                                       }
+                               }
+                               else if (pCategoryChagneInfo->GetChangeType() == RECORD_CHANGE_TYPE_UPDATED)
+                               {
+                                       recordEventType = RECORD_UPDATED;
+                                       pCategory.reset(GetCategoryN(pCategoryChagneInfo->GetCategoryId()));
+                                       if (pCategory == null)
+                                       {
+                                               if (GetLastResult() == E_OBJ_NOT_FOUND)
+                                               {
+                                                       continue;
+                                               }
+                                               else
+                                               {
+                                                       break;
+                                               }
+                                       }
+                               }
+                               else
+                               {
+                                       recordEventType = RECORD_REMOVED;
+                                       pCategory.reset(new (std::nothrow) Category());
+                                       if (pCategory == null)
+                                       {
+                                               SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+                                               break;
+                                       }
+
+                                       _RecordImpl::GetInstance(*pCategory)->SetRecordId(pCategoryChagneInfo->GetCategoryId());
+                               }
+
+                               __pIRecordEventListener->OnRecordChangedN(recordEventType, RECORD_TYPE_CATEGORY, *pCategory, null, null);
+                       }
+               }
+
+       }
+}
+
+void
+_AddressbookImpl::OnRelationChanged(void)
+{
+       if (__pIAddressbookEventListener == null && __pIRecordEventListener == null)
+       {
+               return;
+       }
+
+       std::unique_ptr<IList, AllElementsDeleter> pChangedCategoryList(GetChangedRelationsAfterN(__dbVersionForRelation, __dbVersionForRelation));
+       SysTryReturnVoidResult(NID_SCL, pChangedCategoryList != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       if (pChangedCategoryList->GetCount() > 0)
+       {
+               if (__pIAddressbookEventListener != null)
+               {
+                       __pIAddressbookEventListener->OnCategoriesChanged(*pChangedCategoryList);
+               }
+               else
+               {
+                       RecordEventType recordEventType = RECORD_ADDED;
+                       std::unique_ptr<IEnumerator> pEnum(pChangedCategoryList->GetEnumeratorN());
+                       std::unique_ptr<Category> pCategory(null);
+
+                       while (pEnum->MoveNext() == E_SUCCESS)
+                       {
+                               CategoryChangeInfo* pCategoryChagneInfo = static_cast<CategoryChangeInfo*>(pEnum->GetCurrent());
+
+                               recordEventType = RECORD_UPDATED;
+                               pCategory.reset(GetCategoryN(pCategoryChagneInfo->GetCategoryId()));
+                               if (pCategory == null)
+                               {
+                                       if (GetLastResult() == E_OBJ_NOT_FOUND)
+                                       {
+                                               continue;
+                                       }
+                                       else
+                                       {
+                                               break;
+                                       }
+                               }
+
+                               __pIRecordEventListener->OnRecordChangedN(recordEventType, RECORD_TYPE_CATEGORY, *pCategory, null, null);
+                       }
+               }
+       }
+}
+
+_AddressbookImpl*
+_AddressbookImpl::GetInstance(Addressbook& addressbook)
+{
+       return addressbook.__pAddressbookImpl;
+}
+
+const _AddressbookImpl*
+_AddressbookImpl::GetInstance(const Addressbook& addressbook)
+{
+       return addressbook.__pAddressbookImpl;
+}
+
+}}  // Tizen::Social
diff --git a/src/FScl_AddressbookManagerImpl.cpp b/src/FScl_AddressbookManagerImpl.cpp
new file mode 100644 (file)
index 0000000..474ba46
--- /dev/null
@@ -0,0 +1,3306 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_AddressbookManagerImpl.cpp
+ * @brief              This is the implementation for _AddressbookManagerImpl class.
+ *
+ * This file contains definitions of @e _AddressbookManagerImpl class.
+ */
+#include <contacts.h>
+#include <unique_ptr.h>
+#include <FApp.h>
+#include <FBaseColIListT.h>
+#include <FBaseColArrayListT.h>
+#include <FBaseColHashMapT.h>
+#include <FBaseResult.h>
+#include <FBaseLongLong.h>
+#include <FBaseInteger.h>
+#include <FIoFile.h>
+#include <FSclAddressbook.h>
+#include <FSclAddressbookManager.h>
+#include <FSclIAddressbookChangeEventListener.h>
+#include <FSclContact.h>
+#include <FSclCategory.h>
+#include <FSclUserProfile.h>
+#include <FSclContactChangeInfo.h>
+#include <FSclCategoryChangeInfo.h>
+#include <FSclPerson.h>
+#include <FSclPhoneNumberContact.h>
+#include <FScl_PhoneNumberContactImpl.h>
+#include <FSclEmailContact.h>
+#include <FScl_EmailContactImpl.h>
+#include <FSclAddressbookFilter.h>
+#include <FSclIAddressbookEventListener.h>
+#include <FSclIRecordEventListener.h>
+#include <FBaseSysLog.h>
+#include <FApp_AppInfo.h>
+#include <FBase_StringConverter.h>
+#include "FScl_AddressbookImpl.h"
+#include "FScl_AddressbookFilterImpl.h"
+#include "FScl_AddressbookManagerImpl.h"
+#include "FScl_AddressbookUtil.h"
+#include "FScl_RecordImpl.h"
+#include "FScl_ContactImpl.h"
+#include "FScl_CategoryImpl.h"
+#include "FScl_PersonImpl.h"
+#include "FScl_AddressbookUtil.h"
+#include "FScl_ContactChangeInfoImpl.h"
+#include "FScl_CategoryChangeInfoImpl.h"
+#include "FScl_ContactDbMonitor.h"
+#include "FScl_ContactDbConnector.h"
+#include "FScl_UserProfileImpl.h"
+
+using namespace std;
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+using namespace Tizen::Graphics;
+
+namespace Tizen { namespace Social
+{
+
+_AddressbookManagerImpl::_AddressbookManagerImpl(void)
+       : __pIAddressbookEventListener(null)
+       , __pIAddressbookChangeEventListener(null)
+       , __dbVersionForContact(0)
+       , __dbVersionForGroup(0)
+       , __dbVersionForRelation(0)
+{
+       // empty body.
+}
+
+_AddressbookManagerImpl::~_AddressbookManagerImpl(void)
+{
+       if (__pIAddressbookEventListener != null || __pIAddressbookChangeEventListener != null)
+       {
+               _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance();
+               if (pContactDbMonitor != null)
+               {
+                       pContactDbMonitor->RemoveListener(*this);
+               }
+       }
+}
+
+result
+_AddressbookManagerImpl::Construct(void)
+{
+       result r = _ContactDbConnector::EnsureDbConnection();
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookManagerImpl::SetEventListener(IAddressbookEventListener* pListener)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       result r = E_SUCCESS;
+
+       if (pListener != null)
+       {
+               if (__pIAddressbookEventListener == null && __pIAddressbookChangeEventListener == null)
+               {
+                       _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance();
+                       SysTryReturn(NID_SCL, pContactDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+                       r = pContactDbMonitor->AddListener(*this);
+                       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+
+               __dbVersionForContact = GetLatestVersion();
+               SysTryReturn(NID_SCL, __dbVersionForContact != -1, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+               __dbVersionForGroup = __dbVersionForContact;
+               __dbVersionForRelation = __dbVersionForContact;
+
+               __pIAddressbookChangeEventListener = null;
+               __pIAddressbookEventListener = pListener;
+       }
+       else
+       {
+               if (__pIAddressbookEventListener != null || __pIAddressbookChangeEventListener != null)
+               {
+
+                       _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance();
+                       SysTryReturn(NID_SCL, pContactDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+                       pContactDbMonitor->RemoveListener(*this);
+               }
+
+               __pIAddressbookEventListener = null;
+               __pIAddressbookChangeEventListener = null;
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookManagerImpl::SetAddressbookChangeEventListener(IAddressbookChangeEventListener* pListener)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       result r = E_SUCCESS;
+
+       if (pListener != null)
+       {
+               if (__pIAddressbookChangeEventListener == null && __pIAddressbookEventListener == null)
+               {
+                       _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance();
+                       SysTryReturn(NID_SCL, pContactDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+                       r = pContactDbMonitor->AddListener(*this);
+                       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+
+               __dbVersionForContact = GetLatestVersion();
+               SysTryReturn(NID_SCL, __dbVersionForContact != -1, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+               __dbVersionForGroup = __dbVersionForContact;
+               __dbVersionForRelation = __dbVersionForContact;
+
+               __pIAddressbookEventListener = null;
+               __pIAddressbookChangeEventListener = pListener;
+       }
+       else
+       {
+               if (__pIAddressbookChangeEventListener != null || __pIAddressbookEventListener != null)
+               {
+
+                       _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance();
+                       SysTryReturn(NID_SCL, pContactDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+                       pContactDbMonitor->RemoveListener(*this);
+               }
+
+               __pIAddressbookChangeEventListener = null;
+               __pIAddressbookEventListener = null;
+       }
+
+       return E_SUCCESS;
+}
+
+Addressbook*
+_AddressbookManagerImpl::CreateAddressbookN(AccountId accountId, const String& name)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       SysTryReturn(NID_SCL, accountId >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. account id is invalid.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !name.IsEmpty(), null, E_INVALID_ARG, "[%s] Invalid argument is used. The name is empty.", GetErrorMessage(E_INVALID_ARG));
+
+       ClearLastResult();
+
+       result r = E_SUCCESS;
+       int recordId = 0;
+
+       unique_ptr<char[]> pNameString(_StringConverter::CopyToCharArrayN(name));
+       SysTryReturn(NID_SCL, pNameString !=null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __Filter<__ContactsAddressbook> filter;
+       filter.Construct();
+       filter.AddString(_contacts_address_book.name, CONTACTS_MATCH_EXACTLY, pNameString.get());
+       if (accountId != 0)
+       {
+               filter.AddOperator(CONTACTS_FILTER_OPERATOR_OR);
+               filter.AddInt(_contacts_address_book.account_id, CONTACTS_MATCH_EQUAL, accountId);
+       }
+
+       __Query<__ContactsAddressbook> query;
+       query.Construct();
+       query.SetFilter(filter);
+
+       int count = _AddressbookUtil::GetCountWithQuery(query);
+       SysTryReturn(NID_SCL, count == 0, null, E_OBJ_ALREADY_EXIST, "[%s] The name is already being used by other addressbook.", GetErrorMessage(E_OBJ_ALREADY_EXIST));
+
+       unique_ptr<Addressbook> pAddressbook(new (std::nothrow) Addressbook());
+       SysTryReturn(NID_SCL, pAddressbook != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = pAddressbook->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pAbRecord(_AddressbookUtil::CreateContactRecordN(_contacts_address_book._uri));
+       SysTryReturn(NID_SCL, pAbRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       contacts_record_set_str(pAbRecord.get(), _contacts_address_book.name, pNameString.get());
+       contacts_record_set_int(pAbRecord.get(), _contacts_address_book.account_id, accountId);
+
+       r = _AddressbookUtil::InsertContactRecordN(pAbRecord.get(), recordId);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _AddressbookImpl::GetInstance(*pAddressbook)->SetAccountId(accountId);
+       _AddressbookImpl::GetInstance(*pAddressbook)->SetName(name);
+       _AddressbookImpl::GetInstance(*pAddressbook)->SetId(recordId);
+
+       return pAddressbook.release();
+}
+
+result
+_AddressbookManagerImpl::DeleteAddressbook(AddressbookId addressbookId)
+{
+       SysTryReturn(NID_SCL, addressbookId > 0, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument used.The addressbook ID is invalid or the default addressbook ID.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       result r = _AddressbookUtil::DeleteContactRecord(_contacts_address_book._uri, addressbookId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+IList*
+_AddressbookManagerImpl::GetAddressbooksByAccountN(AccountId accountId) const
+{
+       SysTryReturn(NID_SCL, accountId >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. account id is invalid.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       IList* pAddressbooks = null;
+
+       __Filter<__ContactsAddressbook> accountFilter;
+       accountFilter.Construct();
+       accountFilter.AddInt(_contacts_address_book.account_id, CONTACTS_MATCH_EQUAL, accountId);
+
+       unique_ptr< __Filter<__ContactsAddressbook> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsAddressbook>());
+       if (pRwAbFilter->Get() == null)
+       {
+               __Query<__ContactsAddressbook> query;
+               query.Construct();
+               query.SetFilter(accountFilter);
+
+               pAddressbooks = _AddressbookUtil::SearchWithQueryN<__ContactsAddressbook, Addressbook>(query);
+               SysTryReturn(NID_SCL, pAddressbooks != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       }
+       else
+       {
+               __Filter<__ContactsAddressbook> mainFilter;
+               mainFilter.Construct();
+
+               mainFilter.AddFilter(*pRwAbFilter);
+               mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+               mainFilter.AddFilter(accountFilter);
+
+               __Query<__ContactsAddressbook> query;
+               query.Construct();
+               query.SetFilter(mainFilter);
+
+               pAddressbooks = _AddressbookUtil::SearchWithQueryN<__ContactsAddressbook, Addressbook>(query);
+               SysTryReturn(NID_SCL, pAddressbooks != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       }
+
+       return pAddressbooks;
+}
+
+IList*
+_AddressbookManagerImpl::GetAllAddressbooksN(void) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       __Filter<__ContactsAddressbook> abFilter;
+       abFilter.Construct();
+       abFilter.AddInt(_contacts_address_book.mode, CONTACTS_MATCH_EQUAL, 0);
+
+       __Query<__ContactsAddressbook> query;
+       query.Construct();
+       query.SetFilter(abFilter);
+       query.SetSort(_contacts_address_book.name, true);
+
+       IList* pAddressbooks = _AddressbookUtil::SearchWithQueryN<__ContactsAddressbook, Addressbook>(query);
+       SysTryReturn(NID_SCL, pAddressbooks != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pAddressbooks;
+}
+
+Addressbook*
+_AddressbookManagerImpl::GetAddressbookN(AddressbookId addressbookId) const
+{
+       SysTryReturn(NID_SCL, addressbookId >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. addressbookId.", GetErrorMessage(E_INVALID_ARG), addressbookId);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       result r = E_SUCCESS;
+       int intValue = 0;
+       char* pCharValue = null;
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pAbRecord(_AddressbookUtil::GetContactRecordN(_contacts_address_book._uri, addressbookId));
+       SysTryReturn(NID_SCL, pAbRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       contacts_record_get_int(pAbRecord.get(), _contacts_address_book.mode, &intValue);
+       SysTryReturn(NID_SCL, intValue == 0, null, E_OBJ_NOT_FOUND, "[%s] Addressbook does not exist.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       unique_ptr<Addressbook> pAddressbook(new (std::nothrow) Addressbook());
+       SysTryReturn(NID_SCL, pAddressbook !=null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = pAddressbook->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       _AddressbookImpl::GetInstance(*pAddressbook)->SetId(addressbookId);
+
+       contacts_record_get_int(pAbRecord.get(), _contacts_address_book.account_id, &intValue);
+       _AddressbookImpl::GetInstance(*pAddressbook)->SetAccountId(intValue);
+
+       contacts_record_get_str_p(pAbRecord.get(), _contacts_address_book.name, &pCharValue);
+       _AddressbookImpl::GetInstance(*pAddressbook)->SetName(pCharValue);
+
+       return pAddressbook.release();
+}
+
+result
+_AddressbookManagerImpl::AddContact(Contact& contact, AddressbookId addressbookId)
+{
+       if (_ContactImpl::GetInstance(contact)->IsRemoved())
+       {
+               result r = _ContactImpl::GetInstance(contact)->Invalidate();
+               SysTryReturn(NID_SCL, r == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       SysTryReturn(NID_SCL, contact.GetRecordId() == INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The ID of specified contact is not INVALID_RECORD_ID.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !_ContactImpl::GetInstance(contact)->IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified contact does not have any property.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pAbRecord(_AddressbookUtil::GetContactRecordN(_contacts_address_book._uri, addressbookId));
+       SysTryReturn(NID_SCL, pAbRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int intValue = 0;
+       contacts_record_get_int(pAbRecord.get(), _contacts_address_book.mode, &intValue);
+       SysTryReturn(NID_SCL, intValue == 0, null, E_OBJ_NOT_FOUND, "[%s] Addressbook does not exist.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       contacts_record_h recordHandle = _ContactImpl::GetInstance(contact)->GetContactRecordHandle();
+       contacts_record_set_int(recordHandle, _contacts_contact.address_book_id, addressbookId);
+
+       int recordId = 0;
+       result r = _AddressbookUtil::InsertContactRecordN(recordHandle, recordId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pContactRecord(_AddressbookUtil::GetContactRecordN(_contacts_contact._uri, recordId));
+       SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       _ContactImpl::GetInstance(contact)->SetContactRecordHandle(pContactRecord.release());
+       _RecordImpl::GetInstance(contact)->SetRecordId(recordId);
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookManagerImpl::AddCategory(Category& category, AddressbookId addressbookId)
+{
+       SysTryReturn(NID_SCL, category.GetRecordId() == INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified categoryId is not INVALID_RECORD_ID.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pAbRecord(_AddressbookUtil::GetContactRecordN(_contacts_address_book._uri, addressbookId));
+       SysTryReturn(NID_SCL, pAbRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int intValue = 0;
+       contacts_record_get_int(pAbRecord.get(), _contacts_address_book.mode, &intValue);
+       SysTryReturn(NID_SCL, intValue == 0, null, E_OBJ_NOT_FOUND, "[%s] Addressbook does not exist.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       contacts_record_h recordHandle = _CategoryImpl::GetInstance(category)->GetRecordHandle();
+       contacts_record_set_int(recordHandle, _contacts_group.address_book_id, addressbookId);
+
+       int recordId = 0;
+       result r = _AddressbookUtil::InsertContactRecordN(recordHandle, recordId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pCategoryRecord(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, recordId));
+       SysTryReturn(NID_SCL, pCategoryRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       _CategoryImpl::GetInstance(category)->SetRecordHandle(pCategoryRecord.release());
+       _RecordImpl::GetInstance(category)->SetRecordId(recordId);
+
+       unique_ptr<IListT<int> > pList(_CategoryImpl::GetInstance(category)->GetAddedMembersN());
+       if (pList != null && pList->GetCount() > 0)
+       {
+               unique_ptr<IEnumeratorT<int> > pEnum(pList->GetEnumeratorN());
+
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       int tableId = -1;
+                       pEnum->GetCurrent(tableId);
+
+                       AddMemberToCategory(category.GetRecordId(), tableId);
+               }
+
+               _CategoryImpl::GetInstance(category)->ClearAddedMemberList();
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookManagerImpl::RemoveContact(RecordId contactId)
+{
+       SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified contactId is invalid.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       result r = _AddressbookUtil::DeleteContactRecord(_contacts_contact._uri, contactId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookManagerImpl::RemoveCategory(RecordId categoryId)
+{
+       SysTryReturn(NID_SCL, categoryId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified categoryId is invalid", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pCategoryRecord(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, categoryId));
+       SysTryReturn(NID_SCL, pCategoryRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       bool isReadOnly = false;
+       contacts_record_get_bool(pCategoryRecord.get(), _contacts_group.is_read_only, &isReadOnly);
+       SysTryReturn(NID_SCL, !isReadOnly, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified category is a default category.", GetErrorMessage(E_INVALID_ARG));
+
+       result r = _AddressbookUtil::DeleteContactRecord(_contacts_group._uri, categoryId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookManagerImpl::UpdateContact(const Contact& contact)
+{
+       RecordId contactId = contact.GetRecordId();
+       SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified contactId is not INVALID_RECORD_ID.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !_ContactImpl::GetInstance(contact)->IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified contact does not have any property.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pContactRecord(_AddressbookUtil::GetContactRecordN(_contacts_simple_contact._uri, contactId));
+       SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int intValue = 0;
+       contacts_record_get_int(pContactRecord.get(), _contacts_simple_contact.id, &intValue);
+       SysTryReturn(NID_SCL, intValue == contactId, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The contact is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       contacts_record_h recordHandle = _ContactImpl::GetInstance(contact)->GetContactRecordHandle();
+       SysTryReturn(NID_SCL, recordHandle != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = _AddressbookUtil::UpdateContactRecord(recordHandle);
+       if (r == E_OBJ_NOT_FOUND)
+       {
+               unsigned int count = 0;
+               unsigned int count2 = 0;
+
+               contacts_record_h newRecordHandle = null;
+               int ret = contacts_db_get_record(_contacts_contact._uri, contactId, &newRecordHandle);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+               contacts_record_get_child_record_count(newRecordHandle, _contacts_contact.image, &count);
+               contacts_record_get_child_record_count(recordHandle, _contacts_contact.image, &count2);
+
+               contacts_record_h imageHandle = null;
+               contacts_record_h imageHandle2 = null;
+
+               int imageId = -1;
+               int imageId2 = -1;
+
+               for (int i = (int)count2 - 1; i >= 0; i--)
+               {
+                       contacts_record_get_child_record_at_p(recordHandle, _contacts_contact.image, i, &imageHandle);
+                       contacts_record_get_int(imageHandle, _contacts_image.id, &imageId);
+                       if (imageId == 0)
+                       {
+                               continue;
+                       }
+
+                       bool matchFound = false;
+
+                       for (unsigned int j = 0; j < count; j++)
+                       {
+                               contacts_record_get_child_record_at_p(newRecordHandle, _contacts_contact.image, i, &imageHandle2);
+                               contacts_record_get_int(imageHandle2, _contacts_image.id, &imageId2);
+                               if (imageId == imageId2)
+                               {
+                                       matchFound = true;
+                                       break;
+                               }
+                       }
+
+                       if (!matchFound)
+                       {
+                               contacts_record_remove_child_record(recordHandle, _contacts_contact.image, imageHandle);
+                       }
+               }
+
+               contacts_record_destroy(newRecordHandle, true);
+
+               contacts_record_h copyRecordHandle = CopyContactRecordHandle(recordHandle);
+               SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_h tempHandle = null;
+               contacts_record_get_child_record_count(copyRecordHandle, _contacts_contact.image, &count);
+
+               char* pCharValue = null;
+               String tempPath;
+
+               for (unsigned int i = 0; i < count; i++)
+               {
+                       contacts_record_get_child_record_at_p(copyRecordHandle, _contacts_contact.image, i, &tempHandle);
+                       contacts_record_get_str(tempHandle, _contacts_image.path, &pCharValue);
+
+                       tempPath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/temp";
+                       tempPath.Append((int)i);
+                       tempPath.Append(L".jpg");
+                       String servicePath(pCharValue);
+
+                       File::Copy(servicePath, tempPath, true);
+
+                       std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(tempPath));
+                       SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       contacts_record_set_str(tempHandle, _contacts_image.path, pCharArray.get());
+                       contacts_record_get_str(tempHandle, _contacts_image.path, &pCharValue);
+
+                       tempPath.Clear();
+               }
+
+               ret = contacts_db_replace_record(copyRecordHandle, contactId);
+               contacts_record_destroy(copyRecordHandle, true);
+
+               for (unsigned int i = 0; i < count; i++)
+               {
+                       tempPath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/temp";
+                       tempPath.Append((int)i);
+                       tempPath.Append(L".jpg");
+
+                       File::Remove(tempPath);
+
+                       tempPath.Clear();
+               }
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is insufficient.", GetErrorMessage(E_STORAGE_FULL));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred. Failed to update a contact.", GetErrorMessage(E_SYSTEM));
+       }
+       else
+       {
+               SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       pContactRecord.reset(_AddressbookUtil::GetContactRecordN(_contacts_contact._uri, contact.GetRecordId()));
+       SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       _ContactImpl::GetInstance(*const_cast<Contact*>(&contact))->SetContactRecordHandle(pContactRecord.release());
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookManagerImpl::UpdateCategory(const Category& category)
+{
+       RecordId categoryId = category.GetRecordId();
+       SysTryReturn(NID_SCL, categoryId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified category is invalid.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !category.GetName().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified category does not have name.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pCategoryRecord(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, category.GetRecordId()));
+       SysTryReturn(NID_SCL, pCategoryRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int intValue = 0;
+       contacts_record_get_int(pCategoryRecord.get(), _contacts_group.id, &intValue);
+       SysTryReturn(NID_SCL, intValue == categoryId, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The category is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       contacts_record_h recordHandle = _CategoryImpl::GetInstance(category)->GetRecordHandle();
+
+       result r = _AddressbookUtil::UpdateContactRecord(recordHandle);
+        SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pCategoryRecord.reset(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, category.GetRecordId()));
+       SysTryReturn(NID_SCL, pCategoryRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       _CategoryImpl::GetInstance(*const_cast<Category*>(&category))->SetRecordHandle(pCategoryRecord.release());
+
+       unique_ptr<IListT<int> > pList(_CategoryImpl::GetInstance(category)->GetAddedMembersN());
+       if (pList != null && pList->GetCount() > 0)
+       {
+               int tableId = -1;
+               unique_ptr<IEnumeratorT<int> > pEnum(pList->GetEnumeratorN());
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       pEnum->GetCurrent(tableId);
+
+                       AddMemberToCategory(category.GetRecordId(), tableId);
+               }
+
+               const_cast<_CategoryImpl*>(_CategoryImpl::GetInstance(category))->ClearAddedMemberList();
+       }
+
+       pList.reset(_CategoryImpl::GetInstance(category)->GetRemovedMembersN());
+       if (pList != null && pList->GetCount() > 0)
+       {
+               int tableId = -1;
+               unique_ptr<IEnumeratorT<int> > pEnum(pList->GetEnumeratorN());
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       pEnum->GetCurrent(tableId);
+
+                       RemoveMemberFromCategory(category.GetRecordId(), tableId);
+               }
+
+               const_cast<_CategoryImpl*>(_CategoryImpl::GetInstance(category))->ClearRemovedMemberList();
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookManagerImpl::AddMemberToCategory(RecordId categoryId, RecordId contactId)
+{
+       SysTryReturn(NID_SCL, categoryId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. categoryId = %d.", GetErrorMessage(E_INVALID_ARG), categoryId);
+       SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. contactId = %d.", GetErrorMessage(E_INVALID_ARG), contactId);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       result r = _AddressbookUtil::AddContactToCategory(categoryId, contactId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookManagerImpl::RemoveMemberFromCategory(RecordId categoryId, RecordId contactId)
+{
+       SysTryReturn(NID_SCL, categoryId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. categoryId = %d.", GetErrorMessage(E_INVALID_ARG), categoryId);
+       SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. contactId = %d.", GetErrorMessage(E_INVALID_ARG), contactId);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       result r = _AddressbookUtil::RemoveContactFromCategory(categoryId, contactId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+IList*
+_AddressbookManagerImpl::GetAllCategoriesN(void) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       unique_ptr< __Filter<__ContactsGroup> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsGroup>());
+
+       __Query<__ContactsGroup> query;
+       query.Construct();
+       query.SetSort(_contacts_group.name, true);
+
+       if (pRwAbFilter->Get() != null)
+       {
+               query.SetFilter(*pRwAbFilter);
+       }
+
+       IList* pCategories = _AddressbookUtil::SearchWithQueryN<__ContactsGroup, Category>(query);
+       SysTryReturn(NID_SCL, pCategories != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pCategories;
+}
+
+IList*
+_AddressbookManagerImpl::GetCategoriesByContactN(RecordId contactId) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, null, E_INVALID_ARG, "[%s] Invalid argument is used. The specified contact is invalid.", GetErrorMessage(E_INVALID_ARG));
+
+       ClearLastResult();
+       IList* pCategories = null;
+
+       unique_ptr< __Filter<__ContactsContactGroupRel> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContactGroupRel>());
+
+       __Filter<__ContactsContactGroupRel> relFilter;
+       relFilter.Construct();
+       relFilter.AddInt(_contacts_contact_grouprel.contact_id, CONTACTS_MATCH_EQUAL, contactId);
+
+       if (pRwAbFilter->Get() != null)
+       {
+               __Filter<__ContactsContactGroupRel> mainFilter;
+               mainFilter.Construct();
+               mainFilter.AddFilter(*pRwAbFilter);
+               mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+               mainFilter.AddFilter(relFilter);
+
+               __Query<__ContactsContactGroupRel> query;
+               query.Construct();
+               query.SetFilter(mainFilter);
+
+               pCategories = _AddressbookUtil::SearchWithQueryN<__ContactsContactGroupRel, Category>(query);
+               SysTryReturn(NID_SCL, pCategories != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       }
+       else
+       {
+               __Query<__ContactsContactGroupRel> query;
+               query.Construct();
+               query.SetFilter(relFilter);
+
+               pCategories = _AddressbookUtil::SearchWithQueryN<__ContactsContactGroupRel, Category>(query);
+               SysTryReturn(NID_SCL, pCategories != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       }
+
+       return pCategories;
+}
+
+IList*
+_AddressbookManagerImpl::GetCategoriesByPersonN(PersonId personId) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       IList* pCategories = null;
+
+       unique_ptr< __Filter<__ContactsContactGroupRel> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContactGroupRel>());
+
+       __Filter<__ContactsContactGroupRel> relFilter;
+       relFilter.Construct();
+       relFilter.AddInt(_contacts_contact_grouprel.person_id, CONTACTS_MATCH_EQUAL, personId);
+       relFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+       relFilter.AddInt(_contacts_contact_grouprel.group_id, CONTACTS_MATCH_GREATER_THAN, 0);
+
+       unsigned int propertyIds[] =
+       {
+               _contacts_contact_grouprel.group_id,
+       };
+
+       if (pRwAbFilter->Get() != null)
+       {
+
+               __Filter<__ContactsContactGroupRel> mainFilter;
+               mainFilter.Construct();
+               mainFilter.AddFilter(*pRwAbFilter);
+               mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+               mainFilter.AddFilter(relFilter);
+
+
+               __Query<__ContactsContactGroupRel> query;
+               query.Construct();
+               query.SetProjection(propertyIds, sizeof(propertyIds)/sizeof(unsigned int));
+               query.SetFilter(mainFilter);
+               query.SetSort(_contacts_contact_grouprel.group_name, true);
+               query.SetDistinct(true);
+
+               pCategories = _AddressbookUtil::SearchWithQueryN<__ContactsContactGroupRel, Category>(query);
+               SysTryReturn(NID_SCL, pCategories != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       }
+       else
+       {
+               __Query<__ContactsContactGroupRel> query;
+               query.Construct();
+               query.SetProjection(propertyIds, sizeof(propertyIds)/sizeof(unsigned int));
+               query.SetFilter(relFilter);
+               query.SetSort(_contacts_contact_grouprel.group_name, true);
+               query.SetDistinct(true);
+
+               pCategories = _AddressbookUtil::SearchWithQueryN<__ContactsContactGroupRel, Category>(query);
+               SysTryReturn(NID_SCL, pCategories != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       }
+
+       return pCategories;
+}
+
+IList*
+_AddressbookManagerImpl::GetAllContactsN(void) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       unique_ptr< __Filter<__ContactsContact> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContact>());
+
+       __Query<__ContactsContact> query;
+       query.Construct();
+       query.SetSort(_contacts_contact.display_name, true);
+
+       if (pRwAbFilter->Get() != null)
+       {
+               query.SetFilter(*pRwAbFilter);
+       }
+
+       IList* pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContact, Contact>(query);
+       SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pContacts;
+}
+
+IList*
+_AddressbookManagerImpl::GetContactsByCategoryN(RecordId categoryId) const
+{
+       SysTryReturn(NID_SCL, categoryId >= INVALID_RECORD_ID, null, E_INVALID_ARG, "[%s] Invalid argument is used. The category ID must be greater than or equal to INVALID_RECORD_ID.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       IList* pContacts = null;
+
+       unique_ptr< __Filter<__ContactsContactGroupRel> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContactGroupRel>());
+
+       __Filter<__ContactsContactGroupRel> relFilter;
+       relFilter.Construct();
+
+       if (categoryId != INVALID_RECORD_ID)
+       {
+               relFilter.AddInt(_contacts_contact_grouprel.group_id, CONTACTS_MATCH_EQUAL, categoryId);
+       }
+       else
+       {
+               relFilter.AddInt(_contacts_contact_grouprel.group_id, CONTACTS_MATCH_NONE, 0);
+       }
+
+       if (pRwAbFilter->Get() != null)
+       {
+               __Filter<__ContactsContactGroupRel> mainFilter;
+               mainFilter.Construct();
+
+               mainFilter.AddFilter(*pRwAbFilter);
+               mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+               mainFilter.AddFilter(relFilter);
+
+               __Query<__ContactsContactGroupRel> query;
+               query.Construct();
+               query.SetFilter(mainFilter);
+
+               pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContactGroupRel, Contact>(query);
+               SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       }
+       else
+       {
+               __Query<__ContactsContactGroupRel> query;
+               query.Construct();
+               query.SetFilter(relFilter);
+
+               pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContactGroupRel, Contact>(query);
+               SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       }
+
+       return pContacts;
+}
+
+IList*
+_AddressbookManagerImpl::GetContactsByPersonN(PersonId personId) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       IList* pContacts = null;
+
+       unique_ptr< __Filter<__ContactsContact> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContact>());
+
+       __Filter<__ContactsContact> contactFilter;
+       contactFilter.Construct();
+       contactFilter.AddInt(_contacts_contact.person_id, CONTACTS_MATCH_EQUAL, personId);
+
+       if (pRwAbFilter->Get() != null)
+       {
+               __Filter<__ContactsContact> mainFilter;
+               mainFilter.Construct();
+
+               mainFilter.AddFilter(*pRwAbFilter);
+               mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+               mainFilter.AddFilter(contactFilter);
+
+               __Query<__ContactsContact> query;
+               query.Construct();
+               query.SetFilter(mainFilter);
+               query.SetSort(_contacts_contact.display_name, true);
+
+               pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContact, Contact>(query);
+               SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       }
+       else
+       {
+               __Query<__ContactsContact> query;
+               query.Construct();
+               query.SetFilter(contactFilter);
+               query.SetSort(_contacts_contact.display_name, true);
+
+               pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContact, Contact>(query);
+               SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       }
+
+       return pContacts;
+}
+
+IList*
+_AddressbookManagerImpl::SearchContactsByEmailN(const String& email) const
+{
+       SysTryReturn(NID_SCL, !email.IsEmpty(), null, E_INVALID_ARG, "[%s] Invalid argument is used. The specified email is an empty string.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       IList* pContacts = null;
+
+       unique_ptr< __Filter<__ContactsContactEmail> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContactEmail>());
+
+       unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(email));
+       SysTryReturn(NID_SCL, pCharArray != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __Filter<__ContactsContactEmail> emailFilter;
+       emailFilter.Construct();
+       emailFilter.AddString(_contacts_contact_email.email, CONTACTS_MATCH_CONTAINS, pCharArray.get());
+
+       if (pRwAbFilter->Get() != null)
+       {
+               __Filter<__ContactsContactEmail> mainFilter;
+               mainFilter.Construct();
+
+               mainFilter.AddFilter(*pRwAbFilter);
+               mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+               mainFilter.AddFilter(emailFilter);
+
+               __Query<__ContactsContactEmail> query;
+               query.Construct();
+               query.SetFilter(mainFilter);
+               query.SetSort(_contacts_contact_email.display_name, true);
+
+               pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContactEmail, Contact>(query);
+               SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       }
+       else
+       {
+               __Query<__ContactsContactEmail> query;
+               query.Construct();
+               query.SetFilter(emailFilter);
+               query.SetSort(_contacts_contact_email.display_name, true);
+
+               pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContactEmail, Contact>(query);
+               SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       }
+
+       return pContacts;
+}
+
+IList*
+_AddressbookManagerImpl::SearchContactsByNameN(const String& name) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       IList* pContacts = null;
+
+       unique_ptr< __Filter<__ContactsContact> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContact>());
+
+       SysTryReturn(NID_SCL, !name.IsEmpty(), null, E_INVALID_ARG, "[%s] Invalid argument is used. The specified email is an name string.", GetErrorMessage(E_INVALID_ARG));
+
+       unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(name));
+       SysTryReturn(NID_SCL, pCharArray != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __Filter<__ContactsContact> nameFilter;
+       nameFilter.Construct();
+       nameFilter.AddString(_contacts_contact.display_name, CONTACTS_MATCH_CONTAINS, pCharArray.get());
+
+       if (pRwAbFilter->Get() != null)
+       {
+               __Filter<__ContactsContact> mainFilter;
+               mainFilter.Construct();
+
+               mainFilter.AddFilter(*pRwAbFilter);
+               mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+               mainFilter.AddFilter(nameFilter);
+
+               __Query<__ContactsContact> query;
+               query.Construct();
+               query.SetFilter(mainFilter);
+               query.SetSort(_contacts_contact.display_name, true);
+
+               pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContact, Contact>(query);
+               SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       }
+       else
+       {
+               __Query<__ContactsContact> query;
+               query.Construct();
+               query.SetFilter(nameFilter);
+               query.SetSort(_contacts_contact.display_name, true);
+
+               pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContact, Contact>(query);
+               SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       }
+
+       return pContacts;
+}
+
+IList*
+_AddressbookManagerImpl::SearchContactsByPhoneNumberN(const String& phoneNumber) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       IList* pContacts = null;
+
+       SysTryReturn(NID_SCL, !phoneNumber.IsEmpty(), null, E_INVALID_ARG, "[%s] Invalid argument is used. The specified phoneNumber is an empty string.", GetErrorMessage(E_INVALID_ARG));
+
+       unique_ptr< __Filter<__ContactsContactNumber> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContactNumber>());
+
+       unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(phoneNumber));
+       SysTryReturn(NID_SCL, pCharArray != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __Filter<__ContactsContactNumber> numberFilter;
+       numberFilter.Construct();
+       numberFilter.AddString(_contacts_contact_number.normalized_number, CONTACTS_MATCH_CONTAINS, pCharArray.get());
+       numberFilter.AddOperator(CONTACTS_FILTER_OPERATOR_OR);
+       numberFilter.AddString(_contacts_contact_number.number, CONTACTS_MATCH_CONTAINS, pCharArray.get());
+
+       if (pRwAbFilter->Get() != null)
+       {
+               __Filter<__ContactsContactNumber> mainFilter;
+               mainFilter.Construct();
+
+               mainFilter.AddFilter(*pRwAbFilter);
+               mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+               mainFilter.AddFilter(numberFilter);
+
+               __Query<__ContactsContactNumber> query;
+               query.Construct();
+               query.SetFilter(mainFilter);
+               query.SetDistinct(true);
+               query.SetSort(_contacts_contact_number.display_name, true);
+
+               pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContactNumber, Contact>(query);
+               SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       }
+       else
+       {
+               __Query<__ContactsContactNumber> query;
+               query.Construct();
+               query.SetFilter(numberFilter);
+               query.SetDistinct(true);
+               query.SetSort(_contacts_contact_number.display_name, true);
+
+               pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContactNumber, Contact>(query);
+               SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       }
+
+
+       return pContacts;
+}
+
+int
+_AddressbookManagerImpl::GetCategoryCount(void) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       unique_ptr< __Filter<__ContactsGroup> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsGroup>());
+
+       int count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsGroup>(pRwAbFilter->Get());
+       SysTryReturn(NID_SCL, count >= 0, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return count;
+}
+
+int
+_AddressbookManagerImpl::GetContactCount(void) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       unique_ptr< __Filter<__ContactsContact> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContact>());
+
+       int count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsContact>(pRwAbFilter->Get());
+       SysTryReturn(NID_SCL, count >= 0, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return count;
+}
+
+Contact*
+_AddressbookManagerImpl::GetContactN(RecordId contactId) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, null, E_INVALID_ARG, "[%s] Invalid argument is used. contactId = %d.", GetErrorMessage(E_INVALID_ARG), contactId);
+
+       ClearLastResult();
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pContactRecord(_AddressbookUtil::GetContactRecordN(_contacts_contact._uri, contactId));
+       SysTryReturn(NID_SCL, pContactRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int intValue = 0;
+       contacts_record_get_int(pContactRecord.get(), _contacts_contact.address_book_id, &intValue);
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pAbRecord(_AddressbookUtil::GetContactRecordN(_contacts_address_book._uri, intValue));
+       SysTryReturn(NID_SCL, pAbRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       contacts_record_get_int(pAbRecord.get(), _contacts_address_book.mode, &intValue);
+       SysTryReturn(NID_SCL, intValue == 0, null, E_OBJ_NOT_FOUND, "[%s] Contact does not exist.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       contacts_record_get_int(pContactRecord.get(), _contacts_contact.id, &intValue);
+       SysTryReturn(NID_SCL, intValue == contactId, null, E_OBJ_NOT_FOUND, "[%s] The contact is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       unique_ptr<Contact> pContact(new (std::nothrow) Contact());
+       SysTryReturn(NID_SCL, pContact, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       _ContactImpl::GetInstance(*pContact)->SetContactRecordHandle(pContactRecord.release());
+       _RecordImpl::GetInstance(*pContact)->SetRecordId(intValue);
+
+       return pContact.release();
+}
+
+Person*
+_AddressbookManagerImpl::GetPersonN(PersonId personId) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       SysTryReturn(NID_SCL, personId >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. personId = %d.", GetErrorMessage(E_INVALID_ARG), personId);
+
+       ClearLastResult();
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pPersonRecord(_AddressbookUtil::GetContactRecordN(_contacts_person._uri, personId));
+
+       int intValue = 0;
+       contacts_record_get_int(pPersonRecord.get(), _contacts_person.id, &intValue);
+       SysTryReturn(NID_SCL, intValue == personId, null, E_OBJ_NOT_FOUND, "[%s] The person is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       Person* pPerson = __ContactsPerson::ConvertHandleTo<Person>(pPersonRecord.get());
+       SysTryReturn(NID_SCL, pPerson != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pPerson;
+}
+
+Category*
+_AddressbookManagerImpl::GetCategoryN(RecordId categoryId) const
+{
+       SysTryReturn(NID_SCL, categoryId != INVALID_RECORD_ID, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. categoryId = %d.", categoryId);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pCategoryRecord(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, categoryId));
+       SysTryReturn(NID_SCL, pCategoryRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int intValue = 0;
+
+       contacts_record_get_int(pCategoryRecord.get(), _contacts_group.id, &intValue);
+       SysTryReturn(NID_SCL, categoryId == intValue, null, E_OBJ_NOT_FOUND, "[%s] The category is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       contacts_record_get_int(pCategoryRecord.get(), _contacts_group.address_book_id, &intValue);
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pAbRecord(_AddressbookUtil::GetContactRecordN(_contacts_address_book._uri, intValue));
+       SysTryReturn(NID_SCL, pAbRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       contacts_record_get_int(pAbRecord.get(), _contacts_address_book.mode, &intValue);
+       SysTryReturn(NID_SCL, intValue == 0, null, E_OBJ_NOT_FOUND, "[%s] Category does not exist.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       unique_ptr<Category> pCategory(new (std::nothrow) Category());
+       SysTryReturn(NID_SCL, pCategory != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __Filter<__ContactsGroupRelation> filter;
+       filter.Construct();
+       filter.AddInt(_contacts_group_relation.group_id, CONTACTS_MATCH_EQUAL, categoryId);
+
+       __Query<__ContactsGroupRelation> query;
+       query.Construct();
+       query.SetFilter(filter);
+
+       int count = _AddressbookUtil::GetCountWithQuery(query);
+       SysTryReturn(NID_SCL, count >= 0, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       _CategoryImpl::GetInstance(*pCategory)->SetRecordHandle(pCategoryRecord.release());
+       _CategoryImpl::GetInstance(*pCategory)->SetMemberCount(count);
+       _RecordImpl::GetInstance(*pCategory)->SetRecordId(categoryId);
+
+       return pCategory.release();
+}
+
+int
+_AddressbookManagerImpl::GetLatestVersion(void) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int latestVersion = -1;
+
+       ClearLastResult();
+
+       int ret = contacts_db_get_current_version(&latestVersion);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, -1, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return latestVersion;
+}
+
+IList*
+_AddressbookManagerImpl::GetChangedContactsAfterN(int version, int& latestVersion) const
+{
+       SysTryReturn(NID_SCL, version >= 0, null, E_INVALID_ARG, "[%s] Invalid arguent is used. version %d must be greater that or equal 0.", GetErrorMessage(E_INVALID_ARG), version);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       unique_ptr< IListT<AddressbookId> > pRwAbIdList(_AddressbookUtil::GetRwAbIdListN());
+
+       IList* pChangedContacts = _AddressbookUtil::SearchWithVersionN<__ContactsContactUpdatedInfo, ContactChangeInfo>(-1, version, latestVersion, pRwAbIdList.get());
+       SysTryReturn(NID_SCL, pChangedContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pChangedContacts;
+}
+
+IList*
+_AddressbookManagerImpl::GetChangedCategoriesAfterN(int version, int& latestVersion) const
+{
+       SysTryReturn(NID_SCL, version >= 0, null, E_INVALID_ARG, "[%s] Invalid arguemnt is used. version %d must be greater that or equal 0.", GetErrorMessage(E_INVALID_ARG), version);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       int latestVersion1 = 0;
+       int latestVersion2 = 0;
+
+       unique_ptr< IListT<AddressbookId> > pRwAbIdList(_AddressbookUtil::GetRwAbIdListN());
+
+       unique_ptr<IList, AllElementsDeleter> pChangedGroups(_AddressbookUtil::SearchWithVersionN<__ContactsGroupUpdatedInfo, CategoryChangeInfo>(-1, version, latestVersion1, pRwAbIdList.get()));
+       SysTryReturn(NID_SCL, pChangedGroups != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       unique_ptr<IList, AllElementsDeleter> pChangedRelations(_AddressbookUtil::SearchWithVersionN<__ContactsGroupRelUpdatedInfo, CategoryChangeInfo>(-1, version, latestVersion2, pRwAbIdList.get()));
+       SysTryReturn(NID_SCL, pChangedRelations != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       unique_ptr<ArrayList, AllElementsDeleter> pChangeList(new (std::nothrow) Tizen::Base::Collection::ArrayList());
+       SysTryReturn(NID_SCL, pChangeList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pChangeList->AddItems(*pChangedGroups);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = pChangeList->AddItems(*pChangedRelations);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pChangedGroups->RemoveAll(false);
+       pChangedRelations->RemoveAll(false);
+
+       latestVersion = latestVersion2 > latestVersion1 ? latestVersion2 : latestVersion1;
+
+       return pChangeList.release();
+}
+
+IList*
+_AddressbookManagerImpl::GetChangedGroupsAfterN(int version, int& latestVersion) const
+{
+       SysTryReturn(NID_SCL, version >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. version %d must be greater that or equal 0.", GetErrorMessage(E_INVALID_ARG), version);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       unique_ptr< IListT<AddressbookId> > pRwAbIdList(_AddressbookUtil::GetRwAbIdListN());
+
+       IList* pChangedRelations = _AddressbookUtil::SearchWithVersionN<__ContactsGroupUpdatedInfo, CategoryChangeInfo>(-1, version, latestVersion, pRwAbIdList.get());
+       SysTryReturn(NID_SCL, pChangedRelations != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pChangedRelations;
+}
+
+IList*
+_AddressbookManagerImpl::GetChangedRelationsAfterN(int version, int& latestVersion) const
+{
+       SysTryReturn(NID_SCL, version >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. version %d must be greater that or equal 0.", GetErrorMessage(E_INVALID_ARG), version);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       unique_ptr< IListT<AddressbookId> > pRwAbIdList(_AddressbookUtil::GetRwAbIdListN());
+
+       IList* pChangedRelations = _AddressbookUtil::SearchWithVersionN<__ContactsGroupRelUpdatedInfo, CategoryChangeInfo>(-1, version, latestVersion, pRwAbIdList.get());
+       SysTryReturn(NID_SCL, pChangedRelations != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pChangedRelations;
+}
+
+void
+_AddressbookManagerImpl::OnContactChanged(void)
+{
+       if (__pIAddressbookChangeEventListener == null && __pIAddressbookEventListener == null)
+       {
+               return;
+       }
+
+       IList* pChangedContactList = GetChangedContactsAfterN(__dbVersionForContact, __dbVersionForContact);
+       SysTryReturnVoidResult(NID_SCL, pChangedContactList != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       if (pChangedContactList->GetCount() > 0)
+       {
+               if (__pIAddressbookChangeEventListener != null)
+               {
+                       __pIAddressbookChangeEventListener->OnContactsChanged(*pChangedContactList);
+               }
+               else
+               {
+                       __pIAddressbookEventListener->OnContactsChanged(*pChangedContactList);
+               }
+       }
+
+       pChangedContactList->RemoveAll(true);
+       delete pChangedContactList;
+}
+
+void
+_AddressbookManagerImpl::OnCategoryChanged(void)
+{
+       if (__pIAddressbookChangeEventListener == null && __pIAddressbookEventListener == null)
+       {
+               return;
+       }
+
+       IList* pChangedCategoryList = GetChangedGroupsAfterN(__dbVersionForGroup, __dbVersionForGroup);
+       SysTryReturnVoidResult(NID_SCL, pChangedCategoryList != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       if (pChangedCategoryList->GetCount() > 0)
+       {
+               if (__pIAddressbookChangeEventListener != null)
+               {
+                       __pIAddressbookChangeEventListener->OnCategoriesChanged(*pChangedCategoryList);
+               }
+               else
+               {
+                       __pIAddressbookEventListener->OnCategoriesChanged(*pChangedCategoryList);
+               }
+       }
+
+       pChangedCategoryList->RemoveAll(true);
+       delete pChangedCategoryList;
+}
+
+void
+_AddressbookManagerImpl::OnRelationChanged(void)
+{
+       if (__pIAddressbookEventListener == null)
+       {
+               return;
+       }
+
+       IList* pChangedCategoryList = GetChangedRelationsAfterN(__dbVersionForRelation, __dbVersionForRelation);
+       SysTryReturnVoidResult(NID_SCL, pChangedCategoryList != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       if (pChangedCategoryList->GetCount() > 0)
+       {
+               if (__pIAddressbookEventListener != null)
+               {
+                       __pIAddressbookEventListener->OnCategoriesChanged(*pChangedCategoryList);
+               }
+       }
+
+       pChangedCategoryList->RemoveAll(true);
+       delete pChangedCategoryList;
+}
+
+result
+_AddressbookManagerImpl::RemovePerson(PersonId personId)
+{
+       SysTryReturnResult(NID_SCL, personId > 0, E_INVALID_ARG, "[%s] Invalid argument is used. ", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       result r = _AddressbookUtil::DeleteContactRecord(_contacts_person._uri, personId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+IList*
+_AddressbookManagerImpl::GetAllPersonsN(void) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       unique_ptr< __Filter<__ContactsPersonGroupRel> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsPersonGroupRel>());
+
+       unsigned int propertyIds[] =
+       {
+               _contacts_person_grouprel.person_id,
+               _contacts_person_grouprel.display_name,
+               _contacts_person_grouprel.image_thumbnail_path,
+               _contacts_person_grouprel.ringtone_path,
+               _contacts_person_grouprel.is_favorite,
+               _contacts_person_grouprel.has_phonenumber,
+               _contacts_person_grouprel.has_email,
+               _contacts_person_grouprel.addressbook_ids,
+       };
+
+
+       __Query<__ContactsPersonGroupRel> query;
+       query.Construct();
+       query.SetSort(_contacts_person.display_name, true);
+       query.SetProjection(propertyIds, sizeof(propertyIds)/sizeof(unsigned int));
+       query.SetDistinct(true);
+
+       if (pRwAbFilter->Get() != null)
+       {
+               query.SetFilter(*pRwAbFilter);
+       }
+
+       IList* pPersons = _AddressbookUtil::SearchWithQueryN<__ContactsPersonGroupRel, Person>(query);
+       SysTryReturn(NID_SCL, pPersons != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pPersons;
+}
+
+IList*
+_AddressbookManagerImpl::GetPersonsByCategoryN(RecordId categoryId) const
+{
+       SysTryReturn(NID_SCL, categoryId >= INVALID_RECORD_ID, null, E_INVALID_ARG, "[%s] Invalid argument is used. The specified categoryId is less than INVALID_RECORD_ID.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       if (categoryId > INVALID_RECORD_ID)
+       {
+               unique_ptr<ContactRecord, ContactRecordDeleter> pCategoryRecord(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, categoryId));
+               SysTryReturn(NID_SCL, GetLastResult() != E_OBJ_NOT_FOUND, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+               SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, null, E_SYSTEM, "[%s] An system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       }
+
+       IList* pPersons = null;
+
+       unique_ptr< __Filter<__ContactsPersonGroupRel> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsPersonGroupRel>());
+
+       __Filter<__ContactsPersonGroupRel> groupFilter;
+       groupFilter.Construct();
+       if (categoryId != INVALID_RECORD_ID)
+       {
+               groupFilter.AddInt(_contacts_person_grouprel.group_id, CONTACTS_MATCH_EQUAL, categoryId);
+       }
+       else
+       {
+               groupFilter.AddInt(_contacts_person_grouprel.group_id, CONTACTS_MATCH_NONE, 0);
+       }
+
+       unsigned int propertyIds[] =
+       {
+               _contacts_person_grouprel.person_id,
+               _contacts_person_grouprel.display_name,
+               _contacts_person_grouprel.image_thumbnail_path,
+               _contacts_person_grouprel.ringtone_path,
+               _contacts_person_grouprel.is_favorite,
+               _contacts_person_grouprel.has_phonenumber,
+               _contacts_person_grouprel.has_email,
+               _contacts_person_grouprel.addressbook_ids,
+       };
+
+       if (pRwAbFilter->Get() != null)
+       {
+               __Filter<__ContactsPersonGroupRel> mainFilter;
+               mainFilter.Construct();
+
+               mainFilter.AddFilter(*pRwAbFilter);
+               mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+               mainFilter.AddFilter(groupFilter);
+
+               __Query<__ContactsPersonGroupRel> query;
+               query.Construct();
+               query.SetProjection(propertyIds, sizeof(propertyIds)/sizeof(unsigned int));
+               query.SetFilter(mainFilter);
+               query.SetSort(_contacts_person_grouprel.display_name, true);
+               query.SetDistinct(true);
+
+               pPersons = _AddressbookUtil::SearchWithQueryN<__ContactsPersonGroupRel, Person>(query);
+               SysTryReturn(NID_SCL, pPersons != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       }
+       else
+       {
+               __Query<__ContactsPersonGroupRel> query;
+               query.Construct();
+               query.SetProjection(propertyIds, sizeof(propertyIds)/sizeof(unsigned int));
+               query.SetFilter(groupFilter);
+               query.SetSort(_contacts_person_grouprel.display_name, true);
+               query.SetDistinct(true);
+
+               pPersons = _AddressbookUtil::SearchWithQueryN<__ContactsPersonGroupRel, Person>(query);
+               SysTryReturn(NID_SCL, pPersons != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       }
+
+       return pPersons;
+}
+
+IList*
+_AddressbookManagerImpl::GetFavoritePersonsN() const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       __Filter<__ContactsPerson> filter;
+       filter.Construct();
+       filter.AddBool(_contacts_person.is_favorite, true);
+
+       __Query<__ContactsPerson> query;
+       query.Construct();
+       query.SetFilter(filter);
+       query.SetSort(_contacts_person.display_name, true);
+
+       IList* pPersons = _AddressbookUtil::SearchWithQueryN<__ContactsPerson, Person>(query);
+       SysTryReturn(NID_SCL, pPersons != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pPersons;
+}
+
+IList*
+_AddressbookManagerImpl::SearchPersonsN(const Tizen::Base::String& keyword) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       SysTryReturn(NID_SCL, !keyword.IsEmpty(), null, E_INVALID_ARG, "Invalid argument is used. keyword is empty string.", GetErrorMessage(E_INVALID_ARG));
+
+       ClearLastResult();
+
+       contacts_record_h currentRecord = null;
+       unique_ptr<Person> pPerson(null);
+
+       unique_ptr<ArrayList, AllElementsDeleter> pPersonList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pPersonList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pPersonList->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unique_ptr<__SearchResult<__ContactsPerson> > pSearchResult(_AddressbookUtil::Search<__ContactsPerson>(keyword));
+       SysTryReturn(NID_SCL, pSearchResult != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       while (pSearchResult->MoveNext() == E_SUCCESS)
+       {
+               currentRecord = pSearchResult->GetCurrentRecord();
+               SysTryReturn(NID_SCL, currentRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+               pPerson.reset(__ContactsPerson::ConvertHandleTo<Person>(currentRecord));
+               SysTryReturn(NID_SCL, pPerson != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pPersonList->Add(*pPerson);
+               SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               pPerson.release();
+       }
+
+       return pPersonList.release();
+}
+
+result
+_AddressbookManagerImpl::SetPersonAsFavorite(PersonId personId, bool isFavorite)
+{
+       SysTryReturn(NID_SCL, personId > 0, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. personId = %d.", GetErrorMessage(E_INVALID_ARG), personId);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pPersonRecord(_AddressbookUtil::GetContactRecordN(_contacts_person._uri, personId));
+       SysTryReturn(NID_SCL, pPersonRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       bool boolValue = false;
+       contacts_record_get_bool(pPersonRecord.get(), _contacts_person.is_favorite, &boolValue);
+
+       if (boolValue != isFavorite)
+       {
+               contacts_record_set_bool(pPersonRecord.get(), _contacts_person.is_favorite, isFavorite);
+
+               result r = _AddressbookUtil::UpdateContactRecord(pPersonRecord.get());
+               SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookManagerImpl::MergePersons(PersonId sourcePersonId, PersonId targetPersonId)
+{
+       SysTryReturn(NID_SCL, sourcePersonId > 0 && targetPersonId > 0, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. sourcePersonId %d and targetPersonId must be greater than 0.", GetErrorMessage(E_INVALID_ARG), sourcePersonId, targetPersonId);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int ret = contacts_person_link_person(targetPersonId, sourcePersonId);
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookManagerImpl::UnlinkContact(PersonId personId, RecordId contactId, PersonId& newPersonId)
+{
+       SysTryReturn(NID_SCL, personId > 0 && contactId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. personId %d must be greater thant 0 and contactId %d must not be INVALID_RECORD_ID.", GetErrorMessage(E_INVALID_ARG), personId, contactId);
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int ret = contacts_person_unlink_contact(personId, contactId, &newPersonId);
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return E_SUCCESS;
+}
+
+IList*
+_AddressbookManagerImpl::SearchN(const AddressbookFilter& filter, unsigned long propertySortedBy, SortOrder sortOrder, int offset, int maxCount)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       IList* pList = null;
+       bool ascending = false;
+       unsigned int viewSortPropertyId = 0;
+
+       AddressbookFilterType type = _AddressbookFilterImpl::GetInstance(filter)->GetType();
+       contacts_filter_h filterHandle = _AddressbookFilterImpl::GetInstance(filter)->GetFilterHandle();
+
+       SysTryReturn(NID_SCL, propertySortedBy == 0 || _AddressbookFilterImpl::IsValidProperty(type, propertySortedBy), null, E_INVALID_ARG, "[%s] Invalid argument is used. The protertyToSort %d can not be used for property for sorting.", GetErrorMessage(E_INVALID_ARG), propertySortedBy);
+
+       if (propertySortedBy != 0 && sortOrder != SORT_ORDER_NONE)
+       {
+               viewSortPropertyId = _AddressbookFilterImpl::GetViewPropertyId(type, propertySortedBy);
+               ascending = (sortOrder == SORT_ORDER_ASCENDING) ? true : false;
+       }
+
+       switch(type)
+       {
+       case AB_FI_TYPE_ADDRESSBOOK:
+               {
+                       unique_ptr< __Filter<__ContactsAddressbook> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsAddressbook>());
+
+                       __Filter<__ContactsAddressbook> abFilter;
+                       abFilter.Construct(filterHandle);
+
+                       if (pRwAbFilter->Get() != null)
+                       {
+                               __Filter<__ContactsAddressbook> mainFilter;
+                               mainFilter.Construct();
+                               mainFilter.AddFilter(*pRwAbFilter);
+                               if (abFilter.Get() != null)
+                               {
+                                       mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+                                       mainFilter.AddFilter(abFilter);
+                               }
+
+                               __Query<__ContactsAddressbook> query;
+                               query.Construct();
+                               query.SetFilter(mainFilter);
+
+                               if (viewSortPropertyId != 0)
+                               {
+                                       query.SetSort(viewSortPropertyId, ascending);
+                               }
+
+                               pList = _AddressbookUtil::SearchWithQueryN<__ContactsAddressbook, Addressbook>(query, offset, maxCount);
+                       }
+                       else
+                       {
+                               __Query<__ContactsAddressbook> query;
+                               query.Construct();
+                               query.SetFilter(abFilter);
+
+                               if (viewSortPropertyId != 0)
+                               {
+                                       query.SetSort(viewSortPropertyId, ascending);
+                               }
+
+                               pList = _AddressbookUtil::SearchWithQueryN<__ContactsAddressbook, Addressbook>(query, offset, maxCount);
+
+                       }
+               }
+               break;
+       case AB_FI_TYPE_PERSON:
+               {
+                       unique_ptr< __Filter<__ContactsPersonGroupRel> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsPersonGroupRel>());
+
+                       __Filter<__ContactsPersonGroupRel> personFilter;
+                       personFilter.Construct(filterHandle);
+
+                       unsigned int propertyIds[] =
+                       { _contacts_person_grouprel.person_id,
+                               _contacts_person_grouprel.addressbook_ids,
+                               _contacts_person_grouprel.is_favorite,
+                               _contacts_person_grouprel.has_phonenumber,
+                               _contacts_person_grouprel.has_email,
+                               _contacts_person_grouprel.image_thumbnail_path,
+                               _contacts_person_grouprel.ringtone_path,
+                               _contacts_person_grouprel.display_name
+                       };
+
+                       if (pRwAbFilter->Get() != null)
+                       {
+                               __Filter<__ContactsPersonGroupRel> mainFilter;
+                               mainFilter.Construct();
+                               mainFilter.AddFilter(*pRwAbFilter);
+                               if (personFilter.Get() != null)
+                               {
+                                       mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+                                       mainFilter.AddFilter(personFilter);
+                               }
+
+                               __Query<__ContactsPersonGroupRel> query;
+                               query.Construct();
+                               query.SetFilter(mainFilter);
+                               query.SetProjection(propertyIds, sizeof(propertyIds)/sizeof(unsigned int));
+                               query.SetDistinct(true);
+
+                               if (viewSortPropertyId != 0)
+                               {
+                                       query.SetSort(viewSortPropertyId, ascending);
+                               }
+
+                               pList = _AddressbookUtil::SearchWithQueryN<__ContactsPersonGroupRel, Person>(query, offset, maxCount);
+                       }
+                       else
+                       {
+                               __Query<__ContactsPersonGroupRel> query;
+                               query.Construct();
+                               query.SetFilter(personFilter);
+                               query.SetProjection(propertyIds, sizeof(propertyIds)/sizeof(unsigned int));
+                               query.SetDistinct(true);
+
+                               if (viewSortPropertyId != 0)
+                               {
+                                       query.SetSort(viewSortPropertyId, ascending);
+                               }
+
+                               pList = _AddressbookUtil::SearchWithQueryN<__ContactsPersonGroupRel, Person>(query, offset, maxCount);
+                       }
+               }
+               break;
+       case AB_FI_TYPE_CONTACT:
+               {
+                       unique_ptr< __Filter<__ContactsContact> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContact>());
+
+                       __Filter<__ContactsContact> contactFilter;
+                       contactFilter.Construct(filterHandle);
+
+                       if (pRwAbFilter->Get() != null)
+                       {
+                               __Filter<__ContactsContact> mainFilter;
+                               mainFilter.Construct();
+                               mainFilter.AddFilter(*pRwAbFilter);
+                               if (contactFilter.Get() != null)
+                               {
+                                       mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+                                       mainFilter.AddFilter(contactFilter);
+                               }
+
+                               __Query<__ContactsContact> query;
+                               query.Construct();
+                               query.SetFilter(mainFilter);
+
+                               if (viewSortPropertyId != 0)
+                               {
+                                       query.SetSort(viewSortPropertyId, ascending);
+                               }
+
+                               pList = _AddressbookUtil::SearchWithQueryN<__ContactsContact, Contact>(query, offset, maxCount);
+                       }
+                       else
+                       {
+                               __Query<__ContactsContact> query;
+                               query.Construct();
+                               query.SetFilter(contactFilter);
+
+                               if (viewSortPropertyId != 0)
+                               {
+                                       query.SetSort(viewSortPropertyId, ascending);
+                               }
+
+                               pList = _AddressbookUtil::SearchWithQueryN<__ContactsContact, Contact>(query, offset, maxCount);
+
+                       }
+               }
+               break;
+       case AB_FI_TYPE_CATEGORY:
+               {
+                       unique_ptr< __Filter<__ContactsGroup> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsGroup>());
+
+                       __Filter<__ContactsGroup> groupFilter;
+                       groupFilter.Construct(filterHandle);
+
+                       if (pRwAbFilter->Get() != null)
+                       {
+                               __Filter<__ContactsGroup> mainFilter;
+                               mainFilter.Construct();
+                               mainFilter.AddFilter(*pRwAbFilter);
+                               if (groupFilter.Get() != null)
+                               {
+                                       mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+                                       mainFilter.AddFilter(groupFilter);
+                               }
+
+                               __Query<__ContactsGroup> query;
+                               query.Construct();
+                               query.SetFilter(mainFilter);
+
+                               if (viewSortPropertyId != 0)
+                               {
+                                       query.SetSort(viewSortPropertyId, ascending);
+                               }
+
+                               pList = _AddressbookUtil::SearchWithQueryN<__ContactsGroup, Category>(query, offset, maxCount);
+                       }
+                       else
+                       {
+                               __Query<__ContactsGroup> query;
+                               query.Construct();
+                               query.SetFilter(groupFilter);
+
+                               if (viewSortPropertyId != 0)
+                               {
+                                       query.SetSort(viewSortPropertyId, ascending);
+                               }
+
+                               pList = _AddressbookUtil::SearchWithQueryN<__ContactsGroup, Category>(query, offset, maxCount);
+                       }
+               }
+               break;
+       case AB_FI_TYPE_PHONE_CONTACT:
+               {
+                       unique_ptr< __Filter<__ContactsContactNumber> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContactNumber>());
+
+                       __Filter<__ContactsContactNumber> numberFilter;
+                       numberFilter.Construct(filterHandle);
+
+                       if (pRwAbFilter->Get() != null)
+                       {
+                               __Filter<__ContactsContactNumber> mainFilter;
+                               mainFilter.Construct();
+                               mainFilter.AddFilter(*pRwAbFilter);
+                               if (numberFilter.Get() != null)
+                               {
+                                       mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+                                       mainFilter.AddFilter(numberFilter);
+                               }
+
+                               __Query<__ContactsContactNumber> query;
+                               query.Construct();
+                               query.SetFilter(mainFilter);
+
+                               if (viewSortPropertyId != 0)
+                               {
+                                       query.SetSort(viewSortPropertyId, ascending);
+                               }
+
+                               pList = _AddressbookUtil::SearchWithQueryN<__ContactsContactNumber, PhoneNumberContact>(query, offset, maxCount);
+                       }
+                       else
+                       {
+                               __Query<__ContactsContactNumber> query;
+                               query.Construct();
+                               query.SetFilter(numberFilter);
+
+                               if (viewSortPropertyId != 0)
+                               {
+                                       query.SetSort(viewSortPropertyId, ascending);
+                               }
+
+                               pList = _AddressbookUtil::SearchWithQueryN<__ContactsContactNumber, PhoneNumberContact>(query, offset, maxCount);
+                       }
+               }
+               break;
+       case AB_FI_TYPE_EMAIL_CONTACT:
+               {
+                       unique_ptr< __Filter<__ContactsContactEmail> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContactEmail>());
+
+                       __Filter<__ContactsContactEmail> emailFilter;
+                       emailFilter.Construct(filterHandle);
+
+                       if (pRwAbFilter->Get() != null)
+                       {
+                               __Filter<__ContactsContactEmail> mainFilter;
+                               mainFilter.Construct();
+                               mainFilter.AddFilter(*pRwAbFilter);
+                               if (emailFilter.Get() != null)
+                               {
+                                       mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+                                       mainFilter.AddFilter(emailFilter);
+                               }
+
+                               __Query<__ContactsContactEmail> query;
+                               query.Construct();
+                               query.SetFilter(mainFilter);
+
+                               if (viewSortPropertyId != 0)
+                               {
+                                       query.SetSort(viewSortPropertyId, ascending);
+                               }
+
+                               pList = _AddressbookUtil::SearchWithQueryN<__ContactsContactEmail, EmailContact>(query, offset, maxCount);
+                       }
+                       else
+                       {
+                               __Query<__ContactsContactEmail> query;
+                               query.Construct();
+                               query.SetFilter(emailFilter);
+
+                               if (viewSortPropertyId != 0)
+                               {
+                                       query.SetSort(viewSortPropertyId, ascending);
+                               }
+
+                               pList = _AddressbookUtil::SearchWithQueryN<__ContactsContactEmail, EmailContact>(query, offset, maxCount);
+                       }
+               }
+               break;
+       default:
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. The filter type is invalid", GetErrorMessage(E_INVALID_ARG));
+               pList = null;
+               break;
+       };
+
+       return pList;
+}
+
+int
+_AddressbookManagerImpl::GetMatchedItemCount(const AddressbookFilter& filter)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       int count = 0;
+       AddressbookFilterType type = _AddressbookFilterImpl::GetInstance(filter)->GetType();
+       contacts_filter_h filterHandle = _AddressbookFilterImpl::GetInstance(filter)->GetFilterHandle();
+
+       switch(type)
+       {
+       case AB_FI_TYPE_ADDRESSBOOK:
+               {
+                       unique_ptr< __Filter<__ContactsAddressbook> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsAddressbook>());
+
+                       __Filter<__ContactsAddressbook> abFilter;
+                       abFilter.Construct(filterHandle);
+
+                       if (pRwAbFilter->Get() != null)
+                       {
+                               __Filter<__ContactsAddressbook> mainFilter;
+                               mainFilter.Construct();
+                               mainFilter.AddFilter(*pRwAbFilter);
+                               if (abFilter.Get() != null)
+                               {
+                                       mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+                                       mainFilter.AddFilter(abFilter);
+                               }
+
+                               count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsAddressbook>(mainFilter.Get());
+                       }
+                       else
+                       {
+                               count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsAddressbook>(abFilter.Get());
+                       }
+               }
+               break;
+       case AB_FI_TYPE_PERSON:
+               {
+                       unique_ptr< __Filter<__ContactsPersonGroupRel> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsPersonGroupRel>());
+
+                       __Filter<__ContactsPersonGroupRel> personFilter;
+                       personFilter.Construct(filterHandle);
+
+                       if (pRwAbFilter->Get() != null)
+                       {
+                               __Filter<__ContactsPersonGroupRel> mainFilter;
+                               mainFilter.Construct();
+                               mainFilter.AddFilter(*pRwAbFilter);
+                               if (personFilter.Get() != null)
+                               {
+                                       mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+                                       mainFilter.AddFilter(personFilter);
+                               }
+
+                               unsigned int propertyIds[] = { _contacts_person_grouprel.person_id };
+
+                               __Query<__ContactsPersonGroupRel> query;
+                               query.Construct();
+                               query.SetFilter(mainFilter);
+                               query.SetProjection(propertyIds, sizeof(propertyIds)/sizeof(unsigned int));
+                               query.SetDistinct(true);
+
+                               count = _AddressbookUtil::GetCountWithQuery(query);
+                       }
+                       else
+                       {
+                               unsigned int propertyIds[] = { _contacts_person_grouprel.person_id };
+
+                               __Query<__ContactsPersonGroupRel> query;
+                               query.Construct();
+                               query.SetFilter(personFilter);
+                               query.SetProjection(propertyIds, sizeof(propertyIds)/sizeof(unsigned int));
+                               query.SetDistinct(true);
+
+                               count = _AddressbookUtil::GetCountWithQuery(query);
+
+                       }
+               }
+
+               break;
+       case AB_FI_TYPE_CONTACT:
+               {
+                       unique_ptr< __Filter<__ContactsContact> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContact>());
+
+                       __Filter<__ContactsContact> contactFilter;
+                       contactFilter.Construct(filterHandle);
+
+                       if (pRwAbFilter->Get() != null)
+                       {
+                               __Filter<__ContactsContact> mainFilter;
+                               mainFilter.Construct();
+                               mainFilter.AddFilter(*pRwAbFilter);
+                               if (contactFilter.Get() != null)
+                               {
+                                       mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+                                       mainFilter.AddFilter(contactFilter);
+                               }
+
+                               count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsContact>(mainFilter.Get());
+                       }
+                       else
+                       {
+                               count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsContact>(contactFilter.Get());
+                       }
+               }
+               break;
+       case AB_FI_TYPE_CATEGORY:
+               {
+                       unique_ptr< __Filter<__ContactsGroup> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsGroup>());
+
+                       __Filter<__ContactsGroup> groupFilter;
+                       groupFilter.Construct(filterHandle);
+
+                       if (pRwAbFilter->Get() != null)
+                       {
+                               __Filter<__ContactsGroup> mainFilter;
+                               mainFilter.Construct();
+                               mainFilter.AddFilter(*pRwAbFilter);
+                               if (groupFilter.Get() != null)
+                               {
+                                       mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+                                       mainFilter.AddFilter(groupFilter);
+                               }
+
+                               count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsGroup>(mainFilter.Get());
+                       }
+                       else
+                       {
+                               count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsGroup>(groupFilter.Get());
+                       }
+               }
+               break;
+       case AB_FI_TYPE_PHONE_CONTACT:
+               {
+                       unique_ptr< __Filter<__ContactsContactNumber> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContactNumber>());
+
+                       __Filter<__ContactsContactNumber> numberFilter;
+                       numberFilter.Construct(filterHandle);
+
+                       if (pRwAbFilter->Get() != null)
+                       {
+                               __Filter<__ContactsContactNumber> mainFilter;
+                               mainFilter.Construct();
+                               mainFilter.AddFilter(*pRwAbFilter);
+                               if (numberFilter.Get() != null)
+                               {
+                                       mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+                                       mainFilter.AddFilter(numberFilter);
+                               }
+
+                               count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsContactNumber>(mainFilter.Get());
+                       }
+                       else
+                       {
+                               count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsContactNumber>(numberFilter.Get());
+                       }
+               }
+               break;
+       case AB_FI_TYPE_EMAIL_CONTACT:
+               {
+                       unique_ptr< __Filter<__ContactsContactEmail> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContactEmail>());
+
+                       __Filter<__ContactsContactEmail> emailFilter;
+                       emailFilter.Construct(filterHandle);
+
+                       if (pRwAbFilter->Get() != null)
+                       {
+                               __Filter<__ContactsContactEmail> mainFilter;
+                               mainFilter.Construct();
+                               mainFilter.AddFilter(*pRwAbFilter);
+                               if (emailFilter.Get() != null)
+                               {
+                                       mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+                                       mainFilter.AddFilter(emailFilter);
+                               }
+
+                               count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsContactEmail>(mainFilter.Get());
+                       }
+                       else
+                       {
+                               count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsContactEmail>(emailFilter.Get());
+                       }
+               }
+               break;
+       default:
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. The type of the filter is invalid", GetErrorMessage(GetLastResult()));
+               count = 0;
+               break;
+       };
+
+       return count;
+}
+
+bool
+_AddressbookManagerImpl::OnEachContact(contacts_record_h recordHandle, void* pUserData)
+{
+       IList* pList = static_cast<IList*>(pUserData);
+
+       ClearLastResult();
+
+       unique_ptr<Contact> pContact(new (std::nothrow) Contact());
+       SysTryReturn(NID_SCL, pContact != null, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_h newRecordHandle = null;
+
+       contacts_record_clone(recordHandle, &newRecordHandle);
+       SysTryReturn(NID_SCL, newRecordHandle != null, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       _ContactImpl::GetInstance(*pContact)->SetContactRecordHandle(newRecordHandle);
+
+       result r = pList->Add(*pContact);
+       SysTryReturn(NID_SCL, !IsFailed(r), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       pContact.release();
+
+       return true;
+}
+
+IList*
+_AddressbookManagerImpl::ParseContactsFromVcardN(const Tizen::Base::String& vcardPath)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       File file;
+       result r = file.Construct(vcardPath, "r");
+       SysTryReturn(NID_SCL, r != E_INVALID_ARG, null, E_INVALID_ARG, "[%s] Invalid argument is used..", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, r != E_ILLEGAL_ACCESS, null, E_ILLEGAL_ACCESS, "[%s] Access to the vcard file is denied due to insufficient permission.", GetErrorMessage(E_ILLEGAL_ACCESS));
+       SysTryReturn(NID_SCL, r != E_FILE_NOT_FOUND, null, E_FILE_NOT_FOUND, "[%s] The specified file does not exist.", GetErrorMessage(E_FILE_NOT_FOUND));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+
+       unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(vcardPath));
+
+       int ret = contacts_vcard_parse_to_contact_foreach(pCharArray.get(), OnEachContact, pList.get());
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       return pList.release();
+}
+
+result
+_AddressbookManagerImpl::ExportPersonToVcard(const Person& person, const Tizen::Base::String& vcardPath)
+{
+       bool exist = File::IsFileExist(vcardPath);
+       SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating..", GetErrorMessage(GetLastResult()));
+       SysTryReturn(NID_SCL, !exist, E_FILE_ALREADY_EXIST, E_FILE_ALREADY_EXIST, "[%s] The specified vcard file already exist.", GetErrorMessage(E_FILE_ALREADY_EXIST));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       File file;
+       result r = file.Construct(vcardPath, "w");
+       SysTryReturn(NID_SCL, r != E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, "[%s] Access to the vcard file is denied due to insufficient permission.", GetErrorMessage(E_ILLEGAL_ACCESS));
+       SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pPersonRecord(_AddressbookUtil::GetContactRecordN(_contacts_person._uri, person.GetId()));
+       SysTryReturn(NID_SCL, pPersonRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       char* pVcardStream = null;
+       int ret = contacts_vcard_make_from_person(pPersonRecord.get(), &pVcardStream);
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       r = file.Write(pVcardStream, strlen(pVcardStream));
+       free(pVcardStream);
+       SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookManagerImpl::ExportPersonsToVcard(const Tizen::Base::Collection::IList& personList, const Tizen::Base::String& vcardPath)
+{
+       bool exist = File::IsFileExist(vcardPath);
+       SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating..", GetErrorMessage(GetLastResult()));
+       SysTryReturn(NID_SCL, !exist, E_FILE_ALREADY_EXIST, E_FILE_ALREADY_EXIST, "[%s] The specified vcard file already exist.", GetErrorMessage(E_FILE_ALREADY_EXIST));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int ret = CONTACTS_ERROR_NONE;
+       char* pVcardStream = null;
+       File file;
+
+       result r = file.Construct(vcardPath, "w");
+       SysTryReturn(NID_SCL, r != E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, "[%s] Access to the vcard file is denied due to insufficient permission.", GetErrorMessage(E_ILLEGAL_ACCESS));
+       SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pPersonRecord(null);
+
+       unique_ptr<IEnumerator> pEnum(personList.GetEnumeratorN());
+       SysTryReturnResult(NID_SCL, pEnum != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               Person* pPerson = static_cast<Person*>(pEnum->GetCurrent());
+
+               pPersonRecord.reset(_AddressbookUtil::GetContactRecordN(_contacts_person._uri, pPerson->GetId()));
+               SysTryReturn(NID_SCL, pPersonRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+               ret = contacts_vcard_make_from_person(pPersonRecord.get(), &pVcardStream);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+               r = file.Write(pVcardStream, strlen(pVcardStream));
+               free(pVcardStream);
+               SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
+               SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookManagerImpl::ExportContactToVcard(const Contact& contact, const Tizen::Base::String& vcardPath)
+{
+       bool exist = File::IsFileExist(vcardPath);
+       SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating..", GetErrorMessage(GetLastResult()));
+       SysTryReturn(NID_SCL, !exist, E_FILE_ALREADY_EXIST, E_FILE_ALREADY_EXIST, "[%s] The specified vcard file already exist.", GetErrorMessage(E_FILE_ALREADY_EXIST));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       File file;
+       result r = file.Construct(vcardPath, "w");
+       SysTryReturn(NID_SCL, r != E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, "[%s] Access to the vcard file is denied due to insufficient permission.", GetErrorMessage(E_ILLEGAL_ACCESS));
+       SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       contacts_record_h recordHandle = _ContactImpl::GetInstance(contact)->GetContactRecordHandle();
+
+       char* pVcardStream = null;
+
+       int ret = contacts_vcard_make_from_contact(recordHandle, &pVcardStream);
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       r = file.Write(pVcardStream, strlen(pVcardStream));
+       free(pVcardStream);
+       SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookManagerImpl::ExportContactsToVcard(const Tizen::Base::Collection::IList& contactList, const Tizen::Base::String& vcardPath)
+{
+       bool exist = File::IsFileExist(vcardPath);
+       SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating..", GetErrorMessage(GetLastResult()));
+       SysTryReturn(NID_SCL, !exist, E_FILE_ALREADY_EXIST, E_FILE_ALREADY_EXIST, "[%s] The specified vcard file already exist.", GetErrorMessage(E_FILE_ALREADY_EXIST));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int ret = CONTACTS_ERROR_NONE;
+       char* pVcardStream = null;
+       File file;
+       Contact* pContact = null;
+
+       result r = file.Construct(vcardPath, "w");
+       SysTryReturn(NID_SCL, r != E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, "[%s] Access to the vcard file is denied due to insufficient permission.", GetErrorMessage(E_ILLEGAL_ACCESS));
+       SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       contacts_record_h recordHandle = null;
+
+       unique_ptr<IEnumerator> pEnum(contactList.GetEnumeratorN());
+       SysTryReturnResult(NID_SCL, pEnum != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pContact = static_cast<Contact*>(pEnum->GetCurrent());
+
+               recordHandle = _ContactImpl::GetInstance(*pContact)->GetContactRecordHandle();
+
+               ret = contacts_vcard_make_from_contact(recordHandle, &pVcardStream);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+               r = file.Write(pVcardStream, strlen(pVcardStream));
+               free(pVcardStream);
+               SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
+               SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       }
+
+       return E_SUCCESS;
+}
+
+ByteBuffer*
+_AddressbookManagerImpl::ExportContactToVcardStreamN(const Contact& contact)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       contacts_record_h recordHandle = _ContactImpl::GetInstance(contact)->GetContactRecordHandle();
+
+       char* pVcardStream = null;
+       int ret = CONTACTS_ERROR_NONE;
+
+       ret = contacts_vcard_make_from_contact(recordHandle, &pVcardStream);
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, null, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_SYSTEM, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unique_ptr<ByteBuffer> pByteBuffer(new (std::nothrow) ByteBuffer);
+       if (pByteBuffer == null)
+       {
+               free(pVcardStream);
+               SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               return null;
+       }
+
+       result r = pByteBuffer->Construct(strlen(pVcardStream));
+       if (IsFailed(r))
+       {
+               free(pVcardStream);
+               SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               return null;
+       }
+
+       r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
+       free(pVcardStream);
+       SysTryReturn(NID_SCL, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return pByteBuffer.release();
+}
+
+ByteBuffer*
+_AddressbookManagerImpl::ExportContactsToVcardStreamN(const Tizen::Base::Collection::IList& contactList)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       char* pVcardStream = null;
+       int ret = CONTACTS_ERROR_NONE;
+       Contact* pContact = null;
+       result r = E_SUCCESS;
+       int capacity = 0;
+
+       contacts_record_h recordHandle = null;
+
+       unique_ptr<IEnumerator> pEnum(contactList.GetEnumeratorN());
+       SysTryReturn(NID_SCL, pEnum != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unique_ptr<ByteBuffer> pByteBuffer(new (std::nothrow) ByteBuffer);
+       SysTryReturn(NID_SCL, pByteBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = pByteBuffer->Construct(capacity);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       if (contactList.GetCount() == 0)
+       {
+               return pByteBuffer.release();
+       }
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pContact = static_cast<Contact*>(pEnum->GetCurrent());
+
+               recordHandle = _ContactImpl::GetInstance(*pContact)->GetContactRecordHandle();
+
+               ret = contacts_vcard_make_from_contact(recordHandle, &pVcardStream);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, null, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_SYSTEM, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               capacity += strlen(pVcardStream);
+               r = pByteBuffer->ExpandCapacity(capacity);
+               if (IsFailed(r))
+               {
+                       free(pVcardStream);
+                       SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       return null;
+               }
+
+               r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
+               free(pVcardStream);
+               pVcardStream = null;
+               SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.: capacity(%d), size(%d)", GetErrorMessage(E_SYSTEM));
+       }
+
+       return pByteBuffer.release();
+}
+
+ByteBuffer*
+_AddressbookManagerImpl::ExportPersonToVcardStreamN(const Person& person)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pPersonRecord(_AddressbookUtil::GetContactRecordN(_contacts_person._uri, person.GetId()));
+       SysTryReturn(NID_SCL, GetLastResult() != E_OBJ_NOT_FOUND,  null, E_INVALID_ARG, "[%s] Person does not exist.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS,  null, E_INVALID_ARG, "[%s] Person does not exist.", GetErrorMessage(E_INVALID_ARG));
+
+       char* pVcardStream = null;
+       int ret = contacts_vcard_make_from_person(pPersonRecord.get(), &pVcardStream);
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, null, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       unique_ptr<ByteBuffer> pByteBuffer(new (std::nothrow) ByteBuffer);
+       if (pByteBuffer == null)
+       {
+               free(pVcardStream);
+               SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               return null;
+       }
+
+       result r = pByteBuffer->Construct(strlen(pVcardStream));
+       if (IsFailed(r))
+       {
+               free(pVcardStream);
+               SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               return null;
+       }
+
+       r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
+       free(pVcardStream);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return pByteBuffer.release();
+}
+
+ByteBuffer*
+_AddressbookManagerImpl::ExportPersonsToVcardStreamN(const Tizen::Base::Collection::IList& personList)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       int ret = CONTACTS_ERROR_NONE;
+       Person* pPerson = null;
+       char* pVcardStream = null;
+
+       int capacity = 0;
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pPersonRecord(null);
+
+       unique_ptr<IEnumerator> pEnum(personList.GetEnumeratorN());
+       SysTryReturn(NID_SCL, pEnum != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unique_ptr<ByteBuffer> pByteBuffer(new (std::nothrow) ByteBuffer);
+       SysTryReturn(NID_SCL, pByteBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pByteBuffer->Construct(capacity);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       if (personList.GetCount() == 0)
+       {
+               return pByteBuffer.release();
+       }
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pPerson = static_cast<Person*>(pEnum->GetCurrent());
+
+               pPersonRecord.reset(_AddressbookUtil::GetContactRecordN(_contacts_person._uri, pPerson->GetId()));
+               SysTryReturn(NID_SCL, GetLastResult() != E_OBJ_NOT_FOUND,  null, E_INVALID_ARG, "[%s] Person does not exist.", GetErrorMessage(E_INVALID_ARG));
+               SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS,  null, E_INVALID_ARG, "[%s] Person does not exist.", GetErrorMessage(E_INVALID_ARG));
+
+               ret = contacts_vcard_make_from_person(pPersonRecord.get(), &pVcardStream);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, null, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+               capacity += strlen(pVcardStream);
+               r = pByteBuffer->ExpandCapacity(capacity);
+               if (IsFailed(r))
+               {
+                       free(pVcardStream);
+                       SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       return null;
+               }
+
+               r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
+               free(pVcardStream);
+               pVcardStream = null;
+               SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       }
+
+       return pByteBuffer.release();
+}
+
+IList*
+_AddressbookManagerImpl::ParseVcardStreamN(const Tizen::Base::ByteBuffer& vcardStream)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       contacts_list_h listHandle = null;
+       result r = E_SUCCESS;
+
+       int ret = contacts_vcard_parse_to_contacts(reinterpret_cast<char*>(const_cast<byte*>(vcardStream.GetPointer())), &listHandle);
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, null, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unsigned int count = 0;
+       contacts_record_h recordHandle = null;
+       contacts_list_get_count(listHandle, &count);
+
+       unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       if (pList == null)
+       {
+               contacts_list_destroy(listHandle, true);
+               SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               return null;
+       }
+
+       r = pList->Construct(count);
+       if (IsFailed(r))
+       {
+               contacts_list_destroy(listHandle, true);
+               SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               return null;
+       }
+
+       for (unsigned int i = 0; i < count; i++)
+       {
+               unique_ptr<Contact> pContact(new (std::nothrow) Contact());
+               if (pContact == null)
+               {
+                       contacts_list_destroy(listHandle, true);
+                       SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       return null;
+               }
+
+               r = pList->Add(pContact.get());
+               if (IsFailed(r))
+               {
+                       contacts_list_destroy(listHandle, true);
+                       SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       return null;
+               }
+
+               pContact.release();
+       }
+
+       unique_ptr<IEnumerator> pEnum(pList->GetEnumeratorN());
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               Contact* pContact = static_cast <Contact*> (pEnum->GetCurrent());
+
+               contacts_list_get_current_record_p(listHandle, &recordHandle);
+               _ContactImpl::GetInstance(*pContact)->SetContactRecordHandle(recordHandle);
+
+               ret = contacts_list_next(listHandle);
+       }
+
+       contacts_list_destroy(listHandle, false);
+
+       return pList.release();
+}
+
+ByteBuffer*
+_AddressbookManagerImpl::ExportUserProfileToVcardStreamN(const UserProfile& userProfile)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       char* pVcardStream = null;
+       int ret = CONTACTS_ERROR_NONE;
+       contacts_record_h recordHandle = null;
+
+       recordHandle = _UserProfileImpl::GetInstance(userProfile)->GetUserProfileHandle();
+
+       ret = contacts_vcard_make_from_my_profile(recordHandle, &pVcardStream);
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, null, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_SYSTEM, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unique_ptr<ByteBuffer> pByteBuffer(new (std::nothrow) ByteBuffer);
+       if (pByteBuffer == null)
+       {
+               free(pVcardStream);
+               SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               return null;
+       }
+       SysTryReturn(NID_SCL, pByteBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pByteBuffer->Construct(strlen(pVcardStream));
+       if (IsFailed(r))
+       {
+               free(pVcardStream);
+               SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               return null;
+       }
+
+       r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
+       free(pVcardStream);
+       SysTryReturn(NID_SCL, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return pByteBuffer.release();
+}
+
+ByteBuffer*
+_AddressbookManagerImpl::ExportUserProfilesToVcardStreamN(const Tizen::Base::Collection::IList& userProfileList)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       char* pVcardStream = null;
+       int ret = CONTACTS_ERROR_NONE;
+       UserProfile* pProfile = null;
+       result r = E_SUCCESS;
+       int capacity = 0;
+
+       unique_ptr<IEnumerator> pEnum(userProfileList.GetEnumeratorN());
+       SysTryReturn(NID_SCL, pEnum != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unique_ptr<ByteBuffer> pByteBuffer(new (std::nothrow) ByteBuffer);
+       SysTryReturn(NID_SCL, pByteBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = pByteBuffer->Construct(capacity);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       if (userProfileList.GetCount() == 0)
+       {
+               return pByteBuffer.release();
+       }
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               contacts_record_h recordHandle = null;
+
+               pProfile = static_cast<UserProfile*>(pEnum->GetCurrent());
+
+               recordHandle = _UserProfileImpl::GetInstance(*pProfile)->GetUserProfileHandle();
+
+               ret = contacts_vcard_make_from_my_profile(recordHandle, &pVcardStream);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, null, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_SYSTEM, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               capacity += strlen(pVcardStream);
+               r = pByteBuffer->ExpandCapacity(capacity);
+               if (IsFailed(r))
+               {
+                       free(pVcardStream);
+                       SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       return null;
+               }
+
+               r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
+               free(pVcardStream);
+               SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.: capacity(%d), size(%d)", GetErrorMessage(E_SYSTEM));
+       }
+
+       return pByteBuffer.release();
+}
+
+result
+_AddressbookManagerImpl::ExportUserProfileToVcard(const UserProfile& userProfile, const Tizen::Base::String& vcardPath)
+{
+       bool exist = File::IsFileExist(vcardPath);
+       SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating..", GetErrorMessage(GetLastResult()));
+       SysTryReturn(NID_SCL, !exist, E_FILE_ALREADY_EXIST, E_FILE_ALREADY_EXIST, "[%s] The specified vcard file already exist.", GetErrorMessage(E_FILE_ALREADY_EXIST));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       File file;
+       result r = file.Construct(vcardPath, "w");
+       SysTryReturn(NID_SCL, r != E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, "[%s] Access to the vcard file is denied due to insufficient permission.", GetErrorMessage(E_ILLEGAL_ACCESS));
+       SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       char* pVcardStream = null;
+       contacts_record_h recordHandle = null;
+
+       recordHandle = _UserProfileImpl::GetInstance(userProfile)->GetUserProfileHandle();
+
+       int ret = contacts_vcard_make_from_my_profile(recordHandle, &pVcardStream);
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       r = file.Write(pVcardStream, strlen(pVcardStream));
+       free(pVcardStream);
+       SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return E_SUCCESS;
+}
+
+result
+_AddressbookManagerImpl::ExportUserProfilesToVcard(const Tizen::Base::Collection::IList& userProfileList, const Tizen::Base::String& vcardPath)
+{
+       bool exist = File::IsFileExist(vcardPath);
+       SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating..", GetErrorMessage(GetLastResult()));
+       SysTryReturn(NID_SCL, !exist, E_FILE_ALREADY_EXIST, E_FILE_ALREADY_EXIST, "[%s] The specified vcard file already exist.", GetErrorMessage(E_FILE_ALREADY_EXIST));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int ret = CONTACTS_ERROR_NONE;
+       char* pVcardStream = null;
+       File file;
+       UserProfile* pProfile = null;
+
+       result r = file.Construct(vcardPath, "w");
+       SysTryReturn(NID_SCL, r != E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, "[%s] Access to the vcard file is denied due to insufficient permission.", GetErrorMessage(E_ILLEGAL_ACCESS));
+       SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       unique_ptr<IEnumerator> pEnum(userProfileList.GetEnumeratorN());
+       SysTryReturnResult(NID_SCL, pEnum != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               contacts_record_h recordHandle = null;
+
+               pProfile = static_cast<UserProfile*>(pEnum->GetCurrent());
+
+               recordHandle = _UserProfileImpl::GetInstance(*pProfile)->GetUserProfileHandle();
+
+               ret = contacts_vcard_make_from_my_profile(recordHandle, &pVcardStream);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+               r = file.Write(pVcardStream, strlen(pVcardStream));
+               free(pVcardStream);
+               SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
+               SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       }
+
+       return E_SUCCESS;
+}
+
+IList*
+_AddressbookManagerImpl::GetAllUserProfilesN(void) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       ClearLastResult();
+
+       unique_ptr< __Filter<__ContactsUserProfile> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsUserProfile>());
+       SysTryReturn(NID_SCL, pRwAbFilter != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       __Query<__ContactsUserProfile> query;
+       query.Construct();
+       query.SetSort(_contacts_my_profile.display_name, true);
+
+       if (pRwAbFilter->Get() != null)
+       {
+               query.SetFilter(*pRwAbFilter);
+       }
+
+       IList* pUserProfilesList = _AddressbookUtil::SearchWithQueryN<__ContactsUserProfile, UserProfile>(query);
+       SysTryReturn(NID_SCL, pUserProfilesList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pUserProfilesList;
+}
+
+UserProfile*
+_AddressbookManagerImpl::GetUserProfileN(AddressbookId addressbookId) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       SysTryReturn(NID_SCL, addressbookId >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. Addressbook Id(%d).", GetErrorMessage(E_INVALID_ARG), addressbookId);
+
+       ClearLastResult();
+
+       int mode = 0;
+       unique_ptr<ContactRecord, ContactRecordDeleter> pAbRecord(_AddressbookUtil::GetContactRecordN(_contacts_address_book._uri, addressbookId));
+       SysTryReturn(NID_SCL, pAbRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       contacts_record_get_int(pAbRecord.get(), _contacts_address_book.mode, &mode);
+       SysTryReturn(NID_SCL, mode == 0, null, E_OBJ_NOT_FOUND, "[%s] The addressbook does not exist.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       __Filter<__ContactsUserProfile> filter;
+       filter.Construct();
+       filter.AddInt(_contacts_my_profile.address_book_id, CONTACTS_MATCH_EQUAL, addressbookId);
+
+       __Query<__ContactsUserProfile> query;
+       query.Construct();
+       query.SetFilter(filter);
+
+       unique_ptr<IList, AllElementsDeleter> pUserProfilesList(_AddressbookUtil::SearchWithQueryN<__ContactsUserProfile, UserProfile>(query));
+       SysTryReturn(NID_SCL, pUserProfilesList.get() != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       SysTryReturn(NID_SCL, pUserProfilesList->GetCount() != 0, null, E_SUCCESS, "No UserProfile Set for this Addressbook.");
+       SysTryReturn(NID_SCL, pUserProfilesList->GetCount() == 1, null, E_SYSTEM, "[%s] Propagating. More than one UserProfile not allowed.", GetErrorMessage(E_SYSTEM));
+
+       UserProfile* pProfile = new (std::nothrow) UserProfile(*(static_cast<UserProfile*>(pUserProfilesList->GetAt(0))));
+       SysTryReturn(NID_SCL, pProfile != null, null, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       return pProfile;
+}
+
+contacts_record_h
+_AddressbookManagerImpl::CopyContactRecordHandle(contacts_record_h srcHandle)
+{
+       ClearLastResult();
+
+       int ret = CONTACTS_ERROR_NONE;
+       unsigned int i = 0;
+       unsigned int count = 0;
+       char* pCharValue = null;
+       int intValue = 0;
+       bool boolValue = false;
+
+       contacts_record_h contactHandle = null;
+       contacts_record_h sourceRecordHandle = null;
+       contacts_record_h destRecordHandle = null;
+
+       ret = contacts_record_create(_contacts_contact._uri, &contactHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       // favorite
+       contacts_record_get_bool(sourceRecordHandle, _contacts_contact.is_favorite, &boolValue);
+       contacts_record_set_bool(destRecordHandle, _contacts_contact.is_favorite, boolValue);
+
+       // uid
+       contacts_record_get_str_p(sourceRecordHandle, _contacts_contact.uid, &pCharValue);
+       contacts_record_set_str(destRecordHandle, _contacts_contact.uid, pCharValue);
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // name
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.name, &count);
+       if (count > 0)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.name, 0, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_name._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle nameHandle(destRecordHandle);
+
+               // 1. first
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.first, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.first, pCharValue);
+
+               // 2. last
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.last, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.last, pCharValue);
+
+               // 3. addition
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.addition, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.addition, pCharValue);
+
+               // 4. suffix
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.suffix, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.suffix, pCharValue);
+
+               // 5. prefix
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.prefix, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.prefix, pCharValue);
+
+               // 6. phonetic_first
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_first, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_first, pCharValue);
+
+               // 7. phonetic_last
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_last, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_last, pCharValue);
+
+               // 8. phonetic_middle
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_middle, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_middle, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.name, destRecordHandle);
+
+               nameHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // image
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.image, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.image, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_image._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle imageHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_image.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_image.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_image.label, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_image.label, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_image.path, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_image.path, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.image, destRecordHandle);
+
+               imageHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // company
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.company, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.company, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_company._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle companyHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_company.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_company.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.name, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.name, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.department, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.department, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.job_title, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.job_title, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.assistant_name, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.assistant_name, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.role, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.role, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.logo, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.logo, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.location, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.location, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.description, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.description, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.phonetic_name, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.phonetic_name, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.company, destRecordHandle);
+
+               companyHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // note
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.note, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.note, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_note._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle noteHandle(destRecordHandle);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_note.note, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_note.note, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.note, destRecordHandle);
+
+               noteHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // phone number
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.number, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.number, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_number._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle numberHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_number.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_number.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_number.label, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_number.label, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_number.number, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_number.number, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.number, destRecordHandle);
+
+               numberHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // email
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.email, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.email, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_email._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle emailHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_email.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_email.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_email.label, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_email.label, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_email.email, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_email.email, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.email, destRecordHandle);
+
+               emailHandle.Release();
+
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // event
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.event, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.event, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_event._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle eventHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_event.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_event.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_event.label, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_event.label, pCharValue);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_event.date, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_event.date, intValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.event, destRecordHandle);
+
+               eventHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // im address
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.messenger, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.messenger, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_messenger._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle imAddressHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_messenger.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_messenger.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_messenger.label, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_messenger.label, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_messenger.im_id, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_messenger.im_id, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.messenger, destRecordHandle);
+
+               imAddressHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // address
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.address, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.address, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_address._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle addressHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_address.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_address.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.label, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.label, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.postbox, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.postbox, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.extended, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.extended, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.street, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.street, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.locality, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.locality, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.region, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.region, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.postal_code, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.postal_code, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.country, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.country, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.address, destRecordHandle);
+
+               addressHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // url
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.url, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.url, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_url._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle urlHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_url.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_url.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_url.label, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_url.label, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_url.url, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_url.url, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.url, destRecordHandle);
+
+               urlHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // nickname
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.nickname, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.nickname, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_nickname._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle nicknameHandle(destRecordHandle);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_nickname.name, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_nickname.name, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.nickname, destRecordHandle);
+
+               nicknameHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // relationship
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.relationship, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.relationship, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_relationship._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle relationshipHandle(destRecordHandle);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_relationship.name, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_relationship.name, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.relationship, destRecordHandle);
+
+               relationshipHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // app launch data
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(srcHandle, _contacts_contact.profile, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.profile, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_profile._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle profileHandle(destRecordHandle);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.text, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.text, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.uid, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.uid, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.app_id, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.app_id, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.service_operation, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.service_operation, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.uri, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.uri, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.category, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.category, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.mime, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.mime, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.extra_data, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.extra_data, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.profile, destRecordHandle);
+
+               profileHandle.Release();
+       }
+
+       return contactHandle;
+}
+
+_AddressbookManagerImpl*
+_AddressbookManagerImpl::GetInstance(AddressbookManager& addressbookManager)
+{
+       return addressbookManager.__pAddressbookManagerImpl;
+}
+
+const _AddressbookManagerImpl*
+_AddressbookManagerImpl::GetInstance(const AddressbookManager& addressbookManager)
+{
+       return addressbookManager.__pAddressbookManagerImpl;
+}
+
+}}  // Tizen::Social
diff --git a/src/FScl_AddressbookUtil.cpp b/src/FScl_AddressbookUtil.cpp
new file mode 100644 (file)
index 0000000..521acbd
--- /dev/null
@@ -0,0 +1,939 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_AddressbookUtil.cpp
+ * @brief              This is the implementation for _AddressbookUtil class.
+ *
+ * This file contains definitions of @e _AddressbookUtil class.
+ */
+
+#include <stdlib.h>
+#include <unique_ptr.h>
+#include <FBaseDateTime.h>
+#include <FBaseColArrayList.h>
+#include <FBaseColArrayListT.h>
+#include <FSclTypes.h>
+#include <FSclContact.h>
+#include <FSclPerson.h>
+#include <FSclCategory.h>
+#include <FSclUserProfile.h>
+#include <FSclUrl.h>
+#include <FSclAddress.h>
+#include <FSclImAddress.h>
+#include <FSclContactEvent.h>
+#include <FSclRelationship.h>
+#include <FSclOrganization.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include <FSclContactChangeInfo.h>
+#include <FScl_ContactChangeInfoImpl.h>
+#include <FSclCategoryChangeInfo.h>
+#include <FScl_CategoryChangeInfoImpl.h>
+#include "FScl_AddressbookUtil.h"
+#include "FScl_ContactImpl.h"
+#include "FScl_CategoryImpl.h"
+#include "FScl_RecordImpl.h"
+#include <FSclPhoneNumberContact.h>
+#include "FScl_PhoneNumberContactImpl.h"
+#include <FSclEmailContact.h>
+#include "FScl_EmailContactImpl.h"
+#include "FScl_PersonImpl.h"
+#include "FSclAddressbook.h"
+#include "FScl_AddressbookImpl.h"
+#include "FScl_UserProfileImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Social
+{
+
+template<>
+Contact*
+__ContactsContact::ConvertResultTo<Contact>(__SearchResult<__ContactsContact>& searchResult)
+{
+       int intValue = 0;
+       contacts_record_h newRecord = null;
+
+       contacts_record_h currentRecord = searchResult.GetCurrentRecord();
+       SysTryReturn(NID_SCL, currentRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       contacts_record_get_int(currentRecord, _contacts_contact.id, &intValue);
+       SysTryReturn(NID_SCL, intValue > 0, null, E_OBJ_NOT_FOUND, "[%s] The contact is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       std::unique_ptr<Contact> pContact(new (std::nothrow) Contact());
+       SysTryReturn(NID_SCL, pContact != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       contacts_record_clone(currentRecord, &newRecord);
+       SysTryReturn(NID_SCL, newRecord != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       _ContactImpl::GetInstance(*pContact)->SetContactRecordHandle(newRecord);
+
+       contacts_record_get_int(newRecord, _contacts_contact.id, &intValue);
+
+       _RecordImpl::GetInstance(*pContact)->SetRecordId(intValue);
+
+       return pContact.release();
+}
+
+template<>
+Category*
+__ContactsGroup::ConvertResultTo<Category>(__SearchResult<__ContactsGroup>& searchResult)
+{
+       int intValue = 0;
+       contacts_record_h newRecord = null;
+
+       contacts_record_h currentRecord = searchResult.GetCurrentRecord();
+       SysTryReturn(NID_SCL, currentRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       contacts_record_get_int(currentRecord, _contacts_group.id, &intValue);
+       SysTryReturn(NID_SCL, intValue > 0, null, E_OBJ_NOT_FOUND, "[%s] The contact is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       std::unique_ptr<Category> pCategory(new (std::nothrow) Category());
+       SysTryReturn(NID_SCL, pCategory != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       contacts_record_clone(currentRecord, &newRecord);
+       SysTryReturn(NID_SCL, newRecord != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       _CategoryImpl::GetInstance(*pCategory)->SetRecordHandle(newRecord);
+
+       contacts_record_get_int(newRecord, _contacts_group.id, &intValue);
+
+       _RecordImpl::GetInstance(*pCategory)->SetRecordId(intValue);
+
+       __Filter<__ContactsGroupRelation> filter;
+       filter.Construct();
+       filter.AddInt(_contacts_group_relation.group_id, CONTACTS_MATCH_EQUAL, intValue);
+
+       __Query<__ContactsGroupRelation> query;
+       query.Construct();
+       query.SetFilter(filter);
+
+       int count = _AddressbookUtil::GetCountWithQuery(query);
+       SysTryReturn(NID_SCL, count >= 0, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       _CategoryImpl::GetInstance(*pCategory)->SetMemberCount(count);
+
+       return pCategory.release();
+}
+
+template<>
+Category*
+__ContactsGroupRelation::ConvertResultTo<Category>(__SearchResult<__ContactsGroupRelation>& searchResult)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int intValue = 0;
+
+       contacts_record_h currentRecord = searchResult.GetCurrentRecord();
+       SysTryReturn(NID_SCL, currentRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       contacts_record_get_int(currentRecord, _contacts_group_relation.group_id, &intValue);
+       SysTryReturn(NID_SCL, intValue > 0, null, E_OBJ_NOT_FOUND, "[%s] The category is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       std::unique_ptr<Category> pCategory(new (std::nothrow) Category());
+       SysTryReturn(NID_SCL, pCategory != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pCategoryRecord(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, intValue));
+       SysTryReturn(NID_SCL, pCategoryRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       _CategoryImpl::GetInstance(*pCategory)->SetRecordHandle(pCategoryRecord.release());
+       _RecordImpl::GetInstance(*pCategory)->SetRecordId(intValue);
+
+       __Filter<__ContactsGroupRelation> filter;
+       filter.Construct();
+       filter.AddInt(_contacts_group_relation.group_id, CONTACTS_MATCH_EQUAL, intValue);
+
+       __Query<__ContactsGroupRelation> query;
+       query.Construct();
+       query.SetFilter(filter);
+
+       int count = _AddressbookUtil::GetCountWithQuery(query);
+       if (count < 0)
+       {
+               SysTryReturn(NID_SCL, GetLastResult() != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, GetLastResult() != E_SYSTEM, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+               count = 0;
+       }
+
+       _CategoryImpl::GetInstance(*pCategory)->SetMemberCount(count);
+
+       return pCategory.release();
+}
+
+template<>
+Category*
+__ContactsContactGroupRel::ConvertResultTo<Category>(__SearchResult<__ContactsContactGroupRel>& searchResult)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int intValue = 0;
+
+       contacts_record_h currentRecord = searchResult.GetCurrentRecord();
+       SysTryReturn(NID_SCL, currentRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       contacts_record_get_int(currentRecord, _contacts_contact_grouprel.group_id, &intValue);
+       SysTryReturn(NID_SCL, intValue > 0, null, E_OBJ_NOT_FOUND, "[%s] The category is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       std::unique_ptr<Category> pCategory(new (std::nothrow) Category());
+       SysTryReturn(NID_SCL, pCategory != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pCategoryRecord(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, intValue));
+       SysTryReturn(NID_SCL, pCategoryRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       _CategoryImpl::GetInstance(*pCategory)->SetRecordHandle(pCategoryRecord.release());
+       _RecordImpl::GetInstance(*pCategory)->SetRecordId(intValue);
+
+       __Filter<__ContactsGroupRelation> filter;
+       filter.Construct();
+       filter.AddInt(_contacts_group_relation.group_id, CONTACTS_MATCH_EQUAL, intValue);
+
+       __Query<__ContactsGroupRelation> query;
+       query.Construct();
+       query.SetFilter(filter);
+
+       int count = _AddressbookUtil::GetCountWithQuery(query);
+       if (count < 0)
+       {
+               SysTryReturn(NID_SCL, GetLastResult() != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, GetLastResult() != E_SYSTEM, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+               count = 0;
+       }
+
+       _CategoryImpl::GetInstance(*pCategory)->SetMemberCount(count);
+
+       return pCategory.release();
+}
+
+
+template<>
+Contact*
+__ContactsContactGroupRel::ConvertResultTo<Contact>(__SearchResult<__ContactsContactGroupRel>& searchResult)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int intValue = 0;
+
+       contacts_record_h currentRecord = searchResult.GetCurrentRecord();
+       SysTryReturn(NID_SCL, currentRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       contacts_record_get_int(currentRecord, _contacts_contact_grouprel.contact_id, &intValue);
+       SysTryReturn(NID_SCL, intValue > 0, null, E_OBJ_NOT_FOUND, "[%s] The contact is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       std::unique_ptr<Contact> pContact(new (std::nothrow) Contact());
+       SysTryReturn(NID_SCL, pContact != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pContactRecord(_AddressbookUtil::GetContactRecordN(_contacts_contact._uri, intValue));
+       SysTryReturn(NID_SCL, pContactRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       _ContactImpl::GetInstance(*pContact)->SetContactRecordHandle(pContactRecord.release());
+       _RecordImpl::GetInstance(*pContact)->SetRecordId(intValue);
+
+       return pContact.release();
+}
+
+template<>
+Contact*
+__ContactsContactEmail::ConvertResultTo<Contact>(__SearchResult<__ContactsContactEmail>& searchResult)
+{
+
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int intValue = 0;
+
+       contacts_record_h currentRecord = searchResult.GetCurrentRecord();
+       SysTryReturn(NID_SCL, currentRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       contacts_record_get_int(currentRecord, _contacts_contact_email.contact_id, &intValue);
+       SysTryReturn(NID_SCL, intValue > 0, null, E_OBJ_NOT_FOUND, "[%s] The contact is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       std::unique_ptr<Contact> pContact(new (std::nothrow) Contact());
+       SysTryReturn(NID_SCL, pContact != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pContactRecord(_AddressbookUtil::GetContactRecordN(_contacts_contact._uri, intValue));
+       SysTryReturn(NID_SCL, pContactRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       _ContactImpl::GetInstance(*pContact)->SetContactRecordHandle(pContactRecord.release());
+       _RecordImpl::GetInstance(*pContact)->SetRecordId(intValue);
+
+       return pContact.release();
+}
+
+template<>
+EmailContact*
+__ContactsContactEmail::ConvertResultTo<EmailContact>(__SearchResult<__ContactsContactEmail>& queryResult)
+{
+       int intValue = 0;
+       EmailType type = EMAIL_TYPE_PERSONAL;
+       char* pCharValue = null;
+       int emailRecordId = 0;
+       String label;
+       String email;
+
+       contacts_record_h recordHandle = queryResult.GetCurrentRecord();
+       SysTryReturn(NID_SCL, recordHandle != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       contacts_record_get_int(recordHandle, _contacts_contact_email.contact_id, &intValue);
+       SysTryReturn(NID_SCL, intValue > 0, null, E_OBJ_NOT_FOUND, "[%s] The contact is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       std::unique_ptr<EmailContact> pEmailContact(new (std::nothrow) EmailContact());
+       SysTryReturn(NID_SCL, pEmailContact != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_int(recordHandle, _contacts_contact_email.contact_id, &intValue);
+       _EmailContactImpl::GetInstance(*pEmailContact)->SetContactId(intValue);
+
+       contacts_record_get_int(recordHandle, _contacts_contact_email.person_id, &intValue);
+       _EmailContactImpl::GetInstance(*pEmailContact)->SetPersonId(intValue);
+
+       contacts_record_get_int(recordHandle, _contacts_contact_email.address_book_id, &intValue);
+       _EmailContactImpl::GetInstance(*pEmailContact)->SetAddressbookId(intValue);
+
+       contacts_record_get_str_p(recordHandle, _contacts_contact_email.display_name, &pCharValue);
+       _EmailContactImpl::GetInstance(*pEmailContact)->SetDisplayName(pCharValue);
+
+       contacts_record_get_str_p(recordHandle, _contacts_contact_email.image_thumbnail_path, &pCharValue);
+       _EmailContactImpl::GetInstance(*pEmailContact)->SetThumbnailPath(pCharValue);
+
+       contacts_record_get_str_p(recordHandle, _contacts_contact_email.ringtone_path, &pCharValue);
+       _EmailContactImpl::GetInstance(*pEmailContact)->SetRingtonePath(pCharValue);
+
+       // email id
+       contacts_record_get_int(recordHandle, _contacts_contact_email.email_id, &intValue);
+       emailRecordId = intValue;
+
+       // label
+       contacts_record_get_str_p(recordHandle, _contacts_contact_email.label, &pCharValue);
+       label = pCharValue;
+
+       // type
+       contacts_record_get_int(recordHandle, _contacts_contact_email.type, &intValue);
+       switch (intValue)
+       {
+       case CONTACTS_EMAIL_TYPE_HOME:
+               type = EMAIL_TYPE_PERSONAL;
+               break;
+       case CONTACTS_EMAIL_TYPE_WORK:
+               type = EMAIL_TYPE_WORK;
+               break;
+       case CONTACTS_EMAIL_TYPE_CUSTOM:
+               type = EMAIL_TYPE_CUSTOM;
+               break;
+       default:
+               type = EMAIL_TYPE_OTHER;
+               break;
+       }
+
+       // email
+       contacts_record_get_str_p(recordHandle, _contacts_contact_email.email, &pCharValue);
+       email = pCharValue;
+
+       _EmailContactImpl::GetInstance(*pEmailContact)->SetEmailData(emailRecordId, type, label, email);
+
+       return pEmailContact.release();
+}
+
+template<>
+Contact*
+__ContactsContactNumber::ConvertResultTo<Contact>(__SearchResult<__ContactsContactNumber>& searchResult)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int intValue = 0;
+
+       contacts_record_h currentRecord = searchResult.GetCurrentRecord();
+       SysTryReturn(NID_SCL, currentRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       contacts_record_get_int(currentRecord, _contacts_contact_number.contact_id, &intValue);
+       SysTryReturn(NID_SCL, intValue > 0, null, E_OBJ_NOT_FOUND, "[%s] The contact is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       std::unique_ptr<Contact> pContact(new (std::nothrow) Contact());
+       SysTryReturn(NID_SCL, pContact != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pContactRecord(_AddressbookUtil::GetContactRecordN(_contacts_contact._uri, intValue));
+       SysTryReturn(NID_SCL, pContactRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       _ContactImpl::GetInstance(*pContact)->SetContactRecordHandle(pContactRecord.release());
+       _RecordImpl::GetInstance(*pContact)->SetRecordId(intValue);
+
+       return pContact.release();
+}
+
+template<>
+PhoneNumberContact*
+__ContactsContactNumber::ConvertResultTo<PhoneNumberContact>(__SearchResult<__ContactsContactNumber>& queryResult)
+{
+       int intValue = 0;
+       PhoneNumberType type = PHONENUMBER_TYPE_HOME;
+       char* pCharValue = null;
+       int numberRecordId = 0;
+       String label;
+       String number;
+
+       contacts_record_h recordHandle = queryResult.GetCurrentRecord();
+       SysTryReturn(NID_SCL, recordHandle != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       contacts_record_get_int(recordHandle, _contacts_contact_number.contact_id, &intValue);
+       SysTryReturn(NID_SCL, intValue > 0, null, E_OBJ_NOT_FOUND, "[%s] The contact is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       std::unique_ptr<PhoneNumberContact> pPhoneNumberContact(new (std::nothrow) PhoneNumberContact());
+       SysTryReturn(NID_SCL, pPhoneNumberContact != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_int(recordHandle, _contacts_contact_number.contact_id, &intValue);
+       _PhoneNumberContactImpl::GetInstance(*pPhoneNumberContact)->SetContactId(intValue);
+
+       contacts_record_get_int(recordHandle, _contacts_contact_number.person_id, &intValue);
+       _PhoneNumberContactImpl::GetInstance(*pPhoneNumberContact)->SetPersonId(intValue);
+
+       contacts_record_get_int(recordHandle, _contacts_contact_number.address_book_id, &intValue);
+       _PhoneNumberContactImpl::GetInstance(*pPhoneNumberContact)->SetAddressbookId(intValue);
+
+       contacts_record_get_str_p(recordHandle, _contacts_contact_number.display_name, &pCharValue);
+       _PhoneNumberContactImpl::GetInstance(*pPhoneNumberContact)->SetDisplayName(pCharValue);
+
+       contacts_record_get_str_p(recordHandle, _contacts_contact_number.image_thumbnail_path, &pCharValue);
+       _PhoneNumberContactImpl::GetInstance(*pPhoneNumberContact)->SetThumbnailPath(pCharValue);
+
+       contacts_record_get_str_p(recordHandle, _contacts_contact_number.ringtone_path, &pCharValue);
+       _PhoneNumberContactImpl::GetInstance(*pPhoneNumberContact)->SetRingtonePath(pCharValue);
+
+       // number id
+       contacts_record_get_int(recordHandle, _contacts_contact_number.number_id, &intValue);
+       numberRecordId = intValue;
+
+       // label
+       contacts_record_get_str_p(recordHandle, _contacts_contact_number.label, &pCharValue);
+       label = pCharValue;
+
+       // type
+       contacts_record_get_int(recordHandle, _contacts_contact_number.type, &intValue);
+       switch (intValue)
+       {
+               case CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE:
+                       type = PHONENUMBER_TYPE_HOME;
+                       break;
+               case CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE:
+                       type = PHONENUMBER_TYPE_WORK;
+                       break;
+               case CONTACTS_NUMBER_TYPE_CELL:
+                       type = PHONENUMBER_TYPE_MOBILE;
+                       break;
+               case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME:
+                       type = PHONENUMBER_TYPE_HOME_FAX;
+                       break;
+               case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK:
+                       type = PHONENUMBER_TYPE_WORK_FAX;
+                       break;
+               case CONTACTS_NUMBER_TYPE_PAGER:
+                       type = PHONENUMBER_TYPE_PAGER;
+                       break;
+               case CONTACTS_NUMBER_TYPE_CUSTOM:
+                       type = PHONENUMBER_TYPE_CUSTOM;
+                       break;
+               default:
+                       type = PHONENUMBER_TYPE_OTHER;
+                       break;
+       }
+
+       // number
+       contacts_record_get_str_p(recordHandle, _contacts_contact_number.number, &pCharValue);
+       number = pCharValue;
+
+       _PhoneNumberContactImpl::GetInstance(*pPhoneNumberContact)->SetPhoneNumberData(numberRecordId, type, label, number);
+
+       return pPhoneNumberContact.release();
+}
+
+template<>
+Addressbook*
+__ContactsAddressbook::ConvertResultTo<Addressbook>(__SearchResult<__ContactsAddressbook>& queryResult)
+{
+       int intValue = 0;
+       char* pCharValue = null;
+
+       contacts_record_h currentRecord = queryResult.GetCurrentRecord();
+       SysTryReturn(NID_SCL, currentRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<Addressbook> pAddressbook(new (std::nothrow) Addressbook());
+       SysTryReturn(NID_SCL, pAddressbook != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pAddressbook->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_int(currentRecord, _contacts_address_book.id, &intValue);
+       _AddressbookImpl::GetInstance(*pAddressbook)->SetId(intValue);
+
+       contacts_record_get_str_p(currentRecord, _contacts_address_book.name, &pCharValue);
+       _AddressbookImpl::GetInstance(*pAddressbook)->SetName(pCharValue);
+
+       contacts_record_get_int(currentRecord, _contacts_address_book.account_id, &intValue);
+       _AddressbookImpl::GetInstance(*pAddressbook)->SetAccountId(intValue);
+
+       return pAddressbook.release();
+}
+
+
+
+template<>
+Person*
+__ContactsPerson::ConvertResultTo<Person>(__SearchResult<__ContactsPerson>& queryResult)
+{
+       int intValue = 0;
+       char* pCharValue = null;
+       bool boolValue = false;
+
+       contacts_record_h currentRecord = queryResult.GetCurrentRecord();
+       SysTryReturn(NID_SCL, currentRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<Person> pPerson(_AddressbookUtil::CreatePersonN());
+       SysTryReturn(NID_SCL, pPerson != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_int(currentRecord, _contacts_person.id, &intValue);
+       _PersonImpl::GetInstance(*pPerson)->SetId(intValue);
+
+       contacts_record_get_str_p(currentRecord, _contacts_person.addressbook_ids, &pCharValue);
+       _PersonImpl::GetInstance(*pPerson)->SetAddressbookIdString(pCharValue);
+
+       contacts_record_get_bool(currentRecord, _contacts_person.is_favorite, &boolValue);
+       _PersonImpl::GetInstance(*pPerson)->SetIsFavorite(boolValue);
+
+       contacts_record_get_bool(currentRecord, _contacts_person.has_phonenumber, &boolValue);
+       _PersonImpl::GetInstance(*pPerson)->SetHasPhoneNumber(boolValue);
+
+       contacts_record_get_bool(currentRecord, _contacts_person.has_email, &boolValue);
+       _PersonImpl::GetInstance(*pPerson)->SetHasEmail(boolValue);
+
+       contacts_record_get_str_p(currentRecord, _contacts_person.image_thumbnail_path, &pCharValue);
+       _PersonImpl::GetInstance(*pPerson)->SetThumbnailPath(pCharValue);
+
+       contacts_record_get_str_p(currentRecord, _contacts_person.ringtone_path, &pCharValue);
+       _PersonImpl::GetInstance(*pPerson)->SetRingtonePath(pCharValue);
+
+       contacts_record_get_str_p(currentRecord, _contacts_person.display_name, &pCharValue);
+       _PersonImpl::GetInstance(*pPerson)->SetDisplayName(pCharValue);
+
+       return pPerson.release();
+
+}
+
+Person*
+_AddressbookUtil::CreatePersonN(void)
+{
+       Person* pPerson = new (std::nothrow) Person();
+       return pPerson;
+}
+
+template<>
+Person*
+__ContactsPersonGroupRel::ConvertResultTo<Person>(__SearchResult<__ContactsPersonGroupRel>& searchResult)
+{
+       int intValue = 0;
+       char* pCharValue = null;
+       bool boolValue = false;
+
+       contacts_record_h currentRecord = searchResult.GetCurrentRecord();
+       SysTryReturn(NID_SCL, currentRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<Person> pPerson(_AddressbookUtil::CreatePersonN());
+       SysTryReturn(NID_SCL, pPerson != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_int(currentRecord, _contacts_person_grouprel.person_id, &intValue);
+       _PersonImpl::GetInstance(*pPerson)->SetId(intValue);
+
+       contacts_record_get_str_p(currentRecord, _contacts_person_grouprel.addressbook_ids, &pCharValue);
+       _PersonImpl::GetInstance(*pPerson)->SetAddressbookIdString(pCharValue);
+
+       contacts_record_get_bool(currentRecord, _contacts_person_grouprel.is_favorite, &boolValue);
+       _PersonImpl::GetInstance(*pPerson)->SetIsFavorite(boolValue);
+
+       contacts_record_get_bool(currentRecord, _contacts_person_grouprel.has_phonenumber, &boolValue);
+       _PersonImpl::GetInstance(*pPerson)->SetHasPhoneNumber(boolValue);
+
+       contacts_record_get_bool(currentRecord, _contacts_person_grouprel.has_email, &boolValue);
+       _PersonImpl::GetInstance(*pPerson)->SetHasEmail(boolValue);
+
+       contacts_record_get_str_p(currentRecord, _contacts_person_grouprel.image_thumbnail_path, &pCharValue);
+       _PersonImpl::GetInstance(*pPerson)->SetThumbnailPath(pCharValue);
+
+       contacts_record_get_str_p(currentRecord, _contacts_person_grouprel.ringtone_path, &pCharValue);
+       _PersonImpl::GetInstance(*pPerson)->SetRingtonePath(pCharValue);
+
+       contacts_record_get_str_p(currentRecord, _contacts_person_grouprel.display_name, &pCharValue);
+       _PersonImpl::GetInstance(*pPerson)->SetDisplayName(pCharValue);
+
+       return pPerson.release();
+}
+
+template<>
+Category*
+__ContactsPersonGroupRel::ConvertResultTo<Category>(__SearchResult<__ContactsPersonGroupRel>& searchResult)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int intValue = 0;
+
+       contacts_record_h currentRecord = searchResult.GetCurrentRecord();
+       SysTryReturn(NID_SCL, currentRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<Category> pCategory(new (std::nothrow) Category());
+       SysTryReturn(NID_SCL, pCategory != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_int(currentRecord, _contacts_person_grouprel.group_id, &intValue);
+       SysTryReturn(NID_SCL, intValue > 0, null, E_OBJ_NOT_FOUND, "[%s] The category is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pCategoryRecord(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, intValue));
+        SysTryReturn(NID_SCL, pCategoryRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       _CategoryImpl::GetInstance(*pCategory)->SetRecordHandle(pCategoryRecord.release());
+       _RecordImpl::GetInstance(*pCategory)->SetRecordId(intValue);
+
+       __Filter<__ContactsGroupRelation> filter;
+       filter.Construct();
+       filter.AddInt(_contacts_group_relation.group_id, CONTACTS_MATCH_EQUAL, intValue);
+
+       __Query<__ContactsGroupRelation> query;
+       query.Construct();
+       query.SetFilter(filter);
+
+       int count = _AddressbookUtil::GetCountWithQuery(query);
+       if (count < 0)
+       {
+               SysTryReturn(NID_SCL, GetLastResult() != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, GetLastResult() != E_SYSTEM, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+               count = 0;
+       }
+
+       _CategoryImpl::GetInstance(*pCategory)->SetMemberCount(count);
+
+       return pCategory.release();
+}
+
+template<>
+Person*
+__ContactsPerson::ConvertHandleTo<Person>(contacts_record_h recordHandle)
+{
+       int intValue = 0;
+       char* pCharValue = null;
+       bool boolValue = false;
+
+       std::unique_ptr<Person> pPerson(_AddressbookUtil::CreatePersonN());
+       SysTryReturn(NID_SCL, pPerson != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_int(recordHandle, _contacts_person.id, &intValue);
+       _PersonImpl::GetInstance(*pPerson)->SetId(intValue);
+
+       contacts_record_get_str_p(recordHandle, _contacts_person.addressbook_ids, &pCharValue);
+       _PersonImpl::GetInstance(*pPerson)->SetAddressbookIdString(pCharValue);
+
+       contacts_record_get_bool(recordHandle, _contacts_person.is_favorite, &boolValue);
+       _PersonImpl::GetInstance(*pPerson)->SetIsFavorite(boolValue);
+
+       contacts_record_get_bool(recordHandle, _contacts_person.has_phonenumber, &boolValue);
+       _PersonImpl::GetInstance(*pPerson)->SetHasPhoneNumber(boolValue);
+
+       contacts_record_get_bool(recordHandle, _contacts_person.has_email, &boolValue);
+       _PersonImpl::GetInstance(*pPerson)->SetHasEmail(boolValue);
+
+       contacts_record_get_str_p(recordHandle, _contacts_person.image_thumbnail_path, &pCharValue);
+       _PersonImpl::GetInstance(*pPerson)->SetThumbnailPath(pCharValue);
+
+       contacts_record_get_str_p(recordHandle, _contacts_person.ringtone_path, &pCharValue);
+       _PersonImpl::GetInstance(*pPerson)->SetRingtonePath(pCharValue);
+
+       contacts_record_get_str_p(recordHandle, _contacts_person.display_name, &pCharValue);
+       _PersonImpl::GetInstance(*pPerson)->SetDisplayName(pCharValue);
+
+       return pPerson.release();
+}
+
+template<>
+Person*
+__ContactsPersonGroupRel::ConvertHandleTo<Person>(contacts_record_h recordHandle)
+{
+       int intValue = 0;
+       char* pCharValue = null;
+       bool boolValue = false;
+
+       std::unique_ptr<Person> pPerson(_AddressbookUtil::CreatePersonN());
+       SysTryReturn(NID_SCL, pPerson != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_int(recordHandle, _contacts_person_grouprel.person_id, &intValue);
+       _PersonImpl::GetInstance(*pPerson)->SetId(intValue);
+
+       contacts_record_get_str_p(recordHandle, _contacts_person_grouprel.addressbook_ids, &pCharValue);
+       _PersonImpl::GetInstance(*pPerson)->SetAddressbookIdString(pCharValue);
+
+       contacts_record_get_bool(recordHandle, _contacts_person_grouprel.is_favorite, &boolValue);
+       _PersonImpl::GetInstance(*pPerson)->SetIsFavorite(boolValue);
+
+       contacts_record_get_bool(recordHandle, _contacts_person_grouprel.has_phonenumber, &boolValue);
+       _PersonImpl::GetInstance(*pPerson)->SetHasPhoneNumber(boolValue);
+
+       contacts_record_get_bool(recordHandle, _contacts_person_grouprel.has_email, &boolValue);
+       _PersonImpl::GetInstance(*pPerson)->SetHasEmail(boolValue);
+
+       contacts_record_get_str_p(recordHandle, _contacts_person_grouprel.image_thumbnail_path, &pCharValue);
+       _PersonImpl::GetInstance(*pPerson)->SetThumbnailPath(pCharValue);
+
+       contacts_record_get_str_p(recordHandle, _contacts_person_grouprel.ringtone_path, &pCharValue);
+       _PersonImpl::GetInstance(*pPerson)->SetRingtonePath(pCharValue);
+
+       contacts_record_get_str_p(recordHandle, _contacts_person_grouprel.display_name, &pCharValue);
+       _PersonImpl::GetInstance(*pPerson)->SetDisplayName(pCharValue);
+
+       return pPerson.release();
+}
+
+template<>
+ContactChangeInfo*
+__ContactsContactUpdatedInfo::ConvertResultTo(__SearchResult<__ContactsContactUpdatedInfo>& searchResult)
+{
+       int intValue = 0;
+       bool boolValue = false;
+       RecordChangeType changeType = RECORD_CHANGE_TYPE_ADDED;
+
+       contacts_record_h currentRecord = searchResult.GetCurrentRecord();
+       SysTryReturn(NID_SCL, currentRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<ContactChangeInfo> pContactChagneInfo(new (std::nothrow) ContactChangeInfo());
+       SysTryReturn(NID_SCL, pContactChagneInfo != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       contacts_record_get_int(currentRecord, _contacts_contact_updated_info.contact_id, &intValue);
+       _ContactChangeInfoImpl::GetInstance(*pContactChagneInfo)->SetContactId(intValue);
+
+       contacts_record_get_int(currentRecord, _contacts_contact_updated_info.address_book_id, &intValue);
+       _ContactChangeInfoImpl::GetInstance(*pContactChagneInfo)->SetAddressbookId(intValue);
+
+       contacts_record_get_int(currentRecord, _contacts_contact_updated_info.type, &intValue);
+
+       switch (intValue)
+       {
+               case CONTACTS_CHANGE_INSERTED:
+                       changeType = RECORD_CHANGE_TYPE_ADDED;
+                       break;
+               case CONTACTS_CHANGE_UPDATED:
+                       changeType = RECORD_CHANGE_TYPE_UPDATED;
+                       break;
+               case CONTACTS_CHANGE_DELETED:
+                       // fall through
+               default:
+                       changeType = RECORD_CHANGE_TYPE_REMOVED;
+                       break;
+       }
+
+       _ContactChangeInfoImpl::GetInstance(*pContactChagneInfo)->SetChangeType(changeType);
+
+       contacts_record_get_int(currentRecord, _contacts_contact_updated_info.version, &intValue);
+       _ContactChangeInfoImpl::GetInstance(*pContactChagneInfo)->SetVersion(intValue);
+
+       contacts_record_get_bool(currentRecord, _contacts_contact_updated_info.image_changed, &boolValue);
+       _ContactChangeInfoImpl::GetInstance(*pContactChagneInfo)->SetThumbnailChangeStatus(boolValue);
+
+       return pContactChagneInfo.release();
+}
+
+template<>
+CategoryChangeInfo*
+__ContactsGroupUpdatedInfo::ConvertResultTo(__SearchResult<__ContactsGroupUpdatedInfo>& searchResult)
+{
+       int intValue = 0;
+       RecordChangeType changeType = RECORD_CHANGE_TYPE_ADDED;
+
+       contacts_record_h currentRecord = searchResult.GetCurrentRecord();
+       SysTryReturn(NID_SCL, currentRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<CategoryChangeInfo> pCategoryChangeInfo(new (std::nothrow) CategoryChangeInfo());
+       SysTryReturn(NID_SCL, pCategoryChangeInfo != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       contacts_record_get_int(currentRecord, _contacts_group_updated_info.group_id, &intValue);
+       _CategoryChangeInfoImpl::GetInstance(*pCategoryChangeInfo)->SetCategoryId(intValue);
+
+       contacts_record_get_int(currentRecord, _contacts_group_updated_info.address_book_id, &intValue);
+       _CategoryChangeInfoImpl::GetInstance(*pCategoryChangeInfo)->SetAddressbookId(intValue);
+
+       contacts_record_get_int(currentRecord, _contacts_group_updated_info.type, &intValue);
+
+       switch (intValue)
+       {
+               case CONTACTS_CHANGE_INSERTED:
+                       changeType = RECORD_CHANGE_TYPE_ADDED;
+                       break;
+               case CONTACTS_CHANGE_UPDATED:
+                       changeType = RECORD_CHANGE_TYPE_UPDATED;
+                       break;
+               case CONTACTS_CHANGE_DELETED:
+                       // fall through
+               default:
+                       changeType = RECORD_CHANGE_TYPE_REMOVED;
+                       break;
+       }
+
+       _CategoryChangeInfoImpl::GetInstance(*pCategoryChangeInfo)->SetChangeType(changeType);
+
+       contacts_record_get_int(currentRecord, _contacts_group_updated_info.version, &intValue);
+       _CategoryChangeInfoImpl::GetInstance(*pCategoryChangeInfo)->SetVersion(intValue);
+
+       return pCategoryChangeInfo.release();
+}
+
+template<>
+CategoryChangeInfo*
+__ContactsGroupRelUpdatedInfo::ConvertResultTo(__SearchResult<__ContactsGroupRelUpdatedInfo>& searchResult)
+{
+       int intValue = 0;
+
+       contacts_record_h currentRecord = searchResult.GetCurrentRecord();
+       SysTryReturn(NID_SCL, currentRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<CategoryChangeInfo> pCategoryChangeInfo(new (std::nothrow) CategoryChangeInfo());
+       SysTryReturn(NID_SCL, pCategoryChangeInfo != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_int(currentRecord, _contacts_grouprel_updated_info.group_id, &intValue);
+       _CategoryChangeInfoImpl::GetInstance(*pCategoryChangeInfo)->SetCategoryId(intValue);
+
+       contacts_record_get_int(currentRecord, _contacts_grouprel_updated_info.version, &intValue);
+       _CategoryChangeInfoImpl::GetInstance(*pCategoryChangeInfo)->SetVersion(intValue);
+
+       contacts_record_get_int(currentRecord, _contacts_grouprel_updated_info.address_book_id, &intValue);
+       _CategoryChangeInfoImpl::GetInstance(*pCategoryChangeInfo)->SetAddressbookId(intValue);
+
+       contacts_record_get_int(currentRecord, _contacts_grouprel_updated_info.type, &intValue);
+
+       _CategoryChangeInfoImpl::GetInstance(*pCategoryChangeInfo)->SetChangeType(RECORD_CHANGE_TYPE_UPDATED);
+
+       contacts_record_get_int(currentRecord, _contacts_grouprel_updated_info.version, &intValue);
+       _CategoryChangeInfoImpl::GetInstance(*pCategoryChangeInfo)->SetVersion(intValue);
+
+       return pCategoryChangeInfo.release();
+}
+
+template<>
+UserProfile*
+__ContactsUserProfile::ConvertResultTo<UserProfile>(__SearchResult<__ContactsUserProfile>& searchResult)
+{
+       contacts_record_h newRecord = null;
+
+       contacts_record_h currentRecord = searchResult.GetCurrentRecord();
+       SysTryReturn(NID_SCL, currentRecord != null, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(E_SYSTEM));
+
+       std::unique_ptr<UserProfile> pProfile(new (std::nothrow) UserProfile());
+       SysTryReturn(NID_SCL, pProfile != null, null, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_clone(currentRecord, &newRecord);
+       SysTryReturn(NID_SCL, newRecord != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       _UserProfileImpl::GetInstance(*pProfile)->SetUserProfileHandle(newRecord);
+
+       return pProfile.release();
+}
+
+template<>
+ __SearchResult<__ContactsPerson>*
+_AddressbookUtil::Search(const Tizen::Base::String& keyword)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       __SearchResult<__ContactsPerson>* pQueryResult = null;
+
+       contacts_list_h list = null;
+       std::unique_ptr<char[]> pKeyword(_StringConverter::CopyToCharArrayN(keyword));
+
+       int ret = contacts_db_search_records(__ContactsPerson::GetUri(), pKeyword.get(), 0, 0, &list);
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
+
+       pQueryResult = new (std::nothrow) __SearchResult<__ContactsPerson>(list);
+       SysTryReturn(NID_SCL, pQueryResult, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       return pQueryResult;
+}
+
+IListT<AddressbookId>*
+_AddressbookUtil::GetRwAbIdListN(void)
+{
+       ClearLastResult();
+
+       __Filter<__ContactsAddressbook> filter;
+       filter.Construct();
+       filter.AddInt(_contacts_address_book.mode, CONTACTS_MATCH_GREATER_THAN, 0);
+
+       __Query<__ContactsAddressbook> query;
+       query.Construct();
+       query.SetFilter(filter);
+
+       std::unique_ptr<IList, AllElementsDeleter> pAbList(SearchWithQueryN<__ContactsAddressbook, Addressbook>(query));
+       SysTryReturn(NID_SCL, pAbList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<IEnumerator> pEnum(pAbList->GetEnumeratorN());
+       SysTryReturn(NID_SCL, pEnum != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr< ArrayListT<AddressbookId> > pAbIdList(new (std::nothrow) ArrayListT<AddressbookId>);
+       SysTryReturn(NID_SCL, pAbIdList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pAbIdList->Construct(pAbList->GetCount());
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               Addressbook* pAddressbook = static_cast<Addressbook*>(pEnum->GetCurrent());
+
+               pAbIdList->Add(pAddressbook->GetId());
+       }
+
+       return pAbIdList.release();
+}
+
+result
+_AddressbookUtil::GetAbListN(IListT<AddressbookId>& rwAbIdList, IListT<AddressbookId>& roAbIdList)
+{
+       ClearLastResult();
+
+       __Query<__ContactsAddressbook> query;
+       query.Construct();
+
+       std::unique_ptr<__SearchResult<__ContactsAddressbook> > pSearchResult(_AddressbookUtil::ExecuteQuery(query, 0, 0));
+       if (pSearchResult == null)
+       {
+               return E_SUCCESS;
+       }
+
+       while (pSearchResult->MoveNext() == E_SUCCESS)
+       {
+               int intValue = 0;
+               contacts_record_h currentRecord = pSearchResult->GetCurrentRecord();
+
+               contacts_record_get_int(currentRecord, _contacts_address_book.mode, &intValue);
+               if (intValue == CONTACTS_ADDRESS_BOOK_MODE_NONE)
+               {
+                       contacts_record_get_int(currentRecord, _contacts_address_book.id, &intValue);
+
+                       rwAbIdList.Add(intValue);
+               }
+               else
+               {
+                       contacts_record_get_int(currentRecord, _contacts_address_book.id, &intValue);
+                       roAbIdList.Add(intValue);
+               }
+       }
+
+       return E_SUCCESS;
+}
+
+}}  // Tizen::Social
diff --git a/src/FScl_AddressbookUtil.h b/src/FScl_AddressbookUtil.h
new file mode 100644 (file)
index 0000000..cff8e99
--- /dev/null
@@ -0,0 +1,974 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_AddressbookUtil.h
+ * @brief              This is the header file for the _AddressbookUtil class.
+ *
+ * This header file contains the declarations of the _AddressbookUtil class.
+ */
+#ifndef _FSCL_INTERNAL_ADDRESSBOOK_UTIL_H_
+#define _FSCL_INTERNAL_ADDRESSBOOK_UTIL_H_
+
+#include <unique_ptr.h>
+#include <contacts.h>
+#include <FBaseColArrayList.h>
+#include <FBaseColArrayListT.h>
+#include <FBaseColAllElementsDeleter.h>
+#include "FScl_ContactDbConnector.h"
+
+namespace Tizen { namespace Social
+{
+
+class Person;
+class Contact;
+class UserProfile;
+
+typedef __contacts_record_h ContactRecord;
+
+struct ContactRecordDeleter
+{
+       void operator()(ContactRecord* pRecord)
+       {
+               contacts_record_destroy(pRecord, true);
+       }
+};
+
+class __ContactsRecordHandle
+{
+public:
+       __ContactsRecordHandle(contacts_record_h handle)
+       :__handle(handle)
+       {
+       }
+
+       ~__ContactsRecordHandle(void)
+       {
+               if (__handle != null)
+               {
+                       contacts_record_destroy(__handle, true);
+               }
+       }
+
+       void Reset(contacts_record_h handle)
+       {
+               if (__handle != null)
+               {
+                       contacts_record_destroy(__handle, true);
+               }
+
+               __handle = handle;
+       }
+
+       contacts_record_h Release(void)
+       {
+               contacts_record_h handle = __handle;
+               __handle = null;
+
+               return handle;
+       }
+
+private:
+       contacts_record_h __handle;
+};
+
+template<typename __View>
+class __SearchResult
+{
+public:
+       __SearchResult(contacts_list_h list)
+               :__list(list), __isFirst(true)
+       {
+
+       }
+
+       int GetCount(void) const
+       {
+               if (__list != null)
+               {
+                       unsigned int count = 0;
+                       contacts_list_get_count(__list, &count);
+
+                       return count;
+               }
+
+               return -1;
+       }
+
+       contacts_record_h GetCurrentRecord(void) const
+       {
+               if (__list != null)
+               {
+                       contacts_record_h record = null;
+                       int ret = contacts_list_get_current_record_p(__list, &record);
+                       if (ret != CONTACTS_ERROR_NONE)
+                       {
+                               return null;
+                       }
+
+                       return record;
+               }
+
+               return null;
+       }
+
+       result MoveNext(void)
+       {
+               if (__list != null)
+               {
+                       int ret = CONTACTS_ERROR_NONE;
+
+                       if (!__isFirst)
+                       {
+                               ret = contacts_list_next(__list);
+                               if (ret != CONTACTS_ERROR_NONE)
+                               {
+                                       return E_INVALID_OPERATION;
+                               }
+
+                               return E_SUCCESS;
+                       }
+                       else
+                       {
+                               if (GetCount() > 0)
+                               {
+                                       __isFirst = false;
+
+                                       return E_SUCCESS;
+                               }
+
+                               return E_INVALID_OPERATION;
+                       }
+               }
+
+               return E_INVALID_OPERATION;
+       }
+
+
+       ~__SearchResult(void)
+       {
+               if (__list != null)
+               {
+                       contacts_list_destroy(__list, true);
+               }
+       }
+
+private:
+       contacts_list_h __list;
+       bool __isFirst;
+};
+
+template<typename __View>
+class __Filter
+{
+public:
+       __Filter(void)
+       :__filterHandle(null)
+       ,__destroyFilterHandle(false)
+       {
+       }
+
+       result Construct(void)
+       {
+               contacts_filter_h filterHandle = null;
+               int ret = contacts_filter_create(__View::GetUri(), &filterHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+
+               __filterHandle = filterHandle;
+               __destroyFilterHandle = true;
+
+               return E_SUCCESS;
+       }
+
+       result Construct(contacts_filter_h filterHandle)
+       {
+               __filterHandle = filterHandle;
+               __destroyFilterHandle = false;
+
+               return E_SUCCESS;
+       }
+
+       contacts_filter_h Get(void) const
+       {
+               return __filterHandle;
+       }
+
+       result AddString(unsigned int propertyId, contacts_match_str_flag_e match, const char* value)
+       {
+               int ret = contacts_filter_add_str(__filterHandle, propertyId, match, value);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+
+               return E_SUCCESS;
+       }
+
+       result AddInt(unsigned int propertyId, contacts_match_int_flag_e match, int value)
+       {
+               int ret = contacts_filter_add_int(__filterHandle, propertyId, match, value);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+
+               return E_SUCCESS;
+       }
+
+       result AddLongLong(unsigned int propertyId, contacts_match_int_flag_e match, long long int value)
+       {
+               int ret = contacts_filter_add_lli(__filterHandle, propertyId, match, value);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+
+               return E_SUCCESS;
+       }
+
+       result AddDouble(unsigned int propertyId, contacts_match_int_flag_e match, double value)
+       {
+               int ret = contacts_filter_add_double(__filterHandle, propertyId, match, value);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+
+               return E_SUCCESS;
+       }
+
+       result AddBool(unsigned int propertyId, bool value)
+       {
+               int ret = contacts_filter_add_bool(__filterHandle, propertyId, value);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+
+               return E_SUCCESS;
+       }
+
+       result AddOperator(contacts_filter_operator_e type)
+       {
+               int ret = contacts_filter_add_operator(__filterHandle, type);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+
+               return E_SUCCESS;
+       }
+
+       result AddFilter(__Filter<__View>& filter)
+       {
+               contacts_filter_h handle = filter.Get();
+               int ret = contacts_filter_add_filter(__filterHandle, handle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+
+               return E_SUCCESS;
+       }
+
+       ~__Filter(void)
+       {
+               if (__filterHandle != null && __destroyFilterHandle)
+               {
+                       contacts_filter_destroy(__filterHandle);
+               }
+       }
+
+private:
+       contacts_filter_h __filterHandle;
+       bool __destroyFilterHandle;
+};
+
+template<typename __View>
+class __Query
+{
+public:
+       __Query(void)
+       :__queryHandle(null)
+       {
+       }
+
+       result Construct(void)
+       {
+               contacts_query_h queryHandle = null;
+               int ret = contacts_query_create(__View::GetUri(), &queryHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+
+               __queryHandle = queryHandle;
+
+               return E_SUCCESS;
+       }
+
+       contacts_query_h Get(void) const
+       {
+               return __queryHandle;
+       }
+
+
+       result SetProjection(unsigned int propertyIds[], int count)
+       {
+               int ret = contacts_query_set_projection(__queryHandle, propertyIds, count);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+
+               return E_SUCCESS;
+       }
+
+       result SetDistinct(bool set)
+       {
+               int ret = contacts_query_set_distinct(__queryHandle, set);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+
+               return E_SUCCESS;
+       }
+
+       result SetFilter(__Filter<__View>& filter)
+       {
+               contacts_filter_h filterHandle = filter.Get();
+
+               if (filterHandle != null)
+               {
+                       int ret = contacts_query_set_filter(__queryHandle, filterHandle);
+                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+               }
+
+               return E_SUCCESS;
+       }
+
+       result SetSort(unsigned int propertyId, bool ascending)
+       {
+               int ret = contacts_query_set_sort(__queryHandle, propertyId, ascending);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+
+               return E_SUCCESS;
+       }
+
+       ~__Query(void)
+       {
+               if (__queryHandle != null)
+               {
+                       contacts_query_destroy(__queryHandle);
+               }
+       }
+
+private:
+       contacts_query_h __queryHandle;
+
+};
+
+class __ContactsAddressbook
+{
+public:
+       static const char* GetUri(void)
+       {
+               return _contacts_address_book._uri;
+       }
+
+       template<typename Type>
+       static Type* ConvertResultTo(__SearchResult<__ContactsAddressbook>& searchResult);
+
+       static int GetAbPropertyId(void)
+       {
+               return _contacts_address_book.id;
+       }
+
+};
+
+class __ContactsPerson
+{
+public:
+       static const char* GetUri(void)
+       {
+               return _contacts_person._uri;
+       }
+
+       template<typename Type>
+       static Type* ConvertResultTo(__SearchResult<__ContactsPerson>& searchResult);
+
+       template<typename Type>
+       static Type* ConvertHandleTo(contacts_record_h recordHandle);
+};
+
+
+class __ContactsPersonEmail
+{
+public:
+       static const char* GetUri(void)
+       {
+               return _contacts_person_email._uri;
+       }
+};
+
+class __ContactsPersonGroupRel
+{
+public:
+       static const char* GetUri(void)
+       {
+               return _contacts_person_grouprel._uri;
+       }
+
+       template<typename Type>
+       static Type* ConvertHandleTo(contacts_record_h recordHandle);
+
+       template<typename Type>
+       static Type* ConvertResultTo(__SearchResult<__ContactsPersonGroupRel>& searchResult);
+
+       static int GetAbPropertyId(void)
+       {
+               return _contacts_person_grouprel.address_book_id;
+       }
+};
+
+class __ContactsPersonNumber
+{
+public:
+       static const char* GetUri(void)
+       {
+               return _contacts_person_number._uri;
+       }
+};
+
+
+class __ContactsGroup
+{
+public:
+       static const char* GetUri(void)
+       {
+               return _contacts_group._uri;
+       }
+
+       template<typename Type>
+       static Type* ConvertResultTo(__SearchResult<__ContactsGroup>& searchResult);
+
+       static int GetAbPropertyId(void)
+       {
+               return _contacts_group.address_book_id;
+       }
+};
+
+class __ContactsGroupRelation
+{
+public:
+       static const char* GetUri(void)
+       {
+               return _contacts_group_relation._uri;
+       }
+
+       template<typename Type>
+       static Type* ConvertResultTo(__SearchResult<__ContactsGroupRelation>& searchResult);
+};
+
+class __ContactsContact
+{
+public:
+       static const char* GetUri(void)
+       {
+               return _contacts_contact._uri;
+       }
+
+       template<typename Type>
+       static Type* ConvertResultTo(__SearchResult<__ContactsContact>& searchResult);
+
+       static int GetAbPropertyId(void)
+       {
+               return _contacts_contact.address_book_id;
+       }
+};
+
+class __ContactsContactGroupRel
+{
+public:
+       static const char* GetUri(void)
+       {
+               return _contacts_contact_grouprel._uri;
+       }
+
+       template<typename Type>
+       static Type* ConvertResultTo(__SearchResult<__ContactsContactGroupRel>& searchResult);
+
+       static int GetAbPropertyId(void)
+       {
+               return _contacts_contact_grouprel.address_book_id;
+       }
+};
+
+class __ContactsContactEmail
+{
+public:
+       static const char* GetUri(void)
+       {
+               return _contacts_contact_email._uri;
+       }
+
+       template<typename Type>
+       static Type* ConvertResultTo(__SearchResult<__ContactsContactEmail>& searchResult);
+
+       static int GetAbPropertyId(void)
+       {
+               return _contacts_contact_email.address_book_id;
+       }
+};
+
+class __ContactsContactNumber
+{
+public:
+       static const char* GetUri(void)
+       {
+               return _contacts_contact_number._uri;
+       }
+
+       template<typename Type>
+       static Type* ConvertResultTo(__SearchResult<__ContactsContactNumber>& searchResult);
+
+       static int GetAbPropertyId(void)
+       {
+               return _contacts_contact_number.address_book_id;
+       }
+};
+
+class __ContactsContactUpdatedInfo
+{
+public:
+       static const char* GetUri(void)
+       {
+               return _contacts_contact_updated_info._uri;
+       }
+
+       template<typename Type>
+       static Type* ConvertResultTo(__SearchResult<__ContactsContactUpdatedInfo>& searchResult);
+};
+
+class __ContactsMyProfileUpdatedInfo
+{
+public:
+       static const char* GetUri(void)
+       {
+               return _contacts_my_profile_updated_info._uri;
+       }
+};
+
+class __ContactsGroupUpdatedInfo
+{
+public:
+       static const char* GetUri(void)
+       {
+               return _contacts_group_updated_info._uri;
+       }
+
+       template<typename Type>
+       static Type* ConvertResultTo(__SearchResult<__ContactsGroupUpdatedInfo>& searchResult);
+};
+
+class __ContactsGroupRelUpdatedInfo
+{
+public:
+       static const char* GetUri(void)
+       {
+               return _contacts_grouprel_updated_info._uri;
+       }
+
+       template<typename Type>
+       static Type* ConvertResultTo(__SearchResult<__ContactsGroupRelUpdatedInfo>& searchResult);
+};
+
+class __ContactsUserProfile
+{
+public:
+       static const char* GetUri(void)
+       {
+               return _contacts_my_profile._uri;
+       }
+
+       template<typename Type>
+       static Type* ConvertResultTo(__SearchResult<__ContactsUserProfile>& searchResult);
+
+       static int GetAbPropertyId(void)
+       {
+               return _contacts_my_profile.address_book_id;
+       }
+};
+
+extern "C"  void ctsvc_view_uri_init();
+
+class _AddressbookUtil
+{
+public:
+       static void InitContactViews(void)
+       {
+               ctsvc_view_uri_init();
+       }
+
+       template<typename __View>
+       static __SearchResult<__View>* ExecuteQuery(const __Query<__View>& query, int offset = 0, int limit = 0)
+       {
+               SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+               __SearchResult<__View>* pSearchResult = null;
+
+               contacts_list_h list = null;
+               int ret = contacts_db_get_records_with_query(query.Get(), offset, limit, &list);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_NO_DATA, null, E_OBJ_NOT_FOUND, "[%s] No matched item found. (%d)", GetErrorMessage(E_OBJ_NOT_FOUND), ret);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred. (%d)", GetErrorMessage(E_SYSTEM), ret);
+
+               pSearchResult = new (std::nothrow) __SearchResult<__View>(list);
+               SysTryReturn(NID_SCL, pSearchResult != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               return pSearchResult;
+       }
+
+       template<typename __View>
+       static int GetCountWithQuery(const __Query<__View>& query)
+       {
+               SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+               int count = 0;
+               int ret = contacts_db_get_count_with_query(query.Get(), &count);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, -1, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, -1, E_SYSTEM, "[%s] A system error has been occurred. (%d)", GetErrorMessage(E_SYSTEM), ret);
+
+               return count;
+       }
+
+       template<typename __View>
+       static int GetCount(void)
+       {
+               SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+               int count = 0;
+               int ret = contacts_db_get_count(__View::GetUri(), &count);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, -1, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, -1, E_SYSTEM, "[%s] A system error has been occurred. (%d)", GetErrorMessage(E_SYSTEM), ret);
+
+               return count;
+       }
+
+       template<typename __View>
+       static __SearchResult<__View>* GetAllRecords(int offset = 0, int limit = 0)
+       {
+               SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+               __SearchResult<__View>* pSearchResult = null;
+
+               contacts_list_h list = null;
+               int ret = contacts_db_get_all_records(__View::GetUri(), offset, limit, &list);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred. (%d)", GetErrorMessage(E_SYSTEM), ret);
+
+               pSearchResult = new (std::nothrow) __SearchResult<__View>(list);
+               SysTryReturn(NID_SCL, pSearchResult, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               return pSearchResult;
+       }
+
+       template<typename __View>
+       static __SearchResult<__View>* GetChangesByVersion(int id, int current, int& latest)
+       {
+               SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+               __SearchResult<__View>* pSearchResult = null;
+
+               contacts_list_h list = null;
+               int ret = contacts_db_get_changes_by_version(__View::GetUri(), id, current, &list, &latest);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred. (%d)", GetErrorMessage(E_SYSTEM), ret);
+
+               pSearchResult = new (std::nothrow) __SearchResult<__View>(list);
+               SysTryReturn(NID_SCL, pSearchResult, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               return pSearchResult;
+       }
+
+       template<typename __View>
+       static int GetChangedItemCountByVersion(int id, int current, int& latest)
+       {
+               SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+               unsigned int count = 0;
+               contacts_list_h list = null;
+               int ret = contacts_db_get_changes_by_version(__View::GetUri(), id, current, &list, &latest);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, -1, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, -1, E_SYSTEM, "[%s] A system error has been occurred. (%d)", GetErrorMessage(E_SYSTEM), ret);
+
+               contacts_list_get_count(list, &count);
+               contacts_list_destroy(list, true);
+
+               return count;
+       }
+
+       template<typename __View>
+       static __SearchResult<__View>* Search(const Tizen::Base::String& keyword);
+
+       static Person* CreatePersonN(void);
+
+       template<typename __View, typename ChangeInfo>
+       static Tizen::Base::Collection::IList* SearchWithVersionN(int addressbookId, int currentVersion, int& latestVersion, Tizen::Base::Collection::IListT<AddressbookId>* pRwAbIdList = null)
+       {
+               SysTryReturn(NID_SCL, currentVersion >= 0, null, E_INVALID_ARG, "[%s] currentVersion %d must be greater that or equal 0.", GetErrorMessage(GetLastResult()), currentVersion);
+
+               std::unique_ptr<ChangeInfo> pChangeInfo(null);
+
+               ClearLastResult();
+
+               std::unique_ptr<Tizen::Base::Collection::ArrayList, Tizen::Base::Collection::AllElementsDeleter> pList(new (std::nothrow) Tizen::Base::Collection::ArrayList());
+               SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               result r = pList->Construct();
+               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               std::unique_ptr<__SearchResult<__View> > pSearchResult(_AddressbookUtil::template GetChangesByVersion<__View>(addressbookId, currentVersion, latestVersion));
+               SysTryReturn(NID_SCL, pSearchResult != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+               while (pSearchResult->MoveNext() == E_SUCCESS)
+               {
+                       pChangeInfo.reset(__View::template ConvertResultTo<ChangeInfo>(*pSearchResult));
+                       if (pRwAbIdList != null && (pRwAbIdList->Contains(pChangeInfo->GetAddressbookId())))
+                       {
+                               continue;
+                       }
+
+                       if (pChangeInfo == null)
+                       {
+                               SysTryReturn(NID_SCL, GetLastResult() != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+                               SysTryReturn(NID_SCL, GetLastResult() != E_SYSTEM, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+                               ClearLastResult();
+                               continue;
+                       }
+
+                       r = pList->Add(*pChangeInfo);
+                       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+                       pChangeInfo.release();
+               }
+
+               return pList.release();
+
+       }
+
+       template<typename __View, typename Data>
+       static Tizen::Base::Collection::IList* SearchWithQueryN(__Query<__View>& query, int offset = 0, int limit = 0)
+       {
+               std::unique_ptr<Data> pData(null);
+
+               std::unique_ptr<Tizen::Base::Collection::ArrayList, Tizen::Base::Collection::AllElementsDeleter> pDataList(new (std::nothrow) Tizen::Base::Collection::ArrayList());
+               SysTryReturn(NID_SCL, pDataList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               result r = pDataList->Construct();
+               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               std::unique_ptr<__SearchResult<__View> > pSearchResult(_AddressbookUtil::ExecuteQuery(query, offset, limit));
+               if (pSearchResult == null)
+               {
+                       SysTryReturn(NID_SCL, GetLastResult() == E_OBJ_NOT_FOUND, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+                       ClearLastResult();
+
+                       return pDataList.release();
+               }
+
+               while (pSearchResult->MoveNext() == E_SUCCESS)
+               {
+                       pData.reset(__View::template ConvertResultTo<Data>(*pSearchResult));
+                       if (pData == null)
+                       {
+                               SysTryReturn(NID_SCL, GetLastResult() != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+                               SysTryReturn(NID_SCL, GetLastResult() != E_SYSTEM, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+                               ClearLastResult();
+                               continue;
+                       }
+
+                       r = pDataList->Add(*pData);
+                       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+                       pData.release();
+               }
+
+               return pDataList.release();
+       }
+
+       template<typename __View>
+       static int GetMatchedItemCountWithFilter(contacts_filter_h filterHandle)
+       {
+               int count = 0;
+
+               if (filterHandle != null)
+               {
+                       __Filter<__View> filter;
+                       filter.Construct(filterHandle);
+
+                       __Query<__View> query;
+                       query.Construct();
+                       query.SetFilter(filter);
+
+                       count = _AddressbookUtil::GetCountWithQuery(query);
+               }
+               else
+               {
+                       __Query<__View> query;
+                       query.Construct();
+
+                       count = _AddressbookUtil::GetCountWithQuery(query);
+               }
+
+               return count;
+       }
+
+       static ContactRecord* CreateContactRecordN(const char* pUri)
+       {
+               ClearLastResult();
+
+               contacts_record_h recordHandle = null;
+
+               int ret = contacts_record_create(pUri, &recordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+
+               return recordHandle;
+       }
+
+       static result InsertContactRecordN(contacts_record_h recordHandle, int& recordId)
+       {
+               int ret = contacts_db_insert_record(recordHandle, &recordId);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is insufficient. (%d)", GetErrorMessage(E_STORAGE_FULL), ret);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred. (%d)", GetErrorMessage(E_SYSTEM), ret);
+
+               return E_SUCCESS;
+       }
+
+       static result DeleteContactRecord(const char* pUri, int recordId)
+       {
+               int ret = contacts_db_delete_record(pUri, recordId);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_NO_DATA, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The record is not found. (%d)", GetErrorMessage(E_OBJ_NOT_FOUND), ret);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred. (%d)", GetErrorMessage(E_SYSTEM), ret);
+
+               return E_SUCCESS;
+       }
+
+       static result UpdateContactRecord(contacts_record_h recordHandle)
+       {
+               int ret = contacts_db_update_record(recordHandle);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_NO_DATA, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The Record is not found. (%d)", GetErrorMessage(E_OBJ_NOT_FOUND), ret);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is insufficient. (%d)", GetErrorMessage(E_STORAGE_FULL), ret);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred. Failed to update a contact", GetErrorMessage(E_SYSTEM));
+
+               return E_SUCCESS;
+       }
+
+       static result UpdateContactRecords(contacts_list_h listHandle)
+       {
+               int ret = contacts_db_update_records(listHandle);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_NO_DATA, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The contact is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+               return E_SUCCESS;
+       }
+
+       static ContactRecord* GetContactRecordN(const char* pUri, RecordId recordId)
+       {
+               ClearLastResult();
+
+               contacts_record_h recordHandle = null;
+
+               int ret = contacts_db_get_record(pUri, recordId, &recordHandle);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_NO_DATA, null, E_OBJ_NOT_FOUND, "[%s] The record is not found. (%d)", GetErrorMessage(E_OBJ_NOT_FOUND), ret);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred. (%d)", GetErrorMessage(E_SYSTEM), ret);
+
+               return recordHandle;
+       }
+
+       static result AddContactToCategory(RecordId categoryId, RecordId contactId)
+       {
+               int ret = contacts_group_add_contact(categoryId, contactId);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+               return E_SUCCESS;
+       }
+
+       static result RemoveContactFromCategory(RecordId categoryId, RecordId contactId)
+       {
+
+               int ret = contacts_group_remove_contact(categoryId, contactId);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+               return E_SUCCESS;
+       }
+
+       static Tizen::Base::Collection::IListT<AddressbookId>* GetRwAbIdListN(void);
+       static Tizen::Base::Collection::IListT<AddressbookId>* GetRoAbIdListN(void);
+
+       static result GetAbListN(Tizen::Base::Collection::IListT<AddressbookId>& rwAbIdList, Tizen::Base::Collection::IListT<AddressbookId>& roAbIdList);
+
+       template<typename __View>
+       static __Filter<__View>* GetRwAbFilterN(void)
+       {
+               std::unique_ptr< __Filter<__View> > pFilter(new (std::nothrow) __Filter<__View>);
+               SysTryReturn(NID_SCL, pFilter != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               Tizen::Base::Collection::ArrayListT<AddressbookId> rwAbIdList;
+               rwAbIdList.Construct();
+
+               Tizen::Base::Collection::ArrayListT<AddressbookId> roAbIdList;
+               roAbIdList.Construct();
+
+               GetAbListN(rwAbIdList, roAbIdList);
+
+               if (roAbIdList.GetCount() == 0)
+               {
+                       // return null filter
+                       return pFilter.release();
+               }
+
+               pFilter->Construct();
+
+               bool isFirst = true;
+               AddressbookId addressbookId = -1;
+
+               if (rwAbIdList.GetCount() < 5)
+               {
+                       std::unique_ptr< Tizen::Base::Collection::IEnumeratorT<AddressbookId> > pEnum(rwAbIdList.GetEnumeratorN());
+                       while (pEnum->MoveNext() == E_SUCCESS)
+                       {
+                               pEnum->GetCurrent(addressbookId);
+                               if (!isFirst)
+                               {
+                                       pFilter->AddOperator(CONTACTS_FILTER_OPERATOR_OR);
+                               }
+                               else
+                               {
+                                       isFirst = false;
+                               }
+
+                               pFilter->AddInt(__View::GetAbPropertyId(), CONTACTS_MATCH_EQUAL, addressbookId);
+                       }
+               }
+               else
+               {
+                       std::unique_ptr< Tizen::Base::Collection::IEnumeratorT<AddressbookId> > pEnum(roAbIdList.GetEnumeratorN());
+                       while (pEnum->MoveNext() == E_SUCCESS)
+                       {
+                               pEnum->GetCurrent(addressbookId);
+                               if (!isFirst)
+                               {
+                                       pFilter->AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+                               }
+                               else
+                               {
+                                       isFirst = false;
+                               }
+
+                               pFilter->AddInt(__View::GetAbPropertyId(), CONTACTS_MATCH_NOT_EQUAL, addressbookId);
+                       }
+               }
+
+               return pFilter.release();
+       }
+};
+
+}} // Tizen::Social
+
+#endif //_FSCL_INTERNAL_ADDRESSBOOK_UTIL_H_
diff --git a/src/FScl_CalEventChangeInfoImpl.cpp b/src/FScl_CalEventChangeInfoImpl.cpp
new file mode 100644 (file)
index 0000000..542b0a7
--- /dev/null
@@ -0,0 +1,158 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_CalEventChangeInfoImpl.cpp
+ * @brief              This is the implementation for _CalEventChangeInfoImpl class.
+ *
+ * This file contains definitions of @e _CalEventChangeInfoImpl class.
+ */
+
+#include <FSclCalEventChangeInfo.h>
+#include <FSclRecord.h>
+#include "FScl_CalEventChangeInfoImpl.h"
+#include "FScl_RecordImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+const static int _INVALID_VERSION = -1;
+
+_CalEventChangeInfoImpl::_CalEventChangeInfoImpl(void)
+       : __changeType(RECORD_CHANGE_TYPE_ADDED)
+       , __eventId(INVALID_RECORD_ID)
+       , __calendarId(INVALID_RECORD_ID)
+       , __version(_INVALID_VERSION)
+{
+}
+
+_CalEventChangeInfoImpl::_CalEventChangeInfoImpl(const _CalEventChangeInfoImpl& rhs)
+       : __changeType(rhs.__changeType)
+       , __eventId(rhs.__eventId)
+       , __calendarId(rhs.__calendarId)
+       , __version(rhs.__version)
+{
+}
+
+_CalEventChangeInfoImpl::~_CalEventChangeInfoImpl(void)
+{
+}
+
+_CalEventChangeInfoImpl&
+_CalEventChangeInfoImpl::operator =(const _CalEventChangeInfoImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __changeType = rhs.__changeType;
+       __eventId = rhs.__eventId;
+       __calendarId = rhs.__calendarId;
+       __version = rhs.__version;
+
+       return *this;
+}
+
+bool
+_CalEventChangeInfoImpl::Equals(const Object& rhs) const
+{
+       const _CalEventChangeInfoImpl* pCalEventChangeInfoImpl = dynamic_cast<const _CalEventChangeInfoImpl*>(&rhs);
+
+       if (pCalEventChangeInfoImpl == null)
+       {
+               return false;
+       }
+
+       return (__changeType == pCalEventChangeInfoImpl->__changeType && __eventId == pCalEventChangeInfoImpl->__eventId
+                       && __calendarId == pCalEventChangeInfoImpl->__calendarId && __version == pCalEventChangeInfoImpl->__version);
+}
+
+int
+_CalEventChangeInfoImpl::GetHashCode(void) const
+{
+       int hashCode = 17;
+
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __changeType;
+       hashCode = static_cast<int>(( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __eventId);
+       hashCode = static_cast<int>(( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __calendarId);
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __version;
+
+       return hashCode;
+}
+
+RecordChangeType
+_CalEventChangeInfoImpl::GetChangeType(void) const
+{
+       return __changeType;
+}
+
+RecordId
+_CalEventChangeInfoImpl::GetEventId(void) const
+{
+       return __eventId;
+}
+
+RecordId
+_CalEventChangeInfoImpl::GetCalendarId(void) const
+{
+       return __calendarId;
+}
+
+int
+_CalEventChangeInfoImpl::GetVersion(void) const
+{
+       return __version;
+}
+
+void
+_CalEventChangeInfoImpl::SetChangeType(RecordChangeType changeType)
+{
+       __changeType = changeType;
+}
+
+void
+_CalEventChangeInfoImpl::SetEventId(RecordId eventId)
+{
+       __eventId = eventId;
+}
+
+void
+_CalEventChangeInfoImpl::SetCalendarId(RecordId calendarId)
+{
+       __calendarId = calendarId;
+}
+
+void
+_CalEventChangeInfoImpl::SetVersion(int version)
+{
+       __version = version;
+}
+
+_CalEventChangeInfoImpl*
+_CalEventChangeInfoImpl::GetInstance(CalEventChangeInfo& calEventChangeInfo)
+{
+       return calEventChangeInfo.__pCalEventChangeInfoImpl;
+}
+
+const _CalEventChangeInfoImpl*
+_CalEventChangeInfoImpl::GetInstance(const CalEventChangeInfo& calEventChangeInfo)
+{
+       return calEventChangeInfo.__pCalEventChangeInfoImpl;
+}
+
+}}     // Tizen::Social
diff --git a/src/FScl_CalEventImpl.cpp b/src/FScl_CalEventImpl.cpp
new file mode 100644 (file)
index 0000000..aeba234
--- /dev/null
@@ -0,0 +1,2390 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_CalEventImpl.cpp
+ * @brief              This is the implementation for _CalEventImpl class.
+ *
+ * This file contains definitions of @e _CalEventImpl class.
+ */
+
+#include <new>
+#include <string.h>
+#include <FApp_AppInfo.h>
+#include <FBaseColArrayList.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include <FLclCalendar.h>
+#include <FLclGregorianCalendar.h>
+#include <FLclTimeZone.h>
+#include <FSclAttendee.h>
+#include <FSclCalEvent.h>
+#include <FSclRecord.h>
+#include <FSysSystemTime.h>
+#include "FScl_RecordImpl.h"
+#include "FScl_CalEventImpl.h"
+#include "FScl_RecurrenceImpl.h"
+#include "FScl_CalendarbookImpl.h"
+#include "FScl_CalendarbookDbConnector.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Locales;
+using namespace Tizen::System;
+
+namespace Tizen { namespace Social
+{
+
+static const int _DEFAULT_ADDED_HOUR = 1;
+static const int _INVALID_ATTENDEE_INDEX = -1;
+
+static const int _TERM_LIMIT_DAILY = 1;
+static const int _TERM_LIMIT_WEEKLY = 7;
+static const int _TERM_LIMIT_MONTHLY = 31;
+static const int _TERM_LIMIT_YEARLY = 366;
+static const int _NUMBER_OF_DAYS_OF_WEEK = 7;
+
+static const wchar_t* _EVENT_CATEGORY_APPOINTMENT_STRING = L"Appointment";
+static const wchar_t* _EVENT_CATEGORY_ANNIVERSARY_STRING = L"Anniversary";
+
+static const wchar_t* _RECURRENCE_KEYWORD_SUNDAY = L"SU";
+static const wchar_t* _RECURRENCE_KEYWORD_MONDAY = L"MO";
+static const wchar_t* _RECURRENCE_KEYWORD_TUESDAY = L"TU";
+static const wchar_t* _RECURRENCE_KEYWORD_WEDNESDAY = L"WE";
+static const wchar_t* _RECURRENCE_KEYWORD_THURSDAY = L"TH";
+static const wchar_t* _RECURRENCE_KEYWORD_FRIDAY = L"FR";
+static const wchar_t* _RECURRENCE_KEYWORD_SATURDAY = L"SA";
+
+static const wchar_t* _RECURRENCE_DELIMITER = L",";
+static const int _RECURRENCE_DELIMITER_LENGTH = 1;
+static const wchar_t _RECURRENCE_BY_DAY_CHAR_PLUS = L'+';
+static const wchar_t _RECURRENCE_BY_DAY_CHAR_MINUS = L'-';
+static const wchar_t _RECURRENCE_BY_DAY_CHAR_ONE = L'1';
+static const int _RECURRENCE_BY_DAY_FIRST_INDEX = 0;
+static const int _RECURRENCE_BY_DAY_SECOND_INDEX = 1;
+static const int _MAX_WEEK_OF_MONTH = 5;
+
+static const double _MIN_LATITUDE = -90.0;
+static const double _MAX_LATITUDE = 90.0;
+static const double _MIN_LONGITUDE = -180.0;
+static const double _MAX_LONGITUDE = 180.0;
+
+_CalEventImpl::_CalEventImpl(void)
+       : __originalEventId(INVALID_RECORD_ID)
+       , __isInstance(false)
+       , __reminderListUpdated(false)
+{
+       // Set default start and end time
+       DateTime startTime;
+       SystemTime::GetCurrentTime(startTime);
+       if (IsFailed(GetLastResult()))
+       {
+               startTime = _CalendarbookImpl::GetMinDateTime();
+               ClearLastResult();
+       }
+
+       DateTime endTime(startTime);
+       result r = endTime.AddHours(_DEFAULT_ADDED_HOUR);
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       calendar_time_s startCalendarTime;
+       calendar_time_s endCalendarTime;
+       startCalendarTime.type = CALENDAR_TIME_UTIME;
+       endCalendarTime.type = CALENDAR_TIME_UTIME;
+       startCalendarTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(startTime);
+       endCalendarTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(endTime);
+
+       r = _CalendarbookDbConnector::Connect();
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       calendar_record_h eventHandle = null;
+       int errorCode = calendar_record_create(_calendar_event._uri, &eventHandle);
+       SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __eventRecord.ResetHandle(eventHandle);
+
+       calendar_record_set_caltime(eventHandle, _calendar_event.start_time, startCalendarTime);
+       calendar_record_set_caltime(eventHandle, _calendar_event.end_time, endCalendarTime);
+
+       // default value
+       calendar_record_set_int(eventHandle, _calendar_event.event_status, CALENDAR_EVENT_STATUS_NONE);
+       calendar_record_set_int(eventHandle, _calendar_event.busy_status, CALENDAR_EVENT_BUSY_STATUS_FREE);
+       calendar_record_set_int(eventHandle, _calendar_event.priority, CALENDAR_EVENT_PRIORITY_NORMAL);
+       calendar_record_set_int(eventHandle, _calendar_event.sensitivity, CALENDAR_SENSITIVITY_PUBLIC);
+       calendar_record_set_int(eventHandle, _calendar_event.calendar_book_id, INVALID_RECORD_ID);
+
+       r = __reminderList.Construct();
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+_CalEventImpl::_CalEventImpl(const _CalEventImpl& rhs)
+       : __originalEventId(rhs.__originalEventId)
+       , __isInstance(rhs.__isInstance)
+       , __reminderListUpdated(false)
+{
+       result r = _CalendarbookDbConnector::Connect();
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       calendar_record_h eventHandle = null;
+       int errorCode = calendar_record_clone(rhs.__eventRecord.GetHandle(), &eventHandle);
+       SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __eventRecord.ResetHandle(eventHandle);
+
+       r = __reminderList.Construct();
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+_CalEventImpl::~_CalEventImpl(void)
+{
+       calendar_record_destroy(__eventRecord.ReleaseHandle(), true);
+
+       __reminderList.RemoveAll(true);
+
+       result r = _CalendarbookDbConnector::Disconnect();
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+}
+
+_CalEventImpl&
+_CalEventImpl::operator =(const _CalEventImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __originalEventId = rhs.__originalEventId;
+       __isInstance = rhs.__isInstance;
+       __reminderList.RemoveAll(true);
+       __reminderListUpdated = false;
+
+       int errorCode = CALENDAR_ERROR_NONE;
+       calendar_record_h eventHandle = null;
+
+       errorCode = calendar_record_clone(rhs.__eventRecord.GetHandle(), &eventHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __eventRecord.ResetHandle(eventHandle);
+
+       return *this;
+}
+
+bool
+_CalEventImpl::IsInstance(void) const
+{
+       return __isInstance;
+}
+
+bool
+_CalEventImpl::IsRecurring(void) const
+{
+       int recurrenceFreq = CALENDAR_RECURRENCE_NONE;
+
+       calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.freq, &recurrenceFreq);
+
+       if (recurrenceFreq == CALENDAR_RECURRENCE_NONE)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+RecordId
+_CalEventImpl::GetOriginalCalEventId(void)  const
+{
+       return __originalEventId;
+}
+
+bool
+_CalEventImpl::IsAllDayEvent(void)  const
+{
+       calendar_time_s startCalendarTime;
+
+       calendar_record_get_caltime(__eventRecord.GetHandle(), _calendar_event.start_time, &startCalendarTime);
+       if (startCalendarTime.type == CALENDAR_TIME_UTIME)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+void
+_CalEventImpl::SetAllDayEvent(bool isAllDayEvent)
+{
+       if (GetCategory() == EVENT_CATEGORY_ANNIVERSARY)
+       {
+               return;
+       }
+
+       calendar_time_s startCalendarTime;
+       calendar_time_s tmpStartCalendarTime;
+       calendar_time_s endCalendarTime;
+       calendar_time_s tmpEndCalendarTime;
+
+       bool isChanged = false;
+
+       calendar_record_get_caltime(__eventRecord.GetHandle(), _calendar_event.start_time, &startCalendarTime);
+       calendar_record_get_caltime(__eventRecord.GetHandle(), _calendar_event.end_time, &endCalendarTime);
+
+       if (isAllDayEvent && startCalendarTime.type == CALENDAR_TIME_UTIME)
+       {
+               tmpStartCalendarTime.type = CALENDAR_TIME_LOCALTIME;
+               DateTime tmpStartTime = _CalendarbookUtil::ConvertEpochTimeToDateTime(startCalendarTime.time.utime);
+               tmpStartCalendarTime.time.date.year = tmpStartTime.GetYear();
+               tmpStartCalendarTime.time.date.month = tmpStartTime.GetMonth();
+               tmpStartCalendarTime.time.date.mday = tmpStartTime.GetDay();
+
+               tmpEndCalendarTime.type = CALENDAR_TIME_LOCALTIME;
+               DateTime tmpEndTime = _CalendarbookUtil::ConvertEpochTimeToDateTime(endCalendarTime.time.utime);
+               tmpEndCalendarTime.time.date.year = tmpEndTime.GetYear();
+               tmpEndCalendarTime.time.date.month = tmpEndTime.GetMonth();
+               tmpEndCalendarTime.time.date.mday = tmpEndTime.GetDay();
+
+               calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.start_time, tmpStartCalendarTime);
+               calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.end_time, tmpEndCalendarTime);
+
+               isChanged = true;
+       }
+       else if (!isAllDayEvent && startCalendarTime.type == CALENDAR_TIME_LOCALTIME)
+       {
+               tmpStartCalendarTime.type = CALENDAR_TIME_UTIME;
+               DateTime tmpStartTime;
+               tmpStartTime.SetValue(startCalendarTime.time.date.year, startCalendarTime.time.date.month, startCalendarTime.time.date.mday);
+               tmpStartCalendarTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(tmpStartTime);
+
+               tmpEndCalendarTime.type = CALENDAR_TIME_UTIME;
+               DateTime tmpEndTime;
+               tmpEndTime.SetValue(endCalendarTime.time.date.year, endCalendarTime.time.date.month, endCalendarTime.time.date.mday);
+               tmpEndCalendarTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(tmpEndTime);
+
+               calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.start_time, tmpStartCalendarTime);
+               calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.end_time, tmpEndCalendarTime);
+
+               isChanged = true;
+       }
+
+       if (IsRecurring())
+       {
+               int rangeType = CALENDAR_RANGE_NONE;
+               calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.range_type, &rangeType);
+
+               if (rangeType == CALENDAR_RANGE_UNTIL)
+               {
+                       calendar_time_s untilCalendarTime;
+                       calendar_time_s tmpUntilCalendarTime;
+
+                       calendar_record_get_caltime(__eventRecord.GetHandle(), _calendar_event.until_time, &untilCalendarTime);
+                       if (isAllDayEvent && untilCalendarTime.type == CALENDAR_TIME_UTIME)
+                       {
+                               tmpUntilCalendarTime.type = CALENDAR_TIME_LOCALTIME;
+                               DateTime tmpUntilTime = _CalendarbookUtil::ConvertEpochTimeToDateTime(untilCalendarTime.time.utime);
+                               tmpUntilCalendarTime.time.date.year = tmpUntilTime.GetYear();
+                               tmpUntilCalendarTime.time.date.month = tmpUntilTime.GetMonth();
+                               tmpUntilCalendarTime.time.date.mday = tmpUntilTime.GetDay();
+
+                               calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.until_time, tmpUntilCalendarTime);
+                       }
+                       else if (!isAllDayEvent && untilCalendarTime.type == CALENDAR_TIME_LOCALTIME)
+                       {
+                               tmpUntilCalendarTime.type = CALENDAR_TIME_UTIME;
+                               DateTime tmpUntilTime;
+                               tmpUntilTime.SetValue(untilCalendarTime.time.date.year, untilCalendarTime.time.date.month, untilCalendarTime.time.date.mday);
+                               tmpUntilCalendarTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(tmpUntilTime);
+
+                               calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.until_time, tmpUntilCalendarTime);
+                       }
+               }
+
+               if (isChanged)
+               {
+                       if (__pRecurrence == null)
+                       {
+                               __pRecurrence.reset(ConvertEventHandleToRecurrenceN(__eventRecord.GetHandle()));
+                       }
+
+                       std::unique_ptr<char[]> pExDates(_StringConverter::CopyToCharArrayN(ConvertRecurrenceToRRuleExDateString(*__pRecurrence.get(), isAllDayEvent)));
+                       int errorCode = calendar_record_set_str(__eventRecord.GetHandle(), _calendar_event.exdate, pExDates.get());
+                       SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               }
+       }
+}
+
+ByteBuffer*
+_CalEventImpl::GetUIDN(void) const
+{
+       ClearLastResult();
+
+       char* pStrUid = null;
+       calendar_record_get_str_p(__eventRecord.GetHandle(), _calendar_event.uid, &pStrUid);
+
+       if (pStrUid == null || strlen(pStrUid) == 0)
+       {
+               return null;
+       }
+
+       ByteBuffer* pConvertedUidBuffer = _CalendarbookUtil::ConvertCharArrayToByteBufferN(pStrUid);
+       SysTryReturn(NID_SCL, pConvertedUidBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       return pConvertedUidBuffer;
+}
+
+result
+_CalEventImpl::SetUID(const ByteBuffer* pUid)
+{
+       int errorCode = CALENDAR_ERROR_NONE;
+
+       if (pUid != null)
+       {
+               std::unique_ptr<char[]> pConvertedUidArray(_CalendarbookUtil::ConvertByteBufferToCharArrayN(*pUid));
+               SysTryReturn(NID_SCL, pConvertedUidArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               errorCode = calendar_record_set_str(__eventRecord.GetHandle(), _calendar_event.uid, pConvertedUidArray.get());
+               SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       }
+       else
+       {
+               errorCode = calendar_record_set_str(__eventRecord.GetHandle(), _calendar_event.uid, null);
+               SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       }
+
+       return E_SUCCESS;
+}
+
+String
+_CalEventImpl::GetUid(void) const
+{
+       char* pStrUid = null;
+       calendar_record_get_str_p(__eventRecord.GetHandle(), _calendar_event.uid, &pStrUid);
+
+       return String(pStrUid);
+}
+
+void
+_CalEventImpl::SetUid(const String& uid)
+{
+       std::unique_ptr<char[]> pStrUid(_StringConverter::CopyToCharArrayN(uid));
+       SysTryReturnVoidResult(NID_SCL, pStrUid != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       int errorCode = calendar_record_set_str(__eventRecord.GetHandle(), _calendar_event.uid, pStrUid.get());
+       SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+EventStatus
+_CalEventImpl::GetStatus(void) const
+{
+       int srcEventStatus = CALENDAR_EVENT_STATUS_NONE;
+
+       EventStatus eventStatus = EVENT_STATUS_NONE;
+
+       calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.event_status, &srcEventStatus);
+
+       switch (srcEventStatus)
+       {
+       case CALENDAR_EVENT_STATUS_NONE:
+               eventStatus = EVENT_STATUS_NONE;
+               break;
+       case CALENDAR_EVENT_STATUS_TENTATIVE:
+               eventStatus = EVENT_STATUS_TENTATIVE;
+               break;
+       case CALENDAR_EVENT_STATUS_CONFIRMED:
+               eventStatus = EVENT_STATUS_CONFIRMED;
+               break;
+       case CALENDAR_EVENT_STATUS_CANCELLED:
+               eventStatus = EVENT_STATUS_CANCELLED;
+               break;
+       default :
+               SysLog(NID_SCL, "The status value is invalid.");
+               return EVENT_STATUS_NONE;
+       }
+
+       return eventStatus;
+}
+
+void
+_CalEventImpl::SetStatus(EventStatus status)
+{
+       calendar_record_set_int(__eventRecord.GetHandle(), _calendar_event.event_status, _CalendarbookUtil::ConvertEventStatusToCSEventStatus(status));
+}
+
+BusyStatus
+_CalEventImpl::GetBusyStatus(void) const
+{
+       int srcEventBusyStatus = CALENDAR_EVENT_BUSY_STATUS_FREE;
+
+       BusyStatus busyStatus = BUSY_STATUS_FREE;
+
+       calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.busy_status, &srcEventBusyStatus);
+
+       switch (srcEventBusyStatus)
+       {
+       case CALENDAR_EVENT_BUSY_STATUS_FREE:
+               busyStatus = BUSY_STATUS_FREE;
+               break;
+       case CALENDAR_EVENT_BUSY_STATUS_BUSY:
+               busyStatus = BUSY_STATUS_BUSY;
+               break;
+       case CALENDAR_EVENT_BUSY_STATUS_UNAVAILABLE:
+               busyStatus = BUSY_STATUS_UNAVAILABLE;
+               break;
+       case CALENDAR_EVENT_BUSY_STATUS_TENTATIVE:
+               busyStatus = BUSY_STATUS_TENTATIVE;
+               break;
+       default :
+               SysLog(NID_SCL, "The busy status value is invalid.");
+               busyStatus = BUSY_STATUS_FREE;
+               break;
+       }
+
+       return busyStatus;
+}
+
+void
+_CalEventImpl::SetBusyStatus(BusyStatus busyStatus)
+{
+       calendar_record_set_int(__eventRecord.GetHandle(), _calendar_event.busy_status, _CalendarbookUtil::ConvertBusyStatusToCSEventBusyStatus(busyStatus));
+}
+
+EventPriority
+_CalEventImpl::GetPriority(void) const
+{
+       int srcPriority = CALENDAR_EVENT_PRIORITY_LOW;
+
+       EventPriority priority = EVENT_PRIORITY_NORMAL;
+
+       calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.priority, &srcPriority);
+
+       switch (srcPriority)
+       {
+       case CALENDAR_EVENT_PRIORITY_LOW:
+               priority = EVENT_PRIORITY_LOW;
+               break;
+       case CALENDAR_EVENT_PRIORITY_NONE:
+               // fall through
+       case CALENDAR_EVENT_PRIORITY_NORMAL:
+               priority = EVENT_PRIORITY_NORMAL;
+               break;
+       case CALENDAR_EVENT_PRIORITY_HIGH:
+               priority = EVENT_PRIORITY_HIGH;
+               break;
+       default :
+               SysLog(NID_SCL, "The priority value is invalid.");
+               priority = EVENT_PRIORITY_NORMAL;
+       }
+
+       return priority;
+}
+
+void
+_CalEventImpl::SetPriority(EventPriority priority)
+{
+       calendar_record_set_int(__eventRecord.GetHandle(), _calendar_event.priority, _CalendarbookUtil::ConvertEventPriorityToCSEventPriority(priority));
+}
+
+result
+_CalEventImpl::AddAttendee(const Attendee& attendee)
+{
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0)
+       {
+               SysTryReturnResult(NID_SCL, !attendee.GetEmail().IsEmpty(), E_OBJ_ALREADY_EXIST
+                                       , "The attendee's email string is empty.");
+       }
+       else
+       {
+               SysTryReturnResult(NID_SCL, !attendee.GetEmail().IsEmpty(), E_INVALID_ARG
+                                       , "The attendee's email string is empty.");
+       }
+
+       std::unique_ptr<char[]> pConvertedEmail(_StringConverter::CopyToCharArrayN(attendee.GetEmail()));
+       SysTryReturnResult(NID_SCL, pConvertedEmail != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       SysTryReturnResult(NID_SCL, GetAttendeeIndex(pConvertedEmail.get()) == _INVALID_ATTENDEE_INDEX, E_OBJ_ALREADY_EXIST
+                               , "The specified attendee already exists as this email is already registered.");
+
+       std::unique_ptr<char[]> pConvertedName(_StringConverter::CopyToCharArrayN(attendee.GetName()));
+       SysTryReturnResult(NID_SCL, pConvertedName != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       std::unique_ptr<char[]> pConvertedPhoneNumber(_StringConverter::CopyToCharArrayN(attendee.GetPhoneNumber()));
+       SysTryReturnResult(NID_SCL, pConvertedPhoneNumber != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       calendar_attendee_status_e convertedStatus = CALENDAR_ATTENDEE_STATUS_TENTATIVE;
+       switch (attendee.GetStatus())
+       {
+       case ATTENDEE_STATUS_NONE:
+               convertedStatus = CALENDAR_ATTENDEE_STATUS_COMPLETED;
+               break;
+       case ATTENDEE_STATUS_NOT_RESPONDED:
+               convertedStatus = CALENDAR_ATTENDEE_STATUS_PENDING;
+               break;
+       case ATTENDEE_STATUS_ACCEPTED:
+               convertedStatus = CALENDAR_ATTENDEE_STATUS_ACCEPTED;
+               break;
+       case ATTENDEE_STATUS_DECLINED:
+               convertedStatus = CALENDAR_ATTENDEE_STATUS_DECLINED;
+               break;
+       case ATTENDEE_STATUS_TENTATIVE:
+               convertedStatus = CALENDAR_ATTENDEE_STATUS_TENTATIVE;
+               break;
+       default:
+               SysLog(NID_SCL, "The attendee status value is invalid. attendee status = %d", attendee.GetStatus());
+               convertedStatus = CALENDAR_ATTENDEE_STATUS_TENTATIVE;
+               break;
+       }
+
+       calendar_attendee_role_e convertedRole = CALENDAR_ATTENDEE_ROLE_NON_PARTICIPANT;
+       switch (attendee.GetRole())
+       {
+       case ATTENDEE_ROLE_ATTENDEE:
+               convertedRole = CALENDAR_ATTENDEE_ROLE_OPT_PARTICIPANT;
+               break;
+       case ATTENDEE_ROLE_REQUIRED_ATTENDEE:
+               convertedRole = CALENDAR_ATTENDEE_ROLE_REQ_PARTICIPANT;
+               break;
+       case ATTENDEE_ROLE_ORGANIZER:
+               convertedRole = CALENDAR_ATTENDEE_ROLE_CHAIR;
+               break;
+       default:
+               SysLog(NID_SCL, "The attendee role value is invalid. attendee role = %d", attendee.GetRole());
+               convertedRole = CALENDAR_ATTENDEE_ROLE_OPT_PARTICIPANT;
+               break;
+       }
+
+       calendar_record_h attendeeHandle = null;
+       int errorCode = calendar_record_create(_calendar_attendee._uri, &attendeeHandle);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       errorCode = calendar_record_set_str(attendeeHandle, _calendar_attendee.name, pConvertedName.get());
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       errorCode = calendar_record_set_str(attendeeHandle, _calendar_attendee.email, pConvertedEmail.get());
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       errorCode = calendar_record_set_str(attendeeHandle, _calendar_attendee.number, pConvertedPhoneNumber.get());
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       calendar_record_set_int(attendeeHandle, _calendar_attendee.status, convertedStatus);
+       calendar_record_set_int(attendeeHandle, _calendar_attendee.role, convertedRole);
+       calendar_record_set_int(attendeeHandle, _calendar_attendee.person_id, attendee.GetPersonId());
+
+       errorCode = calendar_record_add_child_record(__eventRecord.GetHandle(), _calendar_event.calendar_attendee, attendeeHandle);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       return E_SUCCESS;
+}
+
+result
+_CalEventImpl::RemoveAttendee(const Attendee& attendee)
+{
+       std::unique_ptr<char[]> pConvertedEmail(_StringConverter::CopyToCharArrayN(attendee.GetEmail()));
+       SysTryReturnResult(NID_SCL, pConvertedEmail != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       int index = GetAttendeeIndex(pConvertedEmail.get());
+       SysTryReturnResult(NID_SCL, index != _INVALID_ATTENDEE_INDEX, E_OBJ_NOT_FOUND, "The specified attendee does not exist.");
+
+       calendar_record_h tmpAttendeeHandle = null;
+       calendar_record_get_child_record_at_p(__eventRecord.GetHandle(), _calendar_event.calendar_attendee, index, &tmpAttendeeHandle);
+       calendar_record_remove_child_record(__eventRecord.GetHandle(), _calendar_event.calendar_attendee, tmpAttendeeHandle);
+
+       return E_SUCCESS;
+}
+
+IList*
+_CalEventImpl::GetAllAttendeesN(void) const
+{
+       ClearLastResult();
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       result r = pList->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       unsigned int attendeeCount = 0;
+       calendar_record_get_child_record_count(__eventRecord.GetHandle(), _calendar_event.calendar_attendee, &attendeeCount);
+
+       for (unsigned int i = 0; i < attendeeCount; i++)
+       {
+               calendar_record_h tmpAttendeeHandle = null;
+               char* pTmpEmail = null;
+               char* pTmpName = null;
+               char* pTmpPhoneNumber = null;
+               int tmpStatus = 0;
+               int tmpRole = 0;
+               int tmpPersonId = -1;
+               AttendeeStatus attendeeStatus = ATTENDEE_STATUS_NONE;
+               AttendeeRole attendeeRole = ATTENDEE_ROLE_ATTENDEE;
+
+               calendar_record_get_child_record_at_p(__eventRecord.GetHandle(), _calendar_event.calendar_attendee, i, &tmpAttendeeHandle);
+               calendar_record_get_str_p(tmpAttendeeHandle, _calendar_attendee.email, &pTmpEmail);
+               calendar_record_get_str_p(tmpAttendeeHandle, _calendar_attendee.name, &pTmpName);
+               calendar_record_get_str_p(tmpAttendeeHandle, _calendar_attendee.number, &pTmpPhoneNumber);
+               calendar_record_get_int(tmpAttendeeHandle, _calendar_attendee.status, &tmpStatus);
+               calendar_record_get_int(tmpAttendeeHandle, _calendar_attendee.role, &tmpRole);
+               calendar_record_get_int(tmpAttendeeHandle, _calendar_attendee.person_id, &tmpPersonId);
+
+               switch (tmpStatus)
+               {
+               case CALENDAR_ATTENDEE_STATUS_PENDING:
+                       attendeeStatus = ATTENDEE_STATUS_NOT_RESPONDED;
+                       break;
+               case CALENDAR_ATTENDEE_STATUS_ACCEPTED:
+                       attendeeStatus = ATTENDEE_STATUS_ACCEPTED;
+                       break;
+               case CALENDAR_ATTENDEE_STATUS_DECLINED:
+                       attendeeStatus = ATTENDEE_STATUS_DECLINED;
+                       break;
+               case CALENDAR_ATTENDEE_STATUS_TENTATIVE:
+                       attendeeStatus = ATTENDEE_STATUS_TENTATIVE;
+                       break;
+               case CALENDAR_ATTENDEE_STATUS_DELEGATED:
+                       attendeeStatus = ATTENDEE_STATUS_NONE;
+                       break;
+               case CALENDAR_ATTENDEE_STATUS_COMPLETED:
+                       attendeeStatus = ATTENDEE_STATUS_NONE;
+                       break;
+               case CALENDAR_ATTENDEE_STATUS_IN_PROCESS:
+                       attendeeStatus = ATTENDEE_STATUS_NOT_RESPONDED;
+                       break;
+               default:
+                       SysLog(NID_SCL, "The attendee status value is invalid. attendee status = %d", tmpStatus);
+                       attendeeStatus = ATTENDEE_STATUS_NONE;
+                       break;
+               }
+
+               switch (tmpRole)
+               {
+               case CALENDAR_ATTENDEE_ROLE_REQ_PARTICIPANT:
+                       attendeeRole = ATTENDEE_ROLE_REQUIRED_ATTENDEE;
+                       break;
+               case CALENDAR_ATTENDEE_ROLE_OPT_PARTICIPANT:
+                       attendeeRole = ATTENDEE_ROLE_ATTENDEE;
+                       break;
+               case CALENDAR_ATTENDEE_ROLE_NON_PARTICIPANT:
+                       attendeeRole = ATTENDEE_ROLE_ATTENDEE;
+                       break;
+               case CALENDAR_ATTENDEE_ROLE_CHAIR:
+                       attendeeRole = ATTENDEE_ROLE_ORGANIZER;
+                       break;
+               default:
+                       SysLog(NID_SCL, "The attendee role value is invalid. attendee role = %d", tmpRole);
+                       attendeeRole = ATTENDEE_ROLE_ATTENDEE;
+                       break;
+               }
+
+               std::unique_ptr<Attendee> pTmpAttendee(new (std::nothrow) Attendee(pTmpEmail));
+               SysTryReturn(NID_SCL, pTmpAttendee != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               if (pTmpName != null && strlen(pTmpName) > 0)
+               {
+                       pTmpAttendee->SetName(pTmpName);
+               }
+
+               if (pTmpPhoneNumber != null && strlen(pTmpPhoneNumber) > 0)
+               {
+                       pTmpAttendee->SetPhoneNumber(pTmpPhoneNumber);
+               }
+
+               pTmpAttendee->SetStatus(attendeeStatus);
+               pTmpAttendee->SetRole(attendeeRole);
+               pTmpAttendee->SetPersonId(tmpPersonId);
+
+               r = pList->Add(pTmpAttendee.get());
+               SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               pTmpAttendee.release();
+       }
+
+       return pList.release();
+}
+
+TimeZone
+_CalEventImpl::GetTimeZone(void) const
+{
+       char* pTimeZoneId = null;
+       TimeZone timeZone;
+
+       calendar_record_get_str_p(__eventRecord.GetHandle(), _calendar_event.start_tzid, &pTimeZoneId);
+       if (pTimeZoneId != null && strlen(pTimeZoneId) > 0)
+       {
+               DateTime startTime = GetStartTime();
+
+               TimeZone::GetTimeZone(pTimeZoneId, startTime, timeZone);
+       }
+
+       return timeZone;
+}
+
+result
+_CalEventImpl::SetTimeZone(const TimeZone& timeZone)
+{
+       std::unique_ptr<char[]> pConvertedTimeZoneId(_StringConverter::CopyToCharArrayN(timeZone.GetId()));
+       SysTryReturnResult(NID_SCL, pConvertedTimeZoneId != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       int errorCode = calendar_record_set_str(__eventRecord.GetHandle(), _calendar_event.start_tzid, pConvertedTimeZoneId.get());
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       errorCode = calendar_record_set_str(__eventRecord.GetHandle(), _calendar_event.end_tzid, pConvertedTimeZoneId.get());
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       return E_SUCCESS;
+}
+
+RecurrenceId
+_CalEventImpl::GetRecurrenceId(void) const
+{
+       ClearLastResult();
+       SysTryReturn(NID_SCL, __isInstance, DateTime(), E_INVALID_STATE,
+                               "[%s] The instance does not have a recurrence or is not a CalEvent instance which doesn't have a RecurrenceId.", GetErrorMessage(E_INVALID_STATE));
+
+       return GetStartTime();
+}
+
+String
+_CalEventImpl::GetSubject(void) const
+{
+       char* pSubject = null;
+
+       calendar_record_get_str_p(__eventRecord.GetHandle(), _calendar_event.summary, &pSubject);
+
+       return String(pSubject);
+}
+
+String
+_CalEventImpl::GetDescription(void) const
+{
+       char* pDescription = null;
+
+       calendar_record_get_str_p(__eventRecord.GetHandle(), _calendar_event.description, &pDescription);
+
+       return String(pDescription);
+}
+DateTime
+_CalEventImpl::GetStartTime(void) const
+{
+       calendar_time_s startCalendarTime;
+       DateTime tmpStartTime;
+
+       calendar_record_get_caltime(__eventRecord.GetHandle(), _calendar_event.start_time, &startCalendarTime);
+
+       if (startCalendarTime.type == CALENDAR_TIME_UTIME)
+       {
+               tmpStartTime = _CalendarbookUtil::ConvertEpochTimeToDateTime(startCalendarTime.time.utime);
+       }
+       else
+       {
+               tmpStartTime.SetValue(startCalendarTime.time.date.year, startCalendarTime.time.date.month, startCalendarTime.time.date.mday);
+       }
+
+       return tmpStartTime;
+}
+
+DateTime
+_CalEventImpl::GetEndTime(void) const
+{
+       calendar_time_s endCalendarTime;
+       DateTime tmpEndTime;
+
+       calendar_record_get_caltime(__eventRecord.GetHandle(), _calendar_event.end_time, &endCalendarTime);
+
+       if (endCalendarTime.type == CALENDAR_TIME_UTIME)
+       {
+               tmpEndTime = _CalendarbookUtil::ConvertEpochTimeToDateTime(endCalendarTime.time.utime);
+       }
+       else if (endCalendarTime.type == CALENDAR_TIME_LOCALTIME)
+       {
+               tmpEndTime.SetValue(endCalendarTime.time.date.year, endCalendarTime.time.date.month, endCalendarTime.time.date.mday);
+       }
+
+       return tmpEndTime;
+}
+
+String
+_CalEventImpl::GetLocation(void) const
+{
+       char* pLocation = null;
+
+       calendar_record_get_str_p(__eventRecord.GetHandle(), _calendar_event.location, &pLocation);
+
+       return String(pLocation);
+}
+
+EventCategory
+_CalEventImpl::GetCategory(void) const
+{
+       char* pCategories = null;
+
+       calendar_record_get_str_p(__eventRecord.GetHandle(), _calendar_event.categories, &pCategories);
+
+       return _CalendarbookUtil::ConvertCSCategoriesToEventCategory(pCategories);
+}
+
+RecordSensitivity
+_CalEventImpl::GetSensitivity(void) const
+{
+       int srcSensitivity = CALENDAR_SENSITIVITY_PUBLIC;
+       RecordSensitivity sensitivity = SENSITIVITY_PUBLIC;
+
+       calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.sensitivity, &srcSensitivity);
+
+       switch (srcSensitivity)
+       {
+       case CALENDAR_SENSITIVITY_PUBLIC:
+               sensitivity = SENSITIVITY_PUBLIC;
+               break;
+       case CALENDAR_SENSITIVITY_PRIVATE:
+               sensitivity = SENSITIVITY_PRIVATE;
+               break;
+       case CALENDAR_SENSITIVITY_CONFIDENTIAL:
+               sensitivity = SENSITIVITY_CONFIDENTIAL;
+               break;
+       default :
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. sensitivity = %d", GetErrorMessage(E_INVALID_ARG), srcSensitivity);
+               sensitivity = SENSITIVITY_PUBLIC;
+       }
+
+       return sensitivity;
+}
+
+const Reminder*
+_CalEventImpl::GetReminder(void) const
+{
+       if (__reminderListUpdated == false)
+       {
+               result r = _CalendarbookUtil::ConvertEventAlarmsToReminderList(__eventRecord.GetHandle(), __reminderList);
+               SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __reminderListUpdated = true;
+       }
+
+       if (__reminderList.GetCount() > 0)
+       {
+               return static_cast<const Reminder*>(__reminderList.GetAt(0));
+       }
+
+       return null;
+}
+
+const Recurrence*
+_CalEventImpl::GetRecurrence(void) const
+{
+       if (__pRecurrence == null)
+       {
+               __pRecurrence.reset(ConvertEventHandleToRecurrenceN(__eventRecord.GetHandle()));
+       }
+
+       return __pRecurrence.get();
+}
+
+Recurrence*
+_CalEventImpl::ConvertEventHandleToRecurrenceN(calendar_record_h eventHandle) const
+{
+       int srcFrequency = CALENDAR_RECURRENCE_NONE;
+       calendar_time_s untilCalendarTime;
+       int rangeType = CALENDAR_RANGE_NONE;
+       int count = 0;
+       int interval = 0;
+       char* pByDay = null;
+       char* pByMonthDay = null;
+       char* pByMonth = null;
+       int weekStart = 0;
+       char* pExDates = null;
+
+       result r = E_SUCCESS;
+       int dayOfWeek = 0;
+       int monthOfYear = 0;
+       int dayOfMonth = 0;
+       int weekOfMonth = 0;
+       CalDayOfWeek convertedWeekStart = CAL_SUNDAY;
+
+       std::unique_ptr<Recurrence> pRecurrence(new (std::nothrow) Recurrence());
+
+       calendar_record_get_int(eventHandle, _calendar_event.freq, &srcFrequency);
+
+       if (srcFrequency == CALENDAR_RECURRENCE_NONE)
+       {
+               return null;
+       }
+
+       calendar_record_get_int(eventHandle, _calendar_event.range_type, &rangeType);
+       calendar_record_get_int(eventHandle, _calendar_event.count, &count);
+       calendar_record_get_int(eventHandle, _calendar_event.interval, &interval);
+       calendar_record_get_caltime(eventHandle, _calendar_event.until_time, &untilCalendarTime);
+       calendar_record_get_int(eventHandle, _calendar_event.wkst, &weekStart);
+
+       calendar_record_get_str_p(eventHandle, _calendar_event.byday, &pByDay);
+       calendar_record_get_str_p(eventHandle, _calendar_event.bymonthday, &pByMonthDay);
+       if (pByMonthDay != null)
+       {
+               r = Integer::Parse(pByMonthDay, dayOfMonth);
+               SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       calendar_record_get_str_p(eventHandle, _calendar_event.bymonth, &pByMonth);
+       if (pByMonth != null)
+       {
+               r = Integer::Parse(pByMonth, monthOfYear);
+               SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       switch (srcFrequency)
+       {
+       case CALENDAR_RECURRENCE_DAILY:
+               pRecurrence->SetFrequency(FREQ_DAILY);
+               break;
+
+       case CALENDAR_RECURRENCE_WEEKLY:
+               pRecurrence->SetFrequency(FREQ_WEEKLY);
+
+               dayOfWeek = ConvertRRuleByDayStringToDayOfWeek(pByDay);
+               SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, null, E_INVALID_ARG, "[%s] Invalid argument is used. byday = %s", GetErrorMessage(E_INVALID_ARG), pByDay);
+
+               pRecurrence->SetDayOfWeek(dayOfWeek);
+               break;
+
+       case CALENDAR_RECURRENCE_MONTHLY:
+               pRecurrence->SetFrequency(FREQ_MONTHLY);
+
+               if (dayOfMonth != 0)
+               {
+                       if (dayOfMonth < 0)
+                       {
+                               int maxDaysOfMonth = _CalendarbookUtil::GetMaxDaysOfMonth(untilCalendarTime.time.date.year, monthOfYear);
+                               pRecurrence->SetDayOfMonth(maxDaysOfMonth + dayOfMonth);
+                       }
+                       else
+                       {
+                               pRecurrence->SetDayOfMonth(dayOfMonth);
+                       }
+               }
+               else
+               {
+                       if(pByDay != null)
+                       {
+                               r = ConvertRRuleByDayStringToDayOfWeekAndWeekOfMonth(pByDay, weekOfMonth, dayOfWeek);
+                               SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_INVALID_ARG, "[%s] Invalid argument is used. byday = %s", GetErrorMessage(E_INVALID_ARG), pByDay);
+
+                               pRecurrence->SetWeekOfMonth(weekOfMonth);
+                               pRecurrence->SetDayOfWeek(dayOfWeek);
+                       }
+                       else
+                       {
+                               DateTime startTime = GetStartTime();
+
+                               dayOfMonth = startTime.GetDay();
+                               pRecurrence->SetDayOfMonth(dayOfMonth);
+                       }
+               }
+
+               break;
+
+       case CALENDAR_RECURRENCE_YEARLY:
+               pRecurrence->SetFrequency(FREQ_YEARLY);
+
+               if (dayOfMonth != 0)
+               {
+                       if (dayOfMonth < 0)
+                       {
+                               int maxDaysOfMonth = _CalendarbookUtil::GetMaxDaysOfMonth(untilCalendarTime.time.date.year, monthOfYear);
+                               pRecurrence->SetDayOfMonth(maxDaysOfMonth + dayOfMonth);
+                       }
+                       else
+                       {
+                               pRecurrence->SetDayOfMonth(dayOfMonth);
+                       }
+               }
+               else
+               {
+                       if(pByDay != null)
+                       {
+                               r = ConvertRRuleByDayStringToDayOfWeekAndWeekOfMonth(pByDay, weekOfMonth, dayOfWeek);
+                               SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_INVALID_ARG, "[%s] Invalid argument is used. byday = %s", GetErrorMessage(E_INVALID_ARG), pByDay);
+
+                               pRecurrence->SetWeekOfMonth(weekOfMonth);
+                               pRecurrence->SetDayOfWeek(dayOfWeek);
+                       }
+                       else
+                       {
+                               DateTime startTime = GetStartTime();
+
+                               dayOfMonth = startTime.GetDay();
+                               monthOfYear = startTime.GetMonth();
+
+                               pRecurrence->SetDayOfMonth(dayOfMonth);
+                       }
+               }
+               pRecurrence->SetMonthOfYear(monthOfYear);
+
+               break;
+
+       default :
+               SysLogException(NID_SCL, E_INVALID_ARG, "Invalid argument is passed. frequency = %d", srcFrequency);
+               return null;
+       }
+
+       if (rangeType == CALENDAR_RANGE_NONE)
+       {
+               pRecurrence->SetUntil(&DateTime::GetMaxValue());
+       }
+       else if (rangeType == CALENDAR_RANGE_UNTIL)
+       {
+               DateTime until;
+
+               if (untilCalendarTime.type == CALENDAR_TIME_LOCALTIME)
+               {
+                       until.SetValue(untilCalendarTime.time.date.year, untilCalendarTime.time.date.month, untilCalendarTime.time.date.mday);
+               }
+               else
+               {
+                       until = _CalendarbookUtil::ConvertEpochTimeToDateTime(untilCalendarTime.time.utime);
+               }
+
+               if (until < _CalendarbookImpl::GetMinDateTime())
+               {
+                       until = _CalendarbookImpl::GetMinDateTime();
+               }
+               else if(until > _CalendarbookImpl::GetMaxDateTime())
+               {
+                       until = _CalendarbookImpl::GetMaxDateTime();
+               }
+
+               pRecurrence->SetUntil(&until);
+       }
+       else
+       {
+               pRecurrence->SetCounts(count);
+       }
+       pRecurrence->SetInterval(interval);
+
+       switch (weekStart)
+       {
+       case CALENDAR_SUNDAY:
+               convertedWeekStart = CAL_SUNDAY;
+               break;
+
+       case CALENDAR_MONDAY:
+               convertedWeekStart = CAL_MONDAY;
+               break;
+
+       default:
+               SysLogException(NID_SCL, E_INVALID_ARG, "Invalid argument is passed. week start = %d", weekStart);
+               return null;
+       }
+       pRecurrence->SetWeekStart(convertedWeekStart);
+
+       calendar_record_get_str_p(eventHandle, _calendar_event.exdate, &pExDates);
+       if (pExDates != null && strlen(pExDates) != 0)
+       {
+               r = ConvertRRuleExDateStringToRecurrence(pExDates, *pRecurrence.get());
+               SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_INVALID_ARG, "[%s] Invalid argument is used. exdate = %s", GetErrorMessage(E_INVALID_ARG), pExDates);
+       }
+
+       return pRecurrence.release();
+}
+
+DateTime
+_CalEventImpl::GetLastRevisedTime(void) const
+{
+       long long lastModifiedTime = 0;
+       DateTime tmpLastRevisedTime;
+
+       calendar_record_get_lli(__eventRecord.GetHandle(), _calendar_event.last_modified_time, &lastModifiedTime);
+
+       tmpLastRevisedTime = _CalendarbookUtil::ConvertEpochTimeToDateTime(lastModifiedTime);
+
+       return tmpLastRevisedTime;
+}
+
+result
+_CalEventImpl::SetSubject(const String& subject)
+{
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               SysTryReturnResult(NID_SCL, subject.GetLength() <= MAX_EVENT_SUBJECT_LENGTH, E_INVALID_ARG
+                               , "The length of the value exceeds MAX_EVENT_SUBJECT_LENGTH.");
+       }
+
+       std::unique_ptr<char[]> pConvertedSubject(_StringConverter::CopyToCharArrayN(subject));
+       SysTryReturnResult(NID_SCL, pConvertedSubject != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       int errorCode = calendar_record_set_str(__eventRecord.GetHandle(), _calendar_event.summary, pConvertedSubject.get());
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       return E_SUCCESS;
+}
+
+result
+_CalEventImpl::SetDescription(const String& description)
+{
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               SysTryReturnResult(NID_SCL, description.GetLength() <= MAX_EVENT_DESCRIPTION_LENGTH, E_INVALID_ARG
+                               , "The length of the value exceeds MAX_EVENT_DESCRIPTION_LENGTH.");
+       }
+
+       std::unique_ptr<char[]> pConvertedDescription(_StringConverter::CopyToCharArrayN(description));
+       SysTryReturnResult(NID_SCL, pConvertedDescription != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       int errorCode = calendar_record_set_str(__eventRecord.GetHandle(), _calendar_event.description, pConvertedDescription.get());
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       return E_SUCCESS;
+}
+
+result
+_CalEventImpl::SetLocation(const String& location)
+{
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               SysTryReturnResult(NID_SCL, location.GetLength() <= MAX_EVENT_LOCATION_LENGTH, E_INVALID_ARG
+                               , "The length of the value exceeds MAX_EVENT_LOCATION_LENGTH.");
+       }
+
+       std::unique_ptr<char[]> pConvertedLocation(_StringConverter::CopyToCharArrayN(location));
+       SysTryReturnResult(NID_SCL, pConvertedLocation != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       int errorCode = calendar_record_set_str(__eventRecord.GetHandle(), _calendar_event.location, pConvertedLocation.get());
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       return E_SUCCESS;
+}
+
+result
+_CalEventImpl::SetStartAndEndTime(const DateTime& start, const DateTime& end)
+{
+       int recurrenceFrequency = 0;
+
+       calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.freq, &recurrenceFrequency);
+
+       SysTryReturnResult(NID_SCL, recurrenceFrequency == CALENDAR_RECURRENCE_NONE, E_INVALID_CONDITION
+                       , "The recurrence date is already set. Cannot modify the start and end date/time.");
+       SysTryReturnResult(NID_SCL, _CalendarbookUtil::CheckValidDateTime(start), E_INVALID_ARG, "Invalid argument is used. start = %S", start.ToString().GetPointer());
+       SysTryReturnResult(NID_SCL, _CalendarbookUtil::CheckValidDateTime(end), E_INVALID_ARG, "Invalid argument is used. end = %S", end.ToString().GetPointer());
+       SysTryReturnResult(NID_SCL, start <= end, E_INVALID_ARG, "Invalid argument is used. The end date is earlier than the start date.");
+
+       return SetStartAndEndTimeCommon(start, end);
+}
+
+result
+_CalEventImpl::SetStartAndEndTimeCommon(const DateTime& start, const DateTime& end)
+{
+       calendar_time_s startCalendarTime;
+       calendar_time_s endCalendarTime;
+
+       calendar_record_get_caltime(__eventRecord.GetHandle(), _calendar_event.start_time, &startCalendarTime);
+
+       if (startCalendarTime.type == CALENDAR_TIME_LOCALTIME)
+       {
+               startCalendarTime.time.date.year = start.GetYear();
+               startCalendarTime.time.date.month = start.GetMonth();
+               startCalendarTime.time.date.mday = start.GetDay();
+
+               endCalendarTime.type = CALENDAR_TIME_LOCALTIME;
+               endCalendarTime.time.date.year = end.GetYear();
+               endCalendarTime.time.date.month = end.GetMonth();
+               endCalendarTime.time.date.mday = end.GetDay();
+       }
+       else
+       {
+               startCalendarTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(start);
+
+               endCalendarTime.type = CALENDAR_TIME_UTIME;
+               endCalendarTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(end);
+       }
+
+       calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.start_time, startCalendarTime);
+       calendar_record_set_caltime(__eventRecord.GetHandle(), _calendar_event.end_time, endCalendarTime);
+
+       return E_SUCCESS;
+}
+
+void
+_CalEventImpl::SetCategory(EventCategory category)
+{
+       std::unique_ptr<char[]> pConvertedCategory;
+
+       if (category == EVENT_CATEGORY_ANNIVERSARY)
+       {
+               SetAllDayEvent(true);
+
+               pConvertedCategory.reset(_StringConverter::CopyToCharArrayN(_EVENT_CATEGORY_ANNIVERSARY_STRING));
+               SysTryReturnVoidResult(NID_SCL, pConvertedCategory != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+       else
+       {
+               pConvertedCategory.reset(_StringConverter::CopyToCharArrayN(_EVENT_CATEGORY_APPOINTMENT_STRING));
+               SysTryReturnVoidResult(NID_SCL, pConvertedCategory != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       int errorCode = calendar_record_set_str(__eventRecord.GetHandle(), _calendar_event.categories, pConvertedCategory.get());
+       SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+void
+_CalEventImpl::SetSensitivity(RecordSensitivity sensitivity)
+{
+       calendar_record_set_int(__eventRecord.GetHandle(), _calendar_event.sensitivity, _CalendarbookUtil::ConvertSensitivityToCSSensitivity(sensitivity));
+}
+
+result
+_CalEventImpl::SetCoordinates(double latitude, double longitude)
+{
+       SysTryReturnResult(NID_SCL, latitude >= _MIN_LATITUDE && latitude <= _MAX_LATITUDE, E_INVALID_ARG, "Invalid argument is used. The latitude is out of range.");
+       SysTryReturnResult(NID_SCL, longitude >= _MIN_LONGITUDE && longitude <= _MAX_LONGITUDE, E_INVALID_ARG, "Invalid argument is used. The longitude is out of range.");
+
+       calendar_record_set_double(__eventRecord.GetHandle(), _calendar_event.latitude, latitude);
+       calendar_record_set_double(__eventRecord.GetHandle(), _calendar_event.longitude, longitude);
+
+       return E_SUCCESS;
+}
+
+void
+_CalEventImpl::GetCoordinates(double& latitude, double& longitude) const
+{
+       calendar_record_get_double(__eventRecord.GetHandle(), _calendar_event.latitude, &latitude);
+       calendar_record_get_double(__eventRecord.GetHandle(), _calendar_event.longitude, &longitude);
+}
+
+result
+_CalEventImpl::SetReminder(const Reminder* pReminder)
+{
+       unsigned int reminderCount = 0;
+       calendar_record_h tmpAlarmHandle = null;
+
+       calendar_record_get_child_record_count(__eventRecord.GetHandle(), _calendar_event.calendar_alarm, &reminderCount);
+
+       if (pReminder != null)
+       {
+               int convertedTimeUnit = 0;
+               switch (pReminder->GetTimeUnit())
+               {
+               case REMINDER_TIME_UNIT_MINUTE:
+                       convertedTimeUnit = CALENDAR_ALARM_TIME_UNIT_MINUTE;
+                       break;
+               case REMINDER_TIME_UNIT_HOUR:
+                       convertedTimeUnit = CALENDAR_ALARM_TIME_UNIT_HOUR;
+                       break;
+               case REMINDER_TIME_UNIT_DAY:
+                       convertedTimeUnit = CALENDAR_ALARM_TIME_UNIT_DAY;
+                       break;
+               case REMINDER_TIME_UNIT_WEEK:
+                       convertedTimeUnit = CALENDAR_ALARM_TIME_UNIT_WEEK;
+                       break;
+               default:
+                       break;
+               }
+
+               calendar_record_h tmpAlarmHandle = null;
+               int errorCode = CALENDAR_ERROR_NONE;
+
+               if (reminderCount > 0)
+               {
+                       calendar_record_get_child_record_at_p(__eventRecord.GetHandle(), _calendar_event.calendar_alarm, 0, &tmpAlarmHandle);
+                       calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick_unit, convertedTimeUnit);
+                       calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick, pReminder->GetTimeOffset());
+
+                       std::unique_ptr<char[]> pTmpAlarmTone(_StringConverter::CopyToCharArrayN(pReminder->GetSoundFile()));
+                       SysTryReturnResult(NID_SCL, pTmpAlarmTone != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+                       errorCode = calendar_record_set_str(tmpAlarmHandle, _calendar_alarm.tone, pTmpAlarmTone.get());
+                       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+               }
+               else
+               {
+                       std::unique_ptr<char[]> pTmpAlarmTone(_StringConverter::CopyToCharArrayN(pReminder->GetSoundFile()));
+                       SysTryReturnResult(NID_SCL, pTmpAlarmTone != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+                       errorCode = calendar_record_create(_calendar_alarm._uri, &tmpAlarmHandle);
+                       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+                       calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick_unit, convertedTimeUnit);
+                       calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick, pReminder->GetTimeOffset());
+                       errorCode = calendar_record_set_str(tmpAlarmHandle, _calendar_alarm.tone, pTmpAlarmTone.get());
+                       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+                       errorCode = calendar_record_add_child_record(__eventRecord.GetHandle(), _calendar_event.calendar_alarm, tmpAlarmHandle);
+                       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+               }
+       }
+       else
+       {
+               if (reminderCount > 0)
+               {
+                       calendar_record_get_child_record_at_p(__eventRecord.GetHandle(), _calendar_event.calendar_alarm, 0, &tmpAlarmHandle);
+                       calendar_record_remove_child_record(__eventRecord.GetHandle(), _calendar_event.calendar_alarm, tmpAlarmHandle);
+               }
+       }
+
+       __reminderList.RemoveAll(true);
+       __reminderListUpdated = false;
+
+       return E_SUCCESS;
+}
+
+result
+_CalEventImpl::SetRecurrence(const Recurrence* pRecurrence)
+{
+       if (pRecurrence != null)
+       {
+               result r = VerifyRecurrence(*pRecurrence);
+               SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               r = ResetStartAndEndTimeByRecurrence(*pRecurrence);
+               SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               r = ConvertRecurrenceToEventHandle(*pRecurrence, __eventRecord.GetHandle());
+               SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               std::unique_ptr<char[]> pExDates(_StringConverter::CopyToCharArrayN(ConvertRecurrenceToRRuleExDateString(*pRecurrence, IsAllDayEvent())));
+               int errorCode = calendar_record_set_str(__eventRecord.GetHandle(), _calendar_event.exdate, pExDates.get());
+               SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               __pRecurrence.reset(new (std::nothrow) Recurrence(*pRecurrence));
+               SysTryReturnResult(NID_SCL, __pRecurrence != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       }
+       else
+       {
+               calendar_record_set_int(__eventRecord.GetHandle(), _calendar_event.freq, CALENDAR_RECURRENCE_NONE);
+
+               __pRecurrence.reset(null);
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_CalEventImpl::AddReminder(const Reminder& reminder)
+{
+       calendar_record_h tmpAlarmHandle = null;
+
+       std::unique_ptr<char[]> pTmpAlarmTone(_StringConverter::CopyToCharArrayN(reminder.GetSoundFile()));
+       SysTryReturnResult(NID_SCL, pTmpAlarmTone != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       int errorCode = calendar_record_create(_calendar_alarm._uri, &tmpAlarmHandle);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       int convertedTimeUnit = 0;
+
+       ReminderTimeUnit timeUnit = reminder.GetTimeUnit();
+       switch (timeUnit)
+       {
+       case REMINDER_TIME_UNIT_MINUTE:
+               convertedTimeUnit = CALENDAR_ALARM_TIME_UNIT_MINUTE;
+               break;
+
+       case REMINDER_TIME_UNIT_HOUR:
+               convertedTimeUnit = CALENDAR_ALARM_TIME_UNIT_HOUR;
+               break;
+
+       case REMINDER_TIME_UNIT_DAY:
+               convertedTimeUnit = CALENDAR_ALARM_TIME_UNIT_DAY;
+               break;
+
+       case REMINDER_TIME_UNIT_WEEK:
+               convertedTimeUnit = CALENDAR_ALARM_TIME_UNIT_WEEK;
+               break;
+
+       case REMINDER_TIME_UNIT_NONE:
+               convertedTimeUnit = CALENDAR_ALARM_TIME_UNIT_SPECIFIC;
+               break;
+
+       default:
+               break;
+       }
+
+       calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick_unit, convertedTimeUnit);
+       calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick, reminder.GetTimeOffset());
+       errorCode = calendar_record_set_str(tmpAlarmHandle, _calendar_alarm.tone, pTmpAlarmTone.get());
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       if (convertedTimeUnit == CALENDAR_ALARM_TIME_UNIT_SPECIFIC)
+       {
+               calendar_record_set_lli(tmpAlarmHandle, _calendar_alarm.time, _CalendarbookUtil::ConvertDateTimeToEpochTime(reminder.GetAbsoluteTime()));
+       }
+
+       errorCode = calendar_record_add_child_record(__eventRecord.GetHandle(), _calendar_event.calendar_alarm, tmpAlarmHandle);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       __reminderList.RemoveAll(true);
+       __reminderListUpdated = false;
+
+       return E_SUCCESS;
+}
+
+result
+_CalEventImpl::RemoveReminderAt(int index)
+{
+       calendar_record_h tmpAlarmHandle = null;
+
+       calendar_record_get_child_record_at_p(__eventRecord.GetHandle(), _calendar_event.calendar_alarm, index, &tmpAlarmHandle);
+       SysTryReturnResult(NID_SCL, tmpAlarmHandle != null, E_OUT_OF_RANGE, "The index is out of range. index = %d", index);
+
+       calendar_record_remove_child_record(__eventRecord.GetHandle(), _calendar_event.calendar_alarm, tmpAlarmHandle);
+
+       __reminderList.RemoveAll(true);
+       __reminderListUpdated = false;
+
+       return E_SUCCESS;
+}
+
+const IList&
+_CalEventImpl::GetAllReminders(void) const
+{
+       ClearLastResult();
+
+       if (__reminderListUpdated == false)
+       {
+               result r = _CalendarbookUtil::ConvertEventAlarmsToReminderList(__eventRecord.GetHandle(), __reminderList);
+               SysTryReturn(NID_SCL, r == E_SUCCESS, __reminderList, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __reminderListUpdated = true;
+       }
+
+       return __reminderList;
+}
+
+result
+_CalEventImpl::ConvertRecurrenceToEventHandle(const Recurrence& recurrence, calendar_record_h eventHandle) const
+{
+       result r = E_SUCCESS;
+
+       int weekStart = CALENDAR_SUNDAY;
+       std::unique_ptr<char[]> pByDay;
+       std::unique_ptr<char[]> pByMonth;
+       std::unique_ptr<char[]> pByMonthDay;
+
+       int dayOfWeek = 0;
+       String dayOfWeekString;
+       String exDateString;
+
+       switch (recurrence.GetWeekStart())
+       {
+       case CAL_SUNDAY:
+               weekStart = CALENDAR_SUNDAY;
+               break;
+
+       case CAL_MONDAY:
+               weekStart = CALENDAR_MONDAY;
+               break;
+
+       default:
+               SysLogException(NID_SCL, E_INVALID_ARG, "Invalid argument is passed. week start = %d", recurrence.GetWeekStart());
+               return E_INVALID_ARG;
+       }
+
+       int errorCode = calendar_record_set_int(eventHandle, _calendar_event.wkst, weekStart);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_INVALID_ARG, "Invalid argument is passed. week start = %d", weekStart);
+
+       if (recurrence.GetUntil() != null)
+       {
+               if (*recurrence.GetUntil() == DateTime::GetMaxValue())
+               {
+                       calendar_record_set_int(eventHandle, _calendar_event.range_type, CALENDAR_RANGE_NONE);
+               }
+               else
+               {
+                       calendar_time_s startCalendarTime;
+                       calendar_time_s untilCalendarTime;
+
+                       calendar_record_get_caltime(eventHandle, _calendar_event.start_time, &startCalendarTime);
+                       if (startCalendarTime.type == CALENDAR_TIME_LOCALTIME)
+                       {
+                               untilCalendarTime.type = CALENDAR_TIME_LOCALTIME;
+                               untilCalendarTime.time.date.year = recurrence.GetUntil()->GetYear();
+                               untilCalendarTime.time.date.month = recurrence.GetUntil()->GetMonth();
+                               untilCalendarTime.time.date.mday = recurrence.GetUntil()->GetDay();
+                       }
+                       else
+                       {
+                               untilCalendarTime.type = CALENDAR_TIME_UTIME;
+                               untilCalendarTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(*recurrence.GetUntil());
+                       }
+
+                       calendar_record_set_int(eventHandle, _calendar_event.range_type, CALENDAR_RANGE_UNTIL);
+                       calendar_record_set_caltime(eventHandle, _calendar_event.until_time, untilCalendarTime);
+               }
+       }
+       else
+       {
+               calendar_record_set_int(eventHandle, _calendar_event.range_type, CALENDAR_RANGE_COUNT);
+               calendar_record_set_int(eventHandle, _calendar_event.count, recurrence.GetCounts());
+       }
+
+       calendar_record_set_int(eventHandle, _calendar_event.interval, recurrence.GetInterval());
+
+       switch (recurrence.GetFrequency())
+       {
+       case FREQ_DAILY:
+               calendar_record_set_int(eventHandle, _calendar_event.freq, CALENDAR_RECURRENCE_DAILY);
+               break;
+
+       case FREQ_WEEKLY:
+               calendar_record_set_int(eventHandle, _calendar_event.freq, CALENDAR_RECURRENCE_WEEKLY);
+
+               dayOfWeek = recurrence.GetDayOfWeek();
+               r = ConvertDayOfWeekToRRuleByDayString(dayOfWeek, 0, dayOfWeekString);
+               SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. day of week = %d", dayOfWeek);
+
+               pByDay.reset(_StringConverter::CopyToCharArrayN(dayOfWeekString));
+
+               break;
+
+       case FREQ_MONTHLY:
+               calendar_record_set_int(eventHandle, _calendar_event.freq, CALENDAR_RECURRENCE_MONTHLY);
+
+               if (recurrence.GetDayOfMonth() != 0)
+               {
+                       pByMonthDay.reset(_StringConverter::CopyToCharArrayN(Integer::ToString(recurrence.GetDayOfMonth())));
+               }
+               else
+               {
+                       dayOfWeek = recurrence.GetDayOfWeek();
+                       r = ConvertDayOfWeekToRRuleByDayString(dayOfWeek, recurrence.GetWeekOfMonth(), dayOfWeekString);
+                       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. day of week = %d", dayOfWeek);
+
+                       pByDay.reset(_StringConverter::CopyToCharArrayN(dayOfWeekString));
+               }
+
+               break;
+
+       case FREQ_YEARLY:
+               calendar_record_set_int(eventHandle, _calendar_event.freq, CALENDAR_RECURRENCE_YEARLY);
+
+               pByMonth.reset(_StringConverter::CopyToCharArrayN(Integer::ToString(recurrence.GetMonthOfYear())));
+
+               if (recurrence.GetDayOfMonth() != 0)
+               {
+                       pByMonthDay.reset(_StringConverter::CopyToCharArrayN(Integer::ToString(recurrence.GetDayOfMonth())));
+               }
+               else
+               {
+                       dayOfWeek = recurrence.GetDayOfWeek();
+                       r = ConvertDayOfWeekToRRuleByDayString(dayOfWeek, recurrence.GetWeekOfMonth(), dayOfWeekString);
+                       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. day of week = %d", dayOfWeek);
+
+                       pByDay.reset(_StringConverter::CopyToCharArrayN(dayOfWeekString));
+               }
+
+               break;
+
+       default:
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. frequency = %d", GetErrorMessage(E_INVALID_ARG), recurrence.GetFrequency());
+               return E_INVALID_ARG;
+       }
+
+       errorCode = calendar_record_set_str(eventHandle, _calendar_event.byday, pByDay.get());
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       errorCode = calendar_record_set_str(eventHandle, _calendar_event.bymonth, pByMonth.get());
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       errorCode = calendar_record_set_str(eventHandle, _calendar_event.bymonthday, pByMonthDay.get());
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       return E_SUCCESS;
+}
+
+result
+_CalEventImpl::ConvertDayOfWeekToRRuleByDayString(int dayOfWeek, int weekOfMonth, String& byDayString) const
+{
+       int tmpDayOfWeek = CAL_SUNDAY;
+
+       byDayString.Clear();
+       for (int i = 0; i < _NUMBER_OF_DAYS_OF_WEEK; i++)
+       {
+               if (dayOfWeek & tmpDayOfWeek)
+               {
+                       if (weekOfMonth != 0)
+                       {
+                               byDayString.Append(weekOfMonth);
+                       }
+
+                       switch (tmpDayOfWeek)
+                       {
+                       case CAL_SUNDAY:
+                               byDayString.Append(_RECURRENCE_KEYWORD_SUNDAY);
+                               break;
+                       case CAL_MONDAY:
+                               byDayString.Append(_RECURRENCE_KEYWORD_MONDAY);
+                               break;
+                       case CAL_TUESDAY:
+                               byDayString.Append(_RECURRENCE_KEYWORD_TUESDAY);
+                               break;
+                       case CAL_WEDNESDAY:
+                               byDayString.Append(_RECURRENCE_KEYWORD_WEDNESDAY);
+                               break;
+                       case CAL_THURSDAY:
+                               byDayString.Append(_RECURRENCE_KEYWORD_THURSDAY);
+                               break;
+                       case CAL_FRIDAY:
+                               byDayString.Append(_RECURRENCE_KEYWORD_FRIDAY);
+                               break;
+                       case CAL_SATURDAY:
+                               byDayString.Append(_RECURRENCE_KEYWORD_SATURDAY);
+                               break;
+                       }
+                       byDayString.Append(_RECURRENCE_DELIMITER);
+               }
+
+               tmpDayOfWeek <<= 1;
+       }
+
+       byDayString.Remove(byDayString.GetLength() - 1, _RECURRENCE_DELIMITER_LENGTH);
+
+       return E_SUCCESS;
+}
+
+RecordId
+_CalEventImpl::GetCalendarId(void) const
+{
+       int srcCalendarbookId = 0;
+
+       calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.calendar_book_id, &srcCalendarbookId);
+
+       return srcCalendarbookId;
+}
+
+RecordId
+_CalEventImpl::GetBaseEventId(void) const
+{
+       int srcBaseEventId = INVALID_RECORD_ID;
+
+       calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.original_event_id, &srcBaseEventId);
+
+       return srcBaseEventId;
+}
+
+void
+_CalEventImpl::SetOriginalCalEventId(RecordId originalEventId)
+{
+       __originalEventId = originalEventId;
+       __isInstance = true;
+}
+
+int
+_CalEventImpl::GetAttendeeIndex(const char* pAttendeeEmail)
+{
+       int index = _INVALID_ATTENDEE_INDEX;
+       unsigned int attendeeCount = 0;
+
+       calendar_record_get_child_record_count(__eventRecord.GetHandle(), _calendar_event.calendar_attendee, &attendeeCount);
+
+       calendar_record_h tmpAttendeeHandle = null;
+       char* pTmpAttendeeEmail = null;
+       for (unsigned int i = 0; i < attendeeCount; i++)
+       {
+               calendar_record_get_child_record_at_p(__eventRecord.GetHandle(), _calendar_event.calendar_attendee, i, &tmpAttendeeHandle);
+               calendar_record_get_str_p(tmpAttendeeHandle, _calendar_attendee.email, &pTmpAttendeeEmail);
+
+               if (strcmp(pAttendeeEmail, pTmpAttendeeEmail) == 0)
+               {
+                       index = i;
+                       break;
+               }
+       }
+
+       return index;
+}
+
+result
+_CalEventImpl::VerifyRecurrence(const Recurrence& recurrence)
+{
+       const DateTime* pUntil = recurrence.GetUntil();
+       RecurFrequency frequency = recurrence.GetFrequency();
+       int durationLimit = 0;
+       int interval = recurrence.GetInterval();
+
+       DateTime startTime = GetStartTime();
+       DateTime endTime = GetEndTime();
+       EventCategory category = GetCategory();
+
+       if (pUntil != null)
+       {
+               SysTryReturnResult(NID_SCL, startTime <= *pUntil, E_INVALID_CONDITION, "The until date of recurrence is earlier than start date.");
+       }
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if (category == EVENT_CATEGORY_ANNIVERSARY)
+               {
+                       SysTryReturnResult(NID_SCL, frequency == FREQ_YEARLY, E_TYPE_MISMATCH
+                                       , "The recurrence pattern is not a yearly pattern in case of the event being an Anniversary.");
+               }
+       }
+
+       if (frequency == FREQ_DAILY)
+       {
+               durationLimit = _TERM_LIMIT_DAILY * interval;
+       }
+       else if (frequency == FREQ_WEEKLY)
+       {
+               SysTryReturnResult(NID_SCL, recurrence.GetDayOfWeek() != 0, E_INVALID_ARG, "Invalid argument is used. The day of week is not set.");
+               durationLimit = _TERM_LIMIT_WEEKLY * interval;
+       }
+       else if (frequency == FREQ_MONTHLY)
+       {
+               SysTryReturnResult(NID_SCL, recurrence.GetDayOfMonth() != 0 || (recurrence.GetDayOfWeek() != 0 && recurrence.GetWeekOfMonth() != 0)
+                               , E_INVALID_ARG, "Invalid argument is used. The day of month or day of week/week of month is not set.");
+               durationLimit = _TERM_LIMIT_MONTHLY * interval;
+       }
+       else if (frequency == FREQ_YEARLY)
+       {
+               int dayOfMonth = recurrence.GetDayOfMonth();
+               int monthOfYear = recurrence.GetMonthOfYear();
+               SysTryReturnResult(NID_SCL, monthOfYear != 0, E_INVALID_ARG, "Invalid argument is used. The month of year is not set.");
+               SysTryReturnResult(NID_SCL, dayOfMonth != 0 || (recurrence.GetDayOfWeek() != 0 && recurrence.GetWeekOfMonth() != 0)
+                               , E_INVALID_ARG, "Invalid argument is used. The day of month or day of week/week of month is not set.");
+
+               SysTryReturnResult(NID_SCL, monthOfYear != 2 || dayOfMonth < 30
+                               , E_INVALID_ARG, "Invalid argument is used. If the frequency is yearly, the max days of the February is less than 30.");
+               if (dayOfMonth > 30)
+               {
+                       SysTryReturnResult(NID_SCL, monthOfYear != 4 && monthOfYear != 6 && monthOfYear != 9 && monthOfYear != 11
+                                       , E_INVALID_ARG, "Invalid argument is used. If the frequency is yearly, the max days of the April, June, September and November is less than 31.");
+               }
+
+               durationLimit = _TERM_LIMIT_YEARLY * interval;
+       }
+
+       TimeSpan duration = endTime.GetTime() - startTime.GetTime();
+       SysTryReturnResult(NID_SCL, duration.GetDays() <= durationLimit, E_INVALID_CONDITION
+                       , "The duration of the event is greater than (interval x frequency) days. duration days = %d", duration.GetDays());
+
+       return E_SUCCESS;
+}
+
+result
+_CalEventImpl::ResetStartAndEndTimeByRecurrence(const Recurrence& recurrence)
+{
+       DateTime startTime;
+       DateTime endTime;
+
+       bool isAllDay = IsAllDayEvent();
+       Locales::TimeZone timeZone;
+
+       if (!isAllDay)
+       {
+               timeZone = GetTimeZone();
+               startTime = timeZone.UtcTimeToWallTime(GetStartTime());
+               endTime = timeZone.UtcTimeToWallTime(GetEndTime());
+       }
+       else
+       {
+               startTime = GetStartTime();
+               endTime = GetEndTime();
+       }
+
+       DateTime calculatedStartTime(startTime);
+       DateTime calculatedEndTime(endTime);
+       RecurFrequency frequency = recurrence.GetFrequency();
+       int interval = recurrence.GetInterval();
+       int dayOfMonth = recurrence.GetDayOfMonth();
+       int dayOfWeek = recurrence.GetDayOfWeek();
+       int weekOfMonth = recurrence.GetWeekOfMonth();
+       int monthOfYear = recurrence.GetMonthOfYear();
+       CalDayOfWeek weekStart = recurrence.GetWeekStart();
+       CalDayOfWeek weekEnd = CAL_SATURDAY;
+       DateTime until;
+       TimeSpan duration = endTime.GetTime() - startTime.GetTime();
+
+       if (weekStart == CAL_MONDAY)
+       {
+               weekEnd = CAL_SUNDAY;
+       }
+
+       if (recurrence.GetUntil() != null)
+       {
+               until = *(recurrence.GetUntil());
+               if (!isAllDay)
+               {
+                       until = timeZone.UtcTimeToWallTime(until);
+               }
+       }
+       else
+       {
+               until = _CalendarbookImpl::GetMaxDateTime();
+       }
+
+       CalDayOfWeek dayOfStartTime = GetDayOfWeek(startTime, timeZone);
+
+       if (frequency == FREQ_WEEKLY)
+       {
+               int count = 0;
+
+               for (int i = 0; i < _NUMBER_OF_DAYS_OF_WEEK; i++)
+               {
+                       if ((dayOfStartTime & dayOfWeek) != 0)
+                       {
+                               break;
+                       }
+
+                       if ((dayOfStartTime & weekEnd) != 0)
+                       {
+                               count += (interval - 1) * _NUMBER_OF_DAYS_OF_WEEK;
+                       }
+
+                       dayOfStartTime = GetNextDayOfWeek(dayOfStartTime);
+                       count++;
+               }
+
+               result r = calculatedStartTime.AddDays(count);
+               SysTryReturnResult(NID_SCL, !IsFailed(r), r, "[%s][Propagating]", GetErrorMessage(r));
+               r = calculatedEndTime.AddDays(count);
+               SysTryReturnResult(NID_SCL, !IsFailed(r), r, "[%s][Propagating]", GetErrorMessage(r));
+
+       }
+       else if (frequency == FREQ_MONTHLY)
+       {
+               if (dayOfMonth != 0)
+               {
+                       bool isDone = false;
+                       while (calculatedStartTime <= until)
+                       {
+                               if (calculatedStartTime.SetValue(calculatedStartTime.GetYear(), calculatedStartTime.GetMonth(), dayOfMonth, calculatedStartTime.GetHour(), calculatedStartTime.GetMinute(), calculatedStartTime.GetSecond()) == E_SUCCESS)
+                               {
+                                       if (calculatedStartTime >= startTime)
+                                       {
+                                               isDone = true;
+                                               break;
+                                       }
+                               }
+                               calculatedStartTime.AddMonths(interval);
+                       }
+                       SysTryReturnResult(NID_SCL, isDone, E_INVALID_ARG, "Invalid argument is used. There is no instance of the recurrence.");
+                       calculatedEndTime = calculatedStartTime;
+                       calculatedEndTime.Add(duration);
+               }
+               else
+               {
+                       bool isDone = false;
+                       int dayCount = 0;
+                       CalDayOfWeek tmpDayOfWeek = GetFirstDay(weekStart, dayOfWeek, dayCount);
+                       while (calculatedStartTime <= until)
+                       {
+                               for (int i = 0; i < dayCount; i++)
+                               {
+                                       calculatedStartTime = GetDate(calculatedStartTime.GetYear(), calculatedStartTime.GetMonth(), weekOfMonth, tmpDayOfWeek, calculatedStartTime, timeZone);
+                                       if (calculatedStartTime >= startTime)
+                                       {
+                                               isDone = true;
+                                               break;
+                                       }
+                                       tmpDayOfWeek = GetNextDay(dayOfWeek, tmpDayOfWeek);
+                               }
+                               if (isDone)
+                               {
+                                       break;
+                               }
+                               calculatedStartTime.AddMonths(interval);
+                       }
+
+                       SysTryReturnResult(NID_SCL, isDone, E_INVALID_ARG, "Invalid argument is used. There is no instance of the recurrence.");
+                       calculatedEndTime = calculatedStartTime;
+                       calculatedEndTime.Add(duration);
+               }
+       }
+       else if (frequency == FREQ_YEARLY)
+       {
+               if (dayOfMonth != 0)
+               {
+                       bool isDone = false;
+                       while (calculatedStartTime <= until)
+                       {
+                               if (calculatedStartTime.SetValue(calculatedStartTime.GetYear(), monthOfYear, dayOfMonth, calculatedStartTime.GetHour(), calculatedStartTime.GetMinute(), calculatedStartTime.GetSecond()) == E_SUCCESS)
+                               {
+                                       if (calculatedStartTime >= startTime)
+                                       {
+                                               isDone = true;
+                                               break;
+                                       }
+                               }
+                               calculatedStartTime.AddYears(interval);
+                       }
+                       SysTryReturnResult(NID_SCL, isDone, E_INVALID_ARG, "Invalid argument is used. There is no instance of the recurrence.");
+                       calculatedEndTime = calculatedStartTime;
+                       calculatedEndTime.Add(duration);
+               }
+               else
+               {
+                       bool isDone = false;
+                       int dayCount = 0;
+                       CalDayOfWeek tmpDayOfWeek = GetFirstDay(weekStart, dayOfWeek, dayCount);
+                       while (calculatedStartTime <= until)
+                       {
+                               for (int i = 0; i < dayCount; i++)
+                               {
+                                       calculatedStartTime = GetDate(calculatedStartTime.GetYear(), monthOfYear, weekOfMonth, tmpDayOfWeek, calculatedStartTime, timeZone);
+                                       if (calculatedStartTime >= startTime)
+                                       {
+                                               isDone = true;
+                                               break;
+                                       }
+                                       tmpDayOfWeek = GetNextDay(dayOfWeek, tmpDayOfWeek);
+                               }
+                               if (isDone)
+                               {
+                                       break;
+                               }
+                               calculatedStartTime.AddYears(interval);
+                       }
+
+                       SysTryReturnResult(NID_SCL, isDone, E_INVALID_ARG, "Invalid argument is used. There is no instance of the recurrence.");
+                       calculatedEndTime = calculatedStartTime;
+                       calculatedEndTime.Add(duration);
+               }
+       }
+
+       if (!isAllDay)
+       {
+               calculatedStartTime = timeZone.WallTimeToUtcTime(calculatedStartTime);
+               calculatedEndTime = timeZone.WallTimeToUtcTime(calculatedEndTime);
+       }
+
+       SysTryReturnResult(NID_SCL, calculatedStartTime <= until, E_INVALID_ARG, "Invalid argument is used. There is no instance of the recurrence.");
+       SysTryReturnResult(NID_SCL, calculatedEndTime <= _CalendarbookImpl::GetMaxDateTime(), E_INVALID_ARG, "Invalid argument is used. There is no instance of the recurrence.");
+
+       SysLog(NID_SCL, "Reset start time : %S", calculatedStartTime.ToString().GetPointer());
+       SetStartAndEndTimeCommon(calculatedStartTime, calculatedEndTime);
+
+       return E_SUCCESS;
+}
+
+int
+_CalEventImpl::ConvertRRuleByDayStringToDayOfWeek(const String& byDay) const
+{
+       int dayOfWeek = 0;
+       ClearLastResult();
+
+       SysTryReturn(NID_SCL, !byDay.IsEmpty(), 0, E_INVALID_ARG, "[%s] Invalid argument is used. The byDay is empty.", GetErrorMessage(E_INVALID_ARG));
+
+       String delim(_RECURRENCE_DELIMITER);
+       String token;
+
+       StringTokenizer strTok(byDay, delim);
+       while (strTok.HasMoreTokens())
+       {
+               result r = strTok.GetNextToken(token);
+               SysTryReturn(NID_SCL, r == E_SUCCESS, 0, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               if (token == String(_RECURRENCE_KEYWORD_SUNDAY))
+               {
+                       dayOfWeek |= CAL_SUNDAY;
+               }
+               else    if (token == String(_RECURRENCE_KEYWORD_MONDAY))
+               {
+                       dayOfWeek |= CAL_MONDAY;
+               }
+               else    if (token == String(_RECURRENCE_KEYWORD_TUESDAY))
+               {
+                       dayOfWeek |= CAL_TUESDAY;
+               }
+               else    if (token == String(_RECURRENCE_KEYWORD_WEDNESDAY))
+               {
+                       dayOfWeek |= CAL_WEDNESDAY;
+               }
+               else    if (token == String(_RECURRENCE_KEYWORD_THURSDAY))
+               {
+                       dayOfWeek |= CAL_THURSDAY;
+               }
+               else    if (token == String(_RECURRENCE_KEYWORD_FRIDAY))
+               {
+                       dayOfWeek |= CAL_FRIDAY;
+               }
+               else    if (token == String(_RECURRENCE_KEYWORD_SATURDAY))
+               {
+                       dayOfWeek |= CAL_SATURDAY;
+               }
+               else
+               {
+                       SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. byday = %S", GetErrorMessage(E_INVALID_ARG), byDay.GetPointer());
+                       return 0;
+               }
+       }
+
+       return dayOfWeek;
+}
+
+result
+_CalEventImpl::ConvertRRuleByDayStringToDayOfWeekAndWeekOfMonth(const String& byDay, int& weekOfMonth, int& dayOfWeek) const
+{
+       String delim(_RECURRENCE_DELIMITER);
+       String token;
+       wchar_t tmpChar = 0;
+       int tmpWeekOfMonth = 0;
+       int weekStringStartIndex = 0;
+       String tmpString;
+
+       weekOfMonth = 0;
+       dayOfWeek = 0;
+
+       SysTryReturnResult(NID_SCL, !byDay.IsEmpty(), E_INVALID_ARG, "Invalid argument is passed. The byDay is empty.");
+
+       StringTokenizer strTok(byDay, delim);
+
+       while (strTok.HasMoreTokens())
+       {
+               result r = strTok.GetNextToken(token);
+               SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               r = token.GetCharAt(_RECURRENCE_BY_DAY_FIRST_INDEX, tmpChar);
+               if (tmpChar == _RECURRENCE_BY_DAY_CHAR_MINUS)
+               {
+                       SysTryReturnResult(NID_SCL, weekOfMonth == 0 || weekOfMonth == _MAX_WEEK_OF_MONTH
+                                       , E_INVALID_ARG, "Invalid argument is passed. byday = %S", byDay.GetPointer());
+
+                       if (weekOfMonth == 0)
+                       {
+                               tmpChar = 0;
+                               r = token.GetCharAt(_RECURRENCE_BY_DAY_SECOND_INDEX, tmpChar);
+                               SysTryReturnResult(NID_SCL, tmpChar == _RECURRENCE_BY_DAY_CHAR_ONE
+                                               , E_INVALID_ARG, "Invalid argument is passed. byday = %S", byDay.GetPointer());
+
+                               weekOfMonth = _MAX_WEEK_OF_MONTH;
+                       }
+                       weekStringStartIndex = _RECURRENCE_BY_DAY_SECOND_INDEX + 1;
+               }
+               else if (tmpChar == _RECURRENCE_BY_DAY_CHAR_PLUS)
+               {
+                       if (weekOfMonth == 0)
+                       {
+                               tmpChar = 0;
+                               r = token.GetCharAt(_RECURRENCE_BY_DAY_SECOND_INDEX, tmpChar);
+                               tmpWeekOfMonth = Character::ToDigit(tmpChar, Character::RADIX_DECIMAL);
+                               SysTryReturnResult(NID_SCL, tmpWeekOfMonth > 0 && tmpWeekOfMonth <= _MAX_WEEK_OF_MONTH
+                                               , E_INVALID_ARG, "Invalid argument is passed. byday = %S", byDay.GetPointer());
+
+                               weekOfMonth = tmpWeekOfMonth;
+                       }
+                       else
+                       {
+                               SysTryReturnResult(NID_SCL, weekOfMonth == tmpWeekOfMonth
+                                               , E_INVALID_ARG, "Invalid argument is passed. byday = %S", byDay.GetPointer());
+                       }
+
+                       weekStringStartIndex = _RECURRENCE_BY_DAY_SECOND_INDEX + 1;
+               }
+               else
+               {
+                       if (weekOfMonth == 0)
+                       {
+                               tmpWeekOfMonth = Character::ToDigit(tmpChar, Character::RADIX_DECIMAL);
+                               SysTryReturnResult(NID_SCL, tmpWeekOfMonth > 0 && tmpWeekOfMonth <= _MAX_WEEK_OF_MONTH
+                                               , E_INVALID_ARG, "Invalid argument is passed. byday = %S", byDay.GetPointer());
+
+                               weekOfMonth = tmpWeekOfMonth;
+                       }
+                       else
+                       {
+                               SysTryReturnResult(NID_SCL, weekOfMonth == tmpWeekOfMonth
+                                               , E_INVALID_ARG, "Invalid argument is passed. byday = %S", byDay.GetPointer());
+                       }
+
+                       weekStringStartIndex = _RECURRENCE_BY_DAY_FIRST_INDEX + 1;
+               }
+
+               token.SubString(weekStringStartIndex, tmpString);
+
+               if (tmpString == String(_RECURRENCE_KEYWORD_SUNDAY))
+               {
+                       dayOfWeek |= CAL_SUNDAY;
+               }
+               else    if (tmpString == String(_RECURRENCE_KEYWORD_MONDAY))
+               {
+                       dayOfWeek |= CAL_MONDAY;
+               }
+               else    if (tmpString == String(_RECURRENCE_KEYWORD_TUESDAY))
+               {
+                       dayOfWeek |= CAL_TUESDAY;
+               }
+               else    if (tmpString == String(_RECURRENCE_KEYWORD_WEDNESDAY))
+               {
+                       dayOfWeek |= CAL_WEDNESDAY;
+               }
+               else    if (tmpString == String(_RECURRENCE_KEYWORD_THURSDAY))
+               {
+                       dayOfWeek |= CAL_THURSDAY;
+               }
+               else    if (tmpString == String(_RECURRENCE_KEYWORD_FRIDAY))
+               {
+                       dayOfWeek |= CAL_FRIDAY;
+               }
+               else    if (tmpString == String(_RECURRENCE_KEYWORD_SATURDAY))
+               {
+                       dayOfWeek |= CAL_SATURDAY;
+               }
+               else
+               {
+                       SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. byday = %S", GetErrorMessage(E_INVALID_ARG), byDay.GetPointer());
+               }
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_CalEventImpl::ConvertRRuleExDateStringToRecurrence(const String& exdate, Recurrence& recurrence) const
+{
+       String delim(_RECURRENCE_DELIMITER);
+       String token;
+       DateTime tmpDateTime;
+       TimeZone tmpTimeZone;
+       TimeZone utcTimeZone = TimeZone::GetGmtTimeZone();
+       bool isDate = false;
+
+       SysTryReturnResult(NID_SCL, !exdate.IsEmpty(), E_INVALID_ARG, "Invalid argument is passed. The exdate is empty.");
+
+       StringTokenizer strTok(exdate, delim);
+       while (strTok.HasMoreTokens())
+       {
+               result r = strTok.GetNextToken(token);
+               SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               r = _CalendarbookUtil::ConvertRRuleDateTimeStringToDateTime(token, tmpDateTime, tmpTimeZone, isDate);
+               SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. exdate = %S", exdate.GetPointer());
+
+               if (!isDate && tmpTimeZone != utcTimeZone)
+               {
+                       tmpDateTime = tmpTimeZone.WallTimeToUtcTime(tmpDateTime);
+               }
+
+               r = recurrence.AddExceptionDate(tmpDateTime);
+               SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. exdate = %S", exdate.GetPointer());
+       }
+
+       return E_SUCCESS;
+}
+
+String
+_CalEventImpl::ConvertRecurrenceToRRuleExDateString(const Recurrence& recurrence, bool isDate) const
+{
+       bool isNotFirst = false;
+       String exdateString;
+
+       std::unique_ptr<IList, AllElementsDeleter> pExDateList(recurrence.GetExceptionDatesN());
+
+       std::unique_ptr<IEnumerator> pEnum(pExDateList->GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               DateTime* pDateTime = static_cast<DateTime*>(pEnum->GetCurrent());
+
+               if (isNotFirst)
+               {
+                       exdateString.Append(_RECURRENCE_DELIMITER);
+               }
+
+               exdateString.Append(_CalendarbookUtil::ConvertDateTimeToRRuleDateTimeString(*pDateTime, isDate));
+
+               isNotFirst = true;
+       }
+
+       return exdateString;
+}
+
+CalDayOfWeek
+_CalEventImpl::GetNextDayOfWeek(CalDayOfWeek currentDay)
+{
+       int tmpDay = currentDay;
+
+       tmpDay <<= 1;
+       if (tmpDay > CAL_SATURDAY)
+       {
+               tmpDay = CAL_SUNDAY;
+       }
+
+       return static_cast<CalDayOfWeek>(tmpDay);
+}
+
+DateTime
+_CalEventImpl::GetDate(int year, int month, int weekOfMonth, CalDayOfWeek dayOfWeek, const DateTime& time, const TimeZone& timeZone)
+{
+       ClearLastResult();
+
+       Tizen::Locales::DayOfWeek dayOfWeekByGregorianCalendar = Tizen::Locales::DAY_OF_WEEK_UNDEFINED;
+
+       switch (dayOfWeek)
+       {
+       case CAL_SUNDAY:
+               dayOfWeekByGregorianCalendar = Tizen::Locales::SUNDAY;
+               break;
+
+       case CAL_MONDAY:
+               dayOfWeekByGregorianCalendar = Tizen::Locales::MONDAY;
+               break;
+
+       case CAL_TUESDAY:
+               dayOfWeekByGregorianCalendar = Tizen::Locales::TUESDAY;
+               break;
+
+       case CAL_WEDNESDAY:
+               dayOfWeekByGregorianCalendar = Tizen::Locales::WEDNESDAY;
+               break;
+
+       case CAL_THURSDAY:
+               dayOfWeekByGregorianCalendar = Tizen::Locales::THURSDAY;
+               break;
+
+       case CAL_FRIDAY:
+               dayOfWeekByGregorianCalendar = Tizen::Locales::FRIDAY;
+               break;
+
+       case CAL_SATURDAY:
+               dayOfWeekByGregorianCalendar = Tizen::Locales::SATURDAY;
+               break;
+
+       default:
+               break;
+       }
+
+       std::unique_ptr<Tizen::Locales::Calendar> pGregorianCalendar(Tizen::Locales::Calendar::CreateInstanceN(timeZone, Tizen::Locales::CALENDAR_GREGORIAN));
+       SysTryReturn(NID_SCL, pGregorianCalendar != null, DateTime(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       pGregorianCalendar->SetTimeField(Tizen::Locales::TIME_FIELD_YEAR, year);
+       pGregorianCalendar->SetTimeField(Tizen::Locales::TIME_FIELD_MONTH, month);
+       pGregorianCalendar->SetTimeField(Tizen::Locales::TIME_FIELD_DAY_OF_MONTH, 1);
+
+       Tizen::Locales::DayOfWeek tmpDayOfWeek = static_cast<Tizen::Locales::DayOfWeek>(pGregorianCalendar->GetTimeField(TIME_FIELD_DAY_OF_WEEK));
+       int maxDaysOfMonth = pGregorianCalendar->GetActualMaxTimeField(TIME_FIELD_DAY_OF_MONTH);
+       int tmpDayOfMonth = ((_NUMBER_OF_DAYS_OF_WEEK + dayOfWeekByGregorianCalendar) - tmpDayOfWeek) % _NUMBER_OF_DAYS_OF_WEEK + 1;
+
+       tmpDayOfMonth += ((weekOfMonth - 1) * _NUMBER_OF_DAYS_OF_WEEK);
+       if (tmpDayOfMonth > maxDaysOfMonth)
+       {
+               tmpDayOfMonth -= _NUMBER_OF_DAYS_OF_WEEK;
+       }
+
+       DateTime resultTime;
+       resultTime.SetValue(year, month, tmpDayOfMonth, time.GetHour(), time.GetMinute(), time.GetSecond());
+
+       return resultTime;
+}
+
+CalDayOfWeek
+_CalEventImpl::GetDayOfWeek(const DateTime& date, const Locales::TimeZone& timeZone)
+{
+       ClearLastResult();
+
+       CalDayOfWeek dayOfWeek = CAL_SUNDAY;
+
+       std::unique_ptr<Tizen::Locales::Calendar> pGregorianCalendar(Tizen::Locales::Calendar::CreateInstanceN(timeZone, Tizen::Locales::CALENDAR_GREGORIAN));
+       SysTryReturn(NID_SCL, pGregorianCalendar != null, dayOfWeek, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       pGregorianCalendar->SetTime(date);
+       int dayOfWeekByGregorianCalendar = pGregorianCalendar->GetTimeField(Tizen::Locales::TIME_FIELD_DAY_OF_WEEK);
+
+       switch (dayOfWeekByGregorianCalendar)
+       {
+       case Tizen::Locales::SUNDAY:
+               dayOfWeek = CAL_SUNDAY;
+               break;
+
+       case Tizen::Locales::MONDAY:
+               dayOfWeek = CAL_MONDAY;
+               break;
+
+       case Tizen::Locales::TUESDAY:
+               dayOfWeek = CAL_TUESDAY;
+               break;
+
+       case Tizen::Locales::WEDNESDAY:
+               dayOfWeek = CAL_WEDNESDAY;
+               break;
+
+       case Tizen::Locales::THURSDAY:
+               dayOfWeek = CAL_THURSDAY;
+               break;
+
+       case Tizen::Locales::FRIDAY:
+               dayOfWeek = CAL_FRIDAY;
+               break;
+
+       case Tizen::Locales::SATURDAY:
+               dayOfWeek = CAL_SATURDAY;
+               break;
+
+       default:
+               break;
+       }
+
+       return dayOfWeek;
+}
+
+CalDayOfWeek
+_CalEventImpl::GetFirstDay(CalDayOfWeek weekStart, int dayOfWeek, int& count)
+{
+       int firstDay = 0;
+       int tmpDay = weekStart;
+
+       count = 0;
+       for (int i = 0; i < _NUMBER_OF_DAYS_OF_WEEK; i++)
+       {
+               if ((tmpDay & dayOfWeek) != 0)
+               {
+                       if (firstDay == 0)
+                       {
+                               firstDay = tmpDay;
+                       }
+
+                       count++;
+               }
+
+               tmpDay = GetNextDayOfWeek(static_cast<CalDayOfWeek>(tmpDay));
+       }
+
+       return static_cast<CalDayOfWeek>(firstDay);
+}
+
+CalDayOfWeek
+_CalEventImpl::GetNextDay(int dayOfWeek, CalDayOfWeek currentDay)
+{
+       int tmpDay = currentDay;
+
+       for (int i = 0; i < _NUMBER_OF_DAYS_OF_WEEK; i++)
+       {
+               tmpDay = GetNextDayOfWeek(static_cast<CalDayOfWeek>(tmpDay));
+
+               if ((tmpDay & dayOfWeek) != 0)
+               {
+                       break;
+               }
+       }
+
+       return static_cast<CalDayOfWeek>(tmpDay);
+}
+
+void
+_CalEventImpl::SetRecordHandle(calendar_record_h eventHandle)
+{
+       __eventRecord.ResetHandle(eventHandle);
+}
+
+calendar_record_h
+_CalEventImpl::GetRecordHandle(void) const
+{
+       return __eventRecord.GetHandle();
+}
+
+CalEvent*
+_CalEventImpl::CreateDefaultInstanceN(void)
+{
+       return new (std::nothrow) CalEvent();
+}
+
+_CalEventImpl*
+_CalEventImpl::GetInstance(CalEvent& event)
+{
+       return event.__pCalEventImpl;
+}
+
+const _CalEventImpl*
+_CalEventImpl::GetInstance(const CalEvent& event)
+{
+       return event.__pCalEventImpl;
+}
+
+}} //Tizen::Social
diff --git a/src/FScl_CalEventInstanceImpl.cpp b/src/FScl_CalEventInstanceImpl.cpp
new file mode 100644 (file)
index 0000000..d2eb436
--- /dev/null
@@ -0,0 +1,301 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_CalEventInstanceImpl.cpp
+ * @brief              This is the implementation for _CalEventInstanceImpl class.
+ *
+ * This file contains definitions of @e _CalEventInstanceImpl class.
+ */
+
+#include <FBaseDateTime.h>
+#include <FBaseString.h>
+#include <FSclCalEventInstance.h>
+#include "FScl_CalEventInstanceImpl.h"
+#include "FScl_RecordImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+_CalEventInstanceImpl::_CalEventInstanceImpl(void)
+       : __originalEventId(INVALID_RECORD_ID)
+       , __calendarId(INVALID_RECORD_ID)
+       , __isAllDayEvent(false)
+       , __busyStatus(BUSY_STATUS_FREE)
+       , __status(EVENT_STATUS_NONE)
+       , __priority(EVENT_PRIORITY_NORMAL)
+       , __sensitivity(SENSITIVITY_PUBLIC)
+       , __isRecurring(false)
+       , __hasReminder(false)
+{
+}
+
+_CalEventInstanceImpl::_CalEventInstanceImpl(const _CalEventInstanceImpl& rhs)
+       : __originalEventId(rhs.__originalEventId)
+       , __calendarId(rhs.__calendarId)
+       , __startDateTime(rhs.__startDateTime)
+       , __endDateTime(rhs.__endDateTime)
+       , __subject(rhs.__subject)
+       , __description(rhs.__description)
+       , __location(rhs.__location)
+       , __isAllDayEvent(rhs.__isAllDayEvent)
+       , __busyStatus(rhs.__busyStatus)
+       , __status(rhs.__status)
+       , __priority(rhs.__priority)
+       , __sensitivity(rhs.__sensitivity)
+       , __isRecurring(rhs.__isRecurring)
+       , __hasReminder(rhs.__hasReminder)
+{
+}
+
+_CalEventInstanceImpl::~_CalEventInstanceImpl(void)
+{
+}
+
+_CalEventInstanceImpl&
+_CalEventInstanceImpl::operator =(const _CalEventInstanceImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __originalEventId = rhs.__originalEventId;
+       __calendarId = rhs.__calendarId;
+       __startDateTime = rhs.__startDateTime;
+       __endDateTime = rhs.__endDateTime;
+       __subject = rhs.__subject;
+       __description = rhs.__description;
+       __location = rhs.__location;
+       __isAllDayEvent = rhs.__isAllDayEvent;
+       __busyStatus = rhs.__busyStatus;
+       __status = rhs.__status;
+       __priority = rhs.__priority;
+       __sensitivity = rhs.__sensitivity;
+       __isRecurring = rhs.__isRecurring;
+       __hasReminder = rhs.__hasReminder;
+
+       return *this;
+}
+
+bool
+_CalEventInstanceImpl::Equals(const Object& rhs) const
+{
+       const _CalEventInstanceImpl* pCalEventInstanceImpl = dynamic_cast<const _CalEventInstanceImpl*>(&rhs);
+
+       if (pCalEventInstanceImpl == null)
+       {
+               return false;
+       }
+
+       return (__originalEventId == pCalEventInstanceImpl->__originalEventId && __calendarId == pCalEventInstanceImpl->__calendarId
+                       && __startDateTime == pCalEventInstanceImpl->__startDateTime);
+}
+
+int
+_CalEventInstanceImpl::GetHashCode(void) const
+{
+       int hashCode = 17;
+
+       hashCode = static_cast<int>(( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __originalEventId);
+       hashCode = static_cast<int>(( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __calendarId);
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __startDateTime.GetHashCode();
+
+       return hashCode;
+}
+
+RecordId
+_CalEventInstanceImpl::GetOriginalEventId(void) const
+{
+       return __originalEventId;
+}
+
+RecordId
+_CalEventInstanceImpl::GetCalendarId(void) const
+{
+       return __calendarId;
+}
+
+DateTime
+_CalEventInstanceImpl::GetStartTime(void) const
+{
+       return __startDateTime;
+}
+
+DateTime
+_CalEventInstanceImpl::GetEndTime(void) const
+{
+       return __endDateTime;
+}
+
+String
+_CalEventInstanceImpl::GetSubject(void) const
+{
+       return __subject;
+}
+
+String
+_CalEventInstanceImpl::GetDescription(void) const
+{
+       return __description;
+}
+
+String
+_CalEventInstanceImpl::GetLocation(void) const
+{
+       return __location;
+}
+
+bool
+_CalEventInstanceImpl::IsAllDayEvent(void) const
+{
+       return __isAllDayEvent;
+}
+
+BusyStatus
+_CalEventInstanceImpl::GetBusyStatus(void) const
+{
+       return __busyStatus;
+}
+
+EventStatus
+_CalEventInstanceImpl::GetStatus(void) const
+{
+       return __status;
+}
+
+EventPriority
+_CalEventInstanceImpl::GetPriority(void) const
+{
+       return __priority;
+}
+
+RecordSensitivity
+_CalEventInstanceImpl::GetSensitivity(void) const
+{
+       return __sensitivity;
+}
+
+bool
+_CalEventInstanceImpl::IsRecurring(void) const
+{
+       return __isRecurring;
+}
+
+bool
+_CalEventInstanceImpl::HasReminder(void) const
+{
+       return __hasReminder;
+}
+
+void
+_CalEventInstanceImpl::SetOriginalEventId(RecordId originalEventId)
+{
+       __originalEventId = originalEventId;
+}
+
+void
+_CalEventInstanceImpl::SetCalendarId(RecordId calendarId)
+{
+       __calendarId = calendarId;
+}
+
+void
+_CalEventInstanceImpl::SetStartTime(const DateTime& startTime)
+{
+       __startDateTime = startTime;
+}
+
+void
+_CalEventInstanceImpl::SetEndTime(const DateTime& endTime)
+{
+       __endDateTime = endTime;
+}
+
+void
+_CalEventInstanceImpl::SetSubject(const String& subject)
+{
+       __subject = subject;
+}
+
+void
+_CalEventInstanceImpl::SetDescription(const String& description)
+{
+       __description = description;
+}
+
+void
+_CalEventInstanceImpl::SetLocation(const String& location)
+{
+       __location = location;
+}
+
+void
+_CalEventInstanceImpl::SetAllDayEvent(bool isAllDayEvent)
+{
+       __isAllDayEvent = isAllDayEvent;
+}
+
+void
+_CalEventInstanceImpl::SetBusyStatus(BusyStatus busyStatus)
+{
+       __busyStatus = busyStatus;
+}
+
+void
+_CalEventInstanceImpl::SetStatus(EventStatus status)
+{
+       __status = status;
+}
+
+void
+_CalEventInstanceImpl::SetPriority(EventPriority priority)
+{
+       __priority = priority;
+}
+
+void
+_CalEventInstanceImpl::SetSensitivity(RecordSensitivity sensitivity)
+{
+       __sensitivity = sensitivity;
+}
+
+void
+_CalEventInstanceImpl::SetRecurring(bool isRecurring)
+{
+       __isRecurring = isRecurring;
+}
+
+void
+_CalEventInstanceImpl::SetHasReminder(bool hasReminder)
+{
+       __hasReminder = hasReminder;
+}
+
+_CalEventInstanceImpl*
+_CalEventInstanceImpl::GetInstance(CalEventInstance& eventInstance)
+{
+       return eventInstance.__pCalEventInstanceImpl;
+}
+
+const _CalEventInstanceImpl*
+_CalEventInstanceImpl::GetInstance(const CalEventInstance& eventInstance)
+{
+       return eventInstance.__pCalEventInstanceImpl;
+}
+
+}} //Tizen::Social
diff --git a/src/FScl_CalTodoChangeInfoImpl.cpp b/src/FScl_CalTodoChangeInfoImpl.cpp
new file mode 100644 (file)
index 0000000..f0cf2e7
--- /dev/null
@@ -0,0 +1,158 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_CalTodoChangeInfoImpl.cpp
+ * @brief              This is the implementation for _CalTodoChangeInfoImpl class.
+ *
+ * This file contains definitions of @e _CalTodoChangeInfoImpl class.
+ */
+
+#include <FSclCalTodoChangeInfo.h>
+#include <FSclRecord.h>
+#include "FScl_CalTodoChangeInfoImpl.h"
+#include "FScl_RecordImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+const static int _INVALID_VERSION = -1;
+
+_CalTodoChangeInfoImpl::_CalTodoChangeInfoImpl(void)
+       : __changeType(RECORD_CHANGE_TYPE_ADDED)
+       , __todoId(INVALID_RECORD_ID)
+       , __calendarId(INVALID_RECORD_ID)
+       , __version(_INVALID_VERSION)
+{
+}
+
+_CalTodoChangeInfoImpl::_CalTodoChangeInfoImpl(const _CalTodoChangeInfoImpl& rhs)
+       : __changeType(rhs.__changeType)
+       , __todoId(rhs.__todoId)
+       , __calendarId(rhs.__calendarId)
+       , __version(rhs.__version)
+{
+}
+
+_CalTodoChangeInfoImpl::~_CalTodoChangeInfoImpl(void)
+{
+}
+
+_CalTodoChangeInfoImpl&
+_CalTodoChangeInfoImpl::operator =(const _CalTodoChangeInfoImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __changeType = rhs.__changeType;
+       __todoId = rhs.__todoId;
+       __calendarId = rhs.__calendarId;
+       __version = rhs.__version;
+
+       return *this;
+}
+
+bool
+_CalTodoChangeInfoImpl::Equals(const Object& rhs) const
+{
+       const _CalTodoChangeInfoImpl* pCalTodoChangeInfoImpl = dynamic_cast<const _CalTodoChangeInfoImpl*>(&rhs);
+
+       if (pCalTodoChangeInfoImpl == null)
+       {
+               return false;
+       }
+
+       return (__changeType == pCalTodoChangeInfoImpl->__changeType && __todoId == pCalTodoChangeInfoImpl->__todoId
+                       && __calendarId == pCalTodoChangeInfoImpl->__calendarId && __version == pCalTodoChangeInfoImpl->__version);
+}
+
+int
+_CalTodoChangeInfoImpl::GetHashCode(void) const
+{
+       int hashCode = 17;
+
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __changeType;
+       hashCode = static_cast<int>(( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __todoId);
+       hashCode = static_cast<int>(( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __calendarId);
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __version;
+
+       return hashCode;
+}
+
+RecordChangeType
+_CalTodoChangeInfoImpl::GetChangeType(void) const
+{
+       return __changeType;
+}
+
+RecordId
+_CalTodoChangeInfoImpl::GetTodoId(void) const
+{
+       return __todoId;
+}
+
+RecordId
+_CalTodoChangeInfoImpl::GetCalendarId(void) const
+{
+       return __calendarId;
+}
+
+int
+_CalTodoChangeInfoImpl::GetVersion(void) const
+{
+       return __version;
+}
+
+void
+_CalTodoChangeInfoImpl::SetChangeType(RecordChangeType changeType)
+{
+       __changeType = changeType;
+}
+
+void
+_CalTodoChangeInfoImpl::SetTodoId(RecordId todoId)
+{
+       __todoId = todoId;
+}
+
+void
+_CalTodoChangeInfoImpl::SetCalendarId(RecordId calendarId)
+{
+       __calendarId = calendarId;
+}
+
+void
+_CalTodoChangeInfoImpl::SetVersion(int version)
+{
+       __version = version;
+}
+
+_CalTodoChangeInfoImpl*
+_CalTodoChangeInfoImpl::GetInstance(CalTodoChangeInfo& calTodoChangeInfo)
+{
+       return calTodoChangeInfo.__pCalTodoChangeInfoImpl;
+}
+
+const _CalTodoChangeInfoImpl*
+_CalTodoChangeInfoImpl::GetInstance(const CalTodoChangeInfo& calTodoChangeInfo)
+{
+       return calTodoChangeInfo.__pCalTodoChangeInfoImpl;
+}
+
+}}     // Tizen::Social
diff --git a/src/FScl_CalTodoImpl.cpp b/src/FScl_CalTodoImpl.cpp
new file mode 100644 (file)
index 0000000..903d0ad
--- /dev/null
@@ -0,0 +1,645 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_CalTodoImpl.cpp
+ * @brief              This is the implementation for _CalTodoImpl class.
+ *
+ * This file contains definitions of @e CalTodoImpl class.
+ */
+
+#include <FApp_AppInfo.h>
+#include <FBaseColArrayList.h>
+#include <FBaseDateTime.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include <FSclCalTodo.h>
+#include <FSclRecord.h>
+#include <FSclReminder.h>
+#include <FSclRecurrence.h>
+#include <FSysSystemTime.h>
+#include <FSclTypes.h>
+#include "FScl_CalendarbookDbConnector.h"
+#include "FScl_CalendarbookImpl.h"
+#include "FScl_CalTodoImpl.h"
+#include "FScl_RecordImpl.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Social
+{
+static const double _MIN_LATITUDE = -90.0;
+static const double _MAX_LATITUDE = 90.0;
+static const double _MIN_LONGITUDE = -180.0;
+static const double _MAX_LONGITUDE = 180.0;
+
+static const long long _CALENDAR_TODO_NO_START_DATE = -0x7fffffffffffffffLL;
+static const long long _CALENDAR_TODO_NO_DUE_DATE = 0x7fffffffffffffffLL;
+
+_CalTodoImpl::_CalTodoImpl(void)
+       : __reminderListUpdated(false)
+{
+       calendar_record_h todoHandle = null;
+
+       result r = _CalendarbookDbConnector::Connect();
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       int errorCode = calendar_record_create(_calendar_todo._uri, &todoHandle);
+       SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               DateTime tmpDateTime;
+
+               // Set start date to current date
+               Tizen::System::SystemTime::GetCurrentTime(tmpDateTime);
+               if (IsFailed(GetLastResult()))
+               {
+                       tmpDateTime = _CalendarbookImpl::GetMinDateTime();
+                       ClearLastResult();
+               }
+               tmpDateTime.SetValue(tmpDateTime.GetYear(), tmpDateTime.GetMonth(), tmpDateTime.GetDay(), 0, 0, 0);
+
+               calendar_time_s convertedCalendarTime;
+
+               convertedCalendarTime.type = CALENDAR_TIME_UTIME;
+               convertedCalendarTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(tmpDateTime);
+
+               calendar_record_set_caltime(todoHandle, _calendar_todo.start_time, convertedCalendarTime);
+               calendar_record_set_caltime(todoHandle, _calendar_todo.due_time, convertedCalendarTime);
+       }
+       else
+       {
+               calendar_time_s convertedStartTime;
+               convertedStartTime.type = CALENDAR_TIME_UTIME;
+               convertedStartTime.time.utime = _CALENDAR_TODO_NO_START_DATE;
+
+               calendar_time_s convertedDueTime;
+               convertedDueTime.type = CALENDAR_TIME_UTIME;
+               convertedDueTime.time.utime = _CALENDAR_TODO_NO_DUE_DATE;
+
+               calendar_record_set_caltime(todoHandle, _calendar_todo.start_time, convertedStartTime);
+               calendar_record_set_caltime(todoHandle, _calendar_todo.due_time, convertedDueTime);
+       }
+
+       // default value
+       calendar_record_set_int(todoHandle, _calendar_todo.todo_status, CALENDAR_TODO_STATUS_NONE);
+       calendar_record_set_int(todoHandle, _calendar_todo.priority, CALENDAR_TODO_PRIORITY_NORMAL);
+       calendar_record_set_int(todoHandle, _calendar_todo.sensitivity, CALENDAR_SENSITIVITY_PUBLIC);
+       calendar_record_set_int(todoHandle, _calendar_todo.calendar_book_id, INVALID_RECORD_ID);
+
+       __todoRecord.ResetHandle(todoHandle);
+
+       r = __reminderList.Construct();
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+_CalTodoImpl::_CalTodoImpl(const _CalTodoImpl& rhs)
+       : __reminderListUpdated(false)
+{
+       calendar_record_h todoHandle = null;
+
+       result r = _CalendarbookDbConnector::Connect();
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       int errorCode = calendar_record_clone(rhs.__todoRecord.GetHandle(), &todoHandle);
+       SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __todoRecord.ResetHandle(todoHandle);
+
+       r = __reminderList.Construct();
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+_CalTodoImpl::~_CalTodoImpl(void)
+{
+       __reminderList.RemoveAll(true);
+
+       result r = _CalendarbookDbConnector::Disconnect();
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+}
+
+_CalTodoImpl&
+_CalTodoImpl::operator =(const _CalTodoImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __reminderList.RemoveAll(true);
+       __reminderListUpdated = false;
+
+       calendar_record_h todoHandle = null;
+
+       int errorCode = calendar_record_clone(rhs.__todoRecord.GetHandle(), &todoHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __todoRecord.ResetHandle(todoHandle);
+
+       return *this;
+}
+
+String
+_CalTodoImpl::GetSubject(void) const
+{
+       char* pSubject = null;
+
+       calendar_record_get_str_p(__todoRecord.GetHandle(), _calendar_todo.summary, &pSubject);
+
+       return String(pSubject);
+}
+
+String
+_CalTodoImpl::GetDescription(void) const
+{
+       char* pDescription = null;
+
+       calendar_record_get_str_p(__todoRecord.GetHandle(), _calendar_todo.description, &pDescription);
+
+       return String(pDescription);
+}
+
+DateTime
+_CalTodoImpl::GetStartDate(void) const
+{
+       ClearLastResult();
+
+       calendar_time_s tmpCalendarTime;
+
+       calendar_record_get_caltime(__todoRecord.GetHandle(), _calendar_todo.start_time, &tmpCalendarTime);
+
+       if (tmpCalendarTime.time.utime == _CALENDAR_TODO_NO_START_DATE)
+       {
+               SetLastResult(E_DATA_NOT_FOUND);
+               return DateTime::GetMinValue();
+       }
+
+       DateTime tmpDateTime = _CalendarbookUtil::ConvertEpochTimeToDateTime(tmpCalendarTime.time.utime);
+
+       return tmpDateTime;
+}
+
+DateTime
+_CalTodoImpl::GetDueDate(void) const
+{
+       ClearLastResult();
+
+       calendar_time_s tmpCalendarTime;
+
+       calendar_record_get_caltime(__todoRecord.GetHandle(), _calendar_todo.due_time, &tmpCalendarTime);
+
+       if (tmpCalendarTime.time.utime == _CALENDAR_TODO_NO_DUE_DATE)
+       {
+               SetLastResult(E_DATA_NOT_FOUND);
+               return DateTime::GetMinValue();
+       }
+
+       DateTime tmpDateTime = _CalendarbookUtil::ConvertEpochTimeToDateTime(tmpCalendarTime.time.utime);
+
+       return tmpDateTime;
+}
+
+TodoPriority
+_CalTodoImpl::GetPriority(void) const
+{
+       int srcPriority = CALENDAR_EVENT_PRIORITY_LOW;
+
+       TodoPriority priority = TODO_PRIORITY_NORMAL;
+
+       calendar_record_get_int(__todoRecord.GetHandle(), _calendar_todo.priority, &srcPriority);
+
+       switch (srcPriority)
+       {
+       case CALENDAR_TODO_PRIORITY_LOW:
+               priority = TODO_PRIORITY_LOW;
+               break;
+
+       case CALENDAR_TODO_PRIORITY_NONE:
+               // fall through
+       case CALENDAR_TODO_PRIORITY_NORMAL:
+               priority = TODO_PRIORITY_NORMAL;
+               break;
+
+       case CALENDAR_TODO_PRIORITY_HIGH:
+               priority = TODO_PRIORITY_HIGH;
+               break;
+
+       default:
+               SysLog(NID_SCL, "The priority value is invalid. priority = %d", srcPriority);
+               priority = TODO_PRIORITY_NORMAL;
+               break;
+       }
+
+       return priority;
+}
+
+TodoStatus
+_CalTodoImpl::GetStatus(void) const
+{
+       int srcStatus = CALENDAR_EVENT_STATUS_NONE;
+
+       TodoStatus status = TODO_STATUS_NONE;
+
+       calendar_record_get_int(__todoRecord.GetHandle(), _calendar_todo.todo_status, &srcStatus);
+
+       switch (srcStatus)
+       {
+       case CALENDAR_TODO_STATUS_NONE:
+               status = TODO_STATUS_NONE;
+               break;
+
+       case CALENDAR_TODO_STATUS_NEEDS_ACTION:
+               status = TODO_STATUS_NEEDS_ACTION;
+               break;
+
+       case CALENDAR_TODO_STATUS_COMPLETED:
+               status = TODO_STATUS_COMPLETED;
+               break;
+
+       case CALENDAR_TODO_STATUS_IN_PROCESS:
+               status = TODO_STATUS_IN_PROCESS;
+               break;
+
+       case CALENDAR_TODO_STATUS_CANCELED:
+               status = TODO_STATUS_CANCELLED;
+               break;
+
+       default:
+               SysLog(NID_SCL, "The status value is invalid. status = %d", srcStatus);
+               status = TODO_STATUS_NONE;
+               break;
+       }
+
+       return status;
+}
+
+RecordSensitivity
+_CalTodoImpl::GetSensitivity(void) const
+{
+       int srcSensitivity = CALENDAR_SENSITIVITY_PUBLIC;
+       RecordSensitivity sensitivity = SENSITIVITY_PUBLIC;
+
+       calendar_record_get_int(__todoRecord.GetHandle(), _calendar_todo.sensitivity, &srcSensitivity);
+
+       switch (srcSensitivity)
+       {
+       case CALENDAR_SENSITIVITY_PUBLIC:
+               sensitivity = SENSITIVITY_PUBLIC;
+               break;
+
+       case CALENDAR_SENSITIVITY_PRIVATE:
+               sensitivity = SENSITIVITY_PRIVATE;
+               break;
+
+       case CALENDAR_SENSITIVITY_CONFIDENTIAL:
+               sensitivity = SENSITIVITY_CONFIDENTIAL;
+               break;
+
+       default:
+               SysLog(NID_SCL, "The sensitivity value is invalid. sensitivity = %d", srcSensitivity);
+               sensitivity = SENSITIVITY_PUBLIC;
+               break;
+       }
+
+       return sensitivity;
+}
+
+DateTime
+_CalTodoImpl::GetLastRevisedTime(void) const
+{
+       long long lastModifiedTime = 0;
+
+       calendar_record_get_lli(__todoRecord.GetHandle(), _calendar_todo.last_modified_time, &lastModifiedTime);
+
+       return _CalendarbookUtil::ConvertEpochTimeToDateTime(lastModifiedTime);
+}
+
+result
+_CalTodoImpl::SetSubject(const String& subject)
+{
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               SysTryReturnResult(NID_SCL, subject.GetLength() <= MAX_TODO_SUBJECT_LENGTH,
+                                       E_INVALID_ARG, "Invalid argument is used. The length of the subject exceeds MAX_TODO_SUBJECT_LENGTH.");
+       }
+
+       std::unique_ptr<char[]> pConvertedSubject(_StringConverter::CopyToCharArrayN(subject));
+       SysTryReturnResult(NID_SCL, pConvertedSubject != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       int errorCode = calendar_record_set_str(__todoRecord.GetHandle(), _calendar_todo.summary, pConvertedSubject.get());
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       return E_SUCCESS;
+}
+
+result
+_CalTodoImpl::SetDescription(const String& description)
+{
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               SysTryReturnResult(NID_SCL, description.GetLength() <= MAX_TODO_DESCRIPTION_LENGTH,
+                                       E_INVALID_ARG, "Invalid argument is used. The length of the description exceeds MAX_TODO_SUBJECT_LENGTH.");
+       }
+
+       std::unique_ptr<char[]> pConvertedDescription(_StringConverter::CopyToCharArrayN(description));
+       SysTryReturnResult(NID_SCL, pConvertedDescription != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       int errorCode = calendar_record_set_str(__todoRecord.GetHandle(), _calendar_todo.description, pConvertedDescription.get());
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       return E_SUCCESS;
+}
+
+result
+_CalTodoImpl::SetStartAndDueDate(const DateTime& startDate, const DateTime& dueDate)
+{
+       SysTryReturnResult(NID_SCL, _CalendarbookUtil::CheckValidDateTime(startDate), E_INVALID_ARG, "Invalid argument is used. The start date is invalid.");
+       SysTryReturnResult(NID_SCL, _CalendarbookUtil::CheckValidDateTime(dueDate), E_INVALID_ARG, "Invalid argument is used. The end date is invalid.");
+       SysTryReturnResult(NID_SCL, startDate <= dueDate, E_INVALID_ARG, "Invalid argument is used. The end date is earlier than the start date.");
+
+       calendar_time_s convertedStartTime;
+       calendar_time_s convertedDueTime;
+
+       convertedStartTime.type = CALENDAR_TIME_UTIME;
+       convertedStartTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(startDate);
+       convertedDueTime.type = CALENDAR_TIME_UTIME;
+       convertedDueTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(dueDate);
+
+       calendar_record_set_caltime(__todoRecord.GetHandle(), _calendar_todo.start_time, convertedStartTime);
+       calendar_record_set_caltime(__todoRecord.GetHandle(), _calendar_todo.due_time, convertedDueTime);
+
+       return E_SUCCESS;
+}
+
+result
+_CalTodoImpl::SetStartDate(const DateTime& startDate)
+{
+       calendar_time_s convertedStartTime;
+       convertedStartTime.type = CALENDAR_TIME_UTIME;
+
+       if (startDate == DateTime::GetMinValue())
+       {
+               convertedStartTime.time.utime = _CALENDAR_TODO_NO_START_DATE;
+       }
+       else if (startDate < _CalendarbookImpl::GetMinDateTime() || startDate > _CalendarbookImpl::GetMaxDateTime())
+       {
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used.  The startDate is invalid.", GetErrorMessage(E_INVALID_ARG));
+               return E_INVALID_ARG;
+       }
+       else
+       {
+               calendar_time_s convertedDueTime;
+               calendar_record_get_caltime(__todoRecord.GetHandle(), _calendar_todo.due_time, &convertedDueTime);
+
+               convertedStartTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(startDate);
+
+               if (convertedStartTime.time.utime > convertedDueTime.time.utime)
+               {
+                       convertedDueTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(DateTime::GetMinValue());
+                       calendar_record_set_caltime(__todoRecord.GetHandle(), _calendar_todo.due_time, convertedDueTime);
+               }
+       }
+
+       calendar_record_set_caltime(__todoRecord.GetHandle(), _calendar_todo.start_time, convertedStartTime);
+
+       return E_SUCCESS;
+}
+
+result
+_CalTodoImpl::SetDueDate(const DateTime& dueDate)
+{
+       calendar_time_s convertedDueTime;
+       convertedDueTime.type = CALENDAR_TIME_UTIME;
+
+       if (dueDate == DateTime::GetMinValue())
+       {
+               convertedDueTime.time.utime = _CALENDAR_TODO_NO_DUE_DATE;
+       }
+       else if (dueDate < _CalendarbookImpl::GetMinDateTime() || dueDate > _CalendarbookImpl::GetMaxDateTime())
+       {
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used.  The dueDate is invalid.", GetErrorMessage(E_INVALID_ARG));
+               return E_INVALID_ARG;
+       }
+       else
+       {
+               calendar_time_s convertedStartTime;
+               calendar_record_get_caltime(__todoRecord.GetHandle(), _calendar_todo.start_time, &convertedStartTime);
+
+               convertedDueTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(dueDate);
+
+               if (convertedStartTime.time.utime > convertedDueTime.time.utime)
+               {
+                       convertedStartTime.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(DateTime::GetMinValue());
+                       calendar_record_set_caltime(__todoRecord.GetHandle(), _calendar_todo.start_time, convertedStartTime);
+               }
+       }
+
+       calendar_record_set_caltime(__todoRecord.GetHandle(), _calendar_todo.due_time, convertedDueTime);
+
+       return E_SUCCESS;
+}
+
+void
+_CalTodoImpl::SetPriority(TodoPriority priority)
+{
+       calendar_record_set_int(__todoRecord.GetHandle(), _calendar_todo.priority, _CalendarbookUtil::ConvertTodoPriorityToCSTodoPriority(priority));
+}
+
+void
+_CalTodoImpl::SetStatus(TodoStatus status)
+{
+       calendar_record_set_int(__todoRecord.GetHandle(), _calendar_todo.todo_status, _CalendarbookUtil::ConvertTodoStatusToCSTodoStatus(status));
+}
+
+void
+_CalTodoImpl::SetSensitivity(RecordSensitivity sensitivity)
+{
+       calendar_record_set_int(__todoRecord.GetHandle(), _calendar_todo.sensitivity, _CalendarbookUtil::ConvertSensitivityToCSSensitivity(sensitivity));
+}
+
+void
+_CalTodoImpl::SetLocation(const String& location)
+{
+       std::unique_ptr<char[]> pConvertedLocation(_StringConverter::CopyToCharArrayN(location));
+       SysTryReturnVoidResult(NID_SCL, pConvertedLocation != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       int errorCode = calendar_record_set_str(__todoRecord.GetHandle(), _calendar_todo.location, pConvertedLocation.get());
+       SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+String
+_CalTodoImpl::GetLocation(void) const
+{
+       char* pLocation = null;
+
+       calendar_record_get_str_p(__todoRecord.GetHandle(), _calendar_todo.location, &pLocation);
+
+       return String(pLocation);
+}
+
+result
+_CalTodoImpl::SetCoordinates(double latitude, double longitude)
+{
+       SysTryReturnResult(NID_SCL, latitude >= _MIN_LATITUDE && latitude <= _MAX_LATITUDE, E_INVALID_ARG, "Invalid argument is used. The latitude is out of range.");
+       SysTryReturnResult(NID_SCL, longitude >= _MIN_LONGITUDE && longitude <= _MAX_LONGITUDE, E_INVALID_ARG, "Invalid argument is used. The longitude is out of range.");
+
+       calendar_record_set_double(__todoRecord.GetHandle(), _calendar_todo.latitude, latitude);
+       calendar_record_set_double(__todoRecord.GetHandle(), _calendar_todo.longitude, longitude);
+
+       return E_SUCCESS;
+}
+
+void
+_CalTodoImpl::GetCoordinates(double& latitude, double& longitude) const
+{
+       calendar_record_get_double(__todoRecord.GetHandle(), _calendar_todo.latitude, &latitude);
+       calendar_record_get_double(__todoRecord.GetHandle(), _calendar_todo.longitude, &longitude);
+}
+
+result
+_CalTodoImpl::AddReminder(const Reminder& reminder)
+{
+       calendar_record_h tmpAlarmHandle = null;
+
+       std::unique_ptr<char[]> pTmpAlarmTone(_StringConverter::CopyToCharArrayN(reminder.GetSoundFile()));
+       SysTryReturnResult(NID_SCL, pTmpAlarmTone != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       int errorCode = calendar_record_create(_calendar_alarm._uri, &tmpAlarmHandle);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       int convertedTimeUnit = 0;
+
+       ReminderTimeUnit timeUnit = reminder.GetTimeUnit();
+       switch (timeUnit)
+       {
+       case REMINDER_TIME_UNIT_MINUTE:
+               convertedTimeUnit = CALENDAR_ALARM_TIME_UNIT_MINUTE;
+               break;
+
+       case REMINDER_TIME_UNIT_HOUR:
+               convertedTimeUnit = CALENDAR_ALARM_TIME_UNIT_HOUR;
+               break;
+
+       case REMINDER_TIME_UNIT_DAY:
+               convertedTimeUnit = CALENDAR_ALARM_TIME_UNIT_DAY;
+               break;
+
+       case REMINDER_TIME_UNIT_WEEK:
+               convertedTimeUnit = CALENDAR_ALARM_TIME_UNIT_WEEK;
+               break;
+
+       case REMINDER_TIME_UNIT_NONE:
+               convertedTimeUnit = CALENDAR_ALARM_TIME_UNIT_SPECIFIC;
+               break;
+
+       default:
+               break;
+       }
+
+       calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick_unit, convertedTimeUnit);
+       calendar_record_set_int(tmpAlarmHandle, _calendar_alarm.tick, reminder.GetTimeOffset());
+       errorCode = calendar_record_set_str(tmpAlarmHandle, _calendar_alarm.tone, pTmpAlarmTone.get());
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       if (convertedTimeUnit == CALENDAR_ALARM_TIME_UNIT_SPECIFIC)
+       {
+               calendar_record_set_lli(tmpAlarmHandle, _calendar_alarm.time, _CalendarbookUtil::ConvertDateTimeToEpochTime(reminder.GetAbsoluteTime()));
+       }
+
+       errorCode = calendar_record_add_child_record(__todoRecord.GetHandle(), _calendar_todo.calendar_alarm, tmpAlarmHandle);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       __reminderList.RemoveAll(true);
+       __reminderListUpdated = false;
+
+       return E_SUCCESS;
+}
+
+result
+_CalTodoImpl::RemoveReminderAt(int index)
+{
+       calendar_record_h tmpAlarmHandle = null;
+
+       calendar_record_get_child_record_at_p(__todoRecord.GetHandle(), _calendar_todo.calendar_alarm, index, &tmpAlarmHandle);
+       SysTryReturnResult(NID_SCL, tmpAlarmHandle != null, E_OUT_OF_RANGE, "The index is either equal to or greater than the number of reminders or less than 0.");
+
+       calendar_record_remove_child_record(__todoRecord.GetHandle(), _calendar_todo.calendar_alarm, tmpAlarmHandle);
+
+       __reminderList.RemoveAll(true);
+       __reminderListUpdated = false;
+
+       return E_SUCCESS;
+}
+
+const IList&
+_CalTodoImpl::GetAllReminders(void) const
+{
+       ClearLastResult();
+
+       if (__reminderListUpdated == false)
+       {
+               result r = _CalendarbookUtil::ConvertTodoAlarmsToReminderList(__todoRecord.GetHandle(), __reminderList);
+               SysTryReturn(NID_SCL, r == E_SUCCESS, __reminderList, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __reminderListUpdated = true;
+       }
+
+       return __reminderList;
+}
+
+RecordId
+_CalTodoImpl::GetCalendarId(void) const
+{
+       int srcCalendarbookId = 0;
+
+       calendar_record_get_int(__todoRecord.GetHandle(), _calendar_todo.calendar_book_id, &srcCalendarbookId);
+
+       return srcCalendarbookId;
+}
+
+void
+_CalTodoImpl::SetRecordHandle(calendar_record_h todoHandle)
+{
+       __todoRecord.ResetHandle(todoHandle);
+}
+
+calendar_record_h
+_CalTodoImpl::GetRecordHandle(void) const
+{
+       return __todoRecord.GetHandle();
+}
+
+CalTodo*
+_CalTodoImpl::CreateDefaultInstanceN(void)
+{
+       return new (std::nothrow) CalTodo();
+}
+
+_CalTodoImpl*
+_CalTodoImpl::GetInstance(CalTodo& todo)
+{
+       return todo.__pCalTodoImpl;
+}
+
+const _CalTodoImpl*
+_CalTodoImpl::GetInstance(const CalTodo& todo)
+{
+       return todo.__pCalTodoImpl;
+}
+
+}}     // Tizen::Social
diff --git a/src/FScl_CalendarImpl.cpp b/src/FScl_CalendarImpl.cpp
new file mode 100644 (file)
index 0000000..b719498
--- /dev/null
@@ -0,0 +1,253 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_CalendarImpl.cpp
+ * @brief              This is the implementation for _CalendarImpl class.
+ *
+ * This file contains definitions of @e _CalendarImpl class.
+ */
+
+#include <FBaseInteger.h>
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include <FBaseUtilStringTokenizer.h>
+#include <FBase_StringConverter.h>
+#include <FSclCalendar.h>
+#include "FScl_CalendarbookDbConnector.h"
+#include "FScl_CalendarImpl.h"
+#include "FScl_RecordImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Graphics;
+
+namespace Tizen { namespace Social
+{
+
+static const wchar_t* _COLOR_STRING_DELIMITER = L".";
+static const int _NUM_OF_COLOR_FACTOR = 3;
+
+_CalendarImpl::_CalendarImpl(CalendarItemType itemType)
+{
+       result r = _CalendarbookDbConnector::Connect();
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       calendar_record_h calendarHandle = null;
+       int errorCode = calendar_record_create(_calendar_book._uri, &calendarHandle);
+       SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       calendar_record_set_int(calendarHandle, _calendar_book.store_type, _CalendarbookUtil::ConvertCalendarItemTypeToCSCalendarbookType(itemType));
+
+       __calendarRecord.ResetHandle(calendarHandle);
+
+}
+
+_CalendarImpl::_CalendarImpl(const _CalendarImpl& rhs)
+{
+       result r = _CalendarbookDbConnector::Connect();
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       calendar_record_h calendarHandle = null;
+       int errorCode = calendar_record_clone(rhs.__calendarRecord.GetHandle(), &calendarHandle);
+       SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __calendarRecord.ResetHandle(calendarHandle);
+}
+
+_CalendarImpl::~_CalendarImpl(void)
+{
+       calendar_record_destroy(__calendarRecord.ReleaseHandle(), true);
+
+       result r = _CalendarbookDbConnector::Disconnect();
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+}
+
+_CalendarImpl&
+_CalendarImpl::operator =(const _CalendarImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       calendar_record_h calendarHandle = null;
+
+       int errorCode = calendar_record_clone(rhs.__calendarRecord.GetHandle(), &calendarHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __calendarRecord.ResetHandle(calendarHandle);
+
+       return *this;
+}
+
+String
+_CalendarImpl::GetName(void) const
+{
+       char* pName = null;
+
+       calendar_record_get_str_p(__calendarRecord.GetHandle(), _calendar_book.name, &pName);
+
+       return String(pName);
+}
+
+CalendarItemType
+_CalendarImpl::GetItemType(void) const
+{
+       int storeType = 0;
+       CalendarItemType calendarItemType = CALENDAR_ITEM_TYPE_EVENT_AND_TODO;
+
+       calendar_record_get_int(__calendarRecord.GetHandle(), _calendar_book.store_type, &storeType);
+       switch (storeType)
+       {
+
+               case CALENDAR_BOOK_TYPE_EVENT | CALENDAR_BOOK_TYPE_TODO:
+                       calendarItemType = CALENDAR_ITEM_TYPE_EVENT_AND_TODO;
+                       break;
+               case CALENDAR_BOOK_TYPE_EVENT:
+                       calendarItemType = CALENDAR_ITEM_TYPE_EVENT_ONLY;
+                       break;
+               case CALENDAR_BOOK_TYPE_TODO:
+                       calendarItemType = CALENDAR_ITEM_TYPE_TODO_ONLY;
+                       break;
+               default:
+                       calendarItemType = CALENDAR_ITEM_TYPE_EVENT_AND_TODO;
+                       break;
+       }
+
+       return calendarItemType;
+}
+
+AccountId
+_CalendarImpl::GetAccountId(void) const
+{
+       int accountId = 0;
+       calendar_record_get_int(__calendarRecord.GetHandle(), _calendar_book.account_id, &accountId);
+
+       return accountId;
+}
+
+result
+_CalendarImpl::GetColor(byte& red, byte& green, byte& blue) const
+{
+       char* pColor = null;
+       calendar_record_get_str_p(__calendarRecord.GetHandle(), _calendar_book.color, &pColor);
+
+       if (pColor == null || strlen(pColor) == 0)
+       {
+               red = 0;
+               green = 0;
+               blue = 0;
+
+               return E_DATA_NOT_FOUND;
+       }
+
+       int tmpRed = 0;
+       int tmpGreen = 0;
+       int tmpBlue = 0;
+
+       String tmpString(pColor);
+       String delim(_COLOR_STRING_DELIMITER);
+       String token;
+
+       StringTokenizer strTok(tmpString, delim);
+
+       strTok.GetNextToken(token);
+       Integer::Parse(token, tmpRed);
+       strTok.GetNextToken(token);
+       Integer::Parse(token, tmpGreen);
+       strTok.GetNextToken(token);
+       Integer::Parse(token, tmpBlue);
+
+       red = tmpRed;
+       green = tmpGreen;
+       blue = tmpBlue;
+
+       return E_SUCCESS;
+}
+
+void
+_CalendarImpl::SetName(const String& name)
+{
+       std::unique_ptr<char[]> pConvertedName(_StringConverter::CopyToCharArrayN(name));
+       SysTryReturnVoidResult(NID_SCL, pConvertedName != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       int errorCode = calendar_record_set_str(__calendarRecord.GetHandle(), _calendar_book.name, pConvertedName.get());
+       SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+void
+_CalendarImpl::SetColor(byte red, byte green, byte blue)
+{
+       String color;
+       color.Append(red);
+       color.Append(_COLOR_STRING_DELIMITER);
+       color.Append(green);
+       color.Append(_COLOR_STRING_DELIMITER);
+       color.Append(blue);
+       color.Append(_COLOR_STRING_DELIMITER);
+       color.Append(255);      // alpha
+
+       std::unique_ptr<char[]> pConvertedColor(_StringConverter::CopyToCharArrayN(color));
+       SysTryReturnVoidResult(NID_SCL, pConvertedColor != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       int errorCode = calendar_record_set_str(__calendarRecord.GetHandle(), _calendar_book.color, pConvertedColor.get());
+       SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+void
+_CalendarImpl::ClearColor(void)
+{
+       int errorCode = calendar_record_set_str(__calendarRecord.GetHandle(), _calendar_book.color, null);
+       SysTryReturnVoidResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+void
+_CalendarImpl::SetAccountId(AccountId accountId)
+{
+       calendar_record_set_int(__calendarRecord.GetHandle(), _calendar_book.account_id, accountId);
+}
+
+void
+_CalendarImpl::SetRecordHandle(calendar_record_h calendarHandle)
+{
+       __calendarRecord.ResetHandle(calendarHandle);
+}
+
+calendar_record_h
+_CalendarImpl::GetRecordHandle(void) const
+{
+       return __calendarRecord.GetHandle();
+}
+
+Calendar*
+_CalendarImpl::CreateDefaultInstanceN(void)
+{
+       return new (std::nothrow) Calendar(CALENDAR_ITEM_TYPE_EVENT_AND_TODO);
+}
+
+_CalendarImpl*
+_CalendarImpl::GetInstance(Calendar& calendar)
+{
+       return calendar.__pCalendarImpl;
+}
+
+const _CalendarImpl*
+_CalendarImpl::GetInstance(const Calendar& calendar)
+{
+       return calendar.__pCalendarImpl;
+}
+
+}}     // Tizen::Social
diff --git a/src/FScl_CalendarbookDbChangeEvent.cpp b/src/FScl_CalendarbookDbChangeEvent.cpp
new file mode 100644 (file)
index 0000000..25fdd42
--- /dev/null
@@ -0,0 +1,75 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_CalendarbookDbChangeEvent.cpp
+ * @brief      This is the implementation file for the _CalendarbookDbChangeEvent class.
+ *
+ */
+
+#include <FBaseRtIEventArg.h>
+#include <FBaseRtIEventListener.h>
+#include <FBaseSysLog.h>
+#include "FScl_CalendarbookDbChangeEvent.h"
+#include "FScl_CalendarbookDbChangeEventArg.h"
+#include "FScl_ICalendarbookDbChangeEventListener.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Social
+{
+
+_CalendarbookDbChangeEvent::_CalendarbookDbChangeEvent(void)
+{
+       // empty body
+}
+
+_CalendarbookDbChangeEvent::~_CalendarbookDbChangeEvent(void)
+{
+       // emtpy body
+}
+
+result
+_CalendarbookDbChangeEvent::Construct(void)
+{
+       result r = E_SUCCESS;
+
+       r = _Event::Initialize();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s]This is not an event-driven thread.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+void
+_CalendarbookDbChangeEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
+{
+       _ICalendarbookDbChangeEventListener* pEventListener = dynamic_cast<_ICalendarbookDbChangeEventListener*>(&listener);
+       const _CalendarbookDbChangeEventArg* pEventArg = dynamic_cast<const _CalendarbookDbChangeEventArg*>(&arg);
+
+       if (pEventListener != null && pEventArg != null)
+       {
+               if (pEventArg->GetChangeType() == _CALENDARBOOK_DB_CHANGE_TYPE_EVENT)
+               {
+                       pEventListener->OnCalEventChanged();
+               }
+               else
+               {
+                       pEventListener->OnCalTodoChanged();
+               }
+       }
+}
+
+}} // Tizen::Social
diff --git a/src/FScl_CalendarbookDbChangeEvent.h b/src/FScl_CalendarbookDbChangeEvent.h
new file mode 100644 (file)
index 0000000..0bff62f
--- /dev/null
@@ -0,0 +1,66 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_CalendarbookDbChangeEvent.h
+ * @brief      This is the header file for the _CalendarbookDbChangeEvent class.
+ *
+ * This file contains the declarations of _CalendarbookDbChangeEvent.
+ */
+
+
+#ifndef _FSCL_INTERNAL_CALENDARBOOK_DB_CHANGE_EVENT_H_
+#define _FSCL_INTERNAL_CALENDARBOOK_DB_CHANGE_EVENT_H_
+
+#include <FBaseResult.h>
+#include <FBaseTypes.h>
+#include <FBaseRt_Event.h>
+
+namespace Tizen { namespace Base { namespace Runtime
+{
+class IEventListener;
+class IEventArg;
+}}}
+
+namespace Tizen { namespace Social
+{
+
+class _CalendarbookDbChangeEvent
+       : public Tizen::Base::Runtime::_Event
+{
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. For full construction, @n
+        * the Construct() method must be called right after calling this constructor.
+        *
+        * @see             Construct()
+        */
+       _CalendarbookDbChangeEvent(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Runtime::_Event::~_Event().
+        */
+       virtual ~_CalendarbookDbChangeEvent(void);
+
+       result Construct(void);
+
+protected:
+       virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+}; // _CalendarbookDbChangeEvent
+
+}} // Tizen::Social
+
+#endif // _FSCL_INTERNAL_CALENDARBOOK_DB_CHANGE_EVENT_H_
diff --git a/src/FScl_CalendarbookDbChangeEventArg.cpp b/src/FScl_CalendarbookDbChangeEventArg.cpp
new file mode 100644 (file)
index 0000000..76cd59f
--- /dev/null
@@ -0,0 +1,44 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_CalendarbookDbChangeEventArg.cpp
+ * @brief      This is the implementation file for the _CalendarbookDbChangeEventArg class.
+ *
+ */
+
+#include <FBaseSysLog.h>
+#include "FScl_CalendarbookDbChangeEventArg.h"
+
+namespace Tizen { namespace Social
+{
+_CalendarbookDbChangeEventArg::_CalendarbookDbChangeEventArg(_CalendarbookDbChangeType changeType)
+: __changeType(changeType)
+{
+       // empty body
+}
+
+_CalendarbookDbChangeEventArg::~_CalendarbookDbChangeEventArg(void)
+{
+       // empty body
+}
+
+_CalendarbookDbChangeType
+_CalendarbookDbChangeEventArg::GetChangeType(void) const
+{
+       return __changeType;
+}
+
+}}// Tizen::Social
diff --git a/src/FScl_CalendarbookDbChangeEventArg.h b/src/FScl_CalendarbookDbChangeEventArg.h
new file mode 100644 (file)
index 0000000..08bd664
--- /dev/null
@@ -0,0 +1,75 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_CalendarbookDbChangeEventArg.h
+ * @brief      This is the header file for the _CalendarbookDbChangeEventArg class.
+ *
+ * This file contains the declarations of _CalendarbookDbChangeEventArg.
+ */
+
+#ifndef _FSCL_INTERNAL_CALENDARBOOK_DB_CHANGE_EVENT_ARG_H_
+#define _FSCL_INTERNAL_CALENDARBOOK_DB_CHANGE_EVENT_ARG_H_
+
+#include <FBaseObject.h>
+#include <FBaseRtIEventArg.h>
+#include <FSclRecord.h>
+
+namespace Tizen { namespace Social
+{
+
+enum _CalendarbookDbChangeType
+{
+       _CALENDARBOOK_DB_CHANGE_TYPE_EVENT,
+       _CALENDARBOOK_DB_CHANGE_TYPE_TODO
+};
+
+class _CalendarbookDbChangeEventArg
+       : public Tizen::Base::Object
+       , public Tizen::Base::Runtime::IEventArg
+{
+public:
+       /**
+        * This is the default constructor of this class
+        */
+       _CalendarbookDbChangeEventArg(_CalendarbookDbChangeType changeType);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        */
+       virtual ~_CalendarbookDbChangeEventArg(void);
+
+       _CalendarbookDbChangeType GetChangeType(void) const;
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private @n
+        * to prohibit copying of objects.
+        */
+       _CalendarbookDbChangeEventArg(const _CalendarbookDbChangeEventArg& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private @n
+        * to prohibit copying of objects.
+        */
+       _CalendarbookDbChangeEventArg& operator =(const _CalendarbookDbChangeEventArg& rhs);
+
+private:
+       _CalendarbookDbChangeType __changeType;
+};
+
+}} // Tizen::Social
+
+#endif // _FSCL_INTERNAL_CALENDARBOOK_DB_CHANGE_EVENT_ARG_H_
diff --git a/src/FScl_CalendarbookDbConnector.cpp b/src/FScl_CalendarbookDbConnector.cpp
new file mode 100644 (file)
index 0000000..18c1f9f
--- /dev/null
@@ -0,0 +1,136 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_CalendarbookDbConnector.cpp
+ * @brief              This is the implementation for _CalendarbookDbConnector class.
+ *
+ * This file contains definitions of @e _CalendarbookDbConnector class.
+ */
+
+#include <cstdlib>
+#include <pthread.h>
+#include <calendar2.h>
+#include <FBaseResult.h>
+#include <FBaseRtMutex.h>
+#include <FBaseSysLog.h>
+#include <FSysSystemTime.h>
+#include "FScl_CalendarbookDbConnector.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Social
+{
+
+int _CalendarbookDbConnector::__connectingCount = 0;
+Mutex _CalendarbookDbConnector::__mutex;
+bool _CalendarbookDbConnector::__isInit = false;
+
+result
+_CalendarbookDbConnector::Connect(void)
+{
+       result r = E_SUCCESS;
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+       if (__isInit == false)
+       {
+               ClearLastResult();
+
+               pthread_once(&onceBlock, InitCalendarbookDbConnector);
+               if (GetLastResult() != E_SUCCESS)
+               {
+                       onceBlock = PTHREAD_ONCE_INIT;
+                       SysLogException(NID_SCL, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+                       return E_SYSTEM;
+               }
+
+               __isInit = true;
+       }
+
+       r = __mutex.Acquire();
+       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred.");
+
+       if (__connectingCount == 0)
+       {
+               long long startTicks = 0;
+               long long endTicks = 0;
+
+               System::SystemTime::GetTicks(startTicks);
+
+               int errorCode = calendar_connect_with_flags(CALENDAR_CONNECT_FLAG_RETRY);
+
+               System::SystemTime::GetTicks(endTicks);
+
+               SysTryCatch(NID_SCL, errorCode == CALENDAR_ERROR_NONE, , E_SYSTEM, "[%s] A system error has been occurred. Elapsed time : %lld (milliseconds)", GetErrorMessage(E_SYSTEM), endTicks - startTicks);
+               __connectingCount = 0;
+       }
+
+       __connectingCount++;
+
+       r = __mutex.Release();
+       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred.");
+
+       return E_SUCCESS;
+
+CATCH:
+       __mutex.Release();
+
+       return E_SYSTEM;
+}
+
+result
+_CalendarbookDbConnector::Disconnect(void)
+{
+       SysTryReturnResult(NID_SCL, __isInit == true, E_SYSTEM, "A system error has been occurred.");
+
+       result r = __mutex.Acquire();
+       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred.");
+
+       __connectingCount--;
+
+       if (__connectingCount == 0)
+       {
+               int errorCode = calendar_disconnect();
+               SysTryCatch(NID_SCL, errorCode == CALENDAR_ERROR_NONE, , E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       }
+
+       r = __mutex.Release();
+       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred.");
+
+       return E_SUCCESS;
+
+CATCH:
+       __mutex.Release();
+
+       return E_SYSTEM;
+}
+
+_CalendarbookDbConnector::_CalendarbookDbConnector(void)
+{
+}
+
+_CalendarbookDbConnector::~_CalendarbookDbConnector(void)
+{
+}
+
+void
+_CalendarbookDbConnector::InitCalendarbookDbConnector(void)
+{
+       result r = __mutex.Create();
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+}
+
+}}  // Tizen::Social
diff --git a/src/FScl_CalendarbookDbConnector.h b/src/FScl_CalendarbookDbConnector.h
new file mode 100644 (file)
index 0000000..ab99f36
--- /dev/null
@@ -0,0 +1,54 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FScl_CalendarbookDbConnector.h
+* @brief       This is the header file for the _CalendarbookDbConnector class.
+*
+* This header file contains the declarations of the _CalendarbookDbConnector class.
+*/
+
+#ifndef _FSCL_INTERNAL_CALENDARBOOK_DB_CONNECTOR_H_
+#define _FSCL_INTERNAL_CALENDARBOOK_DB_CONNECTOR_H_
+
+namespace Tizen { namespace Base { namespace Runtime
+{
+class Mutex;
+}}}
+
+namespace Tizen { namespace Social
+{
+
+class _CalendarbookDbConnector
+{
+public:
+       static result Connect(void);
+       static result Disconnect(void);
+
+private:
+       _CalendarbookDbConnector(void);
+       ~_CalendarbookDbConnector(void);
+
+       static void InitCalendarbookDbConnector(void);
+
+private:
+       static int __connectingCount;
+       static Tizen::Base::Runtime::Mutex __mutex;
+       static bool __isInit;
+};     // _CalendarbookDbConnector
+
+}}  // Tizen::Social
+
+#endif //_FSCL_INTERNAL_CALENDARBOOK_DB_CONNECTOR_H_
diff --git a/src/FScl_CalendarbookDbMonitor.cpp b/src/FScl_CalendarbookDbMonitor.cpp
new file mode 100644 (file)
index 0000000..d41f90c
--- /dev/null
@@ -0,0 +1,253 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_CalendarbookDbMonitor.cpp
+ * @brief              This is the implementation for _CalendarbookDbMonitor class.
+ *
+ * This file contains definitions of @e _CalendarbookDbMonitor class.
+ */
+
+#include <new>
+#include <pthread.h>
+#include <unique_ptr.h>
+#include <calendar2.h>
+#include <FBaseRtMutex.h>
+#include <FBaseSysLog.h>
+#include "FScl_ICalendarbookDbChangeEventListener.h"
+#include "FScl_CalendarbookDbChangeEvent.h"
+#include "FScl_CalendarbookDbChangeEventArg.h"
+#include "FScl_CalendarbookDbMonitor.h"
+#include "FScl_CalendarbookDbConnector.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Social
+{
+
+Mutex _CalendarbookDbMonitor::__mutex;
+int _CalendarbookDbMonitor::__refCnt = 0;
+_CalendarbookDbMonitor*_CalendarbookDbMonitor::__pCalendarbookDbMonitor = null;
+
+_CalendarbookDbMonitor::_CalendarbookCallback::_CalendarbookCallback(void)
+       : __callback(null)
+       , __pUserData(null)
+       , __isRegistered(false)
+{
+}
+
+_CalendarbookDbMonitor::_CalendarbookCallback::~_CalendarbookCallback(void)
+{
+       if (__isRegistered)
+       {
+               calendar_db_remove_changed_cb(_calendar_event._uri, __callback, __pUserData);
+               calendar_db_remove_changed_cb(_calendar_todo._uri, __callback, __pUserData);
+       }
+}
+
+result
+_CalendarbookDbMonitor::_CalendarbookCallback::Register(calendar_db_changed_cb callback, void* pUserData)
+{
+       int errorCode = CALENDAR_ERROR_NONE;
+
+       errorCode = calendar_db_add_changed_cb(_calendar_event._uri, callback, pUserData);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+       errorCode = calendar_db_add_changed_cb(_calendar_todo._uri, callback, pUserData);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+
+       __callback = callback;
+       __pUserData = pUserData;
+       __isRegistered = true;
+
+       return E_SUCCESS;
+}
+
+_CalendarbookDbMonitor::_CalendarbookDbMonitor(void)
+{
+       // empty body.
+}
+
+_CalendarbookDbMonitor::~_CalendarbookDbMonitor(void)
+{
+       result r = _CalendarbookDbConnector::Disconnect();
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+}
+
+result
+_CalendarbookDbMonitor::Construct(void)
+{
+       result r = E_SUCCESS;
+
+       r = _CalendarbookDbConnector::Connect();
+       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred.");
+
+       std::unique_ptr<_CalendarbookCallback> pChangeCallback(new (std::nothrow) _CalendarbookCallback());
+       SysTryReturnResult(NID_SCL, pChangeCallback != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pChangeCallback->Register(OnCalendarbookDbChanged, this);
+       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred.");
+
+       std::unique_ptr<_CalendarbookDbChangeEvent> pEvent(new (std::nothrow) _CalendarbookDbChangeEvent());
+       SysTryReturn(NID_SCL, pEvent != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = pEvent->Construct();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pEvent = std::move(pEvent);
+       __pChangeCallback = std::move(pChangeCallback);
+
+       return E_SUCCESS;
+}
+
+result
+_CalendarbookDbMonitor::AddListener(const _ICalendarbookDbChangeEventListener& listener)
+{
+       result r = __mutex.Acquire();
+       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred.");
+
+       r = __pEvent->AddListener(listener);
+       SysTryCatch(NID_SCL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = __mutex.Release();
+       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred.");
+
+       return E_SUCCESS;
+
+CATCH:
+       __mutex.Release();
+
+       return r;
+}
+
+result
+_CalendarbookDbMonitor::RemoveListener(const _ICalendarbookDbChangeEventListener& listener)
+{
+       result r = __mutex.Acquire();
+       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred.");
+
+       r = __pEvent->RemoveListener(listener);
+       SysTryCatch(NID_SCL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = __mutex.Release();
+       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred.");
+
+       return E_SUCCESS;
+
+CATCH:
+       __mutex.Release();
+
+       return r;
+}
+
+_CalendarbookDbMonitor*
+_CalendarbookDbMonitor::GetInstance(void)
+{
+       result r = E_SUCCESS;
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+       std::unique_ptr<_CalendarbookDbMonitor> pCalendarbookDbMonitor;
+
+       if (__pCalendarbookDbMonitor == null)
+       {
+               ClearLastResult();
+               pthread_once(&onceBlock, InitCalendarbookDbMonitor);
+               if (GetLastResult() != E_SUCCESS)
+               {
+                       onceBlock = PTHREAD_ONCE_INIT;
+                       SysLogException(NID_SCL, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+                       return null;
+               }
+
+               pCalendarbookDbMonitor.reset(new (std::nothrow) _CalendarbookDbMonitor());
+               SysTryReturn(NID_SCL, pCalendarbookDbMonitor != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pCalendarbookDbMonitor->Construct();
+               SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+
+       }
+
+       r = __mutex.Acquire();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       if (pCalendarbookDbMonitor != null)
+       {
+               __pCalendarbookDbMonitor = pCalendarbookDbMonitor.release();
+       }
+
+       __refCnt++;
+
+       r = __mutex.Release();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return __pCalendarbookDbMonitor;
+}
+
+void
+_CalendarbookDbMonitor::Release(void)
+{
+       result r = __mutex.Acquire();
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       __refCnt--;
+
+       if (__refCnt == 0)
+       {
+               delete __pCalendarbookDbMonitor;
+               __pCalendarbookDbMonitor = null;
+       }
+
+       r = __mutex.Release();
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+}
+
+void
+_CalendarbookDbMonitor::OnCalendarbookDbChanged(const char* pViewUri, void* pUserData)
+{
+       _CalendarbookDbMonitor* pCalendarbookDbMonitor = static_cast<_CalendarbookDbMonitor*>(pUserData);
+       _CalendarbookDbChangeEvent* pEvent = pCalendarbookDbMonitor->__pEvent.get();
+
+       _CalendarbookDbChangeType changeType;
+       if (strcmp(pViewUri, _calendar_event._uri) == 0)
+       {
+               changeType = _CALENDARBOOK_DB_CHANGE_TYPE_EVENT;
+       }
+       else if (strcmp(pViewUri, _calendar_todo._uri) == 0)
+       {
+               changeType = _CALENDARBOOK_DB_CHANGE_TYPE_TODO;
+       }
+       else
+       {
+               return;
+       }
+
+       std::unique_ptr<_CalendarbookDbChangeEventArg> pArg(new (std::nothrow) _CalendarbookDbChangeEventArg(changeType));
+       SysTryReturnVoidResult(NID_SCL, pArg != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pEvent->Fire(*pArg.get());
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pArg.release();
+}
+
+void
+_CalendarbookDbMonitor::InitCalendarbookDbMonitor(void)
+{
+       result r = __mutex.Create();
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+}
+
+}}  // Tizen::Social
diff --git a/src/FScl_CalendarbookDbMonitor.h b/src/FScl_CalendarbookDbMonitor.h
new file mode 100644 (file)
index 0000000..4ab8ad6
--- /dev/null
@@ -0,0 +1,110 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FScl_CalendarbookDbMonitor.h
+* @brief       This is the header file for the _CalendarbookDbMonitor class.
+*
+* This header file contains the declarations of the _CalendarbookDbMonitor class.
+*/
+
+#ifndef _FSCL_INTERNAL_CALENDARBOOK_DB_MONITOR_H_
+#define _FSCL_INTERNAL_CALENDARBOOK_DB_MONITOR_H_
+
+#include <unique_ptr.h>
+#include <FBaseObject.h>
+#include <FBaseResult.h>
+#include <FBaseTypes.h>
+
+namespace Tizen { namespace Base { namespace Runtime
+{
+class Mutex;
+}}}
+
+namespace Tizen { namespace Social
+{
+class _ICalendarbookDbChangeEventListener;
+class _CalendarbookDbChangeEvent;
+
+/**
+ * @class      _CalendarbookDbMonitor
+ * @brief      This class handles the _CalendarbookDbMonitor operations.
+ * @since      2.0
+ * @see   _CalendarbookImpl
+ *
+ */
+class _CalendarbookDbMonitor
+       : public Tizen::Base::Object
+{
+               class _CalendarbookCallback
+               {
+               public :
+                       _CalendarbookCallback(void);
+                       ~_CalendarbookCallback(void);
+                       result Register(calendar_db_changed_cb callback, void* pUserData);
+               private :
+                       calendar_db_changed_cb __callback;
+                       void* __pUserData;
+                       bool __isRegistered;
+               };
+
+public:
+       void Release(void);
+
+       result AddListener(const _ICalendarbookDbChangeEventListener& listener);
+
+       result RemoveListener(const _ICalendarbookDbChangeEventListener& listener);
+
+       static _CalendarbookDbMonitor* GetInstance(void);
+
+private:
+       /**
+        * This constructor is intentionally declared as private to implement the Singleton semantic.
+        */
+       _CalendarbookDbMonitor(void);
+
+       /**
+        * This destructor is intentionally declared as private to implement the Singleton semantic.
+        */
+       virtual ~_CalendarbookDbMonitor(void);
+
+       result Construct(void);
+
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private @n
+        * to prohibit copying of objects.
+        */
+       _CalendarbookDbMonitor(const _CalendarbookDbMonitor& rhs);
+
+       static void OnCalendarbookDbChanged(const char* pViewUri, void* pUserData);
+
+       static void InitCalendarbookDbMonitor(void);
+
+       _CalendarbookDbMonitor& operator =(const _CalendarbookDbMonitor& rhs);
+
+private:
+       std::unique_ptr<_CalendarbookDbChangeEvent> __pEvent;
+       std::unique_ptr<_CalendarbookCallback> __pChangeCallback;
+
+       static Tizen::Base::Runtime::Mutex __mutex;
+       static int __refCnt;
+       static _CalendarbookDbMonitor* __pCalendarbookDbMonitor;
+       friend class std::default_delete<_CalendarbookDbMonitor>;
+
+};     // _CalendarbookDbMonitor
+
+}}  // Tizen::Social
+
+#endif //_FSCL_INTERNAL_CALENDARBOOK_DB_MONITOR_H_
diff --git a/src/FScl_CalendarbookFilterImpl.cpp b/src/FScl_CalendarbookFilterImpl.cpp
new file mode 100644 (file)
index 0000000..5f39d40
--- /dev/null
@@ -0,0 +1,647 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FScl_CalendarbookFilterImpl.cpp
+* @brief       This is the implementation for _CalendarbookFilterImpl class.
+*
+* This file contains definitions of @e _CalendarbookFilterImpl class.
+*/
+
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FBaseDateTime.h>
+#include <FBase_StringConverter.h>
+#include <FSclCalendarbookFilter.h>
+#include "FScl_CalendarbookFilterImpl.h"
+#include "FScl_CalendarbookUtil.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+static const long long _CALENDAR_TODO_NO_START_DATE = -0x7fffffffffffffffLL;
+static const long long _CALENDAR_TODO_NO_DUE_DATE = 0x7fffffffffffffffLL;
+
+// CB_FI_TYPE_CALENDAR
+// The entries must be ordered same as CalendarFilterProperty
+const _CalendarbookFilterImpl::__FilterPropertyInfoEntry _CalendarbookFilterImpl::__calendarFilterPropertyInfos[] =
+{
+       {CALENDAR_FI_PR_CALENDAR_ID, _calendar_book.id, DATA_TYPE_INT},
+       {CALENDAR_FI_PR_ACCOUNT_ID, _calendar_book.account_id, DATA_TYPE_INT},
+       {CALENDAR_FI_PR_NAME, _calendar_book.name, DATA_TYPE_STRING},
+       {CALENDAR_FI_PR_ITEM_TYPE, _calendar_book.store_type, DATA_TYPE_INT},
+};
+
+// CB_FI_TYPE_EVENT
+// The entries must be ordered same as EventFilterProperty
+const _CalendarbookFilterImpl::__FilterPropertyInfoEntry _CalendarbookFilterImpl::__eventFilterPropertyInfos[] =
+{
+       {EVENT_FI_PR_EVENT_ID, _calendar_event.id, DATA_TYPE_INT},
+       {EVENT_FI_PR_CALENDAR_ID, _calendar_event.calendar_book_id, DATA_TYPE_INT},
+       {EVENT_FI_PR_SUBJECT, _calendar_event.summary, DATA_TYPE_STRING},
+       {EVENT_FI_PR_DESCRIPTION, _calendar_event.description, DATA_TYPE_STRING},
+       {EVENT_FI_PR_LOCATION, _calendar_event.location, DATA_TYPE_STRING},
+       {EVENT_FI_PR_BUSY_STATUS, _calendar_event.busy_status, DATA_TYPE_INT},
+       {EVENT_FI_PR_PRIORITY, _calendar_event.priority, DATA_TYPE_INT},
+       {EVENT_FI_PR_SENSITIVITY, _calendar_event.sensitivity, DATA_TYPE_INT},
+       {EVENT_FI_PR_STATUS, _calendar_event.event_status, DATA_TYPE_INT},
+       {EVENT_FI_PR_UID, _calendar_event.uid, DATA_TYPE_STRING},
+       {EVENT_FI_PR_LATITUDE, _calendar_event.latitude, DATA_TYPE_DOUBLE},
+       {EVENT_FI_PR_LONGITUDE, _calendar_event.longitude, DATA_TYPE_DOUBLE},
+       {EVENT_FI_PR_LAST_REVISED_TIME, _calendar_event.last_modified_time, DATA_TYPE_DATE_TIME},
+       {EVENT_FI_PR_HAS_REMINDER, _calendar_event.has_alarm, DATA_TYPE_BOOL},
+       {EVENT_FI_PR_HAS_ATTENDEE, _calendar_event.has_attendee, DATA_TYPE_BOOL},
+};
+
+// CB_FI_TYPE_TODO
+// The entries must be ordered same as TodoFilterProperty
+const _CalendarbookFilterImpl::__FilterPropertyInfoEntry _CalendarbookFilterImpl::__todoFilterPropertyInfos[] =
+{
+               {TODO_FI_PR_TODO_ID, _calendar_todo.id, DATA_TYPE_INT},
+               {TODO_FI_PR_CALENDAR_ID, _calendar_todo.calendar_book_id, DATA_TYPE_INT},
+               {TODO_FI_PR_START_DATE, _calendar_todo.start_time, DATA_TYPE_DATE_TIME},
+               {TODO_FI_PR_DUE_DATE, _calendar_todo.due_time, DATA_TYPE_DATE_TIME},
+               {TODO_FI_PR_SUBJECT, _calendar_todo.summary, DATA_TYPE_STRING},
+               {TODO_FI_PR_DESCRIPTION, _calendar_todo.description, DATA_TYPE_STRING},
+               {TODO_FI_PR_LOCATION, _calendar_todo.location, DATA_TYPE_STRING},
+               {TODO_FI_PR_PRIORITY, _calendar_todo.priority, DATA_TYPE_INT},
+               {TODO_FI_PR_SENSITIVITY, _calendar_todo.sensitivity, DATA_TYPE_INT},
+               {TODO_FI_PR_STATUS, _calendar_todo.todo_status, DATA_TYPE_INT},
+               {TODO_FI_PR_LATITUDE, _calendar_todo.latitude, DATA_TYPE_DOUBLE},
+               {TODO_FI_PR_LONGITUDE, _calendar_todo.longitude, DATA_TYPE_DOUBLE},
+               {TODO_FI_PR_LAST_REVISED_TIME, _calendar_todo.last_modified_time, DATA_TYPE_DATE_TIME},
+               {TODO_FI_PR_HAS_REMINDER, _calendar_todo.has_alarm, DATA_TYPE_BOOL},
+};
+
+// CB_FI_TYPE_ALL_DAY_EVENT_INSTANCE
+// The entries must be ordered same as EventInstanceFilterProperty
+const _CalendarbookFilterImpl::__FilterPropertyInfoEntry _CalendarbookFilterImpl::__allDayEventInstanceFilterPropertyInfos[] =
+{
+               {EVENT_INST_FI_PR_ORIGINAL_EVENT_ID, _calendar_instance_allday_calendar_book.event_id, DATA_TYPE_INT},
+               {EVENT_INST_FI_PR_CALENDAR_ID, _calendar_instance_allday_calendar_book.calendar_book_id, DATA_TYPE_INT},
+               {EVENT_INST_FI_PR_START_TIME, _calendar_instance_allday_calendar_book.start_time, DATA_TYPE_DATE_TIME},
+               {EVENT_INST_FI_PR_END_TIME, _calendar_instance_allday_calendar_book.end_time, DATA_TYPE_DATE_TIME},
+               {EVENT_INST_FI_PR_SUBJECT, _calendar_instance_allday_calendar_book.summary, DATA_TYPE_STRING},
+               {EVENT_INST_FI_PR_DESCRIPTION, _calendar_instance_allday_calendar_book.description, DATA_TYPE_STRING},
+               {EVENT_INST_FI_PR_LOCATION, _calendar_instance_allday_calendar_book.location, DATA_TYPE_STRING},
+               {EVENT_INST_FI_PR_BUSY_STATUS, _calendar_instance_allday_calendar_book.busy_status, DATA_TYPE_INT},
+               {EVENT_INST_FI_PR_PRIORITY, _calendar_instance_allday_calendar_book.priority, DATA_TYPE_INT},
+               {EVENT_INST_FI_PR_SENSITIVITY, _calendar_instance_allday_calendar_book.sensitivity, DATA_TYPE_INT},
+               {EVENT_INST_FI_PR_STATUS, _calendar_instance_allday_calendar_book.event_status, DATA_TYPE_INT},
+               {EVENT_INST_FI_PR_LATITUDE, _calendar_instance_allday_calendar_book.latitude, DATA_TYPE_DOUBLE},
+               {EVENT_INST_FI_PR_LONGITUDE, _calendar_instance_allday_calendar_book.longitude, DATA_TYPE_DOUBLE},
+               {EVENT_INST_FI_PR_IS_RECURRING, _calendar_instance_allday_calendar_book.has_rrule, DATA_TYPE_BOOL},
+               {EVENT_INST_FI_PR_HAS_REMINDER, _calendar_instance_allday_calendar_book.has_alarm, DATA_TYPE_BOOL},
+};
+
+// CB_FI_TYPE_NON_ALL_DAY_EVENT_INSTANCE
+// The entries must be ordered same as EventInstanceFilterProperty
+const _CalendarbookFilterImpl::__FilterPropertyInfoEntry _CalendarbookFilterImpl::__nonAllDayEventInstanceFilterPropertyInfos[] =
+{
+               {EVENT_INST_FI_PR_ORIGINAL_EVENT_ID, _calendar_instance_normal_calendar_book.event_id, DATA_TYPE_INT},
+               {EVENT_INST_FI_PR_CALENDAR_ID, _calendar_instance_normal_calendar_book.calendar_book_id, DATA_TYPE_INT},
+               {EVENT_INST_FI_PR_START_TIME, _calendar_instance_normal_calendar_book.start_time, DATA_TYPE_DATE_TIME},
+               {EVENT_INST_FI_PR_END_TIME, _calendar_instance_normal_calendar_book.end_time, DATA_TYPE_DATE_TIME},
+               {EVENT_INST_FI_PR_SUBJECT, _calendar_instance_normal_calendar_book.summary, DATA_TYPE_STRING},
+               {EVENT_INST_FI_PR_DESCRIPTION, _calendar_instance_normal_calendar_book.description, DATA_TYPE_STRING},
+               {EVENT_INST_FI_PR_LOCATION, _calendar_instance_normal_calendar_book.location, DATA_TYPE_STRING},
+               {EVENT_INST_FI_PR_BUSY_STATUS, _calendar_instance_normal_calendar_book.busy_status, DATA_TYPE_INT},
+               {EVENT_INST_FI_PR_PRIORITY, _calendar_instance_normal_calendar_book.priority, DATA_TYPE_INT},
+               {EVENT_INST_FI_PR_SENSITIVITY, _calendar_instance_normal_calendar_book.sensitivity, DATA_TYPE_INT},
+               {EVENT_INST_FI_PR_STATUS, _calendar_instance_normal_calendar_book.event_status, DATA_TYPE_INT},
+               {EVENT_INST_FI_PR_LATITUDE, _calendar_instance_normal_calendar_book.latitude, DATA_TYPE_DOUBLE},
+               {EVENT_INST_FI_PR_LONGITUDE, _calendar_instance_normal_calendar_book.longitude, DATA_TYPE_DOUBLE},
+               {EVENT_INST_FI_PR_IS_RECURRING, _calendar_instance_normal_calendar_book.has_rrule, DATA_TYPE_BOOL},
+               {EVENT_INST_FI_PR_HAS_REMINDER, _calendar_instance_normal_calendar_book.has_alarm, DATA_TYPE_BOOL},
+};
+
+const _CalendarbookFilterImpl::__FilterInfoEntry _CalendarbookFilterImpl::__filterInfos[] =
+{
+       {CB_FI_TYPE_EVENT, _calendar_event._uri, EVENT_FI_PR_EVENT_ID, sizeof(__eventFilterPropertyInfos)/sizeof(_CalendarbookFilterImpl::__FilterPropertyInfoEntry), __eventFilterPropertyInfos},
+       {CB_FI_TYPE_TODO, _calendar_todo._uri, TODO_FI_PR_TODO_ID, sizeof(__todoFilterPropertyInfos)/sizeof(_CalendarbookFilterImpl::__FilterPropertyInfoEntry), __todoFilterPropertyInfos},
+       {CB_FI_TYPE_CALENDAR, _calendar_book._uri, CALENDAR_FI_PR_CALENDAR_ID, sizeof(__calendarFilterPropertyInfos)/sizeof(_CalendarbookFilterImpl::__FilterPropertyInfoEntry), __calendarFilterPropertyInfos},
+       {CB_FI_TYPE_ALL_DAY_EVENT_INSTANCE, _calendar_instance_allday_calendar_book._uri, EVENT_INST_FI_PR_ORIGINAL_EVENT_ID, sizeof(__allDayEventInstanceFilterPropertyInfos)/sizeof(_CalendarbookFilterImpl::__FilterPropertyInfoEntry), __allDayEventInstanceFilterPropertyInfos},
+       {CB_FI_TYPE_NON_ALL_DAY_EVENT_INSTANCE, _calendar_instance_normal_calendar_book._uri, EVENT_INST_FI_PR_ORIGINAL_EVENT_ID, sizeof(__nonAllDayEventInstanceFilterPropertyInfos)/sizeof(_CalendarbookFilterImpl::__FilterPropertyInfoEntry), __nonAllDayEventInstanceFilterPropertyInfos},
+};
+
+bool
+_CalendarbookFilterImpl::IsValidProperty(CalendarbookFilterType filterType, unsigned long property)
+{
+       int filterInfoCount = sizeof(__filterInfos)/sizeof(__FilterInfoEntry);
+
+       if (filterType < 0 || filterType > (filterInfoCount - 1))
+       {
+               return false;
+       }
+
+       unsigned long baseIndex = __filterInfos[filterType].baseIndex;
+       int propertyInfoCount = __filterInfos[filterType].propertyInfoCount;
+
+       if (property < baseIndex || property >= (baseIndex + propertyInfoCount))
+       {
+               return false;
+       }
+
+       return true;
+}
+
+// IsValidProperty must be called before calling this. If IsValidProperty returns false
+// this should not be called.
+const char*
+_CalendarbookFilterImpl::GetUriFromType(CalendarbookFilterType filterType)
+{
+       return __filterInfos[filterType].pViewUri;
+}
+
+// IsValidProperty must be called before calling this. If IsValidProperty returns false
+// this should not be called.
+unsigned int
+_CalendarbookFilterImpl::GetViewPropertyId(CalendarbookFilterType filterType, unsigned long property)
+{
+       const __FilterPropertyInfoEntry* propertyInfos = __filterInfos[filterType].propertyInfos;
+       unsigned long baseIndex = __filterInfos[filterType].baseIndex;
+
+       return propertyInfos[property - baseIndex].viewPropertyId;
+}
+
+// IsValidProperty must be called before calling this. If IsValidProperty returns__nonAllDayEventInstanceFilterPropertyInfos false
+// this should not be called.
+__DataType
+_CalendarbookFilterImpl::GetPropertyType(CalendarbookFilterType filterType, unsigned long property)
+{
+       const __FilterPropertyInfoEntry* propertyInfos = __filterInfos[filterType].propertyInfos;
+       unsigned long baseIndex = __filterInfos[filterType].baseIndex;
+
+       return propertyInfos[property - baseIndex].dataType;
+}
+
+_CalendarbookFilterImpl::_CalendarbookFilterImpl(CalendarbookFilterType type)
+       : __filterHandle(null)
+       , __filterType(type)
+       , __isEmpty(true)
+{
+       calendar_filter_h filterHandle = null;
+       const char* pUri = GetUriFromType(type);
+
+       int ret = calendar_filter_create(pUri, &filterHandle);
+       SysTryReturnVoidResult(NID_SCL, ret == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(GetLastResult()));
+
+       __filterHandle = filterHandle;
+}
+
+_CalendarbookFilterImpl::~_CalendarbookFilterImpl(void)
+{
+       if (__filterHandle != null)
+       {
+               calendar_filter_destroy(__filterHandle);
+       }
+}
+
+bool
+_CalendarbookFilterImpl::Equals(const Object& rhs) const
+{
+       const _CalendarbookFilterImpl* pCalendarbookFilter = dynamic_cast<const _CalendarbookFilterImpl*>(&rhs);
+       if (this == pCalendarbookFilter)
+       {
+               return true;
+       }
+
+       return false;
+}
+
+int
+_CalendarbookFilterImpl::GetHashCode(void) const
+{
+       return (int)__filterHandle;
+}
+
+calendar_match_int_flag_e
+_CalendarbookFilterImpl::GetMatchIntFlag(FilterComparisonOperator comparisonOperator)
+{
+       calendar_match_int_flag_e match = CALENDAR_MATCH_NONE;
+       switch(comparisonOperator)
+       {
+       case FI_CMP_OP_EQUAL:
+               match = CALENDAR_MATCH_EQUAL;
+               break;
+
+       case FI_CMP_OP_LESS_THAN:
+               match = CALENDAR_MATCH_LESS_THAN;
+               break;
+
+       case FI_CMP_OP_LESS_THAN_OR_EQUAL:
+               match = CALENDAR_MATCH_LESS_THAN_OR_EQUAL;
+               break;
+
+       case FI_CMP_OP_GREATER_THAN:
+               match = CALENDAR_MATCH_GREATER_THAN;
+               break;
+
+       case FI_CMP_OP_GREATER_THAN_OR_EQUAL:
+               match = CALENDAR_MATCH_GREATER_THAN_OR_EQUAL;
+               break;
+
+       case FI_CMP_OP_IS_NULL:
+               match = CALENDAR_MATCH_NONE;
+               break;
+
+       default:
+               match = CALENDAR_MATCH_NONE;
+               break;
+       };
+
+       return match;
+}
+
+calendar_match_str_flag_e
+_CalendarbookFilterImpl::GetMatchStrFlag(FilterStringOperator stringOperstor)
+{
+       calendar_match_str_flag_e match = CALENDAR_MATCH_EXISTS;
+       switch(stringOperstor)
+       {
+       case FI_STR_OP_EQUAL:
+               match = CALENDAR_MATCH_EXACTLY;
+               break;
+
+       case FI_STR_OP_FULL_STRING:
+               match = CALENDAR_MATCH_FULLSTRING;
+               break;
+
+       case FI_STR_OP_START_WITH:
+               match = CALENDAR_MATCH_STARTSWITH;
+               break;
+
+       case FI_STR_OP_END_WITH:
+               match = CALENDAR_MATCH_ENDSWITH;
+               break;
+
+       case FI_STR_OP_CONTAIN:
+               match = CALENDAR_MATCH_CONTAINS;
+               break;
+
+       case FI_STR_OP_IS_NOT_NULL:
+               match = CALENDAR_MATCH_EXISTS;
+               break;
+
+       default:
+               match = CALENDAR_MATCH_EXISTS;
+               break;
+       };
+
+       return match;
+}
+
+result
+_CalendarbookFilterImpl::AppendInt(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, int value)
+{
+       SysTryReturn(NID_SCL, IsValidProperty(__filterType, filterProperty), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. filterProperty = %ld", GetErrorMessage(E_INVALID_ARG), filterProperty);
+       SysTryReturn(NID_SCL, GetPropertyType(__filterType, filterProperty) == DATA_TYPE_INT, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The type of the specified filter property %d must be int.", GetErrorMessage(E_INVALID_ARG), filterProperty);
+       SysTryReturn(NID_SCL, !(__isEmpty && (conjunctiveOperator == FI_CONJ_OP_AND || conjunctiveOperator == FI_CONJ_OP_OR)),\
+                       E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. conjunctiveOperator %d must be FI_CONJ_OP_NONE if there is no filtering expression or filter that has been appended before",\
+                       GetErrorMessage(E_INVALID_ARG), conjunctiveOperator);
+       SysTryReturn(NID_SCL, !(!__isEmpty && (conjunctiveOperator == FI_CONJ_OP_NONE)),\
+                       E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. conjunctiveOperator %d must be either of FI_CONJ_OP_AND or FI_CONJ_OP_OR, if there is a filtering expression or filter that has been appended before.",\
+                       GetErrorMessage(E_INVALID_ARG), conjunctiveOperator);
+
+       unsigned int id = _CalendarbookFilterImpl::GetViewPropertyId(__filterType, filterProperty);
+       calendar_match_int_flag_e match = GetMatchIntFlag(comparisonOperator);
+
+       int convertedValue = 0;
+       switch (filterProperty)
+       {
+       case EVENT_FI_PR_BUSY_STATUS:
+               convertedValue = _CalendarbookUtil::ConvertBusyStatusToCSEventBusyStatus(value);
+               break;
+
+       case EVENT_FI_PR_PRIORITY:
+               convertedValue = _CalendarbookUtil::ConvertEventPriorityToCSEventPriority(value);
+               break;
+
+       case EVENT_FI_PR_SENSITIVITY:
+               convertedValue = _CalendarbookUtil::ConvertSensitivityToCSSensitivity(value);
+               break;
+
+       case EVENT_FI_PR_STATUS:
+               convertedValue = _CalendarbookUtil::ConvertEventStatusToCSEventStatus(value);
+               break;
+
+       case TODO_FI_PR_PRIORITY:
+               convertedValue = _CalendarbookUtil::ConvertTodoPriorityToCSTodoPriority(value);
+               break;
+
+       case TODO_FI_PR_SENSITIVITY:
+               convertedValue = _CalendarbookUtil::ConvertSensitivityToCSSensitivity(value);
+               break;
+
+       case TODO_FI_PR_STATUS:
+               convertedValue = _CalendarbookUtil::ConvertTodoStatusToCSTodoStatus(value);
+               break;
+
+       case CALENDAR_FI_PR_ITEM_TYPE:
+               convertedValue = _CalendarbookUtil::ConvertCalendarItemTypeToCSCalendarbookType(value);
+               break;
+
+       case EVENT_INST_FI_PR_BUSY_STATUS:
+               convertedValue = _CalendarbookUtil::ConvertBusyStatusToCSEventBusyStatus(value);
+               break;
+
+       case EVENT_INST_FI_PR_PRIORITY:
+               convertedValue = _CalendarbookUtil::ConvertEventPriorityToCSEventPriority(value);
+               break;
+
+       case EVENT_INST_FI_PR_SENSITIVITY:
+               convertedValue = _CalendarbookUtil::ConvertSensitivityToCSSensitivity(value);
+               break;
+
+       case EVENT_INST_FI_PR_STATUS:
+               convertedValue = _CalendarbookUtil::ConvertEventStatusToCSEventStatus(value);
+               break;
+
+       default:
+               convertedValue = value;
+               break;
+       }
+
+       if (!__isEmpty)
+       {
+               calendar_filter_operator_e filterOperator = conjunctiveOperator == FI_CONJ_OP_AND ? CALENDAR_FILTER_OPERATOR_AND : CALENDAR_FILTER_OPERATOR_OR;
+
+               int ret = calendar_filter_add_operator(__filterHandle, filterOperator);
+               SysTryReturn(NID_SCL, ret == CALENDAR_ERROR_NONE, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       int ret = calendar_filter_add_int(__filterHandle, id, match, convertedValue);
+       SysTryReturn(NID_SCL, ret == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __isEmpty = false;
+
+       return E_SUCCESS;
+}
+
+result
+_CalendarbookFilterImpl::AppendDouble(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, double value)
+{
+       SysTryReturn(NID_SCL, IsValidProperty(__filterType, filterProperty), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. filterProperty = %ld", GetErrorMessage(E_INVALID_ARG), filterProperty);
+       SysTryReturn(NID_SCL, GetPropertyType(__filterType, filterProperty) == DATA_TYPE_DOUBLE, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The type of the specified filter property %d must be double.", GetErrorMessage(E_INVALID_ARG), filterProperty);
+       SysTryReturn(NID_SCL, !(__isEmpty && (conjunctiveOperator == FI_CONJ_OP_AND || conjunctiveOperator == FI_CONJ_OP_OR)),\
+                       E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. conjunctiveOperator %d must be FI_CONJ_OP_NONE if there is no filtering expression or filter that has been appended before",\
+                       GetErrorMessage(E_INVALID_ARG), conjunctiveOperator);
+       SysTryReturn(NID_SCL, !(!__isEmpty && (conjunctiveOperator == FI_CONJ_OP_NONE)),\
+                       E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. conjunctiveOperator %d must be either of FI_CONJ_OP_AND or FI_CONJ_OP_OR, if there is a filtering expression or filter that has been appended before.",\
+                       GetErrorMessage(E_INVALID_ARG), conjunctiveOperator);
+
+       unsigned int id = _CalendarbookFilterImpl::GetViewPropertyId(__filterType, filterProperty);
+       calendar_match_int_flag_e match = GetMatchIntFlag(comparisonOperator);
+
+       if (!__isEmpty)
+       {
+               calendar_filter_operator_e filterOperator = conjunctiveOperator == FI_CONJ_OP_AND ? CALENDAR_FILTER_OPERATOR_AND : CALENDAR_FILTER_OPERATOR_OR;
+
+               int ret = calendar_filter_add_operator(__filterHandle, filterOperator);
+               SysTryReturn(NID_SCL, ret == CALENDAR_ERROR_NONE, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       int ret = calendar_filter_add_double(__filterHandle, id, match, value);
+       SysTryReturn(NID_SCL, ret == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __isEmpty = false;
+
+       return E_SUCCESS;
+}
+
+result
+_CalendarbookFilterImpl::AppendBool(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, bool value)
+{
+       SysTryReturn(NID_SCL, IsValidProperty(__filterType, filterProperty), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. filterProperty = %ld", GetErrorMessage(E_INVALID_ARG), filterProperty);
+       SysTryReturn(NID_SCL, GetPropertyType(__filterType, filterProperty) == DATA_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The type of the specified filter property %d must be bool.", GetErrorMessage(E_INVALID_ARG), filterProperty);
+       SysTryReturn(NID_SCL, !(__isEmpty && (conjunctiveOperator == FI_CONJ_OP_AND || conjunctiveOperator == FI_CONJ_OP_OR)),\
+                       E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. conjunctiveOperator %d must be FI_CONJ_OP_NONE if there is no filtering expression or filter that has been appended before",\
+                       GetErrorMessage(E_INVALID_ARG), conjunctiveOperator);
+       SysTryReturn(NID_SCL, !(!__isEmpty && conjunctiveOperator == FI_CONJ_OP_NONE),\
+                       E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. conjunctiveOperator %d must be either of FI_CONJ_OP_AND or FI_CONJ_OP_OR, if there is a filtering expression or filter that has been appended before.",\
+                       GetErrorMessage(E_INVALID_ARG), conjunctiveOperator);
+       SysTryReturn(NID_SCL, comparisonOperator == FI_CMP_OP_EQUAL, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. comparisonOperator %d must be FI_CMP_OP_EQUAL.", GetErrorMessage(E_INVALID_ARG), comparisonOperator);
+
+       unsigned int viewPropertyId = _CalendarbookFilterImpl::GetViewPropertyId(__filterType, filterProperty);
+
+       if (!__isEmpty)
+       {
+               calendar_filter_operator_e filterOperator = conjunctiveOperator == FI_CONJ_OP_AND ? CALENDAR_FILTER_OPERATOR_AND : CALENDAR_FILTER_OPERATOR_OR;
+
+               int ret = calendar_filter_add_operator(__filterHandle, filterOperator);
+               SysTryReturn(NID_SCL, ret == CALENDAR_ERROR_NONE, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       int ret = calendar_filter_add_int(__filterHandle, viewPropertyId, CALENDAR_MATCH_EQUAL, value);
+       SysTryReturn(NID_SCL, ret == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __isEmpty = false;
+
+       return E_SUCCESS;
+}
+
+result
+_CalendarbookFilterImpl::AppendDateTime(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, const DateTime& value)
+{
+       SysTryReturn(NID_SCL, IsValidProperty(__filterType, filterProperty), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. filterProperty = %ld", GetErrorMessage(E_INVALID_ARG), filterProperty);
+       SysTryReturn(NID_SCL, GetPropertyType(__filterType, filterProperty) == DATA_TYPE_DATE_TIME, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The type of the specified filter property %d must be DateTime.", GetErrorMessage(E_INVALID_ARG), filterProperty);
+       SysTryReturn(NID_SCL, !(__isEmpty && (conjunctiveOperator == FI_CONJ_OP_AND || conjunctiveOperator == FI_CONJ_OP_OR)),\
+                       E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. conjunctiveOperator %d must be FI_CONJ_OP_NONE if there is no filtering expression or filter that has been appended before",\
+                       GetErrorMessage(E_INVALID_ARG), conjunctiveOperator);
+       SysTryReturn(NID_SCL, !(!__isEmpty && conjunctiveOperator == FI_CONJ_OP_NONE),\
+                       E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. conjunctiveOperator %d must be either of FI_CONJ_OP_AND or FI_CONJ_OP_OR, if there is a filtering expression or filter that has been appended before.",\
+                       GetErrorMessage(E_INVALID_ARG), conjunctiveOperator);
+       SysTryReturn(NID_SCL, _CalendarbookUtil::CheckValidDateTime(value), null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. The value is not in a valid range.");
+
+       unsigned int id = _CalendarbookFilterImpl::GetViewPropertyId(__filterType, filterProperty);
+       calendar_match_int_flag_e match = GetMatchIntFlag(comparisonOperator);
+
+       if (!__isEmpty)
+       {
+               calendar_filter_operator_e filterOperator = conjunctiveOperator == FI_CONJ_OP_AND ? CALENDAR_FILTER_OPERATOR_AND : CALENDAR_FILTER_OPERATOR_OR;
+
+               int ret = calendar_filter_add_operator(__filterHandle, filterOperator);
+               SysTryReturn(NID_SCL, ret == CALENDAR_ERROR_NONE, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+
+       if (filterProperty == EVENT_FI_PR_LAST_REVISED_TIME || filterProperty == TODO_FI_PR_LAST_REVISED_TIME)
+       {
+               int ret = calendar_filter_add_lli(__filterHandle, id, match, _CalendarbookUtil::ConvertDateTimeToEpochTime(value));
+               SysTryReturn(NID_SCL, ret == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+       else if (filterProperty == TODO_FI_PR_START_DATE)
+       {
+               calendar_time_s convertedTime;
+
+               if (comparisonOperator == FI_CMP_OP_IS_NULL)
+               {
+                       convertedTime.type = CALENDAR_TIME_UTIME;
+                       convertedTime.time.utime = _CALENDAR_TODO_NO_START_DATE;
+                       match = CALENDAR_MATCH_EQUAL;
+               }
+               else
+               {
+                       _CalendarbookUtil::ConvertDateTimeToCalTime(value, convertedTime);
+               }
+
+               int ret = calendar_filter_add_caltime(__filterHandle, id, match, convertedTime);
+               SysTryReturn(NID_SCL, ret == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+       else if (filterProperty == TODO_FI_PR_DUE_DATE)
+       {
+               calendar_time_s convertedTime;
+
+               if (comparisonOperator == FI_CMP_OP_IS_NULL)
+               {
+                       convertedTime.type = CALENDAR_TIME_UTIME;
+                       convertedTime.time.utime = _CALENDAR_TODO_NO_DUE_DATE;
+                       match = CALENDAR_MATCH_EQUAL;
+               }
+               else
+               {
+                       _CalendarbookUtil::ConvertDateTimeToCalTime(value, convertedTime);
+               }
+
+               int ret = calendar_filter_add_caltime(__filterHandle, id, match, convertedTime);
+               SysTryReturn(NID_SCL, ret == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+       else if ((filterProperty == EVENT_INST_FI_PR_START_TIME || filterProperty == EVENT_INST_FI_PR_END_TIME) && __filterType == CB_FI_TYPE_NON_ALL_DAY_EVENT_INSTANCE)
+       {
+               calendar_time_s convertedTime;
+               _CalendarbookUtil::ConvertDateTimeToCalTime(value, convertedTime);
+
+               int ret = calendar_filter_add_caltime(__filterHandle, id, match, convertedTime);
+               SysTryReturn(NID_SCL, ret == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+       else if ((filterProperty == EVENT_INST_FI_PR_START_TIME || filterProperty == EVENT_INST_FI_PR_END_TIME) && (__filterType == CB_FI_TYPE_ALL_DAY_EVENT_INSTANCE))
+       {
+               calendar_time_s convertedTime;
+               _CalendarbookUtil::ConvertDateToCalTime(value, convertedTime);
+
+               int ret = calendar_filter_add_caltime(__filterHandle, id, match, convertedTime);
+               SysTryReturn(NID_SCL, ret == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+       else
+       {
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. The type of the specified filter property %d must be DateTime.", GetErrorMessage(E_INVALID_ARG), filterProperty);
+               return E_INVALID_ARG;
+       }
+
+       __isEmpty = false;
+
+       return E_SUCCESS;
+}
+
+result
+_CalendarbookFilterImpl::AppendString(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterStringOperator comparisonOperator, const String& value)
+{
+       SysTryReturn(NID_SCL, IsValidProperty(__filterType, filterProperty), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. filterProperty = %ld", GetErrorMessage(E_INVALID_ARG), filterProperty);
+       SysTryReturn(NID_SCL, GetPropertyType(__filterType, filterProperty) == DATA_TYPE_STRING, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The type of the specified filter property %d must be String.", GetErrorMessage(E_INVALID_ARG), filterProperty);
+       SysTryReturn(NID_SCL, !(__isEmpty && (conjunctiveOperator == FI_CONJ_OP_AND  || conjunctiveOperator == FI_CONJ_OP_OR)),\
+                       E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. conjunctiveOperator %d must be FI_CONJ_OP_NONE if there is no filtering expression or filter that has been appended before",\
+                       GetErrorMessage(E_INVALID_ARG), conjunctiveOperator);
+       SysTryReturn(NID_SCL, !(!__isEmpty && conjunctiveOperator == FI_CONJ_OP_NONE),\
+                       E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. conjunctiveOperator %d must be either of FI_CONJ_OP_AND or FI_CONJ_OP_OR, if there is a filtering expression or filter that has been appended before.",\
+                       GetErrorMessage(E_INVALID_ARG), conjunctiveOperator);
+
+       unsigned int viewPropertyId = _CalendarbookFilterImpl::GetViewPropertyId(__filterType, filterProperty);
+
+       calendar_match_str_flag_e match = GetMatchStrFlag(comparisonOperator);
+       std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(value));
+       SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       if (!__isEmpty)
+       {
+               calendar_filter_operator_e filterOperator = conjunctiveOperator == FI_CONJ_OP_AND ? CALENDAR_FILTER_OPERATOR_AND : CALENDAR_FILTER_OPERATOR_OR;
+
+               int ret = calendar_filter_add_operator(__filterHandle, filterOperator);
+               SysTryReturn(NID_SCL, ret == CALENDAR_ERROR_NONE, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       int ret = calendar_filter_add_str(__filterHandle, viewPropertyId, match, pCharArray.get());
+       SysTryReturn(NID_SCL, ret == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __isEmpty = false;
+
+       return E_SUCCESS;
+}
+
+result
+_CalendarbookFilterImpl::AppendFilter(FilterConjunctiveOperator conjunctiveOperator, const _CalendarbookFilterImpl& filter)
+{
+       SysTryReturn(NID_SCL, !filter.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified filter should not be empty.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, __filterType == filter.__filterType, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The type of the filter must be same with the type of this filter.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !(__isEmpty && (conjunctiveOperator == FI_CONJ_OP_AND || conjunctiveOperator == FI_CONJ_OP_OR)),\
+                       E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. conjunctiveOperator %d must be FI_CONJ_OP_NONE if there is no filtering expression or filter that has been appended before",\
+                       GetErrorMessage(E_INVALID_ARG), conjunctiveOperator);
+       SysTryReturn(NID_SCL, !(!__isEmpty && conjunctiveOperator == FI_CONJ_OP_NONE),\
+                       E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. conjunctiveOperator %d must be either of FI_CONJ_OP_AND or FI_CONJ_OP_OR, if there is a filtering expression or filter that has been appended before.",\
+                       GetErrorMessage(E_INVALID_ARG), conjunctiveOperator);
+
+       if (!__isEmpty)
+       {
+               calendar_filter_operator_e filterOperator = conjunctiveOperator == FI_CONJ_OP_AND ? CALENDAR_FILTER_OPERATOR_AND : CALENDAR_FILTER_OPERATOR_OR;
+
+               int ret = calendar_filter_add_operator(__filterHandle, filterOperator);
+               SysTryReturn(NID_SCL, ret == CALENDAR_ERROR_NONE, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       int ret = calendar_filter_add_filter(__filterHandle, filter.__filterHandle);
+       SysTryReturn(NID_SCL, ret == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __isEmpty = false;
+
+       return E_SUCCESS;
+}
+
+calendar_filter_h
+_CalendarbookFilterImpl::GetFilterHandle(void) const
+{
+       if (!__isEmpty)
+       {
+               return __filterHandle;
+       }
+
+       return null;
+}
+
+CalendarbookFilterType
+_CalendarbookFilterImpl::GetType(void) const
+{
+       return __filterType;
+}
+
+bool
+_CalendarbookFilterImpl::IsEmpty(void) const
+{
+       return __isEmpty;
+}
+
+const _CalendarbookFilterImpl*
+_CalendarbookFilterImpl::GetInstance(const CalendarbookFilter& filter)
+{
+       return filter.__pCalendarbookFilterImpl;
+}
+
+_CalendarbookFilterImpl*
+_CalendarbookFilterImpl::GetInstance(CalendarbookFilter& filter)
+{
+       return filter.__pCalendarbookFilterImpl;
+}
+
+}} // Tizen::Social
diff --git a/src/FScl_CalendarbookFilterImpl.h b/src/FScl_CalendarbookFilterImpl.h
new file mode 100644 (file)
index 0000000..1e88d44
--- /dev/null
@@ -0,0 +1,129 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_CalendarbookFilterImpl.h
+ * @brief              This is the header file for the %_CalendarbookFilterImpl class.
+ *
+ * This header file contains the declarations of the %_CalendarbookFilterImpl class.
+ */
+#ifndef _FSCL_CALENDARBOOK_FILTER_IMPL_H_
+#define _FSCL_CALENDARBOOK_FILTER_IMPL_H_
+
+#include <calendar2.h>
+#include <FBaseObject.h>
+#include <FBaseTypes.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+class DateTime;
+}}
+
+namespace Tizen { namespace Social
+{
+
+class CalendarbookFilter;
+
+enum __DataType
+{
+       DATA_TYPE_NONE,
+       DATA_TYPE_INT,
+       DATA_TYPE_DOUBLE,
+       DATA_TYPE_BOOL,
+       DATA_TYPE_DATE_TIME,
+       DATA_TYPE_STRING,
+};
+
+class _OSP_EXPORT_ _CalendarbookFilterImpl
+           : public Tizen::Base::Object
+{
+public:
+       _CalendarbookFilterImpl(CalendarbookFilterType type);
+
+       virtual ~_CalendarbookFilterImpl(void);
+
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       virtual int GetHashCode(void) const;
+
+       calendar_filter_h GetFilterHandle(void) const;
+
+       CalendarbookFilterType GetType(void) const;
+
+       bool IsEmpty(void) const;
+
+       result AppendInt(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, int value);
+
+       result AppendDouble(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, double value);
+
+       result AppendBool(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, bool value);
+
+       result AppendDateTime(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, const Tizen::Base::DateTime& value);
+
+       result AppendString(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterStringOperator comparisonOperator, const Tizen::Base::String& value);
+
+       result AppendFilter(FilterConjunctiveOperator conjunctiveOperator, const _CalendarbookFilterImpl& filter);
+
+       static const char* GetUriFromType(CalendarbookFilterType type);
+
+       static __DataType GetPropertyType(CalendarbookFilterType type, unsigned long filterProperty);
+
+       static bool IsValidProperty(CalendarbookFilterType type, unsigned long filterProperty);
+
+       static unsigned int GetViewPropertyId(CalendarbookFilterType type, unsigned long filterProperty);
+
+       static const _CalendarbookFilterImpl* GetInstance(const CalendarbookFilter& filter);
+
+       static  _CalendarbookFilterImpl* GetInstance(CalendarbookFilter& filter);
+
+public:
+       struct __FilterPropertyInfoEntry
+       {
+               unsigned long propertyId;
+               unsigned long viewPropertyId;
+               __DataType dataType;
+       };
+
+       struct __FilterInfoEntry
+       {
+               unsigned long filterType;
+               const char* pViewUri;
+               unsigned long baseIndex;
+               unsigned long propertyInfoCount;
+               const __FilterPropertyInfoEntry* propertyInfos;
+       };
+
+       static const __FilterPropertyInfoEntry __calendarFilterPropertyInfos[];
+       static const __FilterPropertyInfoEntry __eventFilterPropertyInfos[];
+       static const __FilterPropertyInfoEntry __todoFilterPropertyInfos[];
+       static const __FilterPropertyInfoEntry __allDayEventInstanceFilterPropertyInfos[];
+       static const __FilterPropertyInfoEntry __nonAllDayEventInstanceFilterPropertyInfos[];
+       static const __FilterInfoEntry __filterInfos[];
+
+private:
+       // get match flag
+       static calendar_match_str_flag_e GetMatchStrFlag(FilterStringOperator stringOperstor);
+       static calendar_match_int_flag_e GetMatchIntFlag(FilterComparisonOperator comparisonOperator);
+
+       calendar_filter_h __filterHandle;
+       CalendarbookFilterType __filterType;
+       bool __isEmpty;
+};         // _CalendarbookFilterImpl
+
+}} // Tizen::Social
+
+#endif // _FSCL_CALENDARBOOK_FILTER_IMPL_H_
diff --git a/src/FScl_CalendarbookImpl.cpp b/src/FScl_CalendarbookImpl.cpp
new file mode 100644 (file)
index 0000000..9bd4f32
--- /dev/null
@@ -0,0 +1,3128 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_CalendarbookImpl.cpp
+ * @brief              This is the implementation for _CalendarbookImpl class.
+ *
+ * This file contains definitions of @e _CalendarbookImpl class.
+ */
+
+#include <new>
+#include <unique_ptr.h>
+#include <FBaseColArrayList.h>
+#include <FBaseColHashMapT.h>
+#include <FBaseDateTime.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include <FBaseUtilStringUtil.h>
+#include <FIoFile.h>
+#include <FLclTimeZone.h>
+#include <FSclCalendar.h>
+#include <FSclCalendarbook.h>
+#include <FSclCalEvent.h>
+#include <FSclCalEventChangeInfo.h>
+#include <FSclCalEventInstance.h>
+#include <FSclCalTodo.h>
+#include <FSclCalTodoChangeInfo.h>
+#include <FSclICalendarbookEventListener.h>
+#include <FSclIRecordEventListener.h>
+#include <FSclIRecordListener.h>
+#include "FScl_CalendarbookImpl.h"
+#include "FScl_CalendarbookFilterImpl.h"
+#include "FScl_CalendarbookDbConnector.h"
+#include "FScl_CalendarbookDbMonitor.h"
+#include "FScl_CalendarbookRecordRetrivalEvent.h"
+#include "FScl_CalendarbookRecordRetrivalThread.h"
+#include "FScl_CalendarbookUtil.h"
+#include "FScl_CalEventChangeInfoImpl.h"
+#include "FScl_CalendarImpl.h"
+#include "FScl_CalEventImpl.h"
+#include "FScl_CalEventInstanceImpl.h"
+#include "FScl_CalTodoChangeInfoImpl.h"
+#include "FScl_CalTodoImpl.h"
+#include "FScl_RecordImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Social
+{
+
+RequestId _CalendarbookImpl::__requestId = 0;
+_CalendarbookRecordRetrivalThread* _CalendarbookImpl::__pRecordRetrivalThread = null;
+
+static const int _DEFAULT_EVENT_CALENDAR_DB_ID = 1;
+static const int _DEFAULT_TODO_CALENDAR_DB_ID = 2;
+static const wchar_t* _RECURRENCE_DELIMITER = L",";
+static const int _NUMBER_OF_TODO_STATUS = 5;
+static const int _NUMBER_OF_TODO_PRIORITY = 3;
+static const int _NUMBER_OF_EVENT_CATEGORY_MAP_PROJECTION = 2;
+
+static const int _INVALID_CALENDARBOOK_DB_ID = -1;     // TODO : This value should be checked.
+static const int _INVALID_EVENT_DB_ID = -1;
+
+class _CalendarList
+{
+public :
+       _CalendarList(calendar_list_h calendarListHandle, bool deleteRecord = true)
+               : __calendarListHandle(calendarListHandle)
+               , __deleteRecord(deleteRecord)
+       {
+       }
+
+       ~_CalendarList(void)
+       {
+               if (__calendarListHandle)
+               {
+                       calendar_list_destroy(__calendarListHandle, __deleteRecord);
+               }
+       }
+
+       calendar_list_h GetHandle(void)
+       {
+               return __calendarListHandle;
+       }
+
+       calendar_list_h ReleaseHandle(void)
+       {
+               calendar_list_h calendarListHandle = __calendarListHandle;
+               __calendarListHandle = null;
+               return calendarListHandle;
+       }
+
+private :
+       calendar_list_h __calendarListHandle;
+       bool __deleteRecord;
+};
+
+class _CalendarFilter
+{
+public :
+       _CalendarFilter(calendar_filter_h calendarFilterHandle)
+               : __calendarFilterHandle(calendarFilterHandle)
+       {
+       }
+
+       ~_CalendarFilter(void)
+       {
+               if (__calendarFilterHandle)
+               {
+                       calendar_filter_destroy(__calendarFilterHandle);
+               }
+       }
+
+       calendar_filter_h GetHandle(void)
+       {
+               return __calendarFilterHandle;
+       }
+
+       calendar_filter_h ReleaseHandle(void)
+       {
+               calendar_filter_h calendarFilterHandle = __calendarFilterHandle;
+               __calendarFilterHandle = null;
+               return calendarFilterHandle;
+       }
+
+       void ResetHandle(calendar_filter_h calendarFilterHandle)
+       {
+               if (__calendarFilterHandle)
+               {
+                       calendar_filter_destroy(__calendarFilterHandle);
+               }
+               __calendarFilterHandle = calendarFilterHandle;
+       }
+
+private :
+       calendar_filter_h __calendarFilterHandle;
+};
+
+class _CalendarConnector
+{
+public :
+       _CalendarConnector()
+               : __r(E_SUCCESS)
+       {
+               __r = _CalendarbookDbConnector::Connect();
+       }
+
+       ~_CalendarConnector(void)
+       {
+               if (__r == E_SUCCESS)
+               {
+                       _CalendarbookDbConnector::Disconnect();
+               }
+       }
+
+       result GetResult(void)
+       {
+               return __r;
+       }
+
+private :
+       result __r;
+};
+
+class _CalendarQuery
+{
+public :
+       _CalendarQuery(calendar_query_h calendarQueryHandle)
+               : __calendarQueryHandle(calendarQueryHandle)
+       {
+       }
+
+       ~_CalendarQuery(void)
+       {
+               if (__calendarQueryHandle)
+               {
+                       calendar_query_destroy(__calendarQueryHandle);
+               }
+       }
+
+       calendar_query_h GetHandle(void)
+       {
+               return __calendarQueryHandle;
+       }
+
+       calendar_query_h ReleaseHandle(void)
+       {
+               calendar_query_h calendarQueryHandle = __calendarQueryHandle;
+               __calendarQueryHandle = null;
+               return calendarQueryHandle;
+       }
+
+       void ResetHandle(calendar_query_h calendarQueryHandle)
+       {
+               if (__calendarQueryHandle)
+               {
+                       calendar_query_destroy(__calendarQueryHandle);
+               }
+               __calendarQueryHandle = calendarQueryHandle;
+       }
+
+private :
+       calendar_query_h __calendarQueryHandle;
+};
+
+_CalendarbookImpl::_CalendarbookImpl(void)
+       : __pIRecordEventListener(null)
+       , __pICalendarbookEventListener(null)
+       , __dbVersionForEvent(0)
+       , __dbVersionForTodo(0)
+       , __pCalendarbookDbMonitor(null)
+{
+}
+
+_CalendarbookImpl::~_CalendarbookImpl(void)
+{
+       if (__pCalendarbookDbMonitor != null)
+       {
+               if (__pIRecordEventListener != null || __pICalendarbookEventListener != null)
+               {
+                       __pCalendarbookDbMonitor->RemoveListener(*this);
+               }
+
+               __pCalendarbookDbMonitor->Release();
+       }
+       else
+       {
+               _CalendarbookDbConnector::Disconnect();
+       }
+}
+
+result
+_CalendarbookImpl::Construct(void)
+{
+       result r = _CalendarbookDbConnector::Connect();
+       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred.");
+
+       return E_SUCCESS;
+}
+
+result
+_CalendarbookImpl::Construct(IRecordEventListener* pListener)
+{
+       result r = E_SUCCESS;
+       int dbVersion = -1;
+
+       ClearLastResult();
+
+       _CalendarbookDbMonitor* pCalendarbookDbMonitor = _CalendarbookDbMonitor::GetInstance();
+       SysTryReturnResult(NID_SCL, pCalendarbookDbMonitor != null, E_SYSTEM, "A system error has been occurred.");
+
+       if (pListener != null)
+       {
+               dbVersion = GetLatestVersion();
+               SysTryCatch(NID_SCL, dbVersion != -1, r = GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+               r = pCalendarbookDbMonitor->AddListener(*this);
+               SysTryCatch(NID_SCL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+               __pIRecordEventListener = pListener;
+       }
+
+       __pCalendarbookDbMonitor = pCalendarbookDbMonitor;
+
+       __dbVersionForEvent = dbVersion;
+       __dbVersionForTodo = dbVersion;
+
+       return E_SUCCESS;
+
+CATCH:
+       pCalendarbookDbMonitor->Release();
+
+       return r;
+}
+
+result
+_CalendarbookImpl::Construct(ICalendarbookEventListener& listener)
+{
+       ClearLastResult();
+
+       _CalendarbookDbMonitor* pCalendarbookDbMonitor = _CalendarbookDbMonitor::GetInstance();
+       SysTryReturnResult(NID_SCL, pCalendarbookDbMonitor != null, E_SYSTEM, "A system error has been occurred.");
+
+       result r = E_SUCCESS;
+
+       int dbVersion = GetLatestVersion();
+       SysTryCatch(NID_SCL, dbVersion != -1, r = GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       r = pCalendarbookDbMonitor->AddListener(*this);
+       SysTryCatch(NID_SCL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pICalendarbookEventListener = &listener;
+       __pCalendarbookDbMonitor = pCalendarbookDbMonitor;
+
+       __dbVersionForEvent = dbVersion;
+       __dbVersionForTodo = dbVersion;
+
+       return E_SUCCESS;
+
+CATCH:
+       pCalendarbookDbMonitor->Release();
+
+       return r;
+}
+
+result
+_CalendarbookImpl::AddEvent(CalEvent& event)
+{
+       SysTryReturnResult(NID_SCL, event.GetRecordId() == INVALID_RECORD_ID, E_INVALID_ARG
+                       , "Invalid argument is used. The specified recordId is not INVALID_RECORD_ID.");
+       SysTryReturnResult(NID_SCL, !event.IsInstance(), E_INVALID_ARG
+                       , "Invalid argument is used. The event is not an entry type instance.");
+
+       calendar_record_h eventHandle = _CalEventImpl::GetInstance(event)->GetRecordHandle();
+
+       int errorCode  = calendar_record_set_int(eventHandle, _calendar_event.calendar_book_id, _DEFAULT_EVENT_CALENDAR_DB_ID);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+
+       int dbIndex = -1;
+       errorCode = calendar_db_insert_record(eventHandle, &dbIndex);
+       SysTryReturnResult(NID_SCL, errorCode != CALENDAR_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, "The storage is insufficient.");
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+       _RecordImpl::GetInstance(event)->SetRecordId(dbIndex);
+
+       calendar_record_h tmpEventHandle = null;
+       errorCode = calendar_db_get_record(_calendar_event._uri, dbIndex, &tmpEventHandle);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+       _CalEventImpl::GetInstance(event)->SetRecordHandle(tmpEventHandle);
+
+       return E_SUCCESS;
+}
+
+result
+_CalendarbookImpl::AddEvent(CalEvent& event, RecordId calendarId)
+{
+       SysTryReturnResult(NID_SCL, event.GetRecordId() == INVALID_RECORD_ID, E_INVALID_ARG
+                       , "Invalid argument is used. The specified recordId is not INVALID_RECORD_ID.");
+       SysTryReturnResult(NID_SCL, !event.IsInstance(), E_INVALID_ARG
+                       , "Invalid argument is used. The event is not an entry type instance.");
+       SysTryReturnResult(NID_SCL, calendarId != INVALID_RECORD_ID, E_INVALID_ARG
+                       , "Invalid argument is used. calendarId = %d", calendarId);
+       CalendarItemType itemType = GetCalendarItemTypeByCalendarId(calendarId);
+       SysTryReturnResult(NID_SCL, GetLastResult() == E_SUCCESS, E_OBJ_NOT_FOUND, "The specified calendarId is not found.");
+       SysTryReturnResult(NID_SCL,(itemType == CALENDAR_ITEM_TYPE_EVENT_ONLY || itemType == CALENDAR_ITEM_TYPE_EVENT_AND_TODO)
+                       , E_INVALID_ARG, "Invalid argument is used. The calendar is created for CALENDAR_ITEM_TYPE_TODO_ONLY");
+
+       calendar_record_h eventHandle = _CalEventImpl::GetInstance(event)->GetRecordHandle();
+
+       int errorCode = calendar_record_set_int(eventHandle, _calendar_event.calendar_book_id, calendarId);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+
+       int dbIndex = -1;
+       errorCode = calendar_db_insert_record(eventHandle, &dbIndex);
+       SysTryReturnResult(NID_SCL, errorCode != CALENDAR_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, "The storage is insufficient.");
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+       _RecordImpl::GetInstance(event)->SetRecordId(dbIndex);
+
+       calendar_record_h tmpEventHandle = null;
+       errorCode = calendar_db_get_record(_calendar_event._uri, dbIndex, &tmpEventHandle);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+       _CalEventImpl::GetInstance(event)->SetRecordHandle(tmpEventHandle);
+
+       return E_SUCCESS;
+}
+
+result
+_CalendarbookImpl::AddTodo(CalTodo& todo)
+{
+       SysTryReturnResult(NID_SCL, todo.GetRecordId() == INVALID_RECORD_ID, E_INVALID_ARG
+                       , "Invalid argument is used. The specified recordId is not INVALID_RECORD_ID.");
+
+       calendar_record_h todoHandle = _CalTodoImpl::GetInstance(todo)->GetRecordHandle();
+
+       int errorCode = calendar_record_set_int(todoHandle, _calendar_todo.calendar_book_id, _DEFAULT_TODO_CALENDAR_DB_ID);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+
+       int dbIndex = -1;
+       errorCode = calendar_db_insert_record(todoHandle, &dbIndex);
+       SysTryReturnResult(NID_SCL, errorCode != CALENDAR_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, "The storage is insufficient.");
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+       _RecordImpl::GetInstance(todo)->SetRecordId(dbIndex);
+
+       calendar_record_h tmpTodoHandle = null;
+       errorCode = calendar_db_get_record(_calendar_todo._uri, dbIndex, &tmpTodoHandle);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+       _CalTodoImpl::GetInstance(todo)->SetRecordHandle(tmpTodoHandle);
+
+       return E_SUCCESS;
+}
+
+result
+_CalendarbookImpl::AddTodo(CalTodo& todo, RecordId calendarId)
+{
+       SysTryReturnResult(NID_SCL, todo.GetRecordId() == INVALID_RECORD_ID, E_INVALID_ARG
+                       , "Invalid argument is used. The specified recordId is not INVALID_RECORD_ID.");
+       SysTryReturnResult(NID_SCL, calendarId != INVALID_RECORD_ID, E_INVALID_ARG
+                       , "Invalid argument is used. calendarId = %d", calendarId);
+       CalendarItemType itemType = GetCalendarItemTypeByCalendarId(calendarId);
+       SysTryReturnResult(NID_SCL, GetLastResult() == E_SUCCESS, E_OBJ_NOT_FOUND, "The specified calendarId is not found.");
+       SysTryReturnResult(NID_SCL, (itemType == CALENDAR_ITEM_TYPE_TODO_ONLY || itemType == CALENDAR_ITEM_TYPE_EVENT_AND_TODO)
+                       , E_INVALID_ARG, "Invalid argument is used. The calendar is created for CALENDAR_ITEM_TYPE_EVENT_ONLY");
+
+       calendar_record_h todoHandle = _CalTodoImpl::GetInstance(todo)->GetRecordHandle();
+
+       int errorCode = calendar_record_set_int(todoHandle, _calendar_todo.calendar_book_id, calendarId);
+
+       int dbIndex = -1;
+       errorCode = calendar_db_insert_record(todoHandle, &dbIndex);
+       SysTryReturnResult(NID_SCL, errorCode != CALENDAR_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, "The storage is insufficient.");
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+       _RecordImpl::GetInstance(todo)->SetRecordId(dbIndex);
+
+       calendar_record_h tmpTodoHandle = null;
+       errorCode = calendar_db_get_record(_calendar_todo._uri, dbIndex, &tmpTodoHandle);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+       _CalTodoImpl::GetInstance(todo)->SetRecordHandle(tmpTodoHandle);
+
+       return E_SUCCESS;
+}
+
+result
+_CalendarbookImpl::AddCalendar(Calendar& calendar)
+{
+       SysTryReturnResult(NID_SCL, calendar.GetRecordId() == INVALID_RECORD_ID, E_INVALID_ARG
+                       , "Invalid argument is used. The specified recordId is not INVALID_RECORD_ID.");
+
+       calendar_record_h calendarHandle = _CalendarImpl::GetInstance(calendar)->GetRecordHandle();
+
+       int dbIndex = -1;
+       int errorCode = calendar_db_insert_record(calendarHandle, &dbIndex);
+       SysTryReturnResult(NID_SCL, errorCode != CALENDAR_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, "The storage is insufficient.");
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+       _RecordImpl::GetInstance(calendar)->SetRecordId(dbIndex);
+
+       calendar_record_h tmpCalendarHandle = null;
+       errorCode = calendar_db_get_record(_calendar_book._uri, dbIndex, &tmpCalendarHandle);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+       _CalendarImpl::GetInstance(calendar)->SetRecordHandle(tmpCalendarHandle);
+
+       return E_SUCCESS;
+}
+
+result
+_CalendarbookImpl::AddCalendar(Calendar& calendar, AccountId accountId)
+{
+       SysTryReturnResult(NID_SCL, calendar.GetRecordId() == INVALID_RECORD_ID, E_INVALID_ARG
+                       , "Invalid argument is used. The specified recordId is not INVALID_RECORD_ID.");
+       SysTryReturnResult(NID_SCL, accountId >= 0, E_INVALID_ARG, "Invalid argument is used.");
+
+       calendar_record_h calendarHandle = _CalendarImpl::GetInstance(calendar)->GetRecordHandle();
+
+       int errorCode = calendar_record_set_int(calendarHandle, _calendar_book.account_id, accountId);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+
+       int dbIndex = -1;
+       errorCode = calendar_db_insert_record(calendarHandle, &dbIndex);
+       SysTryReturnResult(NID_SCL, errorCode != CALENDAR_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, "The storage is insufficient.");
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+       _RecordImpl::GetInstance(calendar)->SetRecordId(dbIndex);
+
+       calendar_record_h tmpCalendarHandle = null;
+       errorCode = calendar_db_get_record(_calendar_book._uri, dbIndex, &tmpCalendarHandle);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+       _CalendarImpl::GetInstance(calendar)->SetRecordHandle(tmpCalendarHandle);
+
+       return E_SUCCESS;
+}
+
+result
+_CalendarbookImpl::RemoveEvent(CalEvent& event)
+{
+       SysTryReturnResult(NID_SCL, event.GetRecordId() != INVALID_RECORD_ID, E_INVALID_ARG
+                       , "Invalid argument is used. The specified eventId is INVALID_RECORD_ID.");
+
+       calendar_record_h eventHandle = _CalEventImpl::GetInstance(event)->GetRecordHandle();
+
+       int baseEventId = _INVALID_EVENT_DB_ID;
+       int errorCode = calendar_record_get_int(eventHandle, _calendar_event.original_event_id, &baseEventId);
+       SysTryReturnResult(NID_SCL, baseEventId == _INVALID_EVENT_DB_ID, E_INVALID_OPERATION
+                       , "Invalid argument is used. The event has the base event id.");
+
+       errorCode = calendar_db_delete_record(_calendar_event._uri, event.GetRecordId());
+       SysTryReturnResult(NID_SCL, errorCode != CALENDAR_ERROR_DB_RECORD_NOT_FOUND, E_OBJ_NOT_FOUND, "The specified record is not found.");
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+
+       _RecordImpl* pRecordImpl = _RecordImpl::GetInstance(event);
+       pRecordImpl->SetRecordId(INVALID_RECORD_ID);
+
+       return E_SUCCESS;
+}
+
+result
+_CalendarbookImpl::RemoveEvent(RecordId eventId)
+{
+       SysTryReturnResult(NID_SCL, eventId != INVALID_RECORD_ID, E_INVALID_ARG
+                       , "Invalid argument is used. The specified eventId is INVALID_RECORD_ID.");
+
+       calendar_record_h eventHandle = null;
+
+       int errorCode = calendar_db_get_record(_calendar_event._uri, eventId, &eventHandle);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OBJ_NOT_FOUND, "The specified record is not found.");
+
+       int baseEventId = _INVALID_EVENT_DB_ID;
+       calendar_record_get_int(eventHandle, _calendar_event.original_event_id, &baseEventId);
+
+       calendar_record_destroy(eventHandle, true);
+
+       SysTryReturnResult(NID_SCL, baseEventId == _INVALID_EVENT_DB_ID, E_INVALID_OPERATION
+                       , "Invalid argument is used. The event of eventId has the base event id.");
+
+       errorCode = calendar_db_delete_record(_calendar_event._uri, eventId);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+
+       return E_SUCCESS;
+}
+
+result
+_CalendarbookImpl::RemoveTodo(CalTodo& todo)
+{
+       _RecordImpl* pRecordImpl = _RecordImpl::GetInstance(todo);
+
+       result r = RemoveTodo(todo.GetRecordId());
+       SysTryReturnResult(NID_SCL, !IsFailed(r), r, "Failed to remove the todo.");
+       pRecordImpl->SetRecordId(INVALID_RECORD_ID);
+
+       return r;
+}
+
+result
+_CalendarbookImpl::RemoveTodo(RecordId todoId)
+{
+       SysTryReturnResult(NID_SCL, todoId != INVALID_RECORD_ID, E_INVALID_ARG
+                       , "Invalid argument is used. The specified todoId is INVALID_RECORD_ID.");
+
+       int errorCode = calendar_db_delete_record(_calendar_todo._uri, todoId);
+       SysTryReturnResult(NID_SCL, errorCode != CALENDAR_ERROR_DB_RECORD_NOT_FOUND, E_OBJ_NOT_FOUND, "The specified record is not found.");
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+
+       return E_SUCCESS;
+}
+
+result
+_CalendarbookImpl::RemoveCalendar(RecordId calendarId)
+{
+       SysTryReturnResult(NID_SCL, calendarId != INVALID_RECORD_ID, E_INVALID_ARG
+                       , "The specified calendarId is INVALID_RECORD_ID.");
+       SysTryReturnResult(NID_SCL, calendarId != _DEFAULT_EVENT_CALENDAR_DB_ID
+                       , E_INVALID_ARG, "Invalid argument is used. The calendar represents default calendar.");
+       SysTryReturnResult(NID_SCL, calendarId != _DEFAULT_TODO_CALENDAR_DB_ID
+                       , E_INVALID_ARG, "Invalid argument is used. The calendar represents default calendar.");
+       SysTryReturnResult(NID_SCL, CheckCalendarExistance(calendarId), E_OBJ_NOT_FOUND, "The specified record is not found.");
+
+       int errorCode = calendar_db_delete_record(_calendar_book._uri, calendarId);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+
+       return E_SUCCESS;
+}
+
+result
+_CalendarbookImpl::UpdateEvent(const CalEvent& event)
+{
+       SysTryReturnResult(NID_SCL, event.GetRecordId() != INVALID_RECORD_ID, E_INVALID_ARG
+                       , "Invalid argument is used. The specified recordId is INVALID_RECORD_ID.");
+       SysTryReturnResult(NID_SCL, !event.IsInstance(), E_INVALID_ARG
+                       , "Invalid argument is used. The event is not an entry type instance.");
+
+       calendar_record_h eventHandle = _CalEventImpl::GetInstance(event)->GetRecordHandle();
+
+       int baseEventId = _INVALID_EVENT_DB_ID;
+       int errorCode = calendar_record_get_int(eventHandle, _calendar_event.original_event_id, &baseEventId);
+       SysTryReturnResult(NID_SCL, baseEventId == _INVALID_EVENT_DB_ID, E_INVALID_OPERATION
+                       , "Invalid argument is used. The event has the base event id.");
+
+       SysTryReturnResult(NID_SCL, CheckEventExistance(event.GetRecordId()), E_OBJ_NOT_FOUND, "The specified record is not found.");
+
+       errorCode = calendar_db_update_record(eventHandle);
+       SysTryReturnResult(NID_SCL, errorCode != CALENDAR_ERROR_DB_FAILED, E_SYSTEM, "A system error has been occurred.");
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OBJ_NOT_FOUND, "The specified record is not found.");
+
+       return E_SUCCESS;
+}
+
+result
+_CalendarbookImpl::UpdateTodo(const CalTodo& todo)
+{
+       SysTryReturnResult(NID_SCL, todo.GetRecordId() != INVALID_RECORD_ID, E_INVALID_ARG
+                       , "Invalid argument is used. The specified recordId is INVALID_RECORD_ID.");
+       SysTryReturnResult(NID_SCL, CheckTodoExistance(todo.GetRecordId()), E_OBJ_NOT_FOUND, "The specified record is not found.");
+
+       calendar_record_h todoHandle = _CalTodoImpl::GetInstance(todo)->GetRecordHandle();
+       int errorCode = calendar_db_update_record(todoHandle);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+
+       return E_SUCCESS;
+}
+
+result
+_CalendarbookImpl::UpdateCalendar(const Calendar& calendar)
+{
+       SysTryReturnResult(NID_SCL, calendar.GetRecordId() != INVALID_RECORD_ID, E_INVALID_ARG
+                       , "The specified recordId is INVALID_RECORD_ID.");
+       SysTryReturnResult(NID_SCL, CheckCalendarExistance(calendar.GetRecordId()), E_OBJ_NOT_FOUND, "The specified record is not found.");
+
+       calendar_record_h calendarHandle = _CalendarImpl::GetInstance(calendar)->GetRecordHandle();
+       int errorCode = calendar_db_update_record(calendarHandle);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+
+       return E_SUCCESS;
+}
+
+CalEvent*
+_CalendarbookImpl::GetEventN(RecordId eventId) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_SCL, eventId != INVALID_RECORD_ID, null, E_INVALID_ARG
+                       , "[%s] Invalid argument is used. The specified recordId is INVALID_RECORD_ID.", GetErrorMessage(E_INVALID_ARG));
+
+       std::unique_ptr<CalEvent> pEvent(new (std::nothrow) CalEvent());
+       SysTryReturn(NID_SCL, pEvent != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       calendar_record_h eventHandle = null;
+       int errorCode = calendar_db_get_record(_calendar_event._uri, eventId, &eventHandle);
+       SysTryReturn(NID_SCL, errorCode != CALENDAR_ERROR_DB_FAILED, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OBJ_NOT_FOUND, "[%s] The specified record is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       _CalEventImpl::GetInstance(*pEvent.get())->SetRecordHandle(eventHandle);
+       _RecordImpl::GetInstance(*pEvent.get())->SetRecordId(eventId);
+
+       return pEvent.release();
+}
+
+CalTodo*
+_CalendarbookImpl::GetTodoN(RecordId todoId) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_SCL, todoId != INVALID_RECORD_ID, null, E_INVALID_ARG
+                       , "[%s] Invalid argument is used. The specified recordId is INVALID_RECORD_ID.", GetErrorMessage(E_INVALID_ARG));
+
+       std::unique_ptr<CalTodo> pTodo(new (std::nothrow) CalTodo());
+       SysTryReturn(NID_SCL, pTodo != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       calendar_record_h todoHandle = null;
+       int errorCode = calendar_db_get_record(_calendar_todo._uri, todoId, &todoHandle);
+       SysTryReturn(NID_SCL, errorCode != CALENDAR_ERROR_DB_FAILED, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OBJ_NOT_FOUND, "[%s] The specified record is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       _CalTodoImpl::GetInstance(*pTodo.get())->SetRecordHandle(todoHandle);
+       _RecordImpl::GetInstance(*pTodo.get())->SetRecordId(todoId);
+
+       return pTodo.release();
+}
+
+Calendar*
+_CalendarbookImpl::GetCalendarN(RecordId calendarId) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_SCL, calendarId != INVALID_RECORD_ID, null, E_INVALID_ARG
+                       , "[%s] Invalid argument is used. The specified recordId is INVALID_RECORD_ID.", GetErrorMessage(E_INVALID_ARG));
+
+       std::unique_ptr<Calendar> pCalendar(new (std::nothrow) Calendar(CALENDAR_ITEM_TYPE_EVENT_AND_TODO));
+       SysTryReturn(NID_SCL, pCalendar != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       calendar_record_h calendarHandle = null;
+       int errorCode = calendar_db_get_record(_calendar_book._uri, calendarId, &calendarHandle);
+       SysTryReturn(NID_SCL, errorCode != CALENDAR_ERROR_DB_FAILED, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OBJ_NOT_FOUND, "[%s] The specified record is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+       _CalendarImpl::GetInstance(*pCalendar.get())->SetRecordHandle(calendarHandle);
+       _RecordImpl::GetInstance(*pCalendar.get())->SetRecordId(calendarId);
+
+       return pCalendar.release();
+}
+
+IList*
+_CalendarbookImpl::GetTodosN(const DateTime& start, const DateTime& end, int pageNo, int countPerPage, unsigned long status,
+                                                        unsigned long priority) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_SCL, pageNo > 0 && countPerPage > 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. The pageNo or countPerPage is less than 1.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, start <= end, null, E_INVALID_ARG, "[%s] Invalid argument is used. The start time is later than the end date.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _CalendarbookUtil::CheckValidDateTime(start), null, E_INVALID_ARG, "[%s] Invalid argument is used. start = %S", GetErrorMessage(E_INVALID_ARG), start.ToString().GetPointer());
+       SysTryReturn(NID_SCL, _CalendarbookUtil::CheckValidDateTime(end), null, E_INVALID_ARG, "[%s] Invalid argument is used. end = %S", GetErrorMessage(E_INVALID_ARG), end.ToString().GetPointer());
+       SysTryReturn(NID_SCL, CheckValidTodoStatus(status), null, E_INVALID_ARG, "[%s] Invalid argument is used. status = %ld", GetErrorMessage(E_INVALID_ARG), status);
+       SysTryReturn(NID_SCL, CheckValidTodoPriority(priority), null, E_INVALID_ARG, "[%s] Invalid argument is used. priority = %ld", GetErrorMessage(E_INVALID_ARG), priority);
+
+       DateTime tmpStart;
+       DateTime tmpEnd;
+       tmpStart.SetValue(start.GetYear(), start.GetMonth(), start.GetDay());
+       tmpEnd.SetValue(end.GetYear(), end.GetMonth(), end.GetDay(), 23, 59, 59);
+       calendar_time_s convertedStartTime;
+       calendar_time_s convertedEndTime;
+       _CalendarbookUtil::ConvertDateTimeToCalTime(tmpStart, convertedStartTime);
+       _CalendarbookUtil::ConvertDateTimeToCalTime(tmpEnd, convertedEndTime);
+
+       calendar_filter_h mainFilterHandle = null;
+       int errorCode = calendar_filter_create(_calendar_todo._uri, &mainFilterHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       _CalendarFilter mainFilter(mainFilterHandle);
+
+       // Condition : Due time of the item >= start time of filter
+       errorCode = calendar_filter_add_caltime(mainFilterHandle, _calendar_todo.due_time, CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, convertedStartTime);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       // Condition : Due time of the item <= end time of filter
+       errorCode = calendar_filter_add_operator(mainFilterHandle, CALENDAR_FILTER_OPERATOR_AND);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       errorCode = calendar_filter_add_caltime(mainFilterHandle, _calendar_todo.due_time, CALENDAR_MATCH_LESS_THAN_OR_EQUAL, convertedEndTime);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       // Condition : status
+       calendar_filter_h subFilterHandle = null;
+       errorCode = calendar_filter_create(_calendar_todo._uri, &subFilterHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       _CalendarFilter subFilter(subFilterHandle);
+       subFilterHandle = null;
+
+       int tmpStatus = TODO_STATUS_NONE;
+       bool alreadyAdded = false;
+       for (int i = 0; i < _NUMBER_OF_TODO_STATUS; i++)
+       {
+               if (status & tmpStatus)
+               {
+                       if (alreadyAdded)
+                       {
+                               errorCode = calendar_filter_add_operator(subFilter.GetHandle(), CALENDAR_FILTER_OPERATOR_OR);
+                               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+                       }
+
+                       errorCode = calendar_filter_add_int(subFilter.GetHandle(), _calendar_todo.todo_status, CALENDAR_MATCH_EQUAL, ConvertTodoStatusToCalendarTodoStatus(tmpStatus));
+                       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       alreadyAdded = true;
+               }
+
+               tmpStatus <<= 1;
+       }
+
+       errorCode = calendar_filter_add_operator(mainFilterHandle, CALENDAR_FILTER_OPERATOR_AND);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       errorCode = calendar_filter_add_filter(mainFilterHandle, subFilter.GetHandle());
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       // Condition : priority
+       errorCode = calendar_filter_create(_calendar_todo._uri, &subFilterHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       subFilter.ResetHandle(subFilterHandle);
+       subFilterHandle = null;
+
+       int tmpPriority = TODO_PRIORITY_LOW;
+       alreadyAdded = false;
+       for (int i = 0; i < _NUMBER_OF_TODO_PRIORITY; i++)
+       {
+               if (priority & tmpPriority)
+               {
+                       if (alreadyAdded)
+                       {
+                               errorCode = calendar_filter_add_operator(subFilter.GetHandle(), CALENDAR_FILTER_OPERATOR_OR);
+                               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+                       }
+
+                       errorCode = calendar_filter_add_int(subFilter.GetHandle(), _calendar_todo.priority, CALENDAR_MATCH_EQUAL, ConvertTodoPriorityToCalendarTodoPriority(tmpPriority));
+                       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       alreadyAdded = true;
+               }
+               tmpPriority <<= 1;
+       }
+
+       errorCode = calendar_filter_add_operator(mainFilterHandle, CALENDAR_FILTER_OPERATOR_AND);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       errorCode = calendar_filter_add_filter(mainFilterHandle, subFilter.GetHandle());
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       // Create query
+       calendar_query_h queryHandle = null;
+       errorCode = calendar_query_create(_calendar_todo._uri, &queryHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       _CalendarQuery query(queryHandle);
+
+       calendar_query_set_sort(queryHandle, _calendar_todo.due_time, true);
+       calendar_query_set_filter(queryHandle, mainFilterHandle);
+
+       calendar_list_h calendarListHandle = null;
+       errorCode = calendar_db_get_records_with_query(queryHandle, (pageNo - 1) * countPerPage, countPerPage, &calendarListHandle);
+       SysTryReturn(NID_SCL, errorCode != CALENDAR_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       _CalendarList calendarList(calendarListHandle);
+
+       // TODO:- Should we use SingleObjectDeleter instead ?
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       result r = pList->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       int count = 0;
+       calendar_list_get_count(calendarListHandle, &count);
+
+       for (int i = 0; i < count; i++)
+       {
+               std::unique_ptr<CalTodo> pTmpTodo(new (std::nothrow) CalTodo());
+               SysTryReturn(NID_SCL, pTmpTodo != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pList->Add(pTmpTodo.get());
+               SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               pTmpTodo.release();
+       }
+
+       calendar_list_first(calendarListHandle);
+       std::unique_ptr<IEnumerator> pEnum(pList->GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               CalTodo* pTmpTodo = static_cast<CalTodo*>(pEnum->GetCurrent());
+
+               calendar_record_h tmpRecordHandle = null;
+               errorCode = calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle);
+               SysTryReturn(NID_SCL, errorCode != CALENDAR_ERROR_DB_FAILED, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+               _CalTodoImpl::GetInstance(*pTmpTodo)->SetRecordHandle(tmpRecordHandle);
+
+               int dbIndex = -1;
+               errorCode = calendar_record_get_int(tmpRecordHandle, _calendar_todo.id, &dbIndex);
+               SysTryReturn(NID_SCL, errorCode != CALENDAR_ERROR_DB_FAILED, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+               _RecordImpl::GetInstance(*pTmpTodo)->SetRecordId(dbIndex);
+
+               calendar_list_next(calendarListHandle);
+       }
+
+       calendar_list_destroy(calendarList.ReleaseHandle(), false);
+
+       return pList.release();
+}
+
+int
+_CalendarbookImpl::GetTodoCount(const DateTime& start, const DateTime& end, unsigned long status, unsigned long priority) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_SCL, start <= end, _INVALID_COUNT
+                       , E_INVALID_ARG, "[%s] Invalid argument is used. The start time is later than the end date.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _CalendarbookUtil::CheckValidDateTime(start), _INVALID_COUNT
+                       , E_INVALID_ARG, "[%s] Invalid argument is used. start = %S", GetErrorMessage(E_INVALID_ARG), start.ToString().GetPointer());
+       SysTryReturn(NID_SCL, _CalendarbookUtil::CheckValidDateTime(end), _INVALID_COUNT
+                       , E_INVALID_ARG, "[%s] Invalid argument is used. end = %S", GetErrorMessage(E_INVALID_ARG), end.ToString().GetPointer());
+       SysTryReturn(NID_SCL, CheckValidTodoStatus(status), _INVALID_COUNT
+                       , E_INVALID_ARG, "[%s] Invalid argument is used. status = %ld", GetErrorMessage(E_INVALID_ARG), status);
+       SysTryReturn(NID_SCL, CheckValidTodoPriority(priority), _INVALID_COUNT
+                       , E_INVALID_ARG, "[%s] Invalid argument is used. priority = %ld", GetErrorMessage(E_INVALID_ARG), priority);
+
+       DateTime tmpStart;
+       DateTime tmpEnd;
+       tmpStart.SetValue(start.GetYear(), start.GetMonth(), start.GetDay());
+       tmpEnd.SetValue(end.GetYear(), end.GetMonth(), end.GetDay(), 23, 59, 59);
+       calendar_time_s convertedStartTime;
+       calendar_time_s convertedEndTime;
+       _CalendarbookUtil::ConvertDateTimeToCalTime(tmpStart, convertedStartTime);
+       _CalendarbookUtil::ConvertDateTimeToCalTime(tmpEnd, convertedEndTime);
+
+       calendar_filter_h mainFilterHandle = null;
+       int errorCode = calendar_filter_create(_calendar_todo._uri, &mainFilterHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, _INVALID_COUNT, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       _CalendarFilter mainFilter(mainFilterHandle);
+
+       // Condition : Due time of the item => start time of filter
+       errorCode = calendar_filter_add_caltime(mainFilterHandle, _calendar_todo.due_time, CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, convertedStartTime);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       // Condition : Due time of the item <= end time of filter
+       errorCode = calendar_filter_add_operator(mainFilterHandle, CALENDAR_FILTER_OPERATOR_AND);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       errorCode = calendar_filter_add_caltime(mainFilterHandle, _calendar_todo.due_time, CALENDAR_MATCH_LESS_THAN_OR_EQUAL, convertedEndTime);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       // Condition : status
+       calendar_filter_h subFilterHandle = null;
+       errorCode = calendar_filter_create(_calendar_todo._uri, &subFilterHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, _INVALID_COUNT, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       _CalendarFilter subFilter(subFilterHandle);
+       subFilterHandle = null;
+
+       int tmpStatus = TODO_STATUS_NONE;
+       bool alreadyAdded = false;
+       for (int i = 0; i < _NUMBER_OF_TODO_STATUS; i++)
+       {
+               if (status & tmpStatus)
+               {
+                       if (alreadyAdded)
+                       {
+                               errorCode = calendar_filter_add_operator(subFilter.GetHandle(), CALENDAR_FILTER_OPERATOR_OR);
+                               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+                       }
+
+                       errorCode = calendar_filter_add_int(subFilter.GetHandle(), _calendar_todo.todo_status, CALENDAR_MATCH_EQUAL, ConvertTodoStatusToCalendarTodoStatus(tmpStatus));
+                       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       alreadyAdded = true;
+               }
+
+               tmpStatus <<= 1;
+       }
+       errorCode = calendar_filter_add_operator(mainFilterHandle, CALENDAR_FILTER_OPERATOR_AND);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       errorCode = calendar_filter_add_filter(mainFilterHandle, subFilter.GetHandle());
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       // Condition : priority
+       errorCode = calendar_filter_create(_calendar_todo._uri, &subFilterHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, _INVALID_COUNT, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       subFilter.ResetHandle(subFilterHandle);
+       subFilterHandle = null;
+
+       int tmpPriority = TODO_PRIORITY_LOW;
+       alreadyAdded = false;
+       for (int i = 0; i < _NUMBER_OF_TODO_PRIORITY; i++)
+       {
+               if (priority & tmpPriority)
+               {
+                       if (alreadyAdded)
+                       {
+                               errorCode = calendar_filter_add_operator(subFilter.GetHandle(), CALENDAR_FILTER_OPERATOR_OR);
+                               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+                       }
+
+                       errorCode = calendar_filter_add_int(subFilter.GetHandle(), _calendar_todo.priority, CALENDAR_MATCH_EQUAL, ConvertTodoPriorityToCalendarTodoPriority(tmpPriority));
+                       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       alreadyAdded = true;
+               }
+               tmpPriority <<= 1;
+       }
+
+       errorCode = calendar_filter_add_operator(mainFilterHandle, CALENDAR_FILTER_OPERATOR_AND);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       errorCode = calendar_filter_add_filter(mainFilterHandle, subFilter.GetHandle());
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       // Create query
+       calendar_query_h queryHandle = null;
+       errorCode = calendar_query_create(_calendar_todo._uri, &queryHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, _INVALID_COUNT, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       _CalendarQuery query(queryHandle);
+
+       calendar_query_set_filter(queryHandle, mainFilterHandle);
+
+       int count = _INVALID_COUNT;
+
+       errorCode = calendar_db_get_count_with_query(queryHandle, &count);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return count;
+}
+
+IList*
+_CalendarbookImpl::GetEventInstancesN(const DateTime& start, const DateTime& end,
+                                                                         const Tizen::Locales::TimeZone& timeZone, int pageNo, int countPerPage,
+                                                                         unsigned long category) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_SCL, pageNo > 0 && countPerPage > 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. The pageNo or countPerPage is less than 1.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, start <= end, null, E_INVALID_ARG, "[%s] Invalid argument is used. The start time is later than the end date.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _CalendarbookUtil::CheckValidDateTime(start), null, E_INVALID_ARG, "[%s] Invalid argument is used. start = %S", GetErrorMessage(E_INVALID_ARG), start.ToString().GetPointer());
+       SysTryReturn(NID_SCL, _CalendarbookUtil::CheckValidDateTime(end), null, E_INVALID_ARG, "[%s] Invalid argument is used. end = %S", GetErrorMessage(E_INVALID_ARG), end.ToString().GetPointer());
+       SysTryReturn(NID_SCL, (category & EVENT_CATEGORY_APPOINTMENT) || (category & EVENT_CATEGORY_ANNIVERSARY), null, E_INVALID_ARG, "[%s] Invalid argument is used. category = %ld", GetErrorMessage(E_INVALID_ARG), category);
+
+       std::unique_ptr<IList, AllElementsDeleter> pList(GetEventInstancesCommonN(start, end, timeZone, pageNo, countPerPage, category));
+       result r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pList.release();
+}
+
+result
+_CalendarbookImpl::GetEventInstances(const DateTime& start, const DateTime& end,
+                                                                        const Tizen::Locales::TimeZone& timeZone, int pageNo, int countPerPage, unsigned long category,
+                                                                        RequestId& reqId, const IRecordListener& listener) const
+{
+       __requestId++;
+       reqId = __requestId;
+
+       SysTryReturn(NID_SCL, pageNo > 0 && countPerPage > 0, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The pageNo or countPerPage is less than 1.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, start <= end, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The start time is later than the end date.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _CalendarbookUtil::CheckValidDateTime(start), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. start = %S", GetErrorMessage(E_INVALID_ARG), start.ToString().GetPointer());
+       SysTryReturn(NID_SCL, _CalendarbookUtil::CheckValidDateTime(end), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. end = %S", GetErrorMessage(E_INVALID_ARG), end.ToString().GetPointer());
+       SysTryReturn(NID_SCL, (category & EVENT_CATEGORY_APPOINTMENT) || (category & EVENT_CATEGORY_ANNIVERSARY), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. category = %ld", GetErrorMessage(E_INVALID_ARG), category);
+
+       std::unique_ptr<_CalendarbookRecordRetrivalEvent> pEvent(new (std::nothrow) _CalendarbookRecordRetrivalEvent());
+       SysTryReturnResult(NID_SCL, pEvent != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       result r = pEvent->Construct();
+       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred.");
+       r = pEvent->AddListener(listener);
+       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred.");
+
+       if (__pRecordRetrivalThread != null)
+       {
+               __pRecordRetrivalThread->Join();
+               delete __pRecordRetrivalThread;
+               __pRecordRetrivalThread = null;
+       }
+
+       std::unique_ptr<_CalendarbookRecordRetrivalThread> pRecordRetrivalThread(new (std::nothrow) _CalendarbookRecordRetrivalThread());
+       SysTryReturnResult(NID_SCL, pRecordRetrivalThread != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       r = pRecordRetrivalThread->Construct(__requestId, *pEvent.release(), start, end, timeZone, pageNo, countPerPage, category);
+       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred.");
+
+       r = pRecordRetrivalThread->Start();
+       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred.");
+
+       __pRecordRetrivalThread = pRecordRetrivalThread.release();
+
+       return E_SUCCESS;
+}
+
+IList*
+_CalendarbookImpl::GetAllEventsN(void) const
+{
+       calendar_list_h calendarListHandle = null;
+       int errorCode = calendar_db_get_all_records(_calendar_event._uri, 0, 0, &calendarListHandle);
+       SysTryReturn(NID_SCL, errorCode != CALENDAR_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       _CalendarList calendarList(calendarListHandle);
+
+       result r = E_SUCCESS;
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       r = pList->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       int count = 0;
+       calendar_list_get_count(calendarListHandle, &count);
+
+       for (int i = 0; i < count; i++)
+       {
+               std::unique_ptr<CalEvent> pTmpEvent(new (std::nothrow) CalEvent());
+               SysTryReturn(NID_SCL, pTmpEvent != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pList->Add(pTmpEvent.get());
+               SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               pTmpEvent.release();
+       }
+
+       calendar_list_first(calendarListHandle);
+       std::unique_ptr<IEnumerator> pEnum(pList->GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               CalEvent* pTmpEvent = static_cast<CalEvent*>(pEnum->GetCurrent());
+
+               calendar_record_h tmpRecordHandle = null;
+               errorCode = calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+               _CalEventImpl::GetInstance(*pTmpEvent)->SetRecordHandle(tmpRecordHandle);
+
+               int dbIndex = -1;
+               calendar_record_get_int(tmpRecordHandle, _calendar_event.id, &dbIndex);
+               _RecordImpl::GetInstance(*pTmpEvent)->SetRecordId(dbIndex);
+
+               calendar_list_next(calendarListHandle);
+       }
+
+       calendar_list_destroy(calendarList.ReleaseHandle(), false);
+
+       return pList.release();
+}
+
+IList*
+_CalendarbookImpl::GetAllTodosN(void) const
+{
+       calendar_list_h calendarListHandle = null;
+       int errorCode = calendar_db_get_all_records(_calendar_todo._uri, 0, 0, &calendarListHandle);
+       SysTryReturn(NID_SCL, errorCode != CALENDAR_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       _CalendarList calendarList(calendarListHandle);
+
+       result r = E_SUCCESS;
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       r = pList->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       int count = 0;
+       calendar_list_get_count(calendarListHandle, &count);
+
+       for (int i = 0; i < count; i++)
+       {
+               std::unique_ptr<CalTodo> pTmpTodo(new (std::nothrow) CalTodo());
+               SysTryReturn(NID_SCL, pTmpTodo != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pList->Add(pTmpTodo.get());
+               SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               pTmpTodo.release();
+       }
+
+       calendar_list_first(calendarListHandle);
+       std::unique_ptr<IEnumerator> pEnum(pList->GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               CalTodo* pTmpTodo = static_cast<CalTodo*>(pEnum->GetCurrent());
+
+               calendar_record_h tmpRecordHandle = null;
+               errorCode = calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+               _CalTodoImpl::GetInstance(*pTmpTodo)->SetRecordHandle(tmpRecordHandle);
+
+               int dbIndex = -1;
+               calendar_record_get_int(tmpRecordHandle, _calendar_todo.id, &dbIndex);
+               _RecordImpl::GetInstance(*pTmpTodo)->SetRecordId(dbIndex);
+
+               calendar_list_next(calendarListHandle);
+       }
+
+       calendar_list_destroy(calendarList.ReleaseHandle(), false);
+
+       return pList.release();
+}
+
+IList*
+_CalendarbookImpl::GetAllCalendarsN(void) const
+{
+       calendar_list_h calendarListHandle = null;
+       int errorCode = calendar_db_get_all_records(_calendar_book._uri, 0, 0, &calendarListHandle);
+       SysTryReturn(NID_SCL, errorCode != CALENDAR_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       _CalendarList calendarList(calendarListHandle);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       result r = pList->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       int count = 0;
+       calendar_list_get_count(calendarListHandle, &count);
+
+       for (int i = 0; i < count; i++)
+       {
+               std::unique_ptr<Calendar> pTmpCalendar(_CalendarImpl::CreateDefaultInstanceN());
+               SysTryReturn(NID_SCL, pTmpCalendar != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pList->Add(pTmpCalendar.get());
+               SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               pTmpCalendar.release();
+       }
+
+       calendar_list_first(calendarListHandle);
+       std::unique_ptr<IEnumerator> pEnum(pList->GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               Calendar* pTmpCalendar = static_cast<Calendar*>(pEnum->GetCurrent());
+
+               calendar_record_h tmpRecordHandle = null;
+               errorCode = calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+               _CalendarImpl::GetInstance(*pTmpCalendar)->SetRecordHandle(tmpRecordHandle);
+
+               int dbIndex = -1;
+               calendar_record_get_int(tmpRecordHandle, _calendar_book.id, &dbIndex);
+               _RecordImpl::GetInstance(*pTmpCalendar)->SetRecordId(dbIndex);
+
+               calendar_list_next(calendarListHandle);
+       }
+
+       calendar_list_destroy(calendarList.ReleaseHandle(), false);
+
+       return pList.release();
+}
+
+IList*
+_CalendarbookImpl::GetChangedEventsAfterN(int version, int& latestVersion) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_SCL, version >= 0, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. version = %d", version);
+
+       calendar_list_h calendarListHandle = null;
+       int tmpLatestVersion = 0;
+       int errorCode = calendar_db_get_changes_by_version(_calendar_event._uri, CALENDAR_BOOK_FILTER_ALL, version
+                       , &calendarListHandle, &tmpLatestVersion);
+       SysTryReturn(NID_SCL, errorCode != CALENDAR_ERROR_OUT_OF_MEMORY, null
+                       , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       result r = pList->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       int count = 0;
+       calendar_list_get_count(calendarListHandle, &count);
+
+       calendar_list_first(calendarListHandle);
+       for (int i = 0; i < count; i++)
+       {
+               calendar_record_h tmpRecordHandle = null;
+               errorCode = calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+               std::unique_ptr<CalEventChangeInfo> pChangedInfo(_CalendarbookImpl::ConvertModifiedEventToCalEventChangeInfoN(tmpRecordHandle));
+               SysTryReturn(NID_SCL, pChangedInfo != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pList->Add(pChangedInfo.get());
+               SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               pChangedInfo.release();
+
+               calendar_list_next(calendarListHandle);
+       }
+
+       latestVersion = tmpLatestVersion;
+
+       return pList.release();
+}
+
+IList*
+_CalendarbookImpl::GetChangedTodosAfterN(int version, int& latestVersion) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_SCL, version >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. version = %d", GetErrorMessage(E_INVALID_ARG), version);
+
+       calendar_list_h calendarListHandle = null;
+       int tmpLatestVersion = 0;
+       int errorCode = calendar_db_get_changes_by_version(_calendar_todo._uri, CALENDAR_BOOK_FILTER_ALL, version
+                       , &calendarListHandle, &tmpLatestVersion);
+       SysTryReturn(NID_SCL, errorCode != CALENDAR_ERROR_OUT_OF_MEMORY, null
+                       , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       _CalendarList calendarList(calendarListHandle);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       result r = pList->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       int count = 0;
+       calendar_list_get_count(calendarListHandle, &count);
+
+       calendar_list_first(calendarListHandle);
+       for (int i = 0; i < count; i++)
+       {
+               calendar_record_h tmpRecordHandle = null;
+               errorCode = calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+               std::unique_ptr<CalTodoChangeInfo> pChangedInfo(_CalendarbookImpl::ConvertModifiedTodoToCalTodoChangeInfoN(tmpRecordHandle));
+               SysTryReturn(NID_SCL, pChangedInfo != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pList->Add(pChangedInfo.get());
+               SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               pChangedInfo.release();
+
+               calendar_list_next(calendarListHandle);
+       }
+
+       latestVersion = tmpLatestVersion;
+
+       return pList.release();
+}
+
+result
+_CalendarbookImpl::RemoveEventInstance(const CalEventInstance& eventInstance)
+{
+       calendar_record_h eventHandle = null;
+
+       // Get event handle from DB
+       int errorCode = calendar_db_get_record(_calendar_event._uri, eventInstance.GetOriginalEventId(), &eventHandle);
+       SysTryReturnResult(NID_SCL, errorCode != CALENDAR_ERROR_DB_FAILED, E_SYSTEM, "A system error has been occurred.");
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OBJ_NOT_FOUND, "The specified record is not found.");
+       _CalendarRecord eventRecord(eventHandle);
+
+       int baseEventId = _INVALID_EVENT_DB_ID;
+       calendar_record_get_int(eventHandle, _calendar_event.original_event_id, &baseEventId);
+
+       if (baseEventId != _INVALID_EVENT_DB_ID)
+       {
+               errorCode = calendar_db_delete_record(_calendar_event._uri, eventInstance.GetOriginalEventId());
+               SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+       }
+       else
+       {
+               char* pExdate = null;
+
+               // Append exdate
+               calendar_record_get_str_p(eventHandle, _calendar_event.exdate, &pExdate);
+
+               String exdate;
+               if (pExdate != null && strlen(pExdate) > 0)
+               {
+                       exdate.Append(pExdate);
+                       exdate.Append(_RECURRENCE_DELIMITER);
+               }
+
+               exdate.Append(_CalendarbookUtil::ConvertDateTimeToRRuleDateTimeString(eventInstance.GetStartTime(), eventInstance.IsAllDayEvent()));
+
+               std::unique_ptr<char[]> pAppendedExdate(_StringConverter::CopyToCharArrayN(exdate));
+               SysTryReturnResult(NID_SCL, pAppendedExdate != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               errorCode = calendar_record_set_str(eventHandle, _calendar_event.exdate, pAppendedExdate.get());
+               SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               // Update event handle
+               errorCode = calendar_db_update_record(eventHandle);
+               SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_CalendarbookImpl::UpdateEventInstance(const CalEventInstance& eventInstance, CalEvent& event)
+{
+       SysTryReturnResult(NID_SCL, event.GetRecordId() != INVALID_RECORD_ID, E_INVALID_ARG
+                       , "Invalid argument is used. The event's recordId is INVALID_RECORD_ID.");
+       SysTryReturnResult(NID_SCL, eventInstance.GetOriginalEventId() == event.GetRecordId(), E_INVALID_ARG
+                       , "[%s] Invalid argument is used. The event's recordId is not equal to eventInstance's original event ID.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturnResult(NID_SCL, CheckEventExistance(event.GetRecordId()), E_OBJ_NOT_FOUND, "The specified event is not found.");
+
+       calendar_record_h eventHandle = null;
+       int errorCode = calendar_record_clone(_CalEventImpl::GetInstance(event)->GetRecordHandle(), &eventHandle);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       _CalendarRecord eventRecord(eventHandle);
+
+       int baseEventId = _INVALID_EVENT_DB_ID;
+       calendar_record_get_int(eventHandle, _calendar_event.original_event_id, &baseEventId);
+
+       calendar_record_h baseEventHandle = null;
+       if (baseEventId == _INVALID_EVENT_DB_ID)
+       {
+               errorCode = calendar_db_get_record(_calendar_event._uri, eventInstance.GetOriginalEventId(), &baseEventHandle);
+       }
+       else
+       {
+               errorCode = calendar_db_get_record(_calendar_event._uri, baseEventId, &baseEventHandle);
+       }
+       SysTryReturn(NID_SCL, errorCode != CALENDAR_ERROR_DB_FAILED, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OBJ_NOT_FOUND, "[%s] The base event is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+       _CalendarRecord baseEventRecord(baseEventHandle);
+
+       int tmpIntValue = 0;
+       calendar_record_get_int(baseEventHandle, _calendar_event.freq, &tmpIntValue);
+       calendar_record_set_int(eventHandle, _calendar_event.freq, tmpIntValue);
+       calendar_record_get_int(baseEventHandle, _calendar_event.range_type, &tmpIntValue);
+       calendar_record_set_int(eventHandle, _calendar_event.range_type, tmpIntValue);
+       calendar_record_get_int(baseEventHandle, _calendar_event.count, &tmpIntValue);
+       calendar_record_set_int(eventHandle, _calendar_event.count, tmpIntValue);
+       calendar_record_get_int(baseEventHandle, _calendar_event.interval, &tmpIntValue);
+       calendar_record_set_int(eventHandle, _calendar_event.interval, tmpIntValue);
+       calendar_record_get_int(baseEventHandle, _calendar_event.wkst, &tmpIntValue);
+       calendar_record_set_int(eventHandle, _calendar_event.wkst, tmpIntValue);
+
+       calendar_time_s tmpTimeValue;
+       calendar_record_get_caltime(baseEventHandle, _calendar_event.until_time, &tmpTimeValue);
+
+       calendar_time_s tmpStartTimeValue;
+       DateTime convertedTime;
+       calendar_record_get_caltime(eventHandle, _calendar_event.start_time, &tmpStartTimeValue);
+
+       if (tmpTimeValue.type != tmpStartTimeValue.type)
+       {
+               if (tmpStartTimeValue.type == CALENDAR_TIME_UTIME)
+               {
+                       convertedTime.SetValue(tmpTimeValue.time.date.year, tmpTimeValue.time.date.month, tmpTimeValue.time.date.mday);
+                       tmpTimeValue.type = CALENDAR_TIME_UTIME;
+                       tmpTimeValue.time.utime = _CalendarbookUtil::ConvertDateTimeToEpochTime(convertedTime);
+               }
+               else
+               {
+                       convertedTime = _CalendarbookUtil::ConvertEpochTimeToDateTime(tmpTimeValue.time.utime);
+                       tmpTimeValue.type = CALENDAR_TIME_LOCALTIME;
+                       tmpTimeValue.time.date.year = convertedTime.GetYear();
+                       tmpTimeValue.time.date.month = convertedTime.GetMonth();
+                       tmpTimeValue.time.date.mday = convertedTime.GetDay();
+               }
+       }
+       calendar_record_set_caltime(eventHandle, _calendar_event.until_time, tmpTimeValue);
+
+       char* tmpStrValue = null;
+       calendar_record_get_str_p(baseEventHandle, _calendar_event.byday, &tmpStrValue);
+       errorCode = calendar_record_set_str(eventHandle, _calendar_event.byday, tmpStrValue);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       calendar_record_get_str_p(baseEventHandle, _calendar_event.bymonthday, &tmpStrValue);
+       errorCode = calendar_record_set_str(eventHandle, _calendar_event.bymonthday, tmpStrValue);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       calendar_record_get_str_p(baseEventHandle, _calendar_event.bymonth, &tmpStrValue);
+       errorCode = calendar_record_set_str(eventHandle, _calendar_event.bymonth, tmpStrValue);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       calendar_record_get_str_p(baseEventHandle, _calendar_event.exdate, &tmpStrValue);
+       errorCode = calendar_record_set_str(eventHandle, _calendar_event.exdate, tmpStrValue);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       if (baseEventId == _INVALID_EVENT_DB_ID)
+       {
+               calendar_record_set_int(eventHandle, _calendar_event.original_event_id, eventInstance.GetOriginalEventId());
+
+               std::unique_ptr<char[]> pConvertedRecurrenceId(_StringConverter::CopyToCharArrayN(_CalendarbookUtil::ConvertDateTimeToRRuleDateTimeString(eventInstance.GetStartTime(), eventInstance.IsAllDayEvent())));
+               errorCode = calendar_record_set_str(eventHandle, _calendar_event.recurrence_id, pConvertedRecurrenceId.get());
+               SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               int dbIndex = -1;
+               errorCode = calendar_db_insert_record(eventHandle, &dbIndex);
+               SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+               _RecordImpl::GetInstance(event)->SetRecordId(dbIndex);
+       }
+       else
+       {
+               errorCode = calendar_db_update_record(eventHandle);
+               SysTryReturnResult(NID_SCL, errorCode != CALENDAR_ERROR_DB_FAILED, E_SYSTEM, "A system error has been occurred.");
+               SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OBJ_NOT_FOUND, "The base event of the event is not found.");
+       }
+
+       calendar_record_h tmpEventHandle = null;
+       errorCode = calendar_db_get_record(_calendar_event._uri, event.GetRecordId(), &tmpEventHandle);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+       _CalEventImpl::GetInstance(event)->SetRecordHandle(tmpEventHandle);
+
+       return E_SUCCESS;
+}
+
+int
+_CalendarbookImpl::GetLatestVersion(void) const
+{
+       ClearLastResult();
+
+       int dbVersion = 0;
+       int errorCode = calendar_db_get_current_version(&dbVersion);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, 0, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return dbVersion;
+}
+
+IList*
+_CalendarbookImpl::SearchN(const CalendarbookFilter& filter, unsigned long propertySortedBy, SortOrder sortOrder, int offset, int maxCount) const
+{
+       CalendarbookFilterType type = _CalendarbookFilterImpl::GetInstance(filter)->GetType();
+       calendar_filter_h filterHandle = _CalendarbookFilterImpl::GetInstance(filter)->GetFilterHandle();
+
+       SysTryReturn(NID_SCL, offset >= 0 && maxCount >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. The specified offset or maxCount is less than 0.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, propertySortedBy == 0 || _CalendarbookFilterImpl::IsValidProperty(type, propertySortedBy), null, E_INVALID_ARG
+                       , "[%s] Invalid argument is used. propertySortedBy = %d", GetErrorMessage(E_INVALID_ARG), propertySortedBy);
+
+       const char* pViewUri = _CalendarbookFilterImpl::GetUriFromType(type);
+
+       // Create query
+       calendar_query_h queryHandle = null;
+       int errorCode = calendar_query_create(pViewUri, &queryHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       _CalendarQuery query(queryHandle);
+
+       if (propertySortedBy != 0 && sortOrder != SORT_ORDER_NONE)
+       {
+               unsigned int viewSortPropertyId = _CalendarbookFilterImpl::GetViewPropertyId(type, propertySortedBy);
+               bool ascending = (sortOrder == SORT_ORDER_ASCENDING) ? true : false;
+
+               calendar_query_set_sort(queryHandle, viewSortPropertyId, ascending);
+       }
+
+       if (filterHandle)
+       {
+               calendar_query_set_filter(queryHandle, filterHandle);
+       }
+
+       calendar_list_h resultListHandle = null;
+       errorCode = calendar_db_get_records_with_query(queryHandle, offset, maxCount, &resultListHandle);
+       SysTryReturn(NID_SCL, errorCode != CALENDAR_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       _CalendarList calendarList(resultListHandle);
+
+       std::unique_ptr<IList, AllElementsDeleter> pList(null);
+
+       switch(type)
+       {
+       case CB_FI_TYPE_EVENT:
+               {
+                       pList.reset(ConvertRecordListN<CalEvent, _CalEventImpl, _calendar_event_property_ids>(resultListHandle, _calendar_event));
+                       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                       calendar_list_destroy(calendarList.ReleaseHandle(), false);
+               }
+               break;
+       case CB_FI_TYPE_TODO:
+               {
+                       pList.reset(ConvertRecordListN<CalTodo, _CalTodoImpl, _calendar_todo_property_ids>(resultListHandle, _calendar_todo));
+                       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                       calendar_list_destroy(calendarList.ReleaseHandle(), false);
+               }
+               break;
+       case CB_FI_TYPE_CALENDAR:
+               {
+                       pList.reset(ConvertRecordListN<Calendar, _CalendarImpl, _calendar_book_property_ids>(resultListHandle, _calendar_book));
+                       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                       calendar_list_destroy(calendarList.ReleaseHandle(), false);
+               }
+               break;
+       case CB_FI_TYPE_ALL_DAY_EVENT_INSTANCE:
+               {
+                       pList.reset(ConvertEventInstanceListN(resultListHandle, true));
+                       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+               }
+               break;
+       case CB_FI_TYPE_NON_ALL_DAY_EVENT_INSTANCE:
+               {
+                       pList.reset(ConvertEventInstanceListN(resultListHandle, false));
+                       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+               }
+               break;
+       default:
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. The type of filter is (%d)", GetErrorMessage(E_INVALID_ARG), type);
+               break;
+       };
+
+       return pList.release();
+}
+
+int
+_CalendarbookImpl::GetMatchedItemCount(const CalendarbookFilter& filter) const
+{
+       CalendarbookFilterType type = _CalendarbookFilterImpl::GetInstance(filter)->GetType();
+       calendar_filter_h filterHandle = _CalendarbookFilterImpl::GetInstance(filter)->GetFilterHandle();
+
+       const char* pViewUri = _CalendarbookFilterImpl::GetUriFromType(type);
+
+       // Create query
+       calendar_query_h queryHandle = null;
+       int errorCode = calendar_query_create(pViewUri, &queryHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       _CalendarQuery query(queryHandle);
+
+       if (filterHandle)
+       {
+               calendar_query_set_filter(queryHandle, filterHandle);
+       }
+
+       int count = _INVALID_COUNT;
+
+       errorCode = calendar_db_get_count_with_query(queryHandle, &count);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return count;
+}
+
+IList*
+_CalendarbookImpl::ParseEventsFromVcalendarN(const String& vCalFilePath)
+{
+       ClearLastResult();
+
+       File vCalFile;
+       result r = vCalFile.Construct(vCalFilePath, L"r");
+       SysTryReturn(NID_SCL, r != E_INVALID_ARG && r != E_ILLEGAL_ACCESS && r != E_FILE_NOT_FOUND && r != E_OUT_OF_MEMORY
+                       , null, r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       r = vCalFile.Seek(FILESEEKPOSITION_END, 0);
+       SysTryReturn(NID_SCL, r != E_ILLEGAL_ACCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       int fileLength = vCalFile.Tell();
+       SysTryReturn(NID_SCL, fileLength > 0, null, E_INVALID_ARG, "[%s] Invalid argument is used.  The vCal file is empty.", GetErrorMessage(E_INVALID_ARG));
+
+       r = vCalFile.Seek(FILESEEKPOSITION_BEGIN, 0);
+       SysTryReturn(NID_SCL, r != E_ILLEGAL_ACCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       std::unique_ptr<ByteBuffer> pBuffer(new (std::nothrow) ByteBuffer());
+       SysTryReturn(NID_SCL, pBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       r = pBuffer->Construct(fileLength);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = vCalFile.Read(*pBuffer);
+       SysTryReturn(NID_SCL, r != E_ILLEGAL_ACCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       _CalendarConnector connector;
+       r = connector.GetResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s]A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       pBuffer->Rewind();
+       calendar_list_h calendarListHandle = null;
+       int errorCode = calendar_vcalendar_parse_to_calendar(reinterpret_cast<char*>(const_cast<byte*>(pBuffer->GetPointer())), &calendarListHandle);
+       SysTryReturn(NID_SCL, errorCode != CALENDAR_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, errorCode != CALENDAR_ERROR_INVALID_PARAMETER, null, E_INVALID_ARG, "[%s] Invalid argument is used.  The vCal file is invalid.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE || errorCode == CALENDAR_ERROR_NO_DATA, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       _CalendarList calendarList(calendarListHandle);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       r = pList->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       int count = 0;
+       calendar_list_get_count(calendarListHandle, &count);
+
+       calendar_list_first(calendarListHandle);
+       for (int i = 0; i < count; i++)
+       {
+               calendar_record_h tmpRecordHandle = null;
+               calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle);
+               calendar_list_next(calendarListHandle);
+
+               char* pUri = null;
+               calendar_record_get_uri_p(tmpRecordHandle, &pUri);
+
+               if (strcmp(pUri, _calendar_event._uri) == 0)
+               {
+                       std::unique_ptr<CalEvent> pTmpEvent(new (std::nothrow) CalEvent());
+                       SysTryReturn(NID_SCL, pTmpEvent != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                       r = pList->Add(pTmpEvent.get());
+                       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                       pTmpEvent.release();
+               }
+               else
+               {
+                       calendar_list_remove(calendarListHandle, tmpRecordHandle);
+                       calendar_record_destroy(tmpRecordHandle, true);
+               }
+       }
+
+       calendar_list_first(calendarListHandle);
+       std::unique_ptr<IEnumerator> pEnum(pList->GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               CalEvent* pTmpEvent = static_cast<CalEvent*>(pEnum->GetCurrent());
+
+               calendar_record_h tmpRecordHandle = null;
+               calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle);
+               _CalEventImpl::GetInstance(*pTmpEvent)->SetRecordHandle(tmpRecordHandle);
+
+               calendar_list_next(calendarListHandle);
+       }
+
+       calendar_list_destroy(calendarList.ReleaseHandle(), false);
+
+       return pList.release();
+}
+
+IList*
+_CalendarbookImpl::ParseTodosFromVcalendarN(const String& vCalFilePath)
+{
+       ClearLastResult();
+
+       File vCalFile;
+       result r = vCalFile.Construct(vCalFilePath, L"r");
+       SysTryReturn(NID_SCL, r != E_INVALID_ARG && r != E_ILLEGAL_ACCESS && r != E_FILE_NOT_FOUND && r != E_OUT_OF_MEMORY
+                       , null, r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       r = vCalFile.Seek(FILESEEKPOSITION_END, 0);
+       SysTryReturn(NID_SCL, r != E_ILLEGAL_ACCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       int fileLength = vCalFile.Tell();
+       SysTryReturn(NID_SCL, fileLength > 0, null, E_INVALID_ARG, "[%s] Invalid argument is used.  The vCal file is empty.", GetErrorMessage(E_INVALID_ARG));
+
+       r = vCalFile.Seek(FILESEEKPOSITION_BEGIN, 0);
+       SysTryReturn(NID_SCL, r != E_ILLEGAL_ACCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       std::unique_ptr<ByteBuffer> pBuffer(new (std::nothrow) ByteBuffer());
+       SysTryReturn(NID_SCL, pBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       r = pBuffer->Construct(fileLength);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = vCalFile.Read(*pBuffer);
+       SysTryReturn(NID_SCL, r != E_ILLEGAL_ACCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       _CalendarConnector connector;
+       r = connector.GetResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       pBuffer->Rewind();
+       calendar_list_h calendarListHandle = null;
+       int errorCode = calendar_vcalendar_parse_to_calendar(reinterpret_cast<char*>(const_cast<byte*>(pBuffer->GetPointer())), &calendarListHandle);
+       SysTryReturn(NID_SCL, errorCode != CALENDAR_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, errorCode != CALENDAR_ERROR_INVALID_PARAMETER, null, E_INVALID_ARG, "[%s] Invalid argument is used.  The vCal file is invalid.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE || errorCode == CALENDAR_ERROR_NO_DATA, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       _CalendarList calendarList(calendarListHandle);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       r = pList->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       int count = 0;
+       calendar_list_get_count(calendarListHandle, &count);
+
+       calendar_list_first(calendarListHandle);
+       for (int i = 0; i < count; i++)
+       {
+               calendar_record_h tmpRecordHandle = null;
+               calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle);
+               calendar_list_next(calendarListHandle);
+
+               char* pUri = null;
+               calendar_record_get_uri_p(tmpRecordHandle, &pUri);
+
+               if (strcmp(pUri, _calendar_todo._uri) == 0)
+               {
+                       std::unique_ptr<CalTodo> pTmpTodo(new (std::nothrow) CalTodo());
+                       SysTryReturn(NID_SCL, pTmpTodo != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       r = pList->Add(pTmpTodo.get());
+                       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+                       pTmpTodo.release();
+               }
+               else
+               {
+                       calendar_list_remove(calendarListHandle, tmpRecordHandle);
+                       calendar_record_destroy(tmpRecordHandle, true);
+               }
+       }
+
+       calendar_list_first(calendarListHandle);
+       std::unique_ptr<IEnumerator> pEnum(pList->GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               CalTodo* pTmpTodo = static_cast<CalTodo*>(pEnum->GetCurrent());
+
+               calendar_record_h tmpRecordHandle = null;
+               calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle);
+               _CalTodoImpl::GetInstance(*pTmpTodo)->SetRecordHandle(tmpRecordHandle);
+
+               calendar_list_next(calendarListHandle);
+       }
+
+       calendar_list_destroy(calendarList.ReleaseHandle(), false);
+
+       return pList.release();
+}
+
+result
+_CalendarbookImpl::ExportEventsToVcalendar(const IList& eventList, const String& vCalFilePath)
+{
+       SysTryReturnResult(NID_SCL, !File::IsFileExist(vCalFilePath), E_FILE_ALREADY_EXIST, "The vCalendar file already exists.");
+       result r = GetLastResult();
+       SysTryReturn(NID_SCL, r != E_INVALID_ARG && r != E_ILLEGAL_ACCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _CalendarConnector connector;
+       r = connector.GetResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       calendar_list_h calendarListHandle = null;
+       int errorCode = calendar_list_create(&calendarListHandle);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       _CalendarList calendarList(calendarListHandle, false);
+
+       std::unique_ptr<IEnumerator> pEnum(eventList.GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               Record* pTmpRecord = static_cast<Record*>(pEnum->GetCurrent());
+               SysTryReturnResult(NID_SCL, pTmpRecord->GetRecordType() == RECORD_TYPE_EVENT, E_INVALID_ARG, "Invalid argument is used. The eventList contains invalid record.");
+
+               CalEvent* pTmpEvent = static_cast<CalEvent*>(pTmpRecord);
+               errorCode = calendar_list_add(calendarListHandle, _CalEventImpl::GetInstance(*pTmpEvent)->GetRecordHandle());
+               SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       }
+
+       char* pVCalBuffer = null;
+       errorCode = calendar_vcalendar_make_from_records(calendarListHandle, &pVCalBuffer);
+       SysTryReturnResult(NID_SCL, errorCode != CALENDAR_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+       std::unique_ptr<char[]> pVCal(pVCalBuffer);
+
+       File vCalFile;
+       r = vCalFile.Construct(vCalFilePath, L"w");
+       SysTryReturn(NID_SCL, r != E_INVALID_ARG && r != E_ILLEGAL_ACCESS && r != E_STORAGE_FULL && r != E_FILE_NOT_FOUND && r != E_OUT_OF_MEMORY
+                       , r, r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       int pVCalBufferLength = strlen(pVCalBuffer);
+       r = vCalFile.Write(static_cast<void*>(pVCalBuffer), pVCalBufferLength);
+       SysTryReturn(NID_SCL, r != E_ILLEGAL_ACCESS && r != E_STORAGE_FULL, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return E_SUCCESS;
+}
+
+result
+_CalendarbookImpl::ExportTodosToVcalendar(const IList& todoList, const String& vCalFilePath)
+{
+       SysTryReturnResult(NID_SCL, !File::IsFileExist(vCalFilePath), E_FILE_ALREADY_EXIST, "The vCalendar file already exists.");
+       result r = GetLastResult();
+       SysTryReturn(NID_SCL, r != E_INVALID_ARG && r != E_ILLEGAL_ACCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _CalendarConnector connector;
+       r = connector.GetResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       calendar_list_h calendarListHandle = null;
+       int errorCode = calendar_list_create(&calendarListHandle);
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       _CalendarList calendarList(calendarListHandle, false);
+
+       std::unique_ptr<IEnumerator> pEnum(todoList.GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               Record* pTmpRecord = static_cast<Record*>(pEnum->GetCurrent());
+               SysTryReturnResult(NID_SCL, pTmpRecord->GetRecordType() == RECORD_TYPE_TODO, E_INVALID_ARG, "Invalid argument is used. The todoList contains invalid record.");
+
+               CalTodo* pTmpTodo = static_cast<CalTodo*>(pTmpRecord);
+               errorCode = calendar_list_add(calendarListHandle, _CalTodoImpl::GetInstance(*pTmpTodo)->GetRecordHandle());
+               SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       }
+
+       char* pVCalBuffer = null;
+       errorCode = calendar_vcalendar_make_from_records(calendarListHandle, &pVCalBuffer);
+       SysTryReturnResult(NID_SCL, errorCode != CALENDAR_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred.");
+       std::unique_ptr<char[]> pVCal(pVCalBuffer);
+
+       File vCalFile;
+       r = vCalFile.Construct(vCalFilePath, L"w");
+       SysTryReturn(NID_SCL, r != E_INVALID_ARG && r != E_ILLEGAL_ACCESS && r != E_STORAGE_FULL && r != E_FILE_NOT_FOUND && r != E_OUT_OF_MEMORY
+                       , r, r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       int pVCalBufferLength = strlen(pVCalBuffer);
+       r = vCalFile.Write(static_cast<void*>(pVCalBuffer), pVCalBufferLength);
+       SysTryReturn(NID_SCL, r != E_ILLEGAL_ACCESS && r != E_STORAGE_FULL, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return E_SUCCESS;
+}
+
+DateTime
+_CalendarbookImpl::GetMaxDateTime(void)
+{
+       DateTime maxDateTime;
+       maxDateTime.SetValue(2100, 12, 31, 23, 59, 59);
+
+       return maxDateTime;
+}
+
+DateTime
+_CalendarbookImpl::GetMinDateTime(void)
+{
+       DateTime minDateTime;
+       minDateTime.SetValue(1900, 1, 1, 0, 0, 0);
+
+       return minDateTime;
+}
+
+IList*
+_CalendarbookImpl::GetEventInstancesCommonN(const DateTime& start, const DateTime& end,
+                                                                        const Tizen::Locales::TimeZone& timeZone, int pageNo, int countPerPage, unsigned long category) const
+{
+       ClearLastResult();
+
+       calendar_time_s convertedStartTime;
+       calendar_time_s convertedEndTime;
+       _CalendarbookUtil::ConvertDateTimeToCalTime(start, convertedStartTime);
+       _CalendarbookUtil::ConvertDateTimeToCalTime(end, convertedEndTime);
+
+       Tizen::Locales::TimeZone tmpTimeZone(timeZone);
+       DateTime localStartTime = tmpTimeZone.UtcTimeToWallTime(start);
+       DateTime localEndTime = tmpTimeZone.UtcTimeToWallTime(end);
+
+       calendar_time_s convertedLocalStartTime;
+       calendar_time_s convertedLocalEndTime;
+       _CalendarbookUtil::ConvertDateToCalTime(localStartTime, convertedLocalStartTime);
+       _CalendarbookUtil::ConvertDateToCalTime(localEndTime, convertedLocalEndTime);
+
+       std::unique_ptr<IList, AllElementsDeleter> pList;
+
+       if (category == EVENT_CATEGORY_ALL)
+       {
+               pList.reset(GetEventInstancesOfAllCategoriesN(convertedStartTime, convertedEndTime, convertedLocalStartTime, convertedLocalEndTime, pageNo, countPerPage));
+       }
+       else
+       {
+               pList.reset(GetEventInstancesOfCategoryN(convertedStartTime, convertedEndTime, convertedLocalStartTime, convertedLocalEndTime, pageNo, countPerPage, category));
+       }
+
+       return pList.release();
+}
+
+IList*
+_CalendarbookImpl::GetEventInstancesOfAllCategoriesN(const calendar_time_s& startTime, const calendar_time_s& endTime,
+               const calendar_time_s& localStartTime, const calendar_time_s& localEndTime, int pageNo, int countPerPage) const
+{
+       ClearLastResult();
+
+       calendar_filter_h allDayEventInstanceMainFilterHandle = null;
+       int errorCode = calendar_filter_create(_calendar_instance_allday_calendar_book._uri, &allDayEventInstanceMainFilterHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       _CalendarFilter allDayEventInstanceMainFilter(allDayEventInstanceMainFilterHandle);
+
+       // Condition : End time of the item > start time of filter
+       errorCode = calendar_filter_add_caltime(allDayEventInstanceMainFilterHandle, _calendar_instance_allday_calendar_book.end_time, CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, localStartTime);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       // Condition : Start time of the item < end time of filter
+       errorCode = calendar_filter_add_operator(allDayEventInstanceMainFilterHandle, CALENDAR_FILTER_OPERATOR_AND);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       errorCode = calendar_filter_add_caltime(allDayEventInstanceMainFilterHandle, _calendar_instance_allday_calendar_book.start_time, CALENDAR_MATCH_LESS_THAN_OR_EQUAL, localEndTime);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       // Create query
+       calendar_query_h allDayEventInstanceQueryHandle = null;
+       errorCode = calendar_query_create(_calendar_instance_allday_calendar_book._uri, &allDayEventInstanceQueryHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       _CalendarQuery allDayEventInstanceQuery(allDayEventInstanceQueryHandle);
+
+       calendar_query_set_sort(allDayEventInstanceQueryHandle, _calendar_instance_allday_calendar_book.start_time, true);
+       calendar_query_set_filter(allDayEventInstanceQueryHandle, allDayEventInstanceMainFilterHandle);
+
+       int startIndex = (pageNo - 1) * countPerPage;
+
+       calendar_list_h allDayEventInstanceListHandle = null;
+       errorCode = calendar_db_get_records_with_query(allDayEventInstanceQueryHandle, startIndex, countPerPage, &allDayEventInstanceListHandle);
+       SysTryReturn(NID_SCL, errorCode != CALENDAR_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       _CalendarList allDayEventList(allDayEventInstanceListHandle);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       result r = pList->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       int allDayEventInstanceCount = 0;
+       errorCode = calendar_db_get_count_with_query(allDayEventInstanceQueryHandle, &allDayEventInstanceCount);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       int count = 0;
+       calendar_list_get_count(allDayEventInstanceListHandle, &count);
+
+       int pageCount = allDayEventInstanceCount / countPerPage;
+       int remainingCount = countPerPage - count;
+
+       calendar_list_first(allDayEventInstanceListHandle);
+       for (int i = 0; i < count; i++)
+       {
+               calendar_record_h tmpRecordHandle = null;
+               calendar_list_get_current_record_p(allDayEventInstanceListHandle, &tmpRecordHandle);
+
+               std::unique_ptr<CalEvent> pTmpEventInstance(_CalendarbookImpl::ConvertAllDayEventInstanceHandleToCalEventN(tmpRecordHandle));
+               SysTryReturn(NID_SCL, pTmpEventInstance != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pList->Add(*pTmpEventInstance.release());
+               SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               calendar_list_next(allDayEventInstanceListHandle);
+       }
+
+       if (remainingCount > 0)
+       {
+               calendar_filter_h nonAllDayEventInstanceMainFilterHandle = null;
+               errorCode = calendar_filter_create(_calendar_instance_normal_calendar_book._uri, &nonAllDayEventInstanceMainFilterHandle);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               _CalendarFilter nonAllDayEventInstanceMainFilter(nonAllDayEventInstanceMainFilterHandle);
+
+               calendar_filter_h subFilterHandle = null;
+               errorCode = calendar_filter_create(_calendar_instance_normal_calendar_book._uri, &subFilterHandle);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               _CalendarFilter subFilter(subFilterHandle);
+               subFilterHandle = null;
+
+               // Condition : End time of the item > start time of filter
+               errorCode = calendar_filter_add_caltime(subFilter.GetHandle(), _calendar_instance_normal_calendar_book.end_time, CALENDAR_MATCH_GREATER_THAN, startTime);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               // Condition : Start time of the item < end time of filter
+               errorCode = calendar_filter_add_operator(subFilter.GetHandle(), CALENDAR_FILTER_OPERATOR_AND);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               errorCode = calendar_filter_add_caltime(subFilter.GetHandle(), _calendar_instance_normal_calendar_book.start_time, CALENDAR_MATCH_LESS_THAN, endTime);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               errorCode = calendar_filter_add_filter(nonAllDayEventInstanceMainFilterHandle, subFilter.GetHandle());
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               // Condition : Start time of the item = start time of filter AND Start time of the item = end time of filter
+               errorCode = calendar_filter_create(_calendar_instance_normal_calendar_book._uri, &subFilterHandle);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               subFilter.ResetHandle(subFilterHandle);
+               subFilterHandle = null;
+
+               errorCode = calendar_filter_add_caltime(subFilter.GetHandle(), _calendar_instance_normal_calendar_book.start_time, CALENDAR_MATCH_EQUAL, startTime);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               errorCode = calendar_filter_add_operator(subFilter.GetHandle(), CALENDAR_FILTER_OPERATOR_AND);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               errorCode = calendar_filter_add_caltime(subFilter.GetHandle(), _calendar_instance_normal_calendar_book.start_time, CALENDAR_MATCH_EQUAL, endTime);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               errorCode = calendar_filter_add_operator(nonAllDayEventInstanceMainFilterHandle, CALENDAR_FILTER_OPERATOR_OR);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               errorCode = calendar_filter_add_filter(nonAllDayEventInstanceMainFilterHandle, subFilter.GetHandle());
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               // Create query
+               calendar_query_h nonAllDayEventInstanceQueryHandle = null;
+               errorCode = calendar_query_create(_calendar_instance_normal_calendar_book._uri, &nonAllDayEventInstanceQueryHandle);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               _CalendarQuery nonAllDayEventInstanceQuery(nonAllDayEventInstanceQueryHandle);
+
+               calendar_query_set_sort(nonAllDayEventInstanceQueryHandle, _calendar_instance_normal_calendar_book.start_time, true);
+               calendar_query_set_filter(nonAllDayEventInstanceQueryHandle, nonAllDayEventInstanceMainFilterHandle);
+
+               if (remainingCount == countPerPage)
+               {
+                       startIndex = (((pageNo - pageCount) - 1) * countPerPage) - (allDayEventInstanceCount % countPerPage);
+               }
+               else
+               {
+                       startIndex = 0;
+               }
+
+               calendar_list_h nonAllDayEventInstanceListHandle = null;
+               errorCode = calendar_db_get_records_with_query(nonAllDayEventInstanceQueryHandle, startIndex, remainingCount, &nonAllDayEventInstanceListHandle);
+               SysTryReturn(NID_SCL, errorCode != CALENDAR_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+               _CalendarList nonAllDayEventList(nonAllDayEventInstanceListHandle);
+
+               count = 0;
+               calendar_list_get_count(nonAllDayEventInstanceListHandle, &count);
+               calendar_list_first(nonAllDayEventInstanceListHandle);
+               for (int i = 0; i < count; i++)
+               {
+                       calendar_record_h tmpRecordHandle = null;
+                       calendar_list_get_current_record_p(nonAllDayEventInstanceListHandle, &tmpRecordHandle);
+
+                       std::unique_ptr<CalEvent> pTmpEventInstance(_CalendarbookImpl::ConvertNonAllDayEventInstanceHandleToCalEventN(tmpRecordHandle));
+                       SysTryReturn(NID_SCL, pTmpEventInstance != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       r = pList->Add(pTmpEventInstance.get());
+                       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       pTmpEventInstance.release();
+
+                       calendar_list_next(nonAllDayEventInstanceListHandle);
+               }
+       }
+
+       return pList.release();
+}
+
+IList*
+_CalendarbookImpl::GetEventInstancesOfCategoryN(const calendar_time_s& startTime, const calendar_time_s& endTime,
+               const calendar_time_s& localStartTime, const calendar_time_s& localEndTime, int pageNo, int countPerPage, unsigned long category) const
+{
+       ClearLastResult();
+
+       calendar_filter_h allDayEventInstanceMainFilterHandle = null;
+       int errorCode = calendar_filter_create(_calendar_instance_allday_calendar_book._uri, &allDayEventInstanceMainFilterHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       _CalendarFilter allDayEventInstanceMainFilter(allDayEventInstanceMainFilterHandle);
+
+       // Condition : End time of the item > start time of filter
+       errorCode = calendar_filter_add_caltime(allDayEventInstanceMainFilterHandle, _calendar_instance_allday_calendar_book.end_time, CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, localStartTime);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       // Condition : Start time of the item < end time of filter
+       errorCode = calendar_filter_add_operator(allDayEventInstanceMainFilterHandle, CALENDAR_FILTER_OPERATOR_AND);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       errorCode = calendar_filter_add_caltime(allDayEventInstanceMainFilterHandle, _calendar_instance_allday_calendar_book.start_time, CALENDAR_MATCH_LESS_THAN_OR_EQUAL, localEndTime);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       // Create query
+       calendar_query_h allDayEventInstanceQueryHandle = null;
+       errorCode = calendar_query_create(_calendar_instance_allday_calendar_book._uri, &allDayEventInstanceQueryHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       _CalendarQuery allDayEventInstanceQuery(allDayEventInstanceQueryHandle);
+
+       calendar_query_set_sort(allDayEventInstanceQueryHandle, _calendar_instance_allday_calendar_book.start_time, true);
+       calendar_query_set_filter(allDayEventInstanceQueryHandle, allDayEventInstanceMainFilterHandle);
+
+       // Generate event : category map
+       std::unique_ptr< HashMapT<int, int> > pEventCategoryMap(GenerateEventCategoryMapN());
+       SysTryReturn(NID_SCL, pEventCategoryMap != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       int startIndex = (pageNo - 1) * countPerPage;
+
+       calendar_list_h allDayEventInstanceListHandle = null;
+       errorCode = calendar_db_get_records_with_query(allDayEventInstanceQueryHandle, 0, 0, &allDayEventInstanceListHandle);
+       SysTryReturn(NID_SCL, errorCode != CALENDAR_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       _CalendarList allDayEventList(allDayEventInstanceListHandle);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       result r = pList->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       int remainingCount = countPerPage;
+       int candidateCount = 0;
+       int count = 0;
+       calendar_list_get_count(allDayEventInstanceListHandle, &count);
+       calendar_list_first(allDayEventInstanceListHandle);
+       for (int i = 0; i < count && remainingCount > 0; i++)
+       {
+               calendar_record_h tmpRecordHandle = null;
+               calendar_list_get_current_record_p(allDayEventInstanceListHandle, &tmpRecordHandle);
+
+               int tmpCategory = (int) EVENT_CATEGORY_ALL;
+               int eventId = -1;
+               calendar_record_get_int(tmpRecordHandle, _calendar_instance_allday_calendar_book.event_id, &eventId);
+               pEventCategoryMap->GetValue(eventId, tmpCategory);
+
+               if (tmpCategory == (int) category)
+               {
+                       if (candidateCount >= startIndex)
+                       {
+                               std::unique_ptr<CalEvent> pTmpEventInstance(_CalendarbookImpl::ConvertAllDayEventInstanceHandleToCalEventN(tmpRecordHandle));
+                               SysTryReturn(NID_SCL, pTmpEventInstance != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                               r = pList->Add(pTmpEventInstance.get());
+                               SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+                               pTmpEventInstance.release();
+
+                               remainingCount--;
+                       }
+
+                       candidateCount++;
+               }
+
+               calendar_list_next(allDayEventInstanceListHandle);
+       }
+
+       if (remainingCount > 0)
+       {
+               calendar_filter_h nonAllDayEventInstanceMainFilterHandle = null;
+               errorCode = calendar_filter_create(_calendar_instance_normal_calendar_book._uri, &nonAllDayEventInstanceMainFilterHandle);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               _CalendarFilter nonAllDayEventInstanceMainFilter(nonAllDayEventInstanceMainFilterHandle);
+
+               calendar_filter_h subFilterHandle = null;
+               errorCode = calendar_filter_create(_calendar_instance_normal_calendar_book._uri, &subFilterHandle);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               _CalendarFilter subFilter(subFilterHandle);
+               subFilterHandle = null;
+
+               // Condition : End time of the item > start time of filter
+               errorCode = calendar_filter_add_caltime(subFilter.GetHandle(), _calendar_instance_normal_calendar_book.end_time, CALENDAR_MATCH_GREATER_THAN, startTime);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               // Condition : Start time of the item < end time of filter
+               errorCode = calendar_filter_add_operator(subFilter.GetHandle(), CALENDAR_FILTER_OPERATOR_AND);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               errorCode = calendar_filter_add_caltime(subFilter.GetHandle(), _calendar_instance_normal_calendar_book.start_time, CALENDAR_MATCH_LESS_THAN, endTime);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               errorCode = calendar_filter_add_filter(nonAllDayEventInstanceMainFilterHandle, subFilter.GetHandle());
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               // Condition : Start time of the item = start time of filter AND Start time of the item = end time of filter
+               errorCode = calendar_filter_create(_calendar_instance_normal_calendar_book._uri, &subFilterHandle);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               subFilter.ResetHandle(subFilterHandle);
+               subFilterHandle = null;
+
+               errorCode = calendar_filter_add_caltime(subFilter.GetHandle(), _calendar_instance_normal_calendar_book.start_time, CALENDAR_MATCH_EQUAL, startTime);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               errorCode = calendar_filter_add_operator(subFilter.GetHandle(), CALENDAR_FILTER_OPERATOR_AND);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               errorCode = calendar_filter_add_caltime(subFilter.GetHandle(), _calendar_instance_normal_calendar_book.start_time, CALENDAR_MATCH_EQUAL, endTime);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               errorCode = calendar_filter_add_operator(nonAllDayEventInstanceMainFilterHandle, CALENDAR_FILTER_OPERATOR_OR);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               errorCode = calendar_filter_add_filter(nonAllDayEventInstanceMainFilterHandle, subFilter.GetHandle());
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               // Create query
+               calendar_query_h nonAllDayEventInstanceQueryHandle = null;
+               errorCode = calendar_query_create(_calendar_instance_normal_calendar_book._uri, &nonAllDayEventInstanceQueryHandle);
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               _CalendarQuery nonAllDayEventInstanceQuery(nonAllDayEventInstanceQueryHandle);
+
+               calendar_query_set_sort(nonAllDayEventInstanceQueryHandle, _calendar_instance_normal_calendar_book.start_time, true);
+               calendar_query_set_filter(nonAllDayEventInstanceQueryHandle, nonAllDayEventInstanceMainFilterHandle);
+
+               if (remainingCount == countPerPage)
+               {
+                       int pageCount = candidateCount / countPerPage;
+                       startIndex = (((pageNo - pageCount) - 1) * countPerPage) - (candidateCount % countPerPage);
+               }
+               else
+               {
+                       startIndex = 0;
+               }
+
+               calendar_list_h nonAllDayEventInstanceListHandle = null;
+               errorCode = calendar_db_get_records_with_query(nonAllDayEventInstanceQueryHandle, 0, 0, &nonAllDayEventInstanceListHandle);
+               SysTryReturn(NID_SCL, errorCode != CALENDAR_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+               _CalendarList nonAllDayEventList(nonAllDayEventInstanceListHandle);
+
+               candidateCount = 0;
+               count = 0;
+
+               calendar_list_get_count(nonAllDayEventInstanceListHandle, &count);
+               calendar_list_first(nonAllDayEventInstanceListHandle);
+               for (int i = 0; i < count && remainingCount > 0; i++)
+               {
+                       calendar_record_h tmpRecordHandle = null;
+                       calendar_list_get_current_record_p(nonAllDayEventInstanceListHandle, &tmpRecordHandle);
+
+                       int tmpCategory = (int) EVENT_CATEGORY_ALL;
+                       int eventId = -1;
+                       calendar_record_get_int(tmpRecordHandle, _calendar_instance_normal_calendar_book.event_id, &eventId);
+                       pEventCategoryMap->GetValue(eventId, tmpCategory);
+
+                       if (tmpCategory == (int) category)
+                       {
+                               if (candidateCount >= startIndex)
+                               {
+                                       std::unique_ptr<CalEvent> pTmpEventInstance(_CalendarbookImpl::ConvertNonAllDayEventInstanceHandleToCalEventN(tmpRecordHandle));
+                                       SysTryReturn(NID_SCL, pTmpEventInstance != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                                       r = pList->Add(*pTmpEventInstance.release());
+                                       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                                       remainingCount--;
+                               }
+
+                               candidateCount++;
+                       }
+
+                       calendar_list_next(nonAllDayEventInstanceListHandle);
+               }
+       }
+
+       return pList.release();
+}
+
+HashMapT<int, int>*
+_CalendarbookImpl::GenerateEventCategoryMapN(void) const
+{
+       result r = E_SUCCESS;
+       int errorCode = CALENDAR_ERROR_NONE;
+
+       unsigned int projectionList[_NUMBER_OF_EVENT_CATEGORY_MAP_PROJECTION] = {_calendar_event.id, _calendar_event.categories};
+
+       // Create query
+       calendar_query_h queryHandle = null;
+       errorCode = calendar_query_create(_calendar_event._uri, &queryHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       _CalendarQuery query(queryHandle);
+
+       calendar_query_set_projection(queryHandle, projectionList, _NUMBER_OF_EVENT_CATEGORY_MAP_PROJECTION);
+       calendar_query_set_sort(queryHandle, _calendar_event.id, true);
+
+       calendar_list_h calendarListHandle = null;
+       errorCode = calendar_db_get_records_with_query(queryHandle, 0, 0, &calendarListHandle);
+       SysTryReturn(NID_SCL, errorCode != CALENDAR_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+       _CalendarList calendarList(calendarListHandle);
+
+       std::unique_ptr< HashMapT<int, int> > pEventCategoryMap(new HashMapT<int, int>());
+       SysTryReturn(NID_SCL, pEventCategoryMap != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       r = pEventCategoryMap->Construct();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       int count = 0;
+       calendar_list_get_count(calendarListHandle, &count);
+       calendar_list_first(calendarListHandle);
+       for (int i = 0; i < count; i++)
+       {
+               calendar_record_h tmpRecordHandle = null;
+               calendar_list_get_current_record_p(calendarListHandle, &tmpRecordHandle);
+
+               int eventId = -1;
+               char* pCategories = null;
+
+               calendar_record_get_int(tmpRecordHandle, _calendar_event.id, &eventId);
+               calendar_record_get_str_p(tmpRecordHandle, _calendar_event.categories, &pCategories);
+
+               int category = _CalendarbookUtil::ConvertCSCategoriesToEventCategory(pCategories);
+
+               pEventCategoryMap->Add(eventId, category);
+
+               calendar_list_next(calendarListHandle);
+       }
+
+       return pEventCategoryMap.release();
+}
+
+CalendarItemType
+_CalendarbookImpl::GetCalendarItemTypeByCalendarId(RecordId calendarId) const
+{
+       CalendarItemType calendarItemType = CALENDAR_ITEM_TYPE_EVENT_AND_TODO;
+
+       calendar_record_h calendarHandle = null;
+       int storeType = CALENDAR_BOOK_TYPE_NONE;
+
+       int errorCode = calendar_db_get_record(_calendar_book._uri, calendarId, &calendarHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, CALENDAR_ITEM_TYPE_EVENT_AND_TODO, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       calendar_record_get_int(calendarHandle, _calendar_book.store_type, &storeType);
+
+       if (storeType == (CALENDAR_BOOK_TYPE_EVENT | CALENDAR_BOOK_TYPE_TODO))
+       {
+               calendarItemType = CALENDAR_ITEM_TYPE_EVENT_AND_TODO;
+       }
+       else if (storeType == CALENDAR_BOOK_TYPE_EVENT)
+       {
+               calendarItemType = CALENDAR_ITEM_TYPE_EVENT_ONLY;
+       }
+       else if (storeType == CALENDAR_BOOK_TYPE_TODO)
+       {
+               calendarItemType = CALENDAR_ITEM_TYPE_TODO_ONLY;
+       }
+       else
+       {
+               SetLastResult(E_SYSTEM);
+               SysLogException(NID_SCL, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+               calendar_record_destroy(calendarHandle, true);
+               return CALENDAR_ITEM_TYPE_EVENT_AND_TODO;
+       }
+
+       calendar_record_destroy(calendarHandle, true);
+
+       return calendarItemType;
+}
+
+bool
+_CalendarbookImpl::CheckEventExistance(RecordId eventId) const
+{
+       calendar_record_h eventHandle = null;
+
+       int errorCode = calendar_db_get_record(_calendar_event._uri, eventId, &eventHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, false, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       calendar_record_destroy(eventHandle, true);
+
+       return true;
+}
+
+bool
+_CalendarbookImpl::CheckTodoExistance(RecordId todoId) const
+{
+       calendar_record_h todoHandle = null;
+
+       int errorCode = calendar_db_get_record(_calendar_todo._uri, todoId, &todoHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, false, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       calendar_record_destroy(todoHandle, true);
+
+       return true;
+}
+
+bool
+_CalendarbookImpl::CheckCalendarExistance(RecordId calendarId) const
+{
+       calendar_record_h calendarHandle = null;
+
+       int errorCode = calendar_db_get_record(_calendar_book._uri, calendarId, &calendarHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, false, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       calendar_record_destroy(calendarHandle, true);
+
+       return true;
+}
+
+bool
+_CalendarbookImpl::CheckValidTodoPriority(unsigned long priority) const
+{
+       if ((priority & TODO_PRIORITY_LOW) || (priority & TODO_PRIORITY_NORMAL) || (priority & TODO_PRIORITY_HIGH))
+       {
+               return true;
+       }
+
+       return false;
+}
+
+bool
+_CalendarbookImpl::CheckValidTodoStatus(unsigned long status) const
+{
+       if ((status & TODO_STATUS_NONE) || (status & TODO_STATUS_NEEDS_ACTION) || (status & TODO_STATUS_COMPLETED)
+                       || (status & TODO_STATUS_IN_PROCESS) || (status & TODO_STATUS_CANCELLED))
+       {
+               return true;
+       }
+
+       return false;
+}
+
+int
+_CalendarbookImpl::ConvertTodoStatusToCalendarTodoStatus(unsigned long todoStatus) const
+{
+       return todoStatus << 8;
+}
+
+int
+_CalendarbookImpl::ConvertTodoPriorityToCalendarTodoPriority(unsigned long todoPriority) const
+{
+       int calendarTodoPriority = CALENDAR_TODO_PRIORITY_NONE;
+
+       if (todoPriority == TODO_PRIORITY_LOW)
+       {
+               calendarTodoPriority = CALENDAR_TODO_PRIORITY_LOW;
+       }
+       else if (todoPriority == TODO_PRIORITY_NORMAL)
+       {
+               calendarTodoPriority = CALENDAR_TODO_PRIORITY_NORMAL;
+       }
+       else if (todoPriority == TODO_PRIORITY_HIGH)
+       {
+               calendarTodoPriority = CALENDAR_TODO_PRIORITY_HIGH;
+       }
+
+       return calendarTodoPriority;
+}
+
+CalEvent*
+_CalendarbookImpl::ConvertAllDayEventInstanceHandleToCalEventN(calendar_record_h instanceHandle)
+{
+       int originalEventDBId = _INVALID_EVENT_DB_ID;
+       calendar_record_h eventHandle = null;
+
+       int errorCode = calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.event_id, &originalEventDBId);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. The instanceHandle is invalid record.");
+
+       std::unique_ptr<CalEvent> pEvent(new (std::nothrow) CalEvent());
+       SysTryReturn(NID_SCL, pEvent != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       _CalEventImpl* pEventImpl = _CalEventImpl::GetInstance(*pEvent.get());
+
+       errorCode = calendar_db_get_record(_calendar_event._uri, originalEventDBId, &eventHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       calendar_time_s startCalendarTime;
+       calendar_time_s endCalendarTime;
+       calendar_record_get_caltime(instanceHandle, _calendar_instance_allday_calendar_book.start_time, &startCalendarTime);
+       calendar_record_get_caltime(instanceHandle, _calendar_instance_allday_calendar_book.end_time, &endCalendarTime);
+       calendar_record_set_caltime(eventHandle, _calendar_event.start_time, startCalendarTime);
+       calendar_record_set_caltime(eventHandle, _calendar_event.end_time, endCalendarTime);
+
+       pEventImpl->SetOriginalCalEventId(originalEventDBId);
+       pEventImpl->SetRecordHandle(eventHandle);
+
+       return pEvent.release();
+}
+
+CalEvent*
+_CalendarbookImpl::ConvertNonAllDayEventInstanceHandleToCalEventN(calendar_record_h instanceHandle)
+{
+       int originalEventDBId = _INVALID_EVENT_DB_ID;
+       calendar_record_h eventHandle = null;
+
+       int errorCode = calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.event_id, &originalEventDBId);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_INVALID_ARG, "[%s] Invalid argument is used. The instanceHandle is invalid record.", GetErrorMessage(E_INVALID_ARG));
+
+       std::unique_ptr<CalEvent> pEvent(new (std::nothrow) CalEvent());
+       SysTryReturn(NID_SCL, pEvent != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       _CalEventImpl* pEventImpl = _CalEventImpl::GetInstance(*pEvent.get());
+
+       errorCode = calendar_db_get_record(_calendar_event._uri, originalEventDBId, &eventHandle);
+       SysTryReturn(NID_SCL, errorCode == CALENDAR_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       calendar_time_s startCalendarTime;
+       calendar_time_s endCalendarTime;
+       calendar_record_get_caltime(instanceHandle, _calendar_instance_normal_calendar_book.start_time, &startCalendarTime);
+       calendar_record_get_caltime(instanceHandle, _calendar_instance_normal_calendar_book.end_time, &endCalendarTime);
+       calendar_record_set_caltime(eventHandle, _calendar_event.start_time, startCalendarTime);
+       calendar_record_set_caltime(eventHandle, _calendar_event.end_time, endCalendarTime);
+
+       pEventImpl->SetOriginalCalEventId(originalEventDBId);
+       pEventImpl->SetRecordHandle(eventHandle);
+
+       return pEvent.release();
+}
+
+CalEventInstance*
+_CalendarbookImpl::ConvertAllDayEventInstanceHandleToCalEventInstanceN(calendar_record_h instanceHandle)
+{
+       ClearLastResult();
+
+       std::unique_ptr<CalEventInstance> pEventInstance(new (std::nothrow) CalEventInstance());
+       SysTryReturn(NID_SCL, pEventInstance != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       _CalEventInstanceImpl* pEventInstanceImpl = _CalEventInstanceImpl::GetInstance(*pEventInstance.get());
+
+       int originalEventDBId = _INVALID_EVENT_DB_ID;
+       calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.event_id, &originalEventDBId);
+       pEventInstanceImpl->SetOriginalEventId(originalEventDBId);
+
+       int calendarDBId = _INVALID_CALENDARBOOK_DB_ID;
+       calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.calendar_book_id, &calendarDBId);
+       pEventInstanceImpl->SetCalendarId(calendarDBId);
+
+       int srcEventBusyStatus = CALENDAR_EVENT_BUSY_STATUS_FREE;
+       calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.busy_status, &srcEventBusyStatus);
+       BusyStatus busyStatus = BUSY_STATUS_FREE;
+       switch (srcEventBusyStatus)
+       {
+       case CALENDAR_EVENT_BUSY_STATUS_FREE:
+               busyStatus = BUSY_STATUS_FREE;
+               break;
+       case CALENDAR_EVENT_BUSY_STATUS_BUSY:
+               busyStatus = BUSY_STATUS_BUSY;
+               break;
+       case CALENDAR_EVENT_BUSY_STATUS_UNAVAILABLE:
+               busyStatus = BUSY_STATUS_UNAVAILABLE;
+               break;
+       case CALENDAR_EVENT_BUSY_STATUS_TENTATIVE:
+               busyStatus = BUSY_STATUS_TENTATIVE;
+               break;
+       default :
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. busy status = %d", GetErrorMessage(E_INVALID_ARG), srcEventBusyStatus);
+               busyStatus = BUSY_STATUS_FREE;
+               break;
+       }
+       pEventInstanceImpl->SetBusyStatus(busyStatus);
+
+       int srcEventStatus = CALENDAR_EVENT_STATUS_NONE;
+       calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.event_status, &srcEventStatus);
+       EventStatus eventStatus = EVENT_STATUS_NONE;
+       switch (srcEventStatus)
+       {
+       case CALENDAR_EVENT_STATUS_NONE:
+               eventStatus = EVENT_STATUS_NONE;
+               break;
+       case CALENDAR_EVENT_STATUS_TENTATIVE:
+               eventStatus = EVENT_STATUS_TENTATIVE;
+               break;
+       case CALENDAR_EVENT_STATUS_CONFIRMED:
+               eventStatus = EVENT_STATUS_CONFIRMED;
+               break;
+       case CALENDAR_EVENT_STATUS_CANCELLED:
+               eventStatus = EVENT_STATUS_CANCELLED;
+               break;
+       default :
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. status = %d", GetErrorMessage(E_INVALID_ARG), srcEventStatus);
+               eventStatus = EVENT_STATUS_NONE;
+       }
+       pEventInstanceImpl->SetStatus(eventStatus);
+
+       int srcPriority = CALENDAR_EVENT_PRIORITY_NORMAL;
+       calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.priority, &srcPriority);
+       EventPriority priority = EVENT_PRIORITY_NORMAL;
+       switch (srcPriority)
+       {
+       case CALENDAR_EVENT_PRIORITY_LOW:
+               priority = EVENT_PRIORITY_LOW;
+               break;
+       case CALENDAR_EVENT_PRIORITY_NONE:
+               // fall through
+       case CALENDAR_EVENT_PRIORITY_NORMAL:
+               priority = EVENT_PRIORITY_NORMAL;
+               break;
+       case CALENDAR_EVENT_PRIORITY_HIGH:
+               priority = EVENT_PRIORITY_HIGH;
+               break;
+       default :
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. priority = %d", GetErrorMessage(E_INVALID_ARG), srcPriority);
+               priority = EVENT_PRIORITY_NORMAL;
+       }
+       pEventInstanceImpl->SetPriority(priority);
+
+       int srcSensitivity = CALENDAR_SENSITIVITY_PUBLIC;
+       calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.sensitivity, &srcSensitivity);
+       RecordSensitivity sensitivity = SENSITIVITY_PUBLIC;
+       switch (srcSensitivity)
+       {
+       case CALENDAR_SENSITIVITY_PUBLIC:
+               sensitivity = SENSITIVITY_PUBLIC;
+               break;
+       case CALENDAR_SENSITIVITY_PRIVATE:
+               sensitivity = SENSITIVITY_PRIVATE;
+               break;
+       case CALENDAR_SENSITIVITY_CONFIDENTIAL:
+               sensitivity = SENSITIVITY_CONFIDENTIAL;
+               break;
+       default :
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. sensitivity = %d", GetErrorMessage(E_INVALID_ARG), srcSensitivity);
+               sensitivity = SENSITIVITY_PUBLIC;
+       }
+       pEventInstanceImpl->SetSensitivity(sensitivity);
+
+       calendar_time_s startCalendarTime;
+       DateTime tmpStartTime;
+       calendar_record_get_caltime(instanceHandle, _calendar_instance_allday_calendar_book.start_time, &startCalendarTime);
+       tmpStartTime.SetValue(startCalendarTime.time.date.year, startCalendarTime.time.date.month, startCalendarTime.time.date.mday);
+       pEventInstanceImpl->SetStartTime(tmpStartTime);
+
+       calendar_time_s endCalendarTime;
+       DateTime tmpEndTime;
+       calendar_record_get_caltime(instanceHandle, _calendar_instance_allday_calendar_book.end_time, &endCalendarTime);
+       tmpEndTime.SetValue(endCalendarTime.time.date.year, endCalendarTime.time.date.month, endCalendarTime.time.date.mday);
+       pEventInstanceImpl->SetEndTime(tmpEndTime);
+
+       pEventInstanceImpl->SetAllDayEvent(true);
+
+       int isRecurring = 0;
+       calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.has_rrule, &isRecurring);
+       pEventInstanceImpl->SetRecurring(isRecurring);
+
+       int hasReminder = 0;
+       calendar_record_get_int(instanceHandle, _calendar_instance_allday_calendar_book.has_alarm, &hasReminder);
+       pEventInstanceImpl->SetHasReminder(hasReminder);
+
+       char* pSubject = null;
+       calendar_record_get_str_p(instanceHandle, _calendar_instance_allday_calendar_book.summary, &pSubject);
+       pEventInstanceImpl->SetSubject(pSubject);
+
+       char* pDescription = null;
+       calendar_record_get_str_p(instanceHandle, _calendar_instance_allday_calendar_book.description, &pDescription);
+       pEventInstanceImpl->SetDescription(pDescription);
+
+       char* pLocation = null;
+       calendar_record_get_str_p(instanceHandle, _calendar_instance_allday_calendar_book.location, &pLocation);
+       pEventInstanceImpl->SetLocation(pLocation);
+
+       return pEventInstance.release();
+}
+
+CalEventInstance*
+_CalendarbookImpl::ConvertNonAllDayEventInstanceHandleToCalEventInstanceN(calendar_record_h instanceHandle)
+{
+       ClearLastResult();
+
+       std::unique_ptr<CalEventInstance> pEventInstance(new (std::nothrow) CalEventInstance());
+       SysTryReturn(NID_SCL, pEventInstance != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       _CalEventInstanceImpl* pEventInstanceImpl = _CalEventInstanceImpl::GetInstance(*pEventInstance.get());
+
+       int originalEventDBId = _INVALID_EVENT_DB_ID;
+       calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.event_id, &originalEventDBId);
+       pEventInstanceImpl->SetOriginalEventId(originalEventDBId);
+
+       int calendarDBId = _INVALID_CALENDARBOOK_DB_ID;
+       calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.calendar_book_id, &calendarDBId);
+       pEventInstanceImpl->SetCalendarId(calendarDBId);
+
+       int srcEventBusyStatus = CALENDAR_EVENT_BUSY_STATUS_FREE;
+       calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.busy_status, &srcEventBusyStatus);
+       BusyStatus busyStatus = BUSY_STATUS_FREE;
+       switch (srcEventBusyStatus)
+       {
+       case CALENDAR_EVENT_BUSY_STATUS_FREE:
+               busyStatus = BUSY_STATUS_FREE;
+               break;
+       case CALENDAR_EVENT_BUSY_STATUS_BUSY:
+               busyStatus = BUSY_STATUS_BUSY;
+               break;
+       case CALENDAR_EVENT_BUSY_STATUS_UNAVAILABLE:
+               busyStatus = BUSY_STATUS_UNAVAILABLE;
+               break;
+       case CALENDAR_EVENT_BUSY_STATUS_TENTATIVE:
+               busyStatus = BUSY_STATUS_TENTATIVE;
+               break;
+       default :
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. busy status = %d", GetErrorMessage(E_INVALID_ARG), srcEventBusyStatus);
+               busyStatus = BUSY_STATUS_FREE;
+               break;
+       }
+       pEventInstanceImpl->SetBusyStatus(busyStatus);
+
+       int srcEventStatus = CALENDAR_EVENT_STATUS_NONE;
+       calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.event_status, &srcEventStatus);
+
+       EventStatus eventStatus = EVENT_STATUS_NONE;
+       switch (srcEventStatus)
+       {
+       case CALENDAR_EVENT_STATUS_NONE:
+               eventStatus = EVENT_STATUS_NONE;
+               break;
+       case CALENDAR_EVENT_STATUS_TENTATIVE:
+               eventStatus = EVENT_STATUS_TENTATIVE;
+               break;
+       case CALENDAR_EVENT_STATUS_CONFIRMED:
+               eventStatus = EVENT_STATUS_CONFIRMED;
+               break;
+       case CALENDAR_EVENT_STATUS_CANCELLED:
+               eventStatus = EVENT_STATUS_CANCELLED;
+               break;
+       default :
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. status = %d", GetErrorMessage(E_INVALID_ARG), srcEventStatus);
+               eventStatus = EVENT_STATUS_NONE;
+       }
+       pEventInstanceImpl->SetStatus(eventStatus);
+
+       int srcPriority = CALENDAR_EVENT_PRIORITY_NORMAL;
+       calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.priority, &srcPriority);
+       EventPriority priority = EVENT_PRIORITY_NORMAL;
+       switch (srcPriority)
+       {
+       case CALENDAR_EVENT_PRIORITY_LOW:
+               priority = EVENT_PRIORITY_LOW;
+               break;
+       case CALENDAR_EVENT_PRIORITY_NONE:
+               // fall through
+       case CALENDAR_EVENT_PRIORITY_NORMAL:
+               priority = EVENT_PRIORITY_NORMAL;
+               break;
+       case CALENDAR_EVENT_PRIORITY_HIGH:
+               priority = EVENT_PRIORITY_HIGH;
+               break;
+       default :
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. priority = %d", GetErrorMessage(E_INVALID_ARG), srcPriority);
+               priority = EVENT_PRIORITY_NORMAL;
+       }
+       pEventInstanceImpl->SetPriority(priority);
+
+       int srcSensitivity = CALENDAR_SENSITIVITY_PUBLIC;
+       calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.sensitivity, &srcSensitivity);
+       RecordSensitivity sensitivity = SENSITIVITY_PUBLIC;
+       switch (srcSensitivity)
+       {
+       case CALENDAR_SENSITIVITY_PUBLIC:
+               sensitivity = SENSITIVITY_PUBLIC;
+               break;
+       case CALENDAR_SENSITIVITY_PRIVATE:
+               sensitivity = SENSITIVITY_PRIVATE;
+               break;
+       case CALENDAR_SENSITIVITY_CONFIDENTIAL:
+               sensitivity = SENSITIVITY_CONFIDENTIAL;
+               break;
+       default :
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. sensitivity = %d", GetErrorMessage(E_INVALID_ARG), srcSensitivity);
+               sensitivity = SENSITIVITY_PUBLIC;
+       }
+       pEventInstanceImpl->SetSensitivity(sensitivity);
+
+       calendar_time_s startCalendarTime;
+       DateTime tmpStartTime;
+       calendar_record_get_caltime(instanceHandle, _calendar_instance_normal_calendar_book.start_time, &startCalendarTime);
+       tmpStartTime = _CalendarbookUtil::ConvertEpochTimeToDateTime(startCalendarTime.time.utime);
+       pEventInstanceImpl->SetStartTime(tmpStartTime);
+
+       calendar_time_s endCalendarTime;
+       DateTime tmpEndTime;
+       calendar_record_get_caltime(instanceHandle, _calendar_instance_normal_calendar_book.end_time, &endCalendarTime);
+       tmpEndTime = _CalendarbookUtil::ConvertEpochTimeToDateTime(endCalendarTime.time.utime);
+       pEventInstanceImpl->SetEndTime(tmpEndTime);
+
+       pEventInstanceImpl->SetAllDayEvent(false);
+
+       int isRecurring = 0;
+       calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.has_rrule, &isRecurring);
+       pEventInstanceImpl->SetRecurring(isRecurring);
+
+       int hasReminder = 0;
+       calendar_record_get_int(instanceHandle, _calendar_instance_normal_calendar_book.has_alarm, &hasReminder);
+       pEventInstanceImpl->SetHasReminder(hasReminder);
+
+       char* pSubject = null;
+       calendar_record_get_str_p(instanceHandle, _calendar_instance_normal_calendar_book.summary, &pSubject);
+       pEventInstanceImpl->SetSubject(pSubject);
+
+       char* pDescription = null;
+       calendar_record_get_str_p(instanceHandle, _calendar_instance_normal_calendar_book.description, &pDescription);
+       pEventInstanceImpl->SetDescription(pDescription);
+
+       char* pLocation = null;
+       calendar_record_get_str_p(instanceHandle, _calendar_instance_normal_calendar_book.location, &pLocation);
+       pEventInstanceImpl->SetLocation(pLocation);
+
+       return pEventInstance.release();
+}
+
+CalEventChangeInfo*
+_CalendarbookImpl::ConvertModifiedEventToCalEventChangeInfoN(calendar_record_h modifiedEventHandle)
+{
+       ClearLastResult();
+
+       std::unique_ptr<CalEventChangeInfo> pEventChangeInfo(new (std::nothrow) CalEventChangeInfo());
+       SysTryReturn(NID_SCL, pEventChangeInfo != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       _CalEventChangeInfoImpl* pEventChangeInfoImpl = _CalEventChangeInfoImpl::GetInstance(*pEventChangeInfo.get());
+
+       int eventId = 0;
+       calendar_record_get_int(modifiedEventHandle, _calendar_updated_info.id, &eventId);
+       pEventChangeInfoImpl->SetEventId(eventId);
+
+       int calendarbookId = 0;
+       calendar_record_get_int(modifiedEventHandle, _calendar_updated_info.calendar_book_id, &calendarbookId);
+       pEventChangeInfoImpl->SetCalendarId(calendarbookId);
+
+       int modifiedStatus = CALENDAR_RECORD_MODIFIED_STATUS_INSERTED;
+       calendar_record_get_int(modifiedEventHandle, _calendar_updated_info.modified_status, &modifiedStatus);
+       RecordChangeType recordChangeType = RECORD_CHANGE_TYPE_ADDED;
+       switch (modifiedStatus)
+       {
+       case CALENDAR_RECORD_MODIFIED_STATUS_INSERTED:
+               recordChangeType = RECORD_CHANGE_TYPE_ADDED;
+               break;
+       case CALENDAR_RECORD_MODIFIED_STATUS_UPDATED:
+               recordChangeType = RECORD_CHANGE_TYPE_UPDATED;
+               break;
+       case CALENDAR_RECORD_MODIFIED_STATUS_DELETED:
+               recordChangeType = RECORD_CHANGE_TYPE_REMOVED;
+               break;
+       default:
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. modified status = %d", GetErrorMessage(E_INVALID_ARG), modifiedStatus);
+               return null;
+       }
+       pEventChangeInfoImpl->SetChangeType(recordChangeType);
+
+       int version = 0;
+       calendar_record_get_int(modifiedEventHandle, _calendar_updated_info.version, &version);
+       pEventChangeInfoImpl->SetVersion(version);
+
+       return pEventChangeInfo.release();
+}
+
+CalTodoChangeInfo*
+_CalendarbookImpl::ConvertModifiedTodoToCalTodoChangeInfoN(calendar_record_h modifiedTodoHandle)
+{
+       ClearLastResult();
+
+       std::unique_ptr<CalTodoChangeInfo> pTodoChangeInfo(new (std::nothrow) CalTodoChangeInfo());
+       SysTryReturn(NID_SCL, pTodoChangeInfo != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       _CalTodoChangeInfoImpl* pTodoChangeInfoImpl = _CalTodoChangeInfoImpl::GetInstance(*pTodoChangeInfo.get());
+
+       int todoId = 0;
+       calendar_record_get_int(modifiedTodoHandle, _calendar_updated_info.id, &todoId);
+       pTodoChangeInfoImpl->SetTodoId(todoId);
+
+       int calendarbookId = 0;
+       calendar_record_get_int(modifiedTodoHandle, _calendar_updated_info.calendar_book_id, &calendarbookId);
+       pTodoChangeInfoImpl->SetCalendarId(calendarbookId);
+
+       int modifiedStatus = CALENDAR_RECORD_MODIFIED_STATUS_INSERTED;
+       calendar_record_get_int(modifiedTodoHandle, _calendar_updated_info.modified_status, &modifiedStatus);
+       RecordChangeType recordChangeType = RECORD_CHANGE_TYPE_ADDED;
+
+       switch (modifiedStatus)
+       {
+       case    CALENDAR_RECORD_MODIFIED_STATUS_INSERTED:
+               recordChangeType = RECORD_CHANGE_TYPE_ADDED;
+               break;
+       case CALENDAR_RECORD_MODIFIED_STATUS_UPDATED:
+               recordChangeType = RECORD_CHANGE_TYPE_UPDATED;
+               break;
+       case CALENDAR_RECORD_MODIFIED_STATUS_DELETED:
+               recordChangeType = RECORD_CHANGE_TYPE_REMOVED;
+               break;
+       default:
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. modified status = %d", GetErrorMessage(E_INVALID_ARG), modifiedStatus);
+               return null;
+       }
+       pTodoChangeInfoImpl->SetChangeType(recordChangeType);
+
+       int version = 0;
+       calendar_record_get_int(modifiedTodoHandle, _calendar_updated_info.version, &version);
+       pTodoChangeInfoImpl->SetVersion(version);
+
+       return pTodoChangeInfo.release();
+}
+
+template<typename RecordType, typename RecordTypeImpl, typename RecordView>
+IList*
+_CalendarbookImpl::ConvertRecordListN(calendar_list_h resultListHandle, RecordView recordView)
+{
+       result r = E_SUCCESS;
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       r = pList->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       int count = 0;
+       calendar_list_get_count(resultListHandle, &count);
+
+       for (int i = 0; i < count; i++)
+       {
+               std::unique_ptr<RecordType> pTmpRecord(RecordTypeImpl::CreateDefaultInstanceN());
+               SysTryReturn(NID_SCL, pTmpRecord != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pList->Add(pTmpRecord.get());
+               SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               pTmpRecord.release();
+       }
+
+       calendar_list_first(resultListHandle);
+       std::unique_ptr<IEnumerator> pEnum(pList->GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               RecordType* pTmpRecord = static_cast<RecordType*>(pEnum->GetCurrent());
+
+               calendar_record_h tmpRecordHandle = null;
+               calendar_list_get_current_record_p(resultListHandle, &tmpRecordHandle);
+               RecordTypeImpl::GetInstance(*pTmpRecord)->SetRecordHandle(tmpRecordHandle);
+
+               int dbIndex = -1;
+               calendar_record_get_int(tmpRecordHandle, recordView.id, &dbIndex);
+               _RecordImpl::GetInstance(*pTmpRecord)->SetRecordId(dbIndex);
+
+               calendar_list_next(resultListHandle);
+       }
+
+       return pList.release();
+}
+
+IList*
+_CalendarbookImpl::ConvertEventInstanceListN(calendar_list_h resultListHandle, bool isAllDay)
+{
+       result r = E_SUCCESS;
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       r = pList->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       int count = 0;
+       calendar_list_get_count(resultListHandle, &count);
+       calendar_list_first(resultListHandle);
+       for (int i = 0; i < count; i++)
+       {
+               calendar_record_h tmpRecordHandle = null;
+               calendar_list_get_current_record_p(resultListHandle, &tmpRecordHandle);
+
+               std::unique_ptr<CalEventInstance> pTmpEventInstance;
+
+               if (isAllDay)
+               {
+                       pTmpEventInstance.reset(_CalendarbookImpl::ConvertAllDayEventInstanceHandleToCalEventInstanceN(tmpRecordHandle));
+                       SysTryReturn(NID_SCL, pTmpEventInstance != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               }
+               else
+               {
+                       pTmpEventInstance.reset(_CalendarbookImpl::ConvertNonAllDayEventInstanceHandleToCalEventInstanceN(tmpRecordHandle));
+                       SysTryReturn(NID_SCL, pTmpEventInstance != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               }
+
+               r = pList->Add(pTmpEventInstance.get());
+               SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               pTmpEventInstance.release();
+
+               calendar_list_next(resultListHandle);
+       }
+
+       return pList.release();
+}
+
+void
+_CalendarbookImpl::OnCalEventChanged(void)
+{
+       if (__pICalendarbookEventListener == null && __pIRecordEventListener == null)
+       {
+               return;
+       }
+
+       _CalendarConnector connector;
+       result r = connector.GetResult();
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       std::unique_ptr<IList, AllElementsDeleter> pChangedEventList(GetChangedEventsAfterN(__dbVersionForEvent, __dbVersionForEvent));
+       SysTryReturnVoidResult(NID_SCL, GetLastResult() != E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturnVoidResult(NID_SCL, GetLastResult() == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       if (pChangedEventList->GetCount() > 0)
+       {
+               if (__pICalendarbookEventListener != null)
+               {
+                       __pICalendarbookEventListener->OnCalendarEventsChanged(*pChangedEventList.get());
+               }
+               else
+               {
+                       RecordEventType recordEventType = RECORD_ADDED;
+                       IEnumerator* pEnum = pChangedEventList->GetEnumeratorN();
+                       CalEvent* pEvent = null;
+
+                       while (pEnum->MoveNext() == E_SUCCESS)
+                       {
+                               CalEventChangeInfo* pEventChagneInfo = static_cast<CalEventChangeInfo*>(pEnum->GetCurrent());
+
+                               if (pEventChagneInfo->GetChangeType() == RECORD_CHANGE_TYPE_ADDED)
+                               {
+                                       recordEventType = RECORD_ADDED;
+                                       pEvent = GetEventN(pEventChagneInfo->GetEventId());
+                                       if (pEvent == null)
+                                       {
+                                               if (GetLastResult() == E_OBJ_NOT_FOUND)
+                                               {
+                                                       continue;
+                                               }
+                                               else
+                                               {
+                                                       break;
+                                               }
+                                       }
+                               }
+                               else if (pEventChagneInfo->GetChangeType() == RECORD_CHANGE_TYPE_UPDATED)
+                               {
+                                       recordEventType = RECORD_UPDATED;
+                                       pEvent = GetEventN(pEventChagneInfo->GetEventId());
+                                       if (pEvent == null)
+                                       {
+                                               if (GetLastResult() == E_OBJ_NOT_FOUND)
+                                               {
+                                                       continue;
+                                               }
+                                               else
+                                               {
+                                                       break;
+                                               }
+                                       }
+                               }
+                               else
+                               {
+                                       recordEventType = RECORD_REMOVED;
+                                       pEvent = new (std::nothrow) CalEvent();
+                                       if (pEvent == null)
+                                       {
+                                               SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+                                               break;
+                                       }
+
+                                       _RecordImpl::GetInstance(*pEvent)->SetRecordId(pEventChagneInfo->GetEventId());
+                               }
+
+                               __pIRecordEventListener->OnRecordChangedN(recordEventType, RECORD_TYPE_EVENT, *pEvent, null, null);
+
+                               delete pEvent;
+                       }
+
+                       delete pEnum;
+               }
+       }
+}
+
+void
+_CalendarbookImpl::OnCalTodoChanged(void)
+{
+       if (__pICalendarbookEventListener == null && __pIRecordEventListener == null)
+       {
+               return;
+       }
+
+       _CalendarConnector connector;
+       result r = connector.GetResult();
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       std::unique_ptr<IList, AllElementsDeleter> pChangedTodoList(GetChangedTodosAfterN(__dbVersionForTodo, __dbVersionForTodo));
+       SysTryReturnVoidResult(NID_SCL, GetLastResult() != E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturnVoidResult(NID_SCL, GetLastResult() == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       if (pChangedTodoList->GetCount() > 0)
+       {
+               if (__pICalendarbookEventListener != null)
+               {
+                       __pICalendarbookEventListener->OnCalendarTodosChanged(*pChangedTodoList.get());
+               }
+               else
+               {
+                       RecordEventType recordEventType = RECORD_ADDED;
+                       IEnumerator* pEnum = pChangedTodoList->GetEnumeratorN();
+                       CalTodo* pTodo = null;
+
+                       while (pEnum->MoveNext() == E_SUCCESS)
+                       {
+                               CalTodoChangeInfo* pTodoChagneInfo = static_cast<CalTodoChangeInfo*>(pEnum->GetCurrent());
+
+                               if (pTodoChagneInfo->GetChangeType() == RECORD_CHANGE_TYPE_ADDED)
+                               {
+                                       recordEventType = RECORD_ADDED;
+                                       pTodo = GetTodoN(pTodoChagneInfo->GetTodoId());
+                                       if (pTodo == null)
+                                       {
+                                               if (GetLastResult() == E_OBJ_NOT_FOUND)
+                                               {
+                                                       continue;
+                                               }
+                                               else
+                                               {
+                                                       break;
+                                               }
+                                       }
+                               }
+                               else if (pTodoChagneInfo->GetChangeType() == RECORD_CHANGE_TYPE_UPDATED)
+                               {
+                                       recordEventType = RECORD_UPDATED;
+                                       pTodo = GetTodoN(pTodoChagneInfo->GetTodoId());
+                                       if (pTodo == null)
+                                       {
+                                               if (GetLastResult() == E_OBJ_NOT_FOUND)
+                                               {
+                                                       continue;
+                                               }
+                                               else
+                                               {
+                                                       break;
+                                               }
+                                       }
+                               }
+                               else
+                               {
+                                       recordEventType = RECORD_REMOVED;
+                                       pTodo = new (std::nothrow) CalTodo();
+                                       if (pTodo == null)
+                                       {
+                                               SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+                                               break;
+                                       }
+
+                                       _RecordImpl::GetInstance(*pTodo)->SetRecordId(pTodoChagneInfo->GetTodoId());
+                               }
+
+                               __pIRecordEventListener->OnRecordChangedN(recordEventType, RECORD_TYPE_TODO, *pTodo, null, null);
+
+                               delete pTodo;
+                       }
+
+                       delete pEnum;
+               }
+       }
+}
+
+_CalendarbookImpl*
+_CalendarbookImpl::GetInstance(Calendarbook& calendarbook)
+{
+       return calendarbook.__pCalendarbookImpl;
+}
+
+const _CalendarbookImpl*
+_CalendarbookImpl::GetInstance(const Calendarbook& calendarbook)
+{
+       return calendarbook.__pCalendarbookImpl;
+}
+
+}}     //OSP::Social
diff --git a/src/FScl_CalendarbookRecordRetrivalEvent.cpp b/src/FScl_CalendarbookRecordRetrivalEvent.cpp
new file mode 100644 (file)
index 0000000..76d2d54
--- /dev/null
@@ -0,0 +1,67 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_CalendarbookRecordRetrivalEvent.cpp
+ * @brief      This is the implementation file for the _CalendarbookRecordRetrivalEvent class.
+ *
+ * This file contains definitions of @e _CalendarbookRecordRetrivalEvent class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FSclIRecordListener.h>
+#include "FScl_CalendarbookRecordRetrivalEvent.h"
+#include "FScl_CalendarbookRecordRetrivalEventArg.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Social
+{
+
+_CalendarbookRecordRetrivalEvent::_CalendarbookRecordRetrivalEvent(void)
+{
+       // empty body
+}
+
+_CalendarbookRecordRetrivalEvent::~_CalendarbookRecordRetrivalEvent(void)
+{
+       // emtpy body
+}
+
+result
+_CalendarbookRecordRetrivalEvent::Construct(void)
+{
+       result r = E_SUCCESS;
+
+       r = _Event::Initialize();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] This is not an event-driven thread.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+void
+_CalendarbookRecordRetrivalEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
+{
+       IRecordListener* pIRecordListener = dynamic_cast<IRecordListener*>(&listener);
+       const _CalendarbookRecordRetrivalEventArg* pEventArg = dynamic_cast<const _CalendarbookRecordRetrivalEventArg*>(&arg);
+
+       if (pIRecordListener != null && pEventArg != null)
+       {
+               pIRecordListener->OnRecordsReceivedN(pEventArg->GetRequestId(), pEventArg->GetEventInstanceList(), pEventArg->GetRequestResult());
+       }
+}
+
+}} // Tizen::Social
diff --git a/src/FScl_CalendarbookRecordRetrivalEvent.h b/src/FScl_CalendarbookRecordRetrivalEvent.h
new file mode 100644 (file)
index 0000000..9e67adf
--- /dev/null
@@ -0,0 +1,66 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_CalendarbookRecordRetrivalEvent.h
+ * @brief      This is the header file for the _CalendarbookRecordRetrivalEvent class.
+ *
+ * This file contains the declarations of _CalendarbookRecordRetrivalEvent.
+ */
+
+
+#ifndef _FSCL_INTERNAL_CALENDARBOOK_RECORD_RETRIVAL_EVENT_H_
+#define _FSCL_INTERNAL_CALENDARBOOK_RECORD_RETRIVAL_EVENT_H_
+
+#include <FBaseResult.h>
+#include <FBaseTypes.h>
+#include <FBaseRt_Event.h>
+
+namespace Tizen { namespace Base { namespace Runtime
+{
+class IEventListener;
+class IEventArg;
+}}}
+
+namespace Tizen { namespace Social
+{
+
+class _CalendarbookRecordRetrivalEvent
+       : public Tizen::Base::Runtime::_Event
+{
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. For full construction, @n
+        * the Construct() method must be called right after calling this constructor.
+        *
+        * @see             Construct()
+        */
+       _CalendarbookRecordRetrivalEvent(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Runtime::_Event::~_Event().
+        */
+       virtual ~_CalendarbookRecordRetrivalEvent(void);
+
+       result Construct(void);
+
+protected:
+       virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+}; // _CalendarbookRecordRetrivalEvent
+
+}} // Tizen::Social
+
+#endif // _FSCL_INTERNAL_CALENDARBOOK_RECORD_RETRIVAL_EVENT_H_
diff --git a/src/FScl_CalendarbookRecordRetrivalEventArg.cpp b/src/FScl_CalendarbookRecordRetrivalEventArg.cpp
new file mode 100644 (file)
index 0000000..18efa90
--- /dev/null
@@ -0,0 +1,59 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_CalendarbookRecordRetrivalEventArg.cpp
+ * @brief      This is the implementation file for the _CalendarbookRecordRetrivalEventArg class.
+ *
+ * This file contains definitions of @e _CalendarbookRecordRetrivalEventArg class.
+ */
+
+#include <FBaseSysLog.h>
+#include "FScl_CalendarbookRecordRetrivalEventArg.h"
+
+namespace Tizen { namespace Social
+{
+_CalendarbookRecordRetrivalEventArg::_CalendarbookRecordRetrivalEventArg(RequestId reqId, Tizen::Base::Collection::IList* pEventInstanceList, result r)
+       : __requestId(reqId)
+       , __pEventInstanceList(pEventInstanceList)
+       , __requestResult(r)
+{
+       // empty body
+}
+
+_CalendarbookRecordRetrivalEventArg::~_CalendarbookRecordRetrivalEventArg(void)
+{
+       // empty body
+}
+
+RequestId
+_CalendarbookRecordRetrivalEventArg::GetRequestId(void) const
+{
+       return __requestId;
+}
+
+Tizen::Base::Collection::IList*
+_CalendarbookRecordRetrivalEventArg::GetEventInstanceList(void) const
+{
+       return __pEventInstanceList;
+}
+
+result
+_CalendarbookRecordRetrivalEventArg::GetRequestResult(void) const
+{
+       return __requestResult;
+}
+
+}}// Tizen::Social
diff --git a/src/FScl_CalendarbookRecordRetrivalEventArg.h b/src/FScl_CalendarbookRecordRetrivalEventArg.h
new file mode 100644 (file)
index 0000000..6af8272
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_CalendarbookRecordRetrivalEventArg.h
+ * @brief      This is the header file for the _CalendarbookRecordRetrivalEventArg class.
+ *
+ * This file contains the declarations of _CalendarbookRecordRetrivalEventArg.
+ */
+
+#ifndef _FSCL_INTERNAL_CALENDARBOOK_RECORD_RETRIVAL_EVENT_ARG_H_
+#define _FSCL_INTERNAL_CALENDARBOOK_RECORD_RETRIVAL_EVENT_ARG_H_
+
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FBaseRtIEventArg.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+}}}
+
+namespace Tizen { namespace Social
+{
+
+class _CalendarbookRecordRetrivalEventArg
+       : public Tizen::Base::Object
+       , public Tizen::Base::Runtime::IEventArg
+{
+public:
+       /**
+        * This is default constructor of this class
+        */
+       _CalendarbookRecordRetrivalEventArg(RequestId reqId, Tizen::Base::Collection::IList* pEventInstanceList, result r);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        */
+       virtual ~_CalendarbookRecordRetrivalEventArg(void);
+
+       RequestId GetRequestId(void) const;
+       Tizen::Base::Collection::IList* GetEventInstanceList(void) const;
+       result GetRequestResult(void) const;
+
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private @n
+        * to prohibit copying of objects.
+        */
+       _CalendarbookRecordRetrivalEventArg(const _CalendarbookRecordRetrivalEventArg& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private @n
+        * to prohibit copying of objects.
+        */
+       _CalendarbookRecordRetrivalEventArg& operator =(const _CalendarbookRecordRetrivalEventArg& rhs);
+
+private:
+       RequestId __requestId;
+       Tizen::Base::Collection::IList* __pEventInstanceList;
+       result __requestResult;
+};
+
+}} // Tizen::Social
+
+#endif // _FSCL_INTERNAL_CALENDARBOOK_RECORD_RETRIVAL_EVENT_ARG_H_
diff --git a/src/FScl_CalendarbookRecordRetrivalThread.cpp b/src/FScl_CalendarbookRecordRetrivalThread.cpp
new file mode 100644 (file)
index 0000000..c9289f6
--- /dev/null
@@ -0,0 +1,125 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_CalendarbookRecordRetrivalThread.cpp
+ * @brief      This is the implementation file for the _CalendarbookRecordRetrivalThread class.
+ *
+ */
+
+#include <FBaseColAllElementsDeleter.h>
+#include <FBaseColIList.h>
+#include <FBaseSysLog.h>
+#include "FScl_CalendarbookImpl.h"
+#include "FScl_CalendarbookRecordRetrivalEvent.h"
+#include "FScl_CalendarbookRecordRetrivalEventArg.h"
+#include "FScl_CalendarbookRecordRetrivalThread.h"
+#include "FScl_CalendarbookDbConnector.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Locales;
+
+namespace Tizen { namespace Social
+{
+
+_CalendarbookRecordRetrivalThread::_CalendarbookRecordRetrivalThread(void)
+       : __requestId(-1)
+       , __pEvent(null)
+       , __pageNo(0)
+       , __countPerPage(0)
+       , __category(EVENT_CATEGORY_ALL)
+{
+       // empty body
+}
+
+_CalendarbookRecordRetrivalThread::~_CalendarbookRecordRetrivalThread(void)
+{
+}
+
+result
+_CalendarbookRecordRetrivalThread::Construct(RequestId requestId, _CalendarbookRecordRetrivalEvent& event
+               , const DateTime& start, const DateTime& end, const TimeZone& timeZone
+               , int pageNo, int countPerPage, unsigned long category)
+{
+       __requestId = requestId;
+       __start = start;
+       __end = end;
+       __timeZone = timeZone;
+       __pageNo = pageNo;
+       __countPerPage = countPerPage;
+       __category = category;
+
+       __pEvent.reset(&event);
+
+       result r = Thread::Construct();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return E_SUCCESS;
+}
+
+Object*
+_CalendarbookRecordRetrivalThread::Run(void)
+{
+       result r = E_SUCCESS;
+       _CalendarbookImpl calendarbookImpl;
+       std::unique_ptr<IList, AllElementsDeleter> pList;
+       std::unique_ptr<_CalendarbookRecordRetrivalEventArg> pEventArg;
+
+       r = calendarbookImpl.Construct();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = _CalendarbookDbConnector::Connect();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       pList.reset(calendarbookImpl.GetEventInstancesCommonN(__start, __end, __timeZone, __pageNo, __countPerPage, __category));
+       r = GetLastResult();
+       SysTryCatch(NID_SCL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pEventArg.reset(new (std::nothrow) _CalendarbookRecordRetrivalEventArg(__requestId, pList.get(), r));
+       SysTryCatch(NID_SCL, pEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       pList.release();
+
+       r = _CalendarbookDbConnector::Disconnect();
+       SysTryCatch(NID_SCL, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       r = __pEvent->Fire(*pEventArg.get());
+       SysTryCatch(NID_SCL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pEventArg.release();
+
+       __pEvent.reset(null);
+
+       return null;
+
+CATCH:
+
+       if (__pEvent != null)
+       {
+               pEventArg.reset(new (std::nothrow) _CalendarbookRecordRetrivalEventArg(__requestId, null, r));
+               if (pEventArg != null)
+               {
+                       __pEvent->Fire(*pEventArg);
+               }
+               __pEvent.reset(null);
+       }
+
+       _CalendarbookDbConnector::Disconnect();
+
+       return null;
+}
+
+}} // Tizen::Social
diff --git a/src/FScl_CalendarbookRecordRetrivalThread.h b/src/FScl_CalendarbookRecordRetrivalThread.h
new file mode 100644 (file)
index 0000000..6b86263
--- /dev/null
@@ -0,0 +1,76 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_CalendarbookRecordRetrivalThread.h
+ * @brief      This is the header file for the _CalendarbookRecordRetrivalThread class.
+ *
+ * This file contains the declarations of _CalendarbookRecordRetrivalThread.
+ */
+
+#ifndef _FSCL_INTERNAL_CALENDARBOOK_RECORD_RETRIVAL_THREAD_H_
+#define _FSCL_INTERNAL_CALENDARBOOK_RECORD_RETRIVAL_THREAD_H_
+
+#include <unique_ptr.h>
+#include <FBaseDateTime.h>
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FBaseRtThread.h>
+#include <FBaseTypes.h>
+#include <FLclTimeZone.h>
+
+namespace Tizen { namespace Social
+{
+
+class _CalendarbookRecordRetrivalEvent;
+
+class _CalendarbookRecordRetrivalThread
+       : public Tizen::Base::Runtime::Thread
+{
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. For full construction, @n
+        * the Construct() method must be called right after calling this constructor.
+        *
+        * @see             Construct()
+        */
+       _CalendarbookRecordRetrivalThread(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Runtime::Thread::~Thread().
+        */
+       virtual ~_CalendarbookRecordRetrivalThread(void);
+
+       result Construct(RequestId requestId, _CalendarbookRecordRetrivalEvent& event
+                       , const Tizen::Base::DateTime& start, const Tizen::Base::DateTime& end, const Tizen::Locales::TimeZone& timeZone
+                       , int pageNo, int countPerPage, unsigned long category);
+
+       virtual Tizen::Base::Object* Run(void);
+
+private:
+       RequestId __requestId;
+       std::unique_ptr<_CalendarbookRecordRetrivalEvent> __pEvent;
+       Tizen::Base::DateTime __start;
+       Tizen::Base::DateTime __end;
+       Tizen::Locales::TimeZone __timeZone;
+       int __pageNo;
+       int __countPerPage;
+       unsigned long __category;
+
+}; // _CalendarbookRecordRetrivalThread
+
+}} // Tizen::Social
+
+#endif // _FSCL_INTERNAL_CALENDARBOOK_RECORD_RETRIVAL_THREAD_H_
diff --git a/src/FScl_CalendarbookUtil.cpp b/src/FScl_CalendarbookUtil.cpp
new file mode 100644 (file)
index 0000000..feaff0c
--- /dev/null
@@ -0,0 +1,826 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_CalendarbookUtil.cpp
+ * @brief              This is the implementation for _CalendarbookUtil class.
+ *
+ * This file contains definitions of @e _CalendarbookUtil class.
+ */
+
+#include <new>
+#include <string.h>
+#include <unique_ptr.h>
+#include <FBaseColIList.h>
+#include <FBaseDateTime.h>
+#include <FBaseResult.h>
+#include <FBaseSysLog.h>
+#include <FBaseUtilStringUtil.h>
+#include <FLclGregorianCalendar.h>
+#include <FLclTimeZone.h>
+#include <FSclReminder.h>
+#include <FApp_AppInfo.h>
+#include <FBase_StringConverter.h>
+#include "FScl_CalendarbookImpl.h"
+#include "FScl_CalendarbookUtil.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+
+namespace Tizen { namespace Social
+{
+
+static const byte _CALENDARBOOK_BYTE_VALUE_9 = 0x09;
+static const int _CALENDARBOOK_DEC_ASCII_MASK = 0x30;
+static const int _CALENDARBOOK_CHAR_ASCII_DIFF = 55;
+
+static const int _CALENDARBOOK_MSEC_UNIT = 1000;
+static const long long _CALENDARBOOK_EPOCH_YEAR_INTERVAL_SECONDS = 62135596800;
+
+static const wchar_t* _EVENT_CATEGORY_DELIMITER = L",";
+static const wchar_t* _EVENT_CATEGORY_APPOINTMENT_STRING = L"Appointment";
+static const wchar_t* _EVENT_CATEGORY_ANNIVERSARY_STRING = L"Anniversary";
+
+static const wchar_t _CALENDARBOOK_UTC_SUFFIX = L'Z';
+static const wchar_t _CALENDARBOOK_TIME_PREFIX = L'T';
+static const wchar_t* _CALENDARBOOK_UTC_TZID = L"TZID=";
+static const wchar_t _CALENDARBOOK_DATE_TIME_DELIMITER = L':';
+static const int _CALENDARBOOK_TZID_INDEX = 5;
+static const int _CALENDARBOOK_UTC_DATE_TIME_VALUE_STRING_LENGTH = 16; // ex :20120629T193000Z
+static const int _CALENDARBOOK_DATE_VALUE_STRING_LENGTH = 8;   // ex :20120629
+static const int _CALENDARBOOK_TIME_VALUE_STRING_LENGTH = 6;   // ex :193000
+static const int _CALENDARBOOK_DATE_YEAR_STRING_LENGTH = 4;
+static const int _CALENDARBOOK_DATE_MONTH_STRING_LENGTH = 2;
+static const int _CALENDARBOOK_DATE_DAY_STRING_LENGTH = 2;
+static const int _CALENDARBOOK_TIME_HOUR_STRING_LENGTH = 2;
+static const int _CALENDARBOOK_TIME_MINUTE_STRING_LENGTH = 2;
+static const int _CALENDARBOOK_TIME_SECOND_STRING_LENGTH = 2;
+static const wchar_t* _CALENDARBOOK_ZERO_STRING = L"0";
+
+static const int _INVALID_MAX_DAYS_OF_MONTH = 0;
+
+long long int
+_CalendarbookUtil::ConvertDateTimeToEpochTime(const DateTime& dateTime)
+{
+       return (dateTime.GetTime().GetTicks() / _CALENDARBOOK_MSEC_UNIT) - _CALENDARBOOK_EPOCH_YEAR_INTERVAL_SECONDS;
+}
+
+DateTime
+_CalendarbookUtil::ConvertEpochTimeToDateTime(long long int dateTime)
+{
+       DateTime tmpDateTime;
+       tmpDateTime.SetValue(TimeSpan((dateTime + _CALENDARBOOK_EPOCH_YEAR_INTERVAL_SECONDS) * _CALENDARBOOK_MSEC_UNIT));
+       return tmpDateTime;
+}
+
+char*
+_CalendarbookUtil::ConvertByteBufferToCharArrayN(const ByteBuffer& byteBuffer)
+{
+       int byteBufferLength = byteBuffer.GetCapacity();
+       char* pCharArray = new (std::nothrow) char[byteBufferLength * 2 + 1];
+       SysTryReturn(NID_SCL, pCharArray != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       const byte* pByteBufferPtr = byteBuffer.GetPointer();
+
+       byte tmpByte = 0;
+
+       for (int i = 0; i < byteBufferLength; i++)
+       {
+               tmpByte = pByteBufferPtr[i] >> 4;
+
+               if (tmpByte <= _CALENDARBOOK_BYTE_VALUE_9)
+               {
+                       pCharArray[i * 2] = tmpByte | _CALENDARBOOK_DEC_ASCII_MASK;
+               }
+               else
+               {
+                       pCharArray[i * 2] = tmpByte + _CALENDARBOOK_CHAR_ASCII_DIFF;
+               }
+
+               tmpByte = pByteBufferPtr[i] & 0x0F;
+
+               if (tmpByte <= _CALENDARBOOK_BYTE_VALUE_9)
+               {
+                       pCharArray[i * 2 + 1] = tmpByte | _CALENDARBOOK_DEC_ASCII_MASK;
+               }
+               else
+               {
+                       pCharArray[i * 2 + 1] = tmpByte + _CALENDARBOOK_CHAR_ASCII_DIFF;
+               }
+       }
+
+       pCharArray[byteBufferLength * 2] = 0;
+
+       return pCharArray;
+}
+
+ByteBuffer*
+_CalendarbookUtil::ConvertCharArrayToByteBufferN(const char* pCharArray)
+{
+       int charArrayLength = strlen(pCharArray);
+       SysTryReturn(NID_SCL, charArrayLength > 0, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       int byteBufferLength = 0;
+       std::unique_ptr<byte[]> pByteArray(new (std::nothrow) byte[charArrayLength/2]);
+       SysTryReturn(NID_SCL, pByteArray != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       bool inProgress = false;
+       char tmpChar = 0;
+       byte tmpByte = 0;
+
+       for (int i = 0; i < charArrayLength; i++)
+       {
+               tmpChar = pCharArray[i];
+
+               if (tmpChar >= '0' && tmpChar <= '9')
+               {
+                       tmpChar &= 0x0F;
+               }
+               else if (tmpChar >= 'A' && tmpChar <= 'F')
+               {
+                       tmpChar -= _CALENDARBOOK_CHAR_ASCII_DIFF;
+               }
+               else
+               {
+                       continue;
+               }
+
+               if (!inProgress)
+               {
+                       tmpByte = tmpChar << 4;
+                       inProgress = true;
+               }
+               else
+               {
+                       pByteArray[byteBufferLength] = tmpByte | tmpChar;
+                       byteBufferLength++;
+                       tmpByte = 0;
+                       inProgress = false;
+               }
+       }
+
+       result r = E_SUCCESS;
+       std::unique_ptr<ByteBuffer> pByteBuffer(new (std::nothrow) ByteBuffer());
+       SysTryReturn(NID_SCL, pByteBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       r = pByteBuffer->Construct(byteBufferLength);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       r = pByteBuffer->SetArray(pByteArray.get(), 0, byteBufferLength);
+       pByteBuffer->Rewind();
+
+       return pByteBuffer.release();
+}
+
+result
+_CalendarbookUtil::ConvertEventAlarmsToReminderList(calendar_record_h calendarRecordHandle, ArrayList& reminderList)
+{
+       unsigned int reminderCount = 0;
+       calendar_record_get_child_record_count(calendarRecordHandle, _calendar_event.calendar_alarm, &reminderCount);
+
+       if (reminderCount == 0)
+       {
+               reminderList.RemoveAll(true);
+               return E_SUCCESS;
+       }
+
+       for (unsigned int i = 0; i< reminderCount; i++)
+       {
+               calendar_record_h tmpAlarmHandle = null;
+               int tmpAlarmTickUnit = CALENDAR_ALARM_NONE;
+               int tmpAlarmTick = 0;
+               long long tmpAlarmTime = 0;
+               char* pTmpAlarmTone = null;
+
+               calendar_record_get_child_record_at_p(calendarRecordHandle, _calendar_event.calendar_alarm, i, &tmpAlarmHandle);
+               calendar_record_get_int(tmpAlarmHandle, _calendar_alarm.tick_unit, &tmpAlarmTickUnit);
+               calendar_record_get_int(tmpAlarmHandle, _calendar_alarm.tick, &tmpAlarmTick);
+               calendar_record_get_lli(tmpAlarmHandle, _calendar_alarm.time, &tmpAlarmTime);
+               calendar_record_get_str_p(tmpAlarmHandle, _calendar_alarm.tone, &pTmpAlarmTone);
+
+               std::unique_ptr<Reminder> pReminder(new (std::nothrow) Reminder());
+               SysTryReturnResult(NID_SCL, pReminder != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               pReminder->SetSoundFile(pTmpAlarmTone);
+
+               switch (tmpAlarmTickUnit)
+               {
+               case CALENDAR_ALARM_TIME_UNIT_MINUTE:
+                       pReminder->SetTimeOffset(REMINDER_TIME_UNIT_MINUTE, tmpAlarmTick);
+                       break;
+
+               case CALENDAR_ALARM_TIME_UNIT_HOUR:
+                       pReminder->SetTimeOffset(REMINDER_TIME_UNIT_HOUR, tmpAlarmTick);
+                       break;
+
+               case CALENDAR_ALARM_TIME_UNIT_DAY:
+                       pReminder->SetTimeOffset(REMINDER_TIME_UNIT_DAY, tmpAlarmTick);
+                       break;
+
+               case CALENDAR_ALARM_TIME_UNIT_WEEK:
+                       pReminder->SetTimeOffset(REMINDER_TIME_UNIT_WEEK, tmpAlarmTick);
+                       break;
+
+               case CALENDAR_ALARM_TIME_UNIT_MONTH:
+                       {
+                               calendar_time_s startCalendarTime;
+                               DateTime tmpStartTime;
+
+                               calendar_record_get_caltime(calendarRecordHandle, _calendar_event.start_time, &startCalendarTime);
+                               if (startCalendarTime.type == CALENDAR_TIME_UTIME)
+                               {
+                                       tmpStartTime = _CalendarbookUtil::ConvertEpochTimeToDateTime(startCalendarTime.time.utime);
+                               }
+                               else
+                               {
+                                       tmpStartTime.SetValue(startCalendarTime.time.date.year, startCalendarTime.time.date.month, startCalendarTime.time.date.mday);
+                               }
+
+                               tmpStartTime.AddMonths(-1);
+                               int maxDays = GetMaxDaysOfMonth(tmpStartTime.GetYear(), tmpStartTime.GetMonth());
+
+                               pReminder->SetTimeOffset(REMINDER_TIME_UNIT_DAY, tmpAlarmTick * maxDays);
+                       }
+                       break;
+
+               case CALENDAR_ALARM_TIME_UNIT_SPECIFIC:
+                       if (Tizen::App::_AppInfo::GetApiVersion() > _API_VERSION_2_0)
+                       {
+                               pReminder->SetAbsoluteTime(_CalendarbookUtil::ConvertEpochTimeToDateTime(tmpAlarmTime));
+                       }
+                       break;
+
+               default :
+                       break;
+               }
+
+               result r = reminderList.Add(pReminder.get());
+               SysTryReturnResult(NID_SCL, !IsFailed(r), r, "Propagating.");
+
+               pReminder.release();
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_CalendarbookUtil::ConvertTodoAlarmsToReminderList(calendar_record_h calendarRecordHandle, ArrayList& reminderList)
+{
+       unsigned int reminderCount = 0;
+       calendar_record_get_child_record_count(calendarRecordHandle, _calendar_todo.calendar_alarm, &reminderCount);
+
+       if (reminderCount == 0)
+       {
+               reminderList.RemoveAll(true);
+               return E_SUCCESS;
+       }
+
+       for (unsigned int i = 0; i< reminderCount; i++)
+       {
+               calendar_record_h tmpAlarmHandle = null;
+               int tmpAlarmTickUnit = CALENDAR_ALARM_NONE;
+               int tmpAlarmTick = 0;
+               long long tmpAlarmTime = 0;
+               char* pTmpAlarmTone = null;
+
+               calendar_record_get_child_record_at_p(calendarRecordHandle, _calendar_todo.calendar_alarm, i, &tmpAlarmHandle);
+               calendar_record_get_int(tmpAlarmHandle, _calendar_alarm.tick_unit, &tmpAlarmTickUnit);
+               calendar_record_get_int(tmpAlarmHandle, _calendar_alarm.tick, &tmpAlarmTick);
+               calendar_record_get_lli(tmpAlarmHandle, _calendar_alarm.time, &tmpAlarmTime);
+               calendar_record_get_str_p(tmpAlarmHandle, _calendar_alarm.tone, &pTmpAlarmTone);
+
+               std::unique_ptr<Reminder> pReminder(new (std::nothrow) Reminder());
+               SysTryReturnResult(NID_SCL, pReminder != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               pReminder->SetSoundFile(pTmpAlarmTone);
+
+               switch (tmpAlarmTickUnit)
+               {
+               case CALENDAR_ALARM_TIME_UNIT_MINUTE:
+                       pReminder->SetTimeOffset(REMINDER_TIME_UNIT_MINUTE, tmpAlarmTick);
+                       break;
+
+               case CALENDAR_ALARM_TIME_UNIT_HOUR:
+                       pReminder->SetTimeOffset(REMINDER_TIME_UNIT_HOUR, tmpAlarmTick);
+                       break;
+
+               case CALENDAR_ALARM_TIME_UNIT_DAY:
+                       pReminder->SetTimeOffset(REMINDER_TIME_UNIT_DAY, tmpAlarmTick);
+                       break;
+
+               case CALENDAR_ALARM_TIME_UNIT_WEEK:
+                       pReminder->SetTimeOffset(REMINDER_TIME_UNIT_WEEK, tmpAlarmTick);
+                       break;
+
+               case CALENDAR_ALARM_TIME_UNIT_MONTH:
+                       {
+                               calendar_time_s startCalendarTime;
+                               DateTime tmpStartTime;
+
+                               calendar_record_get_caltime(calendarRecordHandle, _calendar_todo.start_time, &startCalendarTime);
+                               if (startCalendarTime.type == CALENDAR_TIME_UTIME)
+                               {
+                                       tmpStartTime = _CalendarbookUtil::ConvertEpochTimeToDateTime(startCalendarTime.time.utime);
+                               }
+                               else
+                               {
+                                       tmpStartTime.SetValue(startCalendarTime.time.date.year, startCalendarTime.time.date.month, startCalendarTime.time.date.mday);
+                               }
+
+                               tmpStartTime.AddMonths(-1);
+                               int maxDays = GetMaxDaysOfMonth(tmpStartTime.GetYear(), tmpStartTime.GetMonth());
+
+                               pReminder->SetTimeOffset(REMINDER_TIME_UNIT_DAY, tmpAlarmTick * maxDays);
+                       }
+                       break;
+
+               case CALENDAR_ALARM_TIME_UNIT_SPECIFIC:
+                       if (Tizen::App::_AppInfo::GetApiVersion() > _API_VERSION_2_0)
+                       {
+                               pReminder->SetAbsoluteTime(_CalendarbookUtil::ConvertEpochTimeToDateTime(tmpAlarmTime));
+                       }
+                       break;
+
+               default :
+                       break;
+               }
+
+               result r = reminderList.Add(pReminder.get());
+               SysTryReturnResult(NID_SCL, !IsFailed(r), r, "Propagating.");
+
+               pReminder.release();
+       }
+
+       return E_SUCCESS;
+}
+
+void
+_CalendarbookUtil::ConvertDateTimeToCalTime(const DateTime& dateTime, calendar_time_s& convertedCalTime)
+{
+       convertedCalTime.type = CALENDAR_TIME_UTIME;
+       convertedCalTime.time.utime = ConvertDateTimeToEpochTime(dateTime);
+}
+
+void
+_CalendarbookUtil::ConvertDateToCalTime(const DateTime& dateTime, calendar_time_s& convertedCalTime)
+{
+       convertedCalTime.type = CALENDAR_TIME_LOCALTIME;
+       convertedCalTime.time.date.year = dateTime.GetYear();
+       convertedCalTime.time.date.month = dateTime.GetMonth();
+       convertedCalTime.time.date.mday = dateTime.GetDay();
+}
+
+result
+_CalendarbookUtil::ConvertRRuleDateTimeStringToDateTime(const String& dateTimeString, DateTime& dateTime, Tizen::Locales::TimeZone& timeZone, bool& isDate)
+{
+       result r = E_SUCCESS;
+       String dateValue;
+       String timeValue;
+
+       // Split the dateTimeString into date value, time value and time zone
+       if (dateTimeString.GetLength() == _CALENDARBOOK_DATE_VALUE_STRING_LENGTH)
+       {
+               dateValue = dateTimeString;
+               isDate = true;
+       }
+       else if (dateTimeString.GetLength() == _CALENDARBOOK_UTC_DATE_TIME_VALUE_STRING_LENGTH)
+       {
+               int timeValueIndex = 0;
+               int suffixIndex = 0;
+               r = dateTimeString.LastIndexOf(_CALENDARBOOK_TIME_PREFIX, _CALENDARBOOK_UTC_DATE_TIME_VALUE_STRING_LENGTH - 1, timeValueIndex);
+               SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer());   // There is no T prefix
+               SysTryReturnResult(NID_SCL, timeValueIndex == _CALENDARBOOK_DATE_VALUE_STRING_LENGTH
+                               , E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); //The position of T is wrong
+
+               r = dateTimeString.LastIndexOf(_CALENDARBOOK_UTC_SUFFIX, _CALENDARBOOK_UTC_DATE_TIME_VALUE_STRING_LENGTH - 1, suffixIndex);
+               SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer());   // There is no Z suffix
+               SysTryReturnResult(NID_SCL, suffixIndex == _CALENDARBOOK_UTC_DATE_TIME_VALUE_STRING_LENGTH - 1
+                               , E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); //The position of Z is wrong
+
+               r = dateTimeString.SubString(0, _CALENDARBOOK_DATE_VALUE_STRING_LENGTH, dateValue);
+               SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer());
+               r = dateTimeString.SubString(_CALENDARBOOK_DATE_VALUE_STRING_LENGTH + 1
+                               , _CALENDARBOOK_TIME_VALUE_STRING_LENGTH, timeValue);
+               SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer());
+
+               isDate = false;
+       }
+       else if (dateTimeString.GetLength() > _CALENDARBOOK_UTC_DATE_TIME_VALUE_STRING_LENGTH)  // including timezone ID
+       {
+               String timeZoneId;
+               int dateValueIndex = 0;
+
+               r = dateTimeString.LastIndexOf(_CALENDARBOOK_UTC_TZID, dateTimeString.GetLength() - 1, dateValueIndex);
+               SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer());   // There is no TZID
+               SysTryReturnResult(NID_SCL, dateValueIndex == 0, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); //The position of TZID is wrong
+
+               r = dateTimeString.LastIndexOf(_CALENDARBOOK_DATE_TIME_DELIMITER, dateTimeString.GetLength() - 1, dateValueIndex);
+               SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer());   // There is no TZID
+
+               r = dateTimeString.SubString(_CALENDARBOOK_TZID_INDEX, dateValueIndex - _CALENDARBOOK_TZID_INDEX, timeZoneId);
+               SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer());
+
+               dateValueIndex += 1;
+
+               r = dateTimeString.SubString(dateValueIndex, _CALENDARBOOK_DATE_VALUE_STRING_LENGTH, dateValue);
+               SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer());
+               r = dateTimeString.SubString(dateValueIndex +_CALENDARBOOK_DATE_VALUE_STRING_LENGTH + 1
+                               , _CALENDARBOOK_TIME_VALUE_STRING_LENGTH, timeValue);
+               SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer());
+
+               r = Tizen::Locales::TimeZone::GetTimeZone(timeZoneId, timeZone);
+               SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer());   // not supported timezone ID
+               isDate = false;
+       }
+       else
+       {
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. date time string = %S", GetErrorMessage(E_INVALID_ARG), dateTimeString.GetPointer());
+               return E_INVALID_ARG;
+       }
+
+       int tmpIndex = 0;
+       String tmpString;
+       int yearValue = 0;
+       int monthValue = 0;
+       int dayValue = 0;
+       int hourValue = 0;
+       int minuteValue = 0;
+       int secondValue = 0;
+
+       // Parse date value
+       r = dateValue.SubString(tmpIndex, _CALENDARBOOK_DATE_YEAR_STRING_LENGTH, tmpString);
+       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer());
+       r = Integer::Parse(tmpString, yearValue);
+       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer());
+       tmpIndex += _CALENDARBOOK_DATE_YEAR_STRING_LENGTH;
+
+       r = dateValue.SubString(tmpIndex, _CALENDARBOOK_DATE_MONTH_STRING_LENGTH, tmpString);
+       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer());
+       r = Integer::Parse(tmpString, monthValue);
+       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer());
+       tmpIndex += _CALENDARBOOK_DATE_MONTH_STRING_LENGTH;
+
+       r = dateValue.SubString(tmpIndex, _CALENDARBOOK_DATE_DAY_STRING_LENGTH, tmpString);
+       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer());
+       r = Integer::Parse(tmpString, dayValue);
+       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer());
+       tmpIndex += _CALENDARBOOK_DATE_DAY_STRING_LENGTH;
+
+       if (!isDate)
+       {
+               // Parse time value
+               tmpIndex = 0;
+               r = timeValue.SubString(tmpIndex, _CALENDARBOOK_TIME_HOUR_STRING_LENGTH, tmpString);
+               SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer());
+               r = Integer::Parse(tmpString, hourValue);
+               SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer());
+               tmpIndex += _CALENDARBOOK_TIME_HOUR_STRING_LENGTH;
+
+               r = timeValue.SubString(tmpIndex, _CALENDARBOOK_TIME_MINUTE_STRING_LENGTH, tmpString);
+               SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer());
+               r = Integer::Parse(tmpString, minuteValue);
+               SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer());
+               tmpIndex += _CALENDARBOOK_TIME_MINUTE_STRING_LENGTH;
+
+               r = timeValue.SubString(tmpIndex, _CALENDARBOOK_TIME_SECOND_STRING_LENGTH, tmpString);
+               SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer());
+               r = Integer::Parse(tmpString, secondValue);
+               SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer());
+               tmpIndex += _CALENDARBOOK_TIME_SECOND_STRING_LENGTH;
+       }
+
+       r = dateTime.SetValue(yearValue, monthValue, dayValue, hourValue, minuteValue, secondValue);
+       SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer());
+
+       return E_SUCCESS;
+}
+
+String
+_CalendarbookUtil::ConvertDateTimeToRRuleDateTimeString(const Tizen::Base::DateTime& dateTime, bool isDate)
+{
+       String exdateString;
+
+       exdateString.Append(dateTime.GetYear());
+
+       if (dateTime.GetMonth() < 10)
+       {
+               exdateString.Append(_CALENDARBOOK_ZERO_STRING);
+       }
+       exdateString.Append(dateTime.GetMonth());
+
+       if (dateTime.GetDay() < 10)
+       {
+               exdateString.Append(_CALENDARBOOK_ZERO_STRING);
+       }
+       exdateString.Append(dateTime.GetDay());
+
+       if (!isDate)
+       {
+               exdateString.Append(_CALENDARBOOK_TIME_PREFIX);
+
+               if (dateTime.GetHour() < 10)
+               {
+                       exdateString.Append(_CALENDARBOOK_ZERO_STRING);
+               }
+               exdateString.Append(dateTime.GetHour());
+
+               if (dateTime.GetMinute() < 10)
+               {
+                       exdateString.Append(_CALENDARBOOK_ZERO_STRING);
+               }
+               exdateString.Append(dateTime.GetMinute());
+
+               if (dateTime.GetSecond() < 10)
+               {
+                       exdateString.Append(_CALENDARBOOK_ZERO_STRING);
+               }
+               exdateString.Append(dateTime.GetSecond());
+
+               exdateString.Append(_CALENDARBOOK_UTC_SUFFIX);
+       }
+
+       return exdateString;
+}
+
+calendar_event_status_e
+_CalendarbookUtil::ConvertEventStatusToCSEventStatus(int status)
+{
+       calendar_event_status_e convertedEventStatus = CALENDAR_EVENT_STATUS_NONE;
+
+       switch (status)
+       {
+       case EVENT_STATUS_NONE:
+               convertedEventStatus = CALENDAR_EVENT_STATUS_NONE;
+               break;
+
+       case EVENT_STATUS_TENTATIVE:
+               convertedEventStatus = CALENDAR_EVENT_STATUS_TENTATIVE;
+               break;
+
+       case EVENT_STATUS_CONFIRMED:
+               convertedEventStatus = CALENDAR_EVENT_STATUS_CONFIRMED;
+               break;
+
+       case EVENT_STATUS_CANCELLED:
+               convertedEventStatus = CALENDAR_EVENT_STATUS_CANCELLED;
+               break;
+
+       default :
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. status = %d", GetErrorMessage(E_INVALID_ARG), status);
+               convertedEventStatus = CALENDAR_EVENT_STATUS_NONE;
+               break;
+       }
+
+       return convertedEventStatus;
+}
+
+calendar_event_busy_status_e
+_CalendarbookUtil::ConvertBusyStatusToCSEventBusyStatus(int busyStatus)
+{
+       calendar_event_busy_status_e convertedBusyStatus = CALENDAR_EVENT_BUSY_STATUS_FREE;
+
+       switch (busyStatus)
+       {
+       case BUSY_STATUS_FREE:
+               convertedBusyStatus = CALENDAR_EVENT_BUSY_STATUS_FREE;
+               break;
+
+       case BUSY_STATUS_BUSY:
+               convertedBusyStatus = CALENDAR_EVENT_BUSY_STATUS_BUSY;
+               break;
+
+       case BUSY_STATUS_UNAVAILABLE:
+               convertedBusyStatus = CALENDAR_EVENT_BUSY_STATUS_UNAVAILABLE;
+               break;
+
+       case BUSY_STATUS_TENTATIVE:
+               convertedBusyStatus = CALENDAR_EVENT_BUSY_STATUS_TENTATIVE;
+               break;
+
+       default :
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. busyStatus = %d", GetErrorMessage(E_INVALID_ARG), busyStatus);
+               convertedBusyStatus = CALENDAR_EVENT_BUSY_STATUS_FREE;
+               break;
+       }
+
+       return convertedBusyStatus;
+}
+
+calendar_event_priority_e
+_CalendarbookUtil::ConvertEventPriorityToCSEventPriority(int priority)
+{
+       calendar_event_priority_e convertedPriority = CALENDAR_EVENT_PRIORITY_NORMAL;
+
+       switch (priority)
+       {
+       case EVENT_PRIORITY_LOW:
+               convertedPriority = CALENDAR_EVENT_PRIORITY_LOW;
+               break;
+
+       case EVENT_PRIORITY_NORMAL:
+               convertedPriority = CALENDAR_EVENT_PRIORITY_NORMAL;
+               break;
+
+       case EVENT_PRIORITY_HIGH:
+               convertedPriority = CALENDAR_EVENT_PRIORITY_HIGH;
+               break;
+
+       default :
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. priority = %d", GetErrorMessage(E_INVALID_ARG), priority);
+               convertedPriority = CALENDAR_EVENT_PRIORITY_NORMAL;
+               break;
+       }
+
+       return convertedPriority;
+}
+
+calendar_sensitivity_e
+_CalendarbookUtil::ConvertSensitivityToCSSensitivity(int sensitivity)
+{
+       calendar_sensitivity_e convertedSensitivity = CALENDAR_SENSITIVITY_PUBLIC;
+
+       switch (sensitivity)
+       {
+       case SENSITIVITY_PUBLIC:
+               convertedSensitivity = CALENDAR_SENSITIVITY_PUBLIC;
+               break;
+
+       case SENSITIVITY_PRIVATE:
+               convertedSensitivity = CALENDAR_SENSITIVITY_PRIVATE;
+               break;
+
+       case SENSITIVITY_CONFIDENTIAL:
+               convertedSensitivity = CALENDAR_SENSITIVITY_CONFIDENTIAL;
+               break;
+
+       default :
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. sensitivity = %d", GetErrorMessage(E_INVALID_ARG), sensitivity);
+               convertedSensitivity = CALENDAR_SENSITIVITY_PUBLIC;
+               break;
+       }
+
+       return convertedSensitivity;
+}
+
+calendar_todo_status_e
+_CalendarbookUtil::ConvertTodoStatusToCSTodoStatus(int status)
+{
+       calendar_todo_status_e convertedTodoStatus = CALENDAR_TODO_STATUS_NONE;
+
+       switch (status)
+       {
+       case TODO_STATUS_NONE:
+               convertedTodoStatus = CALENDAR_TODO_STATUS_NONE;
+               break;
+
+       case TODO_STATUS_NEEDS_ACTION:
+               convertedTodoStatus = CALENDAR_TODO_STATUS_NEEDS_ACTION;
+               break;
+
+       case TODO_STATUS_COMPLETED:
+               convertedTodoStatus = CALENDAR_TODO_STATUS_COMPLETED;
+               break;
+
+       case TODO_STATUS_IN_PROCESS:
+               convertedTodoStatus = CALENDAR_TODO_STATUS_IN_PROCESS;
+               break;
+
+       case TODO_STATUS_CANCELLED:
+               convertedTodoStatus = CALENDAR_TODO_STATUS_CANCELED;
+               break;
+
+       default :
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. status = %d", GetErrorMessage(E_INVALID_ARG), status);
+               convertedTodoStatus = CALENDAR_TODO_STATUS_NONE;
+               break;
+       }
+
+       return convertedTodoStatus;
+}
+
+calendar_todo_priority_e
+_CalendarbookUtil::ConvertTodoPriorityToCSTodoPriority(int priority)
+{
+       calendar_todo_priority_e convertedPriority = CALENDAR_TODO_PRIORITY_NONE;
+
+       switch (priority)
+       {
+       case TODO_PRIORITY_LOW:
+               convertedPriority = CALENDAR_TODO_PRIORITY_LOW;
+               break;
+
+       case TODO_PRIORITY_NORMAL:
+               convertedPriority = CALENDAR_TODO_PRIORITY_NORMAL;
+               break;
+
+       case TODO_PRIORITY_HIGH:
+               convertedPriority = CALENDAR_TODO_PRIORITY_HIGH;
+               break;
+
+       default :
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. priority = %d", GetErrorMessage(E_INVALID_ARG), priority);
+               convertedPriority = CALENDAR_TODO_PRIORITY_NONE;
+               break;
+       }
+
+       return convertedPriority;
+}
+
+int
+_CalendarbookUtil::ConvertCalendarItemTypeToCSCalendarbookType(int itemType)
+{
+       int storeType = CALENDAR_BOOK_TYPE_EVENT | CALENDAR_BOOK_TYPE_TODO;
+
+       switch (itemType)
+       {
+       case CALENDAR_ITEM_TYPE_EVENT_ONLY:
+               storeType = CALENDAR_BOOK_TYPE_EVENT;
+               break;
+
+       case CALENDAR_ITEM_TYPE_TODO_ONLY:
+               storeType = CALENDAR_BOOK_TYPE_TODO;
+               break;
+
+       case CALENDAR_ITEM_TYPE_EVENT_AND_TODO:
+               storeType = CALENDAR_BOOK_TYPE_EVENT | CALENDAR_BOOK_TYPE_TODO;
+               break;
+
+       default :
+               storeType = CALENDAR_BOOK_TYPE_EVENT | CALENDAR_BOOK_TYPE_TODO;
+               break;
+       }
+
+       return storeType;
+}
+
+EventCategory
+_CalendarbookUtil::ConvertCSCategoriesToEventCategory(const char* pCategories)
+{
+       result r = E_SUCCESS;
+
+       EventCategory eventCategory = EVENT_CATEGORY_APPOINTMENT;
+       String tmpString(pCategories);
+       String delim(_EVENT_CATEGORY_DELIMITER);
+       String token;
+
+       StringTokenizer strTok(tmpString, delim);
+       while (strTok.HasMoreTokens())
+       {
+               r = strTok.GetNextToken(token);
+               SysTryReturn(NID_SCL, r == E_SUCCESS, EVENT_CATEGORY_APPOINTMENT, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               if (token == _EVENT_CATEGORY_APPOINTMENT_STRING)
+               {
+                       eventCategory = EVENT_CATEGORY_APPOINTMENT;
+                       break;
+               }
+               else if (token == _EVENT_CATEGORY_ANNIVERSARY_STRING)
+               {
+                       eventCategory = EVENT_CATEGORY_ANNIVERSARY;
+                       break;
+               }
+       }
+
+       return eventCategory;
+}
+
+int
+_CalendarbookUtil::GetMaxDaysOfMonth(int year, int month)
+{
+       ClearLastResult();
+
+       int maxDaysOfMonth = 0;
+
+       std::unique_ptr<Tizen::Locales::Calendar> pGregorianCalendar(Tizen::Locales::Calendar::CreateInstanceN(Tizen::Locales::CALENDAR_GREGORIAN));
+       SysTryReturn(NID_SCL, pGregorianCalendar != null, _INVALID_MAX_DAYS_OF_MONTH, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       pGregorianCalendar->SetTimeField(Tizen::Locales::TIME_FIELD_YEAR, year);
+       pGregorianCalendar->SetTimeField(Tizen::Locales::TIME_FIELD_MONTH, month);
+
+       maxDaysOfMonth = pGregorianCalendar->GetActualMaxTimeField(Tizen::Locales::TIME_FIELD_DAY_OF_MONTH);
+
+       return maxDaysOfMonth;
+}
+
+bool
+_CalendarbookUtil::CheckValidDateTime(const DateTime& dateTime)
+{
+       if (dateTime < _CalendarbookImpl::GetMinDateTime() || dateTime > _CalendarbookImpl::GetMaxDateTime())
+       {
+               return false;
+       }
+
+       return true;
+}
+
+}}     // Tizen::Social
diff --git a/src/FScl_CalendarbookUtil.h b/src/FScl_CalendarbookUtil.h
new file mode 100644 (file)
index 0000000..04bffd2
--- /dev/null
@@ -0,0 +1,143 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_CalendarbookUtil.h
+ * @brief      This is the header file for the _CalendarbookUtil class.
+ *
+ * This header file contains the declarations of the _CalendarbookUtil class.
+ */
+
+#ifndef _FSCL_INTERNAL_CALENDARBOOK_UTIL_H_
+#define _FSCL_INTERNAL_CALENDARBOOK_UTIL_H_
+
+#include <calendar2.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+class DateTime;
+class ByteBuffer;
+namespace Collection
+{
+class ArrayList;
+}
+}}
+
+namespace Tizen { namespace Locales
+{
+class TimeZone;
+}}
+
+namespace Tizen { namespace Social
+{
+
+class _CalendarRecord
+{
+public :
+       _CalendarRecord()
+               : __recordHandle(null)
+       {
+       }
+
+       _CalendarRecord(calendar_record_h recordHandle)
+               : __recordHandle(recordHandle)
+       {
+       }
+
+       ~_CalendarRecord(void)
+       {
+               if (__recordHandle)
+               {
+                       calendar_record_destroy(__recordHandle, true);
+               }
+       }
+
+       const calendar_record_h GetHandle(void) const
+       {
+               return __recordHandle;
+       }
+
+       calendar_record_h GetHandle(void)
+       {
+               return __recordHandle;
+       }
+
+       calendar_record_h ReleaseHandle(void)
+       {
+               calendar_record_h recordHandle = __recordHandle;
+               __recordHandle = null;
+               return recordHandle;
+       }
+
+       void ResetHandle(calendar_record_h recordHandle)
+       {
+               if (__recordHandle)
+               {
+                       calendar_record_destroy(__recordHandle, true);
+               }
+               __recordHandle = recordHandle;
+       }
+
+private :
+       calendar_record_h __recordHandle;
+};
+
+/**
+ *     @class  _CalendarbookUtil
+ *     @brief  This class represents the calendarbook util.
+ *
+ * The _CalendarbookUtil class support various utilities.
+ */
+class  _CalendarbookUtil
+{
+public:
+       static result ConvertEventAlarmsToReminderList(calendar_record_h calendarRecordHandle, Tizen::Base::Collection::ArrayList& reminderList);
+       static result ConvertTodoAlarmsToReminderList(calendar_record_h calendarRecordHandle, Tizen::Base::Collection::ArrayList& reminderList);
+       static char* ConvertByteBufferToCharArrayN(const Tizen::Base::ByteBuffer& byteBuffer);
+       static Tizen::Base::ByteBuffer* ConvertCharArrayToByteBufferN(const char* pCharArray);
+
+       static long long int ConvertDateTimeToEpochTime(const Tizen::Base::DateTime& dateTime);
+       static Tizen::Base::DateTime ConvertEpochTimeToDateTime(long long int dateTime);
+       static void ConvertDateTimeToCalTime(const Tizen::Base::DateTime& dateTime, calendar_time_s& convertedCalTime);
+       static void ConvertDateToCalTime(const Tizen::Base::DateTime& dateTime, calendar_time_s& convertedCalTime);
+
+       static Tizen::Base::String ConvertDateTimeToRRuleDateTimeString(const Tizen::Base::DateTime& dateTime, bool isDate);
+       static result ConvertRRuleDateTimeStringToDateTime(const Tizen::Base::String& dateTimeString, Tizen::Base::DateTime& dateTime, Tizen::Locales::TimeZone& timeZone, bool& isDate);
+
+       static calendar_event_status_e ConvertEventStatusToCSEventStatus(int status);
+       static calendar_event_busy_status_e ConvertBusyStatusToCSEventBusyStatus(int busyStatus);
+       static calendar_event_priority_e ConvertEventPriorityToCSEventPriority(int priority);
+       static calendar_sensitivity_e ConvertSensitivityToCSSensitivity(int sensitivity);
+       static calendar_todo_status_e ConvertTodoStatusToCSTodoStatus(int status);
+       static calendar_todo_priority_e ConvertTodoPriorityToCSTodoPriority(int priority);
+       static int ConvertCalendarItemTypeToCSCalendarbookType(int itemType);
+       static EventCategory ConvertCSCategoriesToEventCategory(const char* pCategories);
+
+       static int GetMaxDaysOfMonth(int year, int month);
+       static bool CheckValidDateTime(const Tizen::Base::DateTime& dateTime);
+
+private:
+
+       /**
+        * This destructor is intentionally declared as private because this class cannot be constructed.
+        */
+       ~_CalendarbookUtil(void);
+};     // _CalendarbookUtil
+
+}}     // Tizen::Social
+
+#endif//_FSCL_INTERNAL_CALENDARBOOK_UTIL_H_
diff --git a/src/FScl_CategoryChangeInfoImpl.cpp b/src/FScl_CategoryChangeInfoImpl.cpp
new file mode 100644 (file)
index 0000000..24b9cee
--- /dev/null
@@ -0,0 +1,188 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_CategoryChangeInfoImpl.cpp
+ * @brief              This is the implementation for _CategoryChangeInfoImpl class.
+ *
+ * This file contains definitions of @e _CategoryChangeInfoImpl class.
+ */
+
+#include <new>
+#include <FBaseResult.h>
+#include <FSclCategoryChangeInfo.h>
+#include <FBaseSysLog.h>
+#include "FScl_RecordImpl.h"
+#include "FScl_CategoryChangeInfoImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Social
+{
+
+_CategoryChangeInfoImpl::_CategoryChangeInfoImpl(void)
+       : __categoryId(INVALID_RECORD_ID)
+       , __addressbookId(INVALID_ADDRESSBOOK_ID)
+       , __version(0)
+       , __changeType(RECORD_CHANGE_TYPE_ADDED)
+{
+       // empty body
+}
+
+_CategoryChangeInfoImpl::_CategoryChangeInfoImpl(const _CategoryChangeInfoImpl& rhs)
+{
+       __categoryId = rhs.__categoryId;
+       __addressbookId = rhs.__addressbookId;
+       __version = rhs.__version;
+       __changeType = rhs.__changeType;
+}
+
+_CategoryChangeInfoImpl::~_CategoryChangeInfoImpl(void)
+{
+       // empty body
+}
+
+_CategoryChangeInfoImpl&
+_CategoryChangeInfoImpl::operator =(const _CategoryChangeInfoImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __categoryId = rhs.__categoryId;
+       __addressbookId = rhs.__addressbookId;
+       __version = rhs.__version;
+       __changeType = rhs.__changeType;
+
+       return *this;
+}
+
+bool
+_CategoryChangeInfoImpl::operator ==(const _CategoryChangeInfoImpl& rhs) const
+{
+       if (__categoryId != rhs.__categoryId)
+       {
+               return false;
+       }
+
+       if (__addressbookId != rhs.__addressbookId)
+       {
+               return false;
+       }
+
+       if (__version != rhs.__version)
+       {
+               return false;
+       }
+
+       if (__changeType != rhs.__changeType)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+
+bool
+_CategoryChangeInfoImpl::Equals(const Object& rhs) const
+{
+       const _CategoryChangeInfoImpl* pCategoryChangeInfoImpl = dynamic_cast<const _CategoryChangeInfoImpl*>(&rhs);
+
+       if (pCategoryChangeInfoImpl == null)
+       {
+               return false;
+       }
+
+       return *this == *pCategoryChangeInfoImpl;
+}
+
+int
+_CategoryChangeInfoImpl::GetHashCode(void) const
+{
+       int hashCode = 0;
+
+       hashCode = __categoryId;
+       hashCode += __addressbookId;
+       hashCode += __version;
+
+       hashCode += __changeType;
+
+       return hashCode;
+}
+
+AddressbookId
+_CategoryChangeInfoImpl::GetAddressbookId(void) const
+{
+       return __addressbookId;
+}
+
+void
+_CategoryChangeInfoImpl::SetAddressbookId(AddressbookId addressbookId)
+{
+       __addressbookId = addressbookId;
+}
+
+RecordId
+_CategoryChangeInfoImpl::GetCategoryId(void) const
+{
+       return __categoryId;
+}
+
+int
+_CategoryChangeInfoImpl::GetVersion(void) const
+{
+       return __version;
+}
+
+RecordChangeType
+_CategoryChangeInfoImpl::GetChangeType(void) const
+{
+       return __changeType;
+}
+
+void
+_CategoryChangeInfoImpl::SetCategoryId(RecordId categoryId)
+{
+       __categoryId = categoryId;
+}
+
+void
+_CategoryChangeInfoImpl::SetVersion(int version)
+{
+       __version = version;
+}
+
+void
+_CategoryChangeInfoImpl::SetChangeType(RecordChangeType changeType)
+{
+       __changeType = changeType;
+}
+
+_CategoryChangeInfoImpl*
+_CategoryChangeInfoImpl::GetInstance(CategoryChangeInfo& categoryChangeInfo)
+{
+       return categoryChangeInfo.__pCategoryChangeInfoImpl;
+}
+
+const _CategoryChangeInfoImpl*
+_CategoryChangeInfoImpl::GetInstance(const CategoryChangeInfo& categoryChangeInfo)
+{
+       return categoryChangeInfo.__pCategoryChangeInfoImpl;
+}
+
+}} // Tizen::Social
diff --git a/src/FScl_CategoryChangeInfoImpl.h b/src/FScl_CategoryChangeInfoImpl.h
new file mode 100644 (file)
index 0000000..9a2d44d
--- /dev/null
@@ -0,0 +1,109 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_CategoryChangeInfoImpl.h
+ * @brief              This is the header file for the %_CategoryChangeInfoImpl class.
+ *
+ * This header file contains the declarations of the %_CategoryChangeInfoImpl class.
+ */
+#ifndef _FSCL_INTERNAL_CATEGORY_CHANGE_INFO_IMPL_H_
+#define _FSCL_INTERNAL_CATEGORY_CHANGE_INFO_IMPL_H_
+
+#include <FBaseObject.h>
+#include <FSclRecord.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+class CategoryChangeInfo;
+
+/**
+ * @class      _CategoryChangeInfoImpl
+ * @brief      This class provides a category change information.
+ * @since      2.0
+ *
+ * The %_CategoryChangeInfoImpl class provides a category change information
+ *
+ */
+class _CategoryChangeInfoImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is default constructor for this class.
+        *
+        * @since       2.0
+        */
+       _CategoryChangeInfoImpl(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        */
+       _CategoryChangeInfoImpl(const _CategoryChangeInfoImpl& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~_CategoryChangeInfoImpl(void);
+
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       virtual int GetHashCode(void) const;
+
+       void SetAddressbookId(AddressbookId addressbookId);
+
+       AddressbookId GetAddressbookId(void) const;
+
+       void SetCategoryId(RecordId categoryId);
+
+       RecordId GetCategoryId(void) const;
+
+       void SetVersion(int version);
+
+       int GetVersion(void) const;
+
+       void SetChangeType(RecordChangeType type);
+
+       RecordChangeType GetChangeType(void) const;
+
+       static _CategoryChangeInfoImpl* GetInstance(CategoryChangeInfo& categoryChangeInfo);
+
+       static const _CategoryChangeInfoImpl* GetInstance(const CategoryChangeInfo& categoryChangeInfo);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        */
+       _CategoryChangeInfoImpl& operator =(const _CategoryChangeInfoImpl& rhs);
+
+       bool operator ==(const _CategoryChangeInfoImpl& rhs) const;
+
+private:
+       RecordId __categoryId;
+       AddressbookId __addressbookId;
+       int __version;
+       RecordChangeType __changeType;
+
+};     // _CategoryChangeInfoImpl
+
+}}     // Tizen::Social
+
+#endif // _FSCL_INTERNAL_CATEGORY_CHANGE_INFO_IMPL_H_
diff --git a/src/FScl_CategoryImpl.cpp b/src/FScl_CategoryImpl.cpp
new file mode 100644 (file)
index 0000000..4d880a0
--- /dev/null
@@ -0,0 +1,698 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_CategoryImpl.cpp
+ * @brief              This is the implementation for _CategoryImpl class.
+ *
+ * This file contains definitions of _CategoryImpl class.
+ */
+
+#include <new>
+#include <FBaseString.h>
+#include <FBaseColHashMap.h>
+#include <FBaseColArrayListT.h>
+#include <FBaseUtilStringUtil.h>
+#include <FBaseUtilStringTokenizer.h>
+#include <FSclAddressbook.h>
+#include <FSclCategory.h>
+#include <FBaseSysLog.h>
+#include <FIoFile.h>
+#include <FBase_StringConverter.h>
+#include <FApp_AppInfo.h>
+#include "FScl_RecordImpl.h"
+#include "FScl_AddressbookImpl.h"
+#include "FScl_AddressbookUtil.h"
+#include "FScl_CategoryImpl.h"
+#include "FScl_ContactDbConnector.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+
+static const wchar_t CATEGORY_EXT_DATA_GROUP_NAME_ID_KEY[] = L"group_name_id";
+
+namespace Tizen { namespace Social
+{
+_CategoryImpl::_CategoryImpl(void)
+       : __hasMemberList(false)
+       , __memberCount(0)
+       , __pMembers(null)
+       , __pAddedMembers(null)
+       , __pRemovedMembers(null)
+{
+       result r = E_SUCCESS;
+       int ret = CONTACTS_ERROR_NONE;
+       contacts_record_h recordHandle = null;
+
+       _AddressbookUtil::InitContactViews();
+
+       std::unique_ptr< ArrayListT<int> > pMembers (new (std::nothrow) ArrayListT<int>());
+       SysTryReturnVoidResult(NID_SCL, pMembers != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = pMembers->Construct();
+       SysTryReturnVoidResult(NID_SCL, !IsFailed(r), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       std::unique_ptr< ArrayListT<int> > pAddedMembers (new (std::nothrow) ArrayListT<int>());
+       SysTryReturnVoidResult(NID_SCL, pAddedMembers != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = pAddedMembers->Construct();
+       SysTryReturnVoidResult(NID_SCL, !IsFailed(r), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       std::unique_ptr< ArrayListT<int> > pRemovedMembers (new (std::nothrow) ArrayListT<int>());
+       SysTryReturnVoidResult(NID_SCL, pRemovedMembers != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = pRemovedMembers->Construct();
+       SysTryReturnVoidResult(NID_SCL, !IsFailed(r), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       ret = contacts_record_create(_contacts_group._uri, &recordHandle);
+       SysTryReturnVoidResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __pMembers = std::move(pMembers);
+       __pAddedMembers = std::move(pAddedMembers);
+       __pRemovedMembers = std::move(pRemovedMembers);
+
+       __recordHandle = recordHandle;
+
+       return;
+}
+
+_CategoryImpl::_CategoryImpl(const _CategoryImpl& rhs)
+       : __hasMemberList(false)
+       , __memberCount(0)
+       , __pMembers(null)
+       , __pAddedMembers(null)
+       , __pRemovedMembers(null)
+{
+       int ret = CONTACTS_ERROR_NONE;
+       contacts_record_h recordHandle = null;
+
+       _AddressbookUtil::InitContactViews();
+
+       std::unique_ptr< IListT<int> > pMembers (rhs.GetMembersN());
+       SysTryReturnVoidResult(NID_SCL, pMembers != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       std::unique_ptr< IListT<int> > pAddedMembers (rhs.GetAddedMembersN());
+       SysTryReturnVoidResult(NID_SCL, pAddedMembers != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       std::unique_ptr< IListT<int> > pRemovedMembers (rhs.GetRemovedMembersN());
+       SysTryReturnVoidResult(NID_SCL, pRemovedMembers != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       ret = contacts_record_clone(rhs.__recordHandle, &recordHandle);
+       SysTryReturnVoidResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __hasMemberList = rhs.__hasMemberList;
+       __memberCount = rhs.__memberCount;
+
+       __pMembers = std::move(pMembers);
+       __pAddedMembers = std::move(pAddedMembers);
+       __pRemovedMembers = std::move(pRemovedMembers);
+
+       __recordHandle = recordHandle;
+
+       return;
+}
+
+_CategoryImpl::~_CategoryImpl(void)
+{
+       if (__recordHandle != null)
+       {
+               contacts_record_destroy(__recordHandle, true);
+       }
+}
+
+_CategoryImpl&
+_CategoryImpl::operator =(const _CategoryImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       int ret = CONTACTS_ERROR_NONE;
+       contacts_record_h recordHandle = null;
+
+       std::unique_ptr< IListT<int> > pMembers (rhs.GetMembersN());
+       SysTryReturn(NID_SCL, pMembers != null, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       std::unique_ptr< IListT<int> > pAddedMembers (rhs.GetAddedMembersN());
+       SysTryReturn(NID_SCL, pAddedMembers != null, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       std::unique_ptr< IListT<int> > pRemovedMembers (rhs.GetRemovedMembersN());
+       SysTryReturn(NID_SCL, pRemovedMembers != null, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       ret = contacts_record_clone(rhs.__recordHandle, &recordHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __hasMemberList = rhs.__hasMemberList;
+       __memberCount = rhs.__memberCount;
+
+       __pMembers = std::move(pMembers);
+       __pAddedMembers = std::move(pAddedMembers);
+       __pRemovedMembers = std::move(pRemovedMembers);
+
+
+       contacts_record_destroy(__recordHandle, true);
+       __recordHandle = recordHandle;
+
+       return *this;
+}
+
+bool
+_CategoryImpl::Equals(const Tizen::Base::Object& rhs) const
+{
+       const _CategoryImpl* pCategoryImpl = dynamic_cast<const _CategoryImpl*>(&rhs);
+       if (pCategoryImpl == null)
+       {
+               return false;
+       }
+
+       if (GetName() != pCategoryImpl->GetName())
+       {
+               return false;
+       }
+
+       if (GetRingtonePath() != pCategoryImpl->GetRingtonePath())
+       {
+               return false;
+       }
+
+       if (GetThumbnailPath() != pCategoryImpl->GetThumbnailPath())
+       {
+               return false;
+       }
+
+       return true;
+}
+
+bool
+_CategoryImpl::IsDefault(void) const
+{
+       bool isReadOnly = false;
+
+       contacts_record_get_bool(__recordHandle, _contacts_group.is_read_only, &isReadOnly);
+       if (isReadOnly)
+       {
+               return true;
+       }
+
+       return false;
+}
+
+bool
+_CategoryImpl::IsReadOnly(void) const
+{
+       bool isReadOnly = false;
+
+       contacts_record_get_bool(__recordHandle, _contacts_group.is_read_only, &isReadOnly);
+       if (isReadOnly)
+       {
+               return true;
+       }
+
+       return false;
+}
+
+IMap*
+_CategoryImpl::GetExtraDataN(void) const
+{
+       std::unique_ptr<HashMap, AllElementsDeleter> pExtraData(new (std::nothrow) HashMap());
+       SysTryReturn(NID_SCL, pExtraData != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pExtraData->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       char* pCharValue = null;
+       contacts_record_get_str_p(__recordHandle, _contacts_group.extra_data, &pCharValue);
+
+       if (pCharValue == null)
+       {
+               return pExtraData.release();
+       }
+
+       String delim(L":,");
+       String extraData(pCharValue);
+       String decodedString(L"");
+       std::unique_ptr<ByteBuffer> pByteBuffer(null);
+
+       StringTokenizer tokerizer(extraData, delim);
+       String token(L"");
+
+       if (tokerizer.GetTokenCount() == 1) // utf8
+       {
+               if (GetAddressbookId() == DEFAULT_ADDRESSBOOK_ID)
+               {
+                       if (tokerizer.GetNextToken(token) == E_SUCCESS)
+                       {
+                               std::unique_ptr<String> pKey(new (std::nothrow) String(CATEGORY_EXT_DATA_GROUP_NAME_ID_KEY));
+                               SysTryReturn(NID_SCL, pKey != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                               std::unique_ptr<String> pValue(new (std::nothrow) String(token));
+                               SysTryReturn(NID_SCL, pValue != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                               r = pExtraData->Add(pKey.get(), pValue.get());
+                               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                               pKey.release();
+                               pValue.release();
+                       }
+               }
+       }
+       else // base64
+       {
+               while (tokerizer.HasMoreTokens())
+               {
+                       // key
+                       r = tokerizer.GetNextToken(token);
+                       if (r != E_SUCCESS)
+                       {
+                               break;
+                       }
+
+                       pByteBuffer.reset(StringUtil::DecodeBase64StringN(token));
+                       SysTryReturn(NID_SCL, pByteBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       std::unique_ptr<String> pKey(new (std::nothrow) String());
+                       SysTryReturn(NID_SCL, pKey != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       StringUtil::Utf8ToString((const char*)pByteBuffer->GetPointer(), *pKey);
+
+                       // value
+                       r = tokerizer.GetNextToken(token);
+                       if (r != E_SUCCESS)
+                       {
+                               break;
+                       }
+
+                       pByteBuffer.reset(StringUtil::DecodeBase64StringN(token));
+                       SysTryReturn(NID_SCL, pByteBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       std::unique_ptr<String> pValue(new (std::nothrow) String());
+                       SysTryReturn(NID_SCL, pValue != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+                       StringUtil::Utf8ToString((const char*)pByteBuffer->GetPointer(), *pValue);
+
+                       r = pExtraData->Add(pKey.get(), pValue.get());
+                       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       pKey.release();
+                       pValue.release();
+               }
+       }
+
+       return pExtraData.release();
+}
+
+void
+_CategoryImpl::SetRecordHandle(contacts_record_h recordHandle)
+{
+       contacts_record_destroy(__recordHandle, true);
+
+       __recordHandle = recordHandle;
+}
+
+contacts_record_h
+_CategoryImpl::GetRecordHandle(void) const
+{
+       return __recordHandle;
+}
+
+result
+_CategoryImpl::AddMember(RecordId contactId)
+{
+       SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. contactId = %d.", GetErrorMessage(E_INVALID_ARG), contactId);
+
+       result r = E_SUCCESS;
+       int tableId = contactId;
+
+       if (!__hasMemberList)
+       {
+               r = LoadMemberList();
+               SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       SysTryReturn(NID_SCL, !HasMember(contactId), E_OBJ_ALREADY_EXIST, E_OBJ_ALREADY_EXIST, "[%s] The member already exist in the category.", GetErrorMessage(E_OBJ_ALREADY_EXIST));
+
+       r = __pMembers->Add(tableId);
+       SysTryReturnResult(NID_SCL, !IsFailed(r), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       if (__pRemovedMembers->Contains(tableId))
+       {
+               __pRemovedMembers->Remove(tableId);
+       }
+       else
+       {
+               result r = __pAddedMembers->Add(tableId);
+               if (IsFailed(r))
+               {
+                       __pMembers->Remove(tableId);
+
+                       SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       return r;
+               }
+       }
+
+       __memberCount++;
+
+       return E_SUCCESS;
+}
+
+int
+_CategoryImpl::GetMemberCount(void) const
+{
+       return __memberCount;
+}
+
+void
+_CategoryImpl::SetMemberCount(int memberCount)
+{
+       __memberCount = memberCount;
+}
+
+String
+_CategoryImpl::GetName(void) const
+{
+       char* pCharValue = null;
+
+       contacts_record_get_str_p(__recordHandle, _contacts_group.name, &pCharValue);
+
+       return String(pCharValue);
+}
+
+bool
+_CategoryImpl::HasMember(RecordId contactId) const
+{
+       SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. contactId = %d.", GetErrorMessage(E_INVALID_ARG), contactId);
+
+       result r = E_SUCCESS;
+       int tableId = contactId;
+
+       if (!__hasMemberList)
+       {
+               _CategoryImpl* pThis = const_cast<_CategoryImpl*>(this);
+               r = pThis->LoadMemberList();
+               SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       return __pMembers->Contains(tableId);
+}
+
+result
+_CategoryImpl::RemoveMember(RecordId contactId)
+{
+       SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. contactId = %d.", GetErrorMessage(E_INVALID_ARG), contactId);
+
+       result r = E_SUCCESS;
+       int tableId = contactId;
+
+       if (!__hasMemberList)
+       {
+               r = LoadMemberList();
+               SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       if (!_AppInfo::IsOspCompat())
+       {
+               SysTryReturn(NID_SCL, HasMember(contactId), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid arguemnt is used. The contact does not exist in the category.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       // check pended delete list
+       if (__pRemovedMembers->Contains(tableId))
+       {
+               return E_SUCCESS;
+       }
+
+       if (!HasMember(contactId))
+       {
+               return E_SUCCESS;
+       }
+
+       r = __pMembers->Remove(tableId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       if (__pAddedMembers->Contains(tableId))
+       {
+               __pAddedMembers->Remove(tableId);
+       }
+       else
+       {
+               result r = __pRemovedMembers->Add(tableId);
+               if (IsFailed(r))
+               {
+                       __pMembers->Add(tableId);
+                       SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       return r;
+               }
+       }
+
+       __memberCount--;
+
+       return E_SUCCESS;
+}
+
+result
+_CategoryImpl::SetName(const String& name)
+{
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               SysTryReturn(NID_SCL, !IsReadOnly(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. This category is a default category.", GetErrorMessage(E_INVALID_ARG));
+               SysTryReturn(NID_SCL, name.GetLength() <= 100, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified name exceeds the max length.", GetErrorMessage(E_INVALID_ARG));
+       }
+       else
+       {
+               SysTryReturn(NID_SCL, !IsReadOnly(), E_INVALID_OPERATION, E_INVALID_OPERATION, "[%s] This category is a default category.", GetErrorMessage(E_INVALID_OPERATION));
+       }
+
+       SysTryReturn(NID_SCL, !name.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified file path is an empty string", GetErrorMessage(E_INVALID_ARG));
+
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(name));
+       SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       contacts_record_set_str(__recordHandle, _contacts_group.name, pCharArray.get());
+
+       return E_SUCCESS;
+}
+
+result
+_CategoryImpl::SetRingtonePath(const String& filePath)
+{
+       SysTryReturn(NID_SCL, filePath.IsEmpty() || File::IsFileExist(filePath), E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[%s] The specified file is not found.", GetErrorMessage(E_FILE_NOT_FOUND));
+
+       if (!filePath.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(filePath));
+               SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(__recordHandle, _contacts_group.ringtone_path, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(__recordHandle, _contacts_group.ringtone_path, null);
+       }
+
+       return E_SUCCESS;
+}
+
+String
+_CategoryImpl::GetRingtonePath(void) const
+{
+       char* pCharValue = null;
+
+       contacts_record_get_str_p(__recordHandle, _contacts_group.ringtone_path, &pCharValue);
+
+       return String(pCharValue);
+}
+
+IListT<int>*
+_CategoryImpl::GetMembersN(void) const
+{
+       std::unique_ptr<ArrayListT<int> > pList(new (std::nothrow) ArrayListT<int>());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pList->Construct(*__pMembers);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       return pList.release();
+}
+
+IListT<int>*
+_CategoryImpl::GetAddedMembersN(void) const
+{
+       std::unique_ptr<ArrayListT<int> > pList(new (std::nothrow) ArrayListT<int>());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pList->Construct(*__pAddedMembers);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       return pList.release();
+}
+
+IListT<int>*
+_CategoryImpl::GetRemovedMembersN(void) const
+{
+       std::unique_ptr<ArrayListT<int> > pList(new (std::nothrow) ArrayListT<int>());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pList->Construct(*__pRemovedMembers);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       return pList.release();
+}
+
+result
+_CategoryImpl::LoadMemberList(void)
+{
+       _AddressbookUtil::InitContactViews();
+
+       int intValue = 0;
+       result r = E_SUCCESS;
+       std::unique_ptr< ArrayListT<RecordId> > pMembers;
+
+       contacts_record_get_int(__recordHandle, _contacts_group.id, &intValue);
+       if (intValue <= 0)
+       {
+               __hasMemberList = true;
+
+               return E_SUCCESS;
+       }
+
+       contacts_record_h currentRecord = null;
+
+       __Filter<__ContactsContactGroupRel> filter;
+       filter.Construct();
+       filter.AddInt(_contacts_contact_grouprel.group_id, CONTACTS_MATCH_EQUAL, intValue);
+
+       __Query<__ContactsContactGroupRel> query;
+       query.Construct();
+       query.SetFilter(filter);
+
+       std::unique_ptr<__SearchResult<__ContactsContactGroupRel> > pSearchResult(_AddressbookUtil::ExecuteQuery(query));
+       SysTryReturn(NID_SCL, pSearchResult != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       while (pSearchResult->MoveNext() == E_SUCCESS)
+       {
+               currentRecord = pSearchResult->GetCurrentRecord();
+               SysTryReturn(NID_SCL, currentRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+               contacts_record_get_int(currentRecord, _contacts_contact_grouprel.contact_id, &intValue);
+
+               if (intValue > 0)
+               {
+                       r = __pMembers->Add(intValue);
+                       SysTryReturn(NID_SCL, !IsFailed(r), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               }
+       }
+
+       __memberCount = __pMembers->GetCount();
+       __hasMemberList = true;
+
+       return E_SUCCESS;
+}
+
+void
+_CategoryImpl::ClearAddedMemberList(void)
+{
+       __pAddedMembers->RemoveAll();
+}
+
+void
+_CategoryImpl::ClearRemovedMemberList(void)
+{
+       __pRemovedMembers->RemoveAll();
+}
+
+AddressbookId
+_CategoryImpl::GetAddressbookId(void) const
+{
+       int intValue = 0;
+
+       contacts_record_get_int(__recordHandle, _contacts_group.address_book_id, &intValue);
+
+       return intValue;
+}
+
+result
+_CategoryImpl::SetThumbnail(const String& filePath)
+{
+       SysTryReturn(NID_SCL, filePath.IsEmpty() || File::IsFileExist(filePath), E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[%s] The specified file is not found.", GetErrorMessage(E_FILE_NOT_FOUND));
+
+       if (!filePath.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(filePath));
+               SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(__recordHandle, _contacts_group.image_path, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(__recordHandle, _contacts_group.image_path, null);
+       }
+
+       return E_SUCCESS;
+}
+
+String
+_CategoryImpl::GetThumbnailPath(void) const
+{
+       char* pCharValue = null;
+
+       contacts_record_get_str_p(__recordHandle, _contacts_group.image_path, &pCharValue);
+
+       return String(pCharValue);
+}
+
+result
+_CategoryImpl::Invalidate(void)
+{
+       contacts_record_h recordHandle = null;
+       int ret = CONTACTS_ERROR_NONE;
+       char* pCharValue = null;
+
+       ret = contacts_record_create(_contacts_group._uri, &recordHandle);
+       SysTryReturnResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_str_p(__recordHandle, _contacts_group.name, &pCharValue);
+       contacts_record_set_str(recordHandle, _contacts_group.name, pCharValue);
+
+       contacts_record_get_str_p(__recordHandle, _contacts_group.ringtone_path, &pCharValue);
+       contacts_record_set_str(recordHandle, _contacts_group.ringtone_path, pCharValue);
+
+       contacts_record_get_str_p(__recordHandle, _contacts_group.image_path, &pCharValue);
+       contacts_record_set_str(recordHandle, _contacts_group.image_path, pCharValue);
+
+       contacts_record_get_str_p(__recordHandle, _contacts_group.vibration, &pCharValue);
+       contacts_record_set_str(recordHandle, _contacts_group.vibration, pCharValue);
+
+       contacts_record_destroy(__recordHandle, true);
+       __recordHandle = recordHandle;
+
+       return E_SUCCESS;
+}
+
+const _CategoryImpl*
+_CategoryImpl::GetInstance(const Category& category)
+{
+       return category.__pCategoryImpl;
+}
+
+_CategoryImpl*
+_CategoryImpl::GetInstance(Category& category)
+{
+       return category.__pCategoryImpl;
+}
+
+}}  // Tizen::Social
diff --git a/src/FScl_ContactAppLaunchDataImpl.cpp b/src/FScl_ContactAppLaunchDataImpl.cpp
new file mode 100644 (file)
index 0000000..08b157b
--- /dev/null
@@ -0,0 +1,439 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+/**
+ * @file               FScl_ContactAppLaunchDataImpl.cpp
+ * @brief              This is the header file for the %_ContactAppLaunchData class.
+ *
+ * This header file contains the declarations of the %_ContactAppLaunchData class.
+ */
+
+#include <FBaseSysLog.h>
+#include "FScl_ContactAppLaunchDataImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Social
+{
+
+_ContactAppLaunchDataImpl::_ContactAppLaunchDataImpl(void)
+{
+       std::unique_ptr<HashMap, AllElementsDeleter> pExtraData(new (std::nothrow) HashMap());
+       SysTryReturnVoidResult(NID_SCL, pExtraData != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pExtraData->Construct();
+       SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Failed to construct pExtraData.", GetErrorMessage(r));
+
+       __pExtraData = std::move(pExtraData);
+}
+
+_ContactAppLaunchDataImpl::_ContactAppLaunchDataImpl(const _ContactAppLaunchDataImpl& rhs)
+{
+       std::unique_ptr<HashMap, AllElementsDeleter> pExtraData(new (std::nothrow) HashMap());
+       SysTryReturnVoidResult(NID_SCL, pExtraData != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pExtraData->Construct();
+       SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Failed to construct pExtraData.", GetErrorMessage(r));
+
+       std::unique_ptr<IMapEnumerator> pMapEnum((rhs.__pExtraData)->GetMapEnumeratorN());
+       SysTryReturnVoidResult(NID_SCL, pMapEnum != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<String> pKey(null);
+       std::unique_ptr<String> pVal(null);
+       String* pStr = null;
+
+       while (pMapEnum->MoveNext() == E_SUCCESS)
+       {
+               pStr = static_cast<String*> (pMapEnum->GetKey());
+               pKey.reset(new (std::nothrow) String(*pStr));
+               SysTryReturnVoidResult(NID_SCL, pKey != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pStr = static_cast<String*> (pMapEnum->GetValue());
+               pVal.reset(new (std::nothrow) String(*pStr));
+               SysTryReturnVoidResult(NID_SCL, pVal != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pExtraData->Add(pKey.get(), pVal.get());
+               SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Propagating.", GetErrorMessage(r));
+
+               pKey.release();
+               pVal.release();
+       }
+
+       __pExtraData = std::move(pExtraData);
+
+       __displayText = rhs.__displayText;
+       __uid = rhs.__uid;
+       __appId = rhs.__appId;
+       __operationId = rhs.__operationId;
+       __uri = rhs.__uri;
+       __category = rhs.__category;
+       __mime = rhs.__mime;
+}
+
+_ContactAppLaunchDataImpl::~_ContactAppLaunchDataImpl(void)
+{
+}
+
+_ContactAppLaunchDataImpl&
+_ContactAppLaunchDataImpl::operator =(const _ContactAppLaunchDataImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       std::unique_ptr<HashMap, AllElementsDeleter> pExtraData(new (std::nothrow) HashMap());
+       SysTryReturn(NID_SCL, pExtraData != null, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pExtraData->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), *this, r, "[%s] Failed to construct pExtraData.", GetErrorMessage(r));
+
+       std::unique_ptr<IMapEnumerator> pMapEnum((rhs.__pExtraData)->GetMapEnumeratorN());
+       SysTryReturn(NID_SCL, pMapEnum != null, *this, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<String> pKey(null);
+       std::unique_ptr<String> pVal(null);
+       String* pStr = null;
+
+       while (pMapEnum->MoveNext() == E_SUCCESS)
+       {
+               pStr = static_cast<String*> (pMapEnum->GetKey());
+               pKey.reset(new (std::nothrow) String(*pStr));
+               SysTryReturn(NID_SCL, pKey != null, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pStr = static_cast<String*> (pMapEnum->GetValue());
+               pVal.reset(new (std::nothrow) String(*pStr));
+               SysTryReturn(NID_SCL, pVal != null, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pExtraData->Add(pKey.get(), pVal.get());
+               SysTryReturn(NID_SCL, !IsFailed(r), *this, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               pKey.release();
+               pVal.release();
+       }
+
+       __pExtraData = std::move(pExtraData);
+
+       __displayText = rhs.__displayText;
+       __uid = rhs.__uid;
+       __appId = rhs.__appId;
+       __operationId = rhs.__operationId;
+       __uri = rhs.__uri;
+       __category = rhs.__category;
+       __mime = rhs.__mime;
+
+       return *this;
+}
+
+bool operator ==(const _ContactAppLaunchDataImpl& lhs, const _ContactAppLaunchDataImpl& rhs)
+{
+       if (lhs.__displayText != rhs.__displayText)
+       {
+               return false;
+       }
+
+       if (lhs.__uid != rhs.__uid)
+       {
+               return false;
+       }
+
+       if (lhs.__appId != rhs.__appId)
+       {
+               return false;
+       }
+
+       if (lhs.__operationId != rhs.__operationId)
+       {
+               return false;
+       }
+
+       if (lhs.__uri != rhs.__uri)
+       {
+               return false;
+       }
+
+       if (lhs.__category != rhs.__category)
+       {
+               return false;
+       }
+
+       if (lhs.__mime != rhs.__mime)
+       {
+               return false;
+       }
+
+       if (!lhs.__pExtraData->Equals(*rhs.__pExtraData))
+       {
+               return false;
+       }
+
+       return true;
+}
+
+bool operator !=(const _ContactAppLaunchDataImpl& lhs, const _ContactAppLaunchDataImpl& rhs)
+{
+       return !(lhs == rhs);
+}
+
+bool
+_ContactAppLaunchDataImpl::Equals(const Object& rhs) const
+{
+       const _ContactAppLaunchDataImpl* pContactAppLaunchData = dynamic_cast<const _ContactAppLaunchDataImpl*>(&rhs);
+       if (pContactAppLaunchData == null)
+       {
+               return false;
+       }
+
+       return *this == *pContactAppLaunchData;
+}
+
+int
+_ContactAppLaunchDataImpl::GetHashCode(void) const
+{
+       int hash = __displayText.GetHashCode();
+       hash += __uid.GetHashCode();
+       hash += __appId.GetHashCode();
+       hash += __operationId.GetHashCode();
+       hash += __uri.GetHashCode();
+       hash += __category.GetHashCode();
+       hash += __mime.GetHashCode();
+
+       return hash;
+}
+
+String
+_ContactAppLaunchDataImpl::GetDisplayText(void) const
+{
+       return __displayText;
+}
+
+String
+_ContactAppLaunchDataImpl::GetUid(void) const
+{
+       return __uid;
+}
+
+String
+_ContactAppLaunchDataImpl::GetAppId(void) const
+{
+       return __appId;
+}
+
+String
+_ContactAppLaunchDataImpl::GetOperationId(void) const
+{
+       return __operationId;
+}
+
+String
+_ContactAppLaunchDataImpl::GetUri(void) const
+{
+       return __uri;
+}
+
+String
+_ContactAppLaunchDataImpl::GetCategory(void) const
+{
+       return __category;
+}
+
+String
+_ContactAppLaunchDataImpl::GetMime(void) const
+{
+       return __mime;
+}
+
+IMap*
+_ContactAppLaunchDataImpl::GetExtraDataN(void) const
+{
+       ClearLastResult();
+
+       std::unique_ptr<HashMap, AllElementsDeleter> pExtraData(new (std::nothrow) HashMap());
+       SysTryReturn(NID_SCL, pExtraData != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pExtraData->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Failed to construct pExtraData.", GetErrorMessage(r));
+
+       std::unique_ptr<IMapEnumerator> pMapEnum(__pExtraData->GetMapEnumeratorN());
+       SysTryReturn(NID_SCL, pMapEnum != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       std::unique_ptr<String> pKey(null);
+       std::unique_ptr<String> pVal(null);
+       String* pStr = null;
+
+       while (pMapEnum->MoveNext() == E_SUCCESS)
+       {
+               pStr = static_cast<String*> (pMapEnum->GetKey());
+               pKey.reset(new (std::nothrow) String(*pStr));
+               SysTryReturn(NID_SCL, pKey != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pStr = static_cast<String*> (pMapEnum->GetValue());
+               pVal.reset(new (std::nothrow) String(*pStr));
+               SysTryReturn(NID_SCL, pVal != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pExtraData->Add(pKey.get(), pVal.get());
+               SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               pKey.release();
+               pVal.release();
+       }
+
+       return pExtraData.release();
+}
+
+void
+_ContactAppLaunchDataImpl::SetDisplayText(const String& displayText)
+{
+       __displayText = displayText;
+}
+
+void
+_ContactAppLaunchDataImpl::SetUid(const String& uid)
+{
+       __uid = uid;
+}
+
+void
+_ContactAppLaunchDataImpl::SetAppId(const String& appId)
+{
+       __appId = appId;
+}
+
+void
+_ContactAppLaunchDataImpl::SetOperationId(const String& operationId)
+{
+       __operationId = operationId;
+}
+
+void
+_ContactAppLaunchDataImpl::SetUri(const String& uri)
+{
+       __uri = uri;
+}
+
+void
+_ContactAppLaunchDataImpl::SetCategory(const String& category)
+{
+       __category = category;
+}
+
+void
+_ContactAppLaunchDataImpl::SetMime(const String& mime)
+{
+       __mime = mime;
+}
+
+result
+_ContactAppLaunchDataImpl::SetExtraData(const IMap* pExtraData)
+{
+       std::unique_ptr<HashMap, AllElementsDeleter> pNewExtraData(new (std::nothrow) HashMap());
+       SysTryReturn(NID_SCL, pNewExtraData != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pNewExtraData->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Failed to construct pExtraData.", GetErrorMessage(r));
+
+       if (pExtraData != null)
+       {
+               std::unique_ptr<IMapEnumerator> pMapEnum(pExtraData->GetMapEnumeratorN());
+               SysTryReturn(NID_SCL, pMapEnum != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+               std::unique_ptr<String> pKey(null);
+               std::unique_ptr<String> pVal(null);
+               String* pStr = null;
+
+               while (pMapEnum->MoveNext() == E_SUCCESS)
+               {
+                       pStr = static_cast<String*> (pMapEnum->GetKey());
+                       pKey.reset(new (std::nothrow) String(*pStr));
+                       SysTryReturn(NID_SCL, pKey != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       pStr = static_cast<String*> (pMapEnum->GetValue());
+                       pVal.reset(new (std::nothrow) String(*pStr));
+                       SysTryReturn(NID_SCL, pVal != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       r = pNewExtraData->Add(pKey.get(), pVal.get());
+                       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+                       pKey.release();
+                       pVal.release();
+               }
+       }
+
+       __pExtraData = std::move(pNewExtraData);
+
+       return E_SUCCESS;
+}
+
+bool
+_ContactAppLaunchDataImpl::IsEmpty(void) const
+{
+       if (!__displayText.IsEmpty())
+       {
+               return false;
+       }
+
+       if (!__uid.IsEmpty())
+       {
+               return false;
+       }
+
+       if (!__appId.IsEmpty())
+       {
+               return false;
+       }
+
+       if (!__operationId.IsEmpty())
+       {
+               return false;
+       }
+
+       if (!__uri.IsEmpty())
+       {
+               return false;
+       }
+
+       if (!__category.IsEmpty())
+       {
+               return false;
+       }
+
+       if (!__mime.IsEmpty())
+       {
+               return false;
+       }
+
+       if (__pExtraData->GetCount() != 0)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+const _ContactAppLaunchDataImpl*
+_ContactAppLaunchDataImpl::GetInstance(const ContactAppLaunchData& appLaunchData)
+{
+       return appLaunchData.__pContactAppLaunchDataImpl;
+}
+
+_ContactAppLaunchDataImpl*
+_ContactAppLaunchDataImpl::GetInstance(ContactAppLaunchData& appLaunchData)
+{
+       return appLaunchData.__pContactAppLaunchDataImpl;
+}
+
+}} // Tizen::Social
diff --git a/src/FScl_ContactAppLaunchDataImpl.h b/src/FScl_ContactAppLaunchDataImpl.h
new file mode 100644 (file)
index 0000000..986eb10
--- /dev/null
@@ -0,0 +1,109 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+/**
+ * @file               FScl_ContactAppLaunchDataImpl.h
+ * @brief              This is the header file for the %_ContactAppLaunchData class.
+ *
+ * This header file contains the declarations of the %_ContactAppLaunchData class.
+ */
+#ifndef _FSCL_INTERNAL_CONTACT_APP_LAUNCH_DATA_IMPL_H_
+#define _FSCL_INTERNAL_CONTACT_APP_LAUNCH_DATA_IMPL_H_
+
+#include <unique_ptr.h>
+#include <FBaseColAllElementsDeleter.h>
+#include <FBaseColHashMap.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FSclContactAppLaunchData.h>
+
+namespace Tizen { namespace Social
+{
+class _OSP_EXPORT_ _ContactAppLaunchDataImpl
+       :public Tizen::Base::Object
+{
+public:
+       _ContactAppLaunchDataImpl(void);
+
+       _ContactAppLaunchDataImpl(const _ContactAppLaunchDataImpl& rhs);
+
+       virtual ~_ContactAppLaunchDataImpl(void);
+
+       _ContactAppLaunchDataImpl& operator =(const _ContactAppLaunchDataImpl& rhs);
+
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       virtual int GetHashCode(void) const;
+
+       Tizen::Base::String GetDisplayText(void) const;
+
+       Tizen::Base::String GetUid(void) const;
+
+       Tizen::Base::String GetAppId(void) const;
+
+       Tizen::Base::String GetOperationId(void) const;
+
+       Tizen::Base::String GetUri(void) const;
+
+       Tizen::Base::String GetCategory(void) const;
+
+       Tizen::Base::String GetMime(void) const;
+
+       Tizen::Base::Collection::IMap* GetExtraDataN(void) const;
+
+       void SetDisplayText(const Tizen::Base::String& displayText);
+
+       void SetUid(const Tizen::Base::String& uid);
+
+       void SetAppId(const Tizen::Base::String& appId);
+
+       void SetOperationId(const Tizen::Base::String& operationId);
+
+       void SetUri(const Tizen::Base::String& uri);
+
+       void SetCategory(const Tizen::Base::String& category);
+
+       void SetMime(const Tizen::Base::String& mime);
+
+       result SetExtraData(const Tizen::Base::Collection::IMap* pExtraData);
+
+       bool IsEmpty(void) const;
+
+       static const _ContactAppLaunchDataImpl* GetInstance(const ContactAppLaunchData& appLaunchData);
+
+       static _ContactAppLaunchDataImpl* GetInstance(ContactAppLaunchData& appLaunchData);
+
+       friend bool operator ==(const _ContactAppLaunchDataImpl& lhs, const _ContactAppLaunchDataImpl& rhs);
+
+private:
+       Tizen::Base::String __displayText;
+       Tizen::Base::String __uid;
+       Tizen::Base::String __appId;
+       Tizen::Base::String __operationId;
+       Tizen::Base::String __uri;
+       Tizen::Base::String __category;
+       Tizen::Base::String __mime;
+       std::unique_ptr<Tizen::Base::Collection::HashMap, Tizen::Base::Collection::AllElementsDeleter> __pExtraData;
+}; // _ContactAppLaunchDataImpl
+
+bool operator ==(const _ContactAppLaunchDataImpl& lhs, const _ContactAppLaunchDataImpl& rhs);
+
+bool operator !=(const _ContactAppLaunchDataImpl& lhs, const _ContactAppLaunchDataImpl& rhs);
+
+
+}} // Tizen::Social
+
+#endif // _FSCL_INTERNAL_CONTACT_APP_LAUNCH_DATA_IMPL_H_
diff --git a/src/FScl_ContactChangeInfoImpl.cpp b/src/FScl_ContactChangeInfoImpl.cpp
new file mode 100644 (file)
index 0000000..2008509
--- /dev/null
@@ -0,0 +1,209 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_ContactChangeInfoImpl.cpp
+ * @brief              This is the implementation for _ContactChangeInfoImpl class.
+ *
+ * This file contains definitions of @e _ContactChangeInfoImpl class.
+ */
+
+#include <new>
+#include <FBaseResult.h>
+#include <FSclContactChangeInfo.h>
+#include <FBaseSysLog.h>
+#include "FScl_RecordImpl.h"
+#include "FScl_ContactChangeInfoImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Social
+{
+
+_ContactChangeInfoImpl::_ContactChangeInfoImpl(void)
+       : __contactId(INVALID_RECORD_ID)
+       , __addressbookId(INVALID_ADDRESSBOOK_ID)
+       , __version(0)
+       , __changeType(RECORD_CHANGE_TYPE_ADDED)
+       , __isThumbnailChanged(false)
+{
+       // empty body
+}
+
+_ContactChangeInfoImpl::_ContactChangeInfoImpl(const _ContactChangeInfoImpl& rhs)
+{
+       __contactId = rhs.__contactId;
+       __addressbookId = rhs.__addressbookId;
+       __version = rhs.__version;
+       __changeType = rhs.__changeType;
+       __isThumbnailChanged = rhs.__isThumbnailChanged;
+}
+
+_ContactChangeInfoImpl::~_ContactChangeInfoImpl(void)
+{
+       // empty body
+}
+
+_ContactChangeInfoImpl&
+_ContactChangeInfoImpl::operator =(const _ContactChangeInfoImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __contactId = rhs.__contactId;
+       __addressbookId = rhs.__addressbookId;
+       __version = rhs.__version;
+       __changeType = rhs.__changeType;
+       __isThumbnailChanged = rhs.__isThumbnailChanged;
+
+       return *this;
+}
+
+bool
+_ContactChangeInfoImpl::operator ==(const _ContactChangeInfoImpl& rhs) const
+{
+       if (__contactId != rhs.__contactId)
+       {
+               return false;
+       }
+
+       if (__addressbookId != rhs.__addressbookId)
+       {
+               return false;
+       }
+
+       if (__version != rhs.__version)
+       {
+               return false;
+       }
+
+       if (__changeType != rhs.__changeType)
+       {
+               return false;
+       }
+
+       if (__isThumbnailChanged != rhs.__isThumbnailChanged)
+       {
+               return false;
+       }
+
+
+       return true;
+}
+
+
+bool
+_ContactChangeInfoImpl::Equals(const Object& rhs) const
+{
+       const _ContactChangeInfoImpl* pContactChangeInfoImpl = dynamic_cast<const _ContactChangeInfoImpl*>(&rhs);
+
+       if (pContactChangeInfoImpl == null)
+       {
+               return false;
+       }
+
+       return *this == *pContactChangeInfoImpl;
+}
+
+int
+_ContactChangeInfoImpl::GetHashCode(void) const
+{
+       int hashCode = 0;
+
+       hashCode = __contactId;
+       hashCode += __addressbookId;
+       hashCode += __version;
+       hashCode += __changeType;
+       hashCode += __isThumbnailChanged;
+
+       return hashCode;
+}
+
+AddressbookId
+_ContactChangeInfoImpl::GetAddressbookId(void) const
+{
+       return __addressbookId;
+}
+
+void
+_ContactChangeInfoImpl::SetAddressbookId(AddressbookId addressbookId)
+{
+       __addressbookId = addressbookId;
+}
+
+RecordId
+_ContactChangeInfoImpl::GetContactId(void) const
+{
+       return __contactId;
+}
+
+int
+_ContactChangeInfoImpl::GetVersion(void) const
+{
+       return __version;
+}
+
+RecordChangeType
+_ContactChangeInfoImpl::GetChangeType(void) const
+{
+       return __changeType;
+}
+
+void
+_ContactChangeInfoImpl::SetContactId(RecordId contactId)
+{
+       __contactId = contactId;
+}
+
+void
+_ContactChangeInfoImpl::SetVersion(int version)
+{
+       __version = version;
+}
+
+void
+_ContactChangeInfoImpl::SetChangeType(RecordChangeType changeType)
+{
+       __changeType = changeType;
+}
+
+bool
+_ContactChangeInfoImpl::IsThumbnailChanged(void) const
+{
+       return __isThumbnailChanged;
+}
+
+void
+_ContactChangeInfoImpl::SetThumbnailChangeStatus(bool isChanged)
+{
+       __isThumbnailChanged = isChanged;
+}
+
+_ContactChangeInfoImpl*
+_ContactChangeInfoImpl::GetInstance(ContactChangeInfo& contactChangeInfo)
+{
+       return contactChangeInfo.__pContactChangeInfoImpl;
+}
+
+const _ContactChangeInfoImpl*
+_ContactChangeInfoImpl::GetInstance(const ContactChangeInfo& contactChangeInfo)
+{
+       return contactChangeInfo.__pContactChangeInfoImpl;
+}
+
+}} // Tizen::Social
diff --git a/src/FScl_ContactChangeInfoImpl.h b/src/FScl_ContactChangeInfoImpl.h
new file mode 100644 (file)
index 0000000..2a0461f
--- /dev/null
@@ -0,0 +1,114 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_ContactChangeInfoImpl.h
+ * @brief              This is the header file for the %_ContactChangeInfoImpl class.
+ *
+ * This header file contains the declarations of the %_ContactChangeInfoImpl class.
+ */
+#ifndef _FSCL_INTERNAL_CONTACT_CHANGE_INFO_IMPL_H_
+#define _FSCL_INTERNAL_CONTACT_CHANGE_INFO_IMPL_H_
+
+#include <FBaseObject.h>
+#include <FSclRecord.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+class ContactChangeInfo;
+
+/**
+ * @class      _ContactChangeInfoImpl
+ * @brief      This class provides a contact change information.
+ * @since      2.0
+ *
+ * The %_ContactChangeInfoImpl class provides a contact change information
+ *
+ */
+class _ContactChangeInfoImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is default constructor for this class.
+        *
+        * @since       2.0
+        */
+       _ContactChangeInfoImpl(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        */
+       _ContactChangeInfoImpl(const _ContactChangeInfoImpl& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~_ContactChangeInfoImpl(void);
+
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       virtual int GetHashCode(void) const;
+
+       void SetAddressbookId(AddressbookId addressbookId);
+
+       AddressbookId GetAddressbookId(void) const;
+
+       void SetContactId(RecordId contactId);
+
+       RecordId GetContactId(void) const;
+
+       void SetVersion(int version);
+
+       int GetVersion(void) const;
+
+       void SetChangeType(RecordChangeType type);
+
+       RecordChangeType GetChangeType(void) const;
+
+       bool IsThumbnailChanged(void) const;
+
+       void SetThumbnailChangeStatus(bool isChanged);
+
+       static _ContactChangeInfoImpl* GetInstance(ContactChangeInfo& contactChangeInfo);
+
+       static const _ContactChangeInfoImpl* GetInstance(const ContactChangeInfo& contactChangeInfo);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        */
+       _ContactChangeInfoImpl& operator =(const _ContactChangeInfoImpl& rhs);
+
+       bool operator ==(const _ContactChangeInfoImpl& rhs) const;
+
+private:
+       RecordId __contactId;
+       AddressbookId __addressbookId;
+       int __version;
+       RecordChangeType __changeType;
+       bool __isThumbnailChanged;
+
+};     // _ContactChangeInfoImpl
+
+}}     // Tizen::Social
+
+#endif // _FSCL_INTERNAL_CONTACT_CHANGE_INFO_IMPL_H_
diff --git a/src/FScl_ContactDbChangeEvent.cpp b/src/FScl_ContactDbChangeEvent.cpp
new file mode 100644 (file)
index 0000000..3b8b5d7
--- /dev/null
@@ -0,0 +1,82 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_ContactDbChangeEvent.cpp
+ * @brief      This is the implementation file for the _ContactDbChangeEvent class.
+ *
+ */
+
+#include <FBaseRtIEventListener.h>
+#include <FBaseRtIEventArg.h>
+#include <FBaseSysLog.h>
+#include "FScl_IContactDbChangeEventListener.h"
+#include "FScl_ContactDbChangeEventArg.h"
+#include "FScl_ContactDbChangeEvent.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Social
+{
+
+_ContactDbChangeEvent::_ContactDbChangeEvent(void)
+{
+       // empty body
+}
+
+_ContactDbChangeEvent::~_ContactDbChangeEvent(void)
+{
+       // emtpy body
+}
+
+result
+_ContactDbChangeEvent::Construct(void)
+{
+       result r = E_SUCCESS;
+
+       r = _Event::Initialize();
+       if (!IsFailed(r))
+       {
+               SysLog(NID_SCL, "This is not an event-driven thread.");
+       }
+
+       return E_SUCCESS;
+}
+
+void
+_ContactDbChangeEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
+{
+       _IContactDbChangeEventListener* pEventListener = dynamic_cast<_IContactDbChangeEventListener*>(&listener);
+       const _ContactDbChangeEventArg* pEventArg = dynamic_cast<const _ContactDbChangeEventArg*>(&arg);
+
+       if (pEventListener != null && pEventArg != null)
+       {
+               if (pEventArg->GetChangeType() == _CONTACT_DB_CHANGE_TYPE_CONTACT)
+               {
+                       pEventListener->OnContactChanged();
+               }
+               else if (pEventArg->GetChangeType() == _CONTACT_DB_CHANGE_TYPE_GROUP)
+               {
+                       pEventListener->OnCategoryChanged();
+               }
+               else
+               {
+                       pEventListener->OnRelationChanged();
+               }
+       }
+}
+
+}} // Tizen::Social
diff --git a/src/FScl_ContactDbChangeEvent.h b/src/FScl_ContactDbChangeEvent.h
new file mode 100644 (file)
index 0000000..16e93f7
--- /dev/null
@@ -0,0 +1,67 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_ContactDbChangeEvent.h
+ * @brief      This is the header file for the _ContactDbChangeEvent class.
+ *
+ * This file contains the declarations of _ContactDbChangeEvent.
+ */
+
+
+#ifndef _FSCL_INTERNAL_CONTACT_DB_CHANGE_EVENT_H_
+#define _FSCL_INTERNAL_CONTACT_DB_CHANGE_EVENT_H_
+
+#include <FBaseTypes.h>
+#include <FBaseResult.h>
+#include <FBaseRt_Event.h>
+
+namespace Tizen { namespace Base { namespace Runtime
+{
+class IEventListener;
+class IEventArg;
+}}}
+
+namespace Tizen { namespace Social
+{
+
+class _ContactDbChangeEvent
+       : public Tizen::Base::Runtime::_Event
+{
+public:
+       /**
+        * This is the default constructor.
+        *
+        * @since       2.0
+        */
+       _ContactDbChangeEvent(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Runtime::_Event::~_Event().
+        *
+        * @since       2.0
+        */
+       virtual ~_ContactDbChangeEvent(void);
+
+       result Construct(void);
+
+protected:
+       virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+}; // _ContactDbChangeEvent
+
+}} // Tizen::Social
+
+#endif // _FSCL_INTERNAL_CONTACT_DB_CHANGE_EVENT_H_
diff --git a/src/FScl_ContactDbChangeEventArg.cpp b/src/FScl_ContactDbChangeEventArg.cpp
new file mode 100644 (file)
index 0000000..e540338
--- /dev/null
@@ -0,0 +1,44 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_ContactDbChangeEventArg.cpp
+ * @brief      This is the implementation file for the _ContactDbChangeEventArg class.
+ *
+ */
+
+#include <FBaseSysLog.h>
+#include "FScl_ContactDbChangeEventArg.h"
+
+namespace Tizen { namespace Social
+{
+_ContactDbChangeEventArg::_ContactDbChangeEventArg(_ContactDbChangeType changeType)
+: __changeType(changeType)
+{
+       // empty body
+}
+
+_ContactDbChangeEventArg::~_ContactDbChangeEventArg(void)
+{
+       // empty body
+}
+
+_ContactDbChangeType
+_ContactDbChangeEventArg::GetChangeType(void) const
+{
+       return __changeType;
+}
+
+}}// Tizen::Social
diff --git a/src/FScl_ContactDbChangeEventArg.h b/src/FScl_ContactDbChangeEventArg.h
new file mode 100644 (file)
index 0000000..992d781
--- /dev/null
@@ -0,0 +1,85 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_ContactDbChangeEventArg.h
+ * @brief      This is the header file for the _ContactDbChangeEventArg class.
+ *
+ * This file contains the declarations of _ContactDbChangeEventArg.
+ */
+
+#ifndef _FSCL_INTERNAL_CONTACT_DB_CHANGE_EVENT_ARG_H_
+#define _FSCL_INTERNAL_CONTACT_DB_CHANGE_EVENT_ARG_H_
+
+#include <FBaseObject.h>
+#include <FSclRecord.h>
+#include <FBaseRtIEventArg.h>
+
+namespace Tizen { namespace Social
+{
+
+enum _ContactDbChangeType
+{
+       _CONTACT_DB_CHANGE_TYPE_CONTACT,
+       _CONTACT_DB_CHANGE_TYPE_GROUP,
+       _CONTACT_DB_CHANGE_TYPE_RELATION,
+       _CONTACT_DB_CHANGE_TYPE_ADDRESSBOOK
+};
+
+class _ContactDbChangeEventArg
+       : public Tizen::Base::Object
+       , public Tizen::Base::Runtime::IEventArg
+{
+public:
+       /**
+        * Initializes this instance of %_ContactDbChangeEventArg with the specified value.
+        *
+        * @since       2.0
+        *
+        * @param[in]   value   A _ContactDbChangeType type
+        */
+       _ContactDbChangeEventArg(_ContactDbChangeType changeType);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~_ContactDbChangeEventArg(void);
+
+       _ContactDbChangeType GetChangeType(void) const;
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @since       2.0
+        */
+       _ContactDbChangeEventArg(const _ContactDbChangeEventArg& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @since       2.0
+        */
+       _ContactDbChangeEventArg& operator =(const _ContactDbChangeEventArg& rhs);
+
+private:
+       _ContactDbChangeType __changeType;
+};
+
+}} // Tizen::Social
+
+#endif // _FSCL_INTERNAL_CONTACT_DB_CHANGE_EVENT_ARG_H_
diff --git a/src/FScl_ContactDbConnector.cpp b/src/FScl_ContactDbConnector.cpp
new file mode 100644 (file)
index 0000000..a28564c
--- /dev/null
@@ -0,0 +1,129 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_AddressbookUtil.cpp
+ * @brief              This is the implementation for _AddressbookUtil class.
+ *
+ * This file contains definitions of @e _AddressbookUtil class.
+ */
+
+#include <unique_ptr.h>
+#include <pthread.h>
+#include <FBaseSysLog.h>
+#include <FSysSystemTime.h>
+#include "FScl_ContactDbConnector.h"
+
+namespace Tizen { namespace Social
+{
+
+bool _ContactDbConnector::__isConnected = false;
+_ContactDbConnector* _ContactDbConnector::__pInstance = null;
+
+_ContactDbConnector::_ContactDbConnector(void)
+{
+}
+
+_ContactDbConnector::~_ContactDbConnector(void)
+{
+}
+
+result
+_ContactDbConnector::Connect(void)
+{
+       long long startTicks = 0;
+       long long endTicks = 0;
+
+       System::SystemTime::GetTicks(startTicks);
+
+       int ret = contacts_connect_with_flags(CONTACTS_CONNECT_FLAG_RETRY);
+
+       System::SystemTime::GetTicks(endTicks);
+
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_IPC_NOT_AVALIABLE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred. Contact server is not available. Elapsed time : %lld", GetErrorMessage(E_SYSTEM), endTicks - startTicks);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return E_SUCCESS;
+}
+
+result
+_ContactDbConnector::Disconnect(void)
+{
+       int ret = contacts_disconnect2();
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return E_SUCCESS;
+}
+
+result
+_ContactDbConnector::EnsureDbConnection(void)
+{
+       if (!__isConnected)
+       {
+               _ContactDbConnector* pInstance = GetInstance();
+               SysTryReturn(NID_SCL, pInstance != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               result r = pInstance->Connect();
+               SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               __isConnected = true;
+       }
+
+       return E_SUCCESS;
+}
+
+void
+_ContactDbConnector::InitContactDbConnector(void)
+{
+       std::unique_ptr<_ContactDbConnector> pInstance(new (std::nothrow) _ContactDbConnector());
+       SysTryReturnVoidResult(NID_SCL, pInstance, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __pInstance = pInstance.release();
+
+       std::atexit(DestroyContactDbConnector);
+}
+
+void
+_ContactDbConnector::DestroyContactDbConnector(void)
+{
+       delete __pInstance;
+       __pInstance = null;
+}
+
+_ContactDbConnector*
+_ContactDbConnector::GetInstance(void)
+{
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+       if (__pInstance == null)
+       {
+               ClearLastResult();
+
+               pthread_once(&onceBlock, InitContactDbConnector);
+
+               result r = GetLastResult();
+
+               if (IsFailed(r))
+               {
+                       onceBlock = PTHREAD_ONCE_INIT;
+               }
+       }
+
+       return __pInstance;
+}
+
+}}  // Tizen::Social
diff --git a/src/FScl_ContactDbMonitor.cpp b/src/FScl_ContactDbMonitor.cpp
new file mode 100644 (file)
index 0000000..05881a3
--- /dev/null
@@ -0,0 +1,343 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_ContactDbMonitor.cpp
+ * @brief              This is the implementation for _ContactDbMonitor class.
+ *
+ * This file contains definitions of @e _ContactDbMonitor class.
+ */
+
+#include <new>
+#include <contacts.h>
+#include <FBaseRtMutex.h>
+#include <FBaseSysLog.h>
+#include <FBaseColArrayListT.h>
+#include "FScl_IContactDbChangeEventListener.h"
+#include "FScl_ContactDbChangeEvent.h"
+#include "FScl_ContactDbChangeEventArg.h"
+#include "FScl_ContactDbConnector.h"
+#include "FScl_ContactDbMonitor.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Social
+{
+
+_ContactDbMonitor* _ContactDbMonitor::__pTheInstance = null;
+
+_ContactDbMonitor::__Callback::__Callback(const char* uri, contacts_db_changed_cb callback, void* pData)
+: __uri(null)
+, __callback(callback)
+, __pData(pData)
+, __registerred(false)
+{
+       __uri = strdup(uri);
+}
+
+result
+_ContactDbMonitor::__Callback::Register(void)
+{
+       int ret = contacts_db_add_changed_cb(__uri, __callback, __pData);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       __registerred = true;
+
+       return E_SUCCESS;
+}
+
+_ContactDbMonitor::__Callback::~__Callback(void)
+{
+       if (__registerred)
+       {
+               contacts_db_remove_changed_cb(__uri, __callback, __pData);
+       }
+
+       if (__uri != null)
+       {
+               free(__uri);
+       }
+}
+
+_ContactDbMonitor::_ContactDbMonitor(void)
+: __pEvent(null)
+, __pMutex(null)
+, __pContactChangeCallback(null)
+, __pGroupChangeCallback(null)
+, __pGroupRelationChagneCallback(null)
+, __pAddressbookChagneCallback(null)
+, __pAddressbookList(null)
+{
+       // empty body.
+}
+
+_ContactDbMonitor::~_ContactDbMonitor(void)
+{
+       if (__pAddressbookList != null)
+       {
+               contacts_list_destroy(__pAddressbookList, true);
+       }
+}
+
+result
+_ContactDbMonitor::Construct(void)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       result r = E_SUCCESS;
+
+       std::unique_ptr<Mutex> pMutex(new (std::nothrow) Mutex());
+       SysTryReturn(NID_SCL, pMutex != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = pMutex->Create();
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       std::unique_ptr<_ContactDbChangeEvent> pEvent(new (std::nothrow) _ContactDbChangeEvent());
+       SysTryReturnResult(NID_SCL, pEvent != null, E_OUT_OF_MEMORY, "Not enough memory.");
+
+       r = pEvent->Construct();
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       std::unique_ptr<__Callback> pContactChangeCallback(new (std::nothrow) __Callback(_contacts_contact._uri, OnContactDbChanged, this));
+       SysTryReturn(NID_SCL, pContactChangeCallback != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = pContactChangeCallback->Register();
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       std::unique_ptr<__Callback> pGroupChangeCallback(new (std::nothrow) __Callback(_contacts_group._uri, OnContactDbChanged, this));
+       SysTryReturn(NID_SCL, pGroupChangeCallback != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = pGroupChangeCallback->Register();
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       std::unique_ptr<__Callback> pGroupRelationChangeCallback(new (std::nothrow) __Callback(_contacts_group_relation._uri, OnContactDbChanged, this));
+       SysTryReturn(NID_SCL, pGroupRelationChangeCallback != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = pGroupRelationChangeCallback->Register();
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       std::unique_ptr<__Callback> pAddressbookChangeCallback(new (std::nothrow) __Callback(_contacts_address_book._uri, OnContactDbChanged, this));
+       SysTryReturn(NID_SCL, pAddressbookChangeCallback != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = pAddressbookChangeCallback->Register();
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pMutex = move(pMutex);
+       __pEvent = move(pEvent);
+       __pContactChangeCallback = move(pContactChangeCallback);
+       __pGroupChangeCallback = move(pGroupChangeCallback);
+       __pGroupRelationChagneCallback = move(pGroupRelationChangeCallback);
+       __pAddressbookChagneCallback = move(pAddressbookChangeCallback);
+
+       return E_SUCCESS;
+}
+
+result
+_ContactDbMonitor::AddListener(const _IContactDbChangeEventListener& listener)
+{
+       result r = __pMutex->Acquire();
+       SysTryReturn(NID_SCL, !IsFailed(r), E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       r = __pEvent->AddListener(listener);
+       SysTryCatch(NID_SCL, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = __pMutex->Release();
+       SysTryReturn(NID_SCL, !IsFailed(r), E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return E_SUCCESS;
+
+CATCH:
+       r = __pMutex->Release();
+       SysTryReturn(NID_SCL, !IsFailed(r), E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return r;
+}
+
+result
+_ContactDbMonitor::RemoveListener(const _IContactDbChangeEventListener& listener)
+{
+       result r = __pMutex->Acquire();
+       SysTryReturn(NID_SCL, !IsFailed(r), E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       r = __pEvent->RemoveListener(listener);
+       SysTryCatch(NID_SCL, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = __pMutex->Release();
+       SysTryReturn(NID_SCL, !IsFailed(r), E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return E_SUCCESS;
+
+CATCH:
+       r = __pMutex->Release();
+       SysTryReturn(NID_SCL, !IsFailed(r), E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return r;
+}
+
+_ContactDbMonitor*
+_ContactDbMonitor::GetInstance(void)
+{
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+       if (__pTheInstance == null)
+       {
+               ClearLastResult();
+
+               pthread_once(&onceBlock, InitSingleton);
+
+               result r = GetLastResult();
+               if (IsFailed(r))
+               {
+                       onceBlock = PTHREAD_ONCE_INIT;
+               }
+       }
+
+       return __pTheInstance;
+}
+
+void
+_ContactDbMonitor::OnContactDbChanged(const char* viewUri, void* pUserData)
+{
+       result r = E_SUCCESS;
+
+       _ContactDbMonitor* pContactDbMonitor = static_cast<_ContactDbMonitor*>(pUserData);
+       _ContactDbChangeEvent* pEvent = pContactDbMonitor->__pEvent.get();
+
+       std::unique_ptr<_ContactDbChangeEventArg> pArg;
+
+       if (strcmp(viewUri, _contacts_contact._uri) == 0)
+       {
+               pArg.reset(new (std::nothrow) _ContactDbChangeEventArg(_CONTACT_DB_CHANGE_TYPE_CONTACT));
+               SysTryReturnVoidResult(NID_SCL, pArg != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+       else if (strcmp(viewUri, _contacts_group._uri) == 0)
+       {
+               pArg.reset(new (std::nothrow) _ContactDbChangeEventArg(_CONTACT_DB_CHANGE_TYPE_GROUP));
+               SysTryReturnVoidResult(NID_SCL, pArg != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       }
+       else if (strcmp(viewUri, _contacts_group_relation._uri) == 0)
+       {
+               pArg.reset(new (std::nothrow) _ContactDbChangeEventArg(_CONTACT_DB_CHANGE_TYPE_RELATION));
+               SysTryReturnVoidResult(NID_SCL, pArg != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       }
+       else if (strcmp(viewUri, _contacts_address_book._uri) == 0)
+       {
+               pContactDbMonitor->UpdateAddressbookList();
+
+               pArg.reset(new (std::nothrow) _ContactDbChangeEventArg(_CONTACT_DB_CHANGE_TYPE_ADDRESSBOOK));
+               SysTryReturnVoidResult(NID_SCL, pArg != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+       else
+       {
+               return;
+       }
+
+       r = pEvent->Fire(*pArg);
+       SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pArg.release();
+}
+
+result
+_ContactDbMonitor::UpdateAddressbookList(void)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       ClearLastResult();
+
+       contacts_list_h pAddressbookList = null;
+       int ret = contacts_db_get_all_records(_contacts_address_book._uri, 0, 0, &pAddressbookList);
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       __List list(pAddressbookList);
+
+       __Lock lock(__pMutex.get());
+       result r = GetLastResult();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       if (__pAddressbookList != null)
+       {
+               contacts_list_destroy(__pAddressbookList, true);
+       }
+
+       __pAddressbookList = list.Release();
+
+       return E_SUCCESS;
+}
+
+int
+_ContactDbMonitor::GetAccountIdByAddressbookId(int addressbookId)
+{
+       ClearLastResult();
+
+       __Lock lock(__pMutex.get());
+
+       if (__pAddressbookList == null)
+       {
+               result r = UpdateAddressbookList();
+               SysTryReturn(NID_SCL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       int intValue = 0;
+       unsigned int count = 0;
+       contacts_record_h pAddressbook = null;
+
+       contacts_list_get_count(__pAddressbookList, &count);
+       contacts_list_first(__pAddressbookList);
+
+       for (unsigned int i = 0; i < count; i++)
+       {
+               contacts_list_get_current_record_p(__pAddressbookList, &pAddressbook);
+               contacts_record_get_int(pAddressbook, _contacts_address_book.id, &intValue);
+               if (intValue == addressbookId)
+               {
+                       contacts_record_get_int(pAddressbook, _contacts_address_book.account_id, &intValue);
+
+                       return intValue;
+               }
+
+               if (contacts_list_next(__pAddressbookList) != CONTACTS_ERROR_NONE)
+               {
+                       break;
+               }
+       }
+
+       return -1;
+}
+
+void
+_ContactDbMonitor::InitSingleton(void)
+{
+       std::unique_ptr<_ContactDbMonitor> pInst(new (std::nothrow) _ContactDbMonitor());
+       SysTryReturnVoidResult(NID_SCL, pInst, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pInst->Construct();
+       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pTheInstance = pInst.release();
+
+       std::atexit(DestroySingleton);
+}
+
+void
+_ContactDbMonitor::DestroySingleton(void)
+{
+       delete __pTheInstance;
+}
+
+}}  // Tizen::Social
diff --git a/src/FScl_ContactDbMonitor.h b/src/FScl_ContactDbMonitor.h
new file mode 100644 (file)
index 0000000..a8e1692
--- /dev/null
@@ -0,0 +1,176 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FScl_ContactDbMonitor.h
+* @brief       This is the header file for the _ContactDbMonitor class.
+*
+* This header file contains the declarations of the _ContactDbMonitor class.
+*/
+
+#ifndef _FSCL_INTERNAL_CONTACT_DB_MONITOR_H_
+#define _FSCL_INTERNAL_CONTACT_DB_MONITOR_H_
+
+#include <new>
+#include <pthread.h>
+#include <unique_ptr.h>
+#include <contacts.h>
+#include <FBaseTypes.h>
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+
+namespace Tizen { namespace Base {
+
+namespace Collection
+{
+template<typename Type>
+class ArrayListT;
+}
+
+namespace Runtime
+{
+class Mutex;
+}
+
+}}
+
+namespace Tizen { namespace Social
+{
+class _IContactDbChangeEventListener;
+class _ContactDbChangeEvent;
+
+/**
+ * @class      _ContactDbMonitor
+ * @brief      This class handles the _ContactDbMonitor operations.
+ * @since      2.0
+ * @see   _AddressbookImpl
+ *
+ */
+class _ContactDbMonitor
+       : public Tizen::Base::Object
+{
+public:
+       result AddListener(const _IContactDbChangeEventListener& listener);
+
+       result RemoveListener(const _IContactDbChangeEventListener& listener);
+
+       int GetAccountIdByAddressbookId(int addressbookId);
+
+       static _ContactDbMonitor* GetInstance(void);
+
+private:
+       _ContactDbMonitor(void);
+
+       virtual ~_ContactDbMonitor(void);
+
+       result Construct(void);
+
+       _ContactDbMonitor(const _ContactDbMonitor& rhs);
+
+       static void OnContactDbChanged(const char* viewUri, void* pUserData);
+
+       _ContactDbMonitor& operator =(const _ContactDbMonitor& rhs);
+
+       static void InitSingleton(void);
+
+       static void DestroySingleton(void);
+
+       result UpdateAddressbookList(void);
+
+
+private:
+       class __Callback
+       {
+       public:
+               __Callback(const char* uri, contacts_db_changed_cb callback, void* pData);
+               result Register(void);
+               ~__Callback(void);
+
+       private:
+               char* __uri;
+               contacts_db_changed_cb __callback;
+               void* __pData;
+               bool __registerred;
+       };
+
+       class __List
+       {
+               public:
+                       __List(contacts_list_h list)
+                       : __list(list)
+                       {
+                       }
+
+                       contacts_list_h Release(void)
+                       {
+                               contacts_list_h list = __list;
+
+                               __list = null;
+
+                               return list;
+                       }
+
+                       ~__List(void)
+                       {
+                               if (__list != null)
+                               {
+                                       contacts_list_destroy(__list, true);
+                               }
+                       }
+               private:
+                       contacts_list_h __list;
+       };
+
+       class __Lock
+       {
+               public:
+                       __Lock(Tizen::Base::Runtime::Mutex* pMutex)
+                       :__pMutex(null)
+                       {
+                               result r = pMutex->Acquire();
+                               SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+                               __pMutex = pMutex;
+                       }
+
+                       ~__Lock(void)
+                       {
+                               if (__pMutex != null)
+                               {
+                                       result r = __pMutex->Release();
+                                       SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+                               }
+                       }
+
+               private:
+                       Tizen::Base::Runtime::Mutex* __pMutex;
+       };
+
+private:
+       std::unique_ptr<_ContactDbChangeEvent> __pEvent;
+       std::unique_ptr<Tizen::Base::Runtime::Mutex> __pMutex;
+       std::unique_ptr<__Callback> __pContactChangeCallback;
+       std::unique_ptr<__Callback> __pGroupChangeCallback;
+       std::unique_ptr<__Callback> __pGroupRelationChagneCallback;
+       std::unique_ptr<__Callback> __pAddressbookChagneCallback;
+       contacts_list_h __pAddressbookList;
+
+       static _ContactDbMonitor* __pTheInstance;
+       friend struct std::default_delete< _ContactDbMonitor >;
+};     // _ContactDbMonitor
+
+}}  // Tizen::Social
+
+#endif //_FSCL_INTERNAL_CONTACT_DB_MONITOR_H_
diff --git a/src/FScl_ContactEventImpl.cpp b/src/FScl_ContactEventImpl.cpp
new file mode 100644 (file)
index 0000000..3324300
--- /dev/null
@@ -0,0 +1,169 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FScl_ContactEventImpl.cpp
+* @brief       This is the implementation for _ContactEventImpl class.
+*
+* This file contains definitions of @e _ContactEventImpl class.
+*/
+
+#include <FSclContactEvent.h>
+#include <FBaseSysLog.h>
+#include "FScl_ContactEventImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+_ContactEventImpl::_ContactEventImpl(void)
+: __type(CONTACT_EVENT_TYPE_BIRTHDAY)
+, __isDateChanged(false)
+{
+}
+
+_ContactEventImpl::_ContactEventImpl(const _ContactEventImpl& rhs)
+{
+       __date = rhs.__date;
+       __type = rhs.__type;
+       __label = rhs.__label;
+       __isDateChanged = rhs.__isDateChanged;
+}
+
+_ContactEventImpl::~_ContactEventImpl(void)
+{
+
+}
+
+_ContactEventImpl&
+_ContactEventImpl::operator =(const _ContactEventImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __date = rhs.__date;
+       __type = rhs.__type;
+       __label = rhs.__label;
+       __isDateChanged = rhs.__isDateChanged;
+
+       return *this;
+}
+
+bool
+_ContactEventImpl::operator ==(const _ContactEventImpl& rhs) const
+{
+       if (__date != rhs.__date)
+       {
+               return false;
+       }
+
+       if (__type != rhs.__type)
+       {
+               return false;
+       }
+
+       if (__label != rhs.__label)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+bool
+_ContactEventImpl::operator !=(const _ContactEventImpl& rhs) const
+{
+       return !(*this == rhs);
+}
+
+bool
+_ContactEventImpl::Equals(const Object& rhs) const
+{
+       const _ContactEventImpl* pContactEvent = dynamic_cast<const _ContactEventImpl*>(&rhs);
+       if (pContactEvent == null)
+       {
+               return false;
+       }
+
+       return *this == *pContactEvent;
+}
+
+int
+_ContactEventImpl::GetHashCode(void) const
+{
+       int hash = __date.GetHashCode() + __label.GetHashCode() + __type;
+
+       return hash;
+}
+
+ContactEventType
+_ContactEventImpl::GetType(void) const
+{
+       return __type;
+}
+
+DateTime
+_ContactEventImpl::GetDate(void) const
+{
+       return __date;
+}
+
+String
+_ContactEventImpl::GetLabel(void) const
+{
+       return __label;
+}
+
+void
+_ContactEventImpl::SetType(ContactEventType type)
+{
+       __type = type;
+}
+
+void
+_ContactEventImpl::SetDate(const DateTime& date)
+{
+       __date = date;
+       __isDateChanged = true;
+}
+
+void
+_ContactEventImpl::SetLabel(const String& label)
+{
+       __label = label;
+}
+
+bool
+_ContactEventImpl::IsDateChanged(void) const
+{
+       return __isDateChanged;
+}
+
+const _ContactEventImpl*
+_ContactEventImpl::GetInstance(const ContactEvent& contactEvent)
+{
+       return contactEvent.__pContactEventImpl;
+}
+
+_ContactEventImpl*
+_ContactEventImpl::GetInstance(ContactEvent& contactEvent)
+{
+       return contactEvent.__pContactEventImpl;
+}
+
+}} // Tizen::Social
diff --git a/src/FScl_ContactEventImpl.h b/src/FScl_ContactEventImpl.h
new file mode 100644 (file)
index 0000000..1b440ed
--- /dev/null
@@ -0,0 +1,83 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FScl_ContactEventImpl.h
+* @brief       This is the header file for the %_ContactEventImpl class.
+*
+* This header file contains the declarations of the %_ContactEventImpl class.
+*/
+#ifndef _FSCL_INTERNAL_CONTACT_EVENT_IMPL_H_
+#define _FSCL_INTERNAL_CONTACT_EVENT_IMPL_H_
+
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FBaseDateTime.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+
+class ContactEvent;
+
+class _OSP_EXPORT_ _ContactEventImpl
+       : public Tizen::Base::Object
+{
+public:
+       _ContactEventImpl(void);
+
+       _ContactEventImpl(const _ContactEventImpl& rhs);
+
+       virtual ~_ContactEventImpl(void);
+
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       virtual int GetHashCode(void) const;
+
+       ContactEventType GetType(void) const;
+
+       Tizen::Base::DateTime GetDate(void) const;
+
+       Tizen::Base::String GetLabel(void) const;
+
+       void SetType(ContactEventType type);
+
+       void SetLabel(const Tizen::Base::String& label);
+
+       void SetDate(const Tizen::Base::DateTime& date);
+
+       _ContactEventImpl& operator =(const _ContactEventImpl& rhs);
+
+       bool operator ==(const _ContactEventImpl& rhs) const;
+
+       bool operator !=(const _ContactEventImpl& rhs) const;
+
+       bool IsDateChanged(void) const;
+
+       static const _ContactEventImpl* GetInstance(const ContactEvent& contactEvent);
+
+       static _ContactEventImpl* GetInstance(ContactEvent& contactEvent);
+
+private:
+       ContactEventType __type;
+       Tizen::Base::DateTime __date;
+       Tizen::Base::String __label;
+       bool __isDateChanged;
+}; // _ContactEventImpl
+
+}} // Tizen::Social
+
+#endif // _FSCL_CONTACT_EVENT_H_
diff --git a/src/FScl_ContactImpl.cpp b/src/FScl_ContactImpl.cpp
new file mode 100644 (file)
index 0000000..9b272d0
--- /dev/null
@@ -0,0 +1,5015 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_ContactImpl.cpp
+ * @brief              This is the implementation for _ContactImpl class.
+ *
+ * This file contains definitions of _ContactImpl class.
+ */
+#include <FBaseString.h>
+#include <FBaseColArrayList.h>
+#include <FBaseSysLog.h>
+#include <FIoFile.h>
+#include <FMediaImage.h>
+#include <FSclAddress.h>
+#include <FSclPhoneNumber.h>
+#include <FSclEmail.h>
+#include <FSclUrl.h>
+#include <FSclImAddress.h>
+#include <FSclOrganization.h>
+#include <FSclContactEvent.h>
+#include <FSclRelationship.h>
+#include <FSclContactAppLaunchData.h>
+#include <FSclContact.h>
+#include <FApp_AppInfo.h>
+#include <FBase_StringConverter.h>
+#include <FIo_FileImpl.h>
+#include "FScl_ContactDbConnector.h"
+#include "FScl_PhoneNumberImpl.h"
+#include "FScl_ContactImpl.h"
+#include "FScl_AddressbookUtil.h"
+#include "FScl_UrlImpl.h"
+#include "FScl_EmailImpl.h"
+#include "FScl_AddressImpl.h"
+#include "FScl_ImAddressImpl.h"
+#include "FScl_OrganizationImpl.h"
+#include "FScl_ContactEventImpl.h"
+#include "FScl_ContactAppLaunchDataImpl.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Graphics;
+using namespace Tizen::Media;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Social
+{
+
+const int __CONTACT_CHANGED_TIME_YEAR_OFFSET  = 1900;
+const int __CONTACT_CHANGED_TIME_MONTH_OFFSET = 1;
+
+const int __CONTACT_MOD_YEAR = 10000;
+const int __CONTACT_MOD_MONTH = 100;
+
+#define __PARSE_DATE(date, year, month, day)                   \
+       do                                                      \
+       {                                                       \
+               int temp = date;                                \
+               year = temp/__CONTACT_MOD_YEAR;                 \
+               temp -= year*__CONTACT_MOD_YEAR;                \
+               month = temp/__CONTACT_MOD_MONTH;               \
+               day = temp - month*__CONTACT_MOD_MONTH;         \
+       }while(0)
+
+#define __CONVERT_DATE_TO_DATETIME(date, dateTime)             \
+       do                                                      \
+       {                                                       \
+               int temp = date;                                \
+               int year = 0;                                   \
+               int month = 0;                                  \
+               int day = 0;                                    \
+               year = temp/__CONTACT_MOD_YEAR;                 \
+               temp -= year*__CONTACT_MOD_YEAR;                \
+               month = temp/__CONTACT_MOD_MONTH;               \
+               day = temp - month*__CONTACT_MOD_MONTH;         \
+               dateTime.SetValue(year, month, day, 0, 0, 0);   \
+       }while(0)
+
+
+#define __CONVERT_DATETIME_TO_DATE(dateTime, date)                                                                             \
+       do                                                                                                                      \
+       {                                                                                                                       \
+               date = dateTime.GetYear()*__CONTACT_MOD_YEAR + dateTime.GetMonth()*__CONTACT_MOD_MONTH + dateTime.GetDay();     \
+       }while(0)
+
+_ContactImpl::_ContactImpl(void)
+       : __contactHandle(null)
+       , __isRemoved(false)
+{
+       contacts_record_h contactHandle = null;
+
+       _AddressbookUtil::InitContactViews();
+
+       int ret = contacts_record_create(_contacts_contact._uri, &contactHandle);
+       SysTryReturnVoidResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __contactHandle = contactHandle;
+}
+
+_ContactImpl::_ContactImpl(const _ContactImpl& rhs)
+       : __contactHandle(null)
+{
+       contacts_record_h contactHandle = null;
+
+       _AddressbookUtil::InitContactViews();
+
+       int ret = contacts_record_clone(rhs.__contactHandle, &contactHandle);
+       SysTryReturnVoidResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __contactHandle = contactHandle;
+       __isRemoved = rhs.__isRemoved;
+}
+
+_ContactImpl::~_ContactImpl(void)
+{
+       if (__contactHandle != null)
+       {
+               contacts_record_destroy(__contactHandle, true);
+       }
+}
+
+_ContactImpl&
+_ContactImpl::operator =(const _ContactImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       contacts_record_h contactHandle = null;
+
+       int ret = contacts_record_clone(rhs.__contactHandle, &contactHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_destroy(__contactHandle, true);
+       __contactHandle = contactHandle;
+
+       __isRemoved = rhs.__isRemoved;
+
+       return *this;
+}
+
+void
+_ContactImpl::SetContactRecordHandle(contacts_record_h contactHandle)
+{
+       contacts_record_destroy(__contactHandle, true);
+
+       __contactHandle = contactHandle;
+}
+
+contacts_record_h
+_ContactImpl::GetContactRecordHandle(void) const
+{
+       return __contactHandle;
+}
+
+result
+_ContactImpl::SetThumbnailPath(const Tizen::Base::String& filePath)
+{
+       SysTryReturn(NID_SCL, filePath.IsEmpty() || File::IsFileExist(filePath), E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[%s] The specified file is not found.", GetErrorMessage(E_FILE_NOT_FOUND));
+
+       String thumbnailPath;
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               _FileImpl::ConvertVirtualToPhysicalPath(filePath, thumbnailPath);
+       }
+       else
+       {
+               thumbnailPath = filePath;
+       }
+
+       int ret = CONTACTS_ERROR_NONE;
+       unsigned int count = 0;
+       contacts_record_h imageHandle = null;
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
+       if (count > 0)
+       {
+               if (!thumbnailPath.IsEmpty())
+               {
+                       std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(thumbnailPath));
+                       SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       bool isDefault = false;
+
+                       for (unsigned int i = 0; i < count; i++)
+                       {
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, i, &imageHandle);
+                               contacts_record_get_bool(imageHandle, _contacts_image.is_default, &isDefault);
+                               if (isDefault)
+                               {
+                                       break;
+                               }
+                       }
+                       contacts_record_set_bool(imageHandle, _contacts_image.is_default, true);
+                       contacts_record_set_str(imageHandle, _contacts_image.path, pCharArray.get());
+               }
+               else
+               {
+                       while (true)
+                       {
+                               ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, 0, &imageHandle);
+                               if (ret != CONTACTS_ERROR_NONE)
+                               {
+                                       break;
+                               }
+
+                               contacts_record_remove_child_record(__contactHandle, _contacts_contact.image, imageHandle);
+                               contacts_record_destroy(imageHandle, true);
+                       }
+
+               }
+       }
+       else
+       {
+               if (!thumbnailPath.IsEmpty())
+               {
+                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(thumbnailPath));
+                       SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       int ret = contacts_record_create(_contacts_image._uri, &imageHandle);
+                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       contacts_record_set_bool(imageHandle, _contacts_image.is_default, true);
+                       contacts_record_set_str(imageHandle, _contacts_image.path, pCharArray.get());
+
+                       contacts_record_add_child_record(__contactHandle, _contacts_contact.image, imageHandle);
+               }
+       }
+
+       return E_SUCCESS;
+}
+
+String
+_ContactImpl::GetThumbnailPath(void) const
+{
+       unsigned int count = 0;
+       bool isDefault = false;
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
+       if (count == 0)
+       {
+               return String(L"");
+       }
+
+       char* pCharValue = null;
+       contacts_record_h imageHandle = null;
+
+       for (unsigned int i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, i, &imageHandle);
+               contacts_record_get_str_p(imageHandle, _contacts_image.path, &pCharValue);
+
+               contacts_record_get_bool(imageHandle, _contacts_image.is_default, &isDefault);
+               if (isDefault)
+               {
+                       break;
+               }
+       }
+
+       return String(pCharValue);
+}
+
+Bitmap*
+_ContactImpl::GetThumbnailN(void) const
+{
+       unsigned int count = 0;
+       char* pCharValue = null;
+       bool isDefault = false;
+       contacts_record_h imageHandle = null;
+
+       ClearLastResult();
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
+       if (count == 0)
+       {
+               return null;
+       }
+
+       for (unsigned int i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, i, &imageHandle);
+               contacts_record_get_str_p(imageHandle, _contacts_image.path, &pCharValue);
+
+               contacts_record_get_bool(imageHandle, _contacts_image.is_default, &isDefault);
+               if (isDefault)
+               {
+                       break;
+               }
+       }
+
+       String thumbnailPath(pCharValue);
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               _FileImpl::ConvertPhysicalToVirtualPath(pCharValue, thumbnailPath);
+       }
+
+       Image image;
+       result r = image.Construct();
+       SysTryReturn(NID_SCL, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Failed to construct Image.", GetErrorMessage(E_SYSTEM));
+
+       ImageFormat imageFormat = image.GetImageFormat(thumbnailPath);
+       SysTryReturn(NID_SCL, GetLastResult() != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, null, E_SYSTEM, "[%s] Failed to get the format of the thumbnail image.", GetErrorMessage(E_SYSTEM));
+
+       BitmapPixelFormat bitmapPixelFormat = BITMAP_PIXEL_FORMAT_RGB565;
+
+       switch (imageFormat)
+       {
+       case IMG_FORMAT_JPG:
+               //fall through
+       case IMG_FORMAT_GIF:
+               //fall through
+       case IMG_FORMAT_BMP:
+               bitmapPixelFormat = BITMAP_PIXEL_FORMAT_RGB565;
+               break;
+       case IMG_FORMAT_PNG:
+               bitmapPixelFormat = BITMAP_PIXEL_FORMAT_ARGB8888;
+               break;
+       default:
+               SysLogException(NID_SCL, E_SYSTEM, "[%s] Unsupported image format.", GetErrorMessage(E_SYSTEM));
+               return null;
+       }
+
+        Bitmap* pBitmap = image.DecodeN(thumbnailPath, bitmapPixelFormat);
+        SysTryReturn(NID_SCL, GetLastResult() != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. ", GetErrorMessage(E_OUT_OF_MEMORY));
+        SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred. ", GetErrorMessage(E_SYSTEM));
+
+       return pBitmap;
+}
+
+result
+_ContactImpl::GetValue(const ContactPropertyId id, String& value) const
+{
+       unsigned int count = 0;
+       char* pCharValue = null;
+
+       switch (id)
+       {
+       case CONTACT_PROPERTY_ID_FIRST_NAME:
+               {
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_h nameHandle = null;
+
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
+                               contacts_record_get_str_p(nameHandle, _contacts_name.first, &pCharValue);
+                       }
+
+                       value = pCharValue;
+               }
+               break;
+       case CONTACT_PROPERTY_ID_LAST_NAME:
+               {
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_h nameHandle = null;
+
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
+                               contacts_record_get_str_p(nameHandle, _contacts_name.last, &pCharValue);
+                       }
+
+                       value = pCharValue;
+               }
+               break;
+       case CONTACT_PROPERTY_ID_DISPLAY_NAME:
+                       contacts_record_get_str_p(__contactHandle, _contacts_contact.display_name, &pCharValue);
+                       value = pCharValue;
+               break;
+       case CONTACT_PROPERTY_ID_NICK_NAME:
+               {
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_h nicknameHandle = null;
+
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, 0, &nicknameHandle);
+                               contacts_record_get_str_p(nicknameHandle, _contacts_nickname.name, &pCharValue);
+                       }
+
+                       value = pCharValue;
+               }
+               break;
+       case CONTACT_PROPERTY_ID_MIDDLE_NAME:
+               {
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_h nameHandle = null;
+
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
+                               contacts_record_get_str_p(nameHandle, _contacts_name.addition, &pCharValue);
+                       }
+
+                       value = pCharValue;
+               }
+               break;
+       case CONTACT_PROPERTY_ID_NAME_PREFIX:
+               {
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_h nameHandle = null;
+
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
+                               contacts_record_get_str_p(nameHandle, _contacts_name.prefix, &pCharValue);
+                       }
+
+                       value = pCharValue;
+               }
+               break;
+       case CONTACT_PROPERTY_ID_NAME_SUFFIX:
+               {
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_h nameHandle = null;
+
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
+                               contacts_record_get_str_p(nameHandle, _contacts_name.suffix, &pCharValue);
+                       }
+
+                       value = pCharValue;
+               }
+               break;
+       case CONTACT_PROPERTY_ID_JOB_TITLE:
+               {
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_h companyHandle = null;
+
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
+                               contacts_record_get_str_p(companyHandle, _contacts_company.job_title, &pCharValue);
+                       }
+
+                       value = pCharValue;
+               }
+               break;
+       case CONTACT_PROPERTY_ID_COMPANY:
+               {
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_h companyHandle = null;
+
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
+                               contacts_record_get_str_p(companyHandle, _contacts_company.name, &pCharValue);
+                       }
+
+                       value = pCharValue;
+               }
+               break;
+       case CONTACT_PROPERTY_ID_NOTE:
+               {
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_h noteHandle = null;
+
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, 0, &noteHandle);
+                               contacts_record_get_str_p(noteHandle, _contacts_note.note, &pCharValue);
+                       }
+
+                       value = pCharValue;
+               }
+               break;
+       case CONTACT_PROPERTY_ID_RINGTONE:
+               contacts_record_get_str_p(__contactHandle, _contacts_contact.ringtone_path, &pCharValue);
+               value = pCharValue;
+
+               if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+               {
+                       String temp;
+                       _FileImpl::ConvertPhysicalToVirtualPath(pCharValue, temp);
+                       value = temp;
+               }
+               break;
+       case CONTACT_PROPERTY_ID_THUMBNAIL:
+               {
+                       bool isDefault = false;
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_h imageHandle = null;
+
+                               for (unsigned int i = 0; i < count; i++)
+                               {
+                                       contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, i, &imageHandle);
+                                       contacts_record_get_str_p(imageHandle, _contacts_image.path, &pCharValue);
+
+                                       contacts_record_get_bool(imageHandle, _contacts_image.is_default, &isDefault);
+                                       if (isDefault)
+                                       {
+                                               break;
+                                       }
+                               }
+                       }
+               }
+               value = pCharValue;
+               break;
+       case CONTACT_PROPERTY_ID_PHONETIC_FIRST_NAME:
+               {
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_h phoneticNameHandle = null;
+
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
+                               contacts_record_get_str_p(phoneticNameHandle, _contacts_name.phonetic_first, &pCharValue);
+                       }
+
+                       value = pCharValue;
+               }
+               break;
+       case CONTACT_PROPERTY_ID_PHONETIC_LAST_NAME:
+               {
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_h phoneticNameHandle = null;
+
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
+                               contacts_record_get_str_p(phoneticNameHandle, _contacts_name.phonetic_last, &pCharValue);
+                       }
+
+                       value = pCharValue;
+               }
+               break;
+       case CONTACT_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
+               {
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_h phoneticNameHandle = null;
+
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
+                               contacts_record_get_str_p(phoneticNameHandle, _contacts_name.phonetic_middle, &pCharValue);
+                       }
+
+                       value = pCharValue;
+               }
+               break;
+       case CONTACT_PROPERTY_ID_UID:
+               {
+                       contacts_record_get_str_p(__contactHandle, _contacts_contact.uid, &pCharValue);
+                       value = pCharValue;
+               }
+               break;
+
+       default:
+               value = String(L"");
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d", GetErrorMessage(E_INVALID_ARG), id);
+               return E_INVALID_ARG;
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_ContactImpl::GetValue(const ContactPropertyId id, DateTime& value) const
+{
+       int intValue = 0;
+       DateTime dataTime;
+       unsigned int count = 0;
+
+       value = DateTime::GetMinValue();
+
+       switch (id)
+       {
+       case CONTACT_PROPERTY_ID_BIRTHDAY:
+               {
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
+                       if (count > 0)
+                       {
+                               int year = 0;
+                               int month = 0;
+                               int day = 0;
+
+                               contacts_record_h eventHandle = null;
+                               for (unsigned int i = 0; i < count; i++)
+                               {
+                                       contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
+                                       contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
+                                       if (intValue == CONTACTS_EVENT_TYPE_BIRTH)
+                                       {
+                                               contacts_record_get_int(eventHandle, _contacts_event.date, &intValue);
+
+                                               __PARSE_DATE(intValue, year, month, day);
+
+                                               value.SetValue(year, month, day, 0, 0, 0);
+                                               break;
+                                       }
+                               }
+                       }
+               }
+               break;
+
+       case CONTACT_PROPERTY_ID_ANNIVERSARY:
+               {
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
+                       if (count > 0)
+                       {
+                               int year = 0;
+                               int month = 0;
+                               int day = 0;
+
+                               contacts_record_h eventHandle = null;
+                               for (unsigned int i = 0; i < count; i++)
+                               {
+                                       contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
+                                       contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
+                                       if (intValue == CONTACTS_EVENT_TYPE_ANNIVERSARY)
+                                       {
+                                               contacts_record_get_int(eventHandle, _contacts_event.date, &intValue);
+
+                                               __PARSE_DATE(intValue, year, month, day);
+
+                                               value.SetValue(year, month, day, 0, 0, 0);
+                                               break;
+                                       }
+                               }
+                       }
+               }
+               break;
+
+       case CONTACT_PROPERTY_ID_LAST_REVISION:
+               {
+                       struct tm ts;
+                       int intValue = 0;
+
+                       contacts_record_get_int(__contactHandle, _contacts_contact.changed_time, &intValue);
+                       gmtime_r((time_t *)intValue, &ts);
+
+                       value.SetValue(ts.tm_year + __CONTACT_CHANGED_TIME_YEAR_OFFSET, ts.tm_mon + __CONTACT_CHANGED_TIME_MONTH_OFFSET, ts.tm_mday, ts.tm_hour, ts.tm_min, ts.tm_sec);
+               }
+               break;
+
+       default:
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
+               return E_INVALID_ARG;
+       }
+
+       return E_SUCCESS;
+}
+
+bool
+_ContactImpl::IsEmptyCompany(contacts_record_h companyHandle)
+{
+       char* pCharValue = null;
+
+       contacts_record_get_str_p(companyHandle, _contacts_company.name, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       contacts_record_get_str_p(companyHandle, _contacts_company.job_title, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       contacts_record_get_str_p(companyHandle, _contacts_company.department, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       contacts_record_get_str_p(companyHandle, _contacts_company.role, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       contacts_record_get_str_p(companyHandle, _contacts_company.assistant_name, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       contacts_record_get_str_p(companyHandle, _contacts_company.description, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       contacts_record_get_str_p(companyHandle, _contacts_company.location, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       contacts_record_get_str_p(companyHandle, _contacts_company.phonetic_name, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       contacts_record_get_str_p(companyHandle, _contacts_company.logo, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+bool
+_ContactImpl::IsEmptyName(contacts_record_h nameHandle)
+{
+       char* pCharValue = null;
+
+       contacts_record_get_str_p(nameHandle, _contacts_name.first, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       contacts_record_get_str_p(nameHandle, _contacts_name.last, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       contacts_record_get_str_p(nameHandle, _contacts_name.addition, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       contacts_record_get_str_p(nameHandle, _contacts_name.prefix, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       contacts_record_get_str_p(nameHandle, _contacts_name.suffix, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_first, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_last, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_middle, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+result
+_ContactImpl::SetValue(ContactPropertyId id, const String& value)
+{
+       SysTryReturn(NID_SCL, id != CONTACT_PROPERTY_ID_THUMBNAIL, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. Thumbnail cannot be set using this.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, id != CONTACT_PROPERTY_ID_DISPLAY_NAME, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. Display cannot be set using this.", GetErrorMessage(E_INVALID_ARG));
+
+       int ret = CONTACTS_ERROR_NONE;
+       unsigned int count = 0;
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               int maxLength = GetMaxLength(id);
+               SysTryReturn(NID_SCL, value.GetLength() <= maxLength || maxLength == -1 , E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The length of the value exceeds the maximum length.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       switch (id)
+       {
+       case CONTACT_PROPERTY_ID_FIRST_NAME:
+               {
+                       contacts_record_h nameHandle = null;
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
+
+                               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                               contacts_record_set_str(nameHandle, _contacts_name.first, pCharArray.get());
+
+                               if (value.IsEmpty() && IsEmptyName(nameHandle))
+                               {
+                                       contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
+                               }
+                       }
+                       else
+                       {
+                               if (!value.IsEmpty())
+                               {
+                                       ret = contacts_record_create(_contacts_name._uri, &nameHandle);
+                                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                                       contacts_record_set_str(nameHandle, _contacts_name.first, pCharArray.get());
+
+                                       contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
+                               }
+                       }
+               }
+               break;
+
+       case CONTACT_PROPERTY_ID_MIDDLE_NAME:
+               {
+                       contacts_record_h nameHandle = null;
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
+
+                               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                               contacts_record_set_str(nameHandle, _contacts_name.addition, pCharArray.get());
+
+                               if (value.IsEmpty() && IsEmptyName(nameHandle))
+                               {
+                                       contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
+                               }
+                       }
+                       else
+                       {
+                               if (!value.IsEmpty())
+                               {
+                                       ret = contacts_record_create(_contacts_name._uri, &nameHandle);
+                                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                                       contacts_record_set_str(nameHandle, _contacts_name.addition, pCharArray.get());
+
+                                       contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
+                               }
+                       }
+
+               }
+
+               break;
+
+       case CONTACT_PROPERTY_ID_LAST_NAME:
+               {
+                       contacts_record_h nameHandle = null;
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
+
+                               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                               contacts_record_set_str(nameHandle, _contacts_name.last, pCharArray.get());
+
+                               if (value.IsEmpty() && IsEmptyName(nameHandle))
+                               {
+                                       contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
+                               }
+                       }
+                       else
+                       {
+                               if (!value.IsEmpty())
+                               {
+                                       ret = contacts_record_create(_contacts_name._uri, &nameHandle);
+                                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                                       contacts_record_set_str(nameHandle, _contacts_name.last, pCharArray.get());
+
+                                       contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
+                               }
+                       }
+
+               }
+
+               break;
+       case CONTACT_PROPERTY_ID_NAME_SUFFIX:
+               {
+                       contacts_record_h nameHandle = null;
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
+
+                               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                               contacts_record_set_str(nameHandle, _contacts_name.suffix, pCharArray.get());
+
+                               if (value.IsEmpty() && IsEmptyName(nameHandle))
+                               {
+                                       contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
+                               }
+
+                       }
+                       else
+                       {
+                               if (!value.IsEmpty())
+                               {
+                                       ret = contacts_record_create(_contacts_name._uri, &nameHandle);
+
+                                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                                       contacts_record_set_str(nameHandle, _contacts_name.suffix, pCharArray.get());
+
+                                       contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
+                               }
+                       }
+
+               }
+
+               break;
+
+       case CONTACT_PROPERTY_ID_NAME_PREFIX:
+               {
+                       contacts_record_h nameHandle = null;
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
+
+                               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                               contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
+
+                               if (value.IsEmpty() && IsEmptyName(nameHandle))
+                               {
+                                       contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
+                               }
+                       }
+                       else
+                       {
+                               if (!value.IsEmpty())
+                               {
+                                       ret = contacts_record_create(_contacts_name._uri, &nameHandle);
+                                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                                       contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
+
+                                       contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
+                               }
+                       }
+
+               }
+
+               break;
+
+       case CONTACT_PROPERTY_ID_NICK_NAME:
+               {
+                       contacts_record_h nicknameHandle = null;
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, 0, &nicknameHandle);
+                               if (!value.IsEmpty())
+                               {
+                                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                                       contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
+                               }
+                               else
+                               {
+                                       while (true)
+                                       {
+                                               ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, 0, &nicknameHandle);
+                                               if (ret != CONTACTS_ERROR_NONE)
+                                               {
+                                                       break;
+                                               }
+
+                                               contacts_record_remove_child_record(__contactHandle, _contacts_contact.nickname, nicknameHandle);
+                                               contacts_record_destroy(nicknameHandle, true);
+                                       }
+                               }
+                       }
+                       else
+                       {
+                               if (!value.IsEmpty())
+                               {
+                                       ret = contacts_record_create(_contacts_nickname._uri, &nicknameHandle);
+                                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                                       contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
+
+                                       contacts_record_add_child_record(__contactHandle, _contacts_contact.nickname, nicknameHandle);
+                               }
+                       }
+
+               }
+
+               break;
+
+       case CONTACT_PROPERTY_ID_JOB_TITLE:
+               {
+                       contacts_record_h companyHandle = null;
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
+
+                               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                               contacts_record_set_str(companyHandle, _contacts_company.job_title, pCharArray.get());
+
+                               if (value.IsEmpty() && IsEmptyCompany(companyHandle))
+                               {
+                                       while (true)
+                                       {
+                                               ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
+                                               if (ret != CONTACTS_ERROR_NONE)
+                                               {
+                                                       break;
+                                               }
+
+                                               contacts_record_remove_child_record(__contactHandle, _contacts_contact.company, companyHandle);
+                                               contacts_record_destroy(companyHandle, true);
+                                       }
+                               }
+                       }
+                       else
+                       {
+                               if (!value.IsEmpty())
+                               {
+                                       ret = contacts_record_create(_contacts_company._uri, &companyHandle);
+                                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                                       contacts_record_set_str(companyHandle, _contacts_company.job_title, pCharArray.get());
+
+                                       contacts_record_add_child_record(__contactHandle, _contacts_contact.company, companyHandle);
+                               }
+                       }
+
+               }
+               break;
+
+       case CONTACT_PROPERTY_ID_COMPANY:
+               {
+                       contacts_record_h companyHandle = null;
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
+
+                               std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(value));
+                               contacts_record_set_str(companyHandle, _contacts_company.name, pCharArray.get());
+
+                               if (value.IsEmpty() && IsEmptyCompany(companyHandle))
+                               {
+                                       while (true)
+                                       {
+                                               ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
+                                               if (ret != CONTACTS_ERROR_NONE)
+                                               {
+                                                       break;
+                                               }
+
+                                               contacts_record_remove_child_record(__contactHandle, _contacts_contact.company, companyHandle);
+                                               contacts_record_destroy(companyHandle, true);
+                                       }
+
+                               }
+                       }
+                       else
+                       {
+                               if (!value.IsEmpty())
+                               {
+                                       ret = contacts_record_create(_contacts_company._uri, &companyHandle);
+                                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                                       std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(value));
+                                       contacts_record_set_str(companyHandle, _contacts_company.name, pCharArray.get());
+
+                                       contacts_record_add_child_record(__contactHandle, _contacts_contact.company, companyHandle);
+                               }
+                       }
+
+               }
+               break;
+
+       case CONTACT_PROPERTY_ID_NOTE:
+               {
+                       contacts_record_h noteHandle = null;
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
+                       if (count > 0)
+                       {
+                               if (!value.IsEmpty())
+                               {
+                                       contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, 0, &noteHandle);
+
+                                       std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(value));
+                                       contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
+                               }
+                               else
+                               {
+                                       while (true)
+                                       {
+                                               ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, 0, &noteHandle);
+                                               if (ret != CONTACTS_ERROR_NONE)
+                                               {
+                                                       break;
+                                               }
+
+                                               contacts_record_remove_child_record(__contactHandle, _contacts_contact.note, noteHandle);
+                                               contacts_record_destroy(noteHandle, true);
+                                       }
+                               }
+                       }
+                       else
+                       {
+                               if (!value.IsEmpty())
+                               {
+                                       ret = contacts_record_create(_contacts_note._uri, &noteHandle);
+                                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                                       std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(value));
+                                       contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
+
+                                       contacts_record_add_child_record(__contactHandle, _contacts_contact.note, noteHandle);
+                               }
+                       }
+               }
+               break;
+
+       case CONTACT_PROPERTY_ID_RINGTONE:
+       {
+               SysTryReturn(NID_SCL, value.IsEmpty() || File::IsFileExist(value), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+
+               String ringtonePath;
+               if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+               {
+                       if (!value.IsEmpty())
+                       {
+                               result r = _FileImpl::ConvertVirtualToPhysicalPath(value, ringtonePath);
+                               SysTryReturn(NID_SCL, r != E_INVALID_ARG, E_INVALID_ARG,  E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+                       }
+               }
+               else
+               {
+                       ringtonePath = value;
+               }
+
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(ringtonePath));
+
+               contacts_record_set_str(__contactHandle, _contacts_contact.ringtone_path, pCharArray.get());
+       }
+       break;
+
+       case CONTACT_PROPERTY_ID_PHONETIC_FIRST_NAME:
+               {
+                       contacts_record_h phoneticNameHandle = null;
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
+
+                               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                               contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_first, pCharArray.get());
+
+                               if (value.IsEmpty() && IsEmptyName(phoneticNameHandle))
+                               {
+                                       contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
+                                       contacts_record_destroy(phoneticNameHandle, true);
+                               }
+                       }
+                       else
+                       {
+                               if (!value.IsEmpty())
+                               {
+                                       ret = contacts_record_create(_contacts_name._uri, &phoneticNameHandle);
+                                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                                       contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_first, pCharArray.get());
+
+                                       contacts_record_add_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
+                               }
+                       }
+               }
+               break;
+       case CONTACT_PROPERTY_ID_PHONETIC_LAST_NAME:
+               {
+                       contacts_record_h phoneticNameHandle = null;
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
+
+                               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                               contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_last, pCharArray.get());
+
+                               if (value.IsEmpty() && IsEmptyName(phoneticNameHandle))
+                               {
+                                       contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
+                                       contacts_record_destroy(phoneticNameHandle, true);
+                               }
+                       }
+                       else
+                       {
+                               if (!value.IsEmpty())
+                               {
+                                       ret = contacts_record_create(_contacts_name._uri, &phoneticNameHandle);
+                                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                                       contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_last, pCharArray.get());
+
+                                       contacts_record_add_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
+                               }
+                       }
+               }
+               break;
+       case CONTACT_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
+               {
+                       contacts_record_h phoneticNameHandle = null;
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
+
+                               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                               contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_middle, pCharArray.get());
+
+                               if (value.IsEmpty() && IsEmptyName(phoneticNameHandle))
+                               {
+                                       contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
+                                       contacts_record_destroy(phoneticNameHandle, true);
+                               }
+                       }
+                       else
+                       {
+                               if (!value.IsEmpty())
+                               {
+                                       ret = contacts_record_create(_contacts_name._uri, &phoneticNameHandle);
+                                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                                       contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_middle, pCharArray.get());
+
+                                       contacts_record_add_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
+                               }
+                       }
+               }
+               break;
+       case CONTACT_PROPERTY_ID_UID:
+               {
+                       if (!value.IsEmpty())
+                       {
+                               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                               contacts_record_set_str(__contactHandle, _contacts_contact.uid, pCharArray.get());
+                       }
+                       else
+                       {
+                               contacts_record_set_str(__contactHandle, _contacts_contact.uid, null);
+                       }
+               }
+               break;
+       default:
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
+               return E_INVALID_ARG;
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_ContactImpl::SetValue(ContactPropertyId id, const DateTime& value)
+{
+       SysTryReturn(NID_SCL, id != CONTACT_PROPERTY_ID_LAST_REVISION, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. Thumbnail cannot be set using this.", GetErrorMessage(E_INVALID_ARG));
+
+       unsigned int count = 0;
+       int intValue = 0;
+       int ret = CONTACTS_ERROR_NONE;
+
+       switch (id)
+       {
+       case CONTACT_PROPERTY_ID_BIRTHDAY:
+               {
+                       bool found = false;
+                       int date = 0;
+                       contacts_record_h eventHandle = null;
+
+                       __CONVERT_DATETIME_TO_DATE(value, date);
+
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
+                       if (count > 0)
+                       {
+                               for (unsigned int i = 0; i < count; i++)
+                               {
+                                       contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
+                                       contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
+                                       if (intValue == CONTACTS_EVENT_TYPE_BIRTH)
+                                       {
+                                               contacts_record_set_int(eventHandle, _contacts_event.date, date);
+                                               found = true;
+                                               break;
+                                       }
+                               }
+                       }
+
+                       if (!found)
+                       {
+                               ret = contacts_record_create(_contacts_event._uri, &eventHandle);
+                               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                               contacts_record_set_int(eventHandle, _contacts_event.type, CONTACTS_EVENT_TYPE_BIRTH);
+                               contacts_record_set_int(eventHandle, _contacts_event.date, date);
+
+                               contacts_record_add_child_record(__contactHandle, _contacts_contact.event, eventHandle);
+                       }
+               }
+
+               break;
+
+       case CONTACT_PROPERTY_ID_ANNIVERSARY:
+               {
+                       bool found = false;
+                       int date = 0;
+                       contacts_record_h eventHandle = null;
+
+                       __CONVERT_DATETIME_TO_DATE(value, date);
+
+                       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
+                       if (count > 0)
+                       {
+                               for (unsigned int i = 0; i < count; i++)
+                               {
+                                       contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
+                                       contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
+                                       if (intValue == CONTACTS_EVENT_TYPE_ANNIVERSARY)
+                                       {
+                                               contacts_record_set_int(eventHandle, _contacts_event.date, date);
+                                               found = true;
+                                               break;
+                                       }
+                               }
+                       }
+
+                       if (!found)
+                       {
+                               ret = contacts_record_create(_contacts_event._uri, &eventHandle);
+                               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                               contacts_record_set_int(eventHandle, _contacts_event.type, CONTACTS_EVENT_TYPE_ANNIVERSARY);
+                               contacts_record_set_int(eventHandle, _contacts_event.date, date);
+
+                               contacts_record_add_child_record(__contactHandle, _contacts_contact.event, eventHandle);
+                       }
+               }
+
+               break;
+
+       default:
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
+               return E_INVALID_ARG;
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_ContactImpl::AddPhoneNumber(const PhoneNumber& phoneNumber)
+{
+       SysTryReturn(NID_SCL, !phoneNumber.GetPhoneNumber().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The phoneNumber is empty.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       int type = 0;
+       String stringValue;
+       contacts_record_h numberHandle = null;
+
+       int ret = contacts_record_create(_contacts_number._uri, &numberHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __ContactsRecordHandle recordHandle(numberHandle);
+
+       switch (_PhoneNumberImpl::GetInstance(phoneNumber)->GetType())
+       {
+               case PHONENUMBER_TYPE_HOME:
+                       type = CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE;
+                       break;
+               case PHONENUMBER_TYPE_WORK:
+                       type = CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE;
+                       break;
+               case PHONENUMBER_TYPE_MOBILE:
+                       type = CONTACTS_NUMBER_TYPE_CELL;
+                       break;
+               case PHONENUMBER_TYPE_HOME_FAX:
+                       type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME;
+                       break;
+               case PHONENUMBER_TYPE_WORK_FAX:
+                       type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK;
+                       break;
+               case PHONENUMBER_TYPE_PAGER:
+                       type = CONTACTS_NUMBER_TYPE_PAGER;
+                       break;
+               case PHONENUMBER_TYPE_CUSTOM:
+                       type = CONTACTS_NUMBER_TYPE_CUSTOM;
+                       break;
+               case PHONENUMBER_TYPE_ASSISTANT:
+                       type = CONTACTS_NUMBER_TYPE_ASSISTANT;
+                       break;
+               case PHONENUMBER_TYPE_OTHER:
+               default:
+                       type = CONTACTS_NUMBER_TYPE_OTHER;
+                       break;
+       }
+
+       contacts_record_set_int(numberHandle, _contacts_number.type, type);
+
+       stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetLabel();
+
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(numberHandle, _contacts_number.label, pCharArray.get());
+
+       stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetPhoneNumber();
+       pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(numberHandle, _contacts_number.number, pCharArray.get());
+
+       ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.number, numberHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       recordHandle.Release();
+
+       return E_SUCCESS;
+}
+
+result
+_ContactImpl::AddNickname(const String& nickname)
+{
+       SysTryReturn(NID_SCL, !nickname.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The nickname is an empty string.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       contacts_record_h nicknameHandle = null;
+
+       int ret = contacts_record_create(_contacts_nickname._uri, &nicknameHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(nickname));
+       SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
+
+       ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.nickname, nicknameHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       return E_SUCCESS;
+}
+
+result
+_ContactImpl::AddNote(const String& note)
+{
+       SysTryReturn(NID_SCL, !note.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The note is an empty string.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       contacts_record_h noteHandle = null;
+
+       int ret = contacts_record_create(_contacts_note._uri, &noteHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(note));
+       SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
+
+       ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.note, noteHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       return E_SUCCESS;
+}
+
+result
+_ContactImpl::AddEmail(const Email& email)
+{
+       SysTryReturn(NID_SCL, !email.GetEmail().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The email is empty.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       int type = 0;
+       String stringValue;
+       contacts_record_h emailHandle = null;
+
+       int ret = contacts_record_create(_contacts_email._uri, &emailHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __ContactsRecordHandle recordHandle(emailHandle);
+
+       switch (_EmailImpl::GetInstance(email)->GetType())
+       {
+               case EMAIL_TYPE_PERSONAL:
+                       type = CONTACTS_EMAIL_TYPE_HOME;
+                       break;
+               case EMAIL_TYPE_WORK:
+                       type = CONTACTS_EMAIL_TYPE_WORK;
+                       break;
+               case EMAIL_TYPE_CUSTOM:
+                       type = CONTACTS_EMAIL_TYPE_CUSTOM;
+                       break;
+               case EMAIL_TYPE_MOBILE:
+                       type = CONTACTS_EMAIL_TYPE_MOBILE;
+                       break;
+               case EMAIL_TYPE_OTHER:
+                       // fall through
+               default:
+                       type = CONTACTS_EMAIL_TYPE_OTHER;
+                       break;
+       }
+
+       contacts_record_set_int(emailHandle, _contacts_email.type, type);
+
+       stringValue = _EmailImpl::GetInstance(email)->GetLabel();
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(emailHandle, _contacts_email.label, pCharArray.get());
+
+       stringValue = _EmailImpl::GetInstance(email)->GetEmail();
+       pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(emailHandle, _contacts_email.email, pCharArray.get());
+
+       ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.email, emailHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       recordHandle.Release();
+
+       return E_SUCCESS;
+}
+
+result
+_ContactImpl::AddUrl(const Url& url)
+{
+       SysTryReturn(NID_SCL, !url.GetUrl().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The url is empty.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       int type = 0;
+       String stringValue;
+       contacts_record_h urlHandle = null;
+
+       int ret = contacts_record_create(_contacts_url._uri, &urlHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __ContactsRecordHandle recordHandle(urlHandle);
+
+       switch (_UrlImpl::GetInstance(url)->GetType())
+       {
+               case URL_TYPE_PERSONAL:
+                       type = CONTACTS_URL_TYPE_HOME;
+                       break;
+               case URL_TYPE_WORK:
+                       type = CONTACTS_URL_TYPE_WORK;
+                       break;
+               case URL_TYPE_CUSTOM:
+                       type = CONTACTS_URL_TYPE_CUSTOM;
+                       break;
+               case URL_TYPE_OTHER:
+                       // fall through
+               default:
+                       type = CONTACTS_URL_TYPE_OTHER;
+                       break;
+       }
+
+       // set type
+       contacts_record_set_int(urlHandle, _contacts_url.type, type);
+
+       // set label
+       stringValue = _UrlImpl::GetInstance(url)->GetLabel();
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(urlHandle, _contacts_url.label, pCharArray.get());
+
+       // set url
+       stringValue = _UrlImpl::GetInstance(url)->GetUrl();
+       pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(urlHandle, _contacts_url.url, pCharArray.get());
+
+       ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.url, urlHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       recordHandle.Release();
+
+       return E_SUCCESS;
+}
+
+result
+_ContactImpl::AddAddress(const Address& address)
+{
+       SysTryReturn(NID_SCL, !_AddressImpl::GetInstance(address)->IsEmpty() ,E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The address is empty.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       int type = 0;
+       String stringValue;
+       contacts_record_h addressHandle = null;
+
+       int ret = contacts_record_create(_contacts_address._uri, &addressHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __ContactsRecordHandle recordHandle(addressHandle);
+
+       switch (_AddressImpl::GetInstance(address)->GetType())
+       {
+               case ADDRESS_TYPE_HOME:
+                       type = CONTACTS_ADDRESS_TYPE_HOME;
+                       break;
+               case ADDRESS_TYPE_WORK:
+                       type = CONTACTS_ADDRESS_TYPE_WORK;
+                       break;
+               case ADDRESS_TYPE_CUSTOM:
+                       type = CONTACTS_ADDRESS_TYPE_CUSTOM;
+                       break;
+               case ADDRESS_TYPE_OTHER:
+                       // fall through
+               default:
+                       type = CONTACTS_ADDRESS_TYPE_OTHER;
+                       break;
+       }
+
+       contacts_record_set_int(addressHandle, _contacts_address.type, type);
+
+       stringValue = _AddressImpl::GetInstance(address)->GetLabel();
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(addressHandle, _contacts_address.label, pCharArray.get());
+
+       stringValue = _AddressImpl::GetInstance(address)->GetCity();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(addressHandle, _contacts_address.locality, pCharArray.get());
+       }
+
+
+       stringValue = _AddressImpl::GetInstance(address)->GetCountry();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(addressHandle, _contacts_address.country, pCharArray.get());
+       }
+
+       stringValue = _AddressImpl::GetInstance(address)->GetExtended();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(addressHandle, _contacts_address.extended, pCharArray.get());
+       }
+
+       stringValue = _AddressImpl::GetInstance(address)->GetPostalCode();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(addressHandle, _contacts_address.postal_code, pCharArray.get());
+       }
+
+       stringValue = _AddressImpl::GetInstance(address)->GetPostOfficeBoxNumber();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(addressHandle, _contacts_address.postbox, pCharArray.get());
+       }
+
+       stringValue = _AddressImpl::GetInstance(address)->GetState();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(addressHandle, _contacts_address.region, pCharArray.get());
+       }
+
+       stringValue = _AddressImpl::GetInstance(address)->GetStreet();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(addressHandle, _contacts_address.street, pCharArray.get());
+       }
+
+       ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.address, addressHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       recordHandle.Release();
+
+       return E_SUCCESS;
+}
+
+result
+_ContactImpl::AddImAddress(const ImAddress& imAddress)
+{
+       SysTryReturn(NID_SCL, !imAddress.GetImAddress().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%] Invalid argument is used. The imAddress is empty.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       int type = 0;
+       String stringValue;
+       contacts_record_h messengerHandle = null;
+
+       std::unique_ptr<char[]> pCharArray(null);
+
+       int ret = contacts_record_create(_contacts_messenger._uri, &messengerHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __ContactsRecordHandle recordHandle(messengerHandle);
+
+       stringValue = _ImAddressImpl::GetInstance(imAddress)->GetServiceProviderName();
+
+       if (stringValue == IM_ADDRESS_GOOGLE_TALK)
+       {
+               type = CONTACTS_MESSENGER_TYPE_GOOGLE;
+       }
+       else if (stringValue == IM_ADDRESS_MSN)
+       {
+               type = CONTACTS_MESSENGER_TYPE_WLM;
+       }
+       else if (stringValue == IM_ADDRESS_ICQ)
+       {
+               type = CONTACTS_MESSENGER_TYPE_ICQ;
+       }
+       else if (stringValue == IM_ADDRESS_AIM)
+       {
+               type = CONTACTS_MESSENGER_TYPE_AIM;
+       }
+       else if (stringValue == IM_ADDRESS_YAHOO)
+       {
+               type = CONTACTS_MESSENGER_TYPE_YAHOO;
+       }
+       else if (stringValue == IM_ADDRESS_QQ)
+       {
+               type = CONTACTS_MESSENGER_TYPE_QQ;
+       }
+       else if (stringValue == IM_ADDRESS_SKYPE)
+       {
+               type = CONTACTS_MESSENGER_TYPE_SKYPE;
+       }
+       else if (stringValue == IM_ADDRESS_JABBER)
+       {
+               type = CONTACTS_MESSENGER_TYPE_JABBER;
+       }
+       else if (stringValue == IM_ADDRESS_IRC)
+       {
+               type = CONTACTS_MESSENGER_TYPE_IRC;
+       }
+       else if (stringValue == IM_ADDRESS_FACEBOOK)
+       {
+               type = CONTACTS_MESSENGER_TYPE_FACEBOOK;
+       }
+       else
+       {
+               type = CONTACTS_MESSENGER_TYPE_CUSTOM;
+       }
+
+       contacts_record_set_int(messengerHandle, _contacts_messenger.type, type);
+       if (type == CONTACTS_MESSENGER_TYPE_CUSTOM)
+       {
+               pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null,  E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(messengerHandle, _contacts_messenger.label, pCharArray.get());
+       }
+
+       stringValue = _ImAddressImpl::GetInstance(imAddress)->GetImAddress();
+       pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(messengerHandle, _contacts_messenger.im_id, pCharArray.get());
+
+       ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.messenger, messengerHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       recordHandle.Release();
+
+       return E_SUCCESS;
+}
+result
+_ContactImpl::AddRelationship(const Relationship& relationship)
+{
+       SysTryReturn(NID_SCL, !relationship.GetRelativeName().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%] Invalid argument is used. The relationship is empty.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       int intValue = 0;
+       contacts_record_h relationshipHandle = null;
+
+       int ret = contacts_record_create(_contacts_relationship._uri, &relationshipHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __ContactsRecordHandle recordHandle(relationshipHandle);
+
+       switch (relationship.GetType())
+       {
+               case CONTACT_RELATIONSHIP_TYPE_ASSISTANT:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_ASSISTANT;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_BROTHER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_BROTHER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_CHILD:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_CHILD;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_FATHER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_FATHER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_FRIEND:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_FRIEND;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_MANAGER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_MANAGER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_MOTHER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_MOTHER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_PARENT:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_PARENT;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_PARTNER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_PARTNER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_REFERRED_BY:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_RELATIVE:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_RELATIVE;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_SISTER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_SISTER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_SPOUSE:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_SPOUSE;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_CUSTOM:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_CUSTOM;
+                       break;
+               default:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_OTHER;
+                       break;
+       }
+
+       // type
+       contacts_record_set_int(relationshipHandle, _contacts_relationship.type, intValue);
+
+       // label
+       String stringValue = relationship.GetLabel();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(relationshipHandle, _contacts_relationship.label, pCharArray.get());
+       }
+
+       // name
+       stringValue = relationship.GetRelativeName();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(relationshipHandle, _contacts_relationship.name, pCharArray.get());
+       }
+
+       ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.relationship, relationshipHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       recordHandle.Release();
+
+       return E_SUCCESS;
+
+}
+
+result
+_ContactImpl::AddContactAppLaunchData(const ContactAppLaunchData& appLaunchData)
+{
+       SysTryReturn(NID_SCL, !_ContactAppLaunchDataImpl::GetInstance(appLaunchData)->IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified app launch data does not have any property.", GetErrorMessage(E_INVALID_ARG));
+
+       String strValue = L"";
+
+       std::unique_ptr<ContactRecord, ContactRecordDeleter> pProfileRecord(_AddressbookUtil::CreateContactRecordN(_contacts_profile._uri));
+       SysTryReturn(NID_SCL, pProfileRecord != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       strValue = appLaunchData.GetDisplayText();
+       if (!strValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(pProfileRecord.get(), _contacts_profile.text, pCharArray.get());
+       }
+
+       strValue = _ContactAppLaunchDataImpl::GetInstance(appLaunchData)->GetUid();
+       if (!strValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(pProfileRecord.get(), _contacts_profile.uid, pCharArray.get());
+       }
+
+       strValue = appLaunchData.GetAppId();
+       if (!strValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(pProfileRecord.get(), _contacts_profile.app_id, pCharArray.get());
+       }
+
+       strValue = appLaunchData.GetOperationId();
+       if (!strValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(pProfileRecord.get(), _contacts_profile.service_operation, pCharArray.get());
+       }
+
+       strValue = appLaunchData.GetUri();
+       if (!strValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(pProfileRecord.get(), _contacts_profile.uri, pCharArray.get());
+       }
+
+       strValue = _ContactAppLaunchDataImpl::GetInstance(appLaunchData)->GetCategory();
+       if (!strValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(pProfileRecord.get(), _contacts_profile.category, pCharArray.get());
+       }
+
+       strValue = appLaunchData.GetMime();
+       if (!strValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(pProfileRecord.get(), _contacts_profile.mime, pCharArray.get());
+       }
+
+       // extra data
+       std::unique_ptr<IMap, AllElementsDeleter> pExtraData(appLaunchData.GetExtraDataN());
+       SysTryReturn(NID_SCL, pExtraData != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       std::unique_ptr<IMapEnumerator> pMapEnum(pExtraData->GetMapEnumeratorN());
+       SysTryReturn(NID_SCL, pMapEnum != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       result r = E_SUCCESS;
+       int limit = 0;
+       bool isFirst = true;
+       String extraData(L"");
+       String encodedString(L"");
+       std::unique_ptr<ByteBuffer> pByteBuffer(null);
+
+       String* pKey = null;
+       String* pVal = null;
+
+       while (pMapEnum->MoveNext() == E_SUCCESS)
+       {
+               if (!isFirst)
+               {
+                       extraData.Append(L",");
+               }
+               else
+               {
+                       isFirst = false;
+               }
+
+               pKey = static_cast<String*> (pMapEnum->GetKey());
+               pVal = static_cast<String*> (pMapEnum->GetValue());
+
+               pByteBuffer.reset(StringUtil::StringToUtf8N(*pKey));
+               SysTryReturn(NID_SCL, pByteBuffer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               limit = pByteBuffer->GetLimit();
+               pByteBuffer->SetLimit(limit - 1);
+
+               r = StringUtil::EncodeToBase64String(*pByteBuffer, encodedString);
+               SysTryReturn(NID_SCL, !IsFailed(r), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argutmnet is used.", GetErrorMessage(E_INVALID_ARG));
+
+               extraData.Append(encodedString);
+               extraData.Append(L":");
+
+               pByteBuffer.reset(StringUtil::StringToUtf8N(*pVal));
+               SysTryReturn(NID_SCL, pByteBuffer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               limit = pByteBuffer->GetLimit();
+               pByteBuffer->SetLimit(limit - 1);
+
+               r = StringUtil::EncodeToBase64String(*pByteBuffer, encodedString);
+               SysTryReturn(NID_SCL, !IsFailed(r), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argutmnet is used.", GetErrorMessage(E_INVALID_ARG));
+
+               extraData.Append(encodedString);
+       }
+
+       if (!extraData.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(extraData));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(pProfileRecord.get(), _contacts_profile.extra_data, pCharArray.get());
+       }
+
+       int ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.profile, pProfileRecord.get());
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       pProfileRecord.release();
+
+       return E_SUCCESS;
+}
+
+result
+_ContactImpl::AddEvent(const ContactEvent& event)
+{
+       SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, _ContactEventImpl::GetInstance(event)->IsDateChanged(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The datetime of the event has not been set.", GetErrorMessage(E_INVALID_ARG));
+
+       int type = 0;
+       int intValue = 0;
+       String stringValue;
+       contacts_record_h eventHandle = null;
+
+       int ret = contacts_record_create(_contacts_event._uri, &eventHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __ContactsRecordHandle recordHandle(eventHandle);
+
+       switch (event.GetType())
+       {
+               case CONTACT_EVENT_TYPE_ANNIVERSARY:
+                       type = CONTACTS_EVENT_TYPE_ANNIVERSARY;
+                       break;
+               case CONTACT_EVENT_TYPE_BIRTHDAY:
+                       type = CONTACTS_EVENT_TYPE_BIRTH;
+                       break;
+               case CONTACT_EVENT_TYPE_CUSTOM:
+                       type = CONTACTS_EVENT_TYPE_CUSTOM;
+                       break;
+               case CONTACT_EVENT_TYPE_OTHER:
+                       // fall through
+               default:
+                       type = CONTACTS_EVENT_TYPE_OTHER;
+                       break;
+       }
+
+       // type
+       contacts_record_set_int(eventHandle, _contacts_event.type, type);
+
+       // label
+       stringValue = event.GetLabel();
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(eventHandle, _contacts_event.label, pCharArray.get());
+
+       // date
+       DateTime dateValue = event.GetDate();
+       intValue = dateValue.GetYear()*10000 + dateValue.GetMonth()*100 + dateValue.GetDay();
+       contacts_record_set_int(eventHandle, _contacts_event.date, intValue);
+
+       ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.event, eventHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       recordHandle.Release();
+
+       return E_SUCCESS;
+}
+
+result
+_ContactImpl::AddOrganization(const Organization& organization)
+{
+       SysTryReturn(NID_SCL
+                                         ,     !organization.GetName().IsEmpty() ||
+                                               !organization.GetJobTitle().IsEmpty() ||
+                                               !organization.GetDepartment().IsEmpty() ||
+                                               !organization.GetRole().IsEmpty() ||
+                                               !organization.GetAgent().IsEmpty() ||
+                                               !organization.GetDescription().IsEmpty() ||
+                                               !organization.GetLocation().IsEmpty() ||
+                                               !organization.GetPhoneticName().IsEmpty() ||
+                                               !organization.GetLogoPath().IsEmpty()
+                                         ,E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The organization is empty.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_h organizationHandle = null;
+
+       int ret = contacts_record_create(_contacts_company._uri, &organizationHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __ContactsRecordHandle recordHandle(organizationHandle);
+
+       // name
+       String stringValue = organization.GetName();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.name, pCharArray.get());
+       }
+
+       // job title
+       stringValue = organization.GetJobTitle();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.job_title, pCharArray.get());
+       }
+
+       // department
+       stringValue = organization.GetDepartment();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.department, pCharArray.get());
+       }
+
+       // role
+       stringValue = organization.GetRole();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.role, pCharArray.get());
+       }
+
+       // agent
+       stringValue = organization.GetAgent();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, pCharArray.get());
+       }
+
+       // type
+       int type = 0;
+
+       switch (organization.GetType())
+       {
+               case ORGANIZATION_TYPE_WORK:
+                       type = CONTACTS_COMPANY_TYPE_WORK;
+                       break;
+               case ORGANIZATION_TYPE_CUSTOM:
+                       type = CONTACTS_COMPANY_TYPE_CUSTOM;
+                       break;
+               case ORGANIZATION_TYPE_OTHER:
+                       // fall through
+               default:
+                       type = CONTACTS_COMPANY_TYPE_OTHER;
+                       break;
+       }
+
+       contacts_record_set_int(organizationHandle, _contacts_company.type, type);
+
+       // label
+       stringValue = organization.GetLabel();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.label, pCharArray.get());
+       }
+
+       // description
+       stringValue = organization.GetDescription();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.description, pCharArray.get());
+       }
+
+       // location
+       stringValue = organization.GetLocation();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.location, pCharArray.get());
+       }
+
+       // phonetic name
+       stringValue = organization.GetPhoneticName();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, pCharArray.get());
+       }
+
+       // logo path
+       if (_OrganizationImpl::GetInstance(organization)->IsLogoPathChanged() == true)
+       {
+               stringValue = organization.GetLogoPath();
+               if (!stringValue.IsEmpty())
+               {
+                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+                       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       contacts_record_set_str(organizationHandle, _contacts_company.logo, pCharArray.get());
+               }
+       }
+
+       ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.company, organizationHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       recordHandle.Release();
+
+       return E_SUCCESS;
+}
+
+result
+_ContactImpl::RemoveAt(ContactMultiPropertyId id, int index)
+{
+       SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
+
+       unsigned int count = 0;
+       contacts_record_h recordHandle = null;
+
+       switch (id)
+       {
+       case CONTACT_MPROPERTY_ID_PHONE_NUMBERS:
+               contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
+               SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of phone numbers %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.number, index, &recordHandle);
+               contacts_record_remove_child_record(__contactHandle, _contacts_contact.number, recordHandle);
+               contacts_record_destroy(recordHandle, true);
+
+               break;
+       case CONTACT_MPROPERTY_ID_EMAILS:
+               contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
+               SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of emails %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.email, index, &recordHandle);
+               contacts_record_remove_child_record(__contactHandle, _contacts_contact.email, recordHandle);
+               contacts_record_destroy(recordHandle, true);
+
+               break;
+       case CONTACT_MPROPERTY_ID_URLS:
+               contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
+               SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of urls %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.url, index, &recordHandle);
+               contacts_record_remove_child_record(__contactHandle, _contacts_contact.url, recordHandle);
+               contacts_record_destroy(recordHandle, true);
+
+               break;
+       case CONTACT_MPROPERTY_ID_ADDRESSES:
+               contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
+               SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of addresses %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.address, index, &recordHandle);
+               contacts_record_remove_child_record(__contactHandle, _contacts_contact.address, recordHandle);
+               contacts_record_destroy(recordHandle, true);
+
+               break;
+       case CONTACT_MPROPERTY_ID_IMADDRESSES:
+               contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
+               SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of IM addresses %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.messenger, index, &recordHandle);
+               contacts_record_remove_child_record(__contactHandle, _contacts_contact.messenger, recordHandle);
+               contacts_record_destroy(recordHandle, true);
+
+               break;
+       case CONTACT_MPROPERTY_ID_ORGANIZATIONS:
+               contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
+               SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of organizations %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, index, &recordHandle);
+               contacts_record_remove_child_record(__contactHandle, _contacts_contact.company, recordHandle);
+               contacts_record_destroy(recordHandle, true);
+
+               break;
+       case CONTACT_MPROPERTY_ID_EVENTS:
+               contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
+               SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of events %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, index, &recordHandle);
+               contacts_record_remove_child_record(__contactHandle, _contacts_contact.event, recordHandle);
+               contacts_record_destroy(recordHandle, true);
+
+               break;
+       case CONTACT_MPROPERTY_ID_RELATIONSHIPS:
+               contacts_record_get_child_record_count(__contactHandle, _contacts_contact.relationship, &count);
+               SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of relationships %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.relationship, index, &recordHandle);
+               contacts_record_remove_child_record(__contactHandle, _contacts_contact.relationship, recordHandle);
+               contacts_record_destroy(recordHandle, true);
+
+               break;
+       case CONTACT_MPROPERTY_ID_NOTES:
+               contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
+               SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of notes %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, index, &recordHandle);
+               contacts_record_remove_child_record(__contactHandle, _contacts_contact.note, recordHandle);
+               contacts_record_destroy(recordHandle, true);
+
+               break;
+       case CONTACT_MPROPERTY_ID_NICKNAMES:
+               contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
+               SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of nicknames %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, index, &recordHandle);
+               contacts_record_remove_child_record(__contactHandle, _contacts_contact.nickname, recordHandle);
+               contacts_record_destroy(recordHandle, true);
+
+               break;
+       case CONTACT_MPROPERTY_ID_APP_LAUNCH_DATA:
+               contacts_record_get_child_record_count(__contactHandle, _contacts_contact.profile, &count);
+               SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of nicknames %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.profile, index, &recordHandle);
+               contacts_record_remove_child_record(__contactHandle, _contacts_contact.profile, recordHandle);
+               contacts_record_destroy(recordHandle, true);
+               
+               break;
+       default:
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
+               return E_INVALID_ARG;
+       }
+
+       return E_SUCCESS;
+}
+
+IList*
+_ContactImpl::GetValuesN(const ContactMultiPropertyId id)
+{
+       IList* pList = null;
+
+       SetLastResult(E_SUCCESS);
+
+       switch (id)
+       {
+       case CONTACT_MPROPERTY_ID_PHONE_NUMBERS:
+               pList = GetPhoneNumbersN();
+               break;
+
+       case CONTACT_MPROPERTY_ID_EMAILS:
+               pList = GetEmailsN();
+               break;
+
+       case CONTACT_MPROPERTY_ID_URLS:
+               pList = GetUrlsN();
+               break;
+
+       case CONTACT_MPROPERTY_ID_ADDRESSES:
+               pList = GetAddressesN();
+               break;
+
+       case CONTACT_MPROPERTY_ID_IMADDRESSES:
+               pList = GetImAddressesN();
+               break;
+
+       case CONTACT_MPROPERTY_ID_ORGANIZATIONS:
+               pList = GetOrganizationsN();
+               break;
+
+       case CONTACT_MPROPERTY_ID_EVENTS:
+               pList = GetEventsN();
+               break;
+
+       case CONTACT_MPROPERTY_ID_RELATIONSHIPS:
+               pList = GetRelationshipsN();
+               break;
+
+       case CONTACT_MPROPERTY_ID_NOTES:
+               pList = GetNotesN();
+               break;
+
+       case CONTACT_MPROPERTY_ID_NICKNAMES:
+               pList = GetNicknamesN();
+               break;
+       case CONTACT_MPROPERTY_ID_APP_LAUNCH_DATA:
+               pList = GetContactAppLaunchDataN();
+               break;
+       default:
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
+               return null;
+       }
+
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       return pList;
+}
+
+result
+_ContactImpl::SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber)
+{
+       SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
+       SysTryReturn(NID_SCL, !phoneNumber.GetPhoneNumber().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The phoneNumber is string.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unsigned int count = 0;
+       contacts_record_h recordHandle = null;
+       String stringValue;
+       int type = 0;
+       int oriType = 0;
+       PhoneNumberType phoneNumberType = PHONENUMBER_TYPE_HOME;
+       bool isChanged = false;
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
+       SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of phone numbers.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+       contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.number, index, &recordHandle);
+
+
+       stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetLabel();
+
+       switch (_PhoneNumberImpl::GetInstance(phoneNumber)->GetType())
+       {
+               case PHONENUMBER_TYPE_HOME:
+                       type = CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE;
+                       break;
+               case PHONENUMBER_TYPE_WORK:
+                       type = CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE;
+                       break;
+               case PHONENUMBER_TYPE_MOBILE:
+                       type = CONTACTS_NUMBER_TYPE_CELL;
+                       break;
+               case PHONENUMBER_TYPE_HOME_FAX:
+                       type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME;
+                       break;
+               case PHONENUMBER_TYPE_WORK_FAX:
+                       type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK;
+                       break;
+               case PHONENUMBER_TYPE_PAGER:
+                       type = CONTACTS_NUMBER_TYPE_PAGER;
+                       break;
+               case PHONENUMBER_TYPE_CUSTOM:
+                       type = CONTACTS_NUMBER_TYPE_CUSTOM;
+                       break;
+               case PHONENUMBER_TYPE_ASSISTANT:
+                       type = CONTACTS_NUMBER_TYPE_ASSISTANT;
+                       break;
+               case PHONENUMBER_TYPE_OTHER:
+                       isChanged = _PhoneNumberImpl::GetInstance(phoneNumber)->IsPhoneNumberTypeChanged();
+                       if (isChanged)
+                       {
+                               type = CONTACTS_NUMBER_TYPE_OTHER;
+                               break;
+                       }
+
+                       contacts_record_get_int(recordHandle, _contacts_number.type, &oriType);
+                       phoneNumberType = GetNativePhoneNumberType(oriType);
+                       if (phoneNumberType == PHONENUMBER_TYPE_OTHER)
+                       {
+                               type = oriType;
+                       }
+                       else
+                       {
+                               type = CONTACTS_NUMBER_TYPE_OTHER;
+                       }
+                       break;
+               default:
+                       type = CONTACTS_NUMBER_TYPE_OTHER;
+                       break;
+       }
+
+       // set type
+       contacts_record_set_int(recordHandle, _contacts_number.type, type);
+
+       // set label
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(recordHandle, _contacts_number.label, pCharArray.get());
+
+       // set phone number
+       stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetPhoneNumber();
+       pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(recordHandle, _contacts_number.number, pCharArray.get());
+
+       return E_SUCCESS;
+}
+
+result
+_ContactImpl::SetNicknameAt(int index, const String& nickname)
+{
+       SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
+       SysTryReturn(NID_SCL, !nickname.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The nickname is an empty string.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unsigned int count = 0;
+       contacts_record_h nicknameHandle = null;
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
+       SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of nicknames.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+       contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, index, &nicknameHandle);
+
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(nickname));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
+
+       return E_SUCCESS;
+}
+
+result
+_ContactImpl::SetNoteAt(int index, const String& note)
+{
+       SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
+       SysTryReturn(NID_SCL, !note.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The note is an empty string.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unsigned int count = 0;
+       contacts_record_h noteHandle = null;
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
+       SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of notes.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+       contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, index, &noteHandle);
+
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(note));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
+
+       return E_SUCCESS;
+}
+
+result
+_ContactImpl::SetOrganizationAt(int index, const Organization& organization)
+{
+       SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
+       SysTryReturn(NID_SCL
+                                         ,     !organization.GetName().IsEmpty() ||
+                                               !organization.GetJobTitle().IsEmpty() ||
+                                               !organization.GetDepartment().IsEmpty() ||
+                                               !organization.GetRole().IsEmpty() ||
+                                               !organization.GetAgent().IsEmpty() ||
+                                               !organization.GetDescription().IsEmpty() ||
+                                               !organization.GetLocation().IsEmpty() ||
+                                               !organization.GetPhoneticName().IsEmpty() ||
+                                               !organization.GetLogoPath().IsEmpty()
+                                         ,E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The organization is empty.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unsigned int count = 0;
+       contacts_record_h organizationHandle = null;
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
+       SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of organizations.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+
+       contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, index, &organizationHandle);
+
+       // name
+       String stringValue = organization.GetName();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.name, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(organizationHandle, _contacts_company.name, null);
+       }
+
+       // job title
+       stringValue = organization.GetJobTitle();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.job_title, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(organizationHandle, _contacts_company.job_title, null);
+       }
+
+       // department
+       stringValue = organization.GetDepartment();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.department, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(organizationHandle, _contacts_company.department, null);
+       }
+
+       // role
+       stringValue = organization.GetRole();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.role, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(organizationHandle, _contacts_company.role, null);
+       }
+
+       // agent
+       stringValue = organization.GetAgent();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, null);
+       }
+
+       // type
+       int type = 0;
+
+       switch (organization.GetType())
+       {
+               case ORGANIZATION_TYPE_WORK:
+                       type = CONTACTS_COMPANY_TYPE_WORK;
+                       break;
+               case ORGANIZATION_TYPE_CUSTOM:
+                       type = CONTACTS_COMPANY_TYPE_CUSTOM;
+                       break;
+               case ORGANIZATION_TYPE_OTHER:
+                       // fall through
+               default:
+                       type = CONTACTS_COMPANY_TYPE_OTHER;
+                       break;
+       }
+
+       contacts_record_set_int(organizationHandle, _contacts_company.type, type);
+
+       // label
+       stringValue = organization.GetLabel();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.label, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(organizationHandle, _contacts_company.label, null);
+       }
+
+       // description
+       stringValue = organization.GetDescription();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.description, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(organizationHandle, _contacts_company.description, null);
+       }
+
+       // location
+       stringValue = organization.GetLocation();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.location, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(organizationHandle, _contacts_company.location, null);
+       }
+
+       // phonetic name
+       stringValue = organization.GetPhoneticName();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, null);
+       }
+
+       // logo path
+       if (_OrganizationImpl::GetInstance(organization)->IsLogoPathChanged() == true)
+       {
+               stringValue = organization.GetLogoPath();
+               if (!stringValue.IsEmpty())
+               {
+                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+                       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       contacts_record_set_str(organizationHandle, _contacts_company.logo, pCharArray.get());
+               }
+               else
+               {
+                       contacts_record_set_str(organizationHandle, _contacts_company.logo, null);
+               }
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_ContactImpl::SetEventAt(int index, const ContactEvent& event)
+{
+       SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
+       SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, _ContactEventImpl::GetInstance(event)->IsDateChanged(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The datetime of the event has not been set.", GetErrorMessage(E_INVALID_ARG));
+
+       int type = 0;
+       int intValue = 0;
+       unsigned int count = 0;
+       String stringValue;
+       contacts_record_h eventHandle = null;
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
+       SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of events.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+       contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, index, &eventHandle);
+
+       switch (event.GetType())
+       {
+               case CONTACT_EVENT_TYPE_ANNIVERSARY:
+                       type = CONTACTS_EVENT_TYPE_ANNIVERSARY;
+                       break;
+               case CONTACT_EVENT_TYPE_BIRTHDAY:
+                       type = CONTACTS_EVENT_TYPE_BIRTH;
+                       break;
+               case CONTACT_EVENT_TYPE_CUSTOM:
+                       type = CONTACTS_EVENT_TYPE_CUSTOM;
+                       break;
+               case CONTACT_EVENT_TYPE_OTHER:
+                       // fall through
+               default:
+                       type = CONTACTS_EVENT_TYPE_OTHER;
+                       break;
+       }
+
+       // type
+       contacts_record_set_int(eventHandle, _contacts_event.type, type);
+
+       // label
+       stringValue = event.GetLabel();
+
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(eventHandle, _contacts_event.label, pCharArray.get());
+
+       // date
+       DateTime dateValue = event.GetDate();
+       intValue = dateValue.GetYear()*10000 + dateValue.GetMonth()*100 + dateValue.GetDay();
+       contacts_record_set_int(eventHandle, _contacts_event.date, intValue);
+
+       return E_SUCCESS;
+}
+
+result
+_ContactImpl::SetRelationshipAt(int index, const Relationship& relationship)
+{
+       SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
+       SysTryReturn(NID_SCL, !relationship.GetRelativeName().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The relationship is empty.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       int intValue = 0;
+       unsigned int count = 0;
+       contacts_record_h relationshipHandle = null;
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.relationship, &count);
+       SysTryReturn(NID_SCL, count > (unsigned int)index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of relationships.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+       contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.relationship, index, &relationshipHandle);
+
+       switch (relationship.GetType())
+       {
+               case CONTACT_RELATIONSHIP_TYPE_ASSISTANT:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_ASSISTANT;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_BROTHER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_BROTHER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_CHILD:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_CHILD;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_FATHER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_FATHER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_FRIEND:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_FRIEND;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_MANAGER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_MANAGER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_MOTHER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_MOTHER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_PARENT:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_PARENT;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_PARTNER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_PARTNER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_REFERRED_BY:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_RELATIVE:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_RELATIVE;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_SISTER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_SISTER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_SPOUSE:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_SPOUSE;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_CUSTOM:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_CUSTOM;
+                       break;
+               default:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_OTHER;
+                       break;
+       }
+
+       // type
+       contacts_record_set_int(relationshipHandle, _contacts_relationship.type, intValue);
+
+       // label
+       String stringValue = relationship.GetLabel();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(relationshipHandle, _contacts_relationship.label, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(relationshipHandle, _contacts_relationship.label, null);
+       }
+
+       // name
+       stringValue = relationship.GetRelativeName();
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(relationshipHandle, _contacts_relationship.name, pCharArray.get());
+
+       return E_SUCCESS;
+}
+
+result
+_ContactImpl::SetEmailAt(int index, const Email& email)
+{
+       SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
+       SysTryReturn(NID_SCL, !email.GetEmail().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The email is empty.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unsigned int count = 0;
+       contacts_record_h emailHandle = null;
+       String stringValue;
+       int type = 0;
+       int oriType = 0;
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
+       SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of emails.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+       contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.email, index, &emailHandle);
+
+       stringValue = _EmailImpl::GetInstance(email)->GetLabel();
+
+       switch (_EmailImpl::GetInstance(email)->GetType())
+       {
+               case EMAIL_TYPE_PERSONAL:
+                       type = CONTACTS_EMAIL_TYPE_HOME;
+                       break;
+               case EMAIL_TYPE_WORK:
+                       type = CONTACTS_EMAIL_TYPE_WORK;
+                       break;
+               case EMAIL_TYPE_CUSTOM:
+                       type = CONTACTS_EMAIL_TYPE_CUSTOM;
+                       break;
+               case EMAIL_TYPE_MOBILE:
+                       type = CONTACTS_EMAIL_TYPE_MOBILE;
+                       break;
+               case EMAIL_TYPE_OTHER:
+                       contacts_record_get_int(emailHandle, _contacts_email.type, &oriType);
+                       if (oriType == CONTACTS_EMAIL_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
+                       {
+                               char* pCharValue = null;
+
+                               contacts_record_get_str_p(emailHandle, _contacts_email.label, &pCharValue);
+
+                               stringValue = pCharValue;
+                               type = CONTACTS_EMAIL_TYPE_CUSTOM;
+                       }
+                       else if (oriType == CONTACTS_EMAIL_TYPE_MOBILE && _AppInfo::GetApiVersion() < _API_VERSION_2_1)
+                       {
+                               type = CONTACTS_EMAIL_TYPE_MOBILE;
+                       }
+                       else
+                       {
+                               type = CONTACTS_EMAIL_TYPE_OTHER;
+                       }
+                       break;
+               default:
+                       type = CONTACTS_EMAIL_TYPE_OTHER;
+                       break;
+       }
+
+       // set type
+       contacts_record_set_int(emailHandle, _contacts_email.type, type);
+
+       // set label
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(emailHandle, _contacts_email.label, pCharArray.get());
+
+       // set email
+       stringValue = _EmailImpl::GetInstance(email)->GetEmail();
+       pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(emailHandle, _contacts_email.email, pCharArray.get());
+
+       return E_SUCCESS;
+}
+
+result
+_ContactImpl::SetUrlAt(int index, const Url& url)
+{
+       SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
+       SysTryReturn(NID_SCL, !url.GetUrl().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The url is empty.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unsigned int count = 0;
+       contacts_record_h recordHandle = null;
+       String stringValue;
+       int type = 0;
+       int oriType = 0;
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
+       SysTryReturn(NID_SCL, count > (unsigned int)index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of urls.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+       contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.url, index, &recordHandle);
+
+
+       stringValue = _UrlImpl::GetInstance(url)->GetLabel();
+
+       switch (_UrlImpl::GetInstance(url)->GetType())
+       {
+               case URL_TYPE_PERSONAL:
+                       type = CONTACTS_URL_TYPE_HOME;
+                       break;
+               case URL_TYPE_WORK:
+                       type = CONTACTS_URL_TYPE_WORK;
+                       break;
+               case URL_TYPE_CUSTOM:
+                       type = CONTACTS_URL_TYPE_CUSTOM;
+                       break;
+               case URL_TYPE_OTHER:
+                       contacts_record_get_int(recordHandle, _contacts_url.type, &oriType);
+
+                       if (oriType == CONTACTS_URL_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
+                       {
+                               char* pCharValue = null;
+
+                               contacts_record_get_str_p(recordHandle, _contacts_url.label, &pCharValue);
+
+                               stringValue = pCharValue;
+                               type = CONTACTS_URL_TYPE_CUSTOM;
+                       }
+                       else
+                       {
+                               type = CONTACTS_URL_TYPE_OTHER;
+                       }
+                       break;
+               default:
+                       type = CONTACTS_URL_TYPE_OTHER;
+                       break;
+       }
+
+       // set type
+       contacts_record_set_int(recordHandle, _contacts_url.type, type);
+
+       // set label
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(recordHandle, _contacts_url.label, pCharArray.get());
+
+       // set url
+       stringValue = _UrlImpl::GetInstance(url)->GetUrl();
+       pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(recordHandle, _contacts_url.url, pCharArray.get());
+
+       return E_SUCCESS;
+}
+
+result
+_ContactImpl::SetAddressAt(int index, const Address& address)
+{
+       SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_MEMORY, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
+       SysTryReturn(NID_SCL,
+                                         !address.GetCity().IsEmpty() ||
+                                         !address.GetCountry().IsEmpty() ||
+                                         !address.GetExtended().IsEmpty() ||
+                                         !address.GetPostalCode().IsEmpty() ||
+                                         !address.GetPostOfficeBoxNumber().IsEmpty() ||
+                                         !address.GetState().IsEmpty() ||
+                                         !address.GetStreet().IsEmpty(),
+                                         E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The address is empty.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unsigned int count = 0;
+       contacts_record_h recordHandle = null;
+       int type = 0;
+       int oriType = 0;
+       String stringValue;
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
+       SysTryReturn(NID_SCL, count > (unsigned int)index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of addresses %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+       contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.address, index, &recordHandle);
+
+       stringValue = _AddressImpl::GetInstance(address)->GetLabel();
+
+       switch (_AddressImpl::GetInstance(address)->GetType())
+       {
+               case ADDRESS_TYPE_HOME:
+                       type = CONTACTS_ADDRESS_TYPE_HOME;
+                       break;
+               case ADDRESS_TYPE_WORK:
+                       type = CONTACTS_ADDRESS_TYPE_WORK;
+                       break;
+               case ADDRESS_TYPE_CUSTOM:
+                       type = CONTACTS_ADDRESS_TYPE_CUSTOM;
+                       break;
+               case ADDRESS_TYPE_OTHER:
+                       contacts_record_get_int(recordHandle, _contacts_address.type, &oriType);
+
+                       if (oriType == CONTACTS_ADDRESS_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
+                       {
+                               char* pCharValue = null;
+
+                               contacts_record_get_str_p(recordHandle, _contacts_address.label, &pCharValue);
+
+                               stringValue = pCharValue;
+                               type = CONTACTS_ADDRESS_TYPE_CUSTOM;
+                       }
+                       else
+                       {
+                               type = CONTACTS_ADDRESS_TYPE_OTHER;
+                       }
+                       break;
+               default:
+                       type = CONTACTS_ADDRESS_TYPE_OTHER;
+                       break;
+       }
+
+       // set type
+       contacts_record_set_int(recordHandle, _contacts_address.type, type);
+
+       // set label
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(recordHandle, _contacts_address.label, pCharArray.get());
+
+       // address
+       stringValue = _AddressImpl::GetInstance(address)->GetCity();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(recordHandle, _contacts_address.locality, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(recordHandle, _contacts_address.locality, null);
+       }
+
+       stringValue = _AddressImpl::GetInstance(address)->GetCountry();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(recordHandle, _contacts_address.country, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(recordHandle, _contacts_address.country, null);
+       }
+
+       stringValue = _AddressImpl::GetInstance(address)->GetExtended();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(recordHandle, _contacts_address.extended, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(recordHandle, _contacts_address.extended, null);
+       }
+
+       stringValue = _AddressImpl::GetInstance(address)->GetPostalCode();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(recordHandle, _contacts_address.postal_code, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(recordHandle, _contacts_address.postal_code, null);
+       }
+
+       stringValue = _AddressImpl::GetInstance(address)->GetPostOfficeBoxNumber();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(recordHandle, _contacts_address.postbox, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(recordHandle, _contacts_address.postbox, null);
+       }
+
+       stringValue = _AddressImpl::GetInstance(address)->GetState();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(recordHandle, _contacts_address.region, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(recordHandle, _contacts_address.region, null);
+       }
+
+       stringValue = _AddressImpl::GetInstance(address)->GetStreet();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(recordHandle, _contacts_address.street, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(recordHandle, _contacts_address.street, null);
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_ContactImpl::SetImAddressAt(int index, const ImAddress& imAddress)
+{
+       SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
+       SysTryReturn(NID_SCL, !imAddress.GetImAddress().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The imAddress is empty.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unsigned int count = 0;
+       contacts_record_h messengerHandle = null;
+       String stringValue;
+       int type = 0;
+       std::unique_ptr<char[]> pCharArray(null);
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
+       SysTryReturn(NID_SCL, count > (unsigned int)index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of IM addresses.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+       contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.messenger, index, &messengerHandle);
+
+       stringValue = _ImAddressImpl::GetInstance(imAddress)->GetServiceProviderName();
+
+       if (stringValue == IM_ADDRESS_GOOGLE_TALK)
+       {
+               type = CONTACTS_MESSENGER_TYPE_GOOGLE;
+       }
+       else if (stringValue == IM_ADDRESS_MSN)
+       {
+               type = CONTACTS_MESSENGER_TYPE_WLM;
+       }
+       else if (stringValue == IM_ADDRESS_ICQ)
+       {
+               type = CONTACTS_MESSENGER_TYPE_ICQ;
+       }
+       else if (stringValue == IM_ADDRESS_AIM)
+       {
+               type = CONTACTS_MESSENGER_TYPE_AIM;
+       }
+       else if (stringValue == IM_ADDRESS_YAHOO)
+       {
+               type = CONTACTS_MESSENGER_TYPE_YAHOO;
+       }
+       else if (stringValue == IM_ADDRESS_QQ)
+       {
+               type = CONTACTS_MESSENGER_TYPE_QQ;
+       }
+       else if (stringValue == IM_ADDRESS_SKYPE)
+       {
+               type = CONTACTS_MESSENGER_TYPE_SKYPE;
+       }
+       else if (stringValue == IM_ADDRESS_JABBER)
+       {
+               type = CONTACTS_MESSENGER_TYPE_JABBER;
+       }
+       else if (stringValue == IM_ADDRESS_IRC)
+       {
+               type = CONTACTS_MESSENGER_TYPE_IRC;
+       }
+       else if (stringValue == IM_ADDRESS_FACEBOOK)
+       {
+               type = CONTACTS_MESSENGER_TYPE_FACEBOOK;
+       }
+       else
+       {
+               type = CONTACTS_MESSENGER_TYPE_CUSTOM;
+       }
+
+       contacts_record_set_int(messengerHandle, _contacts_messenger.type, type);
+       if (type == CONTACTS_MESSENGER_TYPE_CUSTOM)
+       {
+               pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(messengerHandle, _contacts_messenger.label, pCharArray.get());
+       }
+
+       stringValue = _ImAddressImpl::GetInstance(imAddress)->GetImAddress();
+       pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(messengerHandle, _contacts_messenger.im_id, pCharArray.get());
+
+       return E_SUCCESS;
+}
+
+result
+_ContactImpl::SetContactAppLaunchDataAt(int index, const ContactAppLaunchData& appLaunchData)
+{
+       SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
+       SysTryReturn(NID_SCL, !_ContactAppLaunchDataImpl::GetInstance(appLaunchData)->IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified app launch data does not have any property.", GetErrorMessage(E_INVALID_ARG));
+
+       unsigned int count = 0;
+       String strValue;
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.profile, &count);
+       SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of contact profile %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+       contacts_record_h profileRecord = null;
+       contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.profile, index, &profileRecord);
+
+       strValue = _ContactAppLaunchDataImpl::GetInstance(appLaunchData)->GetDisplayText();
+       if (strValue.IsEmpty())
+       {
+               contacts_record_set_str(profileRecord, _contacts_profile.text, null);
+       }
+
+       else
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(profileRecord, _contacts_profile.text, pCharArray.get());
+       }
+
+       strValue = _ContactAppLaunchDataImpl::GetInstance(appLaunchData)->GetUid();
+       if (strValue.IsEmpty())
+       {
+               contacts_record_set_str(profileRecord, _contacts_profile.uid, null);
+       }
+
+       else
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(profileRecord, _contacts_profile.uid, pCharArray.get());
+       }
+
+       strValue = _ContactAppLaunchDataImpl::GetInstance(appLaunchData)->GetAppId();
+       if (strValue.IsEmpty())
+       {
+               contacts_record_set_str(profileRecord, _contacts_profile.app_id, null);
+       }
+
+       else
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(profileRecord, _contacts_profile.app_id, pCharArray.get());
+       }
+
+       strValue = _ContactAppLaunchDataImpl::GetInstance(appLaunchData)->GetOperationId();
+       if (strValue.IsEmpty())
+       {
+               contacts_record_set_str(profileRecord, _contacts_profile.service_operation, null);
+       }
+
+       else
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(profileRecord, _contacts_profile.service_operation, pCharArray.get());
+       }
+
+       strValue = _ContactAppLaunchDataImpl::GetInstance(appLaunchData)->GetUri();
+       if (strValue.IsEmpty())
+       {
+               contacts_record_set_str(profileRecord, _contacts_profile.uri, null);
+       }
+
+       else
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(profileRecord, _contacts_profile.uri, pCharArray.get());
+       }
+
+       strValue = _ContactAppLaunchDataImpl::GetInstance(appLaunchData)->GetCategory();
+       if (strValue.IsEmpty())
+       {
+               contacts_record_set_str(profileRecord, _contacts_profile.category, null);
+       }
+
+       else
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(profileRecord, _contacts_profile.category, pCharArray.get());
+       }
+
+       strValue = _ContactAppLaunchDataImpl::GetInstance(appLaunchData)->GetMime();
+       if (strValue.IsEmpty())
+       {
+               contacts_record_set_str(profileRecord, _contacts_profile.mime, null);
+       }
+
+       else
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(profileRecord, _contacts_profile.mime, pCharArray.get());
+       }
+
+       // extra data
+       std::unique_ptr<IMap, AllElementsDeleter> pExtraData(appLaunchData.GetExtraDataN());
+       SysTryReturn(NID_SCL, pExtraData != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       std::unique_ptr<IMapEnumerator> pMapEnum(pExtraData->GetMapEnumeratorN());
+       SysTryReturn(NID_SCL, pMapEnum != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       result r = E_SUCCESS;
+       int limit = 0;
+       bool isFirst = true;
+       String extraData(L"");
+       String encodedString(L"");
+       std::unique_ptr<ByteBuffer> pByteBuffer(null);
+
+       String* pKey = null;
+       String* pVal = null;
+
+       while (pMapEnum->MoveNext() == E_SUCCESS)
+       {
+               if (!isFirst)
+               {
+                       extraData.Append(L",");
+               }
+               else
+               {
+                       isFirst = false;
+               }
+
+               pKey = static_cast<String*> (pMapEnum->GetKey());
+               pVal = static_cast<String*> (pMapEnum->GetValue());
+
+               pByteBuffer.reset(StringUtil::StringToUtf8N(*pKey));
+               SysTryReturn(NID_SCL, pByteBuffer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               limit = pByteBuffer->GetLimit();
+               pByteBuffer->SetLimit(limit - 1);
+
+               r = StringUtil::EncodeToBase64String(*pByteBuffer, encodedString);
+               SysTryReturn(NID_SCL, !IsFailed(r), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argutmnet is used.", GetErrorMessage(E_INVALID_ARG));
+
+               extraData.Append(encodedString);
+               extraData.Append(L":");
+
+               pByteBuffer.reset(StringUtil::StringToUtf8N(*pVal));
+               SysTryReturn(NID_SCL, pByteBuffer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               limit = pByteBuffer->GetLimit();
+               pByteBuffer->SetLimit(limit - 1);
+
+               r = StringUtil::EncodeToBase64String(*pByteBuffer, encodedString);
+               SysTryReturn(NID_SCL, !IsFailed(r), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argutmnet is used.", GetErrorMessage(E_INVALID_ARG));
+
+               extraData.Append(encodedString);
+       }
+
+       if (!extraData.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(extraData));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(profileRecord, _contacts_profile.extra_data, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(profileRecord, _contacts_profile.extra_data, null);
+       }
+
+
+       return E_SUCCESS;
+
+}
+
+
+int
+_ContactImpl::GetMaxLength(ContactPropertyId id)
+{
+       switch (id)
+       {
+       case CONTACT_PROPERTY_ID_FIRST_NAME:
+               //fall through
+       case CONTACT_PROPERTY_ID_LAST_NAME:
+               //fall through
+       case CONTACT_PROPERTY_ID_DISPLAY_NAME:
+               //fall through
+       case CONTACT_PROPERTY_ID_NICK_NAME:
+               //fall through
+       case CONTACT_PROPERTY_ID_MIDDLE_NAME:
+               return MAX_CONTACT_NAME_LENGTH;
+
+       case CONTACT_PROPERTY_ID_THUMBNAIL:
+               return -1;
+
+       case CONTACT_PROPERTY_ID_JOB_TITLE:
+               return MAX_CONTACT_JOB_TITLE_LENGTH;
+
+       case CONTACT_PROPERTY_ID_COMPANY:
+               return MAX_CONTACT_COMPANY_LENGTH;
+
+       case CONTACT_PROPERTY_ID_NOTE:
+               return MAX_CONTACT_NOTE_LENGTH;
+
+       case CONTACT_PROPERTY_ID_RINGTONE:
+               return -1;
+
+       case CONTACT_PROPERTY_ID_PHONETIC_FIRST_NAME:
+               //fall through
+       case CONTACT_PROPERTY_ID_PHONETIC_LAST_NAME:
+               //fall through
+       case CONTACT_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
+               return MAX_CONTACT_NAME_LENGTH;
+
+       default:
+               return -1;
+       }
+}
+
+IList*
+_ContactImpl::GetOrganizationsN(void) const
+{
+       result r = E_SUCCESS;
+       contacts_record_h organizationHandle = null;
+       int ret = CONTACTS_ERROR_NONE;
+       char* pCharValue = null;
+       int intValue = 0;
+       unsigned int count = 0;
+       std::unique_ptr<Organization> pOrganization(null);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
+
+       r = pList->Construct(count);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       for (unsigned int i = 0; i < count; i++)
+       {
+               ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, i, &organizationHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+               pOrganization.reset(new (std::nothrow) Organization());
+               SysTryReturn(NID_SCL, pOrganization != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               // name
+               contacts_record_get_str_p(organizationHandle, _contacts_company.name, &pCharValue);
+               pOrganization->SetName(pCharValue);
+
+               // job title
+               contacts_record_get_str_p(organizationHandle, _contacts_company.job_title, &pCharValue);
+               pOrganization->SetJobTitle(pCharValue);
+
+               // department
+               contacts_record_get_str_p(organizationHandle, _contacts_company.department, &pCharValue);
+               pOrganization->SetDepartment(pCharValue);
+
+               // role
+               contacts_record_get_str_p(organizationHandle, _contacts_company.role, &pCharValue);
+               pOrganization->SetRole(pCharValue);
+
+               // agent
+               contacts_record_get_str_p(organizationHandle, _contacts_company.assistant_name, &pCharValue);
+               pOrganization->SetAgent(pCharValue);
+
+               // type
+               contacts_record_get_int(organizationHandle, _contacts_company.type, &intValue);
+               switch (intValue)
+               {
+                       case CONTACTS_COMPANY_TYPE_WORK:
+                               pOrganization->SetType(ORGANIZATION_TYPE_WORK);
+                               break;
+                       case CONTACTS_COMPANY_TYPE_CUSTOM:
+                               pOrganization->SetType(ORGANIZATION_TYPE_CUSTOM);
+                               break;
+                       case CONTACTS_COMPANY_TYPE_OTHER:
+                               // fall through
+                       default:
+                               pOrganization->SetType(ORGANIZATION_TYPE_OTHER);
+                               break;
+               }
+
+               // label
+               contacts_record_get_str_p(organizationHandle, _contacts_company.label, &pCharValue);
+               pOrganization->SetLabel(pCharValue);
+
+               // description
+               contacts_record_get_str_p(organizationHandle, _contacts_company.description, &pCharValue);
+               pOrganization->SetDescription(pCharValue);
+
+               // location
+               contacts_record_get_str_p(organizationHandle, _contacts_company.location, &pCharValue);
+               pOrganization->SetLocation(pCharValue);
+
+               // phonetic name
+               contacts_record_get_str_p(organizationHandle, _contacts_company.phonetic_name, &pCharValue);
+               pOrganization->SetPhoneticName(pCharValue);
+
+               // logo path
+               contacts_record_get_str_p(organizationHandle, _contacts_company.logo, &pCharValue);
+               _OrganizationImpl::GetInstance(*pOrganization)->SetLogoPath(pCharValue);
+
+               r = pList->Add(*pOrganization);
+               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pOrganization.release();
+       }
+
+       return pList.release();
+}
+
+IList*
+_ContactImpl::GetRelationshipsN(void) const
+{
+       result r = E_SUCCESS;
+       contacts_record_h relationshipHandle = null;
+       int ret = CONTACTS_ERROR_NONE;
+       int intValue = 0;
+       char* pCharValue = null;
+       unsigned int count = 0;
+       std::unique_ptr<Relationship> pRelationship(null);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.relationship, &count);
+
+       r = pList->Construct(count);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       for (unsigned int i = 0; i < count; i++)
+       {
+               ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.relationship, i, &relationshipHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+               pRelationship.reset(new (std::nothrow) Relationship());
+               SysTryReturn(NID_SCL, pRelationship != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               // type
+               contacts_record_get_int(relationshipHandle, _contacts_relationship.type, &intValue);
+               switch (intValue)
+               {
+               case CONTACTS_RELATIONSHIP_TYPE_ASSISTANT:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_ASSISTANT);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_BROTHER:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_BROTHER);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_CHILD:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_CHILD);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_FATHER:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_FATHER);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_FRIEND:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_FRIEND);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_MANAGER:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_MANAGER);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_MOTHER:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_MOTHER);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_PARENT:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_PARENT);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_PARTNER:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_PARTNER);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_REFERRED_BY);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_RELATIVE:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_RELATIVE);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_SISTER:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_SISTER);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_SPOUSE:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_SPOUSE);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_CUSTOM:
+                       // fall through
+               default:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_CUSTOM);
+                       break;
+               }
+
+               // label
+               contacts_record_get_str_p(relationshipHandle, _contacts_relationship.label, &pCharValue);
+               pRelationship->SetLabel(pCharValue);
+
+               // name
+               contacts_record_get_str_p(relationshipHandle, _contacts_relationship.name, &pCharValue);
+               pRelationship->SetRelativeName(pCharValue);
+
+               r = pList->Add(*pRelationship);
+               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pRelationship.release();
+       }
+
+       return pList.release();
+}
+
+IList*
+_ContactImpl::GetEventsN(void) const
+{
+       result r = E_SUCCESS;
+       char* pCharValue = null;
+       int intValue = 0;
+       unsigned int count = 0;
+       contacts_record_h eventHandle = null;
+       std::unique_ptr<ContactEvent> pEvent(null);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
+
+       r = pList->Construct(count);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       for (unsigned int i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
+
+               pEvent.reset(new (std::nothrow) ContactEvent());
+               SysTryReturn(NID_SCL, pEvent != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               // label
+               contacts_record_get_str_p(eventHandle, _contacts_event.label, &pCharValue);
+               pEvent->SetLabel(pCharValue);
+
+               // type
+               contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
+               switch (intValue)
+               {
+               case CONTACTS_EVENT_TYPE_BIRTH:
+                       pEvent->SetType(CONTACT_EVENT_TYPE_BIRTHDAY);
+                       break;
+               case CONTACTS_EVENT_TYPE_ANNIVERSARY:
+                       pEvent->SetType(CONTACT_EVENT_TYPE_ANNIVERSARY);
+                       break;
+               case CONTACTS_URL_TYPE_CUSTOM:
+                       pEvent->SetType(CONTACT_EVENT_TYPE_CUSTOM);
+                       break;
+               default:
+                       pEvent->SetType(CONTACT_EVENT_TYPE_OTHER);
+                       break;
+               }
+
+               DateTime dateTime;
+
+               contacts_record_get_int(eventHandle, _contacts_event.date, &intValue);
+               __CONVERT_DATE_TO_DATETIME(intValue, dateTime);
+               pEvent->SetDate(dateTime);
+
+               pList->Add(*pEvent);
+               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pEvent.release();
+       }
+
+       return pList.release();
+}
+
+IList*
+_ContactImpl::GetNotesN(void) const
+{
+       result r = E_SUCCESS;
+       char* pCharValue = null;
+       unsigned int count = 0;
+       contacts_record_h noteHandle = null;
+       std::unique_ptr<String> pNote(null);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
+
+       r = pList->Construct(count);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       for (unsigned int i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, i, &noteHandle);
+
+               contacts_record_get_str_p(noteHandle, _contacts_note.note, &pCharValue);
+
+               pNote.reset(new (std::nothrow) String(pCharValue));
+               SysTryReturn(NID_SCL, pNote != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pList->Add(*pNote);
+               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pNote.release();
+       }
+
+       return pList.release();
+}
+
+IList*
+_ContactImpl::GetNicknamesN(void) const
+{
+       result r = E_SUCCESS;
+       char* pCharValue = null;
+       unsigned int count = 0;
+       contacts_record_h nicknameHandle = null;
+       std::unique_ptr<String> pNickname(null);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
+
+       r = pList->Construct(count);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       for (unsigned int i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, i, &nicknameHandle);
+
+               contacts_record_get_str_p(nicknameHandle, _contacts_nickname.name, &pCharValue);
+       
+               pNickname.reset(new (std::nothrow) String(pCharValue));
+               SysTryReturn(NID_SCL, pNickname != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pList->Add(*pNickname);
+               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pNickname.release();
+       }
+
+       return pList.release();
+}
+
+IList*
+_ContactImpl::GetContactAppLaunchDataN(void) const
+{
+       std::unique_ptr<ArrayList, AllElementsDeleter> pContactAppLaunchDataList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pContactAppLaunchDataList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unsigned int count = 0;
+       char* pCharValue = null;
+       contacts_record_h profileRecord = null;
+       std::unique_ptr<ContactAppLaunchData> pContactAppLaunchData(null);
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.profile, &count);
+
+       result r = pContactAppLaunchDataList->Construct(count);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       for (unsigned int i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.profile, i, &profileRecord);
+
+               pContactAppLaunchData.reset(new (std::nothrow) ContactAppLaunchData());
+               SysTryReturn(NID_SCL, pContactAppLaunchData != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_get_str_p(profileRecord, _contacts_profile.text, &pCharValue);
+               pContactAppLaunchData->SetDisplayText(pCharValue);
+
+               contacts_record_get_str_p(profileRecord, _contacts_profile.uid, &pCharValue);
+               _ContactAppLaunchDataImpl::GetInstance(*pContactAppLaunchData)->SetUid(pCharValue);
+
+               contacts_record_get_str_p(profileRecord, _contacts_profile.app_id, &pCharValue);
+               pContactAppLaunchData->SetAppId(pCharValue);
+
+               contacts_record_get_str_p(profileRecord, _contacts_profile.service_operation, &pCharValue);
+               pContactAppLaunchData->SetOperationId(pCharValue);
+
+               contacts_record_get_str_p(profileRecord, _contacts_profile.uri, &pCharValue);
+               pContactAppLaunchData->SetUri(pCharValue);
+
+               contacts_record_get_str_p(profileRecord, _contacts_profile.category, &pCharValue);
+               _ContactAppLaunchDataImpl::GetInstance(*pContactAppLaunchData)->SetCategory(pCharValue);
+
+               contacts_record_get_str_p(profileRecord, _contacts_profile.mime, &pCharValue);
+               pContactAppLaunchData->SetMime(pCharValue);
+
+               contacts_record_get_str_p(profileRecord, _contacts_profile.extra_data, &pCharValue);
+               if (pCharValue != null)
+               {
+                       result r = E_SUCCESS;
+                       String delim(L":,");
+                       String extraData(pCharValue);
+                       String decodedString(L"");
+                       std::unique_ptr<ByteBuffer> pByteBuffer(null);
+
+                       std::unique_ptr<HashMap, AllElementsDeleter> pHashMap(new (std::nothrow) HashMap());
+                       SysTryReturn(NID_SCL, pHashMap != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       r = pHashMap->Construct();
+                       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       StringTokenizer tokerizer(extraData, delim);
+                       String token(L"");
+
+                       while (tokerizer.HasMoreTokens())
+                       {
+                               // key
+                               r = tokerizer.GetNextToken(token);
+                               if (r != E_SUCCESS)
+                               {
+                                       break;
+                               }
+
+                               pByteBuffer.reset(StringUtil::DecodeBase64StringN(token));
+                               SysTryReturn(NID_SCL, pByteBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                               std::unique_ptr<String> pKey(new (std::nothrow) String());
+                               SysTryReturn(NID_SCL, pKey != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                               StringUtil::Utf8ToString((const char*)pByteBuffer->GetPointer(), *pKey);
+
+                               // value
+                               r = tokerizer.GetNextToken(token);
+                               if (r != E_SUCCESS)
+                               {
+                                       break;
+                               }
+
+                               pByteBuffer.reset(StringUtil::DecodeBase64StringN(token));
+                               SysTryReturn(NID_SCL, pByteBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                               std::unique_ptr<String> pValue(new (std::nothrow) String());
+                               SysTryReturn(NID_SCL, pValue != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+                               StringUtil::Utf8ToString((const char*)pByteBuffer->GetPointer(), *pValue);
+
+                               r = pHashMap->Add(pKey.get(), pValue.get());
+                               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                               pKey.release();
+                               pValue.release();
+                       }
+
+                       if (pHashMap->GetCount() > 0)
+                       {
+                               pContactAppLaunchData->SetExtraData(pHashMap.get());
+                       }
+               }
+
+               r = pContactAppLaunchDataList->Add(*pContactAppLaunchData);
+               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pContactAppLaunchData.release();
+       }
+
+       return pContactAppLaunchDataList.release();
+
+}
+
+PhoneNumberType
+_ContactImpl::GetNativePhoneNumberType(int coreType) const
+{
+       PhoneNumberType type = PHONENUMBER_TYPE_HOME;
+
+       switch (coreType)
+       {
+               case CONTACTS_NUMBER_TYPE_HOME:
+                       // fall through
+               case CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE:
+                       type = PHONENUMBER_TYPE_HOME;
+                       break;
+               case CONTACTS_NUMBER_TYPE_WORK:
+                       // fall through
+               case CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE:
+                       type = PHONENUMBER_TYPE_WORK;
+                       break;
+               case CONTACTS_NUMBER_TYPE_CELL:
+                       type = PHONENUMBER_TYPE_MOBILE;
+                       break;
+               case CONTACTS_NUMBER_TYPE_FAX:
+                       // fall through
+               case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME:
+                       type = PHONENUMBER_TYPE_HOME_FAX;
+                       break;
+               case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK:
+                       type = PHONENUMBER_TYPE_WORK_FAX;
+                       break;
+               case CONTACTS_NUMBER_TYPE_PAGER:
+                       type = PHONENUMBER_TYPE_PAGER;
+                       break;
+               case CONTACTS_NUMBER_TYPE_CUSTOM:
+                       type = PHONENUMBER_TYPE_CUSTOM;
+                       break;
+               case CONTACTS_NUMBER_TYPE_ASSISTANT:
+                       if (_AppInfo::GetApiVersion() < _API_VERSION_2_1)
+                       {
+                               type = PHONENUMBER_TYPE_OTHER;
+                       }
+                       else
+                       {
+                               type = PHONENUMBER_TYPE_ASSISTANT;
+                       }
+                       break;
+               case CONTACTS_NUMBER_TYPE_OTHER:
+                       type = PHONENUMBER_TYPE_OTHER;
+                       break;
+               default:
+                       if (coreType & CONTACTS_NUMBER_TYPE_FAX)
+                       {
+                               type = PHONENUMBER_TYPE_HOME_FAX;
+                       }
+                       else if (coreType & CONTACTS_NUMBER_TYPE_CELL)
+                       {
+                               type = PHONENUMBER_TYPE_MOBILE;
+                       }
+                       else if (coreType & CONTACTS_NUMBER_TYPE_PAGER)
+                       {
+                               type = PHONENUMBER_TYPE_PAGER;
+                       }
+                       else if (coreType & CONTACTS_NUMBER_TYPE_HOME)
+                       {
+                               type = PHONENUMBER_TYPE_HOME;
+                       }
+                       else if (coreType & CONTACTS_NUMBER_TYPE_WORK)
+                       {
+                               type = PHONENUMBER_TYPE_WORK;
+                       }
+                       else if (coreType & CONTACTS_NUMBER_TYPE_VOICE)
+                       {
+                               type = PHONENUMBER_TYPE_HOME;
+                       }
+                       else
+                       {
+                               type = PHONENUMBER_TYPE_OTHER;
+                       }
+                       break;
+       }
+
+       return type;
+}
+
+IList*
+_ContactImpl::GetPhoneNumbersN(void) const
+{
+       result r = E_SUCCESS;
+       unsigned int count = 0;
+       contacts_record_h numberHandle = null;
+       int intValue = 0;
+       char* pCharValue = null;
+       PhoneNumberType type = PHONENUMBER_TYPE_HOME;
+       std::unique_ptr<PhoneNumber> pPhoneNumber(null);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
+
+       contacts_record_get_int(__contactHandle, _contacts_contact.id, &intValue);
+
+       r = pList->Construct(count);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       for (unsigned int i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.number, i, &numberHandle);
+
+               pPhoneNumber.reset(new (std::nothrow) PhoneNumber());
+               SysTryReturn(NID_SCL, pPhoneNumber != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_get_int(numberHandle, _contacts_number.id, &intValue);
+               _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetRecordId(intValue);
+
+               contacts_record_get_str_p(numberHandle, _contacts_number.label, &pCharValue);
+               _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetLabel(pCharValue);
+
+               contacts_record_get_int(numberHandle, _contacts_number.type, &intValue);
+
+               type = GetNativePhoneNumberType(intValue);
+
+               _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetType(type);
+
+               contacts_record_get_str_p(numberHandle, _contacts_number.number, &pCharValue);
+               _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetPhoneNumber(pCharValue);
+
+               r = pList->Add(*pPhoneNumber);
+               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pPhoneNumber.release();
+       }
+
+       return pList.release();
+}
+
+IList*
+_ContactImpl::GetEmailsN(void) const
+{
+       result r = E_SUCCESS;
+       contacts_record_h currentHandle = null;
+       int ret = CONTACTS_ERROR_NONE;
+       int intValue = 0;
+       unsigned int count = 0;
+       char* pCharValue = null;
+       EmailType type = EMAIL_TYPE_PERSONAL;
+       std::unique_ptr<Email> pEmail(null);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
+
+       r = pList->Construct(count);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       for (unsigned int i = 0; i < count; i++)
+       {
+               ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.email, i, &currentHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM))
+
+               pEmail.reset(new (std::nothrow) Email());
+               SysTryReturn(NID_SCL, pEmail != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_get_int(currentHandle, _contacts_email.id, &intValue);
+               _EmailImpl::GetInstance(*pEmail)->SetRecordId(intValue);
+
+               contacts_record_get_str_p(currentHandle, _contacts_email.label, &pCharValue);
+               _EmailImpl::GetInstance(*pEmail)->SetLabel(pCharValue);
+
+               contacts_record_get_int(currentHandle, _contacts_email.type, &intValue);
+               switch (intValue)
+               {
+               case CONTACTS_EMAIL_TYPE_HOME:
+                       type = EMAIL_TYPE_PERSONAL;
+                       break;
+               case CONTACTS_EMAIL_TYPE_WORK:
+                       type = EMAIL_TYPE_WORK;
+                       break;
+               case CONTACTS_EMAIL_TYPE_CUSTOM:
+                       type = EMAIL_TYPE_CUSTOM;
+                       break;
+               case CONTACTS_EMAIL_TYPE_MOBILE:
+                       if (_AppInfo::GetApiVersion() < _API_VERSION_2_1)
+                       {
+                               type = EMAIL_TYPE_OTHER;
+                       }
+                       else
+                       {
+                               type = EMAIL_TYPE_MOBILE;
+                       }
+                       break;
+               default:
+                       type = EMAIL_TYPE_OTHER;
+                       break;
+               }
+
+               _EmailImpl::GetInstance(*pEmail)->SetType(type);
+
+               contacts_record_get_str_p(currentHandle, _contacts_email.email, &pCharValue);
+               _EmailImpl::GetInstance(*pEmail)->SetEmail(pCharValue);
+
+               r = pList->Add(*pEmail);
+               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pEmail.release();
+       }
+
+       return pList.release();
+}
+
+IList*
+_ContactImpl::GetUrlsN(void) const
+{
+       result r = E_SUCCESS;
+       char* pCharValue = null;
+       int intValue = 0;
+       unsigned int count = 0;
+       UrlType type = URL_TYPE_PERSONAL;
+       contacts_record_h urlHandle = null;
+       std::unique_ptr<Url> pUrl(null);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
+
+       r = pList->Construct(count);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       for (unsigned int i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.url, i, &urlHandle);
+
+               pUrl.reset(new (std::nothrow) Url());
+               SysTryReturn(NID_SCL, pUrl != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_get_str_p(urlHandle, _contacts_url.label, &pCharValue);
+               pUrl->SetLabel(pCharValue);
+
+               contacts_record_get_int(urlHandle, _contacts_url.type, &intValue);
+               switch (intValue)
+               {
+               case CONTACTS_URL_TYPE_HOME:
+                       type = URL_TYPE_PERSONAL;
+                       break;
+               case CONTACTS_URL_TYPE_WORK:
+                       type = URL_TYPE_WORK;
+                       break;
+               case CONTACTS_URL_TYPE_CUSTOM:
+                       type = URL_TYPE_CUSTOM;
+                       break;
+               default:
+                       type = URL_TYPE_OTHER;
+                       break;
+               }
+
+               pUrl->SetType(type);
+
+               contacts_record_get_str_p(urlHandle, _contacts_url.url, &pCharValue);
+               _UrlImpl::GetInstance(*pUrl)->SetUrl(pCharValue);
+
+               pList->Add(*pUrl);
+               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pUrl.release();
+       }
+
+       return pList.release();
+}
+
+IList*
+_ContactImpl::GetAddressesN(void) const
+{
+       result r = E_SUCCESS;
+       char* pCharValue = null;
+       int intValue = 0;
+       unsigned int count = 0;
+       contacts_record_h addressHandle = 0;
+       std::unique_ptr<Address> pAddress(null);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
+
+       r = pList->Construct(count);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+
+       for (unsigned int i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.address, i, &addressHandle);
+
+               pAddress.reset(new (std::nothrow) Address());
+               SysTryReturn(NID_SCL, pAddress != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_get_str_p(addressHandle, _contacts_address.label, &pCharValue);
+               pAddress->SetLabel(pCharValue);
+
+               contacts_record_get_int(addressHandle, _contacts_address.type, &intValue);
+               switch (intValue)
+               {
+               case CONTACTS_ADDRESS_TYPE_HOME:
+                       pAddress->SetType(ADDRESS_TYPE_HOME);
+                       break;
+               case CONTACTS_ADDRESS_TYPE_WORK:
+                       pAddress->SetType(ADDRESS_TYPE_WORK);
+                       break;
+               case CONTACTS_ADDRESS_TYPE_CUSTOM:
+                       pAddress->SetType(ADDRESS_TYPE_CUSTOM);
+                       break;
+               default:
+                       pAddress->SetType(ADDRESS_TYPE_OTHER);
+                       break;
+               }
+
+               // 1. country
+               contacts_record_get_str_p(addressHandle, _contacts_address.country, &pCharValue);
+               _AddressImpl::GetInstance(*pAddress)->SetCountry(pCharValue);
+
+               // 2. region
+               contacts_record_get_str_p(addressHandle, _contacts_address.region, &pCharValue);
+               _AddressImpl::GetInstance(*pAddress)->SetState(pCharValue);
+
+               // 3. city
+               contacts_record_get_str_p(addressHandle, _contacts_address.locality, &pCharValue);
+               _AddressImpl::GetInstance(*pAddress)->SetCity(pCharValue);
+
+               // 4. street
+               contacts_record_get_str_p(addressHandle, _contacts_address.street, &pCharValue);
+               _AddressImpl::GetInstance(*pAddress)->SetStreet(pCharValue);
+
+               // 5. extended
+               contacts_record_get_str_p(addressHandle, _contacts_address.extended, &pCharValue);
+               _AddressImpl::GetInstance(*pAddress)->SetExtended(pCharValue);
+
+               // 6. postbox
+               contacts_record_get_str_p(addressHandle, _contacts_address.postbox, &pCharValue);
+               _AddressImpl::GetInstance(*pAddress)->SetPostOfficeBoxNumber(pCharValue);
+
+               // 7. postal code
+               contacts_record_get_str_p(addressHandle, _contacts_address.postal_code, &pCharValue);
+               _AddressImpl::GetInstance(*pAddress)->SetPostalCode(pCharValue);
+
+               r = pList->Add(*pAddress);
+               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pAddress.release();
+       }
+
+       return pList.release();
+}
+
+IList*
+_ContactImpl::GetImAddressesN(void) const
+{
+       result r = E_SUCCESS;
+       char* pCharValue = null;
+       int intValue = 0;
+       contacts_record_h messengerHandle = null;
+       unsigned int count = 0;
+       std::unique_ptr<ImAddress> pImAddress(null);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
+
+       r = pList->Construct(count);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+
+       for (unsigned int i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.messenger, i, &messengerHandle);
+
+               pImAddress.reset(new (std::nothrow) ImAddress());
+               SysTryReturn(NID_SCL, pImAddress != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_get_int(messengerHandle, _contacts_messenger.type, &intValue);
+               switch (intValue)
+               {
+               case CONTACTS_MESSENGER_TYPE_GOOGLE:
+                       pImAddress->SetServiceProviderName(IM_ADDRESS_GOOGLE_TALK);
+                       break;
+               case CONTACTS_MESSENGER_TYPE_WLM:
+                       pImAddress->SetServiceProviderName(IM_ADDRESS_MSN);
+                       break;
+               case CONTACTS_MESSENGER_TYPE_ICQ:
+                       pImAddress->SetServiceProviderName(IM_ADDRESS_ICQ);
+                       break;
+               case CONTACTS_MESSENGER_TYPE_AIM:
+                       pImAddress->SetServiceProviderName(IM_ADDRESS_AIM);
+                       break;
+               case CONTACTS_MESSENGER_TYPE_YAHOO:
+                       pImAddress->SetServiceProviderName(IM_ADDRESS_YAHOO);
+                       break;
+               case CONTACTS_MESSENGER_TYPE_QQ:
+                       pImAddress->SetServiceProviderName(IM_ADDRESS_QQ);
+                       break;
+               case CONTACTS_MESSENGER_TYPE_SKYPE:
+                       pImAddress->SetServiceProviderName(IM_ADDRESS_SKYPE);
+                       break;
+               case CONTACTS_MESSENGER_TYPE_JABBER:
+                       pImAddress->SetServiceProviderName(IM_ADDRESS_JABBER);
+                       break;
+               case CONTACTS_MESSENGER_TYPE_IRC:
+                       pImAddress->SetServiceProviderName(IM_ADDRESS_IRC);
+                       break;
+               case CONTACTS_MESSENGER_TYPE_FACEBOOK:
+                       pImAddress->SetServiceProviderName(IM_ADDRESS_FACEBOOK);
+                       break;
+               case CONTACTS_MESSENGER_TYPE_CUSTOM:
+                       // fall through
+               default:
+                       contacts_record_get_str_p(messengerHandle, _contacts_messenger.label, &pCharValue);
+                       pImAddress->SetServiceProviderName(pCharValue);
+                       break;
+               }
+
+               contacts_record_get_str_p(messengerHandle, _contacts_messenger.im_id, &pCharValue);
+               _ImAddressImpl::GetInstance(*pImAddress)->SetImAddress(pCharValue);
+
+               r = pList->Add(*pImAddress);
+               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pImAddress.release();
+       }
+
+       return pList.release();
+}
+
+bool
+_ContactImpl::IsEmpty(void) const
+{
+       char* pCharValue = null;
+       unsigned int count = 0;
+
+       contacts_record_get_str_p(__contactHandle, _contacts_contact.ringtone_path, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
+       if (count > 0)
+       {
+               return false;
+       }
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
+       if (count > 0)
+       {
+               return false;
+       }
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
+       if (count > 0)
+       {
+               return false;
+       }
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
+       if (count > 0)
+       {
+               return false;
+       }
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
+       if (count > 0)
+       {
+               return false;
+       }
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
+       if (count > 0)
+       {
+               return false;
+       }
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
+       if (count > 0)
+       {
+               return false;
+       }
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
+       if (count > 0)
+       {
+               return false;
+       }
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
+       if (count > 0)
+       {
+               return false;
+       }
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
+       if (count > 0)
+       {
+               return false;
+       }
+
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
+       if (count > 0)
+       {
+               return false;
+       }
+
+       contacts_record_get_str_p(__contactHandle, _contacts_contact.uid, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+AddressbookId
+_ContactImpl::GetAddressbookId(void) const
+{
+       int addressbookId = 0;
+
+       contacts_record_get_int(__contactHandle, _contacts_contact.address_book_id, &addressbookId);
+
+       return addressbookId;
+}
+
+PersonId
+_ContactImpl::GetPersonId(void) const
+{
+       int personId = 0;
+
+       contacts_record_get_int(__contactHandle, _contacts_contact.person_id, &personId);
+
+       return personId;
+}
+
+void
+_ContactImpl::SetAsRemoved(void)
+{
+       __isRemoved = true;
+}
+
+bool
+_ContactImpl::IsRemoved(void) const
+{
+       return __isRemoved;
+}
+
+bool
+_ContactImpl::IsFavorite(void) const
+{
+       bool isFavorite = false;
+       contacts_record_get_bool(__contactHandle, _contacts_contact.is_favorite, &isFavorite);
+
+       return isFavorite;
+}
+
+void
+_ContactImpl::SetAsFavorite(bool isFavorite)
+{
+       contacts_record_set_bool(__contactHandle, _contacts_contact.is_favorite, isFavorite);
+}
+
+result
+_ContactImpl::Invalidate(void)
+{
+       int ret = CONTACTS_ERROR_NONE;
+       unsigned int i = 0;
+       unsigned int count = 0;
+       char* pCharValue = null;
+       int intValue = 0;
+       bool boolValue = false;
+
+       contacts_record_h contactHandle = null;
+       contacts_record_h sourceRecordHandle = null;
+       contacts_record_h destRecordHandle = null;
+
+       ret = contacts_record_create(_contacts_contact._uri, &contactHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __ContactsRecordHandle recordHandle(contactHandle);
+
+       // favorite
+       contacts_record_get_bool(sourceRecordHandle, _contacts_contact.is_favorite, &boolValue);
+       contacts_record_set_bool(destRecordHandle, _contacts_contact.is_favorite, boolValue);
+
+       // uid
+       contacts_record_get_str_p(sourceRecordHandle, _contacts_contact.uid, &pCharValue);
+       contacts_record_set_str(destRecordHandle, _contacts_contact.uid, pCharValue);
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // name
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
+       if (count > 0)
+       {
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_name._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle nameHandle(destRecordHandle);
+
+               // 1. first
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.first, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.first, pCharValue);
+
+               // 2. last
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.last, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.last, pCharValue);
+
+               // 3. addition
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.addition, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.addition, pCharValue);
+
+               // 4. suffix
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.suffix, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.suffix, pCharValue);
+
+               // 5. prefix
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.prefix, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.prefix, pCharValue);
+
+               // 6. phonetic_first
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_first, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_first, pCharValue);
+
+               // 7. phonetic_last
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_last, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_last, pCharValue);
+
+               // 8. phonetic_middle
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_middle, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_middle, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.name, destRecordHandle);
+
+               nameHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // image
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_image._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle imageHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_image.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_image.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_image.label, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_image.label, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_image.path, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_image.path, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.image, destRecordHandle);
+
+               imageHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // company
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_company._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle companyHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_company.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_company.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.name, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.name, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.department, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.department, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.job_title, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.job_title, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.assistant_name, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.assistant_name, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.role, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.role, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.logo, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.logo, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.location, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.location, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.description, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.description, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_company.phonetic_name, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_company.phonetic_name, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.company, destRecordHandle);
+
+               companyHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // note
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_note._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle noteHandle(destRecordHandle);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_note.note, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_note.note, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.note, destRecordHandle);
+
+               noteHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // phone number
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.number, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_number._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle numberHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_number.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_number.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_number.label, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_number.label, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_number.number, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_number.number, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.number, destRecordHandle);
+
+               numberHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // email
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.email, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_email._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle emailHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_email.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_email.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_email.label, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_email.label, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_email.email, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_email.email, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.email, destRecordHandle);
+
+               emailHandle.Release();
+
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // event
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_event._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle eventHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_event.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_event.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_event.label, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_event.label, pCharValue);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_event.date, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_event.date, intValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.event, destRecordHandle);
+
+               eventHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // im address
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.messenger, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_messenger._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle imAddressHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_messenger.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_messenger.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_messenger.label, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_messenger.label, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_messenger.im_id, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_messenger.im_id, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.messenger, destRecordHandle);
+
+               imAddressHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // address
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.address, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_address._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle addressHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_address.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_address.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.label, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.label, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.postbox, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.postbox, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.extended, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.extended, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.street, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.street, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.locality, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.locality, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.region, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.region, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.postal_code, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.postal_code, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_address.country, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_address.country, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.address, destRecordHandle);
+
+               addressHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // url
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.url, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_url._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle urlHandle(destRecordHandle);
+
+               contacts_record_get_int(sourceRecordHandle, _contacts_url.type, &intValue);
+               contacts_record_set_int(destRecordHandle, _contacts_url.type, intValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_url.label, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_url.label, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_url.url, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_url.url, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.url, destRecordHandle);
+
+               urlHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // nickname
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_nickname._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle nicknameHandle(destRecordHandle);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_nickname.name, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_nickname.name, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.nickname, destRecordHandle);
+
+               nicknameHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // relationship
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.relationship, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.relationship, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_relationship._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle relationshipHandle(destRecordHandle);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_relationship.name, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_relationship.name, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.relationship, destRecordHandle);
+
+               relationshipHandle.Release();
+       }
+
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       // app launch data
+       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       contacts_record_get_child_record_count(__contactHandle, _contacts_contact.profile, &count);
+       for (i = 0; i < count; i++)
+       {
+               contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.profile, i, &sourceRecordHandle);
+
+               ret = contacts_record_create(_contacts_profile._uri, &destRecordHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __ContactsRecordHandle profileHandle(destRecordHandle);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.text, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.text, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.uid, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.uid, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.app_id, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.app_id, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.service_operation, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.service_operation, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.uri, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.uri, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.category, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.category, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.mime, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.mime, pCharValue);
+
+               contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.extra_data, &pCharValue);
+               contacts_record_set_str(destRecordHandle, _contacts_profile.extra_data, pCharValue);
+
+               contacts_record_add_child_record(contactHandle, _contacts_contact.profile, destRecordHandle);
+
+               profileHandle.Release();
+       }
+
+       contacts_record_destroy(__contactHandle, true);
+       __contactHandle = contactHandle;
+
+       __isRemoved = false;
+
+       recordHandle.Release();
+
+       return E_SUCCESS;
+}
+
+const _ContactImpl*
+_ContactImpl::GetInstance(const Contact& contact)
+{
+       return contact.__pContactImpl;
+}
+
+_ContactImpl*
+_ContactImpl::GetInstance(Contact& contact)
+{
+       return contact.__pContactImpl;
+}
+
+}} // Tizen::Social
diff --git a/src/FScl_EmailContactImpl.cpp b/src/FScl_EmailContactImpl.cpp
new file mode 100644 (file)
index 0000000..4c07e5e
--- /dev/null
@@ -0,0 +1,251 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_EmailContactImpl.cpp
+ * @brief              This is the implementation for _EmailContactImpl class.
+ *
+ * This file contains definitions of @e _EmailContactImpl class.
+ */
+
+#include <new>
+#include <unique_ptr.h>
+#include <FBaseResult.h>
+#include <FBaseString.h>
+#include <FSclEmailContact.h>
+#include <FBaseSysLog.h>
+#include "FScl_RecordImpl.h"
+#include "FScl_EmailContactImpl.h"
+#include "FScl_EmailImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Social
+{
+
+_EmailContactImpl::_EmailContactImpl(void)
+: __addressbookId(INVALID_ADDRESSBOOK_ID)
+, __contactId(INVALID_RECORD_ID)
+{
+       //empty body
+}
+
+_EmailContactImpl::_EmailContactImpl(const _EmailContactImpl& rhs)
+{
+       __addressbookId = rhs.__addressbookId;
+       __contactId = rhs.__contactId;
+       __personId = rhs.__personId;
+       __displayName = rhs.__displayName;
+       __thumbnail = rhs.__thumbnail;
+       __ringtone = rhs.__ringtone;
+       __email = rhs.__email;
+}
+
+_EmailContactImpl::~_EmailContactImpl(void)
+{
+       //empty body
+}
+
+_EmailContactImpl&
+_EmailContactImpl::operator =(const _EmailContactImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+       __addressbookId = rhs.__addressbookId;
+       __contactId = rhs.__contactId;
+       __personId = rhs.__personId;
+       __displayName = rhs.__displayName;
+       __thumbnail = rhs.__thumbnail;
+       __ringtone = rhs.__ringtone;
+       __email = rhs.__email;
+
+       return *this;
+}
+
+bool
+_EmailContactImpl::operator ==(const _EmailContactImpl& rhs) const
+{
+       if (__addressbookId != rhs.__addressbookId)
+       {
+               return false;
+       }
+
+       if (__contactId != rhs.__contactId)
+       {
+               return false;
+       }
+
+       if (__personId != rhs.__personId)
+       {
+               return false;
+       }
+
+       if (__displayName != rhs.__displayName)
+       {
+               return false;
+       }
+
+       if (__thumbnail != rhs.__thumbnail)
+       {
+               return false;
+       }
+
+       if (__ringtone != rhs.__ringtone)
+       {
+               return false;
+       }
+
+       if (__email != rhs.__email)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+bool
+_EmailContactImpl::Equals(const Object& rhs) const
+{
+       const _EmailContactImpl* pEmailContactImpl = dynamic_cast<const _EmailContactImpl*>(&rhs);
+       if (pEmailContactImpl == null)
+       {
+               return false;
+       }
+
+       return *this == *pEmailContactImpl;
+}
+
+int
+_EmailContactImpl::GetHashCode(void) const
+{
+       int hashCode = 0;
+
+       hashCode = 0xffffffff & __contactId;
+       hashCode += __addressbookId;
+       hashCode += __personId;
+       hashCode += __displayName.GetHashCode();
+       hashCode += __thumbnail.GetHashCode();
+       hashCode += __ringtone.GetHashCode();
+       hashCode += __email.GetHashCode();
+
+       return hashCode;
+}
+
+PersonId
+_EmailContactImpl::GetPersonId(void) const
+{
+       return __personId;
+}
+
+void
+_EmailContactImpl::SetPersonId(PersonId personId)
+{
+       __personId = personId;
+}
+
+
+void
+_EmailContactImpl::SetAddressbookId(AddressbookId addressbookId)
+{
+       __addressbookId = addressbookId;
+}
+
+AddressbookId
+_EmailContactImpl::GetAddressbookId(void) const
+{
+       return __addressbookId;
+}
+
+
+RecordId
+_EmailContactImpl::GetContactId(void) const
+{
+       return __contactId;
+}
+
+String
+_EmailContactImpl::GetDisplayName(void) const
+{
+       return __displayName;
+}
+
+String
+_EmailContactImpl::GetThumbnailPath(void) const
+{
+       return __thumbnail;
+}
+
+String
+_EmailContactImpl::GetRingtonePath(void) const
+{
+       return __ringtone;
+}
+
+Email
+_EmailContactImpl::GetEmail(void) const
+{
+       return __email;
+}
+
+void
+_EmailContactImpl::SetContactId(RecordId contactId)
+{
+       __contactId = contactId;
+}
+
+void
+_EmailContactImpl::SetDisplayName(const String& displayName)
+{
+       __displayName = displayName;
+}
+
+void
+_EmailContactImpl::SetThumbnailPath(const String& thumbnail)
+{
+       __thumbnail = thumbnail;
+}
+
+void
+_EmailContactImpl::SetRingtonePath(const String& ringtone)
+{
+       __ringtone = ringtone;
+}
+
+void
+_EmailContactImpl::SetEmailData(int recordId, EmailType type, const Tizen::Base::String& label, const Tizen::Base::String& email)
+{
+       _EmailImpl::GetInstance(__email)->SetRecordId(recordId);
+       _EmailImpl::GetInstance(__email)->SetType(type);
+       _EmailImpl::GetInstance(__email)->SetLabel(label);
+       _EmailImpl::GetInstance(__email)->SetEmail(email);
+}
+
+_EmailContactImpl*
+_EmailContactImpl::GetInstance(EmailContact& simpleContact)
+{
+       return simpleContact.__pEmailContactImpl;
+}
+
+const _EmailContactImpl*
+_EmailContactImpl::GetInstance(const EmailContact& simpleContact)
+{
+       return simpleContact.__pEmailContactImpl;
+}
+
+
+}}  // Tizen::Social
diff --git a/src/FScl_EmailContactImpl.h b/src/FScl_EmailContactImpl.h
new file mode 100644 (file)
index 0000000..7ccb6ef
--- /dev/null
@@ -0,0 +1,119 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_EmailContactImpl.h
+ * @brief              This is the header file for the %_EmailContactImpl class.
+ *
+ * This header file contains the declarations of the %_EmailContactImpl class.
+ */
+#ifndef _FSCL_INTERNAL_EMAIL_CONTACT_IMPL_H_
+#define _FSCL_INTERNAL_EMAIL_CONTACT_IMPL_H_
+
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FSclTypes.h>
+#include <FSclEmail.h>
+
+namespace Tizen { namespace Social
+{
+
+class EmailContact;
+
+/**
+ * @class      _EmailContactImpl
+ * @brief      This class provides summarized contact information.
+ *
+ * @since      2.0
+ *
+ */
+class _EmailContactImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is default constructor for the class.
+        *
+        * @since       2.0
+        */
+       _EmailContactImpl(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        */
+       _EmailContactImpl(const _EmailContactImpl& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~_EmailContactImpl(void);
+
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       virtual int GetHashCode(void) const;
+
+       RecordId GetContactId(void) const;
+
+       PersonId GetPersonId(void) const;
+
+       Tizen::Base::String GetDisplayName(void) const;
+
+       Tizen::Base::String GetThumbnailPath(void) const;
+
+       Tizen::Base::String GetRingtonePath(void) const;
+
+       Email GetEmail(void) const;
+
+       void SetPersonId(PersonId personId);
+
+       void SetAddressbookId(AddressbookId addressbookId);
+
+       AddressbookId GetAddressbookId(void) const;
+
+       void SetContactId(RecordId contactId);
+
+       void SetDisplayName(const Tizen::Base::String& displayName);
+
+       void SetThumbnailPath(const Tizen::Base::String& thumbnail);
+
+       void SetRingtonePath(const Tizen::Base::String& ringtone);
+
+       void SetEmailData(int recordId, EmailType type, const Tizen::Base::String& label, const Tizen::Base::String& email);
+
+       static _EmailContactImpl* GetInstance(EmailContact& simpleContact);
+
+       static const _EmailContactImpl* GetInstance(const EmailContact& simpleContact);
+
+       _EmailContactImpl& operator =(const _EmailContactImpl& rhs);
+
+       bool operator ==(const _EmailContactImpl& rhs) const;
+
+private:
+       AddressbookId __addressbookId;
+       RecordId        __contactId;
+       PersonId        __personId;
+       Tizen::Base::String __displayName;
+       Tizen::Base::String __thumbnail;
+       Tizen::Base::String __ringtone;
+       Email __email;
+};     // _EmailContactImpl
+
+}}     // Tizen::Social
+
+#endif // _FSCL_INTERNAL_EMAIL_CONTACT_IMPL_H_
diff --git a/src/FScl_EmailImpl.cpp b/src/FScl_EmailImpl.cpp
new file mode 100644 (file)
index 0000000..24cca67
--- /dev/null
@@ -0,0 +1,205 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FScl_EmailImpl.cpp
+* @brief       This is the implementation for _EmailImpl class.
+*
+* This file contains definitions of @e _EmailImpl class.
+*/
+
+#include <unique_ptr.h>
+#include <FApp_AppInfo.h>
+#include <FBaseSysLog.h>
+#include <FSclEmail.h>
+#include <FBase_StringConverter.h>
+#include "FScl_EmailImpl.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+_EmailImpl::_EmailImpl(void)
+: __recordId(-1)
+, __type(EMAIL_TYPE_PERSONAL)
+{
+
+}
+
+_EmailImpl::_EmailImpl(EmailType type, const String& email)
+: __recordId(-1)
+, __type(type)
+{
+       String stringValue = email;
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if (stringValue.GetLength() > MAX_EMAIL_LENGTH)
+               {
+                       stringValue.SetLength(MAX_EMAIL_LENGTH);
+               }
+       }
+
+       __email = stringValue;
+
+}
+
+_EmailImpl::_EmailImpl(const _EmailImpl& rhs)
+{
+       __recordId = rhs.__recordId;
+       __type = rhs.__type;
+       __label = rhs.__label;
+       __email = rhs.__email;
+}
+
+_EmailImpl::~_EmailImpl(void)
+{
+
+}
+
+
+_EmailImpl&
+_EmailImpl::operator =(const _EmailImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __recordId = rhs.__recordId;
+       __type = rhs.__type;
+       __label = rhs.__label;
+       __email = rhs.__email;
+
+       return *this;
+}
+
+bool
+_EmailImpl::operator ==(const _EmailImpl& rhs) const
+{
+       if(__type != rhs.__type || __label != rhs.__label || __email != rhs.__email)
+       {
+               return false;
+       }       
+
+       return true;
+}
+
+bool
+_EmailImpl::operator !=(const _EmailImpl& rhs) const
+{
+       return !(*this == rhs);
+}
+
+bool
+_EmailImpl::Equals(const Object& rhs) const
+{
+       const _EmailImpl* pEmailImpl = dynamic_cast<const _EmailImpl*>(&rhs);
+
+       if (pEmailImpl == null)
+       {
+               return false;
+       }
+
+       return (*this == *pEmailImpl);
+}
+
+int
+_EmailImpl::GetHashCode(void) const
+{
+       int hashCode = __recordId;
+       hashCode += __type;
+       hashCode += __label.GetHashCode();
+       hashCode += __email.GetHashCode();
+
+       return hashCode;
+}
+
+EmailType
+_EmailImpl::GetType(void) const
+{
+
+
+       return __type;
+}
+
+String
+_EmailImpl::GetEmail(void) const
+{
+       return __email;
+}
+
+String
+_EmailImpl::GetLabel(void) const
+{
+       return __label;
+}
+
+void
+_EmailImpl::SetType(EmailType type)
+{
+       __type = type;
+}
+
+result
+_EmailImpl::SetEmail(const String& email)
+{
+       SysTryReturnResult(NID_SCL, !email.IsEmpty(), E_INVALID_ARG, "The email is an empty string.");
+
+
+       __email = email;
+
+       return E_SUCCESS;
+}
+
+void
+_EmailImpl::SetLabel(const String& label)
+{
+       __label = label;
+}
+
+void
+_EmailImpl::SetRecordId(int recordId)
+{
+       __recordId = recordId;
+}
+
+int
+_EmailImpl::GetRecordId(void) const
+{
+       return __recordId;
+}
+
+bool
+_EmailImpl::IsEmpty(void) const
+{
+       return __email.IsEmpty();
+}
+
+const _EmailImpl*
+_EmailImpl::GetInstance(const Email& email)
+{
+       return email.__pEmailImpl;
+}
+
+_EmailImpl*
+_EmailImpl::GetInstance(Email& email)
+{
+       return email.__pEmailImpl;
+}
+
+
+}} // Tizen::Social
diff --git a/src/FScl_IAccountDbChangeEventListener.h b/src/FScl_IAccountDbChangeEventListener.h
new file mode 100644 (file)
index 0000000..29b928c
--- /dev/null
@@ -0,0 +1,54 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_IAccountDbChangeEventListener.h
+ * @brief      This is the header file for the _IAccountDbChangeEventListener class.
+ *
+ * This file contains the declarations of _IAccountDbChangeEventListener.
+ */
+
+#ifndef _FSCL_INTERNAL_IACCOUNT_DB_CHANGE_EVENT_LISTENER_H_
+#define _FSCL_INTERNAL_IACCOUNT_DB_CHANGE_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+
+class _IAccountDbChangeEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+       /**
+        * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes @n
+        * are called when the destructor of this interface is called.
+        *
+        * @since       2.1
+        */
+       virtual ~_IAccountDbChangeEventListener(void) {}
+
+       virtual void OnAccountAdded(AccountId accountId) = 0;
+
+       virtual void OnAccountUpdated(AccountId accountId) = 0;
+
+       virtual void OnAccountRemoved(AccountId accountId) = 0;
+
+}; // _IAccountDbChangeEventListener
+
+}} // Tizen::Social
+
+#endif // _FSCL_INTERNAL_IACCOUNT_DB_CHANGE_EVENT_LISTENER_H_
diff --git a/src/FScl_ICalendarbookDbChangeEventListener.h b/src/FScl_ICalendarbookDbChangeEventListener.h
new file mode 100644 (file)
index 0000000..53584e7
--- /dev/null
@@ -0,0 +1,51 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_ICalendarbookDbChangeEventListener.h
+ * @brief      This is the header file for the _ICalendarbookDbChangeEventListener class.
+ *
+ * This file contains the declarations of _ICalendarbookDbChangeEventListener.
+ */
+
+#ifndef _FSCL_INTERNAL_ICALENDARBOOK_DB_CHANGE_EVENT_LISTENER_H_
+#define _FSCL_INTERNAL_ICALENDARBOOK_DB_CHANGE_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+
+namespace Tizen { namespace Social
+{
+
+class _ICalendarbookDbChangeEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+
+       /**
+        * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes @n
+        * are called when the destructor of this interface is called.
+        *
+        * @since       2.0
+        */
+       virtual ~_ICalendarbookDbChangeEventListener(void){}
+
+       virtual void OnCalEventChanged(void) = 0;
+
+       virtual void OnCalTodoChanged(void) = 0;
+}; // _ICalendarbookDbChangeEventListener
+
+}} // Tizen::Social
+
+#endif // _FSCL_INTERNAL_ICALENDARBOOK_DB_CHANGE_EVENT_LISTENER_H_
diff --git a/src/FScl_ImAddressImpl.cpp b/src/FScl_ImAddressImpl.cpp
new file mode 100644 (file)
index 0000000..23ba872
--- /dev/null
@@ -0,0 +1,163 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FScl_ImAddressImpl.cpp
+* @brief       This is the implementation for _ImAddressImpl class.
+*
+* This file contains definitions of @e _ImAddressImpl class.
+*/
+
+#include <FSclImAddress.h>
+#include <FApp_AppInfo.h>
+#include <FBaseSysLog.h>
+#include "FScl_ImAddressImpl.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+extern const wchar_t IM_ADDRESS_AIM[] = L"AIM";
+extern const wchar_t IM_ADDRESS_GOOGLE_TALK[] = L"Google Talk";
+extern const wchar_t IM_ADDRESS_ICQ[] = L"ICQ";
+extern const wchar_t IM_ADDRESS_JABBER[] = L"Jabber";
+extern const wchar_t IM_ADDRESS_MSN[] = L"MSN";
+extern const wchar_t IM_ADDRESS_QQ[] = L"QQ";
+extern const wchar_t IM_ADDRESS_SKYPE[] = L"Skype";
+extern const wchar_t IM_ADDRESS_YAHOO[] = L"Yahoo";
+extern const wchar_t IM_ADDRESS_IRC[] = L"IRC";
+extern const wchar_t IM_ADDRESS_FACEBOOK[] = L"Facebook";
+
+_ImAddressImpl::_ImAddressImpl(void)
+{
+       //empty body
+}
+
+_ImAddressImpl::_ImAddressImpl(const String& serviceProviderName, const String& imAddress)
+       : __serviceProviderName(serviceProviderName)
+       , __imAddress(imAddress)
+{
+       //empty body
+}
+
+_ImAddressImpl::_ImAddressImpl(const _ImAddressImpl& rhs)
+{
+       __serviceProviderName = rhs.__serviceProviderName;
+       __imAddress = rhs.__imAddress;
+}
+
+_ImAddressImpl::~_ImAddressImpl(void)
+{
+       // empty body.
+}
+
+_ImAddressImpl&
+_ImAddressImpl::operator =(const _ImAddressImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __serviceProviderName = rhs.__serviceProviderName;
+       __imAddress = rhs.__imAddress;
+
+       return *this;
+}
+
+bool
+_ImAddressImpl::operator ==(const _ImAddressImpl& rhs) const
+{
+       if (__serviceProviderName == rhs.__serviceProviderName && __imAddress == rhs.__imAddress)
+       {
+               return true;
+       }
+
+       return false;
+}
+
+bool
+_ImAddressImpl::operator !=(const _ImAddressImpl& rhs) const
+{
+       return !(*this  == rhs);
+}
+
+bool
+_ImAddressImpl::Equals(const Object& rhs) const
+{
+       const _ImAddressImpl* pImAddress = dynamic_cast<const _ImAddressImpl*>(&rhs);
+       if (pImAddress == null)
+       {
+               return false;
+       }
+
+       return (*this == *pImAddress);
+}
+
+int
+_ImAddressImpl::GetHashCode(void) const
+{
+       int hashCode = 0;
+
+       hashCode = __serviceProviderName.GetHashCode();
+       hashCode += __imAddress.GetHashCode();
+
+       return hashCode;
+}
+
+String
+_ImAddressImpl::GetServiceProviderName(void) const
+{
+       return __serviceProviderName;
+}
+
+String
+_ImAddressImpl::GetImAddress(void) const
+{
+       return __imAddress;
+}
+
+void
+_ImAddressImpl::SetServiceProviderName(const String& serviceProviderName)
+{
+       __serviceProviderName = serviceProviderName;
+}
+
+result
+_ImAddressImpl::SetImAddress(const String& imAddress)
+{
+       SysTryReturn(NID_SCL, !imAddress.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The imAddress is an empty string.", GetErrorMessage(E_INVALID_ARG));
+
+       __imAddress = imAddress;
+
+       return E_SUCCESS;
+}
+
+const _ImAddressImpl*
+_ImAddressImpl::GetInstance(const ImAddress& imAddress)
+{
+       return imAddress.__pImAddressImpl;
+}
+
+_ImAddressImpl*
+_ImAddressImpl::GetInstance(ImAddress& imAddress)
+{
+       return imAddress.__pImAddressImpl;
+}
+
+
+}} // Tizen::Social
diff --git a/src/FScl_ImAddressImpl.h b/src/FScl_ImAddressImpl.h
new file mode 100644 (file)
index 0000000..d5e5b9a
--- /dev/null
@@ -0,0 +1,78 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FScl_ImAddressImpl.h
+* @brief       This is the header file for the %_ImAddressImpl class.
+*
+* This header file contains the declarations of the %_ImAddressImpl class.
+*/
+#ifndef _FSCL_INTERNAL_IM_ADDRESS_IMPL_H_
+#define _FSCL_INTERNAL_IM_ADDRESS_IMPL_H_
+
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+
+namespace Tizen { namespace Social
+{
+
+extern const wchar_t IM_ADDRESS_IRC[];
+extern const wchar_t IM_ADDRESS_FACEBOOK[];
+
+class ImAddress;
+
+class _OSP_EXPORT_ _ImAddressImpl
+       : public Tizen::Base::Object
+{
+public:
+       _ImAddressImpl(void);
+
+       _ImAddressImpl(const Tizen::Base::String& serviceProviderName, const Tizen::Base::String& imAddress);
+
+       _ImAddressImpl(const _ImAddressImpl& rhs);
+
+       virtual ~_ImAddressImpl(void);
+
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       virtual int GetHashCode(void) const;
+
+       Tizen::Base::String GetServiceProviderName(void) const;
+
+       Tizen::Base::String GetImAddress(void) const;
+
+       void SetServiceProviderName(const Tizen::Base::String& serviceProviderName);
+
+       result SetImAddress(const Tizen::Base::String& imAddress);
+
+       _ImAddressImpl& operator =(const _ImAddressImpl& rhs);
+
+       bool operator ==(const _ImAddressImpl& rhs) const;
+
+       bool operator !=(const _ImAddressImpl& rhs) const;
+
+       static const _ImAddressImpl* GetInstance(const ImAddress& imAddress);
+
+       static _ImAddressImpl* GetInstance(ImAddress& imAddress);
+
+private:
+       Tizen::Base::String __serviceProviderName;
+       Tizen::Base::String __imAddress;
+}; // _ImAddressImpl
+
+}} // Tizen::Social
+
+#endif // _FSCL_INTERNAL_IM_ADDRESS_IMPL_H_
diff --git a/src/FScl_OrganizationImpl.cpp b/src/FScl_OrganizationImpl.cpp
new file mode 100644 (file)
index 0000000..d85dca3
--- /dev/null
@@ -0,0 +1,403 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FScl_OrganizationImpl.cpp
+* @brief       This is the implementation for _OrganizationImpl class.
+*
+* This file contains definitions of @e _OrganizationImpl class.
+*/
+
+#include <FBaseSysLog.h>
+#include <FSclOrganization.h>
+#include <FIoFile.h>
+#include "FScl_OrganizationImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Social
+{
+
+_OrganizationImpl::_OrganizationImpl(void)
+: __type(ORGANIZATION_TYPE_WORK)
+, __isLogoPathChanged(false)
+{
+
+}
+
+_OrganizationImpl::_OrganizationImpl(const _OrganizationImpl& rhs)
+{
+       __name = rhs.__name;
+       __jobTitle = rhs.__jobTitle;
+       __department = rhs.__department;
+       __role = rhs.__role;
+       __agent = rhs.__agent;
+       __label = rhs.__label;
+       __location = rhs.__location;
+       __description = rhs.__description;
+       __phoneticName = rhs.__phoneticName;
+       __logoPath = rhs.__logoPath;
+       __type = rhs.__type;
+       __isLogoPathChanged = rhs.__isLogoPathChanged;
+}
+
+_OrganizationImpl::~_OrganizationImpl(void)
+{
+
+}
+
+_OrganizationImpl&
+_OrganizationImpl::operator =(const _OrganizationImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __name = rhs.__name;
+       __jobTitle = rhs.__jobTitle;
+       __department = rhs.__department;
+       __role = rhs.__role;
+       __agent = rhs.__agent;
+       __label = rhs.__label;
+       __location = rhs.__location;
+       __description = rhs.__description;
+       __phoneticName = rhs.__phoneticName;
+       __logoPath = rhs.__logoPath;
+       __type = rhs.__type;
+       __isLogoPathChanged = rhs.__isLogoPathChanged;
+
+       return *this;
+}
+
+bool
+_OrganizationImpl::operator ==(const _OrganizationImpl& rhs) const
+{
+       if (__name != rhs.__name)
+       {
+               return false;
+       }
+
+       if (__jobTitle != rhs.__jobTitle)
+       {
+               return false;
+       }
+
+       if (__department != rhs.__department)
+       {
+               return false;
+       }
+
+       if (__role != rhs.__role)
+       {
+               return false;
+       }
+
+       if (__agent != rhs.__agent)
+       {
+               return false;
+       }
+
+       if (__label != rhs.__label)
+       {
+               return false;
+       }
+
+       if (__location != rhs.__location)
+       {
+               return false;
+       }
+
+       if (__description != rhs.__description)
+       {
+               return false;
+       }
+
+       if (__phoneticName != rhs.__phoneticName)
+       {
+               return false;
+       }
+
+       if (__logoPath != rhs.__logoPath)
+       {
+               return false;
+       }
+
+       if (__type != rhs.__type)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+bool
+_OrganizationImpl::operator !=(const _OrganizationImpl& rhs) const
+{
+       return !(*this == rhs);
+}
+
+bool
+_OrganizationImpl::Equals(const Object& rhs) const
+{
+       const _OrganizationImpl* pOrganization = dynamic_cast<const _OrganizationImpl*>(&rhs);
+       if (pOrganization == null)
+       {
+               return false;
+       }
+
+       return *this == *pOrganization;
+}
+
+int
+_OrganizationImpl::GetHashCode(void) const
+{
+       int hash = __name.GetHashCode();
+       hash += __jobTitle.GetHashCode();
+       hash += __department.GetHashCode();
+       hash += __role.GetHashCode();
+       hash += __agent.GetHashCode();
+       hash += __label.GetHashCode();
+       hash += __location.GetHashCode();
+       hash += __description.GetHashCode();
+       hash += __phoneticName.GetHashCode();
+       hash += __logoPath.GetHashCode();
+       hash += __type;
+
+       return hash;
+}
+
+String
+_OrganizationImpl::GetName(void) const
+{
+       return __name;
+}
+
+String
+_OrganizationImpl::GetJobTitle(void) const
+{
+       return __jobTitle;
+}
+
+String
+_OrganizationImpl::GetDepartment(void) const
+{
+       return __department;
+}
+
+String
+_OrganizationImpl::GetRole(void) const
+{
+       return __role;
+}
+
+String
+_OrganizationImpl::GetAgent(void) const
+{
+       return __agent;
+}
+
+OrganizationType
+_OrganizationImpl::GetType(void) const
+{
+       return __type;
+}
+
+String
+_OrganizationImpl::GetLabel(void) const
+{
+       return __label;
+}
+
+String
+_OrganizationImpl::GetLocation(void) const
+{
+       return __location;
+}
+
+String
+_OrganizationImpl::GetDescription(void) const
+{
+       return __description;
+}
+
+String
+_OrganizationImpl::GetPhoneticName(void) const
+{
+       return __phoneticName;
+}
+
+String
+_OrganizationImpl::GetLogoPath(void) const
+{
+       return __logoPath;
+}
+
+void
+_OrganizationImpl::SetName(const String& name)
+{
+       __name = name;
+}
+
+void
+_OrganizationImpl::SetJobTitle(const String& jobTitle)
+{
+       __jobTitle = jobTitle;
+}
+
+void
+_OrganizationImpl::SetDepartment(const String& department)
+{
+       __department = department;
+}
+
+void
+_OrganizationImpl::SetRole(const String& role)
+{
+       __role = role;
+}
+
+void
+_OrganizationImpl::SetAgent(const String& agent)
+{
+       __agent = agent;
+}
+
+void
+_OrganizationImpl::SetType(OrganizationType type)
+{
+       __type = type;
+}
+
+void
+_OrganizationImpl::SetLabel(const String& label)
+{
+       __label = label;
+}
+
+void
+_OrganizationImpl::SetLocation(const String& location)
+{
+       __location = location;
+}
+
+void
+_OrganizationImpl::SetDescription(const String& description)
+{
+       __description = description;
+}
+
+void
+_OrganizationImpl::SetPhoneticName(const Tizen::Base::String& phoneticName)
+{
+       __phoneticName = phoneticName;
+}
+
+result
+_OrganizationImpl::SetLogo(const Tizen::Base::String& filePath)
+{
+       if (!filePath.IsEmpty())
+       {
+               bool fileExist = File::IsFileExist(filePath);
+               SysTryReturn(NID_SCL, GetLastResult() != E_ILLEGAL_ACCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+               SysTryReturn(NID_SCL, GetLastResult() != E_INVALID_ARG, E_INVALID_ARG, E_INVALID_ARG, "[%s] The length of the specified filePath exceeds system limitations..", GetErrorMessage(E_INVALID_ARG));
+               SysTryReturn(NID_SCL, fileExist, E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[%s] The specified file is not found.", GetErrorMessage(E_FILE_NOT_FOUND));
+       }
+
+       __logoPath = filePath;
+       __isLogoPathChanged = true;
+
+       return E_SUCCESS;
+}
+
+bool
+_OrganizationImpl::IsEmpty(void) const
+{
+       if (!__name.IsEmpty())
+       {
+               return false;
+       }
+
+       if (!__jobTitle.IsEmpty())
+       {
+               return false;
+       }
+
+       if (!__role.IsEmpty())
+       {
+               return false;
+       }
+
+       if (!__agent.IsEmpty())
+       {
+               return false;
+       }
+
+       if (!__department.IsEmpty())
+       {
+               return false;
+       }
+
+       if (!__location.IsEmpty())
+       {
+               return false;
+       }
+
+       if (!__description.IsEmpty())
+       {
+               return false;
+       }
+
+       if (!__phoneticName.IsEmpty())
+       {
+               return false;
+       }
+
+       if (!__logoPath.IsEmpty())
+       {
+               return false;
+       }
+
+       return true;
+}
+
+bool
+_OrganizationImpl::IsLogoPathChanged(void) const
+{
+       return __isLogoPathChanged;
+}
+
+result
+_OrganizationImpl::SetLogoPath(const Tizen::Base::String& filePath)
+{
+       __logoPath = filePath;
+
+       return E_SUCCESS;
+}
+
+const _OrganizationImpl*
+_OrganizationImpl::GetInstance(const Organization& organization)
+{
+       return organization.__pOrganizationImpl;
+}
+
+_OrganizationImpl*
+_OrganizationImpl::GetInstance(Organization& organization)
+{
+       return organization.__pOrganizationImpl;
+}
+
+}} // Tizen::Social
diff --git a/src/FScl_OrganizationImpl.h b/src/FScl_OrganizationImpl.h
new file mode 100644 (file)
index 0000000..9ec20a6
--- /dev/null
@@ -0,0 +1,126 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_OrganizationImpl.h
+ * @brief      This is the header file for the %_OrganizationImpl class.
+ *
+ * This header file contains the declarations of the %_OrganizationImpl class.
+ */
+#ifndef _FSCL_INTERNAL_ORGANIZATION_IMPL_H_
+#define _FSCL_INTERNAL_ORGANIZATION_IMPL_H_
+
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+
+class Organization;
+
+class _OSP_EXPORT_ _OrganizationImpl
+       : public Tizen::Base::Object
+{
+public:
+       _OrganizationImpl(void);
+
+       _OrganizationImpl(const _OrganizationImpl& rhs);
+
+       virtual ~_OrganizationImpl(void);
+
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       virtual int GetHashCode(void) const;
+
+       Tizen::Base::String GetName(void) const;
+
+       Tizen::Base::String GetJobTitle(void) const;
+
+       Tizen::Base::String GetDepartment(void) const;
+
+       Tizen::Base::String GetRole(void) const;
+
+       Tizen::Base::String GetAgent(void) const;
+
+       OrganizationType GetType(void) const;
+
+       Tizen::Base::String GetLabel(void) const;
+
+       Tizen::Base::String GetLocation(void) const;
+
+       Tizen::Base::String GetDescription(void) const;
+
+       Tizen::Base::String GetPhoneticName(void) const;
+
+       Tizen::Base::String GetLogoPath(void) const;
+
+       void SetName(const Tizen::Base::String& name);
+
+       void SetJobTitle(const Tizen::Base::String& jobTitle);
+
+       void SetDepartment(const Tizen::Base::String& department);
+
+       void SetRole(const Tizen::Base::String& role);
+
+       void SetAgent(const Tizen::Base::String& agent);
+
+       void SetType(OrganizationType type);
+
+       void SetLabel(const Tizen::Base::String& label);
+
+       void SetLocation(const Tizen::Base::String& location);
+
+       void SetDescription(const Tizen::Base::String& description);
+
+       void SetPhoneticName(const Tizen::Base::String& phoneticName);
+
+       result SetLogo(const Tizen::Base::String& filePath);
+
+       _OrganizationImpl& operator =(const _OrganizationImpl& rhs);
+
+       bool IsEmpty(void) const;
+
+       bool IsLogoPathChanged(void) const;
+
+       result SetLogoPath(const Tizen::Base::String& filePath);
+
+       bool operator ==(const _OrganizationImpl& rhs) const;
+
+       bool operator !=(const _OrganizationImpl& rhs) const;
+
+       static const _OrganizationImpl* GetInstance(const Organization& organization);
+
+       static _OrganizationImpl* GetInstance(Organization& organization);
+
+private:
+       Tizen::Base::String __name;
+       Tizen::Base::String __jobTitle;
+       Tizen::Base::String __department;
+       Tizen::Base::String __role;
+       Tizen::Base::String __agent;
+       Tizen::Base::String __label;
+       Tizen::Base::String __location;
+       Tizen::Base::String __description;
+       Tizen::Base::String __phoneticName;
+       Tizen::Base::String __logoPath;
+       OrganizationType __type;
+       bool __isLogoPathChanged;
+}; // _OrganizationImpl
+
+}} // Tizen::Social
+
+#endif //_FSCL_INTERNAL_ORGANIZATION_IMPL_H_
diff --git a/src/FScl_PersonImpl.cpp b/src/FScl_PersonImpl.cpp
new file mode 100644 (file)
index 0000000..2eea727
--- /dev/null
@@ -0,0 +1,474 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_PersonImpl.cpp
+ * @brief              This is the implementation for Profile class.
+ *
+ * This file contains definitions of @e _PersonImpl class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FBaseUtilStringTokenizer.h>
+#include <FBaseInteger.h>
+#include <FSclPerson.h>
+#include <FSclContact.h>
+#include <FSclCategory.h>
+#include <FApp_AppInfo.h>
+#include <FScl_ContactImpl.h>
+#include <FScl_CategoryImpl.h>
+#include <FScl_RecordImpl.h>
+#include "FScl_PersonImpl.h"
+#include "FScl_EmailImpl.h"
+#include "FScl_PhoneNumberImpl.h"
+#include "FScl_AddressbookUtil.h"
+#include "FScl_ContactDbConnector.h"
+#include "FScl_ContactDbMonitor.h"
+
+using namespace std;
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Graphics;
+using namespace Tizen::Media;
+
+namespace Tizen { namespace Social
+{
+
+_PersonImpl::_PersonImpl()
+: __isFavorite(false)
+, __hasPhoneNumber(false) 
+, __hasEmail(false)
+, __personId(-1)
+, __accountId1(-1)
+, __accountId2(-1)
+, __accountId3(-1)
+{
+
+}
+
+_PersonImpl::~_PersonImpl(void)
+{
+
+}
+
+bool
+_PersonImpl::Equals(const Object& rhs) const
+{
+       const _PersonImpl* pPersonImpl = dynamic_cast<const _PersonImpl*>(&rhs);
+       if (pPersonImpl == null)
+       {
+               return false;
+       }
+
+       if (__personId == pPersonImpl->__personId)
+       {
+               return true;
+       }
+
+       return false;
+}
+
+int
+_PersonImpl::GetHashCode(void) const
+{
+       return 0;
+}
+
+void
+_PersonImpl::SetId(int personId)
+{
+       __personId = personId;
+}
+
+PersonId
+_PersonImpl::GetId(void) const
+{
+       return __personId;
+}
+
+void
+_PersonImpl::SetIsFavorite(bool isFavorite)
+{
+       __isFavorite = isFavorite;
+}
+
+bool
+_PersonImpl::IsFavorite(void) const
+{
+       return __isFavorite;
+}
+
+void
+_PersonImpl::SetAddressbookIdString(const String& addressbookIdString)
+{
+       __addressbookIdString = addressbookIdString;
+}
+
+void
+_PersonImpl::SetDisplayName(const String& displayName)
+{
+       __displayName = displayName;
+}
+
+String
+_PersonImpl::GetDisplayName(void) const
+{
+       return __displayName;
+}
+
+void
+_PersonImpl::SetThumbnailPath(const String& thumbnailPath)
+{
+       __thumbnailPath = thumbnailPath;
+}
+
+String
+_PersonImpl::GetThumbnailPath(void) const
+{
+       return __thumbnailPath;
+}
+
+void
+_PersonImpl::SetRingtonePath(const String& ringtonePath)
+{
+        __ringtonePath = ringtonePath;
+}
+
+String
+_PersonImpl::GetRingtonePath(void) const
+{
+       return __ringtonePath;
+}
+
+void
+_PersonImpl::SetHasPhoneNumber(bool hasPhoneNumber)
+{
+       __hasPhoneNumber = hasPhoneNumber;
+}
+
+bool
+_PersonImpl::HasPhoneNumber(void) const
+{
+       return __hasPhoneNumber;
+}
+
+void
+_PersonImpl::SetHasEmail(bool hasEmail)
+{
+       __hasEmail = hasEmail;
+}
+
+bool
+_PersonImpl::HasEmail(void) const
+{
+       return __hasEmail;
+}
+
+IListT<AccountId>*
+_PersonImpl::GetAccountIdsN(void) const
+{
+       ClearLastResult();
+
+       if (__pAccountIds == null)
+       {
+               _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance();
+               SysTryReturn(NID_SCL, GetLastResult() != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+               std::unique_ptr<ArrayListT<AccountId> > pAccountIdList(new (std::nothrow) ArrayListT<AccountId>());
+               SysTryReturn(NID_SCL, pAccountIdList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               result r = pAccountIdList->Construct();
+               SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               String delim(L" ");
+               StringTokenizer tokenizer(__addressbookIdString, delim);
+               String token;
+               int addressbookId = 0;
+               int accountId = 0;
+
+               while (tokenizer.HasMoreTokens())
+               {
+                       tokenizer.GetNextToken(token);
+                       Integer::Parse(token, addressbookId);
+                       if (addressbookId == DEFAULT_ADDRESSBOOK_ID)
+                       {
+                               continue;
+                       }
+
+                       accountId = pContactDbMonitor->GetAccountIdByAddressbookId(addressbookId);
+                       SysTryReturn(NID_SCL, GetLastResult() != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+                       SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+                       if (accountId > 0)
+                       {
+                               result r = pAccountIdList->Add(accountId);
+                               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+                       }
+               }
+
+               __pAccountIds = std::move(pAccountIdList);
+       }
+
+       std::unique_ptr<ArrayListT<AccountId> > pList(new (std::nothrow) ArrayListT<AccountId>());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pList->Construct(*__pAccountIds);
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       return pList.release();
+}
+
+result
+_PersonImpl::SetAsFavorite(bool isFavorite)
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       unique_ptr<ContactRecord, ContactRecordDeleter> pPersonRecord(_AddressbookUtil::GetContactRecordN(_contacts_person._uri, __personId));
+       SysTryReturn(NID_SCL, pPersonRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       bool boolValue = false;
+       contacts_record_get_bool(pPersonRecord.get(), _contacts_person.is_favorite, &boolValue);
+
+       if (boolValue != isFavorite)
+       {
+               contacts_record_set_bool(pPersonRecord.get(), _contacts_person.is_favorite, isFavorite);
+
+               result r = _AddressbookUtil::UpdateContactRecord(pPersonRecord.get());
+               SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               __isFavorite = isFavorite;
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_PersonImpl::SetAsPrimaryPhoneNumber(const PhoneNumber& phoneNumber)
+{
+       int numberId = _PhoneNumberImpl::GetInstance(phoneNumber)->GetRecordId();
+
+       SysTryReturn(NID_SCL, numberId > 0, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified number is invalid.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int ret = contacts_person_set_default_property(CONTACTS_PERSON_PROPERTY_NUMBER, __personId, numberId);
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return E_SUCCESS;
+}
+
+result
+_PersonImpl::SetAsPrimaryEmail(const Email& email)
+{
+       int emailId = _EmailImpl::GetInstance(email)->GetRecordId();
+
+       SysTryReturn(NID_SCL, emailId > 0, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified number is invalid.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int ret = contacts_person_set_default_property(CONTACTS_PERSON_PROPERTY_EMAIL, __personId, emailId);
+       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return E_SUCCESS;
+}
+
+
+PhoneNumber
+_PersonImpl::GetPrimaryPhoneNumber(void) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, PhoneNumber(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int intValue = 0;
+       char* pCharValue = null;
+       String number(L"");
+       PhoneNumberType type = PHONENUMBER_TYPE_HOME;
+
+       PhoneNumber primaryPhoneNumber;
+       
+       contacts_record_h currentHandle = null;
+
+       __Filter<__ContactsPersonNumber> filter;
+       filter.Construct();
+       filter.AddInt(_contacts_person_number.person_id, CONTACTS_MATCH_EQUAL, __personId);
+       filter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+       filter.AddBool(_contacts_person_email.is_primary_default, true);
+
+       __Query<__ContactsPersonNumber> query;
+       query.Construct();
+       query.SetFilter(filter);
+
+       std::unique_ptr<__SearchResult<__ContactsPersonNumber> > pSearchResult(_AddressbookUtil::ExecuteQuery(query));
+       SysTryReturn(NID_SCL, pSearchResult != null, primaryPhoneNumber, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       if (pSearchResult->GetCount() == 0)
+       {
+               return primaryPhoneNumber;
+       }
+
+       while (pSearchResult->MoveNext() == E_SUCCESS)
+       {
+               currentHandle = pSearchResult->GetCurrentRecord();      
+               contacts_record_get_int(currentHandle, _contacts_person_number.number_id, &intValue);
+
+               contacts_record_get_int(currentHandle, _contacts_person_number.number_id, &intValue);
+               _PhoneNumberImpl::GetInstance(primaryPhoneNumber)->SetRecordId(intValue);
+
+               contacts_record_get_str_p(currentHandle, _contacts_person_number.label, &pCharValue);
+               _PhoneNumberImpl::GetInstance(primaryPhoneNumber)->SetLabel(pCharValue);
+
+               contacts_record_get_int(currentHandle, _contacts_person_number.type, &intValue);
+               switch (intValue)
+               {
+               case CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE:
+                       type = PHONENUMBER_TYPE_HOME;
+                       break;
+               case CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE:
+                       type = PHONENUMBER_TYPE_WORK;
+                       break;
+               case CONTACTS_NUMBER_TYPE_CELL:
+                       type = PHONENUMBER_TYPE_MOBILE;
+                       break;
+               case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME:
+                       type = PHONENUMBER_TYPE_HOME_FAX;
+                       break;
+               case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK:
+                       type = PHONENUMBER_TYPE_WORK_FAX;
+                       break;
+               case CONTACTS_NUMBER_TYPE_PAGER:
+                       type = PHONENUMBER_TYPE_PAGER;
+                       break;
+               case CONTACTS_NUMBER_TYPE_CUSTOM:
+                       type = PHONENUMBER_TYPE_CUSTOM;
+                       break;
+               case CONTACTS_NUMBER_TYPE_ASSISTANT:
+                       if (_AppInfo::GetApiVersion() < _API_VERSION_2_1)
+                       {
+                               type = PHONENUMBER_TYPE_OTHER;
+                       }
+                       else
+                       {
+                               type = PHONENUMBER_TYPE_ASSISTANT;
+                       }
+                       break;
+               default:
+                       type = PHONENUMBER_TYPE_OTHER;
+                       break;
+               }
+
+               _PhoneNumberImpl::GetInstance(primaryPhoneNumber)->SetType(type);
+
+               contacts_record_get_str_p(currentHandle, _contacts_person_number.number, &pCharValue);
+               _PhoneNumberImpl::GetInstance(primaryPhoneNumber)->SetPhoneNumber(pCharValue);
+               
+               break;
+       }       
+
+       return primaryPhoneNumber;
+}
+
+Email
+_PersonImpl::GetPrimaryEmail(void) const
+{
+       SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, Email(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int intValue = 0;
+       char* pCharValue = null;
+       EmailType type = EMAIL_TYPE_PERSONAL;
+       String email(L"");
+
+       Email primaryEmail;     
+       
+       contacts_record_h currentHandle = null;
+
+       __Filter<__ContactsPersonEmail> filter;
+       filter.Construct();
+       filter.AddInt(_contacts_person_email.person_id, CONTACTS_MATCH_EQUAL, __personId);
+       filter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+       filter.AddBool(_contacts_person_email.is_primary_default, true);
+
+       __Query<__ContactsPersonEmail> query;
+       query.Construct();
+       query.SetFilter(filter);
+
+       std::unique_ptr<__SearchResult<__ContactsPersonEmail> > pSearchResult(_AddressbookUtil::ExecuteQuery(query));
+       SysTryReturn(NID_SCL, pSearchResult != null, primaryEmail, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       if (pSearchResult->GetCount() == 0)
+       {
+               return primaryEmail;
+       }
+       while (pSearchResult->MoveNext() == E_SUCCESS)
+       {
+               currentHandle = pSearchResult->GetCurrentRecord();      
+
+               contacts_record_get_int(currentHandle, _contacts_person_email.email_id, &intValue);
+               _EmailImpl::GetInstance(primaryEmail)->SetRecordId(intValue);
+
+               contacts_record_get_str_p(currentHandle, _contacts_person_email.label, &pCharValue);
+               _EmailImpl::GetInstance(primaryEmail)->SetLabel(pCharValue);
+
+               contacts_record_get_int(currentHandle, _contacts_person_email.type, &intValue);
+               switch (intValue)
+               {
+               case CONTACTS_EMAIL_TYPE_HOME:
+                       type = EMAIL_TYPE_PERSONAL;
+                       break;
+               case CONTACTS_EMAIL_TYPE_WORK:
+                       type = EMAIL_TYPE_WORK;
+                       break;
+               case CONTACTS_EMAIL_TYPE_CUSTOM:
+                       type = EMAIL_TYPE_CUSTOM;
+                       break;
+               case CONTACTS_EMAIL_TYPE_MOBILE:
+                       if (_AppInfo::GetApiVersion() < _API_VERSION_2_1)
+                       {
+                               type = EMAIL_TYPE_OTHER;
+                       }
+                       else
+                       {
+                               type = EMAIL_TYPE_MOBILE;
+                       }
+                       break;
+               default:
+                       type = EMAIL_TYPE_OTHER;
+                       break;
+               }
+
+               _EmailImpl::GetInstance(primaryEmail)->SetType(type);
+
+               contacts_record_get_str_p(currentHandle, _contacts_person_email.email, &pCharValue);
+               _EmailImpl::GetInstance(primaryEmail)->SetEmail(pCharValue);
+       }       
+
+       return primaryEmail;
+}
+
+_PersonImpl*
+_PersonImpl::GetInstance(Person& person)
+{
+       return person.__pPersonImpl;
+}
+
+const _PersonImpl*
+_PersonImpl::GetInstance(const Person& person)
+{
+       return person.__pPersonImpl;
+}
+
+}} // Tizen::Social
diff --git a/src/FScl_PersonImpl.h b/src/FScl_PersonImpl.h
new file mode 100644 (file)
index 0000000..6176067
--- /dev/null
@@ -0,0 +1,140 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_PersonImpl.h
+ * @brief              This is the header file for the %_PersonImpl class.
+ *
+ * This header file contains the declarations of the %_PersonImpl class.
+ */
+#ifndef _FSCL_PERSON_IMPL_H_
+#define _FSCL_PERSON_IMPL_H_
+
+#include <unique_ptr.h>
+#include <contacts.h>
+#include <FBaseObject.h>
+#include <FSclRecord.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+
+namespace Collection
+{
+template<typename Type>
+class IListT;
+
+template<typename Type>
+class ArrayListT;
+}
+
+} }
+
+namespace Tizen { namespace Graphics
+{
+class Bitmap;
+} }
+
+namespace Tizen { namespace Social
+{
+
+class PhoneNumber;
+class Email;
+
+class _OSP_EXPORT_ _PersonImpl
+        : public Tizen::Base::Object
+{
+public:
+        _PersonImpl(void);
+
+       virtual ~_PersonImpl(void);
+
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       virtual int GetHashCode(void) const;
+
+       // setter
+       void SetId(int personId);
+       
+       void SetDisplayName(const Tizen::Base::String& displayName);
+       
+       void SetThumbnailPath(const Tizen::Base::String& thumbnailPath);
+       
+       void SetRingtonePath(const Tizen::Base::String& ringtonePath);
+
+       void SetHasPhoneNumber(bool hasPhoneNumber);
+
+       void SetHasEmail(bool hasEmail);
+
+       void SetIsFavorite(bool isFavorite);
+
+       void SetAddressbookIdString(const Tizen::Base::String& addressbookIdString);
+
+       // getter
+       Tizen::Base::String GetDisplayName(void) const;
+
+       Tizen::Base::String GetThumbnailPath(void) const;
+
+       Tizen::Base::String GetRingtonePath(void) const;
+
+       bool HasPhoneNumber(void) const;
+
+       bool HasEmail(void) const;
+
+       bool IsFavorite(void) const;
+
+       Tizen::Base::Collection::IListT<AccountId>* GetAccountIdsN(void) const;
+
+       PersonId GetId(void) const;
+
+       result SetAsFavorite(bool isFavorite);
+
+       result SetAsPrimaryPhoneNumber(const PhoneNumber& phoneNumber);
+
+       result SetAsPrimaryEmail(const Email& email);
+
+       PhoneNumber GetPrimaryPhoneNumber(void) const;
+
+       Email GetPrimaryEmail(void) const;
+
+       static _PersonImpl* GetInstance(Person& person);
+
+       static const _PersonImpl* GetInstance(const Person& person);
+
+private:
+        _PersonImpl(const _PersonImpl& rhs);
+
+        _PersonImpl& operator =(const _PersonImpl& rhs);
+
+private:
+       bool __isFavorite;
+       bool __hasPhoneNumber;
+       bool __hasEmail;
+       int __personId;
+       int __accountId1;
+       int __accountId2;
+       int __accountId3;
+       Tizen::Base::String __displayName;
+       Tizen::Base::String __thumbnailPath;
+       Tizen::Base::String __ringtonePath;
+       Tizen::Base::String __addressbookIdString;
+       mutable std::unique_ptr<Tizen::Base::Collection::ArrayListT<AccountId> > __pAccountIds;
+               
+        friend class _AddressbookManagerImpl;
+};     // _PersonImpl
+
+}}     // Tizen::Social
+
+#endif // _FSCL_PERSON_IMPL_H_
diff --git a/src/FScl_PhoneNumberContactImpl.cpp b/src/FScl_PhoneNumberContactImpl.cpp
new file mode 100644 (file)
index 0000000..e277db1
--- /dev/null
@@ -0,0 +1,255 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_PhoneNumberContactImpl.cpp
+ * @brief              This is the implementation for _PhoneNumberContactImpl class.
+ *
+ * This file contains definitions of @e _PhoneNumberContactImpl class.
+ */
+
+#include <new>
+#include <unique_ptr.h>
+#include <FBaseResult.h>
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include <FSclPhoneNumberContact.h>
+#include <FSclPhoneNumber.h>
+#include "FScl_RecordImpl.h"
+#include "FScl_PhoneNumberImpl.h"
+#include "FScl_PhoneNumberContactImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Social
+{
+
+_PhoneNumberContactImpl::_PhoneNumberContactImpl(void)
+: __addressbookId(INVALID_ADDRESSBOOK_ID)
+, __contactId(INVALID_RECORD_ID)
+{
+       //empty body
+}
+
+_PhoneNumberContactImpl::_PhoneNumberContactImpl(const _PhoneNumberContactImpl& rhs)
+{
+       __addressbookId = rhs.__addressbookId;
+       __contactId = rhs.__contactId;
+       __personId = rhs.__personId;
+       __displayName = rhs.__displayName;
+       __thumbnail = rhs.__thumbnail;
+       __ringtone = rhs.__ringtone;
+       __phoneNumber = rhs.__phoneNumber;
+}
+
+_PhoneNumberContactImpl::~_PhoneNumberContactImpl(void)
+{
+       //empty body
+}
+
+_PhoneNumberContactImpl&
+_PhoneNumberContactImpl::operator =(const _PhoneNumberContactImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+       __addressbookId = rhs.__addressbookId;
+       __contactId = rhs.__contactId;
+       __personId = rhs.__personId;
+       __displayName = rhs.__displayName;
+       __thumbnail = rhs.__thumbnail;
+       __ringtone = rhs.__ringtone;
+       __phoneNumber = rhs.__phoneNumber;
+
+       return *this;
+}
+
+bool
+_PhoneNumberContactImpl::operator ==(const _PhoneNumberContactImpl& rhs) const
+{
+       if (__addressbookId != rhs.__addressbookId)
+       {
+               return false;
+       }
+
+       if (__contactId != rhs.__contactId)
+       {
+               return false;
+       }
+
+       if (__personId != rhs.__personId)
+       {
+               return false;
+       }
+
+       if (__displayName != rhs.__displayName)
+       {
+               return false;
+       }
+
+
+       if (__thumbnail != rhs.__thumbnail)
+       {
+               return false;
+       }
+
+
+       if (__ringtone != rhs.__ringtone)
+       {
+               return false;
+       }
+
+       if (__phoneNumber != rhs.__phoneNumber)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+bool
+_PhoneNumberContactImpl::Equals(const Object& rhs) const
+{
+       const _PhoneNumberContactImpl* pPhoneNumberContactImpl = dynamic_cast<const _PhoneNumberContactImpl*>(&rhs);
+       if (pPhoneNumberContactImpl == null)
+       {
+               return false;
+       }
+
+       return *this == *pPhoneNumberContactImpl;
+}
+
+int
+_PhoneNumberContactImpl::GetHashCode(void) const
+{
+       int hashCode = 0;
+
+       hashCode = 0xffffffff & __contactId;
+       hashCode += __addressbookId;
+       hashCode += __personId;
+       hashCode += __displayName.GetHashCode();
+       hashCode += __thumbnail.GetHashCode();
+       hashCode += __ringtone.GetHashCode();
+       hashCode += __phoneNumber.GetHashCode();
+
+       return hashCode;
+}
+
+PersonId
+_PhoneNumberContactImpl::GetPersonId(void) const
+{
+       return __personId;
+}
+
+void
+_PhoneNumberContactImpl::SetPersonId(PersonId personId)
+{
+       __personId = personId;
+}
+
+
+void
+_PhoneNumberContactImpl::SetAddressbookId(AddressbookId addressbookId)
+{
+       __addressbookId = addressbookId;
+}
+
+AddressbookId
+_PhoneNumberContactImpl::GetAddressbookId(void) const
+{
+       return __addressbookId;
+}
+
+
+RecordId
+_PhoneNumberContactImpl::GetContactId(void) const
+{
+       return __contactId;
+}
+
+String
+_PhoneNumberContactImpl::GetDisplayName(void) const
+{
+       return __displayName;
+}
+
+String
+_PhoneNumberContactImpl::GetThumbnailPath(void) const
+{
+       return __thumbnail;
+}
+
+String
+_PhoneNumberContactImpl::GetRingtonePath(void) const
+{
+       return __ringtone;
+}
+
+
+PhoneNumber
+_PhoneNumberContactImpl::GetPhoneNumber(void) const
+{
+       return __phoneNumber;
+}
+
+void
+_PhoneNumberContactImpl::SetContactId(RecordId contactId)
+{
+       __contactId = contactId;
+}
+
+void
+_PhoneNumberContactImpl::SetDisplayName(const String& displayName)
+{
+       __displayName = displayName;
+}
+
+void
+_PhoneNumberContactImpl::SetThumbnailPath(const String& thumbnail)
+{
+       __thumbnail = thumbnail;
+}
+
+void
+_PhoneNumberContactImpl::SetRingtonePath(const String& ringtone)
+{
+       __ringtone = ringtone;
+}
+
+void
+_PhoneNumberContactImpl::SetPhoneNumberData(int recordId, PhoneNumberType type, const Tizen::Base::String& label, const Tizen::Base::String& number)
+{
+       _PhoneNumberImpl::GetInstance(__phoneNumber)->SetRecordId(recordId);
+       _PhoneNumberImpl::GetInstance(__phoneNumber)->SetType(type);
+       _PhoneNumberImpl::GetInstance(__phoneNumber)->SetLabel(label);
+       _PhoneNumberImpl::GetInstance(__phoneNumber)->SetPhoneNumber(number);
+}
+
+_PhoneNumberContactImpl*
+_PhoneNumberContactImpl::GetInstance(PhoneNumberContact& simpleContact)
+{
+       return simpleContact.__pPhoneNumberContactImpl;
+}
+
+const _PhoneNumberContactImpl*
+_PhoneNumberContactImpl::GetInstance(const PhoneNumberContact& simpleContact)
+{
+       return simpleContact.__pPhoneNumberContactImpl;
+}
+
+
+}}  // Tizen::Social
diff --git a/src/FScl_PhoneNumberContactImpl.h b/src/FScl_PhoneNumberContactImpl.h
new file mode 100644 (file)
index 0000000..631491a
--- /dev/null
@@ -0,0 +1,104 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_PhoneNumberContactImpl.h
+ * @brief              This is the header file for the %_PhoneNumberContactImpl class.
+ *
+ * This header file contains the declarations of the %_PhoneNumberContactImpl class.
+ */
+#ifndef _FSCL_INTERNAL_PHONE_NUMBER_CONTACT_IMPL_H_
+#define _FSCL_INTERNAL_PHONE_NUMBER_CONTACT_IMPL_H_
+
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FSclTypes.h>
+#include <FSclPhoneNumber.h>
+
+namespace Tizen { namespace Social
+{
+
+class PhoneNumberContact;
+
+/**
+ * @class      _PhoneNumberContactImpl
+ * @brief      This class provides summarized contact information.
+ *
+ * @since      2.0
+ *
+ */
+class _PhoneNumberContactImpl
+       : public Tizen::Base::Object
+{
+public:
+       _PhoneNumberContactImpl(void);
+
+       _PhoneNumberContactImpl(const _PhoneNumberContactImpl& rhs);
+
+       virtual ~_PhoneNumberContactImpl(void);
+
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       virtual int GetHashCode(void) const;
+
+       RecordId GetContactId(void) const;
+
+       PersonId GetPersonId(void) const;
+
+       Tizen::Base::String GetDisplayName(void) const;
+
+       Tizen::Base::String GetThumbnailPath(void) const;
+
+       Tizen::Base::String GetRingtonePath(void) const;
+
+       PhoneNumber GetPhoneNumber(void) const;
+
+       void SetPersonId(PersonId personId);
+
+       void SetAddressbookId(AddressbookId addressbookId);
+
+       AddressbookId GetAddressbookId(void) const;
+
+       void SetContactId(RecordId contactId);
+
+       void SetDisplayName(const Tizen::Base::String& displayName);
+
+       void SetThumbnailPath(const Tizen::Base::String& thumbnail);
+
+       void SetRingtonePath(const Tizen::Base::String& ringtone);
+
+       void SetPhoneNumberData(int recordId, PhoneNumberType type, const Tizen::Base::String& label, const Tizen::Base::String& number);
+
+       static _PhoneNumberContactImpl* GetInstance(PhoneNumberContact& simpleContact);
+
+       static const _PhoneNumberContactImpl* GetInstance(const PhoneNumberContact& simpleContact);
+
+       _PhoneNumberContactImpl& operator =(const _PhoneNumberContactImpl& rhs);
+
+       bool operator ==(const _PhoneNumberContactImpl& rhs) const;
+
+private:
+       AddressbookId __addressbookId;
+       RecordId        __contactId;
+       PersonId        __personId;
+       Tizen::Base::String __displayName;
+       Tizen::Base::String __thumbnail;
+       Tizen::Base::String __ringtone;
+       PhoneNumber __phoneNumber;
+};     // _PhoneNumberContactImpl
+
+}}     // Tizen::Social
+
+#endif // _FSCL_INTERNAL_PHONE_NUMBER_CONTACT_IMPL_H_
diff --git a/src/FScl_PhoneNumberImpl.cpp b/src/FScl_PhoneNumberImpl.cpp
new file mode 100644 (file)
index 0000000..76c2ca0
--- /dev/null
@@ -0,0 +1,199 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FScl_PhoneNumberImpl.cpp
+* @brief               This is the implementation for _PhoneNumberImpl class.
+*
+* This file contains definitions of @e _PhoneNumberImpl class.
+*/
+
+#include <unique_ptr.h>
+#include <FSclPhoneNumber.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include "FScl_PhoneNumberImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+_PhoneNumberImpl::_PhoneNumberImpl(void)
+: __recordId(-1)
+, __type(PHONENUMBER_TYPE_HOME)
+, __isPhoneTypeChanged(false)
+{
+
+}
+
+_PhoneNumberImpl::_PhoneNumberImpl(PhoneNumberType type, const String& number)
+: __recordId(-1)
+, __type(type)
+, __number(number)
+, __isPhoneTypeChanged(false)
+{
+
+}
+
+_PhoneNumberImpl::_PhoneNumberImpl(const _PhoneNumberImpl& rhs)
+{
+       __recordId = rhs.__recordId;
+       __type = rhs.__type;
+       __label = rhs.__label;
+       __number = rhs.__number;
+       __isPhoneTypeChanged = rhs.__isPhoneTypeChanged;
+}      
+
+_PhoneNumberImpl::~_PhoneNumberImpl(void)
+{
+}
+
+_PhoneNumberImpl&
+_PhoneNumberImpl::operator =(const _PhoneNumberImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __recordId = rhs.__recordId;
+       __type = rhs.__type;
+       __label = rhs.__label;
+       __number = rhs.__number;
+       __isPhoneTypeChanged = rhs.__isPhoneTypeChanged;
+
+       return *this;
+}
+
+bool
+_PhoneNumberImpl::operator ==(const _PhoneNumberImpl& rhs) const
+{
+       if (__type != rhs.__type || __label != rhs.__label || __number != rhs.__number)
+       {
+               return false;
+       }
+       
+       return true;
+}
+
+bool
+_PhoneNumberImpl::Equals(const Object& rhs) const
+{
+       const _PhoneNumberImpl* pPhoneNumberImpl = dynamic_cast<const _PhoneNumberImpl*>(&rhs);
+
+       if (pPhoneNumberImpl == null)
+       {
+               return false;
+       }
+
+       return (*this == *pPhoneNumberImpl);
+}
+
+int
+_PhoneNumberImpl::GetHashCode(void) const
+{
+       int hashCode = __recordId;
+       hashCode += __type;
+       hashCode += __number.GetHashCode();
+       hashCode += __label.GetHashCode();
+
+       return hashCode;
+}
+
+bool
+_PhoneNumberImpl::operator !=(const _PhoneNumberImpl& rhs) const
+{
+       return !(*this == rhs);
+}
+
+PhoneNumberType
+_PhoneNumberImpl::GetType(void) const
+{
+       return __type;
+}
+
+String
+_PhoneNumberImpl::GetPhoneNumber(void) const
+{
+       return __number;
+}
+
+void
+_PhoneNumberImpl::SetType(PhoneNumberType type)
+{
+       __type = type;
+       __isPhoneTypeChanged = true;
+}
+
+result
+_PhoneNumberImpl::SetPhoneNumber(const String& number)
+{
+       SysTryReturn(NID_SCL, !number.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The phone number is empty.", GetErrorMessage(E_INVALID_ARG));
+
+       __number = number;
+
+       return E_SUCCESS;
+}
+
+void
+_PhoneNumberImpl::SetLabel(const String& label)
+{
+       __label = label;
+}
+
+String
+_PhoneNumberImpl::GetLabel(void) const
+{
+       return __label;
+}
+
+void
+_PhoneNumberImpl::SetRecordId(int recordId)
+{
+       __recordId = recordId;
+}
+
+int
+_PhoneNumberImpl::GetRecordId(void) const
+{
+       return __recordId;
+}
+
+bool
+_PhoneNumberImpl::IsEmpty(void) const
+{
+       return __number.IsEmpty();
+}
+
+bool
+_PhoneNumberImpl::IsPhoneNumberTypeChanged(void) const
+{
+       return __isPhoneTypeChanged;
+}
+
+_PhoneNumberImpl*
+_PhoneNumberImpl::GetInstance(PhoneNumber& phoneNumber)
+{
+       return phoneNumber.__pPhoneNumberImpl;
+}
+
+const _PhoneNumberImpl*
+_PhoneNumberImpl::GetInstance(const PhoneNumber& phoneNumber)
+{
+       return phoneNumber.__pPhoneNumberImpl;
+}
+
+}} // Tizen::Social
diff --git a/src/FScl_PhoneNumberImpl.h b/src/FScl_PhoneNumberImpl.h
new file mode 100644 (file)
index 0000000..edd822c
--- /dev/null
@@ -0,0 +1,107 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FScl_PhoneNumberImpl.h
+* @brief       This is the header file for the %_PhoneNumberImpl class.
+*
+* This header file contains the declarations of the %_PhoneNumberImpl class.
+*/
+#ifndef _FSCL_INTERNAL_PHONE_NUMBER_IMPL_H_
+#define _FSCL_INTERNAL_PHONE_NUMBER_IMPL_H_
+
+#include <contacts.h>
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+}}
+
+namespace Tizen { namespace Social
+{
+class PhoneNumber;
+
+/**
+* @class       _PhoneNumberImpl
+* @brief       This class stores the information of a phone number.
+*
+* @since       2.0
+*
+* The %_PhoneNumberImpl class consists of the phone number and phone number type.
+*
+*/
+class _PhoneNumberImpl
+       : public Tizen::Base::Object
+{
+public:
+       _PhoneNumberImpl(void);
+
+       _PhoneNumberImpl(PhoneNumberType type, const Tizen::Base::String& number);
+
+       _PhoneNumberImpl(const _PhoneNumberImpl& rhs);
+
+       virtual ~_PhoneNumberImpl(void);
+
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       virtual int GetHashCode(void) const;
+
+       // setter       
+       void SetRecordId(int recordId);
+
+       void SetType(PhoneNumberType type);
+
+       void SetLabel(const Tizen::Base::String& label);
+
+       result SetPhoneNumber(const Tizen::Base::String& number);
+
+       // getter
+       int GetRecordId(void) const;
+
+       PhoneNumberType GetType(void) const;
+       
+       Tizen::Base::String GetLabel(void) const;
+
+       Base::String GetPhoneNumber(void) const;
+
+       bool IsEmpty(void) const;
+
+       bool IsPhoneNumberTypeChanged(void) const;
+
+       static _PhoneNumberImpl* GetInstance(PhoneNumber& phoneNUmber);
+
+       static const _PhoneNumberImpl* GetInstance(const PhoneNumber& phoneNUmber);
+
+       _PhoneNumberImpl& operator =(const _PhoneNumberImpl& rhs);
+
+       bool operator ==(const _PhoneNumberImpl& rhs) const;
+
+       bool operator !=(const _PhoneNumberImpl& rhs) const;
+
+private:
+       contacts_record_h __recordHandle;
+       int __recordId;
+       PhoneNumberType __type;
+       Tizen::Base::String __label;
+       Tizen::Base::String __number;
+       bool __isPhoneTypeChanged;
+}; // _PhoneNumberImpl
+
+}} // Tizen::Social
+
+#endif // _FSCL_INTERNAL_PHONE_NUMBER_IMPL_H_
diff --git a/src/FScl_RecordImpl.cpp b/src/FScl_RecordImpl.cpp
new file mode 100644 (file)
index 0000000..5df97c5
--- /dev/null
@@ -0,0 +1,92 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_RecordImpl.cpp
+ * @brief              This is the implementation for _RecordImpl class.
+ *
+ * This file contains definitions of _RecordImpl class.
+ */
+
+#include "FScl_RecordImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+_RecordImpl::_RecordImpl(RecordType type)
+       : __recordType(type)
+       , __recordId(INVALID_RECORD_ID)
+{
+       // empty body.
+}
+
+_RecordImpl::~_RecordImpl()
+{
+       // empty body.
+}
+
+_RecordImpl::_RecordImpl(const _RecordImpl& rhs)
+{
+       __recordType = rhs.__recordType;
+       __recordId = rhs.__recordId;
+}
+
+_RecordImpl&
+_RecordImpl::operator =(const _RecordImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __recordType = rhs.__recordType;
+       __recordId = rhs.__recordId;
+
+       return *this;
+}
+
+RecordType
+_RecordImpl::GetRecordType(void) const
+{
+       return __recordType;
+}
+
+RecordId
+_RecordImpl::GetRecordId(void) const
+{
+       return __recordId;
+}
+
+void
+_RecordImpl::SetRecordId(RecordId recordId)
+{
+       __recordId = recordId;
+}
+
+_RecordImpl*
+_RecordImpl::GetInstance(Record& record)
+{
+       return record.__pRecordImpl;
+}
+
+const _RecordImpl*
+_RecordImpl::GetInstance(const Record& record)
+{
+       return record.__pRecordImpl;
+}
+
+}} // Tizen::Social
diff --git a/src/FScl_RecurrenceImpl.cpp b/src/FScl_RecurrenceImpl.cpp
new file mode 100644 (file)
index 0000000..3c8bf2d
--- /dev/null
@@ -0,0 +1,513 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_RecurrenceImpl.cpp
+ * @brief              This is the implementation for _RecurrenceImpl class.
+ *
+ * This file contains definitions of @e _RecurrenceImpl class.
+ */
+
+#include <new>
+#include <FApp_AppInfo.h>
+#include <FBaseColArrayList.h>
+#include <FBaseColIList.h>
+#include <FBaseDateTime.h>
+#include <FBaseSysLog.h>
+#include <FSclRecurrence.h>
+#include "FScl_CalendarbookImpl.h"
+#include "FScl_CalendarbookUtil.h"
+#include "FScl_RecurrenceImpl.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Social
+{
+
+static const RecurFrequency _DEFAULT_RECURRENCE_TYPE = FREQ_DAILY;
+static const int _DEFAULT_INTERVAL = 1;
+static const int _DEFAULT_COUNT = 1;
+static const CalDayOfWeek _DEFAULT_WEEK_START = CAL_MONDAY;
+static const int _WEEK_ONE = 1;
+static const int _WEEK_FIVE = 5;
+static const int _MONTH_ONE = 1;
+static const int _MONTH_TWELVE = 12;
+static const int _DAY_ONE = 1;
+static const int _DAY_THIRTY_ONE = 31;
+static const int _MIN_RECURRENCE_INTERVAL = 1;
+static const int _MAX_DAY_OF_WEEK = 0x7F;
+
+_RecurrenceImpl::_RecurrenceImpl(void)
+       : __type(_DEFAULT_RECURRENCE_TYPE)
+       , __interval(_DEFAULT_INTERVAL)
+       , __pUntil(null)
+       , __count(_DEFAULT_COUNT)
+       , __weekStart(_DEFAULT_WEEK_START)
+       , __dayOfWeek(0)
+       , __dayOfMonth(0)
+       , __weekOfMonth(0)
+       , __monthOfYear(0)
+{
+       std::unique_ptr<ArrayList, AllElementsDeleter> pExceptionDates(new (std::nothrow) ArrayList());
+       SysTryReturnVoidResult(NID_SCL, pExceptionDates, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pExceptionDates->Construct();
+       SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pExceptionDates = std::move(pExceptionDates);
+}
+
+_RecurrenceImpl::_RecurrenceImpl(const _RecurrenceImpl& rhs)
+       : __type(rhs.__type)
+       , __interval(rhs.__interval)
+       , __pUntil(null)
+       , __count(rhs.__count)
+       , __weekStart(rhs.__weekStart)
+       , __dayOfWeek(rhs.__dayOfWeek)
+       , __dayOfMonth(rhs.__dayOfMonth)
+       , __weekOfMonth(rhs.__weekOfMonth)
+       , __monthOfYear(rhs.__monthOfYear)
+       , __pExceptionDates(null)
+{
+       std::unique_ptr<DateTime> pUntil;
+
+       if (rhs.__pUntil != null)
+       {
+               pUntil = std::unique_ptr<DateTime>(new (std::nothrow) DateTime(*rhs.__pUntil));
+               SysTryReturnVoidResult(NID_SCL, pUntil != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pExceptionDates(new (std::nothrow) ArrayList());
+       SysTryReturnVoidResult(NID_SCL, pExceptionDates, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pExceptionDates->Construct();
+       SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Propagating.", GetErrorMessage(r));
+
+       if (rhs.__pExceptionDates != null)
+       {
+               DateTime* pTmpExDate = null;
+               std::unique_ptr<IEnumerator> pEnum(rhs.__pExceptionDates->GetEnumeratorN());
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       pTmpExDate = static_cast<DateTime*>(pEnum->GetCurrent());
+                       pExceptionDates->Add(*(new (std::nothrow) DateTime(*pTmpExDate)));
+               }
+       }
+
+       __pExceptionDates = std::move(pExceptionDates);
+       __pUntil = std::move(pUntil);
+}
+
+_RecurrenceImpl::~_RecurrenceImpl(void)
+{
+}
+
+_RecurrenceImpl&
+_RecurrenceImpl::operator =(const _RecurrenceImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       std::unique_ptr<DateTime> pUntil;
+
+       __type = rhs.__type;
+       __interval = rhs.__interval;
+       __count = rhs.__count;
+       __weekStart = rhs.__weekStart;
+       __dayOfWeek = rhs.__dayOfWeek;
+       __dayOfMonth = rhs.__dayOfMonth;
+       __weekOfMonth = rhs.__weekOfMonth;
+       __monthOfYear = rhs.__monthOfYear;
+
+       if (rhs.__pUntil != null)
+       {
+               pUntil.reset(new (std::nothrow) DateTime(*(rhs.__pUntil)));
+               SysTryReturn(NID_SCL, pUntil != null, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       if (__pExceptionDates != null && rhs.__pExceptionDates != null)
+       {
+               __pExceptionDates->RemoveAll(true);
+
+               DateTime* pTmpExDate = null;
+               std::unique_ptr<IEnumerator> pEnum(rhs.__pExceptionDates->GetEnumeratorN());
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       pTmpExDate = static_cast<DateTime*>(pEnum->GetCurrent());
+
+                       if (pTmpExDate != null)
+                       {
+                               __pExceptionDates->Add(new (std::nothrow) DateTime(*pTmpExDate));
+                       }
+               }
+       }
+
+       __pUntil = std::move(pUntil);
+
+       return *this;
+}
+
+bool
+_RecurrenceImpl::Equals(const Object& rhs) const
+{
+       const _RecurrenceImpl* pRecurrenceImpl = dynamic_cast<const _RecurrenceImpl*>(&rhs);
+
+       if (pRecurrenceImpl == null)
+       {
+               return false;
+       }
+
+       return (__type == pRecurrenceImpl->__type && __interval == pRecurrenceImpl->__interval
+                       && __count == pRecurrenceImpl->__count && __weekStart == pRecurrenceImpl->__weekStart
+                       && __dayOfWeek == pRecurrenceImpl->__dayOfWeek && __dayOfMonth == pRecurrenceImpl->__dayOfMonth
+                       && __weekOfMonth == pRecurrenceImpl->__weekOfMonth && __monthOfYear == pRecurrenceImpl->__monthOfYear);
+}
+
+int
+_RecurrenceImpl::GetHashCode(void) const
+{
+       int hashCode = 17;
+
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __type;
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __interval;
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __count;
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __weekStart;
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __dayOfWeek;
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __dayOfMonth;
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __weekOfMonth;
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __monthOfYear;
+
+       DateTime* pTmpExDate = null;
+       std::unique_ptr<IEnumerator> pEnum(__pExceptionDates->GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pTmpExDate = static_cast<DateTime*>(pEnum->GetCurrent());
+               hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pTmpExDate->GetHashCode();
+       }
+
+       return hashCode;
+}
+
+RecurFrequency
+_RecurrenceImpl::GetFrequency(void) const
+{
+       return __type;
+}
+
+int
+_RecurrenceImpl::GetInterval(void) const
+{
+       return __interval;
+}
+
+const DateTime*
+_RecurrenceImpl::GetUntil(void) const
+{
+       return __pUntil.get();
+}
+
+int
+_RecurrenceImpl::GetCounts(void) const
+{
+       return __count;
+}
+
+CalDayOfWeek
+_RecurrenceImpl::GetWeekStart(void) const
+{
+       return __weekStart;
+}
+
+int
+_RecurrenceImpl::GetDayOfWeek(void) const
+{
+       return __dayOfWeek;
+}
+
+int
+_RecurrenceImpl::GetDayOfMonth(void) const
+{
+       return __dayOfMonth;
+}
+
+int
+_RecurrenceImpl::GetWeekOfMonth(void) const
+{
+       return __weekOfMonth;
+}
+
+int
+_RecurrenceImpl::GetMonthOfYear(void)const
+{
+       return __monthOfYear;
+}
+
+void
+_RecurrenceImpl::SetFrequency(RecurFrequency type)
+{
+       __type = type;
+
+       // reset all properties
+       if (__pUntil != null)
+       {
+               __pUntil.reset();
+       }
+
+       __dayOfWeek = 0;
+       __dayOfMonth = 0;
+       __weekOfMonth = 0;
+       __monthOfYear = 0;
+       __interval = _DEFAULT_INTERVAL;
+       __count = _DEFAULT_COUNT;
+       __weekStart = _DEFAULT_WEEK_START;
+
+       __pExceptionDates->RemoveAll(true);
+}
+
+result
+_RecurrenceImpl::SetInterval(int interval)
+{
+       SysTryReturnResult(NID_SCL, interval >= _MIN_RECURRENCE_INTERVAL, E_INVALID_ARG, "Invalid argument is used. The interval is less than 1");
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               SysTryReturnResult(NID_SCL, interval <= MAX_RECURRENCE_INTERVAL_VALUE, E_INVALID_ARG
+                               , "The inverval exceeds MAX_RECURRENCE_INTERVAL_VALUE");
+       }
+
+       __interval = interval;
+
+       // reset exception dates
+       __pExceptionDates->RemoveAll(true);
+
+       return E_SUCCESS;
+}
+
+result
+_RecurrenceImpl::SetUntil(const DateTime* pUntil)
+{
+       if (pUntil != null)
+       {
+               SysTryReturnResult(NID_SCL, (_CalendarbookUtil::CheckValidDateTime(*pUntil) == true) || (*pUntil == DateTime::GetMaxValue()), E_INVALID_ARG, "Invalid argument is used. The until date is invalid.");
+
+               __pUntil.reset(new (std::nothrow) DateTime(*pUntil));
+               if (__pUntil == null)
+               {
+                       SysLogException(NID_SCL, E_OUT_OF_MEMORY, "Memory allocation failed.");
+                       return E_OUT_OF_MEMORY;
+               }
+
+               // reset count
+               __count = 0;
+       }
+       else
+       {
+               __pUntil.reset();
+               __count = _DEFAULT_COUNT;
+       }
+
+       // reset exception dates
+       __pExceptionDates->RemoveAll(true);
+
+       return E_SUCCESS;
+}
+
+result
+_RecurrenceImpl::SetCounts(int count)
+{
+       SysTryReturnResult(NID_SCL, count >= 0, E_INVALID_ARG, "Invalid argument is used. The count is less than 0");
+
+       __count = count;
+
+       // reset until
+       if (__pUntil != null)
+       {
+               __pUntil.release();
+       }
+
+       // reset exception dates
+       __pExceptionDates->RemoveAll(true);
+
+       return E_SUCCESS;
+}
+
+result
+_RecurrenceImpl::SetWeekStart(CalDayOfWeek weekStart)
+{
+       SysTryReturnResult(NID_SCL, weekStart == CAL_SUNDAY || weekStart == CAL_MONDAY, E_INVALID_ARG,
+                       "Invalid argument is used. weekStart = %d", weekStart);
+
+       __weekStart = weekStart;
+
+       // reset exception dates
+       __pExceptionDates->RemoveAll(true);
+
+       return E_SUCCESS;
+}
+
+result
+_RecurrenceImpl::SetDayOfWeek(int day)
+{
+       SysTryReturnResult(NID_SCL, __type != FREQ_DAILY, E_TYPE_MISMATCH,
+                               "The frequency type is daily. It should be WEEKLY ,MOTHLY or YEARLY");
+       SysTryReturnResult(NID_SCL, day >= CAL_SUNDAY, E_INVALID_ARG, "Invalid argument is used. The day(%d) is less than min value.", day);
+       SysTryReturnResult(NID_SCL, day <= _MAX_DAY_OF_WEEK, E_INVALID_ARG, "Invalid argument is used. The day(%d) exceeds max value.", day);
+
+       __dayOfWeek = day;
+
+       // reset day of month
+       __dayOfMonth = 0;
+
+       // reset exception dates
+       __pExceptionDates->RemoveAll(true);
+
+       return E_SUCCESS;
+}
+
+result
+_RecurrenceImpl::SetDayOfMonth(int day)
+{
+       SysTryReturnResult(NID_SCL, __type != FREQ_DAILY, E_TYPE_MISMATCH, "The frequency is daily.");
+       SysTryReturnResult(NID_SCL, __type != FREQ_WEEKLY, E_TYPE_MISMATCH, "The frequency is weekly.");
+       SysTryReturnResult(NID_SCL, day >= _DAY_ONE, E_INVALID_ARG, "Invalid argument is used. The day is less than 1");
+       SysTryReturnResult(NID_SCL, day <= _DAY_THIRTY_ONE, E_INVALID_ARG, "Invalid argument is used. The day is greater than 31");
+
+       __dayOfMonth = day;
+
+       // reset day of week and week of month
+       __dayOfWeek = 0;
+       __weekOfMonth = 0;
+
+       // reset exception dates
+       __pExceptionDates->RemoveAll(true);
+
+       return E_SUCCESS;
+}
+
+result
+_RecurrenceImpl::SetWeekOfMonth(int week)
+{
+       SysTryReturnResult(NID_SCL, __type != FREQ_DAILY, E_TYPE_MISMATCH, "The frequency is daily.");
+       SysTryReturnResult(NID_SCL, __type != FREQ_WEEKLY, E_TYPE_MISMATCH, "The frequency is weekly.");
+       SysTryReturnResult(NID_SCL, week >= _WEEK_ONE, E_INVALID_ARG, "Invalid argument is used. The week (%d) is less than 1.", week);
+       SysTryReturnResult(NID_SCL, week <= _WEEK_FIVE, E_INVALID_ARG, "Invalid argument is used. The week (%d) is greater than 5.", week);
+
+       __weekOfMonth = week;
+
+       // reset day of month
+       __dayOfMonth = 0;
+
+       // reset exception dates
+       __pExceptionDates->RemoveAll(true);
+
+       return E_SUCCESS;
+}
+
+
+result
+_RecurrenceImpl::SetMonthOfYear(int month)
+{
+       SysTryReturnResult(NID_SCL, __type != FREQ_DAILY, E_TYPE_MISMATCH, "The frequency is daily.");
+       SysTryReturnResult(NID_SCL, __type != FREQ_WEEKLY, E_TYPE_MISMATCH, "The frequency is weekly.");
+       SysTryReturnResult(NID_SCL, __type != FREQ_MONTHLY, E_TYPE_MISMATCH, "The frequency is monthly.");
+       SysTryReturnResult(NID_SCL, month >= _MONTH_ONE, E_INVALID_ARG, "Invalid argument is used. The month (%d) is less than 1 ", month);
+       SysTryReturnResult(NID_SCL, month <= _MONTH_TWELVE, E_INVALID_ARG, "Invalid argument is used. The month (%d) is greater than 12", month);
+
+       __monthOfYear = month;
+
+       // reset exception dates
+       __pExceptionDates->RemoveAll(true);
+
+       return E_SUCCESS;
+}
+
+result
+_RecurrenceImpl::AddExceptionDate(const DateTime& exceptionDate)
+{
+       SysTryReturnResult(NID_SCL, exceptionDate >= _CalendarbookImpl::GetMinDateTime() &&
+                       exceptionDate <= _CalendarbookImpl::GetMaxDateTime(), E_INVALID_ARG, "Invalid argument is used. exceptionDate = %S", exceptionDate.ToString().GetPointer());
+
+       bool alreadyExist = false;
+
+       DateTime* pTmpExDate = null;
+       std::unique_ptr<IEnumerator> pEnum(__pExceptionDates->GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pTmpExDate = static_cast<DateTime*>(pEnum->GetCurrent());
+               if (*pTmpExDate == exceptionDate)
+               {
+                       alreadyExist = true;
+                       break;
+               }
+       }
+
+       SysTryReturnResult(NID_SCL, !alreadyExist, E_OBJ_ALREADY_EXIST, "The exceptionDate already exists");
+
+       std::unique_ptr<DateTime> pExDate(new (std::nothrow) DateTime(exceptionDate));
+       SysTryReturnResult(NID_SCL, pExDate != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       result r = __pExceptionDates->Add(pExDate.get());
+       SysTryReturnResult(NID_SCL, !IsFailed(r), E_INVALID_ARG, "Propagating.");
+
+       pExDate.release();
+
+       return E_SUCCESS;
+}
+
+IList*
+_RecurrenceImpl::GetExceptionDatesN(void) const
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       r = pList->Construct();
+       SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       DateTime* pExDate = null;
+       DateTime* pTmpExDate = null;
+       std::unique_ptr<IEnumerator> pEnum(__pExceptionDates->GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pExDate = static_cast<DateTime*>(pEnum->GetCurrent());
+               if (pExDate)
+               {
+                       pTmpExDate = new (std::nothrow) DateTime(*pExDate);
+                       SysTryReturn(NID_SCL, pTmpExDate != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+                       pList->Add(pTmpExDate);
+               }
+       }
+
+       return pList.release();
+}
+
+_RecurrenceImpl*
+_RecurrenceImpl::GetInstance(Recurrence& recurrence)
+{
+       return recurrence.__pRecurrenceImpl;
+}
+
+const _RecurrenceImpl*
+_RecurrenceImpl::GetInstance(const Recurrence& recurrence)
+{
+       return recurrence.__pRecurrenceImpl;
+}
+
+}}     // Tizen::Social
diff --git a/src/FScl_RelationshipImpl.cpp b/src/FScl_RelationshipImpl.cpp
new file mode 100644 (file)
index 0000000..c447a96
--- /dev/null
@@ -0,0 +1,160 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FScl_RelationshipImpl.cpp
+* @brief       This is the implementation for _RelationshipImpl class.
+*
+* This file contains definitions of @e _RelationshipImpl class.
+*/
+
+#include <FBaseSysLog.h>
+#include <FSclRelationship.h>
+#include "FScl_RelationshipImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+_RelationshipImpl::_RelationshipImpl(void)
+: __type(CONTACT_RELATIONSHIP_TYPE_ASSISTANT)
+{
+}
+
+_RelationshipImpl::_RelationshipImpl(const _RelationshipImpl& rhs)
+{
+       __name = rhs.__name;
+       __type = rhs.__type;
+       __label = rhs.__label;
+}
+
+_RelationshipImpl::~_RelationshipImpl(void)
+{
+
+}
+
+_RelationshipImpl&
+_RelationshipImpl::operator =(const _RelationshipImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __name = rhs.__name;
+       __type = rhs.__type;
+       __label = rhs.__label;
+
+       return *this;
+}
+
+bool
+_RelationshipImpl::operator ==(const _RelationshipImpl& rhs) const
+{
+       if (__name != rhs.__name)
+       {
+               return false;
+       }
+
+       if (__type != rhs.__type)
+       {
+               return false;
+       }
+
+       if (__label != rhs.__label)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+bool
+_RelationshipImpl::operator !=(const _RelationshipImpl& rhs) const
+{
+       return !(*this == rhs);
+}
+
+bool
+_RelationshipImpl::Equals(const Object& rhs) const
+{
+       const _RelationshipImpl* pRelationship= dynamic_cast<const _RelationshipImpl*>(&rhs);
+       if (pRelationship == null)
+       {
+               return false;
+       }
+
+       return *this == *pRelationship;
+}
+
+int
+_RelationshipImpl::GetHashCode(void) const
+{
+       int hash = __name.GetHashCode() + __label.GetHashCode() + __type;
+
+       return hash;
+}
+
+RelationshipType
+_RelationshipImpl::GetType(void) const
+{
+       return __type;
+}
+
+String
+_RelationshipImpl::GetRelativeName(void) const
+{
+       return __name;
+}
+
+String
+_RelationshipImpl::GetLabel(void) const
+{
+       return __label;
+}
+
+void
+_RelationshipImpl::SetType(RelationshipType type)
+{
+       __type = type;
+}
+
+void
+_RelationshipImpl::SetRelativeName(const String& name)
+{
+       __name = name;
+}
+
+void
+_RelationshipImpl::SetLabel(const String& label)
+{
+       __label = label;
+}
+
+const _RelationshipImpl*
+_RelationshipImpl::GetInstance(const Relationship& relationship)
+{
+       return relationship.__pRelationshipImpl;
+}
+
+_RelationshipImpl*
+_RelationshipImpl::GetInstance(Relationship& relationship)
+{
+       return relationship.__pRelationshipImpl;
+}
+
+
+}} // Tizen::Social
diff --git a/src/FScl_RelationshipImpl.h b/src/FScl_RelationshipImpl.h
new file mode 100644 (file)
index 0000000..2df8017
--- /dev/null
@@ -0,0 +1,77 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FScl_RelationshipImpl.h
+* @brief       This is the header file for the %_RelationshipImpl class.
+*
+* This header file contains the declarations of the %_RelationshipImpl class.
+*/
+#ifndef _FSCL_INTERNAL_RELATIONSHIP_IMPL_H_
+#define _FSCL_INTERNAL_RELATIONSHIP_IMPL_H_
+
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+
+class _OSP_EXPORT_ _RelationshipImpl
+       : public Tizen::Base::Object
+{
+public:
+       _RelationshipImpl(void);
+
+       _RelationshipImpl(const _RelationshipImpl& rhs);
+
+       virtual ~_RelationshipImpl(void);
+
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       virtual int GetHashCode(void) const;
+
+       RelationshipType GetType(void) const;
+
+       Tizen::Base::String GetRelativeName(void) const;
+
+       Tizen::Base::String GetLabel(void) const;
+
+       void SetType(RelationshipType type);
+
+       void SetLabel(const Tizen::Base::String& label);
+
+       void SetRelativeName(const Tizen::Base::String& relativeName);
+
+       _RelationshipImpl& operator =(const _RelationshipImpl& rhs);
+
+       bool operator ==(const _RelationshipImpl& rhs) const;
+
+       bool operator !=(const _RelationshipImpl& rhs) const;
+
+       static const _RelationshipImpl* GetInstance(const Relationship& relationship);
+
+       static _RelationshipImpl* GetInstance(Relationship& relationship);
+
+private:
+       RelationshipType __type;
+       Tizen::Base::String __label;
+       Tizen::Base::String __name;
+}; // _RelationshipImpl
+
+}} // Tizen::Social
+
+#endif // _FSCL_INTERNAL_RELATIONSHIP_IMPL_H_
diff --git a/src/FScl_ReminderImpl.cpp b/src/FScl_ReminderImpl.cpp
new file mode 100644 (file)
index 0000000..d764b3c
--- /dev/null
@@ -0,0 +1,122 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_ReminderImpl.cpp
+ * @brief              This is the implementation for _ReminderImpl class.
+ *
+ * This file contains definitions of @e _ReminderImpl class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FBaseDateTime.h>
+#include <FSclReminder.h>
+#include "FScl_CalendarbookUtil.h"
+#include "FScl_ReminderImpl.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+_ReminderImpl::_ReminderImpl(void)
+{
+}
+
+_ReminderImpl::_ReminderImpl(const _ReminderImpl& rhs)
+       : __absoluteTime(rhs.__absoluteTime)
+       , __isAbsolute(false)
+{
+}
+
+_ReminderImpl::~_ReminderImpl(void)
+{
+}
+
+_ReminderImpl&
+_ReminderImpl::operator =(const _ReminderImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __absoluteTime = rhs.__absoluteTime;
+       __isAbsolute = rhs.__isAbsolute;
+
+       return *this;
+}
+
+bool
+_ReminderImpl::Equals(const Object& rhs) const
+{
+       const _ReminderImpl* pReminderImpl = dynamic_cast<const _ReminderImpl*>(&rhs);
+
+       if (pReminderImpl == null)
+       {
+               return false;
+       }
+
+       return (__absoluteTime.Equals(pReminderImpl->__absoluteTime) && __isAbsolute == pReminderImpl->__isAbsolute);
+}
+
+int
+_ReminderImpl::GetHashCode(void) const
+{
+       int hashCode = 17;
+
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __absoluteTime.GetHashCode();
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __isAbsolute;
+
+       return hashCode;
+}
+
+result
+_ReminderImpl::SetAbsoluteTime(const DateTime& time)
+{
+       SysTryReturnResult(NID_SCL, _CalendarbookUtil::CheckValidDateTime(time), E_INVALID_ARG, "Invalid argument is used. time = %S", time.ToString().GetPointer());
+
+       __absoluteTime = time;
+       __isAbsolute = true;
+
+       return E_SUCCESS;
+}
+
+DateTime
+_ReminderImpl::GetAbsoluteTime(void) const
+{
+       return __absoluteTime;
+}
+
+bool
+_ReminderImpl::IsAbsolute(void) const
+{
+       return __isAbsolute;
+}
+
+_ReminderImpl*
+_ReminderImpl::GetInstance(Reminder& reminder)
+{
+       return reminder.__pReminderImpl;
+}
+
+const _ReminderImpl*
+_ReminderImpl::GetInstance(const Reminder& reminder)
+{
+       return reminder.__pReminderImpl;
+}
+
+}}     // Tizen::Social
diff --git a/src/FScl_UrlImpl.cpp b/src/FScl_UrlImpl.cpp
new file mode 100644 (file)
index 0000000..471e02e
--- /dev/null
@@ -0,0 +1,169 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_UrlImpl.cpp
+ * @brief              This is the implementation for _UrlImpl class.
+ *
+ * This file contains definitions of @e _UrlImpl class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FSclUrl.h>
+#include <FApp_AppInfo.h>
+#include "FScl_UrlImpl.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Social
+{
+
+_UrlImpl::_UrlImpl(void)
+       : __type(URL_TYPE_PERSONAL)
+{
+       //empty body
+}
+
+_UrlImpl::_UrlImpl(UrlType type, const String& url)
+       : __type(type)
+       , __url(url)
+{
+
+}
+
+_UrlImpl::_UrlImpl(const _UrlImpl& rhs)
+{
+       __type = rhs.__type;
+       __label = rhs.__label;
+       __url = rhs.__url;
+}
+
+_UrlImpl::~_UrlImpl(void)
+{
+       // empty body.
+}
+
+_UrlImpl&
+_UrlImpl::operator =(const _UrlImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __type = rhs.__type;
+       __label = rhs.__label;
+       __url = rhs.__url;
+
+       return *this;
+}
+
+bool
+_UrlImpl::operator ==(const _UrlImpl& rhs) const
+{
+       if (__type == rhs.__type && __label == rhs.__label && __url == rhs.__url)
+       {
+               return true;
+       }
+
+       return false;
+}
+
+bool
+_UrlImpl::operator !=(const _UrlImpl& rhs) const
+{
+       return !(*this == rhs);
+}
+
+bool
+_UrlImpl::Equals(const Object& rhs) const
+{
+       const _UrlImpl* pUrl = dynamic_cast<const _UrlImpl*>(&rhs);
+
+       if (pUrl == null)
+       {
+               return false;
+       }
+
+       return (*this == *pUrl);
+}
+
+int
+_UrlImpl::GetHashCode(void) const
+{
+       int hashCode = 0;
+
+       hashCode = __type;
+       hashCode += __label.GetHashCode();
+       hashCode += __url.GetHashCode();
+
+       return hashCode;
+}
+
+UrlType
+_UrlImpl::GetType(void) const
+{
+       return __type;
+}
+
+String
+_UrlImpl::GetUrl(void) const
+{
+       return __url;
+}
+
+void
+_UrlImpl::SetType(UrlType type)
+{
+       __type = type;
+}
+
+result
+_UrlImpl::SetUrl(const String& url)
+{
+       SysTryReturn(NID_SCL,  !url.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The url is empty", GetErrorMessage(E_INVALID_ARG));
+
+       __url = url;
+
+       return E_SUCCESS;
+}
+
+String
+_UrlImpl::GetLabel(void) const
+{
+       return __label;
+}
+
+void
+_UrlImpl::SetLabel(const String& label)
+{
+       __label = label;
+}
+
+const _UrlImpl*
+_UrlImpl::GetInstance(const Url& url)
+{
+       return url.__pUrlImpl;
+}
+
+_UrlImpl*
+_UrlImpl::GetInstance(Url& url)
+{
+       return url.__pUrlImpl;
+}
+
+
+}} // Tizen::Social
diff --git a/src/FScl_UrlImpl.h b/src/FScl_UrlImpl.h
new file mode 100644 (file)
index 0000000..e78de25
--- /dev/null
@@ -0,0 +1,81 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FScl_UrlImpl.h
+* @brief       This is the header file for the %_UrlImpl class.
+*
+* This header file contains the declarations of the %_UrlImpl class.
+*/
+#ifndef _FSCL_INTERNAL_URL_IMPL_H_
+#define _FSCL_INTERNAL_URL_IMPL_H_
+
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+
+class Url;
+
+class _OSP_EXPORT_ _UrlImpl
+       : public Tizen::Base::Object
+{
+public:
+       _UrlImpl(void);
+
+       _UrlImpl(UrlType type, const Tizen::Base::String& url);
+
+       _UrlImpl(const _UrlImpl& rhs);
+
+       virtual ~_UrlImpl(void);
+
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       virtual int GetHashCode(void) const;
+
+       UrlType GetType(void) const;
+
+       Tizen::Base::String GetLabel(void) const;
+
+       void SetLabel(const Tizen::Base::String& label);
+
+       Tizen::Base::String GetUrl(void) const;
+
+       void SetType(UrlType type);
+
+       result SetUrl(const Tizen::Base::String& url);
+
+       static const _UrlImpl* GetInstance(const Url& url);
+
+       static _UrlImpl* GetInstance(Url& url);
+
+       _UrlImpl& operator =(const _UrlImpl& rhs);
+
+       bool operator ==(const _UrlImpl& rhs) const;
+
+       bool operator !=(const _UrlImpl& rhs) const;
+
+private:
+       UrlType __type;
+       Tizen::Base::String __label;
+       Tizen::Base::String __url;
+}; // _UrlImpl
+
+}} // Tizen::Social
+
+#endif // _FSCL_INTERNAL_URL_IMPL_H_
diff --git a/src/FScl_UserProfileImpl.cpp b/src/FScl_UserProfileImpl.cpp
new file mode 100644 (file)
index 0000000..a3a5e2e
--- /dev/null
@@ -0,0 +1,3559 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_UserProfileImpl.cpp
+ * @brief              This is the implementation for _UserProfileImpl class.
+ *
+ * This file contains definitions of _UserProfileImpl class.
+ */
+#include <FBaseString.h>
+#include <FBaseColArrayList.h>
+#include <FBaseSysLog.h>
+#include <FIoFile.h>
+#include <FMediaImage.h>
+#include <FSclAddress.h>
+#include <FSclPhoneNumber.h>
+#include <FSclEmail.h>
+#include <FSclUrl.h>
+#include <FSclImAddress.h>
+#include <FSclOrganization.h>
+#include <FSclContactEvent.h>
+#include <FSclRelationship.h>
+#include <FSclContact.h>
+#include <FSclUserProfile.h>
+#include <FBase_StringConverter.h>
+#include "FScl_ContactDbConnector.h"
+#include "FScl_PhoneNumberImpl.h"
+#include "FScl_AddressbookUtil.h"
+#include "FScl_UrlImpl.h"
+#include "FScl_EmailImpl.h"
+#include "FScl_AddressImpl.h"
+#include "FScl_ImAddressImpl.h"
+#include "FScl_UserProfileImpl.h"
+#include "FScl_OrganizationImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Graphics;
+using namespace Tizen::Media;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Social
+{
+
+const int __CONTACT_MOD_YEAR = 10000;
+const int __CONTACT_MOD_MONTH = 100;
+
+#define __CONVERT_DATE_TO_DATETIME(date, dateTime)             \
+       do                                                      \
+       {                                                       \
+               int temp = date;                                \
+               int year = 0;                                   \
+               int month = 0;                                  \
+               int day = 0;                                    \
+               year = temp/__CONTACT_MOD_YEAR;                 \
+               temp -= year*__CONTACT_MOD_YEAR;                \
+               month = temp/__CONTACT_MOD_MONTH;               \
+               day = temp - month*__CONTACT_MOD_MONTH;         \
+               dateTime.SetValue(year, month, day, 0, 0, 0);   \
+       }while(0)
+
+_UserProfileImpl::_UserProfileImpl(void)
+       : __profileHandle(null)
+{
+       contacts_record_h profileHandle = null;
+
+       _AddressbookUtil::InitContactViews();
+
+       int ret = contacts_record_create(_contacts_my_profile._uri, &profileHandle);
+       SysTryReturnVoidResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __profileHandle = profileHandle;
+}
+
+_UserProfileImpl::_UserProfileImpl(const _UserProfileImpl& rhs)
+       : __profileHandle(null)
+{
+       contacts_record_h profileHandle = null;
+
+       _AddressbookUtil::InitContactViews();
+
+       int ret = contacts_record_clone(rhs.__profileHandle, &profileHandle);
+       SysTryReturnVoidResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __profileHandle = profileHandle;
+}
+
+_UserProfileImpl::~_UserProfileImpl(void)
+{
+       if (__profileHandle != null)
+       {
+               contacts_record_destroy(__profileHandle, true);
+       }
+}
+
+_UserProfileImpl&
+_UserProfileImpl::operator =(const _UserProfileImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       contacts_record_h profileHandle = null;
+
+       int ret = contacts_record_clone(rhs.__profileHandle, &profileHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_destroy(__profileHandle, true);
+       __profileHandle = profileHandle;
+
+       //__isRemoved = rhs.__isRemoved;
+
+       return *this;
+}
+
+bool
+_UserProfileImpl::Equals(const Object& rhs) const
+{
+       const _UserProfileImpl* pRhs = dynamic_cast<const _UserProfileImpl*>(&rhs);
+
+       if (pRhs == null)
+       {
+               return false;
+       }
+
+       //compare single value properties
+       if (this->GetValue(USER_PROFILE_PROPERTY_ID_FIRST_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_FIRST_NAME))
+       {
+               return false;
+       }
+
+       if (this->GetValue(USER_PROFILE_PROPERTY_ID_LAST_NAME) !=  pRhs->GetValue(USER_PROFILE_PROPERTY_ID_LAST_NAME))
+       {
+               return false;
+       }
+
+       if (this->GetValue(USER_PROFILE_PROPERTY_ID_MIDDLE_NAME) !=  pRhs->GetValue(USER_PROFILE_PROPERTY_ID_MIDDLE_NAME))
+       {
+               return false;
+       }
+
+       if (this->GetValue(USER_PROFILE_PROPERTY_ID_NAME_PREFIX) !=  pRhs->GetValue(USER_PROFILE_PROPERTY_ID_NAME_PREFIX))
+       {
+               return false;
+       }
+
+       if (this->GetValue(USER_PROFILE_PROPERTY_ID_NAME_SUFFIX) !=  pRhs->GetValue(USER_PROFILE_PROPERTY_ID_NAME_SUFFIX))
+       {
+               return false;
+       }
+
+       if (this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME) !=  pRhs->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME))
+       {
+               return false;
+       }
+
+       if (this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME) !=  pRhs->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME))
+       {
+               return false;
+       }
+
+       if (this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME) !=  pRhs->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME))
+       {
+               return false;
+       }
+
+       //compare multivalue properties
+       std::unique_ptr<ArrayList, AllElementsDeleter> pCurrentObjectList(null);
+       std::unique_ptr<ArrayList, AllElementsDeleter> pRhsObjectList(null);
+
+       pCurrentObjectList = std::unique_ptr<ArrayList, AllElementsDeleter> (static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS)));
+       pRhsObjectList = std::unique_ptr<ArrayList, AllElementsDeleter> (static_cast<ArrayList*>(pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS)));
+
+       if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
+       {
+               return false;
+       }
+
+       pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_EMAILS))));
+       pRhsObjectList.reset((static_cast<ArrayList*>(pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_EMAILS))));
+
+       if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
+       {
+               return false;
+       }
+
+       pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_URLS))));
+       pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_URLS))));
+
+       if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
+       {
+               return false;
+       }
+
+       pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_ADDRESSES))));
+       pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_ADDRESSES))));
+
+       if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
+       {
+               return false;
+       }
+
+       pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_IMADDRESSES))));
+       pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_IMADDRESSES))));
+
+       if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
+       {
+               return false;
+       }
+
+       pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_EVENTS))));
+       pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_EVENTS))));
+
+       if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
+       {
+               return false;
+       }
+
+       pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS))));
+       pRhsObjectList.reset((static_cast<ArrayList*>(pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS))));
+
+       if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
+       {
+               return false;
+       }
+
+       pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_NOTES))));
+       pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_NOTES))));
+
+       if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
+       {
+               return false;
+       }
+
+       pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_NICKNAMES))));
+       pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_NICKNAMES))));
+
+       if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
+       {
+               return false;
+       }
+
+       pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS))));
+       pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS))));
+
+       if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
+       {
+               return false;
+       }
+
+       return true;
+}
+
+int
+_UserProfileImpl::GetHashCode(void) const
+{
+       int hashCode = 17;
+       std::unique_ptr<IList, AllElementsDeleter> pMultiPropertyList(null);
+
+       //calculate single value properties
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_FIRST_NAME).GetHashCode();
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_LAST_NAME).GetHashCode();
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_MIDDLE_NAME).GetHashCode();
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_NAME_PREFIX).GetHashCode();
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_NAME_SUFFIX).GetHashCode();
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME).GetHashCode();
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME).GetHashCode();
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME).GetHashCode();
+       hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetThumbnailPath().GetHashCode();
+
+       //calculate multi value properties
+       PhoneNumber* pPhoneNumber = null;
+       pMultiPropertyList = std::unique_ptr<IList, AllElementsDeleter> (this->GetValuesN(USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS));
+       std::unique_ptr<IEnumerator> pEnum(pMultiPropertyList->GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pPhoneNumber = static_cast<PhoneNumber*>(pEnum->GetCurrent());
+               hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pPhoneNumber->GetHashCode();
+       }
+
+       Email* pEmail = null;
+       pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_EMAILS));
+       pEnum.reset(pMultiPropertyList->GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pEmail = static_cast<Email*>(pEnum->GetCurrent());
+               hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pEmail->GetHashCode();
+       }
+
+       Url* pUrl = null;
+       pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_URLS));
+       pEnum.reset(pMultiPropertyList->GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pUrl = static_cast<Url*>(pEnum->GetCurrent());
+               hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pUrl->GetHashCode();
+       }
+
+       Address* pAddress = null;
+       pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_ADDRESSES));
+       pEnum.reset(pMultiPropertyList->GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pAddress = static_cast<Address*>(pEnum->GetCurrent());
+               hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pAddress->GetHashCode();
+       }
+
+       ImAddress* pImAddress = null;
+       pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_IMADDRESSES));
+       pEnum.reset(pMultiPropertyList->GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pImAddress = static_cast<ImAddress*>(pEnum->GetCurrent());
+               hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pImAddress->GetHashCode();
+       }
+
+       ContactEvent* pEvent = null;
+       pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_EVENTS));
+       pEnum.reset(pMultiPropertyList->GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pEvent = static_cast<ContactEvent*>(pEnum->GetCurrent());
+               hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pEvent->GetHashCode();
+       }
+
+       Organization* pOrganization = null;
+       pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS));
+       pEnum.reset(pMultiPropertyList->GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pOrganization = static_cast<Organization*>(pEnum->GetCurrent());
+               hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pOrganization->GetHashCode();
+       }
+
+       String* pNote = null;
+       pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_NOTES));
+       pEnum.reset(pMultiPropertyList->GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pNote = static_cast<String*>(pEnum->GetCurrent());
+               hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pNote->GetHashCode();
+       }
+
+       String* pNickname = null;
+       pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_NICKNAMES));
+       pEnum.reset(pMultiPropertyList->GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pNickname = static_cast<String*>(pEnum->GetCurrent());
+               hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pNickname->GetHashCode();
+       }
+
+       Relationship* pRelationship = null;
+       pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS));
+       pEnum.reset(pMultiPropertyList->GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pRelationship = static_cast<Relationship*>(pEnum->GetCurrent());
+               hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pRelationship->GetHashCode();
+       }
+
+       return hashCode;
+}
+
+String
+_UserProfileImpl::GetThumbnailPath(void) const
+{
+       unsigned int count = 0;
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.image, &count);
+       if (count == 0)
+       {
+               return String(L"");
+       }
+
+       char* pCharValue = null;
+       contacts_record_h imageHandle = null;
+
+       contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.image, 0, &imageHandle);
+       contacts_record_get_str_p(imageHandle, _contacts_image.path, &pCharValue);
+
+       return String(pCharValue);
+}
+
+result
+_UserProfileImpl::SetThumbnail(const String& filePath)
+{
+       unsigned int count = 0;
+       contacts_record_h imageHandle = null;
+       int errCode = 0;
+       bool fileExist = true;
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.image, &count);
+       if (count > 0)
+       {
+               errCode = contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.image, 0, &imageHandle);
+               SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
+                                                       "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
+
+               if (!filePath.IsEmpty())
+               {
+                       fileExist = File::IsFileExist(filePath);
+                       SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, E_INVALID_ARG, E_INVALID_ARG,
+                                       "[%s] Invalid file path.", GetErrorMessage(E_INVALID_ARG));
+                       SysTryReturn(NID_SCL, fileExist != false, E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
+                                       "[%s] The specified file is not found.", GetErrorMessage(E_FILE_NOT_FOUND));
+
+                       std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(filePath));
+                       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       errCode = contacts_record_set_str(imageHandle, _contacts_image.path, pCharArray.get());
+                       SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
+                                       "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
+               }
+               else
+               {
+                       errCode = contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.image, imageHandle);
+                       contacts_record_destroy(imageHandle, true);
+                       SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
+                                                               "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
+               }
+       }
+       else
+       {
+               if (!filePath.IsEmpty())
+               {
+                       fileExist = File::IsFileExist(filePath);
+                       SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, E_INVALID_ARG, E_INVALID_ARG,
+                                       "[%s] Invalid file path.", GetErrorMessage(E_INVALID_ARG));
+                       SysTryReturn(NID_SCL, fileExist != false, E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
+                                       "[%s] The specified file is not found.", GetErrorMessage(E_FILE_NOT_FOUND));
+
+                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(filePath));
+                       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       errCode = contacts_record_create(_contacts_image._uri, &imageHandle);
+                       SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       errCode = contacts_record_set_str(imageHandle, _contacts_image.path, pCharArray.get());
+                       SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
+                                       "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
+
+                       errCode = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.image, imageHandle);
+                       SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
+                                       "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
+               }
+       }
+
+       return E_SUCCESS;
+
+}
+
+result
+_UserProfileImpl::SetValue(UserProfilePropertyId id, const String& value)
+{
+       SysTryReturn(NID_SCL, id != USER_PROFILE_PROPERTY_ID_DISPLAY_NAME, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. Display cannot be set using this.", GetErrorMessage(E_INVALID_ARG));
+
+       int ret = CONTACTS_ERROR_NONE;
+       unsigned int count = 0;
+
+       switch (id)
+       {
+       case USER_PROFILE_PROPERTY_ID_FIRST_NAME:
+               {
+                       contacts_record_h nameHandle = null;
+                       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
+
+                       if (count > 0)
+                       {
+                               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
+
+                               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                               contacts_record_set_str(nameHandle, _contacts_name.first, pCharArray.get());
+
+                               if (value.IsEmpty() && IsEmptyName(nameHandle))
+                               {
+                                       contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
+                               }
+                       }
+                       else
+                       {
+                               if (!value.IsEmpty())
+                               {
+                                       ret = contacts_record_create(_contacts_name._uri, &nameHandle);
+                                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                                       contacts_record_set_str(nameHandle, _contacts_name.first, pCharArray.get());
+
+                                       ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                               }
+                       }
+               }
+               break;
+
+       case USER_PROFILE_PROPERTY_ID_MIDDLE_NAME:
+               {
+                       contacts_record_h nameHandle = null;
+                       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
+
+                       if (count > 0)
+                       {
+                               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
+
+                               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                               ret = contacts_record_set_str(nameHandle, _contacts_name.addition, pCharArray.get());
+
+                               if (value.IsEmpty() && IsEmptyName(nameHandle))
+                               {
+                                       contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
+                               }
+                       }
+                       else
+                       {
+                               if (!value.IsEmpty())
+                               {
+                                       ret = contacts_record_create(_contacts_name._uri, &nameHandle);
+                                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                                       contacts_record_set_str(nameHandle, _contacts_name.addition, pCharArray.get());
+
+                                       contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                               }
+                       }
+
+               }
+
+               break;
+
+       case USER_PROFILE_PROPERTY_ID_LAST_NAME:
+               {
+                       contacts_record_h nameHandle = null;
+                       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
+
+                       if (count > 0)
+                       {
+                               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
+
+                               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                               contacts_record_set_str(nameHandle, _contacts_name.last, pCharArray.get());
+
+                               if (value.IsEmpty() && IsEmptyName(nameHandle))
+                               {
+                                       contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
+                               }
+                       }
+                       else
+                       {
+                               if (!value.IsEmpty())
+                               {
+                                       ret = contacts_record_create(_contacts_name._uri, &nameHandle);
+                                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                                       contacts_record_set_str(nameHandle, _contacts_name.last, pCharArray.get());
+
+                                       contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                               }
+                       }
+
+               }
+
+               break;
+       case USER_PROFILE_PROPERTY_ID_NAME_SUFFIX:
+               {
+                       contacts_record_h nameHandle = null;
+                       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
+
+                       if (count > 0)
+                       {
+                               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
+
+                               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                               contacts_record_set_str(nameHandle, _contacts_name.suffix, pCharArray.get());
+
+                               if (value.IsEmpty() && IsEmptyName(nameHandle))
+                               {
+                                       contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
+                               }
+
+                       }
+                       else
+                       {
+                               if (!value.IsEmpty())
+                               {
+                                       contacts_record_create(_contacts_name._uri, &nameHandle);
+                                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                                       contacts_record_set_str(nameHandle, _contacts_name.suffix, pCharArray.get());
+
+                                       contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                               }
+                       }
+
+               }
+
+               break;
+
+       case USER_PROFILE_PROPERTY_ID_NAME_PREFIX:
+               {
+                       contacts_record_h nameHandle = null;
+                       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
+
+                       if (count > 0)
+                       {
+                               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
+
+                               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                               contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
+
+                               if (value.IsEmpty() && IsEmptyName(nameHandle))
+                               {
+                                       contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
+                               }
+                       }
+                       else
+                       {
+                               if (!value.IsEmpty())
+                               {
+                                       ret = contacts_record_create(_contacts_name._uri, &nameHandle);
+                                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                                       contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
+
+                                       contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                               }
+                       }
+
+               }
+
+               break;
+
+       case USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME:
+               {
+                       contacts_record_h nameHandle = null;
+                       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
+
+                       if (count > 0)
+                       {
+                               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
+
+                               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                               contacts_record_set_str(nameHandle, _contacts_name.phonetic_first, pCharArray.get());
+
+                               if (value.IsEmpty() && IsEmptyName(nameHandle))
+                               {
+                                       contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
+                               }
+                       }
+                       else
+                       {
+                               if (!value.IsEmpty())
+                               {
+                                       ret = contacts_record_create(_contacts_name._uri, &nameHandle);
+                                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                                       contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
+
+                                       contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                               }
+                       }
+
+               }
+
+               break;
+
+       case USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME:
+               {
+                       contacts_record_h nameHandle = null;
+                       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
+
+                       if (count > 0)
+                       {
+                               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
+
+                               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                               contacts_record_set_str(nameHandle, _contacts_name.phonetic_last, pCharArray.get());
+
+                               if (value.IsEmpty() && IsEmptyName(nameHandle))
+                               {
+                                       contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
+                               }
+                       }
+                       else
+                       {
+                               if (!value.IsEmpty())
+                               {
+                                       ret = contacts_record_create(_contacts_name._uri, &nameHandle);
+                                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                                       contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
+
+                                       contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                               }
+                       }
+
+               }
+
+               break;
+
+       case USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
+               {
+                       contacts_record_h nameHandle = null;
+                       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
+
+                       if (count > 0)
+                       {
+                               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
+
+                               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                               contacts_record_set_str(nameHandle, _contacts_name.phonetic_middle, pCharArray.get());
+
+                               if (value.IsEmpty() && IsEmptyName(nameHandle))
+                               {
+                                       contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
+                               }
+                       }
+                       else
+                       {
+                               if (!value.IsEmpty())
+                               {
+                                       ret = contacts_record_create(_contacts_name._uri, &nameHandle);
+                                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
+                                       contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
+
+                                       contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                               }
+                       }
+
+               }
+
+               break;
+
+       default:
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
+               return E_INVALID_ARG;
+       }
+
+       return E_SUCCESS;
+}
+
+String
+_UserProfileImpl::GetValue(UserProfilePropertyId id) const
+{
+       unsigned int count = 0;
+       char* pCharValue = null;
+       String value = "";
+
+       switch (id)
+       {
+       case USER_PROFILE_PROPERTY_ID_FIRST_NAME:
+               {
+                       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_h nameHandle = null;
+
+                               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
+                               contacts_record_get_str_p(nameHandle, _contacts_name.first, &pCharValue);
+                       }
+
+                       value = pCharValue;
+               }
+               break;
+       case USER_PROFILE_PROPERTY_ID_LAST_NAME:
+               {
+                       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_h nameHandle = null;
+
+                               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
+                               contacts_record_get_str_p(nameHandle, _contacts_name.last, &pCharValue);
+                       }
+
+                       value = pCharValue;
+               }
+               break;
+       case USER_PROFILE_PROPERTY_ID_MIDDLE_NAME:
+               {
+                       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_h nameHandle = null;
+
+                               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
+                               contacts_record_get_str_p(nameHandle, _contacts_name.addition, &pCharValue);
+                       }
+
+                       value = pCharValue;
+               }
+               break;
+       case USER_PROFILE_PROPERTY_ID_NAME_PREFIX:
+               {
+                       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_h nameHandle = null;
+
+                               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
+                               contacts_record_get_str_p(nameHandle, _contacts_name.prefix, &pCharValue);
+                       }
+
+                       value = pCharValue;
+               }
+               break;
+       case USER_PROFILE_PROPERTY_ID_NAME_SUFFIX:
+               {
+                       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_h nameHandle = null;
+
+                               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
+                               contacts_record_get_str_p(nameHandle, _contacts_name.suffix, &pCharValue);
+                       }
+
+                       value = pCharValue;
+               }
+               break;
+       case USER_PROFILE_PROPERTY_ID_DISPLAY_NAME:
+                       contacts_record_get_str_p(__profileHandle, _contacts_my_profile.display_name, &pCharValue);
+                       value = pCharValue;
+               break;
+       case USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME:
+               {
+                       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_h nameHandle = null;
+
+                               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
+                               contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_first, &pCharValue);
+                       }
+
+                       value = pCharValue;
+               }
+               break;
+       case USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME:
+               {
+                       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_h nameHandle = null;
+
+                               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
+                               contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_last, &pCharValue);
+                       }
+
+                       value = pCharValue;
+               }
+               break;
+       case USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
+               {
+                       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
+                       if (count > 0)
+                       {
+                               contacts_record_h nameHandle = null;
+
+                               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
+                               contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_middle, &pCharValue);
+                       }
+
+                       value = pCharValue;
+               }
+               break;
+       default:
+               value = String(L"");
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d", GetErrorMessage(E_INVALID_ARG), id);
+               return value;
+       }
+
+       return value;
+}
+
+result
+_UserProfileImpl::SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber)
+{
+       SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
+       SysTryReturn(NID_SCL, !phoneNumber.GetPhoneNumber().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The phoneNumber is string.", GetErrorMessage(E_INVALID_ARG));
+
+       unsigned int count = 0;
+       contacts_record_h recordHandle = null;
+       String stringValue;
+       int type = 0;
+       int oriType = 0;
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.number, &count);
+       SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of phone numbers.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+       contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.number, index, &recordHandle);
+
+       stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetLabel();
+
+       switch (_PhoneNumberImpl::GetInstance(phoneNumber)->GetType())
+       {
+               case PHONENUMBER_TYPE_HOME:
+                       type = CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE;
+                       break;
+               case PHONENUMBER_TYPE_WORK:
+                       type = CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE;
+                       break;
+               case PHONENUMBER_TYPE_MOBILE:
+                       type = CONTACTS_NUMBER_TYPE_CELL;
+                       break;
+               case PHONENUMBER_TYPE_HOME_FAX:
+                       type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME;
+                       break;
+               case PHONENUMBER_TYPE_WORK_FAX:
+                       type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK;
+                       break;
+               case PHONENUMBER_TYPE_PAGER:
+                       type = CONTACTS_NUMBER_TYPE_PAGER;
+                       break;
+               case PHONENUMBER_TYPE_CUSTOM:
+                       type = CONTACTS_NUMBER_TYPE_CUSTOM;
+                       break;
+               case PHONENUMBER_TYPE_ASSISTANT:
+                       type = CONTACTS_NUMBER_TYPE_ASSISTANT;
+                       break;
+               case PHONENUMBER_TYPE_OTHER:
+                       contacts_record_get_int(recordHandle, _contacts_number.type, &oriType);
+
+                       if (oriType == (CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE)
+                               || oriType == (CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE)
+                               || oriType == CONTACTS_NUMBER_TYPE_CELL
+                               || oriType == (CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME)
+                               || oriType == (CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK)
+                               || oriType == CONTACTS_NUMBER_TYPE_PAGER
+                               || oriType == CONTACTS_NUMBER_TYPE_CUSTOM)
+                       {
+                               type = CONTACTS_NUMBER_TYPE_OTHER;
+                       }
+                       else
+                       {
+                               type = oriType;
+                       }
+                       break;
+               default:
+                       type = CONTACTS_NUMBER_TYPE_OTHER;
+                       break;
+       }
+
+       // set type
+       contacts_record_set_int(recordHandle, _contacts_number.type, type);
+
+       // set label
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(recordHandle, _contacts_number.label, pCharArray.get());
+
+       // set phone number
+       stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetPhoneNumber();
+       pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(recordHandle, _contacts_number.number, pCharArray.get());
+
+       return E_SUCCESS;
+
+}
+
+result
+_UserProfileImpl::SetEmailAt(int index, const Email& email)
+{
+       SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
+       SysTryReturn(NID_SCL, !email.GetEmail().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The email is empty.", GetErrorMessage(E_INVALID_ARG));
+
+       unsigned int count = 0;
+       contacts_record_h emailHandle = null;
+       String stringValue;
+       int type = 0;
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.email, &count);
+       SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of emails.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+       contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.email, index, &emailHandle);
+
+       stringValue = _EmailImpl::GetInstance(email)->GetLabel();
+
+       switch (_EmailImpl::GetInstance(email)->GetType())
+       {
+               case EMAIL_TYPE_PERSONAL:
+                       type = CONTACTS_EMAIL_TYPE_HOME;
+                       break;
+               case EMAIL_TYPE_WORK:
+                       type = CONTACTS_EMAIL_TYPE_WORK;
+                       break;
+               case EMAIL_TYPE_CUSTOM:
+                       type = CONTACTS_EMAIL_TYPE_CUSTOM;
+                       break;
+               case EMAIL_TYPE_MOBILE:
+                       type = CONTACTS_EMAIL_TYPE_MOBILE;
+                       break;
+               case EMAIL_TYPE_OTHER:
+                       //fallthrough
+               default:
+                       type = CONTACTS_EMAIL_TYPE_OTHER;
+                       break;
+       }
+
+       // set type
+       contacts_record_set_int(emailHandle, _contacts_email.type, type);
+
+       // set label
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(emailHandle, _contacts_email.label, pCharArray.get());
+
+       // set email
+       stringValue = _EmailImpl::GetInstance(email)->GetEmail();
+       pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(emailHandle, _contacts_email.email, pCharArray.get());
+
+       return E_SUCCESS;
+}
+
+result
+_UserProfileImpl::SetUrlAt(int index, const Url& url)
+{
+       SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
+       SysTryReturn(NID_SCL, !url.GetUrl().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The url is empty.", GetErrorMessage(E_INVALID_ARG));
+       //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unsigned int count = 0;
+       contacts_record_h urlHandle = null;
+       String stringValue;
+       int type = 0;
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.url, &count);
+       SysTryReturn(NID_SCL, count > (unsigned int)index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of urls.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+       contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.url, index, &urlHandle);
+
+
+       stringValue = _UrlImpl::GetInstance(url)->GetLabel();
+
+       switch (_UrlImpl::GetInstance(url)->GetType())
+       {
+               case URL_TYPE_PERSONAL:
+                       type = CONTACTS_URL_TYPE_HOME;
+                       break;
+               case URL_TYPE_WORK:
+                       type = CONTACTS_URL_TYPE_WORK;
+                       break;
+               case URL_TYPE_CUSTOM:
+                       type = CONTACTS_URL_TYPE_CUSTOM;
+                       break;
+               case URL_TYPE_OTHER:
+                       //fallthrough
+               default:
+                       type = CONTACTS_URL_TYPE_OTHER;
+                       break;
+       }
+
+       // set type
+       contacts_record_set_int(urlHandle, _contacts_url.type, type);
+
+       // set label
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(urlHandle, _contacts_url.label, pCharArray.get());
+
+       // set url
+       stringValue = _UrlImpl::GetInstance(url)->GetUrl();
+       pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(urlHandle, _contacts_url.url, pCharArray.get());
+
+       return E_SUCCESS;
+
+}
+
+result
+_UserProfileImpl::SetAddressAt(int index, const Address& address)
+{
+       SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_MEMORY, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
+       SysTryReturn(NID_SCL,
+                                         !address.GetCity().IsEmpty() ||
+                                         !address.GetCountry().IsEmpty() ||
+                                         !address.GetExtended().IsEmpty() ||
+                                         !address.GetPostalCode().IsEmpty() ||
+                                         !address.GetPostOfficeBoxNumber().IsEmpty() ||
+                                         !address.GetState().IsEmpty() ||
+                                         !address.GetStreet().IsEmpty(),
+                                         E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The address is empty.", GetErrorMessage(E_INVALID_ARG));
+
+       unsigned int count = 0;
+       contacts_record_h addressHandle = null;
+       int type = 0;
+       String stringValue;
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.address, &count);
+       SysTryReturn(NID_SCL, count > (unsigned int)index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of addresses %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+       contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.address, index, &addressHandle);
+
+       stringValue = _AddressImpl::GetInstance(address)->GetLabel();
+
+       switch (_AddressImpl::GetInstance(address)->GetType())
+       {
+               case ADDRESS_TYPE_HOME:
+                       type = CONTACTS_ADDRESS_TYPE_HOME;
+                       break;
+               case ADDRESS_TYPE_WORK:
+                       type = CONTACTS_ADDRESS_TYPE_WORK;
+                       break;
+               case ADDRESS_TYPE_CUSTOM:
+                       type = CONTACTS_ADDRESS_TYPE_CUSTOM;
+                       break;
+               case ADDRESS_TYPE_OTHER:
+                       //fallthrough
+               default:
+                       type = CONTACTS_ADDRESS_TYPE_OTHER;
+                       break;
+       }
+
+       // set type
+       contacts_record_set_int(addressHandle, _contacts_address.type, type);
+
+       // set label
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(addressHandle, _contacts_address.label, pCharArray.get());
+
+       // address
+       stringValue = _AddressImpl::GetInstance(address)->GetCity();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(addressHandle, _contacts_address.locality, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(addressHandle, _contacts_address.locality, null);
+       }
+
+       stringValue = _AddressImpl::GetInstance(address)->GetCountry();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(addressHandle, _contacts_address.country, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(addressHandle, _contacts_address.country, null);
+       }
+
+       stringValue = _AddressImpl::GetInstance(address)->GetExtended();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(addressHandle, _contacts_address.extended, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(addressHandle, _contacts_address.extended, null);
+       }
+
+       stringValue = _AddressImpl::GetInstance(address)->GetPostalCode();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(addressHandle, _contacts_address.postal_code, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(addressHandle, _contacts_address.postal_code, null);
+       }
+
+       stringValue = _AddressImpl::GetInstance(address)->GetPostOfficeBoxNumber();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(addressHandle, _contacts_address.postbox, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(addressHandle, _contacts_address.postbox, null);
+       }
+
+       stringValue = _AddressImpl::GetInstance(address)->GetState();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(addressHandle, _contacts_address.region, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(addressHandle, _contacts_address.region, null);
+       }
+
+       stringValue = _AddressImpl::GetInstance(address)->GetStreet();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(addressHandle, _contacts_address.street, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(addressHandle, _contacts_address.street, null);
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_UserProfileImpl::SetImAddressAt(int index, const ImAddress& imAddress)
+{
+       SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
+       SysTryReturn(NID_SCL, !imAddress.GetImAddress().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The imAddress is empty.", GetErrorMessage(E_INVALID_ARG));
+       //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unsigned int count = 0;
+       contacts_record_h messengerHandle = null;
+       String stringValue;
+       int type = 0;
+       std::unique_ptr<char[]> pCharArray(null);
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.messenger, &count);
+       SysTryReturn(NID_SCL, count > (unsigned int)index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of IM addresses.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+       contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.messenger, index, &messengerHandle);
+
+       stringValue = _ImAddressImpl::GetInstance(imAddress)->GetServiceProviderName();
+
+       if (stringValue == IM_ADDRESS_GOOGLE_TALK)
+       {
+               type = CONTACTS_MESSENGER_TYPE_GOOGLE;
+       }
+       else if (stringValue == IM_ADDRESS_MSN)
+       {
+               type = CONTACTS_MESSENGER_TYPE_WLM;
+       }
+       else if (stringValue == IM_ADDRESS_ICQ)
+       {
+               type = CONTACTS_MESSENGER_TYPE_ICQ;
+       }
+       else if (stringValue == IM_ADDRESS_AIM)
+       {
+               type = CONTACTS_MESSENGER_TYPE_AIM;
+       }
+       else if (stringValue == IM_ADDRESS_YAHOO)
+       {
+               type = CONTACTS_MESSENGER_TYPE_YAHOO;
+       }
+       else if (stringValue == IM_ADDRESS_QQ)
+       {
+               type = CONTACTS_MESSENGER_TYPE_QQ;
+       }
+       else if (stringValue == IM_ADDRESS_SKYPE)
+       {
+               type = CONTACTS_MESSENGER_TYPE_SKYPE;
+       }
+       else if (stringValue == IM_ADDRESS_JABBER)
+       {
+               type = CONTACTS_MESSENGER_TYPE_JABBER;
+       }
+       else if (stringValue == IM_ADDRESS_IRC)
+       {
+               type = CONTACTS_MESSENGER_TYPE_IRC;
+       }
+       else if (stringValue == IM_ADDRESS_FACEBOOK)
+       {
+               type = CONTACTS_MESSENGER_TYPE_FACEBOOK;
+       }
+       else
+       {
+               type = CONTACTS_MESSENGER_TYPE_CUSTOM;
+       }
+
+       contacts_record_set_int(messengerHandle, _contacts_messenger.type, type);
+       if (type == CONTACTS_MESSENGER_TYPE_CUSTOM)
+       {
+               pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(messengerHandle, _contacts_messenger.label, pCharArray.get());
+       }
+
+       stringValue = _ImAddressImpl::GetInstance(imAddress)->GetImAddress();
+       pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(messengerHandle, _contacts_messenger.im_id, pCharArray.get());
+
+       return E_SUCCESS;
+
+}
+
+result
+_UserProfileImpl::SetNoteAt(int index, const String& note)
+{
+       SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
+       SysTryReturn(NID_SCL, !note.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The note is an empty string.", GetErrorMessage(E_INVALID_ARG));
+       //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unsigned int count = 0;
+       contacts_record_h noteHandle = null;
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.note, &count);
+       SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of notes.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+       contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.note, index, &noteHandle);
+
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(note));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
+
+       return E_SUCCESS;
+}
+
+result
+_UserProfileImpl::SetNicknameAt(int index, const String& nickname)
+{
+       SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
+       SysTryReturn(NID_SCL, !nickname.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The nickname is an empty string.", GetErrorMessage(E_INVALID_ARG));
+       //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unsigned int count = 0;
+       contacts_record_h nicknameHandle = null;
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.nickname, &count);
+       SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of nicknames.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+       contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.nickname, index, &nicknameHandle);
+
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(nickname));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
+
+       return E_SUCCESS;
+}
+
+result
+_UserProfileImpl::SetEventAt(int index, const ContactEvent& event)
+{
+       SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
+       //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       int type = 0;
+       int intValue = 0;
+       unsigned int count = 0;
+       String stringValue;
+       contacts_record_h eventHandle = null;
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.event, &count);
+       SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of events.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+       contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.event, index, &eventHandle);
+
+       switch (event.GetType())
+       {
+               case CONTACT_EVENT_TYPE_ANNIVERSARY:
+                       type = CONTACTS_EVENT_TYPE_ANNIVERSARY;
+                       break;
+               case CONTACT_EVENT_TYPE_BIRTHDAY:
+                       type = CONTACTS_EVENT_TYPE_BIRTH;
+                       break;
+               case CONTACT_EVENT_TYPE_CUSTOM:
+                       type = CONTACTS_EVENT_TYPE_CUSTOM;
+                       break;
+               case CONTACT_EVENT_TYPE_OTHER:
+                       // fall through
+               default:
+                       type = CONTACTS_EVENT_TYPE_OTHER;
+                       break;
+       }
+
+       // type
+       contacts_record_set_int(eventHandle, _contacts_event.type, type);
+
+       // label
+       stringValue = event.GetLabel();
+
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(eventHandle, _contacts_event.label, pCharArray.get());
+
+       // date
+       DateTime dateValue = event.GetDate();
+       intValue = dateValue.GetYear()*10000 + dateValue.GetMonth()*100 + dateValue.GetDay();
+       contacts_record_set_int(eventHandle, _contacts_event.date, intValue);
+
+       return E_SUCCESS;
+}
+
+
+result
+_UserProfileImpl::SetOrganizationAt(int index, const Organization& organization)
+{
+       SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
+       SysTryReturn(NID_SCL
+                                         ,     !organization.GetName().IsEmpty() ||
+                                               !organization.GetJobTitle().IsEmpty() ||
+                                               !organization.GetDepartment().IsEmpty() ||
+                                               !organization.GetRole().IsEmpty() ||
+                                               !organization.GetAgent().IsEmpty() ||
+                                               !organization.GetLocation().IsEmpty() ||
+                                               !organization.GetDescription().IsEmpty() ||
+                                               !organization.GetPhoneticName().IsEmpty() ||
+                                               !organization.GetLogoPath().IsEmpty()
+                                         ,E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The organization is empty.", GetErrorMessage(E_INVALID_ARG));
+
+       unsigned int count = 0;
+       contacts_record_h organizationHandle = null;
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.company, &count);
+       SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of organizations.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+
+       contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.company, index, &organizationHandle);
+
+       // name
+       String stringValue = organization.GetName();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.name, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(organizationHandle, _contacts_company.name, null);
+       }
+
+       // job title
+       stringValue = organization.GetJobTitle();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.job_title, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(organizationHandle, _contacts_company.job_title, null);
+       }
+
+       // department
+       stringValue = organization.GetDepartment();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.department, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(organizationHandle, _contacts_company.department, null);
+       }
+
+       // role
+       stringValue = organization.GetRole();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.role, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(organizationHandle, _contacts_company.role, null);
+       }
+
+       // agent
+       stringValue = organization.GetAgent();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, null);
+       }
+
+       // type
+       int type = 0;
+
+       switch (organization.GetType())
+       {
+               case ORGANIZATION_TYPE_WORK:
+                       type = CONTACTS_COMPANY_TYPE_WORK;
+                       break;
+               case ORGANIZATION_TYPE_CUSTOM:
+                       type = CONTACTS_COMPANY_TYPE_CUSTOM;
+                       break;
+               case ORGANIZATION_TYPE_OTHER:
+                       // fall through
+               default:
+                       type = CONTACTS_COMPANY_TYPE_OTHER;
+                       break;
+       }
+       contacts_record_set_int(organizationHandle, _contacts_company.type, type);
+
+       // label
+       stringValue = organization.GetLabel();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.label, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(organizationHandle, _contacts_company.label, null);
+       }
+
+       // location
+       stringValue = organization.GetLocation();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.location, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(organizationHandle, _contacts_company.location, null);
+       }
+
+       // description
+       stringValue = organization.GetDescription();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.description, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(organizationHandle, _contacts_company.description, null);
+       }
+
+       // phonetic name
+       stringValue = organization.GetPhoneticName();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, null);
+       }
+
+       // logo path
+       if (_OrganizationImpl::GetInstance(organization)->IsLogoPathChanged() == true)
+       {
+               stringValue = organization.GetLogoPath();
+               if (!stringValue.IsEmpty())
+               {
+                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+                       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       contacts_record_set_str(organizationHandle, _contacts_company.logo, pCharArray.get());
+               }
+               else
+               {
+                       contacts_record_set_str(organizationHandle, _contacts_company.logo, null);
+               }
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_UserProfileImpl::SetRelationshipAt(int index, const Relationship& relationship)
+{
+       SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
+       SysTryReturn(NID_SCL, !relationship.GetRelativeName().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The relationship is empty.", GetErrorMessage(E_INVALID_ARG));
+       //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       int intValue = 0;
+       unsigned int count = 0;
+       contacts_record_h relationshipHandle = null;
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.relationship, &count);
+       SysTryReturn(NID_SCL, count > (unsigned int)index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of relationships.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+       contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.relationship, index, &relationshipHandle);
+
+       switch (relationship.GetType())
+       {
+               case CONTACT_RELATIONSHIP_TYPE_ASSISTANT:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_ASSISTANT;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_BROTHER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_BROTHER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_CHILD:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_CHILD;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_FATHER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_FATHER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_FRIEND:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_FRIEND;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_MANAGER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_MANAGER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_MOTHER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_MOTHER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_PARENT:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_PARENT;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_PARTNER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_PARTNER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_REFERRED_BY:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_RELATIVE:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_RELATIVE;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_SISTER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_SISTER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_SPOUSE:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_SPOUSE;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_CUSTOM:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_CUSTOM;
+                       break;
+               default:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_OTHER;
+                       break;
+       }
+
+       // type
+       contacts_record_set_int(relationshipHandle, _contacts_relationship.type, intValue);
+
+       // label
+       String stringValue = relationship.GetLabel();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(relationshipHandle, _contacts_relationship.label, pCharArray.get());
+       }
+       else
+       {
+               contacts_record_set_str(relationshipHandle, _contacts_relationship.label, null);
+       }
+
+       // name
+       stringValue = relationship.GetRelativeName();
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(relationshipHandle, _contacts_relationship.name, pCharArray.get());
+
+       return E_SUCCESS;
+}
+
+AddressbookId
+_UserProfileImpl::GetAddressbookId(void) const
+{
+       int addressbookId = 0;
+
+       contacts_record_get_int(__profileHandle, _contacts_my_profile.address_book_id, &addressbookId);
+
+       return addressbookId;
+}
+
+IList*
+_UserProfileImpl::GetValuesN(const UserProfileMultiPropertyId id) const
+{
+       IList* pList = null;
+
+       ClearLastResult();
+
+       switch (id)
+       {
+       case USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS:
+               pList = GetPhoneNumbersN();
+               break;
+
+       case USER_PROFILE_MPROPERTY_ID_EMAILS:
+               pList = GetEmailsN();
+               break;
+
+       case USER_PROFILE_MPROPERTY_ID_URLS:
+               pList = GetUrlsN();
+               break;
+
+       case USER_PROFILE_MPROPERTY_ID_ADDRESSES:
+               pList = GetAddressesN();
+               break;
+
+       case USER_PROFILE_MPROPERTY_ID_IMADDRESSES:
+               pList = GetImAddressesN();
+               break;
+
+       case USER_PROFILE_MPROPERTY_ID_EVENTS:
+               pList = GetEventsN();
+               break;
+
+       case USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS:
+               pList = GetOrganizationsN();
+               break;
+
+       case USER_PROFILE_MPROPERTY_ID_NOTES:
+               pList = GetNotesN();
+               break;
+
+       case CONTACT_MPROPERTY_ID_NICKNAMES:
+               pList = GetNicknamesN();
+               break;
+
+       case USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS:
+               pList = GetRelationshipsN();
+               break;
+
+
+       default:
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
+               return null;
+       }
+
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       return pList;
+
+}
+
+result
+_UserProfileImpl::AddPhoneNumber(const PhoneNumber& phoneNumber)
+{
+       SysTryReturn(NID_SCL, !phoneNumber.GetPhoneNumber().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The phoneNumber is empty.", GetErrorMessage(E_INVALID_ARG));
+
+       int type = 0;
+       String stringValue;
+       contacts_record_h numberHandle = null;
+
+       int ret = contacts_record_create(_contacts_number._uri, &numberHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __ContactsRecordHandle recordHandle(numberHandle);
+
+       switch (_PhoneNumberImpl::GetInstance(phoneNumber)->GetType())
+       {
+               case PHONENUMBER_TYPE_HOME:
+                       type = CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE;
+                       break;
+               case PHONENUMBER_TYPE_WORK:
+                       type = CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE;
+                       break;
+               case PHONENUMBER_TYPE_MOBILE:
+                       type = CONTACTS_NUMBER_TYPE_CELL;
+                       break;
+               case PHONENUMBER_TYPE_HOME_FAX:
+                       type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME;
+                       break;
+               case PHONENUMBER_TYPE_WORK_FAX:
+                       type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK;
+                       break;
+               case PHONENUMBER_TYPE_PAGER:
+                       type = CONTACTS_NUMBER_TYPE_PAGER;
+                       break;
+               case PHONENUMBER_TYPE_CUSTOM:
+                       type = CONTACTS_NUMBER_TYPE_CUSTOM;
+                       break;
+               case PHONENUMBER_TYPE_ASSISTANT:
+                       type = CONTACTS_NUMBER_TYPE_ASSISTANT;
+                       break;
+               case PHONENUMBER_TYPE_OTHER:
+               default:
+                       type = CONTACTS_NUMBER_TYPE_OTHER;
+                       break;
+       }
+
+       contacts_record_set_int(numberHandle, _contacts_number.type, type);
+
+       stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetLabel();
+
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(numberHandle, _contacts_number.label, pCharArray.get());
+
+       stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetPhoneNumber();
+       pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(numberHandle, _contacts_number.number, pCharArray.get());
+
+       ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.number, numberHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       recordHandle.Release();
+
+       return E_SUCCESS;
+
+}
+
+result
+_UserProfileImpl::AddNickname(const String& nickname)
+{
+
+       SysTryReturn(NID_SCL, !nickname.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The nickname is an empty string.", GetErrorMessage(E_INVALID_ARG));
+
+       contacts_record_h nicknameHandle = null;
+
+       int ret = contacts_record_create(_contacts_nickname._uri, &nicknameHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(nickname));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
+
+       ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.nickname, nicknameHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       return E_SUCCESS;
+
+}
+
+result
+_UserProfileImpl::AddNote(const String& note)
+{
+       SysTryReturn(NID_SCL, !note.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The note is an empty string.", GetErrorMessage(E_INVALID_ARG));
+
+       contacts_record_h noteHandle = null;
+
+       int ret = contacts_record_create(_contacts_note._uri, &noteHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(note));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
+
+       ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.note, noteHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       return E_SUCCESS;
+
+}
+
+result
+_UserProfileImpl::AddEmail(const Email& email)
+{
+
+       SysTryReturn(NID_SCL, !email.GetEmail().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The email is empty.", GetErrorMessage(E_INVALID_ARG));
+
+       int type = 0;
+       String stringValue;
+       contacts_record_h emailHandle = null;
+
+       int ret = contacts_record_create(_contacts_email._uri, &emailHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __ContactsRecordHandle recordHandle(emailHandle);
+
+       switch (_EmailImpl::GetInstance(email)->GetType())
+       {
+               case EMAIL_TYPE_PERSONAL:
+                       type = CONTACTS_EMAIL_TYPE_HOME;
+                       break;
+               case EMAIL_TYPE_WORK:
+                       type = CONTACTS_EMAIL_TYPE_WORK;
+                       break;
+               case EMAIL_TYPE_CUSTOM:
+                       type = CONTACTS_EMAIL_TYPE_CUSTOM;
+                       break;
+               case EMAIL_TYPE_MOBILE:
+                       type = CONTACTS_EMAIL_TYPE_MOBILE;
+                       break;
+               case EMAIL_TYPE_OTHER:
+                       // fall through
+               default:
+                       type = CONTACTS_EMAIL_TYPE_OTHER;
+                       break;
+       }
+
+       contacts_record_set_int(emailHandle, _contacts_email.type, type);
+
+       stringValue = _EmailImpl::GetInstance(email)->GetLabel();
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(emailHandle, _contacts_email.label, pCharArray.get());
+
+       stringValue = _EmailImpl::GetInstance(email)->GetEmail();
+       pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(emailHandle, _contacts_email.email, pCharArray.get());
+
+       ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.email, emailHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       recordHandle.Release();
+
+       return E_SUCCESS;
+
+}
+
+result
+_UserProfileImpl::AddUrl(const Url& url)
+{
+       SysTryReturn(NID_SCL, !url.GetUrl().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The url is empty.", GetErrorMessage(E_INVALID_ARG));
+
+       int type = 0;
+       String stringValue;
+       contacts_record_h urlHandle = null;
+
+       int ret = contacts_record_create(_contacts_url._uri, &urlHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __ContactsRecordHandle recordHandle(urlHandle);
+
+       switch (_UrlImpl::GetInstance(url)->GetType())
+       {
+               case URL_TYPE_PERSONAL:
+                       type = CONTACTS_URL_TYPE_HOME;
+                       break;
+               case URL_TYPE_WORK:
+                       type = CONTACTS_URL_TYPE_WORK;
+                       break;
+               case URL_TYPE_CUSTOM:
+                       type = CONTACTS_URL_TYPE_CUSTOM;
+                       break;
+               case URL_TYPE_OTHER:
+                       // fall through
+               default:
+                       type = CONTACTS_URL_TYPE_OTHER;
+                       break;
+       }
+
+       // set type
+       contacts_record_set_int(urlHandle, _contacts_url.type, type);
+
+       // set label
+       stringValue = _UrlImpl::GetInstance(url)->GetLabel();
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(urlHandle, _contacts_url.label, pCharArray.get());
+
+       // set url
+       stringValue = _UrlImpl::GetInstance(url)->GetUrl();
+       pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(urlHandle, _contacts_url.url, pCharArray.get());
+
+       ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.url, urlHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       recordHandle.Release();
+
+       return E_SUCCESS;
+
+}
+
+result
+_UserProfileImpl::AddAddress(const Address& address)
+{
+
+       SysTryReturn(NID_SCL, !_AddressImpl::GetInstance(address)->IsEmpty() ,E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The address is empty.", GetErrorMessage(E_INVALID_ARG));
+
+       int type = 0;
+       String stringValue;
+       contacts_record_h addressHandle = null;
+
+       int ret = contacts_record_create(_contacts_address._uri, &addressHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __ContactsRecordHandle recordHandle(addressHandle);
+
+       switch (_AddressImpl::GetInstance(address)->GetType())
+       {
+               case ADDRESS_TYPE_HOME:
+                       type = CONTACTS_ADDRESS_TYPE_HOME;
+                       break;
+               case ADDRESS_TYPE_WORK:
+                       type = CONTACTS_ADDRESS_TYPE_WORK;
+                       break;
+               case ADDRESS_TYPE_CUSTOM:
+                       type = CONTACTS_ADDRESS_TYPE_CUSTOM;
+                       break;
+               case ADDRESS_TYPE_OTHER:
+                       // fall through
+               default:
+                       type = CONTACTS_ADDRESS_TYPE_OTHER;
+                       break;
+       }
+
+       contacts_record_set_int(addressHandle, _contacts_address.type, type);
+
+       stringValue = _AddressImpl::GetInstance(address)->GetLabel();
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(addressHandle, _contacts_address.label, pCharArray.get());
+
+       stringValue = _AddressImpl::GetInstance(address)->GetCity();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(addressHandle, _contacts_address.locality, pCharArray.get());
+       }
+
+
+       stringValue = _AddressImpl::GetInstance(address)->GetCountry();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(addressHandle, _contacts_address.country, pCharArray.get());
+       }
+
+       stringValue = _AddressImpl::GetInstance(address)->GetExtended();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(addressHandle, _contacts_address.extended, pCharArray.get());
+       }
+
+       stringValue = _AddressImpl::GetInstance(address)->GetPostalCode();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(addressHandle, _contacts_address.postal_code, pCharArray.get());
+       }
+
+       stringValue = _AddressImpl::GetInstance(address)->GetPostOfficeBoxNumber();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(addressHandle, _contacts_address.postbox, pCharArray.get());
+       }
+
+       stringValue = _AddressImpl::GetInstance(address)->GetState();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(addressHandle, _contacts_address.region, pCharArray.get());
+       }
+
+       stringValue = _AddressImpl::GetInstance(address)->GetStreet();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(addressHandle, _contacts_address.street, pCharArray.get());
+       }
+
+       ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.address, addressHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       recordHandle.Release();
+
+       return E_SUCCESS;
+
+}
+
+result
+_UserProfileImpl::AddImAddress(const ImAddress& imAddress)
+{
+
+       SysTryReturn(NID_SCL, !imAddress.GetImAddress().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%] Invalid argument is used. The imAddress is empty.", GetErrorMessage(E_INVALID_ARG));
+
+       int type = 0;
+       String stringValue;
+       contacts_record_h messengerHandle = null;
+
+       std::unique_ptr<char[]> pCharArray(null);
+
+       int ret = contacts_record_create(_contacts_messenger._uri, &messengerHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __ContactsRecordHandle recordHandle(messengerHandle);
+
+       stringValue = _ImAddressImpl::GetInstance(imAddress)->GetServiceProviderName();
+
+       if (stringValue == IM_ADDRESS_GOOGLE_TALK)
+       {
+               type = CONTACTS_MESSENGER_TYPE_GOOGLE;
+       }
+       else if (stringValue == IM_ADDRESS_MSN)
+       {
+               type = CONTACTS_MESSENGER_TYPE_WLM;
+       }
+       else if (stringValue == IM_ADDRESS_ICQ)
+       {
+               type = CONTACTS_MESSENGER_TYPE_ICQ;
+       }
+       else if (stringValue == IM_ADDRESS_AIM)
+       {
+               type = CONTACTS_MESSENGER_TYPE_AIM;
+       }
+       else if (stringValue == IM_ADDRESS_YAHOO)
+       {
+               type = CONTACTS_MESSENGER_TYPE_YAHOO;
+       }
+       else if (stringValue == IM_ADDRESS_QQ)
+       {
+               type = CONTACTS_MESSENGER_TYPE_QQ;
+       }
+       else if (stringValue == IM_ADDRESS_SKYPE)
+       {
+               type = CONTACTS_MESSENGER_TYPE_SKYPE;
+       }
+       else if (stringValue == IM_ADDRESS_JABBER)
+       {
+               type = CONTACTS_MESSENGER_TYPE_JABBER;
+       }
+       else if (stringValue == IM_ADDRESS_IRC)
+       {
+               type = CONTACTS_MESSENGER_TYPE_IRC;
+       }
+       else if (stringValue == IM_ADDRESS_FACEBOOK)
+       {
+               type = CONTACTS_MESSENGER_TYPE_FACEBOOK;
+       }
+       else
+       {
+               type = CONTACTS_MESSENGER_TYPE_CUSTOM;
+       }
+
+       contacts_record_set_int(messengerHandle, _contacts_messenger.type, type);
+       if (type == CONTACTS_MESSENGER_TYPE_CUSTOM)
+       {
+               pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null,  E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(messengerHandle, _contacts_messenger.label, pCharArray.get());
+       }
+
+       stringValue = _ImAddressImpl::GetInstance(imAddress)->GetImAddress();
+       pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(messengerHandle, _contacts_messenger.im_id, pCharArray.get());
+
+       ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.messenger, messengerHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       recordHandle.Release();
+
+       return E_SUCCESS;
+
+}
+result
+_UserProfileImpl::AddRelationship(const Relationship& relationship)
+{
+       SysTryReturn(NID_SCL, !relationship.GetRelativeName().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%] Invalid argument is used. The relationship is empty.", GetErrorMessage(E_INVALID_ARG));
+
+       int intValue = 0;
+       contacts_record_h relationshipHandle = null;
+
+       int ret = contacts_record_create(_contacts_relationship._uri, &relationshipHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __ContactsRecordHandle recordHandle(relationshipHandle);
+
+       switch (relationship.GetType())
+       {
+               case CONTACT_RELATIONSHIP_TYPE_ASSISTANT:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_ASSISTANT;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_BROTHER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_BROTHER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_CHILD:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_CHILD;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_FATHER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_FATHER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_FRIEND:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_FRIEND;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_MANAGER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_MANAGER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_MOTHER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_MOTHER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_PARENT:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_PARENT;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_PARTNER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_PARTNER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_REFERRED_BY:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_RELATIVE:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_RELATIVE;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_SISTER:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_SISTER;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_SPOUSE:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_SPOUSE;
+                       break;
+               case CONTACT_RELATIONSHIP_TYPE_CUSTOM:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_CUSTOM;
+                       break;
+               default:
+                       intValue = CONTACTS_RELATIONSHIP_TYPE_OTHER;
+                       break;
+       }
+
+       // type
+       contacts_record_set_int(relationshipHandle, _contacts_relationship.type, intValue);
+
+       // label
+       String stringValue = relationship.GetLabel();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(relationshipHandle, _contacts_relationship.label, pCharArray.get());
+       }
+
+       // name
+       stringValue = relationship.GetRelativeName();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(relationshipHandle, _contacts_relationship.name, pCharArray.get());
+       }
+
+       ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.relationship, relationshipHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       recordHandle.Release();
+
+       return E_SUCCESS;
+
+
+}
+
+result
+_UserProfileImpl::AddEvent(const ContactEvent& event)
+{
+
+       int type = 0;
+       int intValue = 0;
+       String stringValue;
+       contacts_record_h eventHandle = null;
+
+       int ret = contacts_record_create(_contacts_event._uri, &eventHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __ContactsRecordHandle recordHandle(eventHandle);
+
+       switch (event.GetType())
+       {
+               case CONTACT_EVENT_TYPE_ANNIVERSARY:
+                       type = CONTACTS_EVENT_TYPE_ANNIVERSARY;
+                       break;
+               case CONTACT_EVENT_TYPE_BIRTHDAY:
+                       type = CONTACTS_EVENT_TYPE_BIRTH;
+                       break;
+               case CONTACT_EVENT_TYPE_CUSTOM:
+                       type = CONTACTS_EVENT_TYPE_CUSTOM;
+                       break;
+               case CONTACT_EVENT_TYPE_OTHER:
+                       // fall through
+               default:
+                       type = CONTACTS_EVENT_TYPE_OTHER;
+                       break;
+       }
+
+       // type
+       contacts_record_set_int(eventHandle, _contacts_event.type, type);
+
+       // label
+       stringValue = event.GetLabel();
+       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_set_str(eventHandle, _contacts_event.label, pCharArray.get());
+
+       // date
+       DateTime dateValue = event.GetDate();
+       intValue = dateValue.GetYear()*10000 + dateValue.GetMonth()*100 + dateValue.GetDay();
+       contacts_record_set_int(eventHandle, _contacts_event.date, intValue);
+
+       ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.event, eventHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       recordHandle.Release();
+
+       return E_SUCCESS;
+
+}
+
+result
+_UserProfileImpl::AddOrganization(const Organization& organization)
+{
+       SysTryReturn(NID_SCL
+                                         ,     !organization.GetName().IsEmpty() ||
+                                               !organization.GetJobTitle().IsEmpty() ||
+                                               !organization.GetDepartment().IsEmpty() ||
+                                               !organization.GetRole().IsEmpty() ||
+                                               !organization.GetAgent().IsEmpty() ||
+                                               !organization.GetDescription().IsEmpty() ||
+                                               !organization.GetLocation().IsEmpty() ||
+                                               !organization.GetPhoneticName().IsEmpty() ||
+                                               !organization.GetLogoPath().IsEmpty()
+                                         ,E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The organization is empty.", GetErrorMessage(E_INVALID_ARG));
+
+       contacts_record_h organizationHandle = null;
+
+       int ret = contacts_record_create(_contacts_company._uri, &organizationHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __ContactsRecordHandle recordHandle(organizationHandle);
+
+       // name
+       String stringValue = organization.GetName();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.name, pCharArray.get());
+       }
+
+       // job title
+       stringValue = organization.GetJobTitle();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.job_title, pCharArray.get());
+       }
+
+       // department
+       stringValue = organization.GetDepartment();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.department, pCharArray.get());
+       }
+
+       // role
+       stringValue = organization.GetRole();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.role, pCharArray.get());
+       }
+
+       // agent
+       stringValue = organization.GetAgent();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, pCharArray.get());
+       }
+
+       // type
+       int type = 0;
+
+       switch (organization.GetType())
+       {
+               case ORGANIZATION_TYPE_WORK:
+                       type = CONTACTS_COMPANY_TYPE_WORK;
+                       break;
+               case ORGANIZATION_TYPE_CUSTOM:
+                       type = CONTACTS_COMPANY_TYPE_CUSTOM;
+                       break;
+               case ORGANIZATION_TYPE_OTHER:
+                       // fall through
+               default:
+                       type = CONTACTS_COMPANY_TYPE_OTHER;
+                       break;
+       }
+
+       contacts_record_set_int(organizationHandle, _contacts_company.type, type);
+
+       // label
+       stringValue = organization.GetLabel();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.label, pCharArray.get());
+       }
+
+       // description
+       stringValue = organization.GetDescription();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.description, pCharArray.get());
+       }
+
+       // location
+       stringValue = organization.GetLocation();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.location, pCharArray.get());
+       }
+
+       // phonetic name
+       stringValue = organization.GetPhoneticName();
+       if (!stringValue.IsEmpty())
+       {
+               std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+               SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, pCharArray.get());
+       }
+
+       // logo path
+       if (_OrganizationImpl::GetInstance(organization)->IsLogoPathChanged() == true)
+       {
+               stringValue = organization.GetLogoPath();
+               if (!stringValue.IsEmpty())
+               {
+                       std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
+                       SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       contacts_record_set_str(organizationHandle, _contacts_company.logo, pCharArray.get());
+               }
+       }
+
+       ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.company, organizationHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       recordHandle.Release();
+
+       return E_SUCCESS;
+
+}
+
+result
+_UserProfileImpl::RemoveAt(UserProfileMultiPropertyId id, int index)
+{
+       SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
+
+       unsigned int count = 0;
+       contacts_record_h recordHandle = null;
+
+       switch (id)
+       {
+       case USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS:
+               contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.number, &count);
+               SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of phone numbers %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.number, index, &recordHandle);
+               contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.number, recordHandle);
+               contacts_record_destroy(recordHandle, true);
+
+               break;
+       case USER_PROFILE_MPROPERTY_ID_EMAILS:
+               contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.email, &count);
+               SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of emails %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.email, index, &recordHandle);
+               contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.email, recordHandle);
+               contacts_record_destroy(recordHandle, true);
+
+               break;
+       case USER_PROFILE_MPROPERTY_ID_URLS:
+               contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.url, &count);
+               SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of urls %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.url, index, &recordHandle);
+               contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.url, recordHandle);
+               contacts_record_destroy(recordHandle, true);
+
+               break;
+       case USER_PROFILE_MPROPERTY_ID_ADDRESSES:
+               contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.address, &count);
+               SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of addresses %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.address, index, &recordHandle);
+               contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.address, recordHandle);
+               contacts_record_destroy(recordHandle, true);
+
+               break;
+       case USER_PROFILE_MPROPERTY_ID_IMADDRESSES:
+               contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.messenger, &count);
+               SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of IM addresses %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.messenger, index, &recordHandle);
+               contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.messenger, recordHandle);
+               contacts_record_destroy(recordHandle, true);
+
+               break;
+       case USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS:
+               contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.company, &count);
+               SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of organizations %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.company, index, &recordHandle);
+               contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.company, recordHandle);
+               contacts_record_destroy(recordHandle, true);
+
+               break;
+       case USER_PROFILE_MPROPERTY_ID_EVENTS:
+               contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.event, &count);
+               SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of events %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.event, index, &recordHandle);
+               contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.event, recordHandle);
+               contacts_record_destroy(recordHandle, true);
+
+               break;
+       case USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS:
+               contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.relationship, &count);
+               SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of relationships %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.relationship, index, &recordHandle);
+               contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.relationship, recordHandle);
+               contacts_record_destroy(recordHandle, true);
+
+               break;
+       case USER_PROFILE_MPROPERTY_ID_NOTES:
+               contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.note, &count);
+               SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of notes %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.note, index, &recordHandle);
+               contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.note, recordHandle);
+               contacts_record_destroy(recordHandle, true);
+
+               break;
+       case USER_PROFILE_MPROPERTY_ID_NICKNAMES:
+               contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.nickname, &count);
+               SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of nicknames %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
+
+               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.nickname, index, &recordHandle);
+               contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.nickname, recordHandle);
+               contacts_record_destroy(recordHandle, true);
+
+               break;
+       default:
+               SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
+               return E_INVALID_ARG;
+       }
+
+       return E_SUCCESS;
+}
+
+IList*
+_UserProfileImpl::GetOrganizationsN(void) const
+{
+       result r = E_SUCCESS;
+       contacts_record_h organizationHandle = null;
+       int ret = CONTACTS_ERROR_NONE;
+       char* pCharValue = null;
+       int intValue = 0;
+       unsigned int count = 0;
+       std::unique_ptr<Organization> pOrganization(null);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.company, &count);
+
+       r = pList->Construct(count);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       for (unsigned int index = 0; index < count; index++)
+       {
+               ret = contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.company, index, &organizationHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+               pOrganization.reset(new (std::nothrow) Organization());
+               SysTryReturn(NID_SCL, pOrganization != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               // name
+               contacts_record_get_str_p(organizationHandle, _contacts_company.name, &pCharValue);
+               pOrganization->SetName(pCharValue);
+
+               // job title
+               contacts_record_get_str_p(organizationHandle, _contacts_company.job_title, &pCharValue);
+               pOrganization->SetJobTitle(pCharValue);
+
+               // department
+               contacts_record_get_str_p(organizationHandle, _contacts_company.department, &pCharValue);
+               pOrganization->SetDepartment(pCharValue);
+
+               // role
+               contacts_record_get_str_p(organizationHandle, _contacts_company.role, &pCharValue);
+               pOrganization->SetRole(pCharValue);
+
+               // agent
+               contacts_record_get_str_p(organizationHandle, _contacts_company.assistant_name, &pCharValue);
+               pOrganization->SetAgent(pCharValue);
+
+               // type
+               contacts_record_get_int(organizationHandle, _contacts_company.type, &intValue);
+               switch (intValue)
+               {
+                       case CONTACTS_COMPANY_TYPE_WORK:
+                               pOrganization->SetType(ORGANIZATION_TYPE_WORK);
+                               break;
+                       case CONTACTS_COMPANY_TYPE_CUSTOM:
+                               pOrganization->SetType(ORGANIZATION_TYPE_CUSTOM);
+                               break;
+                       case CONTACTS_COMPANY_TYPE_OTHER:
+                               // fall through
+                       default:
+                               pOrganization->SetType(ORGANIZATION_TYPE_OTHER);
+                               break;
+               }
+
+               // label
+               contacts_record_get_str_p(organizationHandle, _contacts_company.label, &pCharValue);
+               pOrganization->SetLabel(pCharValue);
+
+               // description
+               contacts_record_get_str_p(organizationHandle, _contacts_company.description, &pCharValue);
+               pOrganization->SetDescription(pCharValue);
+
+               // location
+               contacts_record_get_str_p(organizationHandle, _contacts_company.location, &pCharValue);
+               pOrganization->SetLocation(pCharValue);
+
+               // phonetic name
+               contacts_record_get_str_p(organizationHandle, _contacts_company.phonetic_name, &pCharValue);
+               pOrganization->SetPhoneticName(pCharValue);
+
+               // logo path
+               contacts_record_get_str_p(organizationHandle, _contacts_company.logo, &pCharValue);
+               _OrganizationImpl::GetInstance(*pOrganization)->SetLogoPath(pCharValue);
+
+               r = pList->Add(*pOrganization);
+               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pOrganization.release();
+       }
+
+       return pList.release();
+
+}
+
+IList*
+_UserProfileImpl::GetRelationshipsN(void) const
+{
+
+       result r = E_SUCCESS;
+       contacts_record_h relationshipHandle = null;
+       int ret = CONTACTS_ERROR_NONE;
+       int intValue = 0;
+       char* pCharValue = null;
+       unsigned int count = 0;
+       std::unique_ptr<Relationship> pRelationship(null);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.relationship, &count);
+
+       r = pList->Construct(count);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       for (unsigned int index = 0; index < count; index++)
+       {
+               ret = contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.relationship, index, &relationshipHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+               pRelationship.reset(new (std::nothrow) Relationship());
+               SysTryReturn(NID_SCL, pRelationship != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               // type
+               contacts_record_get_int(relationshipHandle, _contacts_relationship.type, &intValue);
+               switch (intValue)
+               {
+               case CONTACTS_RELATIONSHIP_TYPE_ASSISTANT:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_ASSISTANT);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_BROTHER:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_BROTHER);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_CHILD:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_CHILD);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_FATHER:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_FATHER);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_FRIEND:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_FRIEND);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_MANAGER:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_MANAGER);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_MOTHER:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_MOTHER);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_PARENT:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_PARENT);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_PARTNER:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_PARTNER);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_REFERRED_BY);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_RELATIVE:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_RELATIVE);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_SISTER:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_SISTER);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_SPOUSE:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_SPOUSE);
+                       break;
+               case CONTACTS_RELATIONSHIP_TYPE_CUSTOM:
+                       // fall through
+               default:
+                       pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_CUSTOM);
+                       break;
+               }
+
+               // label
+               contacts_record_get_str_p(relationshipHandle, _contacts_relationship.label, &pCharValue);
+               pRelationship->SetLabel(pCharValue);
+
+               // name
+               contacts_record_get_str_p(relationshipHandle, _contacts_relationship.name, &pCharValue);
+               pRelationship->SetRelativeName(pCharValue);
+
+               r = pList->Add(*pRelationship);
+               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pRelationship.release();
+       }
+
+       return pList.release();
+
+}
+
+IList*
+_UserProfileImpl::GetEventsN(void) const
+{
+       result r = E_SUCCESS;
+       char* pCharValue = null;
+       int intValue = 0;
+       unsigned int count = 0;
+       contacts_record_h eventHandle = null;
+       std::unique_ptr<ContactEvent> pEvent(null);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.event, &count);
+
+       r = pList->Construct(count);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       for (unsigned int index = 0; index < count; index++)
+       {
+               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.event, index, &eventHandle);
+
+               pEvent.reset(new (std::nothrow) ContactEvent());
+               SysTryReturn(NID_SCL, pEvent != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               // label
+               contacts_record_get_str_p(eventHandle, _contacts_event.label, &pCharValue);
+               pEvent->SetLabel(pCharValue);
+
+               // type
+               contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
+               switch (intValue)
+               {
+               case CONTACTS_EVENT_TYPE_BIRTH:
+                       pEvent->SetType(CONTACT_EVENT_TYPE_BIRTHDAY);
+                       break;
+               case CONTACTS_EVENT_TYPE_ANNIVERSARY:
+                       pEvent->SetType(CONTACT_EVENT_TYPE_ANNIVERSARY);
+                       break;
+               case CONTACTS_URL_TYPE_CUSTOM:
+                       pEvent->SetType(CONTACT_EVENT_TYPE_CUSTOM);
+                       break;
+               default:
+                       pEvent->SetType(CONTACT_EVENT_TYPE_OTHER);
+                       break;
+               }
+
+               DateTime dateTime;
+
+               contacts_record_get_int(eventHandle, _contacts_event.date, &intValue);
+               __CONVERT_DATE_TO_DATETIME(intValue, dateTime);
+               pEvent->SetDate(dateTime);
+
+               pList->Add(*pEvent);
+               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pEvent.release();
+       }
+
+       return pList.release();
+
+}
+
+IList*
+_UserProfileImpl::GetNotesN(void) const
+{
+       result r = E_SUCCESS;
+       char* pCharValue = null;
+       unsigned int count = 0;
+       contacts_record_h noteHandle = null;
+       std::unique_ptr<String> pNote(null);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.note, &count);
+
+       r = pList->Construct(count);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       for (unsigned int index = 0; index < count; index++)
+       {
+               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.note, index, &noteHandle);
+
+               contacts_record_get_str_p(noteHandle, _contacts_note.note, &pCharValue);
+
+               pNote.reset(new (std::nothrow) String(pCharValue));
+               SysTryReturn(NID_SCL, pNote != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pList->Add(*pNote);
+               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pNote.release();
+       }
+
+       return pList.release();
+
+}
+
+IList*
+_UserProfileImpl::GetNicknamesN(void) const
+{
+       result r = E_SUCCESS;
+       char* pCharValue = null;
+       unsigned int count = 0;
+       contacts_record_h nicknameHandle = null;
+       std::unique_ptr<String> pNickname(null);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.nickname, &count);
+
+       r = pList->Construct(count);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       for (unsigned int index = 0; index < count; index++)
+       {
+               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.nickname, index, &nicknameHandle);
+
+               contacts_record_get_str_p(nicknameHandle, _contacts_nickname.name, &pCharValue);
+
+               pNickname.reset(new (std::nothrow) String(pCharValue));
+               SysTryReturn(NID_SCL, pNickname != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pList->Add(*pNickname);
+               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pNickname.release();
+       }
+
+       return pList.release();
+
+}
+
+IList*
+_UserProfileImpl::GetPhoneNumbersN(void) const
+{
+       result r = E_SUCCESS;
+       unsigned int count = 0;
+       contacts_record_h numberHandle = null;
+       int intValue = 0;
+       char* pCharValue = null;
+       PhoneNumberType type = PHONENUMBER_TYPE_HOME;
+       std::unique_ptr<PhoneNumber> pPhoneNumber(null);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.number, &count);
+
+       contacts_record_get_int(__profileHandle, _contacts_my_profile.id, &intValue);
+
+       r = pList->Construct(count);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       for (unsigned int index = 0; index < count; index++)
+       {
+               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.number, index, &numberHandle);
+
+               pPhoneNumber.reset(new (std::nothrow) PhoneNumber());
+               SysTryReturn(NID_SCL, pPhoneNumber != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_get_int(numberHandle, _contacts_number.id, &intValue);
+               _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetRecordId(intValue);
+
+               contacts_record_get_str_p(numberHandle, _contacts_number.label, &pCharValue);
+               _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetLabel(pCharValue);
+
+               contacts_record_get_int(numberHandle, _contacts_number.type, &intValue);
+
+               switch (intValue)
+               {
+                       case CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE:
+                               type = PHONENUMBER_TYPE_HOME;
+                               break;
+                       case CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE:
+                               type = PHONENUMBER_TYPE_WORK;
+                               break;
+                       case CONTACTS_NUMBER_TYPE_CELL:
+                               type = PHONENUMBER_TYPE_MOBILE;
+                               break;
+                       case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME:
+                               type = PHONENUMBER_TYPE_HOME_FAX;
+                               break;
+                       case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK:
+                               type = PHONENUMBER_TYPE_WORK_FAX;
+                               break;
+                       case CONTACTS_NUMBER_TYPE_PAGER:
+                               type = PHONENUMBER_TYPE_PAGER;
+                               break;
+                       case CONTACTS_NUMBER_TYPE_CUSTOM:
+                               type = PHONENUMBER_TYPE_CUSTOM;
+                               break;
+                       case CONTACTS_NUMBER_TYPE_ASSISTANT:
+                               type = PHONENUMBER_TYPE_ASSISTANT;
+                               break;
+                       default:
+                               if (intValue & CONTACTS_NUMBER_TYPE_FAX)
+                               {
+                                       type = PHONENUMBER_TYPE_HOME_FAX;
+                               }
+                               else if (intValue & CONTACTS_NUMBER_TYPE_CELL)
+                               {
+                                       type = PHONENUMBER_TYPE_MOBILE;
+                               }
+                               else if (intValue & CONTACTS_NUMBER_TYPE_PAGER)
+                               {
+                                       type = PHONENUMBER_TYPE_PAGER;
+                               }
+                               else if (intValue & CONTACTS_NUMBER_TYPE_HOME)
+                               {
+                                       type = PHONENUMBER_TYPE_HOME;
+                               }
+                               else if (intValue & CONTACTS_NUMBER_TYPE_WORK)
+                               {
+                                       type = PHONENUMBER_TYPE_WORK;
+                               }
+                               else if (intValue & CONTACTS_NUMBER_TYPE_VOICE)
+                               {
+                                       type = PHONENUMBER_TYPE_HOME;
+                               }
+                               else
+                               {
+                                       type = PHONENUMBER_TYPE_OTHER;
+                               }
+                               break;
+               }
+
+               _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetType(type);
+
+               contacts_record_get_str_p(numberHandle, _contacts_number.number, &pCharValue);
+               _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetPhoneNumber(pCharValue);
+
+               r = pList->Add(*pPhoneNumber);
+               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pPhoneNumber.release();
+       }
+
+       return pList.release();
+
+}
+
+IList*
+_UserProfileImpl::GetEmailsN(void) const
+{
+       result r = E_SUCCESS;
+       contacts_record_h currentHandle = null;
+       int ret = CONTACTS_ERROR_NONE;
+       int intValue = 0;
+       unsigned int count = 0;
+       char* pCharValue = null;
+       EmailType type = EMAIL_TYPE_PERSONAL;
+       std::unique_ptr<Email> pEmail(null);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.email, &count);
+
+       r = pList->Construct(count);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       for (unsigned int index = 0; index < count; index++)
+       {
+               ret = contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.email, index, &currentHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM))
+
+               pEmail.reset(new (std::nothrow) Email());
+               SysTryReturn(NID_SCL, pEmail != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_get_int(currentHandle, _contacts_email.id, &intValue);
+               _EmailImpl::GetInstance(*pEmail)->SetRecordId(intValue);
+
+               contacts_record_get_str_p(currentHandle, _contacts_email.label, &pCharValue);
+               _EmailImpl::GetInstance(*pEmail)->SetLabel(pCharValue);
+
+               contacts_record_get_int(currentHandle, _contacts_email.type, &intValue);
+               switch (intValue)
+               {
+               case CONTACTS_EMAIL_TYPE_HOME:
+                       type = EMAIL_TYPE_PERSONAL;
+                       break;
+               case CONTACTS_EMAIL_TYPE_WORK:
+                       type = EMAIL_TYPE_WORK;
+                       break;
+               case CONTACTS_EMAIL_TYPE_CUSTOM:
+                       type = EMAIL_TYPE_CUSTOM;
+                       break;
+               case CONTACTS_EMAIL_TYPE_MOBILE:
+                       type = EMAIL_TYPE_MOBILE;
+                       break;
+               default:
+                       type = EMAIL_TYPE_OTHER;
+                       break;
+               }
+
+               _EmailImpl::GetInstance(*pEmail)->SetType(type);
+
+               contacts_record_get_str_p(currentHandle, _contacts_email.email, &pCharValue);
+               _EmailImpl::GetInstance(*pEmail)->SetEmail(pCharValue);
+
+               r = pList->Add(*pEmail);
+               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pEmail.release();
+       }
+
+       return pList.release();
+
+}
+
+IList*
+_UserProfileImpl::GetUrlsN(void) const
+{
+
+       result r = E_SUCCESS;
+       char* pCharValue = null;
+       int intValue = 0;
+       unsigned int count = 0;
+       UrlType type = URL_TYPE_PERSONAL;
+       contacts_record_h urlHandle = null;
+       std::unique_ptr<Url> pUrl(null);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.url, &count);
+
+       r = pList->Construct(count);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       for (unsigned int index = 0; index < count; index++)
+       {
+               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.url, index, &urlHandle);
+
+               pUrl.reset(new (std::nothrow) Url());
+               SysTryReturn(NID_SCL, pUrl != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_get_str_p(urlHandle, _contacts_url.label, &pCharValue);
+               pUrl->SetLabel(pCharValue);
+
+               contacts_record_get_int(urlHandle, _contacts_url.type, &intValue);
+               switch (intValue)
+               {
+               case CONTACTS_URL_TYPE_HOME:
+                       type = URL_TYPE_PERSONAL;
+                       break;
+               case CONTACTS_URL_TYPE_WORK:
+                       type = URL_TYPE_WORK;
+                       break;
+               case CONTACTS_URL_TYPE_CUSTOM:
+                       type = URL_TYPE_CUSTOM;
+                       break;
+               default:
+                       type = URL_TYPE_OTHER;
+                       break;
+               }
+
+               pUrl->SetType(type);
+
+               contacts_record_get_str_p(urlHandle, _contacts_url.url, &pCharValue);
+               _UrlImpl::GetInstance(*pUrl)->SetUrl(pCharValue);
+
+               pList->Add(*pUrl);
+               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pUrl.release();
+       }
+
+       return pList.release();
+
+}
+
+IList*
+_UserProfileImpl::GetAddressesN(void) const
+{
+       result r = E_SUCCESS;
+       char* pCharValue = null;
+       int intValue = 0;
+       unsigned int count = 0;
+       contacts_record_h addressHandle = 0;
+       std::unique_ptr<Address> pAddress(null);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.address, &count);
+
+       r = pList->Construct(count);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+
+       for (unsigned int index = 0; index < count; index++)
+       {
+               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.address, index, &addressHandle);
+
+               pAddress.reset(new (std::nothrow) Address());
+               SysTryReturn(NID_SCL, pAddress != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_get_str_p(addressHandle, _contacts_address.label, &pCharValue);
+               pAddress->SetLabel(pCharValue);
+
+               contacts_record_get_int(addressHandle, _contacts_address.type, &intValue);
+               switch (intValue)
+               {
+               case CONTACTS_ADDRESS_TYPE_HOME:
+                       pAddress->SetType(ADDRESS_TYPE_HOME);
+                       break;
+               case CONTACTS_ADDRESS_TYPE_WORK:
+                       pAddress->SetType(ADDRESS_TYPE_WORK);
+                       break;
+               case CONTACTS_ADDRESS_TYPE_CUSTOM:
+                       pAddress->SetType(ADDRESS_TYPE_CUSTOM);
+                       break;
+               default:
+                       pAddress->SetType(ADDRESS_TYPE_OTHER);
+                       break;
+               }
+
+               // 1. country
+               contacts_record_get_str_p(addressHandle, _contacts_address.country, &pCharValue);
+               _AddressImpl::GetInstance(*pAddress)->SetCountry(pCharValue);
+
+               // 2. region
+               contacts_record_get_str_p(addressHandle, _contacts_address.region, &pCharValue);
+               _AddressImpl::GetInstance(*pAddress)->SetState(pCharValue);
+
+               // 3. city
+               contacts_record_get_str_p(addressHandle, _contacts_address.locality, &pCharValue);
+               _AddressImpl::GetInstance(*pAddress)->SetCity(pCharValue);
+
+               // 4. street
+               contacts_record_get_str_p(addressHandle, _contacts_address.street, &pCharValue);
+               _AddressImpl::GetInstance(*pAddress)->SetStreet(pCharValue);
+
+               // 5. extended
+               contacts_record_get_str_p(addressHandle, _contacts_address.extended, &pCharValue);
+               _AddressImpl::GetInstance(*pAddress)->SetExtended(pCharValue);
+
+               // 6. postbox
+               contacts_record_get_str_p(addressHandle, _contacts_address.postbox, &pCharValue);
+               _AddressImpl::GetInstance(*pAddress)->SetPostOfficeBoxNumber(pCharValue);
+
+               // 7. postal code
+               contacts_record_get_str_p(addressHandle, _contacts_address.postal_code, &pCharValue);
+               _AddressImpl::GetInstance(*pAddress)->SetPostalCode(pCharValue);
+
+               r = pList->Add(*pAddress);
+               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pAddress.release();
+       }
+
+       return pList.release();
+
+}
+
+IList*
+_UserProfileImpl::GetImAddressesN(void) const
+{
+       result r = E_SUCCESS;
+       char* pCharValue = null;
+       int intValue = 0;
+       contacts_record_h messengerHandle = null;
+       unsigned int count = 0;
+       std::unique_ptr<ImAddress> pImAddress(null);
+
+       std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.messenger, &count);
+
+       r = pList->Construct(count);
+       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       for (unsigned int index = 0; index < count; index++)
+       {
+               contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.messenger, index, &messengerHandle);
+
+               pImAddress.reset(new (std::nothrow) ImAddress());
+               SysTryReturn(NID_SCL, pImAddress != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               contacts_record_get_int(messengerHandle, _contacts_messenger.type, &intValue);
+               switch (intValue)
+               {
+               case CONTACTS_MESSENGER_TYPE_GOOGLE:
+                       pImAddress->SetServiceProviderName(IM_ADDRESS_GOOGLE_TALK);
+                       break;
+               case CONTACTS_MESSENGER_TYPE_WLM:
+                       pImAddress->SetServiceProviderName(IM_ADDRESS_MSN);
+                       break;
+               case CONTACTS_MESSENGER_TYPE_ICQ:
+                       pImAddress->SetServiceProviderName(IM_ADDRESS_ICQ);
+                       break;
+               case CONTACTS_MESSENGER_TYPE_AIM:
+                       pImAddress->SetServiceProviderName(IM_ADDRESS_AIM);
+                       break;
+               case CONTACTS_MESSENGER_TYPE_YAHOO:
+                       pImAddress->SetServiceProviderName(IM_ADDRESS_YAHOO);
+                       break;
+               case CONTACTS_MESSENGER_TYPE_QQ:
+                       pImAddress->SetServiceProviderName(IM_ADDRESS_QQ);
+                       break;
+               case CONTACTS_MESSENGER_TYPE_SKYPE:
+                       pImAddress->SetServiceProviderName(IM_ADDRESS_SKYPE);
+                       break;
+               case CONTACTS_MESSENGER_TYPE_JABBER:
+                       pImAddress->SetServiceProviderName(IM_ADDRESS_JABBER);
+                       break;
+               case CONTACTS_MESSENGER_TYPE_IRC:
+                       pImAddress->SetServiceProviderName(IM_ADDRESS_IRC);
+                       break;
+               case CONTACTS_MESSENGER_TYPE_FACEBOOK:
+                       pImAddress->SetServiceProviderName(IM_ADDRESS_FACEBOOK);
+                       break;
+               case CONTACTS_MESSENGER_TYPE_CUSTOM:
+                       // fall through
+               default:
+                       contacts_record_get_str_p(messengerHandle, _contacts_messenger.label, &pCharValue);
+                       pImAddress->SetServiceProviderName(pCharValue);
+                       break;
+               }
+
+               contacts_record_get_str_p(messengerHandle, _contacts_messenger.im_id, &pCharValue);
+               _ImAddressImpl::GetInstance(*pImAddress)->SetImAddress(pCharValue);
+
+               r = pList->Add(*pImAddress);
+               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pImAddress.release();
+       }
+
+       return pList.release();
+
+}
+
+//////////////////
+bool
+_UserProfileImpl::IsEmptyCompany(contacts_record_h companyHandle)
+{
+       char* pCharValue = null;
+
+       contacts_record_get_str_p(companyHandle, _contacts_company.name, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       contacts_record_get_str_p(companyHandle, _contacts_company.job_title, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+
+       contacts_record_get_str_p(companyHandle, _contacts_company.department, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       contacts_record_get_str_p(companyHandle, _contacts_company.role, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       contacts_record_get_str_p(companyHandle, _contacts_company.assistant_name, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+bool
+_UserProfileImpl::IsEmptyName(contacts_record_h nameHandle)
+{
+       char* pCharValue = null;
+
+       contacts_record_get_str_p(nameHandle, _contacts_name.first, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       contacts_record_get_str_p(nameHandle, _contacts_name.last, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       contacts_record_get_str_p(nameHandle, _contacts_name.addition, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       contacts_record_get_str_p(nameHandle, _contacts_name.prefix, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       contacts_record_get_str_p(nameHandle, _contacts_name.suffix, &pCharValue);
+       if (pCharValue != null)
+       {
+               return false;
+       }
+
+       return true;
+
+}
+
+bool
+_UserProfileImpl::IsEmpty(void) const
+{
+       unsigned int count = 0;
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.number, &count);
+       if (count > 0)
+       {
+               return false;
+       }
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.email, &count);
+       if (count > 0)
+       {
+               return false;
+       }
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.url, &count);
+       if (count > 0)
+       {
+               return false;
+       }
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.address, &count);
+       if (count > 0)
+       {
+               return false;
+       }
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.messenger, &count);
+       if (count > 0)
+       {
+               return false;
+       }
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
+       if (count > 0)
+       {
+               return false;
+       }
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.company, &count);
+       if (count > 0)
+       {
+               return false;
+       }
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.event, &count);
+       if (count > 0)
+       {
+               return false;
+       }
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.note, &count);
+       if (count > 0)
+       {
+               return false;
+       }
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.nickname, &count);
+       if (count > 0)
+       {
+               return false;
+       }
+
+       contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.image, &count);
+       if (count > 0)
+       {
+               return false;
+       }
+
+       return true;
+
+}
+
+void
+_UserProfileImpl::SetUserProfileHandle(contacts_record_h profileHandle)
+{
+       contacts_record_destroy(__profileHandle, true);
+
+       __profileHandle = profileHandle;
+}
+
+contacts_record_h
+_UserProfileImpl::GetUserProfileHandle(void) const
+{
+       return __profileHandle;
+}
+
+const _UserProfileImpl*
+_UserProfileImpl::GetInstance(const UserProfile& userProfile)
+{
+       return userProfile.__pUserProfileImpl;
+}
+
+_UserProfileImpl*
+_UserProfileImpl::GetInstance(UserProfile& userProfile)
+{
+       return userProfile.__pUserProfileImpl;
+}
+
+}} // Tizen::Social
diff --git a/src/inc/FScl_AddressbookImpl.h b/src/inc/FScl_AddressbookImpl.h
new file mode 100644 (file)
index 0000000..85be77e
--- /dev/null
@@ -0,0 +1,211 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FScl_AddressbookImpl.h
+* @brief       This is the header file for the _AddressbookImpl class.
+*
+* This header file contains the declarations of the _AddressbookImpl class.
+*/
+
+#ifndef _FSCL_INTERNAL_ADDRESSBOOK_IMPL_H_
+#define _FSCL_INTERNAL_ADDRESSBOOK_IMPL_H_
+
+#include <unique_ptr.h>
+#include <contacts.h>
+#include <FBaseObject.h>
+#include "FScl_IContactDbChangeEventListener.h"
+
+namespace Tizen { namespace Base {
+class String;
+
+namespace Collection {
+class IList;
+template<class Type> class IListT;
+}
+}}
+
+namespace Tizen { namespace Social
+{
+class Addressbook;
+class Contact;
+class Category;
+class UserProfile;
+class IRecordEventListener;
+class IAddressbookEventListener;
+class IAddressbookChangeEventListener;
+
+/**
+ * @class      _AddressbookImpl
+ * @brief      This class handles the _AddressbookImpl operations.
+ * @since      2.0
+ * @see   Addressbook
+ *
+ */
+class _AddressbookImpl
+       : public Tizen::Base::Object
+       , virtual public _IContactDbChangeEventListener
+{
+public:
+       /**
+        * This is default constructor for the class.
+        *
+        * @since       2.0
+        */
+       _AddressbookImpl(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~_AddressbookImpl(void);
+
+       result Construct(void);
+
+       result SetRecordEventListener(IRecordEventListener* pListener);
+
+       result SetAddressbookEventListener(IAddressbookEventListener* pListener);
+
+       result SetAddressbookChangeEventListener(IAddressbookChangeEventListener* pListener);
+
+       void SetId(AddressbookId addressbookId);
+
+       void SetAccountId(AccountId accountId);
+
+       void SetName(const Tizen::Base::String& name);
+
+       AddressbookId GetId(void) const;
+
+       AccountId GetAccountId(void) const;
+
+       Tizen::Base::String GetName(void) const;
+
+       result AddContact(Contact& contact);
+
+       result AddCategory(Category& category);
+
+       result RemoveContact(RecordId contactId);
+
+       result RemoveContact(Contact& contact);
+
+       result RemoveCategory(RecordId categoryId);
+
+       result UpdateContact(const Contact& contact);
+
+       result UpdateCategory(const Category& category);
+
+       Tizen::Base::Collection::IList* GetAllContactsN(void) const;
+
+       Tizen::Base::Collection::IList* GetContactsByCategoryN(RecordId categoryId) const;
+
+       Tizen::Base::Collection::IListT<RecordId>* GetContactIdsByCategoryN(RecordId categoryId) const;
+
+       result AddMemberToCategory(RecordId categoryId, RecordId contactId);
+
+       result RemoveMemberFromCategory(RecordId categoryId, RecordId contactId);
+
+       Tizen::Base::Collection::IList* GetAllCategoriesN(void) const;
+
+       Tizen::Base::Collection::IList* GetCategoriesByContactN(RecordId contactId) const;
+
+       Tizen::Base::Collection::IList* GetContactsN(int pageNo, int countPerPage) const;
+
+       Tizen::Base::Collection::IList* GetContactsInN(const Category& category, int pageNo, int countPerPage) const;
+
+       Tizen::Base::Collection::IList* SearchContactsByEmailN(const Tizen::Base::String& email) const;
+
+       Tizen::Base::Collection::IList* SearchContactsByNameN(const Tizen::Base::String& name) const;
+
+       Tizen::Base::Collection::IList* SearchContactsByPhoneNumberN(const Tizen::Base::String& phoneNumber) const;
+
+       int GetCategoryCount(void) const;
+
+       int GetContactCount(void) const;
+
+       Contact* GetContactN(RecordId contactId) const;
+
+       Category* GetCategoryN(RecordId categoryId) const;
+
+       int GetLatestVersion(void) const;
+
+       Tizen::Base::Collection::IList* GetChangedContactsAfterN(int version, int& latestVersion) const;
+
+       Tizen::Base::Collection::IList* GetChangedCategoriesAfterN(int version, int& latestVersion) const;
+
+       Tizen::Base::Collection::IList* GetChangedContactInfoListN(int version, int& latestVersion) const;
+
+       Tizen::Base::Collection::IList* GetChangedCategoryInfoListN(int version, int& latestVersion) const;
+
+       result AddContacts(const Tizen::Base::Collection::IList& contactList, Tizen::Base::Collection::IListT<RecordId>* pContactIdList);
+
+       result UpdateContacts(const Tizen::Base::Collection::IList& contactList);
+
+       result RemoveContacts(const Tizen::Base::Collection::IListT<RecordId>& contactIdList);
+
+       result SetUserProfile(const UserProfile* pUserProfile);
+
+       UserProfile* GetUserProfileN(void) const;
+
+       bool IsUserProfileChangedAfter(int version) const;
+
+       contacts_record_h CopyMyProfileRecordHandle(contacts_record_h srcHandle);
+
+       virtual void OnContactChanged(void);
+
+       virtual void OnCategoryChanged(void);
+
+       virtual void OnRelationChanged(void);
+
+       contacts_record_h CopyContactRecordHandle(contacts_record_h srcHandle);
+
+       static _AddressbookImpl* GetInstance(Addressbook& addressbook);
+
+       static const _AddressbookImpl* GetInstance(const Addressbook& addressbook);
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @since       2.0
+        */
+       _AddressbookImpl(const _AddressbookImpl& rhs);
+
+       Tizen::Base::Collection::IList* GetChangedGroupsAfterN(int, int&) const;
+
+       Tizen::Base::Collection::IList* GetChangedRelationsAfterN(int, int&) const;
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @since       2.0
+        */
+       _AddressbookImpl& operator =(const _AddressbookImpl& rhs);
+
+private:
+       IRecordEventListener* __pIRecordEventListener;
+       IAddressbookEventListener* __pIAddressbookEventListener;
+       IAddressbookChangeEventListener* __pIAddressbookChangeEventListener;
+       int __dbVersionForContact;
+       int __dbVersionForGroup;
+       int __dbVersionForRelation;
+       AddressbookId __addressbookId;
+       AccountId __accountId;
+       Tizen::Base::String __name;
+};     // _AddressbookImpl
+
+}}  // Tizen::Social
+
+#endif //_FSCL_INTERNAL_ADDRESSBOOK_IMPL_H_
diff --git a/src/inc/FScl_AddressbookManagerImpl.h b/src/inc/FScl_AddressbookManagerImpl.h
new file mode 100644 (file)
index 0000000..88208b6
--- /dev/null
@@ -0,0 +1,236 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FScl_AddressbookManagerImpl.h
+* @brief       This is the header file for the _AddressbookManagerImpl class.
+*
+* This header file contains the declarations of the _AddressbookManagerImpl class.
+*/
+
+#ifndef _FSCL_INTERNAL_ADDRESSBOOK_MANAGER_IMPL_H_
+#define _FSCL_INTERNAL_ADDRESSBOOK_MANAGER_IMPL_H_
+
+#include <unique_ptr.h>
+#include <contacts.h>
+#include <FBaseObject.h>
+#include "FScl_IContactDbChangeEventListener.h"
+
+namespace Tizen { namespace Base {
+class String;
+
+namespace Collection {
+class IList;
+template<class Type> class IListT;
+template<class Type1, class Type2> class HashMapT;
+}
+}}
+
+namespace Tizen { namespace Social
+{
+class Addressbook;
+class AddressbookManager;
+class UserProfile;
+class Contact;
+class Category;
+class IRecordEventListener;
+class IAddressbookEventListener;
+class IAddressbookChangeEventListener;
+
+/**
+ * @class      _AddressbookManagerImpl
+ * @brief      This class handles the _AddressbookManagerImpl operations.
+ * @since      2.0
+ *
+ */
+class _AddressbookManagerImpl
+       : public Tizen::Base::Object
+       , virtual public _IContactDbChangeEventListener
+{
+public:
+       /**
+        * This is default constructor for the class.
+        *
+        * @since       2.0
+        */
+       _AddressbookManagerImpl(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~_AddressbookManagerImpl(void);
+
+       result Construct(void);
+
+       result SetEventListener(IAddressbookEventListener* pListener);
+
+       result SetAddressbookChangeEventListener(IAddressbookChangeEventListener* pListener);
+
+       Addressbook* CreateAddressbookN(AccountId accountId, const Tizen::Base::String& name);
+
+       result DeleteAddressbook(AddressbookId addressbookId);
+
+       Tizen::Base::Collection::IList* GetAddressbooksByAccountN(AccountId accountId) const;
+
+       Tizen::Base::Collection::IList* GetAllAddressbooksN(void) const;
+
+       Addressbook* GetAddressbookN(AddressbookId addressbookId) const;
+
+       result AddContact(Contact& contact, AddressbookId addressbookId);
+
+       result AddCategory(Category& category, AddressbookId addressbookId);
+
+       result RemoveContact(RecordId contactId);
+
+       result RemoveCategory(RecordId categoryId);
+
+       result UpdateContact(const Contact& contact);
+
+       result UpdateCategory(const Category& category);
+
+       result RemovePerson(PersonId personId);
+
+       Tizen::Base::Collection::IList* GetAllPersonsN(void) const;
+
+       Tizen::Base::Collection::IList* GetPersonsByCategoryN(RecordId categoryId) const;
+
+       Tizen::Base::Collection::IList* GetFavoritePersonsN() const;
+
+       Tizen::Base::Collection::IList* SearchPersonsN(const Tizen::Base::String& keyword) const;
+
+       Tizen::Base::Collection::IList* SearchN(const AddressbookFilter& filter, 
+                       unsigned long propertyToSort, Tizen::Base::SortOrder sortOrder, int offset, int maxCount);
+
+       int GetMatchedItemCount(const AddressbookFilter& filter);
+
+       result SetPersonAsFavorite(PersonId personId, bool isFavorite = true);
+
+        result MergePersons(PersonId sourcePersonId, PersonId targetPersonId);
+
+        result UnlinkContact(PersonId personId, RecordId contactId, PersonId& newPersonId);
+
+       Tizen::Base::Collection::IList* GetAllContactsN(void) const;
+
+       Tizen::Base::Collection::IList* GetContactsByCategoryN(RecordId categoryId) const;
+
+       Tizen::Base::Collection::IList* GetContactsByPersonN(PersonId personId) const;
+
+       Tizen::Base::Collection::IListT<RecordId>* GetContactIdsByCategoryN(RecordId categoryId) const;
+
+       result AddMemberToCategory(RecordId categoryId, RecordId contactId);
+
+       result RemoveMemberFromCategory(RecordId categoryId, RecordId contactId);
+
+       Tizen::Base::Collection::IList* GetAllCategoriesN(void) const;
+
+       Tizen::Base::Collection::IList* GetCategoriesByContactN(RecordId contactId) const;
+
+       Tizen::Base::Collection::IList* GetCategoriesByPersonN(PersonId personId) const;
+
+       Tizen::Base::Collection::IList* GetContactsInN(const Category& category, int pageNo, int countPerPage) const;
+
+       Tizen::Base::Collection::IList* SearchContactsByEmailN(const Tizen::Base::String& email) const;
+
+       Tizen::Base::Collection::IList* SearchContactsByNameN(const Tizen::Base::String& name) const;
+
+       Tizen::Base::Collection::IList* SearchContactsByPhoneNumberN(const Tizen::Base::String& phoneNumber) const;
+
+       int GetCategoryCount(void) const;
+
+       int GetContactCount(void) const;
+
+       Contact* GetContactN(RecordId contactId) const;
+
+       Person* GetPersonN(PersonId personId) const;
+
+       Category* GetCategoryN(RecordId categoryId) const;
+
+       int GetLatestVersion(void) const;
+
+       Tizen::Base::Collection::IList* GetChangedContactsAfterN(int version, int& latestVersion) const;
+
+       Tizen::Base::Collection::IList* GetChangedCategoriesAfterN(int version, int& latestVersion) const;
+
+       virtual void OnContactChanged(void);
+
+       virtual void OnCategoryChanged(void);
+
+       virtual void OnRelationChanged(void);
+
+       Tizen::Base::Collection::IList* ParseContactsFromVcardN(const Tizen::Base::String& vcardPath);
+
+       result ExportPersonToVcard(const Person& person, const Tizen::Base::String& vcardPath);
+
+       result ExportPersonsToVcard(const Tizen::Base::Collection::IList& personList, const Tizen::Base::String& vcardPath);
+
+       result ExportContactToVcard(const Contact& contact, const Tizen::Base::String& vcardPath);
+
+       result ExportContactsToVcard(const Tizen::Base::Collection::IList& contactList, const Tizen::Base::String& vcardPath);
+
+       Tizen::Base::ByteBuffer* ExportContactToVcardStreamN(const Contact& contact);
+
+       Tizen::Base::ByteBuffer*  ExportContactsToVcardStreamN(const Tizen::Base::Collection::IList& contactList);
+
+       Tizen::Base::ByteBuffer*  ExportPersonToVcardStreamN(const Person& person);
+
+       Tizen::Base::ByteBuffer*  ExportPersonsToVcardStreamN(const Tizen::Base::Collection::IList& personList);
+
+       Tizen::Base::Collection::IList* ParseVcardStreamN(const Tizen::Base::ByteBuffer& vcardStream);
+
+       Tizen::Base::ByteBuffer* ExportUserProfileToVcardStreamN(const UserProfile& userProfile);
+
+       Tizen::Base::ByteBuffer* ExportUserProfilesToVcardStreamN(const Tizen::Base::Collection::IList& userProfileList);
+
+       result ExportUserProfileToVcard(const UserProfile& userProfile, const Tizen::Base::String& vcardPath);
+
+       result ExportUserProfilesToVcard(const Tizen::Base::Collection::IList& userProfileList, const Tizen::Base::String& vcardPath);
+
+       Tizen::Base::Collection::IList* GetAllUserProfilesN(void) const;
+
+       UserProfile* GetUserProfileN(AddressbookId addressbookId) const;
+
+       static bool OnEachContact(contacts_record_h recordHandle, void* pUserData);
+
+       contacts_record_h CopyContactRecordHandle(contacts_record_h srcHandle);
+
+       static _AddressbookManagerImpl* GetInstance(AddressbookManager& addressbookManager);
+
+       static const _AddressbookManagerImpl* GetInstance(const AddressbookManager& addressbookManager);
+
+private:
+       Tizen::Base::Collection::IListT<int>* SearchAddressbooksByAccountIdN(AccountId accountId) const;
+
+       Tizen::Base::Collection::IList* GetChangedGroupsAfterN(int version, int& latestVersion) const;
+
+       Tizen::Base::Collection::IList* GetChangedRelationsAfterN(int version, int& latestVersion) const;
+
+       _AddressbookManagerImpl& operator =(const _AddressbookManagerImpl& rhs);
+
+       _AddressbookManagerImpl(const _AddressbookManagerImpl& rhs);
+
+private:
+       IAddressbookEventListener* __pIAddressbookEventListener;
+       IAddressbookChangeEventListener* __pIAddressbookChangeEventListener;
+       int __dbVersionForContact;
+       int __dbVersionForGroup;
+       int __dbVersionForRelation;
+       Tizen::Base::Collection::HashMapT<int, int>* __pIdMap;
+};     // _AddressbookManagerImpl
+
+}}  // Tizen::Social
+
+#endif //_FSCL_INTERNAL_ADDRESSBOOK_MANAGER_IMPL_H_
diff --git a/src/inc/FScl_CalEventChangeInfoImpl.h b/src/inc/FScl_CalEventChangeInfoImpl.h
new file mode 100644 (file)
index 0000000..54b9235
--- /dev/null
@@ -0,0 +1,163 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_CalEventChangeInfoImpl.h
+ * @brief      This is the header file for the _CalEventChangeInfoImpl class.
+ *
+ * This header file contains the declarations of the _CalEventChangeInfoImpl class.
+ */
+
+#ifndef _FSCL_INTERNAL_CAL_EVENT_CHANGE_INFO_IMPL_H_
+#define _FSCL_INTERNAL_CAL_EVENT_CHANGE_INFO_IMPL_H_
+
+#include <FBaseObject.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+
+class CalEventChangeInfo;
+
+/**
+ *     @class  _CalEventChangeInfoImpl
+ */
+class _CalEventChangeInfoImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        */
+       _CalEventChangeInfoImpl(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @param[in]   rhs             An instance of _CalEventChangeInfoImpl
+        */
+       _CalEventChangeInfoImpl(const _CalEventChangeInfoImpl& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        */
+       virtual ~_CalEventChangeInfoImpl(void);
+
+       /**
+        * Compares the input Object with the calling %_CalEventChangeInfoImpl instance.
+        *
+        * @return              @c true if the input object equals the calling %_CalEventChangeInfoImpl instance, @n
+        *                              else @c false
+        * @param[in]   rhs     The object instance to compare with the calling object
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @return              The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the change type.
+        *
+        * @return              The change type
+        */
+       RecordChangeType GetChangeType(void) const;
+
+       /**
+        * Gets the changed event Id.
+        *
+        * @return              The changed event Id
+        */
+       RecordId GetEventId(void) const;
+
+       /**
+        * Gets the calendar ID that the changed event belongs to.
+        *
+        * @return              The calendar ID that the changed event belongs to
+        */
+       RecordId GetCalendarId(void) const;
+
+       /**
+        * Gets the version of the change.
+        *
+        * @return              The version of the change
+        */
+       int GetVersion(void) const;
+
+       /**
+        * Sets the change type.
+        *
+        * @param[in]   changeType                      The change type
+        */
+       void SetChangeType(RecordChangeType changeType);
+
+       /**
+        * Sets the event ID.
+        *
+        * @param[in]   eventId                 The event ID
+        */
+       void SetEventId(RecordId eventId);
+
+       /**
+        * Sets the calendar ID.
+        *
+        * @param[in]   accountId                       The calendar ID
+        */
+       void SetCalendarId(RecordId calendarId);
+
+       /**
+        * Sets the version.
+        *
+        * @param[in]   version                 The version
+        */
+       void SetVersion(int version);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return                      The pointer to _CalEventChangeInfoImpl
+        * @param[in]   calEventChangeInfo              An instance of %CalEventChangeInfo class
+        */
+       static _CalEventChangeInfoImpl* GetInstance(CalEventChangeInfo& calEventChangeInfo);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return                      The pointer to const _CalEventChangeInfoImpl
+        * @param[in]   calEventChangeInfo              A const instance of %CalEventChangeInfo class
+        */
+       static const _CalEventChangeInfoImpl* GetInstance(const CalEventChangeInfo& calEventChangeInfo);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @param[in]   rhs             An instance of _CalEventChangeInfoImpl
+        */
+       _CalEventChangeInfoImpl& operator =(const _CalEventChangeInfoImpl& rhs);
+
+private:
+       RecordChangeType __changeType;
+       RecordId __eventId;
+       RecordId __calendarId;
+       int __version;
+
+};     // _CalEventChangeInfoImpl
+
+}}     // Tizen::Social
+
+#endif //_FSCL_INTERNAL_CAL_EVENT_CHANGE_INFO_IMPL_H_
diff --git a/src/inc/FScl_CalEventImpl.h b/src/inc/FScl_CalEventImpl.h
new file mode 100644 (file)
index 0000000..2b8d520
--- /dev/null
@@ -0,0 +1,609 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_CalEventImpl.h
+ * @brief      This is the header file for the _CalEventImpl class.
+ *
+ * This header file contains the declarations of the _CalEventImpl class.
+ */
+
+#ifndef _FSCL_INTERNAL_CALEVENT_IMPL_H_
+#define _FSCL_INTERNAL_CALEVENT_IMPL_H_
+
+#include <unique_ptr.h>
+#include <calendar2.h>
+#include <FBaseColAllElementsDeleter.h>
+#include <FBaseDateTime.h>
+#include <FSclTypes.h>
+#include "FScl_CalendarbookUtil.h"
+
+namespace Tizen { namespace Base
+{
+class String;
+namespace Collection
+{
+class IList;
+}
+}}
+
+namespace Tizen { namespace Locales
+{
+class TimeZone;
+}}
+
+namespace Tizen { namespace Social
+{
+
+class Calendar;
+class CalEvent;
+class Reminder;
+class Recurrence;
+class Attendee;
+
+/**
+ *     @class  _CalEventImpl
+ *     @brief  This class provides methods to manage the information of a calendarbook event.
+ */
+class _CalEventImpl:
+       public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        */
+       _CalEventImpl(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @param[in]   rhs             An instance of _CalEventImpl
+        */
+       _CalEventImpl(const _CalEventImpl& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        */
+       virtual ~_CalEventImpl(void);
+
+       /**
+        * Checks if this instance is a _CalEventImpl instance or not. @n
+        * One-time _CalEventImpl has only one instance and recurring _CalEventImpl has more than one instances. @n
+        * Each instance of _CalEventImpl has its own recurrence ID.
+        *
+        * @return              @c true, if this instance is a _CalEventImpl instance @n
+        *                                              @c false, otherwise
+        */
+       bool IsInstance(void) const;
+
+       /**
+        * Checks if this instance has a recurring pattern or not.
+        *
+        * @return              @c true, if this instance has the Recurrence @n
+        *                                              @c false, otherwise
+        */
+       bool IsRecurring(void) const;
+
+       /**
+        * Gets the original CalEventId. @n
+        * _CalEventImpl instance has original CalEventId which is a record ID of its entry.
+        *
+        * @return      The original _CalEventImpl ID @n
+        *                                      #INVALID_RECORD_ID, if the RecordId is invalid
+        */
+       RecordId GetOriginalCalEventId(void) const;
+
+       /**
+        * Checks if the event is all day event or not.
+        *
+        * @return              @c true, if this event is all day event @n
+        *                                              @c false, otherwise
+        */
+       bool IsAllDayEvent(void) const;
+
+       /**
+        * Sets the event as an all day event.
+        *
+        * @param[in]   isAllDayEvent   Set to @c true to make it an all day event @n
+        *                                                              @c false, otherwise
+        */
+       void SetAllDayEvent(bool isAllDayEvent);
+
+       /**
+        * Gets the globally unique ID. @n
+        * UID: globally Unique IDentifier (vCalendar 1.0)
+        *
+        * @return              The Globally unique ID
+        * @exception   E_SUCCESS                               The method was successful.
+        * @exception   E_OUT_OF_MEMORY                 Insufficient memory.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::ByteBuffer* GetUIDN(void) const;
+
+       /**
+        * Sets the globally unique ID.
+        * UID: globally Unique IDentifier (vCalendar 1.0)
+        *
+        * @return              An error code
+        * @param[in]   pUid                                    The Globally unique ID
+        * @exception   E_SUCCESS                               The method was successful.
+        * @exception   E_OUT_OF_MEMORY                 Insufficient memory.
+        */
+       result SetUID(const Tizen::Base::ByteBuffer* pUid);
+
+       /**
+        * Gets the globally unique ID. @n
+        * UID: globally Unique IDentifier (vCalendar 1.0)
+        *
+        * @since       2.0
+        *
+        * @return              The globally unique ID
+        */
+       Tizen::Base::String GetUid(void) const;
+
+       /**
+        * Sets the globally unique ID.
+        * UID: globally Unique IDentifier (vCalendar 1.0)
+        *
+        * @since       2.0
+        *
+        * @param[in]   uid                                     The globally unique ID
+        */
+       void SetUid(const Tizen::Base::String& uid);
+
+       /**
+        * Gets the event status. @n
+        * The default status is #EVENT_STATUS_NONE.
+        *
+        * @return              The event status
+        * @see                         EventStatus
+        */
+       EventStatus GetStatus(void) const;
+
+       /**
+        * Sets the status
+        *
+        * @param[in]   status          The status
+        * @see                         EventStatus
+        */
+       void SetStatus(EventStatus status);
+
+       /**
+        * Gets the busy status. @n
+        * The default busy status is #BUSY_STATUS_BUSY.
+        *
+        * @return              The busy status
+        * @see                         BusyStatus
+        */
+       BusyStatus GetBusyStatus(void) const;
+
+       /**
+        * Sets the busy status.
+        *
+        * @param[in]   busyStatus The busy status
+        * @see                         BusyStatus
+        */
+       void SetBusyStatus(BusyStatus busyStatus);
+
+       /**
+        * Gets the priority level of the current instance of _CalEventImpl. @n
+        * The default priority level is #EVENT_PRIORITY_LOW.
+        *
+        * @return              The priority level
+        */
+       EventPriority GetPriority(void) const;
+
+       /**
+        * Sets the priority level of the current instance of _CalEventImpl.
+        *
+        * @param[in]   priority                The priority level to set
+        */
+       void SetPriority(EventPriority priority);
+
+       /**
+        * Adds an attendee.
+        *
+        * @return              An error code
+        * @param[in]   attendee                        The Attendee to add  @n
+        *                                                                      It must have an e-mail address.
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_OBJ_ALREADY_EXIST     An attendee with the same e-mail address already exists.
+        * @exception   E_OUT_OF_MEMORY         Insufficient memory.
+        * @remarks The Attendee values may be lost if an anniversary event including the attendee is modified in the base application.
+        */
+       result AddAttendee(const Attendee& attendee);
+
+       /**
+        * Removes an attendee.
+        *
+        * @return              An error code
+        * @param[in]   attendee                        The Attendee to remove  @n
+        *                                                                      It must have an e-mail address.
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_OBJ_NOT_FOUND         An attendee which has the same e-mail address was not found.
+        */
+       result RemoveAttendee(const Attendee& attendee);
+
+       /**
+        * Gets a list of all attendees.
+        *
+        * @return              A list of #Attendee instances
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @see                 Attendee
+        */
+       Tizen::Base::Collection::IList* GetAllAttendeesN(void) const;
+
+       /**
+        * Gets the time zone.
+        *
+        * @return              The time zone
+        * @see                 Tizen::Locales::TimeZone
+        */
+       Tizen::Locales::TimeZone        GetTimeZone(void) const;
+
+       /**
+        * Sets the time zone. @n
+        * Recurrence is calculated based on the time zone, thus the time zone must be set before setting a recurrence.
+        * If the time zone is not set, it will be considered as Greenwich Mean Time (GMT) 0.
+        *
+        * @return              An error code
+        * @param[in]   timeZone                                The time zone to set
+        * @exception   E_SUCCESS                               The method was successful.
+        * @exception   E_FAILURE                               The method failed.
+        * @remarks             As anniversaries and all day events are not affected by a time zone, it is recommended not to set the time zone.
+        * @see                         Tizen::Locales::TimeZone
+        * @remarks             As anniversaries and all day events are not affected by a time zone, it is recommended not to set the time zone.
+        */
+       result SetTimeZone(const Tizen::Locales::TimeZone& timeZone);
+
+       /**
+        * Gets the recurrence ID. @n
+        * This method works only for _CalEventImpl instances.
+        *
+        * @return              The RecurrenceId
+        * @exception   E_SUCCESS                               The method was successful.
+        * @exception   E_INVALID_STATE                 The instance does not have recurrence or is not a _CalEventImpl instance (does not have a RecurrenceId).
+        */
+       RecurrenceId    GetRecurrenceId(void) const;
+
+       /**
+        * Gets the subject of the current _CalEventImpl.
+        *
+        * @return              The subject @n
+        *                                              @c null, if there is no subject value
+        */
+       Tizen::Base::String GetSubject(void) const;
+
+       /**
+        * Gets the description of the current _CalEventImpl.
+        *
+        * @return      The description
+        */
+       Tizen::Base::String GetDescription(void) const;
+
+       /**
+        * Gets the start date and time of the current _CalEventImpl.
+        *
+        * @return              An instance of DateTime representing the start date and time
+        */
+       Tizen::Base::DateTime GetStartTime(void) const;
+
+       /**
+        * Gets the end date and time of the current _CalEventImpl.
+        *
+        * @return              An instance of DateTime representing the end date and time
+        */
+       Tizen::Base::DateTime GetEndTime(void) const;
+
+       /**
+        * Gets the location of the current _CalEventImpl.
+        *
+        * @return      The location
+        */
+       Tizen::Base::String GetLocation(void) const;
+
+       /**
+        * Gets the category of the current _CalEventImpl.
+        *
+        * @return              The category of the event
+        */
+       EventCategory GetCategory(void) const;
+
+       /**
+        * Gets the sensitivity of the current _CalEventImpl. @n
+        * The default value is #SENSITIVITY_PUBLIC.
+        *
+        * @return              The sensitivity of the event
+        */
+       RecordSensitivity GetSensitivity(void) const;
+
+       /**
+        * Gets the reminder for the current _CalEventImpl.
+        *
+        * @return              Pointer to an instance of Reminder @n
+        *                                              @c null, if the reminder is not set
+        */
+       const Reminder* GetReminder(void) const;
+
+       /**
+        * Gets the recurrence of the current _CalEventImpl.
+        *
+        * @return              Pointer to an instance of Recurrence @n
+        *                                              @c null, if the event is not a recurring event
+        */
+       const Recurrence* GetRecurrence(void) const;
+
+       /**
+        * Gets the last updated date and time of the current instance of _CalEventImpl.
+        *
+        * @return              The last updated date and time
+        */
+       Tizen::Base::DateTime GetLastRevisedTime(void) const;
+
+       /**
+        * Sets the subject of the current _CalEventImpl.
+        *
+        * @return              An error code
+        * @param[in]   subject         The subject of the event
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_ARG           The length of the specified @c subject exceeds #MAX_EVENT_SUBJECT_LENGTH.
+        */
+       result SetSubject(const Tizen::Base::String& subject);
+
+       /**
+        * Sets the description of the current _CalEventImpl.
+        *
+        * @return              An error code
+        * @param[in]   description                     The description of the event
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_ARG           The length of the specified @c description exceeds #MAX_EVENT_DESCRIPTION_LENGTH.
+        */
+       result SetDescription(const Tizen::Base::String& description);
+
+       /**
+        * Sets the start and end date and time of the current _CalEventImpl. @n
+        * If the start date and time is not fixed, the default date and time are set.
+        * The default start date and time is the current time. @n
+        * The start date and time must be earlier than or equal to the end date and time. @n
+        * If the recurrence date is already set, this method returns an exception. @n
+        *
+        * @return              An error code
+        * @param[in]   start                   The start date and time
+        * @param[in]   end                             The end date and time
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_ARG           The specified @c dtEnd value is earlier than the specified @c dtStart value.
+        * @exception   E_INVALID_CONDITION     The recurrence date is already set.
+        * @remarks             The start and end time of the anniversary and all day events created from the base applications is the local time of the location where they are added.
+        *              All the other events are Coordinated Universal Time (UTC). @n In order to integrate it with the base applications, set the
+        *              start and end time properly according to the above guidelines. @n
+        *              If the seconds value of the start time is set, alarm will not be fired.
+        * @remarks             There is no automatic time conversion based on the time zone property of the current _CalEventImpl.
+        */
+       result SetStartAndEndTime(const Tizen::Base::DateTime& start, const Tizen::Base::DateTime& end);
+
+       /**
+        * Sets the location of the current _CalEventImpl.
+        *
+        * @return              An error code
+        * @param[in]   location                        The location of the event
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_ARG           The length of the specified @c location exceeds #MAX_EVENT_LOCATION_LENGTH.
+        */
+       result SetLocation(const Tizen::Base::String& location);
+
+       /**
+        * Sets the category of the current _CalEventImpl. @n
+        * If the category is not set, the default category (#EVENT_CATEGORY_APPOINTMENT) is set.
+        *
+        * @param[in]   category                        The category of the event @n
+        * @remarks             The start and end time of the anniversary and all day events created from the base applications is the local time of the location where they are added.
+        *              All the other events are Coordinated Universal Time (UTC). @n In order to integrate it with the base applications, set the
+        *              start and end time properly according to the above guidelines.
+        */
+       void SetCategory(EventCategory category);
+
+       /**
+        * Sets the sensitivity of the current _CalEventImpl.
+        *
+        * @param[in]   sensitivity                     The sensitivity of the event @n
+        */
+       void  SetSensitivity(RecordSensitivity sensitivity);
+
+       /**
+        * Sets the coordinates.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   latitude                The latitude in the range. The valid range is [-90.0, 90.0]
+        * @param[in]   longitude               The longitude in the range. The valid range is [-180.0, 180.0]
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The latitude or longitude is out of the valid range.
+        */
+       result SetCoordinates(double latitude, double longitude);
+
+       /**
+        * Gets the coordinates.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[out]  latitude                The latitude
+        * @param[out]  longitude               The longitude
+        */
+       void GetCoordinates(double& latitude, double& longitude) const;
+
+       /**
+        * Sets the reminder of the current _CalEventImpl.
+        *
+        * @return              An error code
+        * @param[in]   pReminder                               The reminder to set @n
+                                                                                       @c null to remove the previous reminder
+        * @exception   E_SUCCESS                               The method was successful.
+        * @exception   E_OUT_OF_MEMORY                 Insufficient memory.
+        *
+        */
+       result SetReminder(const Reminder* pReminder);
+
+       /**
+        * Sets the recurrence of the current _CalEventImpl. @n
+        * Recurrences for categories such as Anniversary only accept a yearly pattern.
+        * The recurrence rule date should be equal to the start date of the event.
+        * If the event start date is different than the recurrence rule date, the event start date is set to match the recurrence rule date. @n
+        * For example, if an event start date is 17/02/2010 which is Wednesday and the recurrence rule date is Thursday of every week,
+        * the event start date changes to 18/02/2010 after this method is called. @n
+        * Note that the start/end date and the time zone must be set before setting a recurrence.
+        *
+        * @return              An error code
+        * @param[in]   pRecurrence                             The recurrence to set @n
+                                                                                       @c null, to remove the previous recurrence
+        * @exception   E_SUCCESS                               The method was successful.
+        * @exception   E_INVALID_STATE                 The instance is a _CalEventImpl instance (has a RecurrenceId).
+        * @exception   E_TYPE_MISMATCH                 The recurrence pattern is not a yearly pattern in case of the event being an Anniversary.
+        * @exception   E_INVALID_CONDITION             The recurrence rule date is earlier than the start or end date and time of the event. @n
+        *                                                                              Or, the recurrence rule is invalid, for example the rule 2/30/2010 for a yearly pattern. @n
+        *                                                                              Or, the duration of the event is too long. It should be shorter than the (interval x frequency) days set for the recurrence rule.
+        * @exception   E_INVALID_ARG                   When the frequency is #FREQ_WEEKLY, #DayOfWeek is not set. @n
+        *                                                                              When The frequency is #FREQ_MONTHLY, neither #DayOfMonth nor #DayOfWeek and #WeekOfMonth are not set. @n
+        *                                                                              When The frequency is #FREQ_YEARLY, neither #DayOfMonth and #MonthOfYear nor #DayOfWeek, #WeekOfMonth and #MonthOfYear are not set. @n
+        *                                                                              When The frequency is #FREQ_YEARLY and #MonthOfYear is 2, #DayOfMonth is greater than 29 ( > 29 ). @n
+        *                                                                              When The frequency is #FREQ_YEARLY and #MonthOfYear is 4 or 6 or 9 or 11, #DayOfMonth is greater than 30 ( > 30 ).
+        * @exception   E_SYSTEM                                A system error occurred.
+        * @exception   E_OUT_OF_MEMORY                 Insufficient memory.
+        *
+        */
+       result SetRecurrence(const Recurrence* pRecurrence);
+
+       /**
+        * Adds a reminder.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   reminder                        The reminder to be added
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        */
+       result AddReminder(const Reminder& reminder);
+
+       /**
+        * Removes a reminder at the index.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   index                           The index of reminder to be removed
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_RANGE          The index is either equal to or greater than the number of reminders or less than 0.
+        */
+       result RemoveReminderAt(int index);
+
+       /**
+        * Gets a list of all the reminders.
+        *
+        * @since       2.0
+        *
+        * @return              A list containing the Reminder instances, @n
+        *                              else an empty list if there are no reminders
+        */
+       const Tizen::Base::Collection::IList& GetAllReminders(void) const;
+
+       /**
+        * Gets the ID of the calendar that this event belongs to. @n
+        *
+        * @return              The calendar Id
+        */
+       RecordId GetCalendarId(void) const;
+
+       RecordId GetBaseEventId(void) const;
+
+       /**
+        * Sets the original event ID
+        *
+        * @param[in]   originalEventId                         The original event ID
+        */
+       void SetOriginalCalEventId(RecordId originalEventId);
+
+       //
+       // Sets the record handle
+       //
+       void SetRecordHandle(calendar_record_h eventHandle);
+
+       //
+       // Gets the record handle
+       //
+       calendar_record_h GetRecordHandle(void) const;
+
+       static CalEvent* CreateDefaultInstanceN(void);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return                      The pointer to _CalEventImpl
+        * @param[in]   event           An instance of %CalEvent class
+        */
+       static _CalEventImpl* GetInstance(CalEvent& event);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return                      The pointer to const _CalEventImpl
+        * @param[in]   event           A const instance of %CalEvent class
+        */
+       static const _CalEventImpl* GetInstance(const CalEvent& event);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @param[in]   rhs             An instance of _CalEventImpl
+        */
+       _CalEventImpl& operator =(const _CalEventImpl& rhs);
+
+private:
+       result SetStartAndEndTimeCommon(const Tizen::Base::DateTime& start, const Tizen::Base::DateTime& end);
+       result ConvertRecurrenceToEventHandle(const Recurrence& recurrence, calendar_record_h eventHandle) const;
+       Recurrence*     ConvertEventHandleToRecurrenceN(calendar_record_h eventHandle) const;
+
+       int ConvertRRuleByDayStringToDayOfWeek(const Tizen::Base::String& byDay) const;
+       result ConvertRRuleByDayStringToDayOfWeekAndWeekOfMonth(const Tizen::Base::String& byDay, int& weekOfMonth, int& dayOfWeek) const;
+       result ConvertRRuleExDateStringToRecurrence(const Tizen::Base::String& exdate, Recurrence& recurrence) const;
+       result ConvertDayOfWeekToRRuleByDayString(int dayOfWeek, int weekOfMonth, Tizen::Base::String& byDayString) const;
+       Tizen::Base::String ConvertRecurrenceToRRuleExDateString(const Recurrence& recurrence, bool isDate) const;
+
+       int GetAttendeeIndex(const char* pAttendeeEmail);
+       result VerifyRecurrence(const Recurrence& recurrence);
+       result ResetStartAndEndTimeByRecurrence(const Recurrence& recurrence);
+
+       CalDayOfWeek GetNextDayOfWeek(CalDayOfWeek currentDay);
+       Tizen::Base::DateTime GetDate(int year, int month, int weekOfMonth, CalDayOfWeek dayOfWeek, const Tizen::Base::DateTime& time, const Locales::TimeZone& timeZone);
+       CalDayOfWeek GetDayOfWeek(const Tizen::Base::DateTime& date, const Locales::TimeZone& timeZone);
+       CalDayOfWeek GetFirstDay(CalDayOfWeek weekStart, int dayOfWeek, int& count);
+       CalDayOfWeek GetNextDay(int dayOfWeek, CalDayOfWeek currentDay);
+
+private:
+       RecordId __originalEventId;
+       bool __isInstance;
+       mutable std::unique_ptr<Recurrence> __pRecurrence;
+       mutable Tizen::Base::Collection::ArrayList __reminderList;
+       mutable bool __reminderListUpdated;
+
+       _CalendarRecord __eventRecord;
+
+};     // _CalEventImpl
+
+}}     // Tizen::Social
+
+#endif//_FSCL_INTERNAL_CALEVENT_IMPL_H_
+
diff --git a/src/inc/FScl_CalEventInstanceImpl.h b/src/inc/FScl_CalEventInstanceImpl.h
new file mode 100644 (file)
index 0000000..36d1757
--- /dev/null
@@ -0,0 +1,324 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_CalEventInstanceImpl.h
+ * @brief      This is the header file for the _CalEventInstanceImpl class.
+ *
+ * This header file contains the declarations of the _CalEventInstanceImpl class.
+ */
+
+#ifndef _FSCL_INTERNAL_CAL_EVENT_INSTANCE_IMPL_H_
+#define _FSCL_INTERNAL_CAL_EVENT_INSTANCE_IMPL_H_
+
+#include <FBaseObject.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+class DateTime;
+} }
+
+namespace Tizen { namespace Social
+{
+
+class CalEventInstance;
+
+/**
+ *     @class  _CalEventInstanceImpl
+ *     @brief  This class provides
+ */
+class _CalEventInstanceImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        */
+       _CalEventInstanceImpl(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @param[in]   rhs             An instance of _CalEventInstanceImpl
+        */
+       _CalEventInstanceImpl(const _CalEventInstanceImpl& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        */
+       virtual ~_CalEventInstanceImpl(void);
+
+       /**
+        * Compares the input Object with the calling %_CalEventInstanceImpl instance.
+        *
+        * @return              @c true if the input object equals the calling %_CalEventInstanceImpl instance, @n
+        else @c false
+        * @param[in]   rhs     The object instance to compare with the calling object
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @return              The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the original event ID.
+        *
+        * @since       2.0
+        *
+        * @return              The original event ID.
+        */
+       RecordId GetOriginalEventId(void) const;
+
+       /**
+        * Gets the calendar ID.
+        *
+        * @since       2.0
+        *
+        * @return              The calendar ID, @n
+        *                              else @c INVALID_RECORD_ID if the instance is not associated with any calendar.
+        */
+       RecordId GetCalendarId(void) const;
+
+       /**
+        * Gets the start time.
+        *
+        * @since       2.0
+        *
+        * @return              The start time.
+        */
+       Tizen::Base::DateTime GetStartTime(void) const;
+
+       /**
+        * Gets the end time.
+        *
+        * @since       2.0
+        *
+        * @return              The end time.
+        */
+       Tizen::Base::DateTime GetEndTime(void) const;
+
+       /**
+        * Gets the subject.
+        *
+        * @since       2.0
+        *
+        * @return              The subject.
+        */
+       Tizen::Base::String GetSubject(void) const;
+
+       /**
+        * Gets the description.
+        *
+        * @since       2.0
+        *
+        * @return              The description.
+        */
+       Tizen::Base::String GetDescription(void) const;
+
+       /**
+        * Gets the location.
+        *
+        * @since       2.0
+        *
+        * @return              The location.
+        */
+       Tizen::Base::String GetLocation(void) const;
+
+       /**
+        * Checks whether the original event of this instance  is an all day event.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the original event of this instance is an all day event, @n
+        *                              else @c false
+        */
+       bool IsAllDayEvent(void) const;
+
+       /**
+        * Gets the busy status.
+        *
+        * @since       2.0
+        *
+        * @return              The busy status.
+        */
+       BusyStatus GetBusyStatus(void) const;
+
+       /**
+        * Gets the event status of the original event.
+        *
+        * @since       2.0
+        *
+        * @return              The event status of the original event.
+        */
+       EventStatus GetStatus(void) const;
+
+       /**
+        * Gets the priority level of the original event.
+        *
+        * @since       2.0
+        *
+        * @return              The priority level
+        */
+       EventPriority GetPriority(void) const;
+
+       /**
+        * Gets the sensitivity of the original event.
+        *
+        * @since       2.0
+        *
+        * @return              The sensitivity of the original event
+        */
+       RecordSensitivity GetSensitivity(void) const;
+
+       /**
+        * Checks whether the event instance has a recurring pattern.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the event instance has a recurring pattern, @n
+        *                              else @c false
+        */
+       bool IsRecurring(void) const;
+
+       /**
+        * Checks whether the event instance has reminders.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the event instance has reminders, @n
+        *                              else @c false
+        */
+       bool HasReminder(void) const;
+
+       //
+       // Sets the original event ID
+       //
+       void SetOriginalEventId(RecordId originalEventId);
+
+       //
+       // Sets the calendar ID
+       //
+       void SetCalendarId(RecordId calendarId);
+
+       //
+       // Sets the start time
+       //
+       void SetStartTime(const Tizen::Base::DateTime& startTime);
+
+       //
+       // Sets the end time
+       //
+       void SetEndTime(const Tizen::Base::DateTime& endTime);
+
+       //
+       // Sets the subject
+       //
+       void SetSubject(const Tizen::Base::String& subject);
+
+       //
+       // Sets the description
+       //
+       void SetDescription(const Tizen::Base::String& description);
+
+       //
+       // Sets the location
+       //
+       void SetLocation(const Tizen::Base::String& location);
+
+       //
+       // Sets whether the event instance is all day event or not
+       //
+       void SetAllDayEvent(bool isAllDayEvent);
+
+       //
+       // Sets the busy status
+       //
+       void SetBusyStatus(BusyStatus busyStatus);
+
+       //
+       // Sets the status
+       //
+       void SetStatus(EventStatus status);
+
+       //
+       // Sets the priority
+       //
+       void SetPriority(EventPriority priority);
+
+       //
+       // Sets the sensitivity
+       //
+       void SetSensitivity(RecordSensitivity sensitivity);
+
+       //
+       // Sets whether the event instance is recurring or not
+       //
+       void SetRecurring(bool isRecurring);
+
+       //
+       // Sets whether the event instance is reminder or not
+       //
+       void SetHasReminder(bool hasReminder);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return                      The pointer to _CalEventInstanceImpl
+        * @param[in]   eventInstance           An instance of %CalEventInstance class
+        */
+       static _CalEventInstanceImpl* GetInstance(CalEventInstance& eventInstance);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return                      The pointer to const _CalEventInstanceImpl
+        * @param[in]   eventInstance           A const instance of %CalEventInstance class
+        */
+       static const _CalEventInstanceImpl* GetInstance(const CalEventInstance& eventInstance);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @param[in]   rhs             An instance of _CalEventInstanceImpl
+        */
+       _CalEventInstanceImpl& operator =(const _CalEventInstanceImpl& rhs);
+
+private:
+       RecordId __originalEventId;
+       RecordId __calendarId;
+       Tizen::Base::DateTime __startDateTime;
+       Tizen::Base::DateTime __endDateTime;
+       Tizen::Base::String __subject;
+       Tizen::Base::String __description;
+       Tizen::Base::String __location;
+       bool __isAllDayEvent;
+       BusyStatus __busyStatus;
+       EventStatus __status;
+       EventPriority __priority;
+       RecordSensitivity __sensitivity;
+       bool __isRecurring;
+       bool __hasReminder;
+};
+// _CalEventInstanceImpl
+
+}} // Tizen::Social
+
+#endif//_FSCL_INTERNAL_CAL_EVENT_INSTANCE_IMPL_H_
diff --git a/src/inc/FScl_CalTodoChangeInfoImpl.h b/src/inc/FScl_CalTodoChangeInfoImpl.h
new file mode 100644 (file)
index 0000000..c8ec903
--- /dev/null
@@ -0,0 +1,164 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_CalTodoChangeInfoImpl.h
+ * @brief      This is the header file for the _CalTodoChangeInfoImpl class.
+ *
+ * This header file contains the declarations of the _CalTodoChangeInfoImpl class.
+ */
+
+#ifndef _FSCL_INTERNAL_CAL_TODO_CHANGE_INFO_IMPL_H_
+#define _FSCL_INTERNAL_CAL_TODO_CHANGE_INFO_IMPL_H_
+
+#include <FBaseObject.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+
+class CalTodoChangeInfo;
+
+/**
+ *     @class  _CalTodoChangeInfoImpl
+ */
+class _CalTodoChangeInfoImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        */
+       _CalTodoChangeInfoImpl(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @param[in]   rhs             An instance of _CalTodoChangeInfoImpl
+        */
+       _CalTodoChangeInfoImpl(const _CalTodoChangeInfoImpl& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        */
+       virtual ~_CalTodoChangeInfoImpl(void);
+
+       /**
+        * Compares the input Object with the calling %_CalTodoChangeInfoImpl instance.
+        *
+        * @return              @c true if the input object equals the calling %_CalTodoChangeInfoImpl instance, @n
+                                       else @c false
+        * @param[in]   rhs     The object instance to compare with the calling object
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @return              The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the change type.
+        *
+        * @return              The change type
+        */
+       RecordChangeType GetChangeType(void) const;
+
+       /**
+        * Gets the changed event Id.
+        *
+        * @return              The changed event Id
+        */
+       RecordId GetTodoId(void) const;
+
+       /**
+        * Gets the calendar ID that the changed event belongs to.
+        *
+        * @return              The calendar ID that the changed event belongs to
+        */
+       RecordId GetCalendarId(void) const;
+
+       /**
+        * Gets the version of the change.
+        *
+        * @return              The version of the change
+        */
+       int GetVersion(void) const;
+
+       /**
+        * Sets the change type.
+        *
+        * @param[in]   changeType                      The change type
+        */
+       void SetChangeType(RecordChangeType changeType);
+
+       /**
+        * Sets the event ID.
+        *
+        * @param[in]   todoId                  The event ID
+        */
+       void SetTodoId(RecordId todoId);
+
+       /**
+        * Sets the calendar ID.
+        *
+        * @param[in]   accountId                       The calendar ID
+        */
+       void SetCalendarId(RecordId calendarId);
+
+       /**
+        * Sets the version.
+        *
+        * @param[in]   version                 The version
+        */
+       void SetVersion(int version);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return                      The pointer to _CalTodoChangeInfoImpl
+        * @param[in]   calTodoChangeInfo               An instance of %CalTodoChangeInfo class
+        */
+       static _CalTodoChangeInfoImpl* GetInstance(CalTodoChangeInfo& calTodoChangeInfo);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return                      The pointer to const _CalTodoChangeInfoImpl
+        * @param[in]   calTodoChangeInfo               A const instance of %CalTodoChangeInfo class
+        */
+       static const _CalTodoChangeInfoImpl* GetInstance(const CalTodoChangeInfo& calTodoChangeInfo);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @param[in]   rhs             An instance of _CalTodoChangeInfoImpl
+        */
+       _CalTodoChangeInfoImpl& operator =(const _CalTodoChangeInfoImpl& rhs);
+
+private:
+       RecordChangeType __changeType;
+       RecordId __todoId;
+       RecordId __calendarId;
+       int __version;
+
+};     // _CalTodoChangeInfoImpl
+
+}}     // Tizen::Social
+
+#endif //_FSCL_INTERNAL_CAL_TODO_CHANGE_INFO_IMPL_H_
diff --git a/src/inc/FScl_CalTodoImpl.h b/src/inc/FScl_CalTodoImpl.h
new file mode 100644 (file)
index 0000000..4ec3f5a
--- /dev/null
@@ -0,0 +1,350 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_CalTodoImpl.h
+ * @brief      This is the header file for the _CalTodoImpl class.
+ *
+ * This header file contains the declarations of the _CalTodoImpl class.
+ */
+
+#ifndef _FSCL_INTERNAL_CALTODO_IMPL_H_
+#define _FSCL_INTERNAL_CALTODO_IMPL_H_
+
+#include <unique_ptr.h>
+#include <calendar2.h>
+#include <FBaseColAllElementsDeleter.h>
+#include <FBaseObject.h>
+#include "FScl_CalendarbookUtil.h"
+
+namespace Tizen { namespace Base
+{
+class String;
+class DateTime;
+namespace Collection
+{
+class IList;
+}
+}}
+
+namespace Tizen { namespace Social
+{
+
+class CalTodo;
+class Reminder;
+
+/**
+ *     @class  _CalTodoImpl
+ *     @brief  This class provides methods to manage the information of a calendarbook to-do.
+ */
+class _CalTodoImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        */
+       _CalTodoImpl(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @param[in]   rhs             An instance of _CalTodoImpl
+        */
+       _CalTodoImpl(const _CalTodoImpl& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        */
+       virtual ~_CalTodoImpl(void);
+
+       /**
+        * Gets the subject of the current instance of _CalTodoImpl.
+        *
+        * @return              The subject
+        */
+       Tizen::Base::String GetSubject(void) const;
+
+       /**
+        * Gets the description of the current instance of _CalTodoImpl.
+        *
+        * @return       The description
+        */
+       Tizen::Base::String GetDescription(void) const;
+
+       /**
+        * Gets the start date of the current instance of _CalTodoImpl. @n
+        *
+        * @return              The start date
+        */
+       Tizen::Base::DateTime GetStartDate(void) const;
+
+       /**
+        * Gets the due date of the current instance of _CalTodoImpl. @n
+        *
+        * @return              The due date
+        */
+       Tizen::Base::DateTime GetDueDate(void) const;
+
+       /**
+        * Gets the priority level of the current instance of _CalTodoImpl. @n
+        * The default priority level is #TODO_PRIORITY_LOW.
+        *
+        * @return              The priority level
+        */
+       TodoPriority GetPriority(void) const;
+
+       /**
+        * Gets the status of the current instance of _CalTodoImpl. @n
+        * The default status is #TODO_STATUS_NONE.
+        *
+        * @return              The status of the to-do
+        */
+       TodoStatus GetStatus(void) const;
+
+       /**
+        * Gets the sensitivity of the current instance of _CalTodoImpl. @n
+        * The default value is #SENSITIVITY_PUBLIC.
+        *
+        * @return              The sensitivity of the to-do
+        */
+       RecordSensitivity GetSensitivity(void) const;
+
+       /**
+        * Gets the last updated date and time of the current instance of _CalTodoImpl.
+        *
+        * @return              The last updated date and time
+        */
+       Tizen::Base::DateTime GetLastRevisedTime(void) const;
+
+       /**
+        * Sets the subject of the current instance of _CalTodoImpl.
+        *
+        * @return              An error code
+        * @param[in]   subject         The subject of the to-do
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_ARG           The length of the specified @c subject exceeds #MAX_TODO_SUBJECT_LENGTH.
+        */
+       result SetSubject(const Tizen::Base::String& subject);
+
+       /**
+        * Sets the description of the current instance of _CalTodoImpl.
+        *
+        * @return              An error code
+        * @param[in]   description     The description of the to-do @n
+                                   @c null to remove the existing value
+        * @exception   E_SUCCESS       The method was successful.
+        * @exception   E_INVALID_ARG   The length of the specified @c description exceeds #MAX_TODO_DESCRIPTION_LENGTH.
+        */
+       result SetDescription(const Tizen::Base::String& description);
+
+       /**
+        * Sets the start date and due date for the current instance of _CalTodoImpl. @n
+        * If the start date is not set, the current date is considered as the start date.
+        * The due date must be later than or equal to the start Date. @n
+        *
+        * @return              An error code
+        * @param[in]   start                   The start date
+        * @param[in]   due                             The due date
+        * @exception   E_SUCCESS               The method was successful.
+        * @exception   E_INVALID_ARG   The specified @c due value is earlier than the specified @c start value.
+        */
+       result SetStartAndDueDate(const Tizen::Base::DateTime& start, const Tizen::Base::DateTime& due);
+
+       /**
+        * Sets the start date for the current instance of %CalTodo. @n
+        * If the startDate is minimum value of Tizen::Base::DateTime, the start date is changed to unset. @n
+        * And if the start date is later than due date, the due date will be changed to unset.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   startDate                       The start date
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c start date is invalid.
+        *                                                              The valid range of the date can be referenced from Calendarbook::GetMaxDateTime() and Calendarbook::GetMinDateTime() @n
+        *                                                              and The minimum value of Tizen::Base::DateTime is valid to unset the start date.
+        * @remarks             Tizen::Base::DateTime::GetMinValue();
+        */
+       result SetStartDate(const Tizen::Base::DateTime& startDate);
+
+       /**
+        * Sets the end date for the current instance of %CalTodo. @n
+        * If the dueDate is minimum value of Tizen::Base::DateTime, the due date is changed to unset. @n
+        * And if the due date is earlier than start date, the start date will be changed to unset.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   dueDate                 The due date
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c due date is invalid.
+        *                                                              The valid range of the date can be referenced from Calendarbook::GetMaxDateTime() and Calendarbook::GetMinDateTime() @n
+        *                                                              and The minimum value of Tizen::Base::DateTime is valid to unset the due date.
+        * @remarks             Tizen::Base::DateTime::GetMinValue();
+        */
+       result SetDueDate(const Tizen::Base::DateTime& dueDate);
+
+       /**
+        * Sets the priority level of the current instance of _CalTodoImpl.
+        *
+        * @param[in]   priority                The priority level to set
+        */
+       void SetPriority(TodoPriority priority);
+
+       /**
+        * Sets the status of the current instance of _CalTodoImpl.
+        *
+        * @param[in]   status                  The status to set
+        */
+       void SetStatus(TodoStatus status);
+
+       /**
+        * Sets the sensitivity of the current instance of _CalTodoImpl.
+        *
+        * @param[in]   sensitivity             The sensitivity to set
+        */
+       void SetSensitivity(RecordSensitivity sensitivity);
+
+       /**
+        * Sets the location of the current calendar event.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   location                        The location of the event
+        */
+       void SetLocation(const Tizen::Base::String& location);
+
+       /**
+        * Gets the location of the calendar event.
+        *
+        * @since       2.0
+        *
+        * @return              The location
+        */
+       Tizen::Base::String GetLocation(void) const;
+
+       /**
+        * Sets the coordinates.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   latitude                The latitude in the range. The valid range is [-90.0, 90.0]
+        * @param[in]   longitude               The longitude in the range. The valid range is [-180.0, 180.0]
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The latitude or longitude is out of the valid range.
+        */
+       result SetCoordinates(double latitude, double longitude);
+
+       /**
+        * Gets the coordinates.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[out]  latitude                The latitude
+        * @param[out]  longitude               The longitude
+        */
+       void GetCoordinates(double& latitude, double& longitude) const;
+
+       /**
+        * Adds a reminder.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   reminder                        The reminder to be added
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        */
+       result AddReminder(const Reminder& reminder);
+
+       /**
+        * Removes a reminder at the index.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   index                           The index of reminder to be removed
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_RANGE          The index is either equal to or greater than the number of reminders or less than 0.
+        */
+       result RemoveReminderAt(int index);
+
+       /**
+        * Gets a list of all the reminders.
+        *
+        * @since       2.0
+        *
+        * @return              A list containing the Reminder instances, @n
+        *                              else an empty list if there are no reminders
+        */
+       const Tizen::Base::Collection::IList& GetAllReminders(void) const;
+
+       /**
+        * Gets the ID of the calendar that this to-do belongs to. @n
+        *
+        * @return              The calendar Id
+        */
+       RecordId GetCalendarId(void) const;
+
+       //
+       // Sets the record handle
+       //
+       void SetRecordHandle(calendar_record_h todoHandle);
+
+       //
+       // Gets the record handle
+       //
+       calendar_record_h GetRecordHandle(void) const;
+
+       static CalTodo* CreateDefaultInstanceN(void);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return                      The pointer to const _CalTodoImpl
+        * @param[in]   todo            A const instance of %CalTodo class
+        */
+       static _CalTodoImpl* GetInstance(CalTodo& todo);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return                      The pointer to const _CalTodoImpl
+        * @param[in]   todo            A const instance of %CalTodo class
+        */
+       static const _CalTodoImpl* GetInstance(const CalTodo& todo);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @param[in]   rhs             An instance of _CalTodoImpl
+        */
+       _CalTodoImpl& operator =(const _CalTodoImpl& rhs);
+
+private:
+       mutable Tizen::Base::Collection::ArrayList __reminderList;
+       mutable bool __reminderListUpdated;
+
+       _CalendarRecord __todoRecord;
+
+};     // _CalTodoImpl
+
+}}     // Tizen::Social
+
+#endif //_FSCL_INTERNAL_CALTODO_IMPL_H_
diff --git a/src/inc/FScl_CalendarImpl.h b/src/inc/FScl_CalendarImpl.h
new file mode 100644 (file)
index 0000000..4c040c8
--- /dev/null
@@ -0,0 +1,173 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_CalendarImpl.h
+ * @brief      This is the header file for the _CalendarImpl class.
+ *
+ * This header file contains the declarations of the _CalendarImpl class.
+ */
+
+#ifndef _FSCL_INTERNAL_CALENDAR_IMPL_H_
+#define _FSCL_INTERNAL_CALENDAR_IMPL_H_
+
+#include <unique_ptr.h>
+#include <calendar2.h>
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FSclTypes.h>
+#include "FScl_CalendarbookUtil.h"
+
+namespace Tizen { namespace Base
+{
+class String;
+} }
+
+namespace Tizen { namespace Social
+{
+
+class Calendar;
+
+/**
+ *     @class  _CalendarImpl
+ */
+class _CalendarImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @param[in]   itemType                                The calendar item type
+        */
+       _CalendarImpl(CalendarItemType itemType);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @param[in]   rhs             An instance of _CalendarImpl
+        */
+       _CalendarImpl(const _CalendarImpl& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        */
+       virtual ~_CalendarImpl(void);
+
+       /**
+        * Gets the calendar name.
+        *
+        * @return              The calendar name
+        */
+       Tizen::Base::String GetName(void) const;
+
+       /**
+        * Gets the calendar item type.
+        *
+        * @return              The calendar item type
+        */
+       CalendarItemType GetItemType(void) const;
+
+       /**
+        * Gets the account ID.
+        *
+        * @return              The account ID
+        */
+       AccountId GetAccountId(void) const;
+
+       /**
+        * Gets the calendar color.
+        * If the color is unset, the color components will be set to 0x0.
+        *
+        * @param[out]          red                     The red component
+        * @param[out]          green           The green component
+        * @param[out]          blue                    The blue component
+        * @exception           E_SUCCESS                                       The method is successful.
+        * @exception           E_DATA_NOT_FOUND                The color is unset.
+        */
+       result GetColor(byte& red, byte& green, byte& blue) const;
+
+       /**
+        * Sets the calendar name.
+        *
+        * @param[in]   name                            The calendar name
+        */
+       void SetName(const Tizen::Base::String& name);
+
+       /**
+        * Sets the calendar color.
+        *
+        * @param[in]           red                     The red component
+        * @param[in]           green           The green component
+        * @param[in]           blue                    The blue component
+        */
+       void SetColor(byte red, byte green, byte blue);
+
+       /**
+        * Clears the calendar color.
+        */
+       void ClearColor(void);
+
+       /**
+        * Sets the account ID.
+        *
+        * @param[in]   accountId                       The account ID
+        */
+       void SetAccountId(AccountId accountId);
+
+       //
+       // Sets the record handle
+       //
+       void SetRecordHandle(calendar_record_h calendarHandle);
+
+       //
+       // Gets the record handle
+       //
+       calendar_record_h GetRecordHandle(void) const;
+
+       static Calendar* CreateDefaultInstanceN(void);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return                      The pointer to const _CalendarImpl
+        * @param[in]   calendar                A const instance of %Calendar class
+        */
+       static _CalendarImpl* GetInstance(Calendar& calendar);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return                      The pointer to const _CalendarImpl
+        * @param[in]   calendar                A const instance of %Calendar class
+        */
+       static const _CalendarImpl* GetInstance(const Calendar& calendar);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @param[in]   rhs             An instance of _CalendarImpl
+        */
+       _CalendarImpl& operator =(const _CalendarImpl& rhs);
+
+private:
+
+       _CalendarRecord __calendarRecord;
+
+};     // _CalendarImpl
+
+}}     // Tizen::Social
+
+#endif //_FSCL_INTERNAL_CALENDAR_IMPL_H_
diff --git a/src/inc/FScl_CalendarbookImpl.h b/src/inc/FScl_CalendarbookImpl.h
new file mode 100644 (file)
index 0000000..2da3719
--- /dev/null
@@ -0,0 +1,852 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_CalendarbookImpl.h
+ * @brief              This is the header file for the _CalendarbookImpl class.
+ *
+ * This header file contains the declarations of the _CalendarbookImpl class.
+ */
+
+#ifndef _FSCL_INTERNAL_CALENDARBOOK_IMPL_H_
+#define _FSCL_INTERNAL_CALENDARBOOK_IMPL_H_
+
+#include <calendar2.h>
+#include <FBaseObject.h>
+#include <FSclTypes.h>
+#include "FScl_ICalendarbookDbChangeEventListener.h"
+
+namespace Tizen { namespace Base
+{
+class String;
+class DateTime;
+namespace Collection
+{
+class IList;
+class ArrayList;
+class AllElementsDeleter;
+class IEnumerator;
+template<class KeyType, class ValueType> class HashMapT;
+}
+}}
+
+namespace Tizen { namespace Locales
+{
+class TimeZone;
+}}
+
+namespace Tizen { namespace Social
+{
+
+class Calendarbook;
+class CalEvent;
+class CalTodo;
+class Calendar;
+class CalEventInstance;
+class CalEventChangeInfo;
+class CalTodoChangeInfo;
+class CalendarbookFilter;
+class ICalendarbookEventListener;
+class IRecordEventListener;
+class IRecordListener;
+class ICalendarbookEventListener;
+class _RecordImpl;
+class _CalendarbookRecordRetrivalThread;
+class _CalendarbookDbMonitor;
+
+const static int _INVALID_VERSION = -1;
+const static int _INVALID_COUNT = -1;
+
+/**
+ * @class      _CalendarbookImpl
+ * @brief      This class handles the _CalendarbookImpl operations.
+ * @see                Calendarbook
+ */
+class _CalendarbookImpl
+       : public Tizen::Base::Object
+       , public _ICalendarbookDbChangeEventListener
+{
+
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. For full construction, @n
+        * the Construct() method must be called right after calling this constructor.
+        *
+        * @see             Construct()
+        */
+       _CalendarbookImpl(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        */
+       virtual ~_CalendarbookImpl(void);
+
+       /**
+        * Initializes this instance of _CalendarbookImpl with the specified listener.
+        *
+        * @see         Calendarbook::Construct
+        */
+       result Construct(IRecordEventListener* pListener);
+
+       /**
+        * Initializes this instance of %Calendarbook.
+        *
+        * @return              An error code
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        */
+       result Construct(void);
+
+       /**
+        * Initializes this instance of %Calendarbook with the specified event listener. @n
+        * The events and to-do lists can be read, added, removed, and updated after construction.
+        * If the event listener is registered, the application notifies the user when a record is added, removed, or updated in the device.
+        *
+        * @return              An error code
+        * @param[in]   listener                                The event listener to be registered, @n
+        *                                                                              else @c null if an event listener need not be registered
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        */
+       result Construct(ICalendarbookEventListener& listener);
+
+       /**
+        * Adds a CalEvent to this calendarbook. @n
+        * After adding the event to the database successfully, the event has a valid record ID.
+        *
+        * @compatibility This method has compatibility issues with OSP API versions @b prior @b to @b 2.1. @n
+        *                For more information, see @ref CompCalendarbookAddEventPage "here".
+        *
+        * @return              An error code
+        * @param[in/out]       event                   The CalEvent to add
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_STATE         This instance has not been constructed yet.
+        * @exception   E_STORAGE_FULL          The capacity of this event was full.
+        * @exception   E_INVALID_ARG           Either of the following conditions has occurred: @n
+        *                                                                      -- The specified @c recordId is not #INVALID_RECORD_ID. @n
+        *                                  -- The @c event is not #RECORD_TYPE_EVENT. @n
+        *                                  -- The date of the event is invalid. @n
+        *                                                                              The valid range of the date can be referenced from GetMaxDateTime() and GetMinDateTime().
+        * @exception   E_SYSTEM                                A system error occurred.
+        */
+       result AddEvent(CalEvent& event);
+
+       /**
+        * @page        CompCalendarbookAddEventPage Compatibility for AddEvent()
+        * @section     CompCalendarbookAddEventPageIssueSection Issues
+        *          Implementation of this method in OSP API versions prior to 2.1 has the following issue:
+        *                      -# The event instance type can't be added.
+        *
+        * @section     CompCalendarbookAddEventPageSolutionSection Resolutions
+        *                      The issue mentioned above is resolved in OSP API version 2.1, and it is recommended to use OSP API version 2.1 or above.
+        *                      -# The event instance type will be able to be added.
+        */
+
+       /**
+        * Adds a calendar event to the specific calendar. @n
+        * After adding the event to the database successfully, the event has a valid record ID.
+        *
+        * @return              An error code
+        * @param[in/out]       event                                   The event to add
+        * @param[in]   calendarId                              The calendar ID that the event will be added to
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 This instance has not been constructed as yet.
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred: @n
+        *                                                                              - The event is invalid. @n
+        *                                                                              The valid range of the date can be referenced from GetMaxDateTime() and GetMinDateTime().
+        *                                                                              - The specified @c calendarId is #INVALID_RECORD_ID. @n
+        *                                                                              - The calendar type of the calendarId is #CALENDAR_TYPE_TODO
+        * @exception   E_OBJ_NOT_FOUND                 The specified calendarId is not found.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        */
+       result AddEvent(CalEvent& event, RecordId calendarId);
+
+       /**
+        * Adds a CalTodo to this calendarbook. @n
+        * After adding the to-do item to the database successfully, the item has a valid record ID.
+        *
+        * @return              An error code
+        * @param[in/out]       todo                            The CalTodo to add
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_STATE         This instance has not been constructed yet.
+        * @exception   E_STORAGE_FULL          The capacity of this to-do was full.
+        * @exception   E_INVALID_ARG           The specified @c recordId is not #INVALID_RECORD_ID, or the date of the to-do item is invalid. @n
+        *                                  The valid range of the date is from 12:00:00, midnight, January 1, 1900 to 11:59:59 P.M, December 31, 2100.
+        */
+       result AddTodo(CalTodo& todo);
+
+       /**
+        * Adds a calendar to-do to specific calendar. @n
+        * After adding the to-do item to the database successfully, the item has a valid record ID.
+        *
+        * @return              An error code
+        * @param[in/out]       todo                                    The to-do to add
+        * @param[in]   calendarId                              The calendar ID that the todo will be added to
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 This instance has not been constructed as yet.
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred: @n
+        *                                                                                                      - The todo is invalid. @n
+        *                                                                                                              The valid range of the date can be referenced from GetMaxDateTime() and GetMinDateTime().
+        *                                                                                                              - The specified @c calendarId is #INVALID_RECORD_ID. @n
+        *                                                                                                              - The calendar type of the calendarId is not #CALENDAR_TYPE_CALENDAR
+        * @exception   E_OBJ_NOT_FOUND         The specified calendarId is not found.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        */
+       result AddTodo(CalTodo& todo, RecordId calendarId);
+
+       /**
+        * Adds a calendar. @n
+        * After adding the calendar to the database successfully, the calendar has a valid calendar ID.
+        *
+        * @return              An error code
+        * @param[in/out]       calendar                                The calendar to add
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 This instance has not been constructed as yet.
+        * @exception   E_INVALID_ARG                   The specified @c record ID of the calendar is not #INVALID_RECORD_ID. @n
+        * @exception   E_SYSTEM                                A system error has occurred.
+        */
+       result AddCalendar(Calendar& calendar);
+
+       /**
+        * Adds a calendar that is associated with the specified account of the accountId. @n
+        * After adding the calendar to the database successfully, the calendar has a valid calendar ID.
+        *
+        * @return              An error code
+        * @param[in/out]       calendar                                The calendar to add
+        * @param[in]   accountId                               The account Id
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 This instance has not been constructed as yet.
+        * @exception   E_INVALID_ARG                           Either of the following conditions has occurred: @n
+        *                                                                                                              - The record ID of the calendar is not #INVALID_RECORD_ID. @n
+        *                                                                                                                      - The accountId is invalid.
+        * @exception   E_OBJ_NOT_FOUND                 The specified calendarId is not found.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        */
+       result AddCalendar(Calendar& calendar, AccountId accountId);
+
+       /**
+        * Removes the specified CalEvent from this calendarbook. @n
+        * After removing the event from the database successfully, the event has #INVALID_RECORD_ID.
+        *
+        * @return              An error code
+        * @param[in]   event                   The CalEvent to remove
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_STATE         This instance has not been constructed yet.
+        * @exception   E_INVALID_ARG           The specified @c recordId is #INVALID_RECORD_ID.
+        * @exception   E_OBJ_NOT_FOUND         The specified record was not found.
+        * @exception   E_SYSTEM                                A system error occurred.
+        */
+       result RemoveEvent(CalEvent& event);
+
+       /**
+        * Removes the specified CalEvent from this calendarbook.
+        *
+        * @return              An error code
+        * @param[in]   eventId                         The CalEvent Id to remove
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_STATE         This instance has not been constructed yet.
+        * @exception   E_INVALID_ARG           The specified @c eventId is #INVALID_RECORD_ID.
+        * @exception   E_OBJ_NOT_FOUND         The specified record was not found.
+        * @exception   E_SYSTEM                                A system error occurred.
+        */
+       result RemoveEvent(RecordId eventId);
+
+       /**
+        * Removes the specified CalTodo from this calendarbook. @n
+        * After removing the to-do item from the database successfully, the item has #INVALID_RECORD_ID.
+        *
+        * @return              An error code
+        * @param[in]   todo                            The CalTodo ID to remove
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_STATE         This instance has not been constructed yet.
+        * @exception   E_INVALID_ARG           The recordId is #INVALID_RECORD_ID.
+        * @exception   E_OBJ_NOT_FOUND         The specified record was not found.
+        * @exception   E_SYSTEM                                A system error occurred.
+        */
+       result RemoveTodo(CalTodo& todo);
+
+       /**
+        * Removes the specified CalTodo from this calendarbook.
+        *
+        * @return              An error code
+        * @param[in]   todoId                          The CalTodo ID to remove
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_STATE         This instance has not been constructed yet.
+        * @exception   E_INVALID_ARG           A specified input parameter is invalid.
+        * @exception   E_OBJ_NOT_FOUND         The specified record was not found.
+        * @exception   E_SYSTEM                                A system error occurred.
+        */
+       result RemoveTodo(RecordId todoId);
+
+       /**
+        * Removes the specified calendar of the calendarId. @n
+        *
+        * @return              An error code
+        * @param[in]   calendarId                              The calendar ID to be removed
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 This instance has not been constructed as yet.
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred: @n
+        *                                                                              - The specified @c calendarId is #INVALID_RECORD_ID.
+        *                                                                              - The calendar represents default calendar. @n
+        * @exception   E_OBJ_NOT_FOUND                 The specified calendarId is not found.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        */
+       result RemoveCalendar(RecordId calendarId);
+
+       /**
+        * Updates the specified CalEvent to the internal data storage.
+        *
+        * @return              An error code
+        * @param[in]   event                   The CalEvent to be updated
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_STATE         This instance has not been constructed yet.
+        * @exception   E_INVALID_ARG           Either of the following conditions has occurred: @n
+        *                                                                      -- The specified @c recordId is #INVALID_RECORD_ID. @n
+        *                                  -- The @c event is not #RECORD_TYPE_EVENT. @n
+        *                                  -- The @c event is not an entry type instance. @n
+        *                                  -- The date of the event is invalid. @n
+        *                                    The valid range of the date is from 12:00:00 midnight, January 1, 1900 to 11:59:59 P.M, December 31, 2100.
+        * @exception   E_OBJ_NOT_FOUND         The specified record was not found.
+        * @exception   E_SYSTEM                                A system error occurred.
+        */
+       result UpdateEvent(const CalEvent& event);
+
+       /**
+        * Updates the specified CalTodo on the internal data storage.
+        *
+        * @return              An error code
+        * @param[in]   todo                            The CalTodo to be updated
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_STATE         This instance has not been constructed yet.
+        * @exception   E_INVALID_ARG           The specified recordId is #INVALID_RECORD_ID, or the date of the to-do item is invalid. @n
+        *                                    The valid range of the date is from 12:00:00 midnight, January 1, 1900 to 11:59:59 P.M, December 31, 2100.
+        * @exception   E_OBJ_NOT_FOUND         The specified record was not found.
+        * @exception   E_SYSTEM                                A system error occurred.
+        */
+       result UpdateTodo(const CalTodo& todo);
+
+       /**
+        * Updates the specified calendar.
+        *
+        * @return              An error code
+        * @param[in]   calendar                                The Calendar instance to be updated
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 This instance has not been constructed as yet.
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred: @n
+        *                                                                              - The calendar's recordId is #INVALID_RECORD_ID. @n
+        *                                                                              - The calendar represents default calendar. @n
+        * @exception   E_OBJ_NOT_FOUND                 The specified calendar is not found.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        */
+       result UpdateCalendar(const Calendar& calendar);
+
+       /**
+        * Gets the specified event ID that is matched with the RecordId.
+        *
+        * @return              The matched event
+        * @param[in]   eventId                         The event ID to be found
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_STATE         This instance has not been constructed yet.
+        * @exception   E_OUT_OF_MEMORY         Insufficient memory.
+        * @exception   E_INVALID_ARG           The specified @c eventId is invalid.
+        * @exception   E_OBJ_NOT_FOUND         The specified record was not found.
+        * @exception   E_SYSTEM                                A system error occurred.
+        */
+       CalEvent* GetEventN(RecordId eventId) const;
+
+       /**
+        * Gets the specified to-do after matching it with the specified RecordId.
+        *
+        * @return              The matched to-do
+        * @param[in]   todoId                          The ID of the to-do to be found
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_STATE         This instance has not been constructed yet.
+        * @exception   E_INVALID_ARG           The specified @c todoId is invalid.
+        * @exception   E_OBJ_NOT_FOUND         The specified record was not found.
+        * @exception   E_OUT_OF_MEMORY         Insufficient memory.
+        * @exception   E_SYSTEM                                A system error occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        *
+        */
+       CalTodo* GetTodoN(RecordId todoId) const;
+
+       /**
+        * Gets the specified calendar that is matched with the calendarId.
+        *
+        * @return              The matched calendar
+        * @param[in]   calendarId                              The calendar ID
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 This instance has not been constructed as yet.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_INVALID_ARG                   The specified @c calendarId is invalid.
+        * @exception   E_OBJ_NOT_FOUND                 The specified calendarId is not found.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        */
+       Calendar* GetCalendarN(RecordId calendarId) const;
+
+       /**
+        * Gets all the to-do items in the specified time range.
+        *
+        * @return              A list of all the matched #CalTodo instances, @n
+        *                              else an empty list if there is no matched to-do item @n
+        *              The items are sorted by time.
+        * @param[in]   start                           The start of the time range
+        * @param[in]   end                                     The end of the time range
+        * @param[in]   pageNo                          The page number of the result list @n
+        *                                                                      It starts from @c 1.
+        * @param[in]   countPerPage            The desired maximum count of the result items per page @n
+        * @param[in]   status                          The TodoStatus @n
+        *                                                                      If you set a specific status, the to-dos that have the specified status are returned. @n
+        *                                                                      The default status value is #TODO_STATUS_ALL, which means all the statuses are returned.
+        * @param[in]   priority                        The TodoPriority @n
+        *                                                                      If you set a specific priority, the to-dos that have the specified priority are returned. @n
+        *                                                                      The default priority value is #TODO_PRIORITY_ALL that means all the priorities are returned.
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_STATE         This instance has not been constructed yet.
+        * @exception   E_INVALID_ARG           Either of the following conditions has occurred: @n
+        *                                                                      -- The specified @c pageNo or @c countPerPage is less than @c 1. @n
+        *                                                                      -- The start time is later than the end date. @n
+        *                                                                      -- The start or end time is not in a valid range. @n
+        *                                  The valid range of the date is from 12:00:00 midnight, January 1, 1900 to 11:59:59 P.M, December 31, 2100.
+        * @exception   E_OUT_OF_MEMORY         Insufficient memory.
+        * @exception   E_SYSTEM                                A system error occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method. @n
+        *                              The values for @c status and @c priority can be set by assigning values to both the @c status and @c priority. For example, status = #STATUS_COMPLETED, priority = #TODO_PRIORITY_ALL.
+        *
+        */
+       Tizen::Base::Collection::IList* GetTodosN(const Tizen::Base::DateTime& start, const Tizen::Base::DateTime& end, int pageNo, int countPerPage, unsigned long status = TODO_STATUS_ALL, unsigned long priority = TODO_PRIORITY_ALL) const;
+
+       /**
+        * Gets the total number of to-dos in the specified time range.
+        *
+        * @return              count                           The total number of to-dos, @n
+        *                                                                      else @c -1 if an exception occurs
+        * @param[in]   start                           The start of the time range
+        * @param[in]   end                                     The end of the time range
+        * @param[in]   status                          The TodoStatus @n
+        *                                                                      If you set a specific status, the to-dos that have the specified status are returned. @n
+        *                                                                      The default status value is #TODO_STATUS_ALL, which means all the statuses are returned.
+        * @param[in]   priority                        The TodoPriority @n
+        *                                                                      If you set a specific priority, the to-dos that have the specified priority are returned. @n
+        *                                                                      The default priority value is #TODO_PRIORITY_ALL that means all the priorities are returned.
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_STATE         This instance has not been constructed yet.
+        * @exception   E_INVALID_ARG           The start time is later than the end date, or the start or end time is not in a valid range. @n
+        *                                  The valid range of the date is from 12:00:00 midnight, January 1, 1900 to 11:59:59 P.M, December 31, 2100.
+        * @exception   E_OUT_OF_MEMORY         Insufficient memory.
+        * @exception   E_SYSTEM                                A system error occurred.
+        * @remark              The specific error code can be accessed using the GetLastResult() method.
+        */
+       int GetTodoCount(const Tizen::Base::DateTime& start, const Tizen::Base::DateTime& end, unsigned long status = TODO_STATUS_ALL, unsigned long priority = TODO_PRIORITY_ALL) const;
+
+       /**
+        * Gets the CalEvent instances that are within the specified time range. @n
+        * Anniversary and all day events are retrieved by their start and end dates in the local time zone, while all other events are retrieved by their start and end times in Coordinated Universal Time (UTC).
+        *
+        * @return              A list containing all of the matched #CalEvent instances, @n
+        *                              else an empty list if there are no matched instances or @c null if an exception occurs @n
+        *                              The results are listed in order of their start date.
+        *                              The results within the same start date are ordered by their category in the following order: anniversaries, all day events, and other events.
+        *                              The results in each category are sorted by their start time.
+        * @param[in] start                             The start of the time range
+        * @param[in] end                               The end of the time range
+        * @param[in] timeZone                  The time zone of the specified start and end times
+        * @param[in] pageNo                    The page number of the result list @n
+        *                                                              It starts from @c 1.
+        * @param[in] countPerPage              The desired maximum count of the result items on the page
+        * @param[in] category                  The EventCategory @n
+        *                                                              If you set a specific category, the events that have the specified category are returned. @n
+        *                                                              The default category value is #EVENT_CATEGORY_ALL, which means all the categories are returned.
+        * @exception E_SUCCESS                         The method was successful.
+        * @exception E_INVALID_STATE           This instance has not been constructed yet.
+        * @exception E_INVALID_ARG                     Either of the following conditions has occurred: @n
+        *                                                                      -- The specified @c pageNo or @c countPerPage is less than @c 1. @n
+        *                                                                      -- The start time is later than end date. @n
+        *                                                                      -- The specified category is invalid. @n
+        *                                                                      -- The start or end time is not in a valid range. @n
+        *                                                                  The valid range of date is from 12:00:00 midnight, January 1, 1900 to 11:59:59 P.M, December 31, 2100. @n
+        * @exception E_OUT_OF_MEMORY           Insufficient memory.
+        * @exception E_SYSTEM                                  A system error occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+
+       Tizen::Base::Collection::IList* GetEventInstancesN(const Tizen::Base::DateTime& start, const Tizen::Base::DateTime& end,
+                                                                                                        const Tizen::Locales::TimeZone& timeZone, int pageNo, int countPerPage,
+                                                                                                        unsigned long category = EVENT_CATEGORY_ALL) const;
+
+       /**
+        * Gets the CalEvent instances that are within the specified time range. @n
+        * Anniversary and all day events are retrieved by their start and end dates in the local time zone, while all other events are retrieved by their start and end times in Coordinated Universal Time (UTC).
+        * Although GetEventInstancesN() retrieves the data synchronously, this method returns data asynchronously using RecordListener::OnEventInstancesReceivedN(). @n
+        * It is highly recommended to use the asynchronous method because getting event instances may take long time.
+        *
+        * @return              An error code
+        * @param[in] start                             The start of the time range
+        * @param[in] end                               The end of the time range
+        * @param[in] timeZone                  The time zone of the specified start and end times
+        * @param[in] pageNo                    The page number of the result list @n
+        *                                                              It starts from @c 1.
+        * @param[in] countPerPage              The desired maximum count of the result items on the page
+        * @param[in] category                  The #EventCategory @n
+        *                                                              If you set a specific category, the events which have the specified category are returned. @n
+        *                                                              The default category value is #EVENT_CATEGORY_ALL, which means all the categories are returned.
+        * @param[out] reqId                    The ID of the request
+        * @param[in] listener                  The listener for receiving the responses of the request
+        * @exception E_SUCCESS                         The method was successful.
+        * @exception E_INVALID_STATE           This instance has not been constructed yet.
+        * @exception E_INVALID_ARG                     Either of the following conditions has occurred: @n
+        *                                                                      -- The specified @c pageNo or @c countPerPage is less than @c 1. @n
+        *                                                                      -- The start time is later than end date. @n
+        *                                                                      -- The start or end time is not in a valid range. @n
+        *                                                                      -- The specified category is invalid. @n
+        *                                                                      The valid range of date is from 12:00:00 midnight, January 1, 1900 to 11:59:59 P.M, December 31, 2100.
+        * @exception E_SYSTEM                                  A system error occurred.
+        * @remarks             IRecordListener::OnRecordsReceivedN(), Calendarbook::GetEventInstancesN()
+        */
+
+       result GetEventInstances(const Tizen::Base::DateTime& start, const Tizen::Base::DateTime& end,
+                                                        const Tizen::Locales::TimeZone& timeZone, int pageNo, int countPerPage, unsigned long category,
+                                                        RequestId& reqId,
+                                                        const IRecordListener& listener) const;
+
+       /**
+        * Gets the all events.
+        *
+        * @return              A list containing all the %CalEvent instances, @n
+        *                              else an empty list if there are no events or @c null if an exception occurs @n
+        *                              The results are listed in the order of their start time.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 This instance has not been constructed as yet.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetAllEventsN(void) const;
+
+       /**
+        * Gets all to-dos.
+        *
+        * @since       2.0
+        *
+        * @return              A list containing all the CalTodo instances, @n
+        *                              else an empty list if there are no to-dos or @c null if an exception occurs @n
+        *                              The results are listed in the order of their to-do ID.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @remarks There is a high probability for an occurrence of an out-of-memory exception. If possible, check whether the exception is
+        *                                      E_OUT_OF_MEMORY or not. For more information on how to handle the out-of-memory exception, refer
+        *                                      <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        */
+       Tizen::Base::Collection::IList* GetAllTodosN(void) const;
+
+       /**
+        * Gets all calendars.
+        *
+        * @since       2.0
+        *
+        * @return              A list containing all the Calendar instances, @n
+        *                              else an empty list if there are no calendars or @c null if an exception occurs @n
+        *                              The results are listed in the order of their calendar ID.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @remarks There is a high probability for an occurrence of an out-of-memory exception. If possible, check whether the exception is
+        *                                      E_OUT_OF_MEMORY or not. For more information on how to handle the out-of-memory exception, refer
+        *                                      <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
+        */
+       Tizen::Base::Collection::IList* GetAllCalendarsN(void) const;
+
+       /**
+        * Gets the all infomations of changed events since the version.
+        *
+        * @return              A list containing the %CalEventChangeInfo instances, @n
+        *                              else an empty list if there are no events or @c null if an exception occurs @n
+        *                              The results are listed in the order of their version.
+        * @param[in]   version                                 The version
+        * @param[out]  latestVersion                   The latest change version among the changed events.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 This instance has not been constructed as yet.
+        * @exception   E_INVALID_ARG                   The version is invalid.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetChangedEventsAfterN(int version, int& latestVersion) const;
+
+       /**
+        * Gets the all infomations of changed to-dos since the version.
+        *
+        * @return              A list containing the %CalTodoChangeInfo instances, @n
+        *                              else an empty list if there are no to-dos or @c null if an exception occurs @n
+        *                              The results are listed in the order of their version.
+        * @param[in]   version                                 The version
+        * @param[out]  latestVersion                   The latest change version among the changed to-dos.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 This instance has not been constructed as yet.
+        * @exception   E_INVALID_ARG                   The version is invalid.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetChangedTodosAfterN(int version, int& latestVersion) const;
+
+       /**
+        * Removes an instance of the recurring event. @n
+        * If the event instance has been removed successfully, its start date is added as an exception date to the recurrence of its original event.
+        *
+        * @return              An error code
+        * @param[in]   eventInstance                                   The event instance to remove @n
+        *                                                                                                              The @c eventInstance must be an instance of the recurring event.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                           The instance is invalid.
+        * @exception   E_OBJ_NOT_FOUND                 The instance is not found.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @remarks             The instance's start time is added to the recurrence of original event as exception date.
+        */
+       result RemoveEventInstance(const CalEventInstance& eventInstance);
+
+       result UpdateEventInstance(const CalEventInstance& eventInstance, CalEvent& event);
+
+       /**
+        * Gets the latest version of calendarbook storage.
+        *
+        * @return              The latest version
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 This instance has not been constructed as yet.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        */
+       int GetLatestVersion(void) const;
+
+       /**
+        * Searches items of the calendarbook with the filter.
+        * The filter specifies the item type and condition for searching.
+        * The searched results are ordered by the @c propertySortedBy and @c sortOrder.
+        * If the @c offset is M and the @c maxCount are N, then the first M items are omitted from the result set returned by the searching operation and the next N items are returned.
+        *
+        * @since       2.0
+        *
+        * @return              A list of searched results (The list of CalEvent, CalTodo, Calendar or CalEventInstance), @n
+        *                                              Or, an empty list if there is no searched result @n
+        *                                              Or, null if an exception occurs.
+        * @param[in]   filter          The filter that specifies the search condition. If the filter is empty, all items that are specified by the type of this filter will be searched.
+        * @param[in]   propertySortedBy                The property for sorting. The searched results are ordered by the values of this property.
+        * @param[in]   sortOrder               The order for sorting.
+        * @param[in]   offset                  The offset of the searched results. If this value is 0, it will be ignored.
+        * @param[in]   maxCount                The maximum count of the searched results. If this value is 0, it will be ignored.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_OUT_OF_MEMORY                         The memory is insufficient.
+        * @exception   E_INVALID_ARG                           The specified @c offset or @c maxCount is less than 0.
+        *                                                                                                                              Or, the @c propertySortedBy is not an elements of the enumerator that corresponds with the type of the specified @c filter.
+        * @exception   E_SYSTEM                                        The method cannot proceed due to a severe system error.
+        * @see EventFilterProperty, TodoFilterProperty, CalendarFilterProperty, EventInstanceFilterProperty
+        * @remarks                             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* SearchN(const CalendarbookFilter& filter, unsigned long propertySortedBy, Tizen::Base::SortOrder sortOrder, int offset, int maxCount) const;
+
+       /**
+        * Gets matched item count of the search results with the filter.
+        * The filter specifies the item type and condition for searching.
+        *
+        * @since       2.0
+        *
+        * @return              The count of the searched results
+        * @param[in]   filter  The filter that specifies the search condition. If the filter is empty, all items that are specified by the type of this filter will be searched.
+        * @exception   E_SUCCESS                                               The method is successful.
+        * @exception   E_OUT_OF_MEMORY                         The memory is insufficient.
+        * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
+        */
+       int GetMatchedItemCount(const CalendarbookFilter& filter) const;
+
+       /**
+        * Gets the instances.
+        */
+       Tizen::Base::Collection::IList* GetEventInstancesCommonN(const Tizen::Base::DateTime& start, const Tizen::Base::DateTime& end,
+                                                                                                        const Tizen::Locales::TimeZone& timeZone, int pageNo, int countPerPage, unsigned long category) const;
+
+       virtual void OnCalEventChanged(void);
+
+       virtual void OnCalTodoChanged(void);
+
+       /**
+        * Parses the events from specific vCalendar file.
+        * This method supports to parse for vCalendar version 1.0 and 2.0 (iCalendar).
+        *
+        * @since       2.0
+        *
+        * @return              A list containing the CalEvent instances, @n
+        *                              else an empty list if there are no events or @c null if an exception occurs @n
+        * @param[in]   vCalFilePath                    The path of the vCalendar file
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The specified @c vCalFilePath is invalid.
+        * @exception   E_ILLEGAL_ACCESS                Access is denied due to insufficient permission.
+        * @exception   E_FILE_NOT_FOUND                The specified vCalendar file not found.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       static Tizen::Base::Collection::IList* ParseEventsFromVcalendarN(const Tizen::Base::String& vCalFilePath);
+
+       /**
+        * Parses the to-dos from specific vCalendar file.
+        * This method supports to parse for vCalendar version 1.0 and 2.0 (iCalendar).
+        *
+        * @since       2.0
+        *
+        * @return              A list containing the CalTodo instances, @n
+        *                              else an empty list if there are no to-dos or @c null if an exception occurs @n
+        * @param[in]   vCalFilePath                    The path of the vCalendar file
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The specified @c vCalFilePath is invalid.
+        * @exception   E_ILLEGAL_ACCESS                Access is denied due to insufficient permission.
+        * @exception   E_FILE_NOT_FOUND                The specified vCalendar file not found.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       static Tizen::Base::Collection::IList* ParseTodosFromVcalendarN(const Tizen::Base::String& vCalFilePath);
+
+       /**
+        * Exports the events to vCalendar 2.0 (iCalendar) file.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   eventList                               The event list to export. The list should contain CalEvent instances.
+        * @param[in]   vCalFilePath                    The vCalendar file path.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred: @n
+        *                                                                              - The eventList is invalid.
+        *                                                                              - The specified @c vCalFilePath is invalid.
+        * @exception   E_ILLEGAL_ACCESS                Access of vCalFilePath is denied due to insufficient permission.
+        * @exception   E_FILE_ALREADY_EXIST    The vCalendar file already exists.
+        * @exception   E_STORAGE_FULL                  The disk space is full.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       static result ExportEventsToVcalendar(const Tizen::Base::Collection::IList& eventList, const Tizen::Base::String& vCalFilePath);
+
+       /**
+        * Exports the to-dos to vCalendar 2.0 (iCalendar) file.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   todoList                                The to-do list to export. The list should contain CalTodo instances.
+        * @param[in]   vCalFilePath                    The vCalendar file path.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   Either of the following conditions has occurred: @n
+        *                                                                              - The todoList is invalid.
+        *                                                                              - The specified @c vCalFilePath is invalid.
+        * @exception   E_ILLEGAL_ACCESS                Access of vCalFilePath is denied due to insufficient permission.
+        * @exception   E_FILE_ALREADY_EXIST    The vCalendar file already exists.
+        * @exception   E_STORAGE_FULL                  The disk space is full.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
+        */
+       static result ExportTodosToVcalendar(const Tizen::Base::Collection::IList& todoList, const Tizen::Base::String& vCalFilePath);
+
+       /**
+        * Gets the maximum allowable date and time in the calendarbook (i.e "December 31 2100 23:59:59").
+        *
+        * @return              An instance of %DateTime
+        */
+       static Tizen::Base::DateTime GetMaxDateTime(void);
+
+       /**
+        * Gets the minimum allowable date and time in the calendarbook (i.e "January 1 1900 00:00:00").
+        *
+        * @return              An instance of %DateTime
+        */
+       static Tizen::Base::DateTime GetMinDateTime(void);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return                      The pointer to const _CalendarbookImpl
+        * @param[in]   calendarbook            A const instance of %Calendarbook class
+        */
+       static _CalendarbookImpl* GetInstance(Calendarbook& calendarbook);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return                      The pointer to const _CalendarbookImpl
+        * @param[in]   calendarbook            A const instance of %Calendarbook class
+        */
+       static const _CalendarbookImpl* GetInstance(const Calendarbook& calendarbook);
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private @n
+        * to prohibit copying of objects.
+        *
+        * @since       2.0
+        */
+       _CalendarbookImpl(const _CalendarbookImpl& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private @n
+        * to prohibit copying of objects.
+        *
+        * @since       2.0
+        */
+       _CalendarbookImpl& operator =(const _CalendarbookImpl& rhs);
+
+       CalendarItemType GetCalendarItemTypeByCalendarId(RecordId calendarId) const;
+       bool CheckEventExistance(RecordId eventId) const;
+       bool CheckTodoExistance(RecordId todoId) const;
+       bool CheckCalendarExistance(RecordId calendarId) const;
+       bool CheckValidTodoPriority(unsigned long priority) const;
+       bool CheckValidTodoStatus(unsigned long status) const;
+       int ConvertTodoStatusToCalendarTodoStatus(unsigned long todoStatus) const;
+       int ConvertTodoPriorityToCalendarTodoPriority(unsigned long todoPriority) const;
+
+       Tizen::Base::Collection::HashMapT<int, int>* GenerateEventCategoryMapN(void) const;
+       Tizen::Base::Collection::IList* GetEventInstancesOfAllCategoriesN(const calendar_time_s& startTime, const calendar_time_s& endTime,
+                       const calendar_time_s& localStartTime, const calendar_time_s& localEndTime, int pageNo, int countPerPage) const;
+       Tizen::Base::Collection::IList* GetEventInstancesOfCategoryN(const calendar_time_s& startTime, const calendar_time_s& endTime,
+                       const calendar_time_s& localStartTime, const calendar_time_s& localEndTime, int pageNo, int countPerPage, unsigned long category) const;
+
+       static CalEvent* ConvertAllDayEventInstanceHandleToCalEventN(calendar_record_h instanceHandle);
+       static CalEvent* ConvertNonAllDayEventInstanceHandleToCalEventN(calendar_record_h instanceHandle);
+       static CalEventInstance* ConvertAllDayEventInstanceHandleToCalEventInstanceN(calendar_record_h instanceHandle);
+       static CalEventInstance* ConvertNonAllDayEventInstanceHandleToCalEventInstanceN(calendar_record_h instanceHandle);
+       static CalEventChangeInfo* ConvertModifiedEventToCalEventChangeInfoN(calendar_record_h modifiedEventHandle);
+       static CalTodoChangeInfo* ConvertModifiedTodoToCalTodoChangeInfoN(calendar_record_h modifiedTodoHandle);
+
+       template<typename RecordType, typename RecordTypeImpl, typename RecordView>
+       static Tizen::Base::Collection::IList* ConvertRecordListN(calendar_list_h resultListHandle, RecordView recordView);
+       static Tizen::Base::Collection::IList* ConvertEventInstanceListN(calendar_list_h resultListHandle, bool isAllDay);
+
+private:
+       IRecordEventListener*                       __pIRecordEventListener;
+       ICalendarbookEventListener*                 __pICalendarbookEventListener;
+       int                                         __dbVersionForEvent;
+       int                                         __dbVersionForTodo;
+
+       _CalendarbookDbMonitor*                     __pCalendarbookDbMonitor;
+
+       static RequestId                            __requestId;
+       static _CalendarbookRecordRetrivalThread*   __pRecordRetrivalThread;
+};     // _CalendarbookImpl
+
+}}     // Tizen::Social
+
+#endif //_FSCL_INTERNAL_CALENDARBOOK_IMPL_H_
diff --git a/src/inc/FScl_CategoryImpl.h b/src/inc/FScl_CategoryImpl.h
new file mode 100644 (file)
index 0000000..1cfde87
--- /dev/null
@@ -0,0 +1,154 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_CategoryImpl.h
+ * @brief              This is the header file for the %_CategoryImpl class.
+ *
+ * This header file contains the declarations of the %_CategoryImpl class.
+ */
+
+#ifndef _FSCL_INTERNAL_CATEGORY_IMPL_H_
+#define _FSCL_INTERNAL_CATEGORY_IMPL_H_
+
+#include <contacts.h>
+
+#include <unique_ptr.h>
+#include <FBaseObject.h>
+
+namespace Tizen { namespace Base {
+
+class String;
+
+namespace Collection
+{
+class IList;
+template <typename Type>
+class IListT;
+}}}
+
+namespace Tizen { namespace Social
+{
+class Category;
+class Record;
+
+/**
+ * @class      _CategoryImpl
+ * @since      2.0
+ * @see        Category
+ */
+class _CategoryImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is default constructor.
+        *
+        * @since       2.0
+        */
+       _CategoryImpl(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        */
+       _CategoryImpl(const _CategoryImpl& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~_CategoryImpl(void);
+
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       void SetRecordHandle(contacts_record_h recordHandle);
+
+       contacts_record_h GetRecordHandle(void) const;
+
+       result AddMember(RecordId contactId);
+
+       int GetMemberCount(void) const;
+
+       Tizen::Base::String GetName(void) const;
+
+       bool HasMember(RecordId contactId) const;
+
+       result RemoveMember(RecordId contactId);
+
+       result SetName(const Tizen::Base::String& name);
+
+       result SetRingtonePath(const Tizen::Base::String& ringtone);
+
+       Tizen::Base::String GetRingtonePath(void) const;
+
+       void SetAddressbookId(AddressbookId addressbookId);
+
+       AddressbookId GetAddressbookId(void) const;
+
+       result SetThumbnail(const Tizen::Base::String& filePath);
+
+       Tizen::Base::String GetThumbnailPath(void) const;
+
+       bool IsDefault(void) const;
+
+       bool IsReadOnly(void) const;
+
+       Tizen::Base::Collection::IMap* GetExtraDataN(void) const;
+
+       void SetMemberCount(int memberCount);
+
+       void SetRecord(const Record& record);
+
+       void ClearAddedMemberList(void);
+
+       void ClearRemovedMemberList(void);
+
+       Tizen::Base::Collection::IListT<int>* GetMembersN(void) const;
+
+       Tizen::Base::Collection::IListT<int>* GetAddedMembersN(void) const;
+
+       Tizen::Base::Collection::IListT<int>* GetRemovedMembersN(void) const;
+
+       result Invalidate(void);
+
+       static const _CategoryImpl* GetInstance(const Category& category);
+
+       static _CategoryImpl* GetInstance(Category& category);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        */
+       _CategoryImpl& operator =(const _CategoryImpl& rhs);
+
+private:
+       result LoadMemberList(void);
+
+private:
+       contacts_record_h __recordHandle;
+       bool __hasMemberList;
+       int __memberCount;
+       std::unique_ptr< Tizen::Base::Collection::IListT<int> > __pMembers;
+       std::unique_ptr< Tizen::Base::Collection::IListT<int> > __pAddedMembers;
+       std::unique_ptr< Tizen::Base::Collection::IListT<int> > __pRemovedMembers;
+}; // _CategoryImpl
+
+}} // Tizen::Social
+
+#endif //_FSCL_INTERNAL_CATEGORY_IMPL_H_
diff --git a/src/inc/FScl_ContactDbConnector.h b/src/inc/FScl_ContactDbConnector.h
new file mode 100644 (file)
index 0000000..af6a4f7
--- /dev/null
@@ -0,0 +1,59 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_ContactDbConnector.h
+ * @brief              This is the header file for the _ContactDbConnector class.
+ *
+ * This header file contains the declarations of the _ContactDbConnector class.
+ */
+#ifndef _FSCL_INTERNAL_CONTACT_DB_CONNECTOR_H_
+#define _FSCL_INTERNAL_CONTACT_DB_CONNECTOR_H_
+
+#include <unique_ptr.h>
+#include <contacts.h>
+
+namespace Tizen { namespace Social
+{
+
+class _ContactDbConnector
+{
+public:
+
+       static _ContactDbConnector* GetInstance(void);
+
+       result Connect(void);
+
+       result Disconnect(void);
+
+       static result EnsureDbConnection(void);
+
+private:
+       _ContactDbConnector(void);
+
+       ~_ContactDbConnector(void);
+
+       static void InitContactDbConnector(void);
+       static void DestroyContactDbConnector(void);
+
+private:
+       static _ContactDbConnector* __pInstance;
+       static bool __isConnected;
+       friend class std::default_delete< _ContactDbConnector >;
+};
+
+}} // Tizen::Social
+
+#endif //_FSCL_INTERNAL_CONTACT_DB_CONNECTOR_H_
diff --git a/src/inc/FScl_ContactImpl.h b/src/inc/FScl_ContactImpl.h
new file mode 100644 (file)
index 0000000..a5099b2
--- /dev/null
@@ -0,0 +1,214 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_ContactImpl.h
+ * @brief              This is the header file for the _ContactImpl class.
+ *
+ * This header file contains the declarations of the _ContactImpl class.
+ */
+#ifndef _FSCL_INTERNAL_CONTACT_IMPL_H_
+#define _FSCL_INTERNAL_CONTACT_IMPL_H_
+
+#include <contacts.h>
+#include <unique_ptr.h>
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FBaseColAllElementsDeleter.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Base
+{
+class DateTime;
+
+namespace Collection
+{
+class IList;
+}
+
+}}
+
+namespace Tizen { namespace Graphics
+{
+class Bitmap;
+}}
+
+namespace Tizen { namespace Social
+{
+class Contact;
+class Address;
+class PhoneNumber;
+class Email;
+class Url;
+class ImAddress;
+class Organization;
+class ContactEvent;
+class Relationship;
+class ContactAppLaunchData;
+
+/**
+ * @class      _ContactImpl
+ * @brief      This class provides a contact.
+ * @since      2.0
+ * @see        Contact
+ *
+ */
+class _ContactImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor of the class
+        *
+        * @since       2.0
+        */
+       _ContactImpl(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        */
+       _ContactImpl(const _ContactImpl& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~_ContactImpl(void);
+
+       void SetContactRecordHandle(contacts_record_h contactHandle);
+
+       contacts_record_h GetContactRecordHandle(void) const;
+
+       result SetThumbnailPath(const Tizen::Base::String& filePath);
+
+       Tizen::Base::String GetThumbnailPath(void) const;
+
+       Tizen::Graphics::Bitmap* GetThumbnailN(void) const;
+
+       result GetValue(const ContactPropertyId id, Tizen::Base::String& value) const;
+
+       result GetValue(const ContactPropertyId id, Tizen::Base::DateTime& value) const;
+
+       result SetValue(ContactPropertyId id, const Tizen::Base::String& value);
+
+       result SetValue(ContactPropertyId id, const Tizen::Base::DateTime& value);
+
+       result AddPhoneNumber(const Tizen::Social::PhoneNumber& phoneNumber);
+
+       result AddNickname(const Tizen::Base::String& nickname);
+
+       result AddNote(const Tizen::Base::String& note);
+
+       result AddEmail(const Tizen::Social::Email& email);
+
+       result AddUrl(const Tizen::Social::Url& url);
+
+       result AddAddress(const Tizen::Social::Address& address);
+
+       result AddImAddress(const Tizen::Social::ImAddress& imAddress);
+
+       result AddEvent(const ContactEvent& event);
+
+       result AddOrganization(const Organization& organization);
+
+       result AddRelationship(const Relationship& relationship);
+
+       result AddContactAppLaunchData(const ContactAppLaunchData& appLaunchData);
+
+       result RemoveAt(ContactMultiPropertyId id, int index);
+
+       Tizen::Base::Collection::IList* GetValuesN(const ContactMultiPropertyId id);
+
+       result SetNoteAt(int index, const Tizen::Base::String& note);
+
+       result SetNicknameAt(int index, const Tizen::Base::String& nickname);
+
+       result SetEmailAt(int index, const Tizen::Social::Email& email);
+
+       result SetPhoneNumberAt(int index, const Tizen::Social::PhoneNumber& phoneNumber);
+
+       result SetUrlAt(int index, const Tizen::Social::Url& url);
+
+       result SetAddressAt(int index, const Tizen::Social::Address& address);
+
+       result SetImAddressAt(int index, const Tizen::Social::ImAddress& imAddress);
+
+       result SetRelationshipAt(int index, const Tizen::Social::Relationship& relationship);
+
+       result SetEventAt(int index, const Tizen::Social::ContactEvent& event);
+
+       result SetOrganizationAt(int index, const Tizen::Social::Organization& organization);
+
+       result SetContactAppLaunchDataAt(int index, const Tizen::Social::ContactAppLaunchData& appLaunchData);
+
+       bool IsEmpty(void) const;
+
+       AddressbookId GetAddressbookId(void) const;
+
+       PersonId GetPersonId(void) const;
+
+       void SetAsRemoved(void);
+
+       bool IsRemoved(void) const;
+
+       result Invalidate(void);
+
+       bool IsFavorite(void) const;
+
+       void SetAsFavorite(bool isFavorite = true);
+
+       PhoneNumberType GetNativePhoneNumberType(int coreType) const;
+
+       static const _ContactImpl* GetInstance(const Contact& contact);
+
+       static _ContactImpl* GetInstance(Contact& contact);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        */
+       _ContactImpl& operator =(const _ContactImpl& rhs);
+
+private:
+       bool IsEmptyName(contacts_record_h nameHandle);
+       bool IsEmptyCompany(contacts_record_h companyHandle);
+       int GetMaxLength(ContactPropertyId id);
+
+       Tizen::Base::Collection::IList* GetPhoneNumbersN(void) const;
+       Tizen::Base::Collection::IList* GetEmailsN(void) const;
+       Tizen::Base::Collection::IList* GetUrlsN(void) const;
+       Tizen::Base::Collection::IList* GetAddressesN(void) const;
+       Tizen::Base::Collection::IList* GetImAddressesN(void) const;
+       Tizen::Base::Collection::IList* GetOrganizationsN(void) const;
+       Tizen::Base::Collection::IList* GetRelationshipsN(void) const;
+       Tizen::Base::Collection::IList* GetEventsN(void) const;
+       Tizen::Base::Collection::IList* GetNotesN(void) const;
+       Tizen::Base::Collection::IList* GetNicknamesN(void) const;
+       Tizen::Base::Collection::IList* GetContactAppLaunchDataN(void) const;
+
+private:
+       contacts_record_h __contactHandle;
+       bool __isRemoved;
+
+}; // _ContactImpl
+
+}} // Tizen::Social
+
+#endif //_FSCL_INTERNAL_CONTACT_IMPL_H_
diff --git a/src/inc/FScl_EmailImpl.h b/src/inc/FScl_EmailImpl.h
new file mode 100644 (file)
index 0000000..74cb810
--- /dev/null
@@ -0,0 +1,89 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+* @file                FScl_EmailImpl.h
+* @brief       This is the header file for the %_EmailImpl class.
+*
+* This header file contains the declarations of the %_EmailImpl class.
+*/
+#ifndef _FSCL_EMAIL_IMPL_H_
+#define _FSCL_EMAIL_IMPL_H_
+
+#include <contacts.h>
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Social
+{
+
+class Email;
+
+class _OSP_EXPORT_ _EmailImpl
+       : public Tizen::Base::Object
+{
+public:
+       _EmailImpl(void);
+
+       _EmailImpl(EmailType type, const Tizen::Base::String& email);
+
+       _EmailImpl(const _EmailImpl& rhs);
+
+       virtual ~_EmailImpl(void);
+
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       virtual int GetHashCode(void) const;
+
+       void SetRecordId(int recordId);
+
+       int GetRecordId(void) const;
+
+       EmailType GetType(void) const;
+
+       void SetType(EmailType type);
+
+       Tizen::Base::String GetEmail(void) const;
+
+       result SetEmail(const Tizen::Base::String& email);
+
+       Tizen::Base::String GetLabel(void) const;
+
+       void SetLabel(const Tizen::Base::String& label);
+
+       bool IsEmpty(void) const;
+
+       _EmailImpl& operator =(const _EmailImpl& rhs);
+
+       bool operator ==(const _EmailImpl& rhs) const;
+
+       bool operator !=(const _EmailImpl& rhs) const;
+
+       static const _EmailImpl* GetInstance(const Email& email);
+
+       static _EmailImpl* GetInstance(Email& email);
+
+private:
+       int __recordId;
+       EmailType __type;
+       Tizen::Base::String __label;
+       Tizen::Base::String __email;
+}; // _EmailImpl
+
+}} // Tizen::Social
+
+#endif // _FSCL_EMAIL_H_
diff --git a/src/inc/FScl_IContactDbChangeEventListener.h b/src/inc/FScl_IContactDbChangeEventListener.h
new file mode 100644 (file)
index 0000000..78f161d
--- /dev/null
@@ -0,0 +1,52 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_IContactDbChangeEventListener.h
+ * @brief      This is the header file for the _IContactDbChangeEventListener class.
+ *
+ * This file contains the declarations of _IContactDbChangeEventListener.
+ */
+
+#ifndef _FSCL_INTERNAL_ICONTACT_DB_CHANGE_EVENT_LISTENER_H_
+#define _FSCL_INTERNAL_ICONTACT_DB_CHANGE_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+
+namespace Tizen { namespace Social
+{
+
+class _IContactDbChangeEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+       /**
+        * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes @n
+        * are called when the destructor of this interface is called.
+        *
+        * @since       2.0
+        */
+       virtual ~_IContactDbChangeEventListener(void){}
+
+       virtual void OnContactChanged(void) = 0;
+
+       virtual void OnCategoryChanged(void) = 0;
+
+       virtual void OnRelationChanged(void) = 0;
+}; // _IContactDbChangeEventListener
+
+}} // Tizen::Social
+
+#endif // _FSCL_INTERNAL_ICONTACT_DB_CHANGE_EVENT_LISTENER_H_
diff --git a/src/inc/FScl_RecordImpl.h b/src/inc/FScl_RecordImpl.h
new file mode 100644 (file)
index 0000000..2cc4f50
--- /dev/null
@@ -0,0 +1,123 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_RecordImpl.h
+ * @brief              This is the header file for the %_RecordImpl class.
+ *
+ * This header file contains the declarations of the %_RecordImpl class.
+ */
+#ifndef _FSCL_INTERNAL_RECORD_IMPL_H_
+#define _FSCL_INTERNAL_RECORD_IMPL_H_
+
+#include <FBaseObject.h>
+#include <FSclRecord.h>
+
+namespace Tizen { namespace Social
+{
+
+/**
+ * @class      _RecordImpl
+ * @brief      This class defines the general behavior of records used in various manners
+ * @since      2.0
+ */
+class _RecordImpl
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * Initializes this instance of _RecordImpl with the specified type.
+        *
+        * @param[in]   type                    The type of this record
+        */
+       _RecordImpl(RecordType type);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~_RecordImpl(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             The source instance of _RecordImpl
+        */
+       _RecordImpl(const _RecordImpl& rhs);
+
+       /**
+        * Gets the type of the current instance of _RecordImpl.
+        *
+        * @since       2.0
+        * @see                 Record::GetRecordType
+        */
+       RecordType GetRecordType(void) const;
+
+       /**
+        * Gets the local-wide unique ID of the current instance of Record.
+        *
+        * @since       2.0
+        * @see                 Record::GetRecordId
+        */
+       RecordId GetRecordId(void) const;
+
+       /**
+        * Sets the Id of this record
+        *
+        * @since       2.0
+        * @param[in]   recordId                                        The ID of this record
+        */
+       void SetRecordId(RecordId recordId);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @since       2.0
+        * @return      The pointer to const _RecordImpl
+        * @param[in]   record          A const instance of %Record class
+        */
+       static const _RecordImpl* GetInstance(const Record& record);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @since       2.0
+        * @return      The pointer to _RecordImpl
+        * @param[in]   record          An instance of %Record class
+        */
+       static _RecordImpl* GetInstance(Record& record);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             The source instance of _RecordImpl
+        */
+       _RecordImpl& operator =(const _RecordImpl& rhs);
+
+private:
+       RecordType __recordType;
+       RecordId __recordId;
+
+}; // _RecordImpl
+
+}} // Tizen::Social
+
+#endif //_FSCL_INTERNAL_RECORD_IMPL_H_
diff --git a/src/inc/FScl_RecurrenceImpl.h b/src/inc/FScl_RecurrenceImpl.h
new file mode 100644 (file)
index 0000000..18ab8a4
--- /dev/null
@@ -0,0 +1,428 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_RecurrenceImpl.h
+ * @brief      This is the header file for the %_RecurrenceImpl class.
+ *
+ * This header file contains the declarations of the %_RecurrenceImpl class.
+ */
+#ifndef _FSCL_INTERNAL_RECURRENCE_IMPL_H_
+#define _FSCL_INTERNAL_RECURRENCE_IMPL_H_
+
+#include <unique_ptr.h>
+#include <FBaseColAllElementsDeleter.h>
+#include <FBaseObject.h>
+#include <FSclTypes.h>
+//#include <FScl_CalendarbookUtil.h>
+
+namespace Tizen { namespace Base
+{
+class DateTime;
+namespace Collection
+{
+class ArrayList;
+}
+}}
+
+namespace Tizen { namespace Social
+{
+class Recurrence;
+
+/**
+ * @class      _RecurrenceImpl
+ * @brief      This class provides the methods to access the information of a %_RecurrenceImpl.
+ *
+ * @since      2.0
+ */
+class _RecurrenceImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class. @n
+        * This constructor sets the default values. The recurrence type is daily and recurrence interval is @c 1. @n
+        * The week start day is #CAL_MONDAY. The recurrence count is @c 1.
+        *
+        * @since       2.0
+        */
+       _RecurrenceImpl(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %_RecurrenceImpl
+        */
+       _RecurrenceImpl(const _RecurrenceImpl& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~_RecurrenceImpl(void);
+
+       /**
+        * Compares the input Object with the calling %_RecurrenceImpl instance.
+        *
+        * @return              @c true if the input object equals the calling %_RecurrenceImpl instance, @n
+        *                              else @c false
+        * @param[in]   rhs     The object instance to compare with the calling object
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @return              The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the recurrence frequency type.
+        *
+        * @since       2.0
+        *
+        * @return              A reference to one of the @c RecurFrequency enumeration values, @n
+        *                              else #FREQ_DAILY if this property is not set
+        */
+       RecurFrequency GetFrequency(void) const;
+
+       /**
+        * Gets the recurrence interval. @n
+        * This represents the number of units between two recurrences. @n
+        * If the frequency is weekly and the recurrence interval is set to @c 2, the event occurs every two weeks.
+        *
+        * @since       2.0
+        *
+        * @return              An integer value representing the recurrence interval, @n
+        *                              else @c 1 if this property is not set
+        */
+       int GetInterval(void) const;
+
+       /**
+        * Gets the end date and time of recurrence.
+        *
+        * @since       2.0
+        *
+        * @return              An instance of %DateTime representing the end date and time
+        * @remarks             If this method returns @c null, get the recurrence counts using the GetCounts() method.
+        *
+        */
+       const Tizen::Base::DateTime* GetUntil(void) const;
+
+       /**
+        * Gets the number of times the event recurs.
+        *
+        * @since       2.0
+        *
+        * @return              An integer value representing the number of recurrences
+        * @remarks             If this method returns @c 0, get the recurrence end date and time using the GetUntil() method.
+        *
+        */
+       int GetCounts(void) const;
+
+       /**
+        * Gets the first day of the week. @n
+        * The default value is #CAL_MONDAY.
+        *
+        * @since       2.0
+        *
+        * @return              An integer value representing the first day of the week
+        *
+        */
+       CalDayOfWeek GetWeekStart(void) const;
+
+       /**
+        * Gets the day of the week when the event should recur. @n
+        * The default value is @c 0.
+        *
+        * @since       2.0
+        *
+        * @return              An integer value representing the CalDayofWeek
+        * @remarks             The Frequency property must be obtained. If the frequency is #FREQ_WEEKLY, the return value may be a combination of days,
+        *                              like #CAL_MONDAY| #CAL_THURSDAY.
+        *
+        */
+       int GetDayOfWeek(void) const;
+
+       /**
+        * Gets the day of the month. @n
+        * The default value is @c 0.
+        *
+        * @since       2.0
+        *
+        * @return              An integer value between @c 1 ~ @c 31 representing the day of a month
+        * @remarks             The Frequency property must be obtained.
+        */
+       int GetDayOfMonth(void) const;
+
+       /**
+        * Gets the week of the month. @n
+        * The default value is @c 0.
+        *
+        * @since       2.0
+        *
+        * @return              An integer value between @c 1 ~ @c 5 representing the week of a month
+        * @remarks             The Frequency property must be obtained.
+        *
+        */
+       int GetWeekOfMonth(void) const;
+
+       /**
+        * Gets the month of the year. @n
+        * The default value is @c 0.
+        *
+        * @since       2.0
+        *
+        * @return              An integer value between @c 1 ~ @c 12 representing the month of a year
+        * @remarks             The Frequency property must be obtained.
+        *
+        */
+       int GetMonthOfYear(void) const;
+
+       /**
+        * Set a recurring frequency type among specific types (daily, weekly, monthly, and yearly). @n
+        * This property should be set before setting the day of recurrence. After setting the frequency, other properties are reset to default values. @n
+        * For weekly, the day of week must be set. @n
+        * For monthly, either the day of the month or the day of the week and the week of the month must be set. @n
+        * For yearly, either the day of the month and the month of the year or the day of the week, the week of the month, and the month of the year must be set.
+        *
+        * @since       2.0
+        *
+        * @param[in]   type    The recurrence type
+        *
+        */
+       void SetFrequency(RecurFrequency type);
+
+       /**
+        * Sets the interval of recurrence. @n
+        * If the frequency is weekly and the recurrence interval is set to 2, the event occurs every two weeks.
+        *
+        * @since       2.0
+        * @compatibility       This method has compatibility issues with OSP API versions @b prior @b to @b 2.1. @n
+     *                                 For more information, see @ref CompRecurrenceSetIntervalPage "here".
+        *
+        * @return              An error code
+        * @param[in]   interval                The interval of recurrence
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c interval is less than @c 1.
+        * @remarks             The maximum value of an interval is 255 for OSP API 2.0, whereas, there is no limit for OSP API versions since 2.1
+        */
+       result SetInterval(int interval);
+
+       /**
+        * @page        CompRecurrenceSetIntervalPage Compatibility for SetInterval()
+        * @section     CompRecurrenceSetIntervalPageIssueSection Issues
+        *          Implementation of this method in OSP API versions prior to 2.1 has the following issue:
+        *                      -# If the value of the interval to be set, is greater than 255, E_INVALID_ARG is returned.
+        *
+        * @section     CompRecurrenceSetIntervalPageSolutionSection Resolutions
+        *                      The issue mentioned above is resolved in OSP API version 2.1, and it is recommended to use OSP API version 2.1 or above.
+        */
+
+       /**
+        * Sets the end date of the recurrence. @n
+        * If you want to set the event to have no end date, set the maximum date and time using the Tizen::Base::DateTime::GetMaxValue() method.
+        * Only the date is used to set the recurrence; the time is ignored.
+        * If the @c pUntil parameter is set to @c 2010.01.17 12:30:00, the recurrence uses @c 2010.01.17 00:00:00.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   pUntil                  The end date and time
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_OUT_OF_MEMORY The memory is insufficient.
+        * @remarks             Either the until or count properties may be set. @n
+        *                              When the until property is set, the count property becomes @c 0. @n
+        *                              When the count property is set, the until property becomes @c null.
+        */
+       result SetUntil(const Tizen::Base::DateTime* pUntil);
+
+       /**
+        * Sets the number of times the event recurs.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   count                   The number of times the event recurs
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c count is less than @c 0.
+        * @remarks             Either the until or count properties may be set. @n
+        *                              When the until property is set, the count property becomes @c 0. @n
+        *                              When the count property is set, the until property becomes @c null. @n
+        */
+       result SetCounts(int count);
+
+       /**
+        * Sets the first day of the week. @n
+        * The default value is set to #CAL_MONDAY. The valid values are #CAL_SUNDAY and #CAL_MONDAY. @n
+        * This value is very important when the recurrence type is weekly and the interval is greater than @c 1. @n
+        * The weekly recurrence rule will be calculated based on the week start value.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   weekStart                               The day on which the week starts
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c day is invalid.
+        */
+       result SetWeekStart(CalDayOfWeek weekStart);
+
+       /**
+        * Sets the day of the week that represents the days when the event should recur. @n
+        * The valid values range between #CAL_SUNDAY and #CAL_SATURDAY. @n
+        * Any values other than #CAL_SUNDAY ~ #CAL_SATURDAY are ignored. @n
+        * The @c Frequency property must be set before setting this property.
+        * This property is valid for the following #RecurFrequency enumeration types: #FREQ_WEEKLY, #FREQ_MONTHLY, and #FREQ_YEARLY.
+        * If the frequency is #FREQ_WEEKLY, the value of the day may be a combination of days, such as #CAL_MONDAY|#CAL_FRIDAY.
+        * If the frequency is other than #FREQ_WEEKLY, only one day of the week can be set.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   day                             An integer value representing the day of the week
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c day is invalid.
+        * @exception   E_TYPE_MISMATCH The #RecurFrequency is not #FREQ_WEEKLY, #FREQ_MONTHLY, or #FREQ_YEARLY.
+        * @remarks             After this property is set, the DayOfMonth property value is reset automatically.
+        */
+       result SetDayOfWeek(int day);
+
+       /**
+        * Sets the day of the month which indicates when the event recurs. @n
+        * The @c Frequency property must be set before setting this property. @n
+        * This property is valid for the following #RecurFrequency enumeration types: #FREQ_MONTHLY and #FREQ_YEARLY. @n
+        * If the day of the month is 31 and the frequency is monthly, the months which have only 30 days are not included in the recurrence instance set. @c
+        * Accordingly, with the recurrence rule, 2/29 yearly, 2/29 every four years will be included in the recurrence set.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   day                                     An integer value between @c 1 and @c 31 indicating the day of the month
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c day is less than @c 1 or greater than @c 31.
+        * @exception   E_TYPE_MISMATCH         The #RecurFrequency is not #FREQ_MONTHLY or #FREQ_YEARLY.
+        * @remarks             After you set this property, the DayOfWeek and WeekOfMonth property value are reset automatically.
+        */
+       result SetDayOfMonth(int day);
+
+       /**
+        * Sets the week of the month. @n
+        * If the value of the week is @c 5, it is set as the last week of the month. @n
+        * This property is valid for the following #RecurFrequency enumeration types: #FREQ_MONTHLY and #FREQ_YEARLY.
+        * The @c Frequency property must be set before setting this property. @n
+        * When the week of the month is set, the day of the week should be set accordingly.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   week                            An integer value between @c 1 and @c 5 representing the week of the month
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c week is less than @c 1 or greater than @c 5.
+        * @exception   E_TYPE_MISMATCH         The #RecurFrequency is not #FREQ_MONTHLY or #FREQ_YEARLY.
+        * @remarks             After you set this property, the DayOfMonth property value is reset automatically.
+        */
+       result SetWeekOfMonth(int week);
+
+       /**
+        * Sets the month of the year. @n
+        * This property is valid for the following #RecurFrequency enumeration type: #FREQ_YEARLY. @n
+        * You must set the @c Frequency property before setting this property. @n
+        * When the month of the year is set, the day of the month or both the day of the week and the week of the month should be set accordingly.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   month                           An integer value between @c 1 and @c 12 representing the month of the year
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c month is less than @c 1 or greater than @c 12.
+        * @exception   E_TYPE_MISMATCH         The #RecurFrequency is not #FREQ_YEARLY.
+        */
+       result SetMonthOfYear(int month);
+
+       /**
+        * Adds an exception date to this event.
+        * The instance that its start date and time matched with the exception date will be exclude from recurrence instances.
+        * If there are any changes in this recurrence, the exception dates would be cleared.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   exceptionDate                   The exception date to exclude
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The exceptionDate is invalid.
+        * @exception   E_OBJ_ALREADY_EXIST             The exceptionDate already exists.
+        */
+       result AddExceptionDate(const Tizen::Base::DateTime& exceptionDate);
+
+       /**
+        * Gets the exception dates.
+        *
+        * @since       2.0
+        *
+        * @return              A list containing the exception dates, @n
+        *                              else an empty list if there are no exception dates or @c null if an exception occurs @n
+        *                              The results are listed in the order of date and time.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetExceptionDatesN(void) const;
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return                      The pointer to const _RecurrenceImpl
+        * @param[in]   recurrence              A const instance of %Recurrence class
+        */
+       static _RecurrenceImpl* GetInstance(Recurrence& recurrence);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return                      The pointer to const _RecurrenceImpl
+        * @param[in]   recurrence              A const instance of %Recurrence class
+        */
+       static const _RecurrenceImpl* GetInstance(const Recurrence& recurrence);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %_RecurrenceImpl
+        */
+       _RecurrenceImpl& operator =(const _RecurrenceImpl& rhs);
+
+private:
+       RecurFrequency __type;
+       int __interval;
+       std::unique_ptr<Tizen::Base::DateTime> __pUntil;
+       int __count;
+       CalDayOfWeek __weekStart;
+       int __dayOfWeek;
+       int __dayOfMonth;
+       int __weekOfMonth;
+       int __monthOfYear;
+       std::unique_ptr<Tizen::Base::Collection::ArrayList, Tizen::Base::Collection::AllElementsDeleter> __pExceptionDates;
+
+};     // _RecurrenceImpl
+
+}}     // Tizen::Social
+
+#endif // _FSCL_INTERNAL_RECURRENCE_IMPL_H_
diff --git a/src/inc/FScl_ReminderImpl.h b/src/inc/FScl_ReminderImpl.h
new file mode 100644 (file)
index 0000000..b0f32c3
--- /dev/null
@@ -0,0 +1,91 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file       FScl_ReminderImpl.h
+ * @brief      This is the header file for the %_ReminderImpl class.
+ *
+ * This header file contains the declarations of the %_ReminderImpl class.
+ */
+#ifndef _FSCL_INTERNAL_REMINDER_IMPL_H_
+#define _FSCL_INTERNAL_REMINDER_IMPL_H_
+
+#include <unique_ptr.h>
+#include <FBaseObject.h>
+#include <FSclTypes.h>
+
+namespace Tizen { namespace Base
+{
+class DateTime;
+}}
+
+namespace Tizen { namespace Social
+{
+class Reminder;
+
+/**
+ * @class      _ReminderImpl
+ */
+class _ReminderImpl
+       : public Tizen::Base::Object
+{
+public:
+
+       _ReminderImpl(void);
+       _ReminderImpl(const _ReminderImpl& rhs);
+       virtual ~_ReminderImpl(void);
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+       virtual int GetHashCode(void) const;
+
+       result SetAbsoluteTime(const Tizen::Base::DateTime& time);
+       Tizen::Base::DateTime GetAbsoluteTime(void) const;
+       bool IsAbsolute(void) const;
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return                      The pointer to const _ReminderImpl
+        * @param[in]   reminder                A const instance of %Reminder class
+        */
+       static _ReminderImpl* GetInstance(Reminder& reminder);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return                      The pointer to const _ReminderImpl
+        * @param[in]   reminder                A const instance of %Reminder class
+        */
+       static const _ReminderImpl* GetInstance(const Reminder& reminder);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %_ReminderImpl
+        */
+       _ReminderImpl& operator =(const _ReminderImpl& rhs);
+
+private:
+       Tizen::Base::DateTime __absoluteTime;
+       bool __isAbsolute;
+
+       friend class Reminder;
+
+};     // _ReminderImpl
+
+}}     // Tizen::Social
+
+#endif // _FSCL_INTERNAL_REMINDER_IMPL_H_
diff --git a/src/inc/FScl_UserProfileImpl.h b/src/inc/FScl_UserProfileImpl.h
new file mode 100644 (file)
index 0000000..2eca05c
--- /dev/null
@@ -0,0 +1,496 @@
+//
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+/**
+ * @file               FScl_UserProfileImpl.h
+ * @brief              This is the header file for the _UserProfileImpl class.
+ *
+ * This header file contains the declarations of the _UserProfileImpl class.
+ */
+#ifndef _FSCL_INTERNAL_USER_PROFILE_H_
+#define _FSCL_INTERNAL_USER_PROFILE_H_
+
+#include <contacts.h>
+#include <unique_ptr.h>
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FBaseColAllElementsDeleter.h>
+
+namespace Tizen { namespace Base
+{
+class DateTime;
+
+namespace Collection
+{
+class IList;
+}
+
+}}
+
+namespace Tizen { namespace Social
+{
+class Contact;
+class Address;
+class PhoneNumber;
+class Email;
+class Url;
+class ImAddress;
+class Organization;
+class ContactEvent;
+class Relationship;
+class UserProfile;
+
+/**
+ * @class      _UserProfileImpl
+ * @brief      This class provides a contact.
+ * @since      2.1
+ * @see        UserProfile
+ *
+ */
+class _UserProfileImpl
+        : public Tizen::Base::Object
+{
+public:
+
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.1
+        */
+       _UserProfileImpl(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since       2.1
+        *
+        * @param[in]   rhs             An instance of %UserProfile
+        */
+       _UserProfileImpl(const _UserProfileImpl& rhs);
+
+       /**
+        * This destructor overrides Tizen::Social::Object::~Object().
+        *
+        * @since       2.1
+        *
+        */
+       virtual ~_UserProfileImpl(void);
+
+       /**
+        * Checks whether the value of the specified instance is equal to the value of the current instance of Tizen::Base::Object.
+        *
+        * @since       2.1
+        *
+        * @return      @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Tizen::Base::Object, @n
+        *              else @c false
+        * @param[in]   rhs             An instance of Tizen::Base::Object to compare
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since       2.1
+        *
+        * @return      The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+       /**
+        * Gets the thumbnail path
+        *
+        * @since       2.1
+        *
+        * @return     The file path of the thumbnail
+        * @remarks    If the thumbnail has not been set, an empty string is returned.
+        */
+       Tizen::Base::String GetThumbnailPath(void) const;
+
+       /**
+        * Sets the thumbnail image. @n
+        * If the specified @c filePath is an empty string, the current thumbnail image is removed.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   filePath                The file path of the thumbnail image
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The length of the specified @c filePath exceeds system limitations.
+        * @exception   E_FILE_NOT_FOUND        The specified file cannot be found or accessed.
+        * @exception   E_SYSTEM                A system error has occurred.
+        * @see GetThumbnailPath()
+        */
+       result SetThumbnail(const Tizen::Base::String& filePath);
+
+       /**
+        * Sets the value of the property having the specified ID to the specified value.
+        *
+        *
+        * @return      An error code
+        * @param[in]   id                      The ID of the property whose value is to set
+        * @param[in]   value                   A new string value to set
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified property is read-only.
+        */
+
+       result SetValue(UserProfilePropertyId id, const Tizen::Base::String& value);
+
+       /**
+        * Gets the value of the specified property.
+        *
+        * @since       2.1
+        *
+        * @return      The property value
+        * @param[in]   id                              The property ID
+        */
+       Tizen::Base::String GetValue(UserProfilePropertyId id) const;
+
+       /**
+        * Sets the specified phone number at the specified index.
+        *
+        * @since       2.1
+        *
+        * @return     An error code
+        * @param[in]  index            An index to set the value
+        * @param[in]  phoneNumber      An instance of PhoneNumber to set.
+        * @exception  E_SUCCESS        The method is successful.
+        * @exception  E_INVALID_ARG    The specified @c phoneNumber is empty.
+        * @exception  E_OUT_OF_RANGE   The specified @c index is outside the bounds of the properties.
+        */
+       result SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber);
+
+       /**
+        * Sets the specified email corresponding to the specified index.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   index                   An index to set the value
+        * @param[in]   email                   An instance of Email
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c email is empty.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetEmailAt(int index, const Email& email);
+
+       /**
+        * Sets the specified URL corresponding to the specified index.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   index                   An index to set the value
+        * @param[in]   url                     An instance of Url
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c url is empty.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetUrlAt(int index, const Url& url);
+
+       /**
+        * Sets the specified address corresponding to the specified index.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   index                   An index to set the value
+        * @param[in]   address                 An instance of Address
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c address is empty.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetAddressAt(int index, const Address& address);
+
+       /**
+        * Sets the specified ImAddress corresponding to the specified index.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   index                   An index to set the value
+        * @param[in]   imAddress               An instance of ImAddress
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c imAddress is empty.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetImAddressAt(int index, const ImAddress& imAddress);
+
+       /**
+        * Sets the specified note corresponding to the specified index.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   index                   An index to set the value
+        * @param[in]   note                    The note to set
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c note is empty.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetNoteAt(int index, const Tizen::Base::String& note);
+
+       /**
+        * Sets the specified nick name corresponding to the specified index.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   index                   An index to set the value
+        * @param[in]   nickname                The nick name to set
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetNicknameAt(int index, const Tizen::Base::String& nickname);
+
+       /**
+        * Sets the specified event corresponding to the specified index.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   index                   An index to set the value
+        * @param[in]   event                   The event to set
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c event is empty.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetEventAt(int index, const ContactEvent& event);
+
+       /**
+        * Sets the specified organization corresponding to the specified index.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   index                   An index to set the value
+        * @param[in]   organization            The organization to set
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c organization is empty.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetOrganizationAt(int index, const Organization& organization);
+
+       /**
+        * Sets the specified relationship corresponding to the specified index.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   index                   An index to set the value
+        * @param[in]   relationship            The relationship to set
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c relationship is empty.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result SetRelationshipAt(int index, const Relationship& relationship);
+
+       /**
+        * Gets the addressbook ID.
+        *
+        * @since       2.1
+        *
+        * @return      The addressbook ID
+        */
+       AddressbookId GetAddressbookId(void) const;
+
+       /**
+        * Gets a list of the values belonging to the specific multi value property.
+        *
+        * @since       2.1
+        *
+        * @return      A list of the values belonging to the specific multi value property
+        * @param[in]   id                      A property ID
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @remarks     The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetValuesN(UserProfileMultiPropertyId id) const;
+
+       /**
+        * Adds the specified phone number to the user profile..
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   phoneNumber             The phone number to add
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c phoneNumber is empty.
+        */
+       result AddPhoneNumber(const PhoneNumber& phoneNumber);
+
+       /**
+        * Adds the specified email to the user profile..
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   email           The mail address to add
+        * @exception   E_SUCCESS       The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c email is empty.
+        */
+       result AddEmail(const Email& email);
+
+       /**
+        * Adds the specified URL to the user profile..
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   url             The URL to add
+        * @exception   E_SUCCESS       The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c url is empty.
+        */
+
+       result AddUrl(const Url& url);
+
+       /**
+        * Adds the specified address to the user profile..
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   address         The address to add
+        * @exception   E_SUCCESS       The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c address is empty.
+        */
+       result AddAddress(const Address& address);
+
+       /**
+        * Adds the specified instant message information to the user profile.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   imAddress       The IM address to add
+        * @exception   E_SUCCESS       The method is successful.
+        * @exception   E_INVALID_ARG   The specified @c imAddress is empty.
+        */
+       result AddImAddress(const ImAddress& imAddress);
+
+       /**
+        * Adds the specified note to the user profile..
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   note                    The note to add
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c note is empty.
+        */
+       result AddNote(const Tizen::Base::String& note);
+
+       /**
+        * Adds the specified nick name to the user profile.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   nickname                The nick name to add
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c nickname is empty.
+        */
+       result AddNickname(const Tizen::Base::String& nickname);
+
+       /**
+        * Adds the specified event to the user profile..
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   event                   The event to add
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c event is empty.
+        */
+       result AddEvent(const ContactEvent& event);
+
+       /**
+        * Adds the specified organization to the contact.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   organization            The organization to add
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c organization is empty.
+        */
+       result AddOrganization(const Organization& organization);
+
+       /**
+        * Adds the specified relationship to the user profile.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   relationship            The relationship to add
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c organization is empty.
+        */
+       result AddRelationship(const Relationship& relationship);
+
+       /**
+        * Removes the specific value at the specified index of the multi value property.
+        *
+        * @since       2.1
+        *
+        * @return      An error code
+        * @param[in]   id                      A property ID
+        * @param[in]   index                   The index of the value to remove
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
+        */
+       result RemoveAt(UserProfileMultiPropertyId id, int index);
+
+       void SetUserProfileHandle(contacts_record_h profileHandle);
+
+       contacts_record_h GetUserProfileHandle(void) const;
+
+       bool IsEmpty(void) const;
+
+       static const _UserProfileImpl* GetInstance(const UserProfile& userProfile);
+       static _UserProfileImpl* GetInstance(UserProfile& userProfile);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.1
+        *
+        * @param[in]   rhs             An instance of %UserProfile
+        */
+       _UserProfileImpl& operator =(const _UserProfileImpl& rhs);
+
+private:
+       bool IsEmptyName(contacts_record_h nameHandle);
+       bool IsEmptyCompany(contacts_record_h companyHandle);
+
+       Tizen::Base::Collection::IList* GetPhoneNumbersN(void) const;
+       Tizen::Base::Collection::IList* GetEmailsN(void) const;
+       Tizen::Base::Collection::IList* GetUrlsN(void) const;
+       Tizen::Base::Collection::IList* GetAddressesN(void) const;
+       Tizen::Base::Collection::IList* GetImAddressesN(void) const;
+       Tizen::Base::Collection::IList* GetOrganizationsN(void) const;
+       Tizen::Base::Collection::IList* GetRelationshipsN(void) const;
+       Tizen::Base::Collection::IList* GetEventsN(void) const;
+       Tizen::Base::Collection::IList* GetNotesN(void) const;
+       Tizen::Base::Collection::IList* GetNicknamesN(void) const;
+
+private:
+       contacts_record_h __profileHandle;
+
+}; // _UserProfileImpl
+
+}} // Tizen::Social
+
+#endif //_FSCL_INTERNAL_USER_PROFILE_H_