Implemented adding device contact list while registering. 14/49314/2
authorpolu.sandeep <polu.sandeep@samsung.com>
Mon, 12 Oct 2015 12:17:34 +0000 (21:17 +0900)
committerSung-jae Park <nicesj@nicesj.com>
Tue, 13 Oct 2015 03:52:52 +0000 (20:52 -0700)
Change-Id: I3f8769dd3043e3658efc30b28ae0ae89f6c7b2c2

36 files changed:
TelegramTizen/.cproject
TelegramTizen/inc/server_requests.h
TelegramTizen/inc/tg_add_contact.h [new file with mode: 0644]
TelegramTizen/inc/tg_db_wrapper.h
TelegramTizen/res/edje/telegram_init_screen.edc
TelegramTizen/res/edje/telegram_start_screen.edc [new file with mode: 0644]
TelegramTizen/src/server_requests.c
TelegramTizen/src/telegramtizen.c
TelegramTizen/src/tg_add_contact.c [new file with mode: 0644]
TelegramTizen/src/tg_chat_info_view.c
TelegramTizen/src/tg_db_wrapper.c
TelegramTizen/src/tg_messaging_view.c
TelegramTizen/src/tg_registration.c
TelegramTizen/src/tg_user_info_view.c
TelegramTizen/src/tg_user_main_view.c
TelegramTizen/tg_utils/tg_common.h
tg-engine-service/.cproject
tg-engine-service/contacts_utils/contacts-db-utils.c [moved from TelegramTizen/contacts_utils/contacts-db-utils.c with 100% similarity]
tg-engine-service/contacts_utils/contacts-db-utils.h [moved from TelegramTizen/contacts_utils/contacts-db-utils.h with 91% similarity]
tg-engine-service/contacts_utils/contacts-list-utils.c [moved from TelegramTizen/contacts_utils/contacts-list-utils.c with 100% similarity]
tg-engine-service/contacts_utils/contacts-list-utils.h [moved from TelegramTizen/contacts_utils/contacts-list-utils.h with 100% similarity]
tg-engine-service/contacts_utils/contacts-record-utils.c [moved from TelegramTizen/contacts_utils/contacts-record-utils.c with 100% similarity]
tg-engine-service/contacts_utils/contacts-record-utils.h [moved from TelegramTizen/contacts_utils/contacts-record-utils.h with 100% similarity]
tg-engine-service/contacts_utils/contacts_common.c [moved from TelegramTizen/src/contacts_common.c with 100% similarity]
tg-engine-service/contacts_utils/contacts_common.h [moved from TelegramTizen/inc/contacts_common.h with 100% similarity]
tg-engine-service/contacts_utils/device_contacts_manager.c [moved from TelegramTizen/src/device_contacts_manager.c with 96% similarity]
tg-engine-service/contacts_utils/device_contacts_manager.h [moved from TelegramTizen/inc/device_contacts_manager.h with 67% similarity]
tg-engine-service/inc/server_response.h
tg-engine-service/inc/tg_db_wrapper.h
tg-engine-service/mtprotocol/mtproto-client.c
tg-engine-service/mtprotocol/tgl-layout.h
tg-engine-service/src/server_response.c
tg-engine-service/src/tg-engine-service.c
tg-engine-service/src/tg_db_wrapper.c
tg-engine-service/tg_engine/tg_engine.c
tg-engine-service/tg_engine/tg_engine.h

index 3d38226..2b1d20b 100644 (file)
                                        <folderInfo id="org.tizen.nativecore.config.sbi.gcc45.app.debug.1480907646." name="/" resourcePath="">
                                                <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug.732635461" name="Tizen Native Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug">
                                                        <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.1666638481" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
-                                                       <builder autoBuildTarget="all" buildPath="${workspace_loc:/TelegramTizen}/Debug" enableAutoBuild="true" id="org.tizen.nativecore.target.sbi.gnu.builder.264573658" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/>
+                                                       <builder autoBuildTarget="all" buildPath="${workspace_loc:/TelegramTizen}/Debug" enableAutoBuild="true" id="org.tizen.nativecore.target.sbi.gnu.builder.264573658" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder">
+                                                               <outputEntries>
+                                                                       <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name="Debug"/>
+                                                                       <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name="Release"/>
+                                                               </outputEntries>
+                                                       </builder>
                                                        <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.847004608" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
                                                        <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.688919936" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
                                                                <option id="gnu.cpp.compiler.option.optimization.level.796347749" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
                                                                <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"/>
+                                                               <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=" -fPIE"/>
+                                                                       <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="-mthumb"/>
+                                                               </option>
+                                                               <option id="gnu.cpp.compiler.option.include.paths.628878989" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+                                                                       <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="&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="/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="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/badge"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/base"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/cairo"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/calendar-service2"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ckm"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/contacts-svc"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/content"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/context-service"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/dali"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/dali-toolkit"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/dbus-1.0"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/device"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/dlog"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-audio-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-avahi-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-con-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-evas-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-fb-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-file-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-imf-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-imf-evas-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-input-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-input-evas-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-ipc-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-x-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/e_dbus-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/edje-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/eet-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/efl-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/efl-extension"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/efreet-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/eina-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/eina-1/eina"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/eio-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/eldbus-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/elementary-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/embryo-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/eo-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/eom"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ethumb-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ethumb-client-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/evas-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ewebkit2-0"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/feedback"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/fontconfig"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/freetype2"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/geofence"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/gio-unix-2.0"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/glib-2.0"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/json-glib-1.0"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/location"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/maps"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/media"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/media-content"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/messaging"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/metadata-editor"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/minicontrol"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/minizip"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/network"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/notification"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/phonenumber-utils"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/sensor"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/shortcut"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/storage"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/system"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/telephony"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ui"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/web"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/widget_service"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/widget_viewer_evas"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/wifi-direct"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/lib/dbus-1.0/include"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/lib/glib-2.0/include"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SDK_PATH}/library&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/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/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=" -fPIE"/>
-                                                                       <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="-mthumb"/>
-                                                               </option>
-                                                               <option id="gnu.cpp.compiler.option.include.paths.628878989" 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}/contacts_utils}&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/tg_utils}&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/db_manager}&quot;"/>
-                                                               </option>
                                                                <option id="sbi.gnu.cpp.compiler.option.frameworks.core.1465037038" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs">
                                                                        <listOptionValue builtIn="false" value="Native_API"/>
                                                                </option>
                                                                <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"/>
+                                                               <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=" -fPIE"/>
+                                                                       <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="-mthumb"/>
+                                                               </option>
+                                                               <option id="gnu.c.compiler.option.include.paths.1793735147" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
+                                                                       <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="&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="/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="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/badge"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/base"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/cairo"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/calendar-service2"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ckm"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/contacts-svc"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/content"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/context-service"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/dali"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/dali-toolkit"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/dbus-1.0"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/device"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/dlog"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-audio-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-avahi-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-con-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-evas-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-fb-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-file-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-imf-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-imf-evas-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-input-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-input-evas-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-ipc-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-x-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/e_dbus-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/edje-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/eet-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/efl-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/efl-extension"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/efreet-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/eina-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/eina-1/eina"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/eio-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/eldbus-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/elementary-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/embryo-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/eo-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/eom"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ethumb-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ethumb-client-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/evas-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ewebkit2-0"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/feedback"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/fontconfig"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/freetype2"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/geofence"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/gio-unix-2.0"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/glib-2.0"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/json-glib-1.0"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/location"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/maps"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/media"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/media-content"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/messaging"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/metadata-editor"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/minicontrol"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/minizip"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/network"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/notification"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/phonenumber-utils"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/sensor"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/shortcut"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/storage"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/system"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/telephony"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ui"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/web"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/widget_service"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/widget_viewer_evas"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/wifi-direct"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/lib/dbus-1.0/include"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/lib/glib-2.0/include"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SDK_PATH}/library&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/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/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=" -fPIE"/>
-                                                                       <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="-mthumb"/>
-                                                               </option>
-                                                               <option id="gnu.c.compiler.option.include.paths.1793735147" 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}/contacts_utils}&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/tg_utils}&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/db_manager}&quot;"/>
-                                                               </option>
                                                                <option id="sbi.gnu.c.compiler.option.frameworks.core.1333110749" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs">
                                                                        <listOptionValue builtIn="false" value="Native_API"/>
                                                                </option>
                                                                        <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">
-                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/lib}&quot;"/>
-                                                               </option>
+                                                               <option id="gnu.cpp.link.option.paths.698986850" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"/>
                                                                <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)"/>
                                                                </inputType>
                                                        </tool>
                                                        <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:/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"/>
+                                                                       <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="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/badge"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/base"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/cairo"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/calendar-service2"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ckm"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/contacts-svc"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/content"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/context-service"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/dali"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/dali-toolkit"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/dbus-1.0"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/device"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/dlog"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-audio-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-avahi-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-con-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-evas-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-fb-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-file-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-imf-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-imf-evas-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-input-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-input-evas-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-ipc-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ecore-x-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/e_dbus-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/edje-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/eet-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/efl-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/efl-extension"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/efreet-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/eina-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/eina-1/eina"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/eio-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/eldbus-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/elementary-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/embryo-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/eo-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/eom"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ethumb-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ethumb-client-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/evas-1"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ewebkit2-0"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/feedback"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/fontconfig"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/freetype2"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/geofence"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/gio-unix-2.0"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/glib-2.0"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/json-glib-1.0"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/location"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/maps"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/media"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/media-content"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/messaging"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/metadata-editor"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/minicontrol"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/minizip"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/network"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/notification"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/phonenumber-utils"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/sensor"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/shortcut"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/storage"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/system"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/telephony"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/ui"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/web"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/widget_service"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/widget_viewer_evas"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/include/wifi-direct"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/lib/dbus-1.0/include"/>
+                                                                       <listOptionValue builtIn="false" value="/home/sandeep/tizen-sdk-2_4_new/platforms/tizen-2.4/mobile/rootstraps/mobile-2.4-device.core/usr/lib/glib-2.0/include"/>
+                                                               </option>
                                                                <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1429202929" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
                                                        </tool>
                                                        <tool id="org.tizen.nativecore.tool.fnmapgen.2032294145" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/>
                                                </toolChain>
                                        </folderInfo>
                                        <sourceEntries>
-                                               <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="contacts_utils"/>
                                                <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="db_manager"/>
                                                <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
                                                <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="res"/>
                                                                </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="&quot;${SDK_PATH}/library&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/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;"/>
                                                                </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="&quot;${SDK_PATH}/library&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/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;"/>
                                                </toolChain>
                                        </folderInfo>
                                        <sourceEntries>
-                                               <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="contacts_utils"/>
                                                <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="db_manager"/>
                                                <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
                                                <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="res"/>
index de98757..18c2a1f 100644 (file)
@@ -17,13 +17,12 @@ void send_request_for_validation(service_client* service_client, const char* sms
 void send_request_for_message_transport(appdata_s *ad, service_client* service_client, const int buddy_id, const int message_id, const int msg_type, const char* data, const int type_of_chat);
 void send_request_for_marked_as_read(service_client* service_client, const int buddy_id, const int type_of_chat);
 void send_delete_group_chat_request(service_client* service_client, const int chat_id);
-void send_add_buddy_request(service_client* service_client, const int buddy_id);
+void send_add_buddy_request(service_client* service_client, const int buddy_id, const char *first_name, const char *last_name, const char *phone_number);
 void send_delete_buddy_request(service_client* service_client, const int buddy_id);
 void send_block_buddy_request(service_client* service_client, const int buddy_id);
 void send_unblock_buddy_request(service_client* service_client, const int buddy_id);
 Eina_Bool send_request_for_media_downloading(service_client* service_client, const int buddy_id, const long long media_id);
 void send_request_for_media_transport(appdata_s *ad, service_client* service_client, const int buddy_id, const int message_id, const int media_id,  const int msg_type, const char* file_path, const int type_of_chat);
-void send_contacts_list_to_server(service_client* service_client, Eina_List* contacts_list);
 void send_group_creation_request_to_server(service_client* service_client, Eina_List* buddy_list, const char* group_name, const char* group_image);
 
 void send_add_buddy_to_group_chat_request(service_client* service_client, int user_id, int chat_id);
diff --git a/TelegramTizen/inc/tg_add_contact.h b/TelegramTizen/inc/tg_add_contact.h
new file mode 100644 (file)
index 0000000..c81b1b5
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * tg_add_contact.h
+ *
+ *  Created on: Oct 10, 2015
+ *      Author: sandeep
+ */
+
+#ifndef TG_ADD_CONTACT_H_
+#define TG_ADD_CONTACT_H_
+
+#include "tg_common.h"
+
+extern void launch_add_contact_screen(appdata_s* ad);
+
+#endif /* TG_ADD_CONTACT_H_ */
index 2255592..8ff7ed9 100644 (file)
@@ -57,6 +57,7 @@
 #define USER_INFO_TABLE_LAST_SEEN_TIME "last_seen"
 #define USER_INFO_TABLE_IS_BLOCKED "is_blocked"
 #define USER_INFO_TABLE_IS_DELETED "is_deleted"
+#define USER_INFO_TABLE_IS_UNKNOWN_PEER "is_unknown"
 
 #define BUDDY_INFO_TABLE_NAME "buddy_info_table"
 #if 0
 #define MEDIA_INFO_TABLE_DOCUMENT_DC "doc_dc" //text
 #define MEDIA_INFO_TABLE_DOCUMENT_THUMB_FILE "video_thumb" //text
 
-#define MESSAGE_INFO_TABLE_MESSAGE_ROW_ID "msg_row_id"
+//#define MESSAGE_INFO_TABLE_MESSAGE_ROW_ID "msg_row_id"
 #define MESSAGE_INFO_TABLE_MESSAGE_ID "msg_id"
 #define MESSAGE_INFO_TABLE_FLAGS "flags"
 #define MESSAGE_INFO_TABLE_FWD_FROM_ID "fwd_from_id"
@@ -233,10 +234,22 @@ int get_unread_message_count(char* table_name);
 
 extern void update_msg_into_db(tg_message_s *M, char* table_name);
 
+void get_buddy_contact_details_from_db(int buddy_id, char **first_name, char **last_name, char **phone_number);
+
 char* get_buddy_name_from_id(int buddy_id);
 
+char* get_buddy_phone_num_from_id(int buddy_id);
+
+int  get_buddy_unknown_status(int buddy_id);
+
+Eina_List* get_unknown_buddy_list_info();
+
 int  get_buddy_online_status(int buddy_id);
 
+int  get_buddy_delete_status(int buddy_id);
+
+int  get_buddy_block_status(int buddy_id);
+
 int insert_current_date_to_table(char* tb_name);
 
 Eina_List* load_peer_data_by_name(char* name);
@@ -249,6 +262,7 @@ int get_media_size_from_db(long long media_id);
 
 int get_number_of_unread_messages();
 
+
 void create_buddy_msg_table(const char* table_name);
 
 Eina_Bool insert_unsent_message_to_db(const char *app_name, const char *command, const char *buddy_id, const char *msg_id, const char *msg_type, const char * msg_data, const char *type_of_chat);
index 6fac393..cdd26f1 100644 (file)
@@ -1773,5 +1773,99 @@ group
       }
    }
 
-       
+   group {
+         name: "add_contact_screen";
+      parts {
+          part {
+               name: "pic_name_layout";
+            type: SWALLOW;            
+            description {
+               state: "default" 0.0;
+                       rel1 { relative: 0.0 0.0; }
+                       rel2 { relative: 1.0 0.20; }
+                       color: 61 185 204 255;
+            }
+         }
+         part {
+                       name: "user_info,bg";
+               type: RECT;
+               description {
+                       state: "default" 0.0;
+                       rel1 { relative: 0.0 0.20; }
+                       rel2 { relative: 1.0 0.25; }
+                       color: 96 96 96 255;
+               }
+       }
+       part {
+                       name: "user_info";
+               type: SWALLOW;
+               description {
+                       state: "default" 0.0;
+                       rel1 { relative: 0.0 0.20; }
+                       rel2 { relative: 1.0 0.25; }
+                       color: 255 255 255 255;
+               }
+       }
+       
+       part {
+                       name: "entry_layout";
+               type: RECT;
+               description {
+                       state: "default" 0.0;
+                       rel1 { relative: 0.0 0.25; }
+                       rel2 { relative: 1.0 1.0; }
+                       color: 255 255 255 255;
+               }
+       }
+       
+           part {
+                       name: "setup_guide_text";
+                       type: SWALLOW;            
+                       description {
+                               state: "default" 0.0;
+                       rel1 { relative: 0.1 0.25; }
+                       rel2 { relative: 0.9 0.3; }
+                       }
+               }
+               part {
+                       name: "first_name_entry,bg";
+                       type: RECT;            
+                       description {
+                       state: "default" 0.0;
+                       rel1 { relative: 0.1 0.31; }
+                       rel2 { relative: 0.9 0.41; }
+                       color: 222 222 222 222;                                 
+                       }
+               }
+               part {
+                       name: "first_name_entry";
+                       type: SWALLOW;            
+                       description {
+                               state: "default" 0.0;
+                       rel1 { relative: 0.1 0.31; }
+                       rel2 { relative: 0.9 0.41; }
+                       }
+               }
+               part {
+                       name: "second_name_entry,bg";
+                       type: RECT;            
+                       description {
+                               state: "default" 0.0;
+                       rel1 { relative: 0.1 0.44; }
+                       rel2 { relative: 0.9 0.54; }
+                       color: 222 222 222 222;                                 
+                       }
+               }
+           part {
+               name: "second_name_entry";
+                       type: SWALLOW;            
+                       description {
+                               state: "default" 0.0;
+                       rel1 { relative: 0.1 0.44; }
+                       rel2 { relative: 0.9 0.54; }
+                        }
+               }
+      }
+   }
+
 }
diff --git a/TelegramTizen/res/edje/telegram_start_screen.edc b/TelegramTizen/res/edje/telegram_start_screen.edc
new file mode 100644 (file)
index 0000000..0a4b826
--- /dev/null
@@ -0,0 +1,242 @@
+#define INDICATOR_H 40
+
+images {
+       image: "telegram_icon_telegram.png" COMP;
+       image: "telegram_icon_secure.png" COMP;
+       image: "telegram_icon_private.png" COMP;
+       image: "telegram_icon_powerful.png" COMP;
+       image: "telegram_icon_free.png" COMP;
+       image: "telegram_icon_fast.png" COMP;
+       image: "telegram_icon_cloud.png" COMP;
+}
+
+styles {
+       style {
+               name: "help,comment";
+               base: "font=Tizen text_class=ATO001 font_size=28 align=left color=#FFFFFF color_class=ATO001 ellipsis=1.0";
+               tag:  "br" "\n";
+               tag:  "hilight" "+ font=Tizen:style=Bold";
+               tag:  "b" "+ font=Tizen:style=Bold";
+               tag:  "tab" "\t";
+       }
+}
+
+collections {
+       /**
+        * GUI Setup base layout
+        */
+       group {
+               name: "setup,layout";
+               parts {
+                       /**
+                        * Swallow the scroller to here.
+                        * And the scroller will manages "setup,01", "setup,02", ...
+                        */
+                       part {
+                               name: "content";
+                               type: SWALLOW;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.0 0.0; }
+                                       rel2 { relative: 1.0 1.0; }
+                               }
+                       }
+
+                       part {
+                               name: "indicator";
+                               type: SWALLOW;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.0 (INDICATOR_H+1004)/1280; }
+                                       rel2 { relative: 1.0 (INDICATOR_H+1044)/1280; } 
+                               }
+                       }
+
+                       part {
+                               name: "button";
+                               type: SWALLOW;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.0 1108/1280; }
+                                       rel2 { relative: 1.0 1.0; }
+                               }
+                       }
+               }
+       } // setup,layout
+
+       /**
+        * GUI PPT, Slide 10
+        */
+       group {
+               name: "setup,frame";
+               parts {
+                       part {
+                               name: "bg";
+                               type: RECT;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.0 0.0; }
+                                       rel2 { relative: 1.0 1.0; }
+                               }
+                       }
+
+                       part {
+                               name: "setup,main";
+                               type: SWALLOW;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.0 (286 + INDICATOR_H)/1280; }
+                                       rel2 { relative: 1.0 (657 + INDICATOR_H)/1280; }
+                               }
+                       }
+
+                       part {
+                               name: "start,button";
+                               type: SWALLOW;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.0 (679 + INDICATOR_H)/1280; }
+                                       rel2 { relative: 1.0 (799 + INDICATOR_H)/1280; }
+                               }
+                       }
+               }
+       } // setup,frame
+
+       /**
+        * GUI PPT, Slide 11
+        * Size: 720x371
+        */
+       group {
+               name: "setup,main";
+               parts {
+                       part {
+                               name: "icon";
+                               type: IMAGE;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 280/720 0.0; }
+                                       rel2 { relative: 440/720 160/371; }
+                                       image { normal: "telegram_icon_telegram.png"; }
+                               }
+                               description {
+                                       state: "secure" 0.0;
+                                       rel1 { relative: 280/720 0.0; }
+                                       rel2 { relative: 440/720 160/371; }
+                                       image { normal: "telegram_icon_secure.png"; }
+                               }
+                               description {
+                                       state: "private" 0.0;
+                                       rel1 { relative: 280/720 0.0; }
+                                       rel2 { relative: 440/720 160/371; }
+                                       image { normal: "telegram_icon_private.png"; }
+                               }
+                               description {
+                                       state: "powerful" 0.0;
+                                       rel1 { relative: 280/720 0.0; }
+                                       rel2 { relative: 440/720 160/371; }
+                                       image { normal: "telegram_icon_powerful.png"; }
+                               }
+                               description {
+                                       state: "free" 0.0;
+                                       rel1 { relative: 280/720 0.0; }
+                                       rel2 { relative: 440/720 160/371; }
+                                       image { normal: "telegram_icon_free.png"; }
+                               }
+                               description {
+                                       state: "fast" 0.0;
+                                       rel1 { relative: 280/720 0.0; }
+                                       rel2 { relative: 440/720 160/371; }
+                                       image { normal: "telegram_icon_fast.png"; }
+                               }
+                               description {
+                                       state: "cloud" 0.0;
+                                       rel1 { relative: 280/720 0.0; }
+                                       rel2 { relative: 440/720 160/371; }
+                                       image { normal: "telegram_icon_cloud.png"; }
+                               }
+                       }
+
+                       part {
+                               name: "title";
+                               type: TEXT;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.5 160/371; }
+                                       rel2 { relative: 0.5 227/371; }
+                                       min: 10 0;
+                                       fixed: 1 0;
+                                       text {
+                                               align: 0.5 0.5;
+                                               size: 26;
+                                               text: "Telegram";
+                                       }
+                               }
+                       }
+
+                       part {
+                               name: "comment";
+                               type: TEXTBLOCK;
+                               description {
+                                       state: "default" 0.0;
+                                       min: 1 0;
+                                       fixed: 1 0;
+                                       rel1 { relative: 0.5 242/371; }
+                                       rel2 { relative: 0.5 371/371; }
+                                       text { style: "help,comment"; }
+                               }
+                       }
+               }
+
+               programs {
+                       program {
+                               name: "default";
+                               signal: "telegram";
+                               source: "icon";
+                               action: STATE_SET "default" 0.0;
+                               target: "icon";
+                       }
+                       program {
+                               name: "secure";
+                               signal: "secure";
+                               source: "icon";
+                               action: STATE_SET "secure" 0.0;
+                               target: "icon";
+                       }
+                       program {
+                               name: "cloud";
+                               signal: "cloud";
+                               source: "icon";
+                               action: STATE_SET "cloud" 0.0;
+                               target: "icon";
+                       }
+                       program {
+                               name: "private";
+                               signal: "private";
+                               source: "icon";
+                               action: STATE_SET "private" 0.0;
+                               target: "icon";
+                       }
+                       program {
+                               name: "powerful";
+                               signal: "powerful";
+                               source: "icon";
+                               action: STATE_SET "powerful" 0.0;
+                               target: "icon";
+                       }
+                       program {
+                               name: "free";
+                               signal: "free";
+                               source: "icon";
+                               action: STATE_SET "free" 0.0;
+                               target: "icon";
+                       }
+                       program {
+                               name: "fast";
+                               signal: "fast";
+                               source: "icon";
+                               action: STATE_SET "fast" 0.0;
+                               target: "icon";
+                       }
+               }
+       } // setup,main
+}
\ No newline at end of file
index 8dd23e1..d2d4673 100644 (file)
@@ -6,7 +6,6 @@
 
 #include "server_requests.h"
 #include "tg_db_wrapper.h"
