Implemented native contact interface. 72/50372/1
authorpolu.sandeep <polu.sandeep@samsung.com>
Wed, 28 Oct 2015 07:50:39 +0000 (16:50 +0900)
committerpolu.sandeep <polu.sandeep@samsung.com>
Wed, 28 Oct 2015 07:50:39 +0000 (16:50 +0900)
Change-Id: I85342896f125c6c31a63dbc27ed9062c6e7da373

14 files changed:
TelegramTizen/.cproject
TelegramTizen/contacts_utils/contacts-db-utils.c [new file with mode: 0644]
TelegramTizen/contacts_utils/contacts-db-utils.h [new file with mode: 0644]
TelegramTizen/contacts_utils/contacts-list-utils.c [new file with mode: 0644]
TelegramTizen/contacts_utils/contacts-list-utils.h [new file with mode: 0644]
TelegramTizen/contacts_utils/contacts-record-utils.c [new file with mode: 0644]
TelegramTizen/contacts_utils/contacts-record-utils.h [new file with mode: 0644]
TelegramTizen/contacts_utils/contacts_common.c [new file with mode: 0644]
TelegramTizen/contacts_utils/contacts_common.h [new file with mode: 0644]
TelegramTizen/contacts_utils/device_contacts_manager.c [new file with mode: 0644]
TelegramTizen/contacts_utils/device_contacts_manager.h [new file with mode: 0644]
TelegramTizen/src/telegramtizen.c
TelegramTizen/src/tg_search_peer_view.c
TelegramTizen/tg_utils/tg_common.h

index 2b1d20b..4cdbb91 100644 (file)
                                                                <option id="sbi.gnu.cpp.compiler.option.436467775" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
                                                                        <listOptionValue builtIn="false" value="mobile-2.4-device.core_llvm36.armel.core.app"/>
                                                                </option>
-                                                               <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.963945851" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath"/>
+                                                               <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.963945851" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath">
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-agent&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appfw&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/badge&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/base&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/cairo&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/calendar-service2&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ckm&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/contacts-svc&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/content&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/context-service&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dali&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dali-toolkit&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dbus-1.0&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/device&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dlog&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-audio-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-avahi-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-con-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-evas-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-fb-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-file-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-imf-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-imf-evas-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-input-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-input-evas-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-ipc-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-x-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/e_dbus-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/edje-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eet-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efl-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efl-extension&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efreet-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1/eina&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eio-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eldbus-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/elementary-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/embryo-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eo-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eom&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ethumb-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ethumb-client-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/evas-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ewebkit2-0&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/feedback&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/fontconfig&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/freetype2&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/geofence&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/gio-unix-2.0&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/glib-2.0&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/json-glib-1.0&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/location&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/maps&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/media&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/media-content&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/messaging&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/metadata-editor&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/minicontrol&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/minizip&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/network&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/notification&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/phonenumber-utils&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/sensor&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/shortcut&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/storage&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/system&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/telephony&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ui&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/web&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/widget_service&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/widget_viewer_evas&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/wifi-direct&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/dbus-1.0/include&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/glib-2.0/include&quot;"/>
+                                                               </option>
                                                                <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.904841999" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.core" valueType="stringList">
                                                                        <listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
                                                                        <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/db_manager}&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/tg_utils}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/contacts_utils}&quot;"/>
                                                                        <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include"/>
                                                                        <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/appcore-agent"/>
                                                                        <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/appfw"/>
                                                                <option id="sbi.gnu.c.compiler.option.1798192360" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
                                                                        <listOptionValue builtIn="false" value="mobile-2.4-device.core_llvm36.armel.core.app"/>
                                                                </option>
-                                                               <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.1914765975" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath"/>
+                                                               <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.1914765975" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath">
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-agent&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appfw&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/badge&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/base&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/cairo&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/calendar-service2&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ckm&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/contacts-svc&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/content&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/context-service&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dali&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dali-toolkit&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dbus-1.0&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/device&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dlog&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-audio-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-avahi-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-con-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-evas-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-fb-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-file-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-imf-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-imf-evas-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-input-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-input-evas-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-ipc-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-x-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/e_dbus-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/edje-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eet-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efl-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efl-extension&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efreet-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1/eina&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eio-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eldbus-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/elementary-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/embryo-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eo-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eom&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ethumb-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ethumb-client-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/evas-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ewebkit2-0&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/feedback&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/fontconfig&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/freetype2&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/geofence&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/gio-unix-2.0&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/glib-2.0&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/json-glib-1.0&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/location&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/maps&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/media&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/media-content&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/messaging&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/metadata-editor&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/minicontrol&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/minizip&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/network&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/notification&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/phonenumber-utils&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/sensor&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/shortcut&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/storage&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/system&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/telephony&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ui&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/web&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/widget_service&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/widget_viewer_evas&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/wifi-direct&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/dbus-1.0/include&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/glib-2.0/include&quot;"/>
+                                                               </option>
                                                                <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.142053796" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.core" valueType="stringList">
                                                                        <listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
                                                                        <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/db_manager}&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/tg_utils}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/contacts_utils}&quot;"/>
                                                                        <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include"/>
                                                                        <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/appcore-agent"/>
                                                                        <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/appfw"/>
                                                                        <listOptionValue builtIn="false" value="-L&quot;${SBI_SYSROOT}/usr/lib&quot;"/>
                                                                        <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/>
                                                                </option>
-                                                               <option id="gnu.cpp.link.option.paths.698986850" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"/>
+                                                               <option id="gnu.cpp.link.option.paths.698986850" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths"/>
                                                                <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1943933302" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
                                                                        <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
                                                                        <additionalInput kind="additionalinput" paths="$(LIBS)"/>
                                                        <tool command="arm-linux-gnueabi-as" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.1332015547" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base">
                                                                <option id="gnu.both.asm.option.include.paths.1201993216" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/TelegramTizen/TelegramTizen/inc}&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="../TelegramTizen/contacts_utils"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/TelegramTizen/TelegramTizen/tg_utils}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/contacts_utils}&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/TelegramTizen/TelegramTizen/db_manager}&quot;"/>
                                                                        <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/libxml2"/>
                                                                        <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include"/>
                                                <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="shared"/>
                                                <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
                                                <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="tg_utils"/>
+                                               <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="contacts_utils"/>
                                        </sourceEntries>
                                </configuration>
                        </storageModule>
                                                                <option id="gnu.cpp.compiler.option.optimization.level.1380108046" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
                                                                <option id="sbi.gnu.cpp.compiler.option.debugging.level.core.1670582656" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core"/>
                                                                <option id="sbi.gnu.cpp.compiler.option.1869675469" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
-                                                                       <listOptionValue builtIn="false" value="mobile-2.4-emulator.core_llvm36.i386.core.app"/>
+                                                                       <listOptionValue builtIn="false" value="mobile-2.4-device.core_llvm36.armel.core.app"/>
                                                                </option>
                                                                <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.2127714437" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
                                                                        <listOptionValue builtIn="false" value=" -fPIE"/>
                                                                        <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="-mthumb"/>
                                                                </option>
                                                                <option id="gnu.cpp.compiler.option.include.paths.383957679" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/db_manager}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/tg_utils}&quot;"/>
+                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/contacts_utils}&quot;"/>
                                                                </option>
                                                                <option id="sbi.gnu.cpp.compiler.option.frameworks.core.493027510" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs">
                                                                        <listOptionValue builtIn="false" value="Native_API"/>
                                                                <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.option.optimization.level.1349055118" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
                                                                <option id="sbi.gnu.c.compiler.option.debugging.level.core.568229207" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core"/>
                                                                <option id="sbi.gnu.c.compiler.option.2011803711" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
-                                                                       <listOptionValue builtIn="false" value="mobile-2.4-emulator.core_llvm36.i386.core.app"/>
+                                                                       <listOptionValue builtIn="false" value="mobile-2.4-device.core_llvm36.armel.core.app"/>
                                                                </option>
                                                                <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.1801593329" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
                                                                        <listOptionValue builtIn="false" value=" -fPIE"/>
                                                                        <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="-mthumb"/>
                                                                </option>
                                                                <option id="gnu.c.compiler.option.include.paths.963237261" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/db_manager}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/tg_utils}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/contacts_utils}&quot;"/>
                                                                </option>
                                                                <option id="sbi.gnu.c.compiler.option.frameworks.core.110877648" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs">
                                                                        <listOptionValue builtIn="false" value="Native_API"/>
                                                                        <additionalInput kind="additionalinput" paths="$(LIBS)"/>
                                                                </inputType>
                                                        </tool>
-                                                       <tool command="i386-linux-gnueabi-as" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.147879251" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base">
+                                                       <tool command="arm-linux-gnueabi-as" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.147879251" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base">
                                                                <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1497526917" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
                                                        </tool>
                                                        <tool id="org.tizen.nativecore.tool.fnmapgen.298370672" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/>
                                                <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="shared"/>
                                                <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
                                                <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="tg_utils"/>
+                                               <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="contacts_utils"/>
                                        </sourceEntries>
                                </configuration>
                        </storageModule>
                </scannerConfigBuildInfo>
        </storageModule>
        <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
-       <storageModule moduleId="refreshScope"/>
+       <storageModule moduleId="refreshScope" versionNumber="2">
+               <configuration configurationName="Release">
+                       <resource resourceType="PROJECT" workspacePath="/TelegramTizen"/>
+               </configuration>
+               <configuration configurationName="Debug">
+                       <resource resourceType="PROJECT" workspacePath="/TelegramTizen"/>
+               </configuration>
+       </storageModule>
        <storageModule moduleId="com.samsung.tizen.nativeapp.projectInfo" version="1.0.0"/>
 </cproject>