-#include "device_contacts_manager.h"
 
 void send_request_for_registration(service_client* service_client, const char* phone_number, Eina_Bool through_sms)
 {
@@ -143,7 +142,7 @@ void send_request_for_validation(service_client* service_client, const char* sms
        bundle_free(msg);
 }
 
-void send_add_buddy_request(service_client* service_client, const int buddy_id)
+void send_add_buddy_request(service_client* service_client, const int buddy_id, const char *first_name, const char *last_name, const char *phone_number)
 {
        if (!service_client) {
                // error
@@ -176,6 +175,24 @@ void send_add_buddy_request(service_client* service_client, const int buddy_id)
                return;
        }
 
+       if (bundle_add_str(msg, "first_name", first_name) != 0) {
+               ERR("Failed to add data by key to bundle");
+               bundle_free(msg);
+               return;
+       }
+
+       if (bundle_add_str(msg, "last_name", last_name) != 0) {
+               ERR("Failed to add data by key to bundle");
+               bundle_free(msg);
+               return;
+       }
+
+       if (bundle_add_str(msg, "phone_number", phone_number) != 0) {
+               ERR("Failed to add data by key to bundle");
+               bundle_free(msg);
+               return;
+       }
+
        result = service_client_send_message(service_client, msg);
        if(result != SVC_RES_OK) {
                // error
@@ -702,107 +719,6 @@ Eina_Bool send_request_for_media_downloading(service_client* service_client, con
        return EINA_TRUE;
 }
 
-void send_contacts_list_to_server(service_client* service_client, Eina_List* contacts_list)
-{
-       bundle *msg;
-       int count;
-       char tmp[50];
-       char *first_name;
-       char *last_name;
-       char *phone_number;
-       Eina_List *l;
-       contact_data_s* contact_data;
-       int i;
-
-       if (!service_client || !contacts_list) {
-               // error
-               return;
-       }
-
-       msg = bundle_create();
-       if (!msg) {
-               return;
-       }
-
-       if (bundle_add_str(msg, "app_name", "Tizen Telegram") != 0)     {
-               ERR("Failed to add data by key to bundle");
-               bundle_free(msg);
-               return;
-       }
-
-       if (bundle_add_str(msg, "command", "device_contact_list") != 0) {
-               ERR("Failed to add data by key to bundle");
-               bundle_free(msg);
-               return;
-       }
-
-       count = eina_list_count(contacts_list);
-       snprintf(tmp, sizeof(tmp) - 1, "%d", count);
-
-       if (bundle_add_str(msg, "count", tmp) != 0) {
-               ERR("Failed to add data by key to bundle");
-               bundle_free(msg);
-               return;
-       }
-
-       i = 0;
-
-       EINA_LIST_FOREACH(contacts_list, l, contact_data) {
-               phone_number = contact_data->phone_number;
-               if (!phone_number) {
-                       // error.
-                       LOGE("Phone number is not valid");
-                       continue;
-               }
-
-               first_name = contact_data->first_name;
-               if (!first_name) {
-                       first_name = contact_data->display_name;
-                       if (!first_name) {
-                               first_name = "";
-                       }
-               }
-
-               last_name = contact_data->last_name;
-               if (!last_name) {
-                       last_name = "";
-               }
-
-               snprintf(tmp, sizeof(tmp) - 1, "first_name_%d", i);
-               if (bundle_add_str(msg, tmp, first_name) != 0) {
-                       ERR("Failed to add data by key to bundle");
-                       bundle_free(msg);
-                       return;
-               }
-
-               snprintf(tmp, sizeof(tmp) - 1, "last_name_%d", i);
-               if (bundle_add_str(msg, tmp, last_name) != 0) {
-                       ERR("Failed to add data by key to bundle");
-                       bundle_free(msg);
-                       return;
-               }
-
-               snprintf(tmp, sizeof(tmp) - 1, "phone_number_%d", i);
-               if (bundle_add_str(msg, tmp, phone_number) != 0) {
-                       ERR("Failed to add data by key to bundle");
-                       bundle_free(msg);
-                       return;
-               }
-
-               i++;
-       }
-
-       int result = SVC_RES_FAIL;
-       result = service_client_send_message(service_client, msg);
-
-       if(result != SVC_RES_OK) {
-               // error
-       }
-
-       bundle_free(msg);
-
-}
-
 void send_group_creation_request_to_server(service_client* service_client, Eina_List* buddy_list, const char* group_name, const char* group_image)
 {
        bundle *msg;
index 9c92d2a..4e1684c 100644 (file)
@@ -4,8 +4,6 @@
 #include "tg_db_wrapper.h"
 #include "tg_login.h"
 #include "tg_first_registration.h"
-#include "device_contacts_manager.h"
-#include "contacts-db-utils.h"
 #include "server_requests.h"
 #include "tg_init_screen.h"
 #include "tg_user_main_view.h"
@@ -294,7 +292,11 @@ void load_peer_data(appdata_s *ad)
                        peer_info->photo_id = *temp_pic_id;
                        free(temp_pic_id);
                }
-
+               int *temp_unknown = (int*)eina_list_nth(ts_msg, 11);
+               if (temp_unknown) {
+                       peer_info->is_unknown = *temp_unknown;
+                       free(temp_unknown);
+               }
 
                eina_list_free(ts_msg);
 
@@ -402,7 +404,12 @@ void load_main_list_data(appdata_s *ad)
                                                tg_main_list_item_s* main_list_item = (tg_main_list_item_s*)malloc(sizeof(tg_main_list_item_s));
                                                main_list_item->peer_id = peer_info->peer_id;
                                                main_list_item->peer_type = peer_info->peer_type;
-                                               main_list_item->peer_print_name = strdup(peer_info->print_name);
+                                               if ((peer_info->peer_type == TGL_PEER_USER) && get_buddy_unknown_status(peer_info->peer_id)) {
+                                                       //set phone number
+                                                       main_list_item->peer_print_name = strdup(get_buddy_phone_num_from_id(peer_info->peer_id));
+                                               } else {
+                                                       main_list_item->peer_print_name = strdup(peer_info->print_name);
+                                               }
                                                main_list_item->last_seen_time = msg->date;
                                                main_list_item->profile_pic = NULL;
                                                main_list_item->last_msg_id = msg->msg_id;
@@ -443,7 +450,12 @@ void load_main_list_data(appdata_s *ad)
                                                        tg_main_list_item_s* main_list_item = (tg_main_list_item_s*)malloc(sizeof(tg_main_list_item_s));
                                                        main_list_item->peer_id = peer_info->peer_id;
                                                        main_list_item->peer_type = peer_info->peer_type;
-                                                       main_list_item->peer_print_name = strdup(peer_info->print_name);
+                                                       if ((peer_info->peer_type == TGL_PEER_USER) && get_buddy_unknown_status(peer_info->peer_id)) {
+                                                               //set phone number
+                                                               main_list_item->peer_print_name = strdup(get_buddy_phone_num_from_id(peer_info->peer_id));
+                                                       } else {
+                                                               main_list_item->peer_print_name = strdup(peer_info->print_name);
+                                                       }
                                                        main_list_item->last_seen_time = peer_info->last_seen_time;
                                                        main_list_item->profile_pic = NULL;
                                                        main_list_item->last_message = strdup(item->last_message);
@@ -625,6 +637,225 @@ void load_group_chat_data(appdata_s *ad)
        eina_list_free(chat_details);
 }
 #endif
+
+void load_unknown_buddy_list_data(appdata_s *ad)
+{
+
+       if (!ad) {
+               return;
+       }
+
+       if (ad->unknown_buddy_list) {
+
+               for (int i = 0; i < eina_list_count(ad->unknown_buddy_list) ; i++) {
+                       user_data_with_pic_s *item = eina_list_nth(ad->unknown_buddy_list, i);
+                       user_data_s* user_data = item->use_data;
+
+                       if (user_data->print_name) {
+                               free(user_data->print_name);
+                               user_data->print_name = NULL;
+                       }
+
+                       if (user_data->photo_path) {
+                               free(user_data->photo_path);
+                               user_data->photo_path = NULL;
+                       }
+
+                       if (user_data->first_name) {
+                               free(user_data->first_name);
+                               user_data->first_name = NULL;
+                       }
+
+                       if (user_data->last_name) {
+                               free(user_data->last_name);
+                               user_data->last_name = NULL;
+                       }
+
+                       if (user_data->phone) {
+                               free(user_data->phone);
+                               user_data->phone = NULL;
+                       }
+                       if (user_data->real_first_name) {
+                               free(user_data->real_first_name);
+                               user_data->real_first_name = NULL;
+                       }
+
+                       if (user_data->real_last_name) {
+                               free(user_data->real_last_name);
+                               user_data->real_last_name = NULL;
+                       }
+
+                       if (user_data->username) {
+                               free(user_data->username);
+                               user_data->username = NULL;
+                       }
+                       free(user_data);
+                       free(item);
+               }
+
+               eina_list_free(ad->unknown_buddy_list);
+               ad->unknown_buddy_list = NULL;
+       }
+
+       Eina_List* user_info = get_unknown_buddy_list_info();
+
+       if(!user_info) {
+               //error
+               show_toast(ad, "User info not loaded");
+               return;
+       }
+
+       int row_count = eina_list_count(user_info);
+
+       for (int i = 0 ; i < row_count ; i++) {
+               Eina_List* row_vals = eina_list_nth(user_info, i);
+
+               int *temp_user_id = (int*)eina_list_nth(row_vals, 0);
+
+               if (ad->user_id.id == (*temp_user_id)) {
+                       for (int i = 0 ; i < eina_list_count(row_vals); i++) {
+                               void* val = eina_list_nth(row_vals, i);
+                               free(val);
+                       }
+                       continue;
+               }
+
+               user_data_s* user_data = (user_data_s*)malloc(sizeof(user_data_s));
+               user_data->is_selected = EINA_FALSE;
+
+
+               if (temp_user_id) {
+                       user_data->user_id.id = *temp_user_id;
+                       user_data->user_id.type = TGL_PEER_USER;
+                       free(temp_user_id);
+               }
+
+               char *print_name = (char*)eina_list_nth(row_vals, 1);
+               if(print_name) {
+                       user_data->print_name = strdup(print_name);
+                       free(print_name);
+               } else {
+                       user_data->print_name = NULL;
+               }
+
+               int *temp_struct_ver = (int*)eina_list_nth(row_vals, 2);
+               if(temp_struct_ver) {
+                       user_data->structure_version = *temp_struct_ver;
+                       free(temp_struct_ver);
+               }
+
+               char *photo_path = (char*)eina_list_nth(row_vals, 3);
+               if(photo_path) {
+                       user_data->photo_path = strdup(photo_path);
+                       free(photo_path);
+               } else {
+                       user_data->photo_path = NULL;
+               }
+
+
+               int *temp_photo_id = (int*)eina_list_nth(row_vals, 4);
+               if(temp_photo_id) {
+                       user_data->photo_id = *temp_photo_id;
+                       free(temp_photo_id);
+               }
+
+               char *first_name = (char*)eina_list_nth(row_vals, 5);
+               if(first_name) {
+                       user_data->first_name = strdup(first_name);
+                       free(first_name);
+               } else {
+                       user_data->first_name = NULL;
+               }
+
+               char *last_name = (char*)eina_list_nth(row_vals, 6);
+               if(last_name) {
+                       user_data->last_name = strdup(last_name);
+                       free(last_name);
+               } else {
+                       user_data->last_name = NULL;
+               }
+
+               char *phone_no = (char*)eina_list_nth(row_vals, 7);
+               if(phone_no) {
+                       user_data->phone = strdup(phone_no);
+                       free(phone_no);
+               } else {
+                       user_data->phone = NULL;
+               }
+
+               int *temp_access_hash = (int*)eina_list_nth(row_vals, 8);
+               if(temp_access_hash) {
+                       user_data->access_hash = *temp_access_hash;
+                       free(temp_access_hash);
+               }
+
+               char *real_first_name = (char*)eina_list_nth(row_vals, 9);
+               if(real_first_name) {
+                       user_data->real_first_name = strdup(real_first_name);
+                       free(real_first_name);
+               } else {
+                       user_data->real_first_name = NULL;
+               }
+
+               char *real_last_name = (char*)eina_list_nth(row_vals, 10);
+               if(real_last_name) {
+                       user_data->real_last_name = strdup(real_last_name);
+                       free(real_last_name);
+               } else {
+                       user_data->real_last_name = NULL;
+               }
+
+               char *user_name = (char*)eina_list_nth(row_vals, 11);
+               if(user_name) {
+                       user_data->username = strdup(user_name);
+                       free(user_name);
+               } else {
+                       user_data->username = NULL;
+               }
+
+               int *temp_online_status = (int*)eina_list_nth(row_vals, 12);
+               if(temp_online_status) {
+                       user_data->online = *temp_online_status;
+                       free(temp_online_status);
+               }
+
+               int *temp_last_seen = (int*)eina_list_nth(row_vals, 13);
+               if(temp_last_seen) {
+                       user_data->last_seen = *temp_last_seen;
+                       free(temp_last_seen);
+               }
+
+               int *temp_is_blocked = (int*)eina_list_nth(row_vals, 14);
+               if(temp_is_blocked) {
+                       user_data->is_blocked = *temp_is_blocked;
+                       free(temp_is_blocked);
+               }
+
+               int *temp_is_deleted = (int*)eina_list_nth(row_vals, 15);
+               if(temp_is_deleted) {
+                       user_data->is_deleted = *temp_is_deleted;
+                       free(temp_is_deleted);
+               }
+
+               int *temp_is_unknown = (int*)eina_list_nth(row_vals, 16);
+               if(temp_is_unknown) {
+                       user_data->is_unknown = *temp_is_unknown;
+                       free(temp_is_unknown);
+               }
+
+               user_data_with_pic_s *item = (user_data_with_pic_s*) malloc(sizeof (user_data_with_pic_s));
+               item->use_data = user_data;
+               //item->pic_file_location = NULL;
+               item->contact_icon = NULL;
+               ad->unknown_buddy_list = eina_list_append(ad->unknown_buddy_list, item);
+
+               eina_list_free(row_vals);
+
+       }
+       eina_list_free(user_info);
+
+}
+
 void load_buddy_list_data(appdata_s *ad)
 {
        if (!ad) {
@@ -823,6 +1054,12 @@ void load_buddy_list_data(appdata_s *ad)
                        free(temp_is_deleted);
                }
 
+               int *temp_is_unknown = (int*)eina_list_nth(row_vals, 16);
+               if(temp_is_unknown) {
+                       user_data->is_unknown = *temp_is_unknown;
+                       free(temp_is_unknown);
+               }
+
                user_data_with_pic_s *item = (user_data_with_pic_s*) malloc(sizeof (user_data_with_pic_s));
                item->use_data = user_data;
                //item->pic_file_location = NULL;
@@ -889,7 +1126,7 @@ static int _on_service_client_msg_received_cb(void *data, bundle *const rec_msg)
                        if (app->current_app_state == TG_LOGIN_STATE || app->current_app_state == TG_REGISTRATION_STATE || app->current_app_state == TG_PROFILE_REGISTRATION_STATE) {
                                // Launch buddy list view
                                load_buddy_list_data(app);
-                               //load_group_chat_data(app);
+                               load_unknown_buddy_list_data(app);
                                load_peer_data(app);
                                load_main_list_data(app);
                                elm_naviframe_item_pop(app->nf);
@@ -921,7 +1158,7 @@ static int _on_service_client_msg_received_cb(void *data, bundle *const rec_msg)
                        if (app->current_app_state == TG_LOGIN_STATE || app->current_app_state == TG_REGISTRATION_STATE || app->current_app_state == TG_PROFILE_REGISTRATION_STATE) {
                                // Launch buddy list view
                                load_buddy_list_data(app);
-                               //load_group_chat_data(app);
+                               load_unknown_buddy_list_data(app);
                                load_peer_data(app);
                                load_main_list_data(app);
                                elm_naviframe_item_pop(app->nf);
@@ -941,7 +1178,7 @@ static int _on_service_client_msg_received_cb(void *data, bundle *const rec_msg)
                        // error handling
                        show_toast(app, "Error: loading contacts");
                }
-       } else if (strcmp(rec_key_val, "reponse_group_chat_updated") == 0) {
+       } else if (strcmp(rec_key_val, "response_group_chat_updated") == 0) {
 
                char *chat_id_str = NULL;
                result = bundle_get_str(rec_msg, "chat_id", &chat_id_str);
@@ -1830,45 +2067,7 @@ static int _on_service_client_msg_received_cb(void *data, bundle *const rec_msg)
                        on_video_thumb_download_completed(app, buddy_id, media_id, file_name);
                }
        } else if (strcmp(rec_key_val, "add_contacts_request") == 0) {
-
-               // load contacts
-
-               if(sc_db_utils_connect())
-               {
-                       Eina_List* contacts_list = get_contact_list_from_device_db();
-                       sc_db_utils_disconnect();
-
-                       if (!contacts_list || eina_list_count(contacts_list) <= 0) {
-                               // no contacts avilable. empty contact list.
-                               return result;
-                       }
-                       send_contacts_list_to_server(app->service_client, contacts_list);
-
-                       for (int i = 0; i < eina_list_count(contacts_list) ; i++) {
-                               contact_data_s* contact_data = eina_list_nth(contacts_list, i);
-                               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->phone_number) {
-                                       free(contact_data->phone_number);
-                                       contact_data->phone_number = NULL;
-                               }
-                               free(contact_data);
-                       }
-                       eina_list_free(contacts_list);
-               }
+               // Not to be handled.
        } else if (strcmp(rec_key_val, "new_buddy_added") == 0) {
                char* buddy_id_str = NULL;
                result = bundle_get_str(rec_msg, "buddy_id", &buddy_id_str);
@@ -2212,7 +2411,12 @@ tg_main_list_item_s* get_latest_item(appdata_s *ad,  peer_with_pic_s *item)
                                        main_list_item = (tg_main_list_item_s*)malloc(sizeof(tg_main_list_item_s));
                                        main_list_item->peer_id = peer_info->peer_id;
                                        main_list_item->peer_type = peer_info->peer_type;
-                                       main_list_item->peer_print_name = strdup(peer_info->print_name);
+                                       if (get_buddy_unknown_status(peer_info->peer_id)) {
+                                               //set phone number
+                                               main_list_item->peer_print_name = strdup(get_buddy_phone_num_from_id(peer_info->peer_id));
+                                       } else {
+                                               main_list_item->peer_print_name = strdup(peer_info->print_name);
+                                       }
                                        main_list_item->last_seen_time = msg->date;
                                        main_list_item->profile_pic = NULL;
                                        main_list_item->last_msg_id = msg->msg_id;
@@ -2253,7 +2457,12 @@ tg_main_list_item_s* get_latest_item(appdata_s *ad,  peer_with_pic_s *item)
                                                main_list_item = (tg_main_list_item_s*)malloc(sizeof(tg_main_list_item_s));
                                                main_list_item->peer_id = peer_info->peer_id;
                                                main_list_item->peer_type = peer_info->peer_type;
-                                               main_list_item->peer_print_name = strdup(peer_info->print_name);
+                                               if (get_buddy_unknown_status(peer_info->peer_id)) {
+                                                       //set phone number
+                                                       main_list_item->peer_print_name = strdup(get_buddy_phone_num_from_id(peer_info->peer_id));
+                                               } else {
+                                                       main_list_item->peer_print_name = strdup(peer_info->print_name);
+                                               }
                                                main_list_item->last_seen_time = peer_info->last_seen_time;
                                                main_list_item->profile_pic = NULL;
                                                main_list_item->last_message = strdup(item->last_message);
@@ -2359,6 +2568,10 @@ void app_nf_back_cb(void *data, Evas_Object *obj, void *event_info)
                        elm_naviframe_item_pop(ad->nf);
                        ad->current_app_state = TG_SETTINGS_SCREEN_STATE;
                        break;
+               case TG_ADD_CONTACT_STATE:
+                       elm_naviframe_item_pop(ad->nf);
+                       ad->current_app_state = TG_SET_USER_INFO_STATE;
+                       break;
                case TG_SET_CHAT_INFO_STATE:
                case TG_SET_USER_INFO_STATE:
                        elm_naviframe_item_pop(ad->nf);
@@ -2556,7 +2769,7 @@ static void create_base_gui(appdata_s *ad)
                //show_toast(ad, "user already registered");
                load_registered_user_data(ad);
                load_buddy_list_data(ad);
-               //load_group_chat_data(ad);
+               load_unknown_buddy_list_data(ad);
                load_peer_data(ad);
                load_main_list_data(ad);
 
@@ -2582,6 +2795,7 @@ app_create(void *data)
 
        ad->phone_number = NULL;
        ad->buddy_list = NULL;
+       ad->unknown_buddy_list = NULL;
        ad->main_list = NULL;
        ad->peer_list = NULL;
        ad->search_peer_list = NULL;
@@ -2805,6 +3019,59 @@ app_terminate(void *data)
                app_data->buddy_list = NULL;
        }
 
+       if (app_data->unknown_buddy_list) {
+
+               for (int i = 0; i < eina_list_count(app_data->unknown_buddy_list) ; i++) {
+                       user_data_with_pic_s *item = eina_list_nth(app_data->unknown_buddy_list, i);
+                       user_data_s* user_data = item->use_data;
+
+                       if (user_data->print_name) {
+                               free(user_data->print_name);
+                               user_data->print_name = NULL;
+                       }
+
+                       if (user_data->photo_path) {
+                               free(user_data->photo_path);
+                               user_data->photo_path = NULL;
+                       }
+
+                       if (user_data->first_name) {
+                               free(user_data->first_name);
+                               user_data->first_name = NULL;
+                       }
+
+                       if (user_data->last_name) {
+                               free(user_data->last_name);
+                               user_data->last_name = NULL;
+                       }
+
+                       if (user_data->phone) {
+                               free(user_data->phone);
+                               user_data->phone = NULL;
+                       }
+                       if (user_data->real_first_name) {
+                               free(user_data->real_first_name);
+                               user_data->real_first_name = NULL;
+                       }
+
+                       if (user_data->real_last_name) {
+                               free(user_data->real_last_name);
+                               user_data->real_last_name = NULL;
+                       }
+
+                       if (user_data->username) {
+                               free(user_data->username);
+                               user_data->username = NULL;
+                       }
+                       free(user_data);
+                       free(item);
+               }
+
+               eina_list_free(app_data->unknown_buddy_list);
+               app_data->unknown_buddy_list = NULL;
+       }
+
+
        if (app_data->loaded_msg_list) {
                eina_list_free(app_data->loaded_msg_list);
                app_data->loaded_msg_list = NULL;
diff --git a/TelegramTizen/src/tg_add_contact.c b/TelegramTizen/src/tg_add_contact.c
new file mode 100644 (file)
index 0000000..8fda670
--- /dev/null
@@ -0,0 +1,298 @@
+/*
+ * tg_add_contact.c
+ *
+ *  Created on: Oct 10, 2015
+ *      Author: sandeep
+ */
+
+#include "tg_add_contact.h"
+#include "tg_db_wrapper.h"
+#include "server_requests.h"
+
+#define NEW_NAME_INFO_TEXT "Set up contact's first and last name"
+
+static Evas_Object* get_image_from_path(const char* path, Evas_Object* parent)
+{
+       if (!path || !parent) {
+               return NULL;
+       }
+       Evas_Object *media_image = elm_image_add(parent);
+       elm_image_aspect_fixed_set(media_image, EINA_FALSE);
+       elm_image_file_set(media_image, path, NULL);
+       evas_object_size_hint_weight_set(media_image, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(media_image, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       evas_object_show(media_image);
+       return media_image;
+}
+
+
+static void on_contact_name_entry_done_clicked(void *data, Evas_Object *obj, void *event_info)
+{
+       appdata_s* ad = data;
+       Evas_Object* first_name_entry = evas_object_data_get(ad->nf, "new_contact_first_name_entry");
+       Evas_Object* last_name_entry = evas_object_data_get(ad->nf, "new_contact_second_name_entry");
+       const char* tfirst_name = elm_object_text_get(first_name_entry);
+       if (!tfirst_name) {
+               show_toast(ad, "Enter first name");
+               return;
+       }
+       const char* tlast_name = elm_object_text_get(last_name_entry);
+       if (!tlast_name) {
+               tlast_name = "";
+       }
+       char* first_name = trim((char*)tfirst_name);
+       char* last_name = trim((char*)tlast_name);
+
+       // To-Do
+       if (!first_name || strlen(first_name) <= 0) {
+               show_toast(ad, "Invalid first name");
+       }
+
+       if (!last_name || strlen(last_name) <= 0) {
+               show_toast(ad, "Invalid last name");
+       }
+
+       char* phone_num = get_buddy_phone_num_from_id(ad->peer_in_cahtting_data->use_data->peer_id);
+
+       send_add_buddy_request(ad->service_client, ad->peer_in_cahtting_data->use_data->peer_id, first_name, last_name, phone_num);
+
+
+       free(first_name);
+       free(last_name);
+
+       elm_naviframe_item_pop(ad->nf);
+       show_loading_popup(ad);
+       ad->current_app_state = TG_SET_USER_INFO_STATE;
+}
+
+Evas_Object* on_new_buddy_info_requested(void *data, Evas_Object *obj, const char *part)
+{
+       Evas_Object *eo = NULL;
+       appdata_s* ad = evas_object_data_get(obj, "app_data");
+       if (!strcmp(part, "elm.swallow.icon")) {
+               Evas_Object *profile_pic = NULL;
+
+               if (ad->peer_in_cahtting_data->use_data->photo_path && strlen(ad->peer_in_cahtting_data->use_data->photo_path) > 0 && strstr(ad->peer_in_cahtting_data->use_data->photo_path, "_null_") == NULL) {
+                       profile_pic = get_image_from_path(ad->peer_in_cahtting_data->use_data->photo_path, ad->nf);
+               } else  {
+                       profile_pic = get_image_from_path(ui_utils_get_resource(DEFAULT_PROFILE_PIC), ad->nf);
+               }
+               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, "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);
+
+               evas_object_data_set(ad->nf, "user_profile_pic", profile_pic);
+
+               eo = elm_layout_add(obj);
+               elm_layout_theme_set(eo, "layout", "list/C/type.1", "default");
+               elm_layout_content_set(eo, "elm.swallow.content", user_pic_layout);
+       } else if (!strcmp(part, "elm.swallow.icon.0")) {
+               char edj_path[PATH_MAX] = {0, };
+               app_get_resource(TELEGRAM_INIT_VIEW_EDJ, edj_path, (int)PATH_MAX);
+               Evas_Object* user_status_layout = elm_layout_add(ad->nf);
+               elm_layout_file_set(user_status_layout, edj_path, "main_list_name_status_item");
+               evas_object_size_hint_weight_set(user_status_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+               evas_object_size_hint_align_set(user_status_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+               evas_object_show(user_status_layout);
+
+
+               char* user_name = replace(ad->peer_in_cahtting_data->use_data->print_name, '_', " ");
+               char buf[512] = {'\0'};
+               snprintf(buf, 512, "<font=Tizen:style=Bold color=#FFFFFF align=left><font_size=40>%s</font_size></font>", user_name);
+               free(user_name);
+
+               Evas_Object*  name_lbl = elm_label_add(ad->nf);
+               elm_object_text_set(name_lbl, buf);
+               evas_object_size_hint_weight_set(name_lbl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+               evas_object_size_hint_align_set(name_lbl, EVAS_HINT_FILL, EVAS_HINT_FILL);
+               evas_object_show(name_lbl);
+
+               elm_object_part_content_set(user_status_layout, "swallow.name", name_lbl);
+
+               Evas_Object *profile_time = evas_object_data_get(ad->nf, "profile_time");
+               char *online_status = "";
+               if (profile_time) {
+                       online_status = elm_entry_markup_to_utf8(elm_object_text_get(profile_time));
+               }
+
+               //char* user_status = "online";
+               char status_buf[126] = {'\0'};
+               sprintf(status_buf, "<font=Tizen:style=Italic color=#FFFFFF align=left><font_size=35>%s</font_size></font>", online_status);
+
+               Evas_Object*  status_lbl = elm_label_add(ad->nf);
+               elm_object_text_set(status_lbl, status_buf);
+               evas_object_size_hint_weight_set(status_lbl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+               evas_object_size_hint_align_set(status_lbl, EVAS_HINT_FILL, EVAS_HINT_FILL);
+               evas_object_show(status_lbl);
+
+               elm_object_part_content_set(user_status_layout, "swallow.status", status_lbl);
+               return user_status_layout;
+       } else {
+
+       }
+       return eo;
+}
+
+
+static void on_contact_name_change_enable_ok_button(void *data, Evas_Object *obj, void *event_info)
+{
+       appdata_s* ad = data;
+       Evas_Object* done_btn = evas_object_data_get(ad->nf, "name_done_btn");
+       char buf[256] = {'\0',};
+       snprintf(buf, sizeof(buf), "%s", elm_object_text_get(obj));
+       char* org_buf = trim(buf);
+
+       if (strlen(org_buf) > 0) {
+               elm_object_disabled_set(done_btn, EINA_FALSE);
+       } else {
+               elm_object_disabled_set(done_btn, EINA_TRUE);
+       }
+       free(org_buf);
+}
+
+
+void launch_add_contact_screen(appdata_s* ad)
+{
+       if (!ad) {
+               return;
+       }
+       if (ad->msg_popup) {
+               evas_object_del(ad->msg_popup);
+               ad->msg_popup = NULL;
+       }
+
+       ad->current_app_state = TG_ADD_CONTACT_STATE;
+
+
+       char edj_path[PATH_MAX] = {0, };
+       app_get_resource(TELEGRAM_INIT_VIEW_EDJ, edj_path, (int)PATH_MAX);
+
+       Evas_Object* scroller = elm_scroller_add(ad->nf);
+       elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE);
+       elm_scroller_policy_set(scroller,ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
+
+       Evas_Object* layout = elm_layout_add(ad->nf);
+       elm_layout_file_set(layout, edj_path, "add_contact_screen");
+       evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       evas_object_show(layout);
+       elm_object_content_set(scroller, layout);
+
+       /**************** user info *********************/
+       Evas_Object *pic_name_list = NULL;
+       static Elm_Genlist_Item_Class itc;
+       pic_name_list = elm_genlist_add(ad->nf);
+       elm_list_mode_set(pic_name_list, ELM_LIST_COMPRESS);
+       elm_genlist_mode_set(pic_name_list, ELM_LIST_COMPRESS);
+       elm_object_style_set(pic_name_list, "solid/default");
+       evas_object_size_hint_weight_set(pic_name_list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(pic_name_list, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       evas_object_data_set(pic_name_list, "app_data", ad);
+
+       itc.item_style = "type1";
+       itc.func.text_get = NULL;
+       itc.func.content_get = on_new_buddy_info_requested;
+       itc.func.state_get = NULL;
+       itc.func.del = NULL;
+       int i = 1;
+       elm_genlist_item_append(pic_name_list, &itc, (void *) i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void*) i);
+
+       evas_object_show(pic_name_list);
+       elm_object_part_content_set(layout, "pic_name_layout", pic_name_list);
+       /******************* user Info **********************/
+
+       Evas_Object* user_info_lbl = elm_label_add(ad->nf);
+       evas_object_show(user_info_lbl);
+       evas_object_size_hint_weight_set(user_info_lbl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(user_info_lbl, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       elm_object_text_set(user_info_lbl, "<font=Tizen:style=Bold color=#00FFFF align=left><font_size=45>&nbsp;&nbsp;Add contact</font_size></font>");
+       elm_object_part_content_set(layout, "user_info", user_info_lbl);
+
+       /*************** Entry screen ****************************/
+
+
+
+       char *first_name = NULL;
+       char *last_name = NULL;
+       char *phone_num = NULL;
+       get_buddy_contact_details_from_db(ad->peer_in_cahtting_data->use_data->peer_id, &first_name, &last_name, &phone_num);
+       if (!last_name) {
+               last_name = "";
+       }
+
+       char* info_txt = NULL;
+       info_txt = (char*)malloc(strlen(NEW_NAME_INFO_TEXT) + 1);
+       strcpy(info_txt, NEW_NAME_INFO_TEXT);
+
+       char temp_txt[512] = {0,};
+       snprintf(temp_txt, sizeof(temp_txt), "<font=Tizen:style=Regular color=#666362 align=left><font_size=32>%s</font_size></font>", info_txt);
+       free(info_txt);
+
+       Evas_Object* info_btn = elm_entry_add(layout);
+       elm_object_text_set(info_btn, temp_txt);
+       evas_object_size_hint_weight_set(info_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(info_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       elm_entry_single_line_set(info_btn,  EINA_FALSE);
+       elm_entry_editable_set(info_btn, EINA_FALSE);
+       elm_entry_line_wrap_set(info_btn, EINA_TRUE);
+       evas_object_show(info_btn);
+       elm_object_part_content_set(layout, "setup_guide_text", info_btn);
+
+
+       Evas_Object* first_name_entry = elm_entry_add(layout);
+       evas_object_size_hint_weight_set(first_name_entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(first_name_entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+       elm_object_part_text_set(first_name_entry, "elm.guide", "<font=Tizen:style=Regular color=#666362 align=left><font_size=36>First name (required)</font_size></font>");
+       elm_object_text_set(first_name_entry, first_name);
+       elm_entry_single_line_set(first_name_entry, EINA_TRUE);
+       elm_entry_scrollable_set (first_name_entry, EINA_FALSE);
+       elm_entry_cnp_mode_set(first_name_entry, ELM_CNP_MODE_NO_IMAGE);
+       elm_entry_context_menu_disabled_set(first_name_entry, EINA_TRUE);
+       elm_entry_text_style_user_push(first_name_entry, "DEFAULT='color=#000000'");
+       evas_object_show(first_name_entry);
+       elm_object_part_content_set(layout, "first_name_entry", first_name_entry);
+
+       evas_object_data_set(ad->nf, "new_contact_first_name_entry", (void*)first_name_entry);
+
+       evas_object_smart_callback_add(first_name_entry, "changed", on_contact_name_change_enable_ok_button, ad);
+
+       Evas_Object* second_name_entry = elm_entry_add(layout);
+       evas_object_size_hint_weight_set(second_name_entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(second_name_entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       elm_object_text_set(second_name_entry, last_name);
+       elm_object_part_text_set(second_name_entry, "elm.guide", "<font=Tizen:style=Regular color=#666362 align=left><font_size=36>Last name (optional)</font_size></font>");
+
+       elm_entry_single_line_set(second_name_entry, EINA_TRUE);
+       elm_entry_scrollable_set (second_name_entry, EINA_FALSE);
+       elm_entry_cnp_mode_set(second_name_entry, ELM_CNP_MODE_NO_IMAGE);
+       elm_entry_context_menu_disabled_set(second_name_entry, EINA_TRUE);
+       elm_entry_text_style_user_push(second_name_entry, "DEFAULT='color=#000000'");
+       evas_object_show(second_name_entry);
+       elm_object_part_content_set(layout, "second_name_entry", second_name_entry);
+
+       evas_object_data_set(ad->nf, "new_contact_second_name_entry", (void*)second_name_entry);
+
+       //elm_object_part_content_set(layout, "layout", layout);
+       /*************** Entry screen ****************************/
+
+       Elm_Object_Item* navi_item = elm_naviframe_item_push(ad->nf, "User Info", NULL, NULL, scroller, NULL);
+       Evas_Object *done_btn = elm_button_add(ad->nf);
+       elm_object_style_set(done_btn, "naviframe/title_icon");
+       elm_object_text_set(done_btn, "Done");
+       evas_object_smart_callback_add(done_btn, "clicked", on_contact_name_entry_done_clicked, ad);
+
+       Evas_Object *cancel_btn = elm_label_add(ad->nf);
+       elm_object_style_set(cancel_btn, "naviframe/title_icon");
+
+       elm_object_item_part_content_set(navi_item, "title_right_btn", done_btn);
+       elm_object_item_part_content_set(navi_item, "title_left_btn", cancel_btn);
+
+       evas_object_data_set(ad->nf, "name_done_btn", (void*)done_btn);
+       //elm_object_disabled_set(done_btn, EINA_TRUE);
+}
index a98dd58..e09d131 100644 (file)
@@ -324,6 +324,20 @@ user_data_with_pic_s* is_present_in_buddy_list(appdata_s* ad, int buddy_id)
        return NULL;
 }
 
+user_data_with_pic_s* is_present_in_unknown_buddy_list(appdata_s* ad, int buddy_id)
+{
+       if (ad->unknown_buddy_list) {
+               for (int i = 0 ; i < eina_list_count(ad->unknown_buddy_list) ; i++) {
+                       user_data_with_pic_s *item = eina_list_nth(ad->unknown_buddy_list, i);
+                       user_data_s* user = item->use_data;
+                       if (user->user_id.id == buddy_id) {
+                               return item;
+                       }
+               }
+       }
+       return NULL;
+}
+
 
 /************************* menu *************************/
 
@@ -396,6 +410,12 @@ void on_group_chat_info_updated(appdata_s *ad, char *type_of_change)
                                        if (item) {
                                                selected_buddies = eina_list_append(selected_buddies, item->use_data);
                                                mem_cnt++;
+                                       } else {
+                                               user_data_with_pic_s *item = is_present_in_unknown_buddy_list(ad, chat_info->chat_users[i]);
+                                               if (item) {
+                                                       selected_buddies = eina_list_append(selected_buddies, item->use_data);
+                                                       mem_cnt++;
+                                               }
                                        }
                                }
 
@@ -751,6 +771,8 @@ void launch_chat_info_screen(appdata_s* ad, int chat_id)
        ad->selected_buddy_item = NULL;
        ad->current_app_state = TG_SET_CHAT_INFO_STATE;
 
+       load_unknown_buddy_list_data(ad);
+
        char edj_path[PATH_MAX] = {0, };
        app_get_resource(TELEGRAM_INIT_VIEW_EDJ, edj_path, (int)PATH_MAX);
 
@@ -831,6 +853,12 @@ void launch_chat_info_screen(appdata_s* ad, int chat_id)
                        if (item) {
                                selected_buddies = eina_list_append(selected_buddies, item->use_data);
                                mem_cnt++;
+                       } else {
+                               user_data_with_pic_s *item = is_present_in_unknown_buddy_list(ad, chat_info->chat_users[i]);
+                               if (item) {
+                                       selected_buddies = eina_list_append(selected_buddies, item->use_data);
+                                       mem_cnt++;
+                               }
                        }
                }
 
index 522e1d9..b008b43 100644 (file)
@@ -27,6 +27,7 @@ void create_data_base_tables()
        col_names = eina_list_append(col_names, USER_INFO_TABLE_LAST_SEEN_TIME);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_BLOCKED);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_DELETED);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_UNKNOWN_PEER);
 
        Eina_List* col_types = NULL;
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
@@ -45,6 +46,7 @@ void create_data_base_tables()
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
 
        Eina_Bool ret = create_table(table_name, col_names, col_types);
        if (!ret) {
@@ -72,6 +74,7 @@ void create_data_base_tables()
        col_names = eina_list_append(col_names, USER_INFO_TABLE_LAST_SEEN_TIME);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_BLOCKED);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_DELETED);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_UNKNOWN_PEER);
 
        col_types = NULL;
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
@@ -90,6 +93,7 @@ void create_data_base_tables()
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
 
        ret = create_table(table_name, col_names, col_types);
        if (!ret) {
@@ -298,6 +302,7 @@ void create_data_base_tables()
        col_names = eina_list_append(col_names, PEER_INFO_TABLE_LAST_SEEN_TIME);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_PHOTO_PATH);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_PHOTO_ID);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_UNKNOWN_PEER);
 
        col_types = NULL;
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
@@ -311,6 +316,7 @@ void create_data_base_tables()
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
 
        ret = create_table(table_name, col_names, col_types);
        if(!ret) {
@@ -525,6 +531,7 @@ Eina_List* get_all_peer_details(char* start_name)
        col_names = eina_list_append(col_names, PEER_INFO_TABLE_LAST_SEEN_TIME);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_PHOTO_PATH);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_PHOTO_ID);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_UNKNOWN_PEER);
 
        Eina_List* col_types = NULL;
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
@@ -538,6 +545,7 @@ Eina_List* get_all_peer_details(char* start_name)
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
 
        //peer_details = get_values_from_table_sync(db, table_name, col_names, col_types, NULL);
        char *where_clause = NULL;
@@ -578,6 +586,7 @@ peer_with_pic_s* get_peer_info(int peer_id)
        col_names = eina_list_append(col_names, PEER_INFO_TABLE_LAST_SEEN_TIME);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_PHOTO_PATH);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_PHOTO_ID);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_UNKNOWN_PEER);
 
        Eina_List* col_types = NULL;
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
@@ -591,6 +600,7 @@ peer_with_pic_s* get_peer_info(int peer_id)
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
 
 
        char chat_id_str[50];
@@ -683,7 +693,11 @@ peer_with_pic_s* get_peer_info(int peer_id)
                        peer_info->photo_id = *temp_pic_id;
                        free(temp_pic_id);
                }
-
+               int *temp_unknown = (int*)eina_list_nth(ts_msg, 11);
+               if (temp_unknown) {
+                       peer_info->is_unknown = *temp_unknown;
+                       free(temp_unknown);
+               }
 
                eina_list_free(ts_msg);
 
@@ -982,6 +996,8 @@ Eina_List* get_buddy_list_info()
        col_names = eina_list_append(col_names, USER_INFO_TABLE_LAST_SEEN_TIME);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_BLOCKED);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_DELETED);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_UNKNOWN_PEER);