diff --git a/TelegramTizen/contacts_utils/contacts-db-utils.c b/TelegramTizen/contacts_utils/contacts-db-utils.c
new file mode 100644 (file)
index 0000000..c7f676f
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "contacts-db-utils.h"
+
+#include "logger.h"
+
+#include <contacts.h>
+
+static bool is_connected = false;
+
+bool sc_db_utils_connect()
+{
+       if(!is_connected)
+       {
+               is_connected = sc_db_utils_is_success(contacts_connect());
+       }
+       return is_connected;
+}
+
+bool sc_db_utils_disconnect()
+{
+       if(is_connected)
+       {
+               is_connected = !sc_db_utils_is_success(contacts_disconnect());
+       }
+       return !is_connected;
+}
+
+bool sc_db_utils_is_connected()
+{
+       return is_connected;
+}
+
+bool sc_db_utils_is_success(int err_code)
+{
+#ifdef _DEBUG
+
+       if(err_code == CONTACTS_ERROR_NONE)
+       {
+               return true;
+       }
+       else
+       {
+               const char *error_message = NULL;
+               switch(err_code) {
+               case CONTACTS_ERROR_OUT_OF_MEMORY:
+                       error_message = "Out of memory";
+                       break;
+               case CONTACTS_ERROR_INVALID_PARAMETER:
+                       error_message = "Invalid parameter";
+                       break;
+               case CONTACTS_ERROR_FILE_NO_SPACE:
+                       error_message = "File system is full";
+                       break;
+               case CONTACTS_ERROR_NO_DATA:
+                       error_message = "Requested data does not exist";
+                       break;
+               case CONTACTS_ERROR_PERMISSION_DENIED:
+                       error_message = "Permission denied";
+                       break;
+               case CONTACTS_ERROR_DB:
+                       error_message = "Unknown DB error, make sure that connection was established";
+                       break;
+               case CONTACTS_ERROR_IPC_NOT_AVALIABLE:
+                       error_message = "IPC server is not available";
+                       break;
+               case CONTACTS_ERROR_IPC:
+                       error_message = "Unknown IPC error";
+                       break;
+               case CONTACTS_ERROR_SYSTEM:
+                       error_message = "System error";
+                       break;
+               case CONTACTS_ERROR_INTERNAL:
+                       error_message = "Internal error";
+                       break;
+               default:
+                       error_message = "Unknown error";
+                       break;
+               }
+
+               ERR("Contacts database error %d: %s", err_code, error_message);
+               return false;
+       }
+#else
+       return err_code == CONTACTS_ERROR_NONE;
+#endif /* _DEBUG */
+}
diff --git a/TelegramTizen/contacts_utils/contacts-db-utils.h b/TelegramTizen/contacts_utils/contacts-db-utils.h
new file mode 100644 (file)
index 0000000..1609855
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DATABASE_H__
+#define __DATABASE_H__
+
+#include <stdbool.h>
+
+/**
+ * @brief Connect to database
+ * @return true if success, otherwise false
+ */
+extern bool sc_db_utils_connect();
+
+/**
+ * @brief Disconnect from database
+ * @return true if success, otherwise false
+ */
+extern bool sc_db_utils_disconnect();
+
+/**
+ * @brief Check is connected to database
+ * @return true if connected, otherwise false
+ */
+extern bool sc_db_utils_is_connected();
+
+/**
+ * @brief Check database error code
+ * @param[in]   err_code    Error code
+ * @return true if @a err_code == CONTACTS_ERROR_NONE, otherwise false
+ */
+bool sc_db_utils_is_success(int err_code);
+
+#endif /* __DATABASE_H__ */
diff --git a/TelegramTizen/contacts_utils/contacts-list-utils.c b/TelegramTizen/contacts_utils/contacts-list-utils.c
new file mode 100644 (file)
index 0000000..ab695ef
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "contacts-list-utils.h"
+
+#include "contacts-db-utils.h"
+#include "logger.h"
+
+static contacts_filter_h _get_filter_with_str_field(const char *table_uri, unsigned int filter_field, const char *str_val);
+static contacts_filter_h _get_filter_with_int_field(const char *table_uri, unsigned int filter_field, int int_val);
+static contacts_filter_h _get_filter_with_bool_field(const char *table_uri, unsigned int filter_field, bool bool_val);
+
+static contacts_filter_h _get_filter_with_str_field(const char *table_uri, unsigned int filter_field, const char *str_val)
+{
+       RETVM_IF(NULL == table_uri, NULL, "table_uri is null");
+       RETVM_IF(NULL == str_val, NULL, "value is null");
+       contacts_filter_h filter = NULL;
+
+       if( !(sc_db_utils_is_success(contacts_filter_create(table_uri, &filter))
+                               && sc_db_utils_is_success(contacts_filter_add_str(filter, filter_field, CONTACTS_MATCH_FULLSTRING, str_val))))
+       {
+               contacts_filter_destroy(filter);
+               filter = NULL;
+       }
+       return filter;
+}
+
+static contacts_filter_h _get_filter_with_int_field(const char *table_uri, unsigned int filter_field, int int_val)
+{
+       RETVM_IF(NULL == table_uri, NULL, "table_uri is null");
+       contacts_filter_h filter = NULL;
+
+       if( !(sc_db_utils_is_success(contacts_filter_create(table_uri, &filter))
+                               && sc_db_utils_is_success(contacts_filter_add_int(filter, filter_field, CONTACTS_MATCH_EQUAL, int_val))))
+       {
+               contacts_filter_destroy(filter);
+               filter = NULL;
+       }
+       return filter;
+}
+
+static contacts_filter_h _get_filter_with_bool_field(const char *table_uri, unsigned int filter_field, bool bool_val)
+{
+       RETVM_IF(NULL == table_uri, NULL, "table_uri is null");
+       contacts_filter_h filter = NULL;
+
+       if( !(sc_db_utils_is_success(contacts_filter_create(table_uri, &filter))
+                               && sc_db_utils_is_success(contacts_filter_add_bool(filter, filter_field, bool_val))))
+       {
+               contacts_filter_destroy(filter);
+               filter = NULL;
+       }
+       return filter;
+}
+
+contacts_list_h sc_list_utils_run_query(const char *table_uri, contacts_filter_h filter)
+{
+       RETVM_IF(!sc_db_utils_is_connected(), NULL, "not connected to DB");
+       RETVM_IF(NULL == table_uri, NULL, "table_uri is null");
+       RETVM_IF(NULL == filter, NULL, "filter is null");
+       contacts_list_h  list  = NULL;
+       contacts_query_h query       = NULL;
+       if( sc_db_utils_is_success(contacts_query_create(table_uri, &query))
+                       && sc_db_utils_is_success(contacts_query_set_filter(query, filter)))
+       {
+               if(!sc_db_utils_is_success(contacts_db_get_records_with_query(query, 0, 0, &list)))
+               {
+                       ERR("Error getting records list");
+                       contacts_list_destroy(list, true);
+                       list = NULL;
+               }
+               contacts_query_destroy(query);
+       }
+       return list;
+}
+
+contacts_list_h sc_list_utils_get_records_list_str_filter(const char *table_uri, unsigned filter_field, const char *filter_val)
+{
+       RETVM_IF(NULL == table_uri, NULL, "table_uri is null");
+       RETVM_IF(NULL == filter_val, NULL, "filter_val is null");
+
+       RETVM_IF(!sc_db_utils_is_connected(), NULL, "Not connected to DB");
+       contacts_list_h     list   = NULL;
+       contacts_filter_h   filter = _get_filter_with_str_field(table_uri, filter_field, filter_val);
+
+       if(filter)
+       {
+               list = sc_list_utils_run_query(table_uri, filter);
+
+               contacts_filter_destroy(filter);
+       }
+       return list;
+}
+
+contacts_list_h sc_list_utils_get_records_list_int_filter(const char *table_uri, unsigned filter_field, int filter_val)
+{
+       RETVM_IF(NULL == table_uri, NULL, "table_uri is null");
+
+       RETVM_IF(!sc_db_utils_is_connected(), NULL, "Not connected to DB");
+       contacts_list_h     list   = NULL;
+       contacts_filter_h   filter = _get_filter_with_int_field(table_uri, filter_field, filter_val);
+
+       if(filter)
+       {
+               list = sc_list_utils_run_query(table_uri, filter);
+
+               contacts_filter_destroy(filter);
+       }
+       return list;
+}
+
+contacts_list_h sc_list_utils_get_records_list_bool_filter(const char *table_uri, unsigned filter_field, bool filter_val)
+{
+       RETVM_IF(NULL == table_uri, NULL, "table_uri is null");
+
+       RETVM_IF(!sc_db_utils_is_connected(), NULL, "Not connected to DB");
+       contacts_list_h     list   = NULL;
+       contacts_filter_h   filter = _get_filter_with_bool_field(table_uri, filter_field, filter_val);
+
+       if(filter)
+       {
+               list = sc_list_utils_run_query(table_uri, filter);
+
+               contacts_filter_destroy(filter);
+       }
+       return list;
+}
diff --git a/TelegramTizen/contacts_utils/contacts-list-utils.h b/TelegramTizen/contacts_utils/contacts-list-utils.h
new file mode 100644 (file)
index 0000000..15859ae
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LIST_H__
+#define __LIST_H__
+
+#include <contacts.h>
+
+#define CONTACTS_LIST_FOREACH(list, record) \
+    bool success = (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE); \
+    for( ; success; \
+        success = ((contacts_list_next(list) == CONTACTS_ERROR_NONE) \
+        && (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE)) \
+        )
+
+/**
+ * @brief Execute query
+ * @remark return value MUST be destroyed with contacts_list_destroy by you
+ * @param[in]   table_uri       URI to DB table
+ * @param[in]   filter          Filter for query
+ * @return list on success, otherwise NULL
+ */
+contacts_list_h sc_list_utils_run_query(const char *table_uri, contacts_filter_h filter);
+
+/**
+ *@brief Retrieves record list from contacts DB
+ *@remark return value MUST be destroyed with contacts_list_destroy by you
+ *@param[in]    table_uri       URI to table
+ *@param[in]    filter_field    Filterable field of table
+ *@param[in]    filter_val      Value of filterable field @a filter_field
+ *@return records list on success, otherwise NULL
+ */
+contacts_list_h sc_list_utils_get_records_list_str_filter(const char *table_uri,
+        unsigned filter_field, const char *filter_val);
+
+/**
+ *@brief Retrieves record list from contacts DB
+ *@remark return value MUST be destroyed with contacts_list_destroy by you
+ *@param[in]    table_uri       URI to table
+ *@param[in]    filter_field    Filterable field of table
+ *@param[in]    filter_val      Value of filterable field @a filter_field
+ *@return records list on success, otherwise NULL
+ */
+contacts_list_h sc_list_utils_get_records_list_int_filter(const char *table_uri,
+        unsigned filter_field, int filter_val);
+
+/**
+ *@brief Retrieves record list from contacts DB
+ *@remark return value MUST be destroyed with contacts_list_destroy by you
+ *@param[in]    table_uri       URI to table
+ *@param[in]    filter_field    Filterable field of table
+ *@param[in]    filter_val      Value of filterable field @a filter_field
+ *@return records list on success, otherwise NULL
+ */
+contacts_list_h sc_list_utils_get_records_list_bool_filter(const char *table_uri,
+        unsigned filter_field, bool filter_val);
+
+#endif /* __LIST_H__ */
diff --git a/TelegramTizen/contacts_utils/contacts-record-utils.c b/TelegramTizen/contacts_utils/contacts-record-utils.c
new file mode 100644 (file)
index 0000000..1175e60
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "contacts-record-utils.h"
+#include "contacts-db-utils.h"
+#include "logger.h"
+
+contacts_record_h sc_record_utils_get_child_record(contacts_record_h parent_record, unsigned property_id, const char *child_table_uri)
+{
+       RETVM_IF(!sc_db_utils_is_connected(), NULL, "not connected to DB");
+       RETVM_IF(NULL == parent_record, NULL, "contact_record is null");
+       RETVM_IF(NULL == child_table_uri, NULL, "child_table_uri is null");
+       int count = 0;
+       contacts_record_h child_record = NULL;
+       if(sc_db_utils_is_success(contacts_record_get_child_record_count(parent_record, property_id, &count)))
+       {
+               if(count)
+               {
+                       sc_db_utils_is_success(contacts_record_get_child_record_at_p(parent_record, property_id, 0, &child_record));
+               }
+               else
+               {
+                       if(sc_db_utils_is_success(contacts_record_create(child_table_uri, &child_record)))
+                       {
+                               if(!sc_db_utils_is_success(contacts_record_add_child_record(parent_record, property_id, child_record)))
+                               {
+                                       contacts_record_destroy(child_record, true);
+                                       child_record = NULL;
+                               }
+                       }
+               }
+       }
+       return child_record;
+}
+
+bool sc_record_utils_get_child_str_p(contacts_record_h parent_record, unsigned parent_property_id, unsigned child_property_id, char **value)
+{
+       RETVM_IF(NULL == parent_record, false, "parent record is null");
+       RETVM_IF(NULL == value, false, "pointer to value is null");
+       contacts_record_h child_record = NULL;
+       char *temp_value = NULL;
+       bool result = sc_db_utils_is_success(contacts_record_get_child_record_at_p(parent_record, parent_property_id, 0, &child_record))
+               && sc_db_utils_is_success(contacts_record_get_str_p(child_record, child_property_id, &temp_value));
+       if(result)
+       {
+               *value = temp_value;
+       }
+       return result;
+}
+
+bool sc_record_utils_get_child_int(contacts_record_h parent_record, unsigned parent_property_id, unsigned child_property_id, int *value)
+{
+       RETVM_IF(NULL == parent_record, false, "parent record is null");
+       RETVM_IF(NULL == value, false, "pointer to value is null");
+       contacts_record_h child_record = NULL;
+       int temp_value = 0;
+       bool result = sc_db_utils_is_success(contacts_record_get_child_record_at_p(parent_record, parent_property_id, 0, &child_record))
+               && sc_db_utils_is_success(contacts_record_get_int(child_record, child_property_id, &temp_value));
+       if(result)
+       {
+               *value = temp_value;
+       }
+       return result;
+}
+
+bool sc_record_utils_set_child_str(contacts_record_h contact_record, unsigned parent_property, const char* child_uri, unsigned child_property, const char *str_val)
+{
+       RETVM_IF(!sc_db_utils_is_connected(), false, "not connected to DB");
+       RETVM_IF(NULL == str_val, false, "name is null");
+       RETVM_IF(NULL == contact_record, false, "contact_record is null");
+       bool result = false;
+       contacts_record_h child_record = sc_record_utils_get_child_record(contact_record, parent_property, child_uri);
+       if(child_record)
+       {
+               result = sc_db_utils_is_success(contacts_record_set_str(child_record, child_property, str_val));
+       }
+       return result;
+}
+
+bool sc_record_utils_set_child_int(contacts_record_h contact_record, unsigned parent_property, const char *child_uri, unsigned child_property, int int_val)
+{
+       RETVM_IF(!sc_db_utils_is_connected(), false, "not connected to DB");
+       RETVM_IF(NULL == contact_record, false, "contact_record is null");
+       bool result = false;
+       contacts_record_h child_record = sc_record_utils_get_child_record(contact_record, parent_property, child_uri);
+       if(child_record)
+       {
+               result = sc_db_utils_is_success(contacts_record_set_int(child_record, child_property, int_val));
+       }
+       return result;
+}
diff --git a/TelegramTizen/contacts_utils/contacts-record-utils.h b/TelegramTizen/contacts_utils/contacts-record-utils.h
new file mode 100644 (file)
index 0000000..506476e
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __RECORD_H__
+#define __RECORD_H__
+
+#include <contacts.h>
+
+/**
+ * @brief Gets child record
+ * @remark if child record is not exist, new child record will be created
+ * @remark return value MUST NOT be destroyed by you
+ * @param[in]       parent_record       Handle to parent record
+ * @param[in]       property_id         Id of foreign key in parent table
+ * @param[in]       child_table_uri     URI of child table
+ * return Handle to child record if success, otherwise NULL
+ */
+contacts_record_h sc_record_utils_get_child_record(contacts_record_h parent_record, unsigned property_id, const char *child_table_uri);
+
+/**
+ * @brief Gets string value from child record if it exist
+ * @remark @a value MUST NOT be destroyed by you
+ * @param[in]       parent_record       Parent record
+ * @param[in]       parent_property_id  ID of foreign key in parent table
+ * @param[in]       child_property_id   ID of field in child table, where store string value
+ * @param[out]      value               The value to be returned
+ * @return true if success, otherwise false
+ */
+bool sc_record_utils_get_child_str_p(contacts_record_h parent_record, unsigned parent_property_id, unsigned child_property_id, char **value);
+
+/**
+ * @brief Gets integer value from child record if it exist
+ * @param[in]       parent_record       Parent record
+ * @param[in]       parent_property_id  ID of foreign key in parent table
+ * @param[in]       child_property_id   ID of field in child table, where store integer value
+ * @param[out]      value               The value to be returned
+ * @return true if success, otherwise false
+ */
+bool sc_record_utils_get_child_int(contacts_record_h parent_record, unsigned parent_property_id, unsigned child_property_id, int *value);
+
+/**
+ * @brief Sets string value to child record
+ * @param[in]       parent_record       Parent record
+ * @param[in]       parent_property     ID of foreign key in parent table
+ * @param[in]       child_uri           URI of child table
+ * @param[in]       child_property      ID of field in child table
+ * @param[in]       str_val             Passed string value
+ * @return true if success, otherwise false
+ */
+bool sc_record_utils_set_child_str(contacts_record_h parent_record,
+        unsigned parent_property, const char* child_uri, unsigned child_property, const char *str_val);
+
+/**
+ * @brief Sets integer value to child record
+ * @param[in]       parent_record       Parent record
+ * @param[in]       parent_property     ID of foreign key in parent table
+ * @param[in]       child_uri           URI of child table
+ * @param[in]       child_property      ID of field in child table
+ * @param[in]       int_val             Passed integer value
+ * @return true if success, otherwise false
+ */
+bool sc_record_utils_set_child_int(contacts_record_h parent_record,
+        unsigned parent_property, const char *child_uri, unsigned child_property, int int_val);
+
+#endif /* __RECORD_H__ */
diff --git a/TelegramTizen/contacts_utils/contacts_common.c b/TelegramTizen/contacts_utils/contacts_common.c
new file mode 100644 (file)
index 0000000..7b1e864
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "contacts_common.h"
+#include "logger.h"
+#include <contacts.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <Eina.h>
+
+#define YEAR_BASE           1900
+#define YEAR_FACTOR         10000
+#define MONTH_BASE          1
+#define MONTH_FACTOR        100
+
+#define DATE_STRING_LENGTH  11
+
+static const char * const _common_contact_fields_names[] =
+{
+       "Phone",
+       "First Name",
+       "Last Name",
+       "Phone Number",
+       "Email",
+       "Url",
+       "Company",
+       "Birthday",
+       "Note"
+};
+
+const char *sc_common_get_contact_field_name(sc_common_contact_fields field_type)
+{
+       RETVM_IF(CF_MAX <= field_type || CF_ADDRESSBOOK > field_type, NULL, "incorrect field type");
+       return _common_contact_fields_names[field_type];
+}
+
+void sc_common_get_contact_properties(sc_common_contact_fields field_type, unsigned *parent_property_id, const char **child_uri, unsigned *child_property_id)
+{
+       unsigned temp_parent_property_id = 0;
+       const char *temp_child_uri = NULL;
+       unsigned temp_child_property_id = 0;
+
+       switch(field_type) {
+       case CF_ADDRESSBOOK:
+               //Not needed
+               break;
+       case CF_FIRST_NAME:
+               temp_parent_property_id = _contacts_contact.name;
+               temp_child_uri = _contacts_name._uri;
+               temp_child_property_id = _contacts_name.first;
+               break;
+       case CF_LAST_NAME:
+               temp_parent_property_id = _contacts_contact.name;
+               temp_child_uri = _contacts_name._uri;
+               temp_child_property_id = _contacts_name.last;
+               break;
+       case CF_PHONE_NUMBER:
+               temp_parent_property_id = _contacts_contact.number;
+               temp_child_uri = _contacts_number._uri;
+               temp_child_property_id = _contacts_number.number;
+               break;
+       case CF_EMAIL:
+               temp_parent_property_id = _contacts_contact.email;
+               temp_child_uri = _contacts_email._uri;
+               temp_child_property_id = _contacts_email.email;
+               break;
+       case CF_URL:
+               temp_parent_property_id = _contacts_contact.url;
+               temp_child_uri = _contacts_url._uri;
+               temp_child_property_id = _contacts_url.url;
+               break;
+       case CF_COMPANY:
+               temp_parent_property_id = _contacts_contact.company;
+               temp_child_uri = _contacts_company._uri;
+               temp_child_property_id = _contacts_company.name;
+               break;
+       case CF_BIRTHDAY:
+               temp_parent_property_id = _contacts_contact.event;
+               temp_child_uri = _contacts_event._uri;
+               temp_child_property_id = _contacts_event.date;
+               break;
+       case CF_NOTE:
+               temp_parent_property_id = _contacts_contact.note;
+               temp_child_uri = _contacts_note._uri;
+               temp_child_property_id = _contacts_note.note;
+               break;
+       case CF_MAX:
+               //Not correct field type
+               break;
+       }
+
+       if(parent_property_id) {
+               *parent_property_id = temp_parent_property_id;
+       }
+
+       if(child_uri) {
+               *child_uri = temp_child_uri;
+       }
+
+       if(child_property_id) {
+               *child_property_id = temp_child_property_id;
+       }
+}
+
+int sc_common_date_to_int(const struct tm *date)
+{
+       if(!date)
+       {
+               time_t current_time = time(NULL);
+               date = localtime(&current_time);
+       }
+       return (date->tm_year + YEAR_BASE) * YEAR_FACTOR
+               + (date->tm_mon + MONTH_BASE) * MONTH_FACTOR
+               +  date->tm_mday;
+}
+
+struct tm sc_common_int_to_date(int date_value)
+{
+       struct tm date = {
+               .tm_mday = date_value % MONTH_FACTOR,
+               .tm_mon = (date_value % YEAR_FACTOR) / MONTH_FACTOR - 1,
+               .tm_year = date_value / YEAR_FACTOR - 1900
+       };
+       return date;
+}
+
+char *sc_common_date_to_str(struct tm *date)
+{
+       char *ret_str = malloc(DATE_STRING_LENGTH);
+       if(ret_str)
+       {
+               sprintf(ret_str, "%d/%d/%d", date->tm_year + 1900, date->tm_mon + 1, date->tm_mday);
+       }
+       return ret_str;
+}
+
+char *sc_common_trim_spaces_in_string(const char *str)
+{
+       Eina_Strbuf *strbuff = eina_strbuf_new();
+       RETVM_IF(!strbuff, NULL, "strbuff is not created");
+       eina_strbuf_append(strbuff, str);
+       eina_strbuf_trim(strbuff);
+       char *ret_str = strdup(eina_strbuf_string_get(strbuff));
+       eina_strbuf_free(strbuff);
+       return ret_str;
+}
diff --git a/TelegramTizen/contacts_utils/contacts_common.h b/TelegramTizen/contacts_utils/contacts_common.h
new file mode 100644 (file)
index 0000000..612c96d
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __COMMON_H__
+#define __COMMON_H__
+
+#include <time.h>
+
+typedef enum
+{
+    CF_ADDRESSBOOK = 0,
+    CF_FIRST_NAME,
+    CF_LAST_NAME,
+    CF_PHONE_NUMBER,
+    CF_EMAIL,
+    CF_URL,
+    CF_COMPANY,
+    CF_BIRTHDAY,
+    CF_NOTE,
+    CF_MAX
+} sc_common_contact_fields;
+
+/**
+ * @brief Retrieves properties for contact table
+ * @param[in]    field_type          Type of field: number, email
+ * @param[out]   parent_property_id  Contact's property as key to child table
+ * @param[out]   child_uri           URI of child table
+ * @param[out]   child_property_id   ID of desired field of child table
+ */
+void sc_common_get_contact_properties(sc_common_contact_fields field_type, unsigned *parent_property_id, const char **child_uri, unsigned *child_property_id);
+
+/**
+ * @brief Convert date to contacts database format
+ * @param[in]   date    date tm structure or NULL for current date
+ * @return number representation of date or current date
+ */
+int sc_common_date_to_int(const struct tm *date);
+
+/**
+ * @brief Convert number representation of date to tm structure
+ * @param[in]   date_value    date in contacts database format
+ * @return date tm structure
+ */
+struct tm sc_common_int_to_date(int date_value);
+
+/**
+ * @brief Convert date to string
+ * @remark Return value MUST be destroyed with free() by you
+ * @param[in]   date        date tm structure or NULL for current date
+ * @return date in string representation
+ */
+char *sc_common_date_to_str(struct tm *date);
+
+/**
+ * @brief Gets contact field name by contact type
+ * @remark Return value MUST NOT be destroyed by you
+ * @param[in]   field_type  Field type
+ * @return contact name
+ */
+const char *sc_common_get_contact_field_name(sc_common_contact_fields field_type);
+
+/**
+ * @brief Trims spaces in @a str
+ * @remark Return value MUST be destroyed with free() by you
+ * @param[in]   str     String to trim
+ * @return Trimmed string on success, otherwise NULL
+ */
+char *sc_common_trim_spaces_in_string(const char *str);
+
+#endif //__COMMON_H__
diff --git a/TelegramTizen/contacts_utils/device_contacts_manager.c b/TelegramTizen/contacts_utils/device_contacts_manager.c
new file mode 100644 (file)
index 0000000..e3aa858
--- /dev/null
@@ -0,0 +1,191 @@
+/**
+ * @file device_contacts_manager.c
+ * @date Jul 7, 2015
+ * @author sandeep
+ */
+
+#include "device_contacts_manager.h"
+#include "tg_common.h"
+#include "logger.h"
+
+bool sc_cdetails_get_contact_val(sc_common_contact_fields field_type, int contact_id, char **value)
+{
+       RETVM_IF(field_type >= CF_MAX || field_type < CF_PHONE_NUMBER, false, "incorrect field type");
+       RETVM_IF(NULL == value, false, "pointer to value is null");
+
+       bool is_success = false;
+       unsigned parent_property_id = 0, child_property_id = 0;
+       char *tmp_value = NULL;
+       sc_common_get_contact_properties(field_type, &parent_property_id, NULL, &child_property_id);
+
+       contacts_record_h contact_record = NULL;
+       if(sc_db_utils_is_success(contacts_db_get_record(_contacts_contact._uri, contact_id, &contact_record)))
+       {
+               if(CF_BIRTHDAY == field_type)
+               {
+                       int ivalue = 0;
+                       if( sc_record_utils_get_child_int(contact_record, parent_property_id, child_property_id, &ivalue))
+                       {
+                               struct tm date = sc_common_int_to_date(ivalue);
+                               *value = sc_common_date_to_str(&date);
+                               is_success = true;
+                       }
+               }
+               else
+               {
+                       if( sc_record_utils_get_child_str_p(contact_record, parent_property_id, child_property_id, &tmp_value)
+                                       && tmp_value)
+                       {
+                               *value = strdup(tmp_value);
+                               is_success = true;
+                       }
+               }
+               contacts_record_destroy(contact_record, false);
+       }
+       return is_success;
+}
+
+Eina_List* get_contact_list_from_device_db()
+{
+       Eina_List* contact_list = NULL;
+
+       contacts_record_h record = NULL;
+       contacts_list_h person_list = NULL;
+       if(sc_db_utils_connect())
+       {
+
+
+               if(sc_db_utils_is_success(contacts_db_get_all_records(_contacts_person._uri, 0, 0, &person_list)))
+               {
+                       CONTACTS_LIST_FOREACH(person_list, record)
+                               {
+                               char *name = NULL;
+                               int id = 0;
+                               if (sc_db_utils_is_success(contacts_record_get_str_p(record, _contacts_person.display_name, &name))
+                                               && sc_db_utils_is_success(contacts_record_get_int(record, _contacts_person.id, &id)))
+                               {
+                                       contact_data_s* contact_data = (contact_data_s*)malloc(sizeof(contact_data_s));
+                                       contact_data->display_name = NULL;
+                                       contact_data->first_name = NULL;
+                                       contact_data->last_name = NULL;
+                                       contact_data->phone_number = NULL;
+
+                                       contact_data->contact_id = id;
+                                       contact_data->display_name = strdup(elm_entry_utf8_to_markup(name));
+
+                                       char *first_name = NULL;
+                                       if(sc_cdetails_get_contact_val(CF_FIRST_NAME, contact_data->contact_id, &first_name))
+                                       {
+                                               if (first_name) {
+                                                       contact_data->first_name = strdup(elm_entry_utf8_to_markup(first_name));
+                                                       free(first_name);
+                                               }
+                                       }
+
+                                       char *last_name = NULL;
+                                       if(sc_cdetails_get_contact_val(CF_LAST_NAME, contact_data->contact_id, &last_name))
+                                       {
+                                               if (last_name) {
+                                                       contact_data->last_name = strdup(elm_entry_utf8_to_markup(last_name));
+                                                       free(last_name);
+                                               }
+                                       }
+
+                                       char *pic_url = NULL;
+                                       if(sc_cdetails_get_contact_val(CF_URL, contact_data->pic_url, &pic_url))
+                                       {
+                                               if (pic_url) {
+                                                       contact_data->pic_url = strdup(elm_entry_utf8_to_markup(pic_url));
+                                                       free(pic_url);
+                                               } else {
+                                                       contact_data->pic_url = strdup(ui_utils_get_resource(DEFAULT_LIST_THUMB_SINGLE_PIC));
+                                               }
+                                       } else {
+                                               contact_data->pic_url = strdup(ui_utils_get_resource(DEFAULT_LIST_THUMB_SINGLE_PIC));
+                                       }
+
+
+                                       char *phone_number = NULL;
+                                       if(sc_cdetails_get_contact_val(CF_PHONE_NUMBER, contact_data->contact_id, &phone_number))
+                                       {
+                                               if (phone_number) {
+                                                       contact_data->phone_number = strdup(elm_entry_utf8_to_markup(phone_number));
+                                                       free(phone_number);
+                                               }
+                                       }
+
+
+                                       if (contact_data->phone_number == NULL) {
+
+
+                                               if (contact_data->display_name) {
+                                                       free(contact_data->display_name);
+                                                       contact_data->display_name = NULL;
+                                               }
+
+                                               if (contact_data->first_name) {
+                                                       free(contact_data->first_name);
+                                                       contact_data->first_name = NULL;
+                                               }
+
+                                               if (contact_data->last_name) {
+                                                       free(contact_data->last_name);
+                                                       contact_data->last_name = NULL;
+                                               }
+
+                                               if (contact_data->pic_url) {
+                                                       free(contact_data->pic_url);
+                                                       contact_data->pic_url = NULL;
+                                               }
+
+                                               if (contact_data->phone_number) {
+                                                       free(contact_data->phone_number);
+                                                       contact_data->phone_number = NULL;
+                                               }
+
+                                               free(contact_data);
+                                               continue;
+                                       }
+
+                                       contact_list = eina_list_append(contact_list, contact_data);
+                               }
+
+                               }
+                       contacts_list_destroy(person_list, true);
+               }
+       }
+       sc_db_utils_disconnect();
+
+       return contact_list;
+}
+
+
+void free_contact_list(Eina_List *contact_data)
+{
+       if (contact_data) {
+               for (int i = 0; i < eina_list_count(contact_data); i++) {
+                       contact_data_s* contact = eina_list_nth(contact_data, i);
+                       if (contact) {
+                               if (contact->display_name) {
+                                       free(contact->display_name);
+                                       contact->display_name = NULL;
+                               }
+                               if (contact->first_name) {
+                                       free(contact->first_name);
+                                       contact->first_name = NULL;
+                               }
+                               if (contact->last_name) {
+                                       free(contact->last_name);
+                                       contact->last_name = NULL;
+                               }
+                               if (contact->phone_number) {
+                                       free(contact->phone_number);
+                                       contact->phone_number = NULL;
+                               }
+                       }
+                       free(contact);
+               }
+               eina_list_free(contact_data);
+       }
+}
+
diff --git a/TelegramTizen/contacts_utils/device_contacts_manager.h b/TelegramTizen/contacts_utils/device_contacts_manager.h
new file mode 100644 (file)
index 0000000..02fd579
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * device_contacts_manager.h
+ *
+ *  Created on: Jul 7, 2015
+ *      Author: sandeep
+ */
+
+#ifndef DEVICE_CONTACTS_MANAGER_H_
+#define DEVICE_CONTACTS_MANAGER_H_
+
+#include "tg_common.h"
+#include <contacts.h>
+#include "contacts_common.h"
+#include "contacts-record-utils.h"
+#include "contacts-list-utils.h"
+#include "contacts-db-utils.h"
+
+typedef struct contact_data {
+       int contact_id;
+       char *display_name;
+       char *first_name;
+       char *last_name;
+       char *phone_number;
+       char *pic_url;
+} contact_data_s;
+
+
+extern Eina_List* get_contact_list_from_device_db();
+extern void free_contact_list(Eina_List *contact_data);
+
+
+
+
+#endif /* DEVICE_CONTACTS_MANAGER_H_ */
index 77b5d02..11031ac 100644 (file)
@@ -15,6 +15,7 @@
 #include <notification.h>
 #include <badge.h>
 #include "tg_settings_view.h"
+#include "device_contacts_manager.h"
 
 static void popup_block_clicked_cb(void *data, Evas_Object *obj, void *event_info)
 {
@@ -443,11 +444,15 @@ void load_main_list_data(appdata_s *ad)
                                                        char *phone_num = NULL;
                                                        get_buddy_contact_details_from_db(peer_info->peer_id, &first_name, &last_name, &phone_num);
 
+                                                       if (!first_name || strstr(first_name ,"null") != 0) {
+                                                               first_name = NULL;
+                                                       }
+
                                                        if (!first_name && !last_name && phone_num) {
                                                                first_name = phone_num;
                                                        }
 
-                                                       if (!last_name) {
+                                                       if (!last_name || strstr(last_name ,"null") != 0) {
                                                                last_name = "";
                                                        }
                                                        user_name = (char*)malloc(strlen(first_name) + strlen(" ") + strlen(last_name) + 1);
@@ -516,11 +521,15 @@ void load_main_list_data(appdata_s *ad)
                                                                char *phone_num = NULL;
                                                                get_buddy_contact_details_from_db(peer_info->peer_id, &first_name, &last_name, &phone_num);
 
+                                                               if (!first_name || strstr(first_name ,"null") != 0) {
+                                                                       first_name = NULL;
+                                                               }
+
                                                                if (!first_name && !last_name && phone_num) {
                                                                        first_name = phone_num;
                                                                }
 
-                                                               if (!last_name) {
+                                                               if (!last_name || strstr(last_name ,"null") != 0) {
                                                                        last_name = "";
                                                                }
                                                                user_name = (char*)malloc(strlen(first_name) + strlen(" ") + strlen(last_name) + 1);
@@ -3057,6 +3066,7 @@ static bool app_create(void *data)
        ad->s_notififcation = NULL;
        ad->panel = NULL;
        ad->is_server_ready = EINA_FALSE;
+       ad->contact_list = NULL;
        //ad->msg_count = 0;
        create_base_gui(ad);
        int err = badge_new(TELEGRAM_APP_ID);
@@ -3335,6 +3345,7 @@ app_terminate(void *data)
                service_client_destroy(app_data->service_client);
                app_data->service_client = NULL;
        }
+       free_contact_list(app_data->contact_list);
        tg_db_fini();
 }
 
index 388612f..f6eea63 100755 (executable)
@@ -10,6 +10,7 @@
 #include "tg_messaging_view.h"
 #include "contact_selection_view.h"
 #include "ucol.h"
+#include "device_contacts_manager.h"
 
 #define COMMAND_MENU_ITEM_COUNT 2
 
@@ -390,6 +391,7 @@ static void on_peer_item_clicked(void *data, Evas_Object *obj, void *event_info)
        }
 
        elm_naviframe_item_pop(ad->nf);