+
 
        Eina_List* col_types = NULL;
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
@@ -1000,23 +1016,96 @@ Eina_List* get_buddy_list_info()
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
 
+       int unknown = 0;
+       char unknown_str[50];
+       sprintf(unknown_str, "%d", unknown);
 
-#if 0
-       char* where_clause = (char*)malloc(strlen(USER_INFO_TABLE_USER_ID) + strlen(" = ") + strlen("'Telegram'") + 1);
-       strcpy(where_clause, USER_INFO_TABLE_REAL_FIRST_NAME);
-       strcat(where_clause, " <> ");
-       strcat(where_clause, "'Telegram'");
-#endif
+       char* where_clause = (char*)malloc(strlen(USER_INFO_TABLE_IS_UNKNOWN_PEER) + strlen(" = ") + strlen(unknown_str) + strlen(" AND ") + strlen(USER_INFO_TABLE_IS_DELETED) + strlen(" = ") + strlen(unknown_str) + 1);
+       strcpy(where_clause, USER_INFO_TABLE_IS_UNKNOWN_PEER);
+       strcat(where_clause, " = ");
+       strcat(where_clause, unknown_str);
+       strcat(where_clause, " OR ");
+       strcat(where_clause, USER_INFO_TABLE_IS_DELETED);
+       strcat(where_clause, " = ");
+       strcat(where_clause, unknown_str);
 