+       delete_floating_button(ad);
        launch_messaging_view_cb(ad, peer_id);
 }
 
@@ -447,6 +449,141 @@ static void _append_peer_item(Evas_Object *genlist, appdata_s *ad, Eina_List* it
        }
 }
 
+static void on_contact_item_clicked(void *data, Evas_Object *obj, void *event_info)
+{
+       Elm_Object_Item *it = event_info;
+       elm_genlist_item_selected_set(it, EINA_FALSE);
+
+       int item_id = (int) data;
+       appdata_s* ad = evas_object_data_get(obj, "app_data");
+       Eina_List *list = evas_object_data_get(obj, "contact_list");
+
+       contact_data_s* contact = eina_list_nth(list, item_id);
+       if (!contact) {
+               return;
+       }
+
+       app_control_h app_control;
+       int ret = app_control_create(&app_control);
+       if (ret != APP_CONTROL_ERROR_NONE) {
+               return;
+       }
+       app_control_set_operation(app_control, APP_CONTROL_OPERATION_COMPOSE);
+       app_control_set_mime(app_control,"text/html");
+
+       char phone_num[512] = {0,};
+       strcpy(phone_num, "sms:");
+       strcat(phone_num, contact->phone_number);
+
+       app_control_set_uri(app_control, phone_num);
+       char *text = "Invite you to telegram! https://telegram.org/dl";
+       app_control_add_extra_data(app_control, APP_CONTROL_DATA_TEXT, text);
+       if (app_control_send_launch_request(app_control, NULL, NULL) == APP_CONTROL_ERROR_NONE) {
+               // sms view launched
+       }
+       app_control_destroy(app_control);
+
+       return;
+}
+
+char* on_contact_list_name_requested(void *data, Evas_Object *obj, const char *part)
+{
+       int id = (int) data;
+
+       appdata_s* ad = evas_object_data_get(obj, "app_data");
+       Eina_List *list = evas_object_data_get(obj, "contact_list");
+
+       if (!list) {
+               list = ad->contact_list;
+       }
+
+       contact_data_s* contact = eina_list_nth(list, id);
+       if (!contact) {
+               return NULL;
+       }
+
+       if (!strcmp(part,"elm.text.main.left.top") || !strcmp(part,"elm.text")){
+               return strdup(contact->display_name);
+       } else if (!strcmp(part, "elm.text.sub.left.bottom") || !strcmp(part,"elm.text.sub")) {
+               return NULL;
+       }
+       return NULL;
+}
+
+
+Evas_Object* on_contact_list_image_requested(void *data, Evas_Object *obj, const char *part)
+{
+       Evas_Object *eo = NULL;
+       if (!strcmp(part, "elm.icon.left") || !strcmp(part, "elm.icon.1") || !strcmp(part, "elm.swallow.icon")  ) {
+               int id = (int) data;
+               appdata_s* ad = evas_object_data_get(obj, "app_data");
+               Eina_List *list = evas_object_data_get(obj, "contact_list");
+               if (!list) {
+                       list = ad->contact_list;
+               }
+               int size = eina_list_count(list);
+               if (size <= 0) {
+                       return eo;
+               }
+               contact_data_s* contact = eina_list_nth(list, id);
+               if (!contact || !contact->pic_url) {
+                       return NULL;
+               }
+
+               Evas_Object *profile_pic = NULL;
+               profile_pic = create_image_object_from_file(contact->pic_url, obj);
+               evas_object_color_set(profile_pic, 45, 165, 224, 255);
+
+               char edj_path[PATH_MAX] = {0, };
+               app_get_resource(TELEGRAM_INIT_VIEW_EDJ, edj_path, (int)PATH_MAX);
+               Evas_Object* user_pic_layout = elm_layout_add(ad->nf);
+               elm_layout_file_set(user_pic_layout, edj_path, "search_circle_layout");
+               evas_object_size_hint_weight_set(user_pic_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+               evas_object_size_hint_align_set(user_pic_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+               evas_object_show(user_pic_layout);
+               elm_object_part_content_set(user_pic_layout, "content", profile_pic);
+
+               eo = elm_layout_add(obj);
+               elm_layout_theme_set(eo, "layout", "list/B/type.2", "default");
+               elm_layout_content_set(eo, "elm.swallow.content", user_pic_layout);
+
+       }
+       return eo;
+}
+
+
+static void _append_contact_item(Evas_Object *genlist, appdata_s *ad, Eina_List* item_list)
+{
+
+       if (!genlist || !ad || !item_list) {
+               return;
+       }
+
+       int i;
+       static Elm_Genlist_Item_Class itc;
+       Elm_Object_Item* item = NULL;
+
+       //itc.item_style = "2line.top";
+       itc.item_style = "type1";
+       itc.func.text_get = on_contact_list_name_requested;
+       itc.func.content_get = on_contact_list_image_requested;
+       itc.func.state_get = NULL;
+       itc.func.del = NULL;
+
+       int count = eina_list_count(item_list);
+
+       evas_object_data_set(genlist, "contact_list", item_list);
+
+       if(count > 0) {
+               for (i = 0; i < count; i++) {
+                       item = elm_genlist_item_append(genlist, &itc, (void *) i, NULL, ELM_GENLIST_ITEM_NONE, on_contact_item_clicked, (void*) i);
+               }
+       } else {
+               i = 1;
+               elm_genlist_item_append(genlist, &itc, (void *) i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void*) i);
+       }
+}
+
 static void _append_command_item(Evas_Object *genlist, appdata_s *ad)
 {
        int i;
@@ -754,7 +891,11 @@ void launch_start_peer_search_view(appdata_s* ad)
        ad->current_app_state = TG_PEER_SEARCH_VIEW_STATE;
 
        clear_search_list(ad);
+
+       free_contact_list(ad->contact_list);
+
        ad->search_peer_list = load_buddy_data_by_name(ad->user_id.id, NULL);
+       ad->contact_list = get_contact_list_from_device_db();
 
        Evas_Object* layout = elm_layout_add(ad->nf);
        elm_layout_theme_set(layout, "layout", "application", "searchbar_base");
@@ -766,11 +907,14 @@ void launch_start_peer_search_view(appdata_s* ad)
        elm_object_part_content_set(layout, "searchbar", searchbar_layout);
 
        Evas_Object* fs_layout = elm_layout_add(layout);
-       elm_layout_theme_set(fs_layout, "layout", "application", "fastscroll");
+       //elm_layout_theme_set(fs_layout, "layout", "application", "fastscroll");
+       elm_layout_theme_set(fs_layout, "layout", "application", "default");
        elm_object_part_content_set(layout, "elm.swallow.content", fs_layout);
 
+#if 0
        Evas_Object* index = create_fastscroll(ad);
        elm_object_part_content_set(fs_layout, "elm.swallow.fastscroll", index);
+#endif
 
        Evas_Object* peer_list = create_genlist(ad, fs_layout);
        evas_object_data_set(peer_list, "app_data", ad);
@@ -778,6 +922,9 @@ void launch_start_peer_search_view(appdata_s* ad)
 
        _append_command_item(peer_list, ad);
        _append_peer_item(peer_list, ad, ad->search_peer_list);
+       if (ad->contact_list && eina_list_count(ad->contact_list) > 0) {
+               _append_contact_item(peer_list, ad, ad->contact_list);
+       }
 
        /* no contents */
        Evas_Object *nocontents = elm_layout_add(ad->nf);
index bb0f425..4f841f2 100644 (file)
@@ -574,6 +574,7 @@ typedef struct appdata {
        int screen_mode_for_fb; // for floating button icon
        Evas_Object *menu_popup;
        //int msg_count;
+       Eina_List *contact_list;
 } appdata_s;
 
 extern void show_toast(appdata_s* ad, char* value);