-       //user_details = get_values_from_table_sync(db, table_name, col_names, col_types, NULL);
-       user_details = get_values_from_table_sync_order_by(table_name, col_names, col_types, USER_INFO_TABLE_PRINT_NAME, EINA_TRUE, NULL);
+       user_details = get_values_from_table_sync_order_by(table_name, col_names, col_types, USER_INFO_TABLE_PRINT_NAME, EINA_TRUE, where_clause);
 
        eina_list_free(col_names);
        eina_list_free(col_types);
+       free(where_clause);
+
+       return user_details;
+}
+
+Eina_List* get_unknown_buddy_list_info()
+{
+       Eina_List* user_details = NULL;
+
+       char* table_name = BUDDY_INFO_TABLE_NAME;
+       Eina_List* col_names = NULL;
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_USER_ID);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_PRINT_NAME);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_STRUCTURE_VERSION);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_PHOTO_PATH);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_PHOTO_ID);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_FIRST_NAME);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_LAST_NAME);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_PHONE_NO);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_ACCESS_HASH);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_REAL_FIRST_NAME);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_REAL_LAST_NAME);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_USER_NAME);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_ONLINE_STATUS);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_LAST_SEEN_TIME);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_BLOCKED);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_DELETED);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_UNKNOWN_PEER);
+
+
+       Eina_List* col_types = NULL;
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+
+       int unknown = 1;
+       char unknown_str[50];
+       sprintf(unknown_str, "%d", unknown);
+
+       char* where_clause = (char*)malloc(strlen(USER_INFO_TABLE_IS_UNKNOWN_PEER) + strlen(" = ") + strlen(unknown_str) + strlen(" AND ") + strlen(USER_INFO_TABLE_IS_DELETED) + strlen(" = ") + strlen(unknown_str) + 1);
+       strcpy(where_clause, USER_INFO_TABLE_IS_UNKNOWN_PEER);
+       strcat(where_clause, " = ");
+       strcat(where_clause, unknown_str);
+       strcat(where_clause, " OR ");
+       strcat(where_clause, USER_INFO_TABLE_IS_DELETED);
+       strcat(where_clause, " = ");
+       strcat(where_clause, unknown_str);
+
+       user_details = get_values_from_table_sync_order_by(table_name, col_names, col_types, USER_INFO_TABLE_PRINT_NAME, EINA_TRUE, where_clause);
+
+       eina_list_free(col_names);
+       eina_list_free(col_types);
+       free(where_clause);
 
        return user_details;
 }
+
 #if 0
 void set_chat_bg(char *file_path)
 {
@@ -1191,6 +1280,188 @@ char* get_buddy_name_from_id(int buddy_id)
        return profile_name;
 }
 
+char* get_buddy_phone_num_from_id(int buddy_id)
+{
+       Eina_List* buddy_details_array = NULL;
+       char* phone_num = NULL;
+
+       char* table_name = BUDDY_INFO_TABLE_NAME;
+       Eina_List* col_names = NULL;
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_PHONE_NO);
+
+       Eina_List* col_types = NULL;
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
+
+
+       char buddy_id_str[50];
+       sprintf(buddy_id_str, "%d", buddy_id);
+
+       char* where_clause = (char*)malloc(strlen(USER_INFO_TABLE_USER_ID) + strlen(" = ") + strlen(buddy_id_str) + 1);
+       strcpy(where_clause, USER_INFO_TABLE_USER_ID);
+       strcat(where_clause, " = ");
+       strcat(where_clause, buddy_id_str);
+
+       buddy_details_array = get_values_from_table_sync(table_name, col_names, col_types, where_clause);
+       free(where_clause);
+
+
+
+       if (buddy_details_array && eina_list_count(buddy_details_array) > 0) {
+               Eina_List* buddy_details = eina_list_nth(buddy_details_array, 0);
+               if (buddy_details && eina_list_count(buddy_details) > 0) {
+                       char* name = (char*)eina_list_nth(buddy_details, 0);
+
+                       if (name && strlen(name) > 0) {
+                               phone_num = strdup(name);
+                       }
+                       free(name);
+                       eina_list_free(buddy_details);
+               }
+
+               eina_list_free(buddy_details_array);
+       }
+
+       eina_list_free(col_names);
+       eina_list_free(col_types);
+
+       return phone_num;
+}
+
+int  get_buddy_block_status(int buddy_id)
+{
+       Eina_List* buddy_details_array = NULL;
+
+       char* table_name = BUDDY_INFO_TABLE_NAME;
+       Eina_List* col_names = NULL;
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_BLOCKED);
+
+       Eina_List* col_types = NULL;
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+
+
+       char buddy_id_str[50];
+       sprintf(buddy_id_str, "%d", buddy_id);
+
+       char* where_clause = (char*)malloc(strlen(USER_INFO_TABLE_USER_ID) + strlen(" = ") + strlen(buddy_id_str) + 1);
+       strcpy(where_clause, USER_INFO_TABLE_USER_ID);
+       strcat(where_clause, " = ");
+       strcat(where_clause, buddy_id_str);
+
+       buddy_details_array = get_values_from_table_sync(table_name, col_names, col_types, where_clause);
+       free(where_clause);
+
+       int is_unknown = 0;
+
+       if (buddy_details_array && eina_list_count(buddy_details_array) > 0) {
+               Eina_List* buddy_details = eina_list_nth(buddy_details_array, 0);
+               if (buddy_details && eina_list_count(buddy_details) > 0) {
+
+                       int *temp_unknown_status = (int*)eina_list_nth(buddy_details, 0);
+                       if(temp_unknown_status) {
+                               is_unknown = *temp_unknown_status;
+                               free(temp_unknown_status);
+                       }
+                       eina_list_free(buddy_details);
+               }
+               eina_list_free(buddy_details_array);
+       }
+
+       eina_list_free(col_names);
+       eina_list_free(col_types);
+
+       return is_unknown;
+}
+
+int  get_buddy_delete_status(int buddy_id)
+{
+       Eina_List* buddy_details_array = NULL;
+
+       char* table_name = BUDDY_INFO_TABLE_NAME;
+       Eina_List* col_names = NULL;
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_DELETED);
+
+       Eina_List* col_types = NULL;
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+
+
+       char buddy_id_str[50];
+       sprintf(buddy_id_str, "%d", buddy_id);
+
+       char* where_clause = (char*)malloc(strlen(USER_INFO_TABLE_USER_ID) + strlen(" = ") + strlen(buddy_id_str) + 1);
+       strcpy(where_clause, USER_INFO_TABLE_USER_ID);
+       strcat(where_clause, " = ");
+       strcat(where_clause, buddy_id_str);
+
+       buddy_details_array = get_values_from_table_sync(table_name, col_names, col_types, where_clause);
+       free(where_clause);
+
+       int is_unknown = 0;
+
+       if (buddy_details_array && eina_list_count(buddy_details_array) > 0) {
+               Eina_List* buddy_details = eina_list_nth(buddy_details_array, 0);
+               if (buddy_details && eina_list_count(buddy_details) > 0) {
+
+                       int *temp_unknown_status = (int*)eina_list_nth(buddy_details, 0);
+                       if(temp_unknown_status) {
+                               is_unknown = *temp_unknown_status;
+                               free(temp_unknown_status);
+                       }
+                       eina_list_free(buddy_details);
+               }
+               eina_list_free(buddy_details_array);
+       }
+
+       eina_list_free(col_names);
+       eina_list_free(col_types);
+
+       return is_unknown;
+}
+
+int  get_buddy_unknown_status(int buddy_id)
+{
+       Eina_List* buddy_details_array = NULL;
+
+       char* table_name = BUDDY_INFO_TABLE_NAME;
+       Eina_List* col_names = NULL;
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_UNKNOWN_PEER);
+
+       Eina_List* col_types = NULL;
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+
+
+       char buddy_id_str[50];
+       sprintf(buddy_id_str, "%d", buddy_id);
+
+       char* where_clause = (char*)malloc(strlen(USER_INFO_TABLE_USER_ID) + strlen(" = ") + strlen(buddy_id_str) + 1);
+       strcpy(where_clause, USER_INFO_TABLE_USER_ID);
+       strcat(where_clause, " = ");
+       strcat(where_clause, buddy_id_str);
+
+       buddy_details_array = get_values_from_table_sync(table_name, col_names, col_types, where_clause);
+       free(where_clause);
+
+       int is_unknown = 0;
+
+       if (buddy_details_array && eina_list_count(buddy_details_array) > 0) {
+               Eina_List* buddy_details = eina_list_nth(buddy_details_array, 0);
+               if (buddy_details && eina_list_count(buddy_details) > 0) {
+
+                       int *temp_unknown_status = (int*)eina_list_nth(buddy_details, 0);
+                       if(temp_unknown_status) {
+                               is_unknown = *temp_unknown_status;
+                               free(temp_unknown_status);
+                       }
+                       eina_list_free(buddy_details);
+               }
+               eina_list_free(buddy_details_array);
+       }
+
+       eina_list_free(col_names);
+       eina_list_free(col_types);
+
+       return is_unknown;
+}
+
 int  get_buddy_online_status(int buddy_id)
 {
        Eina_List* buddy_details_array = NULL;
@@ -1258,6 +1529,7 @@ Eina_List* get_buddy_info(int buddy_id)
        col_names = eina_list_append(col_names, USER_INFO_TABLE_LAST_SEEN_TIME);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_BLOCKED);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_DELETED);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_UNKNOWN_PEER);
 
        Eina_List* col_types = NULL;
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
@@ -1276,6 +1548,7 @@ Eina_List* get_buddy_info(int buddy_id)
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
 
        char buddy_id_str[50];
        sprintf(buddy_id_str, "%d", buddy_id);
@@ -1365,7 +1638,7 @@ tg_message_s* get_latest_message_from_message_table(char* table_name)
        col_names = eina_list_append(col_names, MESSAGE_INFO_TABLE_UNIQUE_ID);
 
        Eina_List* col_types = NULL;
-       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
@@ -1533,7 +1806,7 @@ void update_msg_into_db(tg_message_s *M, char* table_name)
        col_names = eina_list_append(col_names, MESSAGE_INFO_TABLE_MEDIA_ID);
 
        Eina_List* col_types = NULL;
-       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
@@ -1711,7 +1984,7 @@ tg_message_s* get_message_from_message_table(long long msg_id, char* table_name)
        col_names = eina_list_append(col_names, MESSAGE_INFO_TABLE_UNIQUE_ID);
 
        Eina_List* col_types = NULL;
-       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
@@ -1875,6 +2148,8 @@ void insert_or_update_peer_into_database(tg_peer_info_s* UC)
        col_names = eina_list_append(col_names, PEER_INFO_TABLE_LAST_SEEN_TIME);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_PHOTO_PATH);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_PHOTO_ID);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_UNKNOWN_PEER);
+
 
        Eina_List* col_types = NULL;
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
@@ -1888,6 +2163,7 @@ void insert_or_update_peer_into_database(tg_peer_info_s* UC)
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
 
 
        Eina_List* col_values = NULL;
@@ -1915,6 +2191,7 @@ void insert_or_update_peer_into_database(tg_peer_info_s* UC)
        col_values = eina_list_append(col_values, UC->photo_path);
 
        col_values = eina_list_append(col_values, &(UC->photo_id));
+       col_values = eina_list_append(col_values, &(UC->is_unknown));
 
        Eina_Bool ret = insert_table(table_name, col_names, col_types,col_values);
        if(!ret) {
@@ -1963,7 +2240,7 @@ void insert_msg_into_db(tg_message_s *M, char* table_name, int unique_id)
 
 
        Eina_List* col_types = NULL;
-       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
@@ -2901,6 +3178,11 @@ Eina_List* load_peer_data_by_name(char* name)
                        free(temp_pic_id);
                }
 
+               int *temp_unknown = (int*)eina_list_nth(ts_msg, 11);
+               if (temp_unknown) {
+                       peer_info->is_unknown = *temp_unknown;
+                       free(temp_unknown);
+               }
 
                eina_list_free(ts_msg);
 
@@ -3524,7 +3806,7 @@ void create_buddy_msg_table(const char* table_name)
        }
        // create user info table
        Eina_List* col_names = NULL;
-       col_names = eina_list_append(col_names, MESSAGE_INFO_TABLE_MESSAGE_ROW_ID);
+       //col_names = eina_list_append(col_names, MESSAGE_INFO_TABLE_MESSAGE_ROW_ID);
        col_names = eina_list_append(col_names, MESSAGE_INFO_TABLE_MESSAGE_ID);
        col_names = eina_list_append(col_names, MESSAGE_INFO_TABLE_FLAGS);
        col_names = eina_list_append(col_names, MESSAGE_INFO_TABLE_FWD_FROM_ID);
@@ -3543,8 +3825,8 @@ void create_buddy_msg_table(const char* table_name)
        col_names = eina_list_append(col_names, MESSAGE_INFO_TABLE_UNIQUE_ID);
 
        Eina_List* col_types = NULL;
-       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_AUTO_INC_KEY);
-       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       //col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_AUTO_INC_KEY);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
@@ -3568,3 +3850,53 @@ void create_buddy_msg_table(const char* table_name)
        eina_list_free(col_names);
        eina_list_free(col_types);
 }
+
+void get_buddy_contact_details_from_db(int buddy_id, char **first_name, char **last_name, char **phone_number)
+{
+       char* file_path = NULL;
+       char* table_name = BUDDY_INFO_TABLE_NAME;
+
+       char usr_str[50];
+       sprintf(usr_str, "%d", buddy_id);
+       char* where_clause = (char *)malloc(strlen(USER_INFO_TABLE_USER_ID) + strlen(" = '") + strlen(usr_str) + strlen("'") + 1);
+       strcpy(where_clause, USER_INFO_TABLE_USER_ID);
+       strcat(where_clause, " = '");
+       strcat(where_clause, usr_str);
+       strcat(where_clause, "'");
+
+       Eina_List* col_types = NULL;
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
+
+       Eina_List* col_names = NULL;
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_FIRST_NAME);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_LAST_NAME);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_PHONE_NO);
+
+       Eina_List* vals = get_values_from_table_sync(table_name, col_names, col_types, where_clause);
+       file_path = NULL;
+
+       if (!vals) {
+               //("DB error");
+               eina_list_free(col_names);
+               return;
+       } else {
+               int row_count = eina_list_count(vals);
+
+               for (int i = 0 ; i < row_count ; i++) {
+                       Eina_List* row_vals = eina_list_nth(vals, i);
+                       char *temp_fname = (char*)eina_list_nth(row_vals, 0);
+                       *first_name = temp_fname;
+                       char *temp_lname = (char*)eina_list_nth(row_vals, 1);
+                       *last_name = temp_lname;
+                       char *temp_pnumber = (char*)eina_list_nth(row_vals, 2);
+                       *phone_number = temp_pnumber;
+                       eina_list_free(row_vals);
+                       break;
+               }
+               eina_list_free(vals);
+       }
+       eina_list_free(col_names);
+       return;
+}
index b51e42a..5910fe2 100644 (file)
@@ -17,8 +17,6 @@
 void on_messaging_menu_option_selected_cb(void *data, Evas_Object *obj, void *event_info)
 {
        appdata_s *ad = data;
-
-
        Elm_Object_Item *it = event_info;
        elm_genlist_item_selected_set(it, EINA_FALSE);
        int id = (int)elm_object_item_data_get(it);
@@ -29,9 +27,101 @@ void on_messaging_menu_option_selected_cb(void *data, Evas_Object *obj, void *ev
 
        if (!sel_item || !user_data) {
                show_toast(ad, "There are no messages to delete.");
+               if (ad->msg_popup) {
+                       evas_object_del(ad->msg_popup);
+                       ad->msg_popup = NULL;
+               }
+               return;
+       }
+
+
+       if (get_buddy_unknown_status(user_data->peer_id) && user_data->peer_type == TGL_PEER_USER) {
+
+               if (id == 0) {
+                       show_toast(ad, "Add contact to ur buddies");
+               } else if (id == 1) {
+                       char* tablename = get_table_name_from_number(user_data->peer_id);
+                       delete_all_records(tablename);
+                       free(tablename);
+
+                       // clear all messages
+                       Evas_Object *genlist = evas_object_data_get(ad->nf, "chat_list");
+                       elm_genlist_clear(genlist);
+
+                       // remove main item from main list
+                       if (ad->main_item_in_cahtting_data) {
+                               tg_main_list_item_s* old_item = ad->main_item_in_cahtting_data;
+                               if (old_item->peer_print_name) {
+                                       free(old_item->peer_print_name);
+                                       old_item->peer_print_name = NULL;
+                               }
+                               if (old_item->last_message) {
+                                       free(old_item->last_message);
+                                       old_item->last_message = NULL;
+                               }
+                               if (old_item->profile_pic_path) {
+                                       free(old_item->profile_pic_path);
+                                       old_item->profile_pic_path = NULL;
+                               }
+                               old_item->date_lbl = NULL;
+                               old_item->msg_status_lbl = NULL;
+                               old_item->profile_pic = NULL;
+                               old_item->profile_pic_path = NULL;
+                               old_item->status_lbl = NULL;
+                               old_item->user_name_lbl = NULL;
+                               ad->main_list = eina_list_remove(ad->main_list,  ad->main_item_in_cahtting_data);
+
+                               ad->main_item_in_cahtting_data = NULL;
+                       }
+                       ad->is_last_msg_changed = EINA_FALSE;
+               } else {
+                       char* tablename = get_table_name_from_number(user_data->peer_id);
+                       delete_all_records(tablename);
+                       free(tablename);
+
+                       // clear all messages
+                       Evas_Object *genlist = evas_object_data_get(ad->nf, "chat_list");
+                       elm_genlist_clear(genlist);
+
+                       // remove main item from main list
+                       if (ad->main_item_in_cahtting_data) {
+                               tg_main_list_item_s* old_item = ad->main_item_in_cahtting_data;
+                               if (old_item->peer_print_name) {
+                                       free(old_item->peer_print_name);
+                                       old_item->peer_print_name = NULL;
+                               }
+                               if (old_item->last_message) {
+                                       free(old_item->last_message);
+                                       old_item->last_message = NULL;
+                               }
+                               if (old_item->profile_pic_path) {
+                                       free(old_item->profile_pic_path);
+                                       old_item->profile_pic_path = NULL;
+                               }
+                               old_item->date_lbl = NULL;
+                               old_item->msg_status_lbl = NULL;
+                               old_item->profile_pic = NULL;
+                               old_item->profile_pic_path = NULL;
+                               old_item->status_lbl = NULL;
+                               old_item->user_name_lbl = NULL;
+                               ad->main_list = eina_list_remove(ad->main_list,  ad->main_item_in_cahtting_data);
+
+                               ad->main_item_in_cahtting_data = NULL;
+                       }
+
+                       ad->is_last_msg_changed = EINA_FALSE;
+
+
+                       app_nf_back_cb(ad, NULL, NULL);
+               }
+               if (ad->msg_popup) {
+                       evas_object_del(ad->msg_popup);
+                       ad->msg_popup = NULL;
+               }
                return;
        }
 
+
        if (id == 0) {
                if (user_data->peer_type == TGL_PEER_USER || user_data->peer_type == TGL_PEER_CHAT) {
                        char* tablename = get_table_name_from_number(user_data->peer_id);
@@ -148,10 +238,23 @@ char* on_messaging_menu_group_text_get_cb(void *data, Evas_Object *obj, const ch
 char* on_messaging_menu_text_get_cb(void *data, Evas_Object *obj, const char *part)
 {
        int id = (int) data;
-       if (id == 0) {
-               return strdup("Clear history");
+       appdata_s *ad = evas_object_data_get(obj, "app_data");
+       peer_with_pic_s  *sel_item = ad->peer_in_cahtting_data;
+       tg_peer_info_s *user_data = sel_item->use_data;
+       if ((user_data->peer_type == TGL_PEER_USER) && get_buddy_unknown_status(user_data->peer_id)) {
+           if (id == 0) {
+               return strdup("Add to contacts");
+           } else if (id == 1) {
+                       return strdup("Clear history");
+               } else {
+                       return strdup("Delete");
+               }
        } else {
-               return strdup("Delete");
+               if (id == 0) {
+                       return strdup("Clear history");
+               } else {
+                       return strdup("Delete");
+               }
        }
 }
 
@@ -191,6 +294,8 @@ void on_messaging_menu_button_clicked(void *data, Evas_Object *obj, void *event_
        evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
 
+       evas_object_data_set(genlist, "app_data", ad);
+
        itc.item_style = "default";
        peer_with_pic_s  *sel_item = ad->peer_in_cahtting_data;
        if (sel_item->use_data->peer_type == TGL_PEER_USER) {
@@ -205,12 +310,21 @@ void on_messaging_menu_button_clicked(void *data, Evas_Object *obj, void *event_
        itc.func.state_get = NULL;
        itc.func.del = NULL;
 
-       for (i = 0; i < 2; i++) {
-               elm_genlist_item_append(genlist, &itc, (void *) i, NULL, ELM_GENLIST_ITEM_NONE, on_messaging_menu_option_selected_cb, ad);
+       tg_peer_info_s *user_data = sel_item->use_data;
+       if ((user_data->peer_type == TGL_PEER_USER) && get_buddy_unknown_status(user_data->peer_id)) {
+               for (i = 0; i < 3; i++) {
+                       elm_genlist_item_append(genlist, &itc, (void *) i, NULL, ELM_GENLIST_ITEM_NONE, on_messaging_menu_option_selected_cb, ad);
+               }
+               evas_object_size_hint_min_set(box, -1, 345);
+       } else {
+               for (i = 0; i < 2; i++) {
+                       elm_genlist_item_append(genlist, &itc, (void *) i, NULL, ELM_GENLIST_ITEM_NONE, on_messaging_menu_option_selected_cb, ad);
+               }
+               evas_object_size_hint_min_set(box, -1, 230);
        }
        evas_object_show(genlist);
        elm_box_pack_end(box, genlist);
-       evas_object_size_hint_min_set(box, -1, 230);
+
        elm_object_content_set(ad->msg_popup, box);
        evas_object_show(ad->msg_popup);
 }
@@ -744,7 +858,7 @@ Evas_Object* on_message_item_content_get_cb(void *data, Evas_Object *obj, const
 
                        //elm_entry_magnifier_disabled_set(entry, EINA_TRUE);
                        // FIXME: Deprecated API
-                       //elm_entry_selection_handler_disabled_set(entry, EINA_TRUE);
+                       elm_entry_selection_handler_disabled_set(entry, EINA_TRUE);
 
                        char *sender_name = NULL;
                        if(msg->out) {
@@ -1104,6 +1218,7 @@ void add_date_item_to_chat(void *data)
        peer_with_pic_s *sel_item =  eina_list_nth(ad->peer_list, user_id);
 
        char* msg_table = get_table_name_from_number(sel_item->use_data->peer_id);
+       create_buddy_msg_table(msg_table);
        int msg_id = insert_current_date_to_table(msg_table);
        free(msg_table);
 
@@ -1158,8 +1273,8 @@ static void on_text_message_send_clicked(void *data, Evas_Object *obj, void *eve
        msg.to_id = sel_item->use_data->peer_id;
        msg.unread = 0;
        msg.msg_state = TG_MESSAGE_STATE_SENDING;
-
        char* msg_table = get_table_name_from_number(msg.to_id);
+       create_buddy_msg_table(msg_table);
        insert_msg_into_db(&msg, msg_table, unique_id);
        free(msg_table);
 
@@ -1387,6 +1502,7 @@ void send_contact_message_to_buddy(void *data, char *first_name, char *last_name
 
 
        char* msg_table = get_table_name_from_number(msg.to_id);
+       create_buddy_msg_table(msg_table);
        insert_msg_into_db(&msg, msg_table, unique_id);
        int img_width = 0;
        int img_height = 0;
@@ -1442,6 +1558,7 @@ void send_location_message_to_buddy(void *data, char *latitude, char *longitude)
        msg.msg_state = TG_MESSAGE_STATE_SENDING;
 
        char* msg_table = get_table_name_from_number(msg.to_id);
+       create_buddy_msg_table(msg_table);
        insert_msg_into_db(&msg, msg_table, unique_id);
        int img_width = 0;
        int img_height = 0;
@@ -1497,6 +1614,7 @@ void send_media_message_to_buddy(void *data, const char* file_path, enum tgl_mes
        msg.msg_state = TG_MESSAGE_STATE_SENDING;
 
        char* msg_table = get_table_name_from_number(msg.to_id);
+       create_buddy_msg_table(msg_table);
        insert_msg_into_db(&msg, msg_table, unique_id);
        int img_width = 0;
        int img_height = 0;
@@ -1554,7 +1672,8 @@ void load_chat_history(Evas_Object* chat_list)
        Eina_List* col_names = NULL;
        col_names = eina_list_append(col_names, MESSAGE_INFO_TABLE_MESSAGE_ID);
 
-       Eina_List* vals = get_values_from_table_sync(tablename, col_names, col_types, NULL);
+       //Eina_List* vals = get_values_from_table_sync(tablename, col_names, col_types, NULL);
+       Eina_List* vals = get_values_from_table_sync_order_by(tablename, col_names, col_types, MESSAGE_INFO_TABLE_DATE, EINA_TRUE, NULL);
        Elm_Object_Item* last_item = NULL;
        if(!vals) {
 
@@ -1942,7 +2061,7 @@ void launch_messaging_view_cb(appdata_s* ad, int user_id)
 
        ad->current_app_state = TG_CHAT_MESSAGING_VIEW_STATE;
        ad->is_last_msg_changed = EINA_FALSE;
-
+       send_request_for_server_connection_status(ad->service_client);
        char edj_path[PATH_MAX] = {0, };
        app_get_resource(TELEGRAM_INIT_VIEW_EDJ, edj_path, (int)PATH_MAX);
 
@@ -2000,7 +2119,7 @@ void launch_messaging_view_cb(appdata_s* ad, int user_id)
        evas_object_size_hint_weight_set(chat_conv_list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        evas_object_size_hint_align_set(chat_conv_list, EVAS_HINT_FILL, EVAS_HINT_FILL);
        // FIXME: Deprecated API
-       //elm_genlist_realization_mode_set(chat_conv_list, EINA_TRUE);
+       elm_genlist_realization_mode_set(chat_conv_list, EINA_TRUE);
        //evas_object_color_set(chat_conv_list, 255 , 255, 255, 255);
 #endif
 
@@ -2043,13 +2162,21 @@ void launch_messaging_view_cb(appdata_s* ad, int user_id)
 
        elm_object_part_content_set(title_layout, "swallow.profile_pic", eo);
 
-       char* user_name = replace(sel_item->use_data->print_name, '_', " ");
-       char temp_name[512] = {'\0'};
-    snprintf(temp_name, 512, "<font=Tizen:style=Italic color=#000000 align=left><font_size=30>%s</font_size></font>", user_name);
-    free(user_name);
 
        Evas_Object* profile_name = elm_label_add(title_layout);
-       elm_object_text_set(profile_name,temp_name);
+       if ((user->peer_type == TGL_PEER_USER) && get_buddy_unknown_status(user->peer_id)) {
+               char temp_name[512] = {'\0'};
+               snprintf(temp_name, 512, "<font=Tizen:style=Italic color=#000000 align=left><font_size=30>%s</font_size></font>", get_buddy_phone_num_from_id(sel_item->use_data->peer_id));
+               elm_object_text_set(profile_name,temp_name);
+       } else {
+               char* user_name = replace(sel_item->use_data->print_name, '_', " ");
+               char temp_name[512] = {'\0'};
+               snprintf(temp_name, 512, "<font=Tizen:style=Italic color=#000000 align=left><font_size=30>%s</font_size></font>", user_name);
+               free(user_name);
+               elm_object_text_set(profile_name,temp_name);
+       }
+
+
        evas_object_size_hint_align_set(profile_name, EVAS_HINT_FILL, EVAS_HINT_FILL);
        evas_object_size_hint_weight_set(profile_name, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        elm_object_style_set(profile_name, "transparent");
index 3d0461c..60d982d 100644 (file)
@@ -8,8 +8,6 @@
 #include "tg_db_manager.h"
 #include "server_requests.h"
 #include "tg_login.h"
-#include "device_contacts_manager.h"
-#include "contacts-db-utils.h"
 
 static void on_text_change_enable_ok_button(void *data, Evas_Object *obj, void *event_info)
 {
index 3fe48a6..f97338f 100644 (file)
@@ -8,6 +8,8 @@
 #include "tg_user_info_view.h"
 #include "server_requests.h"
 #include "tg_user_main_view.h"
+#include "tg_add_contact.h"
+#include "tg_db_wrapper.h"
 
 static Evas_Object* get_image_from_path(const char* path, Evas_Object* parent)
 {
@@ -22,24 +24,52 @@ static Evas_Object* get_image_from_path(const char* path, Evas_Object* parent)
        evas_object_show(media_image);
        return media_image;
 }
-#if 0
-static Eina_Bool on_view_deleteion_requested(void *data)
-{
-       appdata_s *ad = data;
-       if (ad) {
-               elm_naviframe_item_pop(ad->nf);
-               ad->current_app_state = TG_USER_MAIN_VIEW_STATE;
-               hide_loading_popup(ad);
-       }
-    return ECORE_CALLBACK_CANCEL;
-}
-#endif
+
 void on_user_added_response_received(appdata_s *ad, int buddy_id, Eina_Bool is_success)
 {
        if (is_success) {
                if (ad->peer_in_cahtting_data->use_data->peer_id == buddy_id) {
                        if (ad->buddy_in_cahtting_data && ad->buddy_in_cahtting_data->use_data->user_id.id == buddy_id) {
                                ad->buddy_in_cahtting_data->use_data->is_deleted = 0;
+                               load_buddy_list_data(ad);
+                               load_unknown_buddy_list_data(ad);
+                               load_peer_data(ad);
+                               load_main_list_data(ad);
+                               refresh_main_list_view(ad, EINA_FALSE);
+
+                               for (int i = 0; i < eina_list_count(ad->buddy_list); i++) {
+                                       user_data_with_pic_s *item = eina_list_nth(ad->buddy_list, i);
+                                       user_data_s* user_data = item->use_data;
+
+                                       if (user_data->user_id.id == buddy_id) {
+                                               ad->buddy_in_cahtting_data = item;
+                                               break;
+                                       }
+                               }
+
+                               if (ad->buddy_in_cahtting_data == NULL) {
+                                       for (int i = 0; i < eina_list_count(ad->unknown_buddy_list); i++) {
+                                               user_data_with_pic_s *item = eina_list_nth(ad->unknown_buddy_list, i);
+                                               user_data_s* user_data = item->use_data;
+
+                                               if (user_data->user_id.id == buddy_id) {
+                                                       ad->buddy_in_cahtting_data = item;
+                                                       break;
+                                               }
+                                       }
+                               }
+
+                               for (int i = 0; i < eina_list_count(ad->peer_list); i++) {
+                                       peer_with_pic_s* pic_item = eina_list_nth(ad->peer_list, i);
+                                       tg_peer_info_s* item = pic_item->use_data;
+
+                                       if (item->peer_id == buddy_id) {
+                                               ad->peer_in_cahtting_data = pic_item;
+                                               buddy_id = i;
+                                               break;
+                                       }
+                               }
+
                                show_toast(ad, "User added successfully");
                        }
                }
@@ -50,77 +80,55 @@ void on_user_added_response_received(appdata_s *ad, int buddy_id, Eina_Bool is_s
 
 void on_user_deleted_response_received(appdata_s *ad, int buddy_id, Eina_Bool is_success)
 {
-#if 0
        if (is_success) {
                if (ad->peer_in_cahtting_data->use_data->peer_id == buddy_id) {
                        if (ad->buddy_in_cahtting_data && ad->buddy_in_cahtting_data->use_data->user_id.id == buddy_id) {
+                               ad->buddy_in_cahtting_data->use_data->is_deleted = 1;
+                               load_buddy_list_data(ad);
+                               load_unknown_buddy_list_data(ad);
+                               load_peer_data(ad);
+                               load_main_list_data(ad);
+                               refresh_main_list_view(ad, EINA_FALSE);
 
-                               show_toast(ad, "User deleted successfully");
+                               for (int i = 0; i < eina_list_count(ad->buddy_list); i++) {
+                                       user_data_with_pic_s *item = eina_list_nth(ad->buddy_list, i);
+                                       user_data_s* user_data = item->use_data;
 
-                               if(ad->peer_list) {
-                                       int size = eina_list_count(ad->peer_list);
-                                       for (int i = 0 ; i < size ; i++) {
-                                               peer_with_pic_s *item = eina_list_nth(ad->peer_list, i);
-                                               if (item->use_data->peer_id == buddy_id) {
-                                                       ad->peer_list = eina_list_remove(ad->peer_list, item);
-                                                       break;
-                                               }
+                                       if (user_data->user_id.id == buddy_id) {
+                                               ad->buddy_in_cahtting_data = item;
+                                               break;
                                        }
                                }
 
-                               if(ad->main_list) {
-                                       int size = eina_list_count(ad->main_list);
-                                       for (int i = 0 ; i < size ; i++) {
-                                               tg_main_list_item_s *item = eina_list_nth(ad->main_list, i);
-                                               if (item->peer_id == buddy_id) {
-                                                       ad->main_list = eina_list_remove(ad->main_list, item);
+                               if (ad->buddy_in_cahtting_data == NULL) {
+                                       for (int i = 0; i < eina_list_count(ad->unknown_buddy_list); i++) {
+                                               user_data_with_pic_s *item = eina_list_nth(ad->unknown_buddy_list, i);
+                                               user_data_s* user_data = item->use_data;
+
+                                               if (user_data->user_id.id == buddy_id) {
+                                                       ad->buddy_in_cahtting_data = item;
                                                        break;
                                                }
                                        }
                                }
 
-                               if(ad->buddy_list) {
-                                       int size = eina_list_count(ad->buddy_list);
-                                       for (int i = 0 ; i < size ; i++) {
-                                               user_data_with_pic_s *item = eina_list_nth(ad->buddy_list, i);
-                                               user_data_s* user = item->use_data;
+                               for (int i = 0; i < eina_list_count(ad->peer_list); i++) {
+                                       peer_with_pic_s* pic_item = eina_list_nth(ad->peer_list, i);
+                                       tg_peer_info_s* item = pic_item->use_data;
 
-                                               if (user->user_id.id == buddy_id) {
-                                                       ad->buddy_list = eina_list_remove(ad->buddy_list, item);
-                                                       break;
-                                               }
+                                       if (item->peer_id == buddy_id) {
+                                               ad->peer_in_cahtting_data = pic_item;
+                                               buddy_id = i;
+                                               break;
                                        }
                                }
 
-                               refresh_main_list_view(ad, EINA_FALSE);
-                               ad->peer_in_cahtting_data = NULL;
-                               ad->main_item_in_cahtting_data = NULL;
-
-                               elm_naviframe_item_pop(ad->nf);
-                               ad->current_app_state = TG_CHAT_MESSAGING_VIEW_STATE;
-                               /*
-                               elm_naviframe_item_pop(ad->nf);
-                               ad->current_app_state = TG_USER_MAIN_VIEW_STATE;
-                                */
-                               show_loading_popup(ad);
-                               ecore_timer_add(2, on_view_deleteion_requested, ad);
-                       }
-               }
-       } else {
-               show_toast(ad, "Failed to delete user.");
-       }
-#else
-       if (is_success) {
-               if (ad->peer_in_cahtting_data->use_data->peer_id == buddy_id) {
-                       if (ad->buddy_in_cahtting_data && ad->buddy_in_cahtting_data->use_data->user_id.id == buddy_id) {
-                               ad->buddy_in_cahtting_data->use_data->is_deleted = 1;
                                show_toast(ad, "User deleted successfully");
                        }
                }
        } else {
                show_toast(ad, "Failed to delete user.");
        }
-#endif
 }
 
 void on_user_block_response_received(appdata_s *ad, int buddy_id, Eina_Bool is_success)
@@ -154,7 +162,7 @@ void on_user_unblock_response_received(appdata_s *ad, int buddy_id, Eina_Bool is
 
 static void on_userinfo_menu_canceled(void *data, Evas_Object *obj, void *event_info)
 {
-       appdata_s *ad = evas_object_data_get(obj, "app_data");
+       //appdata_s *ad = evas_object_data_get(obj, "app_data");
        Evas_Object *popup = evas_object_data_get(obj, "popup");
        evas_object_del(popup);
 }
@@ -166,7 +174,8 @@ static void on_user_block_ok_selected(void *data, Evas_Object *obj, void *event_
 
        if (ad->peer_in_cahtting_data && ad->peer_in_cahtting_data->use_data) {
                show_loading_popup(ad);
-               if (ad->buddy_in_cahtting_data && ad->buddy_in_cahtting_data->use_data->is_blocked == 1) {
+               peer_with_pic_s  *sel_item = ad->peer_in_cahtting_data;
+               if (get_buddy_block_status(sel_item->use_data->peer_id) == 1) {
                        send_unblock_buddy_request(ad->service_client, ad->peer_in_cahtting_data->use_data->peer_id);
                } else {
                        send_block_buddy_request(ad->service_client, ad->peer_in_cahtting_data->use_data->peer_id);
@@ -186,8 +195,8 @@ static void on_block_selected_cb(appdata_s *ad)
        eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL);
        evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
 
-
-       if (ad->buddy_in_cahtting_data && ad->buddy_in_cahtting_data->use_data->is_blocked == 1) {
+       peer_with_pic_s  *sel_item = ad->peer_in_cahtting_data;
+       if (get_buddy_block_status(sel_item->use_data->peer_id) == 1) {
                elm_object_text_set(popup,"Are you sure want to unblock this contact?");
        } else {
                elm_object_text_set(popup,"Are you sure want to block this contact?");
@@ -222,11 +231,12 @@ static void on_user_delete_ok_selected(void *data, Evas_Object *obj, void *event
        Evas_Object *popup = evas_object_data_get(obj, "popup");
 
        if (ad->peer_in_cahtting_data && ad->peer_in_cahtting_data->use_data) {
-               show_loading_popup(ad);
-
-               if (ad->buddy_in_cahtting_data && ad->buddy_in_cahtting_data->use_data->is_deleted == 1) {
-                       send_add_buddy_request(ad->service_client, ad->peer_in_cahtting_data->use_data->peer_id);
+               peer_with_pic_s  *sel_item = ad->peer_in_cahtting_data;
+               if (get_buddy_delete_status(sel_item->use_data->peer_id) == 1 || get_buddy_unknown_status(sel_item->use_data->peer_id) == 1) {
+                       launch_add_contact_screen(ad);
+                       //send_add_buddy_request(ad->service_client, ad->peer_in_cahtting_data->use_data->peer_id);
                } else {
+                       show_loading_popup(ad);
                        send_delete_buddy_request(ad->service_client, ad->peer_in_cahtting_data->use_data->peer_id);
                }
 
@@ -234,8 +244,6 @@ static void on_user_delete_ok_selected(void *data, Evas_Object *obj, void *event
        evas_object_del(popup);
 }
 
-
-
 static void on_delete_selected_cb(appdata_s *ad)
 {
        Evas_Object *popup, *btn;
@@ -245,16 +253,13 @@ static void on_delete_selected_cb(appdata_s *ad)
        elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
        eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL);
        evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
-
-
-       if (ad->buddy_in_cahtting_data && ad->buddy_in_cahtting_data->use_data->is_deleted == 1) {
+       peer_with_pic_s  *sel_item = ad->peer_in_cahtting_data;
+       if (get_buddy_delete_status(sel_item->use_data->peer_id) == 1 || get_buddy_unknown_status(sel_item->use_data->peer_id) == 1) {
                elm_object_text_set(popup,"Are you sure want to add this contact?");
        } else {
                elm_object_text_set(popup,"Are you sure want to delete this contact?");
        }
 
-
        /* ok button */
        btn = elm_button_add(popup);
        elm_object_style_set(btn, "popup");
@@ -276,8 +281,6 @@ static void on_delete_selected_cb(appdata_s *ad)
        evas_object_show(popup);
 }
 
-
-
 /************************ delete user *****************************/
 
 /************************ Menu Handler ********************/
@@ -310,7 +313,7 @@ void on_user_info_menu_option_selected_cb(void *data, Evas_Object *obj, void *ev
 
                }
 
-       } else if (user_data->peer_type == TGL_PEER_CHAT) {
+       } else {
 
 
        }
@@ -322,38 +325,31 @@ void on_user_info_menu_option_selected_cb(void *data, Evas_Object *obj, void *ev
 }
 
 
-char* on_user_info_menu_group_text_get_cb(void *data, Evas_Object *obj, const char *part)
-{
-       int id = (int) data;
-       if (id == 0) {
-               return strdup("Add member");
-       } else if (id == 1) {
-               return strdup("Edit Name");
-       } else {
-               return strdup("Delete and leave group");
-       }
-}
-
 char* on_user_info_menu_text_get_cb(void *data, Evas_Object *obj, const char *part)
 {
        int id = (int) data;
 
        appdata_s *ad = evas_object_data_get(obj, "app_data");
-
+       peer_with_pic_s  *sel_item = ad->peer_in_cahtting_data;
        if (id == 0) {
-               if (ad && ad->buddy_in_cahtting_data && ad->buddy_in_cahtting_data->use_data->is_blocked == 1) {
-                       return strdup("UnBlock");
-               } else {
-                       return strdup("Block");
+               if (ad && sel_item) {
+                       if (get_buddy_block_status(sel_item->use_data->peer_id) == 1) {
+                               return strdup("UnBlock");
+                       } else {
+                               return strdup("Block");
+                       }
                }
 
        } else {
-               if (ad && ad->buddy_in_cahtting_data && ad->buddy_in_cahtting_data->use_data->is_deleted == 1) {
-                       return strdup("Add");
-               } else {
-                       return strdup("Delete");
+               if (ad && sel_item) {
+                       if (get_buddy_delete_status(sel_item->use_data->peer_id) == 1 || get_buddy_unknown_status(sel_item->use_data->peer_id) == 1) {
+                               return strdup("Add");
+                       } else {
+                               return strdup("Delete");
+                       }
                }
        }
+       return NULL;
 }
 
 void on_user_info_msg_popup_back_cb(void *data, Evas_Object *obj, void *event_info)
@@ -405,17 +401,6 @@ void on_user_info_menu_button_clicked(void *data, Evas_Object *obj, void *event_
                        elm_genlist_item_append(genlist, &itc, (void *) i, NULL, ELM_GENLIST_ITEM_NONE, on_user_info_menu_option_selected_cb, ad);
                }
 
-       } else if (sel_item->use_data->peer_type == TGL_PEER_CHAT) {
-               itc.func.text_get = on_user_info_menu_group_text_get_cb;
-
-               itc.func.content_get = NULL;
-               itc.func.state_get = NULL;
-               itc.func.del = NULL;
-
-               for (i = 0; i < 3; i++) {
-                       elm_genlist_item_append(genlist, &itc, (void *) i, NULL, ELM_GENLIST_ITEM_NONE, on_user_info_menu_option_selected_cb, ad);
-               }
-
        } else {
 
        }
@@ -525,13 +510,18 @@ Evas_Object* on_buddy_phone_info_requested(void *data, Evas_Object *obj, const c
                char* first_text = NULL;
                char buf[512] = {'\0'};
                if (id == 0) {
-                       if (ad->buddy_in_cahtting_data->use_data->phone) {
+                       if (ad->buddy_in_cahtting_data && ad->buddy_in_cahtting_data->use_data->phone) {
                                first_text = ad->buddy_in_cahtting_data->use_data->phone;
                        } else {
-                               first_text = "";
+                               char *phone_no = get_buddy_phone_num_from_id(ad->peer_in_cahtting_data->use_data->peer_id);
+                               if (phone_no) {
+                                       first_text = phone_no;
+                               } else {
+                                       first_text = "";
+                               }
                        }
                } else {
-                       if (ad->buddy_in_cahtting_data->use_data->username && strlen(ad->buddy_in_cahtting_data->use_data->username) > 0 && strstr(ad->buddy_in_cahtting_data->use_data->username, "_null_") == NULL) {
+                       if (ad->buddy_in_cahtting_data && ad->buddy_in_cahtting_data->use_data->username && strlen(ad->buddy_in_cahtting_data->use_data->username) > 0 && strstr(ad->buddy_in_cahtting_data->use_data->username, "_null_") == NULL) {
                                first_text = ad->buddy_in_cahtting_data->use_data->username;
                        } else {
                                first_text = "None";
@@ -671,7 +661,6 @@ void launch_user_info_screen(appdata_s* ad, int peer_id)
                evas_object_hide(settings_info_lbl_bg);
        }
 
-
        Evas_Object* msg_btn = elm_button_add(ad->layout);
        evas_object_size_hint_weight_set(msg_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        evas_object_size_hint_align_set(msg_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
index 52d87f4..fad0368 100644 (file)
@@ -77,8 +77,9 @@ static void launch_contact_picker(appdata_s* ad)
        int ret = app_control_create(&app_control);
 
        app_control_set_operation(app_control, APP_CONTROL_OPERATION_COMPOSE);
-       app_control_set_app_id(app_control, "tizen.messages");
+       //app_control_set_app_id(app_control, "tizen.messages");
        //app_control_add_extra_data(app_control, APP_CONTROL_DATA_TO, recipient);
+       app_control_set_mime(app_control,"text/html");
        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) {
@@ -565,6 +566,18 @@ void on_main_chat_item_selected(void *data, Evas_Object *obj, void *event_info)
                                        break;
                                }
                        }
+
+                       if (ad->buddy_in_cahtting_data == NULL) {
+                               for (int i = 0; i < eina_list_count(ad->unknown_buddy_list); i++) {
+                                       user_data_with_pic_s *item = eina_list_nth(ad->unknown_buddy_list, i);
+                                       user_data_s* user_data = item->use_data;
+
+                                       if (user_data->user_id.id == sel_item->peer_id) {
+                                               ad->buddy_in_cahtting_data = item;
+                                               break;
+                                       }
+                               }
+                       }
                }
 
                for (int i = 0; i < eina_list_count(ad->peer_list); i++) {
@@ -1027,7 +1040,7 @@ void launch_user_main_view_cb(appdata_s* ad)
        ad->is_tg_initilized = EINA_TRUE;
        char edj_path[PATH_MAX] = {0, };
        app_get_resource(TELEGRAM_INIT_VIEW_EDJ, edj_path, (int)PATH_MAX);
-
+       send_request_for_server_connection_status(ad->service_client);
        send_request_for_delete_notifications(ad->service_client);
 
        Evas_Object* scroller = elm_scroller_add(ad->nf);
index d7cdeea..628485c 100644 (file)
@@ -266,7 +266,8 @@ typedef enum state_of_app {
        TG_SET_USERNAME_STATE,
        TG_SET_USER_INFO_STATE,
        TG_SET_CHAT_INFO_STATE,
-       TG_SELECT_BUDDY_VIEW
+       TG_SELECT_BUDDY_VIEW,
+       TG_ADD_CONTACT_STATE
 } state_of_app_s;
 
 enum tgl_typing_status {
@@ -312,6 +313,7 @@ typedef struct user_data {
        Eina_Bool is_selected;
        int is_blocked;
        int is_deleted;
+       int is_unknown;
 } user_data_s;
 
 typedef struct user_data_with_pic {
@@ -365,6 +367,7 @@ typedef struct tg_peer_info {
        int last_seen_time;
        char* photo_path;
        long long photo_id;
+       int is_unknown;
 } tg_peer_info_s;
 
 typedef struct peer_with_pic {
@@ -494,6 +497,7 @@ typedef struct appdata {
        char* phone_number;
        char* sms_code;
        Eina_List* buddy_list;
+       Eina_List* unknown_buddy_list;
        //Eina_List* group_chat_list;
        Eina_List* peer_list;
 
@@ -535,6 +539,7 @@ extern void tg_login_nf_back_cb(void *data, Evas_Object *obj, void *event_info);
 extern void detail_list_nf_back_cb(void *data, Evas_Object *obj, void *event_info);
 extern void create_buddy_msg_table(const char* table_name);
 extern void load_buddy_list_data(appdata_s *ad);
+extern void load_unknown_buddy_list_data(appdata_s *ad);
 //extern void load_group_chat_data(appdata_s *ad);
 extern void load_peer_data(appdata_s *ad);
 extern void load_registered_user_data(appdata_s *ad);
index 8818478..a3037ff 100644 (file)
                                                                </option>
                                                                <option id="gnu.cpp.compiler.option.include.paths.1978545236" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/tg_engine_utils}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/contacts_utils}&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_engine}&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;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/feedback&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="/tg-engine-service/contacts_utils"/>
                                                                </option>
                                                                <option id="sbi.gnu.cpp.compiler.option.frameworks.core.620253534" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs">
                                                                        <listOptionValue builtIn="false" value="Native_API"/>
                                                                </option>
                                                                <option id="gnu.c.compiler.option.include.paths.187162248" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/tg_engine_utils}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/contacts_utils}&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}/mtprotocol}&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;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/feedback&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/tg-engine-service/contacts_utils}&quot;"/>
                                                                </option>
                                                                <option id="sbi.gnu.c.compiler.option.frameworks.core.392684315" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs">
                                                                        <listOptionValue builtIn="false" value="Native_API"/>
                                                                        <listOptionValue builtIn="false" value="-Xlinker --version-script=&quot;${PROJ_PATH}/.exportMap&quot;"/>
                                                                        <listOptionValue builtIn="false" value="-L&quot;${SBI_SYSROOT}/usr/lib&quot;"/>
                                                                        <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/>
-                                                                       <listOptionValue builtIn="false" value="-Xlinker -rpath=&quot;/opt/usr/apps/org.tizen.tg-engine-service/lib&quot;"/>
                                                                </option>
                                                                <option id="gnu.cpp.link.option.paths.1718248047" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths"/>
                                                                <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.269893982" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
                                                </toolChain>
                                        </folderInfo>
                                        <sourceEntries>
+                                               <entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="contacts_utils"/>
                                                <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="db_manager"/>
                                                <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
                                                <entry excluding="tl-parser" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="mtprotocol"/>
  * @brief Connect to database
  * @return true if success, otherwise false
  */
-bool sc_db_utils_connect();
+extern bool sc_db_utils_connect();
 
 /**
  * @brief Disconnect from database
  * @return true if success, otherwise false
  */
-bool sc_db_utils_disconnect();
+extern bool sc_db_utils_disconnect();
 
 /**
  * @brief Check is connected to database
  * @return true if connected, otherwise false
  */
-bool sc_db_utils_is_connected();
+extern bool sc_db_utils_is_connected();
 
 /**
  * @brief Check database error code
@@ -5,10 +5,7 @@
  */
 
 #include "device_contacts_manager.h"
-#include "contacts_common.h"
-#include "contacts-record-utils.h"
-#include "contacts-list-utils.h"
-#include "contacts-db-utils.h"
+#include "logger.h"
 
 bool sc_cdetails_get_contact_val(sc_common_contact_fields field_type, int contact_id, char **value)
 {
 
 #include "tg_common.h"
 #include <contacts.h>
-
-typedef struct contact_data {
-       int contact_id;
-       char* display_name;
-       char* first_name;
-       char* last_name;
-       char* phone_number;
-} contact_data_s;
+#include "contacts_common.h"
+#include "contacts-record-utils.h"
+#include "contacts-list-utils.h"
+#include "contacts-db-utils.h"
 
 extern Eina_List* get_contact_list_from_device_db();
 
index 5648f65..23462f3 100644 (file)
@@ -15,7 +15,7 @@ extern void process_validation_command(tg_engine_data_s *tg_data, char *code);
 extern void process_send_message_command(int buddy_id, int message_id, int msg_type, char* msg_data, int type_of_chat);
 extern void process_marked_as_read_command(int buddy_id, int type_of_chat);
 extern void process_delete_group_chat_request(tg_engine_data_s* tg_data, int chat_id);
-extern void process_add_user_request(tg_engine_data_s* tg_data, int buddy_id);
+extern void process_add_user_request(tg_engine_data_s* tg_data, int buddy_id, char *first_name, char *last_name, char *phone_num);
 extern void process_update_chat_request(tg_engine_data_s* tg_data, int chat_id);
 extern void process_delete_user_request(tg_engine_data_s* tg_data, int buddy_id);
 extern void process_block_user_request(tg_engine_data_s* tg_data, int buddy_id);
@@ -31,9 +31,9 @@ extern void process_remove_buddy_from_chat_command(tg_engine_data_s *tg_data, in
 extern void process_set_group_chat_profile_pic_command(tg_engine_data_s *tg_data, int buddy_id, const char *file_path);
 extern void process_set_username_command(tg_engine_data_s *tg_data, int buddy_id, const char *username);
 
-extern void send_add_contacts_request();
+extern void send_add_contacts_request(tg_engine_data_s *tg_data);
 extern void send_registration_response(tg_engine_data_s *tg_data, Eina_Bool is_success);
-extern void send_name_registration_response();
+extern void send_name_registration_response(tg_engine_data_s *tg_data);
 extern void send_contacts_load_done_response(tg_engine_data_s *tg_data, Eina_Bool is_success);
 extern void send_self_profile_picture_updated_response(tg_engine_data_s *tg_data, char *file_path, Eina_Bool is_success);
 extern void send_self_user_name_updated_response(tg_engine_data_s *tg_data, char *username, Eina_Bool is_success);
index e59ed49..344d75c 100644 (file)
@@ -52,6 +52,7 @@
 #define USER_INFO_TABLE_LAST_SEEN_TIME "last_seen"
 #define USER_INFO_TABLE_IS_BLOCKED "is_blocked"
 #define USER_INFO_TABLE_IS_DELETED "is_deleted"
+#define USER_INFO_TABLE_IS_UNKNOWN_PEER "is_unknown"
 
 #define BUDDY_INFO_TABLE_NAME "buddy_info_table"
 
 #define MEDIA_INFO_TABLE_LAST_NAME "last_name"
 #define MEDIA_INFO_TABLE_FILE_PATH "file_path"
 
-#define MESSAGE_INFO_TABLE_MESSAGE_ROW_ID "msg_row_id"
+//#define MESSAGE_INFO_TABLE_MESSAGE_ROW_ID "msg_row_id"
 #define MESSAGE_INFO_TABLE_MESSAGE_ID "msg_id"
 #define MESSAGE_INFO_TABLE_FLAGS "flags"
 #define MESSAGE_INFO_TABLE_FWD_FROM_ID "fwd_from_id"
@@ -198,15 +199,19 @@ void create_data_base_tables();
 
 Eina_List* get_registered_user_info();
 
-void insert_buddy_into_db(char* table_name, struct tgl_user* U);
+void update_buddy_into_db(char* table_name, struct tgl_user* U);
 
-void update_peer_info_database(tgl_peer_t* UC);
+void init_insert_buddy_into_db(char* table_name, struct tgl_user* U);
+
+void update_peer_info_database(tgl_peer_t* UC, int is_unknown);
 
 void delete_chat_from_db(int peer_id);
 
 void delete_buddy_from_db(int peer_id);
 
-void insert_peer_into_database(tgl_peer_t* UC, int last_msg_id, int unread_count);
+void insert_peer_into_database(tgl_peer_t* UC, int last_msg_id, int unread_count, int is_unknown);
+
+void init_insert_peer_into_database(tgl_peer_t* UC, int last_msg_id, int unread_count, int is_unknown);
 
 void update_buddy_pic_db(char* file_path, char* table_name, int id);
 
@@ -214,11 +219,11 @@ void update_buddy_block_db(char* table_name, int id, int block);
 
 void create_buddy_msg_table(const char* table_name);
 
-void insert_buddy_msg_to_db(struct tgl_message *M);
+Eina_Bool insert_buddy_msg_to_db(struct tgl_message *M);
 
 struct tgl_message* get_message_from_message_table(long long msg_id, char* table_name);
 
-void insert_msg_into_db(struct tgl_message *M, char* table_name, int unique_id);
+Eina_Bool insert_msg_into_db(struct tgl_message *M, char* table_name, int unique_id);
 
 void update_msg_into_db(struct tgl_message *M, char* table_name, int unique_id);
 
index aa138c1..9697ca0 100644 (file)
@@ -1275,8 +1275,12 @@ static int tc_becomes_ready(struct tgl_state *TLS, struct connection *c)
                }
                break;
        default:
+               //sandeep
+               return 0;
+               /*
                vlogprintf(E_DEBUG, "c_state = %d\n", DC->state);
                assert(0);
+               */
        }
        return 0;
 }
index 2f54acf..5d664d7 100644 (file)
@@ -342,6 +342,7 @@ struct tgl_user {
        char *real_first_name;
        char *real_last_name;
        char *username;
+       int is_unknown;
 };
 
 struct tgl_chat_user {
index 61699d8..ce8c7d4 100644 (file)
@@ -71,12 +71,12 @@ void process_delete_group_chat_request(tg_engine_data_s* tg_data, int chat_id)
        leave_group_chat(tg_data, chat_id);
 }
 
-void process_add_user_request(tg_engine_data_s* tg_data, int buddy_id)
+void process_add_user_request(tg_engine_data_s* tg_data, int buddy_id, char *first_name, char *last_name, char *phone_num)
 {
        if (!tgl_engine_get_TLS()) {
                return;
        }
-       do_add_buddy(buddy_id);
+       do_add_buddy(buddy_id, first_name, last_name, phone_num);
 }
 
 void process_update_chat_request(tg_engine_data_s* tg_data, int chat_id)
@@ -283,7 +283,7 @@ void send_response_to_group_chat_updated_response(tg_engine_data_s *tg_data, int
                bundle_free(msg);
        }
 
-       if (bundle_add_str(msg, "command", "reponse_group_chat_updated") != 0) {
+       if (bundle_add_str(msg, "command", "response_group_chat_updated") != 0) {
                ERR("Failed to add data by key to bundle");
                bundle_free(msg);
        }
index d36cd0e..a4a2e8f 100644 (file)
@@ -87,7 +87,16 @@ static int _on_tg_server_msg_received_cb(void *data, bundle *const rec_msg)
        res = bundle_get_str(rec_msg, "buddy_id", &buddy_id_str);
        int buddy_id = atoi(buddy_id_str);
 
-       process_add_user_request(tg_data, buddy_id);
+       char* first_name = NULL;
+       res = bundle_get_str(rec_msg, "first_name", &first_name);
+
+       char* last_name = NULL;
+       res = bundle_get_str(rec_msg, "last_name", &last_name);
+
+       char* phone_number = NULL;
+       res = bundle_get_str(rec_msg, "phone_number", &phone_number);
+
+       process_add_user_request(tg_data, buddy_id, first_name, last_name, phone_number);
     } else if (strcmp(cmd_key_val, "update_chat_info") == 0) {
 
        char* chat_id_str = NULL;
index ec4dde9..2da5346 100644 (file)
@@ -28,6 +28,7 @@ void create_data_base_tables()
        col_names = eina_list_append(col_names, USER_INFO_TABLE_LAST_SEEN_TIME);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_BLOCKED);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_DELETED);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_UNKNOWN_PEER);
 
        Eina_List* col_types = NULL;
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
@@ -46,6 +47,7 @@ void create_data_base_tables()
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
 
        Eina_Bool ret = create_table(table_name, col_names, col_types);
        if(!ret) {
@@ -72,6 +74,7 @@ void create_data_base_tables()
        col_names = eina_list_append(col_names, USER_INFO_TABLE_LAST_SEEN_TIME);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_BLOCKED);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_DELETED);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_UNKNOWN_PEER);
 
        col_types = NULL;
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
@@ -90,6 +93,7 @@ void create_data_base_tables()
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
 
        ret = create_table(table_name, col_names, col_types);
        if(!ret) {
@@ -301,6 +305,7 @@ void create_data_base_tables()
        col_names = eina_list_append(col_names, PEER_INFO_TABLE_LAST_SEEN_TIME);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_PHOTO_PATH);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_PHOTO_ID);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_UNKNOWN_PEER);
 
        col_types = NULL;
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
@@ -314,6 +319,7 @@ void create_data_base_tables()
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
 
        ret = create_table(table_name, col_names, col_types);
        if(!ret) {
@@ -639,7 +645,7 @@ void create_buddy_msg_table(const char* table_name)
        }
        // create user info table
        Eina_List* col_names = NULL;
-       col_names = eina_list_append(col_names, MESSAGE_INFO_TABLE_MESSAGE_ROW_ID);
+       //col_names = eina_list_append(col_names, MESSAGE_INFO_TABLE_MESSAGE_ROW_ID);
        col_names = eina_list_append(col_names, MESSAGE_INFO_TABLE_MESSAGE_ID);
        col_names = eina_list_append(col_names, MESSAGE_INFO_TABLE_FLAGS);
        col_names = eina_list_append(col_names, MESSAGE_INFO_TABLE_FWD_FROM_ID);
@@ -658,8 +664,8 @@ void create_buddy_msg_table(const char* table_name)
        col_names = eina_list_append(col_names, MESSAGE_INFO_TABLE_UNIQUE_ID);
 
        Eina_List* col_types = NULL;
-       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_AUTO_INC_KEY);
-       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       //col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_AUTO_INC_KEY);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
@@ -772,60 +778,10 @@ int insert_current_date_to_table(char* tb_name)
        return -1;
 }
 
-void insert_buddy_msg_to_db(struct tgl_message *M)
+Eina_Bool insert_buddy_msg_to_db(struct tgl_message *M)
 {
        // get user name using id from buddy_info_table
        int t = 0;
-#if 0
-       char* table_name = BUDDY_INFO_TABLE_NAME;
-
-       int user_id = M->from_id.id;
-       char usr_str[50];
-       sprintf(usr_str,"%d",user_id);
-
-       char* where_clause = (char*)malloc(strlen(USER_INFO_TABLE_USER_ID) + strlen(" = ") + strlen(usr_str));
-       strcpy(where_clause, USER_INFO_TABLE_USER_ID);
-       strcat(where_clause, " = ");
-       strcat(where_clause, usr_str);
-
-       Eina_List* col_types = NULL;
-       col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
-
-       Eina_List* col_names = NULL;
-       col_names = eina_list_append(col_names, USER_INFO_TABLE_PHONE_NO);
-
-       Eina_List* vals = get_values_from_table_sync(table_name, col_names, col_types, where_clause);
-       close_database(db);
-
-       char* phone_no = NULL;
-
-       if(!vals) {
-               //("DB error");
-               return;
-       } else {
-               int row_count = eina_list_count(vals);
-
-               for (int i = 0 ; i < row_count ; i++) {
-                       Eina_List* row_vals = eina_list_nth(vals, i);
-                       phone_no = (char*)eina_list_nth(row_vals, 0);
-                       if(!phone_no) {
-                               //("DB Error");
-                               return;
-                       } else {
-                               break;
-                       }
-                       eina_list_free(row_vals);
-               }
-               eina_list_free(vals);
-       }
-
-       if(phone_no) {
-               char* tb_name = get_table_name_from_number(phone_no);
-               insert_msg_into_db(M, tb_name, t);
-               free(tb_name);
-               free(phone_no);
-       }
-#else
        int user_id = 0;
        if (tgl_get_peer_type(M->to_id) == TGL_PEER_USER) {
                user_id = M->from_id.id;
@@ -833,9 +789,9 @@ void insert_buddy_msg_to_db(struct tgl_message *M)
                user_id = M->to_id.id;
        }
        char* tb_name = get_table_name_from_number(user_id);
-       insert_msg_into_db(M, tb_name, t);
+       Eina_Bool ret = insert_msg_into_db(M, tb_name, t);
        free(tb_name);
-#endif
+       return ret;
 }
 
 
@@ -865,7 +821,7 @@ struct tgl_message* get_latest_message_from_message_table(char* table_name)
        col_names = eina_list_append(col_names, MESSAGE_INFO_TABLE_UNIQUE_ID);
 
        Eina_List* col_types = NULL;
-       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
@@ -988,7 +944,7 @@ struct tgl_message* get_latest_message_from_message_table(char* table_name)
 
 
 
-void update_peer_info_database(tgl_peer_t* UC)
+void update_peer_info_database(tgl_peer_t* UC, int is_unknown)
 {
        if (!UC) {
                return;
@@ -1008,6 +964,7 @@ void update_peer_info_database(tgl_peer_t* UC)
        col_names = eina_list_append(col_names, PEER_INFO_TABLE_LAST_SEEN_TIME);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_PHOTO_PATH);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_PHOTO_ID);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_UNKNOWN_PEER);
 
        Eina_List* col_types = NULL;
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
@@ -1021,6 +978,7 @@ void update_peer_info_database(tgl_peer_t* UC)
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
 
        Eina_List* col_values = NULL;
        col_values = eina_list_append(col_values, &(UC->id.id));
@@ -1062,6 +1020,7 @@ void update_peer_info_database(tgl_peer_t* UC)
                photo_id = photo->id;
        }
        col_values = eina_list_append(col_values, &(photo_id));
+       col_values = eina_list_append(col_values, &(is_unknown));
 
        Eina_Bool ret = insert_table(table_name, col_names, col_types,col_values);
        if(!ret) {
@@ -1118,8 +1077,103 @@ void delete_buddy_from_db(int peer_id)
        }
 }
 
+void init_insert_peer_into_database(tgl_peer_t* UC, int last_msg_id, int unread_count, int is_unknown)
+{
+       if (!UC) {
+               return;
+       }
+
+       char* table_name = PEER_INFO_TABLE_NAME;
+       Eina_List* col_names = NULL;
+       col_names = NULL;
+       col_names = eina_list_append(col_names, PEER_INFO_TABLE_CHAT_ID);
+       col_names = eina_list_append(col_names, PEER_INFO_TABLE_PEER_TYPE);
+       col_names = eina_list_append(col_names, PEER_INFO_TABLE_FLAGS);
+       col_names = eina_list_append(col_names, PEER_INFO_TABLE_LAST_MESSAGE_ID);
+       col_names = eina_list_append(col_names, PEER_INFO_TABLE_LAST_MESSAGE_DATE);
+       col_names = eina_list_append(col_names, PEER_INFO_TABLE_PRINT_NAME);
+       col_names = eina_list_append(col_names, PEER_INFO_TABLE_STRUCT_VERSION);
+       col_names = eina_list_append(col_names, PEER_INFO_TABLE_NO_OF_UNREAD_MESSAGES);
+       col_names = eina_list_append(col_names, PEER_INFO_TABLE_LAST_SEEN_TIME);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_PHOTO_PATH);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_PHOTO_ID);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_UNKNOWN_PEER);
+
+       Eina_List* col_types = NULL;
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+
+
+       Eina_List* col_values = NULL;
+       col_values = eina_list_append(col_values, &(UC->id.id));
+       col_values = eina_list_append(col_values, &(UC->id.type));
+       col_values = eina_list_append(col_values, &(UC->flags));
+       char last_msg_id_str[50];
+       sprintf(last_msg_id_str, "%d", last_msg_id);
+       col_values = eina_list_append(col_values, last_msg_id_str);
+
+       // last message date
+       if (UC->last) {
+               col_values = eina_list_append(col_values, &(UC->last->date));
+       } else {
+               int last_msg_date = 0;
+               col_values = eina_list_append(col_values, &(last_msg_date));
+       }
 
-void insert_peer_into_database(tgl_peer_t* UC, int last_msg_id, int unread_count)
+       if (UC->print_name) {
+               col_values = eina_list_append(col_values, UC->print_name);
+       } else {
+               col_values = eina_list_append(col_values, "");
+       }
+
+       col_values = eina_list_append(col_values, &(UC->structure_version));
+
+       col_values = eina_list_append(col_values, &(unread_count));
+
+       if (UC->id.type == TGL_PEER_USER ) {
+               col_values = eina_list_append(col_values, &(UC->user.status.when));
+       } else if (UC->id.type == TGL_PEER_CHAT ) {
+               col_values = eina_list_append(col_values, &(UC->chat.date));
+       } else {
+               int last_seen = 0;
+               col_values = eina_list_append(col_values, &(last_seen));
+       }
+
+       col_values = eina_list_append(col_values, "");
+
+
+
+       struct tgl_photo* photo = &(UC->photo);
+       int photo_id = -1;
+       if (photo) {
+               photo_id = photo->id;
+       }
+       col_values = eina_list_append(col_values, &(photo_id));
+       col_values = eina_list_append(col_values, &(is_unknown));
+
+       Eina_Bool ret = insert_table(table_name, col_names, col_types,col_values);
+       if(!ret) {
+
+       } else {
+
+       }
+       eina_list_free(col_names);
+       eina_list_free(col_types);
+       eina_list_free(col_values);
+}
+
+
+void insert_peer_into_database(tgl_peer_t* UC, int last_msg_id, int unread_count, int is_unknown)
 {
        if (!UC) {
                return;
@@ -1139,6 +1193,7 @@ void insert_peer_into_database(tgl_peer_t* UC, int last_msg_id, int unread_count
        col_names = eina_list_append(col_names, PEER_INFO_TABLE_LAST_SEEN_TIME);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_PHOTO_PATH);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_PHOTO_ID);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_UNKNOWN_PEER);
 
        Eina_List* col_types = NULL;
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
@@ -1152,6 +1207,7 @@ void insert_peer_into_database(tgl_peer_t* UC, int last_msg_id, int unread_count
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
 
 
        Eina_List* col_values = NULL;
@@ -1199,6 +1255,7 @@ void insert_peer_into_database(tgl_peer_t* UC, int last_msg_id, int unread_count
                photo_id = photo->id;
        }
        col_values = eina_list_append(col_values, &(photo_id));
+       col_values = eina_list_append(col_values, &(is_unknown));
 
        Eina_Bool ret = insert_table(table_name, col_names, col_types,col_values);
        if(!ret) {
@@ -1243,7 +1300,7 @@ struct tgl_message* get_message_from_message_table(long long msg_id, char* table
        col_names = eina_list_append(col_names, MESSAGE_INFO_TABLE_UNIQUE_ID);
 
        Eina_List* col_types = NULL;
-       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
@@ -1435,10 +1492,10 @@ struct tgl_message* get_message_from_message_table(long long msg_id, char* table
        return message;
 }
 
-void insert_msg_into_db(struct tgl_message *M, char* table_name, int unique_id)
+Eina_Bool insert_msg_into_db(struct tgl_message *M, char* table_name, int unique_id)
 {
        if(!M) {
-               return;
+               return EINA_FALSE;
        }
 
        Eina_List* col_names = NULL;
@@ -1460,7 +1517,7 @@ void insert_msg_into_db(struct tgl_message *M, char* table_name, int unique_id)
        col_names = eina_list_append(col_names, MESSAGE_INFO_TABLE_UNIQUE_ID);
 
        Eina_List* col_types = NULL;
-       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
@@ -1552,7 +1609,7 @@ void insert_msg_into_db(struct tgl_message *M, char* table_name, int unique_id)
        eina_list_free(col_names);
        eina_list_free(col_types);
        eina_list_free(col_values);
-
+       return ret;
 }
 
 void update_msg_into_db(struct tgl_message *M, char* table_name, int unique_id)
@@ -1582,7 +1639,7 @@ void update_msg_into_db(struct tgl_message *M, char* table_name, int unique_id)
                }
 
                Eina_List* col_types = NULL;
-               col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+               col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
                col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
                col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
                col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
@@ -1723,6 +1780,7 @@ Eina_List* get_registered_user_info()
                col_names = eina_list_append(col_names, USER_INFO_TABLE_USER_NAME);
                col_names = eina_list_append(col_names, USER_INFO_TABLE_ONLINE_STATUS);
                col_names = eina_list_append(col_names, USER_INFO_TABLE_LAST_SEEN_TIME);
+               col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_UNKNOWN_PEER);
 
                Eina_List* col_types = NULL;
                col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
@@ -1739,6 +1797,7 @@ Eina_List* get_registered_user_info()
                col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
                col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
                col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+               col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
 
                user_details = get_values_from_table_sync(table_name, col_names, col_types, NULL);
 
@@ -1800,7 +1859,120 @@ Eina_Bool is_chat_id_already_exists(struct tgl_chat *chat_info)
        return EINA_FALSE;
 }
 
-void insert_buddy_into_db(char* table_name, struct tgl_user* U)
+void init_insert_buddy_into_db(char* table_name, struct tgl_user* U)
+{
+       if(!U) {
+               return;
+       }
+       Eina_List* col_names = NULL;
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_USER_ID);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_PRINT_NAME);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_STRUCTURE_VERSION);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_PHOTO_ID);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_FIRST_NAME);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_LAST_NAME);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_PHONE_NO);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_ACCESS_HASH);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_REAL_FIRST_NAME);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_REAL_LAST_NAME);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_USER_NAME);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_ONLINE_STATUS);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_LAST_SEEN_TIME);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_BLOCKED);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_UNKNOWN_PEER);
+
+       Eina_List* col_types = NULL;
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+
+       Eina_List* col_values = NULL;
+       col_values = eina_list_append(col_values, &(U->id.id));
+       if(U->print_name)
+               col_values = eina_list_append(col_values, U->print_name);
+       else
+               col_values = eina_list_append(col_values, "");
+
+       col_values = eina_list_append(col_values, &(U->structure_version));
+       col_values = eina_list_append(col_values, &(U->photo_id));
+
+       if(U->first_name)
+               col_values = eina_list_append(col_values, U->first_name);
+       else
+               col_values = eina_list_append(col_values, "");
+       if(U->last_name)
+               col_values = eina_list_append(col_values, U->last_name);
+       else
+               col_values = eina_list_append(col_values, "");
+
+       char phone_num[256];
+       if(U->phone) {
+               if (strstr(U->phone, "+") == NULL) {
+                       strcpy(phone_num, "+");
+                       strcat(phone_num, U->phone);
+               } else {
+                       strcpy(phone_num, phone_num);
+               }
+               col_values = eina_list_append(col_values, phone_num);
+       } else {
+               col_values = eina_list_append(col_values, "");
+       }
+
+       col_values = eina_list_append(col_values, &(U->access_hash));
+
+       if(U->real_first_name)
+               col_values = eina_list_append(col_values, U->real_first_name);
+       else
+               col_values = eina_list_append(col_values, "");
+
+       if(U->real_last_name)
+               col_values = eina_list_append(col_values, U->real_last_name);
+       else
+               col_values = eina_list_append(col_values, "");
+
+       if(U->username)
+               col_values = eina_list_append(col_values, U->username);
+       else
+               col_values = eina_list_append(col_values, "");
+
+       col_values = eina_list_append(col_values, &(U->status.online));
+       col_values = eina_list_append(col_values, &(U->status.when));
+       col_values = eina_list_append(col_values, &(U->blocked));
+       col_values = eina_list_append(col_values, &(U->is_unknown));
+
+       Eina_Bool ret = insert_table(table_name, col_names, col_types,col_values);
+       if(!ret) {
+               // already exist. So update the table
+               char* where_clause = NULL;
+               char user_id_str[50];
+               sprintf(user_id_str,"%d",U->id.id);
+               where_clause = (char*)malloc(strlen(USER_INFO_TABLE_USER_ID) + strlen(" = ") + strlen(user_id_str) + 1);
+               strcpy(where_clause, USER_INFO_TABLE_USER_ID);
+               strcat(where_clause, " = ");
+               strcat(where_clause, user_id_str);
+               ret = update_table(table_name, col_names, col_types, col_values, where_clause);
+       } else {
+               // successfully inserted.
+       }
+       eina_list_free(col_names);
+       eina_list_free(col_types);
+       eina_list_free(col_values);
+
+}
+
+void update_buddy_into_db(char* table_name, struct tgl_user* U)
 {
        if(!U) {
                return;
@@ -1822,6 +1994,7 @@ void insert_buddy_into_db(char* table_name, struct tgl_user* U)
        col_names = eina_list_append(col_names, USER_INFO_TABLE_ONLINE_STATUS);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_LAST_SEEN_TIME);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_BLOCKED);
+       //col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_UNKNOWN_PEER);
 
        Eina_List* col_types = NULL;
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
@@ -1839,6 +2012,7 @@ void insert_buddy_into_db(char* table_name, struct tgl_user* U)
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       //col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
 
        Eina_List* col_values = NULL;
        col_values = eina_list_append(col_values, &(U->id.id));
@@ -1860,10 +2034,18 @@ void insert_buddy_into_db(char* table_name, struct tgl_user* U)
        else
                col_values = eina_list_append(col_values, "");
 
-       if(U->phone)
-               col_values = eina_list_append(col_values, U->phone);
-       else
+       char phone_num[256];
+       if(U->phone) {
+               if (strstr(U->phone, "+") == NULL) {
+                       strcpy(phone_num, "+");
+                       strcat(phone_num, U->phone);
+               } else {
+                       strcpy(phone_num, phone_num);
+               }
+               col_values = eina_list_append(col_values, phone_num);
+       } else {
                col_values = eina_list_append(col_values, "");
+       }
 
        col_values = eina_list_append(col_values, &(U->access_hash));
 
@@ -1885,9 +2067,12 @@ void insert_buddy_into_db(char* table_name, struct tgl_user* U)
        col_values = eina_list_append(col_values, &(U->status.online));
        col_values = eina_list_append(col_values, &(U->status.when));
        col_values = eina_list_append(col_values, &(U->blocked));
+       //col_values = eina_list_append(col_values, &(U->is_unknown));
 
+#if 0
        Eina_Bool ret = insert_table(table_name, col_names, col_types,col_values);
        if(!ret) {
+#endif
                // already exist. So update the table
                char* where_clause = NULL;
                char user_id_str[50];
@@ -1896,10 +2081,12 @@ void insert_buddy_into_db(char* table_name, struct tgl_user* U)
                strcpy(where_clause, USER_INFO_TABLE_USER_ID);
                strcat(where_clause, " = ");
                strcat(where_clause, user_id_str);
-               ret = update_table(table_name, col_names, col_types, col_values, where_clause);
+               Eina_Bool ret = update_table(table_name, col_names, col_types, col_values, where_clause);
+#if 0
        } else {
                // successfully inserted.
        }
+#endif
        eina_list_free(col_names);
        eina_list_free(col_types);
        eina_list_free(col_values);
@@ -2350,6 +2537,7 @@ Eina_List* get_buddy_info(int buddy_id)
        col_names = eina_list_append(col_names, USER_INFO_TABLE_USER_NAME);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_ONLINE_STATUS);
        col_names = eina_list_append(col_names, USER_INFO_TABLE_LAST_SEEN_TIME);
+       col_names = eina_list_append(col_names, USER_INFO_TABLE_IS_UNKNOWN_PEER);
 
        Eina_List* col_types = NULL;
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER_PRIMARY_KEY);
@@ -2366,6 +2554,7 @@ Eina_List* get_buddy_info(int buddy_id)
        col_types = eina_list_append(col_types, TG_DB_COLUMN_TEXT);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
        col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
+       col_types = eina_list_append(col_types, TG_DB_COLUMN_INTEGER);
 
        char buddy_id_str[50];
        sprintf(buddy_id_str, "%d", buddy_id);
index ba14574..5f55c8d 100644 (file)
@@ -11,6 +11,7 @@
 #include "tg_db_wrapper.h"
 #include "tgl-fetch.h"
 #include <mime_type.h>
+#include "device_contacts_manager.h"
 
 #define DC_SERIALIZED_MAGIC 0x868aa81d
 #define STATE_FILE_MAGIC 0x28949a93
@@ -510,7 +511,7 @@ void tg_get_string(struct tgl_state *TLS, const char *prompt, int flags, void(*c
        tg_data->get_string = callback;
        tg_data->callback_arg = arg;
        if (strcmp (prompt, "phone number:") == 0) {
-               tg_data->is_first_time_registration = EINA_FALSE;
+               tg_data->is_first_time_registration = EINA_TRUE;
                tg_data->tg_state = TG_ENGINE_STATE_REGISTRATION;
                if (tg_data && tg_data->phone_number) {
                        tg_data->get_string(TLS, tg_data->phone_number, tg_data->callback_arg);
@@ -536,7 +537,7 @@ void tg_get_string(struct tgl_state *TLS, const char *prompt, int flags, void(*c
                if (tg_data->first_name) {
                        tg_data->get_string(TLS, tg_data->first_name, tg_data->callback_arg);
                } else {
-                       send_name_registration_response();
+                       send_name_registration_response(tg_data);
                }
 
        } else if (strcmp (prompt, "Last name:") == 0) {
@@ -556,11 +557,14 @@ void tg_get_string(struct tgl_state *TLS, const char *prompt, int flags, void(*c
 
 void tg_logged_in(struct tgl_state *TLS)
 {
+       tg_engine_data_s *tg_data;
+       tg_data = TLS->callback_data;
        write_auth_file();
        int offline_mode = 0;
        tgl_peer_id_t t_id;
        t_id.id = TLS->our_id;
        t_id.type = TGL_PEER_USER;
+       tg_data->is_first_time_registration = EINA_TRUE;
        tgl_do_get_user_info(TLS, t_id, offline_mode, &on_user_info_loaded, NULL);
 }
 
@@ -780,7 +784,7 @@ void tg_type_in_secret_chat_notification(struct tgl_state *TLS, struct tgl_secre
 void tg_status_notification(struct tgl_state *TLS, struct tgl_user *buddy)
 {
        if (buddy) {
-               insert_buddy_into_db(BUDDY_INFO_TABLE_NAME, buddy);
+               update_buddy_into_db(BUDDY_INFO_TABLE_NAME, buddy);
 
                char *name_of_buddy = NULL;
 
@@ -905,7 +909,7 @@ void tg_user_update(struct tgl_state *TLS, struct tgl_user *buddy, unsigned flag
        }
 
        if (!(flags & TGL_UPDATE_DELETED)) {
-               insert_buddy_into_db(BUDDY_INFO_TABLE_NAME, buddy);
+               update_buddy_into_db(BUDDY_INFO_TABLE_NAME, buddy);
 
                if (flags & TGL_UPDATE_PHONE) {
                        send_message(TLS->callback_data, buddy, "%s phone number updated.", name_of_buddy, name_of_buddy_len);
@@ -1012,7 +1016,7 @@ void on_new_chat_info_received(struct tgl_state *TLS, void *callback_extra, int
        tgl_peer_t* chat_UC = tgl_peer_get(TLS, chat_info->id);
        insert_chat_info_to_db(chat_info, NULL);
        chat_UC->last = M;
-       insert_peer_into_database(chat_UC, 0, 0);
+       insert_peer_into_database(chat_UC, 0, 0, 0);
 
        send_new_group_added_response(tg_data, chat_info->id.id);
 
@@ -1036,7 +1040,7 @@ void on_group_chat_info_updated(struct tgl_state *TLS, void *callback_extra, int
 
        tgl_peer_t* chat_UC = tgl_peer_get(TLS, chat_info->id);
        insert_chat_info_to_db(chat_info, NULL);
-       insert_peer_into_database(chat_UC, 0, 0);
+       insert_peer_into_database(chat_UC, 0, 0, 0);
        send_group_chat_updated_response(tg_data, chat_info->id.id, type_of_change);
        free(type_of_change);
 }
@@ -1068,7 +1072,7 @@ void on_new_chat_pic_loaded(struct tgl_state *TLS, void *callback_extra, int suc
                tgl_peer_t* UC = tgl_peer_get(TLS, M->to_id);
                struct tgl_chat *chat_info = &(UC->chat);
                update_chat_info_to_db(chat_info, filename);
-               update_peer_info_database(UC);
+               update_peer_info_database(UC, 0);
                update_buddy_pic_db(filename, PEER_INFO_TABLE_NAME, chat_info->id.id);
                send_buddy_profile_pic_updated_response(TLS->callback_data, chat_info->id.id, filename);
        }
@@ -1206,7 +1210,7 @@ void on_requested_update_chat_received(struct tgl_state *TLS, void *callback_ext
        //char *type_of_change = strdup("add_user");
        tgl_peer_t* chat_UC = tgl_peer_get(TLS, chat_info->id);
        insert_chat_info_to_db(chat_info, NULL);
-       insert_peer_into_database(chat_UC, 0, 0);
+       insert_peer_into_database(chat_UC, 0, 0, 0);
        send_response_to_group_chat_updated_response(tg_data, chat_info->id.id);
        //free(type_of_change);
 }
@@ -1225,18 +1229,54 @@ void on_new_buddy_info_loaded(struct tgl_state *TLS, void *callback_extra, int s
                return;
        }
        tg_engine_data_s *tg_data = TLS->callback_data;
+       struct tgl_message *M = callback_extra;
        if (U->id.id == tg_data->id.id) {
                return;
        }
        tgl_peer_t* UC = tgl_peer_get(TLS, U->id);
-       insert_peer_into_database(UC, 0, 0);
-       insert_buddy_into_db(BUDDY_INFO_TABLE_NAME, U);
+       insert_peer_into_database(UC, 0, 0, 1);
+       U->is_unknown = 1;
+       init_insert_buddy_into_db(BUDDY_INFO_TABLE_NAME, U);
        struct tgl_photo* pic = &(U->photo);
        if(pic) {
                tgl_do_load_photo(TLS, pic ,&on_buddy_pic_loaded,U);
        }
 
        send_new_buddy_added_response(tg_data, U->id.id);
+
+       if (M) {
+               char* tb_name = get_table_name_from_number(U->id.id);
+               int msg_id = insert_current_date_to_table(tb_name);
+               free(tb_name);
+               if (msg_id > 0) {
+                       send_message_received_response(TLS->callback_data, M->from_id.id, M->to_id.id, msg_id, tgl_get_peer_type(M->to_id));
+
+                       struct tg_temp_msg_data *msg_data = (struct tg_temp_msg_data*)malloc(sizeof(struct tg_temp_msg_data));
+                       msg_data->M = M;
+                       msg_data->TLS = TLS;
+                       msg_data->send_timer = ecore_timer_add(3, on_msg_received_cb, msg_data);
+               } else {
+                       if (M->media.type != tgl_message_media_none && (M->media.document.flags & FLAG_DOCUMENT_AUDIO)) {
+                               M->message = strdup("Audio");
+                               M->message_len = strlen("Audio");
+                       } else if (M->media.type != tgl_message_media_none && (M->media.document.flags & FLAG_DOCUMENT_VIDEO)) {
+                               M->message = strdup("Video");
+                               M->message_len = strlen("Video");
+                       }
+                       insert_buddy_msg_to_db(M);
+                       if(M->media.type != tgl_message_media_none) {
+                               insert_media_info_to_db(M, "");
+                               if (M->media.type != tgl_message_media_none && (M->media.document.flags & FLAG_DOCUMENT_VIDEO)) {
+                                       tgl_do_load_document_thumb(TLS, &(M->media.document), on_video_thumb_loaded, M);
+                                       return;
+                               } else if (M->media.type != tgl_message_media_none && (M->media.document.flags & FLAG_DOCUMENT_AUDIO)) {
+
+                               }
+                       }
+                       // inform to application
+                       send_message_received_response(TLS->callback_data, M->from_id.id, M->to_id.id, M->id, tgl_get_peer_type(M->to_id));
+               }
+       }
 }
 
 void tg_msg_receive(struct tgl_state *TLS, struct tgl_message *M)
@@ -1314,7 +1354,7 @@ void tg_msg_receive(struct tgl_state *TLS, struct tgl_message *M)
                                        tgl_peer_t* lUC = tgl_peer_get(TLS, M->to_id);
                                        struct tgl_chat *chat_info = &(lUC->chat);
                                        update_chat_info_to_db(chat_info, filename);
-                                       update_peer_info_database(lUC);
+                                       update_peer_info_database(lUC, 0);
                                        update_buddy_pic_db(filename, PEER_INFO_TABLE_NAME, chat_info->id.id);
                                        send_buddy_profile_pic_updated_response(TLS->callback_data, chat_info->id.id, filename);
 
@@ -1378,13 +1418,8 @@ void tg_msg_receive(struct tgl_state *TLS, struct tgl_message *M)
                                        M->message_len = 0;
                                }
 
-                               int user_id = 0;
-                               if (tgl_get_peer_type(M->to_id) == TGL_PEER_USER) {
-                                       user_id = M->from_id.id;
-                               } else if (tgl_get_peer_type(M->to_id) == TGL_PEER_CHAT) {
-                                       user_id = M->to_id.id;
-                               }
-
+                               int user_id = M->from_id.id;
+#if 0
                                Eina_Bool is_present_in_db = is_user_present_peer_table(user_id);
                                char* tb_name = get_table_name_from_number(user_id);
                                create_buddy_msg_table(tb_name);
@@ -1392,7 +1427,16 @@ void tg_msg_receive(struct tgl_state *TLS, struct tgl_message *M)
                                        // add to buddy table
                                        tgl_do_get_user_info(TLS, M->from_id, 0, on_new_buddy_info_loaded, NULL);
                                }
-
+#else
+                               char* tb_name = get_table_name_from_number(user_id);
+                               Eina_Bool is_present_in_db = is_user_present_peer_table(user_id);
+                               create_buddy_msg_table(tb_name);
+                               if (!is_present_in_db) {
+                                       tgl_do_get_user_info(TLS, M->from_id, 0, on_new_buddy_info_loaded, M);
+                                       free(tb_name);
+                                       return;
+                               }
+#endif
                                int msg_id = insert_current_date_to_table(tb_name);
                                free(tb_name);
                                if (msg_id > 0) {
@@ -1523,9 +1567,9 @@ void tg_user_status_update(struct tgl_state *TLS, struct tgl_user *U)
                }
 
                if (U->flags & FLAG_USER_SELF) {
-                       insert_buddy_into_db(USER_INFO_TABLE_NAME, U);
+                       update_buddy_into_db(USER_INFO_TABLE_NAME, U);
                } else if (U->flags & FLAG_USER_CONTACT) {
-                       insert_buddy_into_db(BUDDY_INFO_TABLE_NAME, U);
+                       update_buddy_into_db(BUDDY_INFO_TABLE_NAME, U);
 #if 0
                        struct tgl_user_status *S = &(U->status);
 
@@ -1589,7 +1633,7 @@ void on_chat_pic_loaded(struct tgl_state *TLS, void *callback_extra, int success
        if (filename) {
                update_chat_info_to_db(chat_info, filename);
                tgl_peer_t* UC = tgl_peer_get(TLS, chat_info->id);
-               update_peer_info_database(UC);
+               update_peer_info_database(UC, 0);
                update_buddy_pic_db(filename, PEER_INFO_TABLE_NAME, chat_info->id.id);
                send_buddy_profile_pic_updated_response(TLS->callback_data, chat_info->id.id, filename);
        }
@@ -1696,7 +1740,7 @@ void on_buddy_info_loaded(struct tgl_state *TLS, void *callback_extra, int succe
                return;
        }
 
-       //insert_buddy_into_db(BUDDY_INFO_TABLE_NAME, U);
+       //update_buddy_into_db(BUDDY_INFO_TABLE_NAME, U);
        struct tgl_photo* pic = &(U->photo);
        if(pic) {
                tgl_do_load_photo(TLS, pic ,&on_buddy_pic_loaded,U);
@@ -1708,17 +1752,21 @@ void on_contacts_received(struct tgl_state *TLS, void *callback_extra, int succe
        for (int i = size - 1; i >= 0; i--) {
                struct tgl_user *buddy = contacts[i];
 
-               if (buddy->id.id == 777000 || buddy->id.id == 333000) {
-                       continue;
-               }
-
-
                char* msg_table = get_table_name_from_number(buddy->id.id);
                create_buddy_msg_table(msg_table);
                free(msg_table);
 
                //tgl_do_get_user_info(TLS, buddy->id, 0, &on_buddy_info_loaded, NULL);
-               insert_buddy_into_db(BUDDY_INFO_TABLE_NAME, buddy);
+               if (buddy->id.id == 333000 || buddy->id.id == 777000) {
+                       buddy->is_unknown = 1;
+               } else {
+                       buddy->is_unknown = 0;
+               }
+               init_insert_buddy_into_db(BUDDY_INFO_TABLE_NAME, buddy);
+               tgl_peer_t* UC = tgl_peer_get(TLS, buddy->id);
+               if (UC) {
+                       init_insert_peer_into_database(UC, 0, 0, 0);
+               }
        }
 
        // inform client that contact loading is done.
@@ -1736,22 +1784,49 @@ void on_contacts_received(struct tgl_state *TLS, void *callback_extra, int succe
        ecore_timer_add(5, on_send_unsent_messages_requested, TLS);
 }
 
+void on_history_received(struct tgl_state *TLS, void *callback_extra, int success, int size, struct tgl_message *list[])
+{
+       for (int i = 0; i < size; i++) {
+               //struct tgl_message
+               struct tgl_message* message = list[i];
+               if (message->service) {
+                       continue;
+               }
+               Eina_Bool ret = insert_buddy_msg_to_db(message);
+               if (ret) {
+                       tg_msg_receive(s_info.TLS, message);
+               }
+       }
+}
+
+#if 0
+static Eina_Bool on_load_history_requested(void *data)
+{
+       tgl_peer_t* UC = data;
+       tgl_do_get_history(s_info.TLS, UC->id, 15, 0, on_history_received, UC);
+       return ECORE_CALLBACK_CANCEL;
+}
+#endif
+
 void on_contacts_and_chats_loaded(struct tgl_state *TLS, void *callback_extra, int success, int size, tgl_peer_id_t peers[], int last_msg_id[], int unread_count[])
 {
+#if 0
+       int int_cnt = 5;
+#endif
        for (int i = size - 1; i >= 0; i--) {
-               tgl_peer_t* UC;
-               UC = tgl_peer_get(TLS, peers[i]);
+               tgl_peer_t* UC = tgl_peer_get(TLS, peers[i]);
                // insert into peer table
-               insert_peer_into_database(UC, last_msg_id[i], unread_count[i]);
-               //struct tgl_user* buddy;
-               //struct tgl_chat* chat_info;
+               insert_peer_into_database(UC, last_msg_id[i], unread_count[i], 0);
+#if 0
+               int_cnt = int_cnt + 3;
+               ecore_timer_add(int_cnt, on_load_history_requested, UC);
+#endif
                switch (tgl_get_peer_type(peers[i])) {
                        case TGL_PEER_USER:
                                // To-Do
                                break;
                        case TGL_PEER_CHAT:
                                // To-Do
-                               //tgl_do_get_chat_info(TLS, peers[i], 0, &on_chat_info_received, NULL);
                                break;
                        case TGL_PEER_ENCR_CHAT:
                                // To-Do
@@ -1763,6 +1838,32 @@ void on_contacts_and_chats_loaded(struct tgl_state *TLS, void *callback_extra, i
        tgl_do_update_contact_list(TLS, on_contacts_received, NULL);
 }
 
+void add_contacts_to_account(struct tgl_state *TLS)
+{
+       tg_engine_data_s *tg_data = TLS->callback_data;
+       if(sc_db_utils_connect())
+       {
+               Eina_List* contact_list = get_contact_list_from_device_db();
+               sc_db_utils_disconnect();
+
+               if (!contact_list || eina_list_count(contact_list) <= 0) {
+                       // no contacts avilable. empty contact list.
+                       tgl_do_get_dialog_list(TLS, on_contacts_and_chats_loaded, NULL);
+                       if (contact_list) {
+                               eina_list_free(contact_list);
+                       }
+                       return;
+               }
+               int size = eina_list_count(contact_list);
+               if (size > 0) {
+                       add_contacts_to_user(tg_data, size, contact_list);
+               } else {
+                       eina_list_free(contact_list);
+                       tgl_do_get_dialog_list(TLS, on_contacts_and_chats_loaded, NULL);
+               }
+       }
+}
+
 void on_user_info_loaded(struct tgl_state *TLS, void *extra, int success, struct tgl_user *buddy)
 {
        tg_engine_data_s *tg_data = TLS->callback_data;
@@ -1774,12 +1875,13 @@ void on_user_info_loaded(struct tgl_state *TLS, void *extra, int success, struct
        if(pic) {
                tgl_do_load_photo(TLS, pic ,&on_buddy_pic_loaded, buddy);
        }
-
-       insert_buddy_into_db(USER_INFO_TABLE_NAME, buddy);
+       buddy->is_unknown = 0;
+       init_insert_buddy_into_db(USER_INFO_TABLE_NAME, buddy);
 
        if (tg_data->is_first_time_registration) {
                // send contact list to add friends.
-               send_add_contacts_request();
+               //send_add_contacts_request(tg_data);
+               add_contacts_to_account(TLS);
        } else {
                tgl_do_get_dialog_list(TLS, on_contacts_and_chats_loaded, NULL);
        }
@@ -1920,7 +2022,23 @@ void on_contact_added(struct tgl_state *TLS,void *callback_extra, int success, i
                        char *first_name = contact->first_name;
                        char *last_name = contact->last_name;
                        char *phone_number = contact->phone_number;
-                       tgl_do_add_contact(TLS, phone_number, first_name, last_name, 0, on_contact_added, data);
+
+                       if (!first_name) {
+                               first_name = contact->display_name;
+                               if (!first_name) {
+                                       first_name = "";
+                               }
+                       }
+
+                       if (!last_name) {
+                               last_name = "";
+                       }
+
+                       if (first_name && last_name && phone_number) {
+                               tgl_do_add_contact(tgl_engine_get_TLS(), phone_number, first_name, last_name, 0, on_contact_added, data);
+                       } else {
+                               on_contact_added(tgl_engine_get_TLS(), data, 0, 0, NULL);
+                       }
                }
 
        } else {
@@ -2027,8 +2145,7 @@ void on_new_group_created(struct tgl_state *TLS, void *callback_extra, int succe
                                chat_UC->chat.date = M->date;
                                insert_chat_info_to_db(&(chat_UC->chat), NULL);
                                chat_UC->last = M;
-                               insert_peer_into_database(chat_UC, 0, 0);
-
+                               insert_peer_into_database(chat_UC, 0, 0, 0);
 
                                if (tg_data->new_group_icon) {
                                        tgl_peer_t* UC = tgl_peer_get(TLS, M->to_id);
@@ -2246,8 +2363,8 @@ void on_set_username_response_received(struct tgl_state *TLS, void *callback_ext
        char *org_username = callback_extra;
        if (success) {
                // update db
-               insert_buddy_into_db(USER_INFO_TABLE_NAME, buddy);
-               insert_buddy_into_db(BUDDY_INFO_TABLE_NAME, buddy);
+               update_buddy_into_db(USER_INFO_TABLE_NAME, buddy);
+               update_buddy_into_db(BUDDY_INFO_TABLE_NAME, buddy);
                send_self_user_name_updated_response(tg_data, org_username, EINA_TRUE);
        } else {
                send_self_user_name_updated_response(tg_data, org_username, EINA_FALSE);
@@ -2309,7 +2426,23 @@ void add_contacts_to_user(tg_engine_data_s *tg_data, int size, Eina_List* contac
                char *phone_number = contact->phone_number;
 
                tg_data->current_index = 0;
-               tgl_do_add_contact(tgl_engine_get_TLS(), phone_number, first_name, last_name, 0, on_contact_added, tg_data);
+
+               if (!first_name) {
+                       first_name = contact->display_name;
+                       if (!first_name) {
+                               first_name = "";
+                       }
+               }
+
+               if (!last_name) {
+                       last_name = "";
+               }
+
+               if (first_name && last_name && phone_number) {
+                       tgl_do_add_contact(tgl_engine_get_TLS(), phone_number, first_name, last_name, 0, on_contact_added, tg_data);
+               } else {
+                       on_contact_added(tgl_engine_get_TLS(), tg_data, 0, 0, NULL);
+               }
        }
 }
 
@@ -2594,15 +2727,17 @@ void on_buddy_readded(struct tgl_state *TLS,void *callback_extra, int success, i
        }
 }
 
-void do_add_buddy(int buddy_id)
+void do_add_buddy(int buddy_id, char *first_name, char *last_name, char *phone_num)
 {
-       char *first_name = NULL;
-       char *last_name = NULL;
-       char *phone_num = NULL;
-       get_buddy_contact_details_from_db(buddy_id, &first_name, &last_name, &phone_num);
+       if (!first_name) {
+               first_name = "";
+       }
        if (!last_name) {
                last_name = "";
        }
+       if (!phone_num) {
+               phone_num = "";
+       }
 
        if (first_name && last_name && phone_num) {
                tgl_do_add_contact(s_info.TLS, phone_num, first_name, last_name, 0, on_buddy_readded, (void*)(buddy_id));
@@ -2661,7 +2796,43 @@ void leave_group_chat(tg_engine_data_s *tg_data, int group_chat_id)
 
        tgl_do_del_user_from_chat(s_info.TLS, chat_id, self_id, on_group_chat_delete_reponse, (void*)(group_chat_id));
 }
+#if 0
+void on_new_msg_requested_chat_info_received(struct tgl_state *TLS, void *callback_extra, int success, struct tgl_chat *chat_info)
+{
+       tg_engine_data_s *tg_data;
+
+       struct tgl_message *msg = callback_extra;
 
+       char *msg_table;
+
+       if (!chat_info) {
+               return;
+       }
+       if (!chat_info->user_list) {
+               tgl_do_get_chat_info(TLS, chat_info->id, 0, &on_requested_chat_info_received, callback_extra);
+               return;
+       }
+
+       tg_data = TLS->callback_data;
+
+       msg_table = get_table_name_from_number(chat_info->id.id);
+
+       create_buddy_msg_table(msg_table);
+
+       insert_chat_info_to_db(chat_info, NULL);
+       struct tgl_photo *pic = &(chat_info->photo);
+       if(pic) {
+               tgl_do_load_photo(TLS, pic ,&on_chat_pic_loaded,chat_info);
+       }
+
+       tgl_do_send_message(s_info.TLS, msg->to_id, msg->message, strlen(msg->message), &on_message_sent_to_buddy, (void*)(msg));
+
+       char *type_of_change = strdup("add_user");
+       tgl_do_get_chat_info(s_info.TLS, msg->to_id, 0, &on_group_chat_info_updated, type_of_change);
+
+       free(msg_table);
+}
+#endif
 void send_message_to_buddy(int buddy_id, int message_id, int msg_type, char *msg_data, int type_of_chat)
 {
        // get type of chat from buddy_id.
@@ -2676,7 +2847,14 @@ void send_message_to_buddy(int buddy_id, int message_id, int msg_type, char *msg
                } else if (type_of_chat == TGL_PEER_CHAT) {
                        msg->from_id.type = TGL_PEER_CHAT;
                        msg->to_id.type = TGL_PEER_CHAT;
-                       //tgl_do_send_message(s_info.TLS, msg->to_id, msg_data, strlen(msg_data), &on_message_sent_to_buddy, (void*)(msg));
+#if 0
+                       Eina_Bool is_present_in_chat_db = is_user_present_chat_table(msg->to_id.id);
+                       if (!is_present_in_chat_db) {
+                               //sandeep
+                               tgl_do_get_chat_info(s_info.TLS, msg->to_id, 0, &on_new_msg_requested_chat_info_received, msg);
+                               return;
+                       }
+#endif
                        tgl_do_send_message(s_info.TLS, msg->to_id, msg->message, strlen(msg->message), &on_message_sent_to_buddy, (void*)(msg));
                } else if (type_of_chat == TGL_PEER_ENCR_CHAT) {
 
index 8d862b6..0be34c3 100644 (file)
@@ -167,7 +167,7 @@ extern void request_for_code_via_call(struct tgl_state *TLS, char* phone_no, Ein
 extern void free_contact_data(Eina_List *contact_data);
 extern void leave_group_chat(tg_engine_data_s *tg_data, int group_chat_id);
 extern void do_delete_buddy(int buddy_id);
-extern void do_add_buddy(int buddy_id);
+extern void do_add_buddy(int buddy_id, char *first_name, char *last_name, char *phone_num);
 extern void do_update_chat_info(int chat_id);
 extern void do_unblock_buddy(int buddy_id);
 extern void do_block_buddy(int buddy_id);