diff options
Diffstat (limited to 'lib-contact')
145 files changed, 42465 insertions, 0 deletions
diff --git a/lib-contact/CMakeLists.txt b/lib-contact/CMakeLists.txt new file mode 100755 index 0000000..aed78f1 --- /dev/null +++ b/lib-contact/CMakeLists.txt @@ -0,0 +1,9 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +ADD_SUBDIRECTORY(ct-list) +ADD_SUBDIRECTORY(ct-detail) +ADD_SUBDIRECTORY(ct-importer) +ADD_SUBDIRECTORY(ct-tab) +ADD_SUBDIRECTORY(ct-setting) +ADD_SUBDIRECTORY(ct-common) +ADD_SUBDIRECTORY(ct-vcard) diff --git a/lib-contact/ct-common/.cproject b/lib-contact/ct-common/.cproject new file mode 100644 index 0000000..bc8f3e8 --- /dev/null +++ b/lib-contact/ct-common/.cproject @@ -0,0 +1,514 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage"> + <storageModule moduleId="org.eclipse.cdt.core.settings"> + <cconfiguration id="org.tizen.nativecore.config.sbi.gcc45.so.debug.691514410"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.tizen.nativecore.config.sbi.gcc45.so.debug.691514410" moduleId="org.eclipse.cdt.core.settings" name="Debug"> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> + <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + </extensions> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <configuration artifactExtension="a" artifactName="ct-common" buildArtefactType="org.tizen.nativecore.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.staticLib" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.so.debug.691514410" name="Debug" parent="org.tizen.nativecore.config.sbi.gcc45.so.debug"> + <folderInfo id="org.tizen.nativecore.config.sbi.gcc45.so.debug.691514410." name="/" resourcePath=""> + <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.so.debug.2009740696" name="Tizen Core Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.so.debug"> + <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.593145699" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/> + <builder autoBuildTarget="all" buildPath="${workspace_loc:/ct-common}/Debug" enableAutoBuild="true" id="org.tizen.nativecore.target.sbi.gnu.builder.1227963111" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" parallelBuildOn="true" parallelizationNumber="unlimited" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/> + <tool command="i386-linux-gnueabi-ar" id="org.tizen.nativecore.tool.sbi.gnu.archiver.2091423949" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/> + <tool command="i386-linux-gnueabi-g++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.918331842" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler"> + <option id="gnu.cpp.compiler.option.optimization.level.942532901" 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.debugging.level.core.948776940" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/> + <option defaultValue="true" id="sbi.gnu.cpp.compiler.option.misc.pic.core.59936685" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.cpp.compiler.option.701449554" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs"> + <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_gcc45.i386.core.staticLib"/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.1979815518" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath"> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SDK_INSTALL_PATH}/library""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/EGL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/GLES""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/GLES2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/KHR""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.2143900558" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.core" valueType="stringList"> + <listOptionValue builtIn="false" value=""/> + <listOptionValue builtIn="false" value=""/> + <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-fvisibility=hidden"/> + </option> + <option id="gnu.cpp.compiler.option.include.paths.772005435" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc/app-assist}""/> + <listOptionValue builtIn="false" value="../../../app-assist-efl/inc"/> + <listOptionValue builtIn="false" value=""${workspace_loc:/common/inc}""/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks.core.2058635380" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + </option> + <option id="gnu.cpp.compiler.option.preprocessor.def.564170628" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols"> + <listOptionValue builtIn="false" value="_DEBUG"/> + <listOptionValue builtIn="false" value="TIZEN_DEBUG_ENABLE"/> + <listOptionValue builtIn="false" value="_SDK_BUILD"/> + <listOptionValue builtIn="false" value="_CONTACTS_EAS_ENABLE"/> + </option> + <option id="gnu.cpp.compiler.option.other.other.1470101398" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -std=c++0x" valueType="string"/> + <option id="gnu.cpp.compiler.option.dialect.std.1804704199" name="Language standard" superClass="gnu.cpp.compiler.option.dialect.std" value="gnu.cpp.compiler.dialect.default" valueType="enumerated"/> + <inputType id="sbi.gnu.cpp.compiler.tizen.inputType.736036519"/> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1495358801" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool command="i386-linux-gnueabi-gcc" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.571385956" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler"> + <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.396717193" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/> + <option id="sbi.gnu.c.compiler.option.debugging.level.core.678618685" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" value="gnu.c.debugging.level.max" valueType="enumerated"/> + <option defaultValue="true" id="sbi.gnu.c.compiler.option.misc.pic.core.1014425052" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.c.compiler.option.903860821" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs"> + <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_gcc45.i386.core.staticLib"/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.4265944" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath"> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SDK_INSTALL_PATH}/library""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/EGL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/GLES""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/GLES2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/KHR""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.601685425" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.core" valueType="stringList"> + <listOptionValue builtIn="false" value=""/> + <listOptionValue builtIn="false" value=""/> + <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-fvisibility=hidden"/> + </option> + <option id="gnu.c.compiler.option.include.paths.121396318" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks.core.1417547572" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + </option> + <option id="gnu.c.compiler.option.preprocessor.def.symbols.705446393" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols"> + <listOptionValue builtIn="false" value="_DEBUG"/> + </option> + <inputType id="sbi.gnu.c.compiler.tizen.inputType.2081638084"/> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.512521038" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.89477899" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/> + <tool command="i386-linux-gnueabi-g++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.1691048737" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker"> + <option defaultValue="true" id="sbi.gnu.cpp.linker.option.shared_flag.core.578109820" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" valueType="boolean"/> + <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.1819646414" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList"> + <listOptionValue builtIn="false" value=""/> + <listOptionValue builtIn="false" value=""/> + <listOptionValue builtIn="false" value="-lpthread "/> + <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-L"${SBI_SYSROOT}/usr/lib""/> + <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/> + </option> + <option id="gnu.cpp.link.option.paths.2137762097" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lib}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/app-assist-efl/Debug}""/> + </option> + <option id="gnu.cpp.link.option.libs.608169094" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs"> + <listOptionValue builtIn="false" value="app-assist-efl"/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1927193621" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input"> + <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> + <additionalInput kind="additionalinput" paths="$(LIBS)"/> + </inputType> + </tool> + <tool command="i386-linux-gnueabi-as" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.378611956" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1238590231" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + <tool id="org.tizen.nativecore.tool.sbi.po.compiler.320194692" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/> + <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.1877021876" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"/> + <tool id="org.tizen.nativecore.tool.fnmapgen.2098112705" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/> + <tool id="org.tizen.nativecore.tool.fnmapgen.cpp.2145131180" name="C++ FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen.cpp"/> + <tool id="org.tizen.nativecore.tool.ast.1628962850" name="C Static Analyzer" superClass="org.tizen.nativecore.tool.ast"/> + <tool id="org.tizen.nativecore.tool.ast.cpp.54477225" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/> + </toolChain> + </folderInfo> + <sourceEntries> + <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/> + <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/> + </sourceEntries> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> + </cconfiguration> + <cconfiguration id="org.tizen.nativecore.config.sbi.gcc45.so.release.1639123928"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.tizen.nativecore.config.sbi.gcc45.so.release.1639123928" moduleId="org.eclipse.cdt.core.settings" name="Release"> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> + <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + </extensions> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <configuration artifactExtension="so" artifactName="ct-common" buildArtefactType="org.tizen.nativecore.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.sharedLib" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.so.release.1639123928" name="Release" parent="org.tizen.nativecore.config.sbi.gcc45.so.release"> + <folderInfo id="org.tizen.nativecore.config.sbi.gcc45.so.release.1639123928." name="/" resourcePath=""> + <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.so.release.2102909390" name="Tizen Core Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.so.release"> + <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.1362502348" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/> + <builder buildPath="${workspace_loc:/ct-common}/Release" id="org.tizen.nativecore.target.sbi.gnu.builder.1287607123" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/> + <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.334471775" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/> + <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.834073385" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler"> + <option id="gnu.cpp.compiler.option.optimization.level.1336392527" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/> + <option id="sbi.gnu.cpp.compiler.option.debugging.level.core.1705549432" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core"/> + <option defaultValue="true" id="sbi.gnu.cpp.compiler.option.misc.pic.core.1125036502" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.cpp.compiler.option.1373967143" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs"> + <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_llvm34.i386.core.sharedLib"/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.1917199260" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath"> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SDK_INSTALL_PATH}/library""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/EGL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/GLES""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/GLES2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/KHR""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.1589651941" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.core" valueType="stringList"> + <listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain ${SDK_INSTALL_PATH}/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.6/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/> + <listOptionValue builtIn="false" value=""/> + <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-fvisibility=hidden"/> + </option> + <option id="gnu.cpp.compiler.option.include.paths.1853379360" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + <listOptionValue builtIn="false" value="../../../app-assist-efl/inc"/> + <listOptionValue builtIn="false" value=""${workspace_loc:/common/inc}""/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks.core.524243909" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + </option> + <inputType id="sbi.gnu.cpp.compiler.tizen.inputType.82775161"/> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1881458277" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool command="clang" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.1359594252" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler"> + <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.option.optimization.level.1649457629" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/> + <option id="sbi.gnu.c.compiler.option.debugging.level.core.815198694" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core"/> + <option defaultValue="true" id="sbi.gnu.c.compiler.option.misc.pic.core.1848896510" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.c.compiler.option.607900344" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs"> + <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_llvm34.i386.core.sharedLib"/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.780759297" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath"> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SDK_INSTALL_PATH}/library""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/EGL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/GLES""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/GLES2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/KHR""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.1189886472" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.core" valueType="stringList"> + <listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain ${SDK_INSTALL_PATH}/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.6/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/> + <listOptionValue builtIn="false" value=""/> + <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-fvisibility=hidden"/> + </option> + <option id="gnu.c.compiler.option.include.paths.172903393" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks.core.828358636" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + </option> + <inputType id="sbi.gnu.c.compiler.tizen.inputType.1039393934"/> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.464724140" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.702306790" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/> + <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.1789927415" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker"> + <option defaultValue="true" id="sbi.gnu.cpp.linker.option.shared_flag.core.1215854844" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" valueType="boolean"/> + <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.1149968053" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList"> + <listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain ${SDK_INSTALL_PATH}/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.6/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Xlinker --as-needed"/> + <listOptionValue builtIn="false" value=""/> + <listOptionValue builtIn="false" value="-lpthread "/> + <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-L"${SBI_SYSROOT}/usr/lib""/> + <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/> + </option> + <option id="gnu.cpp.link.option.paths.1174321458" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lib}""/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.686023384" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input"> + <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> + <additionalInput kind="additionalinput" paths="$(LIBS)"/> + </inputType> + </tool> + <tool command="i386-linux-gnueabi-as" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.1996200748" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.42292016" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + <tool id="org.tizen.nativecore.tool.sbi.po.compiler.1892569141" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/> + <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.535309428" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"/> + <tool id="org.tizen.nativecore.tool.fnmapgen.1958645038" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/> + <tool id="org.tizen.nativecore.tool.fnmapgen.cpp.869548175" name="C++ FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen.cpp"/> + <tool id="org.tizen.nativecore.tool.ast.21246305" name="C Static Analyzer" superClass="org.tizen.nativecore.tool.ast"/> + <tool id="org.tizen.nativecore.tool.ast.cpp.365678594" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/> + </toolChain> + </folderInfo> + <sourceEntries> + <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/> + <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/> + </sourceEntries> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> + </cconfiguration> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <project id="ct-common.org.tizen.nativecore.target.sbi.gcc45.so.716984208" name="Tizen Core Shared Library" projectType="org.tizen.nativecore.target.sbi.gcc45.so"/> + </storageModule> + <storageModule moduleId="scannerConfiguration"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + <scannerConfigBuildInfo instanceId="org.tizen.nativecore.config.sbi.gcc45.so.release.1639123928"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.tizen.nativecommon.TizenGCCManagedMakePerProjectProfileCPP"/> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="org.tizen.nativecore.config.sbi.gcc45.so.debug.691514410"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.tizen.nativecommon.TizenGCCManagedMakePerProjectProfileCPP"/> + </scannerConfigBuildInfo> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/> + <storageModule moduleId="org.tizen.tizen.nativeapp.projectInfo" version="1.0.0"/> + <storageModule moduleId="refreshScope" versionNumber="2"> + <configuration configurationName="Release"> + <resource resourceType="PROJECT" workspacePath="/ct-common"/> + </configuration> + <configuration configurationName="Debug"> + <resource resourceType="PROJECT" workspacePath="/ct-common"/> + </configuration> + </storageModule> +</cproject> diff --git a/lib-contact/ct-common/.project b/lib-contact/ct-common/.project new file mode 100644 index 0000000..11dbf7c --- /dev/null +++ b/lib-contact/ct-common/.project @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>ct-common</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> + <triggers>full,incremental,</triggers> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.tizen.nativecore.apichecker.core.builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.cdt.core.cnature</nature> + <nature>org.eclipse.cdt.core.ccnature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> + <nature>org.tizen.nativecore.apichecker.core.tizenCppNature</nature> + </natures> + <filteredResources> + <filter> + <id>1413282478425</id> + <name></name> + <type>26</type> + <matcher> + <id>org.eclipse.ui.ide.multiFilter</id> + <arguments>1.0-projectRelativePath-matches-false-false-*/.tpk</arguments> + </matcher> + </filter> + </filteredResources> +</projectDescription> diff --git a/lib-contact/ct-common/.tproject b/lib-contact/ct-common/.tproject new file mode 100644 index 0000000..f1cc1fd --- /dev/null +++ b/lib-contact/ct-common/.tproject @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<tproject xmlns="http://www.tizen.org/tproject"> + <platforms> + <platform> + <name>mobile-2.3</name> + </platform> + </platforms> + <package> + <blacklist/> + </package> +</tproject> diff --git a/lib-contact/ct-common/CMakeLists.txt b/lib-contact/ct-common/CMakeLists.txt new file mode 100755 index 0000000..86000d5 --- /dev/null +++ b/lib-contact/ct-common/CMakeLists.txt @@ -0,0 +1,15 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(ct-common CXX) + +INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/app-assist-efl/inc + ${CMAKE_SOURCE_DIR}/lib-common/inc + ${CMAKE_CURRENT_SOURCE_DIR}/inc +) + +FILE(GLOB SRCS "src/*.cpp") +ADD_LIBRARY(${PROJECT_NAME} STATIC ${SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${TIZEN_PKGS_LDFLAGS} + "app-assist-efl" + "contacts-common" +) diff --git a/lib-contact/ct-common/inc/CtCommon.h b/lib-contact/ct-common/inc/CtCommon.h new file mode 100644 index 0000000..bf9fced --- /dev/null +++ b/lib-contact/ct-common/inc/CtCommon.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_COMMON_H_ +#define _CT_COMMON_H_ + +#include <app.h> +#include <Elementary.h> +#include <contacts.h> +#include <string> + +#include "CtString.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +//#define ELM_SCALE_SIZE(x) (x / elm_app_base_scale_get() * elm_config_scale_get()) + +#define _EDJ(obj) (Evas_Object *)elm_layout_edje_get(obj) + +//App control launch +//void ctCommonTerminateAppservice(Evas_Object *navi); +//void ctCommonResetAppservice(Evas_Object *navi, app_control_h service); +//void ctCommonUnlockUiForAppsvc(Evas_Object *navi); +//int ctCommonServiceSendLaunchRequest(Evas_Object *navi, app_control_h service, app_control_reply_cb callback, void *user_data); +//bool ctCommonIsUiLockedForAppsvc(Evas_Object *navi); + +enum DefaultIconType +{ + LIST_ICON, + DETAIL_ICON +}; + +//utils +char* ctCommonMarkupToUtf8(const char *string); +bool ctCommonCheckDirtyPhoneNumber(const std::string& str); +void ctCommonRemoveNewline(char *src); +Eina_List* ctCommonGetContactsList(int personId); +Eina_List* ctCommonGetWritableContactList(int personId); +void ctCommonDestroyRecordList(Eina_List *list); + +void ctCommonCleanNumber(const char *src, char *dest, int destSize); +int ctCommonCheckUtf8(char c); + +void ctCommonGetProviderNameByAddressbookId(contacts_record_h recordAddressBook, int addressbookId ,char** providerName, char**userName); +bool ctCommonIsValidPerson(const int personId); + +void ctCommonSendSimpleAppControlResult(app_control_h appControl, const char *key, const char *value, app_control_result_e result); + +int ctCommonGetEasDefaultGroupId(int addressbook_id); + +void* ctGetDllHandle(const char* dllName); +int ctCommonGetAddressBookId(char* addressbookName); +char* ctCommonGetAddressBookName(int addressbookId); + +Eina_List* ctCommonGetChekedDuplicatedNumberList(Eina_List *sourceList); +Eina_List* ctCommonGetChekedDuplicatedEmailList(Eina_List *sourceList); + +char *getOtherDirectoryPath(); +std::string createVcardFile(contacts_record_h record); +void sharePerson(int personId, bool isMyProfile); + +#ifdef __cplusplus +} +#endif + +#endif // _CT_COMMON_H_ diff --git a/lib-contact/ct-common/inc/CtPath.h b/lib-contact/ct-common/inc/CtPath.h new file mode 100755 index 0000000..2f1d57c --- /dev/null +++ b/lib-contact/ct-common/inc/CtPath.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __CT_PATH_H_ +#define __CT_PATH_H_ + +#ifndef CTIMGDIR +#define CTIMGDIR "/usr/ug/res/images/ug-phone/contacts" +#endif + +#ifndef CTHDIMGDIR +#define CTHDIMGDIR "/usr/apps/org.tizen.contacts/res/images/contacts" +#endif + +//TODO should not use WVGA images +#define IMAGE_PATH "./contacts/images/WVGA/contact_images/" + +#define HD_IMAGE_PATH "./contacts/images/HD/" + +#define CONTACTS_EDJ "contacts/contacts.edj" +#define LIST_LAYOUT_EDJ "contacts/list.edj" +#define DETAIL_LAYOUT_EDJ "contacts/detail_layout.edj" +#define SETTINGS_LAYOUT_EDJ "contacts/settings_layout.edj" +#define GENLIST_EXTENDED_ITEM_EDJ "contacts/genlist_extended_item.edj" +#define CUSTOM_BUTTON_STYLES_EDJ "common/custom_button_styles.edj" + +#define CT_IMG_LINKED_CONTACT_SIM1 CTIMGDIR"/logs_icon_sim_1_46.png" +#define CT_IMG_LINKED_CONTACT_SIM2 CTIMGDIR"/logs_icon_sim_2_46.png" +#define CT_IMG_LINKED_CONTACT_SIM_MMS CTIMGDIR"/logs_icon_sim_data_46.png" +#define CT_IMG_LINKED_CONTACT_SIM_OFFICE CTIMGDIR"/logs_icon_sim_office_46.png" +#define CT_IMG_LINKED_CONTACT_SIM_PHONE CTIMGDIR"/logs_icon_sim_phone_46.png" +#define CT_IMG_LINKED_CONTACT_SIM_SMS CTIMGDIR"/logs_icon_sim_sms_46.png" +#define CT_IMG_LINKED_CONTACT_SIM_HEART CTIMGDIR"/logs_icon_sim_heart_46.png" +#define CT_IMG_LINKED_CONTACT_SIM_HOME CTIMGDIR"/logs_icon_sim_home_46.png" +#define CT_IMG_LINKED_CONTACT_SIM_INTERNET CTIMGDIR"/logs_icon_sim_internet_46.png" + +#define CT_IMG_ICON_PHONE CTIMGDIR"/C02_icon_phone.png" +#define CT_IMG_ICON_LINKED CTIMGDIR"/contacts_ic_linked.png" +#define CT_IMG_ICON_LINK CTIMGDIR"/contacts_icon_link.png" +#define CT_IMG_ICON_INPUT_DELETE CTIMGDIR"/contacts_icon_delete.png" +#define CT_IMG_ICON_DETAIL_DEFAULT_CALLER_ID CTIMGDIR"/contacts_default_90.png" + +#define CT_IMG_ICON_LIST_DEFAULT_CALLER_ID CTIMGDIR"/contacts_caller_id_default_02.png" +#define CT_IMG_ICON_LIST_DEFAULT_CALLER_ID_BG "contacts_caller_id_default_bg_02.png" +#define CT_IMG_ICON_LIST_IMG_CHROMAKEY_74 CTIMGDIR"/contacts_caller_id_default_masking_02.png" +#define CT_IMG_ICON_LIST_ADD_BUTTON CTHDIMGDIR"/core_floating_icon_01.png" +#define CT_IMG_ICON_DETAIL_CALL CTIMGDIR"/contacts_icon_call.png" +#define CT_IMG_ICON_DETAIL_MESSAGE CTIMGDIR"/contacts_icon_message.png" +#define CT_IMG_ICON_INPUT_DELETE CTIMGDIR"/contacts_icon_delete.png" +#define CT_IMG_ICON_INPUT_DEFAULT_CALLER_ID "contacts_caller_id_default.png" +#define CT_IMG_ICON_INPUT_DEFAULT_CALLER_ID_BG "contacts_caller_id_default_bg.png" +#define CT_IMG_ICON_INPUT_IMG_CHROMAKEY_134 CTIMGDIR"/contacts_caller_id_default_masking.png" +//#define CT_IMG_ICON_DETAIL_FAVORITES CTIMGDIR"/contacts_icon_badgel.png" + +#define CT_IMG_ICON_INPUT_RELATIONSHIP HD_IMAGE_PATH"/contacts_btn_ic_multiple.png" +#define CT_IMG_ICON_INPUT_CALL CTHDIMGDIR"/contacts_circle_btn_ic_call.png" +#define CT_IMG_ICON_INPUT_EMAIL CTHDIMGDIR"/contacts_circle_btn_ic_email.png" +#define CT_IMG_ICON_INPUT_NOTE CTHDIMGDIR"/contacts_circle_btn_ic_note.png" +#define CT_IMG_ICON_INPUT_MORE CTHDIMGDIR"/contacts_circle_btn_ic_more.png" + +#define CT_IMG_ICON_DETAIL_FAVORITES CTIMGDIR"/contacts_icon_favorite.png" + +//HD +#define CT_IMG_ICON_DETAIL_EMAIL CTHDIMGDIR"/contacts_btn_ic_email.png" +#define CT_IMG_ICON_DETAIL_INTERNET CTHDIMGDIR"/contacts_btn_ic_Internet.png" + +#define GROUP_BTN_IC_MULTIPLE "contacts_btn_ic_multiple" + +#endif diff --git a/lib-contact/ct-common/inc/CtProgressBarPopup.h b/lib-contact/ct-common/inc/CtProgressBarPopup.h new file mode 100644 index 0000000..4948373 --- /dev/null +++ b/lib-contact/ct-common/inc/CtProgressBarPopup.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_PROGRESS_BAR_POPUP_H_ +#define _CT_PROGRESS_BAR_POPUP_H_ + +#include "WPopup.h" +#include <string> + + +class CtProgressBarPopup : public WPopup +{ +public: + CtProgressBarPopup(int totalCount, const char* description); + CtProgressBarPopup(int totalCount, const char* description, bool autoUpdate); + + void setProgressRemainCount(int count); + void setProgressStatusCount(int count); + + +private: + virtual Evas_Object* onCreate( Evas_Object* parent, void* viewParam); + virtual void onDestroy(); + Evas_Object* __createContent(Evas_Object *parent); + +private: + CtProgressBarPopup(); + virtual ~CtProgressBarPopup(); + +private: + + int __totalCount; + std::string __description; + Evas_Object* __progressbar; + Evas_Object* __contentLayout; + bool __timerUpdate; + int __remainCount; + int __statusCount; + Ecore_Timer* __timer; + + +}; + + +#endif //_CT_PROGRESS_BAR_POPUP_H_ + diff --git a/lib-contact/ct-common/inc/CtProgressController.h b/lib-contact/ct-common/inc/CtProgressController.h new file mode 100644 index 0000000..1bdecc2 --- /dev/null +++ b/lib-contact/ct-common/inc/CtProgressController.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_PROGRESS_CONTROLLER_H_ +#define _CT_PROGRESS_CONTROLLER_H_ + +#include <functional> +#include <vector> + +#include "IWUiObject.h" +#include "WDefine.h" + +class CtProgressBarPopup; + +class WAPP_ASSIST_EXPORT CtProgressController +{ +public: + + /** + * @brief Get Progress popup + * @return Progress popup + */ + CtProgressBarPopup *getProgressPopup(); + + /** + * @brief Run thread. + */ + void run(); + + /** + * @brief Set End thread callback. + * @param[in] handlerFunc The callback + */ + void setOnFinish(std::function<void(CtProgressController&)> handlerFunc); + +protected: + CtProgressController(const char *title, int totalCount); + virtual ~CtProgressController(); + + bool onProgress(int count); + + virtual void onStart(Ecore_Thread *thread) = 0; + virtual void onCanceled() = 0; + virtual bool onCancel(); + + void cancel(); + void createProgressPopup(const char *title, int totalCount); + +private: + static void onStart(void *data, Ecore_Thread *thread); + static void onFinish(void *data, Ecore_Thread *thread); + static void onCanceled(void *data, Ecore_Thread *thread); + + WDISABLE_COPY_AND_ASSIGN(CtProgressController); + +private: + bool m_Cancel; + std::function<void(CtProgressController&)> m_FinishFunction; + CtProgressBarPopup *m_ProgressPopup; + WUiObjectPtr m_PopupMonitor; + Ecore_Thread *m_Thread; +}; + +#endif // _CT_PROGRESS_CONTROLLER_H_ diff --git a/lib-contact/ct-common/inc/CtRegistryMgr.h b/lib-contact/ct-common/inc/CtRegistryMgr.h new file mode 100644 index 0000000..58b9d6e --- /dev/null +++ b/lib-contact/ct-common/inc/CtRegistryMgr.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _Ct_REGISTRY_MGR_H_ +#define _Ct_REGISTRY_MGR_H_ + + +#include <string> +#include <map> + +#include "WDefine.h" + +//define here all using keys +typedef enum { + REGISTRY_KEY_FAVORITE_UPDATED = 0, + REGISTRY_KEY_INSERTED_PERSON_ID, + REGISTRY_KEY_DELETED_PERSON_ID, + REGISTRY_KEY_INSERTED_PERSON, + REGISTRY_KEY_DELETED_PERSON, + REGISTRY_KEY_MFC_UPDATED, +}ctRegistryKey; + +typedef enum { + REGISTRY_SUCCESS = 0, + REGISTRY_NO_DATA, + REGISTRY_FAIL, +}ctRegistryErr; + +class WAPP_ASSIST_EXPORT CtRegistryMgr +{ +public: + static CtRegistryMgr* getInstance(); + void destroy(); + ctRegistryErr setInt(ctRegistryKey key, int value); + ctRegistryErr setStr(ctRegistryKey key, const char *value); + + ctRegistryErr getInt(ctRegistryKey key, int *value); + ctRegistryErr getStr(ctRegistryKey key, std::string &value); + +private: + typedef struct { + int intValue; + std::string strValue; + } CtRegistryData; + + +private: + CtRegistryMgr(); + virtual ~CtRegistryMgr(); + +private: + static CtRegistryMgr* __instance; + std::map<ctRegistryKey, CtRegistryData*> __registry; + +}; + +#endif /* _Ct_REGISTRY_MGR_H_ */ diff --git a/lib-contact/ct-common/inc/CtString.h b/lib-contact/ct-common/inc/CtString.h new file mode 100755 index 0000000..1b37806 --- /dev/null +++ b/lib-contact/ct-common/inc/CtString.h @@ -0,0 +1,727 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __CT_STRING_H__ +#define __CT_STRING_H__ + +#include <app.h> +#include <Elementary.h> +#include <contacts.h> +#include <string> + +#include "CtString.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include <libintl.h> + +enum { + PHTEXT_KEYPAD, + PHTEXT_FAVORITES, + PHTEXT_SPEEDDIAL, + PHTEXT_VOICE_MAIL, + PHTEXT_LOGS, + PHTEXT_SPEED_DIAL_REQUEST, + PHTEXT_EMERGENCY_CALL, + PHTEXT_NO_LOGS, + PHTEXT_EXCEED_NUM_MAX_LENGTH, + PHTEXT_DELETING_LOGS, + PHTEXT_INITIALIZING, + PHTEXT_INCOMMING_CALL, + PHTEXT_OUTGOING_CALL, + PHTEXT_MISSED_CALL, + PHTEXT_SENT_MESSAGE, + PHTEXT_RECEIVED_MESSAGE, + PHTEXT_REJECTED_CALL_ABB, + PHTEXT_EDIT_NUMBER_BEFORE_CALL, + PHTEXT_SOUND_MODE_SET_TO_SOUND_ABB, + PHTEXT_SOUND_MODE_SET_TO_VIBRATE_ABB, + PHTEXT_ADD_PD_SEC_PAUSE_ABB, + PHTEXT_ALL_LOGS, + PHTEXT_ALL_CALLS_ABB, + PHTEXT_MISSED_CALLS_ABB, + PHTEXT_DIALLED_CALLS, + PHTEXT_RECEIVED_CALLS_ABB, + PHTEXT_REJECTED_CALLS, + PHTEXT_ALL_MESSAGES_M_SMS, + PHTEXT_SET_DIAL_TO_START_SCREEN, + PHTEXT_CALLER_ID_NOTIFICATION, + PHTEXT_CALLER_ID_NON_NOTIFICATION, + PHTEXT_CALLER_ID_DISPLAY, + PHTEXT_CALLER_ID_NOT_DISPLAY, + PHTEXT_INTERNATIONAL_CALL, + PHTEXT_SET_START_UP_SCREEN, + PHTEXT_SET_RECENT_CALLS_TO_START_SCREEN, + PHTEXT_SEARCH_LOCATION, + PHTEXT_VOICE_COURIER, + PHTEXT_VIEW_BY, + PHTEXT_SPEED_DIAL_SETTING, + PHTEXT_CONVERT_INTERNATIONAL_PREFIX, + PHTEXT_IMADOCO_SEARCH, + PHTEXT_IMADOCO_SIMPLE_SEARCH, + PHTEXT_CONNECT_TO_THE_SITE, + PHTEXT_UPDATE_EXISTING, + PHTEXT_EMERGENCY_CONTACTS, + PHTEXT_EMERGENCY_SERVICE, + PHTEXT_MINIMISE, + PHTEXT_UNAVAILABLE, + PHTEXT_PAYPHONE, + PHTEXT_REJECT_BY_USER, + PHTEXT_CONVERT_COUNTRY_CODE, + PHTEXT_SET_VOICEMAIL, + PHTEXT_PLAY_VOICE_MAIL, + PHTEXT_RECORD_KOE_TAKU, + PHTEXT_PLAY_KOE_TAKU, + PHTEXT_KOE_TAKU_LIST, + PHTEXT_KOE_TAKU_SETTING, + PHTEXT_START_VOICE_MAIL, + PHTEXT_STOP_VOICE_MAIL, + PHTEXT_SET_VOICE_MAIL, + PHTEXT_RING_TIME, + PHTEXT_START_CALL_FWD, + PHTEXT_STOP_CALL_FWD, + PHTEXT_SET_CALL_FWD, + PHTEXT_CHECK_SETTING, + PHTEXT_CHECK_OPERATION, + PHTEXT_ROAMING_GUIDE, + PHTEXT_INCOMING_SETTING, + PHTEXT_CALL_SETTING, + PHTEXT_MISSING_VOICEMAIL_NUMBER, + PHTEXT_ADD_NUMBER, + PHTEXT_PIN1_CHANGED, + PHTEXT_PIN2_CHANGED, + PHTEXT_PASSWORDS_DO_NOT_MATCH, + PHTEXT_PUK1_VERIFIED, + PHTEXT_PUK2_VERIFIED, + PHTEXT_PIN1_BLOCKED, + PHTEXT_PIN2_BLOCKED, + PHTEXT_INCORRECT_PUK1_CODE, + PHTEXT_INCORRECT_PUK2_CODE, + PHTEXT_YOUR_PIN_MUST_BE_BETWEEN_P1SD_AND_P2SD_DIGITS_LONG_TRY_AGAIN, + PHTEXT_INCORRECT_PIN1, + PHTEXT_INCORRECT_PIN2, + PHTEXT_CONNECTION_PROBLEM_OR_INVALID_MMI_CODE, + PHTEXT_SELECT_ITEM, + PHTEXT_SIM_CARD_BUSY, + PHTEXT_SIM_CARD_ERROR, + PHTEXT_SIM_BLOCKED, + PHTEXT_SIM_RUIM_CARD_LOCKED, + PHTEXT_SIM_CARD_INITIALISING_ING, + PHTEXT_NO_SIM_CARD_FOUND_PLEASE_INSERT_A_SIM_CARD_INTO_THE_PHONE, + PHTEXT_REJECTION_SETTINGS_ABB, + PHTEXT_VIEW_CONTACT_ABB, + PHTEXT_LOGENTRYUNKNOWN, + PHTEXT_NO_CALLS, + PHTEXT_NO_MISSED_CALLS, + PHTEXT_NO_DIALLED_CALLS, + PHTEXT_NO_RECEIVED_CALLS, + PHTEXT_NO_REJECTED_CALLS, + PHTEXT_NO_MESSAGES, + PHTEXT_CALL_DURATION, + PHTEXT_COPY_TO_DIALLING_SCREEN, + PHTEXT_DIALINPUT_SEND_NUMBER_TMO, + PHTEXT_SENT_MESSAGES, + PHTEXT_RECEIVED_MESSAGES, + PHTEXT_SELECT_SPEED_DIAL_CONTACT_ABB, + PHTEXT_VOICE_CALL, + PHTEXT_ALL_CALLS, + PHTEXT_RECEIVED_CALLS, + PHTEXT_LAST_CALL, + PHTEXT_VIEW_MORE, + PHTEXT_SEARCH_RESULT, + PHTEXT_ADDED_TO_REJECT_LIST, + PHTEXT_REMOVED_FROM_REJECT_LIST, + PHTEXT_UNKNOWN_M_NUMBER, + PHTEXT_RESET, + PHTEXT_MANAGE_REJECT_LIST_IN_CALL_SETTINGS, + PHTEXT_DO_NOT_SHOW_AGAIN, + PHTEXT_ASSIGN, + PHTEXT_ON_ABB, + PHTEXT_OFF_ABB_M_STATUS, + PHTEXT_SPEED_DIAL_SETTINGS_ABB, + PHTEXT_SWAP_SPEED_DIAL_NUMBER_ABB, + PHTEXT_VIEW, + PHTEXT_ENTER_NUMBER, + PHTEXT_SETTING_COMPLETED, + PHTEXT_NO_SPEED_DIAL_NUMBER_ASSIGNED_ASSIGN_NOW_Q, + PHTEXT_SWIPE_TO_CALL_SEND_MESSAGES_ABB, + PHTEXT_UNASSIGNED_M_STATUS_ABB, + PHTEXT_EMERGENCY_SERVICES_NUMBER_ABB, + PHTEXT_COUNTRY_CODES_ABB, + PHTEXT_DOCOMO_WORDING_SEARCH, + PHTEXT_DOCOMO_WORDING_UPDATE_EXISTING, + PHTEXT_DOCOMO_WORDING_CREATE_CONTACT, + PHTEXT_EMERGENCY_CALL_Q, + PHTEXT_ENTER_NUMBER_ABB, + PHTEXT_REMOVED, + PHTEXT_COUNTRY_CODE_NEED, + PHTEXT_REMOVE, + PHTEXT_PRIVATE_NUMBER, + PHTEXT_USE_TOUCH_TONE_KEYPAD, + PHTEXT_RETURN_TO_CALL_IN_PROGRESS, + PHTEXT_ADD_CALL, + PHTEXT_MINI_APPS_CANNOT_BE_OPENED_WHILE_SCREEN_READER_IS_ENABLED_SCREEN_READER_WILL_BE_DISABLED, + PHTEXT_CLOSE_APPLICATION_Q, + PHTEXT_MAXIMUM_NUMBER_OF_REJECT_LISTS_REACHED, + PHTEXT_UNABLE_TO_OPEN_PHONE_IN_MINI_MODE_DURING_CALL_ABB, + PHTEXT_HASH, + PHTEXT_ASTERISK, + PHTEXT_CREATE_CONTACT, + PHTEXT_SPEED_DIAL_ASSIGNED, + PHTEXT_REMOVE_FROM_EMERGENCY_CONTACT_SHORTCUTS_Q, + PHTEXT_UNSAVED_M_NOUN, + PHTEXT_LOGS_HEADER_DELETE_LOG_ITEMS_ABB, + PHTEXT_LOGS_POP_DELETE_THIS_LOG_ITEM_Q, + PHTEXT_LOGS_POP_DELETE_PD_LOG_ITEMS_Q, + PHTEXT_DELETE_LOG_ABB, + PHTEXT_CLOSE_APPLICATION_ABB, + PHTEXT_NO_SPEED_DIAL_ENTRY +}; //PH_GET_TEXT_BASIC + +enum { + PHTEXT_OPEN_PS_PHONE, + PHTEXT_ENTER_THE_NUMBER_YOU_WANT_TO_DIAL, + PHTEXT_TAP_PS_TO_MAKE_A_VOICE_CALL, + PHTEXT_TAP_END_CALL, + PHTEXT_TAP_PS_TO_MAKE_A_VIDEO_CALL, + PHTEXT_NOW_YOU_KNOW_HOW_TO_MAKE_CALLS, + PHTEXT_ENTER_THE_NUMBER_YOU_WANT_TO_SAVE, + PHTEXT_TAP_ADD_TO_CONTACTS, + PHTEXT_ENTER_THE_CONTACT_DETAILS_AND_THEN_TAP_SAVE, + PHTEXT_THE_CONTACT_HAS_BEEN_SAVED, + PHTEXT_SELECT_A_CONTACT_FROM_THE_LIST, + PHTEXT_SELECT_A_SAVING_OPTION, +}; //PH_GET_TEXT_HELP + +enum { + CTTEXT_ALL_CONTACTS, + CTTEXT_NOT_ASSIGNED, + CTTEXT_SDN, + CTTEXT_PHONE, + CTTEXT_GROUP, + CTTEXT_CREATE_CONTACT, + CTTEXT_DEFAULT, + CTTEXT_WEBSITE, + CTTEXT_IM, + CTTEXT_EMAIL, + CTTEXT_NUMBER, + CTTEXT_NOTE, + CTTEXT_POSTAL_ADDRESS, + CTTEXT_DETAILS, + CTTEXT_COMPANY, + CTTEXT_SORT_BY, + CTTEXT_FIRSTNAME, + CTTEXT_LASTNAME, + CTTEXT_MIDDLE, + CTTEXT_SUFFIX, + CTTEXT_NICKNAME, + CTTEXT_SELECT, + CTTEXT_POSTAL_CODE, + CTTEXT_COUNTRY, + CTTEXT_CITY, + CTTEXT_STREET, + CTTEXT_EXPORTED, + CTTEXT_DELETING_CONTACTS, + CTTEXT_REMOVING_CONTACT, + CTTEXT_IMPORTING_SIM_CONTACTS, + CTTEXT_IMPORTING_SD_CONTACTS, + CTTEXT_VCARD_CONTACTS, + CTTEXT_LOADING_VCARD, + CTTEXT_IMPORTED, + CTTEXT_LINKED_CONTACTS, + CTTEXT_MORE_INFORMATION, + CTTEXT_JOB_TITLE, + CTTEXT_DEPARTMENT, + CTTEXT_GROUP_NAME, + CTTEXT_ADD_ACCOUNT, + CTTEXT_ADDING_MEMBERS_TO_GROUP, + CTTEXT_CONTACTS_TO_DISPLAY, + CTTEXT_COUNT_CONTACTS, + CTTEXT_RELATIONSHIP, + CTTEXT_NO_HISTORIES, + CTTEXT_ADDING_ING, + CTTEXT_CUSTOM, + CTTEXT_TEMP_CUSTOM, + CTTEXT_INPUT_TEXT, + CTTEXT_ADDITIONAL_INFO, + CTTEXT_PO_BOX, + CTTEXT_STATE, + CTTEXT_FRIENDS, + CTTEXT_FAMILY, + CTTEXT_CO_WORKERS, + CTTEXT_EMERGENCY_CONTACTS, + CTTEXT_VIBRATIONS, + CTTEXT_SET_AS_DEFAULT, + CTTEXT_EVENT, + CTTEXT_1_CONTACT, + CTTEXT_WI_FI_DIRECT, + CTTEXT_EXPORT_TO_SIM_CARD, + CTTEXT_ACTIVITIES, + CTTEXT_GROUP_MESSAGE, + CTTEXT_GROUP_EMAIL, + CTTEXT_HOURS_AGO, + CTTEXT_MINUTE_AGO, + CTTEXT_REMOVE_Q, + CTTEXT_INSTANT_MESSENGER, + CTTEXT_GIVEN_NAME_FIRST, + CTTEXT_FAMILY_NAME_FIRST, + CTTEXT_DISPLAY_CONTACT, + CTTEXT_YANDEX_SEARCH, + CTTEXT_YANDEX_SEARCH_HPD, + CTTEXT_ONLY_CONTACTS_WITH_PHONES, + CTTEXT_DISPLAY_NAMES_BY, + CTTEXT_MOST_FREQUENT_CONTACTS, + CTTEXT_PHONETIC_LAST_NAME, + CTTEXT_PHONETIC_MIDDLE_NAME, + CTTEXT_PHONETIC_FIRST_NAME, + CTTEXT_PHONETIC_NAME, + CTTEXT_MAPS, + CTTEXT_EXPORT, + CTTEXT_IMPORT, + CTTEXT_DOCOMO_PHONEBOOK_JPN_DCM, + CTTEXT_MY_NUMBER_JPN_DCM, + CTTEXT_NTT_DOCOMO_INC_JPN_DCM, + CTTEXT_NUMBER_OF_REGISTERED_DATA_IN_PHONEBOOK_JPN_DCM, + CTTEXT_PDDATA_JPN_DCM, + CTTEXT_UNABLE_TO_DO_THIS_ACTION_NOT_ENOUGH_MEMORY_JPN_DCM, + CTTEXT_TURNED_INTERNATIONAL_USE_SETTING_OFF_BECAUSE_YOU_MOVED_ABROAD_MSG_JPN_DCM, + CTTEXT_EDITING_DATA_IS_DISCARDED_BECAUSE_CONTACTS_DATA_IS_ALTERED_JPN_DCM, + CTTEXT_MY_PROFILE_JPN_DCM, + CTTEXT_VERSION, //not use + CTTEXT_APPLICATION_NAME, + CTTEXT_HELP, + CTTEXT_CLOUD_MENU, + CTTEXT_OTHER_SETTINGS_JPN_DCM, //no STMS word. + CTTEXT_ABOUT_JPN_DCM, //no STMS word. + CTTEXT_PROVIDER_JPN_DCM, //no STMS word. + CTTEXT_PREFIX, + CTTEXT_ADDED_TO_HOME_SCREEN, + CTTEXT_GROUP_INDEX, + CTTEXT_UNABLE_TO_SAVE_NO_PHONE_NUMBER_ENTERED_FOR_EMERGENCY_CONTACT, + CTTEXT_ONLY_CONTACTS_WITH_PHONES_DESCRIPTION_MSG, + CTTEXT_WELCOME_TO_THE_CONTACTS_DASHBOARD, //UI + CTTEXT_ADD_YOUR_FAVOURITE_CONTACTS_TO_THE_DASHBOARD, + CTTEXT_SAVE_GROUP_TO, + CTTEXT_RECOMMENDED, + CTTEXT_SET_DEFAULT_NAME, + CTTEXT_MERGE_WITH_SAMSUNG_ACCOUNT, + CTTEXT_YOUR_FREQUENT_CONTACTS_WILL_BE_DISPLAYED_ON_THE_DASHBOARD, + CTTEXT_VCARD_ADDED_TO_CONTACTS, + CTTEXT_COPY_TO_CLIPBOARD, + CTTEXT_DEVICE, + CTTEXT_SD_CARD, + CTTEXT_TO_SIGN_IN_TO_YOUR_SAMSUNG_ACCOUNT_OR_CREATE_AN_ACCOUNT_TAP_CONTINUE, + CTTEXT_DISPLAY_CONTACTS_IN_SETTINGS, + CTTEXT_IMPORT_CONTACTS_FROM, + CTTEXT_EXPORT_CONTACTS_TO, + CTTEXT_BODY_NUMBER_M_PHONE, + CTTEXT_BODY_CALL_T_APPLICATIONSETTINGS, + CTTEXT_HEADER_SELECT_GROUP, + CTTEXT_BODY_SERVICE_NUMBERS, + CTTEXT_HEADER_SELECT_NUMBER, + CTTEXT_HEADER_SELECT_ITEM, + CTTEXT_ITAB_RECENT, + CTTEXT_MESSAGE_ALERT, + CTTEXT_FILE_TRANSFER, + CTTEXT_CONTACTS, + CTTEXT_PB_BODY_CHAT, + CTTEXT_PB_BODY_GALLERY, + CTTEXT_COM_BODY_RECORD_VIDEO, + CTTEXT_COM_BODY_MY_FILES, + CTTEXT_COM_BODY_CALENDAR, + CTTEXT_UNSELECT_ALL, + CTTEXT_BUTTON_T_TTS, + CTTEXT_EDITFIELD, + CTTEXT_DOUBLE_TAP_TO_OPEN_THE_LIST_T_TTS, + CTTEXT_SEND_ALL_NAMECARDS, + CTTEXT_SEND_INDIVIDUAL_NAMECARDS, + CTTEXT_EMPTY_SLOT_T_TTS, + CTTEXT_RECORD_SOUND, + CTTEXT_UNFAVOURITE_T_TTS, + CTTEXT_SEND_MESSAGE, + CTTEXT_SEND_EMAIL, + CTTEXT_SEND_MESSAGE_EMAIL, + CTTEXT_ACCOUNT, + CTTEXT_WHEN_YOU_TRANSFER_HELP_MSG, + CTTEXT_DELETE_CONTACT, + CTTEXT_CONTACT_SHARING_SETTINGS, + CTTEXT_GROUP_AND_GROUP_MEMBERS, + CTTEXT_GROUP_ONLY, + CTTEXT_CONTACT_PHOTO, + CTTEXT_ADD_PHOTO, + CTTEXT_REMOVE_FROM_FAVOURITES, + CTTEXT_MERGED, + CTTEXT_LINKED, + CTTEXT_CREATE, + CTTEXT_DISCARD_CHANGES_Q, + CTTEXT_SAMSUNG_ACCOUNT, + CTTEXT_TAKE_PICTURE, + CTTEXT_IMAGE, + CTTEXT_EMAIL_ADDRESS, + CTTEXT_PHONE_NUMBER, + CTTEXT_YOUR_DEVICE_CONTACTS_WILL_BE_MERGED_WITH_CONTACTS_FROM_YOUR_SAMSUNG_ACCOUNT, + CTTEXT_REORDER, + CTTEXT_AFTER_YOU_CREATE_CONTACTS_CONTACTS_WILL_BE_SHOWN_HERE, + CTTEXT_CLEAR_ALL, + CTTEXT_PROCESSING, + CTTEXT_ADD_CALLER_ID_Q, + CTTEXT_PICTURES_BY_PEOPLE, + CTTEXT_IMPORTING_PS_CANCELLED, + CTTEXT_TAB_LOGS, + CTTEXT_THIS_GROUP_WILL_BE_DELETED_ONE, + CTTEXT_THIS_GROUP_WILL_BE_DELETED_MANY, + CTTEXT_DELETE_GROUP_AND_DELETE_ALL_OF_ITS_MEMBERS_FROM_CONTACTS_Q, + CTTEXT_DELETE_PD_GROUPS_AND_DELETE_ALL_OF_THEIR_MEMBERS_FROM_CONTACTS_Q, + CTTEXT_SOME_INFORMATION_MIGHT_BE_LOST_CONTINUE_Q, + CTTEXT_GROUP_PHOTO, + CTTEXT_ADDRESS, + CTTEXT_EXPAND_BUTTON_T_TTS, + CTTEXT_ADD_ALL_CONTACTS, + CTTEXT_EDIT_FAVOURITES, + CTTEXT_MY_CONTACTS, + CTTEXT_BUSINESS_CARD_RECOGNITION_ABB, + CTTEXT_PHONE_ABB, + CTTEXT_DISCARD, + CTTEXT_ABCDEFGHIJKLMNOPQRSTUVWXYZ, + CTTEXT_REMOVE_MEMBER, + CTTEXT_FAVOURITE_CONTACTS, + CTTEXT_DELETE_CONTACTS, + CTTEXT_CONTACT_SAVED, + CTTEXT_DISPLAY_MAP_DCM, + CTTEXT_ADDRESS_ICONICIER_DCM, + CTTEXT_MEMO_ICONICIER_DCM, + CTTEXT_SITE_ICONICIER_DCM, + CTTEXT_SIM_CARD_DCM, + CTTEXT_CLOUD_DCM, + CTTEXT_APROACH_ANNOUNCEMENT, + CTTEXT_NEW_CONTACT_WILL_BE_SAVED_TO_CONTACTS_ON_DEVICE, + CTTEXT_NO_FAVOURITES, + CTTEXT_P1SS_IS_DISABLED_IN_THIS_APPLICATION_TO_ENABLE_THIS_FUNCTION_MSG, + CTTEXT_MAXIMUM_NUMBER_OF_RECIPIENTS_HPD_REACHED, + CTTEXT_UP_TO_PD_ITEMS_CAN_BE_SELECTED, + CTTEXT_YOUR_FREQUENTLY_USED_CONTACTS_WILL_BE_DISPLAYED_IN_YOUR_FAVOURITES, + CTTEXT_REMOVING_MEMBERS_FROM_GROUP_ING, + CTTEXT_DELETE_GROUP, + CTTEXT_CONTACTS_IN_PS, + CTTEXT_MY_PROFILE_SAVED, + CTTEXT_EXPORTED_TO_PS, + CTTEXT_FREQUENTLY_USED_CONTACTS_CANNOT_BE_REORDERED, + CTTEXT_FREQUENT_CONTACTS_ABB, + CTTEXT_PAGE_PD_OF_PD, + CTTEXT_TTS_RADIO_BUTTON, + CTTEXT_TTS_SELECTED, + CTTEXT_TTS_DESELECTED, + CTTEXT_BODY_DAY, + CTTEXT_BODY_MONTH, + CTTEXT_BODY_YEAR, + CTTEXT_TAB_T_TTS, + CTTEXT_SIM_1, + CTTEXT_SIM_2, + CTTEXT_REMOVE_FROM_PS_Q, + CTTEXT_DOUBLE_TAP_TO_ADD_IMAGE, + CTTEXT_AFTER_YOU_ADD_CONTACTS_TO_FAVOURITES_THEY_WILL_BE_SHOWN_HERE, + CTTEXT_GRID_VIEW, + CTTEXT_LIST_VIEW, + CTTEXT_SWIPE_TO_CALL_SEND_MSGS, + CTTEXT_SERVER_IS_NOT_RESPONDING, + CTTEXT_NETWORK_ERROR, + CTTEXT_TAP_TO_ADD_A_NEW_BUSINESS_CARD, + CTTEXT_AFTER_YOU_ADD_BUSINESS_CARDS_THEY_WILL_BE_SHOWN_HERE, + CTTEXT_CHANGE_CONTACT_PICTURE, + CTTEXT_DATE_OLDEST, + CTTEXT_DATE_MOST_RECENT, + CTTEXT_CHANGING_THE_CONTACT_PICTURE_WILL_DELETE_THE_IMAGE_OF_THE_SCANNED_BUSINESS_CARD, + CTTEXT_NO_BUSINESS_CARDS, + CTTEXT_BUSINESS_CARDS, + CTTEXT_SORT, + CTTEXT_EXPORTING_CONTACTS, + CTTEXT_EXPORTING_CONTACTS_ING, + CTTEXT_PRIMARY_CONTACTS, + CTTEXT_CREATE_PRIMARY_CONTACT_ABB, + CTTEXT_SELECT_FROM_CONTACTS, + CTTEXT_DELETE_THIS_CONTACT_Q, + CTTEXT_DELETE_PD_GROUPS_Q, + CTTEXT_DELETE_THIS_GROUP_Q, + CTTEXT_SELECT_PD_OR_MORE_CONTACTS_TO_LINK, + CTTEXT_UNABLE_TO_ADD_CONTACTS, + CTTEXT_ADD_TO_FAVOURITES_INDICATOR, + CTTEXT_REMOVE_FROM_FAVOURITES_INDICATOR, + CTTEXT_DELETE_BUSINESS_CARDS, + CTTEXT_DELETE_BUSINESS_CARD, + CTTEXT_DELETE_BUSINESS_CARD_Q, + CTTEXT_ON_OFF_BUTTON, + CTTEXT_NOTIFICATION, + CTTEXT_DELETE_GROUPS, + CTTEXT_UNABLE_TO_ADD_MORE_ITEMS, + CTTEXT_UNABLE_TO_SELECT_MORE_ITEMS_ABB, + CTTEXT_DELETING_THESE_BUSINESS_CARDS, + CTTEXT_DELETING_THIS_BUSINESS_CARD, + CTTEXT_UNKNOWN, + CTTEXT_SETTINGS, +}; //CT_GET_TEXT_BASIC +enum { + CTTEXT_TAP_ADD_TO_CONTACTS, + CTTEXT_ENTER_THE_CONTACT_DETAILS_AND_THEN_TAP_SAVE, + CTTEXT_THE_CONTACT_HAS_BEEN_SAVED, + CTTEXT_SELECT_A_CONTACT_FROM_THE_LIST, + CTTEXT_TAP_TO_CREATE_A_NEW_CONTACT, + CTTEXT_AFTER_YOU_MAKE_RECEIVE_CALLS_AND_SEND_RECEIVE_MESSAGES_OR_EMAILS_THE_LOGS_WILL_BE_SHOWN_HERE, + CTTEXT_SELECT_THE_CONTACTS_YOU_WANT_TO_ADD, + CTTEXT_TAP_ADD, + CTTEXT_TAP_ON_THE_AREA_INDICATED, + CTTEXT_ENTER_THE_CONTACT_DETAILS_THEN_TAP_SAVE, + CTTEXT_CONTACT_SAVED_HELP, + CTTEXT_FLICK_LEFT_OR_RIGHT_TO_CHANGE_PAGE, + CTTEXT_FLICK_UP_TO_SHRINK, + CTTEXT_FLICK_DOWN_TO_EXPAND, + CTTEXT_TAP_AND_HOLD_TO_ENTER_EDIT_MODE, + CTTEXT_TUTORIAL_COMPLETE, + CTTEXT_ADD_CONTACTS_TO_FAVOURITES, + CTTEXT_YOU_HAVE_SUCCESSFULLY_ADDED_THE_CONTACT_TO_YOUR_FAVOURITES, + CTTEXT_THE_LAST_SIZE_CHOSEN_WILL_BE_USED_IN_FAVOURITES, + CTTEXT_TAP_AND_HOLD_FAVOURITES_TO_REORDER_THEM, + CTTEXT_EDITING_FAVOURITES_ABB, + CTTEXT_TAP_ANYWHERE_OUTSIDE_OF_THE_FAVOURITES_AREA_TO_EXIT_EDIT_MODE, + CTTEXT_SELECT_PS, + CTTEXT_TAP_TO_REMOVE_A_FAVOURITE, + CTTEXT_FAVOURITES_IS_ONLY_AVAILABLE_IN_PORTRAIT_MODE, + CTTEXT_PRESS_THE_MENU_KEY, + CTTEXT_ADD_TO_FAVOURITES_HELP, + CTTEXT_PRESS_THE_MENU_KEY_THEN_SELECT_EDIT, +}; //CT_GET_TEXT_HELP + +enum { + CTTEXT_INVALID_EMAIL, + CTTEXT_SAVE_FAIL, + CTTEXT_ERR_DB_LOCKED, + CTTEXT_ALREADY_EXIST, + CTTEXT_NO_GROUP, + CTTEXT_NO_NUMBER, + CTTEXT_NO_EMAIL, + CTTEXT_NO_CONTACTS, + CTTEXT_IMPORT_SIM_NO_DATA, + CTTEXT_EXCEED_LIMIT, + CTTEXT_SIM_MEMORY_FULL, + CTTEXT_NO_CONTACTS_HELP_TEXT, + CTTEXT_NO_HISTORIES_HELP_TEXT, + CTTEXT_UNABLE_TO_SEND_NAME_CARDS, + CTTEXT_NONE, + CTTEXT_NO_RESULTS_FOUND, + CTTEXT_NO_CONTACTS_GROUP_HELP_TEXT, +};//CT_GET_TEXT_ERR + +enum { + PHTEXT_SELECT_LOGS, + PHTEXT_SELECT_SPEED_DIAL_CONTACTS, + PHTEXT_UNBLOCK, + PHTEXT_CHANGE_CONTACT, + PHTEXT_ADD_PAUSE, + PHTEXT_ADD_WAIT, + PHTEXT_EXIT, +}; // PH_GET_TEXT_BASE_OP + +enum { + PHTEXT_BODY_SUNDAY, + PHTEXT_BODY_MONDAY, + PHTEXT_BODY_TUESDAY, + PHTEXT_BODY_WEDNESDAY, + PHTEXT_BODY_THURSDAY, + PHTEXT_BODY_FRIDAY, + PHTEXT_BODY_SATURDAY, +}; // PH_GET_TEXT_DAY + +enum { + CTTEXT_SET_DEFAULT_NUMBER, + CTTEXT_SET_DEFAULT_EMAIL, + CTTEXT_TAKE_A_PHOTO, + CTTEXT_ADD_TO_HOME, + CTTEXT_SAVE_CONTACT_TO, + CTTEXT_SAVE_TO, + CTTEXT_IMPORT_SIM_CONTACTS, + CTTEXT_GIVEN_NAME, + CTTEXT_FAMILY_NAME, + CTTEXT_SHOW, + CTTEXT_HIDE, + CTTEXT_CREATE_GROUP, + CTTEXT_EXPORT_CONTACTS, + CTTEXT_IMPORT_CONTACTS, + CTTEXT_LINK_CONTACT, + CTTEXT_LINK_CONTACTS, + CTTEXT_UNLINK_CONTACT, + CTTEXT_ALL_LINKED_CONTACTS_WILL_BE_DELETED, + CTTEXT_ADD_TO_FAVOURITES,//UI + CTTEXT_EDIT_GROUP,//UI + CTTEXT_ADD_MEMBER, + CTTEXT_GO_TO_FACEBOOK, + CTTEXT_SHARE, + CTTEXT_SAVE_CONTACT_Q, + CTTEXT_REMOVE, + CTTEXT_DELETING_SYNC_CONTACT_DELETE_MSG, + CTTEXT_DELETING_LINKED_SYNC_CONTACT_DELETE_MSG, + CTTEXT_CONTACT_INCLUDED_READ_ONLY_ACCOUNTS_NOTDELETED_BUT_HIDDEN_MSG, + CTTEXT_ALL_JOINED_CONTACTS_WILL_BE_DELETED, + CTTEXT_DELETING_THIS_BUSINESS_CARD_WILL_DELETE_THE_CONTACTS_LINKED_TO_IT_DELETE_Q, + CTTEXT_DELETE_PD_CONTACTS_Q, + CTTEXT_DELETE, +}; //CT_GET_TEXT_BASE_OP + +enum { + CTTEXT_REL_NONE, + CTTEXT_REL_ASSISTANT,// + CTTEXT_REL_BROTHER, + CTTEXT_REL_CHILD, + CTTEXT_REL_DOMESTIC_PARTNER, + CTTEXT_REL_FATHER, + CTTEXT_REL_FRIEND, + CTTEXT_REL_MANAGER,// + CTTEXT_REL_MOTHER, + CTTEXT_REL_PARENT, + CTTEXT_REL_PARTNER, + CTTEXT_REL_REFERRED_BY, + CTTEXT_REL_RELATIVE, + CTTEXT_REL_SISTER, + CTTEXT_REL_SPOUSE, + CTTEXT_REL_CUSTOM, + CTTEXT_REL_ASSISTANT_JPN, +}; //CT_GET_TEXT_RELATIONSHIP_TYPE +#if 0 +enum { + CTTEXT_EMAIL_TYPE_OTHER, + CTTEXT_EMAIL_TYPE_CUSTOM, + CTTEXT_EMAIL_TYPE_HOME, + CTTEXT_EMAIL_TYPE_WORK, + CTTEXT_EMAIL_TYPE_MOBILE, +}; + +enum { + CTTEXT_ADDRESS_TYPE_OTHER, + CTTEXT_ADDRESS_TYPE_CUSTOM, + CTTEXT_ADDRESS_TYPE_HOME, + CTTEXT_ADDRESS_TYPE_WORK, +}; + +enum { + CTTEXT_WEBSITE_TYPE_OTHER, + CTTEXT_WEBSITE_TYPE_CUSTOM, + CTTEXT_WEBSITE_TYPE_HOME, + CTTEXT_WEBSITE_TYPE_WORK, +}; +#endif + +enum { + PH_GET_TEXT_BASIC, + PH_GET_TEXT_BASE_OP, + PH_GET_TEXT_DAY, + CT_GET_TEXT_BASIC, + CT_GET_TEXT_ERR, + CT_GET_TEXT_BASE_OP, + CT_GET_TEXT_NUM_TYPE, + CT_GET_TEXT_EMAIL_TYPE, + CT_GET_TEXT_WEBSITE_TYPE, + CT_GET_TEXT_POSTAL_TYPE, + CT_GET_TEXT_EVENT_TYPE, + CT_GET_TEXT_IM_TYPE, + CT_GET_TEXT_MONTH, + CT_GET_TEXT_RELATIONSHIP_TYPE, + PH_GET_TEXT_HELP, + CT_GET_TEXT_HELP, +}; + +#define V_(str) dgettext("contacts", str) + +const char* ctGetContactsString(const char* did); + +enum { + PH_SYS_SK_OK, + CT_SYS_SK_SAVE, + CT_SYS_SK_DONE, + PH_SYS_SK_EDIT, + PH_SYS_SK_DELETE, + PH_SYS_SK_CANCEL, + PH_SYS_SK3_BLOCK, + PH_SYS_SK_NO, + PH_SYS_SK_YES, + CT_SYS_SK_ADD, + CT_SYS_SK_MORE, + CT_SYS_SK_NEXT, + PH_SYS_BODY_CALL, + PH_SYS_BODY_MESSAGE, + PH_SYS_BODY_VIDEO_CALL, + PH_SYS_BODY_UNKNOWN, + PH_SYS_BODY_SELECT_ALL, + PH_SYS_BODY_CONTACTS, + PH_SYS_BODY_DETAILS, + PH_SYS_BODY_TODAY, + PH_SYS_BODY_YESTERDAY, + PH_SYS_BODY_PREVIOUS, + PH_SYS_BODY_NONAME, + CT_SYS_BODY_CREATE, + CT_SYS_BODY_MOVE, + CT_SYS_BODY_COPY, + CT_SYS_BODY_PHONE, + CT_SYS_BODY_SEARCH, + CT_SYS_BODY_BLUETOOTH, + CT_SYS_BODY_EMAIL, + CT_SYS_BODY_SIM, + CT_SYS_BODY_MEMORYCARD, + CT_SYS_BODY_NAME, + PH_SYS_BODY_ALL, + PH_SYS_POP_FAIL, + PH_SYS_POP_FAILED, + PH_SYS_POP_CLOSE, + PH_SYS_POP_REMOVED, + PH_SYS_POP_DELETED, + PH_SYS_POP_INCORRECT_PASSWORD, + PH_SYS_POP_ALREDY_EXISTS, + PH_SYS_POP_SELECTED, + CT_SYS_POP_SUCCESS, + CT_SYS_POP_ERROR, + CT_SYS_POP_MOVED, + CT_SYS_POP_ADDED, + CT_SYS_POP_NOT_ENOUGH_MEMORY, + CT_SYS_POP_NOTHING_SELECTED, + CT_SYS_POP_FILE_NOT_FOUND, + CT_SYS_POP_ADDRESS, + PH_SYS_OPT_ADD_TO_CONTACTS, + PH_SYS_BODY_SELECTED_DATA_NOT_FOUND, + PH_SYS_POP_DELETE_Q, + CT_SYS_SK_SET, + CT_SYS_SK_RESET, + CT_SYS_OPT_MY_FILES, + CT_SYS_DAYS_AGO, + CT_SYS_BODY_SETTINGS, + CT_SYS_BODY_BACK, + CT_SYS_BODY_MORE, + CT_SYS_BODY_NO_CONTENTS, + CT_SYS_BODY_PD_SELECTED, + CT_PB_BODY_ABCDEFGHIJKLMNOPQRSTUVWXYZ_M_INDEXLIST, + CT_SYS_POP_MAXIMUM_NUMBER_OF_CHARACTERS_REACHED, + CT_SYS_SK_SELECT, + CT_SYS_OPT_S_MEMO, + CT_SYS_BODY_CONTINUE, + CT_SYS_POP_CANCELLED, +}; + +#ifdef __cplusplus +} +#endif + +#endif // __CT_STRING_H__ + diff --git a/lib-contact/ct-common/inc/CtThemeMgr.h b/lib-contact/ct-common/inc/CtThemeMgr.h new file mode 100644 index 0000000..473cc2b --- /dev/null +++ b/lib-contact/ct-common/inc/CtThemeMgr.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_THEME_MGR_H_ +#define _CT_THEME_MGR_H_ + +#include <string> +#include <vector> +#include <memory> + +#include "WDefine.h" + +class WAPP_ASSIST_EXPORT CtThemeMgr +{ +public: + static CtThemeMgr* getInstance(); + void destroy(); + void setObjectTheme(Evas_Object *obj); + Elm_Theme* getTheme(); + bool addExtensionTheme(const char *themePath); + bool removeExtensionTheme(const char *themePath); + + +private: + CtThemeMgr(); + virtual ~CtThemeMgr(); + +private: + static CtThemeMgr* __instance; + Elm_Theme *__theme; + std::vector<std::string> __themeList; + +}; + +#endif /* _CT_THEME_MGR_H_ */ diff --git a/lib-contact/ct-common/inc/CtThread.h b/lib-contact/ct-common/inc/CtThread.h new file mode 100644 index 0000000..353f5dc --- /dev/null +++ b/lib-contact/ct-common/inc/CtThread.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_THREAD_H_ +#define _CT_THREAD_H_ + +#include <pthread.h> +#include <Eina.h> +#include <Ecore.h> + + +typedef void* PTHREAD_FN; +typedef void (*ctThreadJob)(void *data); +typedef void (*ctThreadCompleteCb)(void *data); + +class CtThread +{ +public: + CtThread(ctThreadJob job, void *jobData, ctThreadCompleteCb completeCb, void *completeCbData); + + void start(); + void cancel(); + void destroy(); + + +private: + + ~CtThread(); + + void __cancel(); + + static Eina_Bool __ctThreadTimerCb(void *data); + static PTHREAD_FN __ctThreadJob(void *data); + + +private: + + bool __isAlive; + bool __isComplete; + pthread_t __pthread; + Ecore_Timer *__timer; + ctThreadJob __job; + void *__jobData; + ctThreadCompleteCb __completeCb; + void *__completeCbData; + +}; + + +#endif //_CT_THREAD_H_ + diff --git a/lib-contact/ct-common/inc/CtType.h b/lib-contact/ct-common/inc/CtType.h new file mode 100644 index 0000000..c64ba9f --- /dev/null +++ b/lib-contact/ct-common/inc/CtType.h @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_TYPE_H_ +#define _CT_TYPE_H_ + +#include <app_control.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define CT_EDITFIELD_MAX_CHAR 1000 +#define CT_MAIN_NAME_EDITFIELD_MAX_CHAR 5005 +#define CT_SIMNAME_EDITFIELD_MAX_CHAR 14 +#define CT_SIMNUMBER_EDITFIELD_MAX_CHAR 40 + + +#define CT_TEXT_MAX_LEN 1024 +#define CT_HELP_TEXT_MAX_LEN 4096 +#define CT_TEXT_SHORT_LEN 256 +#define CT_EDITFIELD_MAX_BUFFER 1000*3 +#define CT_SEARCHBAR_MAX_CHAR 100 + +#define CT_KEY_APPSVC_TIMER "appsvc_timer" +#define CT_KEY_SERVICE "app_control_h" +#define CT_KEY_LIST_MFC_PERSON_IDS "db/private/org.tizen.contacts/list_mfc_person_ids" +#define CT_KEY_LIST_DISPLAY_ADDRESSBOOK "db/private/org.tizen.contacts/list_display_addressbook" +#define CT_KEY_INPUT_BASE_ADDRESSBOOK "db/private/org.tizen.contacts/input_base_addressbook" +#define CT_KEY_SETTING_CONTACT_SHARING_SETTINGS "db/private/org.tizen.contacts/contact_sharing_settings" +#define CT_KEY_CONTACT_CREATE_FIRST "db/private/org.tizen.contacts/contact_create_first" +#define CT_KEY_MYPROFILE_CREATE_FIRST "db/private/org.tizen.contacts/myprofile_create_first" +#define CT_KEY_DISPLAY_WITH_NUMBER "db/private/org.tizen.contacts/display_contacts_with_number" +#define CT_KEY_LAST_SELECTED_TAB_INDEX_FOR_PHONE "db/private/org.tizen.contacts/last_selected_tab_index_for_phone" +#define CT_KEY_SHOW_LINK_CONTACTS_TOAST_POPUP "db/private/org.tizen.contacts/show_link_contacts_toast_popup" +#define CT_KEY_NUM_OF_LINKABLE_CONTACTS "db/private/org.tizen.contacts/num_of_linkable_contacts" +#define CT_SIM_ADDRESSBOOK_NAME "http://tizen.samsung.com/addressbook/sim" +#define CT_EAS_ADDRESSBOOK_NAME "Microsoft Exchange ActiveSync" +#define CT_EAS_ADDRESSBOOK_DISPLAY_NAME "Exchange ActiveSync" +#define CT_FACEBOOK_ADDRESSBOOK_NAME "Sync apps with Facebook" + +#define CT_KEY_SIM_CARD_NUMBER "sim_card_number" + +//////////////////////// List Data..We need to hide these enum into list data class//////////////////////// +typedef struct { + int addressbookId; + int accountId; + char *iconPath; + char *addressbookName; + char *displayName; + bool display; + int mode; +} CtAddressbookInfo; + +typedef enum { + LIST_ADDRESSBOOK_MODE_NONE, + LIST_ADDRESSBOOK_MODE_ALL, + LIST_ADDRESSBOOK_MODE_VISIBLE, + LIST_ADDRESSBOOK_MODE_INVISIBLE, +}CtListAddressbookMode; + + +////////////////////////////////////////////////////////////////////////////////////////////////// + +typedef enum { + LIST_DATA_DEFAULT,//Add enumtype refer to op + LIST_DATA_ALL_PERSON, + LIST_DATA_ALL_FAVORITES, + LIST_DATA_PERSON_EXCEPT_SIM,//without sim + //Carrier matching + LIST_DATA_PERSON_WITH_NUMBER, + LIST_DATA_PERSON_EXCEPT_FACEBOOK, + +}CtListDataType; + +typedef enum { + LIST_CTRL_DEFAULT, //go to detail + LIST_CTRL_DELETE_CONTACTS, + LIST_CTRL_SHARE_CONTACTS, + LIST_CTRL_ADD_FAVORITES, + LIST_CTRL_REMOVE_FAVORITES, + LIST_CTRL_REORDER_FAVORITES, + LIST_CTRL_LINK_CONTACT, + + // Brazil carrier matching + LIST_CTRL_CARRIER_MATCH_SYNC_CONTACTS, + + //for app control + LIST_CTRL_REQUEST_UPDATE_CONTACT, //for choose + + LIST_CTRL_REQUEST_SELECT_FOR_PERSON, //for pick single + LIST_CTRL_REQUEST_SELECT_FOR_NUMBER, // + LIST_CTRL_REQUEST_SELECT_FOR_EMAIL, // + LIST_CTRL_REQUEST_SELECT_FOR_NUMBER_OR_EMAIL, // + LIST_CTRL_REQUEST_SELECT_FOR_URL, // + LIST_CTRL_REQUEST_SELECT_FOR_VCARD, // + + LIST_CTRL_REQUEST_CHECK_FOR_PERSON, //for pick multiple + LIST_CTRL_REQUEST_CHECK_FOR_NUMBER, // + LIST_CTRL_REQUEST_CHECK_FOR_EMAIL, // + LIST_CTRL_REQUEST_CHECK_FOR_VCARD, // + LIST_CTRL_REQUEST_CHECK_FOR_NUMBER_OR_EMAIL, // + LIST_CTRL_REQUEST_CHECK_FOR_LINK_CONTACTS, + + LIST_CTRL_SHARE_CONTACT_INFO, +}CtListCtrlType; + +typedef enum { + LIST_VIEW_DEFAULT, + LIST_VIEW_CHECK, + LIST_VIEW_REORDER, +}CtListViewType; + +typedef enum { + CHECK_NONE = -1, + CHECK_OFF, + CHECK_ON, +}CtCheckState; + +typedef enum { + RESULT_FAILED = APP_CONTROL_RESULT_FAILED, + RESULT_SUCCESS = APP_CONTROL_RESULT_SUCCEEDED, + RESULT_CANCELLED = APP_CONTROL_RESULT_CANCELED +} CtResultType; + +enum { + INPUT_ADDED_ITEM_INDEX_NONE = 0, + INPUT_ADDED_ITEM_INDEX_PHONETIC_INFO, + INPUT_ADDED_ITEM_INDEX_NICKNAME, + INPUT_ADDED_ITEM_INDEX_ORGANIZATION, + INPUT_ADDED_ITEM_INDEX_NUMBER, + INPUT_ADDED_ITEM_INDEX_EMAIL, + INPUT_ADDED_ITEM_INDEX_NOTE, + INPUT_ADDED_ITEM_INDEX_URL, + INPUT_ADDED_ITEM_INDEX_ADDRESS, + INPUT_ADDED_ITEM_INDEX_IM, + INPUT_ADDED_ITEM_INDEX_RELATIONSHIP, +}; + +typedef enum { + CTTEXT_TYPE_CUSTOM = 1, + CTTEXT_TYPE_MOBILE, + CTTEXT_TYPE_WORK, + CTTEXT_TYPE_HOME, + CTTEXT_TYPE_MAIN, + CTTEXT_TYPE_FAX_WORK, + CTTEXT_TYPE_FAX_HOME, + CTTEXT_TYPE_PAGER, + CTTEXT_TYPE_OTHER, +}CtInputNumberDataType; + +typedef enum { + CTTEXT_EMAIL_TYPE_CUSTOM, + CTTEXT_EMAIL_TYPE_HOME, + CTTEXT_EMAIL_TYPE_WORK, + CTTEXT_EMAIL_TYPE_OTHER, +}CtInputEmailDataType; + +typedef enum { + CTTEXT_MESSENGER_TYPE_CUSTOM, + CTTEXT_MESSENGER_TYPE_AIM, + CTTEXT_MESSENGER_TYPE_YAHOO, + CTTEXT_MESSENGER_TYPE_SKYPE, + CTTEXT_MESSENGER_TYPE_QQ, + CTTEXT_MESSENGER_TYPE_HANGOUTS, + CTTEXT_MESSENGER_TYPE_ICQ, + CTTEXT_MESSENGER_TYPE_JABBER, +}CtInputMessengerDataType; + +typedef enum { + LIST_QUERY_DEFAULT, + LIST_QUERY_FAVORITE, + LIST_QUERY_MFC, +}CtListQueryType; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib-contact/ct-common/inc/CtView.h b/lib-contact/ct-common/inc/CtView.h new file mode 100755 index 0000000..8f25f07 --- /dev/null +++ b/lib-contact/ct-common/inc/CtView.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_VIEW_H_ +#define _CT_VIEW_H_ + +#include "WView.h" + +class WAPP_ASSIST_EXPORT CtView +{ +public: + CtView(); + virtual ~CtView(); + +public: + int getEmergencyMode(); + int getEasyMode(); + +protected: + //virtual void onAppPause(); + //virtual void onAppResume(); + //virtual bool onWinRotate(); + virtual void onLanguageChanged() = 0; + //virtual void onEasyModeChanged(); + //virtual void onEmergencyModeChanged(); + + Evas_Object* createBaseLayout(Evas_Object* parent); + +private: + static void __languageChangedCb(void* data, Evas_Object* obj, void* event_info); + +private: + Evas_Object *__layout; + int __easyMode; + int __emergencyMode; +}; + +#endif // _CT_VIEW_H_ diff --git a/lib-contact/ct-common/inc/ICtChangeListener.h b/lib-contact/ct-common/inc/ICtChangeListener.h new file mode 100755 index 0000000..d5bdf96 --- /dev/null +++ b/lib-contact/ct-common/inc/ICtChangeListener.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _ICT_CHANGE_LISTENER_H_ +#define _ICT_CHANGE_LISTENER_H_ + +class ICtChangeListener +{ +public: + virtual ~ICtChangeListener(){}; + virtual void onDbChanged(const char* viewUri) = 0; + virtual void onCompleteGetContacts(int offset) = 0; + virtual void onConditionChagned() = 0; +}; + +#endif // _CT_CHANGE_LISTENER_H_ + diff --git a/lib-contact/ct-common/src/CtCommon.cpp b/lib-contact/ct-common/src/CtCommon.cpp new file mode 100755 index 0000000..f3984d5 --- /dev/null +++ b/lib-contact/ct-common/src/CtCommon.cpp @@ -0,0 +1,1069 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <dlfcn.h> +#include <Elementary.h> +#include <app.h> +#include <Eina.h> +//#include <efl_assist.h> +#include <metadata_extractor.h> +#include <account.h> +#include <tapi_common.h> +#include <telephony/telephony.h> +#include <storage.h> +#include <string> +#include <fcntl.h> +//#include "csc-feature/csc-feature.h" + + +#include <errno.h> +#include <system_settings.h> + +#include "CtCommon.h" +#include "CtType.h" +#include "CtPath.h" +#include "ContactsDebug.h" +#include "ContactsAppControl.h" + +#define FILE_ACCESS_MODE 0644 +#define VCARD_NAME_SUFFIX_LEN 16 + +static bool __ctCommongetProviderCb(char* appId, char* label, char* locale, void* userData); + +char* ctCommonMarkupToUtf8(const char *string) +{ + unsigned int i; + char *ret = NULL; + + ret = elm_entry_markup_to_utf8(string); + WPRET_VM(NULL == ret, NULL, "elm_entry_markup_to_utf8() return NULL"); + + for (i = 0; i < strlen(ret); i++) + if (' ' != ret[i]) return ret; + + ret[0] = '\0'; + return ret; +} + +//static Eina_Bool __ctCommonAppsvcUiLockTimerCb(void *user_data) +//{ +// WENTER(); +// WDEBUG("[PAUSE] __common_appsvc_ui_lock_timer_cb"); +// Evas_Object *navi = (Evas_Object*)user_data; +// WPRET_VM (NULL == navi, ECORE_CALLBACK_CANCEL,"navi null"); +// +// evas_object_freeze_events_set(navi, EINA_FALSE); +// evas_object_data_del(navi, CT_KEY_APPSVC_TIMER); +// +// return ECORE_CALLBACK_CANCEL; +//} +// +//static void __ctCommonAppsvcNaviDelCb(void *data, Evas *e, Evas_Object *obj, void *event_info) +//{ +// WENTER(); +// WDEBUG("[PAUSE] __common_appsvc_navi_del_cb"); +// Evas_Object *navi = (Evas_Object*)obj; +// Ecore_Timer *timer = NULL; +// +// timer = (Ecore_Timer*)evas_object_data_del(navi, CT_KEY_APPSVC_TIMER); +// if (timer) +// ecore_timer_del(timer); +//} + +//void ctCommonTerminateAppservice(Evas_Object *navi) +//{ +// app_control_h service = NULL; +// WPRET_M(NULL == navi, "navi null"); +// +// service = (app_control_h)evas_object_data_del(navi, CT_KEY_SERVICE); +// WPRET_M(NULL == service, "service null"); +// +// WHIT(); +// int err = app_control_send_terminate_request(service); +// app_control_destroy(service); +// +// WDEBUG("yunju 222 %p %p err%d", navi, service, err); +//} + +//void ctCommonResetAppservice(Evas_Object *navi, app_control_h service) +//{ +// app_control_h service_old = NULL; +// WPRET_M(NULL == navi, "navi null"); +// +// service_old = (app_control_h)evas_object_data_del(navi, CT_KEY_SERVICE); +// if (service_old) +// app_control_destroy(service_old); +// +// evas_object_data_set(navi, CT_KEY_SERVICE, service); +// +// WDEBUG("yunju 111 %p %p", navi, service); +//} + +//void ctCommonUnlockUiForAppsvc(Evas_Object *navi) +//{ +// WENTER(); +// WDEBUG("[PAUSE] phct_common_unlock_ui_for_appsvc"); +// Ecore_Timer *timer = NULL; +// WPRET_M(NULL == navi,"navi null"); +// +// evas_object_freeze_events_set(navi, EINA_FALSE); +// +// timer = (Ecore_Timer*)evas_object_data_del(navi, CT_KEY_APPSVC_TIMER); +// if (timer) // ui lock for appsvc +// ecore_timer_del(timer); +// evas_object_event_callback_del_full(navi, EVAS_CALLBACK_DEL, __ctCommonAppsvcNaviDelCb, navi); +//} +// +//int ctCommonServiceSendLaunchRequest(Evas_Object *navi, app_control_h service, app_control_reply_cb callback, void *user_data) +//{ +// WENTER(); +// const double ui_lock_duration = 3.0; +// Ecore_Timer *appsvc_timer = NULL; +// if (navi) { +// evas_object_freeze_events_set(navi, EINA_TRUE); +// +// appsvc_timer = ecore_timer_add(ui_lock_duration, __ctCommonAppsvcUiLockTimerCb, navi); +// evas_object_data_set(navi, CT_KEY_APPSVC_TIMER, appsvc_timer); +// +// evas_object_event_callback_add(navi, EVAS_CALLBACK_DEL, __ctCommonAppsvcNaviDelCb, navi); +// } +// +// return app_control_send_launch_request(service, callback, user_data); +//} + +//bool ctCommonIsUiLockedForAppsvc(Evas_Object *navi) +//{ +// WPRET_VM(NULL == navi, false, "navi null"); +// if (evas_object_data_get(navi, CT_KEY_APPSVC_TIMER)) +// return true; +// return false; +//} + +bool ctCommonCheckDirtyPhoneNumber(const std::string& str) +{ + for(auto it =str.begin();it != str.end(); it++) { + switch (*it) + { + case '/': + case 'N': + case '.': + case '0' ... '9': + case 'p': + case 'w': + case 'P': + case 'W': + case '#': + case '*': + case '(': + case ')': + case ',': + case ';': + case '+': + break; + + default: + return false; + } + } + + return true; +} + +void ctCommonRemoveNewline(char *src) +{ + int i=0; + + if(!src) + return; + + while(src[i]) + { + if (src[i] == '\n') + src[i] = ' '; + i++; + } +} + +Eina_List* ctCommonGetContactsList(int personId) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + contacts_record_h contactRecord = NULL; + contacts_record_h contactRecordClone = NULL; + contacts_list_h contactList = NULL; + Eina_List *contactRcordList = NULL; + contacts_filter_h filter = NULL; + contacts_query_h query = NULL; + + err = contacts_filter_create(_contacts_contact._uri, &filter); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contactcs_filter_create() Failed(%d)", err); + err = contacts_filter_add_int(filter, _contacts_contact.person_id, CONTACTS_MATCH_EQUAL, personId); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_filter_add_int() Failed(%d)", err); + contacts_filter_destroy(filter); + return NULL; + } + err = contacts_query_create(_contacts_contact._uri, &query); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_query_create() Failed(%d)", err); + contacts_filter_destroy(filter); + return NULL; + } + err = contacts_query_set_filter(query, filter); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_query_set_filter() Failed(%d)", err); + contacts_filter_destroy(filter); + contacts_query_destroy(query); + return NULL; + } + err = contacts_db_get_records_with_query(query, 0, 0, &contactList); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_db_get_records_with_query() Failed(%d)", err); + contacts_list_destroy(contactList, true); + contacts_filter_destroy(filter); + contacts_query_destroy(query); + return NULL; + } + + contacts_filter_destroy(filter); + contacts_query_destroy(query); + + while (CONTACTS_ERROR_NONE == contacts_list_get_current_record_p(contactList, &contactRecord)) { + err = contacts_record_clone(contactRecord, &contactRecordClone); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_clone() Failed(%d)", err); + break; + } + contactRcordList = eina_list_append(contactRcordList, contactRecordClone); + contacts_list_next(contactList); + } + contacts_list_destroy(contactList, true); + return contactRcordList; +} + +Eina_List* ctCommonGetWritableContactList(int personId) +{ + int addressbookId; + int addressbookMode; + Eina_List *contactList = NULL; + + int err = CONTACTS_ERROR_NONE; + contacts_record_h addressbookRecord = NULL; + contacts_record_h contactRecordClone = NULL; + + WPRET_VM(personId <= 0, NULL, "Invalid parameter(%d)", personId); + + Eina_List* list = ctCommonGetContactsList(personId); + WPRET_VM(list == NULL, NULL, "contact list is null"); + + void *data = NULL; + Eina_List *cursor = NULL; + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h contactRecord = (contacts_record_h)data; + + err = contacts_record_get_int(contactRecord, _contacts_contact.address_book_id, &addressbookId); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_int() Failed(%d)", err); + break; + } + + err = contacts_db_get_record(_contacts_address_book._uri, addressbookId, &addressbookRecord); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_db_get_record() Failed(%d)", err); + break; + } + + err = contacts_record_get_int(addressbookRecord, _contacts_address_book.mode, &addressbookMode); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_int() Failed(%d)", err); + err = contacts_record_destroy(addressbookRecord, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_destroy() Failed(%d)", err); + break; + } + + char *name = NULL; + err = contacts_record_get_str_p(addressbookRecord, _contacts_address_book.name, &name); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_str_p() Failed(%d)", err); + err = contacts_record_destroy(addressbookRecord, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_destroy() Failed(%d)", err); + break; + } + + if (addressbookMode & CONTACTS_ADDRESS_BOOK_MODE_READONLY) { + err = contacts_record_destroy(addressbookRecord, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_destroy() Failed(%d)", err); + continue; + } + + err = contacts_record_destroy(addressbookRecord, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_destroy() Failed(%d)", err); + + err = contacts_record_clone(contactRecord, &contactRecordClone); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_clone() Failed(%d)", err); + break; + } + + contactList = eina_list_append(contactList, contactRecordClone); + } + + ctCommonDestroyRecordList(list); + + return contactList; +} + +void ctCommonDestroyRecordList(Eina_List *list) +{ + int err = CONTACTS_ERROR_NONE; + void *data = NULL; + EINA_LIST_FREE(list, data) { + contacts_record_h record = (contacts_record_h)data; + err = contacts_record_destroy(record, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_clone() Failed(%d)", err); + } +} + +bool __ctCommonCheckDirtyNumber(char digit) +{ + switch (digit) + { + case '/': + case 'N': + case '.': + case '0' ... '9': + //case 'p': + //case 'w': + //case 'P': + //case 'W': + case '#': + case '*': + case '(': + case ')': + case ',': + case ';': + case '+': + case '-': + //case ' ': + return false; + default: + return true; + } +} + +int ctCommonCheckUtf8(char c) +{ + if (c < 128) { + return 1; + } + else if ((c & (char)0xe0) == (char)0xc0) { + return 2; + } + else if ((c & (char)0xf0) == (char)0xe0) { + return 3; + } + else if ((c & (char)0xf8) == (char)0xf0) { + return 4; + } + else if ((c & (char)0xfc) == (char)0xf8) { + return 5; + } + else if ((c & (char)0xfe) == (char)0xfc) { + return 6; + } + else { + return -1; + } +} + +void ctCommonCleanNumber(const char *src, char *dest, int destSize) +{ + int sPos = 0, dPos = 0, charType; + + if (NULL == src) { + WDEBUG("The parameter(src) is NULL"); + } + else { + while (src[sPos] != 0) { + if (dPos >= destSize-2) { + break; + } + charType = ctCommonCheckUtf8(src[sPos]); + if (charType <= 1) { + if (__ctCommonCheckDirtyNumber(src[sPos])) { + sPos++; + continue; + } + dest[dPos++] = src[sPos++]; + } + else { + sPos += charType; + } + } + } + + dest[dPos] = 0; +} + +bool __ctCommongetProviderCb(char* appId, char* label, char* locale, void* userData) +{ + char ** name = (char **)userData; + if(strcmp(locale,"default") == 0) { + *name = SAFE_STRDUP(label); + } + + return true; +} + +void ctCommonGetProviderNameByAddressbookId(contacts_record_h recordAddressBook, int addressbookId ,char** providerName, char**userName) +{ + WHIT(); + int ret; + int accountId; + char *appId = NULL; + char *addressbookName = NULL; + char *addressbookUsername = NULL; + account_h account = NULL; + int err = CONTACTS_ERROR_NONE; +// contacts_record_h record = NULL; + + //WASSERT(NULL == providerName); + SAFE_FREE(*providerName); + + if (addressbookId <0){ + return; + } + + err = contacts_record_get_str_p(recordAddressBook,_contacts_address_book.name,&addressbookName); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + + WDEBUG("addressbookName %s", addressbookName); + + if(!strcmp(addressbookName, "http://tizen.org/addressbook/phone")) + *providerName = strdup(V_("IDS_PB_OPT_DEVICE")); + else if(!strcmp(addressbookName, CT_SIM_ADDRESSBOOK_NAME"/0")) { + *providerName = strdup("SIM1"); + } + else if(!strcmp(addressbookName, CT_SIM_ADDRESSBOOK_NAME"/1")) { + *providerName = strdup("SIM2"); + } + else if(!strcmp(addressbookName, CT_SIM_ADDRESSBOOK_NAME)) { //for one sim device + *providerName = strdup("SIM"); + } + + err = contacts_record_get_int(recordAddressBook, _contacts_address_book.account_id, &accountId); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_int() Failed(%d)", err); + return; + } + + if (0 == accountId) + return; + + account = NULL; + ret = account_create(&account); + if (ACCOUNT_ERROR_NONE != ret) { + WERROR("account_create() Failed(%d)", ret); + return; + } + + ret = account_query_account_by_account_id(accountId, &account); + if (ACCOUNT_ERROR_NONE != ret) { + WERROR("account_query_account_by_account_id(%d) Failed(%d)", accountId, ret); + account_destroy(account); + return; + } + + if(userName) { + ret = account_get_user_name(account, &addressbookUsername); + if (ACCOUNT_ERROR_NONE != ret) { + WERROR("account_get_display_name() Failed(%d)", ret); + account_destroy(account); + return; + } + WDEBUG("user name:%s", addressbookUsername); + if(addressbookUsername) + *userName = addressbookUsername; + else + *userName = NULL; + } + + ret = account_get_package_name(account, &appId); + if (ACCOUNT_ERROR_NONE != ret) { + WERROR("account_get_display_name() Failed(%d)", ret); + account_destroy(account); + return; + } + + WERROR("package_name = %s", appId); + + ret = account_type_query_label_by_app_id(__ctCommongetProviderCb, appId, providerName); + WPWARN(ACCOUNT_ERROR_NONE != ret, "account_type_query_label_by_app_id() Failed(%d)", ret); + if(*providerName == NULL){ + WERROR("provider_name is null"); + ret = account_get_domain_name(account, providerName); + WPWARN(ACCOUNT_ERROR_NONE != ret, "account_get_domain_name() is Failed(%d)", ret); + } + account_destroy(account); + free(appId); + + WDEBUG("providerName %s addressbookName %s", *providerName, addressbookName); + if(!strcmp(*providerName, CT_EAS_ADDRESSBOOK_NAME)) { + *providerName = strdup(CT_EAS_ADDRESSBOOK_DISPLAY_NAME); + if(userName) { + *userName = strdup(addressbookName); + free(addressbookUsername); + } + } + return; +} + +bool ctCommonIsValidPerson(const int personId) +{ + int err = CONTACTS_ERROR_NONE; + bool isValidPerson = false; + contacts_record_h tempRecord = NULL; + + err = contacts_db_get_record(_contacts_person._uri, personId, &tempRecord); + if (CONTACTS_ERROR_NONE == err) { + isValidPerson = true; + } + + contacts_record_destroy(tempRecord, true); + + return isValidPerson; +} + +void ctCommonSendSimpleAppControlResult(app_control_h appControl, const char *key, const char *value, app_control_result_e result) +{ + WDEBUG("result %d, key %s, value %s", result, key, value); + app_control_h appControlResult = NULL; + + app_control_create(&appControlResult); + + if (key && value) { + app_control_add_extra_data(appControlResult, key, value); + } + + app_control_reply_to_launch_request(appControlResult, appControl, result); + app_control_destroy(appControlResult); +} + +int ctCommonGetEasDefaultGroupId(int addressbook_id) +{ + contacts_filter_h filter = NULL; + contacts_query_h query = NULL; + contacts_list_h list = NULL; + int ret = 0; + contacts_record_h group = NULL; + contacts_record_h addressbook = NULL; + int eas_default_group_id =0; + int account_id = 0; + account_h account = NULL; + char *domain_name = NULL; + + ret = contacts_db_get_record(_contacts_address_book._uri, addressbook_id, &addressbook); + WPRET_VM(CONTACTS_ERROR_NONE != ret, -1, "contacts_db_get_record() Failed(%d)", ret); + + ret = contacts_record_get_int(addressbook, _contacts_address_book.account_id, &account_id); + if(CONTACTS_ERROR_NONE != ret) { + WERROR("contacts_record_get_int() Failed(%d)", ret); + + contacts_record_destroy(addressbook, true); + return -1; + } + + ret = contacts_record_destroy(addressbook, true); + if(CONTACTS_ERROR_NONE != ret) { + WERROR("contacts_record_destroy() Failed(%d)", ret); + return -1; + } + + if (0 == account_id) { + return -1; + } + + ret = account_create(&account); + if (ACCOUNT_ERROR_NONE != ret) { + WERROR("account_create() Failed(%d)", ret); + + return -1; + } + + ret = account_query_account_by_account_id(account_id, &account); + if (ACCOUNT_ERROR_NONE != ret) { + WERROR("account_query_account_by_account_id() Failed(%d)", ret); + account_destroy(account); + return -1; + } + + ret = account_get_domain_name(account, &domain_name); + if (ACCOUNT_ERROR_NONE != ret) { + WERROR("account_get_display_name() Failed(%d)", ret); + if(domain_name) + free(domain_name); + account_destroy(account); + return -1; + } + if(domain_name && strcmp(domain_name, "Exchange") != 0){ + WERROR("domain name: %s", domain_name); + free(domain_name); + account_destroy(account); + return -1; + } + free(domain_name); + account_destroy(account); + + + ret = contacts_filter_create(_contacts_group._uri, &filter); + WPRET_VM(CONTACTS_ERROR_NONE != ret, -1, "contacts_filter_create() Failed(%d)", ret); + + ret = contacts_filter_add_int(filter, _contacts_group.address_book_id, CONTACTS_MATCH_EQUAL, addressbook_id); + if(CONTACTS_ERROR_NONE != ret) { + WERROR("contacts_filter_add_int() Failed(%d)", ret); + contacts_filter_destroy(filter); + return -1; + } + + ret = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); + if(CONTACTS_ERROR_NONE != ret) { + WERROR("contacts_filter_add_operator() Failed(%d)", ret); + contacts_filter_destroy(filter); + return -1; + } + + ret = contacts_filter_add_str(filter, _contacts_group.name, CONTACTS_MATCH_EXACTLY, "Contacts"); + if(CONTACTS_ERROR_NONE != ret) { + WERROR("contacts_filter_add_str() Failed(%d)", ret); + contacts_filter_destroy(filter); + return -1; + } + + ret = contacts_query_create(_contacts_group._uri, &query); + if(CONTACTS_ERROR_NONE != ret) { + WERROR("contacts_query_create() Failed(%d)", ret); + contacts_filter_destroy(filter); + return -1; + } + + ret = contacts_query_set_filter(query, filter); + if(CONTACTS_ERROR_NONE != ret) { + WERROR("contacts_query_create() Failed(%d)", ret); + contacts_query_destroy(query); + contacts_filter_destroy(filter); + return -1; + } + + ret = contacts_db_get_records_with_query(query, 0, 0, &list); + if(CONTACTS_ERROR_NONE != ret) { + WERROR("contacts_db_get_records_with_query() Failed(%d)", ret); + contacts_list_destroy(list, true); + contacts_query_destroy(query); + contacts_filter_destroy(filter); + return -1; + } + + ret = contacts_list_get_current_record_p(list, &group); + if(CONTACTS_ERROR_NONE != ret) { + WERROR("contacts_list_get_current_record_p() Failed(%d)", ret); + contacts_list_destroy(list, true); + contacts_query_destroy(query); + contacts_filter_destroy(filter); + return -1; + } + + ret = contacts_record_get_int(group, _contacts_group.id, &eas_default_group_id); + if(CONTACTS_ERROR_NONE != ret) { + WERROR("contacts_record_get_int() Failed(%d)", ret); + contacts_list_destroy(list, true); + contacts_query_destroy(query); + contacts_filter_destroy(filter); + return -1; + } + + ret = contacts_list_destroy(list, true); + if(CONTACTS_ERROR_NONE != ret) { + WERROR("contacts_record_get_int() Failed(%d)", ret); + contacts_query_destroy(query); + contacts_filter_destroy(filter); + return -1; + } + + ret = contacts_query_destroy(query); + if(CONTACTS_ERROR_NONE != ret) { + WERROR("contacts_query_destroy() Failed(%d)", ret); + contacts_filter_destroy(filter); + return -1; + } + + ret = contacts_filter_destroy(filter); + if(CONTACTS_ERROR_NONE != ret) { + WERROR("contacts_record_get_int() Failed(%d)", ret); + return -1; + } + + return eas_default_group_id; +} + +void* ctGetDllHandle(const char* dllName) +{ + if (strcmp(dllName, "libct-detail.so") == 0) { + static void* detailDllHandle = NULL; + if (detailDllHandle == NULL) { + detailDllHandle = dlopen("libct-detail.so", RTLD_LAZY); + if (!detailDllHandle) { + WERROR("%s", dlerror()); + } + } + + return detailDllHandle; + } + else if (strcmp(dllName, "libct-setting.so") == 0) { + static void* settingDllHandle = NULL; + if (settingDllHandle == NULL) { + settingDllHandle = dlopen("libct-setting.so", RTLD_LAZY); + if (!settingDllHandle) { + WERROR("%s", dlerror()); + } + } + + return settingDllHandle; + } + + return NULL; +} + +int ctCommonGetAddressBookId(char* addressbookName) +{ + int err = CONTACTS_ERROR_NONE; + contacts_filter_h filter = NULL; + contacts_query_h query = NULL; + contacts_list_h list = NULL; + contacts_record_h record = NULL; + int addressbookId = -1;//0 is phone addressbook id + WPRET_VM(NULL == addressbookName, -1, "addressbookName is null"); + + err = contacts_filter_create(_contacts_address_book._uri, &filter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + err = contacts_filter_add_str(filter,_contacts_address_book.name , CONTACTS_MATCH_FULLSTRING, addressbookName); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_str() Failed(%d)", err); + err = contacts_query_create(_contacts_address_book._uri, &query); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_create() Failed(%d)", err); + err = contacts_query_set_filter(query, filter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_filter() Failed(%d)", err); + err = contacts_db_get_records_with_query(query, 0, 0, &list); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_records_with_query() Failed(%d)", err); + err = contacts_list_get_current_record_p(list, &record); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_get_current_record_p() Failed(%d)", err); + if (record){ + err = contacts_record_get_int(record,_contacts_address_book.id, &addressbookId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + } + + contacts_list_destroy(list, true); + contacts_filter_destroy(filter); + contacts_query_destroy(query); + + return addressbookId; +} + +char* ctCommonGetAddressBookName(int addressbookId) +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + char* val = NULL; + char* name = NULL; + + err = contacts_db_get_record(_contacts_address_book._uri, addressbookId, &record); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_record() Failed(%d)", err); + err = contacts_record_get_str_p(record, _contacts_address_book.name, &val); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + + name = SAFE_STRDUP(val); + err = contacts_record_destroy(record, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_destroy() Failed(%d)", err); + + return name; +} + +Eina_List* ctCommonGetChekedDuplicatedNumberList(Eina_List *sourceList) +{ + WENTER(); + bool bAlready = false; + void *info = NULL; + Eina_List *list = NULL; + Eina_List *checkedDuplicatedList = NULL; + + if(NULL == sourceList) + return NULL; + + EINA_LIST_FOREACH(sourceList, list, info) { + contacts_record_h recordClone = (contacts_record_h)info; + void *checked_info = NULL; + Eina_List *checked_list = NULL; + char *value = NULL; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_str_p(recordClone, _contacts_number.number, &value); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + EINA_LIST_FOREACH(checkedDuplicatedList, checked_list, checked_info) { + contacts_record_h checked_recordClone = (contacts_record_h)checked_info; + char *checked_value = NULL; + err = contacts_record_get_str_p(checked_recordClone, _contacts_number.number, &checked_value); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + if (strcmp(value, checked_value) == 0) { + bAlready = true; + err = contacts_record_destroy(recordClone, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_clone() Failed(%d)", err); + break; + } + } + WDEBUG("bAlready %d %s", bAlready, value); + if(false == bAlready) + checkedDuplicatedList = eina_list_append(checkedDuplicatedList, info); + } + + eina_list_free(sourceList); + + return checkedDuplicatedList; +} + +Eina_List* ctCommonGetChekedDuplicatedEmailList(Eina_List *sourceList) +{ + WENTER(); + bool bAlready = false; + void *info = NULL; + Eina_List *list = NULL; + Eina_List *checkedDuplicatedList = NULL; + + if(NULL == sourceList) + return NULL; + + EINA_LIST_FOREACH(sourceList, list, info) { + contacts_record_h recordClone = (contacts_record_h)info; + void *checked_info = NULL; + Eina_List *checked_list = NULL; + char *value = NULL; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_str_p(recordClone, _contacts_email.email, &value); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + EINA_LIST_FOREACH(checkedDuplicatedList, checked_list, checked_info) { + contacts_record_h checked_recordClone = (contacts_record_h)checked_info; + char *checked_value = NULL; + err = contacts_record_get_str_p(checked_recordClone, _contacts_email.email, &checked_value); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + if (strcmp(value, checked_value) == 0) { + bAlready = true; + err = contacts_record_destroy(recordClone, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_clone() Failed(%d)", err); + break; + } + } + WDEBUG("bAlready %d %s", bAlready, value); + if(false == bAlready) + checkedDuplicatedList = eina_list_append(checkedDuplicatedList, info); + } + + eina_list_free(sourceList); + + return checkedDuplicatedList; +} + +static bool __isUsableVcardChar(char c) +{ + switch (c) { + case '\\': + case '/': + case ':': + case '*': + case '?': + case '\"': + case '<': + case '>': + case '|': + case ';': + case ' ': + return false; + default: + return true; + } +} + +static bool check_blank_string(const char *display) +{ + for (size_t i = 0; display[i]; ++i) { + if (display[i] != ' ') { + return false; + } + } + + return true; +} + +static bool __storageCb(int storageId, storage_type_e type, storage_state_e state, const char *path, void *userData) +{ + if (type == STORAGE_TYPE_INTERNAL) { + int *internalStorage = (int *)userData; + *internalStorage = storageId; + return false; + } + return true; +} + +char *getOtherDirectoryPath() +{ + WHIT(); + char *dirPath = NULL; + int storageId = 0; + int error = storage_foreach_device_supported(__storageCb, &storageId); + WPRET_VM(error != STORAGE_ERROR_NONE, NULL, "storage_foreach_device_supported() failed"); + + error = storage_get_directory(storageId, STORAGE_DIRECTORY_OTHERS, &dirPath); + WPRET_VM(error != STORAGE_ERROR_NONE, NULL, "storage_get_directory() failed"); + + return dirPath; +} + +static std::string __makeVcardName(const char* displayName) +{ + WHIT(); + char *dirPath = getOtherDirectoryPath(); + WPRET_VM(!dirPath, "", "directory path is empty"); + + struct stat buf; + std::string firstFilePath; + std::string filePathStr = dirPath; + free(dirPath); + filePathStr += '/'; + + size_t nameLength = strlen(displayName); + + if (false == check_blank_string(displayName)) { + size_t dirPathLength = filePathStr.length(); + + for (size_t i = 0; i < nameLength; ++i) { + if ((filePathStr.length() - dirPathLength + 1) > (NAME_MAX - VCARD_NAME_SUFFIX_LEN)) { + WDEBUG("File name is too long. It will be cut."); + break; + } + if (__isUsableVcardChar(displayName[i])) { + filePathStr += displayName[i]; + } else if (iscntrl(displayName[i])) { + filePathStr += ' '; + } + } + } else { + const char *unknown = V_("IDS_LOGS_MBODY_UNKNOWN"); + + filePathStr += unknown; + } + + firstFilePath = filePathStr; + firstFilePath += ".vcf"; + + if (stat(firstFilePath.c_str(), &buf) != 0) { + filePathStr = firstFilePath; + } else { + size_t i = 1; + + do { + char filePath[BUFSIZ] = { '\0' }; + snprintf(filePath, BUFSIZ - 1, "%s_%d.vcf", filePathStr.c_str(), i++); + if(stat(filePath, &buf) != 0) { + filePathStr = filePath; + break; + } + } while (true); + } + + return filePathStr; +} + +std::string createVcardFile(contacts_record_h record) +{ + WHIT(); + const char *uri = NULL; + char *displayName = NULL; + char *vcard = NULL; + int fd = -1; + std::string vcardPath; + + contacts_record_get_uri_p(record, &uri); + if (0 == strcmp(_contacts_person._uri, uri)) { + contacts_record_get_str_p(record, _contacts_person.display_name, &displayName); + contacts_vcard_make_from_person(record, &vcard); + } else if (0 == strcmp(_contacts_contact._uri, uri)) { + contacts_record_get_str_p(record, _contacts_contact.display_name, &displayName); + contacts_vcard_make_from_contact(record, &vcard); + } else if (0 == strcmp(_contacts_my_profile._uri, uri)) { + contacts_record_get_str_p(record, _contacts_my_profile.display_name, &displayName); + contacts_vcard_make_from_my_profile(record, &vcard); + } + + bool failed_occured = false; + do { + + if (!vcard) { + WERROR("vcard is NULL"); + failed_occured = true; + break; + } + + if (!displayName) { + WERROR("displayName is NULL"); + failed_occured = true; + break; + } + + vcardPath = __makeVcardName(displayName); + if (vcardPath.empty()) { + WERROR("__makeVcardName() failed"); + failed_occured = true; + break; + } + + fd = open(vcardPath.c_str(), O_WRONLY|O_CREAT|O_TRUNC, FILE_ACCESS_MODE); + if (fd < 0) { + WERROR("open(%s) Failed(%s)", vcardPath.c_str(), strerror(errno)); + failed_occured = true; + break; + } + + int ret = write(fd, vcard, strlen(vcard)); + if (ret == -1) { + WERROR("write() Failed(%s)", strerror(errno)); + } + + close(fd); + } while (false); + + free(vcard); + + if(!failed_occured) { + return vcardPath; + } + + return ""; +} + +void sharePerson(int personId, bool isMyProfile) +{ + char buf[CT_TEXT_SHORT_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%d", personId); + + int err = launchShareContact(buf, isMyProfile); + WPWARN(err != APP_CONTROL_ERROR_NONE, "launchShareContact() failed(%d)", err); +} diff --git a/lib-contact/ct-common/src/CtProgressBarPopup.cpp b/lib-contact/ct-common/src/CtProgressBarPopup.cpp new file mode 100644 index 0000000..7a81aac --- /dev/null +++ b/lib-contact/ct-common/src/CtProgressBarPopup.cpp @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "ContactsCommon.h" + +#include "CtPath.h" +#include "CtType.h" +#include "ContactsDebug.h" +#include "CtProgressBarPopup.h" +#include "CtThemeMgr.h" +#include "CtString.h" + +CtProgressBarPopup::CtProgressBarPopup(int totalCount, const char* description) +{ + __totalCount = totalCount; + __description = description; + __progressbar = NULL; + __contentLayout = NULL; + __timerUpdate = false; + __remainCount = 0; + __statusCount = 0; + __timer = NULL; + +} + +CtProgressBarPopup::CtProgressBarPopup(int totalCount, const char* description, bool timerUpdate) +{ + __totalCount = totalCount; + __description = description; + __progressbar = NULL; + __contentLayout = NULL; + __timerUpdate = timerUpdate; + __remainCount = 0; + __statusCount = 0; + + __timer = ecore_timer_add(0.1, [](void* data)->Eina_Bool{ + CtProgressBarPopup* p = static_cast<CtProgressBarPopup*>(data); + + char percent[CT_TEXT_SHORT_LEN] = {0,}; + char percentTotal[CT_TEXT_SHORT_LEN] = {0, }; + double value = 0.0; + + if(p->__remainCount > 0 ){ + value = (double)(p->__totalCount - p->__remainCount) / (double)(p->__totalCount); + snprintf(percent, sizeof(percent), "%d%%", (int)(100.0 * (double)(p->__totalCount- p->__remainCount)/(double)(p->__totalCount))); + snprintf(percentTotal, sizeof(percentTotal), "%d/%d", p->__totalCount- p->__remainCount, p->__totalCount); + } + else if(p->__statusCount >0){ + value = (double)(p->__statusCount) / (double)(p->__totalCount); + snprintf(percent, sizeof(percent), "%d%%", (int)(100.0 * (double)(p->__statusCount)/(double)(p->__totalCount))); + snprintf(percentTotal, sizeof(percentTotal), "%d/%d", p->__statusCount, p->__totalCount); + } + else + return ECORE_CALLBACK_RENEW; + + elm_progressbar_value_set(p->__progressbar, value); + elm_object_part_text_set(p->__progressbar, "elm.text.bottom.left", percent); + elm_object_part_text_set(p->__progressbar, "elm.text.bottom.right", percentTotal); + + if (value == 1) + return ECORE_CALLBACK_CANCEL; + + return ECORE_CALLBACK_RENEW; + }, this); + +} + +Evas_Object* CtProgressBarPopup::__createContent(Evas_Object *parent) +{ + WENTER(); + + char percentTotal[CT_TEXT_SHORT_LEN] = {0, }; + std::string contactsEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + /* layout */ + __contentLayout = elm_layout_add(parent); + CtThemeMgr::getInstance()->addExtensionTheme(contactsEdjePath.c_str()); + CtThemeMgr::getInstance()->setObjectTheme(__contentLayout); + elm_layout_file_set(__contentLayout, contactsEdjePath.c_str(), "popup_text_progressbar_view_layout"); + evas_object_size_hint_weight_set(__contentLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + /* progressbar */ + __progressbar = elm_progressbar_add(__contentLayout); + evas_object_size_hint_align_set(__progressbar, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(__progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + snprintf(percentTotal, sizeof(percentTotal), "%d/%d", 0, __totalCount); + elm_object_part_text_set(__progressbar, "elm.text.bottom.left", "0%"); + elm_object_part_text_set(__progressbar, "elm.text.bottom.right", percentTotal); + + elm_progressbar_pulse(__progressbar, EINA_TRUE); + elm_object_signal_emit(__progressbar, "elm,units,show", "elm"); + elm_object_part_content_set(__contentLayout, "progressbar", __progressbar); + elm_object_content_set(parent, __contentLayout); + + return __contentLayout; +} + +Evas_Object* CtProgressBarPopup::onCreate( Evas_Object* parent, void* viewParam) +{ + WHIT(); + + setContent([this](Evas_Object* parent)->Evas_Object* { + return __createContent(parent); + }); + + setTitle(__description.c_str()); + return WPopup::onCreate(parent, viewParam); +} +void CtProgressBarPopup::setProgressRemainCount(int count) +{ + char percent[CT_TEXT_SHORT_LEN] = {0,}; + char percentTotal[CT_TEXT_SHORT_LEN] = {0, }; + double value = 0.0; + + if(__timerUpdate){ + __remainCount = count; + } + else { + value = (double)(__totalCount-count) / (double)__totalCount; + elm_progressbar_value_set(__progressbar, value); + snprintf(percent, sizeof(percent), "%d%%", (int)(100.0 * (double)(__totalCount-count)/(double)__totalCount)); + snprintf(percentTotal, sizeof(percentTotal), "%d/%d", count, __totalCount); + elm_object_part_text_set(__progressbar, "elm.text.bottom.left", percent); + elm_object_part_text_set(__progressbar, "elm.text.bottom.right", percentTotal); + } +} + +void CtProgressBarPopup::setProgressStatusCount(int count) +{ + char percent[CT_TEXT_SHORT_LEN] = {0,}; + char percentTotal[CT_TEXT_SHORT_LEN] = {0, }; + double value = 0.0; + + if(__timerUpdate) + __statusCount = count; + else { + value = (double)count / (double)__totalCount; + elm_progressbar_value_set(__progressbar, value); + snprintf(percent, sizeof(percent), "%d%%", (int)(100.0 * (double)count/(double)__totalCount)); + snprintf(percentTotal, sizeof(percentTotal), "%d/%d", count, __totalCount); + elm_object_part_text_set(__progressbar, "elm.text.bottom.left", percent); + elm_object_part_text_set(__progressbar, "elm.text.bottom.right", percentTotal); + } +} + + +void CtProgressBarPopup::onDestroy() +{ + WENTER(); + + if (__timer){ + ecore_timer_del(__timer); + __timer = NULL; + } +} + +CtProgressBarPopup::~CtProgressBarPopup() +{ + +} + diff --git a/lib-contact/ct-common/src/CtProgressController.cpp b/lib-contact/ct-common/src/CtProgressController.cpp new file mode 100644 index 0000000..ee8b246 --- /dev/null +++ b/lib-contact/ct-common/src/CtProgressController.cpp @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "ContactsDebug.h" +#include "CtProgressBarPopup.h" +#include "CtString.h" +#include "CtProgressController.h" + +CtProgressController::CtProgressController(const char *title, int totalCount) +: m_Cancel(false) +, m_ProgressPopup(NULL) +, m_Thread(NULL) +{ + WHIT(); + createProgressPopup(title, totalCount); +} + +CtProgressController::~CtProgressController() +{ + WHIT(); + if (auto popup = m_PopupMonitor.lock()) { + popup->destroy(); + } +} + +CtProgressBarPopup *CtProgressController::getProgressPopup() +{ + return m_ProgressPopup; +} + +void CtProgressController::run() +{ + WHIT(); + m_Thread = ecore_thread_run(onStart, onFinish, onCanceled, this); +} + +void CtProgressController::setOnFinish(std::function<void(CtProgressController&)> handlerFunc) +{ + m_FinishFunction = std::move(handlerFunc); +} + +bool CtProgressController::onProgress(int currentCount) +{ + m_ProgressPopup->setProgressStatusCount(currentCount); + return !m_Cancel; +} + +void CtProgressController::onStart(void *data, Ecore_Thread *thread) +{ + WPRDT_M(!data, "invalid data"); + CtProgressController *vcardProgressPopup = (CtProgressController *) data; + vcardProgressPopup->onStart(vcardProgressPopup->m_Thread); +} + +void CtProgressController::onFinish(void *data, Ecore_Thread *thread) +{ + WPRDT_M(!data, "invalid data"); + CtProgressController *vcardProgressPopup = (CtProgressController *) data; + vcardProgressPopup->m_FinishFunction(*vcardProgressPopup); + + delete vcardProgressPopup; +} + +void CtProgressController::onCanceled(void *data, Ecore_Thread *thread) +{ + WPRDT_M(!data, "invalid data"); + CtProgressController *vcardProgressPopup = (CtProgressController *) data; + vcardProgressPopup->onCanceled(); + + delete vcardProgressPopup; +} + +bool CtProgressController::onCancel() +{ + WHIT(); + return true; +} + +void CtProgressController::cancel() +{ + WHIT(); + m_Cancel = true; +} + +void CtProgressController::createProgressPopup(const char *title, int totalCount) +{ + m_ProgressPopup = new CtProgressBarPopup(totalCount, title, true); + + auto cancelFunction = [this](bool *destroyPopup)->void { + if (onCancel()) { + cancel(); + } + *destroyPopup = false; + }; + + m_ProgressPopup->addButton(V_("IDS_PB_BUTTON_CANCEL"), cancelFunction); + m_ProgressPopup->setOnBack(cancelFunction); + + m_PopupMonitor = m_ProgressPopup->getWeakPtr(); +} diff --git a/lib-contact/ct-common/src/CtRegistryMgr.cpp b/lib-contact/ct-common/src/CtRegistryMgr.cpp new file mode 100644 index 0000000..ddca140 --- /dev/null +++ b/lib-contact/ct-common/src/CtRegistryMgr.cpp @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "CtRegistryMgr.h" + +#include "ContactsDebug.h" + +CtRegistryMgr* CtRegistryMgr::__instance = NULL; + +CtRegistryMgr* CtRegistryMgr::getInstance() +{ + if( __instance == NULL ) + __instance = new CtRegistryMgr(); + return __instance; +} + +CtRegistryMgr::CtRegistryMgr() +{ + WHIT(); +} + +CtRegistryMgr::~CtRegistryMgr() +{ + WHIT(); +} + +void CtRegistryMgr::destroy() +{ + WHIT(); + delete __instance; + __instance = NULL; +} + +ctRegistryErr CtRegistryMgr::setInt(ctRegistryKey key, int value) +{ + WDEBUG("key %d, value %d", key, value); + std::map<ctRegistryKey, CtRegistryData*>::iterator iter; + iter = __registry.find(key); + if(iter != __registry.end()) { + WDEBUG("replace as new value"); + delete (*iter).second; + __registry.erase(iter); + } + + CtRegistryData *registryData = new CtRegistryData; + registryData->intValue = value; + + __registry.insert(std::make_pair(key, registryData)); + + return REGISTRY_SUCCESS; +} + +ctRegistryErr CtRegistryMgr::setStr(ctRegistryKey key, const char *value) +{ + WDEBUG("key %d, value %s", key, value); + std::map<ctRegistryKey, CtRegistryData*>::iterator iter; + iter = __registry.find(key); + if(iter != __registry.end()) { + WDEBUG("replace as new value"); + delete (*iter).second; + __registry.erase(iter); + } + + CtRegistryData *registryData = new CtRegistryData; + registryData->strValue = value; + + __registry.insert(std::make_pair(key, registryData)); + + return REGISTRY_SUCCESS; +} + +ctRegistryErr CtRegistryMgr::getInt(ctRegistryKey key, int *value) +{ + WDEBUG("key %d", key); + + std::map<ctRegistryKey, CtRegistryData*>::iterator iter; + iter = __registry.find(key); + if(iter != __registry.end()) { + *value = (*iter).second->intValue; + delete (*iter).second; + __registry.erase(iter); + + return REGISTRY_SUCCESS; + } + else + return REGISTRY_NO_DATA; +} + +ctRegistryErr CtRegistryMgr::getStr(ctRegistryKey key, std::string &value) +{ + WDEBUG("key %d", key); + std::map<ctRegistryKey, CtRegistryData*>::iterator iter; + iter = __registry.find(key); + if(iter != __registry.end()) { + value = (*iter).second->strValue; + delete (*iter).second; + __registry.erase(iter); + + return REGISTRY_SUCCESS; + } + else + return REGISTRY_NO_DATA; +} + diff --git a/lib-contact/ct-common/src/CtString.cpp b/lib-contact/ct-common/src/CtString.cpp new file mode 100755 index 0000000..aeaca3e --- /dev/null +++ b/lib-contact/ct-common/src/CtString.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "ContactsDebug.h" +#include "CtString.h" + + +const char* ctGetContactsString(const char* did) +{ + return dgettext("contacts", did); +} diff --git a/lib-contact/ct-common/src/CtThemeMgr.cpp b/lib-contact/ct-common/src/CtThemeMgr.cpp new file mode 100644 index 0000000..f938af1 --- /dev/null +++ b/lib-contact/ct-common/src/CtThemeMgr.cpp @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "CtCommon.h" +#include "CtThemeMgr.h" + +#include "ContactsDebug.h" + +CtThemeMgr* CtThemeMgr::__instance = NULL; + +CtThemeMgr* CtThemeMgr::getInstance() +{ + if( __instance == NULL ) + __instance = new CtThemeMgr(); + return __instance; +} + +CtThemeMgr::CtThemeMgr() +{ + WENTER(); + __theme = elm_theme_new(); + elm_theme_ref_set(__theme, NULL); +} + +CtThemeMgr::~CtThemeMgr() +{ + WHIT(); + for (auto iter = __themeList.begin(); iter != __themeList.end(); iter++) { + WDEBUG("theme %s", (*iter).c_str()); + elm_theme_extension_del(__theme, (*iter).c_str()); + } + + elm_theme_free(__theme); + __themeList.clear(); +} + +void CtThemeMgr::destroy() +{ + WHIT(); + delete __instance; + __instance = NULL; +} + + +void CtThemeMgr::setObjectTheme(Evas_Object *obj) +{ + elm_object_theme_set(obj, __theme); +} + +Elm_Theme* CtThemeMgr::getTheme() +{ + return __theme; +} + +bool CtThemeMgr::addExtensionTheme(const char *themePath) +{ + WENTER(); + WPRET_VM(themePath == NULL, false, "themePath is NULL"); + + for (auto iter = __themeList.begin(); iter != __themeList.end(); iter++) + { + WDEBUG("themePath:%s", themePath); + if(strcmp(themePath, (*iter).c_str()) == 0) { + return false; + } + } + + WDEBUG("themePath %s", themePath); + __themeList.push_back(themePath); + elm_theme_extension_add(__theme, themePath); + + WLEAVE(); + return true; +} + + + +bool CtThemeMgr::removeExtensionTheme(const char *themePath) +{ + WENTER(); + WPRET_VM(themePath == NULL, false, "themePath is NULL"); + + for (auto iter = __themeList.begin(); iter != __themeList.end(); iter++) + { + if(strcmp(themePath, (*iter).c_str()) == 0) { + __themeList.erase(iter); + elm_theme_extension_del(__theme, themePath); + WDEBUG("themePath %s", themePath); + return true; + } + } + + return false; +} diff --git a/lib-contact/ct-common/src/CtThread.cpp b/lib-contact/ct-common/src/CtThread.cpp new file mode 100644 index 0000000..2110749 --- /dev/null +++ b/lib-contact/ct-common/src/CtThread.cpp @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "CtType.h" +#include "ContactsDebug.h" +#include "CtThread.h" + +#define CT_THREAD_TIMER_DURATION 0.02 + +CtThread::CtThread(ctThreadJob job, void *jobData, ctThreadCompleteCb completeCb, void *completeCbData) +{ + WHIT(); + __isAlive = false; + __isComplete = false; + __pthread = 0; + __timer = NULL; + __job = job; + __jobData = jobData; + __completeCb = completeCb; + __completeCbData = completeCbData; +} + + +void CtThread::start() +{ + WENTER(); + + int ret; + ret = pthread_create(&__pthread, NULL, __ctThreadJob, this); + WPRET_M(0 != ret, "pthread_create() Failed(%d)", ret); + + __isAlive = true; + __timer = ecore_timer_add(CT_THREAD_TIMER_DURATION, __ctThreadTimerCb, this); + +} + +void CtThread::__cancel() +{ + WENTER(); + if(__timer){ + ecore_timer_del(__timer); + } + __timer = NULL; + + __completeCb = NULL; + + __isAlive = false; + __isComplete = false; + + WDEBUG("pthread_join(%p)", __pthread); + + if(__pthread > 0) { + WDEBUG("thread join start"); + pthread_join(__pthread, NULL); + __pthread = 0; + WDEBUG("thread join end"); + } + + WLEAVE(); +} + +void CtThread::destroy() +{ + WHIT(); + + __cancel(); + + delete this; +} + + +Eina_Bool CtThread::__ctThreadTimerCb(void *data) +{ + CtThread *self = (CtThread*)data; + WPRET_VM(NULL == self, ECORE_CALLBACK_CANCEL, "data NULL"); + WPRET_VM(self->__isAlive, ECORE_CALLBACK_RENEW, "thread alive yet"); + + WDEBUG("pthread_join(%p)", self->__pthread); + + if(self->__pthread > 0) { + WDEBUG("thread join start"); + pthread_join(self->__pthread, NULL); + self->__pthread = 0; + WDEBUG("thread join end"); + } + + self->__timer = NULL; + + if (self->__isComplete && self->__completeCb) { + self->__completeCb(self->__completeCbData); + } + + return ECORE_CALLBACK_CANCEL; +} + + + +PTHREAD_FN CtThread::__ctThreadJob(void *data) +{ + WENTER(); + + CtThread *self = (CtThread*)data; + WDEBUG("thread job start"); + if(self->__job) + self->__job(self->__jobData); + WDEBUG("thread job end"); + self->__isAlive = false; + self->__isComplete = true; + WDEBUG("thread pthread_exit"); + pthread_exit(NULL); + + WLEAVE(); +} + +CtThread::~CtThread() +{ + +} + diff --git a/lib-contact/ct-common/src/CtView.cpp b/lib-contact/ct-common/src/CtView.cpp new file mode 100755 index 0000000..e31fd2d --- /dev/null +++ b/lib-contact/ct-common/src/CtView.cpp @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "CtView.h" +#include "ContactsDebug.h" + + +CtView::CtView() +{ + WHIT(); + __layout = NULL; + __emergencyMode = 0; + __easyMode = 0; + + + //evas_object_smart_callback_add(layout, "language,changed", __languageChangedCb , this); + //evas_object_smart_callback_add(getWindow()->getEvasObj(), "wm,rotation,changed", __windowChangedCb , this); +} + +CtView::~CtView() +{ + WHIT(); + + evas_object_smart_callback_del_full(__layout, "language,changed", __languageChangedCb , this); +/* + evas_object_smart_callback_del_full(__layout, "language,changed", __languageChangedCb , this); + evas_object_smart_callback_del_full(getWindow()->getEvasObj(), "wm,rotation,changed", __windowRotationCb , this); +*/ +} + +int CtView::getEmergencyMode() +{ + return __emergencyMode; +} + +int CtView::getEasyMode() +{ + return __easyMode; +} + + +void CtView::__languageChangedCb(void* data, Evas_Object* obj, void* event_info) +{ + WHIT(); + CtView *self = (CtView*)data; + self->onLanguageChanged(); +} +/* +void CtView::__windowRotationCb(void* data, Evas_Object* obj, void* event_info) +{ + WHIT(); + CtView *self = data; + self->onWinRotate(); +} +*/ +// +Evas_Object* CtView::createBaseLayout(Evas_Object* parent) +{ + WHIT(); + Evas_Object *layout = elm_layout_add(parent); + elm_layout_theme_set(layout, "layout", "application", "default"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(layout); + + evas_object_smart_callback_add(layout, "language,changed", __languageChangedCb , this); + + return layout; + +} + + diff --git a/lib-contact/ct-detail/.cproject b/lib-contact/ct-detail/.cproject new file mode 100644 index 0000000..a5e05c9 --- /dev/null +++ b/lib-contact/ct-detail/.cproject @@ -0,0 +1,578 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage"> + <storageModule moduleId="org.eclipse.cdt.core.settings"> + <cconfiguration id="org.tizen.nativecore.config.sbi.gcc45.so.debug.733114978"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.tizen.nativecore.config.sbi.gcc45.so.debug.733114978" moduleId="org.eclipse.cdt.core.settings" name="Debug"> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> + <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + </extensions> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <configuration artifactExtension="so" artifactName="ct-detail" buildArtefactType="org.tizen.nativecore.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.sharedLib,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.so.debug.733114978" name="Debug" parent="org.tizen.nativecore.config.sbi.gcc45.so.debug"> + <folderInfo id="org.tizen.nativecore.config.sbi.gcc45.so.debug.733114978." name="/" resourcePath=""> + <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.so.debug.1671982753" name="Tizen Core Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.so.debug"> + <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.1231818368" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/> + <builder autoBuildTarget="all" buildPath="${workspace_loc:/ct-detail}/Debug" enableAutoBuild="true" id="org.tizen.nativecore.target.sbi.gnu.builder.1949297261" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" parallelBuildOn="true" parallelizationNumber="unlimited" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/> + <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.719434481" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/> + <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.841462338" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler"> + <option id="gnu.cpp.compiler.option.optimization.level.402083544" 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.debugging.level.core.23706693" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/> + <option defaultValue="true" id="sbi.gnu.cpp.compiler.option.misc.pic.core.1160483029" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.cpp.compiler.option.1674850922" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs"> + <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_llvm34.i386.core.sharedLib"/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.1665723509" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath"> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SDK_PATH}/library""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.2041721148" 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="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-fvisibility=hidden"/> + </option> + <option id="gnu.cpp.compiler.option.include.paths.579365461" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc/app-assist}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/ct-list/inc}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/carriermatch/inc}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/ct-common/inc}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/common/inc}""/> + <listOptionValue builtIn="false" value="../../../app-assist-efl/inc"/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SDK_PATH}/library""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks.core.3949846" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + </option> + <option id="gnu.cpp.compiler.option.preprocessor.def.489348503" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols"> + <listOptionValue builtIn="false" value="_DEBUG"/> + <listOptionValue builtIn="false" value="TIZEN_DEBUG_ENABLE"/> + <listOptionValue builtIn="false" value="_SDK_BUILD"/> + </option> + <option id="gnu.cpp.compiler.option.other.other.1928107877" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -std=c++0x" valueType="string"/> + <inputType id="sbi.gnu.cpp.compiler.tizen.inputType.1352902830"/> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.884132498" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool command="clang" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.1064904422" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler"> + <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.1637741243" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/> + <option id="sbi.gnu.c.compiler.option.debugging.level.core.794423367" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" value="gnu.c.debugging.level.max" valueType="enumerated"/> + <option defaultValue="true" id="sbi.gnu.c.compiler.option.misc.pic.core.2013731222" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.c.compiler.option.668102284" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs"> + <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_llvm34.i386.core.sharedLib"/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.296102097" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath"> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SDK_PATH}/library""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.1429147713" 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="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-fvisibility=hidden"/> + </option> + <option id="gnu.c.compiler.option.include.paths.770925106" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks.core.2029254141" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + </option> + <option id="gnu.c.compiler.option.preprocessor.def.symbols.577182294" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols"> + <listOptionValue builtIn="false" value="_DEBUG"/> + </option> + <inputType id="sbi.gnu.c.compiler.tizen.inputType.777610520"/> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.761875954" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.909890089" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/> + <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.1209336056" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker"> + <option defaultValue="true" id="sbi.gnu.cpp.linker.option.shared_flag.core.1852977643" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" valueType="boolean"/> + <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.654120521" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList"> + <listOptionValue builtIn="false" value="${TC_LINKER_MISC}"/> + <listOptionValue builtIn="false" value="${RS_LINKER_MISC}"/> + <listOptionValue builtIn="false" value="-lpthread "/> + <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-L"${SBI_SYSROOT}/usr/lib""/> + <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/> + </option> + <option id="gnu.cpp.link.option.paths.1550545908" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lib}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/ct-list/Debug}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/carriermatch/Debug}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/common/Debug}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/ct-common/Debug}""/> + <listOptionValue builtIn="false" value="../../../app-assist-efl/Debug"/> + </option> + <option id="gnu.cpp.link.option.libs.1793899734" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs"> + <listOptionValue builtIn="false" value="ct-list"/> + <listOptionValue builtIn="false" value="carriermatch"/> + <listOptionValue builtIn="false" value="common"/> + <listOptionValue builtIn="false" value="ct-common"/> + <listOptionValue builtIn="false" srcPrefixMapping="" srcRootPath="" value="app-assist-efl"/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.2139934058" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input"> + <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> + <additionalInput kind="additionalinput" paths="$(LIBS)"/> + </inputType> + </tool> + <tool command="i386-linux-gnueabi-as" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.975714952" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.767526932" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + <tool id="org.tizen.nativecore.tool.sbi.po.compiler.458239630" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/> + <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.535206278" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"/> + <tool id="org.tizen.nativecore.tool.fnmapgen.574602431" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/> + <tool id="org.tizen.nativecore.tool.fnmapgen.cpp.2087777887" name="C++ FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen.cpp"/> + <tool id="org.tizen.nativecore.tool.ast.1612499143" name="C Static Analyzer" superClass="org.tizen.nativecore.tool.ast"/> + <tool id="org.tizen.nativecore.tool.ast.cpp.1549270031" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/> + </toolChain> + </folderInfo> + <sourceEntries> + <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/> + <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/> + </sourceEntries> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"> + <externalSettings containerId="ct-list;" factoryId="org.eclipse.cdt.core.cfg.export.settings.sipplier"/> + </storageModule> + </cconfiguration> + <cconfiguration id="org.tizen.nativecore.config.sbi.gcc45.so.release.924732129"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.tizen.nativecore.config.sbi.gcc45.so.release.924732129" moduleId="org.eclipse.cdt.core.settings" name="Release"> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> + <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + </extensions> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <configuration artifactExtension="so" artifactName="ct-detail" buildArtefactType="org.tizen.nativecore.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.sharedLib" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.so.release.924732129" name="Release" parent="org.tizen.nativecore.config.sbi.gcc45.so.release"> + <folderInfo id="org.tizen.nativecore.config.sbi.gcc45.so.release.924732129." name="/" resourcePath=""> + <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.so.release.1948418090" name="Tizen Core Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.so.release"> + <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.1449119755" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/> + <builder buildPath="${workspace_loc:/ct-detail}/Release" id="org.tizen.nativecore.target.sbi.gnu.builder.2081669966" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/> + <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.871632349" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/> + <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.642992971" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler"> + <option id="gnu.cpp.compiler.option.optimization.level.1091784034" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/> + <option id="sbi.gnu.cpp.compiler.option.debugging.level.core.1304367202" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core"/> + <option defaultValue="true" id="sbi.gnu.cpp.compiler.option.misc.pic.core.2087093264" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.cpp.compiler.option.1768795935" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs"> + <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_llvm34.i386.core.sharedLib"/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.1032766660" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath"> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SDK_INSTALL_PATH}/library""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/EGL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/GLES""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/GLES2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/KHR""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.1197857985" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.core" valueType="stringList"> + <listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain ${SDK_INSTALL_PATH}/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.6/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/> + <listOptionValue builtIn="false" value=""/> + <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-fvisibility=hidden"/> + </option> + <option id="gnu.cpp.compiler.option.include.paths.1977030670" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + <listOptionValue builtIn="false" value="../../../app-assist-efl/inc"/> + <listOptionValue builtIn="false" value=""${workspace_loc:/common/inc}""/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks.core.959566350" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + </option> + <inputType id="sbi.gnu.cpp.compiler.tizen.inputType.819638528"/> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1733628775" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool command="clang" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.2003263497" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler"> + <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.option.optimization.level.35944084" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/> + <option id="sbi.gnu.c.compiler.option.debugging.level.core.526622017" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core"/> + <option defaultValue="true" id="sbi.gnu.c.compiler.option.misc.pic.core.1131372015" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.c.compiler.option.1867659485" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs"> + <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_llvm34.i386.core.sharedLib"/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.868237870" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath"> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SDK_INSTALL_PATH}/library""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/EGL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/GLES""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/GLES2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/KHR""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.1921633924" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.core" valueType="stringList"> + <listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain ${SDK_INSTALL_PATH}/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.6/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/> + <listOptionValue builtIn="false" value=""/> + <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-fvisibility=hidden"/> + </option> + <option id="gnu.c.compiler.option.include.paths.946929662" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks.core.2114978419" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + </option> + <inputType id="sbi.gnu.c.compiler.tizen.inputType.238407475"/> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1054529306" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.1219515644" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/> + <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.1883968601" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker"> + <option defaultValue="true" id="sbi.gnu.cpp.linker.option.shared_flag.core.1928692397" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" valueType="boolean"/> + <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.1496466690" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList"> + <listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain ${SDK_INSTALL_PATH}/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.6/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Xlinker --as-needed"/> + <listOptionValue builtIn="false" value=""/> + <listOptionValue builtIn="false" value="-lpthread "/> + <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-L"${SBI_SYSROOT}/usr/lib""/> + <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/> + </option> + <option id="gnu.cpp.link.option.paths.1440159667" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lib}""/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1945866080" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input"> + <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> + <additionalInput kind="additionalinput" paths="$(LIBS)"/> + </inputType> + </tool> + <tool command="i386-linux-gnueabi-as" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.936961471" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.910232452" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + <tool id="org.tizen.nativecore.tool.sbi.po.compiler.514808697" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/> + <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.1157111406" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"/> + <tool id="org.tizen.nativecore.tool.fnmapgen.901335212" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/> + <tool id="org.tizen.nativecore.tool.fnmapgen.cpp.811302152" name="C++ FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen.cpp"/> + <tool id="org.tizen.nativecore.tool.ast.55510356" name="C Static Analyzer" superClass="org.tizen.nativecore.tool.ast"/> + <tool id="org.tizen.nativecore.tool.ast.cpp.320528601" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/> + </toolChain> + </folderInfo> + <sourceEntries> + <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/> + <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/> + </sourceEntries> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> + </cconfiguration> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <project id="ct-detail.org.tizen.nativecore.target.sbi.gcc45.so.101672261" name="Tizen Core Shared Library" projectType="org.tizen.nativecore.target.sbi.gcc45.so"/> + </storageModule> + <storageModule moduleId="scannerConfiguration"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + <scannerConfigBuildInfo instanceId="org.tizen.nativecore.config.sbi.gcc45.so.debug.733114978"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.tizen.nativecommon.TizenGCCManagedMakePerProjectProfileCPP"/> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="org.tizen.nativecore.config.sbi.gcc45.so.release.924732129"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.tizen.nativecommon.TizenGCCManagedMakePerProjectProfileCPP"/> + </scannerConfigBuildInfo> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/> + <storageModule moduleId="org.tizen.tizen.nativeapp.projectInfo" version="1.0.0"/> + <storageModule moduleId="refreshScope" versionNumber="2"> + <configuration configurationName="Release"> + <resource resourceType="PROJECT" workspacePath="/ct-detail"/> + </configuration> + <configuration configurationName="Debug"> + <resource resourceType="PROJECT" workspacePath="/ct-detail"/> + </configuration> + </storageModule> +</cproject> diff --git a/lib-contact/ct-detail/.project b/lib-contact/ct-detail/.project new file mode 100644 index 0000000..12d82bf --- /dev/null +++ b/lib-contact/ct-detail/.project @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>ct-detail</name> + <comment></comment> + <projects> + <project>ct-list</project> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> + <triggers>full,incremental,</triggers> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.tizen.nativecore.apichecker.core.builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.cdt.core.cnature</nature> + <nature>org.eclipse.cdt.core.ccnature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> + <nature>org.tizen.nativecore.apichecker.core.tizenCppNature</nature> + </natures> + <filteredResources> + <filter> + <id>1413282507945</id> + <name></name> + <type>26</type> + <matcher> + <id>org.eclipse.ui.ide.multiFilter</id> + <arguments>1.0-projectRelativePath-matches-false-false-*/.tpk</arguments> + </matcher> + </filter> + </filteredResources> +</projectDescription> diff --git a/lib-contact/ct-detail/.tproject b/lib-contact/ct-detail/.tproject new file mode 100644 index 0000000..f1cc1fd --- /dev/null +++ b/lib-contact/ct-detail/.tproject @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<tproject xmlns="http://www.tizen.org/tproject"> + <platforms> + <platform> + <name>mobile-2.3</name> + </platform> + </platforms> + <package> + <blacklist/> + </package> +</tproject> diff --git a/lib-contact/ct-detail/CMakeLists.txt b/lib-contact/ct-detail/CMakeLists.txt new file mode 100755 index 0000000..ebd50b1 --- /dev/null +++ b/lib-contact/ct-detail/CMakeLists.txt @@ -0,0 +1,21 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(ct-detail CXX) + +INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/app-assist-efl/inc + ${CMAKE_SOURCE_DIR}/lib-common/inc + ${CMAKE_SOURCE_DIR}/lib-contact/ct-common/inc + ${CMAKE_SOURCE_DIR}/lib-contact/ct-list/inc + ${CMAKE_CURRENT_SOURCE_DIR}/inc + ${CMAKE_CURRENT_SOURCE_DIR}/src +) + +FILE(GLOB SRCS "src/*.cpp") +ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${TIZEN_PKGS_LDFLAGS} + "app-assist-efl" + "contacts-common" + "ct-common" +) + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_APP_LIB_DIR}) diff --git a/lib-contact/ct-detail/inc/CtDetailView.h b/lib-contact/ct-detail/inc/CtDetailView.h new file mode 100755 index 0000000..0ae0ede --- /dev/null +++ b/lib-contact/ct-detail/inc/CtDetailView.h @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_DETAIL_VIEW_H_ +#define _CT_DETAIL_VIEW_H_ + +#include <Ecore.h> +#include <Elementary.h> +#include <contacts.h> + +#include "WDefine.h" +#include "WPopup.h" +#include "WNaviframe.h" +#include "WView.h" + +#include "ContactsCommon.h" + +#include "ICtChangeListener.h" +#include "CtType.h" +#include "CtView.h" + +class CtDetailData; +class CtDetailViewBasicInfoControl; + +class WAPP_ASSIST_EXPORT CtDetailView: public WView, public CtView, public ICtChangeListener +{ +public: + CtDetailView(int personId); + virtual const char* getClassName(); + int getPersoinId(void); + + +protected: + virtual Evas_Object* onCreate(Evas_Object* parent, void* viewParam); + virtual void onDestroy(); + virtual void onPushed(Elm_Object_Item* naviItem); + virtual void onEvent(int eventType); + +protected: + virtual void onLanguageChanged(); + +private: + + virtual void onDbChanged(const char* viewUri); + virtual void onCompleteGetContacts(int offset); + virtual void onConditionChagned(); + +private: + typedef enum { + DETAIL_NUMBER = 0, + DETAIL_EMAIL, + DETAIL_ADDRESS, + DETAIL_MESSENGER, + DETAIL_WEBSITE, + DETAIL_RELATIONSHIP, + DETAIL_EVENT, + DETAIL_NOTE, + DETAIL_ADDRBOOK, + DETAIL_ITEMS_MAX, + } CtDetailItems; + void __initialize(); + Evas_Object* __getWindow(void); + + void __setItemClassStyle(); + void __addAllItems(); + void __addItem(CtDetailItems itemType); + + void __addNumberItems(); + void __addEmailItems(); + void __addNoteItems(); + void __addAddressItems(); + void __addEventItems(); + void __addRelationItems(); + void __addWebsiteItems(); + void __addMessengerItems(); + void __addAddressbookItems(); + void __updateGenlist(); + + static void __onBasicInfoFavoritesClickedCb(void *data, Evas_Object *obj, void *event_info); + static void __onNumberCallIconSelectedCb(void *data, Evas_Object *obj, const char *emission, const char *source); + static void __onNumberMessageIconSelectedCb(void *data, Evas_Object *obj, const char *emission, const char *source); + static void __onPhonenumberItemSelectedCb(void *data, Evas_Object *obj, void *event_info); + static void __onEmailItemSelectedCb(void *data, Evas_Object *obj, void *event_info); + static void __onWebsiteItemSelectedCb(void *data, Evas_Object *obj, void *event_info); + + static void __onEditCb(void *data, Evas_Object *obj, void *event_info); + static void __onDeleteCb(void *data, Evas_Object *obj, void *event_info); + static int __deleteContacts(void *data); + static void __onShareCb(void *data, Evas_Object *obj, void *event_info); + + static void __detailBackBtnCb(void *data, Evas_Object *obj, const char *emission, const char *source); + + void __createBaseInfo(); + void __updateNumberFields(); + int __getHeightByItemCount(Evas_Object* win, int count); + + static void __linkContactReplyCb(app_control_h request, app_control_h reply, app_control_result_e result, void *data); + static void __launchVideoCall(CtDetailView *p, Eina_List *numberList); + + bool __checkConditionForGenlistHomogeneous(CtDetailData *detailData); +private: + CtDetailView(); + virtual ~CtDetailView(); + +private: + CtDetailData *__detailData; + CtDetailViewBasicInfoControl *__basicInfo; + + Evas_Object *__mainLayout; + Evas_Object *__genlist; + Elm_Object_Item *__genlistItems[DETAIL_ITEMS_MAX]; + Elm_Object_Item *__genlistItemNumberFirst; + Elm_Object_Item *__genlistItemNumberLast; + + int __appendIndex; + bool __checkStatus; + Elm_Object_Item* __emailItem; + bool __needHomogeneous; +}; + +#endif /* _CT_DETAIL_VIEW_H_ */ diff --git a/lib-contact/ct-detail/inc/CtDetailViewBasicInfoControl.h b/lib-contact/ct-detail/inc/CtDetailViewBasicInfoControl.h new file mode 100644 index 0000000..9c9483e --- /dev/null +++ b/lib-contact/ct-detail/inc/CtDetailViewBasicInfoControl.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + +#ifndef _CT_DETAIL_VIEW_BASIC_INFO_CONTROL_H_ +#define _CT_DETAIL_VIEW_BASIC_INFO_CONTROL_H_ + +#include "WControl.h" + +class CtDetailDataBase; + +class CtDetailViewBasicInfoControl : public WControl +{ +public: + /** + * @brief Create Basic info view + * @param[in] data Base detail data + * @param[in] showFavoriteIcon True if favorite icon should be shown + */ + CtDetailViewBasicInfoControl(CtDetailDataBase *data, bool showFavoriteIcon); + +protected: + virtual Evas_Object *onCreate(Evas_Object *parent, void *param); + +private: + int getLinesCount(); + void updateBaseLayout(Evas_Object *parent); + void setThumbnail(); + void setFavoriteBtn(); + void setText(const char *text, const char *textPart); + + static void onBasicInfoFavoritesClickedCb(void *data, Evas_Object *obj, void *event_info); + +private: + CtDetailDataBase *m_DetailData; + Evas_Object *m_BaseLayout; + bool m_ShowFavoriteIcon; + bool m_FavoriteReference; +}; + +#endif /* _CT_DETAIL_VIEW_BASIC_INFO_CONTROL_H_ */ diff --git a/lib-contact/ct-detail/inc/CtEditTabView.h b/lib-contact/ct-detail/inc/CtEditTabView.h new file mode 100644 index 0000000..fc1c80e --- /dev/null +++ b/lib-contact/ct-detail/inc/CtEditTabView.h @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_EDIT_TAB_VIEW_H_ +#define _CT_EDIT_TAB_VIEW_H_ + +#include <vector> +#include <app.h> +#include <string> +#include <memory> +#include <Ecore.h> + +#include "WPageSlideView.h" + +#include "ContactsCommon.h" +#include "CtInputView.h" + + +class CtInputView; +#define EDIT_TAB_VIEW_MAX 10 +class WAPP_ASSIST_EXPORT CtEditTabView: public WPageSlideView +{ +public: + CtEditTabView(Eina_List* contactList); + +public: + void updateSaveBtn(Eina_Bool empty); + + +private: + virtual Evas_Object* onCreate(Evas_Object* parent, void* viewParam); + virtual void onDestroy(); + virtual Elm_Object_Item* onPushToNaviframe( Evas_Object* naviFrame); + virtual void onPushed(Elm_Object_Item* naviItem); + virtual bool onPop(); + +private: + bool __checkViewExist(Elm_Object_Item *tabItem); + void __getTabViewTitle(contacts_record_h recordContact, char *buf, int bufLen); + + static void __onTabChangedCb(void* data, Evas_Object* obj, void* event_info); + static void __pageScrollStopCb(void* data, Evas_Object* obj, void* event_info); + static void __pageScrollStartCb(void* data, Evas_Object* obj, void* event_info); + static void __cancelCb(void *data, Evas_Object *obj, void *event_info); + static void __saveCb(void *data, Evas_Object *obj, void *event_info); + + void __tabChanged(Elm_Object_Item *selectedItem); + + static Eina_Bool __createRestViewTimerCb(void* data); + +private: + ~CtEditTabView(); + +private: + Evas_Object* __tabbar; + Evas_Object* __saveBtn; + Elm_Object_Item* __tabItem[EDIT_TAB_VIEW_MAX]; + int __tabCount; + int __selectedView; + bool __subViewLoaded[EDIT_TAB_VIEW_MAX]; + CtInputView* __subView[EDIT_TAB_VIEW_MAX]; + bool __hasTitle; + bool __discard; + Ecore_Timer *__timer; + Ecore_Idler *__idler; + +}; + + + +#endif // _CT_EDIT_TAB_VIEW_H_ diff --git a/lib-contact/ct-detail/inc/CtInputView.h b/lib-contact/ct-detail/inc/CtInputView.h new file mode 100644 index 0000000..93a256a --- /dev/null +++ b/lib-contact/ct-detail/inc/CtInputView.h @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_INPUT_VIEW_H_ +#define _CT_INPUT_VIEW_H_ + +#include <Elementary.h> + +#include <contacts.h> + +#include "WNaviframe.h" +#include "WPopup.h" +#include "WView.h" + +#include "ContactsCommon.h" + +#include "IContactsTabPageView.h" +#include "ICtChangeListener.h" +#include "CtEditTabView.h" +#include "CtType.h" +#include "CtView.h" +#include "CtThread.h" + +class CtData; +class CtInputViewControl; +class CtEditTabView; + +class WAPP_ASSIST_EXPORT CtInputView: public CtView, public IContactsTabPageView, public ICtChangeListener +{ +public: + CtInputView(contacts_record_h contactRecord); + CtInputView(contacts_record_h contactRecord, CtEditTabView* tabView, bool isSubView); + CtInputView(int personId, const char* number, const char* email, const char* uri); + CtInputView(const char* name, const char* number, const char* email, const char* uri); + +public: + bool getIsCreate() { return __isCreate; } + bool getIsDestroy() { return __destroy; } + Evas_Object* getNaviframeEvasObj(); + Evas_Object* getWindowEvasObj(); + Evas_Object* getConformantEvasObject(); + void setOnResult(const std::function<void(int, CtResultType)>& handlerFunc); + + void createEditSubViewContent(); + void createInputViewControl(Evas_Object *base); + void updateSaveBtn(Eina_Bool empty); + void updateNumberSaveBtn(Eina_Bool isEmpty); + void saveContactForEditTabSubView(); + void getChangedForEditTabSubView(bool* changed); + void getEmptyForEditTabSubView(bool* empty); + virtual void onTabSelect(Elm_Object_Item *naviItem); + virtual void onTabUnselect(Elm_Object_Item *naviItem); + virtual bool onTabPop(); + virtual void onTabScrollStart() {return;} + virtual void onTabScrollStop() {return;} + void resetTheme(); + +protected: + virtual Evas_Object* onCreate(Evas_Object* parent, void* viewParam); + virtual void onDestroy(); + virtual void onPushed(Elm_Object_Item* naviItem); + virtual void onEvent(int eventType); + virtual bool onPop(); + +protected: + virtual void onLanguageChanged(); + +private: + + virtual void onDbChanged(const char* viewUri); + virtual void onCompleteGetContacts(int offset); + virtual void onConditionChagned(); + + void __initialize(); + + void __createToastPopup(const char* msg); + static void __saveCb(void *data, Evas_Object *obj, void *event_info); + static void __cancelCb(void *data, Evas_Object *obj, void *event_info); + int __getPersonIdByContactId(int contactId); + + static Eina_Bool __createAddressbookPopupIdlerCb(void *data); + +private: + CtInputView(); + virtual ~CtInputView(); + +private: + + WUiObjectPtr __inputControl; + CtEditTabView *__tabView; + std::shared_ptr<CtData> __inputData; + + int __savedAddressbookId; + bool __isCreate; + bool __saved; + bool __discard; + bool __changed; + bool __destroy; + + Evas_Object* __saveBtn; + Evas_Object* __baseLayout; + + Ecore_Idler *__popupIdler; + Ecore_Event_Handler* __windowVisibilityChangeHandler; + std::function<void(int, CtResultType)> __resultHandler; +}; + +#endif /* _CT_INPUT_VIEW_H_ */ diff --git a/lib-contact/ct-detail/inc/CtMyProfileDetailView.h b/lib-contact/ct-detail/inc/CtMyProfileDetailView.h new file mode 100755 index 0000000..e1ae43d --- /dev/null +++ b/lib-contact/ct-detail/inc/CtMyProfileDetailView.h @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_MYPROFILE_DETAIL_VIEW_H_ +#define _CT_MYPROFILE_DETAIL_VIEW_H_ + +#include <Elementary.h> +#include <contacts.h> + +#include "WDefine.h" +#include "WPopup.h" +#include "WNaviframe.h" +#include "WView.h" + +#include "ContactsCommon.h" + +#include "ICtChangeListener.h" +#include "CtType.h" +#include "CtView.h" + +class CtMyProfileDetailData; + +class WAPP_ASSIST_EXPORT CtMyProfileDetailView: public WView, public CtView, public ICtChangeListener +{ +public: + CtMyProfileDetailView(); + virtual const char* getClassName(); + + int getPersoinId(void); + + +protected: + virtual Evas_Object* onCreate(Evas_Object* parent, void* viewParam); + virtual void onDestroy(); + virtual void onPushed(Elm_Object_Item* naviItem); + virtual void onEvent(int eventType); + +public: + + virtual void onDbChanged(const char* viewUri); + virtual void onCompleteGetContacts(int offset); + virtual void onConditionChagned(); + +protected: + virtual void onLanguageChanged(); + +private: + typedef enum { + MYPROFILE_DETAIL_MSISDN = 0, + MYPROFILE_DETAIL_NUMBER, + MYPROFILE_DETAIL_EMAIL, + MYPROFILE_DETAIL_NOTE, + MYPROFILE_DETAIL_ADDRESS, + MYPROFILE_DETAIL_EVENT, + MYPROFILE_DETAIL_RELATIONSHIP, + MYPROFILE_DETAIL_WEBSITE, + MYPROFILE_DETAIL_MESSENGER, + MYPROFILE_DETAIL_ITEMS_MAX, + } CtMyProfileDetailItems; + void __initialize(); + Evas_Object* __getWindow(void); + + void __setItemClassStyle(); + void __addAllItems(); + void __addItem(int itemType); + + void __createBaseInfo(); + + void __addMsisdnItem(); + void __addNumberItems(); + void __addEmailItems(); + void __addNoteItems(); + void __addAddressItems(); + void __addEventItems(); + void __addRelationItems(); + void __addWebsiteItems(); + void __addMessengerItems(); + + static void __basicInfoBackBtnCb(void *data, Evas_Object *obj, const char *emission, const char *source); + static void __onShareCb(void *data, Evas_Object *obj, void *event_info); + static void __onDeleteCb(void *data, Evas_Object *obj, void *event_info); + bool __isContactSyncToAnyAccount(contacts_record_h personRecord); + int __deleteContacts(void *data); + + void __updateGenlist(); + +private: + virtual ~CtMyProfileDetailView(); + +private: + + CtMyProfileDetailData *__detailData; + + Evas_Object *__mainLayout; + Evas_Object *__genlist; + Elm_Object_Item *__genlistItems[MYPROFILE_DETAIL_ITEMS_MAX]; +}; + +#endif /* _CT_MYPROFILE_DETAIL_VIEW_H_ */ diff --git a/lib-contact/ct-detail/inc/CtMyProfileInputView.h b/lib-contact/ct-detail/inc/CtMyProfileInputView.h new file mode 100755 index 0000000..ad06b18 --- /dev/null +++ b/lib-contact/ct-detail/inc/CtMyProfileInputView.h @@ -0,0 +1,185 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_MYPROFILE_INPUT_VIEW_H_ +#define _CT_MYPROFILE_INPUT_VIEW_H_ + +#include <Elementary.h> + +#include <contacts.h> + +#include "WNaviframe.h" +#include "WPopup.h" +#include "WView.h" + +#include "ContactsCommon.h" + +#include "ICtChangeListener.h" +#include "CtType.h" +#include "CtView.h" + +class CtData; + +class WAPP_ASSIST_EXPORT CtMyProfileInputView: public WView, public CtView, public ICtChangeListener +{ +public: + CtMyProfileInputView(contacts_record_h contactRecord); + +protected: + virtual Evas_Object* onCreate(Evas_Object* parent, void* viewParam); + virtual void onDestroy(); + virtual void onPushed(Elm_Object_Item* naviItem); + virtual void onEvent(int eventType); + virtual bool onPop(); + +private: + + virtual void onDbChanged(const char* viewUri); + virtual void onCompleteGetContacts(int offset); + virtual void onConditionChagned(); + +protected: + virtual void onLanguageChanged(); + +private: + typedef struct { + CtMyProfileInputView *view; + contacts_record_h record; + Elm_Object_Item *item; + const char *view_uri; + bool isChanged; + char *oldVal; + }CtMyProfileInputViewItem; + + void __initialize(); + void __addAllItems(); + void __addItem(int itemType); + + Evas_Object* __getWindowEvasObj(void); + Evas_Object* __getNaviframeEvasObj(void); + + static void __onGallerySelCb(void *data, Evas_Object *obj, void *event_info); + static void __onCameraSelCb(void *data, Evas_Object *obj, void *event_info); + static void __onRemoveSelCb(void *data, Evas_Object *obj, void *event_info); + + static void __importantSubitemSelectedCb(void* data, Evas_Object* obj, void* event_info); + void __addNumberClickedCb(); + void __addEmailClickedCb(); + void __addNoteClickedCb(); + void __addMoreClickedCb(); + bool __checkIsEmpty(); + bool __checkIsChanged(); + void __updateSaveBtn(); + void __updateNoteBtn(bool isNoteInput); + void __save(); + + + static void __saveCb(void *data, Evas_Object *obj, void *event_info); + static void __cancelCb(void *data, Evas_Object *obj, void *event_info); + static void __genlistRealizedCb(void *data, Evas_Object *obj, void *event_info); + static void __genlistUnrealizedCb(void *data, Evas_Object *obj, void *event_info); + + static void __galleryReplyCb(app_control_h request, app_control_h reply, app_control_result_e result, void *data); + static void __launchGallery(CtMyProfileInputView *view); + + static void __cameraReplyCb(app_control_h request, app_control_h reply, app_control_result_e result, void *data); + static void __launchCamera(CtMyProfileInputView *view); + + void __itemChanged(); + void __basicInfoItemImageClicked(Evas_Object* obj); + void __basicInfoItemDeleted( int deletedInfo); + void __basicInfoItemShowCreateKeypad( Evas_Object* obj); + void __basicInfoExpandClickedCb(); + void __basicInfoUpdateImage(); + + Elm_Object_Item* __getLastItem(Elm_Object_Item* deleteItem); + void __numberItemDeleted(Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record); + void __emailItemDeleted(Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record); + void __addressItemDeleted(Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record); + void __messengerItemDeleted(Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record); + void __websiteItemDeleted(Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record); + void __eventItemDeleted(Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record); + void __noteItemDeleted( Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record); + void __activateNextEntry(Evas_Object* obj, Elm_Object_Item* item); + void __updateEntryReturnKeyType(Elm_Object_Item* deleteItem); + void __updateBasicInfoItem(); + void __createEventDataPopup(); + void __appendEventItem(int year, int month, int day); + +private: + CtMyProfileInputView(); + virtual ~CtMyProfileInputView(); + +private: + + typedef enum { + MYPROFILE_INPUT_BASIC_INFO = 0, + MYPROFILE_INPUT_MSISDN, + MYPROFILE_INPUT_NUMBER, + MYPROFILE_INPUT_EMAIL, + MYPROFILE_INPUT_NOTE, + + MYPROFILE_INPUT_ADDRESS, + MYPROFILE_INPUT_EVENT, + MYPROFILE_INPUT_URL, + MYPROFILE_INPUT_MESSENGER, + + MYPROFILE_INPUT_IMPORTANT_FIELDS, + MYPROFILE_INPUT_IMPORTANT_SUBITEM, + MYPROFILE_INPUT_ITEMS_MAX, + }CtMyProfileInputItems; + + typedef enum { + MYPROFILE_INPUT_IMPORTANT_ADDRESS = 1, + MYPROFILE_INPUT_IMPORTANT_EVENT, + MYPROFILE_INPUT_IMPORTANT_NICKNAME, + MYPROFILE_INPUT_IMPORTANT_ORGANIZATION, + MYPROFILE_INPUT_IMPORTANT_URL, + MYPROFILE_INPUT_IMPORTANT_MESSENGER, + MYPROFILE_INPUT_IMPORTANT_PHONETIC_INFO, + MYPROFILE_INPUT_IMPORTANT_MAX, + }CtMyProfileInputSubItems; + + std::shared_ptr<bool> __birthdayEventExist; + std::shared_ptr<CtData> __inputData; + + int __contactId; + WPopup* __popup; + Evas_Object *__genlist; + Evas_Object *__ctxpopup; + Evas_Object *__customEntry; + int __savedAddressbookId; + + bool __saved; + bool __discard; + bool __changed; + + int __appendIndex; + int __addedIndex; + + Elm_Genlist_Item_Class __inputItc[MYPROFILE_INPUT_ITEMS_MAX]; + Elm_Object_Item *__genlistItems[MYPROFILE_INPUT_ITEMS_MAX]; + + Evas_Object *__nameEntry; + char *__basicInfoFullName; + Evas_Object* __saveBtn; + + bool __baseInfoExpanded; + bool __isCreate; +}; + +#endif /* _CT_MYPROFILE_INPUT_VIEW_H_ */ diff --git a/lib-contact/ct-detail/src/CtData.h b/lib-contact/ct-detail/src/CtData.h new file mode 100755 index 0000000..fc99425 --- /dev/null +++ b/lib-contact/ct-detail/src/CtData.h @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_DATA_H_ +#define _CT_DATA_H_ + +#include <Eina.h> + +#include <contacts.h> +//#include <contacts_product.h> + +#include "ContactsCommon.h" +#include "ICtChangeListener.h" + +#include "CtType.h" + +class CtData +{ +public: + virtual ~CtData(){}; +public: + + virtual int insertContact(int *contactId) = 0; + virtual int updateContact() = 0; + + virtual int separateFullName(contacts_record_h nameRecord, const char *full_name) = 0; + virtual int separatePhoneticFullName(contacts_record_h nameRecord, const char *full_name) = 0; + virtual int setPrefixName(const char *text) = 0; + virtual int setSuffixName(const char *text) = 0; + virtual int setPhoneticFullName(const char *text) = 0; + virtual int setPhoneticFirstName(const char *text) = 0; + virtual int setPhoneticMiddleName(const char *text) = 0; + virtual int setPhoneticLastName(const char *text) = 0; + virtual int setNickname(const char *text) = 0; + virtual int setCompany(const char *text) = 0; + virtual int setJobTitle(const char *text) = 0; + virtual int setFullName(const char *text) = 0; + virtual int setFirstName(const char *text) = 0; + virtual int setMiddleName(const char *text) = 0; + virtual int setLastName(const char *text) = 0; + virtual const char* getPrefixName() = 0; + virtual const char* getSuffixName() = 0; + virtual const char* getPhoneticFirstName() = 0; + virtual const char* getPhoneticMiddleName() = 0; + virtual const char* getPhoneticLastName() = 0; + virtual const char* getNickname() = 0; + virtual const char* getCompany() = 0; + virtual const char* getJobTitle() = 0; + virtual void getFullName(std::string &Name) = 0; + virtual const char* getFirstName() = 0; + virtual const char* getMiddleName() = 0; + virtual const char* getLastName() = 0; + // ... + virtual bool getFavorite() =0; + virtual int getPersonId() =0; + //virtual bool getMFC()=0; + + virtual int getAddressbookId() = 0; + virtual const char* getAddressbookName() = 0; + virtual const char* getUserName() = 0; + virtual void setAddressbookInfo(int addressbookId) = 0; + virtual void setPreferenceCreateFirst(bool isFirst) = 0; + + virtual const char* getImagePath() = 0; + virtual contacts_record_h getImageRecord() = 0; + virtual int removeImage(contacts_record_h record) = 0; + virtual int setImage(contacts_record_h record, char *image, int type) = 0; + + virtual contacts_record_h getEmergencyNumber() = 0; + virtual Eina_List* getNumberList() = 0; + virtual contacts_record_h addNumber(const char *number) = 0; + virtual int setNumberNumber(contacts_record_h record, const char *number) = 0; + virtual int setNumberType(contacts_record_h record, int type, const char *customStr) = 0; + virtual int removeNumber(contacts_record_h record) = 0; + virtual const char* getNumberNumber(contacts_record_h record) = 0; + virtual int getNumberType(contacts_record_h record) = 0; + virtual const char *getDataTypeCustom(contacts_record_h record, int property_id) = 0; + virtual void getNumberTypeStr(contacts_record_h record, int numberType, std::string &typeString) = 0; + virtual int getNumberRetType(int indexType) = 0; + virtual int getNumberIndexType(int numberType) = 0; + virtual int getNextNumberType() = 0; + + virtual Eina_List* getEmailList() = 0; + virtual contacts_record_h addEmail(const char *email) = 0; + virtual int setEmailEmail(contacts_record_h record, const char *email) = 0; + virtual int setEmailType(contacts_record_h record, int type, char *customStr) = 0; + virtual const char* getEmailEmail(contacts_record_h record) = 0; + virtual int getEmailType(contacts_record_h record) = 0; + virtual void getEmailTypeStr(contacts_record_h record, int indexType, std::string &typeString) = 0; + virtual int getNextEmailType() = 0; + virtual int removeEmail(contacts_record_h record) = 0; + + virtual Eina_List* getNoteList() = 0; + virtual contacts_record_h getNoteRecord() = 0; + virtual contacts_record_h addNote(const char *note) = 0; + virtual int setNote(contacts_record_h record, const char *note) = 0; + virtual const char* getNote(contacts_record_h record) = 0; + virtual int removeNote(contacts_record_h record) = 0; + + virtual Eina_List* getAddressList() = 0; + virtual contacts_record_h addAddress(const char *address) = 0; + virtual int setAddressAddress(contacts_record_h record, const char *address) = 0; + virtual int setAddressType(contacts_record_h record, int type, const char *customStr) = 0; + virtual int getAddressAddress(contacts_record_h record, char *buf, int length) = 0; + virtual int getAddressType(contacts_record_h record) = 0; + virtual void getAddressTypeStr(contacts_record_h record, int indexType, std::string &typeString) = 0; + virtual int getNextAddressType() = 0; + virtual int removeAddress(contacts_record_h record) = 0; + + virtual Eina_List* getMessengerList() = 0; + virtual contacts_record_h addMessenger(const char *messenger) = 0; + virtual int setMessengerMessenger(contacts_record_h record, const char *messenger) = 0; + virtual int setMessengerType(contacts_record_h record, int type, const char *customStr) = 0; + virtual int getMessengerIndexType(int emailType) = 0; + virtual int getMessengerRetType(int indexType) = 0; + virtual const char* getMessengerMessenger(contacts_record_h record) = 0; + virtual int getMessengerType(contacts_record_h record) = 0; + virtual void getMessengerTypeStr(contacts_record_h record, int indexType, std::string &typeString) = 0; + virtual int getNextMessengerType() = 0; + virtual int removeMessenger(contacts_record_h record) = 0; + + virtual Eina_List* getWebsiteList() = 0; + virtual contacts_record_h addWebsite(const char *url) = 0; + virtual int setWebsiteWebsite(contacts_record_h record, const char *url) = 0; + virtual const char* getWebsiteWebsite(contacts_record_h record) = 0; + virtual int removeWebsite(contacts_record_h record) = 0; + + virtual Eina_List* getRelationshipList() = 0; + virtual contacts_record_h addRelationship(const char *relationship) = 0; + virtual int setRelationshipRelationship(contacts_record_h record, const char *relationship) = 0; + virtual int setRelationshipType(contacts_record_h record, int type, const char *customStr) = 0; + virtual const char* getRelationshipRelationship(contacts_record_h record) = 0; + virtual int getRelationshipType(contacts_record_h record) = 0; + virtual void getRelationshipTypeStr(contacts_record_h record, int indexType, std::string &typeString) = 0; + virtual int getNextRelationshipType() = 0; + virtual int removeRelationship(contacts_record_h record) = 0; + + virtual Eina_List* getEventList() = 0; + virtual contacts_record_h addEvent(int date) = 0; + virtual int setEventEvent(contacts_record_h record, int date) = 0; + virtual int setEventType(contacts_record_h record, int type, char *customStr) = 0; + virtual int getEventEvent(contacts_record_h record) = 0; + virtual int getEventType(contacts_record_h record) = 0; + virtual void getEventTypeStr(contacts_record_h record, int eventType, std::string &typeString) = 0; + virtual int getNextEventType() = 0; + virtual int removeEvent(contacts_record_h record) = 0; + // ... + + + virtual int getContactId() = 0; + + virtual contacts_record_h getDefaultEmail() = 0; + virtual contacts_record_h getDefaultNumber() = 0; + virtual bool checkChangedTypeIsDeleted() = 0; + + virtual void attachListener(ICtChangeListener* listener) = 0; + virtual void detachListener() = 0; + + virtual contacts_record_h addGroupRelation(int groupId) = 0; + + // for check input addressbook item is added or not + virtual void setInputAddressbookItem(bool added) = 0; + virtual bool getInputAddressbookItem(void) = 0; + +}; + +#endif //_CT_DATA_H_ diff --git a/lib-contact/ct-detail/src/CtDetailData.cpp b/lib-contact/ct-detail/src/CtDetailData.cpp new file mode 100755 index 0000000..078ba73 --- /dev/null +++ b/lib-contact/ct-detail/src/CtDetailData.cpp @@ -0,0 +1,1571 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "ContactsDebug.h" + +#include "CtDetailData.h" +#include "CtCommon.h" +#include "CtPath.h" + +#include "ICtChangeListener.h" + +CtDetailData::CtDetailData(int personId) +{ + WDEBUG("personId %d", personId); + __personId = personId; + __personRecord = NULL; + + init(); + +} + +CtDetailData::CtDetailData(contacts_record_h personRecord) +{ + WHIT(); + __personId = 0; + __personRecord = personRecord; + + init(); + +} + +CtDetailData::CtDetailData() +{ + init(); +} + +CtDetailData::~CtDetailData() +{ + deInit(); +} + +void CtDetailData::deInit() +{ + SAFE_FREE(__displayName); + SAFE_FREE(__imagePath); + SAFE_FREE(__vibration); + SAFE_FREE(__messageAlert); + SAFE_FREE(__nickName); + SAFE_FREE(__phoneticName); + SAFE_FREE(__extraName); + __freeRecordList(__numberList); + __freeRecordList(__emailList); + __freeRecordList(__addressList); + __freeRecordList(__messengerList); + __freeRecordList(__relationshipList); + __freeRecordList(__urlList); + __freeRecordList(__eventList); + __freeRecordList(__noteList); + __freeRecordList(__contactList); + + if (__formatter) + i18n_udate_destroy (__formatter); + if (__personRecord) + contacts_record_destroy(__personRecord, true); + + int err = contacts_db_remove_changed_cb(_contacts_person._uri, __onPersonChanged, this); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_remove_changed_cb() Failed(%d)", err); +} + +void CtDetailData::init() +{ + WENTER(); + int err = CONTACTS_ERROR_NONE; + + __link_count = 0; + __imagePath = NULL; + __displayName = NULL; + __extraName = NULL; + __phoneticName = NULL; + __nickName = NULL; + __company = NULL; + __messageAlert = NULL; + __vibration = NULL; + + __contactList = NULL; + __numberList = NULL; + __emailList = NULL; + __addressList = NULL; + __messengerList = NULL; + __relationshipList = NULL; + __urlList = NULL; + __eventList = NULL; + __noteList = NULL; + __listener = NULL; + __favorite = NULL; + + // get person record + if(__personRecord == NULL && __personId > 0) + __personRecord = __getPerson(__personId); + + if(__personRecord && __personId == 0) + { + err = contacts_record_get_int(__personRecord, _contacts_person.id, &__personId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + } + + //get link count + err = contacts_record_get_int(__personRecord, _contacts_person.link_count, &__link_count); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + + // get contact list + __contactList = ctCommonGetContactsList(__personId); + + // get basic info + __getBasicInfo(__personRecord, __contactList); + + // get number list + __numberList = __getChildDataList(__contactList, _contacts_contact.number); + // get email list + __emailList = __getChildDataList(__contactList, _contacts_contact.email); + // get address list + __addressList = __getChildDataList(__contactList, _contacts_contact.address); + // get messenger list + __messengerList = __getChildDataList(__contactList, _contacts_contact.messenger); + // get url list + __urlList = __getChildDataList(__contactList, _contacts_contact.url); + // get relationship list + __relationshipList = __getChildDataList(__contactList, _contacts_contact.relationship); + // get event list + __eventList = __getChildDataList(__contactList, _contacts_contact.event); + // get note list + __noteList = __getChildDataList(__contactList, _contacts_contact.note); + + + // set db change noti + contacts_db_get_current_version(&__version); + err = contacts_db_add_changed_cb(_contacts_person._uri, __onPersonChanged, this); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_add_changed_cb() Failed(%d)", err); + + __formatter = __initTimeFormatter(); + + WLEAVE(); +} + +void CtDetailData::attachListener(ICtChangeListener* listener) +{ + WPRET_M(NULL == listener, "listener is NULL"); + __listener = listener; +} + +void CtDetailData::detachListener() +{ + __listener = NULL; +} + +int CtDetailData::getPersonId() +{ + return __personId; +} + +Eina_List* CtDetailData::getContactsList() +{ + return __contactList; +} + +int CtDetailData::__setImage(contacts_record_h record, char *image, int type) +{ + WDEBUG("image %s", image); + int err = CONTACTS_ERROR_NONE; + + if(image && *image) { + //for update + free(__imagePath); + __imagePath = strdup(image); + err = contacts_record_set_str(record, _contacts_image.path, image); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + err = contacts_record_set_int(record, _contacts_image.type, type); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_int() Failed(%d)", err); + } + return err; +} + +int CtDetailData::__removeImage(contacts_record_h contactRecord, contacts_record_h imageRecord) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + //for update + free(__imagePath); + __imagePath = NULL; + err = contacts_record_remove_child_record(contactRecord, _contacts_contact.image, imageRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_remove_child_record() Failed(%d)", err); + + err = contacts_record_destroy(imageRecord, true); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_destroy() Failed(%d)", err); + + return err; +} + + +bool CtDetailData::__getHasReadOnlyMode(void) +{ + WHIT(); + int addressbookId = -1; + //int addressbookMode = CONTACTS_ADDRESS_BOOK_MODE_EX_NONE; + int addressbookMode = CONTACTS_ADDRESS_BOOK_MODE_NONE; + int err = CONTACTS_ERROR_NONE; + Eina_List *l; + void* tmp = NULL; + contacts_record_h recordContact = NULL; + contacts_record_h recordAddressbook = NULL; + + WPRET_VM(NULL == __contactList, true, "listContacts is NULL"); + + EINA_LIST_FOREACH(__contactList, l, tmp) { + if (NULL == tmp) { + continue; + } + recordContact = (contacts_record_h)tmp; + + err = contacts_record_get_int(recordContact, _contacts_contact.address_book_id, &addressbookId); + WPRET_VM(CONTACTS_ERROR_NONE != err, false, "contacts_record_get_int() Failed(%d)", err); + + err = contacts_db_get_record(_contacts_address_book._uri, addressbookId, &recordAddressbook); + WPRET_VM(CONTACTS_ERROR_NONE != err, false, "contacts_db_get_record() Failed(%d)", err); + + err = contacts_record_get_int(recordAddressbook, _contacts_address_book.mode, &addressbookMode); + WPRET_VM(CONTACTS_ERROR_NONE != err, false, "contacts_record_get_int() Failed(%d)", err); + + err = contacts_record_destroy(recordAddressbook, true); + WPRET_VM(CONTACTS_ERROR_NONE != err, false, "contacts_record_destroy() Failed(%d)", err); + +// if (CONTACTS_ADDRESS_BOOK_MODE_EX_READONLY & addressbookMode) { + if (CONTACTS_ADDRESS_BOOK_MODE_READONLY & addressbookMode) { + return true; + } + } + return false; +} + + +int CtDetailData::setFavorite(bool favorite) +{ + WDEBUG("favorite %d", favorite); + int err = CONTACTS_ERROR_NONE; + __favorite = favorite; + + if(__getHasReadOnlyMode()) + { + err = contacts_record_set_bool(__personRecord, _contacts_person.is_favorite, __favorite); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_set_bool() Failed(%d)", err); + err = contacts_db_update_record(__personRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_update_record() Failed(%d)", err); + return err; + } + + void *data = NULL; + Eina_List *cursor = NULL; + EINA_LIST_FOREACH(__contactList, cursor, data) { + contacts_record_h contactRecord = (contacts_record_h)data; + + err = contacts_record_set_bool(contactRecord, _contacts_contact.is_favorite, __favorite); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_set_bool() Failed(%d)", err); + err = contacts_db_update_record(contactRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_update_record() Failed(%d)", err); + } + + return err; +} + +bool CtDetailData::getFavorite() +{ + return __favorite; +} +/* +bool CtDetailData::getMFC() +{ + int err = CONTACTS_ERROR_NONE; + contacts_list_h personUsageList = NULL; + contacts_query_h query= NULL; + contacts_filter_h filter = NULL; + + err = contacts_query_create(_contacts_person_usage._uri, &query); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_create() Failed(%d)", err); + err = contacts_filter_create(_contacts_person_usage._uri, &filter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + do { + if (CONTACTS_ERROR_NONE != (err = contacts_filter_add_int(filter, _contacts_person_usage.times_used, CONTACTS_MATCH_GREATER_THAN_OR_EQUAL, 1))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_filter_add_int(filter, _contacts_person_usage.usage_type, CONTACTS_MATCH_EQUAL, CONTACTS_USAGE_STAT_TYPE_OUTGOING_CALL))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_filter_add_bool(filter, _contacts_person_usage.is_favorite, false))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_query_set_filter(query, filter))) break; + } while (0); + + err = contacts_query_set_sort(query, _contacts_person_usage.times_used, false); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_sort() Failed(%d)", err); + + err = contacts_db_get_records_with_query(query, 0, 5, &personUsageList); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_get_list() Failed(%d)", err); + + contacts_filter_destroy(filter); + contacts_query_destroy(query); + contacts_record_h recordPerson = NULL; + int mfcIndex = 1; + + while (CONTACTS_ERROR_NONE == contacts_list_get_current_record_p(personUsageList, &recordPerson)) { + if(mfcIndex >5) + break; + int personId = -1; + err = contacts_record_get_int(recordPerson, _contacts_person.id, &personId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + if(__personId == personId){ + contacts_list_destroy(personUsageList, true); + return true; + } + mfcIndex++; + contacts_list_next(personUsageList); + } + contacts_list_destroy(personUsageList, true); + return false; +} +*/ +const char* CtDetailData::getImagePath() +{ + return __imagePath; +} + +const char* CtDetailData::getDisplayName() +{ + return __displayName; +} + +const char* CtDetailData::getExtraName() +{ + return __extraName; +} + +const char* CtDetailData::getPhoneticName() +{ + return __phoneticName; +} + +const char* CtDetailData::getNickName() +{ + return __nickName; +} + +const char* CtDetailData::getCompany() +{ + return __company; +} + +const char* CtDetailData::getMessageAlert() +{ + return __messageAlert; +} + +const char* CtDetailData::getVibration() +{ + return __vibration; +} + + +Eina_List* CtDetailData::getNumberList() +{ + return __numberList; +} + +Eina_List* CtDetailData::getEmailList() +{ + return __emailList; +} + +Eina_List* CtDetailData::getAddressList() +{ + return __addressList; +} + +Eina_List* CtDetailData::getMessengerList() +{ + return __messengerList; +} + +Eina_List* CtDetailData::getUrlList() +{ + return __urlList; +} + +Eina_List* CtDetailData::getRelationshipList() +{ + return __relationshipList; +} + +Eina_List* CtDetailData::getEventList() +{ + return __eventList; +} + +Eina_List* CtDetailData::getNoteList() +{ + return __noteList; +} + +const char* CtDetailData::getNumber(contacts_record_h record) +{ + char *value = NULL; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_str_p(record, _contacts_number.number, &value); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_str_p() Failed(%d)", err); + + return value; +} + +int CtDetailData::getNumberType(contacts_record_h record) +{ + int type = 0; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_int(record, _contacts_number.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, CONTACTS_NUMBER_TYPE_OTHER, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +void CtDetailData::getNumberTypeStr(contacts_record_h record, int numberType, std::string &typeString) +{ + WHIT(); + const char* typeStr = NULL; + char buf[128] = {0,}; + + if (numberType & CONTACTS_NUMBER_TYPE_CUSTOM) { + typeStr = getDataTypeCustom(record, _contacts_number.label); + + } + else if (numberType & CONTACTS_NUMBER_TYPE_CELL) { + if (numberType & CONTACTS_NUMBER_TYPE_HOME) { + snprintf(buf, sizeof(buf),"%s 2", V_("IDS_PB_OPT_HOME_ABB")); + typeStr = buf; + } + else if (numberType & CONTACTS_NUMBER_TYPE_WORK) { + snprintf(buf, sizeof(buf),"%s 2", V_("IDS_PB_OPT_WORK")); + typeStr = buf; + } + else { + typeStr = V_("IDS_PB_OPT_MOBILE"); + } + } + else if (numberType & CONTACTS_NUMBER_TYPE_VOICE) { + if (numberType & CONTACTS_NUMBER_TYPE_HOME) { + typeStr = V_("IDS_PB_OPT_HOME_ABB"); + } + else if (numberType & CONTACTS_NUMBER_TYPE_WORK) { + typeStr = V_("IDS_PB_OPT_WORK"); + } + else { + typeStr = V_("IDS_PB_OPT_OTHER"); + } + } + else if (numberType & CONTACTS_NUMBER_TYPE_FAX) { + if (numberType & CONTACTS_NUMBER_TYPE_HOME) { + typeStr = V_("IDS_PB_OPT_FAX_HHOME_ABB"); + } + else if (numberType & CONTACTS_NUMBER_TYPE_WORK) { + typeStr = V_("IDS_PB_OPT_FAX_HWORK_ABB"); + } + else { + typeStr = V_("IDS_PB_BODY_FAX"); + } + } + else if (numberType & CONTACTS_NUMBER_TYPE_MAIN) { + typeStr = V_("IDS_PB_OPT_MAIN"); + } + else if (numberType & CONTACTS_NUMBER_TYPE_PAGER) { + typeStr = V_("IDS_PB_OPT_PAGER"); + } + else { + if (numberType & CONTACTS_NUMBER_TYPE_HOME) { + typeStr = V_("IDS_PB_OPT_HOME_ABB"); + } + else if (numberType & CONTACTS_NUMBER_TYPE_WORK) { + typeStr = V_("IDS_PB_OPT_WORK"); + } + else { + typeStr = V_("IDS_PB_OPT_OTHER"); + } + } + + char *result = elm_entry_utf8_to_markup(typeStr); + if (result) { + typeString = result; + free(result); + } +} + +const char* CtDetailData::getNumberTypeCustom(contacts_record_h record) +{ + char* type = NULL; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_str_p(record, _contacts_number.label, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +const char* CtDetailData::getEmail(contacts_record_h record) +{ + WHIT(); + char *value = NULL; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_str_p(record, _contacts_email.email, &value); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_str_p() Failed(%d)", err); + + return value; +} + +int CtDetailData::getEmailType(contacts_record_h record) +{ + WHIT(); + int type = 0; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_int(record, _contacts_email.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, CONTACTS_EMAIL_TYPE_OTHER, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +void CtDetailData::getEmailTypeStr(contacts_record_h record, int indexType, std::string &typeString) +{ + WHIT(); + const char* typeStr = NULL; + + if (indexType & CONTACTS_EMAIL_TYPE_CUSTOM) { + typeStr = getDataTypeCustom(record, _contacts_email.label); + } + else if (indexType & CONTACTS_EMAIL_TYPE_HOME) { + typeStr = V_("IDS_PB_OPT_HOME_ABB"); + } + else if (indexType & CONTACTS_EMAIL_TYPE_WORK) { + typeStr = V_("IDS_PB_OPT_WORK"); + } + else { + typeStr = V_("IDS_PB_OPT_OTHER"); + } + + char *result = elm_entry_utf8_to_markup(typeStr); + if (result) { + typeString = result; + free(result); + } +} + +int CtDetailData::getAddress(contacts_record_h record, char *buf, int length) +{ + WHIT(); + return __getFullAddress(record, buf, length); +} + + +int CtDetailData::getAddressType(contacts_record_h record) +{ + int type = 0; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_int(record, _contacts_address.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +const char* CtDetailData::getDataTypeCustom(contacts_record_h record, int property_id) +{ + char* typeStr = NULL; + const char* result = NULL; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_str_p(record, property_id, &typeStr); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_int() Failed(%d)", err); + + result = typeStr; + return result; +} + +void CtDetailData::getAddressTypeStr(contacts_record_h record, int indexType, std::string &typeString) +{ + WHIT(); + const char* typeStr = NULL; + + if (indexType & CONTACTS_ADDRESS_TYPE_CUSTOM) { + typeStr = getDataTypeCustom(record, _contacts_address.label); + } + else if (indexType & CONTACTS_ADDRESS_TYPE_HOME) { + typeStr = V_("IDS_PB_OPT_HOME_ABB"); + } + else if (indexType & CONTACTS_ADDRESS_TYPE_WORK) { + typeStr = V_("IDS_PB_OPT_WORK"); + } + else { + typeStr = V_("IDS_PB_OPT_OTHER"); + } + + char *result = elm_entry_utf8_to_markup(typeStr); + if (result) { + typeString = result; + free(result); + } +} + +const char* CtDetailData::getUrl(contacts_record_h record) +{ + char *value = NULL; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_str_p(record, _contacts_url.url, &value); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_str_p() Failed(%d)", err); + + return value; +} + +int CtDetailData::getUrlType(contacts_record_h record) +{ + int type = 0; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_int(record, _contacts_url.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +const char* CtDetailData::getMessenger(contacts_record_h record) +{ + char *value = NULL; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_str_p(record, _contacts_messenger.im_id, &value); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_str_p() Failed(%d)", err); + + return value; +} + +int CtDetailData::getMessengerType(contacts_record_h record) +{ + int type = 0; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_int(record, _contacts_messenger.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +void CtDetailData::getMessengerTypeStr(contacts_record_h record, int indexType, std::string &typeString) +{ + WHIT(); + const char* typeStr = NULL; + + if (indexType == CONTACTS_MESSENGER_TYPE_CUSTOM) { + typeStr = getDataTypeCustom(record, _contacts_messenger.label); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_AIM) { + typeStr = V_("IDS_PB_OPT_AIM"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_YAHOO) { + typeStr = V_("IDS_PB_OPT_YAHOO_E"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_SKYPE) { + typeStr = V_("IDS_PB_BODY_SKYPE"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_QQ) { + typeStr = V_("IDS_PB_OPT_QQ"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_GOOGLE) { + typeStr = V_("IDS_PB_OPT_HANGOUTS"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_ICQ) { + typeStr = V_("IDS_PB_OPT_ICQ"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_JABBER) { + typeStr = V_("IDS_PB_OPT_JABBER"); + } + + char *result = elm_entry_utf8_to_markup(typeStr); + if (result) { + typeString = result; + free(result); + } +} + +int CtDetailData::getEvent(contacts_record_h record) +{ + int date = 0; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_int(record, _contacts_event.date, &date); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return date; +} + +int CtDetailData::getEventType(contacts_record_h record) +{ + int type = 0; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_int(record, _contacts_event.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +void CtDetailData::getEventTypeStr(contacts_record_h record, int eventType, std::string &typeString) +{ + WHIT(); + const char* typeStr = NULL; + + if (eventType == CONTACTS_EVENT_TYPE_CUSTOM) { + typeStr = getDataTypeCustom(record, _contacts_event.label); + } + else if (eventType == CONTACTS_EVENT_TYPE_BIRTH) { + typeStr = V_("IDS_PB_OPT_BIRTHDAY"); + } + else if (eventType == CONTACTS_EVENT_TYPE_ANNIVERSARY) { + typeStr = V_("IDS_PB_OPT_ANNIVERSARY_ABB"); + } + else { + typeStr = V_("IDS_PB_OPT_OTHER"); + } + + char *result = elm_entry_utf8_to_markup(typeStr); + if (result) { + typeString = result; + free(result); + } +} + +const char* CtDetailData::getRelationship(contacts_record_h record) +{ + char *value = NULL; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_str_p(record, _contacts_relationship.name, &value); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_str_p() Failed(%d)", err); + + return value; +} + +int CtDetailData::getRelationshipType(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + int type = 0; + + err = contacts_record_get_int(record, _contacts_relationship.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +void CtDetailData::getRelationshipTypeStr(contacts_record_h record, int indexType, std::string &typeString) +{ + WHIT(); + const char* typeStr = NULL; + + if (indexType == CONTACTS_RELATIONSHIP_TYPE_CUSTOM) { + typeStr = getDataTypeCustom(record, _contacts_relationship.label); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_ASSISTANT) { + typeStr = V_("IDS_PB_OPT_ASSISTANT_M_CONTACTS"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_BROTHER) { + typeStr = V_("IDS_PB_OPT_BROTHER"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_CHILD) { + typeStr = V_("IDS_PB_OPT_CHILD"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER) { + typeStr = V_("IDS_PB_OPT_DOMESTIC_PARTNER_ABB2"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_FATHER) { + typeStr = V_("IDS_PB_OPT_FATHER"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_FRIEND) { + typeStr = V_("IDS_PB_OPT_FRIEND"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_MANAGER) { + typeStr = V_("IDS_PB_OPT_MANAGER"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_MOTHER) { + typeStr = V_("IDS_PB_OPT_MOTHER"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_PARENT) { + typeStr = V_("IDS_PB_OPT_PARENT"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_PARTNER) { + typeStr = V_("IDS_PB_OPT_PARTNER"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY) { + typeStr = V_("IDS_PB_OPT_REFERRED_BY_ABB"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_RELATIVE) { + typeStr = V_("IDS_PB_OPT_RELATIVE"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_SISTER) { + typeStr = V_("IDS_PB_OPT_SISTER"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_SPOUSE) { + typeStr = V_("IDS_PB_OPT_SPOUSE"); + } + + char *result = elm_entry_utf8_to_markup(typeStr); + if (result) { + typeString = result; + free(result); + } +} + + +const char* CtDetailData::getNote(contacts_record_h record) +{ + char *value = NULL; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_str_p(record, _contacts_note.note, &value); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_str_p() Failed(%d)", err); + + return value; +} + + +void CtDetailData::__onPersonChanged(const char *viewUri, void *userData) +{ + WHIT(); + + WPRET_M(NULL == userData, "userData is NULL"); + CtDetailData* data = (CtDetailData*)userData; + int err = CONTACTS_ERROR_NONE; + Eina_List *cursor = NULL; + void *record = NULL; + int link_count = 0; + int version = 0; + bool matched = false; + + if(data->__personRecord) { + contacts_record_h personRecord = NULL; + err = contacts_db_get_record(_contacts_person._uri, data->__personId, &personRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_record() Failed(%d) id", err); + err = contacts_record_get_int(personRecord, _contacts_person.link_count, &link_count); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d) id", err); + } + if(data->__link_count != link_count) + matched = true; + + EINA_LIST_FOREACH(data->__contactList, cursor, record) { + contacts_record_h contactRecord = (contacts_record_h)record; + int addressbookId = 0; + int contactId = 0; + contacts_list_h chagnedList = NULL; + contacts_record_h changedRecord = NULL; + + err = contacts_record_get_int(contactRecord, _contacts_contact.address_book_id, &addressbookId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d) address_book_id", err); + + err = contacts_record_get_int(contactRecord, _contacts_contact.id, &contactId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d) id", err); + + err = contacts_db_get_changes_by_version(_contacts_contact_updated_info._uri, addressbookId, data->__version, &chagnedList, &version); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_changes_by_version() Failed(%d)", err); + + while (CONTACTS_ERROR_NONE == contacts_list_get_current_record_p(chagnedList, &changedRecord)) { + int changedId = 0; + err = contacts_record_get_int(changedRecord, _contacts_contact_updated_info.contact_id, &changedId); + if(contactId == changedId) { + WDEBUG("update matched"); + matched = true; + break; + } + contacts_list_next(chagnedList); + } + + err = contacts_list_destroy(chagnedList, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_destroy(out_change_list) Failed(%d)", err); + + if(matched == true) { + break; + } + } + + if(version > 0) + data->__version = version; + + if(matched && data->__listener) + data->__listener->onDbChanged(viewUri); +} + + + +void CtDetailData::__freeRecordList(Eina_List *recordList) +{ + int err = CONTACTS_ERROR_NONE; + void *data = NULL; + if(NULL == recordList) { + return; + } + + EINA_LIST_FREE(recordList, data) { + contacts_record_h record = (contacts_record_h)data; + if (NULL == record) continue; + err = contacts_record_destroy(record, true); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_destroy() Failed(%d)", err); + continue; + } + } +} + + +contacts_record_h CtDetailData::__getPerson(int personId) +{ + WHIT(); + contacts_record_h personRecord = NULL; + int err = CONTACTS_ERROR_NONE; + err = contacts_db_get_record(_contacts_person._uri, personId, &personRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_db_get_record() Failed(%d)", err); + + return personRecord; +} + +void CtDetailData::__getBasicInfo(contacts_record_h personRecord, Eina_List *contactList) +{ + WENTER(); + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_str(personRecord, _contacts_person.display_name, &__displayName); + if(err != CONTACTS_ERROR_NONE) { + WERROR("contacts_record_get_str display_name %d", err); + } + err = contacts_record_get_str(personRecord, _contacts_person.image_thumbnail_path, &__imagePath); + if(err != CONTACTS_ERROR_NONE) { + WERROR("contacts_record_get_str image_thumbnail_path %d", err); + } + err = contacts_record_get_str(personRecord, _contacts_person.vibration, &__vibration); + if(err != CONTACTS_ERROR_NONE) { + WERROR("contacts_record_get_str vibration %d", err); + } + err = contacts_record_get_str(personRecord, _contacts_person.message_alert, &__messageAlert); + if(err != CONTACTS_ERROR_NONE) { + WERROR("contacts_record_get_str message_alert %d", err); + } + err = contacts_record_get_bool(personRecord, _contacts_person.is_favorite, &__favorite); + if(err != CONTACTS_ERROR_NONE) { + WERROR("contacts_record_get_str is_favorite %d", err); + } + + ctCommonRemoveNewline(__displayName); + + __getCompany(contactList, &__company); + + __getExtraName1(contactList, &__nickName, &__phoneticName); + + __getExtraName2(__nickName, __phoneticName, &__extraName); + + WLEAVE(); +} + +void CtDetailData::__getCompany(Eina_List *contactList, char **dest) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + void *data; + contacts_record_h companyRecord = NULL; + Eina_List *l; + WPRET_M(NULL == contactList, "contactList is NULL"); + + EINA_LIST_FOREACH(contactList, l, data) { + contacts_record_h contactRecord = (contacts_record_h)data; + if (NULL == contactRecord) + continue; + err = contacts_record_get_child_record_at_p(contactRecord, _contacts_contact.company, 0, &companyRecord); + if(CONTACTS_ERROR_NONE != err) + WERROR("contacts_record_get_child_record_at_p() Failed(%d)", err); + else { + __getCompanyStr(companyRecord, dest); + break; + } + } +} + +void CtDetailData::__getExtraName2(char* nick, char* phonetic, char** extra) +{ + WHIT(); + char name[CT_TEXT_MAX_LEN+1] = {0, }; + + free(*extra); + + if(phonetic && *phonetic) { + if(nick && *nick) + snprintf(name, sizeof(name), "%s, %s", phonetic, nick); + else + snprintf(name, sizeof(name), "%s", phonetic); + } + else if(nick && *nick) + snprintf(name, sizeof(name), "%s", nick); + + if( strlen(name) > 0) + *extra = strdup(name); + else + *extra = NULL; +} + + +void CtDetailData::__getExtraName1(Eina_List *contactList, char **nick, char **phonetic) +{ + WHIT(); + int err1 = CONTACTS_ERROR_NONE; + int err2 = CONTACTS_ERROR_NONE; + void *data; + contacts_record_h nameRecord = NULL; + contacts_record_h nicknameRecord = NULL; + Eina_List *l; + + WPRET_M(NULL == contactList, "contact_list is NULL"); + + EINA_LIST_FOREACH(contactList, l, data) { + contacts_record_h contactRecord = (contacts_record_h)data; + if (NULL == contactRecord) + continue; + + err1 = contacts_record_get_child_record_at_p(contactRecord, _contacts_contact.name, 0, &nameRecord); + WPWARN(CONTACTS_ERROR_NONE != err1, "contacts_record_get_child_record_at_p() name Failed(%d)", err1); + err2 = contacts_record_get_child_record_at_p(contactRecord, _contacts_contact.nickname, 0, &nicknameRecord); + WPWARN(CONTACTS_ERROR_NONE != err2, "contacts_record_get_child_record_at_p() nickname Failed(%d)", err2); + + if (CONTACTS_ERROR_NONE == err1 || CONTACTS_ERROR_NONE == err2) { + __getExtraNameStr(nameRecord, nicknameRecord, nick, phonetic); + break; + } + } +} + +void CtDetailData::__getExtraNameStr(contacts_record_h nameRecord, contacts_record_h nicknameRecord, char **nick, char **phonetic) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + char *nickname = NULL; + int length = 0; + + free(*nick); + free(*phonetic); + *nick = NULL; + *phonetic = NULL; + char *phoneticFirst = NULL; + char *phoneticMiddle = NULL; + char *phoneticLast = NULL; + char *phoneticFull = NULL; + + if(nicknameRecord) { + err = contacts_record_get_str_p(nicknameRecord, _contacts_nickname.name, (char**)&nickname); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() name Failed(%d)", err); + *nick = SAFE_STRDUP(nickname); + } + + if(nameRecord) { + + contacts_name_display_order_e name_display_order; + contacts_setting_get_name_display_order(&name_display_order); + + err = contacts_record_get_str_p(nameRecord, _contacts_name.phonetic_first, (char**)&phoneticFirst); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() phoneticname Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_name.phonetic_middle, (char**)&phoneticMiddle); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() phoneticname Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_name.phonetic_last, (char**)&phoneticLast); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() phoneticname Failed(%d)", err); + + int phoneticLength = SAFE_STRLEN(phoneticFirst) + SAFE_STRLEN(phoneticMiddle) + SAFE_STRLEN(phoneticLast) + 3; + WDEBUG("phoneticLength = %d", phoneticLength); + phoneticFull = (char*)malloc(sizeof(char)*phoneticLength); + WPRET_M(NULL == phoneticFull, "failed to malloc"); + memset(phoneticFull, 0, sizeof(char)*phoneticLength); + + if (CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST == name_display_order) { + if (phoneticFirst && *phoneticFirst) { + strncat(phoneticFull, phoneticFirst, SAFE_STRLEN(phoneticFirst)); + } + if (phoneticMiddle && *phoneticMiddle) { + if (phoneticFull && *phoneticFull) { + strncat(phoneticFull, " ", 1); + } + strncat(phoneticFull, phoneticMiddle, SAFE_STRLEN(phoneticMiddle)); + } + if (phoneticLast && *phoneticLast) { + if (phoneticFull && *phoneticFull) { + strncat(phoneticFull, " ", 1); + } + strncat(phoneticFull, phoneticLast, SAFE_STRLEN(phoneticLast)); + } + } + else { + if (phoneticLast && *phoneticLast) { + strncat(phoneticFull, phoneticLast, SAFE_STRLEN(phoneticLast)); + } + if (phoneticFirst && *phoneticFirst) { + if (phoneticFull && *phoneticFull) { + strncat(phoneticFull, " ", 1); + } + strncat(phoneticFull, phoneticFirst, SAFE_STRLEN(phoneticFirst)); + } + if (phoneticMiddle && *phoneticMiddle) { + if (phoneticFull && *phoneticFull) { + strncat(phoneticFull, " ", 1); + } + strncat(phoneticFull, phoneticMiddle, SAFE_STRLEN(phoneticMiddle)); + } + } + length += phoneticLength; + + *phonetic = SAFE_STRDUP(phoneticFull); + free(phoneticFull); + } + +} + +void CtDetailData::__getCompanyStr(contacts_record_h companyRecord, char **dest) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + char *company, *job, *department; + char *fullName = NULL; + int length = 0; + *dest = NULL; + + err = contacts_record_get_str_p(companyRecord, _contacts_company.name, (char**)&company); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + err = contacts_record_get_str_p(companyRecord, _contacts_company.department, (char**)&department); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + err = contacts_record_get_str_p(companyRecord, _contacts_company.job_title, (char**)&job); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + + length = SAFE_STRLEN(company) + SAFE_STRLEN(department) + SAFE_STRLEN(job) + 5; + WDEBUG("length = %d", length); + + fullName = (char*)malloc(sizeof(char)*length); + WPRET_M(NULL == fullName, "failed to malloc"); + memset(fullName, 0, sizeof(char)*length); + + if (company) { + strncat(fullName, company, SAFE_STRLEN(company)); + } + + if (department) { + if (fullName && *fullName) { + strncat(fullName, ", ", 2); + } + strncat(fullName, department, SAFE_STRLEN(department)); + } + + if (job) { + if (fullName && *fullName) { + strncat(fullName, ", ", 2); + } + strncat(fullName, job, SAFE_STRLEN(job)); + } + + *dest = SAFE_STRDUP(fullName); + free(fullName); + fullName = NULL; +} + +bool CtDetailData::__isDataExist(Eina_List *dataList, contacts_record_h record, unsigned int propertyId) +{ + WHIT(); + Eina_List *l; + char *originText = NULL; + char *tempText = NULL; + int err = CONTACTS_ERROR_NONE; + void* data; + + unsigned int dataPropertyId; + + if(propertyId == _contacts_contact.number) + dataPropertyId = _contacts_number.number; + else if(propertyId == _contacts_contact.email) + dataPropertyId = _contacts_email.email; + else if(propertyId == _contacts_contact.messenger) + dataPropertyId = _contacts_messenger.im_id; + else if(propertyId == _contacts_contact.url) + dataPropertyId = _contacts_url.url; + else if(propertyId == _contacts_contact.relationship) + dataPropertyId = _contacts_relationship.name; + else if(propertyId == _contacts_contact.note) + dataPropertyId = _contacts_note.note; + else { + WERROR("cannot handle %d", propertyId); + return false; + } + + err = contacts_record_get_str_p(record, dataPropertyId, &originText); + WPRET_VM(CONTACTS_ERROR_NONE != err, false, "contacts_record_get_str_p() Failed(%d)", err); + + EINA_LIST_FOREACH(dataList, l, data) { + contacts_record_h tempRecord = (contacts_record_h)data; + if (NULL == tempRecord) + continue; + + err = contacts_record_get_str_p(tempRecord, dataPropertyId, &tempText); + WPRET_VM(CONTACTS_ERROR_NONE != err, false, "contacts_record_get_str_p() Failed(%d)", err); + + if (NULL == tempText) + continue; + + if (0 == strcmp(originText, tempText)) + return true; + } + return false; +} + +bool CtDetailData::__isAddressExist(Eina_List *dataList, contacts_record_h record) +{ + WHIT(); + Eina_List *l; + void *data; + char originAddress[CT_TEXT_MAX_LEN] = {0,}; + + __getFullAddress(record, originAddress, sizeof(originAddress)); + + EINA_LIST_FOREACH(dataList, l, data) { + char tempAddress[CT_TEXT_MAX_LEN] = {0,}; + contacts_record_h tempRecord = (contacts_record_h)data; + if (NULL == tempRecord) + continue; + + __getFullAddress(tempRecord, tempAddress, sizeof(tempAddress)); + if (0 == strcmp(tempAddress, originAddress)) { + return true; + } + } + return false; +} + +bool CtDetailData::__isEventExist(Eina_List *dataList, contacts_record_h record) +{ + WHIT(); + Eina_List *l; + int originDate; + int tempDate; + int err = CONTACTS_ERROR_NONE; + void *data; + + err = contacts_record_get_int(record, _contacts_event.date, &originDate); + WPRET_VM(CONTACTS_ERROR_NONE != err, false, "contacts_record_get_int() Failed(%d)", err); + + EINA_LIST_FOREACH(dataList, l, data) { + contacts_record_h tempRecord = (contacts_record_h)data; + if (NULL == tempRecord) + continue; + + err = contacts_record_get_int(tempRecord, _contacts_event.date, &tempDate); + WPRET_VM(CONTACTS_ERROR_NONE != err, false, "contacts_record_get_int() Failed(%d)", err); + + if(originDate == tempDate) + return true; + + } + return false; +} + +void CtDetailData::__appendStringWithLinebreak(const char *src, char *dest, int length) +{ + char temp[CT_TEXT_MAX_LEN]; + if (src && '\0' != src[0]) { + if ('\0' == dest[0]) + snprintf(dest, length, "%s", src); + else { + snprintf(temp, sizeof(temp), "%s\n%s", src, dest); + snprintf(dest, length, "%s", temp); + } + } +} + +int CtDetailData::__getFullAddress(contacts_record_h addresssRecord, char *buf, int length) +{ + WHIT(); + const char *code = NULL; + const char *region = NULL; + const char *locality = NULL; + const char *street = NULL; + const char *extended = NULL; + const char *country = NULL; + const char *pobox = NULL; + int err = CONTACTS_ERROR_NONE; + + do { + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.postal_code , (char**)&code))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.extended , (char**)&extended))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.postbox , (char**)&pobox))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.street , (char**)&street))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.locality , (char**)&locality))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.region , (char**)®ion))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.country ,(char**)&country))) break; + } while (0); + if(CONTACTS_ERROR_NONE != err) + WERROR("contacts_record_get_str_p() Failed(%d)", err); + + __appendStringWithLinebreak(country, buf, length); + __appendStringWithLinebreak(code, buf, length); + __appendStringWithLinebreak(region, buf, length); + __appendStringWithLinebreak(locality, buf, length); + __appendStringWithLinebreak(street, buf, length); + __appendStringWithLinebreak(extended, buf, length); + __appendStringWithLinebreak(pobox, buf, length); + return 0; +} + +Eina_List* CtDetailData::__getChildDataList(Eina_List *contactList, unsigned int propertyId) +{ + WDEBUG("propertyId %d", propertyId); + Eina_Bool checkduplicate = false; + int index = 0; + Eina_List *l; + Eina_List *dataRecordList = NULL; + int err = CONTACTS_ERROR_NONE; + contacts_record_h dataRecord = NULL; + contacts_record_h dataRecordClone = NULL; + void *data = NULL; + + EINA_LIST_FOREACH(contactList, l, data) { + contacts_record_h record = (contacts_record_h)data; + index = 0; + while (CONTACTS_ERROR_NONE == contacts_record_get_child_record_at_p(record, propertyId, index++, &dataRecord)) { + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_str_p() Failed(%d)", err); + break; + } + + if (checkduplicate) { + if(propertyId == _contacts_contact.address) { + if (__isAddressExist(dataRecordList, dataRecord) == true) { + WERROR("__isDataExist() return true %d", propertyId); + continue; + } + } + else if(propertyId == _contacts_contact.event) { + if (__isEventExist(dataRecordList, dataRecord) == true) { + WERROR("__isDataExist() return true %d", propertyId); + continue; + } + } + else { + if (__isDataExist(dataRecordList, dataRecord, propertyId) == true) { + WERROR("__isDataExist() return true %d", propertyId); + continue; + } + } + + } + err = contacts_record_clone(dataRecord, &dataRecordClone); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_list_get_current_record_p() Failed(%d)", err); + break; + } + dataRecordList = eina_list_append(dataRecordList, dataRecordClone); + } + checkduplicate = true; + } + + WDEBUG("count %d", eina_list_count(dataRecordList)); + + return dataRecordList; +} + +i18n_udate_format_h CtDetailData::__initTimeFormatter() +{ + const char *locale; + int32_t pattern_capacity; + i18n_uchar pattern[256]; + i18n_uchar customSkeleton[256]; + i18n_udate_format_h formatter = NULL; + i18n_udatepg_h generator = NULL; + int status = I18N_ERROR_NONE; + int bestPatternLength; + + i18n_ustring_copy_ua_n(customSkeleton, "yMMMMd", SAFE_STRLEN("yMMMMd")); + + status = i18n_ulocale_get_default(&locale); + WPRET_VM(NULL == locale, NULL, "uloc_getDefault() return NULL"); + + status = i18n_udatepg_create (locale, &generator); + + pattern_capacity = (int32_t) (sizeof(pattern) / sizeof((pattern)[0])); + status = i18n_udatepg_get_best_pattern (generator, customSkeleton, 6, pattern, pattern_capacity, &bestPatternLength); + + if (!status) + status = i18n_udate_create (I18N_UDATE_PATTERN , I18N_UDATE_PATTERN , locale, NULL, -1, pattern, -1, &formatter); + + i18n_udatepg_destroy(generator); + return formatter; +} + + +char* CtDetailData::getDatetimeStr(i18n_udate_format_h formatter, int year, int mon, int day) +{ + char *ret_str = NULL; + char formatted_str[256]; + i18n_uchar formatted[256] = {0, }; + int status = I18N_ERROR_NONE; + i18n_udate millis = 0; + i18n_ucalendar_h cal = NULL; + int formattedLength = 0; + + const char* locale = NULL; + status = i18n_ulocale_get_default(&locale); + + status = i18n_ucalendar_create(NULL, -1, locale, I18N_UCALENDAR_TRADITIONAL , &cal); + WPRET_VM(status, NULL, "ucal_open() Failed()"); + + status = i18n_ucalendar_set_date_time(cal, year, mon-1, day, 0, 0, 0); + + status = i18n_ucalendar_set_attribute(cal, I18N_UCALENDAR_LENIENT , 1); + + status = i18n_ucalendar_get_milliseconds(cal, &millis); + + if (status) { + WDEBUG("i18n_ucalendar_get_milliseconds() Failed()"); + i18n_ucalendar_destroy(cal); + return NULL; + } + + status = i18n_udate_format_date(formatter, millis, formatted, 256, NULL, &formattedLength); + + if (status) { + WDEBUG("udat_format() Failed()"); + i18n_ucalendar_destroy(cal); + return NULL; + } + + i18n_ustring_copy_au (formatted_str, formatted); + ret_str = g_strdup(formatted_str); + i18n_ucalendar_destroy(cal); + + return ret_str; +} + +i18n_udate_format_h CtDetailData::getDateFormater() +{ + return __formatter; +} + + +Eina_List* CtDetailData::getContactsWithoutReadOnly() +{ + WHIT(); + int addressbookId = -1; + //int addressbookMode = CONTACTS_ADDRESS_BOOK_MODE_EX_FACEBOOK; + int addressbookMode = CONTACTS_ADDRESS_BOOK_MODE_READONLY; + int err = CONTACTS_ERROR_NONE; + Eina_List *l; + void* tmp = NULL; + contacts_record_h recordContact = NULL; + contacts_record_h contactRecordClone = NULL; + contacts_record_h recordAddressbook = NULL; + Eina_List *outList = NULL; + + WPRET_VM(NULL == __contactList, NULL, "listContacts is NULL"); + + EINA_LIST_FOREACH(__contactList, l, tmp) { + if (NULL == tmp) { + continue; + } + recordContact = (contacts_record_h)tmp; + + err = contacts_record_get_int(recordContact, _contacts_contact.address_book_id, &addressbookId); + if(CONTACTS_ERROR_NONE != err) + { + WWARNING("contacts_record_get_int() Failed(%d)", err); + continue; + } + err = contacts_db_get_record(_contacts_address_book._uri, addressbookId, &recordAddressbook); + if(CONTACTS_ERROR_NONE != err) + { + WWARNING("contacts_record_get_int() Failed(%d)", err); + contacts_record_destroy(recordAddressbook, true); + continue; + } + + err = contacts_record_get_int(recordAddressbook, _contacts_address_book.mode, &addressbookMode); + if(CONTACTS_ERROR_NONE != err) + { + WWARNING("contacts_record_get_int() Failed(%d)", err); + contacts_record_destroy(recordAddressbook, true); + continue; + } + + err = contacts_record_destroy(recordAddressbook, true); + if(CONTACTS_ERROR_NONE != err) + WWARNING("contacts_record_destroy() Failed(%d)", err); + +// if (CONTACTS_ADDRESS_BOOK_MODE_EX_READONLY & addressbookMode) { + if (CONTACTS_ADDRESS_BOOK_MODE_READONLY & addressbookMode) { + continue; + } + err = contacts_record_clone(recordContact, &contactRecordClone); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_clone() Failed(%d)", err); + continue; + } + outList = eina_list_append(outList, contactRecordClone); + } + return outList; +} + +bool CtDetailData::getReadOnlyMode() +{ + WHIT(); + int addressbookId = -1; +// int addressbookMode = CONTACTS_ADDRESS_BOOK_MODE_EX_FACEBOOK; + int addressbookMode = CONTACTS_ADDRESS_BOOK_MODE_READONLY; + int err = CONTACTS_ERROR_NONE; + Eina_List *l; + void* tmp = NULL; + contacts_record_h recordContact = NULL; + contacts_record_h recordAddressbook = NULL; + + WPRET_VM(NULL == __contactList, true, "listContacts is NULL"); + + EINA_LIST_FOREACH(__contactList, l, tmp) { + if (NULL == tmp) { + continue; + } + recordContact = (contacts_record_h)tmp; + + err = contacts_record_get_int(recordContact, _contacts_contact.address_book_id, &addressbookId); + WPRET_VM(CONTACTS_ERROR_NONE != err, false, "contacts_record_get_int() Failed(%d)", err); + + err = contacts_db_get_record(_contacts_address_book._uri, addressbookId, &recordAddressbook); + WPRET_VM(CONTACTS_ERROR_NONE != err, false, "contacts_db_get_record() Failed(%d)", err); + + err = contacts_record_get_int(recordAddressbook, _contacts_address_book.mode, &addressbookMode); + WPRET_VM(CONTACTS_ERROR_NONE != err, false, "contacts_record_get_int() Failed(%d)", err); + + err = contacts_record_destroy(recordAddressbook, true); + WPRET_VM(CONTACTS_ERROR_NONE != err, false, "contacts_record_destroy() Failed(%d)", err); + +// if (CONTACTS_ADDRESS_BOOK_MODE_EX_READONLY & addressbookMode) + if (CONTACTS_ADDRESS_BOOK_MODE_READONLY & addressbookMode) + continue; + return false; + } + return true; +} + +bool CtDetailData::isCurrentPersonValid() +{ + WHIT(); + + int personId = getPersonId(); + + return ctCommonIsValidPerson(personId); +} + +char* CtDetailData::getVcardStream() const +{ + char* vcardStream = NULL; + int err = CONTACTS_ERROR_NONE; + err = contacts_vcard_make_from_person(__personRecord, &vcardStream); + WPRET_VM(err != CONTACTS_ERROR_NONE, NULL, "contacts_vcard_make_from_person() Failed(%d)", err); + + return vcardStream; +} diff --git a/lib-contact/ct-detail/src/CtDetailData.h b/lib-contact/ct-detail/src/CtDetailData.h new file mode 100755 index 0000000..a17ed65 --- /dev/null +++ b/lib-contact/ct-detail/src/CtDetailData.h @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_DETAIL_DATA_H_ +#define _CT_DETAIL_DATA_H_ + +#include <utils_i18n.h> + +#include <contacts.h> +//#include <contacts_product.h> + +#include "ContactsCommon.h" + +#include "CtType.h" +#include "CtDetailDataBase.h" +#include "CtData.h" + +#if 0 +#include "CtGalSearchMgr.h" +#endif + +class CtDetailData : public CtDetailDataBase +{ +public: + CtDetailData(int personId); + CtDetailData(contacts_record_h personRecord); +#if 0 + CtDetailData(CtGalSearchContact* galSearchContact); +#endif + CtDetailData(); + virtual ~CtDetailData(); + +public: + + void init(); + void deInit(); + + int getPersonId(); + Eina_List* getContactsList(); + int setFavorite(bool favorite); + + const char* getImagePath(); + const char* getDisplayName(); + const char* getExtraName(); + const char* getPhoneticName(); + const char* getNickName(); + const char* getCompany(); + const char* getMessageAlert(); + const char* getVibration(); + bool getFavorite(); + //bool getMFC(); + + Eina_List* getNumberList(); + const char* getNumber(contacts_record_h record); + int getNumberType(contacts_record_h record); + void getNumberTypeStr(contacts_record_h record, int numberType, std::string &typeString); + const char* getNumberTypeCustom(contacts_record_h record); + Eina_List* getEmailList(); + const char* getEmail(contacts_record_h record); + int getEmailType(contacts_record_h record); + void getEmailTypeStr(contacts_record_h record, int indexType, std::string &typeString); + Eina_List* getAddressList(); + int getAddress(contacts_record_h record, char *buf, int length); + const char* getDataTypeCustom(contacts_record_h record, int property_id); + int getAddressType(contacts_record_h record); + void getAddressTypeStr(contacts_record_h record, int indexType, std::string &typeString); + Eina_List* getMessengerList(); + const char* getMessenger(contacts_record_h record); + int getMessengerType(contacts_record_h record); + void getMessengerTypeStr(contacts_record_h record, int indexType, std::string &typeString); + Eina_List* getUrlList(); + const char* getUrl(contacts_record_h record); + int getUrlType(contacts_record_h record); + Eina_List* getRelationshipList(); + const char* getRelationship(contacts_record_h record); + int getRelationshipType(contacts_record_h record); + void getRelationshipTypeStr(contacts_record_h record, int indexType, std::string &typeString); + Eina_List* getEventList(); + int getEvent(contacts_record_h record); + int getEventType(contacts_record_h record); + void getEventTypeStr(contacts_record_h record, int eventType, std::string &typeString); + Eina_List* getNoteList(); + const char* getNote(contacts_record_h record); + char* getDatetimeStr(i18n_udate_format_h formatter, int year, int mon, int day); + i18n_udate_format_h getDateFormater(); + bool getReadOnlyMode(); + void attachListener(ICtChangeListener* listener); + void detachListener(); + Eina_List* getContactsWithoutReadOnly(); + + bool isCurrentPersonValid(); + + char* getVcardStream() const; + +private: + static void __onPersonChanged(const char *viewUri, void *userData); + void __freeRecordList(Eina_List *recordList); + + contacts_record_h __getPerson(int personId); + Eina_List* __getContactsList(int personId); + + Eina_List* __getChildDataList(Eina_List *contactList, unsigned int propertyId); + int __getFullAddress(contacts_record_h addresssRecord, char *buf, int length); + bool __isEventExist(Eina_List *dataList, contacts_record_h record); + bool __isAddressExist(Eina_List *dataList, contacts_record_h record); + bool __isDataExist(Eina_List *dataList, contacts_record_h record, unsigned int propertyId); + void __appendStringWithLinebreak(const char *src, char *dest, int length); + int __setImage(contacts_record_h record, char *image, int type); + int __removeImage(contacts_record_h contactRecord, contacts_record_h imageRecord); + bool __getHasReadOnlyMode(void); + + void __getBasicInfo(contacts_record_h personRecord, Eina_List *contactList); + void __getCompany(Eina_List *contactList, char **dest); + void __getExtraName1(Eina_List *contactList, char **nick, char **phonetic); + void __getExtraName2(char* nick, char* phonetic, char** extra); + void __getExtraNameStr(contacts_record_h nameRecord, contacts_record_h nicknameRecord, char **nick, char **phonetic); + void __getCompanyStr(contacts_record_h companyRecord, char **dest); + i18n_udate_format_h __initTimeFormatter(); +#if 0 + void __initGalSearchContact(CtGalSearchContact* galSearchContact); +#endif + +private: + + int __version; + + int __personId; + contacts_record_h __personRecord; + + int __link_count; + char *__imagePath; + char *__displayName; + char *__extraName; + char *__phoneticName; + char *__nickName; + char *__company; + char *__messageAlert; + char *__vibration; + bool __favorite; + + Eina_List *__contactList; + Eina_List *__numberList; + Eina_List *__emailList; + Eina_List *__addressList; + Eina_List *__messengerList; + Eina_List *__urlList; + Eina_List *__relationshipList; + Eina_List *__eventList; + Eina_List *__noteList; + + i18n_udate_format_h __formatter; + ICtChangeListener* __listener; +#if 0 + CtGalSearchContact* __galSearchContact; +#endif + +}; + +#endif //_CT_DETAIL_DATA_H_ diff --git a/lib-contact/ct-detail/src/CtDetailDataBase.h b/lib-contact/ct-detail/src/CtDetailDataBase.h new file mode 100755 index 0000000..14cafec --- /dev/null +++ b/lib-contact/ct-detail/src/CtDetailDataBase.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_DETAIL_DATA_BASE_H_ +#define _CT_DETAIL_DATA_BASE_H_ + +#include <utils_i18n.h> + +#include <contacts.h> + +#include "ContactsCommon.h" + +#include "CtType.h" + +class CtDetailDataBase +{ +public: + virtual ~CtDetailDataBase(){}; + +public: + + virtual void init() = 0; + virtual void deInit() = 0; + + virtual int getPersonId() = 0; + virtual Eina_List* getContactsList() = 0; + virtual int setFavorite(bool favorite) = 0; + + virtual const char* getImagePath() = 0; + virtual const char* getDisplayName() = 0; + virtual const char* getExtraName() = 0; + virtual const char* getPhoneticName() = 0; + virtual const char* getNickName() = 0; + virtual const char* getCompany() = 0; + virtual const char* getMessageAlert() = 0; + virtual const char* getVibration() = 0; + virtual bool getFavorite() = 0; + //virtual bool getMFC() = 0; + + virtual Eina_List* getNumberList() = 0; + virtual const char* getNumber(contacts_record_h record) = 0; + virtual int getNumberType(contacts_record_h record) = 0; + virtual void getNumberTypeStr(contacts_record_h record, int numberType, std::string &typeString) = 0; + virtual const char* getNumberTypeCustom(contacts_record_h record) = 0; + virtual Eina_List* getEmailList() = 0; + virtual const char* getEmail(contacts_record_h record) = 0; + virtual int getEmailType(contacts_record_h record) = 0; + virtual void getEmailTypeStr(contacts_record_h record, int indexType, std::string &typeString) = 0; + virtual Eina_List* getAddressList() = 0; + virtual int getAddress(contacts_record_h record, char *buf, int length) = 0; + virtual const char* getDataTypeCustom(contacts_record_h record, int property_id) = 0; + virtual int getAddressType(contacts_record_h record) = 0; + virtual void getAddressTypeStr(contacts_record_h record, int indexType, std::string &typeString) = 0; + virtual Eina_List* getMessengerList() = 0; + virtual const char* getMessenger(contacts_record_h record) = 0; + virtual int getMessengerType(contacts_record_h record) = 0; + virtual void getMessengerTypeStr(contacts_record_h record, int indexType, std::string &typeString) = 0; + virtual Eina_List* getUrlList() = 0; + virtual const char* getUrl(contacts_record_h record) = 0; + virtual int getUrlType(contacts_record_h record) = 0; + virtual Eina_List* getRelationshipList() = 0; + virtual const char* getRelationship(contacts_record_h record) = 0; + virtual int getRelationshipType(contacts_record_h record) = 0; + virtual void getRelationshipTypeStr(contacts_record_h record, int indexType, std::string &typeString) = 0; + virtual Eina_List* getEventList() = 0; + virtual int getEvent(contacts_record_h record) = 0; + virtual int getEventType(contacts_record_h record) = 0; + virtual void getEventTypeStr(contacts_record_h record, int eventType, std::string &typeString) = 0; + virtual Eina_List* getNoteList() = 0; + virtual const char* getNote(contacts_record_h record) = 0; + virtual char* getDatetimeStr(i18n_udate_format_h formatter, int year, int mon, int day) = 0; + virtual i18n_udate_format_h getDateFormater() = 0; + virtual bool getReadOnlyMode() = 0; +}; + +#endif //_CT_DETAIL_DATA_BASE_H_ diff --git a/lib-contact/ct-detail/src/CtDetailView.cpp b/lib-contact/ct-detail/src/CtDetailView.cpp new file mode 100755 index 0000000..7d2ad58 --- /dev/null +++ b/lib-contact/ct-detail/src/CtDetailView.cpp @@ -0,0 +1,664 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <app.h> +#include <contacts.h> +#include <notification.h> +#include <app_preference.h> + +#include "WNaviframe.h" +#include "WWindow.h" +#include "WMenuPopup.h" +#include "WToastPopup.h" + +#include "ContactsDebug.h" +#include "ContactsAppControlLauncher.h" +#include "ContactsAppControl.h" +#include "CtPath.h" +#include "CtCommon.h" +#include "CtThemeMgr.h" +#include "CtRegistryMgr.h" +#include "ContactsCommon.h" + +#include "CtDetailView.h" +#include "CtDetailViewBasicInfoControl.h" +#include "CtDetailViewNumberItem.h" +#include "CtDetailViewEmailItem.h" +#include "CtDetailViewNoteItem.h" +#include "CtDetailViewAddressItem.h" +#include "CtDetailViewEventItem.h" +#include "CtDetailViewMessengerItem.h" +#include "CtDetailViewRelationItem.h" +#include "CtDetailViewWebsiteItem.h" +#include "CtDetailData.h" +#include "CtInputView.h" +#include "CtEditTabView.h" + +#define __ITEM_HEIGHT 98 +#define __MAX_HEIGHT 680 +#define __MAX_HEIGHT_LANDSCAPE 360 +#define CT_DETAIL_UPDATE_TIMER 3.0 + +CtDetailView::CtDetailView(int personId) +{ + __initialize(); + __detailData = new CtDetailData(personId); + __needHomogeneous = __checkConditionForGenlistHomogeneous(__detailData); +} + +CtDetailView::~CtDetailView() +{ + WHIT(); + + destroyPopup(); + + delete __detailData; + // TODO Auto-generated destructor stub +} + +bool CtDetailView::__checkConditionForGenlistHomogeneous(CtDetailData *detailData) +{ + //addressbook item is multiple line + Eina_List *addressList = detailData->getAddressList(); + Eina_List *noteList = detailData->getNoteList(); + if(addressList) { + WDEBUG("address count %d", eina_list_count(addressList)); + if(eina_list_count(addressList) > 0) + return false; + } + + if(noteList) { + WDEBUG("note count %d", eina_list_count(noteList)); + if(eina_list_count(noteList) > 0) + return false; + } + + return true; +} + +void CtDetailView::__updateGenlist() +{ + WHIT(); + + int personId = getPersoinId(); + + delete __detailData; + __detailData = new CtDetailData(personId); + __detailData->attachListener(this); + + elm_genlist_clear(__genlist); + + __needHomogeneous = __checkConditionForGenlistHomogeneous(__detailData); + + if(__needHomogeneous) + elm_genlist_homogeneous_set(__genlist, EINA_TRUE); + else + elm_genlist_homogeneous_set(__genlist, EINA_FALSE); + + __emailItem = NULL; + __appendIndex = 0; + __genlistItemNumberFirst = NULL; + __genlistItemNumberLast = NULL; + memset( __genlistItems, 0, sizeof(__genlistItems) ); + + __addAllItems(); +} + +void CtDetailView::__initialize() +{ + WENTER(); + __basicInfo = NULL; + __appendIndex = 0; + __genlistItemNumberFirst = NULL; + __genlistItemNumberLast = NULL; + __emailItem = NULL; + __needHomogeneous = false; + memset( __genlistItems, 0, sizeof(__genlistItems) ); + + WLEAVE(); +} +const char* CtDetailView::getClassName() +{ + return "CtDetailView"; +} + +void CtDetailView::onDbChanged(const char* viewUri) +{ + WENTER(); + + std::string contactsEdjePath; + std::string detailLayoutEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + ContactsCommon::getAppEdjePath(DETAIL_LAYOUT_EDJ, detailLayoutEdjePath); + // if launch ct-list UG(like select relationship), when destroy ct-list UG, CtThemeMgr instance will be deleted, so it need to recreate + CtThemeMgr::getInstance()->addExtensionTheme(contactsEdjePath.c_str()); + CtThemeMgr::getInstance()->addExtensionTheme(detailLayoutEdjePath.c_str()); + CtThemeMgr::getInstance()->setObjectTheme(getEvasObj()); + + bool isPersonValid = false; + isPersonValid = __detailData->isCurrentPersonValid(); + if(false == isPersonValid) { + popOut(); + return; + } + + __updateGenlist(); + __createBaseInfo(); +} + +void CtDetailView::onCompleteGetContacts(int offset) +{ + WENTER(); +} + +void CtDetailView::onConditionChagned() +{ + WENTER(); +} + +Evas_Object* CtDetailView::__getWindow(void) +{ + if(getWindow()) + return getWindow()->getEvasObj(); + else + WASSERT_EX(0, "window null"); + + return NULL; +} + +void CtDetailView::onDestroy() +{ + WHIT(); +} + +void CtDetailView::onEvent(int eventType) +{ + WENTER(); + +} + +void CtDetailView::__detailBackBtnCb(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + WHIT(); + WPRET_M(!data, "data is NULL"); + CtDetailView* view = (CtDetailView*)data; + + view->popOut(); +} + +void CtDetailView::__createBaseInfo() +{ + WHIT(); + + __basicInfo = new CtDetailViewBasicInfoControl(__detailData, true); + __basicInfo->create(__mainLayout, NULL); + edje_object_signal_callback_add(_EDJ(__basicInfo->getEvasObj()), "mouse,clicked,*", "back_btn", __detailBackBtnCb, this); + + elm_object_part_content_set(__mainLayout, "swallow.base_info", __basicInfo->getEvasObj()); +} + +void CtDetailView::onPushed(Elm_Object_Item* naviItem) +{ + WENTER(); + + __addAllItems(); + elm_naviframe_item_title_enabled_set(naviItem, EINA_FALSE, EINA_FALSE); + + __detailData->attachListener(this); + enableMoreButton(naviItem, [](void *data, Evas_Object *obj, void *event_info){ + CtDetailView* view = static_cast<CtDetailView*>(data); + Eina_List* list = view->__detailData->getContactsList(); + // gal search contact does not have contact list + WPRET_M(0 == eina_list_count(list), "contacts list is empty"); + + WMenuPopup* popup = new WMenuPopup(); + popup->prepare(view->__getWindow(), view->getNaviframe()->getEvasObj() ); + + if (!view->__detailData->getReadOnlyMode()) { + popup->appendItem(V_("IDS_PB_OPT_EDIT"), [view]() + { + view->__onEditCb(view, NULL, NULL); + }); + } + popup->appendItem(V_("IDS_PB_BUTTON_DELETE_ABB4"), [view]() + { + view->__onDeleteCb(view, NULL, NULL); + }); + if (!view->__detailData->getReadOnlyMode()) { + popup->appendItem(V_("IDS_PB_HEADER_SHARE_VIA"), [view]() + { + view->__onShareCb(view, NULL, NULL); + }); + } + + view->attachPopup( popup ); + + }, this); + + __createBaseInfo(); + + WLEAVE(); +} + +Evas_Object* CtDetailView::onCreate(Evas_Object* parent, void* viewParam) +{ + WENTER(); + std::string contactsEdjePath; + std::string detailLayoutEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + ContactsCommon::getAppEdjePath(DETAIL_LAYOUT_EDJ, detailLayoutEdjePath); + CtThemeMgr::getInstance()->addExtensionTheme(contactsEdjePath.c_str()); + CtThemeMgr::getInstance()->addExtensionTheme(detailLayoutEdjePath.c_str()); + + __mainLayout = elm_layout_add(parent); + elm_layout_file_set(__mainLayout, ContactsCommon::getAppEdjePath(DETAIL_LAYOUT_EDJ).c_str(), "main_layout"); + + CtThemeMgr::getInstance()->setObjectTheme(__mainLayout); + + Evas_Object* genlist = elm_genlist_add(__mainLayout); + evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS); + if(__needHomogeneous) + elm_genlist_homogeneous_set(genlist, EINA_TRUE); + + evas_object_show(genlist); + __genlist = genlist; + elm_object_part_content_set(__mainLayout, "swallow.content", genlist); + + WLEAVE(); + return __mainLayout; +} + +void CtDetailView::onLanguageChanged() +{ + WHIT(); + + if(__genlist) + elm_genlist_realized_items_update(__genlist); +} + +int CtDetailView::getPersoinId(void) +{ + WASSERT_EX(NULL != __detailData, "__detailData is null"); + return __detailData->getPersonId(); +} + +void CtDetailView::__addAllItems() +{ + WENTER(); + for (int i = __appendIndex; i < DETAIL_ITEMS_MAX; i++) { + __addItem((CtDetailItems) i); + } + + WLEAVE(); +} + +void CtDetailView::__addItem(CtDetailItems itemType) +{ + WENTER(); + WDEBUG("itemType %d", (int)itemType); + switch(itemType) { + case DETAIL_NUMBER: + __addNumberItems(); + break; + case DETAIL_EMAIL: + __addEmailItems(); + break; + case DETAIL_NOTE: + __addNoteItems(); + break; + case DETAIL_ADDRESS: + __addAddressItems(); + break; + case DETAIL_EVENT: + __addEventItems(); + break; + case DETAIL_RELATIONSHIP: + __addRelationItems(); + break; + case DETAIL_WEBSITE: + __addWebsiteItems(); + break; + case DETAIL_MESSENGER: + __addMessengerItems(); + break; + case DETAIL_ADDRBOOK: + __addAddressbookItems(); + break; + + default: + WDEBUG("Unsupported type: %d", itemType); + break; + } + WLEAVE(); +} + +void CtDetailView::__addNumberItems() +{ + WENTER(); + void *data = NULL; + Eina_List *cursor = NULL; + Eina_List *list = NULL; + WASSERT_EX(NULL != __detailData, "__detailData is null"); + list = __detailData->getNumberList(); + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) + continue; + + CtDetailViewNumberItem *item = new CtDetailViewNumberItem(__detailData, record); + Elm_Object_Item *obj = elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, __onPhonenumberItemSelectedCb, item); + item->setElmObjectItem(obj); + if (NULL == __genlistItemNumberFirst) + __genlistItemNumberFirst = (Elm_Object_Item*)item->getElmObjectItem(); + __genlistItemNumberLast= (Elm_Object_Item*)item->getElmObjectItem(); + } + + WLEAVE(); +} + +void CtDetailView::__addEmailItems() +{ + WENTER(); + void *data = NULL; + Eina_List *cursor = NULL; + Eina_List *list = NULL; + + WASSERT_EX(NULL != __detailData, "__detailData is null"); + list = __detailData->getEmailList(); + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) + continue; + + CtDetailViewEmailItem *item = new CtDetailViewEmailItem(__detailData, record); + item->setElmObjectItem(elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, __onEmailItemSelectedCb, item)); + __emailItem = (Elm_Object_Item*)item->getElmObjectItem(); + } + WLEAVE(); +} + +void CtDetailView::__addNoteItems() +{ + WENTER(); + void *data = NULL; + Eina_List *cursor = NULL; + Eina_List *list = NULL; + + WASSERT_EX(NULL != __detailData, "__detailData is null"); + list = __detailData->getNoteList(); + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) + continue; + + CtDetailViewNoteItem *item = new CtDetailViewNoteItem(__detailData, record); + item->setElmObjectItem(elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL)); + elm_genlist_item_select_mode_set((Elm_Object_Item*)item->getElmObjectItem(), ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + } + WLEAVE(); +} + +void CtDetailView::__addAddressItems() +{ + WENTER(); + void *data = NULL; + Eina_List *cursor = NULL; + Eina_List *list = NULL; + + WASSERT_EX(NULL != __detailData, "__detailData is null"); + list = __detailData->getAddressList(); + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) + continue; + + CtDetailViewAddressItem *item = new CtDetailViewAddressItem(__detailData, record); + item->setElmObjectItem(elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL)); + elm_genlist_item_select_mode_set((Elm_Object_Item*)item->getElmObjectItem(), ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + } + WLEAVE(); +} + +void CtDetailView::__addEventItems() +{ + WENTER(); + void *data = NULL; + Eina_List *cursor = NULL; + Eina_List *list = NULL; + + WASSERT_EX(NULL != __detailData, "__detailData is null"); + list = __detailData->getEventList(); + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) + continue; + + CtDetailViewEventItem *item = new CtDetailViewEventItem(__detailData, record); + item->setElmObjectItem(elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL)); + elm_genlist_item_select_mode_set((Elm_Object_Item*)item->getElmObjectItem(), ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + } + WLEAVE(); +} + +void CtDetailView::__addRelationItems() +{ + WENTER(); + void *data = NULL; + Eina_List *cursor = NULL; + Eina_List *list = NULL; + + WASSERT_EX(NULL != __detailData, "__detailData is null"); + list = __detailData->getRelationshipList(); + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) + continue; + + CtDetailViewRelationItem *item = new CtDetailViewRelationItem(__detailData, record); + item->setElmObjectItem(elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL)); + elm_genlist_item_select_mode_set((Elm_Object_Item*)item->getElmObjectItem(), ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + } + WLEAVE(); +} + +void CtDetailView::__addWebsiteItems() +{ + WENTER(); + void *data = NULL; + Eina_List *cursor = NULL; + Eina_List *list = NULL; + + WASSERT_EX(NULL != __detailData, "__detailData is null"); + list = __detailData->getUrlList(); + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) + continue; + + CtDetailViewWebsiteItem *item = new CtDetailViewWebsiteItem(__detailData, record); + item->setElmObjectItem(elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, __onWebsiteItemSelectedCb, item) ); + } + WLEAVE(); +} + +void CtDetailView::__addMessengerItems() +{ + WENTER(); + void *data = NULL; + Eina_List *cursor = NULL; + Eina_List *list = NULL; + + WASSERT_EX(NULL != __detailData, "__detailData is null"); + list = __detailData->getMessengerList(); + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) + continue; + + CtDetailViewMessengerItem *item = new CtDetailViewMessengerItem(__detailData, record); + item->setElmObjectItem(elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL) ); + elm_genlist_item_select_mode_set((Elm_Object_Item*)item->getElmObjectItem(), ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + } + WLEAVE(); +} + +void CtDetailView::__addAddressbookItems() +{ + WENTER(); + WLEAVE(); +} + +void CtDetailView::__onPhonenumberItemSelectedCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + + CtDetailViewNumberItem* item = (CtDetailViewNumberItem*)data; + Elm_Object_Item * elmItem = (Elm_Object_Item *) event_info; + elm_genlist_item_selected_set(elmItem, EINA_FALSE); + + item->onSelect(data, obj, event_info); +} + +void CtDetailView::__onEmailItemSelectedCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + CtDetailViewEmailItem* item = (CtDetailViewEmailItem*)data; + Elm_Object_Item *elmItem = (Elm_Object_Item *) event_info; + elm_genlist_item_selected_set(elmItem, EINA_FALSE); + + item->onSelect(data, obj, event_info); +} + +void CtDetailView::__onWebsiteItemSelectedCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + + CtDetailViewWebsiteItem* item = (CtDetailViewWebsiteItem*)data; + Elm_Object_Item *elmItem = (Elm_Object_Item *) event_info; + elm_genlist_item_selected_set(elmItem, EINA_FALSE); + + item->onSelect(data, obj, event_info); +} + +void CtDetailView::__onEditCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + CtDetailView* view = static_cast<CtDetailView*>(data); + Eina_List* contactList = view->__detailData->getContactsWithoutReadOnly(); + int err = CONTACTS_ERROR_NONE; + unsigned int count = eina_list_count(contactList); + if (count == 1) { + contacts_record_h record_contact = static_cast<contacts_record_h>(contactList->data); + contacts_record_h record_contact_cloned = NULL; + err = contacts_record_clone(record_contact, &record_contact_cloned); + WPRDT_M(CONTACTS_ERROR_NONE != err, "contacts_record_clone() Failed(%d)", err); + view->getNaviframe()->push(new CtInputView(record_contact_cloned), NULL, NULL); + } + else { + view->getNaviframe()->push(new CtEditTabView(contactList), NULL, NULL); + } +} + +void CtDetailView::__onDeleteCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + CtDetailView* view = static_cast<CtDetailView*>(data); + Eina_List* contactList = view->__detailData->getContactsList(); + unsigned int count = eina_list_count(contactList); + + WPopup *popup = new WPopup(); + popup->setTextTranslatable(PACKAGE); + popup->setTitle("IDS_PB_BUTTON_DELETE_ABB4"); + + if (count > 1) { + popup->setContent("IDS_PB_POP_THIS_CONTACT_AND_ALL_ITS_LINKED_CONTACTS_WILL_BE_DELETED"); + } + else { + popup->setContent("IDS_PB_POP_THIS_CONTACT_WILL_BE_DELETED"); + } + + popup->addButton("IDS_PB_BUTTON_CANCEL", [](bool* destroyPopup){ + WDEBUG("Cancel"); + *destroyPopup = true; + }); + popup->addButton("IDS_PB_BUTTON_DELETE_ABB4", [view](bool* destroyPopup){ + WDEBUG("Delete"); + if (CONTACTS_ERROR_NONE == __deleteContacts(view)) { +// view->popOut(); // popOut is called twice + *destroyPopup = false; + } + else { + *destroyPopup = true; + } + }); + + view->attachPopup( popup ); +} + +int CtDetailView::__deleteContacts(void *data) +{ + WHIT(); + CtDetailView* view = static_cast<CtDetailView*>(data); + int err = CONTACTS_ERROR_NONE; + + CtRegistryMgr::getInstance()->setInt(REGISTRY_KEY_DELETED_PERSON, 1); + CtRegistryMgr::getInstance()->setInt(REGISTRY_KEY_DELETED_PERSON_ID, view->getPersoinId()); + + err = contacts_db_delete_record(_contacts_person._uri, view->getPersoinId()); + WPWARN(err != CONTACTS_ERROR_NONE, "contacts_db_delete_record() fail(%d)",err); + return err; +} + +void CtDetailView::__onShareCb(void *data, Evas_Object *obj, void *event_info) +{ + WENTER(); + CtDetailView* view = static_cast<CtDetailView*>(data); + WPRET_M(!(view && view->__detailData), "invalid data"); + + sharePerson(view->__detailData->getPersonId(), false); +} + +void CtDetailView::__updateNumberFields() +{ + WHIT(); + Elm_Object_Item* item = __genlistItemNumberFirst; + + while (item) { + elm_genlist_item_fields_update(item, "elm.icon.left.bottom", ELM_GENLIST_ITEM_FIELD_CONTENT); + if (item == __genlistItemNumberLast) { + break; + } + item = elm_genlist_item_next_get(item); + } +} + +int CtDetailView::__getHeightByItemCount(Evas_Object* win, int count) +{ + int height = ELM_SCALE_SIZE(__ITEM_HEIGHT * count); + int maxHeight = ELM_SCALE_SIZE(__MAX_HEIGHT); + int rotation = elm_win_rotation_get(win); + if (90 == rotation || 270 == rotation) { + maxHeight = ELM_SCALE_SIZE(__MAX_HEIGHT_LANDSCAPE); + } + if (height > maxHeight) { + return maxHeight; + } + else { + return height; + } +} diff --git a/lib-contact/ct-detail/src/CtDetailViewAddressItem.h b/lib-contact/ct-detail/src/CtDetailViewAddressItem.h new file mode 100644 index 0000000..f0ecde4 --- /dev/null +++ b/lib-contact/ct-detail/src/CtDetailViewAddressItem.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_DETAIL_VIEW_ADDRESS_ITEM_H_ +#define _CT_DETAIL_VIEW_ADDRESS_ITEM_H_ + +#include "WGenlistItem.h" +#include "CtDetailDataBase.h" + +class CtDetailViewAddressItem : public WGenlistItem +{ +public: + CtDetailViewAddressItem(CtDetailDataBase *data, contacts_record_h record) + { + m_DetailData = data; + m_Record = record; + } + +public: + virtual Elm_Genlist_Item_Class *getItemClassStatic() + { + static Elm_Genlist_Item_Class itc = {}; + if( itc.item_style ) + return &itc; + itc.item_style = "multiline"; + itc.func.text_get = getTextAddress; + itc.func.del = WGENLIST_ITEM_DEL(); + return &itc; + } + +private: + static char *getTextAddress(void *data, Evas_Object *obj, const char *part) + { + WPRET_VM(!data, NULL, "data is NULL"); + CtDetailViewAddressItem *item = (CtDetailViewAddressItem *)data; + WPRET_VM(!item->m_DetailData, NULL, "m_DetailData is NULL"); + + if (0 == strcmp(part, "elm.text")) { + char text[CT_TEXT_MAX_LEN] = {0,}; + int type = item->m_DetailData->getAddressType( item->m_Record ); + std::string typeStr; + + item->m_DetailData->getAddressTypeStr( item->m_Record, type, typeStr); + snprintf(text, sizeof(text), "<font_size=32><font color=#4D4D4D>%s</font></font_size>", typeStr.c_str()); + return SAFE_STRDUP(text); + + } else if (0 == strcmp(part, "elm.text.multiline")) { + char text[CT_TEXT_MAX_LEN] = {0,}; + char *markupText=NULL; + + item->m_DetailData->getAddress( item->m_Record, text, sizeof(text)); + markupText = elm_entry_utf8_to_markup(text); + snprintf(text, sizeof(text), "<font_size=40><font color=#000000>%s</font></font_size>", markupText); + free(markupText); + + return SAFE_STRDUP(text); + } + return NULL; + } + +private: + CtDetailViewAddressItem(); + CtDetailDataBase *m_DetailData; + contacts_record_h m_Record; +}; + + +#endif /* _CT_DETAIL_VIEW_ADDRESS_ITEM_H_ */ diff --git a/lib-contact/ct-detail/src/CtDetailViewBasicInfoControl.cpp b/lib-contact/ct-detail/src/CtDetailViewBasicInfoControl.cpp new file mode 100644 index 0000000..8bf3c78 --- /dev/null +++ b/lib-contact/ct-detail/src/CtDetailViewBasicInfoControl.cpp @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + +#include "ContactsThumbnail.h" +#include "CtCommon.h" +#include "CtDetailDataBase.h" +#include "CtDetailViewBasicInfoControl.h" +#include "CtPath.h" +#include "CtRegistryMgr.h" +#include "WDebugBase.h" + + + +CtDetailViewBasicInfoControl::CtDetailViewBasicInfoControl(CtDetailDataBase *data, bool showFavoriteIcon) +{ + m_DetailData = data; + m_BaseLayout = NULL; + m_ShowFavoriteIcon = showFavoriteIcon; + m_FavoriteReference = false; +} + +Evas_Object *CtDetailViewBasicInfoControl::onCreate(Evas_Object *parent, void *viewParam) +{ + WHIT(); + WPRET_VM(!m_DetailData, NULL, "__detailData is NULL"); + + m_BaseLayout = elm_layout_add(parent); + updateBaseLayout(parent); + + setThumbnail(); + setFavoriteBtn(); + setText(m_DetailData->getDisplayName(), "text_1line"); + + if ((m_DetailData->getPhoneticName() && *m_DetailData->getPhoneticName())) { + setText(m_DetailData->getPhoneticName(), "text_2line"); + + if ((m_DetailData->getCompany() && *m_DetailData->getCompany())) { + setText(m_DetailData->getCompany(), "text_3line"); + } + + } else if ((m_DetailData->getCompany() && *m_DetailData->getCompany())) { + setText(m_DetailData->getCompany(), "text_2line"); + } + + return m_BaseLayout; +} + +int CtDetailViewBasicInfoControl::getLinesCount() +{ + WPRET_VM(!m_DetailData, -1, "__detailData is NULL"); + int count = 0; + + if (m_DetailData->getPhoneticName() && *m_DetailData->getPhoneticName()) { + ++count; + } + if (m_DetailData->getCompany() && *m_DetailData->getCompany()) { + ++count; + } + WDEBUG("count %d", count); + + return count; +} + +void CtDetailViewBasicInfoControl::updateBaseLayout(Evas_Object *parent) +{ + WPRET_M(!m_DetailData, "__detailData is NULL"); + + const char *signal[] = { + "set_1line", + "set_2lines", + "set_3lines" + }; + const char *groupName[] = { + "base_info_1line", + "base_info_2lines", + "base_info_3lines" + }; + int count = getLinesCount(); + if (count >= 0) { + WDEBUG("signal: %s, group name: %s", signal[count], groupName[count]); + + elm_object_signal_emit(parent, signal[count], ""); + elm_layout_file_set(m_BaseLayout, ContactsCommon::getAppEdjePath(DETAIL_LAYOUT_EDJ).c_str(), groupName[count]); + } +} + +void CtDetailViewBasicInfoControl::setThumbnail() +{ + WPRET_M(!m_DetailData, "__detailData is NULL"); + + Evas_Object *thumbnail = createThumbnail(m_BaseLayout, THUMBNAIL_240, m_DetailData->getImagePath()); + elm_object_part_content_set(m_BaseLayout, "swallow.image_thumbnail", thumbnail); +} + +void CtDetailViewBasicInfoControl::setFavoriteBtn() +{ + WPRET_M(!m_DetailData, "__detailData is NULL"); + + if (m_ShowFavoriteIcon) { + m_FavoriteReference = m_DetailData->getFavorite(); + Evas_Object *check = elm_check_add(m_BaseLayout); + elm_object_style_set(check, "favorite"); + elm_check_state_set(check, m_FavoriteReference); + evas_object_smart_callback_add(check, "changed", onBasicInfoFavoritesClickedCb, this); + elm_layout_content_set(m_BaseLayout, "swallow.favor_btn", check); + } +} + +void CtDetailViewBasicInfoControl::setText(const char *text, const char *textPart) +{ + char *markupText = elm_entry_utf8_to_markup(text); + if (markupText && *markupText) { + WDEBUG("text = %s", markupText); + elm_object_part_text_set(m_BaseLayout, textPart, markupText); + } + free(markupText); +} + +void CtDetailViewBasicInfoControl::onBasicInfoFavoritesClickedCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + WPRET_M(!data, "data is NULL"); + + CtDetailViewBasicInfoControl *basicInfo = (CtDetailViewBasicInfoControl*) data; + WPRET_M(!basicInfo->m_DetailData, "__detailData is NULL"); + + CtRegistryMgr::getInstance()->setInt(REGISTRY_KEY_FAVORITE_UPDATED, 1); + + basicInfo->m_FavoriteReference = !basicInfo->m_FavoriteReference; + basicInfo->m_DetailData->setFavorite(basicInfo->m_FavoriteReference); + + WDEBUG("favorite %d", basicInfo->m_DetailData->getFavorite()); +} diff --git a/lib-contact/ct-detail/src/CtDetailViewEmailItem.h b/lib-contact/ct-detail/src/CtDetailViewEmailItem.h new file mode 100755 index 0000000..8280193 --- /dev/null +++ b/lib-contact/ct-detail/src/CtDetailViewEmailItem.h @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_DETAIL_VIEW_EMAIL_ITEM_H_ +#define _CT_DETAIL_VIEW_EMAIL_ITEM_H_ + +#include "WGenlistItem.h" +#include "ContactsAppControl.h" +#include "CtDetailDataBase.h" + +#define ICON_EMAIL_SIZE 80 +#define ICON_EMAIL_COLOR 61, 185, 204, 255 + +class CtDetailViewEmailItem : public WGenlistItem +{ +public: + CtDetailViewEmailItem(CtDetailDataBase *data, contacts_record_h record, bool myProfile = false) + { + m_DetailData = data; + m_Record = record; + m_MyProfile = myProfile; + } +public: + virtual Elm_Genlist_Item_Class *getItemClassStatic() + { + static Elm_Genlist_Item_Class itc = {}; + if( itc.item_style ) + return &itc; + itc.item_style = "type2"; + itc.func.content_get = getContentEmail; + itc.func.text_get = getTextEmail; + itc.func.del = WGENLIST_ITEM_DEL(); + return &itc; + } + + virtual void onSelect(void *data, Evas_Object *obj, void *event_info) + { + WPRET_M(!data, "data is NULL"); + CtDetailViewEmailItem *item = (CtDetailViewEmailItem *)data; + WPRET_M(!item->m_DetailData, "m_DetailData is NULL"); + + int err = launchMessageComposer("mailto:", item->m_DetailData->getEmail(item->m_Record)); + WPWARN(err != APP_CONTROL_ERROR_NONE, "launchMessageComposer() failed(%d)", err); + } + +private: + static Evas_Object *getContentEmail(void *data, Evas_Object *obj, const char *part) + { + WPRET_VM(!data, NULL, "data is NULL"); + CtDetailViewEmailItem *item = (CtDetailViewEmailItem *)data; + + if (0 == strcmp(part, "elm.swallow.end")) { + if (item->m_MyProfile) { + return NULL; + } + + Evas_Object *iconEmail = elm_image_add(obj); + elm_image_file_set(iconEmail, CT_IMG_ICON_DETAIL_EMAIL, nullptr); + evas_object_color_set(iconEmail, ICON_EMAIL_COLOR); + elm_image_aspect_fixed_set(iconEmail, EINA_TRUE); + evas_object_size_hint_min_set(iconEmail, ContactsCommon::getScaledWidth(ICON_EMAIL_SIZE), ContactsCommon::getScaledHeight(ICON_EMAIL_SIZE)); + + return iconEmail; + } + return NULL; + } + + static char *getTextEmail(void *data, Evas_Object *obj, const char *part) + { + WPRET_VM(!data, NULL, "data is NULL"); + CtDetailViewEmailItem *item = (CtDetailViewEmailItem *)data; + WPRET_VM(!item->m_DetailData, NULL, "m_DetailData is NULL"); + + if (0 == strcmp(part, "elm.text.sub")) { + int type = item->m_DetailData->getEmailType(item->m_Record); + std::string typeStr; + item->m_DetailData->getEmailTypeStr(item->m_Record, type, typeStr); + return SAFE_STRDUP(typeStr.c_str()); + } else if (0 == strcmp(part, "elm.text")) { + return elm_entry_utf8_to_markup(item->m_DetailData->getEmail(item->m_Record)); + } + return NULL; + } + +private: + CtDetailViewEmailItem(); + CtDetailDataBase *m_DetailData; + contacts_record_h m_Record; + bool m_MyProfile; +}; + +#endif /* _CT_DETAIL_VIEW_EMAIL_ITEM_H_ */ diff --git a/lib-contact/ct-detail/src/CtDetailViewEventItem.h b/lib-contact/ct-detail/src/CtDetailViewEventItem.h new file mode 100644 index 0000000..411c11e --- /dev/null +++ b/lib-contact/ct-detail/src/CtDetailViewEventItem.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_DETAIL_VIEW_EVENT_ITEM_H_ +#define _CT_DETAIL_VIEW_EVENT_ITEM_H_ + +#include "WGenlistItem.h" +#include "CtDetailDataBase.h" + +class CtDetailViewEventItem : public WGenlistItem +{ +public: + CtDetailViewEventItem(CtDetailDataBase *data, contacts_record_h record) + { + m_DetailData = data; + m_Record = record; + } +public: + virtual Elm_Genlist_Item_Class *getItemClassStatic() + { + static Elm_Genlist_Item_Class itc = {}; + if( itc.item_style ) + return &itc; + itc.item_style = "type2"; + itc.func.text_get = getTextEvent; + itc.func.del = WGENLIST_ITEM_DEL(); + return &itc; + } + +private: + + static char *getTextEvent(void *data, Evas_Object *obj, const char *part) + { + WPRET_VM(!data, NULL, "data is NULL"); + CtDetailViewEventItem *item = (CtDetailViewEventItem *)data; + WPRET_VM(!item->m_DetailData, NULL, "m_DetailData is NULL"); + + if (0 == strcmp(part, "elm.text.sub")) { + int type = item->m_DetailData->getEventType( item->m_Record); + std::string typeStr; + item->m_DetailData->getEventTypeStr( item->m_Record, type, typeStr); + return SAFE_STRDUP(typeStr.c_str()); + } else if (0 == strcmp(part, "elm.text")) { + int date = item->m_DetailData->getEvent( item->m_Record); + int day = date%100; + int mon = (date%10000)/100; + int year = date/10000; + WPRET_VM(mon < 1 || 12 < mon || day < 1 || 31 < day, NULL, "Invalid date(mon=%d,day=%d)",mon,day); + return item->m_DetailData->getDatetimeStr(item->m_DetailData->getDateFormater(), year, mon, day); + } + return NULL; + } + +private: + CtDetailViewEventItem(); + CtDetailDataBase *m_DetailData; + contacts_record_h m_Record; +}; + +#endif /* _CT_DETAIL_VIEW_EVENT_ITEM_H_ */ diff --git a/lib-contact/ct-detail/src/CtDetailViewMessengerItem.h b/lib-contact/ct-detail/src/CtDetailViewMessengerItem.h new file mode 100644 index 0000000..911de86 --- /dev/null +++ b/lib-contact/ct-detail/src/CtDetailViewMessengerItem.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_DETAIL_VIEW_MESSENGER_ITEM_H_ +#define _CT_DETAIL_VIEW_MESSENGER_ITEM_H_ + +#include "WGenlistItem.h" +#include "CtDetailDataBase.h" + +class CtDetailViewMessengerItem : public WGenlistItem +{ +public: + CtDetailViewMessengerItem(CtDetailDataBase *data, contacts_record_h record) + { + m_DetailData = data; + m_Record = record; + } +public: + virtual Elm_Genlist_Item_Class* getItemClassStatic() + { + static Elm_Genlist_Item_Class itc = {}; + if( itc.item_style ) + return &itc; + itc.item_style = "type2"; + itc.func.text_get = getTextMessenger; + itc.func.del = WGENLIST_ITEM_DEL(); + return &itc; + } + +private: + static char *getTextMessenger(void *data, Evas_Object *obj, const char *part) + { + WPRET_VM(!data, NULL, "data is NULL"); + CtDetailViewMessengerItem *item = (CtDetailViewMessengerItem *)data; + WPRET_VM(!item->m_DetailData, NULL, "m_DetailData is NULL"); + + if (0 == strcmp(part, "elm.text.sub")) { + int type = item->m_DetailData->getMessengerType( item->m_Record ); + std::string typeStr; + item->m_DetailData->getMessengerTypeStr( item->m_Record, type, typeStr); + return SAFE_STRDUP(typeStr.c_str()); + } else if (0 == strcmp(part, "elm.text")) { + return elm_entry_utf8_to_markup( item->m_DetailData->getMessenger( item->m_Record )); + } + return NULL; + } + +private: + CtDetailViewMessengerItem(); + CtDetailDataBase *m_DetailData; + contacts_record_h m_Record; +}; + + + +#endif /* _CT_DETAIL_VIEW_MESSENGER_ITEM_H_ */ diff --git a/lib-contact/ct-detail/src/CtDetailViewNoteItem.h b/lib-contact/ct-detail/src/CtDetailViewNoteItem.h new file mode 100644 index 0000000..dab04fc --- /dev/null +++ b/lib-contact/ct-detail/src/CtDetailViewNoteItem.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_DETAIL_VIEW_NOTE_ITEM_H_ +#define _CT_DETAIL_VIEW_NOTE_ITEM_H_ + +#include "WGenlistItem.h" +#include "CtDetailDataBase.h" + +class CtDetailViewNoteItem : public WGenlistItem +{ +public: + CtDetailViewNoteItem(CtDetailDataBase *data, contacts_record_h record) + { + m_DetailData = data; + m_Record = record; + } + +public: + virtual Elm_Genlist_Item_Class *getItemClassStatic() + { + static Elm_Genlist_Item_Class itc = {}; + if( itc.item_style ) { + return &itc; + } + itc.item_style = "multiline"; + itc.func.text_get = getTextNote; + itc.func.del = WGENLIST_ITEM_DEL(); + return &itc; + } + +private: + static char *getTextNote(void *data, Evas_Object *obj, const char *part) + { + WPRET_VM(!data, NULL, "data is NULL"); + CtDetailViewNoteItem *item = (CtDetailViewNoteItem *)data; + WPRET_VM(!item->m_DetailData, NULL, "m_DetailData is NULL"); + + if (0 == strcmp(part, "elm.text.multiline")) { + return elm_entry_utf8_to_markup(item->m_DetailData->getNote(item->m_Record)); + } + return NULL; + } + +private: + CtDetailViewNoteItem(); + CtDetailDataBase *m_DetailData; + contacts_record_h m_Record; +}; + + +#endif /* _CT_DETAIL_VIEW_NOTE_ITEM_H_ */ diff --git a/lib-contact/ct-detail/src/CtDetailViewNumberItem.h b/lib-contact/ct-detail/src/CtDetailViewNumberItem.h new file mode 100644 index 0000000..1223610 --- /dev/null +++ b/lib-contact/ct-detail/src/CtDetailViewNumberItem.h @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_DETAIL_VIEW_NUMBER_ITEM_H_ +#define _CT_DETAIL_VIEW_NUMBER_ITEM_H_ + +#include "ContactsAppControl.h" +#include "ContactsNumberItemIcons.h" +#include "CtDetailDataBase.h" +#include "CtThemeMgr.h" +#include "WGenlistItem.h" + +class CtDetailViewNumberItem : public WGenlistItem +{ +public: + CtDetailViewNumberItem(CtDetailDataBase *data, contacts_record_h record, bool myProfile = false) + { + m_DetailData = data; + m_Record = record; + m_MyProfile = myProfile; + } + +public: + virtual Elm_Genlist_Item_Class *getItemClassStatic() + { + static Elm_Genlist_Item_Class itc = {}; + if( itc.item_style ) + return &itc; + itc.item_style = "type2"; + itc.func.content_get = getContentNumber; + itc.func.text_get = getTextNumber; + itc.func.del = WGENLIST_ITEM_DEL(); + return &itc; + } + + virtual void onSelect(void *data, Evas_Object *obj, void *event_info) + { + WPRET_M(!m_DetailData, "m_DetailData is NULL"); + + int err = launchCall(m_DetailData->getNumber(m_Record)); + WPWARN(err != APP_CONTROL_ERROR_NONE, "launchCall() failed(0x%x)", err); + } + + contacts_record_h getRecord() + { + return m_Record; + } + +private: + static Evas_Object *getContentNumber(void *data, Evas_Object *obj, const char *part) + { + WHIT(); + WPRET_VM(!data, NULL, "data is NULL"); + CtDetailViewNumberItem *item = (CtDetailViewNumberItem *)data; + + if (0 == strcmp(part, "elm.swallow.end")){ + if (item->m_MyProfile) { + return NULL; + } + + return createNumberItemIconsLayout(obj, item->m_DetailData->getNumber(item->m_Record)); + } + return NULL; + } + + static char *getTextNumber(void *data, Evas_Object *obj, const char *part) + { + WPRET_VM(!data, NULL, "data is NULL"); + CtDetailViewNumberItem *item = (CtDetailViewNumberItem*)data; + WPRET_VM(!item->m_DetailData, NULL, "m_DetailData is NULL"); + + if (0 == strcmp(part, "elm.text.sub")) { + std::string typeStr; + int type = item->m_DetailData->getNumberType(item->m_Record); + item->m_DetailData->getNumberTypeStr(item->m_Record, type, typeStr); + WDEBUG("type %d text %s", type, typeStr.c_str()); + return SAFE_STRDUP(typeStr.c_str()); + } else if (0 == strcmp(part, "elm.text")) { + return elm_entry_utf8_to_markup( item->m_DetailData->getNumber( item->m_Record )); + } + return NULL; + } + +private: + CtDetailViewNumberItem(); + CtDetailDataBase *m_DetailData; + contacts_record_h m_Record; + bool m_MyProfile; +}; + + +#endif /* _CT_DETAIL_VIEW_NUMBER_ITEM_H_ */ diff --git a/lib-contact/ct-detail/src/CtDetailViewRelationItem.h b/lib-contact/ct-detail/src/CtDetailViewRelationItem.h new file mode 100644 index 0000000..4d6f423 --- /dev/null +++ b/lib-contact/ct-detail/src/CtDetailViewRelationItem.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_DETAIL_VIEW_RELATION_ITEM_H_ +#define _CT_DETAIL_VIEW_RELATION_ITEM_H_ + +#include "WGenlistItem.h" +#include "CtDetailDataBase.h" + +class CtDetailViewRelationItem : public WGenlistItem +{ +public: + CtDetailViewRelationItem(CtDetailDataBase *data, contacts_record_h record) + { + m_DetailData = data; + m_Record = record; + } +public: + virtual Elm_Genlist_Item_Class *getItemClassStatic() + { + static Elm_Genlist_Item_Class itc = {}; + if( itc.item_style ) + return &itc; + itc.item_style = "type2"; + itc.func.text_get = getTextRelationship; + itc.func.del = WGENLIST_ITEM_DEL(); + return &itc; + } + +private: + static char *getTextRelationship(void *data, Evas_Object *obj, const char *part) + { + WPRET_VM(!data, NULL, "data is NULL"); + CtDetailViewRelationItem *item = (CtDetailViewRelationItem *)data; + WPRET_VM(!item->m_DetailData, NULL, "m_DetailData is NULL"); + + if (0 == strcmp(part, "elm.text.sub")) { + int type = item->m_DetailData->getRelationshipType( item->m_Record); + std::string typeStr; + item->m_DetailData->getRelationshipTypeStr( item->m_Record, type, typeStr); + return SAFE_STRDUP(typeStr.c_str()); + } else if (0 == strcmp(part, "elm.text")) { + return elm_entry_utf8_to_markup(item->m_DetailData->getRelationship( item->m_Record)); + } + return NULL; + } + +private: + CtDetailViewRelationItem(); + CtDetailDataBase *m_DetailData; + contacts_record_h m_Record; +}; + +#endif /* _CT_DETAIL_VIEW_RELATION_ITEM_H_ */ diff --git a/lib-contact/ct-detail/src/CtDetailViewWebsiteItem.h b/lib-contact/ct-detail/src/CtDetailViewWebsiteItem.h new file mode 100755 index 0000000..27359ba --- /dev/null +++ b/lib-contact/ct-detail/src/CtDetailViewWebsiteItem.h @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_DETAIL_VIEW_WEBSITE_ITEM_H_ +#define _CT_DETAIL_VIEW_WEBSITE_ITEM_H_ + +#include "WGenlistItem.h" +#include "CtDetailDataBase.h" +#include "CtString.h" + +#define ICON_WEBSITE_SIZE 80 + +class CtDetailViewWebsiteItem : public WGenlistItem +{ +public: + CtDetailViewWebsiteItem(CtDetailDataBase *data, contacts_record_h record, bool myProfile = false) + { + m_DetailData = data; + m_Record = record; + m_MyProfile = myProfile; + } +public: + virtual Elm_Genlist_Item_Class *getItemClassStatic() + { + static Elm_Genlist_Item_Class itc = {}; + if( itc.item_style ) + return &itc; + itc.item_style = "type1"; + itc.func.content_get = getContentWebsite; + itc.func.text_get = getTextWebsite; + itc.func.del = WGENLIST_ITEM_DEL(); + return &itc; + } + + virtual void onSelect(void *data, Evas_Object *obj, void *event_info) + { + WPRET_M(!m_DetailData, "m_DetailData is NULL"); + + launchWebsite(m_DetailData, m_Record); + } +private: + static char *getTextWebsite(void *data, Evas_Object *obj, const char *part) + { + WPRET_VM(!data, NULL, "data is NULL"); + CtDetailViewWebsiteItem *item = (CtDetailViewWebsiteItem *)data; + WPRET_VM(!item->m_DetailData, NULL, "m_DetailData is NULL"); + + if (0 == strcmp(part, "elm.text")) { + return elm_entry_utf8_to_markup( item->m_DetailData->getUrl( item->m_Record)); + } + return NULL; + } + + static Evas_Object *getContentWebsite(void *data, Evas_Object *obj, const char *part) + { + WPRET_VM(!data, NULL, "data is NULL"); + CtDetailViewWebsiteItem *item = (CtDetailViewWebsiteItem *)data; + WPRET_VM(!item->m_DetailData, NULL, "m_DetailData is NULL"); + + if (0 == strcmp(part, "elm.swallow.end")) { + if (item->m_MyProfile) { + return NULL; + } + + Evas_Object *iconWebsite = elm_image_add(obj); + elm_image_file_set(iconWebsite, CT_IMG_ICON_DETAIL_INTERNET, nullptr); + evas_object_color_set(iconWebsite, 61, 185, 204, 255); + elm_image_aspect_fixed_set(iconWebsite, EINA_TRUE); + evas_object_size_hint_min_set(iconWebsite, ContactsCommon::getScaledWidth(ICON_WEBSITE_SIZE), ContactsCommon::getScaledHeight(ICON_WEBSITE_SIZE)); + evas_object_smart_callback_add(iconWebsite, "clicked", onWebsiteIconClickedCb, item); + + return iconWebsite; + } + return NULL; + } + + void launchWebsite(CtDetailDataBase *detailData, contacts_record_h record) + { + WHIT(); + app_control_h service; + const char *website = detailData->getUrl( record ); + + app_control_create(&service); + app_control_set_operation(service, APP_CONTROL_OPERATION_VIEW ); + if (strstr(website, "http")) + app_control_set_uri(service, website); + else { + char *new_url = g_strdup_printf("http://%s", website); + app_control_set_uri(service, new_url); + free(new_url); + } + app_control_set_launch_mode(service, APP_CONTROL_LAUNCH_MODE_GROUP); + + app_control_send_launch_request(service, NULL, NULL); + app_control_destroy(service); + } + + static void onWebsiteIconClickedCb(void *data, Evas_Object *obj, void *event_info) + { + WPRET_M(!data, "data is NULL"); + CtDetailViewWebsiteItem *item = (CtDetailViewWebsiteItem *)data; + WPRET_M(!item->m_DetailData, "m_DetailData is NULL"); + + item->launchWebsite(item->m_DetailData, item->m_Record); + } + +private: + CtDetailViewWebsiteItem(); + CtDetailDataBase *m_DetailData; + contacts_record_h m_Record; + bool m_MyProfile; +}; + +#endif /* _CT_DETAIL_VIEW_WEBSITE_ITEM_H_ */ diff --git a/lib-contact/ct-detail/src/CtEditTabView.cpp b/lib-contact/ct-detail/src/CtEditTabView.cpp new file mode 100755 index 0000000..e08bfca --- /dev/null +++ b/lib-contact/ct-detail/src/CtEditTabView.cpp @@ -0,0 +1,428 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +//#include <ui_extension.h> + +#include "WPageSlideView.h" + +#include "ContactsDebug.h" +//#include "ContactsAppControlLauncher.h" + +#include "CtCommon.h" +#include "CtString.h" +#include "CtEditTabView.h" +#include "CtInputView.h" + +#define CT_TAB_CREATE_SUB_VIEW_TIMER 1.0 + +CtEditTabView::CtEditTabView(Eina_List* contactList) +{ + WENTER(); + __idler = NULL; + __timer = NULL; + __tabbar = NULL; + __tabCount = eina_list_count(contactList); + __discard = false; + __selectedView = 0; + + int i = 0; + Eina_List *l = NULL; + void* data = NULL; + char buf[CT_TEXT_MAX_LEN] = {0}; + WDEBUG("__tabCount %d", __tabCount); + if (__tabCount > EDIT_TAB_VIEW_MAX) { + __tabCount = EDIT_TAB_VIEW_MAX; + } + + for( i=0; i<__tabCount; i++) { + __tabItem[i] = NULL; + __subViewLoaded[i] = false; + __subView[i] = NULL; + } + i = 0; + EINA_LIST_FOREACH(contactList, l, data) { + contacts_record_h record = (contacts_record_h)data; + if (NULL == record) break; + contacts_record_h recordCloned = NULL; + int err = contacts_record_clone(record, &recordCloned); + WPRDT_M(CONTACTS_ERROR_NONE != err, "contacts_record_clone() Failed(%d)", err); + __subView[i] = new CtInputView(recordCloned, this, true); + __getTabViewTitle(recordCloned, buf, sizeof(buf)); + __subView[i]->setName(buf); + i++; + if(i == EDIT_TAB_VIEW_MAX) + break; + } + + WLEAVE(); +} + +CtEditTabView::~CtEditTabView() +{ + WHIT(); +} + + +Evas_Object* CtEditTabView::onCreate(Evas_Object* parent, void* viewParam) +{ + WENTER(); + + Evas_Object* layout = elm_layout_add(parent); + elm_layout_theme_set(layout, "layout", "application", "default"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + setOnInitScroller( [](Evas_Object* scroller) + { + elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); + //uxt_scroller_set_auto_scroll_enabled(scroller, EINA_FALSE); + }); + + Evas_Object* slideViewObj = WPageSlideView::onCreate(layout, NULL); + + elm_object_part_content_set(layout, "elm.swallow.content", slideViewObj); + evas_object_smart_callback_add(getScroller(), "scroll,anim,stop", __pageScrollStopCb, this ); + evas_object_smart_callback_add(getScroller(), "scroll,drag,start", __pageScrollStartCb, this ); + + evas_object_show(layout); + + WDEBUG("layout %p", layout); + + return layout; + +} + + +void CtEditTabView::onDestroy() +{ + if(__idler) + ecore_idler_del(__idler); + __idler = NULL; + + if(__timer) + ecore_timer_del(__timer); + __timer = NULL; +} + +Elm_Object_Item* CtEditTabView::onPushToNaviframe(Evas_Object* naviFrame) +{ + WDEBUG("page set"); + + //create tabbar + Evas_Object* tabbar = elm_toolbar_add(naviFrame); + elm_toolbar_shrink_mode_set(tabbar, ELM_TOOLBAR_SHRINK_EXPAND); + elm_toolbar_select_mode_set(tabbar, ELM_OBJECT_SELECT_MODE_ALWAYS); + elm_toolbar_transverse_expanded_set(tabbar, EINA_TRUE); + + Elm_Object_Item* naviItem = NULL; + elm_object_style_set(tabbar, "tabbar_with_title"); + naviItem = elm_naviframe_item_push(naviFrame, V_("IDS_PB_OPT_EDIT"), NULL, NULL, getEvasObj(), "tabbar"); + + elm_object_item_part_content_set(naviItem, "tabbar", tabbar); + __tabbar = tabbar; + for( int i = 0; i<__tabCount; i++) { + const char *tabName = NULL; + tabName = __subView[i]->getName(); + + WDEBUG("tabName %s %d", tabName, i); + __tabItem[i] = elm_toolbar_item_append(tabbar, NULL, tabName, __onTabChangedCb, this); + elm_object_item_domain_text_translatable_set(__tabItem[i], PACKAGE, EINA_TRUE); + } + + WLEAVE(); + + return naviItem; + +} + +void CtEditTabView::onPushed(Elm_Object_Item* naviItem) +{ + WENTER(); + + for( int i = 0; i<__tabCount; i++) { + if(__subView[i]) + appendPage(); + } + + //set first show page + if(__subView[__selectedView]) { + setPageContent(__selectedView, __subView[__selectedView]); + __subView[__selectedView]->createEditSubViewContent(); + __subViewLoaded[__selectedView] = true; + //elm_toolbar_item_selected_set(__tabItem[__selectedView], EINA_TRUE); + + // showPage(__selectedView, false); + //__timer = ecore_timer_add(CT_TAB_CREATE_SUB_VIEW_TIMER, __createRestViewTimerCb, this); + } + + __saveBtn = elm_button_add(getNaviframe()->getEvasObj()); + elm_object_style_set(__saveBtn, "naviframe/title_done"); + elm_object_text_set(__saveBtn, V_("IDS_TPLATFORM_ACBUTTON_DONE_ABB")); + evas_object_smart_callback_add(__saveBtn, "clicked", __saveCb, this); + elm_object_item_part_content_set(naviItem, "title_right_btn", __saveBtn); + + Evas_Object* cancelBtn = elm_button_add(getNaviframe()->getEvasObj()); + elm_object_style_set(cancelBtn, "naviframe/title_cancel"); + elm_object_text_set(cancelBtn, V_("IDS_TPLATFORM_ACBUTTON_CANCEL_ABB")); + evas_object_smart_callback_add(cancelBtn, "clicked", __cancelCb, this); + elm_object_item_part_content_set(naviItem, "title_left_btn", cancelBtn); + WLEAVE(); +} + +bool CtEditTabView::onPop( ) +{ + WHIT(); + bool changed = false; + + for( int i = 0; i<__tabCount; i++) { + if (__subView[i]) { + __subView[i]->onTabPop(); + bool changedSub = false; + __subView[i]->getChangedForEditTabSubView(&changedSub); + changed = changed | changedSub; + } + } + if (__discard) { + return true; + } + + if (changed) { + WDEBUG("changed"); + + WPopup *popup = new WPopup(); + popup->setTextTranslatable(PACKAGE); + popup->setTitle("IDS_PB_HEADER_DISCARD_CHANGES_ABB"); + popup->setContent("IDS_PB_POP_ALL_CHANGES_WILL_BE_DISCARDED"); + + popup->addButton("IDS_PB_BUTTON_CANCEL", [](bool* destroyPopup){ + WDEBUG("Cancel"); + *destroyPopup = true; + }); + popup->addButton(V_("IDS_PB_BUTTON_DISCARD_ABB"), [this](bool* destroyPopup){ + WDEBUG("Discard"); + __discard = true; + popOut(); + *destroyPopup = false; + }); + + attachPopup(popup); + return false; + } + + return true; +} + +void CtEditTabView::updateSaveBtn(Eina_Bool empty) +{ + if (!empty) { + bool emptyAll = false; + for( int i = 0; i<__tabCount; i++) { + if (__subView[i]) { + bool emptySub = false; + __subView[i]->getEmptyForEditTabSubView(&emptySub); + emptyAll = emptyAll | emptySub; + if (emptyAll) { + break; + } + } + } + empty = emptyAll; + } + elm_object_disabled_set(__saveBtn, empty); + WPRET_M(true == empty, "all fields are empty, can't save"); +} + +void CtEditTabView::__saveCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + CtEditTabView* view = (CtEditTabView*)data; + + for( int i = 0; i<view->__tabCount; i++) { + if (view->__subView[i]) { + bool changedSub = false; + view->__subView[i]->getChangedForEditTabSubView(&changedSub); + if (changedSub) { + view->__subView[i]->saveContactForEditTabSubView(); + } + } + } + view->destroyPopup(); + elm_object_item_del(view->getNaviItem()); + + //view->popOut(); +} + +void CtEditTabView::__cancelCb(void *data, Evas_Object *obj, void *event_info) +{ + CtEditTabView* view = (CtEditTabView*)data; + view->popOut(); +} + +void CtEditTabView::__onTabChangedCb(void* data, Evas_Object* obj, void* event_info) +{ + WHIT(); + CtEditTabView* view = (CtEditTabView*)data; + Elm_Object_Item *selectedItem = elm_toolbar_selected_item_get(obj); + + view->__tabChanged(selectedItem); + +} + +void CtEditTabView::__tabChanged(Elm_Object_Item *selectedItem) +{ + WHIT(); + + if(getPageCount() == 0) { + WERROR("page item not added"); + return; + } + + if(selectedItem != __tabItem[__selectedView]) { + int i = 0; + WDEBUG("%d", __selectedView); + + if(selectedItem) { + + if(__subView[__selectedView] && __subViewLoaded[__selectedView]) + __subView[__selectedView]->onTabUnselect(getNaviItem()); + + for (i=0;i<__tabCount;i++) { + if (__tabItem[i]) { + if (selectedItem == __tabItem[i]) { + if(__subView[i]) { + setPageContent(i, __subView[i]); + __subViewLoaded[i] = true; + __subView[i]->onTabSelect(getNaviItem()); + } + break; + } + } + } + + __selectedView = i; + } + else {//first selected(launched) + WDEBUG("first launched"); + if(__subView[__selectedView] && __subViewLoaded[__selectedView]) { + __subView[__selectedView]->onTabSelect(getNaviItem()); + } + } + } + + showPage(__selectedView, false); + +} + +void CtEditTabView::__pageScrollStopCb(void* data, Evas_Object* obj, void* event_info) +{ + CtEditTabView* view = (CtEditTabView*)data; + for(int i = 0; i < view->__tabCount; i++) { + if(view->__subView[i] && view->__subViewLoaded[i]) + view->__subView[i]->onTabScrollStop(); + } + + int hpage = 0; + elm_scroller_current_page_get(obj, &hpage, NULL); + WDEBUG("pagen %d", hpage); + + elm_toolbar_item_selected_set(view->__tabItem[hpage], EINA_TRUE); + return; +} + +void CtEditTabView::__pageScrollStartCb(void* data, Evas_Object* obj, void* event_info) +{ + WHIT(); + CtEditTabView* view = (CtEditTabView*)data; + for( int i = 0; i<view->__tabCount; i++) { + WDEBUG("subView %d", i); + if(view->__subView[i] && view->__subViewLoaded[i] == false) { + view->setPageContent(i, view->__subView[i]); + view->__subViewLoaded[i] = true; + } + view->__subView[i]->onTabScrollStart(); + } + + return; +} + +bool CtEditTabView::__checkViewExist(Elm_Object_Item *tabItem) +{ + bool result = false; + int i = 0; + for(i=0;i<__tabCount;i++) { + if(__tabItem[i] == tabItem) { + if(__subView[i]) { + result = true; + break; + } + } + } + + return result; +} + + +void CtEditTabView::__getTabViewTitle(contacts_record_h recordContact, char *buf, int bufLen) +{ + int addressbookId = -1; + int err = CONTACTS_ERROR_NONE; + char *addressbookName = NULL; + contacts_record_h recordAddressbook = NULL; + + buf[0] = '\0'; + + err = contacts_record_get_int(recordContact, _contacts_contact.address_book_id, &addressbookId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + + err = contacts_db_get_record(_contacts_address_book._uri, addressbookId, &recordAddressbook); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_record() Failed(%d)", err); + + ctCommonGetProviderNameByAddressbookId(recordAddressbook, addressbookId, &addressbookName, NULL); + WDEBUG("addressbookName %s ", addressbookName); + + err = contacts_record_destroy(recordAddressbook, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_destroy() Failed(%d)", err); + + snprintf(buf, bufLen, "%s", addressbookName); + + free(addressbookName); +} + +Eina_Bool CtEditTabView::__createRestViewTimerCb(void* data) +{ + WHIT(); + CtEditTabView* view = (CtEditTabView*)data; + view->__timer = NULL; + + view->__idler = ecore_idler_add([](void* data)->Eina_Bool { + CtEditTabView* view = (CtEditTabView*)data; + + for( int i = 0; i<view->__tabCount; i++) { + WDEBUG("subView %d", i); + if(view->__subView[i] && view->__subViewLoaded[i] == false) { + view->setPageContent(i, view->__subView[i]); + view->__subView[i]->createEditSubViewContent(); + view->__subViewLoaded[i] = true; + } + } + view->__idler = NULL; + + return ECORE_CALLBACK_CANCEL; + }, view ); + + return ECORE_CALLBACK_CANCEL; +} + diff --git a/lib-contact/ct-detail/src/CtInputData.cpp b/lib-contact/ct-detail/src/CtInputData.cpp new file mode 100644 index 0000000..0cc73cb --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputData.cpp @@ -0,0 +1,2792 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <vector> +#include <app_preference.h> + +#include "ContactsDebug.h" +#include "CtInputData.h" +#include "CtCommon.h" +#include "CtString.h" + +CtInputData::CtInputData(contacts_record_h contactRecord) +{ + WHIT(); + __contactRecord = contactRecord; + __contactId = 0; + __baseAddressbookId = 0; + __baseAddressbookName = NULL; + __userName = NULL; + __personId = 0; + __favorite = false; + __init(); +} + +CtInputData::CtInputData(int personId, const char *number, const char *email, const char *url) +{ + WHIT(); + __contactRecord = NULL; + __contactId = 0; + __baseAddressbookId = 0; + __baseAddressbookName = NULL; + __userName = NULL; + __contactRecord = __getInitContact(personId, number, email, url); + __personId = 0; + __favorite = false; + __init(); +} + +CtInputData::CtInputData(const char *name, const char *number, const char *email, const char *url) +{ + WHIT(); + __contactRecord = NULL; + __contactId = 0; + __baseAddressbookId = 0; + __baseAddressbookName = NULL; + __userName = NULL; + __contactRecord = NULL; + __personId = 0; + __favorite = false; + __init(); + + if (name) { + setFullName(name); + } + if (number) { + addNumber(number); + } + if (email) { + addEmail(email); + } + if (url) { + addWebsite(url); + } +} + +CtInputData::CtInputData() +{ + WHIT(); + __init(); +} + +CtInputData::~CtInputData() +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + + free(__baseAddressbookName); + free(__userName); + err = contacts_db_remove_changed_cb(_contacts_contact._uri, __onPersonChanged, this); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_remove_changed_cb() Failed(%d)", err); + + err = contacts_record_destroy(__contactRecord, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_destroy() Failed(%d)", err); +} + +void CtInputData::__init() +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; +// contacts_record_h addressbookRecord; + __currentVersion = 0; + __listener = NULL; + __inputAddressbook = false; + __favorite = false; + + if (__contactRecord == NULL) { + if(__contactId > 0) { + WDEBUG("get contact %d", __contactId); +// contacts_record_h personRecord = NULL; + int err = CONTACTS_ERROR_NONE; + err = contacts_db_get_record(_contacts_contact._uri, __contactId, &__contactRecord); + WPRET_M(CONTACTS_ERROR_NONE != err, "contacts_db_get_record() Failed(%d)", err); + + } + else { + WDEBUG("create contact"); + err = contacts_record_create(_contacts_contact._uri, &__contactRecord); + WPRET_M(CONTACTS_ERROR_NONE != err, "contacts_record_create() Failed(%d))", err); + + __baseAddressbookId = __getBaseAddressbookId(); + } + } else { + err = contacts_record_get_int(__contactRecord, _contacts_contact.id, &__contactId); + WPRET_M(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + WDEBUG("get contact id %d", __contactId); + if(__contactId > 0) { + err = contacts_record_get_int(__contactRecord, _contacts_contact.address_book_id, &(__baseAddressbookId)); + WPRET_M(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + } + else { + __baseAddressbookId = __getBaseAddressbookId(); + } + + err = contacts_record_get_int(__contactRecord, _contacts_contact.person_id, &__personId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + + err = contacts_record_get_bool(__contactRecord, _contacts_contact.is_favorite, &__favorite); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str is_favorite %d", err); + } + + err = contacts_db_get_current_version(&__currentVersion); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_current_version() Failed(%d)", err); + + err = contacts_db_add_changed_cb(_contacts_contact._uri, __onPersonChanged, this); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_add_changed_cb() Failed(%d)", err); + + setAddressbookInfo(__baseAddressbookId); +} + +void CtInputData::__onPersonChanged(const char *viewUri, void *userData) +{ + WHIT(); + WPRET_M(NULL == userData, "userData is NULL"); + CtInputData* data = (CtInputData*)userData; + + WPRET_M(0 == data->__contactId, "no need to update"); + + int err = CONTACTS_ERROR_NONE; + int version = 0; + bool matched = false; + contacts_list_h chagnedList = NULL; + contacts_record_h changedRecord = NULL; + + err = contacts_db_get_changes_by_version(_contacts_contact_updated_info._uri, data->__baseAddressbookId, data->__currentVersion, &chagnedList, &version); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_changes_by_version() Failed(%d)", err); + + while (CONTACTS_ERROR_NONE == contacts_list_get_current_record_p(chagnedList, &changedRecord)) { + int changedId = 0; + err = contacts_record_get_int(changedRecord, _contacts_contact_updated_info.contact_id, &changedId); + if(data->__contactId == changedId) { + WDEBUG("update matched"); + matched = true; + break; + } + contacts_list_next(chagnedList); + } + + err = contacts_list_destroy(chagnedList, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_destroy(out_change_list) Failed(%d)", err); + + if(version > 0) + data->__currentVersion = version; + + if(matched && data->__listener) + data->__listener->onDbChanged(viewUri); +} + +bool CtInputData::checkChangedTypeIsDeleted() +{ + WENTER(); + contacts_list_h list = NULL; + int contactId = 0; + int currentVersion = 0; + + int type = -1; + int err = CONTACTS_ERROR_NONE; + contacts_record_h updatedRecord = NULL; + + err = contacts_record_get_int(__contactRecord, _contacts_contact.address_book_id, &__baseAddressbookId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + + err = contacts_db_get_changes_by_version(_contacts_contact_updated_info._uri, __baseAddressbookId, __currentVersion, &list, ¤tVersion); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_changes_by_version() Failed(%d)", err); + + while (CONTACTS_ERROR_NONE == contacts_list_get_current_record_p(list, &updatedRecord)) { + err = contacts_record_get_int(updatedRecord, _contacts_contact_updated_info.contact_id, &contactId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_next() Failed(%d)", err); + if (CONTACTS_ERROR_NONE != err) { + err = contacts_list_next(list); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_next() Failed(%d)", err); + continue; + } + + if (contactId == __contactId) { + err = contacts_record_get_int(updatedRecord, _contacts_contact_updated_info.type, &type); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + + break; + } + contacts_list_next(list); + } + err = contacts_list_destroy(list, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_destrot() Failed(%d)", err); + + if (currentVersion) { + __currentVersion = currentVersion; + } + + if (CONTACTS_CHANGE_DELETED == type) { + return true; + } + else { + return false; + } +} + +void CtInputData::setPreferenceCreateFirst(bool isFirst) +{ + WHIT(); + + preference_set_boolean(CT_KEY_CONTACT_CREATE_FIRST, isFirst); +} + +void CtInputData::__setContactInfo(int personId) +{ + WHIT(); + + WDEBUG("personID %d", personId); + + int err = CONTACTS_ERROR_NONE; + + if(personId > 0) { + __contactRecord = __getWritableContact(personId); + err = contacts_record_get_int(__contactRecord, _contacts_contact.id, &__contactId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + + err = contacts_record_get_int(__contactRecord, _contacts_contact.person_id, &__personId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + + err = contacts_record_get_bool(__contactRecord, _contacts_contact.is_favorite, &__favorite); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str is_favorite %d", err); + } + + if (__contactRecord == NULL) { + WDEBUG("create contact"); + err = contacts_record_create(_contacts_contact._uri, &__contactRecord); + WPRET_M(CONTACTS_ERROR_NONE != err, "contacts_record_create() Failed(%d))", err); + + __baseAddressbookId = __getBaseAddressbookId(); + } +} + +contacts_record_h CtInputData::__getInitContact(int personId, const char *number, const char *email, const char *url) +{ + WHIT(); + + __setContactInfo(personId); + setAddressbookInfo(__baseAddressbookId); + + if (number) { + addNumber(number); + } + if (email) { + addEmail(email); + } + if (url) { + addWebsite(url); + } + + return __contactRecord; +} +/* +bool CtInputData::getMFC() +{ + int err = CONTACTS_ERROR_NONE; + contacts_list_h personUsageList = NULL; + contacts_query_h query= NULL; + contacts_filter_h filter = NULL; + + + err = contacts_query_create(_contacts_person_usage._uri, &query); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_create() Failed(%d)", err); + err = contacts_filter_create(_contacts_person_usage._uri, &filter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + do { + if (CONTACTS_ERROR_NONE != (err = contacts_filter_add_int(filter, _contacts_person_usage.times_used, CONTACTS_MATCH_GREATER_THAN_OR_EQUAL, 1))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_filter_add_int(filter, _contacts_person_usage.usage_type, CONTACTS_MATCH_EQUAL, CONTACTS_USAGE_STAT_TYPE_OUTGOING_CALL))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_filter_add_bool(filter, _contacts_person_usage.is_favorite, false))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_query_set_filter(query, filter))) break; + } while (0); + + err = contacts_query_set_sort(query, _contacts_person_usage.times_used, false); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_sort() Failed(%d)", err); + + err = contacts_db_get_records_with_query(query, 0, 5, &personUsageList); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_get_list() Failed(%d)", err); + + contacts_filter_destroy(filter); + contacts_query_destroy(query); + int mfcIndex = 0; + contacts_record_h recordPerson = NULL; + while (CONTACTS_ERROR_NONE == contacts_list_get_current_record_p(personUsageList, &recordPerson)) { + if(mfcIndex >5) + break; + int personId = 0; + err = contacts_record_get_int(recordPerson, _contacts_person.id, &personId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + if(__personId == personId){ + contacts_list_destroy(personUsageList, true); + return true; + } + mfcIndex++; + contacts_list_next(personUsageList); + } + contacts_list_destroy(personUsageList, true); + return false; +} +*/ +contacts_record_h CtInputData::__getWritableContact(int personId) +{ + WDEBUG("personId %d", personId); + + int err = CONTACTS_ERROR_NONE; + contacts_record_h contactRecord = NULL; + + if(personId > 0) { + Eina_List *contactList = ctCommonGetWritableContactList(personId); + void *data = NULL; + Eina_List *cursor = NULL; + EINA_LIST_FOREACH(contactList, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + err = contacts_record_clone(record, &contactRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_clone() Failed(%d)", err); + break; + } + + ctCommonDestroyRecordList(contactList); + } + else { + err = contacts_record_create(_contacts_contact._uri, &contactRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_create() Failed(%d)", err); + } + + return contactRecord; +} + + +void CtInputData::setAddressbookInfo(int addressbookId) +{ + WDEBUG("addressbookId %d", addressbookId); + + __baseAddressbookId = addressbookId; + + contacts_list_h list = NULL; + contacts_record_h record_address_book = NULL; + int err = CONTACTS_ERROR_NONE; + + err = contacts_db_get_all_records(_contacts_address_book._uri, 0, 0, &list); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_all_records() Failed(%d)", err); + while (CONTACTS_ERROR_NONE == contacts_list_get_current_record_p(list, &record_address_book)) { + int addressbook_id; + char *addressbook_name = NULL; + char *addressbook_username = NULL; + + err = contacts_record_get_int(record_address_book, _contacts_address_book.id, &addressbook_id); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + ctCommonGetProviderNameByAddressbookId(record_address_book, addressbook_id, &addressbook_name, &addressbook_username); + + if(addressbook_id == __baseAddressbookId) { + FREEandSTRDUP(__baseAddressbookName, addressbook_name); + FREEandSTRDUP(__userName, addressbook_username); + WDEBUG("addressbook_id %d is %s", addressbook_id, addressbook_name); + SAFE_FREE(addressbook_name); + SAFE_FREE(addressbook_username); + err = contacts_list_destroy(list, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_destroy() Failed(%d)", err); + return; + } + SAFE_FREE(addressbook_name); + SAFE_FREE(addressbook_username); + contacts_list_next(list); + } + err = contacts_list_destroy(list, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_destroy() Failed(%d)", err); + __baseAddressbookName = NULL; + __userName = NULL; + return; +} + +bool CtInputData::__hasSuffix(const char *src) +{ + int index = strlen(src) - 1; + bool delim = false; + for (int i = index; i >= 0; i--) { + if (src[i] == ' ' || src[i] == '.') { + delim = true; + } else if (src[i] == ',') { + return true; + } else if (delim) { + return false; + } + } + return false; +} + +int CtInputData::separateFullName(contacts_record_h nameRecord, const char *full_name) +{ + WHIT(); + WPRET_VM(NULL == nameRecord, -1, "nameRecord is NULL"); + WPRET_VM(NULL == full_name, -1, "full_name is NULL"); + int err = CONTACTS_ERROR_NONE; + char *tmp_name = NULL; + char *tmp_str = NULL; + char tmp[CT_TEXT_MAX_LEN] = {0}; + std::string tmp_first; + snprintf(tmp, sizeof(tmp), "%s", full_name); + std::vector<char*> fields; + + tmp_str = strtok_r(tmp, ",. ", &tmp_name); + while(tmp_str && *tmp_str) { + fields.push_back(tmp_str); + tmp_str = strtok_r(NULL, ",. ", &tmp_name); + } + + if ((fields.size() > 2) && __hasSuffix(full_name)) { + err = contacts_record_set_str(nameRecord, _contacts_name.suffix, fields.back()); + fields.pop_back(); + } else { + err = contacts_record_set_str(nameRecord, _contacts_name.suffix, NULL); + } + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + if (fields.size() > 1) { + err = contacts_record_set_str(nameRecord, _contacts_name.last, fields.back()); + fields.pop_back(); + } else { + err = contacts_record_set_str(nameRecord, _contacts_name.last, NULL); + } + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + if (fields.size() > 1) { + err = contacts_record_set_str(nameRecord, _contacts_name.addition, fields.back()); + fields.pop_back(); + } else { + err = contacts_record_set_str(nameRecord, _contacts_name.addition, NULL); + } + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + if (fields.size() < 1) { + err = contacts_record_set_str(nameRecord, _contacts_name.prefix, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.first, NULL); + } else { + for (auto &str : fields) { + tmp_first.append(str); + tmp_first.append(" "); + } + tmp_first.pop_back(); + err = contacts_record_set_str(nameRecord, _contacts_name.first, tmp_first.c_str()); + } + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + return err; +} + +int CtInputData::separatePhoneticFullName(contacts_record_h nameRecord, const char *full_name) +{ + WHIT(); + WPRET_VM(NULL == nameRecord, -1, "nameRecord is NULL"); + int err = CONTACTS_ERROR_NONE; + char *temp_name = NULL; + char *temp_first = NULL; + char *temp_middle = NULL; + char *temp_last = NULL; + char tmp[CT_TEXT_MAX_LEN] = {0}; + + if (NULL == full_name) { + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_first, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_middle, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_last, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + return err; + } + + snprintf(tmp, sizeof(tmp), "%s", full_name); + + temp_first = strtok_r(tmp, " ", &temp_name); + if (temp_first) { + temp_middle = strtok_r(NULL, " ", &temp_name); + if (temp_middle) { + temp_last = temp_name; + } + } + + WDEBUG("full_name %s, first %s, middle %s, last %s", full_name, temp_first, temp_middle, temp_last); + + if(temp_first && *temp_first) { + if(temp_last && *temp_last) { + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_first, temp_first); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_middle, temp_middle); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_last, temp_last); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + else { + if(temp_middle && *temp_middle) { + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_first, temp_first); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_middle, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_last, temp_middle); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + else { + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_first, temp_first); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_middle, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_last, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + } + }else { + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_first, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_middle, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_last, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +int CtInputData::setPrefixName(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.name, 0, &nameRecord); + + if (nameRecord == NULL) { + err = contacts_record_create(_contacts_name._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_contact.name, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = contacts_record_set_str(nameRecord, _contacts_name.prefix, text); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + return err; +} + +int CtInputData::setSuffixName(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.name, 0, &nameRecord); + + if (nameRecord == NULL) { + err = contacts_record_create(_contacts_name._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_contact.name, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = contacts_record_set_str(nameRecord, _contacts_name.suffix, text); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + return err; +} + +int CtInputData::setPhoneticFullName(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.name, 0, &nameRecord); + + if(nameRecord == NULL) { + err = contacts_record_create(_contacts_name._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_contact.name, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = separatePhoneticFullName(nameRecord, text); + return err; +} + +int CtInputData::setPhoneticFirstName(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.name, 0, &nameRecord); + + if (nameRecord == NULL) { + err = contacts_record_create(_contacts_name._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_contact.name, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_first, text); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + return err; +} + +int CtInputData::setPhoneticMiddleName(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.name, 0, &nameRecord); + + if (nameRecord == NULL) { + err = contacts_record_create(_contacts_name._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_contact.name, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_middle, text); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + return err; +} +int CtInputData::setPhoneticLastName(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.name, 0, &nameRecord); + + if (nameRecord == NULL) { + err = contacts_record_create(_contacts_name._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_contact.name, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_last, text); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + return err; +} + +int CtInputData::setNickname(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.nickname, 0, &nameRecord); + + if (nameRecord == NULL) { + err = contacts_record_create(_contacts_nickname._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_contact.nickname, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = contacts_record_set_str(nameRecord, _contacts_nickname.name, text); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + return err; +} + +int CtInputData::setCompany(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.company, 0, &nameRecord); + + if (nameRecord == NULL) { + err = contacts_record_create(_contacts_company._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_contact.company, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = contacts_record_set_str(nameRecord, _contacts_company.name, text); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + return err; +} + +int CtInputData::setJobTitle(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.company, 0, &nameRecord); + + if (nameRecord == NULL) { + err = contacts_record_create(_contacts_company._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_contact.company, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = contacts_record_set_str(nameRecord, _contacts_company.job_title, text); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + return err; +} + +int CtInputData::setFullName(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.name, 0, &nameRecord); + //WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + if(nameRecord == NULL) { + err = contacts_record_create(_contacts_name._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_contact.name, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = separateFullName(nameRecord, text); + return err; +} + +int CtInputData::setFirstName(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.name, 0, &nameRecord); + + if (nameRecord == NULL) { + err = contacts_record_create(_contacts_name._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_contact.name, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = contacts_record_set_str(nameRecord, _contacts_name.first, text); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + return err; +} + +int CtInputData::setMiddleName(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.name, 0, &nameRecord); + + if (nameRecord == NULL) { + err = contacts_record_create(_contacts_name._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_contact.name, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = contacts_record_set_str(nameRecord, _contacts_name.addition, text); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + return err; +} + +int CtInputData::setLastName(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.name, 0, &nameRecord); + + if (nameRecord == NULL) { + err = contacts_record_create(_contacts_name._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_contact.name, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = contacts_record_set_str(nameRecord, _contacts_name.last, text); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + return err; +} + +const char* CtInputData::getPrefixName() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + char *prefix = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.name, 0, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_name.prefix, &prefix); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + ctCommonRemoveNewline(prefix); + + return prefix; +} + +const char* CtInputData::getSuffixName() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + char *suffix = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.name, 0, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_name.suffix, &suffix); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + ctCommonRemoveNewline(suffix); + + return suffix; +} + +const char* CtInputData::getPhoneticFirstName() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + char *phoneticName = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.name, 0, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_name.phonetic_first, &phoneticName); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + ctCommonRemoveNewline(phoneticName); + + return phoneticName; +} + +const char* CtInputData::getPhoneticMiddleName() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + char *phoneticName = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.name, 0, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_name.phonetic_middle, &phoneticName); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + ctCommonRemoveNewline(phoneticName); + + return phoneticName; +} + +const char* CtInputData::getPhoneticLastName() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + char *phoneticName = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.name, 0, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_name.phonetic_last, &phoneticName); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + ctCommonRemoveNewline(phoneticName); + + return phoneticName; +} + +const char* CtInputData::getNickname() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + char *nickname = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.nickname, 0, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_nickname.name, &nickname); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + return nickname; +} + +const char* CtInputData::getCompany() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + char *company = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.company, 0, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_company.name, &company); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + return company; +} + +const char* CtInputData::getJobTitle() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + char *jobTitle = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.company, 0, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_company.job_title, &jobTitle); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + return jobTitle; +} + +/** + * @return must be freed by you + */ +void CtInputData::getFullName(std::string &Name) +{ + int strLen = 0; + const char *firstName = NULL; + const char *middleName = NULL; + const char *lastName = NULL; + const char *prefixName = NULL; + const char *suffixName = NULL; + char *fullName = NULL; + + firstName = getFirstName(); + middleName = getMiddleName(); + lastName = getLastName(); + prefixName = getPrefixName(); + suffixName = getSuffixName(); + + strLen = SAFE_STRLEN(prefixName) + SAFE_STRLEN(firstName) + SAFE_STRLEN(middleName) + SAFE_STRLEN(lastName) + SAFE_STRLEN(suffixName) + 6; + WDEBUG("strLen = %d", strLen); + + fullName = (char*)malloc(sizeof(char)*strLen); + WPRET_M(NULL == fullName, "failed to malloc"); + memset(fullName, 0, sizeof(char)*strLen); + + if (prefixName && *prefixName) { + strncat(fullName, prefixName, SAFE_STRLEN(prefixName)); + } + if (firstName && *firstName) { + if (fullName && *fullName) { + strncat(fullName, " ", 1); + } + strncat(fullName, firstName, SAFE_STRLEN(firstName)); + } + if (middleName && *middleName) { + if (fullName && *fullName) { + strncat(fullName, " ", 1); + } + strncat(fullName, middleName, SAFE_STRLEN(middleName)); + } + if (lastName && *lastName) { + if (fullName && *fullName) { + strncat(fullName, " ", 1); + } + strncat(fullName, lastName, SAFE_STRLEN(lastName)); + } + if (suffixName && *suffixName) { + if (fullName && *fullName) { + strncat(fullName, ", ", 2); + } + strncat(fullName, suffixName, SAFE_STRLEN(suffixName)); + } + + Name = fullName; + free(fullName); +} + +const char* CtInputData::getFirstName() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + char *firstName = NULL; + const char *result = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.name, 0, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_name.first, &firstName); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + ctCommonRemoveNewline(firstName); + + result = firstName; + return result; +} + +const char* CtInputData::getMiddleName() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + char *middleName = NULL; + const char *result = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.name, 0, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_name.addition, &middleName); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + ctCommonRemoveNewline(middleName); + + result = middleName; + return result; +} + +const char* CtInputData::getLastName() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + char *lastName = NULL; + const char *result = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.name, 0, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_name.last, &lastName); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + ctCommonRemoveNewline(lastName); + + result = lastName; + return result; +} + +int CtInputData::removeImage(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + + err = contacts_record_remove_child_record(__contactRecord, _contacts_contact.image, record); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_remove_child_record() Failed(%d)", err); + + err = contacts_record_destroy(record, true); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_destroy() Failed(%d)", err); + + return err; +} + +const char* CtInputData::getImagePath() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h imageRecord = NULL; + char *image = NULL; + const char *result = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.image, 0, &imageRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(imageRecord, _contacts_image.path, &image); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + result = image; + return result; +} + +contacts_record_h CtInputData::getImageRecord() +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.image, 0, &record); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_child_record_at_p() Failed(%d)", err); + if (NULL != record) { + return record; + } + + return record; +} + +int CtInputData::setImage(contacts_record_h record, char *image, int type) +{ + WDEBUG("image %s", image); + int err = CONTACTS_ERROR_NONE; + + if(image && *image) { + if(record == NULL) { + err = contacts_record_create(_contacts_image._uri, &record); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_contact.image, record); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_add_child_record() Failed(%d)", err); + } + err = contacts_record_set_int(record, _contacts_image.type, type); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_int() Failed(%d)", err); + err = contacts_record_set_str(record, _contacts_image.path, image); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +Eina_List* CtInputData::getNumberList() +{ + WHIT(); + return __getChildDataList(__contactRecord, _contacts_contact.number); +} + +contacts_record_h CtInputData::addNumber(const char *number) +{ + WDEBUG("number %s", number); + + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + + err = contacts_record_create(_contacts_number._uri, &record); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_create() Failed(%d)", err); + + setNumberNumber(record, number); + setNumberType(record, getNextNumberType(), NULL); + + err = contacts_record_add_child_record(__contactRecord, _contacts_contact.number, record); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(record, true); + return NULL; + } + return record; +} + +int CtInputData::setNumberNumber(contacts_record_h record, const char *number) +{ + WDEBUG("number %s", number); + int err = CONTACTS_ERROR_NONE; + + if(number) { + err = contacts_record_set_str(record, _contacts_number.number, number); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +int CtInputData::setNumberType(contacts_record_h record, int type, const char *customStr) +{ + WDEBUG("type %d", type); + WDEBUG("customStr %s", customStr); + int err = CONTACTS_ERROR_NONE; + + if (type >= 0) { + err = contacts_record_set_int(record, _contacts_number.type, type); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + if (customStr) { + err = contacts_record_set_str(record, _contacts_number.label, customStr); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + return err; +} + +int CtInputData::removeNumber(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + + err = contacts_record_remove_child_record(__contactRecord, _contacts_contact.number, record); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_remove_child_record() Failed(%d)", err); + + return err; +} + +const char* CtInputData::getNumberNumber(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + char *number = NULL; + const char *result = NULL; + + err = contacts_record_get_str_p(record, _contacts_number.number, &number); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_str_p() Failed(%d)", err); + + result = number; + return result; +} + +contacts_record_h CtInputData::getEmergencyNumber() +{ + WHIT(); + /* + int err = CONTACTS_ERROR_NONE; + contacts_record_h numberRecord = NULL; + contacts_record_h emergencyRecord = NULL; + contacts_query_h query = NULL; + contacts_filter_h filter = NULL; + contacts_list_h emergencyList = NULL; + int personId = 0; + int numberId = 0; + int index = 0; + + err = contacts_record_get_int(__contactRecord, _contacts_contact.person_id, &personId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + + err = contacts_filter_create(_contacts_emergency._uri, &filter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + + do { + if (CONTACTS_ERROR_NONE != (err = contacts_filter_add_int(filter, _contacts_emergency.person_id, CONTACTS_MATCH_EQUAL, personId))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_query_create(_contacts_emergency._uri, &query))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_query_set_filter(query, filter))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_db_get_records_with_query(query, 0, 0, &emergencyList))) break; + } while (0); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_get_list() Failed(%d)", err); + + contacts_filter_destroy(filter); + contacts_query_destroy(query); + if (emergencyList && CONTACTS_ERROR_NONE == contacts_list_get_current_record_p(emergencyList, &emergencyRecord)) { + err = contacts_record_get_int(emergencyRecord,_contacts_emergency.number_data_id, &numberId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + } + contacts_list_destroy(emergencyList, true); + + while (CONTACTS_ERROR_NONE == contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.number, index++, &numberRecord)) { + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_str_p() Failed(%d)", err); + break; + } + int id = 0; + err = contacts_record_get_int(numberRecord, _contacts_number.id, &id); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + if (id == numberId) { + break; + } + } + + return numberRecord; + */ + return NULL; +} + +contacts_record_h CtInputData::getDefaultNumber() +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.number, 0, &record); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_child_record_at_p() Failed(%d)", err); + } + return record; +} + +int CtInputData::getNumberType(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + int type = 0; + + err = contacts_record_get_int(record, _contacts_number.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +Eina_List* CtInputData::getEmailList() +{ + WHIT(); + return __getChildDataList(__contactRecord, _contacts_contact.email); +} + +const char* CtInputData::getDataTypeCustom(contacts_record_h record, int property_id) +{ + char* typeStr = NULL; + const char* result = NULL; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_str_p(record, property_id, &typeStr); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_int() Failed(%d)", err); + + result = typeStr; + return result; +} + +void CtInputData::getNumberTypeStr(contacts_record_h record, int numberType, std::string &typeString) +{ + WHIT(); + const char* typeStr = NULL; + char buf[128] = {0,}; + + if (numberType & CONTACTS_NUMBER_TYPE_CUSTOM) { + typeStr = getDataTypeCustom(record, _contacts_number.label); + + } + else if (numberType & CONTACTS_NUMBER_TYPE_CELL) { + if (numberType & CONTACTS_NUMBER_TYPE_HOME) { + snprintf(buf, sizeof(buf),"%s 2", V_("IDS_PB_OPT_HOME_ABB")); + typeStr = buf; + } + else if (numberType & CONTACTS_NUMBER_TYPE_WORK) { + snprintf(buf, sizeof(buf),"%s 2", V_("IDS_PB_OPT_WORK")); + typeStr = buf; + } + else { + typeStr = V_("IDS_PB_OPT_MOBILE"); + } + } + else if (numberType & CONTACTS_NUMBER_TYPE_VOICE) { + if (numberType & CONTACTS_NUMBER_TYPE_HOME) { + typeStr = V_("IDS_PB_OPT_HOME_ABB"); + } + else if (numberType & CONTACTS_NUMBER_TYPE_WORK) { + typeStr = V_("IDS_PB_OPT_WORK"); + } + else { + typeStr = V_("IDS_PB_OPT_OTHER"); + } + } + else if (numberType & CONTACTS_NUMBER_TYPE_FAX) { + if (numberType & CONTACTS_NUMBER_TYPE_HOME) { + typeStr = V_("IDS_PB_OPT_FAX_HHOME_ABB"); + } + else if (numberType & CONTACTS_NUMBER_TYPE_WORK) { + typeStr = V_("IDS_PB_OPT_FAX_HWORK_ABB"); + } + else { + typeStr = V_("IDS_PB_BODY_FAX"); + } + } + else if (numberType & CONTACTS_NUMBER_TYPE_MAIN) { + typeStr = V_("IDS_PB_OPT_MAIN"); + } + else if (numberType & CONTACTS_NUMBER_TYPE_PAGER) { + typeStr = V_("IDS_PB_OPT_PAGER"); + } + else { + if (numberType & CONTACTS_NUMBER_TYPE_HOME) { + typeStr = V_("IDS_PB_OPT_HOME_ABB"); + } + else if (numberType & CONTACTS_NUMBER_TYPE_WORK) { + typeStr = V_("IDS_PB_OPT_WORK"); + } + else { + typeStr = V_("IDS_PB_OPT_OTHER"); + } + } + + char *result = elm_entry_utf8_to_markup(typeStr); + if (result) { + typeString = result; + free(result); + } +} + +int CtInputData::getNumberRetType(int indexType) +{ + int retType; + + switch (indexType) { + case CTTEXT_TYPE_MOBILE: + retType = CONTACTS_NUMBER_TYPE_CELL; + break; + case CTTEXT_TYPE_HOME: + retType = CONTACTS_NUMBER_TYPE_VOICE | CONTACTS_NUMBER_TYPE_HOME; + break; + case CTTEXT_TYPE_WORK: + retType = CONTACTS_NUMBER_TYPE_VOICE | CONTACTS_NUMBER_TYPE_WORK; + break; + case CTTEXT_TYPE_FAX_HOME: + retType = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME; + break; + case CTTEXT_TYPE_FAX_WORK: + retType = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK; + break; + case CTTEXT_TYPE_PAGER: + retType = CONTACTS_NUMBER_TYPE_PAGER; + break; + case CTTEXT_TYPE_CUSTOM: + retType = CONTACTS_NUMBER_TYPE_CUSTOM; + break; + case CTTEXT_TYPE_MAIN: + retType = CONTACTS_NUMBER_TYPE_MAIN; + break; + case CTTEXT_TYPE_OTHER: + default: + retType = CONTACTS_NUMBER_TYPE_OTHER; + break; + } + + return retType; +} +int CtInputData::getNumberIndexType(int numberType) +{ + if (numberType & CONTACTS_NUMBER_TYPE_CUSTOM) { + return (CTTEXT_TYPE_OTHER); + } + else if (numberType & CONTACTS_NUMBER_TYPE_CELL) { + return (CTTEXT_TYPE_MOBILE); + } + else if (numberType & CONTACTS_NUMBER_TYPE_VOICE) { + if (numberType & CONTACTS_NUMBER_TYPE_HOME) { + return (CTTEXT_TYPE_HOME); + } + else if (numberType & CONTACTS_NUMBER_TYPE_WORK) { + return (CTTEXT_TYPE_WORK); + } + } + else if (numberType & CONTACTS_NUMBER_TYPE_FAX) { + if (numberType & CONTACTS_NUMBER_TYPE_HOME) + return (CTTEXT_TYPE_FAX_HOME); + else if (numberType & CONTACTS_NUMBER_TYPE_WORK) + return (CTTEXT_TYPE_FAX_WORK); + } + else if (numberType & CONTACTS_NUMBER_TYPE_PAGER) + return (CTTEXT_TYPE_PAGER); + else if (numberType & CONTACTS_NUMBER_TYPE_MAIN) + return (CTTEXT_TYPE_MAIN); + else { + if (numberType == CONTACTS_NUMBER_TYPE_HOME) + return (CTTEXT_TYPE_HOME); + else if (numberType == CONTACTS_NUMBER_TYPE_WORK) + return (CTTEXT_TYPE_WORK); + else + return (CTTEXT_TYPE_OTHER); + } + + return CTTEXT_TYPE_MOBILE; +} + +int CtInputData::getNextNumberType() +{ + int i; + int numberType; + int indexType; + int index = 0; + int err = CONTACTS_ERROR_NONE; + int used[CTTEXT_TYPE_OTHER+1] = {0}; + contacts_record_h record = NULL; + + while (CONTACTS_ERROR_NONE == contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.number, index++, &record)) { + err = contacts_record_get_int(record, _contacts_number.type, &numberType); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_int() Failed(%d)", err); + continue; + } + indexType = getNumberIndexType(numberType); + used[indexType] = 1; + } + + for (i=CTTEXT_TYPE_MOBILE;i<CTTEXT_TYPE_OTHER;i++) { + if (0 == used[i]) { + + return getNumberRetType(i); + } + } + + return CONTACTS_NUMBER_TYPE_OTHER; + +} + +contacts_record_h CtInputData::addEmail(const char *email) +{ + WDEBUG("email %s", email); + + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + + err = contacts_record_create(_contacts_email._uri, &record); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_create() Failed(%d)", err); + + setEmailEmail(record, email); + setEmailType(record, getNextEmailType(), NULL); + + err = contacts_record_add_child_record(__contactRecord, _contacts_contact.email, record); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(record, true); + return NULL; + } + return record; +} + +int CtInputData::setEmailEmail(contacts_record_h record, const char *email) +{ + WDEBUG("email %s", email); + int err = CONTACTS_ERROR_NONE; + + if (email) { + err = contacts_record_set_str(record, _contacts_email.email, email); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +int CtInputData::setEmailType(contacts_record_h record, int type, char *customStr) +{ + WDEBUG("type %d", type); + int err = CONTACTS_ERROR_NONE; + + if (type >= 0) { + err = contacts_record_set_int(record, _contacts_email.type, type); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + if (customStr) { + err = contacts_record_set_str(record, _contacts_email.label, customStr); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +const char* CtInputData::getEmailEmail(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + char *email = NULL; + const char *result = NULL; + + err = contacts_record_get_str_p(record, _contacts_email.email, &email); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_str_p() Failed(%d)", err); + + result = email; + return result; +} + +contacts_record_h CtInputData::getDefaultEmail() +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.email, 0, &record); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_child_record_at_p() Failed(%d)", err); + } + return record; +} + +int CtInputData::getEmailType(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + int type = 0; + + err = contacts_record_get_int(record, _contacts_email.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +void CtInputData::getEmailTypeStr(contacts_record_h record, int indexType, std::string &typeString) +{ + WHIT(); + + const char* typeStr = NULL; + + if (indexType & CONTACTS_EMAIL_TYPE_CUSTOM) { + typeStr = getDataTypeCustom(record, _contacts_email.label); + } + else if (indexType & CONTACTS_EMAIL_TYPE_HOME) { + typeStr = V_("IDS_PB_OPT_HOME_ABB"); + } + else if (indexType & CONTACTS_EMAIL_TYPE_WORK) { + typeStr = V_("IDS_PB_OPT_WORK"); + } + else { + typeStr = V_("IDS_PB_OPT_OTHER"); + } + + char *result = elm_entry_utf8_to_markup(typeStr); + if (result) { + typeString = result; + free(result); + } +} + +int CtInputData::getNextEmailType() +{ + int i; + int used = 0; + int emailType; + int index = 0; + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + while (CONTACTS_ERROR_NONE == contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.email, index++, &record)) { + err = contacts_record_get_int(record, _contacts_email.type, &emailType); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_int() Failed(%d)", err); + continue; + } + used |= emailType; + } + + int maxType = CONTACTS_EMAIL_TYPE_WORK; + for (i=1;(1<<i)<=maxType;i++) { + if (!(used & (1<<i))) { + return 1<<i; + } + } + + return CONTACTS_EMAIL_TYPE_OTHER; + +} + +int CtInputData::removeEmail(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + + err = contacts_record_remove_child_record(__contactRecord, _contacts_contact.email, record); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_remove_child_record() Failed(%d)", err); + + return err; +} + +contacts_record_h CtInputData::getNoteRecord() +{ + WHIT(); + contacts_record_h record = NULL; + int err = CONTACTS_ERROR_NONE; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.note, 0, &record); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + return record; +} + +Eina_List* CtInputData::getNoteList() +{ + WHIT(); + return __getChildDataList(__contactRecord, _contacts_contact.note); +} + +contacts_record_h CtInputData::addNote(const char *note) +{ + WDEBUG("note %s", note); + + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + + err = contacts_record_create(_contacts_note._uri, &record); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_create() Failed(%d)", err); + + setNote(record, note); + + err = contacts_record_add_child_record(__contactRecord, _contacts_contact.note, record); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(record, true); + return NULL; + } + return record; +} + +int CtInputData::setNote(contacts_record_h record, const char *note) +{ + WDEBUG("note %s", note); + int err = CONTACTS_ERROR_NONE; + + if (note) { + err = contacts_record_set_str(record, _contacts_note.note, note); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +const char* CtInputData::getNote(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + char *note = NULL; + const char *result = NULL; + + err = contacts_record_get_str_p(record, _contacts_note.note, ¬e); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_str_p() Failed(%d)", err); + + result = note; + return result; +} + +int CtInputData::removeNote(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + + err = contacts_record_remove_child_record(__contactRecord, _contacts_contact.note, record); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_remove_child_record() Failed(%d)", err); + + return err; +} + +Eina_List* CtInputData::getAddressList() +{ + WHIT(); + return __getChildDataList(__contactRecord, _contacts_contact.address); +} + +contacts_record_h CtInputData::addAddress(const char *address) +{ + WDEBUG("address %s", address); + + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + + err = contacts_record_create(_contacts_address._uri, &record); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_create() Failed(%d)", err); + + setAddressAddress(record, address); + setAddressType(record, getNextAddressType(), NULL); + + err = contacts_record_add_child_record(__contactRecord, _contacts_contact.address, record); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(record, true); + return NULL; + } + return record; +} + +int CtInputData::setAddressAddress(contacts_record_h record, const char *address) +{ + WDEBUG("address %s", address); + int ret = CONTACTS_ERROR_NONE; + + if (address) { + do { + if (CONTACTS_ERROR_NONE != (ret = contacts_record_set_str(record, _contacts_address.postbox, NULL))) break; + if (CONTACTS_ERROR_NONE != (ret = contacts_record_set_str(record, _contacts_address.postal_code, NULL))) break; + if (CONTACTS_ERROR_NONE != (ret = contacts_record_set_str(record, _contacts_address.region, NULL))) break; + if (CONTACTS_ERROR_NONE != (ret = contacts_record_set_str(record, _contacts_address.locality, NULL))) break; + if (CONTACTS_ERROR_NONE != (ret = contacts_record_set_str(record, _contacts_address.street, address))) break; + if (CONTACTS_ERROR_NONE != (ret = contacts_record_set_str(record, _contacts_address.country, NULL))) break; + if (CONTACTS_ERROR_NONE != (ret = contacts_record_set_str(record, _contacts_address.extended, NULL))) break; + } while (0); + WPRET_VM(CONTACTS_ERROR_NONE != ret, ret, "contacts_record_set_str() Failed(%d)", ret); + } + + return ret; +} + +int CtInputData::setAddressType(contacts_record_h record, int type, const char *customStr) +{ + WDEBUG("type %d", type); + int err = CONTACTS_ERROR_NONE; + + if (type >= 0) { + err = contacts_record_set_int(record, _contacts_address.type, type); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + if (customStr) { + err = contacts_record_set_str(record, _contacts_address.label, customStr); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +int CtInputData::getAddressAddress(contacts_record_h record, char *buf, int length) +{ + WHIT(); + return __getFullAddress(record, buf, length); +} + +void CtInputData::__appendStringWithLinebreak(const char *src, char *dest, int length) +{ + char temp[CT_TEXT_MAX_LEN]; + if (src && '\0' != src[0]) { + if ('\0' == dest[0]) + snprintf(dest, length, "%s", src); + else { + snprintf(temp, sizeof(temp), "%s\n%s", src, dest); + snprintf(dest, length, "%s", temp); + } + } +} + +int CtInputData::__getFullAddress(contacts_record_h addresssRecord, char *buf, int length) +{ + WHIT(); + + const char *code = NULL; + const char *region = NULL; + const char *locality = NULL; + const char *street = NULL; + const char *extended = NULL; + const char *country = NULL; + const char *pobox = NULL; + int err = CONTACTS_ERROR_NONE; + + do { + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.postal_code , (char**)&code))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.extended , (char**)&extended))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.postbox , (char**)&pobox))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.street , (char**)&street))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.locality , (char**)&locality))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.region , (char**)®ion))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.country ,(char**)&country))) break; + } while (0); + if(CONTACTS_ERROR_NONE != err) + WERROR("contacts_record_get_str_p() Failed(%d)", err); + + __appendStringWithLinebreak(country, buf, length); + __appendStringWithLinebreak(code, buf, length); + __appendStringWithLinebreak(region, buf, length); + __appendStringWithLinebreak(locality, buf, length); + __appendStringWithLinebreak(street, buf, length); + __appendStringWithLinebreak(extended, buf, length); + __appendStringWithLinebreak(pobox, buf, length); + + return 0; +} + +int CtInputData::getAddressType(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + int type = 0; + + err = contacts_record_get_int(record, _contacts_address.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +void CtInputData::getAddressTypeStr(contacts_record_h record, int indexType, std::string &typeString) +{ + WHIT(); + const char* typeStr = NULL; + + if (indexType & CONTACTS_ADDRESS_TYPE_CUSTOM) { + typeStr = getDataTypeCustom(record, _contacts_address.label); + } + else if (indexType & CONTACTS_ADDRESS_TYPE_HOME) { + typeStr = V_("IDS_PB_OPT_HOME_ABB"); + } + else if (indexType & CONTACTS_ADDRESS_TYPE_WORK) { + typeStr = V_("IDS_PB_OPT_WORK"); + } + else { + typeStr = V_("IDS_PB_OPT_OTHER"); + } + + char *result = elm_entry_utf8_to_markup(typeStr); + if (result) { + typeString = result; + free(result); + } +} + +int CtInputData::getNextAddressType() +{ + int i; + int used = 0; + int addressType; + int index = 0; + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + while (CONTACTS_ERROR_NONE == contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.address, index++, &record)) { + err = contacts_record_get_int(record, _contacts_address.type, &addressType); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_int() Failed(%d)", err); + continue; + } + used |= addressType; + } + + int maxType = CONTACTS_ADDRESS_TYPE_WORK; + for (i=1;(1<<i)<=maxType;i++) { + if (!(used & (1<<i))) { + return 1<<i; + } + } + + return CONTACTS_ADDRESS_TYPE_OTHER; + +} + +int CtInputData::removeAddress(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + + err = contacts_record_remove_child_record(__contactRecord, _contacts_contact.address, record); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_remove_child_record() Failed(%d)", err); + + return err; +} + +Eina_List* CtInputData::getMessengerList() +{ + WHIT(); + return __getChildDataList(__contactRecord, _contacts_contact.messenger); +} + +contacts_record_h CtInputData::addMessenger(const char *messenger) +{ + WDEBUG("messenger %s", messenger); + + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + + err = contacts_record_create(_contacts_messenger._uri, &record); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_create() Failed(%d)", err); + + setMessengerMessenger(record, messenger); + setMessengerType(record, getNextMessengerType(), NULL); + + err = contacts_record_add_child_record(__contactRecord, _contacts_contact.messenger, record); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(record, true); + return NULL; + } + return record; +} + +int CtInputData::setMessengerMessenger(contacts_record_h record, const char *messenger) +{ + WDEBUG("messenger %s", messenger); + int err = CONTACTS_ERROR_NONE; + + if (messenger) { + err = contacts_record_set_str(record, _contacts_messenger.im_id, messenger); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +int CtInputData::setMessengerType(contacts_record_h record, int type, const char *customStr) +{ + WDEBUG("type %d", type); + int err = CONTACTS_ERROR_NONE; + + if (type >= 0) { + err = contacts_record_set_int(record, _contacts_messenger.type, type); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + if (customStr) { + err = contacts_record_set_str(record, _contacts_messenger.label, customStr); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +int CtInputData::getMessengerIndexType(int emailType) +{ + switch (emailType) { + case CONTACTS_MESSENGER_TYPE_CUSTOM: + return CTTEXT_MESSENGER_TYPE_CUSTOM; + case CONTACTS_MESSENGER_TYPE_AIM: + return CTTEXT_MESSENGER_TYPE_AIM; + case CONTACTS_MESSENGER_TYPE_YAHOO: + return CTTEXT_MESSENGER_TYPE_YAHOO; + case CONTACTS_MESSENGER_TYPE_SKYPE: + return CTTEXT_MESSENGER_TYPE_SKYPE; + case CONTACTS_MESSENGER_TYPE_QQ: + return CTTEXT_MESSENGER_TYPE_QQ; + case CONTACTS_MESSENGER_TYPE_GOOGLE: + return CTTEXT_MESSENGER_TYPE_HANGOUTS; + case CONTACTS_MESSENGER_TYPE_ICQ: + return CTTEXT_MESSENGER_TYPE_ICQ; + case CONTACTS_MESSENGER_TYPE_JABBER: + default: + return CTTEXT_MESSENGER_TYPE_JABBER; + } +} + +int CtInputData::getMessengerRetType(int indexType) +{ + int retType; + + switch (indexType) { + case CTTEXT_MESSENGER_TYPE_CUSTOM: + retType = CONTACTS_MESSENGER_TYPE_CUSTOM; + break; + case CTTEXT_MESSENGER_TYPE_AIM: + retType = CONTACTS_MESSENGER_TYPE_AIM; + break; + case CTTEXT_MESSENGER_TYPE_YAHOO: + retType = CONTACTS_MESSENGER_TYPE_YAHOO; + break; + case CTTEXT_MESSENGER_TYPE_SKYPE: + retType = CONTACTS_MESSENGER_TYPE_SKYPE; + break; + case CTTEXT_MESSENGER_TYPE_QQ: + retType = CONTACTS_MESSENGER_TYPE_QQ; + break; + case CTTEXT_MESSENGER_TYPE_HANGOUTS: + retType = CONTACTS_MESSENGER_TYPE_GOOGLE; + break; + case CTTEXT_MESSENGER_TYPE_ICQ: + retType = CONTACTS_MESSENGER_TYPE_ICQ; + break; + case CTTEXT_MESSENGER_TYPE_JABBER: + default: + retType = CONTACTS_MESSENGER_TYPE_JABBER; + break; + } + + return retType; +} + +const char* CtInputData::getMessengerMessenger(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + char *messenger = NULL; + const char *result = NULL; + + err = contacts_record_get_str_p(record, _contacts_messenger.im_id, &messenger); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_str_p() Failed(%d)", err); + + result = messenger; + return result; +} + +int CtInputData::getMessengerType(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + int type = 0; + + err = contacts_record_get_int(record, _contacts_messenger.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +void CtInputData::getMessengerTypeStr(contacts_record_h record, int indexType, std::string &typeString) +{ + WHIT(); + const char* typeStr = NULL; + + if (indexType == CONTACTS_MESSENGER_TYPE_CUSTOM) { + typeStr = getDataTypeCustom(record, _contacts_messenger.label); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_AIM) { + typeStr = V_("IDS_PB_OPT_AIM"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_YAHOO) { + typeStr = V_("IDS_PB_OPT_YAHOO_E"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_SKYPE) { + typeStr = V_("IDS_PB_BODY_SKYPE"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_QQ) { + typeStr = V_("IDS_PB_OPT_QQ"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_GOOGLE) { + typeStr = V_("IDS_PB_OPT_HANGOUTS"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_ICQ) { + typeStr = V_("IDS_PB_OPT_ICQ"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_JABBER) { + typeStr = V_("IDS_PB_OPT_JABBER"); + } + + char *result = elm_entry_utf8_to_markup(typeStr); + if (result) { + typeString = result; + free(result); + } +} + +int CtInputData::getNextMessengerType() +{ + int i; + int messengerType; + int indexType; + int index = 0; + int err = CONTACTS_ERROR_NONE; + int used[CTTEXT_TYPE_OTHER+1] = {0}; + contacts_record_h record = NULL; + while (CONTACTS_ERROR_NONE == contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.messenger, index++, &record)) { + err = contacts_record_get_int(record, _contacts_messenger.type, &messengerType); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_int() Failed(%d)", err); + continue; + } + indexType = getMessengerIndexType(messengerType); + used[indexType] = 1; + } + + for (i=CTTEXT_MESSENGER_TYPE_AIM;i<=CTTEXT_MESSENGER_TYPE_JABBER;i++) { + if (0 == used[i]) { + return getMessengerRetType(i); + } + } + + return CONTACTS_MESSENGER_TYPE_JABBER; +} + +int CtInputData::removeMessenger(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + + err = contacts_record_remove_child_record(__contactRecord, _contacts_contact.messenger, record); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_remove_child_record() Failed(%d)", err); + + return err; +} + +Eina_List* CtInputData::getWebsiteList() +{ + WHIT(); + return __getChildDataList(__contactRecord, _contacts_contact.url); +} + +contacts_record_h CtInputData::addWebsite(const char *url) +{ + WDEBUG("url %s", url); + + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + + err = contacts_record_create(_contacts_url._uri, &record); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_create() Failed(%d)", err); + + setWebsiteWebsite(record, url); + + err = contacts_record_add_child_record(__contactRecord, _contacts_contact.url, record); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(record, true); + return NULL; + } + return record; +} + +int CtInputData::setWebsiteWebsite(contacts_record_h record, const char *url) +{ + WDEBUG("url %s", url); + int err = CONTACTS_ERROR_NONE; + + if (url) { + err = contacts_record_set_str(record, _contacts_url.url, url); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +const char* CtInputData::getWebsiteWebsite(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + char *url = NULL; + const char *result = NULL; + + err = contacts_record_get_str_p(record, _contacts_url.url, &url); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_str_p() Failed(%d)", err); + + result = url; + return result; +} + +int CtInputData::removeWebsite(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + + err = contacts_record_remove_child_record(__contactRecord, _contacts_contact.url, record); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_remove_child_record() Failed(%d)", err); + + return err; +} + +Eina_List* CtInputData::getRelationshipList() +{ + WHIT(); + return __getChildDataList(__contactRecord, _contacts_contact.relationship); +} + +contacts_record_h CtInputData::addRelationship(const char *relationship) +{ + WDEBUG("relationship %s", relationship); + + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + + err = contacts_record_create(_contacts_relationship._uri, &record); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_create() Failed(%d)", err); + + setRelationshipRelationship(record, relationship); + setRelationshipType(record, getNextRelationshipType(), NULL); + + err = contacts_record_add_child_record(__contactRecord, _contacts_contact.relationship, record); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(record, true); + return NULL; + } + return record; +} + +int CtInputData::setRelationshipRelationship(contacts_record_h record, const char *relationship) +{ + WDEBUG("relationship %s", relationship); + int err = CONTACTS_ERROR_NONE; + + if (relationship) { + err = contacts_record_set_str(record, _contacts_relationship.name, relationship); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +int CtInputData::setRelationshipType(contacts_record_h record, int type, const char *customStr) +{ + WDEBUG("type %d", type); + int err = CONTACTS_ERROR_NONE; + + if (type >= 0) { + err = contacts_record_set_int(record, _contacts_relationship.type, type); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + if (customStr) { + err = contacts_record_set_str(record, _contacts_relationship.label, customStr); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +const char* CtInputData::getRelationshipRelationship(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + char *relationship = NULL; + const char *result = NULL; + + err = contacts_record_get_str_p(record, _contacts_relationship.name, &relationship); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_str_p() Failed(%d)", err); + + result = relationship; + return result; +} + +int CtInputData::getRelationshipType(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + int type = 0; + + err = contacts_record_get_int(record, _contacts_relationship.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +void CtInputData::getRelationshipTypeStr(contacts_record_h record, int indexType, std::string &typeString) +{ + WHIT(); + const char* typeStr = NULL; + + if (indexType == CONTACTS_RELATIONSHIP_TYPE_CUSTOM) { + typeStr = getDataTypeCustom(record, _contacts_relationship.label); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_ASSISTANT) { + typeStr = V_("IDS_PB_OPT_ASSISTANT_M_CONTACTS"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_BROTHER) { + typeStr = V_("IDS_PB_OPT_BROTHER"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_CHILD) { + typeStr = V_("IDS_PB_OPT_CHILD"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER) { + typeStr = V_("IDS_PB_OPT_DOMESTIC_PARTNER_ABB2"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_FATHER) { + typeStr = V_("IDS_PB_OPT_FATHER"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_FRIEND) { + typeStr = V_("IDS_PB_OPT_FRIEND"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_MANAGER) { + typeStr = V_("IDS_PB_OPT_MANAGER"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_MOTHER) { + typeStr = V_("IDS_PB_OPT_MOTHER"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_PARENT) { + typeStr = V_("IDS_PB_OPT_PARENT"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_PARTNER) { + typeStr = V_("IDS_PB_OPT_PARTNER"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY) { + typeStr = V_("IDS_PB_OPT_REFERRED_BY_ABB"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_RELATIVE) { + typeStr = V_("IDS_PB_OPT_RELATIVE"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_SISTER) { + typeStr = V_("IDS_PB_OPT_SISTER"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_SPOUSE) { + typeStr = V_("IDS_PB_OPT_SPOUSE"); + } + + char *result = elm_entry_utf8_to_markup(typeStr); + if (result) { + typeString = result; + free(result); + } +} + +int CtInputData::getNextRelationshipType() +{ + int i; + int relationshipType; + int index = 0; + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + int used[CONTACTS_RELATIONSHIP_TYPE_SPOUSE+1] = {0}; + + while (CONTACTS_ERROR_NONE == contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.relationship, index++, &record)) { + err = contacts_record_get_int(record, _contacts_relationship.type, &relationshipType); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_int() Failed(%d)", err); + continue; + } + used[relationshipType] = 1; + } + + for (i=CONTACTS_RELATIONSHIP_TYPE_ASSISTANT;i<=CONTACTS_RELATIONSHIP_TYPE_SPOUSE;i++) { + if (!used[i]) + return i; + } + + return CONTACTS_RELATIONSHIP_TYPE_SPOUSE; + +} + +int CtInputData::removeRelationship(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + + err = contacts_record_remove_child_record(__contactRecord, _contacts_contact.relationship, record); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_remove_child_record() Failed(%d)", err); + + return err; +} + +Eina_List* CtInputData::getEventList() +{ + WHIT(); + return __getChildDataList(__contactRecord, _contacts_contact.event); +} + +contacts_record_h CtInputData::addEvent(int date) +{ + WDEBUG("date %d", date); + + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + + err = contacts_record_create(_contacts_event._uri, &record); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_create() Failed(%d)", err); + + setEventEvent(record, date); + setEventType(record, getNextEventType(), NULL); + + err = contacts_record_add_child_record(__contactRecord, _contacts_contact.event, record); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(record, true); + return NULL; + } + return record; +} + +int CtInputData::setEventEvent(contacts_record_h record, int date) +{ + WDEBUG("date %d", date); + int err = CONTACTS_ERROR_NONE; + + if (date > 0) { + err = contacts_record_set_int(record, _contacts_event.date, date); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_int() Failed(%d)", err); + } + return err; +} + +int CtInputData::setEventType(contacts_record_h record, int type, char *customStr) +{ + WDEBUG("type %d", type); + int err = CONTACTS_ERROR_NONE; + + if (type >= 0) { + err = contacts_record_set_int(record, _contacts_event.type, type); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + if (customStr) { + err = contacts_record_set_str(record, _contacts_event.label, customStr); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +int CtInputData::getEventEvent(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + int date = 0; + + err = contacts_record_get_int(record, _contacts_event.date, &date); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return date; +} + +int CtInputData::getEventType(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + int type = 0; + + err = contacts_record_get_int(record, _contacts_event.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +void CtInputData::getEventTypeStr(contacts_record_h record, int eventType, std::string &typeString) +{ + WHIT(); + const char* typeStr = NULL; + + if (eventType == CONTACTS_EVENT_TYPE_CUSTOM) { + typeStr = getDataTypeCustom(record, _contacts_event.label); + } + else if (eventType == CONTACTS_EVENT_TYPE_BIRTH) { + typeStr = V_("IDS_PB_OPT_BIRTHDAY"); + } + else if (eventType == CONTACTS_EVENT_TYPE_ANNIVERSARY) { + typeStr = V_("IDS_PB_OPT_ANNIVERSARY_ABB"); + } + else { + typeStr = V_("IDS_PB_OPT_OTHER"); + } + + char *result = elm_entry_utf8_to_markup(typeStr); + if (result) { + typeString = result; + free(result); + } +} + +int CtInputData::getNextEventType() +{ + int eventType; + int index = 0; + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + bool usedBirthday = false; + bool usedAnniversary = false; + + while (CONTACTS_ERROR_NONE == contacts_record_get_child_record_at_p(__contactRecord, _contacts_contact.event, index++, &record)) { + err = contacts_record_get_int(record, _contacts_event.type, &eventType); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_int() Failed(%d)", err); + continue; + } + if (CONTACTS_EVENT_TYPE_BIRTH == eventType) { + usedBirthday = true; + } + else if (CONTACTS_EVENT_TYPE_ANNIVERSARY == eventType) { + usedAnniversary = true; + } + if (usedBirthday && usedAnniversary) { + break; + } + } + + if (!usedBirthday) { + return CONTACTS_EVENT_TYPE_BIRTH; + } + else if (!usedAnniversary) { + return CONTACTS_EVENT_TYPE_ANNIVERSARY; + } + + return CONTACTS_EVENT_TYPE_OTHER; + +} + +int CtInputData::removeEvent(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + + err = contacts_record_remove_child_record(__contactRecord, _contacts_contact.event, record); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_remove_child_record() Failed(%d)", err); + + return err; +} + +void CtInputData::__removeEmptyFiedls() +{ + removeEmptyFieldRecord(_contacts_contact.number, _contacts_number.number); + removeEmptyFieldRecord(_contacts_contact.email, _contacts_email.email); + removeEmptyFieldRecord(_contacts_contact.address, _contacts_address.street); + removeEmptyFieldRecord(_contacts_contact.url, _contacts_url.url); + removeEmptyFieldRecord(_contacts_contact.messenger, _contacts_messenger.im_id); + removeEmptyFieldRecord(_contacts_contact.note, _contacts_note.note); + removeEmptyFieldRecord(_contacts_contact.relationship, _contacts_relationship.name); +} + +int CtInputData::insertContact(int *contactId) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + err = contacts_record_set_int(__contactRecord, _contacts_contact.address_book_id, __baseAddressbookId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_set_int() Failed(%d)", err); + err = contacts_record_set_int(__contactRecord, _contacts_contact.link_mode, CONTACTS_CONTACT_LINK_MODE_IGNORE_ONCE); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_set_int() Failed(%d)", err); + return contacts_db_insert_record(__contactRecord, contactId); +} + +int CtInputData::updateContact() +{ + WHIT(); + return contacts_db_update_record(__contactRecord); +} + +int CtInputData::getContactId() +{ + WHIT(); + return __contactId; +} + +int CtInputData::__getBaseAddressbookId(void) +{ + WHIT(); + int addressBookId = 0; + char* addressbookName = NULL; + + int error = preference_get_string(CT_KEY_INPUT_BASE_ADDRESSBOOK, &addressbookName); + WPRET_VM(error != PREFERENCE_ERROR_NONE, 0, "preference_get_string failed error code (%d)", error); + WPRET_VM(!addressbookName, 0, "preference_get_string(%d) Failed", CT_KEY_INPUT_BASE_ADDRESSBOOK); + + if (addressbookName && *addressbookName) { + addressBookId = ctCommonGetAddressBookId(addressbookName); + } + else { + addressBookId = 0; + } + free(addressbookName); + + if(addressBookId == -1) { + addressBookId = 0; + } + + WDEBUG("%d",addressBookId); + return addressBookId; +} + +Eina_List* CtInputData::__getChildDataList(contacts_record_h contactRecord, unsigned int propertyId) +{ + WDEBUG("propertyId %d", propertyId); + int index = 0; +// Eina_List *l; + Eina_List *dataRecordList = NULL; + int err = CONTACTS_ERROR_NONE; + contacts_record_h dataRecord = NULL; +// contacts_record_h dataRecordClone = NULL; + + while (CONTACTS_ERROR_NONE == contacts_record_get_child_record_at_p(contactRecord, propertyId, index++, &dataRecord)) { + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_str_p() Failed(%d)", err); + break; + } + + //err = contacts_record_clone(dataRecord, &dataRecordClone); + //if (CONTACTS_ERROR_NONE != err) { + // WERROR("contacts_list_get_current_record_p() Failed(%d)", err); + // break; + //} + dataRecordList = eina_list_append(dataRecordList, dataRecord); + } + + return dataRecordList; +} + +void CtInputData::removeEmptyFieldRecord(int property_id, int property_id_str) +{ + int i; + int count; + char *str1 = NULL; + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + bool empty = false; + + err = contacts_record_get_child_record_count(__contactRecord, property_id, &count); + WPRET_M(CONTACTS_ERROR_NONE != err, "contacts_record_get_child_record_count() Failed(%d)", err); + + for (i=count-1;0<=i;i--) { + empty = false; + err = contacts_record_get_child_record_at_p(__contactRecord, property_id, i, &record); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_child_record_at_p() Failed(%d)", err); + continue; + } + + err = contacts_record_get_str(record, property_id_str, &str1); + WPRET_M(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + if (CONTACTS_ERROR_NONE != err || NULL == str1 || '\0' == *str1) { + empty = true; + } + free(str1); + + if (empty) { + err = contacts_record_remove_child_record(__contactRecord, property_id, record); + WPRET_M(CONTACTS_ERROR_NONE != err, "contacts_record_remove_child_record() Failed(%d)", err); + err = contacts_record_destroy(record, true); + WPRET_M(CONTACTS_ERROR_NONE != err, "contacts_record_destroy() Failed(%d)", err); + } + } +} + +void CtInputData::attachListener(ICtChangeListener* listener) +{ + WPRET_M(NULL == listener, "listener is NULL"); + __listener = listener; +} + +void CtInputData::detachListener() +{ + __listener = NULL; +} + +contacts_record_h CtInputData::addGroupRelation(int groupId) +{ + contacts_record_h groupRelationRecord= NULL; + int err = contacts_record_create(_contacts_group_relation._uri, &groupRelationRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_set_int(groupRelationRecord, _contacts_group_relation.group_id, groupId); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_set_int() Failed(%d)", err); + contacts_record_destroy(groupRelationRecord, true); + + return NULL; + } + + err = contacts_record_add_child_record(__contactRecord, _contacts_contact.group_relation, groupRelationRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(groupRelationRecord, true); + + return NULL; + } + + return groupRelationRecord; +} + +// for check input addressbook item is added or not +void CtInputData::setInputAddressbookItem(bool added) +{ + __inputAddressbook = added; +} +bool CtInputData::getInputAddressbookItem(void) +{ + return __inputAddressbook; +} diff --git a/lib-contact/ct-detail/src/CtInputData.h b/lib-contact/ct-detail/src/CtInputData.h new file mode 100755 index 0000000..95fa5c4 --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputData.h @@ -0,0 +1,213 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_INPUT_DATA_H_ +#define _CT_INPUT_DATA_H_ + +#include <Eina.h> + +#include <contacts.h> +//#include <contacts_product.h> + +#include "ContactsCommon.h" + +#include "CtType.h" +#include "CtData.h" + +class CtInputData:public CtData +{ +public: + CtInputData(contacts_record_h contactRecord); + CtInputData(int personId, const char *number, const char *email, const char *url); + CtInputData(const char *name, const char *number, const char *email, const char *url); + CtInputData(); + virtual ~CtInputData(); + +public: + + int insertContact(int *contactId); + int updateContact(); + + int separateFullName(contacts_record_h nameRecord, const char *full_name); + int separatePhoneticFullName(contacts_record_h nameRecord, const char *full_name); + int setPrefixName(const char *text); + int setSuffixName(const char *text); + int setPhoneticFullName(const char *text); + int setPhoneticFirstName(const char *text); + int setPhoneticMiddleName(const char *text); + int setPhoneticLastName(const char *text); + int setNickname(const char *text); + int setCompany(const char *text); + int setJobTitle(const char *text); + int setFullName(const char *text); + int setFirstName(const char *text); + int setMiddleName(const char *text); + int setLastName(const char *text); + const char* getPrefixName(); + const char* getSuffixName(); + const char* getPhoneticFirstName(); + const char* getPhoneticMiddleName(); + const char* getPhoneticLastName(); + const char* getNickname(); + const char* getCompany(); + const char* getJobTitle(); + void getFullName(std::string &Name); + const char* getFirstName(); + const char* getMiddleName(); + const char* getLastName(); + // ... + + int getAddressbookId() {return __baseAddressbookId;} + const char* getAddressbookName() {return (const char*)__baseAddressbookName;} + const char* getUserName() {return (const char*)__userName;} + void setAddressbookInfo(int addressbookId); + void setPreferenceCreateFirst(bool isFirst); + + bool getFavorite(){return __favorite;} + //bool getMFC(); + int getPersonId(){return __personId;} + const char* getImagePath(); + contacts_record_h getImageRecord(); + int removeImage(contacts_record_h record); + int setImage(contacts_record_h record, char *image, int type); + + contacts_record_h getEmergencyNumber(); + Eina_List* getNumberList(); + contacts_record_h addNumber(const char *number); + int setNumberNumber(contacts_record_h record, char const *number); + int setNumberType(contacts_record_h record, int type, const char *customStr); + int removeNumber(contacts_record_h record); + const char* getNumberNumber(contacts_record_h record); + contacts_record_h getDefaultEmail(); + contacts_record_h getDefaultNumber(); + int getNumberType(contacts_record_h record); + const char *getDataTypeCustom(contacts_record_h record, int property_id); + void getNumberTypeStr(contacts_record_h record, int numberType, std::string &typeString); + int getNumberRetType(int indexType); + int getNumberIndexType(int numberType); + int getNextNumberType(); + + Eina_List* getEmailList(); + Eina_List* getNoteList(); + contacts_record_h addEmail(const char *email); + int setEmailEmail(contacts_record_h record, const char *email); + int setEmailType(contacts_record_h record, int type, char *customStr); + const char* getEmailEmail(contacts_record_h record); + int getEmailType(contacts_record_h record); + void getEmailTypeStr(contacts_record_h record, int indexType, std::string &typeString); + int getNextEmailType(); + int removeEmail(contacts_record_h record); + + contacts_record_h getNoteRecord(); + contacts_record_h addNote( const char *note); + int setNote(contacts_record_h record, const char *note); + const char* getNote(contacts_record_h record); + int removeNote(contacts_record_h record); + + Eina_List* getAddressList(); + contacts_record_h addAddress(const char *address); + int setAddressAddress(contacts_record_h record, const char *address); + int setAddressType(contacts_record_h record, int type, const char *customStr); + int getAddressAddress(contacts_record_h record, char *buf, int length); + int getAddressType(contacts_record_h record); + void getAddressTypeStr(contacts_record_h record, int indexType, std::string &typeString); + int getNextAddressType(); + int removeAddress(contacts_record_h record); + + Eina_List* getMessengerList(); + contacts_record_h addMessenger(const char *messenger); + int setMessengerMessenger(contacts_record_h record, const char *messenger); + int setMessengerType(contacts_record_h record, int type, const char *customStr); + int getMessengerIndexType(int emailType); + int getMessengerRetType(int indexType); + const char* getMessengerMessenger(contacts_record_h record); + int getMessengerType(contacts_record_h record); + void getMessengerTypeStr(contacts_record_h record, int indexType, std::string &typeString); + int getNextMessengerType(); + int removeMessenger(contacts_record_h record); + + Eina_List* getWebsiteList(); + contacts_record_h addWebsite(const char *url); + int setWebsiteWebsite(contacts_record_h record, const char *url); + const char* getWebsiteWebsite(contacts_record_h record); + int removeWebsite(contacts_record_h record); + + Eina_List* getRelationshipList(); + contacts_record_h addRelationship(const char *relationship); + int setRelationshipRelationship(contacts_record_h record, const char *relationship); + int setRelationshipType(contacts_record_h record, int type, const char *customStr); + const char* getRelationshipRelationship(contacts_record_h record); + int getRelationshipType(contacts_record_h record); + void getRelationshipTypeStr(contacts_record_h record, int indexType, std::string &typeString); + int getNextRelationshipType(); + int removeRelationship(contacts_record_h record); + + Eina_List* getEventList(); + contacts_record_h addEvent(int date); + int setEventEvent(contacts_record_h record, int date); + int setEventType(contacts_record_h record, int type, char *customStr); + int getEventEvent(contacts_record_h record); + int getEventType(contacts_record_h record); + void getEventTypeStr(contacts_record_h record, int eventType, std::string &typeString); + int getNextEventType(); + int removeEvent(contacts_record_h record); + void removeEmptyFieldRecord(int property_id, int property_id_str); + + int getContactId(); + + + bool checkChangedTypeIsDeleted(); + void attachListener(ICtChangeListener* listener); + void detachListener(); + + contacts_record_h addGroupRelation(int groupId); + + // for check input addressbook item is added or not + void setInputAddressbookItem(bool added); + bool getInputAddressbookItem(void); + +private: + void __init(); + static void __onPersonChanged(const char *viewUri, void *userData); + + contacts_record_h __getInitContact(int personId, const char *number, const char *email, const char *url); + contacts_record_h __getWritableContact(int personId); + int __getBaseAddressbookId(void); + + void __appendStringWithLinebreak(const char *src, char *dest, int length); + int __getFullAddress(contacts_record_h addresssRecord, char *buf, int length); + Eina_List* __getChildDataList(contacts_record_h contactRecord, unsigned int propertyId); + void __removeEmptyFiedls(); + void __setContactInfo(int personId); + bool __hasSuffix(const char *src); + +private: + contacts_record_h __contactRecord; + + int __personId; + bool __favorite; + int __contactId; + int __baseAddressbookId; + char* __baseAddressbookName; + char* __userName; + int __currentVersion; + bool __inputAddressbook; + + ICtChangeListener* __listener; +}; + +#endif //_CT_INPUT_DATA_H_ diff --git a/lib-contact/ct-detail/src/CtInputDataTypeCtxPopup.cpp b/lib-contact/ct-detail/src/CtInputDataTypeCtxPopup.cpp new file mode 100755 index 0000000..92b050e --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputDataTypeCtxPopup.cpp @@ -0,0 +1,265 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <Elementary.h> + +#include <contacts.h> +#include <efl_extension.h> +#include <vector> + +#include "CtInputView.h" +#include "WPopup.h" +#include "ContactsDebug.h" +#include "CtCommon.h" +#include "CtPath.h" +#include "CtInputDataTypeCtxPopup.h" + +CtInputDataTypeCtxPopup::CtInputDataTypeCtxPopup(Evas_Object *genlist, Evas_Object *typeBtn, const char *viewUri, const char* customLabel ) +{ + WHIT(); + __viewUri = SAFE_STRDUP( viewUri ); + __customLabel = SAFE_STRDUP( customLabel ); + __removeBirthdayType = false; + __genlist = genlist; + __typeButton = typeBtn; + __createPopupTimer = NULL; +} + +CtInputDataTypeCtxPopup::~CtInputDataTypeCtxPopup() +{ + WHIT(); + SAFE_FREE( __viewUri ); + SAFE_FREE( __customLabel ); + + if(__createPopupTimer) + ecore_timer_del(__createPopupTimer); +} + +void CtInputDataTypeCtxPopup::__movePopup(Evas_Object* popup) +{ + Evas_Coord x, y, w, h; + Eina_Bool directionDown = EINA_FALSE; + + evas_object_geometry_get(__typeButton, &x, &y, &w, &h); + + WDEBUG("x %d, y %d, h %d", x, y, h); + + evas_object_move(popup, x, y + h); + + directionDown = elm_ctxpopup_direction_available_get(popup, ELM_CTXPOPUP_DIRECTION_DOWN); + if(!directionDown) { + elm_ctxpopup_direction_priority_set(popup, ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_UP); + evas_object_move(popup, x , y); + } + + evas_object_show(popup); +} + +void CtInputDataTypeCtxPopup::setOnSelectCb(std::function<void (int type)> selectCb) +{ + __selectCb = selectCb; +} + +Evas_Object* CtInputDataTypeCtxPopup::onCreate(Evas_Object* parent, void* viewParam) +{ + Evas_Object *popup = elm_ctxpopup_add(elm_object_top_widget_get(parent)); + elm_object_style_set(popup, "dropdown/label"); + eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, eext_ctxpopup_back_cb, NULL); + evas_object_smart_callback_add(popup, "dismissed", [](void* data, Evas_Object* obj, void* event_info){ + CtInputDataTypeCtxPopup* p = (CtInputDataTypeCtxPopup*)data; + p->destroy(); + }, this); + + elm_ctxpopup_direction_priority_set(popup, ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_DOWN); + evas_object_data_set(popup, "popup_data", this); + + if (0 == strcmp(__viewUri, _contacts_number._uri)) { + if( __customLabel && __customLabel[0] !='\0' ) + elm_ctxpopup_item_append(popup, __customLabel, NULL, __dataTypeNumberChangedCb, (void *)-1); + + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_MOBILE"), NULL, __dataTypeNumberChangedCb, (void *)CTTEXT_TYPE_MOBILE); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_WORK"), NULL, __dataTypeNumberChangedCb, (void *)CTTEXT_TYPE_WORK); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_HOME_ABB"), NULL, __dataTypeNumberChangedCb, (void *)CTTEXT_TYPE_HOME); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_MAIN"), NULL, __dataTypeNumberChangedCb, (void *)CTTEXT_TYPE_MAIN); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_FAX_HWORK_ABB"), NULL, __dataTypeNumberChangedCb, (void *)CTTEXT_TYPE_FAX_WORK); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_FAX_HHOME_ABB"), NULL, __dataTypeNumberChangedCb, (void *)CTTEXT_TYPE_FAX_HOME); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_PAGER"), NULL, __dataTypeNumberChangedCb, (void *)CTTEXT_TYPE_PAGER); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_OTHER"), NULL, __dataTypeNumberChangedCb, (void *)CTTEXT_TYPE_OTHER); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_CUSTOM"), NULL, __dataTypeNumberChangedCb, (void *)CTTEXT_TYPE_CUSTOM); + } + else if (0 == strcmp(__viewUri, _contacts_email._uri)) { + if( __customLabel && __customLabel[0] !='\0' ) + elm_ctxpopup_item_append(popup, __customLabel, NULL, __dataTypeEmailChangedCb, (void *)-1); + + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_HOME_ABB"), NULL, __dataTypeEmailChangedCb, (void *)CONTACTS_EMAIL_TYPE_HOME); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_WORK"), NULL, __dataTypeEmailChangedCb, (void *)CONTACTS_EMAIL_TYPE_WORK); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_OTHER"), NULL, __dataTypeEmailChangedCb, (void *)CONTACTS_EMAIL_TYPE_OTHER); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_CUSTOM"), NULL, __dataTypeEmailChangedCb, (void *)CONTACTS_EMAIL_TYPE_CUSTOM); + } + else if (0 == strcmp(__viewUri, _contacts_address._uri)) { + if( __customLabel && __customLabel[0] !='\0' ) + elm_ctxpopup_item_append(popup, __customLabel, NULL, __dataTypeAddressChangedCb, (void *)-1); + + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_HOME_ABB"), NULL, __dataTypeAddressChangedCb, (void *)CONTACTS_ADDRESS_TYPE_HOME); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_WORK"), NULL, __dataTypeAddressChangedCb, (void *)CONTACTS_ADDRESS_TYPE_WORK); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_OTHER"), NULL, __dataTypeAddressChangedCb, (void *)CONTACTS_ADDRESS_TYPE_OTHER); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_CUSTOM"), NULL, __dataTypeAddressChangedCb, (void *)CONTACTS_ADDRESS_TYPE_CUSTOM); + } + else if (0 == strcmp(__viewUri, _contacts_messenger._uri)) { + if( __customLabel && __customLabel[0] !='\0' ) + elm_ctxpopup_item_append(popup, __customLabel, NULL, __dataTypeMessengerChangedCb, (void *)-1); + + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_AIM"), NULL, __dataTypeMessengerChangedCb, (void *)CONTACTS_MESSENGER_TYPE_AIM); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_YAHOO_E"), NULL, __dataTypeMessengerChangedCb, (void *)CONTACTS_MESSENGER_TYPE_YAHOO); + elm_ctxpopup_item_append(popup, V_("IDS_PB_BODY_SKYPE"), NULL, __dataTypeMessengerChangedCb, (void *)CONTACTS_MESSENGER_TYPE_SKYPE); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_QQ"), NULL, __dataTypeMessengerChangedCb, (void *)CONTACTS_MESSENGER_TYPE_QQ); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_HANGOUTS"), NULL, __dataTypeMessengerChangedCb, (void *)CONTACTS_MESSENGER_TYPE_GOOGLE); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_ICQ"), NULL, __dataTypeMessengerChangedCb, (void *)CONTACTS_MESSENGER_TYPE_ICQ); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_JABBER"), NULL, __dataTypeMessengerChangedCb, (void *)CONTACTS_MESSENGER_TYPE_JABBER); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_CUSTOM"), NULL, __dataTypeMessengerChangedCb, (void *)CONTACTS_MESSENGER_TYPE_CUSTOM); + } + else if (0 == strcmp(__viewUri, _contacts_relationship._uri)) { + if( __customLabel && __customLabel[0] !='\0' ) + elm_ctxpopup_item_append(popup, __customLabel, NULL, __dataTypeFriendshipChangedCb, (void *)-1); + + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_ASSISTANT_M_CONTACTS"), NULL, __dataTypeFriendshipChangedCb, (void *)CONTACTS_RELATIONSHIP_TYPE_ASSISTANT); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_BROTHER"), NULL, __dataTypeFriendshipChangedCb, (void *)CONTACTS_RELATIONSHIP_TYPE_BROTHER); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_CHILD"), NULL, __dataTypeFriendshipChangedCb, (void *)CONTACTS_RELATIONSHIP_TYPE_CHILD); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_DOMESTIC_PARTNER_ABB2"), NULL, __dataTypeFriendshipChangedCb, (void *)CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_FATHER"), NULL, __dataTypeFriendshipChangedCb, (void *)CONTACTS_RELATIONSHIP_TYPE_FATHER); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_FRIEND"), NULL, __dataTypeFriendshipChangedCb, (void *)CONTACTS_RELATIONSHIP_TYPE_FRIEND); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_MANAGER"), NULL, __dataTypeFriendshipChangedCb, (void *)CONTACTS_RELATIONSHIP_TYPE_MANAGER); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_MOTHER"), NULL, __dataTypeFriendshipChangedCb, (void *)CONTACTS_RELATIONSHIP_TYPE_MOTHER); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_PARENT"), NULL, __dataTypeFriendshipChangedCb, (void *)CONTACTS_RELATIONSHIP_TYPE_PARENT); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_PARTNER"), NULL, __dataTypeFriendshipChangedCb, (void *)CONTACTS_RELATIONSHIP_TYPE_PARTNER); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_REFERRED_BY_ABB"), NULL, __dataTypeFriendshipChangedCb, (void *)CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_RELATIVE"), NULL, __dataTypeFriendshipChangedCb, (void *)CONTACTS_RELATIONSHIP_TYPE_RELATIVE); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_SISTER"), NULL, __dataTypeFriendshipChangedCb, (void *)CONTACTS_RELATIONSHIP_TYPE_SISTER); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_SPOUSE"), NULL, __dataTypeFriendshipChangedCb, (void *)CONTACTS_RELATIONSHIP_TYPE_SPOUSE); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_CUSTOM"), NULL, __dataTypeFriendshipChangedCb, (void *)CONTACTS_RELATIONSHIP_TYPE_CUSTOM); + } + else if (0 == strcmp(__viewUri, _contacts_event._uri)) { + if( __customLabel && __customLabel[0] !='\0' ) + elm_ctxpopup_item_append(popup, __customLabel, NULL, __dataTypeEventChangedCb, (void *)-1); + + if( !__removeBirthdayType ) + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_BIRTHDAY"), NULL, __dataTypeEventChangedCb, (void *)CONTACTS_EVENT_TYPE_BIRTH); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_ANNIVERSARY_ABB"), NULL, __dataTypeEventChangedCb, (void *)CONTACTS_EVENT_TYPE_ANNIVERSARY); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_OTHER"), NULL, __dataTypeEventChangedCb, (void *)CONTACTS_EVENT_TYPE_OTHER); + elm_ctxpopup_item_append(popup, V_("IDS_PB_OPT_CUSTOM"), NULL, __dataTypeEventChangedCb, (void *)CONTACTS_EVENT_TYPE_CUSTOM); + } + + __movePopup(popup); + + return popup; + +} + +void CtInputDataTypeCtxPopup::onDestroy() +{ + WHIT(); +} + + +void CtInputDataTypeCtxPopup::__dataTypeNumberChangedCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + int indexType = (int)data; + CtInputDataTypeCtxPopup* p = (CtInputDataTypeCtxPopup*)evas_object_data_get(obj, "popup_data"); + WPRET_M(!p, "popup data is NULL"); + + if (indexType == -1) + { + p->destroy(); + return; + } + + p->__selectCb( indexType ); +} + +void CtInputDataTypeCtxPopup::__dataTypeEmailChangedCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + int emailType = (int)data; + CtInputDataTypeCtxPopup* p = (CtInputDataTypeCtxPopup*)evas_object_data_get(obj, "popup_data"); + WPRET_M(!p, "popup data is NULL"); + + if (emailType == -1) { + p->destroy(); + return; + } + + p->__selectCb( emailType ); +} + +void CtInputDataTypeCtxPopup::__dataTypeAddressChangedCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + int addressType = (int)data; + CtInputDataTypeCtxPopup* p = (CtInputDataTypeCtxPopup*)evas_object_data_get(obj, "popup_data"); + WPRET_M(!p, "popup data is NULL"); + + if (addressType == -1) { + p->destroy(); + return; + } + + p->__selectCb( addressType ); +} + +void CtInputDataTypeCtxPopup::__dataTypeMessengerChangedCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + int MessengerType = (int)data; + CtInputDataTypeCtxPopup* p = (CtInputDataTypeCtxPopup*)evas_object_data_get(obj, "popup_data"); + WPRET_M(!p, "popup data is NULL"); + + if (MessengerType == -1) { + p->destroy(); + return; + } + p->__selectCb( MessengerType ); +} + +void CtInputDataTypeCtxPopup::__dataTypeFriendshipChangedCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + int relationshipType = (int)data; + CtInputDataTypeCtxPopup* p = (CtInputDataTypeCtxPopup*)evas_object_data_get(obj, "popup_data"); + WPRET_M(!p, "popup data is NULL"); + + if (relationshipType == -1) { + p->destroy(); + return; + } + p->__selectCb( relationshipType ); +} + +void CtInputDataTypeCtxPopup::__dataTypeEventChangedCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + int eventType = (int)data; + CtInputDataTypeCtxPopup* p = (CtInputDataTypeCtxPopup*)evas_object_data_get(obj, "popup_data"); + WPRET_M(!p, "popup data is NULL"); + + if (eventType == -1) { + p->destroy(); + return; + } + p->__selectCb( eventType ); +} + diff --git a/lib-contact/ct-detail/src/CtInputDataTypeCtxPopup.h b/lib-contact/ct-detail/src/CtInputDataTypeCtxPopup.h new file mode 100644 index 0000000..ce805df --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputDataTypeCtxPopup.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_INPUT_DATA_TYPE_POPUP2_H_ +#define _CT_INPUT_DATA_TYPE_POPUP2_H_ + +#include <Ecore.h> +#include <Elementary.h> +#include <functional> +#include "WControl.h" + +class CtInputDataTypeCtxPopup : public WControl +{ +public: + CtInputDataTypeCtxPopup(Evas_Object *genlist, Evas_Object *typeBtn, const char *viewUri, const char* customLabel); + + void setOnSelectCb(std::function<void (int type)> selectCb); + + void setRemoveBirthdayType(){ __removeBirthdayType = true; } +private: + virtual Evas_Object* onCreate( Evas_Object* parent, void* viewParam); + virtual void onDestroy(); +private: + + static void __dataTypeNumberChangedCb(void *data, Evas_Object *obj, void *event_info); + static void __dataTypeEmailChangedCb(void *data, Evas_Object *obj, void *event_info); + static void __dataTypeAddressChangedCb(void *data, Evas_Object *obj, void *event_info); + static void __dataTypeMessengerChangedCb(void *data, Evas_Object *obj, void *event_info); + static void __dataTypeFriendshipChangedCb(void *data, Evas_Object *obj, void *event_info); + static void __dataTypeEventChangedCb(void *data, Evas_Object *obj, void *event_info); + + void __movePopup(Evas_Object *popup); +private: + CtInputDataTypeCtxPopup(); + virtual ~CtInputDataTypeCtxPopup(); + +private: + char* __viewUri; + char* __customLabel; + Evas_Coord __x, __y, __w, __h; + std::function<void (int type)> __selectCb; + bool __removeBirthdayType; + Ecore_Timer *__createPopupTimer; + Evas_Object *__genlist; + Evas_Object *__typeButton; + +}; + +#endif //_CT_INPUT_DATA_TYPE_POPUP_H_ diff --git a/lib-contact/ct-detail/src/CtInputDataTypeCustomPopup.cpp b/lib-contact/ct-detail/src/CtInputDataTypeCustomPopup.cpp new file mode 100644 index 0000000..7ca1d96 --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputDataTypeCustomPopup.cpp @@ -0,0 +1,252 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <Elementary.h> +#include <contacts.h> +//#include <efl_assist.h> +#include <notification.h> + +#include "ContactsCommon.h" +#include "ContactsDebug.h" +#include "CtCommon.h" +#include "CtPath.h" +#include "CtType.h" +#include "CtInputDataTypeCustomPopup.h" +#include "CtThemeMgr.h" +#include "WEditfield.h" + +CtInputDataTypeCustomPopup::CtInputDataTypeCustomPopup() +{ + __customEntry = NULL; + __resultCb = NULL; + __notificationTimer = NULL; +} + +void CtInputDataTypeCustomPopup::setOnResultCb(std::function<void (const char* text)> resultCb) +{ + __resultCb = resultCb; +} +void CtInputDataTypeCustomPopup:: __entryShowCb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + WHIT(); + elm_object_focus_set(obj, EINA_TRUE); + evas_object_event_callback_del(obj, EVAS_CALLBACK_SHOW, __entryShowCb); +} + +Evas_Object* CtInputDataTypeCustomPopup::onCreate(Evas_Object* parent, void* viewParam) +{ + Evas_Object* popup = NULL; + + setTitle(V_("IDS_PB_HEADER_ENTER_CUSTOM_LABEL_ABB")); + setContent( [this](Evas_Object* parent)->Evas_Object* { + std::string contactsEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + Evas_Object *layout = elm_layout_add(parent); + CtThemeMgr::getInstance()->setObjectTheme(layout); + elm_layout_file_set(layout, contactsEdjePath.c_str(), "popup_input_text"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_content_set(parent, layout); + + WEditfield *editfield = __createEditField(layout, V_("IDS_MF_POP_INPUT_TEXT"), false, NULL, NULL, NULL, NULL); + Evas_Object *entry = editfield->getEntry(); + + elm_object_part_content_set(layout, "elm.swallow.content" , editfield->getEvasObj()); + evas_object_smart_callback_add(entry, "changed", __dataTypeCustomEntryChangedCb, this); + evas_object_smart_callback_add(entry, "preedit,changed", __dataTypeCustomEntryChangedCb, this); + + Evas_Object *clear_btn = editfield->getClearButton(); + evas_object_smart_callback_add(clear_btn, "clicked", __dataTypeCustomEntryChangedCb, this); + evas_object_event_callback_add(entry, EVAS_CALLBACK_SHOW, __entryShowCb, NULL); + //evas_object_smart_callback_add(entry, "activated", ct_common_entry_done_activated_cb, NULL); + __customEntry = entry; + return layout; + }); + + addButton( V_("IDS_PB_BUTTON_CANCEL"), NULL ); + addButton( V_("IDS_PB_SK_CREATE_ABB"), [this](bool* destroyPopup){ + __saveCustomDataType(); + *destroyPopup = true; + }); + popup = WPopup::onCreate( parent, viewParam ); + Evas_Object* saveBtn = elm_object_part_content_get(popup, "button2"); + elm_object_disabled_set(saveBtn, EINA_TRUE); + + return popup; +} + +void CtInputDataTypeCustomPopup::onDestroy() +{ + WHIT(); +} + +CtInputDataTypeCustomPopup::~CtInputDataTypeCustomPopup() +{ + if (__notificationTimer) { + ecore_timer_del(__notificationTimer); + } +} + +WEditfield* CtInputDataTypeCustomPopup::__createEditField(Evas_Object *parent, const char *guideText, bool multiline, + Evas_Smart_Cb unfocusedCallback, void *userData1, Evas_Smart_Cb focusedCallback, void *userData2) +{ + WHIT(); + WEditfield *editfield = new WEditfield(); + editfield->create(parent, NULL); + + Evas_Object *entry = editfield->getEntry(); + + if (guideText && *guideText) + elm_object_domain_translatable_part_text_set(entry, "elm.guide", PACKAGE, guideText); + + if (!multiline) + elm_entry_input_panel_return_key_type_set(entry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_NEXT); + + Elm_Entry_Filter_Limit_Size filter; + filter.max_char_count = CT_EDITFIELD_MAX_CHAR; + elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &filter); + + elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT); + elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_NORMAL); + evas_object_smart_callback_add(entry, "maxlength,reached", __editfieldTextMaxReachedCb, this); + elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_WORD); + + elm_entry_input_panel_return_key_type_set(entry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE); + elm_entry_input_panel_imdata_set(entry, (void*)"allowEmoji=true", 15); + +// if (unfocusedCallback) +// evas_object_smart_callback_add(entry, "unfocused", unfocusedCallback, userData1); +// +// if (focusedCallback) +// evas_object_smart_callback_add(entry, "focused", focusedCallback, userData2); + + return editfield; +} + +void CtInputDataTypeCustomPopup::__editfieldTextMaxReachedCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + WPRET_M(NULL == data, "data is NULL"); + CtInputDataTypeCustomPopup *customPopup = (CtInputDataTypeCustomPopup*)data; + + if (customPopup->__notificationTimer) { + return; + } + + customPopup->__showTickerNotification(V_("IDS_PB_POP_MAXIMUM_NUMBER_OF_CHARACTERS_REACHED")); + customPopup->__notificationTimer = ecore_timer_add(3.5, __notificationTimerCb, customPopup); +} + +Eina_Bool CtInputDataTypeCustomPopup::__notificationTimerCb(void *data) +{ + WHIT(); + WPRET_VM(NULL == data, ECORE_CALLBACK_CANCEL, "parameter(data) is NULL"); + CtInputDataTypeCustomPopup *customPopup = (CtInputDataTypeCustomPopup*)data; + + customPopup->__notificationTimer = NULL; + return ECORE_CALLBACK_CANCEL; +} + +void CtInputDataTypeCustomPopup::__showTickerNotification(const char *msg) +{ + WHIT(); + int err = notification_status_message_post(msg); + WPWARN(CONTACTS_ERROR_NONE != err, "notification_status_message_post() Failed(%d)", err); +} + +void CtInputDataTypeCustomPopup::__saveCustomDataType() +{ +// WHIT(); +// CtInputDataTypeCustomPopup *p = (CtInputDataTypeCustomPopup *)data; +// int err = CONTACTS_ERROR_NONE; +// Evas_Object *typeBtn = NULL; + char *realStr = NULL; + size_t i = 0; +// char* temp = NULL; + + char *text = ctCommonMarkupToUtf8(elm_entry_entry_get(__customEntry)); + + // remove ' ' in the head of string + for (i = 0; i < SAFE_STRLEN(text); i++) { + if (' ' != text[i]){ + realStr = text + i; + break; + } + } + + if (realStr != NULL) { + // remove ' ' at the end of string + for (i = (SAFE_STRLEN(realStr) - 1); i > 0; i--) { + if (' ' != realStr[i]){ + realStr[i+1] = '\0'; + break; + } + } + } + + if( realStr && __resultCb) + __resultCb( realStr ); + free(text); + +// if (0 == strcmp(p->__viewUri, _contacts_number._uri)) { +// +// p->__inputData->setNumberType(p->__record, CONTACTS_NUMBER_TYPE_CUSTOM, realStr); +// } +// else if (0 == strcmp(p->__viewUri, _contacts_email._uri)) { +// p->__inputData->setEmailType(p->__record, CONTACTS_EMAIL_TYPE_CUSTOM, realStr); +// } +// else if (0 == strcmp(p->__viewUri, _contacts_address._uri)) { +// p->__inputData->setAddressType(p->__record, CONTACTS_ADDRESS_TYPE_CUSTOM, realStr); +// } +// else if (0 == strcmp(p->__viewUri, _contacts_messenger._uri)) { +// p->__inputData->setMessengerType(p->__record, CONTACTS_MESSENGER_TYPE_CUSTOM, realStr); +// } +// else if (0 == strcmp(p->__viewUri, _contacts_relationship._uri)) { +// p->__inputData->setRelationshipType(p->__record, CONTACTS_RELATIONSHIP_TYPE_CUSTOM, realStr); +// } +// else if (0 == strcmp(p->__viewUri, _contacts_event._uri)) { +// p->__inputData->setEventType(p->__record, CONTACTS_EVENT_TYPE_CUSTOM, realStr); +// } +// +// elm_genlist_item_fields_update(p->__item, "elm.icon.1", ELM_GENLIST_ITEM_FIELD_CONTENT); +// p->destroy(); + +} + +void CtInputDataTypeCustomPopup::__dataTypeCustomEntryChangedCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + WPRET_M(NULL == data, "data is NULL"); + CtInputDataTypeCustomPopup *customPopup = (CtInputDataTypeCustomPopup*)data; + Evas_Object *popup = customPopup->getEvasObj(); + Evas_Object *saveBtn = NULL; + char *text; + + text = ctCommonMarkupToUtf8(elm_entry_entry_get(obj)); + saveBtn = elm_object_part_content_get(popup, "button2"); + + if (text && *text) + elm_object_disabled_set(saveBtn, EINA_FALSE); + else + elm_object_disabled_set(saveBtn, EINA_TRUE); + free(text); +} +//void CtInputDataTypeCustomPopup::__dataTypeCustomCancelCb(void *data, Evas_Object *obj, void *event_info) +//{ +// CtInputDataTypeCustomPopup *p = (CtInputDataTypeCustomPopup *)data; +// p->destroy(); +//} + diff --git a/lib-contact/ct-detail/src/CtInputDataTypeCustomPopup.h b/lib-contact/ct-detail/src/CtInputDataTypeCustomPopup.h new file mode 100644 index 0000000..3f5eb42 --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputDataTypeCustomPopup.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_INPUT_DATA_TYPE_CUSTOM_POPUP_H_ +#define _CT_INPUT_DATA_TYPE_CUSTOM_POPUP_H_ + +#include <Elementary.h> +#include <functional> +#include "WPopup.h" + +class WEditfield; + +class CtInputDataTypeCustomPopup : public WPopup +{ +public: + CtInputDataTypeCustomPopup(); + + void setOnResultCb(std::function<void (const char* text)> resultCb); +private: + virtual Evas_Object* onCreate( Evas_Object* parent, void* viewParam); + virtual void onDestroy(); + virtual ~CtInputDataTypeCustomPopup(); +private: + void __saveCustomDataType(); + WEditfield* __createEditField(Evas_Object *parent, const char *guideText, bool multiline, + Evas_Smart_Cb unfocusedCallback, void *userData1, Evas_Smart_Cb focusedCallback, void *userData2); + static void __dataTypeCustomCancelCb(void *data, Evas_Object *obj, void *event_info); + static void __dataTypeCustomEntryChangedCb(void *data, Evas_Object *obj, void *event_info); + static void __entryShowCb(void *data, Evas *e, Evas_Object *obj, void *event_info); + + static Eina_Bool __notificationTimerCb(void *data); + static void __editfieldTextMaxReachedCb(void *data, Evas_Object *obj, void *event_info); + void __showTickerNotification(const char *msg); +private: + Evas_Object* __customEntry; + Ecore_Timer *__notificationTimer; + + std::function<void (const char* text)> __resultCb; +}; + +#endif //_CT_INPUT_DATA_TYPE_CUSTOM_POPUP_H_ diff --git a/lib-contact/ct-detail/src/CtInputView.cpp b/lib-contact/ct-detail/src/CtInputView.cpp new file mode 100644 index 0000000..c585f42 --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputView.cpp @@ -0,0 +1,530 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <app_preference.h> +#include <contacts.h> + +#include "WPopup.h" +#include "WToastPopup.h" + +#include "ContactsDebug.h" +#include "ContactsAppControl.h" +#include "ContactsAppControlLauncher.h" + +#include "CtString.h" +#include "CtPath.h" +#include "CtInputData.h" +#include "CtInputView.h" +#include "CtCommon.h" +#include "CtDetailView.h" +#include "CtInputViewControl.h" +#include "CtRegistryMgr.h" +#include "CtThemeMgr.h" + +#define __ITEM_HEIGHT 98 + +CtInputView::CtInputView(contacts_record_h contactRecord) +{ + WHIT(); + __inputData = std::shared_ptr<CtData>( new CtInputData(contactRecord) ); + __initialize(); +} + +CtInputView::CtInputView(contacts_record_h contactRecord, CtEditTabView* tabView, bool isSubView) +{ + WHIT(); + __inputData = std::shared_ptr<CtData>( new CtInputData(contactRecord) ); + __initialize(); + __tabView = tabView; +} + +CtInputView::CtInputView(int personId, const char* number, const char* email, const char* uri) +{ + WHIT(); + __inputData = std::shared_ptr<CtData>( new CtInputData(personId, number, email, uri) ); + __initialize(); +} + +CtInputView::CtInputView(const char* name, const char* number, const char* email, const char* uri) +{ + __inputData = std::shared_ptr<CtData>( new CtInputData(name, number, email, uri) ); + __initialize(); +} + +CtInputView::~CtInputView() +{ + WHIT(); + ContactsAppControlLauncher::getInstance().terminate(); + + destroyPopup(); + if (__windowVisibilityChangeHandler) { + ecore_event_handler_del(__windowVisibilityChangeHandler); + __windowVisibilityChangeHandler = NULL; + } + if(__popupIdler) + ecore_idler_del(__popupIdler); + auto sp = __inputControl.lock(); + if ( sp ) { + CtInputViewControl* control = static_cast<CtInputViewControl*>(sp.get()); + control->setIsDestroy(true); + } +} + +Evas_Object* CtInputView::getNaviframeEvasObj() +{ + if( getNaviframe() ) + return getNaviframe()->getEvasObj(); + else + return NULL; +} + +Evas_Object* CtInputView::getWindowEvasObj() +{ + if(getWindow()) { + return getWindow()->getEvasObj(); + } + else { + WASSERT_EX(1, "window null"); + } + return NULL; +} + +Evas_Object* CtInputView::getConformantEvasObject() +{ + if(getWindow()) { + return getWindow()->getConformantEvasObj(); + } + else { + WASSERT_EX(1, "window null"); + } + return NULL; +} + +void CtInputView::setOnResult(const std::function<void(int, CtResultType)>& handlerFunc) +{ + __resultHandler = handlerFunc; +} + +void CtInputView::__initialize() +{ + + __saveBtn = NULL; + __saved = false; + __discard = false; + __changed = false; + __destroy = false; + __tabView = NULL; + __popupIdler = NULL; + __windowVisibilityChangeHandler = NULL; + + __savedAddressbookId = __inputData->getAddressbookId(); + __isCreate = __inputData->getContactId() > 0 ? false : true; +} + +void CtInputView::onDbChanged(const char* viewUri) +{ + WENTER(); + if (__inputData->checkChangedTypeIsDeleted()) { + WDEBUG("Contact is deleted"); + __discard = true; + popOut(); + } +} + +void CtInputView::onCompleteGetContacts(int offset) +{ + WENTER(); +} + +void CtInputView::onConditionChagned() +{ + WENTER(); +} + +Evas_Object* CtInputView::onCreate(Evas_Object* parent, void* viewParam) +{ + WHIT(); + Evas_Object *base = createBaseLayout(parent); + __baseLayout = base; + + std::string contactsEdjePath; + std::string buttonStylesEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + ContactsCommon::getAppEdjePath(CUSTOM_BUTTON_STYLES_EDJ, buttonStylesEdjePath); + CtThemeMgr::getInstance()->addExtensionTheme(contactsEdjePath.c_str()); + CtThemeMgr::getInstance()->addExtensionTheme(buttonStylesEdjePath.c_str()); + CtThemeMgr::getInstance()->setObjectTheme(__baseLayout); + + if (__isCreate) + { + setTitle(V_("IDS_PB_BUTTON_CREATE_ABB2")); + } + else + { + setTitle(V_("IDS_PB_OPT_EDIT")); + } + return base; +} + +void CtInputView::onLanguageChanged() +{ + WHIT(); + + destroyPopup(); + + auto sp = __inputControl.lock(); + if (sp) { + CtInputViewControl* control = static_cast<CtInputViewControl*>(sp.get()); + control->destroyPopup(); + } + + elm_object_text_set(__saveBtn, V_("IDS_TPLATFORM_ACBUTTON_CANCEL_ABB")); + + Evas_Object* cancelBtn = elm_object_item_part_content_get(getNaviItem(), "title_left_btn"); + elm_object_text_set(cancelBtn, V_("IDS_TPLATFORM_ACBUTTON_CANCEL_ABB")); + + if (__isCreate) { + elm_object_item_part_text_set(getNaviItem(), "elm.text.title", V_("IDS_PB_BUTTON_CREATE_ABB2")); + } + else { + elm_object_item_part_text_set(getNaviItem(), "elm.text.title", V_("IDS_PB_OPT_EDIT")); + } + + Evas_Object* genlist = elm_object_part_content_get(getEvasObj(), "elm.swallow.content"); + if(genlist) + elm_genlist_realized_items_update(genlist); +} + +void CtInputView::onPushed(Elm_Object_Item* naviItem) +{ + WENTER(); + //add title button + __saveBtn = elm_button_add(getNaviframe()->getEvasObj()); + elm_object_style_set(__saveBtn, "naviframe/title_right"); + elm_object_text_set(__saveBtn, V_("IDS_TPLATFORM_ACBUTTON_DONE_ABB")); + evas_object_smart_callback_add(__saveBtn, "clicked", __saveCb, this); + elm_object_item_part_content_set(naviItem, "title_right_btn", __saveBtn); + + if (__isCreate) { + elm_object_disabled_set(__saveBtn, EINA_TRUE); + } + + Evas_Object* cancelButton = elm_button_add(getNaviframe()->getEvasObj()); + elm_object_style_set(cancelButton, "naviframe/title_left"); + elm_object_text_set(cancelButton, V_("IDS_TPLATFORM_ACBUTTON_CANCEL_ABB")); + evas_object_smart_callback_add(cancelButton, "clicked", __cancelCb, this); + elm_object_item_part_content_set(naviItem, "title_left_btn", cancelButton); + + createInputViewControl(__baseLayout); + __inputData->attachListener(this); + + WLEAVE(); +} + +void CtInputView::createEditSubViewContent() +{ + WHIT(); + createInputViewControl(__baseLayout); + __inputData->attachListener(this); +} + +void CtInputView::createInputViewControl(Evas_Object *base) +{ + WHIT(); + + auto sp = __inputControl.lock(); + if ( sp ) { + CtInputViewControl* control = static_cast<CtInputViewControl*>(sp.get()); + control->setIsDestroy(true); + } + + Evas_Object* genlist = elm_object_part_content_unset(base, "elm.swallow.content"); + if (genlist) { + evas_object_del(genlist); + } + + CtInputViewControl* control = new CtInputViewControl( __inputData, this ); + __inputControl = control->getWeakPtr(); + control->create( base, NULL); + elm_object_part_content_set( base, "elm.swallow.content", control->getEvasObj() ); +} + +void CtInputView::updateNumberSaveBtn(Eina_Bool isEmpty) +{ + elm_object_disabled_set(__saveBtn, isEmpty); +} + +void CtInputView::updateSaveBtn(Eina_Bool empty) +{ + WHIT(); + elm_object_disabled_set(__saveBtn, empty); + if (__tabView) { + __tabView->updateSaveBtn(empty); + } + WPRET_M(true == empty, "all fields are empty, can't save"); +} + +void CtInputView::saveContactForEditTabSubView() +{ + WHIT(); + + int err = CONTACTS_ERROR_NONE; + const char* addressbookName = __inputData->getAddressbookName(); + + if(addressbookName) { + err = __inputData->updateContact(); + } + + if(__resultHandler) { + __resultHandler(__inputData->getPersonId(), CONTACTS_ERROR_NONE == err ? RESULT_SUCCESS : RESULT_FAILED); + } + + __saved = true; +} + +void CtInputView::getChangedForEditTabSubView(bool* changed) +{ + WHIT(); + CtInputViewControl* control = NULL; + + auto sp = __inputControl.lock(); + if( sp ) { + control = static_cast<CtInputViewControl*>(sp.get()); + if (changed) { + *changed = control->getIsChanged(); + } + } +} + +void CtInputView::getEmptyForEditTabSubView(bool* empty) +{ + WHIT(); + CtInputViewControl* control = NULL; + + auto sp = __inputControl.lock(); + if( sp ) { + control = static_cast<CtInputViewControl*>(sp.get()); + if (empty) { + *empty = control->getIsEmpty(); + } + } +} + +void CtInputView::__createToastPopup(const char* msg) +{ + WToastPopup* popup = new WToastPopup( msg ); + popup->create( getWindowEvasObj(), NULL); +} + +int CtInputView::__getPersonIdByContactId(int contactId) +{ + int personId = 0; + contacts_record_h record = NULL; + int err = CONTACTS_ERROR_NONE; + + err = contacts_db_get_record(_contacts_contact._uri, contactId, &record); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_db_get_record() Failed(%d)", err); + + err = contacts_record_get_int(record, _contacts_contact.person_id, &personId); + if (CONTACTS_ERROR_NONE != err) { + contacts_record_destroy(record, true); + WDEBUG("contacts_record_get_int() Failed(%d)", err); + + return 0; + } + contacts_record_destroy(record, true); + + return personId; +} + +void CtInputView::__saveCb(void *data, Evas_Object *obj, void *event_info) +{ + WENTER(); + CtInputView *view = (CtInputView*)data; + + int err = CONTACTS_ERROR_NONE; + int contactId = 0; + const char* addressbookName = view->__inputData->getAddressbookName(); + + // add contact + if (view->__isCreate) { + WDEBUG("addressbook_name %s", addressbookName); + if(addressbookName) { + int groupId = ctCommonGetEasDefaultGroupId(view->__inputData->getAddressbookId()); + if (groupId > 0) { // EAS default group + // In the case of EAS contacts, the contacts is required to add the default EAS contact group + view->__inputData->addGroupRelation(groupId); + } + + CtRegistryMgr::getInstance()->setInt(REGISTRY_KEY_INSERTED_PERSON, 1); + err = view->__inputData->insertContact(&contactId); + if(CONTACTS_ERROR_NONE == err) + CtRegistryMgr::getInstance()->setInt(REGISTRY_KEY_INSERTED_PERSON_ID, contactId); + + if (CONTACTS_ERROR_NONE != err) { + WERROR("insert failed %d", err); + if(CONTACTS_ERROR_FILE_NO_SPACE == err) + view->__createToastPopup(V_("IDS_PB_POP_NOT_ENOUGH_MEMORY")); + else + view->__createToastPopup(V_("IDS_PB_POP_FAILED")); + } else { + char* name = ctCommonGetAddressBookName(view->__inputData->getAddressbookId()); + WDEBUG("name = %s", name); + int ret = preference_set_string(CT_KEY_INPUT_BASE_ADDRESSBOOK, name); + WPWARN(ret, "preference_set_string(%d) Failed", ret); + SAFE_FREE(name); + } + } + } else { + if(addressbookName) { + err = view->__inputData->updateContact(); + } + contactId = view->__inputData->getContactId(); + } + + int personId = view->__getPersonIdByContactId(contactId); + if(view->__resultHandler) { + view->__resultHandler(personId, + CONTACTS_ERROR_NONE == err ? RESULT_SUCCESS : RESULT_FAILED); + } + view->__saved = true; + + if (view->__isCreate) { + view->getNaviframe()->push(new CtDetailView(personId)); + view->destroy(); + } else { + view->popOut(); + } +} + +void CtInputView::__cancelCb(void *data, Evas_Object *obj, void *event_info) +{ + CtInputView *view = (CtInputView*)data; + if (view->__resultHandler) { + view->__resultHandler(0, RESULT_CANCELLED); + } + + view->popOut(); +} + +void CtInputView::onTabSelect(Elm_Object_Item *naviItem) +{ + WHIT(); + + elm_object_focus_set(getEvasObj(), EINA_TRUE); + destroyPopup(); + +} +void CtInputView::onTabUnselect(Elm_Object_Item *naviItem) +{ + WHIT(); + destroyPopup(); +} + +bool CtInputView::onTabPop() +{ + WHIT(); + return TRUE; +} + +void CtInputView::onDestroy() +{ + WHIT(); +} + +void CtInputView::onEvent(int eventType) +{ + WHIT(); +} + +bool CtInputView::onPop() +{ + bool empty = false; + bool isChanged = false; + CtInputViewControl* control = NULL; + + auto sp = __inputControl.lock(); + if( sp ) { + control = static_cast<CtInputViewControl*>(sp.get()); + empty = control->getIsEmpty(); + isChanged = control->getIsChanged(); + } + if(__saved == true) { + WDEBUG("saved"); + __destroy = true; + } + else { + WDEBUG("canceled"); + if (__discard) { + __destroy = true; + return true; + } + + if (__isCreate && empty) { + __destroy = true; + return true; + } + + Eina_Bool changed = isChanged; + if (!__isCreate) { // edit view + if (__changed) { + changed = EINA_TRUE; + } + } else { + // in create view, if empty is false, so changed should be true + if (!empty) { + changed = EINA_TRUE; + } + } + + if (changed) { + WDEBUG("changed"); + + WPopup *popup = new WPopup(); + popup->setTextTranslatable(PACKAGE); + popup->setTitle("IDS_PB_HEADER_DISCARD_CHANGES_ABB"); + popup->setContent("IDS_PB_POP_ALL_CHANGES_WILL_BE_DISCARDED"); + + popup->addButton("IDS_PB_BUTTON_CANCEL", NULL ); + popup->addButton("IDS_PB_BUTTON_DISCARD_ABB", [this](bool* destroyPopup){ + WDEBUG("Discard"); + __discard = true; + popOut(); + *destroyPopup = false; + }); + + attachPopup(popup); + return false; + } else { + WDEBUG("not changed"); + __destroy = true; + return true; + } + } + + __destroy = true; + return true; +} + +void CtInputView::resetTheme() +{ + WHIT(); + std::string contactsEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + CtThemeMgr::getInstance()->addExtensionTheme(contactsEdjePath.c_str()); + CtThemeMgr::getInstance()->setObjectTheme(__baseLayout); +} diff --git a/lib-contact/ct-detail/src/CtInputViewAddressItem.h b/lib-contact/ct-detail/src/CtInputViewAddressItem.h new file mode 100644 index 0000000..3ccde7e --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputViewAddressItem.h @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_INPUT_VIEW_ADDRESS_ITEM_H_ +#define _CT_INPUT_VIEW_ADDRESS_ITEM_H_ + +#include "CtInputViewGenlistItem.h" +#include "CtDetailDataBase.h" +#include "CtInputDataTypeCtxPopup.h" +#include "CtInputDataTypeCustomPopup.h" +#include "CtInputViewControl.h" +#include "CtData.h" + +class CtInputViewAddressItem : public CtInputViewGenlistItem +{ +public: + CtInputViewAddressItem( std::shared_ptr<CtData>& inputData, contacts_record_h record, const char* oldVal, int addedIndex, + const std::function<void ()>& itemChangedCb, + const std::function<void (Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record )>& itemDeletedCb, + const std::function<void (Evas_Object*, Elm_Object_Item* )>& activateNextEntryCb) : CtInputViewGenlistItem(oldVal) + { + __inputData = inputData; __record = record; __addedIndex = addedIndex; + __itemChangedCb = itemChangedCb; __itemDeletedCb = itemDeletedCb; __activateNextEntryCb = activateNextEntryCb; + }; + virtual ~CtInputViewAddressItem() {WHIT();} +public: + virtual Elm_Genlist_Item_Class* getItemClassStatic() { + static Elm_Genlist_Item_Class itc = {}; + if( itc.item_style ) + return &itc; + itc.item_style = "input.3icon"; + itc.func.content_get = __getContentAddress; + itc.func.del = WGENLIST_ITEM_DEL(); + return &itc; + } + + virtual const char* getEntryObjPartName() + { + return "elm.icon.entry"; + } + +private: + static Evas_Object* __getContentAddress(void *data, Evas_Object *obj, const char *part) + { + WHIT(); + CtInputViewAddressItem *item = (CtInputViewAddressItem*)data; + + if (0 == strcmp(part, "elm.icon.entry")) { + WEditfield *editfield = item->createEditField(obj, V_("IDS_PB_BODY_ADDRESS_ABB2"), true); + Evas_Object *entry = editfield->getEntry(); + + elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_WORD); + elm_entry_input_panel_imdata_set(entry, (void*)"type=post&allowEmoji=true", 25); + + evas_object_smart_callback_add(entry, "changed", __addressChangedCb, item); + evas_object_smart_callback_add(entry, "preedit,changed", __addressChangedCb, item); + if (INPUT_ADDED_ITEM_INDEX_ADDRESS == item->__addedIndex ) { + evas_object_event_callback_add(entry, EVAS_CALLBACK_SHOW, __entryShowCb, NULL); + } + char address[CT_TEXT_MAX_LEN] = {0,}; + item->__inputData->getAddressAddress( item->__record, address, sizeof(address)); + setEntryText(entry, address); + return editfield->getEvasObj(); + } + else if (0 == strcmp(part, "elm.icon.2")) { + Evas_Object *btn_minus = elm_button_add(obj); + elm_object_style_set(btn_minus, "icon_expand_delete"); + evas_object_smart_callback_add(btn_minus, "clicked", __addressDeleteCb, item); + + return btn_minus; + } + else if (0 == strcmp(part, "elm.icon.1")) { + Evas_Object *btn_type = elm_button_add(obj); + elm_object_style_set(btn_type, "custom_dropdown"); + evas_object_show(btn_type); + + int addressType = item->__inputData->getAddressType( item->__record); + std::string typeStr; + item->__inputData->getAddressTypeStr( item->__record, addressType, typeStr); + elm_object_text_set(btn_type, typeStr.c_str()); + evas_object_smart_callback_add(btn_type, "clicked", __dataTypeClickedCb, item); + return btn_type; + } + + return NULL; + } + + static void __activatedCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewAddressItem* item = (CtInputViewAddressItem*)data; + item->__activateNextEntryCb( obj, item->getElmObjectItem() ); + } + static void __entryShowCb(void *data, Evas *e, Evas_Object *obj, void *event_info) + { + WHIT(); + elm_object_focus_set(obj, EINA_TRUE); + evas_object_event_callback_del(obj, EVAS_CALLBACK_SHOW, __entryShowCb); + } + + static void __dataTypeClickedCb(void *data, Evas_Object *obj, void *event_info) + { + WHIT(); + CtInputViewAddressItem* item = (CtInputViewAddressItem*)data; + + std::string typeStr; + if( item->__inputData->getAddressType( item->__record) == CONTACTS_ADDRESS_TYPE_CUSTOM) + { + item->__inputData->getAddressTypeStr( item->__record, CONTACTS_ADDRESS_TYPE_CUSTOM, typeStr); + } + CtInputDataTypeCtxPopup* popup = new CtInputDataTypeCtxPopup(elm_object_item_widget_get(item->getElmObjectItem()), obj, _contacts_address._uri, typeStr.c_str()); + + popup->setOnSelectCb( [popup,item,obj](int type){ + if( CONTACTS_ADDRESS_TYPE_CUSTOM == type ) + { + item->__showDataTypeInputPopup(); + return; + } + item->__inputData->setAddressType( item->__record, type, NULL); + std::string typeStr; + item->__inputData->getAddressTypeStr( item->__record, type, typeStr); + elm_object_text_set( obj, typeStr.c_str()); + popup->destroy(); + }); + + item->attachToView( popup ); + } + + void __showDataTypeInputPopup() + { + CtInputDataTypeCustomPopup* popup = new CtInputDataTypeCustomPopup(); + popup->setOnResultCb([this](const char* text){ + __inputData->setAddressType( __record, CONTACTS_ADDRESS_TYPE_CUSTOM, (char*)text ); + elm_genlist_item_fields_update( getElmObjectItem(), "elm.icon.1", ELM_GENLIST_ITEM_FIELD_CONTENT); + }); + attachToView( popup ); + } + static void __addressChangedCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewAddressItem* item = (CtInputViewAddressItem*)data; + char *text = NULL; + text = ctCommonMarkupToUtf8(elm_entry_entry_get(obj)); + item->__inputData->setAddressAddress(item->__record, text); + item->updateChangeState( text ); + item->__itemChangedCb(); + SAFE_FREE(text); + } + static void __addressDeleteCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewAddressItem* item = (CtInputViewAddressItem*)data; + item->updateChangeState(NULL); + item->__itemDeletedCb( item->getElmObjectItem(), item->getIsChanged(), item->__record ); + elm_object_item_del( item->getElmObjectItem() ); + } +private: + CtInputViewAddressItem(); + + std::shared_ptr<CtData> __inputData; + contacts_record_h __record; + int __addedIndex; + // + std::function<void ()> __itemChangedCb; + std::function<void (Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record )> __itemDeletedCb; + std::function<void (Evas_Object*, Elm_Object_Item*)> __activateNextEntryCb; + +}; + +#endif /* _CT_INPUT_VIEW_ADDRESS_ITEM_H_ */ diff --git a/lib-contact/ct-detail/src/CtInputViewBasicInfoItem.cpp b/lib-contact/ct-detail/src/CtInputViewBasicInfoItem.cpp new file mode 100755 index 0000000..502ee8e --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputViewBasicInfoItem.cpp @@ -0,0 +1,1516 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <app_preference.h> +#include <system_info.h> + +#include "CtInputViewBasicInfoItem.h" +#include "CtType.h" +#include "CtInputData.h" +#include "ContactsDebug.h" +#include "ContactsThumbnail.h" +#include "CtPath.h" +#include "CtInputView.h" +#include "CtString.h" +#include "CtCommon.h" +#include "CtThemeMgr.h" + +#define LABEL_FONT_SIZE 40 +#define W_HEIGHT_Z1 800 +#define W_HEIGHT_Z3 1280 + +CtInputViewBasicInfoItem::CtInputViewBasicInfoItem(std::shared_ptr<CtData>& inputData, Evas_Object** nameEntry, + const std::function<void ()>& itemChangedCb, + const std::function<void (CtInputViewBasicInfoItem::ITEM_DELETED)>& itemDeletedCb, + const std::function<void (Evas_Object*)>& imageClickedCb, + const std::function<void (Evas_Object*, Elm_Object_Item*)>& activateNextEntryCb, + const std::function<void (Evas_Object*)>& showCreateKeypadCb, + const std::function<void (Elm_Object_Item*)>& updateEntryReturnKeyType) +{ + __inputData = inputData; + __nameEntry = nameEntry; + __itemChangedCb = itemChangedCb; + __itemDeletedCb = itemDeletedCb; + __imageClickedCb = imageClickedCb; + __activateNextEntryCb = activateNextEntryCb; + __showCreateKeypadCb = showCreateKeypadCb; + __updateEntryReturnKeyType = updateEntryReturnKeyType; + + __initialize(); + + system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_FONT_SIZE, __onFontChangedCb, this); +}; + +CtInputViewBasicInfoItem::~CtInputViewBasicInfoItem() +{ + WHIT(); + + SAFE_FREE( __oldFullName ); + SAFE_FREE( __oldPrefix ); + SAFE_FREE( __oldFirstName ); + SAFE_FREE( __oldMiddleName ); + SAFE_FREE( __oldLastName ); + SAFE_FREE( __oldSuffix ); + SAFE_FREE( __oldPhoneticFirstName ); + SAFE_FREE( __oldPhoneticMiddleName ); + SAFE_FREE( __oldPhoneticLastName ); + SAFE_FREE( __oldNickname ); + SAFE_FREE( __oldCompany ); + SAFE_FREE( __oldJobTitle ); + SAFE_FREE( __oldImagePath ); + + system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_FONT_SIZE); +} + +void CtInputViewBasicInfoItem::__initialize() +{ + __focusEntry = NULL; + __addedIndex = INPUT_ADDED_ITEM_INDEX_NONE; + __oldBaseInfoExpanded = false; + __baseInfoExpanded = true; + + __fullNameIsChanged = false; + __prefixIsChanged = false; + __firstNameIsChanged = false; + __middleNameIsChanged = false; + __lastNameIsChanged = false; + __suffixIsChanged = false; + __phoneticFirstNameIsChanged = false; + __phoneticMiddleNameIsChanged = false; + __phoneticLastNameIsChanged = false; + __nicknameIsChanged = false; + __companyIsChanged = false; + __jobTitleIsChanged = false; + + __fullNameIsEmpty = true; + __prefixIsEmpty = true; + __firstNameIsEmpty = true; + __middleNameIsEmpty = true; + __lastNameIsEmpty = true; + __suffixIsEmpty = true; + __phoneticFirstNameIsEmpty = true; + __phoneticMiddleNameIsEmpty = true; + __phoneticLastNameIsEmpty = true; + __nicknameIsEmpty = true; + __companyIsEmpty = true; + __jobTitleIsEmpty = true; + + std::string name; + __inputData->getFullName(name); + __oldFullName = SAFE_STRDUP(name.c_str()); + __oldPrefix = SAFE_STRDUP(__inputData->getPrefixName()); + __oldFirstName = SAFE_STRDUP(__inputData->getFirstName()); + __oldMiddleName = SAFE_STRDUP(__inputData->getMiddleName()); + __oldLastName = SAFE_STRDUP(__inputData->getLastName()); + __oldSuffix = SAFE_STRDUP(__inputData->getSuffixName()); + __oldPhoneticFirstName = SAFE_STRDUP(__inputData->getPhoneticFirstName()); + __oldPhoneticMiddleName = SAFE_STRDUP(__inputData->getPhoneticMiddleName()); + __oldPhoneticLastName = SAFE_STRDUP(__inputData->getPhoneticLastName()); + __oldNickname = SAFE_STRDUP(__inputData->getNickname()); + __oldCompany = SAFE_STRDUP(__inputData->getCompany()); + __oldJobTitle = SAFE_STRDUP(__inputData->getJobTitle()); + __oldImagePath = SAFE_STRDUP(__inputData->getImagePath()); + + if (__inputData->getPhoneticFirstName() || __inputData->getPhoneticMiddleName() || __inputData->getPhoneticLastName()) { + __addPhoneticName = true; + } else { + __addPhoneticName = false; + } + if (__inputData->getNickname()) { + __addNickname = true; + } else { + __addNickname = false; + } + if (__inputData->getCompany() || __inputData->getJobTitle()) { + __addOrganization = true; + } else { + __addOrganization = false; + } + __updateItem = false; + __isRealized = false; + __subItemSize = 0; +} + +Elm_Genlist_Item_Class* CtInputViewBasicInfoItem::getItemClassStatic() +{ + static Elm_Genlist_Item_Class itc = {}; + + itc.item_style = "baseinfo.contract"; + itc.func.content_get = __getContentBasicInfo; + itc.func.del = WGENLIST_ITEM_DEL(); //__deleteGenlistItem; + return &itc; +} + +Evas_Object* CtInputViewBasicInfoItem::__getContentBasicInfo(void *data, Evas_Object *obj, const char *part) +{ + //WHIT(); + WPRET_VM(NULL == data, NULL, "data is NULL"); + CtInputViewBasicInfoItem *item = (CtInputViewBasicInfoItem*)data; + + //WDEBUG("part %s", part); + if (0 == strcmp(part, "elm.icon.1")) { + Evas_Object *box = NULL; + Evas_Object *layout = NULL; + int count = 0; + + box = elm_box_add(obj); + evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(box); + if (item->__baseInfoExpanded) { + layout = __createPrefixField(item, box); + elm_box_pack_end(box, layout); + count++; + + layout = __createFirstNameField(item, box); + elm_box_pack_end(box, layout); + count++; + + layout = __createMiddleNameField(item, box); + elm_box_pack_end(box, layout); + count++; + + layout = __createLastNameField(item, box); + elm_box_pack_end(box, layout); + count++; + + layout = __createSuffixField(item, box); + elm_box_pack_end(box, layout); + count++; + } + else { + layout = __createNameField(item, box); + elm_box_pack_end(box, layout); + count++; + } + + if( item->__addPhoneticName ) { + layout = __createPhoneticFirstNameField(item, box); + elm_box_pack_end(box, layout); + count++; + + layout = __createPhoneticMiddleNameField(item, box); + elm_box_pack_end(box, layout); + count++; + + layout = __createPhoneticLastNameField(item, box); + elm_box_pack_end(box, layout); + count++; + } + if( item->__addNickname ) { + layout = __createNicknameField(item, box); + elm_box_pack_end(box, layout); + count++; + } + if( item->__addOrganization ) { + layout = __createCompanyField(item, box); + elm_box_pack_end(box, layout); + count++; + + layout = __createJobTitleField(item, box); + elm_box_pack_end(box, layout); + count++; + } + + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_min_set(box, 0, item->__subItemSize * count); + + return box; + } else if (0 == strcmp(part, "elm.icon.2")) { + Evas_Object *icon = createThumbnail(obj, THUMBNAIL_166, item->__inputData->getImagePath()); + evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_UP, __basicInfoImageClickedCb, item); + return icon; + } else if (0 == strcmp(part, "elm.name.label")) { + Evas_Object* label = elm_label_add(obj); + char text[CT_TEXT_MAX_LEN] = {0}; + snprintf(text, CT_TEXT_MAX_LEN, "<font_size=%d>%s</font_size>", LABEL_FONT_SIZE, V_("IDS_PB_BODY_NAME")); + elm_object_text_set(label, text); + evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(label); + + return label; + } + + return NULL; +} + +Evas_Object* CtInputViewBasicInfoItem::__createNameField(CtInputViewBasicInfoItem* item, Evas_Object *parent) +{ + WHIT(); + Evas_Object *layout = NULL; + WEditfield *editfield = NULL; + Evas_Object *entry = NULL; + + + std::string contactsEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + layout = elm_layout_add(parent); + CtThemeMgr::getInstance()->setObjectTheme(layout); + elm_layout_file_set(layout, contactsEdjePath.c_str(), "baseinfo_sub_layout"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0.0); + evas_object_show(layout); + + std::string name; + item->__inputData->getFullName(name); + + if (name.size() > 0) { + editfield = item->createEditField(layout, NULL, false, true); + } + else { + editfield = item->createEditField(layout, V_("IDS_PB_BODY_NAME"), false); + } + entry = editfield->getEntry(); + + *item->__nameEntry = entry; + elm_object_part_content_set(layout, "elm.icon.1", editfield->getEvasObj()); + + elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_WORD); + evas_object_smart_callback_add(entry, "changed", __basicInfoNameChangedCb, item); + evas_object_smart_callback_add(entry, "preedit,changed", __basicInfoNameChangedCb, item); + evas_object_smart_callback_add(entry, "activated", __activatedCb, item); + + elm_entry_input_panel_imdata_set(entry, (void*)"type=name&allowEmoji=true", 25); + + bool first = false; + int error = preference_get_boolean(CT_KEY_CONTACT_CREATE_FIRST, &first); + if (error != PREFERENCE_ERROR_NONE) + { + WDEBUG("preference_get_boolean failed"); + } + else + { + if (!first && item->__inputData->getContactId() == 0 ) { + evas_object_event_callback_add(entry, EVAS_CALLBACK_SHOW, __basicInfoNameShowCb, item); + } + } + + setEntryText( entry, name.c_str()); + + std::string detailLayoutEdjePath; + ContactsCommon::getAppEdjePath(DETAIL_LAYOUT_EDJ, detailLayoutEdjePath); + + Evas_Object *button = elm_button_add(layout); + elm_object_style_set(button, "transparent"); + + Evas_Object *button_content_layout = elm_layout_add(button); + elm_layout_file_set(button_content_layout, detailLayoutEdjePath.c_str(), "input_open"); + elm_object_part_content_set(button, "elm.swallow.content", button_content_layout); + + evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(button, EVAS_HINT_FILL, 0.0); + evas_object_smart_callback_add(button, "clicked", __basicInfoExpandClickedCb, item); + + elm_object_part_content_set(layout, "elm.icon.2", button); + + return layout; +} + +Evas_Object* CtInputViewBasicInfoItem::__createPrefixField( CtInputViewBasicInfoItem* item, Evas_Object *parent) +{ + WHIT(); + Evas_Object *layout = NULL; + WEditfield *editfield = NULL; + Evas_Object *entry = NULL; + const char *prefix = NULL; + + std::string contactsEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + layout = elm_layout_add(parent); + CtThemeMgr::getInstance()->setObjectTheme(layout); + elm_layout_file_set(layout, contactsEdjePath.c_str(), "baseinfo_sub_layout"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0.0); + evas_object_show(layout); + + prefix = item->__inputData->getPrefixName(); + + if (prefix && *prefix) { + editfield = item->createEditField(layout, NULL, false); + } + else { + editfield = item->createEditField(layout, V_("IDS_PB_BODY_TITLE_M_NAMEPREFIX"), false); + } + + entry = editfield->getEntry(); + elm_object_part_content_set(layout, "elm.icon.1", editfield->getEvasObj()); + + elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_WORD); + + evas_object_smart_callback_add(entry, "changed", __basicInfoPrefixChangedCb, item); + evas_object_smart_callback_add(entry, "preedit,changed", __basicInfoPrefixChangedCb, item); + evas_object_smart_callback_add(entry, "activated", __activatedCb, item); + + setEntryText(entry, prefix); + + std::string detailLayoutEdjePath; + ContactsCommon::getAppEdjePath(DETAIL_LAYOUT_EDJ, detailLayoutEdjePath); + + Evas_Object* button = elm_button_add(layout); + elm_object_style_set(button, "transparent"); + + Evas_Object *button_content_layout = elm_layout_add(button); + elm_layout_file_set(button_content_layout, detailLayoutEdjePath.c_str(), "input_close"); + elm_object_part_content_set(button, "elm.swallow.content", button_content_layout); + + evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(button, EVAS_HINT_FILL, 0.0); + evas_object_smart_callback_add(button, "clicked", __basicInfoExpandClickedCb, item); + + elm_object_part_content_set(layout, "elm.icon.2", button); + + return layout; +} + +Evas_Object* CtInputViewBasicInfoItem::__createFirstNameField(CtInputViewBasicInfoItem* item, Evas_Object *parent) +{ + //WHIT(); + Evas_Object *layout = NULL; + WEditfield *editfield = NULL; + Evas_Object *entry = NULL; + const char *firstName = NULL; + + std::string contactsEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + layout = elm_layout_add(parent); + if (item->__subItemSize == 0) { + evas_object_event_callback_add(layout, EVAS_CALLBACK_RESIZE, CtInputViewBasicInfoItem::__subItemResizeCb, item); + } + CtThemeMgr::getInstance()->setObjectTheme(layout); + elm_layout_file_set(layout, contactsEdjePath.c_str(), "baseinfo_sub_layout"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0.0); + evas_object_show(layout); + + firstName = item->__inputData->getFirstName(); + + if (firstName && *firstName) { + editfield = item->createEditField(layout, NULL, false); + } + else { + editfield = item->createEditField(layout, V_("IDS_PB_OPT_FIRST_NAME"), false); + } + + entry = editfield->getEntry(); + elm_object_part_content_set(layout, "elm.icon.1", editfield->getEvasObj()); + + elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_WORD); + + evas_object_smart_callback_add(entry, "changed", __basicInfoFirstNameChangedCb, item); + evas_object_smart_callback_add(entry, "preedit,changed", __basicInfoFirstNameChangedCb, item); + evas_object_smart_callback_add(entry, "activated", __activatedCb, item); + + setEntryText(entry, firstName ); + return layout; +} + +Evas_Object* CtInputViewBasicInfoItem::__createMiddleNameField(CtInputViewBasicInfoItem* item, Evas_Object *parent) +{ + //WHIT(); + Evas_Object *layout = NULL; + WEditfield *editfield = NULL; + Evas_Object *entry = NULL; + const char *middleName = NULL; + + std::string contactsEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + layout = elm_layout_add(parent); + CtThemeMgr::getInstance()->setObjectTheme(layout); + elm_layout_file_set(layout, contactsEdjePath.c_str(), "baseinfo_sub_layout"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0.0); + evas_object_show(layout); + + middleName = item->__inputData->getMiddleName(); + + if (middleName && *middleName) { + editfield = item->createEditField(layout, NULL, false); + } + else { + editfield = item->createEditField(layout, V_("IDS_PB_BODY_MIDDLE_NAME_ABB"), false); + } + + entry = editfield->getEntry(); + elm_object_part_content_set(layout, "elm.icon.1", editfield->getEvasObj()); + + elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_WORD); + + evas_object_smart_callback_add(entry, "changed", __basicInfoMiddleNameChangedCb, item); + evas_object_smart_callback_add(entry, "preedit,changed", __basicInfoMiddleNameChangedCb, item); + evas_object_smart_callback_add(entry, "activated", __activatedCb, item); + + setEntryText(entry, middleName); + return layout; +} + +Evas_Object* CtInputViewBasicInfoItem::__createLastNameField(CtInputViewBasicInfoItem* item, Evas_Object *parent) +{ + //WHIT(); + Evas_Object *layout = NULL; + WEditfield *editfield = NULL; + Evas_Object *entry = NULL; + const char *lastName = NULL; + + std::string contactsEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + layout = elm_layout_add(parent); + CtThemeMgr::getInstance()->setObjectTheme(layout); + elm_layout_file_set(layout, contactsEdjePath.c_str(), "baseinfo_sub_layout"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0.0); + evas_object_show(layout); + + lastName = item->__inputData->getLastName(); + + if (lastName && *lastName) { + editfield = item->createEditField(layout, NULL, false); + } + else { + editfield = item->createEditField(layout, V_("IDS_PB_BODY_LAST_NAME_ABB"), false); + } + + entry = editfield->getEntry(); + elm_object_part_content_set(layout, "elm.icon.1", editfield->getEvasObj()); + + elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_WORD); + + evas_object_smart_callback_add(entry, "changed", __basicInfoLastNameChangedCb, item); + evas_object_smart_callback_add(entry, "preedit,changed", __basicInfoLastNameChangedCb, item); + evas_object_smart_callback_add(entry, "activated", __activatedCb, item); + + setEntryText(entry, lastName); + return layout; +} + +Evas_Object* CtInputViewBasicInfoItem::__createSuffixField(CtInputViewBasicInfoItem* item, Evas_Object *parent) +{ + //WHIT(); + Evas_Object *layout = NULL; + WEditfield *editfield = NULL; + Evas_Object *entry = NULL; + const char *suffix = NULL; + + std::string contactsEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + layout = elm_layout_add(parent); + CtThemeMgr::getInstance()->setObjectTheme(layout); + elm_layout_file_set(layout, contactsEdjePath.c_str(), "baseinfo_sub_layout"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0.0); + evas_object_show(layout); + + suffix = item->__inputData->getSuffixName(); + + if (suffix && *suffix) { + editfield = item->createEditField(layout, NULL, false); + } + else { + editfield = item->createEditField(layout, V_("IDS_PB_BODY_NAME_SUFFIX_ABB"), false); + } + + entry = editfield->getEntry(); + elm_object_part_content_set(layout, "elm.icon.1", editfield->getEvasObj()); + + elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_WORD); + + evas_object_smart_callback_add(entry, "changed", __basicInfoSuffixChangedCb, item); + evas_object_smart_callback_add(entry, "preedit,changed", __basicInfoSuffixChangedCb, item); + evas_object_smart_callback_add(entry, "activated", __activatedCb, item); + evas_object_event_callback_add(entry, EVAS_CALLBACK_SHOW, __basicInfoSuffixShowCb, item); + + setEntryText(entry, suffix); + return layout; +} + +Evas_Object* CtInputViewBasicInfoItem::__createPhoneticFirstNameField(CtInputViewBasicInfoItem* item, Evas_Object *parent) +{ + //WHIT(); + ////CONTACTS_LOGGING_LOG(LOGGING_LOG_PHONETIC_NAME); //DO NOT REMOVE!!! + + Evas_Object *layout = NULL; + WEditfield *editfield = NULL; + Evas_Object *entry = NULL; + const char *phoneticName = NULL; + + std::string contactsEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + layout = elm_layout_add(parent); + CtThemeMgr::getInstance()->setObjectTheme(layout); + elm_layout_file_set(layout, contactsEdjePath.c_str(), "baseinfo_sub_layout"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0.0); + evas_object_show(layout); + + phoneticName = item->__inputData->getPhoneticFirstName(); + + if (phoneticName && *phoneticName) { + editfield = item->createEditField(layout, NULL, false); + } + else { + // TODO: language translation + editfield = item->createEditField(layout, V_("IDS_PB_BODY_PHONETIC_FIRST_NAME_ABB"), false); + } + + entry = editfield->getEntry(); + elm_object_part_content_set(layout, "elm.icon.1", editfield->getEvasObj()); + + elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_WORD); + + evas_object_smart_callback_add(entry, "changed", __basicInfoPhoneticFirstNameChangedCb, item); + evas_object_smart_callback_add(entry, "preedit,changed", __basicInfoPhoneticFirstNameChangedCb, item); + evas_object_smart_callback_add(entry, "activated", __activatedCb, item); + if (INPUT_ADDED_ITEM_INDEX_PHONETIC_INFO == item->__addedIndex ) { + if (item->__isRealized) { + elm_object_focus_set(entry, EINA_TRUE); + item->__addedIndex = INPUT_ADDED_ITEM_INDEX_NONE; + } else { + item->__focusEntry = entry; + } + } + + setEntryText(entry, phoneticName); + + Evas_Object* btn_minus = elm_button_add(layout); + elm_object_style_set(btn_minus, "icon_expand_delete"); + elm_object_part_content_set(layout, "elm.icon.2", btn_minus); + evas_object_smart_callback_add(btn_minus, "clicked", __phoneticNameDeleteCb, item); + return layout; +} + +Evas_Object* CtInputViewBasicInfoItem::__createPhoneticMiddleNameField(CtInputViewBasicInfoItem* item, Evas_Object *parent) +{ + //WHIT(); + ////CONTACTS_LOGGING_LOG(LOGGING_LOG_PHONETIC_NAME); //DO NOT REMOVE!!! + + Evas_Object *layout = NULL; + WEditfield *editfield = NULL; + Evas_Object *entry = NULL; + const char *phoneticName = NULL; + + std::string contactsEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + layout = elm_layout_add(parent); + CtThemeMgr::getInstance()->setObjectTheme(layout); + elm_layout_file_set(layout, contactsEdjePath.c_str(), "baseinfo_sub_layout"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0.0); + evas_object_show(layout); + + phoneticName = item->__inputData->getPhoneticMiddleName(); + + if (phoneticName && *phoneticName) { + editfield = item->createEditField(layout, NULL, false); + } + else { + // TODO: language translation + editfield = item->createEditField(layout, V_("IDS_PB_BODY_PHONETIC_MIDDLE_NAME_ABB"), false); + } + + entry = editfield->getEntry(); + elm_object_part_content_set(layout, "elm.icon.1", editfield->getEvasObj()); + + elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_WORD); + + evas_object_smart_callback_add(entry, "changed", __basicInfoPhoneticMiddleNameChangedCb, item); + evas_object_smart_callback_add(entry, "preedit,changed", __basicInfoPhoneticMiddleNameChangedCb, item); + evas_object_smart_callback_add(entry, "activated", __activatedCb, item); + + setEntryText(entry, phoneticName); + return layout; +} + +Evas_Object* CtInputViewBasicInfoItem::__createPhoneticLastNameField(CtInputViewBasicInfoItem* item, Evas_Object *parent) +{ + //WHIT(); + ////CONTACTS_LOGGING_LOG(LOGGING_LOG_PHONETIC_NAME); //DO NOT REMOVE!!! + + Evas_Object *layout = NULL; + WEditfield *editfield = NULL; + Evas_Object *entry = NULL; + const char *phoneticName = NULL; + + std::string contactsEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + layout = elm_layout_add(parent); + CtThemeMgr::getInstance()->setObjectTheme(layout); + elm_layout_file_set(layout, contactsEdjePath.c_str(), "baseinfo_sub_layout"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0.0); + evas_object_show(layout); + + phoneticName = item->__inputData->getPhoneticLastName(); + + if (phoneticName && *phoneticName) { + editfield = item->createEditField(layout, NULL, false); + } + else { + // TODO: language translation + editfield = item->createEditField(layout, V_("IDS_PB_BODY_PHONETIC_LAST_NAME_ABB"), false); + } + + entry = editfield->getEntry(); + elm_object_part_content_set(layout, "elm.icon.1", editfield->getEvasObj()); + + elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_WORD); + + evas_object_smart_callback_add(entry, "changed", __basicInfoPhoneticLastNameChangedCb, item); + evas_object_smart_callback_add(entry, "preedit,changed", __basicInfoPhoneticLastNameChangedCb, item); + evas_object_smart_callback_add(entry, "activated", __activatedCb, item); + + setEntryText(entry, phoneticName); + return layout; +} + +Evas_Object* CtInputViewBasicInfoItem::__createNicknameField(CtInputViewBasicInfoItem* item, Evas_Object *parent) +{ + //WHIT(); + Evas_Object *layout = NULL; + WEditfield *editfield = NULL; + Evas_Object *entry = NULL; + const char *nickname = NULL; + + std::string contactsEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + layout = elm_layout_add(parent); + CtThemeMgr::getInstance()->setObjectTheme(layout); + elm_layout_file_set(layout, contactsEdjePath.c_str(), "baseinfo_sub_layout"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0.0); + evas_object_show(layout); + + nickname = item->__inputData->getNickname(); + + if (nickname && *nickname) { + editfield = item->createEditField(layout, NULL, false); + } + else { + editfield = item->createEditField(layout, V_("IDS_PB_BODY_NICKNAME_ABB"), false); + } + + entry = editfield->getEntry(); + elm_object_part_content_set(layout, "elm.icon.1", editfield->getEvasObj()); + + elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_WORD); + + evas_object_smart_callback_add(entry, "changed", __basicInfoNicknameChangedCb, item); + evas_object_smart_callback_add(entry, "preedit,changed", __basicInfoNicknameChangedCb, item); + evas_object_smart_callback_add(entry, "activated", __activatedCb, item); + if (INPUT_ADDED_ITEM_INDEX_NICKNAME == item->__addedIndex ) { + if (item->__isRealized) { + elm_object_focus_set(entry, EINA_TRUE); + item->__addedIndex = INPUT_ADDED_ITEM_INDEX_NONE; + } else { + item->__focusEntry = entry; + } + } + + setEntryText(entry, nickname); + + Evas_Object* btn_minus = elm_button_add(layout); + elm_object_style_set(btn_minus, "icon_expand_delete"); + elm_object_part_content_set(layout, "elm.icon.2", btn_minus); + evas_object_smart_callback_add(btn_minus, "clicked", __nicknameDeleteCb, item); + return layout; +} + +Evas_Object* CtInputViewBasicInfoItem::__createCompanyField(CtInputViewBasicInfoItem* item, Evas_Object *parent) +{ + //WHIT(); + Evas_Object *layout = NULL; + WEditfield *editfield = NULL; + Evas_Object *entry = NULL; + const char *company = NULL; + + std::string contactsEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + layout = elm_layout_add(parent); + CtThemeMgr::getInstance()->setObjectTheme(layout); + elm_layout_file_set(layout, contactsEdjePath.c_str(), "baseinfo_sub_layout"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0.0); + evas_object_show(layout); + + company = item->__inputData->getCompany(); + + if (company && *company) { + editfield = item->createEditField(layout, NULL, false); + } + else { + editfield = item->createEditField(layout, V_("IDS_PB_BODY_COMPANY_ABB"), false); + } + + entry = editfield->getEntry(); + elm_object_part_content_set(layout, "elm.icon.1", editfield->getEvasObj()); + + elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_WORD); + + evas_object_smart_callback_add(entry, "changed", __basicInfoCompanyChangedCb, item); + evas_object_smart_callback_add(entry, "preedit,changed", __basicInfoCompanyChangedCb, item); + evas_object_smart_callback_add(entry, "activated", __activatedCb, item); + if (INPUT_ADDED_ITEM_INDEX_ORGANIZATION == item->__addedIndex ) { + if (item->__isRealized) { + elm_object_focus_set(entry, EINA_TRUE); + item->__addedIndex = INPUT_ADDED_ITEM_INDEX_NONE; + } else { + item->__focusEntry = entry; + } + } + + setEntryText(entry, company); + + Evas_Object* btn_minus = elm_button_add(layout); + elm_object_style_set(btn_minus, "icon_expand_delete"); + elm_object_part_content_set(layout, "elm.icon.2", btn_minus); + evas_object_smart_callback_add(btn_minus, "clicked", __organizationDeleteCb, item); + + return layout; +} + +Evas_Object* CtInputViewBasicInfoItem::__createJobTitleField(CtInputViewBasicInfoItem* item, Evas_Object *parent) +{ + //WHIT(); + Evas_Object *layout = NULL; + WEditfield *editfield = NULL; + Evas_Object *entry = NULL; + const char *jobTitle = NULL; + + std::string contactsEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + layout = elm_layout_add(parent); + CtThemeMgr::getInstance()->setObjectTheme(layout); + elm_layout_file_set(layout, contactsEdjePath.c_str(), "baseinfo_sub_layout"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0.0); + evas_object_show(layout); + + jobTitle = item->__inputData->getJobTitle(); + + if (jobTitle && *jobTitle) { + editfield = item->createEditField(layout, NULL, false); + } + else { + editfield = item->createEditField(layout, V_("IDS_PB_BODY_JOB_TITLE_ABB"), false); + } + + entry = editfield->getEntry(); + elm_object_part_content_set(layout, "elm.icon.1", editfield->getEvasObj()); + + elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_WORD); + + evas_object_smart_callback_add(entry, "changed", __basicInfoJobTitleChangedCb, item); + evas_object_smart_callback_add(entry, "preedit,changed", __basicInfoJobTitleChangedCb, item); + evas_object_smart_callback_add(entry, "activated", __activatedCb, item); + + setEntryText(entry, jobTitle); + return layout; +} + +void CtInputViewBasicInfoItem::__basicInfoExpandClickedCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + CtInputViewBasicInfoItem* item = (CtInputViewBasicInfoItem*)data; + item->__baseInfoExpanded = !item->__baseInfoExpanded; + item->__addedIndex = INPUT_ADDED_ITEM_INDEX_NONE; + + Elm_Genlist_Item_Class* itc = item->getItemClassStatic(); + if( item->__baseInfoExpanded) + { + itc->item_style = "baseinfo.expand"; + } + else + { + itc->item_style = "baseinfo.contract"; + } + + Evas_Object* box = NULL; + box = elm_object_item_part_content_get(item->getElmObjectItem(), "elm.icon.1"); + if (box) { + elm_box_clear(box); + } + + item->__updateItem = true; + elm_genlist_item_item_class_update( (Elm_Object_Item*)item->getElmObjectItem(), itc ); + + elm_object_item_signal_emit((Elm_Object_Item*)item->getElmObjectItem(), "image,enable", ""); +} + +void CtInputViewBasicInfoItem::__basicInfoImageClickedCb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + CtInputViewBasicInfoItem* item = (CtInputViewBasicInfoItem*)data; + elm_object_item_signal_emit(item->getElmObjectItem(), "play_sound", "elm.icon.2"); + item->__imageClickedCb( obj ); +} + +void CtInputViewBasicInfoItem::__subItemResizeCb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + Evas_Coord height = 0; + evas_object_geometry_get(obj, NULL, NULL, NULL, &height); + evas_object_event_callback_del(obj, EVAS_CALLBACK_RESIZE, CtInputViewBasicInfoItem::__subItemResizeCb); + CtInputViewBasicInfoItem *self = (CtInputViewBasicInfoItem *)data; + self->__subItemSize = height; + self->__baseInfoExpanded = self->__oldBaseInfoExpanded; + + elm_genlist_item_update(self->getElmObjectItem()); +} + +void CtInputViewBasicInfoItem::__onFontChangedCb(system_settings_key_e key, void *user_data) +{ + CtInputViewBasicInfoItem *self = (CtInputViewBasicInfoItem *)user_data; + self->__subItemSize = 0; + + self->__oldBaseInfoExpanded = self->__baseInfoExpanded; + if(!self->__baseInfoExpanded) { + self->__baseInfoExpanded = true; + } + + elm_genlist_item_update(self->getElmObjectItem()); +} + +bool CtInputViewBasicInfoItem::__compareWithOldVal(const char* text, const char* oldVal) +{ + WPRET_VM(NULL == text, false, "text is NULL"); + bool ret = false; + if (NULL == oldVal) { + if (SAFE_STRLEN(text)) { + ret = true; + } + else { + ret = false; + } + } + else { + if (!strcmp(text, oldVal)) { + ret = false; + } + else { + ret = true; + } + } + return ret; +} + +void CtInputViewBasicInfoItem::__entryTextChanged( Evas_Object* obj, int changedInfo ) +{ + WHIT(); + char *text = NULL; + ITEM_CHANGED info = (ITEM_CHANGED)changedInfo; + + switch( info ) + { + case NAME_CHANGED: + { + text = ctCommonMarkupToUtf8(elm_entry_entry_get(obj)); + std::string name; + __inputData->getFullName(name); + if(!(name.size() > 0 && text && strcmp(name.c_str(), text) == 0)) { + __inputData->setFullName(text); + } + __fullNameIsChanged = __compareWithOldVal(text, __oldFullName); + if (SAFE_STRLEN(text)) { + __fullNameIsEmpty = false; + } + else { + __fullNameIsEmpty = true; + } + } + break; + case PREFIX_CHANGED: + { + text = ctCommonMarkupToUtf8(elm_entry_entry_get(obj)); + __inputData->setPrefixName(text); + __prefixIsChanged = __compareWithOldVal(text, __oldPrefix); + if (SAFE_STRLEN(text)) { + __prefixIsEmpty = false; + } + else { + __prefixIsEmpty = true; + } + } + break; + case FIRST_NAME_CHANGED: + { + text = ctCommonMarkupToUtf8(elm_entry_entry_get(obj)); + __inputData->setFirstName(text); + __firstNameIsChanged = __compareWithOldVal(text, __oldFirstName); + if (SAFE_STRLEN(text)) { + __firstNameIsEmpty = false; + } + else { + __firstNameIsEmpty = true; + } + } + break; + case MIDDLE_NAME_CHANGED: + { + text = ctCommonMarkupToUtf8(elm_entry_entry_get(obj)); + __inputData->setMiddleName(text); + __middleNameIsChanged = __compareWithOldVal(text, __oldMiddleName); + if (SAFE_STRLEN(text)) { + __middleNameIsEmpty = false; + } + else { + __middleNameIsEmpty = true; + } + } + break; + case LAST_NAME_CHANGED: + { + text = ctCommonMarkupToUtf8(elm_entry_entry_get(obj)); + __inputData->setLastName(text); + __lastNameIsChanged = __compareWithOldVal(text, __oldLastName); + if (SAFE_STRLEN(text)) { + __lastNameIsEmpty = false; + } + else { + __lastNameIsEmpty = true; + } + } + break; + case SUFFIX_CHANGED: + { + text = ctCommonMarkupToUtf8(elm_entry_entry_get(obj)); + __inputData->setSuffixName(text); + __suffixIsChanged = __compareWithOldVal(text, __oldSuffix); + if (SAFE_STRLEN(text)) { + __suffixIsEmpty = false; + } + else { + __suffixIsEmpty = true; + } + } + break; + case PHONETIC_FIRST_NAME_CHANGED: + { + text = ctCommonMarkupToUtf8(elm_entry_entry_get(obj)); + __inputData->setPhoneticFirstName(text); + __phoneticFirstNameIsChanged = __compareWithOldVal(text, __oldPhoneticFirstName); + if (SAFE_STRLEN(text)) { + __phoneticFirstNameIsEmpty = false; + } + else { + __phoneticFirstNameIsEmpty = true; + } + } + break; + case PHONETIC_MIDDLE_NAME_CHANGED: + { + text = ctCommonMarkupToUtf8(elm_entry_entry_get(obj)); + __inputData->setPhoneticMiddleName(text); + __phoneticMiddleNameIsChanged = __compareWithOldVal(text, __oldPhoneticMiddleName); + if (SAFE_STRLEN(text)) { + __phoneticMiddleNameIsEmpty = false; + } + else { + __phoneticMiddleNameIsEmpty = true; + } + } + break; + case PHONETIC_LAST_NAME_CHANGED: + { + text = ctCommonMarkupToUtf8(elm_entry_entry_get(obj)); + __inputData->setPhoneticLastName(text); + __phoneticLastNameIsChanged = __compareWithOldVal(text, __oldPhoneticLastName); + if (SAFE_STRLEN(text)) { + __phoneticLastNameIsEmpty = false; + } + else { + __phoneticLastNameIsEmpty = true; + } + } + break; + case NICKNAME_CHANGED: + { + text = ctCommonMarkupToUtf8(elm_entry_entry_get(obj)); + __inputData->setNickname(text); + __nicknameIsChanged = __compareWithOldVal(text, __oldNickname); + if (SAFE_STRLEN(text)) { + __nicknameIsEmpty = false; + } + else { + __nicknameIsEmpty = true; + } + } + break; + case COMPANY_CHANGED: + { + text = ctCommonMarkupToUtf8(elm_entry_entry_get(obj)); + __inputData->setCompany(text); + __companyIsChanged = __compareWithOldVal(text, __oldCompany); + if (SAFE_STRLEN(text)) { + __companyIsEmpty = false; + } + else { + __companyIsEmpty = true; + } + } + break; + case JOB_TITLE_CHANGED: + { + text = ctCommonMarkupToUtf8(elm_entry_entry_get(obj)); + __inputData->setJobTitle(text); + __jobTitleIsChanged = __compareWithOldVal(text, __oldJobTitle); + if (SAFE_STRLEN(text)) { + __jobTitleIsEmpty = false; + } + else { + __jobTitleIsEmpty = true; + } + } + break; + default: + WERROR("Not handled case =%d", changedInfo); + break; + } + SAFE_FREE(text); +} + +void CtInputViewBasicInfoItem::__basicInfoNameChangedCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + CtInputViewBasicInfoItem* item = (CtInputViewBasicInfoItem*)data; + item->__entryTextChanged( obj, NAME_CHANGED ); + item->__itemChangedCb(); + item->__updateEntryReturnKeyType(NULL); + + // this code is for fixing the text blink issue when touch expand button + const char* entryText = elm_entry_entry_get(obj); + if (!(entryText && *entryText)) { + elm_object_domain_translatable_part_text_set(obj, "elm.guide", PACKAGE, "IDS_PB_BODY_NAME"); + } +} + +void CtInputViewBasicInfoItem::__basicInfoPrefixChangedCb(void *data, Evas_Object *obj, void *event_info) +{ + CtInputViewBasicInfoItem* item = (CtInputViewBasicInfoItem*)data; + item->__entryTextChanged( obj, PREFIX_CHANGED ); + item->__itemChangedCb(); + + // this code is for fixing the text blink issue when touch expand button + const char* entryText = elm_entry_entry_get(obj); + if (!(entryText && *entryText)) { + elm_object_domain_translatable_part_text_set(obj, "elm.guide", PACKAGE, "IDS_PB_BODY_TITLE_M_NAMEPREFIX"); + } +} + +void CtInputViewBasicInfoItem::__basicInfoFirstNameChangedCb(void *data, Evas_Object *obj, void *event_info) +{ + CtInputViewBasicInfoItem* item = (CtInputViewBasicInfoItem*)data; + item->__entryTextChanged( obj, FIRST_NAME_CHANGED ); + item->__itemChangedCb(); + + // this code is for fixing the text blink issue when touch expand button + const char* entryText = elm_entry_entry_get(obj); + if (!(entryText && *entryText)) { + elm_object_domain_translatable_part_text_set(obj, "elm.guide", PACKAGE, "IDS_PB_OPT_FIRST_NAME"); + } +} + +void CtInputViewBasicInfoItem::__basicInfoMiddleNameChangedCb(void *data, Evas_Object *obj, void *event_info) +{ + CtInputViewBasicInfoItem* item = (CtInputViewBasicInfoItem*)data; + item->__entryTextChanged( obj, MIDDLE_NAME_CHANGED ); + item->__itemChangedCb(); + + // this code is for fixing the text blink issue when touch expand button + const char* entryText = elm_entry_entry_get(obj); + if (!(entryText && *entryText)) { + elm_object_domain_translatable_part_text_set(obj, "elm.guide", PACKAGE, "IDS_PB_BODY_MIDDLE_NAME_ABB"); + } +} + +void CtInputViewBasicInfoItem::__basicInfoLastNameChangedCb(void *data, Evas_Object *obj, void *event_info) +{ + CtInputViewBasicInfoItem* item = (CtInputViewBasicInfoItem*)data; + item->__entryTextChanged( obj, LAST_NAME_CHANGED ); + item->__itemChangedCb(); + + // this code is for fixing the text blink issue when touch expand button + const char* entryText = elm_entry_entry_get(obj); + if (!(entryText && *entryText)) { + elm_object_domain_translatable_part_text_set(obj, "elm.guide", PACKAGE, "IDS_PB_BODY_LAST_NAME_ABB"); + } +} +void CtInputViewBasicInfoItem::__basicInfoSuffixChangedCb(void *data, Evas_Object *obj, void *event_info) +{ + CtInputViewBasicInfoItem* item = (CtInputViewBasicInfoItem*)data; + item->__entryTextChanged( obj, SUFFIX_CHANGED ); + item->__itemChangedCb(); + + // this code is for fixing the text blink issue when touch expand button + const char* entryText = elm_entry_entry_get(obj); + if (!(entryText && *entryText)) { + elm_object_domain_translatable_part_text_set(obj, "elm.guide", PACKAGE, "IDS_PB_BODY_NAME_SUFFIX_ABB"); + } +} + +void CtInputViewBasicInfoItem::__basicInfoPhoneticFirstNameChangedCb(void *data, Evas_Object *obj, void *event_info) +{ + CtInputViewBasicInfoItem* item = (CtInputViewBasicInfoItem*)data; + item->__entryTextChanged( obj, PHONETIC_FIRST_NAME_CHANGED ); + item->__itemChangedCb(); + + // this code is for fixing the text blink issue when touch expand button + const char* entryText = elm_entry_entry_get(obj); + if (!(entryText && *entryText)) { + // TODO: language translation + elm_object_domain_translatable_part_text_set(obj, "elm.guide", PACKAGE, "IDS_PB_BODY_PHONETIC_FIRST_NAME_ABB"); + } +} + +void CtInputViewBasicInfoItem::__basicInfoPhoneticMiddleNameChangedCb(void *data, Evas_Object *obj, void *event_info) +{ + CtInputViewBasicInfoItem* item = (CtInputViewBasicInfoItem*)data; + item->__entryTextChanged( obj, PHONETIC_MIDDLE_NAME_CHANGED ); + item->__itemChangedCb(); + + // this code is for fixing the text blink issue when touch expand button + const char* entryText = elm_entry_entry_get(obj); + if (!(entryText && *entryText)) { + // TODO: language translation + elm_object_domain_translatable_part_text_set(obj, "elm.guide", PACKAGE, "IDS_PB_BODY_PHONETIC_MIDDLE_NAME_ABB"); + } +} + +void CtInputViewBasicInfoItem::__basicInfoPhoneticLastNameChangedCb(void *data, Evas_Object *obj, void *event_info) +{ + CtInputViewBasicInfoItem* item = (CtInputViewBasicInfoItem*)data; + item->__entryTextChanged( obj, PHONETIC_LAST_NAME_CHANGED ); + item->__itemChangedCb(); + + // this code is for fixing the text blink issue when touch expand button + const char* entryText = elm_entry_entry_get(obj); + if (!(entryText && *entryText)) { + // TODO: language translation + elm_object_domain_translatable_part_text_set(obj, "elm.guide", PACKAGE, "IDS_PB_BODY_PHONETIC_LAST_NAME_ABB"); + } +} + +void CtInputViewBasicInfoItem::__basicInfoNicknameChangedCb(void *data, Evas_Object *obj, void *event_info) +{ + CtInputViewBasicInfoItem* item = (CtInputViewBasicInfoItem*)data; + item->__entryTextChanged( obj, NICKNAME_CHANGED ); + item->__itemChangedCb(); + + // this code is for fixing the text blink issue when touch expand button + const char* entryText = elm_entry_entry_get(obj); + if (!(entryText && *entryText)) { + elm_object_domain_translatable_part_text_set(obj, "elm.guide", PACKAGE, "IDS_PB_BODY_NICKNAME_ABB"); + } +} + +void CtInputViewBasicInfoItem::__basicInfoCompanyChangedCb(void *data, Evas_Object *obj, void *event_info) +{ + CtInputViewBasicInfoItem* item = (CtInputViewBasicInfoItem*)data; + item->__entryTextChanged( obj, COMPANY_CHANGED ); + item->__itemChangedCb(); + + // this code is for fixing the text blink issue when touch expand button + const char* entryText = elm_entry_entry_get(obj); + if (!(entryText && *entryText)) { + elm_object_domain_translatable_part_text_set(obj, "elm.guide", PACKAGE, "IDS_PB_BODY_COMPANY_ABB"); + } +} + +void CtInputViewBasicInfoItem::__basicInfoJobTitleChangedCb(void *data, Evas_Object *obj, void *event_info) +{ + CtInputViewBasicInfoItem* item = (CtInputViewBasicInfoItem*)data; + item->__entryTextChanged( obj, JOB_TITLE_CHANGED ); + item->__itemChangedCb(); + + // this code is for fixing the text blink issue when touch expand button + const char* entryText = elm_entry_entry_get(obj); + if (!(entryText && *entryText)) { + elm_object_domain_translatable_part_text_set(obj, "elm.guide", PACKAGE, "IDS_PB_BODY_JOB_TITLE_ABB"); + } +} + +void CtInputViewBasicInfoItem::__activatedCb(void *data, Evas_Object *obj, void *event_info) +{ + CtInputViewBasicInfoItem* item = (CtInputViewBasicInfoItem*)data; + Evas_Object* entry = NULL; + Evas_Object* box = NULL; + Eina_List* list = NULL; + Eina_List* cursor = NULL; + Evas_Object* layout = NULL; + bool find = false; + Evas_Object* focusedEntry = NULL; + void *tmp = NULL; + + box = elm_object_item_part_content_get(item->getElmObjectItem(), "elm.icon.1"); + if (box) { + list = elm_box_children_get(box); + EINA_LIST_FOREACH(list, cursor, tmp) { + layout = (Evas_Object*)tmp; + if (layout) { + entry = elm_object_part_content_get(layout, "elm.icon.1"); + if (find) { + focusedEntry = entry; + break; + } + + if (entry == obj) { + find = true; + } + } + } + } + + if (focusedEntry) { + elm_object_focus_set(focusedEntry, EINA_TRUE); + } + else { + item->__activateNextEntryCb( entry, item->getElmObjectItem() ); + } +} + +void CtInputViewBasicInfoItem::__basicInfoNameShowCb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + WHIT(); + CtInputViewBasicInfoItem* item = (CtInputViewBasicInfoItem*)data; + evas_object_event_callback_del_full( obj, EVAS_CALLBACK_SHOW, __basicInfoNameShowCb, item ); + + item->__showCreateKeypadCb( obj ); +} + +void CtInputViewBasicInfoItem::__basicInfoSuffixShowCb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + WHIT(); + CtInputViewBasicInfoItem* item = (CtInputViewBasicInfoItem*)data; + evas_object_event_callback_del_full( obj, EVAS_CALLBACK_SHOW, __basicInfoSuffixShowCb, item ); + + Evas_Object* entry = NULL; + Evas_Object* box = NULL; + Eina_List* list = NULL; + Eina_List* cursor = NULL; + void *tmp = NULL; + Evas_Object* layout = NULL; + if (item->__inputData->getContactId() == 0 && item->__updateItem) { + box = elm_object_item_part_content_get(item->getElmObjectItem(), "elm.icon.1"); + if (box) { + list = elm_box_children_get(box); + EINA_LIST_FOREACH(list, cursor, tmp) { + layout = (Evas_Object*)tmp; + if (layout) { + entry = elm_object_part_content_get(layout, "elm.icon.1"); + if (entry) { + elm_object_focus_set(entry, EINA_TRUE); + elm_entry_cursor_end_set(entry); + break; + } + } + } + } + item->__updateItem = false; + } + item->__updateEntryReturnKeyType(NULL); +} + +void CtInputViewBasicInfoItem::__phoneticNameDeleteCb(void *data, Evas_Object *obj, void *event_info) +{ + CtInputViewBasicInfoItem* item = (CtInputViewBasicInfoItem*)data; + item->__itemDeletedCb( PHONETIC_NAME_DELETED ); + item->__phoneticFirstNameIsEmpty = true; + item->__phoneticMiddleNameIsEmpty = true; + item->__phoneticLastNameIsEmpty = true; + elm_genlist_item_fields_update( item->getElmObjectItem(), "elm.icon.1", ELM_GENLIST_ITEM_FIELD_CONTENT); +} + +void CtInputViewBasicInfoItem::__nicknameDeleteCb(void *data, Evas_Object *obj, void *event_info) +{ + CtInputViewBasicInfoItem* item = (CtInputViewBasicInfoItem*)data; + item->__itemDeletedCb( NICKNAME_DELETED ); + item->__nicknameIsEmpty = true; + elm_genlist_item_fields_update( item->getElmObjectItem(), "elm.icon.1", ELM_GENLIST_ITEM_FIELD_CONTENT); +} + +void CtInputViewBasicInfoItem::__organizationDeleteCb(void *data, Evas_Object *obj, void *event_info) +{ + CtInputViewBasicInfoItem* item = (CtInputViewBasicInfoItem*)data; + item->__itemDeletedCb( ORGANIZATION_DELETED ); + item->__companyIsEmpty = true; + item->__jobTitleIsEmpty = true; + elm_genlist_item_fields_update( item->getElmObjectItem(), "elm.icon.1", ELM_GENLIST_ITEM_FIELD_CONTENT); +} + +bool CtInputViewBasicInfoItem::getIsChanged() +{ + WHIT(); + bool ret = false; + + const char* imagePath = __inputData->getImagePath(); + bool imagePathIsChanged = __compareWithOldVal(imagePath ? imagePath : "", __oldImagePath); + + if (__baseInfoExpanded) { + if (true == __prefixIsChanged + || true == __firstNameIsChanged + || true == __middleNameIsChanged + || true == __lastNameIsChanged + || true == __suffixIsChanged + || true == __phoneticFirstNameIsChanged + || true == __phoneticMiddleNameIsChanged + || true == __phoneticLastNameIsChanged + || true == __nicknameIsChanged + || true == __companyIsChanged + || true == __jobTitleIsChanged + || true == imagePathIsChanged) { + ret = true; + } + } else { + if (true == __fullNameIsChanged + || true == __phoneticFirstNameIsChanged + || true == __phoneticMiddleNameIsChanged + || true == __phoneticLastNameIsChanged + || true == __nicknameIsChanged + || true == __companyIsChanged + || true == __jobTitleIsChanged + || true == imagePathIsChanged) { + ret = true; + } + } + return ret; +} + +void CtInputViewBasicInfoItem::setPhoneticNameIsChanged(bool val) +{ + __phoneticFirstNameIsChanged = val; + __phoneticMiddleNameIsChanged = val; + __phoneticLastNameIsChanged = val; +} + +bool CtInputViewBasicInfoItem::getPhoneticNameIsChanged() +{ + if (__phoneticFirstNameIsChanged || __phoneticMiddleNameIsChanged || __phoneticLastNameIsChanged) { + return true; + } + else { + return false; + } +} + +void CtInputViewBasicInfoItem::setNicknameIsChanged(bool val) +{ + __nicknameIsChanged = val; +} + +bool CtInputViewBasicInfoItem::getNicknameIsChanged() +{ + return __nicknameIsChanged; +} + +void CtInputViewBasicInfoItem::setCompanyIsChanged(bool val) +{ + __companyIsChanged = val; +} + +bool CtInputViewBasicInfoItem::getCompanyIsChanged() +{ + return __companyIsChanged; +} + +void CtInputViewBasicInfoItem::setJobTitleIsChanged(bool val) +{ + __jobTitleIsChanged = val; +} + +bool CtInputViewBasicInfoItem::getJobTitleIsChanged() +{ + return __jobTitleIsChanged; +} + +bool CtInputViewBasicInfoItem::getIsEmpty() +{ + WHIT(); + bool ret = true; + if (__baseInfoExpanded) { + if (false == __prefixIsEmpty + || false == __firstNameIsEmpty + || false == __middleNameIsEmpty + || false == __lastNameIsEmpty + || false == __suffixIsEmpty + || false == __phoneticFirstNameIsEmpty + || false == __phoneticMiddleNameIsEmpty + || false == __phoneticLastNameIsEmpty + || false == __nicknameIsEmpty + || false == __companyIsEmpty + || false == __jobTitleIsEmpty) { + ret = false; + } + } else { + if (false == __fullNameIsEmpty + || false == __phoneticFirstNameIsEmpty + || false == __phoneticMiddleNameIsEmpty + || false == __phoneticLastNameIsEmpty + || false == __nicknameIsEmpty + || false == __companyIsEmpty + || false == __jobTitleIsEmpty) { + ret = false; + } + } + return ret; +} + +bool CtInputViewBasicInfoItem::getAddPhoneticName() +{ + return __addPhoneticName; +} + +void CtInputViewBasicInfoItem::setAddPhoneticName(bool addPhoneticName) +{ + __addPhoneticName = addPhoneticName; +} + +bool CtInputViewBasicInfoItem::getAddNickname() +{ + return __addNickname; +} + +void CtInputViewBasicInfoItem::setAddNickname(bool addNickname) +{ + __addNickname = addNickname; +} + +bool CtInputViewBasicInfoItem::getAddOrganization() +{ + return __addOrganization; +} + +void CtInputViewBasicInfoItem::setAddOrganization(bool addOrganization) +{ + __addOrganization = addOrganization; +} + +void CtInputViewBasicInfoItem::setAddedIndex(int addedIndex) +{ + __addedIndex = addedIndex; +} + +void CtInputViewBasicInfoItem::onRealized() +{ + __isRealized = true; + if (__focusEntry) { + elm_object_focus_set(__focusEntry, EINA_TRUE); + __focusEntry = NULL; + __addedIndex = INPUT_ADDED_ITEM_INDEX_NONE; + } +} + +void CtInputViewBasicInfoItem::onUnrealized() +{ + __isRealized = false; + __focusEntry = NULL; +} diff --git a/lib-contact/ct-detail/src/CtInputViewBasicInfoItem.h b/lib-contact/ct-detail/src/CtInputViewBasicInfoItem.h new file mode 100644 index 0000000..8fe2d5e --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputViewBasicInfoItem.h @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_INPUT_VIEW_BASIC_INFO_ITEM_H_ +#define _CT_INPUT_VIEW_BASIC_INFO_ITEM_H_ + +#include <functional> +#include "CtCommon.h" +#include "CtInputViewGenlistItem.h" +#include "CtInputViewControl.h" +#include "CtData.h" + +class CtInputView; +class CtInputData; + +class CtInputViewBasicInfoItem : public CtInputViewGenlistItem +{ +public: + enum ITEM_DELETED + { + PHONETIC_NAME_DELETED, + NICKNAME_DELETED, + ORGANIZATION_DELETED, + }; + + enum ITEM_CHANGED + { + NAME_CHANGED, + PREFIX_CHANGED, + FIRST_NAME_CHANGED, + MIDDLE_NAME_CHANGED, + LAST_NAME_CHANGED, + SUFFIX_CHANGED, + PHONETIC_FIRST_NAME_CHANGED, + PHONETIC_MIDDLE_NAME_CHANGED, + PHONETIC_LAST_NAME_CHANGED, + NICKNAME_CHANGED, + COMPANY_CHANGED, + JOB_TITLE_CHANGED + }; + CtInputViewBasicInfoItem(std::shared_ptr<CtData>& inputData, Evas_Object** nameEntry, + const std::function<void ()>& itemChangedCb, + const std::function<void (CtInputViewBasicInfoItem::ITEM_DELETED)>& itemDeletedCb, + const std::function<void (Evas_Object*)>& imageClickedCb, + const std::function<void (Evas_Object*, Elm_Object_Item* )>& activateNextEntryCb, + const std::function<void (Evas_Object*)>& showCreateKeypadCb, + const std::function<void (Elm_Object_Item* )>& updateEntryReturnKeyType); + + virtual ~CtInputViewBasicInfoItem(); + +public: + virtual Elm_Genlist_Item_Class* getItemClassStatic(); + + virtual bool getIsChanged(); + virtual bool getIsEmpty(); + void setPhoneticNameIsChanged(bool val); + bool getPhoneticNameIsChanged(); + void setNicknameIsChanged(bool val); + bool getNicknameIsChanged(); + void setCompanyIsChanged(bool val); + bool getCompanyIsChanged(); + void setJobTitleIsChanged(bool val); + bool getJobTitleIsChanged(); + + bool getAddPhoneticName(); + void setAddPhoneticName(bool addPhoneticName); + bool getAddNickname(); + void setAddNickname(bool addNickname); + bool getAddOrganization(); + void setAddOrganization(bool addOrganization); + void setAddedIndex(int addedIndex); + + virtual void onRealized(); + virtual void onUnrealized(); +private: + void __initialize(); + + static Evas_Object* __getContentBasicInfo(void *data, Evas_Object *obj, const char *part); + static Evas_Object* __createNameField(CtInputViewBasicInfoItem* item, Evas_Object *parent); + static Evas_Object* __createPrefixField( CtInputViewBasicInfoItem* item, Evas_Object *parent); + static Evas_Object* __createFirstNameField(CtInputViewBasicInfoItem* item, Evas_Object *parent); + static Evas_Object* __createMiddleNameField(CtInputViewBasicInfoItem* item, Evas_Object *parent); + static Evas_Object* __createLastNameField(CtInputViewBasicInfoItem* item, Evas_Object *parent); + static Evas_Object* __createSuffixField(CtInputViewBasicInfoItem* item, Evas_Object *parent); + static Evas_Object* __createPhoneticFirstNameField(CtInputViewBasicInfoItem* item, Evas_Object *parent); + static Evas_Object* __createPhoneticMiddleNameField(CtInputViewBasicInfoItem* item, Evas_Object *parent); + static Evas_Object* __createPhoneticLastNameField(CtInputViewBasicInfoItem* item, Evas_Object *parent); + static Evas_Object* __createNicknameField(CtInputViewBasicInfoItem* item, Evas_Object *parent); + static Evas_Object* __createCompanyField(CtInputViewBasicInfoItem* item, Evas_Object *parent); + static Evas_Object* __createJobTitleField(CtInputViewBasicInfoItem* item, Evas_Object *parent); + static void __set_entry_text(Evas_Object *entry, const char *text); + static Evas_Object* __createEditField(Evas_Object *parent, const char *guideText, bool multiline, + Evas_Smart_Cb unfocusedCallback, void *userData1, Evas_Smart_Cb focusedCallback, void *userData2); + static void __onEditfieldTextMaxReached(void *data, Evas_Object *obj, void *event_info); + static void __basicInfoExpandClickedCb(void *data, Evas_Object *obj, void *event_info); + + static void __basicInfoImageClickedCb(void *data, Evas *e, Evas_Object *obj, void *event_info); + static void __subItemResizeCb(void *data, Evas *e, Evas_Object *obj, void *event_info); + static void __onFontChangedCb(system_settings_key_e key, void *user_data); + + bool __compareWithOldVal(const char* text, const char* oldVal); + void __entryTextChanged( Evas_Object* obj, int changedInfo ); + static void __basicInfoNameChangedCb(void *data, Evas_Object *obj, void *event_info); + static void __basicInfoPrefixChangedCb(void *data, Evas_Object *obj, void *event_info); + static void __basicInfoFirstNameChangedCb(void *data, Evas_Object *obj, void *event_info); + static void __basicInfoMiddleNameChangedCb(void *data, Evas_Object *obj, void *event_info); + static void __basicInfoLastNameChangedCb(void *data, Evas_Object *obj, void *event_info); + static void __basicInfoSuffixChangedCb(void *data, Evas_Object *obj, void *event_info); + static void __basicInfoPhoneticFirstNameChangedCb(void *data, Evas_Object *obj, void *event_info); + static void __basicInfoPhoneticMiddleNameChangedCb(void *data, Evas_Object *obj, void *event_info); + static void __basicInfoPhoneticLastNameChangedCb(void *data, Evas_Object *obj, void *event_info); + static void __basicInfoNicknameChangedCb(void *data, Evas_Object *obj, void *event_info); + static void __basicInfoCompanyChangedCb(void *data, Evas_Object *obj, void *event_info); + static void __basicInfoJobTitleChangedCb(void *data, Evas_Object *obj, void *event_info); + static void __activatedCb(void *data, Evas_Object *obj, void *event_info); + static void __basicInfoNameShowCb(void *data, Evas *e, Evas_Object *obj, void *event_info); + static void __basicInfoSuffixShowCb(void *data, Evas *e, Evas_Object *obj, void *event_info); + static void __phoneticNameDeleteCb(void *data, Evas_Object *obj, void *event_info); + static void __nicknameDeleteCb(void *data, Evas_Object *obj, void *event_info); + static void __organizationDeleteCb(void *data, Evas_Object *obj, void *event_info); +private: + CtInputViewBasicInfoItem(); + + int __addedIndex; + std::shared_ptr<CtData> __inputData; + Evas_Object** __nameEntry; + Evas_Object* __focusEntry; + + std::function<void ()> __itemChangedCb; + std::function<void (ITEM_DELETED)> __itemDeletedCb; + + std::function<void (Evas_Object*)> __imageClickedCb; + std::function<void (Evas_Object*, Elm_Object_Item*)> __activateNextEntryCb; + std::function<void (Evas_Object*)> __showCreateKeypadCb; + std::function<void (Elm_Object_Item*)> __updateEntryReturnKeyType; + + bool __oldBaseInfoExpanded; + bool __baseInfoExpanded; + + bool __fullNameIsChanged; + bool __prefixIsChanged; + bool __firstNameIsChanged; + bool __middleNameIsChanged; + bool __lastNameIsChanged; + bool __suffixIsChanged; + bool __phoneticFirstNameIsChanged; + bool __phoneticMiddleNameIsChanged; + bool __phoneticLastNameIsChanged; + bool __nicknameIsChanged; + bool __companyIsChanged; + bool __jobTitleIsChanged; + + bool __fullNameIsEmpty; + bool __prefixIsEmpty; + bool __firstNameIsEmpty; + bool __middleNameIsEmpty; + bool __lastNameIsEmpty; + bool __suffixIsEmpty; + bool __phoneticFirstNameIsEmpty; + bool __phoneticMiddleNameIsEmpty; + bool __phoneticLastNameIsEmpty; + bool __nicknameIsEmpty; + bool __companyIsEmpty; + bool __jobTitleIsEmpty; + + char* __oldFullName; + char* __oldPrefix; + char* __oldFirstName; + char* __oldMiddleName; + char* __oldLastName; + char* __oldSuffix; + char* __oldPhoneticFirstName; + char* __oldPhoneticMiddleName; + char* __oldPhoneticLastName; + char* __oldNickname; + char* __oldCompany; + char* __oldJobTitle; + char* __oldImagePath; + + bool __addPhoneticName; + bool __addNickname; + bool __addOrganization; + bool __updateItem; + bool __isRealized; + + Evas_Coord __subItemSize; +}; + +#endif /* _CT_INPUT_VIEW_BASIC_INFO_ITEM_H_ */ diff --git a/lib-contact/ct-detail/src/CtInputViewControl.cpp b/lib-contact/ct-detail/src/CtInputViewControl.cpp new file mode 100644 index 0000000..3779959 --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputViewControl.cpp @@ -0,0 +1,1639 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <system_settings.h> +#include <app_preference.h> +#include <contacts.h> + +#include "WPopup.h" + +#include "ContactsDebug.h" +#include "ContactsAppControl.h" +#include "ContactsAppControlLauncher.h" + +#include "CtString.h" +#include "CtPath.h" +#include "CtInputData.h" +#include "CtInputViewControl.h" +#include "CtCommon.h" +#include "CtDetailView.h" +#include "CtInputView.h" + +#include "CtInputViewGenlistItem.h" +#include "CtInputViewBasicInfoItem.h" +#include "CtInputViewEmailItem.h" +#include "CtInputViewNoteItem.h" +#include "CtInputViewMessengerItem.h" +#include "CtInputViewAddressItem.h" +#include "CtInputViewWebsiteItem.h" +#include "CtInputViewRelationItem.h" +#include "CtInputViewEventItem.h" +#include "CtInputViewNumberItem.h" +#include "CtInputViewImportantFieldsItem.h" +#include "CtInputViewImportantSubItem.h" +#include "CtThemeMgr.h" +#include "SystemSettingsMgr.h" + +#define GALLERY_UG "ug-gallery-efl" +#define INPUT_CREATE_KEYPAD_TIMER 0.2 +#define DATE_TIME_FORMAT "%%c" + + +CtInputViewControl::CtInputViewControl( std::shared_ptr<CtData>& inputData, CtInputView* view ) +{ + __inputData = inputData; + __view = view; + __initialize(); +} + +CtInputViewControl::~CtInputViewControl() +{ + WHIT(); + + if (__conformant) { + evas_object_smart_callback_del(__conformant, "virtualkeypad,state,on", __onSipUpCb); + evas_object_smart_callback_del(__conformant, "virtualkeypad,state,off", __onSipDownCb); + } + + if (__keypadTimer) { + ecore_timer_del(__keypadTimer); + __keypadTimer = NULL; + } +} + +bool CtInputViewControl::getIsCreate() +{ + return __view->getIsCreate(); +} + +bool CtInputViewControl::getIsEmpty() +{ + return __checkIsEmpty(); +} + +bool CtInputViewControl::getIsChanged() +{ + return __checkIsChanged(); +} + +void CtInputViewControl::updateNumberSaveBtn(Eina_Bool isEmpty) +{ + __view->updateNumberSaveBtn(isEmpty); +} + + +void CtInputViewControl::setIsDestroy(bool isDestroy) +{ + __isDestroy = isDestroy; +} + +Evas_Object* CtInputViewControl::getViewEvasObj() +{ + return __view->getEvasObj(); +} + +Evas_Object* CtInputViewControl::getNaviframeEvasObj() +{ + return __view->getNaviframeEvasObj(); +} + +Evas_Object* CtInputViewControl::onCreate(Evas_Object* parent, void* viewParam) +{ + WENTER(); + Evas_Object* genlist = elm_genlist_add(parent); + evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS); + evas_object_show(genlist); + __genlist = genlist; + + evas_object_smart_callback_add(genlist, "realized", __genlistRealizedCb, this); + evas_object_smart_callback_add(genlist, "unrealized", __genlistUnrealizedCb, this); + __addAllItems(genlist); + + // set virtual keypad + __conformant = __view->getConformantEvasObject(); + if (__conformant) { + evas_object_smart_callback_add(__conformant, "virtualkeypad,state,on", __onSipUpCb, this); + evas_object_smart_callback_add(__conformant, "virtualkeypad,state,off", __onSipDownCb, this); + } + + WLEAVE(); + return genlist; +} + +void CtInputViewControl::onDestroy() +{ + evas_object_smart_callback_del(__genlist, "unrealized", __genlistUnrealizedCb); + evas_object_smart_callback_del(__genlist, "realized", __genlistRealizedCb); + SystemSettingsMgr::getInstance().unregisterChangedCallback(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, __regionFormatChangedCb); +} + +void CtInputViewControl::__initialize() +{ + __changed = false; + __isDestroy = false; + __needResetTheme = false; + __needShowMorePopup = false; + __sipIsShown = false; + __addedIndex = INPUT_ADDED_ITEM_INDEX_NONE; + __keypadTimer = NULL; + + memset( __genlistItems, 0, sizeof(__genlistItems) ); + + __genlist = NULL; + __conformant = NULL; + __birthdayEventExist = std::make_shared<bool> (false); + + + SystemSettingsMgr::getInstance().registerChangedCallback(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, __regionFormatChangedCb, this); +} + +void CtInputViewControl::__regionFormatChangedCb(system_settings_key_e key, void *data) +{ + CtInputViewControl *control = (CtInputViewControl*)data; + char *regionFormat = NULL; + system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, ®ionFormat); + + WDEBUG("regionFormat %s", regionFormat); + + if(control->__genlistItems[INPUT_EVENT]) + elm_genlist_realized_items_update(control->__genlist); +} + +void CtInputViewControl::__addAllItems(Evas_Object* genlist) +{ + WENTER(); + Eina_List *cursor = NULL; + Eina_List *list = NULL; + void *data = NULL; + contacts_record_h record = NULL; + int itemType = 0; + + for (; itemType < INPUT_ITEMS_MAX; itemType++) { + switch(itemType) { + case INPUT_BASIC_INFO: + { + CtInputViewBasicInfoItem *item = new CtInputViewBasicInfoItem(__inputData,&__nameEntry, + [this](){ __itemChanged(); }, + [this](CtInputViewBasicInfoItem::ITEM_DELETED deletedInfo){ __basicInfoItemDeleted( deletedInfo); }, + [this](Evas_Object* obj){ __basicInfoItemImageClicked(obj); }, + [this](Evas_Object* obj, Elm_Object_Item* objItem){ __activateNextEntry(obj, objItem); }, + [this](Evas_Object* obj){ basicInfoItemShowCreateKeypad(obj); }, + [this](Elm_Object_Item* objItem){ __updateEntryReturnKeyType(objItem); }); + Elm_Object_Item *genItem = elm_genlist_item_append(genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[INPUT_BASIC_INFO] = genItem; + break; + } + case INPUT_NUMBER: + { + list = __inputData->getNumberList(); + + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) { + continue; + } + + WDEBUG("added"); + + const char *number = __inputData->getNumberNumber(record); + + CtInputViewNumberItem *item = new CtInputViewNumberItem( this, __inputData, record, number, INPUT_ADDED_ITEM_INDEX_NONE, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* objItem, bool isChanged, contacts_record_h record){ __numberItemDeleted( objItem, isChanged, record ); }, + [this](Evas_Object* obj, Elm_Object_Item* objItem){ __activateNextEntry(obj, objItem); } ); + + Elm_Object_Item *genItem = elm_genlist_item_append(genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[INPUT_NUMBER] = genItem; + } + + if (__view->getIsCreate() && list == NULL) { + WDEBUG("set base number"); + record = __inputData->addNumber(""); + + CtInputViewNumberItem *item = new CtInputViewNumberItem( this, __inputData, record, NULL, INPUT_ADDED_ITEM_INDEX_NONE, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* objItem, bool isChanged, contacts_record_h record){ __numberItemDeleted( objItem, isChanged, record ); }, + [this](Evas_Object* obj, Elm_Object_Item* objItem){ __activateNextEntry(obj, objItem); } ); + + Elm_Object_Item *genItem = elm_genlist_item_append(genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[INPUT_NUMBER] = genItem; + } + break; + } + case INPUT_EMAIL: + { + list = __inputData->getEmailList(); + + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) continue; + + const char *email = __inputData->getEmailEmail(record); + + CtInputViewEmailItem *item = new CtInputViewEmailItem( __inputData, record, email, INPUT_ADDED_ITEM_INDEX_NONE, + [this](){ __itemChanged( ); }, + [this](Elm_Object_Item* objItem, bool isChanged, contacts_record_h record){ __emailItemDeleted( objItem, isChanged, record ); }, + [this](Evas_Object* obj, Elm_Object_Item* objItem){ __activateNextEntry(obj, objItem); } ); + Elm_Object_Item *genItem = elm_genlist_item_append(genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[INPUT_EMAIL] = genItem; + } + break; + } + case INPUT_ADDRESS: + { + list = __inputData->getAddressList(); + + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) { + continue; + } + + char address[CT_TEXT_MAX_LEN] = {0,}; + __inputData->getAddressAddress( record, address, sizeof(address)); + + CtInputViewAddressItem *item = new CtInputViewAddressItem( __inputData, record, address, INPUT_ADDED_ITEM_INDEX_NONE, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* objItem, bool isChanged, contacts_record_h record){ __addressItemDeleted( objItem, isChanged, record ); }, + [this](Evas_Object* obj, Elm_Object_Item* objItem){ __activateNextEntry(obj, objItem); } ); + Elm_Object_Item *genItem = elm_genlist_item_append(genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[INPUT_ADDRESS] = genItem; + } + + break; + } + case INPUT_MESSENGER: + { + list = __inputData->getMessengerList(); + + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) { + continue; + } + + const char *messenger = __inputData->getMessengerMessenger(record); + + CtInputViewMessengerItem *item = new CtInputViewMessengerItem( __inputData, record, messenger, INPUT_ADDED_ITEM_INDEX_NONE, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* objItem, bool isChanged, contacts_record_h record){ __messengerItemDeleted( objItem, isChanged, record ); }, + [this](Evas_Object* obj, Elm_Object_Item* objItem){ __activateNextEntry(obj, objItem); } ); + Elm_Object_Item *genItem = elm_genlist_item_append(genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[INPUT_MESSENGER] = genItem; + } + break; + } + case INPUT_URL: + { + list = __inputData->getWebsiteList(); + + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) { + continue; + } + + const char *website = __inputData->getWebsiteWebsite(record); + + CtInputViewWebsiteItem *item = new CtInputViewWebsiteItem( __inputData, record, website, INPUT_ADDED_ITEM_INDEX_NONE, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* objItem, bool isChanged, contacts_record_h record){ __websiteItemDeleted( objItem, isChanged, record ); }, + [this](Evas_Object* obj, Elm_Object_Item* objItem){__activateNextEntry(obj, objItem); } ); + Elm_Object_Item *genItem = elm_genlist_item_append(genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[INPUT_URL] = genItem; + } + break; + } + case INPUT_RELATIONSHIP: + { + list = __inputData->getRelationshipList(); + + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) { + continue; + } + + const char *relationship = __inputData->getRelationshipRelationship(record); + + CtInputViewRelationItem *item = new CtInputViewRelationItem( this,__inputData, record, relationship, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* objItem, bool isChanged, contacts_record_h record){ __relationItemDeleted( objItem, isChanged, record ); }, + [this](Evas_Object* obj, Elm_Object_Item* objItem){ __activateNextEntry(obj, objItem); }); + Elm_Object_Item *genItem = elm_genlist_item_append(genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[INPUT_RELATIONSHIP] = genItem; + } + break; + } + case INPUT_EVENT: + { + list = __inputData->getEventList(); + + *__birthdayEventExist = false; + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) { + continue; + } + char event[256]; + snprintf( event, sizeof(event), "%d", __inputData->getEventEvent(record) ); + + if( __inputData->getEventType(record) == CONTACTS_EVENT_TYPE_BIRTH) + *__birthdayEventExist = true; + + CtInputViewEventItem *item = new CtInputViewEventItem( __view, __inputData, record, event, __birthdayEventExist, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* objItem, bool isChanged, contacts_record_h record){ __eventItemDeleted( objItem, isChanged, record ); }); + Elm_Object_Item *genItem = elm_genlist_item_append(genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[INPUT_EVENT] = genItem; + } + break; + } + case INPUT_NOTE: + { + list = __inputData->getNoteList(); + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) { + continue; + } + const char *note = __inputData->getNote(record); + CtInputViewNoteItem *item = new CtInputViewNoteItem( __inputData, record, note, INPUT_ADDED_ITEM_INDEX_NONE, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* objItem, bool isChanged, contacts_record_h record){ __noteItemDeleted( objItem, isChanged, record ); }, + [this](Evas_Object* obj, Elm_Object_Item* objItem){this->__activateNextEntry(obj, objItem);} ); + Elm_Object_Item *genItem = elm_genlist_item_append(genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[INPUT_NOTE] = genItem; + __updateNoteBtn(true); + } + break; + } + case INPUT_IMPORTANT_FIELDS: + { + bool isNoteInput = (__genlistItems[INPUT_NOTE] == NULL) ? false : true; + CtInputViewImportantFieldsItem *item = new CtInputViewImportantFieldsItem([this](){ __addNumberClickedCb(); }, + [this](){ __addEmailClickedCb(); }, + [this](){ __addNoteClickedCb(); }, + [this](){ __addMoreClickedCb(); }, + isNoteInput); + Elm_Object_Item *genItem = elm_genlist_item_append(genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[INPUT_IMPORTANT_FIELDS] = genItem; + break; + } + } + } + WLEAVE(); +} + +void CtInputViewControl:: __genlistRealizedCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + CtInputViewControl *control = (CtInputViewControl*)data; + + control->__updateEntryReturnKeyType(NULL); + + Elm_Object_Item *objectItem = (Elm_Object_Item*) event_info; + CtInputViewGenlistItem *item = (CtInputViewGenlistItem*) elm_object_item_data_get(objectItem); + if (item) { + item->onRealized(); + } + + if (objectItem == control->__genlistItems[INPUT_BASIC_INFO]) { + control->__updateBasicInfoItem(); + } +} + +void CtInputViewControl::__genlistUnrealizedCb(void *data, Evas_Object *obj, void *event_info) +{ + Elm_Object_Item *objectItem = (Elm_Object_Item*) event_info; + CtInputViewGenlistItem *item = (CtInputViewGenlistItem*) elm_object_item_data_get(objectItem); + if (item) { + item->onUnrealized(); + } +} + +void CtInputViewControl::__updateNoteBtn(bool isNoteInput) +{ + WHIT(); + + if(__genlistItems[INPUT_IMPORTANT_FIELDS]) { + CtInputViewImportantFieldsItem *item = (CtInputViewImportantFieldsItem*)elm_object_item_data_get(__genlistItems[INPUT_IMPORTANT_FIELDS]); + if(item) { + item->updateNoteBtn(isNoteInput); + } + } + +} + +void CtInputViewControl::showTopItem() +{ + WHIT(); + + elm_genlist_item_show(__genlistItems[INPUT_BASIC_INFO], ELM_GENLIST_ITEM_SCROLLTO_TOP); + + bool first = false; + int error = preference_get_boolean(CT_KEY_CONTACT_CREATE_FIRST, &first); + WPRET_M(error != PREFERENCE_ERROR_NONE, "preference_get_boolean failed"); + + if (!first && __inputData->getContactId() == 0 && __nameEntry) { + elm_object_focus_set(__nameEntry, EINA_TRUE); + elm_entry_cursor_end_set(__nameEntry); + } +} + +void CtInputViewControl::__addNumberClickedCb() +{ + WHIT(); + contacts_record_h record = NULL; + + __resetTheme(); + + record = __inputData->addNumber(""); + __addedIndex = INPUT_ADDED_ITEM_INDEX_NUMBER; + + CtInputViewNumberItem* item = new CtInputViewNumberItem( this, __inputData, record, NULL, __addedIndex, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* objItem, bool isChanged, contacts_record_h record){ __numberItemDeleted( objItem, isChanged, record ); }, + [this](Evas_Object* obj, Elm_Object_Item* objItem){ __activateNextEntry(obj, objItem); } ); + + Elm_Object_Item* genItem = NULL; + if (__genlistItems[INPUT_NUMBER]) + { + genItem = elm_genlist_item_insert_after(getEvasObj(), item->getItemClassStatic(), item, NULL, __genlistItems[INPUT_NUMBER], ELM_GENLIST_ITEM_NONE, NULL, NULL); + } + else + { + genItem = elm_genlist_item_insert_after(getEvasObj(), item->getItemClassStatic(), item, NULL, __genlistItems[INPUT_BASIC_INFO], ELM_GENLIST_ITEM_NONE, NULL, NULL); + } + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[INPUT_NUMBER] = genItem; + elm_genlist_item_show(genItem, ELM_GENLIST_ITEM_SCROLLTO_TOP); + item->focus(); +} + +void CtInputViewControl::__addEmailClickedCb() +{ + WHIT(); + contacts_record_h record = NULL; + CtInputItems checkExistItem = INPUT_BASIC_INFO; + + __resetTheme(); + + record = __inputData->addEmail(""); + __addedIndex = INPUT_ADDED_ITEM_INDEX_EMAIL; + + if (__genlistItems[INPUT_EMAIL]) { + checkExistItem = INPUT_EMAIL; + } + else if (__genlistItems[INPUT_NUMBER]) { + checkExistItem = INPUT_NUMBER; + } + else { + checkExistItem = INPUT_BASIC_INFO; + } + WDEBUG("INPUT_EMAIL item is after %d item", checkExistItem); + + CtInputViewEmailItem *item = new CtInputViewEmailItem( __inputData, record, NULL, __addedIndex, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* item, bool isChanged, contacts_record_h record){ __emailItemDeleted( item, isChanged, record ); }, + [this](Evas_Object* obj, Elm_Object_Item* item){ __activateNextEntry(obj, item); } ); + Elm_Object_Item* genItem = elm_genlist_item_insert_after( getEvasObj(), item->getItemClassStatic(), item, NULL, __genlistItems[checkExistItem], ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[INPUT_EMAIL] = genItem; + elm_genlist_item_show( genItem, ELM_GENLIST_ITEM_SCROLLTO_TOP); + item->focus(); +} + +void CtInputViewControl::__addNoteClickedCb() +{ + WHIT(); + contacts_record_h record = NULL; + CtInputItems checkExistItem = INPUT_BASIC_INFO; + + __resetTheme(); + + WPRET_M(__genlistItems[INPUT_NOTE], "note already is added"); + + record = __inputData->addNote(""); + __addedIndex = INPUT_ADDED_ITEM_INDEX_NOTE; + + if (__genlistItems[INPUT_EMAIL]) { + checkExistItem = INPUT_EMAIL; + } + else if (__genlistItems[INPUT_NUMBER]) { + checkExistItem = INPUT_NUMBER; + } + else { + checkExistItem = INPUT_BASIC_INFO; + } + + CtInputViewNoteItem *item = new CtInputViewNoteItem( __inputData, record, NULL, __addedIndex, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* item, bool isChanged, contacts_record_h record){ __noteItemDeleted( item, isChanged, record ); }, + [this](Evas_Object* obj, Elm_Object_Item* objItem){this->__activateNextEntry(obj, objItem);} ); + Elm_Object_Item* genItem = elm_genlist_item_insert_after( getEvasObj(), item->getItemClassStatic(), item, NULL, __genlistItems[checkExistItem], ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[INPUT_NOTE] = genItem; + __updateNoteBtn(true); + elm_genlist_item_show( genItem, ELM_GENLIST_ITEM_SCROLLTO_TOP); + item->focus(); +} + +void CtInputViewControl::__addMoreClickedCb() +{ + WHIT(); + + __resetTheme(); + + if (__sipIsShown) { + // show popup in __onSipDownCb + __needShowMorePopup = true; + } + else { + __showMorePopup(); + } +} + +void CtInputViewControl::__importantSubitemSelectedCb(void* data, Evas_Object* obj, void* event_info) +{ + WPRET_M(NULL == data, "data is NULL"); + CtInputSubItems selectedSubitem = INPUT_IMPORTANT_NONE; + CtInputViewControl *control = (CtInputViewControl*)data; + Elm_Object_Item *item = (Elm_Object_Item *) event_info; + CtInputViewImportantSubItem *importantSubItem = (CtInputViewImportantSubItem *)elm_object_item_data_get(item); + contacts_record_h record = NULL; + CtInputItems checkExistItem = INPUT_BASIC_INFO; + Elm_Object_Item *addedItem = NULL; + + selectedSubitem = (CtInputSubItems)importantSubItem->getIndex(); + + elm_genlist_item_selected_set(item, EINA_FALSE); + + switch (selectedSubitem) { + case INPUT_IMPORTANT_PHONETIC_INFO: + { + CtInputViewBasicInfoItem* basicInfoItem = (CtInputViewBasicInfoItem*)elm_object_item_data_get(control->__genlistItems[INPUT_BASIC_INFO]); + WPRET_M(NULL == basicInfoItem, "basicInfoItem is NULL"); + + elm_object_item_disabled_set(item, EINA_TRUE); + basicInfoItem->setAddPhoneticName(true); + basicInfoItem->setAddedIndex(INPUT_ADDED_ITEM_INDEX_PHONETIC_INFO); + elm_genlist_item_fields_update(control->__genlistItems[INPUT_BASIC_INFO], "elm.icon.1", ELM_GENLIST_ITEM_FIELD_CONTENT); + addedItem = control->__genlistItems[INPUT_BASIC_INFO]; + control->destroyPopup(); + break; + } + case INPUT_IMPORTANT_MESSENGER: + { + record = control->__inputData->addMessenger(""); + control->__addedIndex = INPUT_ADDED_ITEM_INDEX_IM; + + if (control->__genlistItems[INPUT_MESSENGER]) { + checkExistItem = INPUT_MESSENGER; + } + else if (control->__genlistItems[INPUT_URL]) { + checkExistItem = INPUT_URL; + } + else if (control->__genlistItems[INPUT_RELATIONSHIP]) { + checkExistItem = INPUT_RELATIONSHIP; + } + else if (control->__genlistItems[INPUT_EVENT]) { + checkExistItem = INPUT_EVENT; + } + else if (control->__genlistItems[INPUT_ADDRESS]) { + checkExistItem = INPUT_ADDRESS; + } + else if (control->__genlistItems[INPUT_NOTE]) { + checkExistItem = INPUT_NOTE; + } + else if (control->__genlistItems[INPUT_EMAIL]) { + checkExistItem = INPUT_EMAIL; + } + else if (control->__genlistItems[INPUT_NUMBER]) { + checkExistItem = INPUT_NUMBER; + } + else { + checkExistItem = INPUT_BASIC_INFO; + } + WDEBUG("INPUT_MESSENGER item is after %d item", checkExistItem); + + CtInputViewMessengerItem *item = new CtInputViewMessengerItem( control->__inputData, record, NULL, control->__addedIndex, + [control](){ control->__itemChanged(); }, + [control](Elm_Object_Item* item, bool isChanged, contacts_record_h record){ control->__messengerItemDeleted( item, isChanged, record ); }, + [control](Evas_Object* obj, Elm_Object_Item* item){ control->__activateNextEntry(obj, item); } ); + Elm_Object_Item* genItem = elm_genlist_item_insert_after( control->getEvasObj(), item->getItemClassStatic(), item, NULL, control->__genlistItems[checkExistItem], ELM_GENLIST_ITEM_NONE, NULL, NULL); + item->setElmObjectItem( genItem ); + control->__genlistItems[INPUT_MESSENGER] = genItem; + addedItem = genItem; + control->destroyPopup(); + item->focus(); + break; + } + case INPUT_IMPORTANT_URL: + { + record = control->__inputData->addWebsite(""); + control->__addedIndex = INPUT_ADDED_ITEM_INDEX_URL; + + if (control->__genlistItems[INPUT_URL]) { + checkExistItem = INPUT_URL; + } + else if (control->__genlistItems[INPUT_RELATIONSHIP]) { + checkExistItem = INPUT_RELATIONSHIP; + } + else if (control->__genlistItems[INPUT_EVENT]) { + checkExistItem = INPUT_EVENT; + } + else if (control->__genlistItems[INPUT_ADDRESS]) { + checkExistItem = INPUT_ADDRESS; + } + else if (control->__genlistItems[INPUT_NOTE]) { + checkExistItem = INPUT_NOTE; + } + else if (control->__genlistItems[INPUT_EMAIL]) { + checkExistItem = INPUT_EMAIL; + } + else if (control->__genlistItems[INPUT_NUMBER]) { + checkExistItem = INPUT_NUMBER; + } + else { + checkExistItem = INPUT_BASIC_INFO; + } + WDEBUG("INPUT_URL item is after %d item", checkExistItem); + + CtInputViewWebsiteItem *item = new CtInputViewWebsiteItem( control->__inputData, record, NULL, control->__addedIndex, + [control](){ control->__itemChanged(); }, + [control](Elm_Object_Item* item, bool isChanged, contacts_record_h record){ control->__websiteItemDeleted( item, isChanged, record );}, + [control](Evas_Object* obj, Elm_Object_Item* item){ control->__activateNextEntry(obj, item); } ); + Elm_Object_Item* genItem = elm_genlist_item_insert_after( control->getEvasObj(), item->getItemClassStatic(), item, NULL, control->__genlistItems[checkExistItem], ELM_GENLIST_ITEM_NONE, NULL, NULL); + item->setElmObjectItem( genItem ); + control->__genlistItems[INPUT_URL] = genItem; + addedItem = genItem; + control->destroyPopup(); + item->focus(); + break; + } + case INPUT_IMPORTANT_ORGANIZATION: + { + CtInputViewBasicInfoItem* basicInfoItem = (CtInputViewBasicInfoItem*)elm_object_item_data_get(control->__genlistItems[INPUT_BASIC_INFO]); + WPRET_M(NULL == basicInfoItem, "basicInfoItem is NULL"); + + elm_object_item_disabled_set(item, EINA_TRUE); + basicInfoItem->setAddOrganization(true); + basicInfoItem->setAddedIndex(INPUT_ADDED_ITEM_INDEX_ORGANIZATION); + elm_genlist_item_fields_update(control->__genlistItems[INPUT_BASIC_INFO], "elm.icon.1", ELM_GENLIST_ITEM_FIELD_CONTENT); + addedItem = control->__genlistItems[INPUT_BASIC_INFO]; + control->destroyPopup(); + break; + } + case INPUT_IMPORTANT_RELATIONSHIP: + { + record = control->__inputData->addRelationship(""); + control->__addedIndex = INPUT_ADDED_ITEM_INDEX_RELATIONSHIP; + + if (control->__genlistItems[INPUT_RELATIONSHIP]) { + checkExistItem = INPUT_RELATIONSHIP; + } + else if (control->__genlistItems[INPUT_EVENT]) { + checkExistItem = INPUT_EVENT; + } + else if (control->__genlistItems[INPUT_ADDRESS]) { + checkExistItem = INPUT_ADDRESS; + } + else if (control->__genlistItems[INPUT_NOTE]) { + checkExistItem = INPUT_NOTE; + } + else if (control->__genlistItems[INPUT_EMAIL]) { + checkExistItem = INPUT_EMAIL; + } + else if (control->__genlistItems[INPUT_NUMBER]) { + checkExistItem = INPUT_NUMBER; + } + else { + checkExistItem = INPUT_BASIC_INFO; + } + WDEBUG("INPUT_RELATIONSHIP item is after %d item", checkExistItem); + + CtInputViewRelationItem *item = new CtInputViewRelationItem( control,control->__inputData, record, NULL, + [control](){ control->__itemChanged(); }, + [control](Elm_Object_Item* objItem, bool isChanged, contacts_record_h record){ control->__relationItemDeleted( objItem, isChanged, record );}, + [control](Evas_Object* obj, Elm_Object_Item* objItem){ control->__activateNextEntry(obj, objItem); }); + Elm_Object_Item* genItem = elm_genlist_item_insert_after( control->getEvasObj(), item->getItemClassStatic(), item, NULL, control->__genlistItems[checkExistItem], ELM_GENLIST_ITEM_NONE, NULL, NULL); + item->setElmObjectItem( genItem ); + control->__genlistItems[INPUT_RELATIONSHIP] = genItem; + addedItem = genItem; + control->destroyPopup(); + item->focus(); + break; + } + case INPUT_IMPORTANT_NICKNAME: + { + CtInputViewBasicInfoItem* basicInfoItem = (CtInputViewBasicInfoItem*)elm_object_item_data_get(control->__genlistItems[INPUT_BASIC_INFO]); + WPRET_M(NULL == basicInfoItem, "basicInfoItem is NULL"); + + elm_object_item_disabled_set(item, EINA_TRUE); + basicInfoItem->setAddNickname(true); + basicInfoItem->setAddedIndex(INPUT_ADDED_ITEM_INDEX_NICKNAME); + elm_genlist_item_fields_update(control->__genlistItems[INPUT_BASIC_INFO], "elm.icon.1", ELM_GENLIST_ITEM_FIELD_CONTENT); + addedItem = control->__genlistItems[INPUT_BASIC_INFO]; + control->destroyPopup(); + break; + } + case INPUT_IMPORTANT_EVENT: + { + control->__createEventDataPopup(); + break; + } + case INPUT_IMPORTANT_ADDRESS: + { + record = control->__inputData->addAddress(""); + control->__addedIndex = INPUT_ADDED_ITEM_INDEX_ADDRESS; + + if (control->__genlistItems[INPUT_ADDRESS]) { + checkExistItem = INPUT_ADDRESS; + } + else if (control->__genlistItems[INPUT_NOTE]) { + checkExistItem = INPUT_NOTE; + } + else if (control->__genlistItems[INPUT_EMAIL]) { + checkExistItem = INPUT_EMAIL; + } + else if (control->__genlistItems[INPUT_NUMBER]) { + checkExistItem = INPUT_NUMBER; + } + else { + checkExistItem = INPUT_BASIC_INFO; + } + WDEBUG("INPUT_ADDRESS item is after %d item", checkExistItem); + + CtInputViewAddressItem *item = new CtInputViewAddressItem( control->__inputData, record, NULL, control->__addedIndex, + [control](){ control->__itemChanged(); }, + [control](Elm_Object_Item* item, bool isChanged, contacts_record_h record){ control->__addressItemDeleted( item, isChanged, record ); }, + [control](Evas_Object* obj, Elm_Object_Item* item){ control->__activateNextEntry(obj, item); } ); + Elm_Object_Item* genItem = elm_genlist_item_insert_after( control->getEvasObj(), item->getItemClassStatic(), item, NULL, control->__genlistItems[checkExistItem], ELM_GENLIST_ITEM_NONE, NULL, NULL); + item->setElmObjectItem( genItem ); + control->__genlistItems[INPUT_ADDRESS] = genItem; + addedItem = genItem; + control->destroyPopup(); + item->focus(); + break; + } + default: + break; + } + if (addedItem) { + elm_genlist_item_select_mode_set(addedItem, ELM_OBJECT_SELECT_MODE_NONE); + elm_genlist_item_show(addedItem, ELM_GENLIST_ITEM_SCROLLTO_TOP); + } +} + +bool CtInputViewControl::__checkIsEmpty() +{ + bool isEmpty = true; + + CtInputViewGenlistItem *nameItem = (CtInputViewGenlistItem*) + elm_object_item_data_get(__genlistItems[INPUT_BASIC_INFO]); + CtInputViewGenlistItem *numberItem = (CtInputViewGenlistItem*) + elm_object_item_data_get(__genlistItems[INPUT_NUMBER]); + + if (nameItem) { + isEmpty = nameItem->getIsEmpty(); + } + + if (numberItem) { + isEmpty = isEmpty && numberItem->getIsEmpty(); + } + + return isEmpty; +} + +bool CtInputViewControl::__checkIsChanged() +{ + Elm_Object_Item *item = __genlistItems[INPUT_BASIC_INFO]; + bool changed = false; + + if (__changed) return __changed; + while (item) { + if (item == __genlistItems[INPUT_IMPORTANT_FIELDS]) { + break; + } + + CtInputViewGenlistItem *viewItem = (CtInputViewGenlistItem *)elm_object_item_data_get(item); + if (viewItem) { + WDEBUG("viewItem->getIsChanged() = %d", viewItem->getIsChanged()); + if (true == viewItem->getIsChanged()) { + changed = true; + break; + } + } + item = elm_genlist_item_next_get(item); + } + return changed; +} + +void CtInputViewControl::__updateSaveBtn() +{ + WHIT(); + Eina_Bool empty = __checkIsEmpty(); + __view->updateSaveBtn(empty); +} + +void CtInputViewControl::__itemChanged() +{ + __updateSaveBtn(); +} + +void CtInputViewControl::__basicInfoItemDeleted( int deletedInfo) +{ + CtInputViewBasicInfoItem::ITEM_DELETED info = (CtInputViewBasicInfoItem::ITEM_DELETED)deletedInfo; + + CtInputViewBasicInfoItem* basicInfoItem = (CtInputViewBasicInfoItem*)elm_object_item_data_get(__genlistItems[INPUT_BASIC_INFO]); + WPRET_M(NULL == basicInfoItem, "basicInfoItem is NULL"); + + switch( info ) + { + case CtInputViewBasicInfoItem::PHONETIC_NAME_DELETED: + if( basicInfoItem->getPhoneticNameIsChanged() + || __inputData->getPhoneticFirstName() + || __inputData->getPhoneticMiddleName() + || __inputData->getPhoneticLastName()) { + __changed = true; + } + + basicInfoItem->setPhoneticNameIsChanged(false); + basicInfoItem->setAddPhoneticName(false); + __inputData->setPhoneticFullName(NULL); + break; + case CtInputViewBasicInfoItem::NICKNAME_DELETED: + if( basicInfoItem->getNicknameIsChanged() || __inputData->getNickname()) + __changed = true; + + basicInfoItem->setNicknameIsChanged(false); + basicInfoItem->setAddNickname(false); + __inputData->setNickname(NULL); + break; + case CtInputViewBasicInfoItem::ORGANIZATION_DELETED: + if( (basicInfoItem->getCompanyIsChanged() || __inputData->getCompany()) + || (basicInfoItem->getJobTitleIsChanged() || __inputData->getJobTitle())) + { + __changed = true; + } + + basicInfoItem->setCompanyIsChanged(false); + basicInfoItem->setJobTitleIsChanged(false); + basicInfoItem->setAddOrganization(false); + __inputData->setCompany(NULL); + __inputData->setJobTitle(NULL); + break; + default: + WERROR("Not handled case =%d", deletedInfo); + break; + } + + __updateSaveBtn(); + __updateEntryReturnKeyType(__genlistItems[INPUT_BASIC_INFO]); +} + +void CtInputViewControl::__basicInfoItemImageClicked( Evas_Object* obj ) +{ + WPopup* popup = new WPopup(); + popup->setTextTranslatable(PACKAGE); + popup->setTitle( "IDS_PB_HEADER_SET_CONTACT_PICTURE_ABB"); + popup->setContent([this](Evas_Object* parent)->Evas_Object* + { + int count = 2; + Elm_Genlist_Item_Class* itc1 = elm_genlist_item_class_new(); + Elm_Genlist_Item_Class* itc2 = elm_genlist_item_class_new(); + Elm_Genlist_Item_Class* itc3 = elm_genlist_item_class_new(); + + if (itc1) { + itc1->item_style = "type1"; + itc1->func.text_get = [](void* data, Evas_Object* obj, const char* part)->char* + { + if(!strcmp(part, "elm.text")) { + return SAFE_STRDUP(V_("IDS_PB_OPT_FROM_GALLERY_ABB2")); + } + return NULL; + }; + } + + if (itc2) { + itc2->item_style = "type1"; + itc2->func.text_get = [](void* data, Evas_Object* obj, const char* part)->char* + { + if(!strcmp(part, "elm.text")) { + return SAFE_STRDUP(V_("IDS_PB_OPT_TAKE_PICTURE_ABB")); + } + return NULL; + }; + } + + if (itc3) { + itc3->item_style = "type1"; + itc3->func.text_get = [](void* data, Evas_Object* obj, const char* part)->char* + { + if(!strcmp(part, "elm.text")) { + CtInputViewControl *control = (CtInputViewControl*)data; + if(control->__inputData->getImagePath()) + return SAFE_STRDUP(V_("IDS_PB_OPT_REMOVE")); + else + return NULL; + + } + return NULL; + }; + } + + Evas_Object* genlist = elm_genlist_add(parent); + elm_object_style_set( genlist, "popup" ); + elm_genlist_homogeneous_set(genlist, EINA_TRUE); + elm_genlist_mode_set( genlist, ELM_LIST_COMPRESS ); + elm_scroller_content_min_limit( genlist, EINA_FALSE, EINA_TRUE ); // Automatically pop-up height is calculated + elm_object_content_set(parent, genlist); + + elm_genlist_item_append(genlist, itc1, this, NULL, ELM_GENLIST_ITEM_NONE, __onGallerySelCb, this); + elm_genlist_item_append(genlist, itc2, this, NULL, ELM_GENLIST_ITEM_NONE, __onCameraSelCb, this); + + if(__inputData->getImagePath()) { + elm_genlist_item_append(genlist, itc3, this, NULL, ELM_GENLIST_ITEM_NONE, __onRemoveSelCb, this); + count++; + } + + evas_object_show(genlist); + elm_genlist_item_class_free(itc1); + elm_genlist_item_class_free(itc2); + elm_genlist_item_class_free(itc3); + + return genlist; + + }); + // Make a parent as window. Issue: when IME is displayed, the pop-up is displayed at the moment upper side of IME keyboard, if its parent is not window.2014.11.05 + popup->create(__view->getWindow()->getEvasObj(), NULL ); + + attachPopup( popup ); +} + +void CtInputViewControl::__activateNextEntry( Evas_Object* obj, Elm_Object_Item* item ) // activatedCb +{ + WHIT(); + WPRET_M(NULL == obj, "obj is NULL"); + WPRET_M(NULL == item, "item is NULL"); + Elm_Object_Item* nextItem = elm_genlist_item_next_get(item); + bool focused = false; + Evas_Object* entry = obj; + while (nextItem) { + if (nextItem == __genlistItems[INPUT_IMPORTANT_FIELDS]) { + break; + } + + CtInputViewGenlistItem *viewItem = (CtInputViewGenlistItem *)elm_object_item_data_get(nextItem); + if (viewItem) { + entry = viewItem->getEntry(); + if (entry) { + elm_object_focus_set(entry, EINA_TRUE); + focused = true; + break; + } + } + nextItem = elm_genlist_item_next_get(nextItem); + } + // don't have next entry, close IME + elm_object_focus_set(entry, focused); +} + +void CtInputViewControl::basicInfoItemShowCreateKeypad( Evas_Object* obj) +{ + WHIT(); + if (__inputData->getContactId() == 0 && __nameEntry) { + elm_object_focus_set(__nameEntry, EINA_TRUE); + elm_entry_cursor_end_set(__nameEntry); + } +} + +void CtInputViewControl::__basicInfoUpdateImage() +{ + WHIT(); + + elm_genlist_item_fields_update(__genlistItems[INPUT_BASIC_INFO], "elm.icon.2", ELM_GENLIST_ITEM_FIELD_CONTENT); + return; +} + +Elm_Object_Item* CtInputViewControl::__getLastItem(Elm_Object_Item* deleteItem) +{ + Elm_Object_Item* item = NULL; + Elm_Object_Item* lastItem = NULL; + Elm_Object_Item* retItem = NULL; + int count = 0; + + item = elm_genlist_first_item_get( getEvasObj()); + while (item) { + if( elm_genlist_item_item_class_get( deleteItem ) == elm_genlist_item_item_class_get(item)) { + lastItem = item; + count++; + } + item = elm_genlist_item_next_get(item); + } + + if( lastItem == deleteItem ) { + if (1 == count) { + retItem = NULL; + } + else { // must > 1 + retItem = elm_genlist_item_prev_get(lastItem); + } + } + else { + retItem = lastItem; + } + + return retItem; +} + + +void CtInputViewControl::__numberItemDeleted(Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record) +{ + WHIT(); + __genlistItems[INPUT_NUMBER] = __getLastItem(deleteItem); + + if( isChanged || __inputData->getNumberNumber(record)) { + CtInputViewGenlistItem *viewItem = (CtInputViewGenlistItem *)elm_object_item_data_get(deleteItem); + if (viewItem) { + __changed = true; + } + } + + __inputData->removeNumber(record); + __updateSaveBtn(); + __updateEntryReturnKeyType(deleteItem); +} + +void CtInputViewControl::__emailItemDeleted( Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record) +{ + WHIT(); + __genlistItems[INPUT_EMAIL] = __getLastItem(deleteItem); + + if( isChanged || __inputData->getEmailEmail( record ) ) { + __changed = true; + } + __inputData->removeEmail( record ); + __updateSaveBtn(); + __updateEntryReturnKeyType(deleteItem); +} + +void CtInputViewControl::__addressItemDeleted( Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record) +{ + WHIT(); + __genlistItems[INPUT_ADDRESS] = __getLastItem(deleteItem); + + char address[CT_TEXT_MAX_LEN] = {0,}; + __inputData->getAddressAddress( record, address, sizeof(address)); + if( isChanged || address[0] != '\0') { + __changed = true; + } + + __inputData->removeAddress(record); + __updateSaveBtn(); + __updateEntryReturnKeyType(deleteItem); +} + +void CtInputViewControl::__websiteItemDeleted( Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record) +{ + WHIT(); + __genlistItems[INPUT_URL] = __getLastItem(deleteItem); + + if( isChanged || __inputData->getWebsiteWebsite( record )) { + __changed = true; + } + + __inputData->removeWebsite(record); + __updateSaveBtn(); + __updateEntryReturnKeyType(deleteItem); +} + +void CtInputViewControl::__messengerItemDeleted( Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record) +{ + WHIT(); + __genlistItems[INPUT_MESSENGER] = __getLastItem(deleteItem); + + if ( isChanged || __inputData->getMessengerMessenger( record)) { + __changed = true; + } + + __inputData->removeMessenger(record); + __updateSaveBtn(); + __updateEntryReturnKeyType(deleteItem); +} + +void CtInputViewControl::__relationItemDeleted( Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record) +{ + WHIT(); + __genlistItems[INPUT_RELATIONSHIP] = __getLastItem(deleteItem); + + if (isChanged || __inputData->getRelationshipRelationship(record)) { + __changed = true; + } + + __inputData->removeRelationship(record); + __updateSaveBtn(); + __updateEntryReturnKeyType(deleteItem); +} + +void CtInputViewControl::__eventItemDeleted(Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record) +{ + WHIT(); + __genlistItems[INPUT_EVENT] = __getLastItem(deleteItem); + + if (isChanged || __inputData->getEventEvent(record)) { + __changed = true; + } + + __inputData->removeEvent(record); + __updateSaveBtn(); +} + +void CtInputViewControl::__noteItemDeleted( Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record) +{ + WHIT(); + Evas_Object *noteBtn = elm_object_item_part_content_get(__genlistItems[INPUT_IMPORTANT_FIELDS], "elm.icon.3"); + elm_object_disabled_set(noteBtn, EINA_FALSE); + + if( isChanged || __inputData->getNote(record)) { + __changed = true; + } + + __inputData->removeNote( record ); + __genlistItems[INPUT_NOTE] = NULL; + __updateNoteBtn(false); + __updateSaveBtn(); + __updateEntryReturnKeyType(deleteItem); +} + +void CtInputViewControl::__onGallerySelCb(void *data, Evas_Object *obj, void *event_info) +{ + WPRET_M(NULL == data, "data is NULL"); + CtInputViewControl *control = (CtInputViewControl*)data; + + control->__launchGallery(control); + + control->destroyPopup(); +} + +void CtInputViewControl::__onCameraSelCb(void *data, Evas_Object *obj, void *event_info) +{ + WPRET_M(NULL == data, "data is NULL"); + CtInputViewControl *control = (CtInputViewControl*)data; + + control->__launchCamera(control); + + control->destroyPopup(); +} + +void CtInputViewControl::__onRemoveSelCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + WPRET_M(NULL == data, "data is NULL"); + CtInputViewControl *control = (CtInputViewControl*)data; + control->destroyPopup(); + + control->__inputData->removeImage(control->__inputData->getImageRecord()); + control->__basicInfoUpdateImage(); +} + +void CtInputViewControl::__galleryReplyCb(app_control_h request, app_control_h reply, app_control_result_e result, void *data) +{ + WHIT(); + char **pathArray = NULL; + char *path = NULL; + int arrayLength = 0; + CtInputViewControl *control = (CtInputViewControl*)data; + int i=0; + + app_control_get_extra_data_array(reply, APP_CONTROL_DATA_SELECTED, &pathArray, &arrayLength); + if (arrayLength > 0 && pathArray[0]) { + path = strdup(pathArray[0]); + } + for(i = 0; i < arrayLength; i++) { + free(pathArray[i]); + } + free(pathArray); + + + elm_object_tree_focus_allow_set(control->__view->getNaviframeEvasObj(), EINA_TRUE); + + if (path) { + WDEBUG("image path %s", path); + contacts_record_h record = control->__inputData->getImageRecord(); +// control->__inputData->setImage(record, path, CONTACTS_IMAGE_TYPE_EX_OTHER); + control->__inputData->setImage(record, path, CONTACTS_IMAGE_TYPE_OTHER); + control->__basicInfoUpdateImage(); + free(path); + } +// else { +// elm_object_focus_set(cinput_d->image_focus_btn, EINA_TRUE); +// } +} + +void CtInputViewControl::__launchGallery(CtInputViewControl *control) +{ + WHIT(); + + app_control_h service = NULL; + int ret = 0; + + elm_object_tree_focus_allow_set(control->__view->getNaviframeEvasObj(), EINA_FALSE); + + ret = app_control_create(&service); + WPWARN(APP_CONTROL_ERROR_NONE != ret, "app_control_create() Failed(%d)", ret); + + app_control_set_operation(service, APP_CONTROL_OPERATION_PICK); + app_control_set_app_id(service, GALLERY_UG); + app_control_add_extra_data(service, "hide-personal", "true"); + app_control_add_extra_data(service, "launch-type", "select-setas"); + app_control_add_extra_data(service, "setas-type", "callerid"); + app_control_set_launch_mode(service, APP_CONTROL_LAUNCH_MODE_GROUP); + + app_control_add_extra_data(service, "View Mode", "SETAS"); + app_control_add_extra_data(service, "Setas type", "CallerID"); + app_control_add_extra_data(service, "Area Size", "100"); + app_control_add_extra_data(service, "Resolution", "480x480"); + + + if( false == ContactsAppControlLauncher::getInstance().sendLaunchRequest( service, __galleryReplyCb, control, control->__view->getNaviframeEvasObj()) ) + { + WERROR("phct_common_service_send_launch_request() Failed"); + elm_object_tree_focus_allow_set(control->__view->getNaviframeEvasObj(), EINA_TRUE); + } +// ret = ctCommonServiceSendLaunchRequest(view->__getNaviframeEvasObj(), service, __galleryReplyCb, view); +// if (APP_CONTROL_ERROR_NONE != ret) { +// WERROR("phct_common_service_send_launch_request() Failed(%d)", ret); +// elm_object_tree_focus_allow_set(view->__getNaviframeEvasObj(), EINA_TRUE); +// } +// +// ctCommonResetAppservice(view->__getNaviframeEvasObj(), service); +} + +void CtInputViewControl::__cameraReplyCb(app_control_h request, app_control_h reply, app_control_result_e result, void *data) +{ + WHIT(); + char *path = NULL; + CtInputViewControl *control = (CtInputViewControl*)data; + + elm_object_tree_focus_allow_set(control->__view->getNaviframeEvasObj(), EINA_TRUE); + + app_control_get_extra_data(reply, APP_CONTROL_DATA_SELECTED, &path); + if (path && *path) { + contacts_record_h record = control->__inputData->getImageRecord(); + control->__inputData->setImage(record, path, CONTACTS_IMAGE_TYPE_OTHER); + control->__basicInfoUpdateImage(); + } + free(path); +} + +void CtInputViewControl::__launchCamera(CtInputViewControl *control) +{ + app_control_h service; + app_control_create(&service); + app_control_set_operation(service, APP_CONTROL_OPERATION_CREATE_CONTENT); + app_control_set_launch_mode(service, APP_CONTROL_LAUNCH_MODE_GROUP); + app_control_set_mime(service, "image/jpg"); + app_control_add_extra_data(service, "CALLER", "contacts"); + + bool ret = ContactsAppControlLauncher::getInstance().sendLaunchRequest( service, __cameraReplyCb, control, control->__view->getNaviframeEvasObj() ); + if( !ret ) + { + WERROR("launch Failed"); + } +// ctCommonServiceSendLaunchRequest(view->__getNaviframeEvasObj(), service, __cameraReplyCb, view); +// ctCommonResetAppservice(view->__getNaviframeEvasObj(), service); +} + +void CtInputViewControl::__updateEntryReturnKeyType(Elm_Object_Item* deleteItem) +{ + WENTER(); + Elm_Object_Item *item = __genlistItems[INPUT_BASIC_INFO]; + Evas_Object* entry = NULL; + Evas_Object* box = NULL; + Eina_List* list = NULL; + Eina_List* cursor = NULL; + void *tmp = NULL; + Evas_Object* layout = NULL; + + while (item) { + if (item == __genlistItems[INPUT_IMPORTANT_FIELDS]) { + break; + } + + if (item == deleteItem) { + item = elm_genlist_item_next_get(item); + continue; + } + + if (item == __genlistItems[INPUT_BASIC_INFO]) { + box = elm_object_item_part_content_get(item, "elm.icon.1"); + if (box) { + list = elm_box_children_get(box); + EINA_LIST_FOREACH(list, cursor, tmp) { + layout = (Evas_Object*)tmp; + if (layout) { + entry = elm_object_part_content_get(layout, "elm.icon.1"); + if (entry && elm_entry_single_line_get(entry)) { + elm_entry_input_panel_return_key_type_set(entry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_NEXT); + } + } + } + } + } + else { + CtInputViewGenlistItem *viewItem = (CtInputViewGenlistItem *)elm_object_item_data_get(item); + if (viewItem) { + entry = viewItem->getEntry(); + + if (entry && elm_entry_single_line_get(entry)) { + elm_entry_input_panel_return_key_type_set(entry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_NEXT); + } + } + } + item = elm_genlist_item_next_get(item); + } + + if (entry && elm_entry_single_line_get(entry)) { + elm_entry_input_panel_return_key_type_set(entry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE); + } + + WLEAVE(); +} + +void CtInputViewControl::__setEntryUnfocus() +{ + Elm_Object_Item *item = __genlistItems[INPUT_BASIC_INFO]; + bool find = false; + Evas_Object* entry = NULL; + Evas_Object* box = NULL; + Eina_List* list = NULL; + Eina_List* cursor = NULL; + void *tmp = NULL; + Evas_Object* layout = NULL; + + while (item) { + if (item == __genlistItems[INPUT_IMPORTANT_FIELDS]) { + break; + } + + if (item == __genlistItems[INPUT_BASIC_INFO]) { + box = elm_object_item_part_content_get(item, "elm.icon.1"); + if (box) { + list = elm_box_children_get(box); + EINA_LIST_FOREACH(list, cursor, tmp) { + layout = (Evas_Object*)tmp; + if (layout) { + entry = elm_object_part_content_get(layout, "elm.icon.1"); + if (entry && elm_object_focus_get(entry)) { + elm_object_focus_set(entry, EINA_FALSE); + find = true; + break; + } + } + } + } + } + else { + if (true == find) { + break; + } + + CtInputViewGenlistItem *viewItem = (CtInputViewGenlistItem *)elm_object_item_data_get(item); + if (viewItem) { + entry = viewItem->getEntry(); + + if (entry && elm_object_focus_get(entry)) { + elm_object_focus_set(entry, EINA_FALSE); + break; + } + } + } + item = elm_genlist_item_next_get(item); + } +} + +void CtInputViewControl::__updateBasicInfoItem() +{ + WHIT(); + if(__genlistItems[INPUT_BASIC_INFO]) { + elm_object_item_signal_emit(__genlistItems[INPUT_BASIC_INFO], "image,enable", ""); + } +} + +void CtInputViewControl::__resetTheme() +{ + WHIT(); + // if launch ct-list ug to select relationship, when destroy ug, the CtThemeMgr instance will be deleted + // so need to recreate the CtThemeMgr instance + if (__needResetTheme) { + __view->resetTheme(); + __needResetTheme = false; + } +} + +void CtInputViewControl::__createEventDataPopup() +{ + WHIT(); + WPopup* popup = new WPopup(); + popup->setTextTranslatable(PACKAGE); + popup->setTitle("IDS_ST_BODY_SET_DATE"); + popup->addButton("IDS_PB_BUTTON_CANCEL", NULL); + popup->addButton("IDS_PB_SK_SET", [popup, this](bool* destroyPopup) { + struct tm time1 = {}; + time_t t; + t = time(NULL); + localtime_r(&t, &time1); + + int year = 0; + int month = 0; + int day = 0; + Evas_Object *datetimePickerBg = elm_object_content_get(popup->getEvasObj()); + Evas_Object *dateTime = elm_object_part_content_get(datetimePickerBg, "elm.swallow.content"); + elm_datetime_value_get(dateTime, &time1); + year = time1.tm_year + 1900; + month = time1.tm_mon + 1; + day = time1.tm_mday; + + __appendEventItem(year, month, day); + + *destroyPopup = true; + }); + popup->setOnMoreProperties([this](Evas_Object* popupObj ) { + struct tm time1 = {}; + time_t t; + t = time(NULL); + localtime_r(&t, &time1); + + Evas_Object* dateTime = elm_datetime_add(popupObj); + elm_datetime_format_set(dateTime, DATE_TIME_FORMAT); + elm_datetime_value_set(dateTime, &time1); + + std::string contactsEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + Evas_Object* datetimePickerBg = elm_layout_add(popupObj); + evas_object_size_hint_weight_set(datetimePickerBg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + CtThemeMgr::getInstance()->setObjectTheme(datetimePickerBg); + elm_layout_file_set(datetimePickerBg, contactsEdjePath.c_str(), "datetimePickerBg"); + elm_object_part_content_set(datetimePickerBg, "elm.swallow.content", dateTime); + evas_object_show(datetimePickerBg); + + elm_object_content_set(popupObj, datetimePickerBg); + }); + + attachPopup( popup ); +} + +void CtInputViewControl::__appendEventItem(int year, int month, int day) +{ + WHIT(); + contacts_record_h record = NULL; + CtInputItems checkExistItem = INPUT_BASIC_INFO; + + record = __inputData->addEvent(year * 10000 + month * 100 + day); + + if (__genlistItems[INPUT_EVENT]) { + checkExistItem = INPUT_EVENT; + } + else if (__genlistItems[INPUT_ADDRESS]) { + checkExistItem = INPUT_ADDRESS; + } + else if (__genlistItems[INPUT_NOTE]) { + checkExistItem = INPUT_NOTE; + } + else if (__genlistItems[INPUT_EMAIL]) { + checkExistItem = INPUT_EMAIL; + } + else if (__genlistItems[INPUT_NUMBER]) { + checkExistItem = INPUT_NUMBER; + } + else { + checkExistItem = INPUT_BASIC_INFO; + } + WDEBUG("INPUT_EVENT item is after %d item", checkExistItem); + + if (!*__birthdayEventExist) { + if(__inputData->getEventType(record) == CONTACTS_EVENT_TYPE_BIRTH) { + *__birthdayEventExist = true; + } + } + + CtInputViewEventItem *item = new CtInputViewEventItem(__view, __inputData, record, NULL, __birthdayEventExist, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* item, bool isChanged, contacts_record_h record){ __eventItemDeleted( item, isChanged, record ); } ); + Elm_Object_Item* genItem = elm_genlist_item_insert_after(getEvasObj(), item->getItemClassStatic(), item, NULL, __genlistItems[checkExistItem], ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[INPUT_EVENT] = genItem; + elm_genlist_item_show(genItem, ELM_GENLIST_ITEM_SCROLLTO_TOP); +} + +void CtInputViewControl::__onSipUpCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + WPRET_M(NULL == data, "data is NULL"); + CtInputViewControl* control = (CtInputViewControl*) data; + control->__sipIsShown = true; +} + +void CtInputViewControl::__onSipDownCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + WPRET_M(NULL == data, "data is NULL"); + CtInputViewControl* control = (CtInputViewControl*) data; + control->__sipIsShown = false; + if (control->__needShowMorePopup) { + control->__needShowMorePopup = false; + control->__showMorePopup(); + } +} + +void CtInputViewControl::__showMorePopup() +{ + WHIT(); + WPopup* popup = new WPopup(); + popup->setTextTranslatable(PACKAGE); + popup->setTitle("IDS_PB_OPT_ADD_FIELD"); + popup->setContent([this](Evas_Object* parent)->Evas_Object* + { + Elm_Object_Item *genItem = NULL; + + Evas_Object* genlist = elm_genlist_add(parent); + elm_object_style_set( genlist, "popup" ); + elm_genlist_homogeneous_set(genlist, EINA_TRUE); + elm_genlist_mode_set( genlist, ELM_LIST_COMPRESS ); + elm_scroller_content_min_limit( genlist, EINA_FALSE, EINA_TRUE ); // Automatically pop-up height is calculated + + CtInputViewBasicInfoItem* basicInfoItem = (CtInputViewBasicInfoItem*)elm_object_item_data_get(__genlistItems[INPUT_BASIC_INFO]); + WPRET_VM(NULL == basicInfoItem, NULL, "basicInfoItem is NULL"); + + for (int i = INPUT_IMPORTANT_ADDRESS; i < INPUT_IMPORTANT_MAX; i++) { + //WDEBUG("item %d", i); + if (i == INPUT_IMPORTANT_PHONETIC_INFO) { + if (basicInfoItem->getAddPhoneticName()) { + continue; + } + } else if (i == INPUT_IMPORTANT_NICKNAME) { + if (basicInfoItem->getAddNickname()) { + continue; + } + } else if (i == INPUT_IMPORTANT_ORGANIZATION) { + if (basicInfoItem->getAddOrganization()) { + continue; + } + } + + CtInputViewImportantSubItem *item = new CtInputViewImportantSubItem(i, false); + genItem = elm_genlist_item_append( genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, __importantSubitemSelectedCb, this); + item->setElmObjectItem( genItem ); + } + + elm_object_content_set(parent, genlist); + evas_object_show(genlist); + + return genlist; + }); + + attachPopup( popup ); +} diff --git a/lib-contact/ct-detail/src/CtInputViewControl.h b/lib-contact/ct-detail/src/CtInputViewControl.h new file mode 100755 index 0000000..dddb0d5 --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputViewControl.h @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_INPUT_VIEW_CONTROL_H_ +#define _CT_INPUT_VIEW_CONTROL_H_ + +#include <Elementary.h> + +#include <contacts.h> +#include <system_settings.h> + +#include "WNaviframe.h" +#include "WPopup.h" + +#include "ContactsCommon.h" + +#include "ICtChangeListener.h" +#include "CtType.h" +#include "CtView.h" +#include "CtData.h" + + +class CtInputData; +class CtInputView; + +class CtInputViewControl: public WControl +{ +public: + CtInputViewControl( std::shared_ptr<CtData>& inputData, CtInputView* view ); + +public: + int getAddedIndex() { return __addedIndex; } + + bool getIsCreate(); + bool getIsEmpty(); + bool getIsChanged(); + void updateNumberSaveBtn(Eina_Bool isEmpty); + void setIsDestroy(bool isDestroy); + Evas_Object* getViewEvasObj(); + Evas_Object* getNaviframeEvasObj(); + + void showTopItem(); + void basicInfoItemShowCreateKeypad( Evas_Object* obj); + +protected: + virtual Evas_Object* onCreate(Evas_Object* parent, void* viewParam); + virtual void onDestroy(); + +private: + void __initialize(); + void __addAllItems(Evas_Object* genlist); + static void __genlistRealizedCb(void *data, Evas_Object *obj, void *event_info); + static void __genlistUnrealizedCb(void *data, Evas_Object *obj, void *event_info); + + + static void __importantSubitemSelectedCb(void* data, Evas_Object* obj, void* event_info); + void __addNumberClickedCb(); + void __addEmailClickedCb(); + void __addNoteClickedCb(); + void __addMoreClickedCb(); + + static void __onGallerySelCb(void *data, Evas_Object *obj, void *event_info); + static void __onCameraSelCb(void *data, Evas_Object *obj, void *event_info); + static void __onRemoveSelCb(void *data, Evas_Object *obj, void *event_info); + static void __galleryReplyCb(app_control_h request, app_control_h reply, app_control_result_e result, void *data); + static void __launchGallery(CtInputViewControl *control); + static void __cameraReplyCb(app_control_h request, app_control_h reply, app_control_result_e result, void *data); + static void __launchCamera(CtInputViewControl *control); + + void __numberItemDeleted(Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record); + void __emailItemDeleted(Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record); + void __messengerItemDeleted(Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record); + void __addressItemDeleted(Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record); + void __websiteItemDeleted(Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record); + void __relationItemDeleted(Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record); + void __eventItemDeleted(Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record); + void __noteItemDeleted(Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record); + + bool __checkIsChanged(); + bool __checkIsEmpty(); + void __updateSaveBtn(); + void __updateNoteBtn(bool isNoteInput); + + void __itemChanged(); + void __basicInfoItemImageClicked(Evas_Object* obj); + void __basicInfoItemDeleted( int deletedInfo); + void __activateNextEntry(Evas_Object* obj, Elm_Object_Item* item); + void __basicInfoExpandClickedCb(); + void __basicInfoUpdateImage(); + Elm_Object_Item* __getLastItem(Elm_Object_Item* deleteItem); + void __updateEntryReturnKeyType(Elm_Object_Item* deleteItem); + void __setEntryUnfocus(); + + static void __regionFormatChangedCb(system_settings_key_e key, void *data); + void __updateBasicInfoItem(); + void __resetTheme(); + void __createEventDataPopup(); + void __appendEventItem(int year, int month, int day); + static void __onSipUpCb(void *data, Evas_Object *obj, void *event_info); + static void __onSipDownCb(void *data, Evas_Object *obj, void *event_info); + void __showMorePopup(); + +private: + CtInputViewControl(); + virtual ~CtInputViewControl(); + +private: + + typedef enum { + INPUT_BASIC_INFO = 0, + INPUT_NUMBER, + INPUT_EMAIL, + INPUT_NOTE, + INPUT_ADDRESS, + + INPUT_EVENT, + INPUT_RELATIONSHIP, + INPUT_URL, + INPUT_MESSENGER, + + INPUT_IMPORTANT_FIELDS, + INPUT_IMPORTANT_SUBITEM, + INPUT_ITEMS_MAX, + }CtInputItems; + + typedef enum { + INPUT_IMPORTANT_NONE = 0, + INPUT_IMPORTANT_ADDRESS, + INPUT_IMPORTANT_EVENT, + INPUT_IMPORTANT_NICKNAME, + INPUT_IMPORTANT_RELATIONSHIP, + INPUT_IMPORTANT_ORGANIZATION, + INPUT_IMPORTANT_URL, + INPUT_IMPORTANT_MESSENGER, + INPUT_IMPORTANT_PHONETIC_INFO, + INPUT_IMPORTANT_MAX, + }CtInputSubItems; + + Evas_Object *__nameEntry; + Evas_Object* __genlist; + Evas_Object* __conformant; + + bool __changed; + bool __isDestroy; + bool __needResetTheme; + bool __needShowMorePopup; + bool __sipIsShown; + + int __addedIndex; + + Elm_Object_Item *__genlistItems[INPUT_ITEMS_MAX]; + + // + std::shared_ptr<bool> __birthdayEventExist; + + std::shared_ptr<CtData> __inputData; + CtInputView* __view; + + Ecore_Timer* __keypadTimer; +}; + +#endif /* _CT_INPUT_VIEW_H_ */ diff --git a/lib-contact/ct-detail/src/CtInputViewEmailItem.h b/lib-contact/ct-detail/src/CtInputViewEmailItem.h new file mode 100644 index 0000000..1b914c8 --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputViewEmailItem.h @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_INPUT_VIEW_EMAIL_ITEM_H_ +#define _CT_INPUT_VIEW_EMAIL_ITEM_H_ + +#include "CtInputViewGenlistItem.h" +#include "CtDetailDataBase.h" +#include "CtInputDataTypeCtxPopup.h" +#include "CtInputDataTypeCustomPopup.h" +#include "CtData.h" +#include "CtString.h" + +class CtInputViewEmailItem : public CtInputViewGenlistItem +{ +public: + CtInputViewEmailItem( std::shared_ptr<CtData>& inputData, contacts_record_h record, const char* oldVal, int addedIndex, + const std::function<void ()>& itemChangedCb, + const std::function<void (Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record )>& itemDeletedCb, + const std::function<void (Evas_Object*, Elm_Object_Item* )>& activateNextEntryCb) : CtInputViewGenlistItem(oldVal) + { + __inputData = inputData; __record = record; __addedIndex = addedIndex; + __itemChangedCb = itemChangedCb; __itemDeletedCb = itemDeletedCb; __activateNextEntryCb = activateNextEntryCb; + }; + virtual ~CtInputViewEmailItem() {WHIT();} +public: + virtual Elm_Genlist_Item_Class* getItemClassStatic() { + static Elm_Genlist_Item_Class itc = {}; + if( itc.item_style ) + return &itc; + itc.item_style = "input.3icon"; + itc.func.content_get = __getContentEmail; + itc.func.del = WGENLIST_ITEM_DEL(); + return &itc; + } + + virtual const char* getEntryObjPartName() + { + return "elm.icon.entry"; + } + +private: + static Evas_Object* __getContentEmail(void *data, Evas_Object *obj, const char *part) + { + WHIT(); + CtInputViewEmailItem *item = (CtInputViewEmailItem*)data; + // + if (0 == strcmp(part, "elm.icon.entry")) + { + WEditfield *editfield = item->createEditField(obj, V_("IDS_PB_BUTTON_EMAIL_ABB3"), false); + Evas_Object *entry = editfield->getEntry(); + + elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_EMAIL); + + evas_object_smart_callback_add(entry, "changed", __emailChangedCb, item); + evas_object_smart_callback_add(entry, "preedit,changed", __emailChangedCb, item); + evas_object_smart_callback_add(entry, "activated", __activatedCb, item); + if (INPUT_ADDED_ITEM_INDEX_EMAIL == item->__addedIndex ) { + evas_object_event_callback_add(entry, EVAS_CALLBACK_SHOW, __entryShowCb, NULL); + } + + const char *email = item->__inputData->getEmailEmail( item->__record ); + setEntryText(entry, email); + return editfield->getEvasObj(); + } + else if (0 == strcmp(part, "elm.icon.2")) { + Evas_Object *btn_minus = elm_button_add(obj); + elm_object_style_set(btn_minus, "icon_expand_delete"); + evas_object_smart_callback_add(btn_minus, "clicked", __emailDeleteCb, item); + + return btn_minus; + } + else if (0 == strcmp(part, "elm.icon.1")) { + Evas_Object *btn_type = elm_button_add(obj); + elm_object_style_set(btn_type, "custom_dropdown"); + evas_object_show(btn_type); + + int emailType = item->__inputData->getEmailType( item->__record); + std::string typeStr; + item->__inputData->getEmailTypeStr( item->__record, emailType, typeStr); + elm_object_text_set(btn_type, typeStr.c_str()); + + evas_object_smart_callback_add(btn_type, "clicked", __dataTypeClickedCb, item); + return btn_type; + } + + return NULL; + } + static void __activatedCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewEmailItem* item = (CtInputViewEmailItem*)data; + item->__activateNextEntryCb( obj, item->getElmObjectItem() ); + } + static void __entryShowCb(void *data, Evas *e, Evas_Object *obj, void *event_info) + { + WHIT(); + elm_object_focus_set(obj, EINA_TRUE); + evas_object_event_callback_del(obj, EVAS_CALLBACK_SHOW, __entryShowCb); + } + + static void __dataTypeClickedCb(void *data, Evas_Object *obj, void *event_info) + { + WHIT(); + CtInputViewEmailItem* item = (CtInputViewEmailItem*)data; + // + std::string typeStr; + if( item->__inputData->getEmailType( item->__record) == CONTACTS_EMAIL_TYPE_CUSTOM) + { + item->__inputData->getEmailTypeStr( item->__record, CONTACTS_EMAIL_TYPE_CUSTOM, typeStr); + } + CtInputDataTypeCtxPopup* popup = new CtInputDataTypeCtxPopup(elm_object_item_widget_get(item->getElmObjectItem()), obj, _contacts_email._uri, typeStr.c_str()); + + popup->setOnSelectCb( [popup,item,obj](int type){ + if( CONTACTS_EMAIL_TYPE_CUSTOM == type ) + { + item->__showDataTypeInputPopup(); + return; + } + item->__inputData->setEmailType( item->__record, type, NULL); + std::string typeStr; + item->__inputData->getEmailTypeStr( item->__record, type, typeStr); + elm_object_text_set( obj, typeStr.c_str()); + popup->destroy(); + }); + + item->attachToView( popup ); + } + + void __showDataTypeInputPopup() + { + CtInputDataTypeCustomPopup* popup = new CtInputDataTypeCustomPopup(); + popup->setOnResultCb([this](const char* text){ + __inputData->setEmailType( __record, CONTACTS_EMAIL_TYPE_CUSTOM, (char*)text ); + elm_genlist_item_fields_update( getElmObjectItem(), "elm.icon.1", ELM_GENLIST_ITEM_FIELD_CONTENT); + }); + attachToView( popup ); + } + static void __emailChangedCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewEmailItem* item = (CtInputViewEmailItem*)data; + char *text = NULL; + text = ctCommonMarkupToUtf8(elm_entry_entry_get(obj)); + item->__inputData->setEmailEmail(item->__record, text); + item->updateChangeState( text ); + item->__itemChangedCb(); + SAFE_FREE(text); + } + static void __emailDeleteCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewEmailItem* item = (CtInputViewEmailItem*)data; + item->updateChangeState(NULL); + item->__itemDeletedCb( item->getElmObjectItem(), item->getIsChanged(), item->__record ); + elm_object_item_del( item->getElmObjectItem() ); + } +private: + CtInputViewEmailItem(); + + std::shared_ptr<CtData> __inputData; + contacts_record_h __record; + int __addedIndex; + + std::function<void ()> __itemChangedCb; + std::function<void (Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record )> __itemDeletedCb; + std::function<void (Evas_Object*, Elm_Object_Item*)> __activateNextEntryCb; + +}; + +#endif /* _CT_INPUT_VIEW_EMAIL_ITEM_H_ */ diff --git a/lib-contact/ct-detail/src/CtInputViewEventItem.cpp b/lib-contact/ct-detail/src/CtInputViewEventItem.cpp new file mode 100644 index 0000000..98ad368 --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputViewEventItem.cpp @@ -0,0 +1,266 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "CtCommon.h" +#include "CtInputViewEventItem.h" +#include "CtDetailDataBase.h" +#include "CtInputDataTypeCtxPopup.h" +#include "CtInputDataTypeCustomPopup.h" +#include "CtInputView.h" +#include "CtInputData.h" +#include "CtString.h" +#include "CtPath.h" +#include "CtThemeMgr.h" + +#define BUTTON_COLOR_NORMAL 82, 198, 216, 255 +#define BUTTON_COLOR_PRESSED 48, 139, 153, 255 + +#define EVENT_DATE_FORMAT "%b/%d/%Y" +#define DATE_TIME_FORMAT "%%c" + +CtInputViewEventItem::CtInputViewEventItem( WView* view, std::shared_ptr<CtData>& inputData, contacts_record_h record, const char* oldVal, std::shared_ptr<bool>& birthdayExist, + const std::function<void ()>& itemChangedCb, + const std::function<void (Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record )>& itemDeletedCb ) : CtInputViewGenlistItem(oldVal) +{ + __view = view; + __inputData = inputData; __record = record; __birthdayExist = birthdayExist; + __itemChangedCb = itemChangedCb; __itemDeletedCb = itemDeletedCb; +} + +CtInputViewEventItem::~CtInputViewEventItem() +{ + WHIT(); + __destroyPopup(); +} + +Elm_Genlist_Item_Class* CtInputViewEventItem::getItemClassStatic() +{ + static Elm_Genlist_Item_Class itc = {}; + if( itc.item_style ) + return &itc; + itc.item_style = "input.3icon"; + itc.func.content_get = __getContentEvent; + itc.func.del = WGENLIST_ITEM_DEL(); + return &itc; +} + +bool CtInputViewEventItem::getIsEmpty() +{ + return true; +} + +Evas_Object* CtInputViewEventItem::__getContentEvent(void *data, Evas_Object *obj, const char *part) +{ + WHIT(); + CtInputViewEventItem *item = (CtInputViewEventItem*)data; + + struct tm time1 = {}; + time_t t; + t = time(NULL); + localtime_r(&t, &time1); + + if (0 == strcmp(part, "elm.icon.entry")) + { + + Evas_Object *layout = elm_layout_add(obj); + elm_layout_theme_set(layout, "layout", "list/A/left.icon", "default"); + + Evas_Object *dateTime = elm_button_add(obj); + elm_object_style_set(dateTime, "custom_default"); + + Evas_Object *edje = elm_layout_edje_get(dateTime); + edje_object_color_class_set(edje, "button_normal", BUTTON_COLOR_NORMAL, 0, 0, 0, 0, 0, 0, 0, 0); + edje_object_color_class_set(edje, "button_pressed", BUTTON_COLOR_PRESSED, 0, 0, 0, 0, 0, 0, 0, 0); + + elm_layout_content_set(layout, "elm.swallow.content", dateTime); + evas_object_smart_callback_add(dateTime, "clicked", __eventDateBtnClickedCb, item); + int date = item->__inputData->getEventEvent(item->__record); + + time1.tm_year = date / 10000 - 1900; + time1.tm_mon = (date % 10000) / 100 - 1; + time1.tm_mday = date % 100; + + char text_str[CT_TEXT_SHORT_LEN] = { 0 }; + strftime(text_str, CT_TEXT_SHORT_LEN, EVENT_DATE_FORMAT, &time1); + elm_object_text_set(dateTime, text_str); + return layout; + } + else if (0 == strcmp(part, "elm.icon.2")) { + Evas_Object *btn_minus = elm_button_add(obj); + elm_object_style_set(btn_minus, "icon_expand_delete"); + evas_object_smart_callback_add(btn_minus, "clicked", __eventDeleteCb, item); + + return btn_minus; + } + else if (0 == strcmp(part, "elm.icon.1")) { + Evas_Object *btn_type = elm_button_add(obj); + elm_object_style_set(btn_type, "custom_dropdown"); + evas_object_show(btn_type); + + int eventType = item->__inputData->getEventType(item->__record); + std::string typeStr; + item->__inputData->getEventTypeStr(item->__record, eventType, typeStr); + elm_object_text_set(btn_type, typeStr.c_str()); + + evas_object_smart_callback_add(btn_type, "clicked", __dataTypeClickedCb, item); + return btn_type; + } + + return NULL; +} + +void CtInputViewEventItem::__eventDateBtnClickedCb(void *data, Evas_Object *obj, void *event_info) +{ + CtInputViewEventItem *item = (CtInputViewEventItem*)data; + + item->__destroyPopup(); + + WPopup* popup = new WPopup(); + popup->setTextTranslatable(PACKAGE); + popup->setTitle("IDS_ST_BODY_SET_DATE"); + popup->addButton("IDS_PB_BUTTON_CANCEL", NULL); + popup->addButton("IDS_PB_SK_SET", [obj, popup, item](bool* destroyPopup) { + struct tm time1 = {}; + time_t t; + t = time(NULL); + localtime_r(&t, &time1); + + int year = 0; + int month = 0; + int day = 0; + Evas_Object *datetimePickerBg = elm_object_content_get(popup->getEvasObj()); + Evas_Object *dateTime = elm_object_part_content_get(datetimePickerBg, "elm.swallow.content"); + elm_datetime_value_get(dateTime, &time1); + year = time1.tm_year + 1900; + month = time1.tm_mon + 1; + day = time1.tm_mday; + + char text[CT_TEXT_SHORT_LEN] = {0}; + snprintf(text, sizeof(text), "%d", year * 10000 + month * 100 + day); + char text_str[CT_TEXT_SHORT_LEN] = {0}; + strftime(text_str, CT_TEXT_SHORT_LEN, EVENT_DATE_FORMAT, &time1); + item->__inputData->setEventEvent( item->__record, year * 10000 + month * 100 + day); + item->updateChangeState(text); + item->__itemChangedCb(); + elm_object_text_set( obj, text_str); + + *destroyPopup = true; + }); + popup->setOnMoreProperties([obj, item](Evas_Object* popupObj ) { + struct tm time1 = {}; + time_t t; + t = time(NULL); + localtime_r(&t, &time1); + + int date = item->__inputData->getEventEvent(item->__record); + + time1.tm_year = date / 10000 - 1900; + time1.tm_mon = (date % 10000) / 100 - 1; + time1.tm_mday = date % 100; + + Evas_Object* dateTime = elm_datetime_add(popupObj); + elm_datetime_format_set(dateTime, DATE_TIME_FORMAT); + elm_datetime_value_set(dateTime, &time1); + + std::string contactsEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + Evas_Object* datetimePickerBg = elm_layout_add(popupObj); + evas_object_size_hint_weight_set(datetimePickerBg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + CtThemeMgr::getInstance()->setObjectTheme(datetimePickerBg); + elm_layout_file_set(datetimePickerBg, contactsEdjePath.c_str(), "datetimePickerBg"); + elm_object_part_content_set(datetimePickerBg, "elm.swallow.content", dateTime); + evas_object_show(datetimePickerBg); + + elm_object_content_set(popupObj, datetimePickerBg);} ); + + popup->create( item->__view->getWindow()->getBaseLayoutEvasObj(), NULL ); // Do not attach pop-up to view! It is not working, pop-up is destroyed too fast! + + item->__popup = popup->getWeakPtr(); +} + +void CtInputViewEventItem::__destroyPopup() +{ + if ( auto popup = __popup.lock() ) { + popup->destroy(); + } +} + +void CtInputViewEventItem::__dataTypeClickedCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + CtInputViewEventItem* item = (CtInputViewEventItem*)data; + std::string typeStr; + + int oldType = item->__inputData->getEventType( item->__record); + if( oldType == CONTACTS_EVENT_TYPE_CUSTOM) { + item->__inputData->getEventTypeStr( item->__record, CONTACTS_EVENT_TYPE_CUSTOM, typeStr); + } + + CtInputDataTypeCtxPopup* popup = new CtInputDataTypeCtxPopup(elm_object_item_widget_get(item->getElmObjectItem()), obj, _contacts_event._uri, typeStr.c_str()); + if( *item->__birthdayExist && (oldType != CONTACTS_EVENT_TYPE_BIRTH) ) { + popup->setRemoveBirthdayType(); + } + + popup->setOnSelectCb( [popup,item,obj,oldType](int type){ + + if( CONTACTS_EVENT_TYPE_CUSTOM == type ) { + item->__showDataTypeInputPopup(); + return; + } + + if( type == CONTACTS_EVENT_TYPE_BIRTH ) { + *item->__birthdayExist = true; + } + else { + if( oldType == CONTACTS_EVENT_TYPE_BIRTH ) { + *item->__birthdayExist = false; + } + } + + item->__inputData->setEventType( item->__record, type, NULL); + std::string typeStr; + item->__inputData->getEventTypeStr( item->__record, type, typeStr); + elm_object_text_set( obj, typeStr.c_str()); + popup->destroy(); + }); + + item->attachToView( popup ); + +} + +void CtInputViewEventItem::__showDataTypeInputPopup() +{ + CtInputDataTypeCustomPopup* popup = new CtInputDataTypeCustomPopup(); + popup->setOnResultCb([this](const char* text){ + if( __inputData->getEventType( __record) == CONTACTS_EVENT_TYPE_BIRTH ) + *__birthdayExist = false; + + __inputData->setEventType( __record, CONTACTS_EVENT_TYPE_CUSTOM, (char*)text ); + elm_genlist_item_fields_update( getElmObjectItem(), "elm.icon.1", ELM_GENLIST_ITEM_FIELD_CONTENT); + }); + attachToView(popup); +} + + +void CtInputViewEventItem::__eventDeleteCb(void *data, Evas_Object *obj, void *event_info) +{ + CtInputViewEventItem* item = (CtInputViewEventItem*)data; + if( item->__inputData->getEventType( item->__record) == CONTACTS_EVENT_TYPE_BIRTH ) + *item->__birthdayExist = false; + item->__itemDeletedCb( item->getElmObjectItem(), item->getIsChanged(), item->__record ); + elm_object_item_del( item->getElmObjectItem() ); +} diff --git a/lib-contact/ct-detail/src/CtInputViewEventItem.h b/lib-contact/ct-detail/src/CtInputViewEventItem.h new file mode 100644 index 0000000..fcc0a2b --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputViewEventItem.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_INPUT_VIEW_EVENT_ITEM_H_ +#define _CT_INPUT_VIEW_EVENT_ITEM_H_ + +#include <memory> +#include "CtInputViewControl.h" +#include "CtInputViewGenlistItem.h" +#include "CtDetailDataBase.h" +#include "WControl.h" +#include "CtData.h" + +class CtInputData; + +class CtInputViewEventItem : public CtInputViewGenlistItem +{ +public: + CtInputViewEventItem( WView* view, std::shared_ptr<CtData>& inputData, contacts_record_h record, const char* oldVal, std::shared_ptr<bool>& birthdayExist, + const std::function<void ()>& itemChangedCb, + const std::function<void (Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record )>& itemDeletedCb ); + virtual ~CtInputViewEventItem(); +public: + virtual Elm_Genlist_Item_Class* getItemClassStatic(); + virtual bool getIsEmpty(); + +private: + virtual void onLanguageChanged() {}; +private: + void __destroyPopup(); + void __showDataTypeInputPopup(); + + static Evas_Object* __getContentEvent(void *data, Evas_Object *obj, const char *part); + static char* __eventDateFormatGet(); + static void __eventDateBtnClickedCb(void *data, Evas_Object *obj, void *event_info); + static void __dataTypeClickedCb(void *data, Evas_Object *obj, void *event_info); + static void __eventDeleteCb(void *data, Evas_Object *obj, void *event_info); +private: + CtInputViewEventItem(); + + WView* __view; + std::shared_ptr<CtData> __inputData; + contacts_record_h __record; + WUiObjectPtr __popup; + contacts_event_type_e __type; + std::shared_ptr<bool> __birthdayExist; + + std::function<void ()> __itemChangedCb; + std::function<void (Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record )> __itemDeletedCb; +}; + +#endif /* _CT_INPUT_VIEW_EVENT_ITEM_H_ */ diff --git a/lib-contact/ct-detail/src/CtInputViewGenlistItem.cpp b/lib-contact/ct-detail/src/CtInputViewGenlistItem.cpp new file mode 100755 index 0000000..be35f19 --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputViewGenlistItem.cpp @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "CtInputViewGenlistItem.h" +#include "CtDetailDataBase.h" +#include <notification.h> +#include "CtString.h" +#include "WEditfield.h" + + +CtInputViewGenlistItem::CtInputViewGenlistItem(const char* oldVal): +__isChanged(false), __isEmpty(true), __notificationTimer(NULL), __entry(NULL), __focused(false) +{ + WHIT(); + __oldVal = SAFE_STRDUP(oldVal); +} + +CtInputViewGenlistItem::CtInputViewGenlistItem(): +__isChanged(false), __isEmpty(true), __oldVal(NULL), __notificationTimer(NULL), __entry(NULL), __focused(false) +{ + WHIT(); +} + +CtInputViewGenlistItem::~CtInputViewGenlistItem() +{ + WHIT(); + SAFE_FREE(__oldVal); + if (__notificationTimer) { + ecore_timer_del(__notificationTimer); + } +} + +void CtInputViewGenlistItem::onRealized() +{ + if (__entry && __focused) { + elm_object_focus_set(__entry, EINA_TRUE); + __focused = false; + } +} + +void CtInputViewGenlistItem::onUnrealized() +{ +} + +bool CtInputViewGenlistItem::getIsChanged() +{ + return __isChanged; +} + +void CtInputViewGenlistItem::setIsChanged(bool isChanged) +{ + __isChanged = isChanged; +} + +bool CtInputViewGenlistItem::getIsEmpty() +{ + return __isEmpty; +} + +void CtInputViewGenlistItem::updateChangeState(const char *text) +{ + if (SAFE_STRLEN(text)) { + __isEmpty = false; + if( __oldVal && !strcmp(text, __oldVal) ) { + __isChanged = false; + } + else { + __isChanged = true; + } + } + else { + __isEmpty = true; + if( __oldVal && __oldVal[0] != '\0' ) { + __isChanged = true; + } + else { + __isChanged = false; + } + } +} + +WEditfield* CtInputViewGenlistItem::createEditField(Evas_Object *parent, const char *guideText, bool multiline, bool isMainField) +{ + WENTER(); + WEditfield *editfield = new WEditfield(); + editfield->create(parent, NULL); + + Evas_Object *entry = editfield->getEntry(); + + if (guideText && *guideText) + elm_object_domain_translatable_part_text_set(entry, "elm.guide", PACKAGE, guideText); + + if (!multiline) + elm_entry_input_panel_return_key_type_set(entry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_NEXT); + + Elm_Entry_Filter_Limit_Size filter; + if (isMainField) { + filter.max_char_count = CT_MAIN_NAME_EDITFIELD_MAX_CHAR; + } + else { + filter.max_char_count = CT_EDITFIELD_MAX_CHAR; + } + elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &filter); + + elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT); + elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_NORMAL); + evas_object_smart_callback_add(entry, "maxlength,reached", __editfieldTextMaxReachedCb, this); + elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_NONE); + + __entry = entry; + + WLEAVE(); + + return editfield; +} + +void CtInputViewGenlistItem::__editfieldTextMaxReachedCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + WPRET_M(NULL == data, "parameter(data) is NULL"); + CtInputViewGenlistItem *itemData = (CtInputViewGenlistItem *)data; + + if (itemData->__notificationTimer) { + return; + } +//TODO : tranlation need + itemData->__showTickerNotification(V_("IDS_PB_POP_MAXIMUM_NUMBER_OF_CHARACTERS_REACHED")); + itemData->__notificationTimer = ecore_timer_add(3.5, __notificationTimerCb, itemData); +} + +Eina_Bool CtInputViewGenlistItem::__notificationTimerCb(void *data) +{ + WHIT(); + WPRET_VM(NULL == data, ECORE_CALLBACK_CANCEL, "parameter(data) is NULL"); + CtInputViewGenlistItem *itemData = (CtInputViewGenlistItem *)data; + + itemData->__notificationTimer = NULL; + return ECORE_CALLBACK_CANCEL; +} + +void CtInputViewGenlistItem::__showTickerNotification(const char *msg) +{ + WHIT(); + int err = notification_status_message_post(msg); + WPWARN(CONTACTS_ERROR_NONE != err, "notification_status_message_post() Failed(%d)", err); +} + +void CtInputViewGenlistItem::setEntryText(Evas_Object *entry, const char *text) +{ + WPRET_M(NULL == entry, "entry is NULL"); + WPRET_M(NULL == text, "text is NULL"); + char *input = NULL; + input = elm_entry_utf8_to_markup(text); + elm_entry_entry_set(entry, ""); + if (input && *input) { + elm_entry_entry_insert(entry, input); + } + free(input); +} + +const char* CtInputViewGenlistItem::getEntryObjPartName() +{ + return NULL; +} + +Evas_Object* CtInputViewGenlistItem::getEntry() +{ + Evas_Object *entry = NULL; + Evas_Object *layout = elm_object_item_part_content_get(getElmObjectItem(), getEntryObjPartName()); + if (layout) { + entry = elm_object_part_content_get(layout, "elm.swallow.content"); + } + + return entry; +} + +void CtInputViewGenlistItem::focus() +{ + Evas_Object *entry = getEntry(); + if (entry) { + elm_object_focus_set(entry, EINA_TRUE); + } else { + __focused = true; + } +} diff --git a/lib-contact/ct-detail/src/CtInputViewGenlistItem.h b/lib-contact/ct-detail/src/CtInputViewGenlistItem.h new file mode 100755 index 0000000..e4cf211 --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputViewGenlistItem.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_INPUT_VIEW_GENLIST_ITEM_H_ +#define _CT_INPUT_VIEW_GENLIST_ITEM_H_ + +#include <list> +#include "WEditfield.h" +#include "WGenlistItem.h" +#include "ContactsDebug.h" + +class CtInputViewGenlistItem : public WGenlistItem +{ +public: + CtInputViewGenlistItem(const char* oldVal); + CtInputViewGenlistItem(); + virtual ~CtInputViewGenlistItem(); + +public: + virtual void onRealized(); + virtual void onUnrealized(); + + virtual bool getIsChanged(); + virtual bool getIsEmpty(); + virtual const char* getEntryObjPartName(); + Evas_Object* getEntry(); + void focus(); + +protected: + void setIsChanged(bool isChanged); + void updateChangeState( const char *text); + WEditfield* createEditField(Evas_Object *parent, const char *guideText, bool multiline, bool isMainField = false); + static void setEntryText(Evas_Object *entry, const char *text); +private: + static Eina_Bool __notificationTimerCb(void *data); + static void __editfieldTextMaxReachedCb(void *data, Evas_Object *obj, void *event_info); + void __showTickerNotification(const char *msg); + +private: + bool __isChanged; + bool __isEmpty; + char* __oldVal; + Ecore_Timer *__notificationTimer; + + Evas_Object *__entry; + bool __focused; +}; + +#endif /* _CT_INPUT_VIEW_GENLIST_ITEM_H_ */ diff --git a/lib-contact/ct-detail/src/CtInputViewImportantFieldsItem.h b/lib-contact/ct-detail/src/CtInputViewImportantFieldsItem.h new file mode 100755 index 0000000..d73e80a --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputViewImportantFieldsItem.h @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_INPUT_VIEW_IMPORTANT_FIELDS_ITEM_H_ +#define _CT_INPUT_VIEW_IMPORTANT_FIELDS_ITEM_H_ + +#include "CtInputViewGenlistItem.h" +#include "CtDetailDataBase.h" +#include "CtData.h" + +class CtInputViewImportantFieldsItem : public CtInputViewGenlistItem +{ +public: + CtInputViewImportantFieldsItem(const std::function<void ()>& addNumberCb, + const std::function<void ()>& addEmailCb, + const std::function<void ()>& addNoteCb, + const std::function<void ()>& addMoreCb, + bool isNoteInput) + { + __addNumberCb = addNumberCb; + __addEmailCb = addEmailCb; + __addNoteCb = addNoteCb; + __addMoreCb = addMoreCb; + __isNoteInput = isNoteInput; + }; + virtual ~CtInputViewImportantFieldsItem() { WHIT(); } +public: + virtual Elm_Genlist_Item_Class* getItemClassStatic() { + static Elm_Genlist_Item_Class itc = {}; + if( itc.item_style ) + return &itc; + + itc.item_style = "input.4icon"; + itc.func.content_get = __getContentImportantFields; + itc.func.del = WGENLIST_ITEM_DEL(); + return &itc; + } + + virtual bool getIsEmpty() + { + return true; + } + + void updateNoteBtn(bool isNoteInput) + { + __isNoteInput = isNoteInput; + Evas_Object *btn = elm_object_item_part_content_get(getElmObjectItem(), "elm.icon.3"); + elm_object_disabled_set(btn, __isNoteInput); + } + +private: + static Evas_Object* __getContentImportantFields(void *data, Evas_Object *obj, const char *part) + { + CtInputViewImportantFieldsItem* item = (CtInputViewImportantFieldsItem*)data; + Evas_Object *btn = NULL; + Evas_Object *img = NULL; + + btn = elm_button_add(obj); + elm_object_style_set(btn, "circle"); + + if (0 == strcmp(part, "elm.icon.1")) { + elm_object_text_set(btn, V_("IDS_PB_BUTTON_PHONE")); + evas_object_smart_callback_add(btn, "clicked", __addNumberClickedCb, item); + + img = elm_image_add(btn); + elm_image_file_set(img, CT_IMG_ICON_INPUT_CALL, NULL); + elm_image_resizable_set(img, EINA_TRUE, EINA_TRUE); + elm_object_part_content_set(btn, "icon", img); + } + else if (0 == strcmp(part, "elm.icon.2")) { + elm_object_text_set(btn, V_("IDS_PB_BUTTON_EMAIL_ABB3")); + evas_object_smart_callback_add(btn, "clicked", __addEmailClickedCb, item); + + img = elm_image_add(btn); + elm_image_file_set(img, CT_IMG_ICON_INPUT_EMAIL, NULL); + elm_image_resizable_set(img, EINA_TRUE, EINA_TRUE); + elm_object_part_content_set(btn, "icon", img); + } + else if (0 == strcmp(part, "elm.icon.3")) { + elm_object_text_set(btn, V_("IDS_PB_BUTTON_NOTES")); + evas_object_smart_callback_add(btn, "clicked", __addNoteClickedCb, item); + + img = elm_image_add(btn); + elm_image_file_set(img, CT_IMG_ICON_INPUT_NOTE, NULL); + elm_image_resizable_set(img, EINA_TRUE, EINA_TRUE); + elm_object_part_content_set(btn, "icon", img); + elm_object_disabled_set(btn, item->__isNoteInput); + } + else if (0 == strcmp(part, "elm.icon.4")) { + elm_object_text_set(btn, V_("IDS_PB_BUTTON_MORE")); + evas_object_smart_callback_add(btn, "clicked", __addMoreClickedCb, item); + + img = elm_image_add(btn); + elm_image_file_set(img, CT_IMG_ICON_INPUT_MORE, NULL); + elm_image_resizable_set(img, EINA_TRUE, EINA_TRUE); + elm_object_part_content_set(btn, "icon", img); + } + + return btn; + } + + static void __addNumberClickedCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewImportantFieldsItem* item = (CtInputViewImportantFieldsItem*)data; + item->__addNumberCb(); + } + + static void __addEmailClickedCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewImportantFieldsItem* item = (CtInputViewImportantFieldsItem*)data; + item->__addEmailCb(); + } + + static void __addNoteClickedCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewImportantFieldsItem* item = (CtInputViewImportantFieldsItem*)data; + elm_object_disabled_set(obj, EINA_TRUE); + item->__addNoteCb(); + } + + static void __addMoreClickedCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewImportantFieldsItem* item = (CtInputViewImportantFieldsItem*)data; + elm_object_focus_set(obj, EINA_TRUE); + item->__addMoreCb(); + } +private: + CtInputViewImportantFieldsItem(); + + std::function<void ()> __addNumberCb; + std::function<void ()> __addEmailCb; + std::function<void ()> __addNoteCb; + std::function<void ()> __addMoreCb; + bool __isNoteInput; +}; + +#endif /* _CT_INPUT_VIEW_IMPORTANT_FIELDS_ITEM_H_ */ diff --git a/lib-contact/ct-detail/src/CtInputViewImportantSubItem.h b/lib-contact/ct-detail/src/CtInputViewImportantSubItem.h new file mode 100755 index 0000000..022c949 --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputViewImportantSubItem.h @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_INPUT_VIEW_IMPORTANT_SUB_ITEM_H_ +#define _CT_INPUT_VIEW_IMPORTANT_SUB_ITEM_H_ + +#include "CtInputViewGenlistItem.h" +#include "CtDetailDataBase.h" +#include "CtInputViewControl.h" +#include "CtData.h" + +class CtInputViewImportantSubItem : public CtInputViewGenlistItem +{ +public: + CtInputViewImportantSubItem(int index, bool isMyProfile): __index(index), __isMyProfile(isMyProfile) + { + }; + virtual ~CtInputViewImportantSubItem() { WHIT(); } +public: + virtual Elm_Genlist_Item_Class* getItemClassStatic() { + static Elm_Genlist_Item_Class itc = {}; + if( itc.item_style ) + return &itc; + + itc.item_style = "type1"; + itc.func.text_get = __getTextImportantSubitem; + itc.func.del = WGENLIST_ITEM_DEL(); + return &itc; + } + + virtual bool getIsEmpty() + { + return true; + } + + int getIndex() + { + return __index; + } + +private: + static char* __getTextImportantSubitem(void *data, Evas_Object *obj, const char *part) + { + //WHIT(); + CtInputViewImportantSubItem* item = (CtInputViewImportantSubItem*)data; + if (0 == strcmp(part, "elm.text")) { + if (item->__isMyProfile) { + switch (item->__index) { + case MYPROFILE_INPUT_IMPORTANT_PHONETIC_INFO: + return strdup(V_("IDS_PB_BODY_PHONETIC_NAME_ABB")); + case MYPROFILE_INPUT_IMPORTANT_MESSENGER: + return strdup(V_("IDS_PB_BODY_IM")); + case MYPROFILE_INPUT_IMPORTANT_URL: + return strdup(V_("IDS_PB_BODY_WEBSITE_ABB")); + case MYPROFILE_INPUT_IMPORTANT_ORGANIZATION: + return strdup(V_("IDS_PB_OPT_ORGANISATION_ABB")); + case MYPROFILE_INPUT_IMPORTANT_NICKNAME: + return strdup(V_("IDS_PB_BODY_NICKNAME_ABB")); + case MYPROFILE_INPUT_IMPORTANT_EVENT: + return strdup(V_("IDS_PB_MBODY_EVENT")); + case MYPROFILE_INPUT_IMPORTANT_ADDRESS: + return strdup(V_("IDS_PB_BODY_ADDRESS_ABB2")); + default: + return NULL; + } + } + else { + switch (item->__index) { + case INPUT_IMPORTANT_PHONETIC_INFO: + return strdup(V_("IDS_PB_BODY_PHONETIC_NAME_ABB")); + case INPUT_IMPORTANT_MESSENGER: + return strdup(V_("IDS_PB_BODY_IM")); + case INPUT_IMPORTANT_URL: + return strdup(V_("IDS_PB_BODY_WEBSITE_ABB")); + case INPUT_IMPORTANT_ORGANIZATION: + return strdup(V_("IDS_PB_OPT_ORGANISATION_ABB")); + case INPUT_IMPORTANT_RELATIONSHIP: + return strdup(V_("IDS_PB_OPT_RELATIONSHIP_ABB2")); + case INPUT_IMPORTANT_NICKNAME: + return strdup(V_("IDS_PB_BODY_NICKNAME_ABB")); + case INPUT_IMPORTANT_EVENT: + return strdup(V_("IDS_PB_MBODY_EVENT")); + case INPUT_IMPORTANT_ADDRESS: + return strdup(V_("IDS_PB_BODY_ADDRESS_ABB2")); + case INPUT_IMPORTANT_ADDRBOOK: + return strdup(V_("IDS_PB_OPT_SAVE_CONTACT_TO")); + default: + return NULL; + } + } + } + + return NULL; + } + +private: + CtInputViewImportantSubItem(); + typedef enum { + MYPROFILE_INPUT_IMPORTANT_ADDRESS = 1, + MYPROFILE_INPUT_IMPORTANT_EVENT, + MYPROFILE_INPUT_IMPORTANT_NICKNAME, + MYPROFILE_INPUT_IMPORTANT_ORGANIZATION, + MYPROFILE_INPUT_IMPORTANT_URL, + MYPROFILE_INPUT_IMPORTANT_MESSENGER, + MYPROFILE_INPUT_IMPORTANT_PHONETIC_INFO, + MYPROFILE_INPUT_IMPORTANT_MAX, + }CtMyProfileInputSubItems; + + typedef enum { + INPUT_IMPORTANT_ADDRBOOK, + INPUT_IMPORTANT_ADDRESS, + INPUT_IMPORTANT_EVENT, + INPUT_IMPORTANT_NICKNAME, + INPUT_IMPORTANT_RELATIONSHIP, + INPUT_IMPORTANT_ORGANIZATION, + INPUT_IMPORTANT_URL, + INPUT_IMPORTANT_MESSENGER, + INPUT_IMPORTANT_PHONETIC_INFO, + INPUT_IMPORTANT_MAX, + + }CtInputSubItems; + + int __index; + bool __isMyProfile; +}; + +#endif /* _CT_INPUT_VIEW_IMPORTANT_SUB_ITEM_H_ */ diff --git a/lib-contact/ct-detail/src/CtInputViewMessengerItem.h b/lib-contact/ct-detail/src/CtInputViewMessengerItem.h new file mode 100644 index 0000000..5fae77b --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputViewMessengerItem.h @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + +#ifndef _CT_INPUT_VIEW_MESSENGER_ITEM_H_ +#define _CT_INPUT_VIEW_MESSENGER_ITEM_H_ + +#include "CtInputViewGenlistItem.h" +#include "CtDetailDataBase.h" +#include "CtInputDataTypeCtxPopup.h" +#include "CtInputDataTypeCustomPopup.h" +#include "CtInputViewControl.h" +#include "CtData.h" + +class CtInputViewMessengerItem : public CtInputViewGenlistItem +{ +public: + CtInputViewMessengerItem( std::shared_ptr<CtData>& inputData, contacts_record_h record, const char* oldVal, int addedIndex, + const std::function<void ()>& itemChangedCb, + const std::function<void (Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record )>& itemDeletedCb, + const std::function<void (Evas_Object*, Elm_Object_Item* )>& activateNextEntryCb ) : CtInputViewGenlistItem(oldVal) + { + __inputData = inputData; __record = record; __addedIndex = addedIndex; + __itemChangedCb = itemChangedCb; __itemDeletedCb = itemDeletedCb; __activateNextEntryCb = activateNextEntryCb; + }; + virtual ~CtInputViewMessengerItem() {WHIT();} +public: + virtual Elm_Genlist_Item_Class* getItemClassStatic() { + static Elm_Genlist_Item_Class itc = {}; + if( itc.item_style ) + return &itc; + itc.item_style = "input.3icon"; + itc.func.content_get = __getContentMessenger; + itc.func.del = WGENLIST_ITEM_DEL(); + return &itc; + } + + virtual const char* getEntryObjPartName() + { + return "elm.icon.entry"; + } + +private: + static Evas_Object* __getContentMessenger(void *data, Evas_Object *obj, const char *part) + { + CtInputViewMessengerItem *item = (CtInputViewMessengerItem*)data; + + if (0 == strcmp(part, "elm.icon.entry")) { + WEditfield *editfield = item->createEditField(obj, V_("IDS_PB_BODY_IM"), false); + Evas_Object *entry = editfield->getEntry(); + + elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_EMAIL); + + evas_object_smart_callback_add(entry, "changed", __messengerChangedCb, item); + evas_object_smart_callback_add(entry, "preedit,changed", __messengerChangedCb, item); + evas_object_smart_callback_add(entry, "activated", __activatedCb, item); + if (INPUT_ADDED_ITEM_INDEX_IM == item->__addedIndex ) { + evas_object_event_callback_add(entry, EVAS_CALLBACK_SHOW, __entryShowCb, NULL); + } + + const char *address = item->__inputData->getMessengerMessenger( item->__record); + setEntryText(entry, address); + return editfield->getEvasObj(); + } + else if (0 == strcmp(part, "elm.icon.2")) { + Evas_Object *btn_minus = elm_button_add(obj); + elm_object_style_set(btn_minus, "icon_expand_delete"); + evas_object_smart_callback_add(btn_minus, "clicked", __messengerDeleteCb, item); + + return btn_minus; + } + else if (0 == strcmp(part, "elm.icon.1")) { + Evas_Object *btn_type = elm_button_add(obj); + elm_object_style_set(btn_type, "custom_dropdown"); + evas_object_show(btn_type); + + int messengerType = item->__inputData->getMessengerType(item->__record); + std::string typeStr; + item->__inputData->getMessengerTypeStr( item->__record, messengerType, typeStr); + elm_object_text_set(btn_type, typeStr.c_str()); + + + evas_object_smart_callback_add(btn_type, "clicked", __dataTypeClickedCb, item); + return btn_type; + } + + return NULL; + } + + static void __activatedCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewMessengerItem* item = (CtInputViewMessengerItem*)data; + item->__activateNextEntryCb( obj, item->getElmObjectItem() ); + } + static void __entryShowCb(void *data, Evas *e, Evas_Object *obj, void *event_info) + { + WHIT(); + elm_object_focus_set(obj, EINA_TRUE); + evas_object_event_callback_del(obj, EVAS_CALLBACK_SHOW, __entryShowCb); + } + + static void __dataTypeClickedCb(void *data, Evas_Object *obj, void *event_info) + { + WHIT(); + CtInputViewMessengerItem* item = (CtInputViewMessengerItem*)data; + + std::string typeStr; + if( item->__inputData->getMessengerType( item->__record) == CONTACTS_MESSENGER_TYPE_CUSTOM) + { + item->__inputData->getMessengerTypeStr( item->__record, CONTACTS_MESSENGER_TYPE_CUSTOM, typeStr); + } + CtInputDataTypeCtxPopup* popup = new CtInputDataTypeCtxPopup(elm_object_item_widget_get(item->getElmObjectItem()), obj, _contacts_messenger._uri, typeStr.c_str()); + + popup->setOnSelectCb( [popup,item,obj](int type){ + if( CONTACTS_MESSENGER_TYPE_CUSTOM == type ) + { + item->__showDataTypeInputPopup(); + return; + } + item->__inputData->setMessengerType( item->__record, type, NULL); + std::string typeStr; + item->__inputData->getMessengerTypeStr( item->__record, type, typeStr); + elm_object_text_set( obj, typeStr.c_str()); + popup->destroy(); + }); + + item->attachToView( popup ); + } + + void __showDataTypeInputPopup() + { + CtInputDataTypeCustomPopup* popup = new CtInputDataTypeCustomPopup(); + popup->setOnResultCb([this](const char* text){ + __inputData->setMessengerType( __record, CONTACTS_MESSENGER_TYPE_CUSTOM, (char*)text ); + elm_genlist_item_fields_update( getElmObjectItem(), "elm.icon.1", ELM_GENLIST_ITEM_FIELD_CONTENT); + }); + attachToView( popup ); + } + + static void __messengerChangedCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewMessengerItem* item = (CtInputViewMessengerItem*)data; + char *text = NULL; + text = ctCommonMarkupToUtf8(elm_entry_entry_get(obj)); + item->__inputData->setMessengerMessenger(item->__record, text); + item->updateChangeState( text ); + item->__itemChangedCb(); + SAFE_FREE(text); + } + + static void __messengerDeleteCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewMessengerItem* item = (CtInputViewMessengerItem*)data; + item->updateChangeState(NULL); + item->__itemDeletedCb( item->getElmObjectItem(), item->getIsChanged(), item->__record ); + elm_object_item_del( item->getElmObjectItem() ); + } +private: + CtInputViewMessengerItem(); + + std::shared_ptr<CtData> __inputData; + contacts_record_h __record; + int __addedIndex; + + std::function<void ()> __itemChangedCb; + std::function<void (Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record )> __itemDeletedCb; + std::function<void (Evas_Object*, Elm_Object_Item*)> __activateNextEntryCb; +}; + +#endif /* _CT_INPUT_VIEW_MESSENGER_ITEM_H_ */ diff --git a/lib-contact/ct-detail/src/CtInputViewMsisdnItem.h b/lib-contact/ct-detail/src/CtInputViewMsisdnItem.h new file mode 100644 index 0000000..98ad379 --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputViewMsisdnItem.h @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_INPUT_VIEW_MSISDN_ITEM_H_ +#define _CT_INPUT_VIEW_MSISDN_ITEM_H_ + +#include "CtInputViewGenlistItem.h" +#include "CtInputViewControl.h" +#include "CtData.h" + +class CtInputViewMsisdnItem : public CtInputViewGenlistItem +{ +public: + CtInputViewMsisdnItem( std::shared_ptr<CtData>& inputData, contacts_record_h record) + { + + __inputData = inputData; __record = record; + }; + virtual ~CtInputViewMsisdnItem() {WHIT();} +public: + virtual Elm_Genlist_Item_Class* getItemClassStatic() { + static Elm_Genlist_Item_Class itc = {}; + if( itc.item_style ) + return &itc; + itc.item_style = "2line.bottom"; + itc.func.text_get = __getTextNumber; + itc.func.del = WGENLIST_ITEM_DEL(); + return &itc; + } + +protected: + static char* __getTextNumber(void *data, Evas_Object *obj, const char *part) + { + WHIT(); + WDEBUG("part %s", part); + CtInputViewMsisdnItem *item = (CtInputViewMsisdnItem *)data; + contacts_record_h defaultRecord = item->__record; + if (0 == strcmp(part, "elm.text.sub.left.top")) { + std::string typeStr; + int type = item->__inputData->getNumberType(defaultRecord); + item->__inputData->getNumberTypeStr(defaultRecord, type, typeStr); + WDEBUG("type %d text %s", type, typeStr.c_str()); + return SAFE_STRDUP(typeStr.c_str()); + } else if (0 == strcmp(part, "elm.text.main.left.bottom")) { + return elm_entry_utf8_to_markup(item->__inputData->getNumberNumber(defaultRecord)); + } + return NULL; + } + +protected: + CtInputViewMsisdnItem(); + + std::shared_ptr<CtData> __inputData; + contacts_record_h __record; + +}; + +#endif /* _CT_INPUT_VIEW_MSISDN_ITEM_H_ */ diff --git a/lib-contact/ct-detail/src/CtInputViewNoteItem.h b/lib-contact/ct-detail/src/CtInputViewNoteItem.h new file mode 100644 index 0000000..8c4e183 --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputViewNoteItem.h @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_INPUT_VIEW_NOTE_ITEM_H_ +#define _CT_INPUT_VIEW_NOTE_ITEM_H_ + +#include "CtInputViewGenlistItem.h" +#include "CtDetailDataBase.h" +#include "CtInputViewControl.h" +#include "CtData.h" +#include "CtString.h" + +class CtInputViewNoteItem : public CtInputViewGenlistItem +{ +public: + CtInputViewNoteItem( std::shared_ptr<CtData>& inputData, contacts_record_h record, const char* oldVal, int addedIndex, + const std::function<void ()>& itemChangedCb, + const std::function<void (Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record )>& itemDeletedCb, + const std::function<void (Evas_Object*, Elm_Object_Item* )>& activateNextEntryCb) : CtInputViewGenlistItem(oldVal) + { + __inputData = inputData; __record = record; __addedIndex = addedIndex; + __itemChangedCb = itemChangedCb; __itemDeletedCb = itemDeletedCb; __activateNextEntryCb = activateNextEntryCb; + }; + virtual ~CtInputViewNoteItem() { WHIT(); } +public: + virtual Elm_Genlist_Item_Class* getItemClassStatic() { + static Elm_Genlist_Item_Class itc = {}; + if( itc.item_style ) + return &itc; + itc.item_style = "input.2icon"; + itc.func.content_get = __getContentNote; + itc.func.del = WGENLIST_ITEM_DEL(); + return &itc; + } + + virtual const char* getEntryObjPartName() + { + return "elm.icon.entry"; + } + +private: + static Evas_Object* __getContentNote(void *data, Evas_Object *obj, const char *part) + { + //WHIT(); + CtInputViewNoteItem *item = (CtInputViewNoteItem*)data; + + if (0 == strcmp(part, "elm.icon.entry")) + { + WEditfield *editfield = item->createEditField(obj, V_("IDS_PB_BUTTON_NOTES"), true); + Evas_Object *entry = editfield->getEntry(); + + elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_WORD); + elm_entry_input_panel_imdata_set(entry, (void*)"allowEmoji=true", 15); + + evas_object_smart_callback_add(entry, "changed", __noteChangedCb, item); + evas_object_smart_callback_add(entry, "preedit,changed", __noteChangedCb, item); + evas_object_smart_callback_add(entry, "activated", __activatedCb, item); + if (INPUT_ADDED_ITEM_INDEX_NOTE == item->__addedIndex) { + evas_object_event_callback_add(entry, EVAS_CALLBACK_SHOW, __entryShowCb, NULL); + } + + const char *note = item->__inputData->getNote( item->__record); + setEntryText(entry, note); + return editfield->getEvasObj(); + } + else if (0 == strcmp(part, "elm.icon.2")) + { + Evas_Object *btn_minus = elm_button_add(obj); + elm_object_part_content_set(obj, "elm.icon.edit", btn_minus); + elm_object_style_set(btn_minus, "icon_expand_delete"); + evas_object_smart_callback_add(btn_minus, "clicked", __noteDeleteCb, item); + + return btn_minus; + } + + return NULL; + } + + static void __entryShowCb(void *data, Evas *e, Evas_Object *obj, void *event_info) + { + WHIT(); + elm_object_focus_set(obj, EINA_TRUE); + evas_object_event_callback_del(obj, EVAS_CALLBACK_SHOW, __entryShowCb); + } + + static void __noteChangedCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewNoteItem* item = (CtInputViewNoteItem*)data; + char *text = NULL; + text = ctCommonMarkupToUtf8(elm_entry_entry_get(obj)); + item->__inputData->setNote(item->__record, text); + item->updateChangeState( text ); + item->__itemChangedCb(); + SAFE_FREE(text); + } + + static void __noteDeleteCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewNoteItem* item = (CtInputViewNoteItem*)data; + item->updateChangeState(NULL); + item->__itemDeletedCb( item->getElmObjectItem(), item->getIsChanged(), item->__record ); + elm_object_item_del( item->getElmObjectItem() ); + } + + static void __activatedCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewNoteItem* item = (CtInputViewNoteItem*)data; + item->__activateNextEntryCb( obj, item->getElmObjectItem() ); + } +private: + CtInputViewNoteItem(); + + std::shared_ptr<CtData> __inputData; + contacts_record_h __record; + int __addedIndex; + + std::function<void ()> __itemChangedCb; + std::function<void (Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record )> __itemDeletedCb; + std::function<void (Evas_Object*, Elm_Object_Item*)> __activateNextEntryCb; +}; + +#endif /* _CT_INPUT_VIEW_NOTE_ITEM_H_ */ diff --git a/lib-contact/ct-detail/src/CtInputViewNumberItem.h b/lib-contact/ct-detail/src/CtInputViewNumberItem.h new file mode 100755 index 0000000..f977a3d --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputViewNumberItem.h @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_INPUT_VIEW_NUMBER_ITEM_H_ +#define _CT_INPUT_VIEW_NUMBER_ITEM_H_ + +#include "CtInputViewGenlistItem.h" +#include "CtDetailDataBase.h" +#include "CtInputDataTypeCtxPopup.h" +#include "CtInputDataTypeCustomPopup.h" +#include "CtInputViewControl.h" +#include "CtData.h" + +class CtInputViewNumberItem : public CtInputViewGenlistItem +{ +public: + CtInputViewNumberItem( CtInputViewControl* control, std::shared_ptr<CtData>& inputData, contacts_record_h record, const char* oldVal, int addedIndex, + const std::function<void ()>& itemChangedCb, + const std::function<void (Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record )>& itemDeletedCb, + const std::function<void (Evas_Object*, Elm_Object_Item* )>& activateNextEntryCb) : CtInputViewGenlistItem(oldVal) + { + __inputControl = control; __inputData = inputData; __record = record; __addedIndex = addedIndex; + __itemChangedCb = itemChangedCb; __itemDeletedCb = itemDeletedCb; __activateNextEntryCb = activateNextEntryCb; + }; + virtual ~CtInputViewNumberItem() {WHIT();} +public: + virtual Elm_Genlist_Item_Class* getItemClassStatic() { + static Elm_Genlist_Item_Class itc = {}; + if( itc.item_style ) + return &itc; + itc.item_style = "input.3icon"; + itc.func.content_get = __getContentNumber; + itc.func.del = WGENLIST_ITEM_DEL(); + return &itc; + } + + virtual const char* getEntryObjPartName() + { + return "elm.icon.entry"; + } + +protected: + static Evas_Object* __getContentNumber(void *data, Evas_Object *obj, const char *part) + { + WHIT(); + CtInputViewNumberItem *item = (CtInputViewNumberItem*)data; + // + if (0 == strcmp(part, "elm.icon.entry")) { + WEditfield *editfield = item->createEditField(obj, NULL, false); + Evas_Object *entry = editfield->getEntry(); + + elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_PHONENUMBER); + +// Elm_Entry_Filter_Accept_Set digits_filter_data; +// digits_filter_data.accepted = "0123456789"; +// digits_filter_data.rejected = NULL; + + evas_object_smart_callback_add(entry, "changed", __numberChangedCb, item); + evas_object_smart_callback_add(entry, "activated", __activatedCb, item); + if (INPUT_ADDED_ITEM_INDEX_NUMBER == item->__addedIndex) { + evas_object_event_callback_add(entry, EVAS_CALLBACK_SHOW, __entryShowCb, NULL); + } + + // this code is for fixing the screen blink issue if launched as UG + const char *number = item->__inputData->getNumberNumber( item->__record); + if (number && *number) { + setEntryText(entry, number); + } + else { + elm_object_domain_translatable_part_text_set(entry, "elm.guide", PACKAGE, "IDS_PB_BODY_PHONE_NUMBER_ABB"); + } + // this code is for fixing the screen blink issue if launched as UG + return editfield->getEvasObj(); + } + else if (0 == strcmp(part, "elm.icon.2")) { + Evas_Object *btn_minus = elm_button_add(obj); + elm_object_style_set(btn_minus, "icon_expand_delete"); + evas_object_smart_callback_add(btn_minus, "clicked", __numberDeleteCb, item); + + return btn_minus; + + } + else if (0 == strcmp(part, "elm.icon.1")) { + Evas_Object *btn_type = elm_button_add(obj); + elm_object_style_set(btn_type, "custom_dropdown"); + evas_object_show(btn_type); + int numberType = item->__inputData->getNumberType( item->__record); + std::string typeStr; + item->__inputData->getNumberTypeStr( item->__record, numberType, typeStr); + elm_object_text_set(btn_type, typeStr.c_str()); + + evas_object_smart_callback_add(btn_type, "clicked", __dataTypeClickedCb, item); + + return btn_type; + } + + return NULL; + } + + static void __activatedCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewNumberItem* item = (CtInputViewNumberItem*)data; + item->__activateNextEntryCb( obj, item->getElmObjectItem() ); + } + static void __entryShowCb(void *data, Evas *e, Evas_Object *obj, void *event_info) + { + WHIT(); + elm_object_focus_set(obj, EINA_TRUE); + evas_object_event_callback_del(obj, EVAS_CALLBACK_SHOW, __entryShowCb); + } + + static void __dataTypeClickedCb(void *data, Evas_Object *obj, void *event_info) + { + WHIT(); + CtInputViewNumberItem* item = (CtInputViewNumberItem*)data; + WPRET_M(NULL == item, "item is NULL"); + + std::string typeStr; + if(item->__inputData->getNumberType(item->__record) == CONTACTS_NUMBER_TYPE_CUSTOM) + { + item->__inputData->getNumberTypeStr(item->__record, CONTACTS_NUMBER_TYPE_CUSTOM, typeStr); + } + CtInputDataTypeCtxPopup* popup = new CtInputDataTypeCtxPopup(elm_object_item_widget_get(item->getElmObjectItem()), obj, _contacts_number._uri, typeStr.c_str()); + + popup->setOnSelectCb( [popup, item, obj](int type){ + int numberType = item->__inputData->getNumberRetType(type); + if(CONTACTS_NUMBER_TYPE_CUSTOM == numberType ) + { + item->__showDataTypeInputPopup(); + return; + } + item->__inputData->setNumberType(item->__record, numberType, NULL); + std::string typeStr; + item->__inputData->getNumberTypeStr(item->__record, numberType, typeStr); + elm_object_text_set( obj, typeStr.c_str()); + + Evas_Object *entry = elm_object_item_part_content_get(item->getElmObjectItem(), "elm.icon.entry"); + if (entry) { + elm_object_focus_set(entry, EINA_TRUE); + } + popup->destroy(); + }); + + item->attachToView(popup); + } + + void __showDataTypeInputPopup() + { + CtInputDataTypeCustomPopup* popup = new CtInputDataTypeCustomPopup(); + popup->setOnResultCb([this](const char* text){ + __inputData->setNumberType( __record, CONTACTS_NUMBER_TYPE_CUSTOM, (char*)text ); + elm_genlist_item_fields_update( getElmObjectItem(), "elm.icon.1", ELM_GENLIST_ITEM_FIELD_CONTENT); + }); + attachToView( popup ); + } + static void __numberChangedCb(void *data, Evas_Object *obj, void *event_info) + { + WENTER(); + CtInputViewNumberItem* item = (CtInputViewNumberItem*)data; + char *text = ctCommonMarkupToUtf8(elm_entry_entry_get(obj)); + + item->updateChangeState(text); + item->__inputData->setNumberNumber(item->__record, text); + item->__itemChangedCb(); + + free(text); + } + + static void __numberDeleteCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewNumberItem* item = (CtInputViewNumberItem*)data; + item->updateChangeState(NULL); + item->__itemDeletedCb( item->getElmObjectItem(), item->getIsChanged(), item->__record ); + elm_object_item_del( item->getElmObjectItem() ); + } +protected: + CtInputViewNumberItem(); + + CtInputViewControl* __inputControl; + std::shared_ptr<CtData> __inputData; + contacts_record_h __record; + int __addedIndex; + + std::function<void ()> __itemChangedCb; + std::function<void (Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record )> __itemDeletedCb; + std::function<void (Evas_Object*, Elm_Object_Item*)> __activateNextEntryCb; +}; + +#endif /* _CT_INPUT_VIEW_NUMBER_ITEM_H_ */ diff --git a/lib-contact/ct-detail/src/CtInputViewRelationItem.h b/lib-contact/ct-detail/src/CtInputViewRelationItem.h new file mode 100644 index 0000000..4b4310c --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputViewRelationItem.h @@ -0,0 +1,231 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_INPUT_VIEW_RELATION_ITEM_H_ +#define _CT_INPUT_VIEW_RELATION_ITEM_H_ + +#include "CtInputViewGenlistItem.h" +#include "CtDetailDataBase.h" +#include "CtInputDataTypeCtxPopup.h" +#include "CtInputDataTypeCustomPopup.h" +#include "CtInputViewControl.h" +#include "CtData.h" +#include "CtPath.h" +#include "ContactsCommon.h" + +#define CONTACTS_BTN_ICON_SIZE 80 + +class CtInputViewRelationItem : public CtInputViewGenlistItem +{ +public: + CtInputViewRelationItem( CtInputViewControl* control, std::shared_ptr<CtData>& inputData, contacts_record_h record, const char* oldVal, + const std::function<void ()>& itemChangedCb, + const std::function<void (Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record )>& itemDeletedCb, + const std::function<void (Evas_Object*, Elm_Object_Item* )>& activateNextEntryCb) + : CtInputViewGenlistItem(oldVal) + { + __control = control; __inputData = inputData; __record = record; + __itemChangedCb = itemChangedCb; __itemDeletedCb = itemDeletedCb; __activateNextEntryCb = activateNextEntryCb; + }; + virtual ~CtInputViewRelationItem() { WHIT(); } +public: + virtual Elm_Genlist_Item_Class* getItemClassStatic() { + static Elm_Genlist_Item_Class itc = {}; + if( itc.item_style ) + return &itc; + itc.item_style = "input.relationship"; + itc.func.content_get = __getContentRelation; + itc.func.del = WGENLIST_ITEM_DEL(); + return &itc; + } + + virtual const char* getEntryObjPartName() + { + return "elm.icon.entry"; + } + +private: + static Evas_Object* __getContentRelation(void *data, Evas_Object *obj, const char *part) + { + WHIT(); + CtInputViewRelationItem *item = (CtInputViewRelationItem*)data; + // + if (0 == strcmp(part, "elm.icon.entry")) { + WEditfield *editfield = item->createEditField(obj, V_("IDS_PB_OPT_RELATIONSHIP_ABB2"), false); + Evas_Object *entry = editfield->getEntry(); + + elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_EMAIL); + + evas_object_smart_callback_add(entry, "changed", __relationshipChangedCb, item); + evas_object_smart_callback_add(entry, "preedit,changed", __relationshipChangedCb, item); + evas_object_smart_callback_add(entry, "activated", __activatedCb, item); + if (INPUT_ADDED_ITEM_INDEX_RELATIONSHIP == item->__control->getAddedIndex()) { + evas_object_event_callback_add(entry, EVAS_CALLBACK_SHOW, __entryShowCb, NULL); + } + + const char *address = item->__inputData->getRelationshipRelationship(item->__record); + setEntryText(entry, address); + return editfield->getEvasObj(); + } + else if (0 == strcmp(part, "elm.icon.2")) { + Evas_Object *btn_minus = elm_button_add(obj); + elm_object_style_set(btn_minus, "icon_expand_delete"); + evas_object_smart_callback_add(btn_minus, "clicked", __relationshipDeleteCb, item); + + return btn_minus; + } + else if (0 == strcmp(part, "elm.icon.1")) { + Evas_Object *btn_type = elm_button_add(obj); + elm_object_style_set(btn_type, "custom_dropdown"); + evas_object_show(btn_type); + + int relationshipType = item->__inputData->getRelationshipType(item->__record); + std::string typeStr; + item->__inputData->getRelationshipTypeStr(item->__record, relationshipType, typeStr); + elm_object_text_set(btn_type, typeStr.c_str()); + + evas_object_smart_callback_add(btn_type, "clicked", __dataTypeClickedCb, item); + return btn_type; + } else if (0 == strcmp(part, "elm.icon.3")) { + Evas_Object *image = elm_image_add(obj); + const std::string edjPath = ContactsCommon::getAppEdjePath(DETAIL_LAYOUT_EDJ); + elm_image_file_set(image, edjPath.c_str(), GROUP_BTN_IC_MULTIPLE); + evas_object_size_hint_min_set(image, ContactsCommon::getScaledWidth(CONTACTS_BTN_ICON_SIZE), ContactsCommon::getScaledHeight(CONTACTS_BTN_ICON_SIZE)); + evas_object_propagate_events_set(image, EINA_FALSE); + evas_object_smart_callback_add(image, "clicked", __relationshipSelectContact, item); + return image; + } + + return NULL; + } + + static void __activatedCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewRelationItem* item = (CtInputViewRelationItem*)data; + item->__activateNextEntryCb( obj, item->getElmObjectItem() ); + } + static void __entryShowCb(void *data, Evas *e, Evas_Object *obj, void *event_info) + { + WHIT(); + elm_object_focus_set(obj, EINA_TRUE); + evas_object_event_callback_del(obj, EVAS_CALLBACK_SHOW, __entryShowCb); + } + + static void __dataTypeClickedCb(void *data, Evas_Object *obj, void *event_info) + { + WHIT(); + CtInputViewRelationItem* item = (CtInputViewRelationItem*)data; + // + std::string typeStr; + if( item->__inputData->getRelationshipType( item->__record) == CONTACTS_RELATIONSHIP_TYPE_CUSTOM) + { + item->__inputData->getRelationshipTypeStr( item->__record, CONTACTS_RELATIONSHIP_TYPE_CUSTOM, typeStr); + } + CtInputDataTypeCtxPopup* popup = new CtInputDataTypeCtxPopup(elm_object_item_widget_get(item->getElmObjectItem()), obj, _contacts_relationship._uri, typeStr.c_str()); + + popup->setOnSelectCb( [popup,item,obj](int type){ + if( CONTACTS_RELATIONSHIP_TYPE_CUSTOM == type ) + { + item->__showDataTypeInputPopup(); + return; + } + item->__inputData->setRelationshipType( item->__record, type, NULL); + std::string typeStr; + item->__inputData->getRelationshipTypeStr( item->__record, type, typeStr); + elm_object_text_set( obj, typeStr.c_str()); + popup->destroy(); + }); + + item->attachToView( popup ); + } + + void __showDataTypeInputPopup() + { + CtInputDataTypeCustomPopup* popup = new CtInputDataTypeCustomPopup(); + popup->setOnResultCb([this](const char* text){ + __inputData->setRelationshipType( __record, CONTACTS_RELATIONSHIP_TYPE_CUSTOM, (char*)text ); + elm_genlist_item_fields_update( getElmObjectItem(), "elm.icon.1", ELM_GENLIST_ITEM_FIELD_CONTENT); + }); + attachToView( popup ); + } + static void __relationshipChangedCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewRelationItem* item = (CtInputViewRelationItem*)data; + char *text = NULL; + text = ctCommonMarkupToUtf8(elm_entry_entry_get(obj)); + item->__inputData->setRelationshipRelationship(item->__record, text); + item->updateChangeState(text); + item->__itemChangedCb(); + SAFE_FREE(text); + } + static void __relationshipDeleteCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewRelationItem* item = (CtInputViewRelationItem*)data; + item->updateChangeState(NULL); + item->__itemDeletedCb( item->getElmObjectItem(), item->getIsChanged(), item->__record ); + elm_object_item_del( item->getElmObjectItem() ); + } + static void __relationshipSelectContact(void *data, Evas_Object *obj, void *event_info) + { + launchContactPick(APP_CONTROL_DATA_SELECTION_MODE_SINGLE, + APP_CONTROL_DATA_TYPE_ID, __contactPickCb, data); + } + + static void __contactPickCb(app_control_h request, app_control_h reply, app_control_result_e result, void *data) + { + CtInputViewRelationItem *item = (CtInputViewRelationItem*)data; + char **personIds = NULL; + int count = 0; + int ret = app_control_get_extra_data_array(reply, APP_CONTROL_DATA_SELECTED, &personIds, &count); + + if (ret == APP_CONTROL_ERROR_NONE && personIds && personIds[0]) { + contacts_record_h record = NULL; + char *displayName = NULL; + + int err = contacts_db_get_record(_contacts_person._uri, atoi(personIds[0]), &record); + WPWARN(err != CONTACTS_ERROR_NONE, "contacts_db_get_record() failed(%d)", err); + + err = contacts_record_get_str_p(record, _contacts_person.display_name, &displayName); + WPWARN(err != CONTACTS_ERROR_NONE, "contacts_record_get_str_p() failed(%d)", err); + + ctCommonRemoveNewline(displayName); + item->__inputData->setRelationshipRelationship(item->__record, displayName); + elm_genlist_item_fields_update(item->getElmObjectItem(), "elm.icon.entry", ELM_GENLIST_ITEM_FIELD_CONTENT); + + contacts_record_destroy(record, true); + } + + for (int i = 0; i < count; ++i) { + free(personIds[i]); + } + free(personIds); + } + +private: + CtInputViewRelationItem(); + + CtInputViewControl* __control; + std::shared_ptr<CtData> __inputData; + contacts_record_h __record; + + std::function<void ()> __itemChangedCb; + std::function<void (Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record )> __itemDeletedCb; + std::function<void (Evas_Object*, Elm_Object_Item*)> __activateNextEntryCb; + +}; + +#endif /* _CT_INPUT_VIEW_RELATION_ITEM_H_ */ diff --git a/lib-contact/ct-detail/src/CtInputViewWebsiteItem.h b/lib-contact/ct-detail/src/CtInputViewWebsiteItem.h new file mode 100644 index 0000000..49c38c7 --- /dev/null +++ b/lib-contact/ct-detail/src/CtInputViewWebsiteItem.h @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_INPUT_VIEW_WEBSITE_ITEM_H_ +#define _CT_INPUT_VIEW_WEBSITE_ITEM_H_ + +#include "CtInputViewGenlistItem.h" +#include "CtDetailDataBase.h" +#include "CtData.h" + +class CtInputViewWebsiteItem : public CtInputViewGenlistItem +{ +public: + CtInputViewWebsiteItem( std::shared_ptr<CtData>& inputData, contacts_record_h record, const char* oldVal, int addedIndex, + const std::function<void ()>& itemChangedCb, + const std::function<void (Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record )>& itemDeletedCb, + const std::function<void (Evas_Object*, Elm_Object_Item* )>& activateNextEntryCb) : CtInputViewGenlistItem(oldVal) + { + __inputData = inputData; __record = record; __addedIndex = addedIndex; + __itemChangedCb = itemChangedCb; __itemDeletedCb = itemDeletedCb; __activateNextEntryCb = activateNextEntryCb; + }; + virtual ~CtInputViewWebsiteItem() { WHIT(); } +public: + virtual Elm_Genlist_Item_Class* getItemClassStatic() { + static Elm_Genlist_Item_Class itc = {}; + if( itc.item_style ) + return &itc; + itc.item_style = "input.2icon"; + itc.func.content_get = __getContentWebsite; + itc.func.del = WGENLIST_ITEM_DEL(); + return &itc; + } + + virtual const char* getEntryObjPartName() + { + return "elm.icon.entry"; + } + +private: + static Evas_Object* __getContentWebsite(void *data, Evas_Object *obj, const char *part) + { + //WHIT(); + CtInputViewWebsiteItem *item = (CtInputViewWebsiteItem*)data; + if (0 == strcmp(part, "elm.icon.entry")) + { + WEditfield *editfield = item->createEditField(obj,V_("IDS_PB_BODY_WEBSITE_ABB"), false); + Evas_Object *entry = editfield->getEntry(); + + elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_URL); + evas_object_smart_callback_add(entry, "changed", __websiteChangedCb, item); + evas_object_smart_callback_add(entry, "preedit,changed", __websiteChangedCb, item); + evas_object_smart_callback_add(entry, "activated", __activatedCb, item); + if (INPUT_ADDED_ITEM_INDEX_URL == item->__addedIndex) { + evas_object_event_callback_add(entry, EVAS_CALLBACK_SHOW, __entryShowCb, NULL); + } + + const char *url = item->__inputData->getWebsiteWebsite(item->__record); + setEntryText(entry, url); + return editfield->getEvasObj(); + } + else if (0 == strcmp(part, "elm.icon.2")) { + Evas_Object *btn_minus = elm_button_add(obj); + elm_object_part_content_set(obj, "elm.icon.edit", btn_minus); + elm_object_style_set(btn_minus, "icon_expand_delete"); + evas_object_smart_callback_add(btn_minus, "clicked", __websiteDeleteCb, item); + + return btn_minus; + } + + return NULL; + } + + static void __activatedCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewWebsiteItem* item = (CtInputViewWebsiteItem*)data; + item->__activateNextEntryCb( obj, item->getElmObjectItem() ); + } + static void __entryShowCb(void *data, Evas *e, Evas_Object *obj, void *event_info) + { + WHIT(); + elm_object_focus_set(obj, EINA_TRUE); + evas_object_event_callback_del(obj, EVAS_CALLBACK_SHOW, __entryShowCb); + } + static void __websiteChangedCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewWebsiteItem* item = (CtInputViewWebsiteItem*)data; + char *text = NULL; + text = ctCommonMarkupToUtf8(elm_entry_entry_get(obj)); + item->__inputData->setWebsiteWebsite(item->__record, text); + item->updateChangeState( text ); + item->__itemChangedCb(); + SAFE_FREE(text); + } + static void __websiteDeleteCb(void *data, Evas_Object *obj, void *event_info) + { + CtInputViewWebsiteItem* item = (CtInputViewWebsiteItem*)data; + item->updateChangeState(NULL); + item->__itemDeletedCb( item->getElmObjectItem(), item->getIsChanged(), item->__record ); + elm_object_item_del( item->getElmObjectItem() ); + } +private: + CtInputViewWebsiteItem(); + + std::shared_ptr<CtData> __inputData; + contacts_record_h __record; + int __addedIndex; + + std::function<void ()> __itemChangedCb; + std::function<void (Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record )> __itemDeletedCb; + std::function<void (Evas_Object*, Elm_Object_Item*)> __activateNextEntryCb; +}; + +#endif /* _CT_INPUT_VIEW_WEBSITE_ITEM_H_ */ diff --git a/lib-contact/ct-detail/src/CtMyProfileDetailData.cpp b/lib-contact/ct-detail/src/CtMyProfileDetailData.cpp new file mode 100755 index 0000000..bb8ccfe --- /dev/null +++ b/lib-contact/ct-detail/src/CtMyProfileDetailData.cpp @@ -0,0 +1,1138 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "ContactsDebug.h" + +#include "CtMyProfileDetailData.h" +#include "CtCommon.h" + +CtMyProfileDetailData::CtMyProfileDetailData() +{ + init(); + int err = CONTACTS_ERROR_NONE; + + __listener = NULL; + err = contacts_db_add_changed_cb(_contacts_my_profile._uri, __onPersonChanged, this); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_add_changed_cb() Failed(%d)", err); +} + +CtMyProfileDetailData::~CtMyProfileDetailData() +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + err = contacts_db_remove_changed_cb(_contacts_my_profile._uri, __onPersonChanged, this); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_remove_changed_cb() Failed(%d)", err); + deInit(); +} + +void CtMyProfileDetailData::deInit() +{ + WHIT(); + i18n_udate_destroy (__formatter); + + __freeRecordList(__numberList); + __freeRecordList(__emailList); + __freeRecordList(__addressList); + __freeRecordList(__messengerList); + __freeRecordList(__relationshipList); + __freeRecordList(__urlList); + __freeRecordList(__eventList); + __freeRecordList(__noteList); + __freeRecordList(__contactList); + + contacts_record_destroy(__defaultNumberRecord, true); + contacts_record_destroy(__personRecord, true); + free(__displayName); + free(__imagePath); + WHIT(); +} + +void CtMyProfileDetailData::init() +{ + WHIT(); + + __imagePath = NULL; + __displayName = NULL; + __extraName = NULL; + __phoneticName = NULL; + __nickName = NULL; + __company = NULL; + __messageAlert = NULL; + __vibration = NULL; + + __contactList = NULL; + __numberList = NULL; + __emailList = NULL; + __addressList = NULL; + __messengerList = NULL; + __relationshipList = NULL; + __urlList = NULL; + __eventList = NULL; + __noteList = NULL; + + int err = CONTACTS_ERROR_NONE; + contacts_list_h myprofileList = NULL; + int count = 0; + contacts_record_h record = NULL; + + err = contacts_db_get_all_records(_contacts_my_profile._uri, 0, 0, &myprofileList); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_all_records() Failed(%d)", err); + + if (myprofileList != NULL) { + contacts_list_get_count(myprofileList, &count); + if (count > 0) { + err = contacts_list_get_current_record_p(myprofileList, &record); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_get_current_record_p() Failed(%d)", err); + err = contacts_record_get_int(record, _contacts_my_profile.id, &__personId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + } + } + if(NULL == record){ + WPWARN(NULL == record, "record is NULL"); + contacts_list_destroy(myprofileList, true); + return; + } + err = contacts_record_clone(record, &__personRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_clone() Failed(%d)", err); + err = contacts_list_destroy(myprofileList, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_get_count() Failed(%d)", err); + + // get basic info + __getBasicInfo(__personRecord, __contactList); + + // get number list + __defaultNumberRecord = __getDefaultNumber(); + __numberList = __getChildNumberList(); + // get email list + __emailList = __getChildDataList(__contactList, _contacts_my_profile.email); + // get address list + __addressList = __getChildDataList(__contactList, _contacts_my_profile.address); + // get messenger list + __messengerList = __getChildDataList(__contactList, _contacts_my_profile.messenger); + // get url list + __urlList = __getChildDataList(__contactList, _contacts_my_profile.url); + // get relationship list + __relationshipList = __getChildDataList(__contactList, _contacts_my_profile.relationship); + // get event list + __eventList = __getChildDataList(__contactList, _contacts_my_profile.event); + // get note list + __noteList = __getChildDataList(__contactList, _contacts_my_profile.note); + + __formatter = __initTimeFormatter(); +} + +int CtMyProfileDetailData::getPersonId() +{ + WHIT(); + + return __personId; +} + +contacts_record_h CtMyProfileDetailData::getPersonRecord() +{ + WHIT(); + + return __personRecord; +} + +Eina_List* CtMyProfileDetailData::getContactsList() +{ + return __contactList; +} + +int CtMyProfileDetailData::setFavorite(bool favorite) +{ + return 0; +} + +bool CtMyProfileDetailData::getFavorite() +{ + return false; +} + +const char* CtMyProfileDetailData::getImagePath() +{ + return __imagePath; +} + +const char* CtMyProfileDetailData::getDisplayName() +{ + return __displayName; +} + +const char* CtMyProfileDetailData::getExtraName() +{ + return __extraName; +} + +const char* CtMyProfileDetailData::getPhoneticName() +{ + return __phoneticName; +} + +const char* CtMyProfileDetailData::getNickName() +{ + return __nickName; +} + +const char* CtMyProfileDetailData::getCompany() +{ + return __company; +} + +const char* CtMyProfileDetailData::getMessageAlert() +{ + return __messageAlert; +} + +const char* CtMyProfileDetailData::getVibration() +{ + return __vibration; +} + + +Eina_List* CtMyProfileDetailData::getNumberList() +{ + return __numberList; +} + +Eina_List* CtMyProfileDetailData::getEmailList() +{ + return __emailList; +} + +Eina_List* CtMyProfileDetailData::getAddressList() +{ + return __addressList; +} + +Eina_List* CtMyProfileDetailData::getMessengerList() +{ + return __messengerList; +} + +Eina_List* CtMyProfileDetailData::getUrlList() +{ + return __urlList; +} + +Eina_List* CtMyProfileDetailData::getRelationshipList() +{ + return __relationshipList; +} + +Eina_List* CtMyProfileDetailData::getEventList() +{ + return __eventList; +} + +Eina_List* CtMyProfileDetailData::getNoteList() +{ + return __noteList; +} + +contacts_record_h CtMyProfileDetailData::getDefNumberRecord() +{ + return __defaultNumberRecord; +} + +const char* CtMyProfileDetailData::getNumber(contacts_record_h record) +{ + char *value = NULL; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_str_p(record, _contacts_number.number, &value); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_str_p() Failed(%d)", err); + + return value; +} + +int CtMyProfileDetailData::getNumberType(contacts_record_h record) +{ + int type = 0; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_int(record, _contacts_number.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, CONTACTS_NUMBER_TYPE_OTHER, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +void CtMyProfileDetailData::getNumberTypeStr(contacts_record_h record, int numberType, std::string &typeString) +{ + WHIT(); + const char* typeStr = NULL; + char buf[128] = {0,}; + + if (numberType & CONTACTS_NUMBER_TYPE_CUSTOM) { + typeStr = getDataTypeCustom(record, _contacts_number.label); + + } + else if (numberType & CONTACTS_NUMBER_TYPE_CELL) { + if (numberType & CONTACTS_NUMBER_TYPE_HOME) { + snprintf(buf, sizeof(buf),"%s 2", V_("IDS_PB_OPT_HOME_ABB")); + typeStr = buf; + } + else if (numberType & CONTACTS_NUMBER_TYPE_WORK) { + snprintf(buf, sizeof(buf),"%s 2", V_("IDS_PB_OPT_WORK")); + typeStr = buf; + } + else { + typeStr = V_("IDS_PB_OPT_MOBILE"); + } + } + else if (numberType & CONTACTS_NUMBER_TYPE_VOICE) { + if (numberType & CONTACTS_NUMBER_TYPE_HOME) { + typeStr = V_("IDS_PB_OPT_HOME_ABB"); + } + else if (numberType & CONTACTS_NUMBER_TYPE_WORK) { + typeStr = V_("IDS_PB_OPT_WORK"); + } + else { + typeStr = V_("IDS_PB_BODY_TELEPHONE"); + } + } + else if (numberType & CONTACTS_NUMBER_TYPE_FAX) { + if (numberType & CONTACTS_NUMBER_TYPE_HOME) { + typeStr = V_("IDS_PB_OPT_FAX_HHOME_ABB"); + } + else if (numberType & CONTACTS_NUMBER_TYPE_WORK) { + typeStr = V_("IDS_PB_OPT_FAX_HWORK_ABB"); + } + else { + typeStr = V_("IDS_PB_BODY_FAX"); + } + } + else if (numberType & CONTACTS_NUMBER_TYPE_MAIN) { + typeStr = V_("IDS_PB_OPT_MAIN"); + } + else if (numberType & CONTACTS_NUMBER_TYPE_PAGER) { + typeStr = V_("IDS_PB_OPT_PAGER"); + } + else { + if (numberType & CONTACTS_NUMBER_TYPE_HOME) { + typeStr = V_("IDS_PB_OPT_HOME_ABB"); + } + else if (numberType & CONTACTS_NUMBER_TYPE_WORK) { + typeStr = V_("IDS_PB_OPT_WORK"); + } + else { + typeStr = V_("IDS_PB_OPT_OTHER"); + } + } + + char *result = elm_entry_utf8_to_markup(typeStr); + if (result) { + typeString = result; + free(result); + } +} + +const char* CtMyProfileDetailData::getNumberTypeCustom(contacts_record_h record) +{ + char* type = NULL; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_str_p(record, _contacts_number.label, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +const char* CtMyProfileDetailData::getEmail(contacts_record_h record) +{ + WHIT(); + char *value = NULL; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_str_p(record, _contacts_email.email, &value); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_str_p() Failed(%d)", err); + + return value; +} + +int CtMyProfileDetailData::getEmailType(contacts_record_h record) +{ + WHIT(); + int type = 0; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_int(record, _contacts_email.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, CONTACTS_EMAIL_TYPE_OTHER, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +void CtMyProfileDetailData::getEmailTypeStr(contacts_record_h record, int indexType, std::string &typeString) +{ + WHIT(); + const char* typeStr = NULL; + + if (indexType & CONTACTS_EMAIL_TYPE_CUSTOM) { + typeStr = getDataTypeCustom(record, _contacts_email.label); + } + else if (indexType & CONTACTS_EMAIL_TYPE_HOME) { + typeStr = V_("IDS_PB_OPT_HOME_ABB"); + } + else if (indexType & CONTACTS_EMAIL_TYPE_WORK) { + typeStr = V_("IDS_PB_OPT_WORK"); + } + else { + typeStr = V_("IDS_PB_OPT_OTHER"); + } + + char *result = elm_entry_utf8_to_markup(typeStr); + if (result) { + typeString = result; + free(result); + } +} + +int CtMyProfileDetailData::getAddress(contacts_record_h record, char *buf, int length) +{ + WHIT(); + return __getFullAddress(record, buf, length); +} + + +int CtMyProfileDetailData::getAddressType(contacts_record_h record) +{ + int type = 0; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_int(record, _contacts_address.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +const char* CtMyProfileDetailData::getDataTypeCustom(contacts_record_h record, int property_id) +{ + char* typeStr = NULL; + const char* result = NULL; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_str_p(record, property_id, &typeStr); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_int() Failed(%d)", err); + + result = typeStr; + return result; +} + +void CtMyProfileDetailData::getAddressTypeStr(contacts_record_h record, int indexType, std::string &typeString) +{ + WHIT(); + const char* typeStr = NULL; + + if (indexType & CONTACTS_ADDRESS_TYPE_CUSTOM) { + typeStr = getDataTypeCustom(record, _contacts_address.label); + } + else if (indexType & CONTACTS_ADDRESS_TYPE_HOME) { + typeStr = V_("IDS_PB_OPT_HOME_ABB"); + } + else if (indexType & CONTACTS_ADDRESS_TYPE_WORK) { + typeStr = V_("IDS_PB_OPT_WORK"); + } + else { + typeStr = V_("IDS_PB_OPT_OTHER"); + } + + char *result = elm_entry_utf8_to_markup(typeStr); + if (result) { + typeString = result; + free(result); + } +} + +const char* CtMyProfileDetailData::getUrl(contacts_record_h record) +{ + char *value = NULL; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_str_p(record, _contacts_url.url, &value); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_str_p() Failed(%d)", err); + + return value; +} + +int CtMyProfileDetailData::getUrlType(contacts_record_h record) +{ + int type = 0; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_int(record, _contacts_url.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +const char* CtMyProfileDetailData::getMessenger(contacts_record_h record) +{ + char *value = NULL; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_str_p(record, _contacts_messenger.im_id, &value); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_str_p() Failed(%d)", err); + + return value; +} + +int CtMyProfileDetailData::getMessengerType(contacts_record_h record) +{ + int type = 0; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_int(record, _contacts_messenger.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +void CtMyProfileDetailData::getMessengerTypeStr(contacts_record_h record, int indexType, std::string &typeString) +{ + WHIT(); + const char* typeStr = NULL; + + if (indexType == CONTACTS_MESSENGER_TYPE_CUSTOM) { + typeStr = getDataTypeCustom(record, _contacts_messenger.label); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_AIM) { + typeStr = V_("IDS_PB_OPT_AIM"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_YAHOO) { + typeStr = V_("IDS_PB_OPT_YAHOO_E"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_SKYPE) { + typeStr = V_("IDS_PB_BODY_SKYPE"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_QQ) { + typeStr = V_("IDS_PB_OPT_QQ"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_GOOGLE) { + typeStr = V_("IDS_PB_OPT_HANGOUTS"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_ICQ) { + typeStr = V_("IDS_PB_OPT_ICQ"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_JABBER) { + typeStr = V_("IDS_PB_OPT_JABBER"); + } + + char *result = elm_entry_utf8_to_markup(typeStr); + if (result) { + typeString = result; + free(result); + } +} + +int CtMyProfileDetailData::getEvent(contacts_record_h record) +{ + int date = 0; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_int(record, _contacts_event.date, &date); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return date; +} + +int CtMyProfileDetailData::getEventType(contacts_record_h record) +{ + int type = 0; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_int(record, _contacts_event.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +void CtMyProfileDetailData::getEventTypeStr(contacts_record_h record, int eventType, std::string &typeString) +{ + WHIT(); + const char* typeStr = NULL; + + if (eventType == CONTACTS_EVENT_TYPE_CUSTOM) { + typeStr = getDataTypeCustom(record, _contacts_event.label); + } + else if (eventType == CONTACTS_EVENT_TYPE_BIRTH) { + typeStr = V_("IDS_PB_OPT_BIRTHDAY"); + } + else if (eventType == CONTACTS_EVENT_TYPE_ANNIVERSARY) { + typeStr = V_("IDS_PB_OPT_ANNIVERSARY_ABB"); + } + else { + typeStr = V_("IDS_PB_OPT_OTHER"); + } + + char *result = elm_entry_utf8_to_markup(typeStr); + if (result) { + typeString = result; + free(result); + } +} + +const char* CtMyProfileDetailData::getRelationship(contacts_record_h record) +{ + char *value = NULL; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_str_p(record, _contacts_relationship.name, &value); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_str_p() Failed(%d)", err); + + return value; +} + +int CtMyProfileDetailData::getRelationshipType(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + int type = 0; + + err = contacts_record_get_int(record, _contacts_relationship.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +void CtMyProfileDetailData::getRelationshipTypeStr(contacts_record_h record, int indexType, std::string &typeString) +{ + WHIT(); + const char* typeStr = NULL; + + if (indexType == CONTACTS_RELATIONSHIP_TYPE_CUSTOM) { + typeStr = getDataTypeCustom(record, _contacts_relationship.label); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_ASSISTANT) { + typeStr = V_("IDS_PB_OPT_ASSISTANT_M_CONTACTS"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_BROTHER) { + typeStr = V_("IDS_PB_OPT_BROTHER"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_CHILD) { + typeStr = V_("IDS_PB_OPT_CHILD"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER) { + typeStr = V_("IDS_PB_OPT_DOMESTIC_PARTNER_ABB2"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_FATHER) { + typeStr = V_("IDS_PB_OPT_FATHER"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_FRIEND) { + typeStr = V_("IDS_PB_OPT_FRIEND"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_MANAGER) { + typeStr = V_("IDS_PB_OPT_MANAGER"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_MOTHER) { + typeStr = V_("IDS_PB_OPT_MOTHER"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_PARENT) { + typeStr = V_("IDS_PB_OPT_PARENT"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_PARTNER) { + typeStr = V_("IDS_PB_OPT_PARTNER"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY) { + typeStr = V_("IDS_PB_OPT_REFERRED_BY_ABB"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_RELATIVE) { + typeStr = V_("IDS_PB_OPT_RELATIVE"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_SISTER) { + typeStr = V_("IDS_PB_OPT_SISTER"); + } + else if (indexType == CONTACTS_RELATIONSHIP_TYPE_SPOUSE) { + typeStr = V_("IDS_PB_OPT_SPOUSE"); + } + + char *result = elm_entry_utf8_to_markup(typeStr); + if (result) { + typeString = result; + free(result); + } +} + +const char* CtMyProfileDetailData::getNote(contacts_record_h record) +{ + char *value = NULL; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_str_p(record, _contacts_note.note, &value); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_str_p() Failed(%d)", err); + + return value; +} + +void CtMyProfileDetailData::__onPersonChanged(const char *viewUri, void *userData) +{ + WHIT(); + WPRET_M(NULL == userData, "userData is NULL"); + CtMyProfileDetailData* data = (CtMyProfileDetailData*)userData; + WPRET_M(NULL == data->__listener, "__listener is NULL"); + + data->deInit(); + data->init(); + + data->__listener->onDbChanged(viewUri); +} + +void CtMyProfileDetailData::__freeRecordList(Eina_List *recordList) +{ + int err = CONTACTS_ERROR_NONE; + void *data = NULL; + if(NULL == recordList) { + return; + } + + EINA_LIST_FREE(recordList, data) { + contacts_record_h record = (contacts_record_h)data; + if (NULL == record) continue; + err = contacts_record_destroy(record, true); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_destroy() Failed(%d)", err); + continue; + } + } +} + +void CtMyProfileDetailData::__getBasicInfo(contacts_record_h personRecord, Eina_List *contactList) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_str(personRecord, _contacts_my_profile.display_name, &__displayName); + if(err != CONTACTS_ERROR_NONE) { + WERROR("contacts_record_get_str display_name %d", err); + } + err = contacts_record_get_str(personRecord, _contacts_my_profile.image_thumbnail_path, &__imagePath); + if(err != CONTACTS_ERROR_NONE) { + WERROR("contacts_record_get_str image_thumbnail_path %d", err); + } + ctCommonRemoveNewline(__displayName); + + __getCompany(contactList, &__company); + + __getExtraName1(contactList, &__nickName, &__phoneticName); + + __getExtraName2(__nickName, __phoneticName, &__extraName); + +} + +void CtMyProfileDetailData::__getCompany(Eina_List *contactList, char **dest) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + + contacts_record_h companyRecord = NULL; + + err = contacts_record_get_child_record_at_p(__personRecord, _contacts_my_profile.company, 0, &companyRecord); + if(CONTACTS_ERROR_NONE != err) + WERROR("contacts_record_get_child_record_at_p() Failed(%d)", err); + else { + __getCompanyStr(companyRecord, dest); + } +} + +void CtMyProfileDetailData::__getExtraName2(char* nick, char* phonetic, char** extra) +{ + WHIT(); + char name[CT_TEXT_MAX_LEN+1] = {0, }; + + free(*extra); + + if(phonetic && *phonetic) { + if(nick && *nick) + snprintf(name, sizeof(name), "%s, %s", phonetic, nick); + else + snprintf(name, sizeof(name), "%s", phonetic); + } + else if(nick && *nick) + snprintf(name, sizeof(name), "%s", nick); + + if( strlen(name) > 0) + *extra = strdup(name); + else + *extra = NULL; +} + + +void CtMyProfileDetailData::__getExtraName1(Eina_List *contactList, char **nick, char **phonetic) +{ + WHIT(); + int err1 = CONTACTS_ERROR_NONE; + int err2 = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + contacts_record_h nicknameRecord = NULL; + + err1 = contacts_record_get_child_record_at_p(__personRecord, _contacts_my_profile.name, 0, &nameRecord); + WPWARN(CONTACTS_ERROR_NONE != err1, "contacts_record_get_child_record_at_p() name Failed(%d)", err1); + err2 = contacts_record_get_child_record_at_p(__personRecord, _contacts_my_profile.nickname, 0, &nicknameRecord); + WPWARN(CONTACTS_ERROR_NONE != err2, "contacts_record_get_child_record_at_p() nickname Failed(%d)", err2); + + if (CONTACTS_ERROR_NONE == err1 || CONTACTS_ERROR_NONE == err2) { + __getExtraNameStr(nameRecord, nicknameRecord, nick, phonetic); + } +} + +void CtMyProfileDetailData::__getExtraNameStr(contacts_record_h nameRecord, contacts_record_h nicknameRecord, char **nick, char **phonetic) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + char *nickname = NULL; + int length = 0; + + free(*nick); + free(*phonetic); + *nick = NULL; + *phonetic = NULL; + + char *phoneticFirst = NULL; + char *phoneticMiddle = NULL; + char *phoneticLast = NULL; + char *phoneticFull = NULL; + + if(nicknameRecord) { + err = contacts_record_get_str_p(nicknameRecord, _contacts_nickname.name, (char**)&nickname); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() name Failed(%d)", err); + *nick = SAFE_STRDUP(nickname); + } + + if(nameRecord) { + + contacts_name_display_order_e name_display_order; + contacts_setting_get_name_display_order(&name_display_order); + + err = contacts_record_get_str_p(nameRecord, _contacts_name.phonetic_first, (char**)&phoneticFirst); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() phoneticname Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_name.phonetic_middle, (char**)&phoneticMiddle); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() phoneticname Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_name.phonetic_last, (char**)&phoneticLast); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() phoneticname Failed(%d)", err); + + int phoneticLength = SAFE_STRLEN(phoneticFirst) + SAFE_STRLEN(phoneticMiddle) + SAFE_STRLEN(phoneticLast) + 3; + WDEBUG("phoneticLength = %d", phoneticLength); + phoneticFull = (char*)malloc(sizeof(char)*phoneticLength); + WPRET_M(NULL == phoneticFull, "failed to malloc"); + memset(phoneticFull, 0, sizeof(char)*phoneticLength); + + if (CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST == name_display_order) { + if (phoneticFirst && *phoneticFirst) { + strncat(phoneticFull, phoneticFirst, SAFE_STRLEN(phoneticFirst)); + } + if (phoneticMiddle && *phoneticMiddle) { + if (phoneticFull && *phoneticFull) { + strncat(phoneticFull, " ", 1); + } + strncat(phoneticFull, phoneticMiddle, SAFE_STRLEN(phoneticMiddle)); + } + if (phoneticLast && *phoneticLast) { + if (phoneticFull && *phoneticFull) { + strncat(phoneticFull, " ", 1); + } + strncat(phoneticFull, phoneticLast, SAFE_STRLEN(phoneticLast)); + } + } + else { + if (phoneticLast && *phoneticLast) { + strncat(phoneticFull, phoneticLast, SAFE_STRLEN(phoneticLast)); + } + if (phoneticFirst && *phoneticFirst) { + if (phoneticFull && *phoneticFull) { + strncat(phoneticFull, " ", 1); + } + strncat(phoneticFull, phoneticFirst, SAFE_STRLEN(phoneticFirst)); + } + if (phoneticMiddle && *phoneticMiddle) { + if (phoneticFull && *phoneticFull) { + strncat(phoneticFull, " ", 1); + } + strncat(phoneticFull, phoneticMiddle, SAFE_STRLEN(phoneticMiddle)); + } + } + length += phoneticLength; + + *phonetic = SAFE_STRDUP(phoneticFull); + free(phoneticFull); + } + +} + +void CtMyProfileDetailData::__getCompanyStr(contacts_record_h companyRecord, char **dest) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + char *company, *job, *department; + char *fullName = NULL; + int length = 0; + *dest = NULL; + + err = contacts_record_get_str_p(companyRecord, _contacts_company.name, (char**)&company); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + err = contacts_record_get_str_p(companyRecord, _contacts_company.department, (char**)&department); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + err = contacts_record_get_str_p(companyRecord, _contacts_company.job_title, (char**)&job); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + + length = SAFE_STRLEN(company) + SAFE_STRLEN(department) + SAFE_STRLEN(job) + 5; + WDEBUG("length = %d", length); + + fullName = (char*)malloc(sizeof(char)*length); + WPRET_M(NULL == fullName, "failed to malloc"); + memset(fullName, 0, sizeof(char)*length); + + if (company) { + strncat(fullName, company, SAFE_STRLEN(company)); + } + + if (department) { + if (fullName && *fullName) { + strncat(fullName, ", ", 2); + } + strncat(fullName, department, SAFE_STRLEN(department)); + } + + if (job) { + if (fullName && *fullName) { + strncat(fullName, ", ", 2); + } + strncat(fullName, job, SAFE_STRLEN(job)); + } + + *dest = SAFE_STRDUP(fullName); + free(fullName); + fullName = NULL; +} + +void CtMyProfileDetailData::__appendStringWithLinebreak(const char *src, char *dest, int length) +{ + char temp[CT_TEXT_MAX_LEN]; + if (src && '\0' != src[0]) { + if ('\0' == dest[0]) + snprintf(dest, length, "%s", src); + else { + snprintf(temp, sizeof(temp), "%s\n%s", src, dest); + snprintf(dest, length, "%s", temp); + } + } +} + +int CtMyProfileDetailData::__getFullAddress(contacts_record_h addresssRecord, char *buf, int length) +{ + WHIT(); + const char *code = NULL; + const char *region = NULL; + const char *locality = NULL; + const char *street = NULL; + const char *extended = NULL; + const char *country = NULL; + const char *pobox = NULL; + int err = CONTACTS_ERROR_NONE; + + do { + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.postal_code , (char**)&code))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.extended , (char**)&extended))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.postbox , (char**)&pobox))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.street , (char**)&street))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.locality , (char**)&locality))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.region , (char**)®ion))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.country ,(char**)&country))) break; + } while (0); + if(CONTACTS_ERROR_NONE != err) + WERROR("contacts_record_get_str_p() Failed(%d)", err); + + __appendStringWithLinebreak(country, buf, length); + __appendStringWithLinebreak(code, buf, length); + __appendStringWithLinebreak(region, buf, length); + __appendStringWithLinebreak(locality, buf, length); + __appendStringWithLinebreak(street, buf, length); + __appendStringWithLinebreak(extended, buf, length); + __appendStringWithLinebreak(pobox, buf, length); + return 0; +} + + +Eina_List* CtMyProfileDetailData::__getChildDataList(Eina_List *contactList, unsigned int propertyId) +{ + WDEBUG("propertyId %d", propertyId); + int index = 0; + + Eina_List *dataRecordList = NULL; + int err = CONTACTS_ERROR_NONE; + contacts_record_h dataRecord = NULL; + contacts_record_h dataRecordClone = NULL; + + while (CONTACTS_ERROR_NONE == contacts_record_get_child_record_at_p(__personRecord, propertyId, index++, &dataRecord)) { + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_str_p() Failed(%d)", err); + break; + } + err = contacts_record_clone(dataRecord, &dataRecordClone); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_list_get_current_record_p() Failed(%d)", err); + break; + } + dataRecordList = eina_list_append(dataRecordList, dataRecordClone); + } + return dataRecordList; +} + +Eina_List* CtMyProfileDetailData::__getChildNumberList() +{ + WHIT(); + + int index = 0; + bool value = 0; + Eina_List *dataRecordList = NULL; + int err = CONTACTS_ERROR_NONE; + contacts_record_h dataRecord = NULL; + contacts_record_h dataRecordClone = NULL; + + while (CONTACTS_ERROR_NONE == contacts_record_get_child_record_at_p(__personRecord, _contacts_my_profile.number, index++, &dataRecord)) { + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_str_p() Failed(%d)", err); + break; + } + + err = contacts_record_get_bool(dataRecord, _contacts_number.is_default, &value); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_bool() Failed(%d)", err); + if (value != true) { + err = contacts_record_clone(dataRecord, &dataRecordClone); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_clone() Failed(%d)", err); + break; + } + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_clone() Failed(%d)", err); + dataRecordList = eina_list_append(dataRecordList, dataRecordClone); + } + } + + return dataRecordList; +} + +contacts_record_h CtMyProfileDetailData::__getDefaultNumber() +{ + int index = 0; + bool value = 0; + int err = CONTACTS_ERROR_NONE; + contacts_record_h dataRecord = NULL; + contacts_record_h dataRecordClone = NULL; + + while (CONTACTS_ERROR_NONE == contacts_record_get_child_record_at_p(__personRecord, _contacts_my_profile.number, index++, &dataRecord)) { + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_str_p() Failed(%d)", err); + break; + } + + err = contacts_record_get_bool(dataRecord, _contacts_number.is_default, &value); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_bool() Failed(%d)", err); + if (value == true) { + err = contacts_record_clone(dataRecord, &dataRecordClone); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_clone() Failed(%d)", err); + break; + } + return dataRecordClone; + } + } + + return NULL; +} + +i18n_udate_format_h CtMyProfileDetailData::__initTimeFormatter() +{ + const char *locale; + int32_t pattern_capacity; + i18n_uchar pattern[256]; + i18n_uchar customSkeleton[256]; + i18n_udate_format_h formatter = NULL; + i18n_udatepg_h generator = NULL; + int status = I18N_ERROR_NONE; + int bestPatternLength; + + i18n_ustring_copy_ua_n(customSkeleton, "yMMMMd", SAFE_STRLEN("yMMMMd")); + + status = i18n_ulocale_get_default(&locale); + WPRET_VM(NULL == locale, NULL, "uloc_getDefault() return NULL"); + + status = i18n_udatepg_create (locale, &generator); + + pattern_capacity = (int32_t) (sizeof(pattern) / sizeof((pattern)[0])); + status = i18n_udatepg_get_best_pattern (generator, customSkeleton, 6, pattern, pattern_capacity, &bestPatternLength); + + if (!status) + status = i18n_udate_create (I18N_UDATE_PATTERN , I18N_UDATE_PATTERN , locale, NULL, -1, pattern, -1, &formatter); + + i18n_udatepg_destroy(generator); + return formatter; +} + +char* CtMyProfileDetailData::getDatetimeStr(i18n_udate_format_h formatter, int year, int mon, int day) +{ + char *ret_str = NULL; + char formatted_str[256]; + i18n_uchar formatted[256] = {0, }; + int status = I18N_ERROR_NONE; + i18n_udate millis = 0; + i18n_ucalendar_h cal = NULL; + int formattedLength = 0; + + const char* locale = NULL; + status = i18n_ulocale_get_default(&locale); + + status = i18n_ucalendar_create(NULL, -1, locale, I18N_UCALENDAR_TRADITIONAL , &cal); + WPRET_VM(status, NULL, "ucal_open() Failed()"); + + status = i18n_ucalendar_set_date_time(cal, year, mon-1, day, 0, 0, 0); + status = i18n_ucalendar_set_attribute(cal, I18N_UCALENDAR_LENIENT , 1); + status = i18n_ucalendar_get_milliseconds(cal, &millis); + + if (status) { + WDEBUG("i18n_ucalendar_get_milliseconds() Failed()"); + i18n_ucalendar_destroy(cal); + return NULL; + } + + status = i18n_udate_format_date(formatter, millis, formatted, 256, NULL, &formattedLength); + + if (status) { + WDEBUG("udat_format() Failed()"); + i18n_ucalendar_destroy(cal); + return NULL; + } + + i18n_ustring_copy_au (formatted_str, formatted); + ret_str = g_strdup(formatted_str); + i18n_ucalendar_destroy(cal); + + return ret_str; +} + +i18n_udate_format_h CtMyProfileDetailData::getDateFormater() +{ + return __formatter; +} + +bool CtMyProfileDetailData::getReadOnlyMode() +{ + return false; +} + +void CtMyProfileDetailData::attachListener(ICtChangeListener* listener) +{ + WASSERT(listener); + __listener = listener; +} + +void CtMyProfileDetailData::detachListener() +{ + __listener = NULL; +} + +char* CtMyProfileDetailData::getVcardStream() const +{ + char* vcardStream = NULL; + int err = contacts_vcard_make_from_my_profile(__personRecord, &vcardStream); + WPRET_VM(err != CONTACTS_ERROR_NONE, NULL, "contacts_vcard_make_from_my_profile() Failed(%d)", err); + return vcardStream; +} diff --git a/lib-contact/ct-detail/src/CtMyProfileDetailData.h b/lib-contact/ct-detail/src/CtMyProfileDetailData.h new file mode 100755 index 0000000..31a6c5f --- /dev/null +++ b/lib-contact/ct-detail/src/CtMyProfileDetailData.h @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_MYPROFILE_DETAIL_DATA_H_ +#define _CT_MYPROFILE_DETAIL_DATA_H_ + +#include <utils_i18n.h> +#include <contacts.h> + +#include "ContactsCommon.h" + +#include "CtType.h" + +#include "CtDetailDataBase.h" +#include "ICtChangeListener.h" + +class CtMyProfileDetailData : public CtDetailDataBase +{ +public: + CtMyProfileDetailData(); + virtual ~CtMyProfileDetailData(); + +public: + + void init(); + void deInit(); + + int getPersonId(); + contacts_record_h getPersonRecord(); + Eina_List* getContactsList(); + int setFavorite(bool favorite); + + const char* getImagePath(); + const char* getDisplayName(); + const char* getExtraName(); + const char* getPhoneticName(); + const char* getNickName(); + const char* getCompany(); + const char* getMessageAlert(); + const char* getVibration(); + bool getFavorite(); + //bool getMFC(); + + Eina_List* getNumberList(); + contacts_record_h getDefNumberRecord(); + const char* getNumber(contacts_record_h record); + int getNumberType(contacts_record_h record); + void getNumberTypeStr(contacts_record_h record, int numberType, std::string &typeString); + const char* getNumberTypeCustom(contacts_record_h record); + Eina_List* getEmailList(); + const char* getEmail(contacts_record_h record); + int getEmailType(contacts_record_h record); + void getEmailTypeStr(contacts_record_h record, int indexType, std::string &typeString); + Eina_List* getAddressList(); + int getAddress(contacts_record_h record, char *buf, int length); + const char* getDataTypeCustom(contacts_record_h record, int property_id); + int getAddressType(contacts_record_h record); + void getAddressTypeStr(contacts_record_h record, int indexType, std::string &typeString); + Eina_List* getMessengerList(); + const char* getMessenger(contacts_record_h record); + int getMessengerType(contacts_record_h record); + void getMessengerTypeStr(contacts_record_h record, int indexType, std::string &typeString); + Eina_List* getUrlList(); + const char* getUrl(contacts_record_h record); + int getUrlType(contacts_record_h record); + Eina_List* getRelationshipList(); + const char* getRelationship(contacts_record_h record); + int getRelationshipType(contacts_record_h record); + void getRelationshipTypeStr(contacts_record_h record, int indexType, std::string &typeString); + Eina_List* getEventList(); + int getEvent(contacts_record_h record); + int getEventType(contacts_record_h record); + void getEventTypeStr(contacts_record_h record, int eventType, std::string &typeString); + Eina_List* getNoteList(); + const char* getNote(contacts_record_h record); + char* getDatetimeStr(i18n_udate_format_h formatter, int year, int mon, int day); + i18n_udate_format_h getDateFormater(); + bool getReadOnlyMode(); + + void attachListener(ICtChangeListener* listener); + void detachListener(); + + char* getVcardStream() const; + +private: + static void __onPersonChanged(const char *viewUri, void *userData); + void __freeRecordList(Eina_List *recordList); + + Eina_List* __getChildDataList(Eina_List *contactList, unsigned int propertyId); + Eina_List* __getChildNumberList(); + contacts_record_h __getDefaultNumber(); + int __getFullAddress(contacts_record_h addresssRecord, char *buf, int length); + void __appendStringWithLinebreak(const char *src, char *dest, int length); + + + void __getBasicInfo(contacts_record_h personRecord, Eina_List *contactList); + void __getCompany(Eina_List *contactList, char **dest); + void __getExtraName1(Eina_List *contactList, char **nick, char **phonetic); + void __getExtraName2(char* nick, char* phonetic, char** extra); + void __getExtraNameStr(contacts_record_h nameRecord, contacts_record_h nicknameRecord, char **nick, char **phonetic); + void __getCompanyStr(contacts_record_h companyRecord, char **dest); + i18n_udate_format_h __initTimeFormatter(); +private: + + int __version; + + int __personId; + contacts_record_h __personRecord; + contacts_record_h __defaultNumberRecord; + + char *__imagePath; + char *__displayName; + char *__extraName; + char *__phoneticName; + char *__nickName; + char *__company; + char *__messageAlert; + char *__vibration; + bool __favorite; + + Eina_List *__contactList; + Eina_List *__numberList; + Eina_List *__emailList; + Eina_List *__addressList; + Eina_List *__messengerList; + Eina_List *__urlList; + Eina_List *__relationshipList; + Eina_List *__eventList; + Eina_List *__noteList; + + i18n_udate_format_h __formatter; + + ICtChangeListener* __listener; +}; + +#endif //_CT_MYPROFILE_DETAIL_DATA_H_ diff --git a/lib-contact/ct-detail/src/CtMyProfileDetailView.cpp b/lib-contact/ct-detail/src/CtMyProfileDetailView.cpp new file mode 100755 index 0000000..7dfc6ba --- /dev/null +++ b/lib-contact/ct-detail/src/CtMyProfileDetailView.cpp @@ -0,0 +1,548 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <app.h> +#include <contacts.h> +#include <app_preference.h> + +#include "WNaviframe.h" +#include "WWindow.h" +#include "WMenuPopup.h" + +#include "ContactsDebug.h" +#include "ContactsAppControlLauncher.h" +#include "CtPath.h" +#include "CtCommon.h" +#include "ContactsCommon.h" + +#include "CtMyProfileDetailView.h" +#include "CtDetailViewBasicInfoControl.h" +#include "CtDetailViewNumberItem.h" +#include "CtDetailViewEmailItem.h" +#include "CtDetailViewNoteItem.h" +#include "CtDetailViewAddressItem.h" +#include "CtDetailViewEventItem.h" +#include "CtDetailViewMessengerItem.h" +#include "CtDetailViewRelationItem.h" +#include "CtDetailViewWebsiteItem.h" +#include "CtMyProfileDetailData.h" +#include "CtMyProfileInputView.h" +#include "CtThemeMgr.h" + +#define __ITEM_HEIGHT 96 + + +CtMyProfileDetailView::CtMyProfileDetailView() +{ + __detailData = new CtMyProfileDetailData(); + __initialize(); +} + +CtMyProfileDetailView::~CtMyProfileDetailView() +{ + WHIT(); + //ctCommonTerminateAppservice(getNaviframe()->getEvasObj()); + destroyPopup(); + delete __detailData; +} + +void CtMyProfileDetailView::__initialize() +{ + for (int i = MYPROFILE_DETAIL_MSISDN; i < MYPROFILE_DETAIL_ITEMS_MAX; i++) { + __genlistItems[i] = {}; + } +} + +const char* CtMyProfileDetailView::getClassName() +{ + return "CtMyProfileDetailView"; +} + +void CtMyProfileDetailView::onDbChanged(const char* viewUri) +{ + WENTER(); + __createBaseInfo(); + __updateGenlist(); +} + +void CtMyProfileDetailView::onCompleteGetContacts(int offset) +{ + WENTER(); +} + +void CtMyProfileDetailView::onConditionChagned() +{ + WENTER(); +} + +Evas_Object* CtMyProfileDetailView::__getWindow(void) +{ + if(getWindow()) + return getWindow()->getEvasObj(); + else + WASSERT_EX(0, "window null"); + + return NULL; +} + +void CtMyProfileDetailView::onDestroy() +{ + WENTER(); + +} + +void CtMyProfileDetailView::onEvent(int eventType) +{ + WENTER(); + +} + +void CtMyProfileDetailView::onPushed(Elm_Object_Item* naviItem) +{ + WHIT(); + elm_naviframe_item_title_enabled_set(naviItem, EINA_FALSE, EINA_FALSE); + + enableMoreButton(naviItem, [](void *data, Evas_Object *obj, void *event_info){ + CtMyProfileDetailView* view = static_cast<CtMyProfileDetailView*>(data); + WMenuPopup* popup = new WMenuPopup(); + popup->prepare(view->__getWindow(), view->getNaviframe()->getEvasObj() ); + + popup->appendItem(V_("IDS_PB_OPT_EDIT"), [view]() + { + view->getNaviframe()->push(new CtMyProfileInputView(NULL), NULL, NULL); + }); + popup->appendItem(V_("IDS_PB_BUTTON_DELETE_ABB4"), [view]() + { + view->__onDeleteCb(view, NULL, NULL); + }); + popup->appendItem(V_("IDS_PB_HEADER_SHARE_VIA"), [view]() + { + view->__onShareCb(view, NULL, NULL); + }); + view->attachPopup( popup ); + + }, this); + __detailData->attachListener(this); +} + +void CtMyProfileDetailView::__basicInfoBackBtnCb(void *data, Evas_Object *obj, + const char *emission, const char *source) +{ + WHIT(); + WPRET_M(!data, "data is NULL"); + CtMyProfileDetailView* view = (CtMyProfileDetailView*)data; + + view->popOut(); +} + +void CtMyProfileDetailView::__createBaseInfo() +{ + WHIT(); + CtDetailViewBasicInfoControl *basicInfo = new CtDetailViewBasicInfoControl(__detailData, false); + WPRET_M(!basicInfo, "basicInfo is NULL"); + basicInfo->create(__mainLayout, NULL); + edje_object_signal_callback_add(_EDJ(basicInfo->getEvasObj()), "mouse,clicked,*", "back_btn", __basicInfoBackBtnCb, this); + + elm_object_part_content_set(__mainLayout, "swallow.base_info", basicInfo->getEvasObj()); +} + +Evas_Object* CtMyProfileDetailView::onCreate(Evas_Object* parent, void* viewParam) +{ + WHIT(); + + std::string detailLayoutEdjePath; + ContactsCommon::getAppEdjePath(DETAIL_LAYOUT_EDJ, detailLayoutEdjePath); + CtThemeMgr::getInstance()->addExtensionTheme(detailLayoutEdjePath.c_str()); + + __mainLayout = elm_layout_add(parent); + elm_layout_file_set(__mainLayout, ContactsCommon::getAppEdjePath(DETAIL_LAYOUT_EDJ).c_str(), "main_layout"); + + CtThemeMgr::getInstance()->setObjectTheme(__mainLayout); + + __genlist = elm_genlist_add(__mainLayout); + evas_object_size_hint_weight_set(__genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_genlist_mode_set(__genlist, ELM_LIST_COMPRESS); + elm_object_part_content_set(__mainLayout, "swallow.content", __genlist); + + __createBaseInfo(); + __addAllItems(); + + return __mainLayout; + +} + +void CtMyProfileDetailView::onLanguageChanged() +{ + WHIT(); + + if(__genlist) + elm_genlist_realized_items_update(__genlist); +} + +int CtMyProfileDetailView::getPersoinId(void) +{ + WASSERT_EX(NULL != __detailData, "__detailData is null"); + return __detailData->getPersonId(); +} + + +void CtMyProfileDetailView::__addAllItems() +{ + WHIT(); + for (int i = 0; i < MYPROFILE_DETAIL_ITEMS_MAX; i++) { + __addItem(i); + } +} + +void CtMyProfileDetailView::__addItem(int itemType) +{ + WHIT(); + + WDEBUG("itemType %d", itemType); + switch(itemType) { + case MYPROFILE_DETAIL_MSISDN: + __addMsisdnItem(); + break; + case MYPROFILE_DETAIL_NUMBER: + __addNumberItems(); + break; + case MYPROFILE_DETAIL_EMAIL: + __addEmailItems(); + break; + case MYPROFILE_DETAIL_NOTE: + __addNoteItems(); + break; + case MYPROFILE_DETAIL_ADDRESS: + __addAddressItems(); + break; + case MYPROFILE_DETAIL_EVENT: + __addEventItems(); + break; + case MYPROFILE_DETAIL_RELATIONSHIP: + __addRelationItems(); + break; + case MYPROFILE_DETAIL_WEBSITE: + __addWebsiteItems(); + break; + case MYPROFILE_DETAIL_MESSENGER: + __addMessengerItems(); + break; + default: + WDEBUG("Unsupported type: %d", itemType); + break; + } +} + +void CtMyProfileDetailView::__addMsisdnItem() +{ + WHIT(); + + WASSERT_EX(NULL != __detailData, "__detailData is null"); + contacts_record_h defaultRecord = __detailData->getDefNumberRecord(); + if (defaultRecord) { + CtDetailViewNumberItem *item = new CtDetailViewNumberItem(__detailData, defaultRecord, true); + item->setElmObjectItem(elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL)); + elm_genlist_item_select_mode_set((Elm_Object_Item*)item->getElmObjectItem(), ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + } +} + +void CtMyProfileDetailView::__addNumberItems() +{ + WHIT(); + void *data = NULL; + Eina_List *cursor = NULL; + Eina_List *list = NULL; + + WASSERT_EX(NULL != __detailData, "__detailData is null"); + list = __detailData->getNumberList(); + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) + continue; + + CtDetailViewNumberItem *item = new CtDetailViewNumberItem(__detailData, record, true); + item->setElmObjectItem(elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL)); + elm_genlist_item_select_mode_set((Elm_Object_Item*)item->getElmObjectItem(), ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + } +} + +void CtMyProfileDetailView::__addEmailItems() +{ + WHIT(); + void *data = NULL; + Eina_List *cursor = NULL; + Eina_List *list = NULL; + + WASSERT_EX(NULL != __detailData, "__detailData is null"); + list = __detailData->getEmailList(); + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) + continue; + CtDetailViewEmailItem* item = new CtDetailViewEmailItem(__detailData, record, true); + item->setElmObjectItem(elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL)); + elm_genlist_item_select_mode_set((Elm_Object_Item*)item->getElmObjectItem(), ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + } +} + +void CtMyProfileDetailView::__addNoteItems() +{ + WHIT(); + void *data = NULL; + Eina_List *cursor = NULL; + Eina_List *list = NULL; + + WASSERT_EX(NULL != __detailData, "__detailData is null"); + list = __detailData->getNoteList(); + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) + continue; + + CtDetailViewNoteItem* item = new CtDetailViewNoteItem(__detailData, record); + item->setElmObjectItem(elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL)); + elm_genlist_item_select_mode_set((Elm_Object_Item*)item->getElmObjectItem(), ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + } +} + +void CtMyProfileDetailView::__addAddressItems() +{ + WHIT(); + void *data = NULL; + Eina_List *cursor = NULL; + Eina_List *list = NULL; + + WASSERT_EX(NULL != __detailData, "__detailData is null"); + list = __detailData->getAddressList(); + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) + continue; + + CtDetailViewAddressItem* item = new CtDetailViewAddressItem(__detailData, record); + item->setElmObjectItem(elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL)); + elm_genlist_item_select_mode_set((Elm_Object_Item*)item->getElmObjectItem(), ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + } +} + +void CtMyProfileDetailView::__addEventItems() +{ + WHIT(); + void *data = NULL; + Eina_List *cursor = NULL; + Eina_List *list = NULL; + + WASSERT_EX(NULL != __detailData, "__detailData is null"); + list = __detailData->getEventList(); + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) + continue; + + CtDetailViewEventItem *item = new CtDetailViewEventItem(__detailData, record); + item->setElmObjectItem(elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL)); + elm_genlist_item_select_mode_set((Elm_Object_Item*)item->getElmObjectItem(), ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + } +} + +void CtMyProfileDetailView::__addRelationItems() +{ + WHIT(); + void *data = NULL; + Eina_List *cursor = NULL; + Eina_List *list = NULL; + + WASSERT_EX(NULL != __detailData, "__detailData is null"); + list = __detailData->getRelationshipList(); + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) + continue; + + CtDetailViewRelationItem *item = new CtDetailViewRelationItem(__detailData, record); + item->setElmObjectItem(elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL)); + elm_genlist_item_select_mode_set((Elm_Object_Item*)item->getElmObjectItem(), ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + } +} + +void CtMyProfileDetailView::__addWebsiteItems() +{ + WHIT(); + void *data = NULL; + Eina_List *cursor = NULL; + Eina_List *list = NULL; + + WASSERT_EX(NULL != __detailData, "__detailData is null"); + list = __detailData->getUrlList(); + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) + continue; + + CtDetailViewWebsiteItem *item = new CtDetailViewWebsiteItem(__detailData, record, true); + item->setElmObjectItem(elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL) ); + elm_genlist_item_select_mode_set((Elm_Object_Item*)item->getElmObjectItem(), ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + } +} + +void CtMyProfileDetailView::__addMessengerItems() +{ + WHIT(); + void *data = NULL; + Eina_List *cursor = NULL; + Eina_List *list = NULL; + + WASSERT_EX(NULL != __detailData, "__detailData is null"); + list = __detailData->getMessengerList(); + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) + continue; + + CtDetailViewMessengerItem *item = new CtDetailViewMessengerItem(__detailData, record); + item->setElmObjectItem(elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL) ); + elm_genlist_item_select_mode_set((Elm_Object_Item*)item->getElmObjectItem(), ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + } +} + +//MENU +void CtMyProfileDetailView::__onShareCb(void *data, Evas_Object *obj, void *event_info) +{ + WENTER(); + CtMyProfileDetailView* view = static_cast<CtMyProfileDetailView*>(data); + WPRET_M(!(view && view->__detailData), "invalid data"); + + sharePerson(view->__detailData->getPersonId(), true); +} + +//MENU +void CtMyProfileDetailView::__onDeleteCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + CtMyProfileDetailView* view = static_cast<CtMyProfileDetailView*>(data); + Eina_List* contactList = view->__detailData->getContactsList(); + unsigned int count = eina_list_count(contactList); + + WPopup *popup = new WPopup(); + popup->setTextTranslatable(PACKAGE); + popup->setTitle("IDS_PB_BUTTON_DELETE_ABB4"); + + char *text = NULL; + + if(view->__isContactSyncToAnyAccount(view->__detailData->getPersonRecord()))// contact synced with any account + { + if( count > 1 ) { + text = strdup(V_("IDS_PB_POP_WHEN_SYNC_IS_ENABLED_THIS_CONTACT_AND_ALL_ITS_LINKED_CONTACTS_IN_OTHER_SYNCED_ACCOUNTS_WILL_BE_DELETED")); + } + else { + text = strdup(V_("IDS_PB_POP_WHEN_SYNC_IS_ENABLED_THIS_CONTACT_WILL_BE_DELETED_FROM_ANY_SYNCED_ACCOUNTS_IT_IS_SAVED_IN")); + } + } + else // contact not synced with any account + { + if( count > 1 ) { + text = strdup(V_("IDS_PB_POP_THIS_CONTACT_AND_ALL_ITS_LINKED_CONTACTS_WILL_BE_DELETED")); + } + else { + text = strdup(V_("IDS_PB_POP_THIS_CONTACT_WILL_BE_DELETED")); + } + } + + popup->setContent(text); + popup->addButton(V_("IDS_PB_BUTTON_CANCEL"), [](bool* destroyPopup){ + WDEBUG("Cancel"); + *destroyPopup = true; + }); + popup->addButton(V_("IDS_PB_BUTTON_DELETE_ABB4"), [view](bool* destroyPopup){ + WDEBUG("Delete"); + if (CONTACTS_ERROR_NONE == view->__deleteContacts(view)) { + evas_object_data_set(view->getNaviframe()->getEvasObj(), "ct_list_update_myprofile", (void *)1); + + view->popOut(); + *destroyPopup = false; + } + else { + *destroyPopup = true; + } + }); + + view->attachPopup( popup ); + SAFE_FREE(text); +} + +int CtMyProfileDetailView::__deleteContacts(void *data) +{ + WHIT(); + CtMyProfileDetailView* view = static_cast<CtMyProfileDetailView*>(data); + int err = CONTACTS_ERROR_NONE; + WDEBUG("view->getPersoinId() = %d", view->getPersoinId()); + + err = contacts_db_delete_record(_contacts_my_profile._uri, view->getPersoinId()); + WPWARN(err != CONTACTS_ERROR_NONE, "contacts_db_delete_record() fail(%d)",err); + if (err == CONTACTS_ERROR_NONE) { + view->__detailData->detachListener(); + int ret = preference_set_boolean(CT_KEY_MYPROFILE_CREATE_FIRST, true); + WDEBUG("preference_set_boolean(%d) Failed", ret); + } + return err; +} + +bool CtMyProfileDetailView::__isContactSyncToAnyAccount(contacts_record_h personRecord) +{ + WHIT(); + contacts_record_h addressbookRecord = NULL; + char* accountName = NULL; + int addressbookId = -1; + + int ret = contacts_record_get_int(personRecord, _contacts_my_profile.address_book_id, &addressbookId); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_str_p() Failed(%d)", ret); + WDEBUG("addressbookId = %d", addressbookId); + + ret = contacts_db_get_record(_contacts_address_book._uri, addressbookId, &addressbookRecord); + WPRET_VM(CONTACTS_ERROR_NONE != ret, NULL, "contacts_db_get_record() Failed(%d)", ret); + + ret = contacts_record_get_str_p(addressbookRecord, _contacts_address_book.name, &accountName); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_str_p() Failed(%d)", ret); + WDEBUG("accountName = %s", accountName); + + if(strstr(accountName, "addressbook/phone")==NULL && strstr(accountName, "addressbook/sim")==NULL) { + contacts_record_destroy(addressbookRecord, true); + return true; + } + + contacts_record_destroy(addressbookRecord, true); + return false; +} + +void CtMyProfileDetailView::__updateGenlist() +{ + WHIT(); + elm_genlist_clear(__genlist); + for (int i = MYPROFILE_DETAIL_MSISDN; i < MYPROFILE_DETAIL_ITEMS_MAX; i++) { + __genlistItems[i] = {}; + } + + __addAllItems(); +} + +extern "C" { + WAPP_ASSIST_EXPORT WView* createMyProfileDetailView() { + CtMyProfileDetailView* view = new CtMyProfileDetailView(); + return view; + } +} + diff --git a/lib-contact/ct-detail/src/CtMyProfileInputData.cpp b/lib-contact/ct-detail/src/CtMyProfileInputData.cpp new file mode 100755 index 0000000..c0e9663 --- /dev/null +++ b/lib-contact/ct-detail/src/CtMyProfileInputData.cpp @@ -0,0 +1,2248 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "ContactsDebug.h" +#include "CtMyProfileInputData.h" +#include "CtCommon.h" + +CtMyProfileInputData::CtMyProfileInputData(contacts_record_h contactRecord) +{ + WHIT(); + __contactRecord = contactRecord; + __contactId = 0; + __init(); + +} + + +CtMyProfileInputData::CtMyProfileInputData(ContactsData &contactsData) +{ + WHIT(); + __contactRecord = NULL; + __contactId = 0; +} + +CtMyProfileInputData::CtMyProfileInputData() +{ + WHIT(); + __init(); +} + +CtMyProfileInputData::~CtMyProfileInputData() +{ + WHIT(); + contacts_record_destroy(__contactRecord, true); +} + +//contacts_record_h CtMyProfileInputData::getContactRecord() +//{ +// WHIT(); +// return __contactRecord; +//} + +void CtMyProfileInputData::__init() +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + contacts_list_h myprofileList = NULL; + int count = 0; + contacts_record_h record = NULL; + + err = contacts_db_get_all_records(_contacts_my_profile._uri, 0, 0, &myprofileList); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_all_records() Failed(%d)", err); + + if (myprofileList != NULL) { +// int myprofile_id = 0; + contacts_list_get_count(myprofileList, &count); + if (count > 0) { + err = contacts_list_get_current_record_p(myprofileList, &record); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_get_current_record_p() Failed(%d)", err); + err = contacts_record_get_int(record, _contacts_my_profile.id, &__contactId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + } + + err = contacts_record_clone(record, &__contactRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_clone() Failed(%d)", err); + contacts_list_destroy(myprofileList, true); + } + + if (__contactRecord == NULL) { + err = contacts_record_create(_contacts_my_profile._uri, &__contactRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_create() Failed(%d)", err); + } +} + +int CtMyProfileInputData::separateFullName(contacts_record_h nameRecord, const char *full_name) +{ + WHIT(); + WPRET_VM(NULL == nameRecord, -1, "nameRecord is NULL"); + WPRET_VM(NULL == full_name, -1, "full_name is NULL"); + int err = CONTACTS_ERROR_NONE; + char *temp_name = NULL; + char *temp_first = NULL; + char *temp_middle = NULL; + char *temp_last = NULL; + char tmp[CT_TEXT_MAX_LEN] = {0}; + + snprintf(tmp, sizeof(tmp), "%s", full_name); + + temp_first = strtok_r(tmp, " ", &temp_name); + if (temp_first) { + temp_middle = strtok_r(NULL, " ", &temp_name); + if (temp_middle) { + temp_last = temp_name; + } + } + + WDEBUG("full_name %s, first %s, middle %s, last %s", full_name, temp_first, temp_middle, temp_last); + + if(temp_first && *temp_first) { + if(temp_last && *temp_last) { + err = contacts_record_set_str(nameRecord, _contacts_name.first, temp_first); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.addition, temp_middle); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.last, temp_last); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + else { + if(temp_middle && *temp_middle) { + err = contacts_record_set_str(nameRecord, _contacts_name.first, temp_first); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.addition, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.last, temp_middle); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + else { + err = contacts_record_set_str(nameRecord, _contacts_name.first, temp_first); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.addition, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.last, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + } + }else { + err = contacts_record_set_str(nameRecord, _contacts_name.first, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.addition, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.last, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +int CtMyProfileInputData::separatePhoneticFullName(contacts_record_h nameRecord, const char *full_name) +{ + WHIT(); + WPRET_VM(NULL == nameRecord, -1, "nameRecord is NULL"); + int err = CONTACTS_ERROR_NONE; + char *temp_name = NULL; + char *temp_first = NULL; + char *temp_middle = NULL; + char *temp_last = NULL; + char tmp[CT_TEXT_MAX_LEN] = {0}; + + if (NULL == full_name) { + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_first, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_middle, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_last, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + return err; + } + + snprintf(tmp, sizeof(tmp), "%s", full_name); + + temp_first = strtok_r(tmp, " ", &temp_name); + if (temp_first) { + temp_middle = strtok_r(NULL, " ", &temp_name); + if (temp_middle) { + temp_last = temp_name; + } + } + + WDEBUG("full_name %s, first %s, middle %s, last %s", full_name, temp_first, temp_middle, temp_last); + + if(temp_first && *temp_first) { + if(temp_last && *temp_last) { + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_first, temp_first); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_middle, temp_middle); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_last, temp_last); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + else { + if(temp_middle && *temp_middle) { + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_first, temp_first); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_middle, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_last, temp_middle); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + else { + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_first, temp_first); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_middle, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_last, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + } + }else { + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_first, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_middle, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_last, NULL); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +int CtMyProfileInputData::setPrefixName(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.name, 0, &nameRecord); + + if (nameRecord == NULL) { + err = contacts_record_create(_contacts_name._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_my_profile.name, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = contacts_record_set_str(nameRecord, _contacts_name.prefix, text); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + return err; +} + +int CtMyProfileInputData::setSuffixName(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.name, 0, &nameRecord); + + if (nameRecord == NULL) { + err = contacts_record_create(_contacts_name._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_my_profile.name, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = contacts_record_set_str(nameRecord, _contacts_name.suffix, text); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + return err; +} + +int CtMyProfileInputData::setPhoneticFullName(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.name, 0, &nameRecord); + //WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + if(nameRecord == NULL) { + err = contacts_record_create(_contacts_name._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_my_profile.name, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = separatePhoneticFullName(nameRecord, text); + return err; +} + +int CtMyProfileInputData::setPhoneticFirstName(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.name, 0, &nameRecord); + + if (nameRecord == NULL) { + err = contacts_record_create(_contacts_name._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_my_profile.name, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_first, text); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + return err; +} + +int CtMyProfileInputData::setPhoneticMiddleName(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.name, 0, &nameRecord); + + if (nameRecord == NULL) { + err = contacts_record_create(_contacts_name._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_my_profile.name, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_middle, text); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + return err; +} + +int CtMyProfileInputData::setPhoneticLastName(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.name, 0, &nameRecord); + + if (nameRecord == NULL) { + err = contacts_record_create(_contacts_name._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_my_profile.name, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = contacts_record_set_str(nameRecord, _contacts_name.phonetic_last, text); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + return err; +} + +int CtMyProfileInputData::setNickname(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.nickname, 0, &nameRecord); + + if (nameRecord == NULL) { + err = contacts_record_create(_contacts_nickname._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_my_profile.nickname, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = contacts_record_set_str(nameRecord, _contacts_nickname.name, text); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + return err; +} + +int CtMyProfileInputData::setCompany(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.company, 0, &nameRecord); + + if (nameRecord == NULL) { + err = contacts_record_create(_contacts_company._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_my_profile.company, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = contacts_record_set_str(nameRecord, _contacts_company.name, text); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + return err; +} + +int CtMyProfileInputData::setJobTitle(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.company, 0, &nameRecord); + + if (nameRecord == NULL) { + err = contacts_record_create(_contacts_company._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_my_profile.company, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = contacts_record_set_str(nameRecord, _contacts_company.job_title, text); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + return err; +} + +int CtMyProfileInputData::setFullName(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.name, 0, &nameRecord); + //WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + if(nameRecord == NULL) { + err = contacts_record_create(_contacts_name._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_my_profile.name, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = separateFullName(nameRecord, text); + return err; +} + +int CtMyProfileInputData::setFirstName(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.name, 0, &nameRecord); + + if (nameRecord == NULL) { + err = contacts_record_create(_contacts_name._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_my_profile.name, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = contacts_record_set_str(nameRecord, _contacts_name.first, text); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + return err; +} + +int CtMyProfileInputData::setMiddleName(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.name, 0, &nameRecord); + + if (nameRecord == NULL) { + err = contacts_record_create(_contacts_name._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_my_profile.name, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = contacts_record_set_str(nameRecord, _contacts_name.addition, text); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + return err; +} + +int CtMyProfileInputData::setLastName(const char *text) +{ + WDEBUG("text %s", text); + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.name, 0, &nameRecord); + + if (nameRecord == NULL) { + err = contacts_record_create(_contacts_name._uri, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_my_profile.name, nameRecord); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(nameRecord, true); + return err; + } + } + + err = contacts_record_set_str(nameRecord, _contacts_name.last, text); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + + return err; +} + +const char* CtMyProfileInputData::getPrefixName() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + char *prefix = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.name, 0, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_name.prefix, &prefix); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + return prefix; +} + +const char* CtMyProfileInputData::getSuffixName() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + char *suffix = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.name, 0, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_name.suffix, &suffix); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + return suffix; +} + +const char* CtMyProfileInputData::getPhoneticFirstName() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + char *phoneticName = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.name, 0, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_name.phonetic_first, &phoneticName); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + return phoneticName; +} + +const char* CtMyProfileInputData::getPhoneticMiddleName() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + char *phoneticName = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.name, 0, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_name.phonetic_middle, &phoneticName); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + return phoneticName; +} + +const char* CtMyProfileInputData::getPhoneticLastName() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + char *phoneticName = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.name, 0, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_name.phonetic_last, &phoneticName); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + return phoneticName; +} + +const char* CtMyProfileInputData::getNickname() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + char *nickname = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.nickname, 0, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_nickname.name, &nickname); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + return nickname; +} + +const char* CtMyProfileInputData::getCompany() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + char *company = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.company, 0, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_company.name, &company); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + return company; +} + +const char* CtMyProfileInputData::getJobTitle() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + char *jobTitle = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.company, 0, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_company.job_title, &jobTitle); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + return jobTitle; +} + +/** + * @return must be freed by you + */ +void CtMyProfileInputData::getFullName(std::string &Name) +{ + int strLen = 0; + const char *firstName = NULL; + const char *middleName = NULL; + const char *lastName = NULL; + const char *prefixName = NULL; + const char *suffixName = NULL; + char *fullName = NULL; + + firstName = getFirstName(); + middleName = getMiddleName(); + lastName = getLastName(); + prefixName = getPrefixName(); + suffixName = getSuffixName(); + + strLen = SAFE_STRLEN(prefixName) + SAFE_STRLEN(firstName) + SAFE_STRLEN(middleName) + SAFE_STRLEN(lastName) + SAFE_STRLEN(suffixName) + 6; + WDEBUG("strLen = %d", strLen); + + fullName = (char*)malloc(sizeof(char)*strLen); + WPRET_M(NULL == fullName, "failed to malloc"); + memset(fullName, 0, sizeof(char)*strLen); + + if (prefixName && *prefixName) { + strncat(fullName, prefixName, SAFE_STRLEN(prefixName)); + } + if (firstName && *firstName) { + if (fullName && *fullName) { + strncat(fullName, " ", 1); + } + strncat(fullName, firstName, SAFE_STRLEN(firstName)); + } + if (middleName && *middleName) { + if (fullName && *fullName) { + strncat(fullName, " ", 1); + } + strncat(fullName, middleName, SAFE_STRLEN(middleName)); + } + if (lastName && *lastName) { + if (fullName && *fullName) { + strncat(fullName, " ", 1); + } + strncat(fullName, lastName, SAFE_STRLEN(lastName)); + } + if (suffixName && *suffixName) { + if (fullName && *fullName) { + strncat(fullName, ", ", 2); + } + strncat(fullName, suffixName, SAFE_STRLEN(suffixName)); + } + + Name = fullName; + free(fullName); +} + +const char* CtMyProfileInputData::getFirstName() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + char *firstName = NULL; + const char *result = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.name, 0, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_name.first, &firstName); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + result = firstName; + return result; +} + +const char* CtMyProfileInputData::getMiddleName() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + char *middleName = NULL; + const char *result = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.name, 0, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_name.addition, &middleName); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + result = middleName; + return result; +} + +const char* CtMyProfileInputData::getLastName() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h nameRecord = NULL; + char *lastName = NULL; + const char *result = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.name, 0, &nameRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(nameRecord, _contacts_name.last, &lastName); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + result = lastName; + return result; +} + +int CtMyProfileInputData::removeImage(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + + err = contacts_record_remove_child_record(__contactRecord, _contacts_my_profile.image, record); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_remove_child_record() Failed(%d)", err); + + err = contacts_record_destroy(record, true); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_destroy() Failed(%d)", err); + + return err; +} + +const char* CtMyProfileInputData::getImagePath() +{ + int err = CONTACTS_ERROR_NONE; + contacts_record_h imageRecord = NULL; + char *image = NULL; + const char *result = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.image, 0, &imageRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + err = contacts_record_get_str_p(imageRecord, _contacts_image.path, &image); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_set_str() Failed(%d)", err); + + result = image; + return result; +} +contacts_record_h CtMyProfileInputData::getImageRecord() +{ + WHIT(); + + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.image, 0, &record); + if (NULL != record) { + return record; + } + + err = contacts_record_create(_contacts_image._uri, &record); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_create() Failed(%d)", err); + + err = contacts_record_add_child_record(__contactRecord, _contacts_my_profile.image, record); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_add_child_record() Failed(%d)", err); + + return record; +} + +int CtMyProfileInputData::setImage(contacts_record_h record, char *image, int type) +{ + WDEBUG("image %s", image); + int err = CONTACTS_ERROR_NONE; + + if(image && *image) { + err = contacts_record_set_int(record, _contacts_image.type, type); + err = contacts_record_set_str(record, _contacts_image.path, image); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +Eina_List* CtMyProfileInputData::getNumberList() +{ + WHIT(); + + int index = 0; + bool value = 0; + Eina_List *dataRecordList = NULL; + int err = CONTACTS_ERROR_NONE; + contacts_record_h dataRecord = NULL; + const char* typeStr = NULL; + + while (CONTACTS_ERROR_NONE == contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.number, index++, &dataRecord)) { + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_str_p() Failed(%d)", err); + break; + } + + err = contacts_record_get_bool(dataRecord, _contacts_number.is_default, &value); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_bool() Failed(%d)", err); + typeStr = getDataTypeCustom(dataRecord, _contacts_number.label); + + if (value == true && (typeStr && 0 == strcmp(typeStr, CT_KEY_SIM_CARD_NUMBER))) { + continue; + } + dataRecordList = eina_list_append(dataRecordList, dataRecord); + } + + return dataRecordList; +} + +contacts_record_h CtMyProfileInputData::getEmergencyNumber() +{ + WHIT(); + return NULL; +} + +contacts_record_h CtMyProfileInputData::getDefaultNumber() +{ + int index = 0; + bool value = 0; + int err = CONTACTS_ERROR_NONE; + contacts_record_h dataRecord = NULL; + const char* typeStr = NULL; + + while (CONTACTS_ERROR_NONE == contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.number, index++, &dataRecord)) { + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_str_p() Failed(%d)", err); + break; + } + + err = contacts_record_get_bool(dataRecord, _contacts_number.is_default, &value); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_bool() Failed(%d)", err); + + typeStr = getDataTypeCustom(dataRecord, _contacts_number.label); + if (value == true && (typeStr && 0 == strcmp(typeStr, CT_KEY_SIM_CARD_NUMBER))) { + return dataRecord; + } + } + + return NULL; +} + +contacts_record_h CtMyProfileInputData::addNumber(const char *number) +{ + WDEBUG("number %s", number); + + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + + err = contacts_record_create(_contacts_number._uri, &record); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_create() Failed(%d)", err); + + setNumberNumber(record, number); + setNumberType(record, getNextNumberType(), NULL); + + err = contacts_record_add_child_record(__contactRecord, _contacts_my_profile.number, record); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(record, true); + return NULL; + } + return record; +} + +int CtMyProfileInputData::setNumberNumber(contacts_record_h record, const char *number) +{ + WDEBUG("number %s", number); + int err = CONTACTS_ERROR_NONE; + + if(number) { + err = contacts_record_set_str(record, _contacts_number.number, number); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +int CtMyProfileInputData::setNumberType(contacts_record_h record, int type, const char *customStr) +{ + WDEBUG("type %d", type); + WDEBUG("customStr %s", customStr); + int err = CONTACTS_ERROR_NONE; + + if (type >= 0) { + err = contacts_record_set_int(record, _contacts_number.type, type); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + if (customStr) { + err = contacts_record_set_str(record, _contacts_number.label, customStr); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + return err; +} + +int CtMyProfileInputData::removeNumber(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + + err = contacts_record_remove_child_record(__contactRecord, _contacts_my_profile.number, record); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_remove_child_record() Failed(%d)", err); + + return err; +} + +const char* CtMyProfileInputData::getNumberNumber(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + char *number = NULL; + const char *result = NULL; + + err = contacts_record_get_str_p(record, _contacts_number.number, &number); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_str_p() Failed(%d)", err); + + result = number; + return result; +} + +int CtMyProfileInputData::getNumberType(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + int type = 0; + + err = contacts_record_get_int(record, _contacts_number.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +Eina_List* CtMyProfileInputData::getEmailList() +{ + WHIT(); + return __getChildDataList(__contactRecord, _contacts_my_profile.email); +} + +const char* CtMyProfileInputData::getDataTypeCustom(contacts_record_h record, int property_id) +{ + char* typeStr = NULL; + const char* result = NULL; + int err = CONTACTS_ERROR_NONE; + err = contacts_record_get_str_p(record, property_id, &typeStr); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_int() Failed(%d)", err); + + result = typeStr; + return result; +} + +void CtMyProfileInputData::getNumberTypeStr(contacts_record_h record, int numberType, std::string &typeString) +{ + WHIT(); + const char* typeStr = NULL; + char buf[128] = {0,}; + + if (numberType & CONTACTS_NUMBER_TYPE_CUSTOM) { + typeStr = getDataTypeCustom(record, _contacts_number.label); + + } + else if (numberType & CONTACTS_NUMBER_TYPE_CELL) { + if (numberType & CONTACTS_NUMBER_TYPE_HOME) { + snprintf(buf, sizeof(buf),"%s 2", V_("IDS_PB_OPT_HOME_ABB")); + typeStr = buf; + } + else if (numberType & CONTACTS_NUMBER_TYPE_WORK) { + snprintf(buf, sizeof(buf),"%s 2", V_("IDS_PB_OPT_WORK")); + typeStr = buf; + } + else { + typeStr = V_("IDS_PB_OPT_MOBILE"); + } + } + else if (numberType & CONTACTS_NUMBER_TYPE_VOICE) { + if (numberType & CONTACTS_NUMBER_TYPE_HOME) { + typeStr = V_("IDS_PB_OPT_HOME_ABB"); + } + else if (numberType & CONTACTS_NUMBER_TYPE_WORK) { + typeStr = V_("IDS_PB_OPT_WORK"); + } + else { + typeStr = V_("IDS_PB_BODY_TELEPHONE"); + } + } + else if (numberType & CONTACTS_NUMBER_TYPE_FAX) { + if (numberType & CONTACTS_NUMBER_TYPE_HOME) { + typeStr = V_("IDS_PB_OPT_FAX_HHOME_ABB"); + } + else if (numberType & CONTACTS_NUMBER_TYPE_WORK) { + typeStr = V_("IDS_PB_OPT_FAX_HWORK_ABB"); + } + else { + typeStr = V_("IDS_PB_BODY_FAX"); + } + } + else if (numberType & CONTACTS_NUMBER_TYPE_MAIN) { + typeStr = V_("IDS_PB_OPT_MAIN"); + } + else if (numberType & CONTACTS_NUMBER_TYPE_PAGER) { + typeStr = V_("IDS_PB_OPT_PAGER"); + } + else { + if (numberType & CONTACTS_NUMBER_TYPE_HOME) { + typeStr = V_("IDS_PB_OPT_HOME_ABB"); + } + else if (numberType & CONTACTS_NUMBER_TYPE_WORK) { + typeStr = V_("IDS_PB_OPT_WORK"); + } + else { + typeStr = V_("IDS_PB_OPT_OTHER"); + } + } + + char *result = elm_entry_utf8_to_markup(typeStr); + if (result) { + typeString = result; + free(result); + } +} + +int CtMyProfileInputData::getNumberRetType(int indexType) +{ + int retType; + + switch (indexType) { + case CTTEXT_TYPE_MOBILE: + retType = CONTACTS_NUMBER_TYPE_CELL; + break; + case CTTEXT_TYPE_HOME: + retType = CONTACTS_NUMBER_TYPE_VOICE | CONTACTS_NUMBER_TYPE_HOME; + break; + case CTTEXT_TYPE_WORK: + retType = CONTACTS_NUMBER_TYPE_VOICE | CONTACTS_NUMBER_TYPE_WORK; + break; + case CTTEXT_TYPE_FAX_HOME: + retType = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME; + break; + case CTTEXT_TYPE_FAX_WORK: + retType = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK; + break; + case CTTEXT_TYPE_PAGER: + retType = CONTACTS_NUMBER_TYPE_PAGER; + break; + case CTTEXT_TYPE_CUSTOM: + retType = CONTACTS_NUMBER_TYPE_CUSTOM; + break; + case CTTEXT_TYPE_MAIN: + retType = CONTACTS_NUMBER_TYPE_MAIN; + break; + case CTTEXT_TYPE_OTHER: + default: + retType = CONTACTS_NUMBER_TYPE_OTHER; + break; + } + + return retType; +} +int CtMyProfileInputData::getNumberIndexType(int numberType) +{ + if (numberType & CONTACTS_NUMBER_TYPE_CUSTOM) { + return (CTTEXT_TYPE_OTHER); + } + else if (numberType & CONTACTS_NUMBER_TYPE_CELL) { + return (CTTEXT_TYPE_MOBILE); + } + else if (numberType & CONTACTS_NUMBER_TYPE_VOICE) { + if (numberType & CONTACTS_NUMBER_TYPE_HOME) { + return (CTTEXT_TYPE_HOME); + } + else if (numberType & CONTACTS_NUMBER_TYPE_WORK) { + return (CTTEXT_TYPE_WORK); + } + } + else if (numberType & CONTACTS_NUMBER_TYPE_FAX) { + if (numberType & CONTACTS_NUMBER_TYPE_HOME) + return (CTTEXT_TYPE_FAX_HOME); + else if (numberType & CONTACTS_NUMBER_TYPE_WORK) + return (CTTEXT_TYPE_FAX_WORK); + } + else if (numberType & CONTACTS_NUMBER_TYPE_PAGER) + return (CTTEXT_TYPE_PAGER); + else if (numberType & CONTACTS_NUMBER_TYPE_MAIN) + return (CTTEXT_TYPE_MAIN); + else { + if (numberType == CONTACTS_NUMBER_TYPE_HOME) + return (CTTEXT_TYPE_HOME); + else if (numberType == CONTACTS_NUMBER_TYPE_WORK) + return (CTTEXT_TYPE_WORK); + else + return (CTTEXT_TYPE_OTHER); + } + WERROR("Not handled case numberType=%d", numberType); + return (CTTEXT_TYPE_OTHER); +} + +int CtMyProfileInputData::getNextNumberType() +{ + int i; + int numberType; + int indexType; + int index = 0; + int err = CONTACTS_ERROR_NONE; + int used[CTTEXT_TYPE_OTHER+1] = {0}; + contacts_record_h record = NULL; + + while (CONTACTS_ERROR_NONE == contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.number, index++, &record)) { + err = contacts_record_get_int(record, _contacts_number.type, &numberType); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_int() Failed(%d)", err); + continue; + } + indexType = getNumberIndexType(numberType); + used[indexType] = 1; + } + + for (i=CTTEXT_TYPE_MOBILE;i<CTTEXT_TYPE_OTHER;i++) { + if (0 == used[i]) { + + return getNumberRetType(i); + } + } + + return CONTACTS_NUMBER_TYPE_OTHER; + +} + +contacts_record_h CtMyProfileInputData::addEmail(const char *email) +{ + WDEBUG("email %s", email); + + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + + err = contacts_record_create(_contacts_email._uri, &record); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_create() Failed(%d)", err); + + setEmailEmail(record, email); + setEmailType(record, getNextEmailType(), NULL); + + err = contacts_record_add_child_record(__contactRecord, _contacts_my_profile.email, record); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(record, true); + return NULL; + } + return record; +} + +int CtMyProfileInputData::setEmailEmail(contacts_record_h record, const char *email) +{ + WDEBUG("email %s", email); + int err = CONTACTS_ERROR_NONE; + + if (email) { + err = contacts_record_set_str(record, _contacts_email.email, email); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +int CtMyProfileInputData::setEmailType(contacts_record_h record, int type, char *customStr) +{ + WDEBUG("type %d", type); + int err = CONTACTS_ERROR_NONE; + + if (type >= 0) { + err = contacts_record_set_int(record, _contacts_email.type, type); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + if (customStr) { + err = contacts_record_set_str(record, _contacts_email.label, customStr); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +const char* CtMyProfileInputData::getEmailEmail(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + char *email = NULL; + const char *result = NULL; + + err = contacts_record_get_str_p(record, _contacts_email.email, &email); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_str_p() Failed(%d)", err); + + result = email; + return result; +} + +int CtMyProfileInputData::getEmailType(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + int type = 0; + + err = contacts_record_get_int(record, _contacts_email.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +void CtMyProfileInputData::getEmailTypeStr(contacts_record_h record, int indexType, std::string &typeString) +{ + WHIT(); + const char* typeStr = NULL; + + if (indexType & CONTACTS_EMAIL_TYPE_CUSTOM) { + typeStr = getDataTypeCustom(record, _contacts_email.label); + } + else if (indexType & CONTACTS_EMAIL_TYPE_HOME) { + typeStr = V_("IDS_PB_OPT_HOME_ABB"); + } + else if (indexType & CONTACTS_EMAIL_TYPE_WORK) { + typeStr = V_("IDS_PB_OPT_WORK"); + } + else { + typeStr = V_("IDS_PB_OPT_OTHER"); + } + + char *result = elm_entry_utf8_to_markup(typeStr); + if (result) { + typeString = result; + free(result); + } +} + +int CtMyProfileInputData::getNextEmailType() +{ + int i; + int used = 0; + int emailType; + int index = 0; + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + while (CONTACTS_ERROR_NONE == contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.email, index++, &record)) { + err = contacts_record_get_int(record, _contacts_email.type, &emailType); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_int() Failed(%d)", err); + continue; + } + used |= emailType; + } + + int maxType = CONTACTS_EMAIL_TYPE_WORK; + for (i=1;(1<<i)<=maxType;i++) { + if (!(used & (1<<i))) { + return 1<<i; + } + } + + return CONTACTS_EMAIL_TYPE_OTHER; + +} + +int CtMyProfileInputData::removeEmail(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + + err = contacts_record_remove_child_record(__contactRecord, _contacts_my_profile.email, record); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_remove_child_record() Failed(%d)", err); + + return err; +} + +contacts_record_h CtMyProfileInputData::getNoteRecord() +{ + WHIT(); + contacts_record_h record = NULL; + int err = CONTACTS_ERROR_NONE; + + err = contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.note, 0, &record); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_child_record_at_p() Failed(%d)", err); + return record; +} + +contacts_record_h CtMyProfileInputData::addNote(const char *note) +{ + WDEBUG("note %s", note); + + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + + err = contacts_record_create(_contacts_note._uri, &record); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_create() Failed(%d)", err); + + setNote(record, note); + + err = contacts_record_add_child_record(__contactRecord, _contacts_my_profile.note, record); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(record, true); + return NULL; + } + return record; +} + +int CtMyProfileInputData::setNote(contacts_record_h record, const char *note) +{ + WDEBUG("note %s", note); + int err = CONTACTS_ERROR_NONE; + + if (note) { + err = contacts_record_set_str(record, _contacts_note.note, note); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +Eina_List* CtMyProfileInputData::getNoteList() +{ + WHIT(); + return __getChildDataList(__contactRecord, _contacts_my_profile.note); +} + +const char* CtMyProfileInputData::getNote(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + char *note = NULL; + const char *result = NULL; + + err = contacts_record_get_str_p(record, _contacts_note.note, ¬e); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_str_p() Failed(%d)", err); + + result = note; + return result; +} + +int CtMyProfileInputData::removeNote(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + + err = contacts_record_remove_child_record(__contactRecord, _contacts_my_profile.note, record); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_remove_child_record() Failed(%d)", err); + + return err; +} + +Eina_List* CtMyProfileInputData::getAddressList() +{ + WHIT(); + return __getChildDataList(__contactRecord, _contacts_my_profile.address); +} + +contacts_record_h CtMyProfileInputData::addAddress(const char *address) +{ + WDEBUG("address %s", address); + + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + + err = contacts_record_create(_contacts_address._uri, &record); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_create() Failed(%d)", err); + + setAddressAddress(record, address); + setAddressType(record, getNextAddressType(), NULL); + + err = contacts_record_add_child_record(__contactRecord, _contacts_my_profile.address, record); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(record, true); + return NULL; + } + return record; +} + +int CtMyProfileInputData::setAddressAddress(contacts_record_h record, const char *address) +{ + WDEBUG("address %s", address); + int ret = CONTACTS_ERROR_NONE; + + if (address) { + do { + if (CONTACTS_ERROR_NONE != (ret = contacts_record_set_str(record, _contacts_address.postbox, NULL))) break; + if (CONTACTS_ERROR_NONE != (ret = contacts_record_set_str(record, _contacts_address.postal_code, NULL))) break; + if (CONTACTS_ERROR_NONE != (ret = contacts_record_set_str(record, _contacts_address.region, NULL))) break; + if (CONTACTS_ERROR_NONE != (ret = contacts_record_set_str(record, _contacts_address.locality, NULL))) break; + if (CONTACTS_ERROR_NONE != (ret = contacts_record_set_str(record, _contacts_address.street, address))) break; + if (CONTACTS_ERROR_NONE != (ret = contacts_record_set_str(record, _contacts_address.country, NULL))) break; + if (CONTACTS_ERROR_NONE != (ret = contacts_record_set_str(record, _contacts_address.extended, NULL))) break; + } while (0); + WPRET_VM(CONTACTS_ERROR_NONE != ret, ret, "contacts_record_set_str() Failed(%d)", ret); + } + + return ret; +} + +int CtMyProfileInputData::setAddressType(contacts_record_h record, int type, const char *customStr) +{ + WDEBUG("type %d", type); + int err = CONTACTS_ERROR_NONE; + + if (type >= 0) { + err = contacts_record_set_int(record, _contacts_address.type, type); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + if (customStr) { + err = contacts_record_set_str(record, _contacts_address.label, customStr); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +int CtMyProfileInputData::getAddressAddress(contacts_record_h record, char *buf, int length) +{ + WHIT(); + return __getFullAddress(record, buf, length); +} + +void CtMyProfileInputData::__appendStringWithLinebreak(const char *src, char *dest, int length) +{ + char temp[CT_TEXT_MAX_LEN]; + if (src && '\0' != src[0]) { + if ('\0' == dest[0]) + snprintf(dest, length, "%s", src); + else { + snprintf(temp, sizeof(temp), "%s\n%s", src, dest); + snprintf(dest, length, "%s", temp); + } + } +} + +int CtMyProfileInputData::__getFullAddress(contacts_record_h addresssRecord, char *buf, int length) +{ + WHIT(); + + const char *code = NULL; + const char *region = NULL; + const char *locality = NULL; + const char *street = NULL; + const char *extended = NULL; + const char *country = NULL; + const char *pobox = NULL; + int err = CONTACTS_ERROR_NONE; + + do { + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.postal_code , (char**)&code))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.extended , (char**)&extended))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.postbox , (char**)&pobox))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.street , (char**)&street))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.locality , (char**)&locality))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.region , (char**)®ion))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_get_str_p(addresssRecord, _contacts_address.country ,(char**)&country))) break; + } while (0); + if(CONTACTS_ERROR_NONE != err) + WERROR("contacts_record_get_str_p() Failed(%d)", err); + + __appendStringWithLinebreak(country, buf, length); + __appendStringWithLinebreak(code, buf, length); + __appendStringWithLinebreak(region, buf, length); + __appendStringWithLinebreak(locality, buf, length); + __appendStringWithLinebreak(street, buf, length); + __appendStringWithLinebreak(extended, buf, length); + __appendStringWithLinebreak(pobox, buf, length); + + return 0; +} + +int CtMyProfileInputData::getAddressType(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + int type = 0; + + err = contacts_record_get_int(record, _contacts_address.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +void CtMyProfileInputData::getAddressTypeStr(contacts_record_h record, int indexType, std::string &typeString) +{ + WHIT(); + const char* typeStr = NULL; + + if (indexType & CONTACTS_ADDRESS_TYPE_CUSTOM) { + typeStr = getDataTypeCustom(record, _contacts_address.label); + } + else if (indexType & CONTACTS_ADDRESS_TYPE_HOME) { + typeStr = V_("IDS_PB_OPT_HOME_ABB"); + } + else if (indexType & CONTACTS_ADDRESS_TYPE_WORK) { + typeStr = V_("IDS_PB_OPT_WORK"); + } + else { + typeStr = V_("IDS_PB_OPT_OTHER"); + } + + char *result = elm_entry_utf8_to_markup(typeStr); + if (result) { + typeString = result; + free(result); + } +} + +int CtMyProfileInputData::getNextAddressType() +{ + int i; + int used = 0; + int addressType; + int index = 0; + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + while (CONTACTS_ERROR_NONE == contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.address, index++, &record)) { + err = contacts_record_get_int(record, _contacts_address.type, &addressType); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_int() Failed(%d)", err); + continue; + } + used |= addressType; + } + + int maxType = CONTACTS_ADDRESS_TYPE_WORK; + for (i=1;(1<<i)<=maxType;i++) { + if (!(used & (1<<i))) { + return 1<<i; + } + } + + return CONTACTS_ADDRESS_TYPE_OTHER; + +} + +int CtMyProfileInputData::removeAddress(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + + err = contacts_record_remove_child_record(__contactRecord, _contacts_my_profile.address, record); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_remove_child_record() Failed(%d)", err); + + return err; +} + +Eina_List* CtMyProfileInputData::getMessengerList() +{ + WHIT(); + return __getChildDataList(__contactRecord, _contacts_my_profile.messenger); +} + +contacts_record_h CtMyProfileInputData::addMessenger(const char *messenger) +{ + WDEBUG("messenger %s", messenger); + + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + + err = contacts_record_create(_contacts_messenger._uri, &record); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_create() Failed(%d)", err); + + setMessengerMessenger(record, messenger); + setMessengerType(record, getNextMessengerType(), NULL); + + err = contacts_record_add_child_record(__contactRecord, _contacts_my_profile.messenger, record); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(record, true); + return NULL; + } + return record; +} + +int CtMyProfileInputData::setMessengerMessenger(contacts_record_h record, const char *messenger) +{ + WDEBUG("messenger %s", messenger); + int err = CONTACTS_ERROR_NONE; + + if (messenger) { + err = contacts_record_set_str(record, _contacts_messenger.im_id, messenger); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +int CtMyProfileInputData::setMessengerType(contacts_record_h record, int type, const char *customStr) +{ + WDEBUG("type %d", type); + int err = CONTACTS_ERROR_NONE; + + if (type >= 0) { + err = contacts_record_set_int(record, _contacts_messenger.type, type); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + if (customStr) { + err = contacts_record_set_str(record, _contacts_messenger.label, customStr); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +int CtMyProfileInputData::getMessengerIndexType(int emailType) +{ + switch (emailType) { + case CONTACTS_MESSENGER_TYPE_CUSTOM: + return CTTEXT_MESSENGER_TYPE_CUSTOM; + case CONTACTS_MESSENGER_TYPE_AIM: + return CTTEXT_MESSENGER_TYPE_AIM; + case CONTACTS_MESSENGER_TYPE_YAHOO: + return CTTEXT_MESSENGER_TYPE_YAHOO; + case CONTACTS_MESSENGER_TYPE_SKYPE: + return CTTEXT_MESSENGER_TYPE_SKYPE; + case CONTACTS_MESSENGER_TYPE_QQ: + return CTTEXT_MESSENGER_TYPE_QQ; + case CONTACTS_MESSENGER_TYPE_ICQ: + return CTTEXT_MESSENGER_TYPE_ICQ; + case CONTACTS_MESSENGER_TYPE_JABBER: + default: + return CTTEXT_MESSENGER_TYPE_JABBER; + } +} + +int CtMyProfileInputData::getMessengerRetType(int indexType) +{ + int retType; + + switch (indexType) { + case CTTEXT_MESSENGER_TYPE_CUSTOM: + retType = CONTACTS_MESSENGER_TYPE_CUSTOM; + break; + case CTTEXT_MESSENGER_TYPE_AIM: + retType = CONTACTS_MESSENGER_TYPE_AIM; + break; + case CTTEXT_MESSENGER_TYPE_YAHOO: + retType = CONTACTS_MESSENGER_TYPE_YAHOO; + break; + case CTTEXT_MESSENGER_TYPE_SKYPE: + retType = CONTACTS_MESSENGER_TYPE_SKYPE; + break; + case CTTEXT_MESSENGER_TYPE_QQ: + retType = CONTACTS_MESSENGER_TYPE_QQ; + break; + case CTTEXT_MESSENGER_TYPE_ICQ: + retType = CONTACTS_MESSENGER_TYPE_ICQ; + break; + case CTTEXT_MESSENGER_TYPE_JABBER: + default: + retType = CONTACTS_MESSENGER_TYPE_JABBER; + break; + } + + return retType; +} + +const char* CtMyProfileInputData::getMessengerMessenger(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + char *messenger = NULL; + const char *result = NULL; + + err = contacts_record_get_str_p(record, _contacts_messenger.im_id, &messenger); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_str_p() Failed(%d)", err); + + result = messenger; + return result; +} + +int CtMyProfileInputData::getMessengerType(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + int type = 0; + + err = contacts_record_get_int(record, _contacts_messenger.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +void CtMyProfileInputData::getMessengerTypeStr(contacts_record_h record, int indexType, std::string &typeString) +{ + WHIT(); + const char* typeStr = NULL; + + if (indexType == CONTACTS_MESSENGER_TYPE_CUSTOM) { + typeStr = getDataTypeCustom(record, _contacts_messenger.label); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_AIM) { + typeStr = V_("IDS_PB_OPT_AIM"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_YAHOO) { + typeStr = V_("IDS_PB_OPT_YAHOO_E"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_SKYPE) { + typeStr = V_("IDS_PB_BODY_SKYPE"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_QQ) { + typeStr = V_("IDS_PB_OPT_QQ"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_GOOGLE) { + typeStr = V_("IDS_PB_OPT_HANGOUTS"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_ICQ) { + typeStr = V_("IDS_PB_OPT_ICQ"); + } + else if (indexType == CONTACTS_MESSENGER_TYPE_JABBER) { + typeStr = V_("IDS_PB_OPT_JABBER"); + } + + char *result = elm_entry_utf8_to_markup(typeStr); + if (result) { + typeString = result; + free(result); + } +} + +int CtMyProfileInputData::getNextMessengerType() +{ + int i; + int messengerType; + int indexType; + int index = 0; + int err = CONTACTS_ERROR_NONE; + int used[CTTEXT_TYPE_OTHER+1] = {0}; + contacts_record_h record = NULL; + while (CONTACTS_ERROR_NONE == contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.messenger, index++, &record)) { + err = contacts_record_get_int(record, _contacts_messenger.type, &messengerType); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_int() Failed(%d)", err); + continue; + } + indexType = getMessengerIndexType(messengerType); + used[indexType] = 1; + } + + for (i=CTTEXT_MESSENGER_TYPE_AIM;i<=CTTEXT_MESSENGER_TYPE_JABBER;i++) { + if (0 == used[i]) { + return getMessengerRetType(i); + } + } + + return CONTACTS_MESSENGER_TYPE_CUSTOM; + +} + +int CtMyProfileInputData::removeMessenger(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + + err = contacts_record_remove_child_record(__contactRecord, _contacts_my_profile.messenger, record); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_remove_child_record() Failed(%d)", err); + + return err; +} + +Eina_List* CtMyProfileInputData::getWebsiteList() +{ + WHIT(); + return __getChildDataList(__contactRecord, _contacts_my_profile.url); +} + +contacts_record_h CtMyProfileInputData::addWebsite(const char *url) +{ + WDEBUG("url %s", url); + + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + + err = contacts_record_create(_contacts_url._uri, &record); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_create() Failed(%d)", err); + + setWebsiteWebsite(record, url); + + err = contacts_record_add_child_record(__contactRecord, _contacts_my_profile.url, record); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(record, true); + return NULL; + } + return record; +} + +int CtMyProfileInputData::setWebsiteWebsite(contacts_record_h record, const char *url) +{ + WDEBUG("url %s", url); + int err = CONTACTS_ERROR_NONE; + + if (url) { + err = contacts_record_set_str(record, _contacts_url.url, url); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +const char* CtMyProfileInputData::getWebsiteWebsite(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + char *url = NULL; + const char *result = NULL; + + err = contacts_record_get_str_p(record, _contacts_url.url, &url); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_get_str_p() Failed(%d)", err); + + result = url; + return result; +} + +int CtMyProfileInputData::removeWebsite(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + + err = contacts_record_remove_child_record(__contactRecord, _contacts_my_profile.url, record); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_remove_child_record() Failed(%d)", err); + + return err; +} + +Eina_List* CtMyProfileInputData::getEventList() +{ + WHIT(); + return __getChildDataList(__contactRecord, _contacts_my_profile.event); +} + +contacts_record_h CtMyProfileInputData::addEvent(int date) +{ + WDEBUG("date %d", date); + + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + + err = contacts_record_create(_contacts_event._uri, &record); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_record_create() Failed(%d)", err); + + setEventEvent(record, date); + setEventType(record, getNextEventType(), NULL); + + err = contacts_record_add_child_record(__contactRecord, _contacts_my_profile.event, record); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_add_child_record() Failed(%d)", err); + contacts_record_destroy(record, true); + return NULL; + } + return record; +} + +int CtMyProfileInputData::setEventEvent(contacts_record_h record, int date) +{ + WDEBUG("date %d", date); + int err = CONTACTS_ERROR_NONE; + + if (date > 0) { + err = contacts_record_set_int(record, _contacts_event.date, date); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_int() Failed(%d)", err); + } + return err; +} + +int CtMyProfileInputData::setEventType(contacts_record_h record, int type, char *customStr) +{ + WDEBUG("type %d", type); + int err = CONTACTS_ERROR_NONE; + + if (type >= 0) { + err = contacts_record_set_int(record, _contacts_event.type, type); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + if (customStr) { + err = contacts_record_set_str(record, _contacts_event.label, customStr); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + } + + return err; +} + +int CtMyProfileInputData::getEventEvent(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + int date = 0; + + err = contacts_record_get_int(record, _contacts_event.date, &date); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return date; +} + +int CtMyProfileInputData::getEventType(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + int type = 0; + + err = contacts_record_get_int(record, _contacts_event.type, &type); + WPRET_VM(CONTACTS_ERROR_NONE != err, 0, "contacts_record_get_int() Failed(%d)", err); + + return type; +} + +void CtMyProfileInputData::getEventTypeStr(contacts_record_h record, int eventType, std::string &typeString) +{ + WHIT(); + const char* typeStr = NULL; + + if (eventType == CONTACTS_EVENT_TYPE_CUSTOM) { + typeStr = getDataTypeCustom(record, _contacts_event.label); + } + else if (eventType == CONTACTS_EVENT_TYPE_BIRTH) { + typeStr = V_("IDS_PB_OPT_BIRTHDAY"); + } + else if (eventType == CONTACTS_EVENT_TYPE_ANNIVERSARY) { + typeStr = V_("IDS_PB_OPT_ANNIVERSARY_ABB"); + } + else { + typeStr = V_("IDS_PB_OPT_OTHER"); + } + + char *result = elm_entry_utf8_to_markup(typeStr); + if (result) { + typeString = result; + free(result); + } +} + +int CtMyProfileInputData::getNextEventType() +{ + int eventType; + int index = 0; + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + bool usedBirthday = false; + + while (CONTACTS_ERROR_NONE == contacts_record_get_child_record_at_p(__contactRecord, _contacts_my_profile.event, index++, &record)) { + err = contacts_record_get_int(record, _contacts_event.type, &eventType); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_int() Failed(%d)", err); + continue; + } + if (CONTACTS_EVENT_TYPE_BIRTH == eventType) { + usedBirthday = true; + break; + } + } + + if (usedBirthday) + return CONTACTS_EVENT_TYPE_ANNIVERSARY; + + return CONTACTS_EVENT_TYPE_BIRTH; + +} + +int CtMyProfileInputData::removeEvent(contacts_record_h record) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + + err = contacts_record_remove_child_record(__contactRecord, _contacts_my_profile.event, record); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_remove_child_record() Failed(%d)", err); + + return err; +} + +void CtMyProfileInputData::__removeEmptyFiedls() +{ + removeEmptyFieldRecord(_contacts_my_profile.number, _contacts_number.number); + removeEmptyFieldRecord(_contacts_my_profile.email, _contacts_email.email); + removeEmptyFieldRecord(_contacts_my_profile.address, _contacts_address.street); + removeEmptyFieldRecord(_contacts_my_profile.url, _contacts_url.url); + removeEmptyFieldRecord(_contacts_my_profile.messenger, _contacts_messenger.im_id); + removeEmptyFieldRecord(_contacts_my_profile.note, _contacts_note.note); +} + +int CtMyProfileInputData::insertContact(int *contactId) +{ + WHIT(); + return contacts_db_insert_record(__contactRecord, contactId); +} + +int CtMyProfileInputData::updateContact() +{ + WHIT(); + return contacts_db_update_record(__contactRecord); +} + +int CtMyProfileInputData::getContactId() +{ + WHIT(); + return __contactId; +} + +Eina_List* CtMyProfileInputData::__getChildDataList(contacts_record_h contactRecord, unsigned int propertyId) +{ + WDEBUG("propertyId %d", propertyId); + int index = 0; +// Eina_List *l; + Eina_List *dataRecordList = NULL; + int err = CONTACTS_ERROR_NONE; + contacts_record_h dataRecord = NULL; +// contacts_record_h dataRecordClone = NULL; + + while (CONTACTS_ERROR_NONE == contacts_record_get_child_record_at_p(contactRecord, propertyId, index++, &dataRecord)) { + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_str_p() Failed(%d)", err); + break; + } + + //err = contacts_record_clone(dataRecord, &dataRecordClone); + //if (CONTACTS_ERROR_NONE != err) { + // WERROR("contacts_list_get_current_record_p() Failed(%d)", err); + // break; + //} + dataRecordList = eina_list_append(dataRecordList, dataRecord); + } + + return dataRecordList; +} + +void CtMyProfileInputData::setPreferenceCreateFirst(bool isFirst) +{ + WHIT(); +} + +int CtMyProfileInputData::getAddressbookId() +{ + WHIT(); + return 0; +} + +const char* CtMyProfileInputData::getAddressbookName() +{ + WHIT(); + return NULL; +} + +const char* CtMyProfileInputData::getUserName() +{ + WHIT(); + return NULL; +} + +void CtMyProfileInputData::setAddressbookInfo(int addressbookId) +{ + WHIT(); +} + +Eina_List* CtMyProfileInputData::getRelationshipList() +{ + WHIT(); + return NULL; +} + +contacts_record_h CtMyProfileInputData::addRelationship(const char *relationship) +{ + WHIT(); + return NULL; +} + +int CtMyProfileInputData::setRelationshipRelationship(contacts_record_h record, const char *relationship) +{ + WHIT(); + return 0; +} + +int CtMyProfileInputData::setRelationshipType(contacts_record_h record, int type, const char *customStr) +{ + WHIT(); + return 0; +} + +const char* CtMyProfileInputData::getRelationshipRelationship(contacts_record_h record) +{ + WHIT(); + return NULL; +} + +int CtMyProfileInputData::getRelationshipType(contacts_record_h record) +{ + WHIT(); + return 0; +} + +void CtMyProfileInputData::getRelationshipTypeStr(contacts_record_h record, int indexType, std::string &typeString) +{ + WHIT(); +} + +int CtMyProfileInputData::getNextRelationshipType() +{ + WHIT(); + return 0; +} + +int CtMyProfileInputData::removeRelationship(contacts_record_h record) +{ + WHIT(); + return 0; +} + +contacts_record_h CtMyProfileInputData::getDefaultEmail() +{ + WHIT(); + return NULL; +} + +bool CtMyProfileInputData::checkChangedTypeIsDeleted() +{ + WHIT(); + return false; +} + +void CtMyProfileInputData::attachListener(ICtChangeListener* listener) +{ + WHIT(); +} + +void CtMyProfileInputData::detachListener() +{ + WHIT(); +} + +void CtMyProfileInputData::removeEmptyFieldRecord(int property_id, int property_id_str) +{ + int i; + int count; + char *str1 = NULL; + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + bool empty = false; + + err = contacts_record_get_child_record_count(__contactRecord, property_id, &count); + WPRET_M(CONTACTS_ERROR_NONE != err, "contacts_record_get_child_record_count() Failed(%d)", err); + + for (i=count-1;0<=i;i--) { + empty = false; + err = contacts_record_get_child_record_at_p(__contactRecord, property_id, i, &record); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_child_record_at_p() Failed(%d)", err); + continue; + } + + err = contacts_record_get_str(record, property_id_str, &str1); + WPRET_M(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + if (CONTACTS_ERROR_NONE != err || NULL == str1 || '\0' == *str1) { + empty = true; + } + free(str1); + + if (empty) { + err = contacts_record_remove_child_record(__contactRecord, property_id, record); + WPRET_M(CONTACTS_ERROR_NONE != err, "contacts_record_remove_child_record() Failed(%d)", err); + err = contacts_record_destroy(record, true); + WPRET_M(CONTACTS_ERROR_NONE != err, "contacts_record_destroy() Failed(%d)", err); + } + } +} diff --git a/lib-contact/ct-detail/src/CtMyProfileInputData.h b/lib-contact/ct-detail/src/CtMyProfileInputData.h new file mode 100755 index 0000000..8be67bf --- /dev/null +++ b/lib-contact/ct-detail/src/CtMyProfileInputData.h @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_MYPROFILE_INPUT_DATA_H_ +#define _CT_MYPROFILE_INPUT_DATA_H_ + +#include <Eina.h> + +#include <contacts.h> +//#include <contacts_product.h> + +#include "ContactsCommon.h" + +#include "CtType.h" + +#include "CtData.h" + +class CtMyProfileInputData:public CtData +{ +public: + CtMyProfileInputData(contacts_record_h contactRecord); + CtMyProfileInputData(ContactsData &contactsData); + CtMyProfileInputData(); + virtual ~CtMyProfileInputData(); + contacts_record_h addGroupRelation(int groupId){ return NULL; }; + +public: + + virtual int insertContact(int *contactId); + virtual int updateContact(); + + virtual int separateFullName(contacts_record_h nameRecord, const char *full_name); + virtual int separatePhoneticFullName(contacts_record_h nameRecord, const char *full_name); + virtual int setPrefixName(const char *text); + virtual int setSuffixName(const char *text); + virtual int setPhoneticFullName(const char *text); + virtual int setPhoneticFirstName(const char *text); + virtual int setPhoneticMiddleName(const char *text); + virtual int setPhoneticLastName(const char *text); + virtual int setNickname(const char *text); + virtual int setCompany(const char *text); + virtual int setJobTitle(const char *text); + virtual int setFullName(const char *text); + virtual int setFirstName(const char *text); + virtual int setMiddleName(const char *text); + virtual int setLastName(const char *text); + virtual const char* getPrefixName(); + virtual const char* getSuffixName(); + virtual const char* getPhoneticFirstName(); + virtual const char* getPhoneticMiddleName(); + virtual const char* getPhoneticLastName(); + virtual const char* getNickname(); + virtual const char* getCompany(); + virtual const char* getJobTitle(); + virtual void getFullName(std::string &Name); + virtual const char* getFirstName(); + virtual const char* getMiddleName(); + virtual const char* getLastName(); + // ... + virtual bool getFavorite(){return false;} + //virtual bool getMFC(){return false;} + virtual int getPersonId(){return 0;} + + virtual int getAddressbookId(); + virtual const char* getAddressbookName(); + virtual const char* getUserName(); + virtual void setAddressbookInfo(int addressbookId); + + virtual const char* getImagePath(); + virtual contacts_record_h getImageRecord(); + virtual int removeImage(contacts_record_h record); + virtual int setImage(contacts_record_h record, char *image, int type); + virtual void setPreferenceCreateFirst(bool isFirst); + + virtual contacts_record_h getEmergencyNumber(); + virtual Eina_List* getNumberList(); + virtual contacts_record_h addNumber(const char *number); + virtual int setNumberNumber(contacts_record_h record, const char *number); + virtual int setNumberType(contacts_record_h record, int type, const char *customStr); + virtual int removeNumber(contacts_record_h record); + virtual const char* getNumberNumber(contacts_record_h record); + virtual int getNumberType(contacts_record_h record); + virtual const char *getDataTypeCustom(contacts_record_h record, int property_id); + virtual void getNumberTypeStr(contacts_record_h record, int numberType, std::string &typeString); + virtual int getNumberRetType(int indexType); + virtual int getNumberIndexType(int numberType); + virtual int getNextNumberType(); + + virtual Eina_List* getEmailList(); + virtual contacts_record_h addEmail(const char *email); + virtual int setEmailEmail(contacts_record_h record, const char *email); + virtual int setEmailType(contacts_record_h record, int type, char *customStr); + virtual const char* getEmailEmail(contacts_record_h record); + virtual int getEmailType(contacts_record_h record); + virtual void getEmailTypeStr(contacts_record_h record, int indexType, std::string &typeString); + virtual int getNextEmailType(); + virtual int removeEmail(contacts_record_h record); + + virtual Eina_List* getNoteList(); + virtual contacts_record_h getNoteRecord(); + virtual contacts_record_h addNote(const char *note); + virtual int setNote(contacts_record_h record, const char *note); + virtual const char* getNote(contacts_record_h record); + virtual int removeNote(contacts_record_h record); + + virtual Eina_List* getAddressList(); + virtual contacts_record_h addAddress(const char *address); + virtual int setAddressAddress(contacts_record_h record, const char *address); + virtual int setAddressType(contacts_record_h record, int type, const char *customStr); + virtual int getAddressAddress(contacts_record_h record, char *buf, int length); + virtual int getAddressType(contacts_record_h record); + virtual void getAddressTypeStr(contacts_record_h record, int indexType, std::string &typeString); + virtual int getNextAddressType(); + virtual int removeAddress(contacts_record_h record); + + virtual Eina_List* getMessengerList(); + virtual contacts_record_h addMessenger(const char *messenger); + virtual int setMessengerMessenger(contacts_record_h record, const char *messenger); + virtual int setMessengerType(contacts_record_h record, int type, const char *customStr); + virtual int getMessengerIndexType(int emailType); + virtual int getMessengerRetType(int indexType); + virtual const char* getMessengerMessenger(contacts_record_h record); + virtual int getMessengerType(contacts_record_h record); + virtual void getMessengerTypeStr(contacts_record_h record, int indexType, std::string &typeString); + virtual int getNextMessengerType(); + virtual int removeMessenger(contacts_record_h record); + + virtual Eina_List* getWebsiteList(); + virtual contacts_record_h addWebsite(const char *url); + virtual int setWebsiteWebsite(contacts_record_h record, const char *url); + virtual const char* getWebsiteWebsite(contacts_record_h record); + virtual int removeWebsite(contacts_record_h record); + + virtual Eina_List* getRelationshipList(); + virtual contacts_record_h addRelationship(const char *relationship); + virtual int setRelationshipRelationship(contacts_record_h record, const char *relationship); + virtual int setRelationshipType(contacts_record_h record, int type, const char *customStr); + virtual const char* getRelationshipRelationship(contacts_record_h record); + virtual int getRelationshipType(contacts_record_h record); + virtual void getRelationshipTypeStr(contacts_record_h record, int indexType, std::string &typeString); + virtual int getNextRelationshipType(); + virtual int removeRelationship(contacts_record_h record); + + virtual Eina_List* getEventList(); + virtual contacts_record_h addEvent(int date); + virtual int setEventEvent(contacts_record_h record, int date); + virtual int setEventType(contacts_record_h record, int type, char *customStr); + virtual int getEventEvent(contacts_record_h record); + virtual int getEventType(contacts_record_h record); + virtual void getEventTypeStr(contacts_record_h record, int eventType, std::string &typeString); + virtual int getNextEventType(); + virtual int removeEvent(contacts_record_h record); + + virtual int getContactId(); + + virtual contacts_record_h getDefaultEmail(); + virtual contacts_record_h getDefaultNumber(); + virtual bool checkChangedTypeIsDeleted(); + virtual void attachListener(ICtChangeListener* listener); + virtual void detachListener(); + void removeEmptyFieldRecord(int property_id, int property_id_str); + + // for check input addressbook item is added or not + virtual void setInputAddressbookItem(bool added) {} + virtual bool getInputAddressbookItem(void) {return false;} + +private: + void __init(); + void __appendStringWithLinebreak(const char *src, char *dest, int length); + int __getFullAddress(contacts_record_h addresssRecord, char *buf, int length); + Eina_List* __getChildDataList(contacts_record_h contactRecord, unsigned int propertyId); + void __removeEmptyFiedls(); + +private: + contacts_record_h __contactRecord; + + int __contactId; +}; + +#endif //_CT_MYPROFILE_INPUT_DATA_H_ diff --git a/lib-contact/ct-detail/src/CtMyProfileInputView.cpp b/lib-contact/ct-detail/src/CtMyProfileInputView.cpp new file mode 100755 index 0000000..9e8cc26 --- /dev/null +++ b/lib-contact/ct-detail/src/CtMyProfileInputView.cpp @@ -0,0 +1,1591 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <account.h> +#include <app_preference.h> +#include <contacts.h> + +#include "WPopup.h" + +#include "ContactsDebug.h" +#include "ContactsAppControlLauncher.h" + +#include "CtPath.h" +#include "CtMyProfileDetailView.h" +#include "CtMyProfileInputData.h" +#include "CtMyProfileInputView.h" +#include "CtCommon.h" + +#include "CtInputViewGenlistItem.h" +#include "CtInputViewBasicInfoItem.h" +#include "CtInputViewEmailItem.h" +#include "CtInputViewNoteItem.h" +#include "CtInputViewMessengerItem.h" +#include "CtInputViewAddressItem.h" +#include "CtInputViewWebsiteItem.h" +#include "CtInputViewEventItem.h" +#include "CtInputViewNumberItem.h" +#include "CtInputViewMsisdnItem.h" +#include "CtInputViewImportantFieldsItem.h" +#include "CtInputViewImportantSubItem.h" +#include "CtThemeMgr.h" + +#define GALLERY_UG "ug-gallery-efl" +#define __ITEM_HEIGHT 96 +#define DATE_TIME_FORMAT "%%c" + +CtMyProfileInputView::CtMyProfileInputView(contacts_record_h contactRecord) +{ + WHIT(); + __inputData = std::shared_ptr<CtData>( new CtMyProfileInputData(contactRecord) ); + __initialize(); +} + +CtMyProfileInputView::~CtMyProfileInputView() +{ + WHIT(); + destroyPopup(); + ContactsAppControlLauncher::getInstance().terminate(); + + free(__basicInfoFullName); +} + +void CtMyProfileInputView::__initialize() +{ + __contactId = 0; + __appendIndex = 0; + __saved = false; + __discard = false; + __changed = false; + + __basicInfoFullName = NULL; + __baseInfoExpanded = false; + __isCreate = __inputData->getContactId() > 0 ? false : true; + + memset( __genlistItems, 0, sizeof(__genlistItems) ); + + __birthdayEventExist = std::make_shared<bool> (false); +} + +void CtMyProfileInputView::onDbChanged(const char* viewUri) +{ + WENTER(); +} + +void CtMyProfileInputView::onCompleteGetContacts(int offset) +{ + WENTER(); +} + +void CtMyProfileInputView::onConditionChagned() +{ + WENTER(); +} + + +Evas_Object* CtMyProfileInputView::onCreate(Evas_Object* parent, void* viewParam) +{ + WHIT(); + if (__isCreate) + setTitle(V_("IDS_PB_SK_CREATE_ABB")); + else + setTitle(V_("IDS_PB_OPT_EDIT")); + + std::string contactsEdjePath; + std::string buttonStylesEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + ContactsCommon::getAppEdjePath(CUSTOM_BUTTON_STYLES_EDJ, buttonStylesEdjePath); + Evas_Object *base = createBaseLayout(parent); + CtThemeMgr::getInstance()->addExtensionTheme(contactsEdjePath.c_str()); + CtThemeMgr::getInstance()->addExtensionTheme(buttonStylesEdjePath.c_str()); + CtThemeMgr::getInstance()->setObjectTheme(base); + + Evas_Object* genlist = elm_genlist_add(base); + evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS); + evas_object_show(genlist); + __genlist = genlist; + + elm_object_part_content_set(base, "elm.swallow.content", genlist); + evas_object_smart_callback_add(genlist, "realized", __genlistRealizedCb, this); + evas_object_smart_callback_add(genlist, "unrealized", __genlistUnrealizedCb, this); + + return base; +} + +void CtMyProfileInputView::onLanguageChanged() +{ + WHIT(); + + destroyPopup(); + + elm_object_text_set(__saveBtn, V_("IDS_PB_BUTTON_DONE_ABB3")); + + Evas_Object* cancelBtn = elm_object_item_part_content_get(getNaviItem(), "title_left_btn"); + elm_object_text_set(cancelBtn, V_("IDS_PB_BUTTON_CANCEL")); + + if (__isCreate) { + elm_object_item_part_text_set(getNaviItem(), "elm.text.title", V_("IDS_PB_BUTTON_CREATE_ABB2")); + } + else { //TODO: translation needed + elm_object_item_part_text_set(getNaviItem(), "elm.text.title", "EDIT"); + } + + if(__genlist) + elm_genlist_realized_items_update(__genlist); +} + +Evas_Object* CtMyProfileInputView::__getWindowEvasObj(void) +{ + if(getWindow()) + return getWindow()->getEvasObj(); + else + WASSERT_EX(1, "window null"); + return NULL; +} +Evas_Object* CtMyProfileInputView::__getNaviframeEvasObj(void) +{ + if (getNaviframe()) { + return getNaviframe()->getEvasObj(); + } + else { + return NULL; + } +} + + +void CtMyProfileInputView:: __genlistRealizedCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + CtMyProfileInputView *view = (CtMyProfileInputView*)data; + + view->__updateEntryReturnKeyType(NULL); + + Elm_Object_Item *objectItem = (Elm_Object_Item*) event_info; + CtInputViewGenlistItem *item = (CtInputViewGenlistItem*) elm_object_item_data_get(objectItem); + if (item) { + item->onRealized(); + } + + if (objectItem == view->__genlistItems[MYPROFILE_INPUT_BASIC_INFO]) { + view->__updateBasicInfoItem(); + } +} + + +void CtMyProfileInputView::__genlistUnrealizedCb(void *data, Evas_Object *obj, void *event_info) +{ + Elm_Object_Item *objectItem = (Elm_Object_Item*) event_info; + CtInputViewGenlistItem *item = (CtInputViewGenlistItem*) elm_object_item_data_get(objectItem); + if (item) { + item->onUnrealized(); + } +} + +void CtMyProfileInputView::__save() +{ + int err = CONTACTS_ERROR_NONE; + int retId = 0; + + if (__isCreate) { + err = __inputData->insertContact(&retId); + + if (CONTACTS_ERROR_NONE != err) { + WERROR("insert failed %d", err); + } + } + else { + err = __inputData->updateContact(); + if (CONTACTS_ERROR_NONE != err) { + WERROR("update failed %d", err); + } + } + __saved = true; + + if (__isCreate) { + getNaviframe()->push(new CtMyProfileDetailView()); + destroy(); + } else { + popOut(); + } + + int ret = preference_set_boolean(CT_KEY_MYPROFILE_CREATE_FIRST, false); + WDEBUG("preference_set_boolean(%d) Failed", ret); +} + +void CtMyProfileInputView::__saveCb(void *data, Evas_Object *obj, void *event_info) +{ + CtMyProfileInputView *view = (CtMyProfileInputView*)data; + + view->__save(); +} + +void CtMyProfileInputView::__cancelCb(void *data, Evas_Object *obj, void *event_info) +{ + CtMyProfileInputView *view = (CtMyProfileInputView*)data; + elm_naviframe_item_pop(view->__getNaviframeEvasObj()); +} + +void CtMyProfileInputView::onPushed(Elm_Object_Item* naviItem) +{ + WHIT(); + //add title button + __saveBtn = elm_button_add(getNaviframe()->getEvasObj()); + elm_object_style_set(__saveBtn, "naviframe/title_right"); + elm_object_text_set(__saveBtn, V_("IDS_TPLATFORM_ACBUTTON_DONE_ABB")); + evas_object_smart_callback_add(__saveBtn, "clicked", __saveCb, this); + elm_object_item_part_content_set(naviItem, "title_right_btn", __saveBtn); + + if (__isCreate) { + elm_object_disabled_set(__saveBtn, EINA_TRUE); + } + + Evas_Object* cancelButton = elm_button_add(getNaviframe()->getEvasObj()); + elm_object_style_set(cancelButton, "naviframe/title_left"); + elm_object_text_set(cancelButton, V_("IDS_TPLATFORM_ACBUTTON_CANCEL_ABB")); + evas_object_smart_callback_add(cancelButton, "clicked", __cancelCb, this); + elm_object_item_part_content_set(naviItem, "title_left_btn", cancelButton); + + __addAllItems(); + +} + +void CtMyProfileInputView::__galleryReplyCb(app_control_h request, app_control_h reply, app_control_result_e result, void *data) +{ + WHIT(); + char **pathArray = NULL; + char *path = NULL; + int arrayLength = 0; + CtMyProfileInputView *view = (CtMyProfileInputView*)data; + int i=0; + + app_control_get_extra_data_array(reply, APP_CONTROL_DATA_SELECTED, &pathArray, &arrayLength); + if (arrayLength > 0 && pathArray[0]) { + path = strdup(pathArray[0]); + } + for (i = 0; i < arrayLength; i++) { + free(pathArray[i]); + } + free(pathArray); + + elm_object_tree_focus_allow_set(view->__getNaviframeEvasObj(), EINA_TRUE); + + if (path) { + WDEBUG("image path %s", path); + contacts_record_h record = view->__inputData->getImageRecord(); + //view->__inputData->setImage(record, path, CONTACTS_IMAGE_TYPE_EX_OTHER); + view->__inputData->setImage(record, path, CONTACTS_IMAGE_TYPE_OTHER); + view->__basicInfoUpdateImage(); + free(path); + } +// else { +// elm_object_focus_set(cinput_d->image_focus_btn, EINA_TRUE); +// } +} + +void CtMyProfileInputView::__launchGallery(CtMyProfileInputView *view) +{ + WHIT(); + + app_control_h service = NULL; + int ret = 0; + + elm_object_tree_focus_allow_set(view->__getNaviframeEvasObj(), EINA_FALSE); + + ret = app_control_create(&service); + WPWARN(APP_CONTROL_ERROR_NONE != ret, "app_control_create() Failed(%d)", ret); + + app_control_set_operation(service, APP_CONTROL_OPERATION_PICK); + app_control_set_app_id(service, GALLERY_UG); + app_control_add_extra_data(service, "hide-personal", "true"); + app_control_add_extra_data(service, "launch-type", "select-setas"); + app_control_add_extra_data(service, "setas-type", "callerid"); + app_control_set_launch_mode(service, APP_CONTROL_LAUNCH_MODE_GROUP); + + app_control_add_extra_data(service, "View Mode", "SETAS"); + app_control_add_extra_data(service, "Setas type", "CallerID"); + app_control_add_extra_data(service, "Area Size", "100"); + app_control_add_extra_data(service, "Resolution", "480x480"); + + + if( !ContactsAppControlLauncher::getInstance().sendLaunchRequest( service, __galleryReplyCb, view, view->__getNaviframeEvasObj() ) ) + { + WERROR("launch Failed"); + elm_object_tree_focus_allow_set(view->__getNaviframeEvasObj(), EINA_TRUE); + } +} + +void CtMyProfileInputView::__cameraReplyCb(app_control_h request, app_control_h reply, app_control_result_e result, void *data) +{ + WHIT(); + char *path = NULL; + CtMyProfileInputView *view = (CtMyProfileInputView*)data; + + elm_object_tree_focus_allow_set(view->__getNaviframeEvasObj(), EINA_TRUE); + + app_control_get_extra_data(reply, APP_CONTROL_DATA_SELECTED, &path); + if (path && *path) { + contacts_record_h record = view->__inputData->getImageRecord(); + view->__inputData->setImage(record, path, CONTACTS_IMAGE_TYPE_OTHER); + view->__basicInfoUpdateImage(); + } + free(path); +} + +void CtMyProfileInputView::__launchCamera(CtMyProfileInputView *view) +{ + app_control_h service; + app_control_create(&service); + app_control_set_operation(service, APP_CONTROL_OPERATION_CREATE_CONTENT); + app_control_set_launch_mode(service, APP_CONTROL_LAUNCH_MODE_GROUP); + app_control_set_mime(service, "image/jpg"); + app_control_add_extra_data(service, "CALLER", "contacts"); + + bool ret = ContactsAppControlLauncher::getInstance().sendLaunchRequest( service, __cameraReplyCb, view, view->__getNaviframeEvasObj() ); + + if( !ret ) + { + WERROR("launch Failed"); + } +} + + +void CtMyProfileInputView::__onGallerySelCb(void *data, Evas_Object *obj, void *event_info) +{ + WPRET_M(NULL == data, "data is NULL"); + CtMyProfileInputView *view = (CtMyProfileInputView*)data; + + view->__launchGallery(view); + + view->destroyPopup(); +} + +void CtMyProfileInputView::__onCameraSelCb(void *data, Evas_Object *obj, void *event_info) +{ + WPRET_M(NULL == data, "data is NULL"); + CtMyProfileInputView *view = (CtMyProfileInputView*)data; + + view->__launchCamera(view); + + view->destroyPopup(); +} + +void CtMyProfileInputView::__onRemoveSelCb(void *data, Evas_Object *obj, void *event_info) +{ + WPRET_M(NULL == data, "data is NULL"); + CtMyProfileInputView *view = (CtMyProfileInputView*)data; + view->destroyPopup(); + + contacts_record_h record = NULL; + record = view->__inputData->getImageRecord(); + view->__inputData->removeImage(record); + view->__basicInfoUpdateImage(); +} + +void CtMyProfileInputView::__importantSubitemSelectedCb(void* data, Evas_Object* obj, void* event_info) +{ + WPRET_M(NULL == data, "data is NULL"); + CtMyProfileInputView *view = (CtMyProfileInputView*)data; + Elm_Object_Item *item = (Elm_Object_Item *) event_info; + CtInputViewImportantSubItem *importantSubItem = (CtInputViewImportantSubItem *)elm_object_item_data_get(item); + contacts_record_h record = NULL; + CtMyProfileInputItems checkExistItem = MYPROFILE_INPUT_BASIC_INFO; + Elm_Object_Item *addedItem = NULL; + + view->destroyPopup(); + + elm_genlist_item_selected_set(item, EINA_FALSE); + + switch (importantSubItem->getIndex()) { + case MYPROFILE_INPUT_IMPORTANT_PHONETIC_INFO: + { + CtInputViewBasicInfoItem* basicInfoItem = (CtInputViewBasicInfoItem*)elm_object_item_data_get(view->__genlistItems[MYPROFILE_INPUT_BASIC_INFO]); + WPRET_M(NULL == basicInfoItem, "basicInfoItem is NULL"); + + elm_object_item_disabled_set(item, EINA_TRUE); + basicInfoItem->setAddPhoneticName(true); + basicInfoItem->setAddedIndex(INPUT_ADDED_ITEM_INDEX_PHONETIC_INFO); + elm_genlist_item_fields_update(view->__genlistItems[MYPROFILE_INPUT_BASIC_INFO], "elm.icon.1", ELM_GENLIST_ITEM_FIELD_CONTENT); + addedItem = view->__genlistItems[MYPROFILE_INPUT_BASIC_INFO]; + + break; + } + case MYPROFILE_INPUT_IMPORTANT_MESSENGER: + { + record = view->__inputData->addMessenger(""); + view->__addedIndex = INPUT_ADDED_ITEM_INDEX_IM; + + if (view->__genlistItems[MYPROFILE_INPUT_MESSENGER]) { + checkExistItem = MYPROFILE_INPUT_MESSENGER; + } + else if (view->__genlistItems[MYPROFILE_INPUT_URL]) { + checkExistItem = MYPROFILE_INPUT_URL; + } + else if (view->__genlistItems[MYPROFILE_INPUT_EVENT]) { + checkExistItem = MYPROFILE_INPUT_EVENT; + } + else if (view->__genlistItems[MYPROFILE_INPUT_ADDRESS]) { + checkExistItem = MYPROFILE_INPUT_ADDRESS; + } + else if (view->__genlistItems[MYPROFILE_INPUT_NOTE]) { + checkExistItem = MYPROFILE_INPUT_NOTE; + } + else if (view->__genlistItems[MYPROFILE_INPUT_EMAIL]) { + checkExistItem = MYPROFILE_INPUT_EMAIL; + } + else if (view->__genlistItems[MYPROFILE_INPUT_NUMBER]) { + checkExistItem = MYPROFILE_INPUT_NUMBER; + } + else if (view->__genlistItems[MYPROFILE_INPUT_MSISDN]) { + checkExistItem = MYPROFILE_INPUT_MSISDN; + } + else { + checkExistItem = MYPROFILE_INPUT_BASIC_INFO; + } + WDEBUG("INPUT_MESSENGER item is after %d item", checkExistItem); + + CtInputViewMessengerItem* item = new CtInputViewMessengerItem( view->__inputData, record, NULL, view->__addedIndex, + [view](){ view->__itemChanged(); }, + [view](Elm_Object_Item* item, bool isChanged, contacts_record_h record){ view->__messengerItemDeleted( item, isChanged, record ); }, + [view](Evas_Object* obj, Elm_Object_Item* objItem){ view->__activateNextEntry(obj, objItem); } ); + Elm_Object_Item* genItem = elm_genlist_item_insert_after( view->__genlist, item->getItemClassStatic(), item, NULL, view->__genlistItems[checkExistItem], ELM_GENLIST_ITEM_NONE, NULL, NULL); + item->setElmObjectItem( genItem ); + item->focus(); + view->__genlistItems[MYPROFILE_INPUT_MESSENGER] = genItem; + addedItem = genItem; + break; + } + case MYPROFILE_INPUT_IMPORTANT_URL: + { + record = view->__inputData->addWebsite(""); + view->__addedIndex = INPUT_ADDED_ITEM_INDEX_URL; + + if (view->__genlistItems[MYPROFILE_INPUT_URL]) { + checkExistItem = MYPROFILE_INPUT_URL; + } + else if (view->__genlistItems[MYPROFILE_INPUT_EVENT]) { + checkExistItem = MYPROFILE_INPUT_EVENT; + } + else if (view->__genlistItems[MYPROFILE_INPUT_ADDRESS]) { + checkExistItem = MYPROFILE_INPUT_ADDRESS; + } + else if (view->__genlistItems[MYPROFILE_INPUT_NOTE]) { + checkExistItem = MYPROFILE_INPUT_NOTE; + } + else if (view->__genlistItems[MYPROFILE_INPUT_EMAIL]) { + checkExistItem = MYPROFILE_INPUT_EMAIL; + } + else if (view->__genlistItems[MYPROFILE_INPUT_NUMBER]) { + checkExistItem = MYPROFILE_INPUT_NUMBER; + } + else if (view->__genlistItems[MYPROFILE_INPUT_MSISDN]) { + checkExistItem = MYPROFILE_INPUT_MSISDN; + } + else { + checkExistItem = MYPROFILE_INPUT_BASIC_INFO; + } + WDEBUG("INPUT_URL item is after %d item", checkExistItem); + + CtInputViewWebsiteItem* item = new CtInputViewWebsiteItem( view->__inputData, record, NULL, view->__addedIndex, + [view](){ view->__itemChanged(); }, + [view](Elm_Object_Item* item, bool isChanged, contacts_record_h record){ view->__websiteItemDeleted( item, isChanged, record );}, + [view](Evas_Object* obj, Elm_Object_Item* objItem){ view->__activateNextEntry(obj, objItem); } ); + Elm_Object_Item* genItem = elm_genlist_item_insert_after( view->__genlist, item->getItemClassStatic(), item, NULL, view->__genlistItems[checkExistItem], ELM_GENLIST_ITEM_NONE, NULL, NULL); + item->setElmObjectItem( genItem ); + item->focus(); + view->__genlistItems[MYPROFILE_INPUT_URL] = genItem; + addedItem = genItem; + break; + } + case MYPROFILE_INPUT_IMPORTANT_ORGANIZATION: + { + CtInputViewBasicInfoItem* basicInfoItem = (CtInputViewBasicInfoItem*)elm_object_item_data_get(view->__genlistItems[MYPROFILE_INPUT_BASIC_INFO]); + WPRET_M(NULL == basicInfoItem, "basicInfoItem is NULL"); + + elm_object_item_disabled_set(item, EINA_TRUE); + basicInfoItem->setAddOrganization(true); + basicInfoItem->setAddedIndex(INPUT_ADDED_ITEM_INDEX_ORGANIZATION); + elm_genlist_item_fields_update(view->__genlistItems[MYPROFILE_INPUT_BASIC_INFO], "elm.icon.1", ELM_GENLIST_ITEM_FIELD_CONTENT); + addedItem = view->__genlistItems[MYPROFILE_INPUT_BASIC_INFO]; + + break; + } + case MYPROFILE_INPUT_IMPORTANT_NICKNAME: + { + CtInputViewBasicInfoItem* basicInfoItem = (CtInputViewBasicInfoItem*)elm_object_item_data_get(view->__genlistItems[MYPROFILE_INPUT_BASIC_INFO]); + WPRET_M(NULL == basicInfoItem, "basicInfoItem is NULL"); + + elm_object_item_disabled_set(item, EINA_TRUE); + basicInfoItem->setAddNickname(true); + basicInfoItem->setAddedIndex(INPUT_ADDED_ITEM_INDEX_NICKNAME); + elm_genlist_item_fields_update(view->__genlistItems[MYPROFILE_INPUT_BASIC_INFO], "elm.icon.1", ELM_GENLIST_ITEM_FIELD_CONTENT); + addedItem = view->__genlistItems[MYPROFILE_INPUT_BASIC_INFO]; + + break; + } + case MYPROFILE_INPUT_IMPORTANT_EVENT: + { + view->__createEventDataPopup(); + break; + } + case MYPROFILE_INPUT_IMPORTANT_ADDRESS: + { + record = view->__inputData->addAddress(""); + view->__addedIndex = INPUT_ADDED_ITEM_INDEX_ADDRESS; + + if (view->__genlistItems[MYPROFILE_INPUT_ADDRESS]) { + checkExistItem = MYPROFILE_INPUT_ADDRESS; + } + if (view->__genlistItems[MYPROFILE_INPUT_NOTE]) { + checkExistItem = MYPROFILE_INPUT_NOTE; + } + else if (view->__genlistItems[MYPROFILE_INPUT_EMAIL]) { + checkExistItem = MYPROFILE_INPUT_EMAIL; + } + else if (view->__genlistItems[MYPROFILE_INPUT_NUMBER]) { + checkExistItem = MYPROFILE_INPUT_NUMBER; + } + else if (view->__genlistItems[MYPROFILE_INPUT_MSISDN]) { + checkExistItem = MYPROFILE_INPUT_MSISDN; + } + else { + checkExistItem = MYPROFILE_INPUT_BASIC_INFO; + } + WDEBUG("INPUT_ADDRESS item is after %d item", checkExistItem); + + CtInputViewAddressItem* item = new CtInputViewAddressItem( view->__inputData, record, NULL, view->__addedIndex, + [view](){ view->__itemChanged(); }, + [view](Elm_Object_Item* item, bool isChanged, contacts_record_h record){ view->__addressItemDeleted( item, isChanged, record ); }, + [view](Evas_Object* obj, Elm_Object_Item* objItem){ view->__activateNextEntry(obj, objItem); } ); + Elm_Object_Item* genItem = elm_genlist_item_insert_after( view->__genlist, item->getItemClassStatic(), item, NULL, view->__genlistItems[checkExistItem], ELM_GENLIST_ITEM_NONE, NULL, NULL); + item->setElmObjectItem( genItem ); + item->focus(); + view->__genlistItems[MYPROFILE_INPUT_ADDRESS] = genItem; + addedItem = genItem; + break; + } + default: + break; + } + if (addedItem) { + elm_genlist_item_select_mode_set(addedItem, ELM_OBJECT_SELECT_MODE_NONE); + elm_genlist_item_show(addedItem, ELM_GENLIST_ITEM_SCROLLTO_TOP); + } +} + +void CtMyProfileInputView::__addNumberClickedCb() +{ + WHIT(); + contacts_record_h record = NULL; + + record = __inputData->addNumber(""); + __addedIndex = INPUT_ADDED_ITEM_INDEX_NUMBER; + + CtInputViewNumberItem* item = new CtInputViewNumberItem( NULL, __inputData, record, NULL, __addedIndex, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* objItem, bool isChanged, contacts_record_h record){ __numberItemDeleted( objItem, isChanged, record ); }, + [this](Evas_Object* obj, Elm_Object_Item* objItem){ __activateNextEntry(obj, objItem); } ); + + Elm_Object_Item* genItem = NULL; + if (__genlistItems[MYPROFILE_INPUT_NUMBER]) { + genItem = elm_genlist_item_insert_after(__genlist, item->getItemClassStatic(), item, NULL, __genlistItems[MYPROFILE_INPUT_NUMBER], ELM_GENLIST_ITEM_NONE, NULL, NULL); + } + else if (__genlistItems[MYPROFILE_INPUT_MSISDN]) { + genItem = elm_genlist_item_insert_after(__genlist, item->getItemClassStatic(), item, NULL, __genlistItems[MYPROFILE_INPUT_MSISDN], ELM_GENLIST_ITEM_NONE, NULL, NULL); + } + else { + genItem = elm_genlist_item_insert_after(__genlist, item->getItemClassStatic(), item, NULL, __genlistItems[MYPROFILE_INPUT_BASIC_INFO], ELM_GENLIST_ITEM_NONE, NULL, NULL); + } + item->setElmObjectItem( genItem ); + item->focus(); + __genlistItems[MYPROFILE_INPUT_NUMBER] = genItem; + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + elm_genlist_item_show(genItem, ELM_GENLIST_ITEM_SCROLLTO_TOP); +} + +void CtMyProfileInputView::__addEmailClickedCb() +{ + WHIT(); + contacts_record_h record = NULL; + CtMyProfileInputItems checkExistItem = MYPROFILE_INPUT_BASIC_INFO; + + record = __inputData->addEmail(""); + __addedIndex = INPUT_ADDED_ITEM_INDEX_EMAIL; + + if (__genlistItems[MYPROFILE_INPUT_EMAIL]) { + checkExistItem = MYPROFILE_INPUT_EMAIL; + } + else if (__genlistItems[MYPROFILE_INPUT_NUMBER]) { + checkExistItem = MYPROFILE_INPUT_NUMBER; + } + else if (__genlistItems[MYPROFILE_INPUT_MSISDN]) { + checkExistItem = MYPROFILE_INPUT_MSISDN; + } + else { + checkExistItem = MYPROFILE_INPUT_BASIC_INFO; + } + WDEBUG("INPUT_EMAIL item is after %d item", checkExistItem); + + CtInputViewEmailItem *item = new CtInputViewEmailItem( __inputData, record, NULL, __addedIndex, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* item, bool isChanged, contacts_record_h record){ __emailItemDeleted( item, isChanged, record ); }, + [this](Evas_Object* obj, Elm_Object_Item* objItem){ __activateNextEntry(obj, objItem); } ); + Elm_Object_Item* genItem = elm_genlist_item_insert_after( __genlist, item->getItemClassStatic(), item, NULL, __genlistItems[checkExistItem], ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + item->focus(); + __genlistItems[MYPROFILE_INPUT_EMAIL] = genItem; + elm_genlist_item_show(genItem, ELM_GENLIST_ITEM_SCROLLTO_TOP); +} + +void CtMyProfileInputView::__addNoteClickedCb() +{ + WHIT(); + contacts_record_h record = NULL; + CtMyProfileInputItems checkExistItem = MYPROFILE_INPUT_BASIC_INFO; + + WPRET_M(__genlistItems[MYPROFILE_INPUT_NOTE], "note already is added"); + + record = __inputData->addNote(""); + __addedIndex = INPUT_ADDED_ITEM_INDEX_NOTE; + + if (__genlistItems[MYPROFILE_INPUT_EMAIL]) { + checkExistItem = MYPROFILE_INPUT_EMAIL; + } + else if (__genlistItems[MYPROFILE_INPUT_NUMBER]) { + checkExistItem = MYPROFILE_INPUT_NUMBER; + } + else if (__genlistItems[MYPROFILE_INPUT_MSISDN]) { + checkExistItem = MYPROFILE_INPUT_MSISDN; + } + else { + checkExistItem = MYPROFILE_INPUT_BASIC_INFO; + } + WDEBUG("INPUT_NOTE item is after %d item", checkExistItem); + + CtInputViewNoteItem *item = new CtInputViewNoteItem( __inputData, record, NULL, __addedIndex, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* item, bool isChanged, contacts_record_h record){ __noteItemDeleted( item, isChanged, record ); }, + [this](Evas_Object* obj, Elm_Object_Item* objItem){this->__activateNextEntry(obj, objItem);}); + Elm_Object_Item* genItem = elm_genlist_item_insert_after( __genlist, item->getItemClassStatic(), item, NULL, __genlistItems[checkExistItem], ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + item->focus(); + __genlistItems[MYPROFILE_INPUT_NOTE] = genItem; + __updateNoteBtn(true); + elm_genlist_item_show(genItem, ELM_GENLIST_ITEM_SCROLLTO_TOP); +} + +void CtMyProfileInputView::__addMoreClickedCb() +{ + WHIT(); + + WPopup* popup = new WPopup(); + popup->setTextTranslatable(PACKAGE); + popup->setTitle( "IDS_PB_BUTTON_MORE"); + popup->setContent([this](Evas_Object* parent)->Evas_Object* + { + Elm_Object_Item *genItem = NULL; + + Evas_Object* genlist = elm_genlist_add(parent); + elm_object_style_set( genlist, "popup" ); + elm_genlist_homogeneous_set(genlist, EINA_TRUE); + elm_genlist_mode_set( genlist, ELM_LIST_COMPRESS ); + elm_scroller_content_min_limit( genlist, EINA_FALSE, EINA_TRUE ); // Automatically pop-up height is calculated + elm_object_content_set(parent, genlist); + + CtInputViewBasicInfoItem* basicInfoItem = (CtInputViewBasicInfoItem*)elm_object_item_data_get(__genlistItems[MYPROFILE_INPUT_BASIC_INFO]); + WPRET_VM(NULL == basicInfoItem, NULL, "basicInfoItem is NULL"); + + for (int i = MYPROFILE_INPUT_IMPORTANT_ADDRESS; i < MYPROFILE_INPUT_IMPORTANT_MAX; i++) { + WDEBUG("item %d", i); + if (i == MYPROFILE_INPUT_IMPORTANT_PHONETIC_INFO) { + if (basicInfoItem->getAddPhoneticName()) { + continue; + } + } else if (i == MYPROFILE_INPUT_IMPORTANT_NICKNAME) { + if (basicInfoItem->getAddNickname()) { + continue; + } + } else if (i == MYPROFILE_INPUT_IMPORTANT_ORGANIZATION) { + if (basicInfoItem->getAddOrganization()) { + continue; + } + } + CtInputViewImportantSubItem *item = new CtInputViewImportantSubItem(i, true); + genItem = elm_genlist_item_append( genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, __importantSubitemSelectedCb, this); + item->setElmObjectItem( genItem ); + } + + evas_object_show(genlist); + + return genlist; + + }); + + attachPopup( popup ); +} + + +bool CtMyProfileInputView::__checkIsEmpty() +{ + Elm_Object_Item *item = __genlistItems[MYPROFILE_INPUT_BASIC_INFO]; + bool isEmpty = true; + + while (item) { + if (item == __genlistItems[MYPROFILE_INPUT_IMPORTANT_FIELDS]) { + break; + } + + CtInputViewGenlistItem *viewItem = (CtInputViewGenlistItem *)elm_object_item_data_get(item); + if (viewItem) { + WDEBUG("viewItem->getIsEmpty() = %d", viewItem->getIsEmpty()); + if (false == viewItem->getIsEmpty()) { + isEmpty = false; + break; + } + } + item = elm_genlist_item_next_get(item); + } + return isEmpty; +} + +bool CtMyProfileInputView::__checkIsChanged() +{ + Elm_Object_Item *item = __genlistItems[MYPROFILE_INPUT_BASIC_INFO]; + bool changed = false; + + while (item) { + if (item == __genlistItems[MYPROFILE_INPUT_IMPORTANT_FIELDS]) { + break; + } + + CtInputViewGenlistItem *viewItem = (CtInputViewGenlistItem *)elm_object_item_data_get(item); + if (viewItem) { + WDEBUG("viewItem->getIsChanged() = %d", viewItem->getIsChanged()); + if (true == viewItem->getIsChanged()) { + changed = true; + break; + } + } + item = elm_genlist_item_next_get(item); + } + return changed; +} + +void CtMyProfileInputView::__updateNoteBtn(bool isNoteInput) +{ + WHIT(); + if (__genlistItems[MYPROFILE_INPUT_IMPORTANT_FIELDS]) { + CtInputViewImportantFieldsItem *item = (CtInputViewImportantFieldsItem*)elm_object_item_data_get(__genlistItems[MYPROFILE_INPUT_IMPORTANT_FIELDS]); + if(item) { + item->updateNoteBtn(isNoteInput); + } + } +} + +void CtMyProfileInputView::__updateSaveBtn() +{ + Eina_Bool empty = __checkIsEmpty(); + + elm_object_disabled_set(__saveBtn, empty); + WPRET_M(true == empty, "all fields are empty, can't save"); + + WPRET_M(false == __isCreate, "don't need to update save button"); + + Eina_Bool changed = __checkIsChanged(); + + elm_object_disabled_set(__saveBtn, !changed); +} + +void CtMyProfileInputView::__addItem(int itemType) +{ + WDEBUG("itemType %d", itemType); + Eina_List *cursor = NULL; + Eina_List *list = NULL; + void *data = NULL; + contacts_record_h record = NULL; + + switch(itemType) { + case MYPROFILE_INPUT_BASIC_INFO: + { + CtInputViewBasicInfoItem* item = new CtInputViewBasicInfoItem(__inputData, &__nameEntry, + [this](){ __itemChanged(); }, + [this](CtInputViewBasicInfoItem::ITEM_DELETED deletedInfo){ __basicInfoItemDeleted( deletedInfo); }, + [this](Evas_Object* obj){ __basicInfoItemImageClicked(obj); }, + [this](Evas_Object* obj, Elm_Object_Item* objItem){ __activateNextEntry(obj, objItem); }, + [this](Evas_Object* obj){ __basicInfoItemShowCreateKeypad(obj); }, + [this](Elm_Object_Item* objItem){ __updateEntryReturnKeyType(objItem); }); + Elm_Object_Item *genItem = elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[MYPROFILE_INPUT_BASIC_INFO] = genItem; + __updateBasicInfoItem(); + break; + } + case MYPROFILE_INPUT_MSISDN: + { + contacts_record_h defaultRecord = __inputData->getDefaultNumber(); + if (defaultRecord) { + CtInputViewMsisdnItem *item = new CtInputViewMsisdnItem( __inputData, defaultRecord); + + Elm_Object_Item *genItem = elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[MYPROFILE_INPUT_MSISDN] = genItem; + } + break; + } + case MYPROFILE_INPUT_NUMBER: + { + list = __inputData->getNumberList(); + + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) { + continue; + } + + WDEBUG("added"); + + const char *number = __inputData->getNumberNumber(record); + + CtInputViewNumberItem *item = new CtInputViewNumberItem( NULL, __inputData, record, number, INPUT_ADDED_ITEM_INDEX_NONE, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* objItem, bool isChanged, contacts_record_h record){ __numberItemDeleted( objItem, isChanged, record ); }, + [this](Evas_Object* obj, Elm_Object_Item* objItem){ __activateNextEntry(obj, objItem); } ); + + Elm_Object_Item *genItem = elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[MYPROFILE_INPUT_NUMBER] = genItem; + } + + if (__isCreate && list == NULL) { + record = __inputData->addNumber(""); + + CtInputViewNumberItem *item = new CtInputViewNumberItem( NULL, __inputData, record, NULL, INPUT_ADDED_ITEM_INDEX_NONE, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* objItem, bool isChanged, contacts_record_h record){ __numberItemDeleted( objItem, isChanged, record ); }, + [this](Evas_Object* obj, Elm_Object_Item* objItem){ __activateNextEntry(obj, objItem); } ); + + Elm_Object_Item* genItem = elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[MYPROFILE_INPUT_NUMBER] = genItem; + } + break; + } + case MYPROFILE_INPUT_EMAIL: + { + list = __inputData->getEmailList(); + + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) { + continue; + } + + const char *email = __inputData->getEmailEmail(record); + + CtInputViewEmailItem* item = new CtInputViewEmailItem( __inputData, record, email, INPUT_ADDED_ITEM_INDEX_NONE, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* objItem, bool isChanged, contacts_record_h record){ __emailItemDeleted( objItem, isChanged, record ); }, + [this](Evas_Object* obj, Elm_Object_Item* objItem){ __activateNextEntry(obj, objItem); } ); + Elm_Object_Item *genItem = elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[MYPROFILE_INPUT_EMAIL] = genItem; + } + break; + } + case MYPROFILE_INPUT_ADDRESS: + { + list = __inputData->getAddressList(); + + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) { + continue; + } + + char address[CT_TEXT_MAX_LEN] = {0,}; + __inputData->getAddressAddress( record, address, sizeof(address)); + + CtInputViewAddressItem* item = new CtInputViewAddressItem( __inputData, record, address, INPUT_ADDED_ITEM_INDEX_NONE, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* objItem, bool isChanged, contacts_record_h record){ __addressItemDeleted( objItem, isChanged, record ); }, + [this](Evas_Object* obj, Elm_Object_Item* objItem){ __activateNextEntry(obj, objItem); } ); + Elm_Object_Item *genItem = elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[MYPROFILE_INPUT_ADDRESS] = genItem; + } + break; + } + case MYPROFILE_INPUT_MESSENGER: + { + list = __inputData->getMessengerList(); + + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) { + continue; + } + + const char *messenger = __inputData->getMessengerMessenger(record); + + CtInputViewMessengerItem* item = new CtInputViewMessengerItem( __inputData, record, messenger, INPUT_ADDED_ITEM_INDEX_NONE, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* objItem, bool isChanged, contacts_record_h record){ __messengerItemDeleted( objItem, isChanged, record ); }, + [this](Evas_Object* obj, Elm_Object_Item* objItem){ __activateNextEntry(obj, objItem); } ); + Elm_Object_Item *genItem = elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[MYPROFILE_INPUT_MESSENGER] = genItem; + } + break; + } + case MYPROFILE_INPUT_URL: + { + list = __inputData->getWebsiteList(); + + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) { + continue; + } + + const char *website = __inputData->getWebsiteWebsite(record); + + CtInputViewWebsiteItem* item = new CtInputViewWebsiteItem( __inputData, record, website, INPUT_ADDED_ITEM_INDEX_NONE, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* objItem, bool isChanged, contacts_record_h record){ __websiteItemDeleted( objItem, isChanged, record ); }, + [this](Evas_Object* obj, Elm_Object_Item* objItem){ __activateNextEntry(obj, objItem); } ); + Elm_Object_Item *genItem = elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[MYPROFILE_INPUT_URL] = genItem; + } + break; + } + case MYPROFILE_INPUT_EVENT: + { + list = __inputData->getEventList(); + + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) { + continue; + } + + char event[256] = {0}; + snprintf(event, sizeof(event), "%d", __inputData->getEventEvent(record)); + + if( __inputData->getEventType(record) == CONTACTS_EVENT_TYPE_BIRTH) { + *__birthdayEventExist = true; + } + + CtInputViewEventItem *item = new CtInputViewEventItem( this, __inputData, record, event, __birthdayEventExist, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* objItem, bool isChanged, contacts_record_h record){ __eventItemDeleted( objItem, isChanged, record ); }); + Elm_Object_Item *genItem = elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[MYPROFILE_INPUT_EVENT] = genItem; + } + break; + } + case MYPROFILE_INPUT_NOTE: + { + list = __inputData->getNoteList(); + EINA_LIST_FOREACH(list, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + if(record == NULL) { + continue; + } + const char *note = __inputData->getNote(record); + + CtInputViewNoteItem *item = new CtInputViewNoteItem( __inputData, record, note, INPUT_ADDED_ITEM_INDEX_NONE, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* objItem, bool isChanged, contacts_record_h record){ __noteItemDeleted( objItem, isChanged, record ); }, + [this](Evas_Object* obj, Elm_Object_Item* objItem){this->__activateNextEntry(obj, objItem);}); + Elm_Object_Item *genItem = elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[MYPROFILE_INPUT_NOTE] = genItem; + __updateNoteBtn(true); + } + break; + } + case MYPROFILE_INPUT_IMPORTANT_FIELDS: + { + bool isNoteInput = (__genlistItems[MYPROFILE_INPUT_NOTE] == NULL) ? false : true; + CtInputViewImportantFieldsItem *item = new CtInputViewImportantFieldsItem([this](){ __addNumberClickedCb(); }, + [this](){ __addEmailClickedCb(); }, + [this](){ __addNoteClickedCb(); }, + [this](){ __addMoreClickedCb(); }, + isNoteInput); + Elm_Object_Item *genItem = elm_genlist_item_append(__genlist, item->getItemClassStatic(), item, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[MYPROFILE_INPUT_IMPORTANT_FIELDS] = genItem; + break; + } + } +} + +void CtMyProfileInputView::__addAllItems() +{ + WHIT(); + int i = 0; + + for (; i < MYPROFILE_INPUT_ITEMS_MAX; i++) { + __addItem(i); + } +} + +void CtMyProfileInputView::onDestroy() +{ + WHIT(); + evas_object_smart_callback_del(__genlist, "unrealized", __genlistUnrealizedCb); + evas_object_smart_callback_del(__genlist, "realized", __genlistRealizedCb); +} + +void CtMyProfileInputView::onEvent(int eventType) +{ + WHIT(); +} + +bool CtMyProfileInputView::onPop() +{ + if(!__saved) { + WDEBUG("canceled"); + if (__discard) { + return true; + } + + Eina_Bool changed = __checkIsChanged(); + + if (!__isCreate) { // edit view + if (__changed) { + changed = EINA_TRUE; + } + } + + if (changed) { + WDEBUG("changed"); + + WPopup *popup = new WPopup(); + popup->setTextTranslatable(PACKAGE); + popup->setTitle("IDS_PB_HEADER_DISCARD_CHANGES_ABB"); + popup->setContent("IDS_PB_POP_ALL_CHANGES_WILL_BE_DISCARDED"); + + popup->addButton("IDS_PB_BUTTON_CANCEL", NULL ); + popup->addButton("IDS_PB_BUTTON_DISCARD_ABB", [this](bool* destroyPopup){ + WDEBUG("Discard"); + this->__discard = true; + popOut(); + *destroyPopup = false; + }); + + attachPopup(popup); + return false; + } else { + WDEBUG("not changed"); + return true; + } + } + + return true; +} + +void CtMyProfileInputView::__itemChanged() +{ + __updateSaveBtn(); +} + +void CtMyProfileInputView::__basicInfoItemDeleted( int deletedInfo) +{ + CtInputViewBasicInfoItem::ITEM_DELETED info = (CtInputViewBasicInfoItem::ITEM_DELETED)deletedInfo; + + CtInputViewBasicInfoItem* basicInfoItem = (CtInputViewBasicInfoItem*)elm_object_item_data_get(__genlistItems[MYPROFILE_INPUT_BASIC_INFO]); + WPRET_M(NULL == basicInfoItem, "basicInfoItem is NULL"); + + switch( info ) + { + case CtInputViewBasicInfoItem::PHONETIC_NAME_DELETED: + if( basicInfoItem->getPhoneticNameIsChanged() + || __inputData->getPhoneticFirstName() + || __inputData->getPhoneticMiddleName() + || __inputData->getPhoneticLastName()) { + __changed = true; + } + + basicInfoItem->setPhoneticNameIsChanged(false); + basicInfoItem->setAddPhoneticName(false); + __inputData->setPhoneticFullName(NULL); + break; + case CtInputViewBasicInfoItem::NICKNAME_DELETED: + if( basicInfoItem->getNicknameIsChanged() || __inputData->getNickname()) + __changed = true; + + basicInfoItem->setNicknameIsChanged(false); + basicInfoItem->setAddNickname(false); + __inputData->setNickname(NULL); + break; + case CtInputViewBasicInfoItem::ORGANIZATION_DELETED: + if( (basicInfoItem->getCompanyIsChanged() || __inputData->getCompany()) + || (basicInfoItem->getJobTitleIsChanged() || __inputData->getJobTitle())) + { + __changed = true; + } + + basicInfoItem->setCompanyIsChanged(false); + basicInfoItem->setJobTitleIsChanged(false); + basicInfoItem->setAddOrganization(false); + __inputData->setCompany(NULL); + __inputData->setJobTitle(NULL); + break; + default: + WERROR("Not handled case =%d", deletedInfo); + break; + } + + __updateSaveBtn(); + __updateEntryReturnKeyType(__genlistItems[MYPROFILE_INPUT_BASIC_INFO]); +} + +void CtMyProfileInputView::__basicInfoItemImageClicked( Evas_Object* obj ) +{ + WPopup* popup = new WPopup(); + popup->setTextTranslatable(PACKAGE); + popup->setTitle("IDS_PB_HEADER_SET_CONTACT_PICTURE_ABB"); + popup->setContent([this](Evas_Object* parent)->Evas_Object* + { + Elm_Genlist_Item_Class* itc1 = elm_genlist_item_class_new(); + Elm_Genlist_Item_Class* itc2 = elm_genlist_item_class_new(); + Elm_Genlist_Item_Class* itc3 = elm_genlist_item_class_new(); + + if (itc1) { + itc1->item_style = "type1"; + itc1->func.text_get = [](void* data, Evas_Object* obj, const char* part)->char* + { + if(!strcmp(part, "elm.text")) { + return SAFE_STRDUP(V_("IDS_PB_OPT_FROM_GALLERY_ABB2")); + } + return NULL; + }; + } + + if (itc2) { + itc2->item_style = "type1"; + itc2->func.text_get = [](void* data, Evas_Object* obj, const char* part)->char* + { + if(!strcmp(part, "elm.text")) { + return SAFE_STRDUP(V_("IDS_PB_OPT_TAKE_PICTURE_ABB")); + } + return NULL; + }; + } + + if (itc3) { + itc3->item_style = "type1"; + itc3->func.text_get = [](void* data, Evas_Object* obj, const char* part)->char* + { + if(!strcmp(part, "elm.text")) { + CtMyProfileInputView* view = (CtMyProfileInputView*)data; + if(view->__inputData->getImagePath()) + return SAFE_STRDUP(V_("IDS_PB_OPT_REMOVE")); + else + return NULL; + + } + return NULL; + }; + } + + int count = 2; + + Evas_Object* genlist = elm_genlist_add(parent); + elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS); + elm_genlist_homogeneous_set(genlist, EINA_TRUE); + elm_scroller_content_min_limit(genlist, EINA_FALSE, EINA_TRUE); + + elm_genlist_item_append(genlist, itc1, this, NULL, ELM_GENLIST_ITEM_NONE, __onGallerySelCb, this); + elm_genlist_item_append(genlist, itc2, this, NULL, ELM_GENLIST_ITEM_NONE, __onCameraSelCb, this); + + if(__inputData->getImagePath()) { + elm_genlist_item_append(genlist, itc3, this, NULL, ELM_GENLIST_ITEM_NONE, __onRemoveSelCb, this); + count++; + } + + elm_genlist_item_class_free(itc1); + elm_genlist_item_class_free(itc2); + elm_genlist_item_class_free(itc3); + + return genlist; + }); + + attachPopup( popup ); +} + +void CtMyProfileInputView::__basicInfoItemShowCreateKeypad( Evas_Object* obj) +{ + WHIT(); + if (__inputData->getContactId() == 0) { + elm_object_focus_set(__nameEntry, EINA_TRUE); + elm_entry_cursor_end_set(__nameEntry); + } +} + +void CtMyProfileInputView::__basicInfoUpdateImage() +{ + WHIT(); + elm_genlist_item_fields_update(__genlistItems[MYPROFILE_INPUT_BASIC_INFO], "elm.icon.2", ELM_GENLIST_ITEM_FIELD_CONTENT); +} + +Elm_Object_Item* CtMyProfileInputView::__getLastItem(Elm_Object_Item* deleteItem) +{ + Elm_Object_Item* item = NULL; + Elm_Object_Item* lastItem = NULL; + Elm_Object_Item* retItem = NULL; + int count = 0; + + item = elm_genlist_first_item_get( __genlist ); + while (item) { + if( elm_genlist_item_item_class_get( deleteItem ) == elm_genlist_item_item_class_get(item)) { + lastItem = item; + count++; + } + item = elm_genlist_item_next_get(item); + } + + if( lastItem == deleteItem ) { + if (1 == count) { + retItem = NULL; + } + else { // must > 1 + retItem = elm_genlist_item_prev_get(lastItem); + } + } + else { + retItem = lastItem; + } + + return retItem; +} + +void CtMyProfileInputView::__numberItemDeleted(Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record) +{ + WHIT(); + __genlistItems[MYPROFILE_INPUT_NUMBER] = __getLastItem(deleteItem); + + if( isChanged || __inputData->getNumberNumber(record)) { + __changed = true; + } + + __inputData->removeNumber(record); + __updateSaveBtn(); + __updateEntryReturnKeyType(deleteItem); +} + +void CtMyProfileInputView::__emailItemDeleted( Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record) +{ + WHIT(); + __genlistItems[MYPROFILE_INPUT_EMAIL] = __getLastItem(deleteItem); + + if( isChanged || __inputData->getEmailEmail( record ) ) { + __changed = true; + } + __inputData->removeEmail( record ); + __updateSaveBtn(); + __updateEntryReturnKeyType(deleteItem); +} + +void CtMyProfileInputView::__addressItemDeleted( Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record) +{ + WHIT(); + __genlistItems[MYPROFILE_INPUT_ADDRESS] = __getLastItem(deleteItem); + + char address[CT_TEXT_MAX_LEN] = {0,}; + __inputData->getAddressAddress( record, address, sizeof(address)); + if( isChanged || address[0] != '\0') { + __changed = true; + } + + __inputData->removeAddress(record); + __updateSaveBtn(); + __updateEntryReturnKeyType(deleteItem); +} + +void CtMyProfileInputView::__messengerItemDeleted( Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record) +{ + WHIT(); + __genlistItems[MYPROFILE_INPUT_MESSENGER] = __getLastItem(deleteItem); + + if ( isChanged || __inputData->getMessengerMessenger( record)) { + __changed = true; + } + + __inputData->removeMessenger(record); + __updateSaveBtn(); + __updateEntryReturnKeyType(deleteItem); +} + +void CtMyProfileInputView::__websiteItemDeleted( Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record) +{ + WHIT(); + __genlistItems[MYPROFILE_INPUT_URL] = __getLastItem(deleteItem); + + if( isChanged || __inputData->getWebsiteWebsite( record )) { + __changed = true; + } + + __inputData->removeWebsite(record); + __updateSaveBtn(); + __updateEntryReturnKeyType(deleteItem); +} + +void CtMyProfileInputView::__eventItemDeleted(Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record) +{ + WHIT(); + __genlistItems[MYPROFILE_INPUT_EVENT] = __getLastItem(deleteItem); + + if (isChanged || __inputData->getEventEvent(record)) { + __changed = true; + } + + __inputData->removeEvent(record); + __updateSaveBtn(); +} + +void CtMyProfileInputView::__noteItemDeleted( Elm_Object_Item* deleteItem, bool isChanged, contacts_record_h record) +{ + WHIT(); + Evas_Object *noteBtn = elm_object_item_part_content_get(__genlistItems[MYPROFILE_INPUT_IMPORTANT_FIELDS], "elm.icon.3"); + elm_object_disabled_set(noteBtn, EINA_FALSE); + + if( isChanged || __inputData->getNote(record)) { + __changed = true; + } + + __inputData->removeNote( record ); + __genlistItems[MYPROFILE_INPUT_NOTE] = NULL; + __updateNoteBtn(false); + __updateSaveBtn(); + __updateEntryReturnKeyType(deleteItem); +} + +void CtMyProfileInputView::__activateNextEntry( Evas_Object* obj, Elm_Object_Item* item ) +{ + WHIT(); + WPRET_M(NULL == obj, "obj is NULL"); + WPRET_M(NULL == item, "item is NULL"); + Elm_Object_Item* nextItem = elm_genlist_item_next_get(item); + bool focused = false; + Evas_Object* entry = obj; + while (nextItem) { + if (nextItem == __genlistItems[MYPROFILE_INPUT_IMPORTANT_FIELDS]) { + break; + } + + CtInputViewGenlistItem *viewItem = (CtInputViewGenlistItem *)elm_object_item_data_get(nextItem); + if (viewItem) { + entry = viewItem->getEntry(); + if (entry) { + elm_object_focus_set(entry, EINA_TRUE); + focused = true; + break; + } + } + nextItem = elm_genlist_item_next_get(nextItem); + } + // don't have next entry, close IME + elm_object_focus_set(entry, focused); +} + +void CtMyProfileInputView::__updateEntryReturnKeyType(Elm_Object_Item* deleteItem) +{ + WHIT(); + Elm_Object_Item *item = __genlistItems[MYPROFILE_INPUT_BASIC_INFO]; + Evas_Object* entry = NULL; + Evas_Object* box = NULL; + Eina_List* list = NULL; + Eina_List* cursor = NULL; + void *tmp = NULL; + Evas_Object* layout = NULL; + + while (item) { + if (item == __genlistItems[MYPROFILE_INPUT_IMPORTANT_FIELDS]) { + break; + } + + if (item == deleteItem) { + item = elm_genlist_item_next_get(item); + continue; + } + + if (item == __genlistItems[MYPROFILE_INPUT_BASIC_INFO]) { + box = elm_object_item_part_content_get(item, "elm.icon.1"); + if (box) { + list = elm_box_children_get(box); + EINA_LIST_FOREACH(list, cursor, tmp) { + layout = (Evas_Object*)tmp; + if (layout) { + entry = elm_object_part_content_get(layout, "elm.icon.1"); + if (entry && elm_entry_single_line_get(entry)) { + elm_entry_input_panel_return_key_type_set(entry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_NEXT); + } + } + } + } + } + else { + CtInputViewGenlistItem *viewItem = (CtInputViewGenlistItem *)elm_object_item_data_get(item); + if (viewItem) { + entry = viewItem->getEntry(); + + if (entry && elm_entry_single_line_get(entry)) { + elm_entry_input_panel_return_key_type_set(entry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_NEXT); + } + } + } + item = elm_genlist_item_next_get(item); + } + + if (entry && elm_entry_single_line_get(entry)) { + elm_entry_input_panel_return_key_type_set(entry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE); + } +} + +void CtMyProfileInputView::__updateBasicInfoItem() +{ + WHIT(); + if(__genlistItems[MYPROFILE_INPUT_BASIC_INFO]) { + elm_object_item_signal_emit(__genlistItems[MYPROFILE_INPUT_BASIC_INFO], "image,enable", ""); + } +} + +void CtMyProfileInputView::__createEventDataPopup() +{ + WHIT(); + WPopup* popup = new WPopup(); + popup->setTextTranslatable(PACKAGE); + popup->setTitle("IDS_ST_BODY_SET_DATE"); + popup->addButton("IDS_PB_BUTTON_CANCEL", NULL); + popup->addButton( "IDS_PB_SK_SET", [popup, this](bool* destroyPopup) { + struct tm time1 = {}; + time_t t; + t = time(NULL); + localtime_r(&t, &time1); + + int year = 0; + int month = 0; + int day = 0; + Evas_Object *datetimePickerBg = elm_object_content_get(popup->getEvasObj()); + Evas_Object *dateTime = elm_object_part_content_get(datetimePickerBg, "elm.swallow.content"); + elm_datetime_value_get(dateTime, &time1); + year = time1.tm_year + 1900; + month = time1.tm_mon + 1; + day = time1.tm_mday; + + __appendEventItem(year, month, day); + + *destroyPopup = true; + }); + popup->setOnMoreProperties([this](Evas_Object* popupObj ) { + struct tm time1 = {}; + time_t t; + t = time(NULL); + localtime_r(&t, &time1); + + Evas_Object* dateTime = elm_datetime_add(popupObj); + elm_datetime_format_set(dateTime, DATE_TIME_FORMAT); + elm_datetime_value_set(dateTime, &time1); + + std::string contactsEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + Evas_Object* datetimePickerBg = elm_layout_add(popupObj); + evas_object_size_hint_weight_set(datetimePickerBg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + CtThemeMgr::getInstance()->setObjectTheme(datetimePickerBg); + elm_layout_file_set(datetimePickerBg, contactsEdjePath.c_str(), "datetimePickerBg"); + elm_object_part_content_set(datetimePickerBg, "elm.swallow.content", dateTime); + evas_object_show(datetimePickerBg); + + elm_object_content_set(popupObj, datetimePickerBg); + }); + + attachPopup( popup ); +} + +void CtMyProfileInputView::__appendEventItem(int year, int month, int day) +{ + WHIT(); + contacts_record_h record = NULL; + CtMyProfileInputItems checkExistItem = MYPROFILE_INPUT_BASIC_INFO; + + record = __inputData->addEvent(year * 10000 + month * 100 + day); + + if (__genlistItems[MYPROFILE_INPUT_EVENT]) { + checkExistItem = MYPROFILE_INPUT_EVENT; + } + else if (__genlistItems[MYPROFILE_INPUT_ADDRESS]) { + checkExistItem = MYPROFILE_INPUT_ADDRESS; + } + else if (__genlistItems[MYPROFILE_INPUT_NOTE]) { + checkExistItem = MYPROFILE_INPUT_NOTE; + } + else if (__genlistItems[MYPROFILE_INPUT_EMAIL]) { + checkExistItem = MYPROFILE_INPUT_EMAIL; + } + else if (__genlistItems[MYPROFILE_INPUT_NUMBER]) { + checkExistItem = MYPROFILE_INPUT_NUMBER; + } + else if (__genlistItems[MYPROFILE_INPUT_MSISDN]) { + checkExistItem = MYPROFILE_INPUT_MSISDN; + } + else { + checkExistItem = MYPROFILE_INPUT_BASIC_INFO; + } + WDEBUG("INPUT_EVENT item is after %d item", checkExistItem); + + if(*__birthdayEventExist ) { + __inputData->setEventType(record, CONTACTS_EVENT_TYPE_ANNIVERSARY, NULL); + } + else { + if(__inputData->getEventType(record) == CONTACTS_EVENT_TYPE_BIRTH) { + *__birthdayEventExist = true; + } + } + + CtInputViewEventItem *item = new CtInputViewEventItem(this, __inputData, record, NULL, __birthdayEventExist, + [this](){ __itemChanged(); }, + [this](Elm_Object_Item* item, bool isChanged, contacts_record_h record){ __eventItemDeleted( item, isChanged, record ); } ); + Elm_Object_Item *genItem = elm_genlist_item_insert_after( __genlist, item->getItemClassStatic(), item, NULL, __genlistItems[checkExistItem], ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(genItem, ELM_OBJECT_SELECT_MODE_NONE); + item->setElmObjectItem( genItem ); + __genlistItems[MYPROFILE_INPUT_EVENT] = genItem; + elm_genlist_item_show(genItem, ELM_GENLIST_ITEM_SCROLLTO_TOP); +} + +extern "C" { + WAPP_ASSIST_EXPORT WView* createMyProfileInputView(contacts_record_h contactRecord) { + CtMyProfileInputView* view = new CtMyProfileInputView(contactRecord); + return view; + } +} diff --git a/lib-contact/ct-importer/CMakeLists.txt b/lib-contact/ct-importer/CMakeLists.txt new file mode 100644 index 0000000..e9c87ab --- /dev/null +++ b/lib-contact/ct-importer/CMakeLists.txt @@ -0,0 +1,20 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(ct-importer CXX) + +INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/app-assist-efl/inc + ${CMAKE_SOURCE_DIR}/lib-common/inc + ${CMAKE_SOURCE_DIR}/lib-contact/ct-common/inc + ${CMAKE_CURRENT_SOURCE_DIR}/inc + ${CMAKE_CURRENT_SOURCE_DIR}/src +) + +FILE(GLOB SRCS "src/*.cpp") +ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${TIZEN_PKGS_LDFLAGS} + "app-assist-efl" + "contacts-common" + "ct-common" +) + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_APP_LIB_DIR})
\ No newline at end of file diff --git a/lib-contact/ct-importer/inc/CtImporter.h b/lib-contact/ct-importer/inc/CtImporter.h new file mode 100644 index 0000000..e43fae8 --- /dev/null +++ b/lib-contact/ct-importer/inc/CtImporter.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_SETTING_CONTACT_IMPORTER_H_ +#define _CT_SETTING_CONTACT_IMPORTER_H_ + +#include <string> +#include <vector> + +#include "WDefine.h" + +class CtProgressBarPopup; + +class CtImporter { +public: + CtImporter(int abId, std::vector<std::string> vcards, int contactsCount); + ~CtImporter(); + + CtProgressBarPopup *getProgressPopup(); + WPopup *getCancelPopup(); + void run(); + +private: + void __createProgressPopup(); + void __createCancelPopup(); + void __cancelImporting(bool* destroyPopup); + void __stopImporting(bool* destroyPopup); + void __continueImporting(bool* destroyPopup); + static void __importFromVcardsCb(void *data, Ecore_Thread *thread); + static void __importFromVcardsEndCb(void *data, Ecore_Thread *thread); + static void __importFromVcardsCancelCb(void *data, Ecore_Thread *thread); + static bool __vcardParseCb(contacts_record_h record, void *user_data); + +private: + WDISABLE_COPY_AND_ASSIGN(CtImporter); + +private: + int __addressBookId; + bool __canceled; + bool __paused; + std::vector<int> __importedContacts; + CtProgressBarPopup *__progressPopup; + WUiObjectPtr __popupMonitor; + Ecore_Thread *__importThread; + std::vector<std::string> __vcards; + WPopup *__cancelPopup; + int __contactsCount; +}; + +#endif //_CT_SETTING_CONTACT_IMPORTER_H_ diff --git a/lib-contact/ct-importer/src/CtImporter.cpp b/lib-contact/ct-importer/src/CtImporter.cpp new file mode 100644 index 0000000..f4ee91e --- /dev/null +++ b/lib-contact/ct-importer/src/CtImporter.cpp @@ -0,0 +1,225 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <contacts.h> +#include <notification.h> + +#include "ContactsDebug.h" +#include "CtProgressBarPopup.h" +#include "CtImporter.h" +#include "CtString.h" +#include "CtType.h" + +CtImporter::CtImporter(int abId, std::vector<std::string> vcards, int contactsCount) +: __addressBookId(abId) +, __canceled(false) +, __paused(false) +, __importThread(NULL) +, __vcards(std::move(vcards)) +, __contactsCount(contactsCount) +{ + WHIT(); + __createProgressPopup(); + __createCancelPopup(); +} + +void CtImporter::__createProgressPopup() +{ + __progressPopup = new CtProgressBarPopup(__contactsCount, V_("IDS_PB_HEADER_IMPORT_CONTACTS_ABB2"), true); + auto stopFunction = std::bind(&CtImporter::__stopImporting, this, std::placeholders::_1); + __progressPopup->addButton(V_("IDS_PB_BUTTON_CANCEL"), stopFunction); + __progressPopup->setOnBack(stopFunction); + __popupMonitor = __progressPopup->getWeakPtr(); +} + +void CtImporter::__createCancelPopup() +{ + __cancelPopup = new WPopup(); + __cancelPopup->setTextTranslatable(PACKAGE); + __cancelPopup->setTitle("IDS_PB_HEADER_CANCEL_IMPORTING_ABB"); + + auto continueFunction = std::bind(&CtImporter::__continueImporting, this, std::placeholders::_1); + __cancelPopup->addButton("IDS_PB_BUTTON_CANCEL", continueFunction); + __cancelPopup->setOnBack(continueFunction); + + auto cancelFunction = std::bind(&CtImporter::__cancelImporting, this, std::placeholders::_1); + __cancelPopup->addButton("IDS_PB_BUTTON_OK_ABB2", cancelFunction); +} + +CtImporter::~CtImporter() +{ + WHIT(); + if (auto popup = __popupMonitor.lock()) { + popup->destroy(); + } + if (__cancelPopup) { + __cancelPopup->destroy(); + } +} + +CtProgressBarPopup *CtImporter::getProgressPopup() +{ + return __progressPopup; +} + +WPopup *CtImporter::getCancelPopup() +{ + return __cancelPopup; +} + +void CtImporter::run() +{ + WHIT(); + __canceled = false; + __paused = false; + __importThread = ecore_thread_run(__importFromVcardsCb, __importFromVcardsEndCb, __importFromVcardsCancelCb, this); +} + +void CtImporter::__stopImporting(bool* destroyPopup) +{ + WHIT(); + __paused = true; + *destroyPopup = false; + char content[CT_TEXT_MAX_LEN] = {0}; + char percent[CT_TEXT_SHORT_LEN] = {0}; + snprintf(percent, CT_TEXT_SHORT_LEN, "%d%%", (int)(100.0 * (double)(__importedContacts.size())/(double(__contactsCount)))); + snprintf(content, CT_TEXT_MAX_LEN, V_("IDS_PB_POP_CONTACTS_WILL_STOP_BEING_IMPORTED_FROM_PS"), percent); + elm_object_text_set(__cancelPopup->getEvasObj(), content); + evas_object_hide(__progressPopup->getEvasObj()); + evas_object_show(__cancelPopup->getEvasObj()); +} + +void CtImporter::__cancelImporting(bool* destroyPopup) +{ + WHIT(); + __paused = false; + __canceled = true; + *destroyPopup = true; + __cancelPopup = nullptr; +} + +void CtImporter::__continueImporting(bool* destroyPopup) +{ + WHIT(); + __paused = false; + *destroyPopup = false; + evas_object_show(__progressPopup->getEvasObj()); + evas_object_hide(__cancelPopup->getEvasObj()); +} + +void CtImporter::__importFromVcardsCb(void *data, Ecore_Thread *thread) +{ + WHIT(); + CtImporter* importer = static_cast<CtImporter*>(data); + + for (auto &&vcard : importer->__vcards) { + if (importer->__canceled) { + WDEBUG("Import canceled"); + ecore_thread_cancel(importer->__importThread); + return; + } + if (importer->__paused) { + WDEBUG("Import paused"); + while (importer->__paused) { + usleep(1000); + } + } + + int err = contacts_vcard_parse_to_contact_foreach(vcard.c_str(), __vcardParseCb, importer); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_vcard_parse_to_contact_foreach failed: %d", err); + } + } +} + +void CtImporter::__importFromVcardsEndCb(void* data, Ecore_Thread* thread) +{ + WHIT(); + CtImporter* importer = static_cast<CtImporter*>(data); + int count = importer->__importedContacts.size(); + + if (count > 0) { + char buf[256] = { 0, }; + if (count == 1) { + snprintf(buf, sizeof(buf), V_("IDS_PB_TPOP_1_CONTACT_IMPORTED")); + } else { + snprintf(buf, sizeof(buf), ctGetContactsString("IDS_PB_TPOP_PD_CONTACTS_IMPORTED"), count); + } + WDEBUG("notification: %s", buf); + int err = notification_status_message_post(buf); + if (err != NOTIFICATION_ERROR_NONE) { + WERROR("notification_status_message_post: %d", err); + } + } + + delete importer; +} + +void CtImporter::__importFromVcardsCancelCb(void* data, Ecore_Thread* thread) +{ + WHIT(); + CtImporter* importer = static_cast<CtImporter*>(data); + + for (auto &&id : importer->__importedContacts) { + contacts_db_delete_record(_contacts_contact._uri, id); + } + + int err = notification_status_message_post( V_("IDS_PB_SBODY_IMPORTING_CANCELLED_M_STATUS_ABB") ); + if (err != NOTIFICATION_ERROR_NONE) { + WERROR("notification_status_message_post failed: %d", err); + } + + delete importer; +} + +bool CtImporter::__vcardParseCb(contacts_record_h record, void* user_data) +{ + WHIT(); + CtImporter *importer = static_cast<CtImporter *>(user_data); + + if (record) { + if (importer->__canceled) { + ecore_thread_cancel(importer->__importThread); + return false; + } + + if (importer->__paused) { + WDEBUG("Import paused"); + while (importer->__paused) { + usleep(1000); + } + } + + int id = 0; + + int err = contacts_record_set_int(record, _contacts_contact.address_book_id, importer->__addressBookId); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_set_int failed: %d", err); + } + + err = contacts_db_insert_record(record, &id); + if ((CONTACTS_ERROR_NONE != err) || (id <= 0)) { + WERROR("contacts_db_insert_record failed: err = %d, id = %d", err, id); + } + + importer->__importedContacts.push_back(id); + importer->__progressPopup->setProgressStatusCount(importer->__importedContacts.size()); + } + + // Return true to continue to scan next contact, according to contacts_vcard_parse_cb specification. + return true; +} diff --git a/lib-contact/ct-list/.cproject b/lib-contact/ct-list/.cproject new file mode 100644 index 0000000..5784c55 --- /dev/null +++ b/lib-contact/ct-list/.cproject @@ -0,0 +1,505 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage"> + <storageModule moduleId="org.eclipse.cdt.core.settings"> + <cconfiguration id="org.tizen.nativecore.config.sbi.gcc45.so.debug.2033459981"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.tizen.nativecore.config.sbi.gcc45.so.debug.2033459981" moduleId="org.eclipse.cdt.core.settings" name="Debug"> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> + <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + </extensions> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <configuration artifactExtension="so" artifactName="ct-list" buildArtefactType="org.tizen.nativecore.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.sharedLib,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.so.debug.2033459981" name="Debug" parent="org.tizen.nativecore.config.sbi.gcc45.so.debug"> + <folderInfo id="org.tizen.nativecore.config.sbi.gcc45.so.debug.2033459981." name="/" resourcePath=""> + <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.so.debug.1697298416" name="Tizen Core Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.so.debug"> + <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.774068803" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/> + <builder autoBuildTarget="all" buildPath="${workspace_loc:/ct-list}/Debug" enableAutoBuild="true" id="org.tizen.nativecore.target.sbi.gnu.builder.2118466175" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" parallelBuildOn="true" parallelizationNumber="unlimited" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/> + <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.253440942" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/> + <tool command="i386-linux-gnueabi-g++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.492947525" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler"> + <option id="gnu.cpp.compiler.option.optimization.level.1301476186" 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.debugging.level.core.2145270580" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/> + <option defaultValue="true" id="sbi.gnu.cpp.compiler.option.misc.pic.core.2106259" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.cpp.compiler.option.1495069354" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs"> + <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_gcc46.i386.core.sharedLib"/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.816717232" 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.686416948" 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="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-fvisibility=hidden"/> + </option> + <option id="gnu.cpp.compiler.option.include.paths.1612349545" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc/app-assist}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/ct-detail/inc}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/ct-common/inc}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/common/inc}""/> + <listOptionValue builtIn="false" value="../../../app-assist-efl/inc"/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SDK_PATH}/library""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks.core.1286549398" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + </option> + <option id="gnu.cpp.compiler.option.preprocessor.def.1552982377" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols"> + <listOptionValue builtIn="false" value="_DEBUG"/> + <listOptionValue builtIn="false" value="TIZEN_DEBUG_ENABLE"/> + <listOptionValue builtIn="false" value="_SDK_BUILD"/> + <listOptionValue builtIn="false" value="_CONTACTS_EAS_ENABLE"/> + </option> + <option id="gnu.cpp.compiler.option.other.other.1205564902" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -std=c++0x" valueType="string"/> + <option id="gnu.cpp.compiler.option.dialect.std.304910220" name="Language standard" superClass="gnu.cpp.compiler.option.dialect.std" value="gnu.cpp.compiler.dialect.default" valueType="enumerated"/> + <inputType id="sbi.gnu.cpp.compiler.tizen.inputType.127301685"/> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1678696321" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool command="i386-linux-gnueabi-gcc" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.1861215757" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler"> + <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.2037686547" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/> + <option id="sbi.gnu.c.compiler.option.debugging.level.core.1452719209" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" value="gnu.c.debugging.level.max" valueType="enumerated"/> + <option defaultValue="true" id="sbi.gnu.c.compiler.option.misc.pic.core.1453909711" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.c.compiler.option.233868578" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs"> + <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_gcc46.i386.core.sharedLib"/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.1118601788" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath"> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SDK_PATH}/library""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.658862147" 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="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-fvisibility=hidden"/> + </option> + <option id="gnu.c.compiler.option.include.paths.835810376" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks.core.1152637183" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + </option> + <option id="gnu.c.compiler.option.preprocessor.def.symbols.965861493" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols"> + <listOptionValue builtIn="false" value="_DEBUG"/> + </option> + <inputType id="sbi.gnu.c.compiler.tizen.inputType.1883002997"/> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1757696344" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.1507702414" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/> + <tool command="i386-linux-gnueabi-g++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.1368529777" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker"> + <option defaultValue="true" id="sbi.gnu.cpp.linker.option.shared_flag.core.1878679236" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" valueType="boolean"/> + <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.1143377747" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList"> + <listOptionValue builtIn="false" value="${TC_LINKER_MISC}"/> + <listOptionValue builtIn="false" value="${RS_LINKER_MISC}"/> + <listOptionValue builtIn="false" value="-lpthread "/> + <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-L"${SBI_SYSROOT}/usr/lib""/> + <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/> + </option> + <option id="gnu.cpp.link.option.paths.1428178331" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"> + <listOptionValue builtIn="false" value="../../../app-assist-efl/Debug"/> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lib}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/common/Debug}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/ct-common/Debug}""/> + </option> + <option id="gnu.cpp.link.option.libs.1164009587" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs"> + <listOptionValue builtIn="false" value="common"/> + <listOptionValue builtIn="false" value="ct-common"/> + <listOptionValue builtIn="false" srcPrefixMapping="" srcRootPath="" value="app-assist-efl"/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.176149213" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input"> + <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> + <additionalInput kind="additionalinput" paths="$(LIBS)"/> + </inputType> + </tool> + <tool command="i386-linux-gnueabi-as" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.2005224609" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1762273030" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + <tool id="org.tizen.nativecore.tool.sbi.po.compiler.1228218169" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/> + <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.2001283476" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"/> + <tool id="org.tizen.nativecore.tool.fnmapgen.844629607" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/> + <tool id="org.tizen.nativecore.tool.fnmapgen.cpp.1347283376" name="C++ FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen.cpp"/> + <tool id="org.tizen.nativecore.tool.ast.125956742" name="C Static Analyzer" superClass="org.tizen.nativecore.tool.ast"/> + <tool id="org.tizen.nativecore.tool.ast.cpp.2092563166" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/> + </toolChain> + </folderInfo> + <sourceEntries> + <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/> + <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/> + </sourceEntries> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> + </cconfiguration> + <cconfiguration id="org.tizen.nativecore.config.sbi.gcc45.so.release.1227286930"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.tizen.nativecore.config.sbi.gcc45.so.release.1227286930" moduleId="org.eclipse.cdt.core.settings" name="Release"> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> + <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + </extensions> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <configuration artifactExtension="so" artifactName="ct-list" buildArtefactType="org.tizen.nativecore.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.sharedLib,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.so.release.1227286930" name="Release" parent="org.tizen.nativecore.config.sbi.gcc45.so.release"> + <folderInfo id="org.tizen.nativecore.config.sbi.gcc45.so.release.1227286930." name="/" resourcePath=""> + <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.so.release.1224831716" name="Tizen Core Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.so.release"> + <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.186230389" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/> + <builder buildPath="${workspace_loc:/ct-list}/Release" id="org.tizen.nativecore.target.sbi.gnu.builder.1123109998" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/> + <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.553322821" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/> + <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.1034541289" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler"> + <option id="gnu.cpp.compiler.option.optimization.level.1011342723" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/> + <option id="sbi.gnu.cpp.compiler.option.debugging.level.core.1046041859" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core"/> + <option defaultValue="true" id="sbi.gnu.cpp.compiler.option.misc.pic.core.401837846" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.cpp.compiler.option.1585209480" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs"> + <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_llvm34.i386.core.sharedLib"/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.203692581" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath"> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SDK_PATH}/library""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.276466369" 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="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-fvisibility=hidden"/> + </option> + <option id="gnu.cpp.compiler.option.include.paths.449335621" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/ct-common/inc}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/app-assist-efl/inc}""/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks.core.1812671095" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + </option> + <option id="gnu.cpp.compiler.option.other.other.690763084" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -std=c++0x" valueType="string"/> + <inputType id="sbi.gnu.cpp.compiler.tizen.inputType.314101167"/> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1394335062" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool command="clang" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.1226083928" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler"> + <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.option.optimization.level.595259819" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/> + <option id="sbi.gnu.c.compiler.option.debugging.level.core.1252256951" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core"/> + <option defaultValue="true" id="sbi.gnu.c.compiler.option.misc.pic.core.2055009438" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.c.compiler.option.390505349" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs"> + <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_llvm34.i386.core.sharedLib"/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.1445168488" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath"> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SDK_PATH}/library""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.1649663234" 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="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-fvisibility=hidden"/> + </option> + <option id="gnu.c.compiler.option.include.paths.276795984" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks.core.423469432" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + </option> + <inputType id="sbi.gnu.c.compiler.tizen.inputType.1355345044"/> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.640334408" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.603047174" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/> + <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.1670796608" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker"> + <option defaultValue="true" id="sbi.gnu.cpp.linker.option.shared_flag.core.1005778828" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" valueType="boolean"/> + <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.1857702820" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList"> + <listOptionValue builtIn="false" value="${TC_LINKER_MISC}"/> + <listOptionValue builtIn="false" value="${RS_LINKER_MISC}"/> + <listOptionValue builtIn="false" value="-lpthread "/> + <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-L"${SBI_SYSROOT}/usr/lib""/> + <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/> + </option> + <option id="gnu.cpp.link.option.paths.1030145055" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lib}""/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1098827167" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input"> + <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> + <additionalInput kind="additionalinput" paths="$(LIBS)"/> + </inputType> + </tool> + <tool command="i386-linux-gnueabi-as" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.903542346" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1418099674" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + <tool id="org.tizen.nativecore.tool.sbi.po.compiler.539531336" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/> + <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.1313133147" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"/> + <tool id="org.tizen.nativecore.tool.fnmapgen.846852445" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/> + <tool id="org.tizen.nativecore.tool.fnmapgen.cpp.658828604" name="C++ FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen.cpp"/> + <tool id="org.tizen.nativecore.tool.ast.1484701725" name="C Static Analyzer" superClass="org.tizen.nativecore.tool.ast"/> + <tool id="org.tizen.nativecore.tool.ast.cpp.2089776750" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/> + </toolChain> + </folderInfo> + <sourceEntries> + <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/> + <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/> + </sourceEntries> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> + </cconfiguration> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <project id="ct-list.org.tizen.nativecore.target.sbi.gcc45.so.2035770886" name="Tizen Core Shared Library" projectType="org.tizen.nativecore.target.sbi.gcc45.so"/> + </storageModule> + <storageModule moduleId="scannerConfiguration"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + <scannerConfigBuildInfo instanceId="org.tizen.nativecore.config.sbi.gcc45.so.debug.2033459981"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.tizen.nativecommon.TizenGCCManagedMakePerProjectProfileCPP"/> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="org.tizen.nativecore.config.sbi.gcc45.so.release.1227286930"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.tizen.nativecommon.TizenGCCManagedMakePerProjectProfileCPP"/> + </scannerConfigBuildInfo> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/> + <storageModule moduleId="org.tizen.tizen.nativeapp.projectInfo" version="1.0.0"/> + <storageModule moduleId="refreshScope" versionNumber="2"> + <configuration configurationName="Release"> + <resource resourceType="PROJECT" workspacePath="/ct-list"/> + </configuration> + <configuration configurationName="Debug"> + <resource resourceType="PROJECT" workspacePath="/ct-list"/> + </configuration> + </storageModule> +</cproject> diff --git a/lib-contact/ct-list/.project b/lib-contact/ct-list/.project new file mode 100644 index 0000000..34a93b9 --- /dev/null +++ b/lib-contact/ct-list/.project @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>ct-list</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> + <triggers>full,incremental,</triggers> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.tizen.nativecore.apichecker.core.builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.cdt.core.cnature</nature> + <nature>org.eclipse.cdt.core.ccnature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> + <nature>org.tizen.nativecore.apichecker.core.tizenCppNature</nature> + </natures> + <filteredResources> + <filter> + <id>1413282533349</id> + <name></name> + <type>26</type> + <matcher> + <id>org.eclipse.ui.ide.multiFilter</id> + <arguments>1.0-projectRelativePath-matches-false-false-*/.tpk</arguments> + </matcher> + </filter> + </filteredResources> +</projectDescription> diff --git a/lib-contact/ct-list/.tproject b/lib-contact/ct-list/.tproject new file mode 100644 index 0000000..f1cc1fd --- /dev/null +++ b/lib-contact/ct-list/.tproject @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<tproject xmlns="http://www.tizen.org/tproject"> + <platforms> + <platform> + <name>mobile-2.3</name> + </platform> + </platforms> + <package> + <blacklist/> + </package> +</tproject> diff --git a/lib-contact/ct-list/CMakeLists.txt b/lib-contact/ct-list/CMakeLists.txt new file mode 100644 index 0000000..5b4bfa3 --- /dev/null +++ b/lib-contact/ct-list/CMakeLists.txt @@ -0,0 +1,27 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(ct-list CXX) + +INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/app-assist-efl/inc + ${CMAKE_SOURCE_DIR}/lib-common/inc + ${CMAKE_SOURCE_DIR}/lib-contact/ct-common/inc + ${CMAKE_SOURCE_DIR}/lib-contact/ct-detail/inc + ${CMAKE_SOURCE_DIR}/lib-contact/ct-importer/inc + ${CMAKE_SOURCE_DIR}/lib-contact/ct-setting/inc + ${CMAKE_SOURCE_DIR}/lib-contact/ct-vcard/inc + ${CMAKE_CURRENT_SOURCE_DIR}/inc + ${CMAKE_CURRENT_SOURCE_DIR}/src +) + +FILE(GLOB SRCS "src/*.cpp") +ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${TIZEN_PKGS_LDFLAGS} + "app-assist-efl" + "contacts-common" + "ct-common" + "ct-detail" + "ct-importer" + "ct-vcard" +) + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_APP_LIB_DIR}) diff --git a/lib-contact/ct-list/inc/CtListController.h b/lib-contact/ct-list/inc/CtListController.h new file mode 100644 index 0000000..c92a3e0 --- /dev/null +++ b/lib-contact/ct-list/inc/CtListController.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_LIST_CONTROLLER_H_ +#define _CT_LIST_CONTROLLER_H_ + +#include <Elementary.h> + +typedef enum { + CT_LIST_UPDATE_DATA_NUMBER, + CT_LIST_UPDATE_DATA_EMAIL, + CT_LIST_UPDATE_DATA_WEB, + CT_LIST_UPDATE_DATA_IMAGE, + CT_LIST_UPDATE_DATA_FACETAG_IMAGE +}CtListUpdateDataType; + +class CtListView; + +class CtListController +{ +public: + virtual ~CtListController(){}; + + virtual void onListUpdated() = 0; + virtual void onSelectItem(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState) = 0; + virtual void onSelectCreate(void *data, Evas_Object *obj, void *event_info) { }; + virtual void onSelectDone(void *data, Evas_Object *obj, void *event_info) = 0; + virtual void onSelectBack(void *data, Evas_Object *obj, void *event_info) = 0; + virtual void onSelectCancel(void *data, Evas_Object *obj, void *event_info) = 0; + virtual void onSwipeLeftItem(void *data, Evas_Object *obj, void *event_info) = 0; + virtual void onSwipeRightItem(void *data, Evas_Object *obj, void *event_info) = 0; + virtual void onSelectCheckAll(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState) = 0; + virtual void onSelectMenu(CtListView *view) = 0; + + // should remove + virtual void moreManageFavoritesItemOperation() = 0; + +}; + +#endif // _CT_LIST_CONTROLLER_H_ + diff --git a/lib-contact/ct-list/inc/CtListView.h b/lib-contact/ct-list/inc/CtListView.h new file mode 100755 index 0000000..a087396 --- /dev/null +++ b/lib-contact/ct-list/inc/CtListView.h @@ -0,0 +1,415 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __CT_LIST_VIEW_H_ +#define __CT_LIST_VIEW_H_ + +#include <string> +#include <vector> +#include <list> +#include <memory> + +#include "WNaviframe.h" + +#include "ContactsCommon.h" +#include "IContactsTabPageView.h" +#include "CtType.h" +#include "CtView.h" +#include "ICtChangeListener.h" +#include "CtListController.h" +#include "CtThread.h" + +class CtListModel; +class CtListModelDb; +class CtListModelGroup; +class CtListDataPerson; +class CtListDataGroup; + +class CtListBasicController; +class CtListUgChooseController; +class CtListUgMultiPickController; +class CtListUgSinglePickController; + +typedef enum { + LIST_SUB_DEFAULT, + LIST_SUB_LINK_SUGGEST, + LIST_SUB_FAVORITE, + LIST_SUB_MFC, +}CtListSubListType; + +enum CtListSelectMode { + LIST_SELECT_SINGLE, + LIST_SELECT_SINGLE_OR_CREATE, + LIST_SELECT_MULTIPLE +}; + +enum CtListResultType { + LIST_RESULT_ID, + LIST_RESULT_NUMBER, + LIST_RESULT_NUMBER_FOR_CALL, + LIST_RESULT_NUMBER_FOR_MESSAGE, + LIST_RESULT_EMAIL, + LIST_RESULT_VCARD, + LIST_RESULT_NUMBER_OR_EMAIL +}; + +class WAPP_ASSIST_EXPORT CtListView : public CtView, public IContactsTabPageView, public ICtChangeListener +{ +public: + typedef std::function<void(const char*, CtListResultType)> SingleResultCb; + typedef std::function<void(const char*[], size_t)> MultiResultCb; + + CtListView(const char *vcardPath); + CtListView(CtListSelectMode selectMode, CtListResultType resultType, int limit); + CtListView(CtListViewType viewType, CtListDataType dataType, CtListCtrlType ctrlType); + virtual const char* getClassName(); + + Evas_Object* getViewWindow(void); + Evas_Object* getViewNaviframe(void); + WNaviframe* getWNaviframe(void); + + const int getListTopItemPersonId(void); + void setTopItemOnList(const int personId) {__topItemPersonId = personId;} + void setOnProgressOperation(bool onProgress); + + Elm_Object_Item* getGenlistItemByPersonId(int personId); + + void setOnSingleResult(SingleResultCb handler); + void setOnMultiResult(MultiResultCb handler); + + void sendSingleResult(const char *data, CtListResultType type) const; + void sendMultiResult(const char *data[], size_t count) const; + +protected: + virtual Evas_Object* onCreate( Evas_Object* parent, void* viewParam); + virtual void onDestroy(); + virtual void onPushed(Elm_Object_Item* naviItem); + virtual void onEvent(int eventType); + virtual void onSetAsPageContent(Elm_Object_Item* parentNaviItem); + virtual void onTabSelect(Elm_Object_Item *naviItem); + virtual void onTabUnselect(Elm_Object_Item *naviItem); + virtual bool onTabPop(); + virtual void onTabScrollStart() {return;} + virtual void onTabScrollStop() {return;} + virtual bool onPop(); + +protected: + virtual void onLanguageChanged(); + +private: + + virtual void onDbChanged(const char* viewUri); + virtual void onCompleteGetContacts(int offset); + virtual void onConditionChagned(); + + typedef struct { + int position; + int skipped_count; + char index[10]; + Elm_Object_Item *item; + } CtListFastIndexData; + + + struct CtListDataItem { + Elm_Object_Item* item; + CtListView *listView; + std::shared_ptr<CtListDataPerson> personData; + }; + + void __resetCheckitems(); + void __initialize(void); + void __hideFastScroll(void); + void __showFastScroll(void); + void __freeFastIndexData(void); + void __appendFastScrollLetter(const std::string &str); + void __showNoContent(void); + void __showGenlist(void); + void __updatetGenlistItem(void); + void __showTitleButton(bool show); + void __initViewCondition(CtListViewType viewType, CtListCtrlType ctrlType); + void __appendGenlistItems(int offset); + char* __getSearchHighlightNumber(const char *src); + void __setItemClassStyle(); + void __updateCheckRelatedInfo(); + void __updateCheckAllRelatedInfo(); + void __initFastscrollData(); + + //item style + void __setReorderItemClassStyle(void); + void __setCheckItemClassStyle(void); + void __setDefaultItemClassStyle(void); + void __setGroupTitleItemClassStyle(void); + void __setMyProfileItemClassStyle(void); + void __setSelectAllItemClassStyle(void); + void __setSearchbarItemClassStyle(void); + void __setFavoriteTitleItemClassStyle(void); + void __setMfcTitleItemClassStyle(void); + void __setLinkSuggestTitleItemClassStyle(void); +#if 0 + void __setGalSearchItemClassStyle(void); + void __setGalSearchTitleItemClassStyle(void); + void __setGalSearchMoreItemClassStyle(void); + void __setGalSearchProgressItemClassStyle(void); +#endif + static Evas_Object* __createToolbar(Evas_Object *navi); + + //Group Index + Eina_Unicode __hangulCompatibilityToJamo(Eina_Unicode unicode); + bool __compareCharacter(const char *str1, const char *str2); + void __linkItemsManually(Eina_List *indexItem, Elm_Object_Item *genItem); + void __linkItemToIndex(Elm_Object_Item *groupItem); + void __linkItemToRestIndex(); + + + Evas_Object* __createGenlist(Evas_Object* parent); + Evas_Object* __createFastscroll(Evas_Object* parent); + Evas_Object* __createSearchbar(Evas_Object* parent); + Evas_Object* __createNoContent(Evas_Object* parent); + Evas_Object* __createFloatBtn(Evas_Object* parent); + void __cleanSearchbar(void); + void __hideCreateButton(void); + void __showCreateButton(void); + Evas_Object* __setNoContentsLayout(Evas_Object* parent); + void __setNoContentsText(std::string text, std::string helptext=""); + void __hideNoContentsLayout(); + void __showNoContentsLayout(); + +#if 0 + void __clearGalSearchItems(); +#endif + +private: + + char *__getDelPopupText(); + + //view evas obj item callbacks + static void __onSelectItem(void *data, Evas_Object *obj, void *event_info); + static void __onMyProfileSelectCb(void *data, Evas_Object *obj, void *event_info); + static void __onGenlistRealizedCb(void *data, Evas_Object *obj, void *event_info); + static void __onChangedSearchEditField(void *data, Evas_Object *obj, void *event_info); + static void __onSearchbarActivatedCb(void *data, Evas_Object *obj, void *event_info); + static void __onSipUpCb(void *data, Evas_Object *obj, void *event_info); + static void __onSipDownCb(void *data, Evas_Object *obj, void *event_info); + static void __onNaviTitleCancel(void *data, Evas_Object *obj, void *event_info); + static void __deletePopupDelCb(void *data, Evas *e, Evas_Object *obj, void *event_info); + static void __onNaviTitleDone(void *data, Evas_Object *obj, void *event_info); + static void __onClickRemoveBtn(void *data, Evas_Object *obj, void *event_info); + static void __onToolbarDone(void *data, Evas_Object *obj, void *event_info); + static void __onSelectCheckAll(void *data, Evas_Object *obj, void *event_info); + static void __onSelectMenu(void *data, Evas_Object *obj, void *event_info); + static void __onSelectFloatBtn(void *data, Evas_Object *obj, void *event_info); + static void __onEntryFocused(void *data, Evas_Object *obj, void *event_info); + static void __onEntryUnfocused(void *data, Evas_Object *obj, void *event_info); + static void __onEntryBackButton(void *data, Evas_Object *obj, void *event_info); + static void __onCancelButtonClicked(void *data, Evas_Object *obj, void *event_info); + + static void __genlistReoderCb(void *data, Evas_Object *obj, void *event_info); + + static void __focusInCb(void *data, Evas_Object *obj, void *event_info); + +#if 0 + static void __onSelectGalSearchMore(void *data, Evas_Object *obj, void *event_info); + static Eina_Bool __galSearchTimeoutCb(void* data); +#endif + + //bool __checkMFC(int personId); + //fast index callbacks + static void __fastIndexChanged(void *data, Evas_Object *obj, void *event_info); + static void __fastIndexSelected(void *data, Evas_Object *obj, void *event_info); + + static bool __checkValidSpecialCharForNumber(char character); + static bool __checkValidCharForNumber(char character); + + static void __onGenlistScrollStartCb(void *data, Evas_Object *obj, void *event_info); + static void __onGenlistScrollStopCb(void *data, Evas_Object *obj, void *event_info); + static void __onNaviTransitionFinishedCb(void *data, Evas_Object *obj, void *event_info); + + static Eina_Bool __loadImageTimerCb(void *user_data); + + static void __onInitMyProfileThreadRunCb(void *data); + static void __onInitMyProfileThreadEndCb(void *data); + static Eina_Bool __onInitMyProfileIdlerCb(void *data); + + static void __reorderButtonMouseDownCb(void *data, Evas *evas, Evas_Object *obj, void *event_info); + static void __reorderButtonMouseUpCb(void *data, Evas *evas, Evas_Object *obj, void *event_info); + + static Eina_Bool __createNocontentsPopupCb(void* data); + + static void __onSearchGetContactsThreadRunCb(void *data); + static void __onSearchGetContactsThreadEndCb(void *data); + + char *__getMyProfileNumber() const; + char* __getMsisdnFromSim(); + void __initMyProfile(void); + + void __initListItems(void); + Elm_Object_Item* __addSearchbarItem(void); + Elm_Object_Item* __addSelectAllItem(void); + Elm_Object_Item* __addMyProfileItem(void); + Elm_Object_Item* __addFavoriteTitleItem(Elm_Object_Item *curItem); + Elm_Object_Item* __addFavoriteItem(Elm_Object_Item *curItem, CtListDataItem* itemData); + Elm_Object_Item* __addMfcTitleItem(Elm_Object_Item *curItem); + Elm_Object_Item* __addMfcItem(Elm_Object_Item *curItem, CtListDataItem* itemData); + Elm_Object_Item* __addDefaultItem(Elm_Object_Item *curItem, CtListDataItem* itemData, bool needGroupTitle); + Elm_Object_Item* __addLinkSuggestItem(Elm_Object_Item *curItem, CtListDataItem* itemData); + Elm_Object_Item* __addLinkSuggestTitleItem(Elm_Object_Item *curItem); + Elm_Object_Item* __appendGroupItem(Elm_Object_Item *curItem, CtListDataItem* itemData); + + void __deleteRestItems(Elm_Object_Item *curItem, bool all); + + int __addLinkSuggestList(void); + int __addFavoriteList(void); + int __addMfcList(void); + int __addDefaultList(int offset); + int __addSearchList(int offset); + + Elm_Object_Item* __getStandardItem(CtListSubListType listType); + +private: + virtual ~CtListView(); + +private: + Evas_Object* __baseLayout; + Evas_Object* __fastLayout; + Evas_Object* __fastScroll; + Evas_Object* __genlist; + Evas_Object* __selectAllObj; + Evas_Object* __compose_btn; + Evas_Object* __noContentLayout; + + Elm_Object_Item* __searchbarItem; + Elm_Object_Item* __selectAllItem; + Elm_Object_Item* __linkSuggestTitleItem; + Elm_Object_Item* __favoriteTitleItem; + Elm_Object_Item* __mfcTitleItem; + Elm_Object_Item* __myProfileItem; + +#if 0 + Elm_Object_Item* __galSearchMoreItem; + Ecore_Timer *__galSearchTimer; +#endif + + CtListController* __listController; + CtListModel* __listModel; + CtListModelGroup* __listGroupModel; + CtListViewType __viewType; + CtListCtrlType __ctrlType; + + //for group title + Elm_Object_Item *__curGroupTitleItem; + Elm_Object_Item *__unmatchedGroupTitleItem; + std::string __curGroupIndex; + + bool __onSearching; + bool __onShowGroupButton; + bool __onShowGroupList; + bool __onShowMemberList; + + bool __sipStatus; + bool __launching; + bool __genlistScrolling; + int __curAppendIndex; + int __launched; + bool __loaded; + bool __selectedCheckAll; + bool __onProgressOperation; + bool __onNoContentLayout; + + int __updateQueue; + Eina_List *__fastIndexList; + std::vector<std::shared_ptr<CtListDataPerson>> __vcPersonData; + + typedef struct { + int personId; + int prevPersonId; + int nextPersonId; + } CtListFavoriteReorderData; + std::vector <CtListFavoriteReorderData> __reorderData; + + //itc member + Elm_Genlist_Item_Class* __listItc; + Elm_Genlist_Item_Class* __groupTitleItc; + Elm_Genlist_Item_Class* __myProfileItc; + Elm_Genlist_Item_Class* __selectAllItc; + Elm_Genlist_Item_Class* __searchbarItc; + Elm_Genlist_Item_Class* __favoriteTitleItc; + Elm_Genlist_Item_Class* __mfcTitleItc; + Elm_Genlist_Item_Class* __linkSuggestTitleItc; + +#if 0 + Elm_Genlist_Item_Class* __galSearchItc; + Elm_Genlist_Item_Class* __galSearchTitleItc; + Elm_Genlist_Item_Class* __galSearchMoreItc; + Elm_Genlist_Item_Class* __galSearchProgressItc; +#endif + + //view condition + bool __hasTitle; + bool __hasSearchbar; + bool __hasFastscroll; + bool __hasToolbar; + bool __hasCreateButton; + bool __hasSelectAll; + bool __hasTotalCount; + bool __hasGroupTitle; + bool __hasMenu; + bool __hasDoneCancel; + bool __hasFavGroupTitle; + bool __hasMyProfile; + bool __enableDone; + bool __hasFavoriteList; + bool __hasMfcList; + bool __hasDefaultList; + bool __hasLinkSuggest; + bool __hasGroupButton; + + CtCheckState __selectAllState; + int __selectedPersonId; + int __topItemPersonId; + +#if 0 + int __galSearchOffset; + bool __onUpdateGalSearch; +#endif + + char* __groupName; + + CtThread *__myProfileThread; + Ecore_Idler *__myProfileIdler; + + Ecore_Timer *__loadImageTimer; + CtThread *__searchGetContactThread; + + void* __detailDllHandle; + void* __cmDllHandle; + + bool __background; + bool __isFirstGroupSync; + bool __isFirstGroupMemberSync; + + int __groupUpdateTimer; + SingleResultCb __singleResultCb; + MultiResultCb __multiResultCb; + + friend class CtListBasicController; + friend class CtListUgMultiPickController; + friend class CtListUgSinglePickController; + friend class CtListUgVcardViewController; + friend class CtListLinkContactController; +}; + +#endif diff --git a/lib-contact/ct-list/src/CtListBasicController.cpp b/lib-contact/ct-list/src/CtListBasicController.cpp new file mode 100755 index 0000000..35a2fa0 --- /dev/null +++ b/lib-contact/ct-list/src/CtListBasicController.cpp @@ -0,0 +1,1049 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <dlfcn.h> +#include <vector> +#include <Elementary.h> +#include <app_preference.h> +#include <app.h> +#include <contacts.h> +#include <Ecore_File.h> +#include <app_preference.h> + +#include "WView.h" +#include "WNaviframe.h" +#include "WPopup.h" +#include "WMenuPopup.h" +#include "WToastPopup.h" + +#include "ContactsDebug.h" +#include "ContactsAppControl.h" +#include "ContactsAppControlLauncher.h" +#include "CtDetailView.h" +#include "CtType.h" +#include "CtListBasicController.h" +#include "CtListDataPerson.h" +#include "CtCommon.h" +#include "CtContactsToVcard.h" +#include "CtPath.h" +#include "CtListView.h" +#include "CtListModelDb.h" +#include "CtRegistryMgr.h" + +#define __ITEM_HEIGHT 96 + +bool CtListBasicController::__stopDoAsyncAction = false; + +CtListBasicController::CtListBasicController(CtListCtrlType ctrlType, CtListView *listView, CtListModelDb* listModel) +{ + WHIT(); + + __listView = listView; + __listModel = listModel; + __ctrlType = ctrlType; + __progressPopup = NULL; + __updateDataType = 0; + __canceled = false; + __stopDoAsyncAction = false; + __doActionThread = NULL; + __settingDllHandle = NULL; + __detailDllHandle = NULL; + __cmDllHandle = NULL; + + preference_set_changed_cb(CT_KEY_SHOW_LINK_CONTACTS_TOAST_POPUP, __onPreferenceChangedCb, this); +} + +CtListBasicController::~CtListBasicController() +{ + WHIT(); + + preference_unset_changed_cb(CT_KEY_SHOW_LINK_CONTACTS_TOAST_POPUP); + + __stopDoAsyncAction = true; + + __canceled = true; + + if (auto popup = __popupMonitor.lock()) { + popup->destroy(); + } + + if(__doActionThread){ + __doActionThread->destroy(); + __doActionThread = NULL; + } + +} + +void CtListBasicController::__onPreferenceChangedCb(const char *key, void *data) +{ + CtListBasicController * listCtrl = static_cast<CtListBasicController*>(data); + + if (strcmp(key, CT_KEY_SHOW_LINK_CONTACTS_TOAST_POPUP) == 0) { + bool showPopup = false; + + int error = preference_get_boolean(CT_KEY_SHOW_LINK_CONTACTS_TOAST_POPUP, &showPopup); + WPRET_M(error != PREFERENCE_ERROR_NONE, "preference_get_boolean failed"); + + WDEBUG("showPopup %d", showPopup); + + if (showPopup) { + preference_set_boolean(CT_KEY_SHOW_LINK_CONTACTS_TOAST_POPUP, false); + WToastPopup* popup = new WToastPopup("Some of your contacts appear to be duplicates. Manage this in Link contacts."); + listCtrl->__listView->attachPopup(popup); + + } + } +} + +bool CtListBasicController::__changeCheckState(Elm_Object_Item *item, bool checkState) +{ + WHIT(); + + Elm_Genlist_Item_Type item_type = elm_genlist_item_type_get(item); + if(item_type == ELM_GENLIST_ITEM_GROUP) { + return false; + } + + Evas_Object* layout = elm_object_item_part_content_get(item,"elm.icon.2"); + Evas_Object* check = elm_layout_content_get(layout, "elm.swallow.content"); + + CtListView::CtListDataItem* itemData = (CtListView::CtListDataItem*)elm_object_item_data_get(item); + WPRET_VM(itemData == NULL, false, "itemData is null"); + + itemData->personData->setAsChecked(checkState); + if(itemData->personData->isChecked() == true) { + __listModel->pushCheckedData(itemData->personData); + } + else { + __listModel->removeCheckedData(itemData->personData); + } + elm_check_state_set(check, (Eina_Bool)checkState); + + int checkedCount = __listModel->getCheckedDataCount(); + Elm_Object_Item *naviItem = elm_naviframe_top_item_get(__listView->getViewNaviframe()); + Evas_Object *btn = elm_object_item_part_content_get(naviItem, "title_right_btn"); + if(btn) { + if(checkedCount > 0) + elm_object_disabled_set(btn, EINA_FALSE); + else + elm_object_disabled_set(btn, EINA_TRUE); + } + + WDEBUG("%d, %d", checkedCount, __listModel->getPersonListCount(LIST_QUERY_DEFAULT)); + + if (__listView->__onSearching) { + if(__listView->__selectAllObj) { + if (__listModel->checkIsSelectAllOnSearching()) { + WDEBUG("check select all"); + elm_check_state_set(__listView->__selectAllObj, EINA_TRUE); + __listView->__selectAllState = CHECK_ON; + } + else { + elm_check_state_set(__listView->__selectAllObj, EINA_FALSE); + __listView->__selectAllState = CHECK_OFF; + } + } + } + else { + if(__listView->__selectAllObj) { + if( checkedCount == __listModel->getPersonListCount(LIST_QUERY_DEFAULT)) { + WDEBUG("check select all"); + elm_check_state_set(__listView->__selectAllObj, EINA_TRUE); + __listView->__selectAllState = CHECK_ON; + } + else { + elm_check_state_set(__listView->__selectAllObj, EINA_FALSE); + __listView->__selectAllState = CHECK_OFF; + } + } + } + + __listModel->setSelectAllState(false); + + char buf[CT_TEXT_SHORT_LEN] = {0,}; + if(__listModel->getLimitCount() == 0) + snprintf(buf, sizeof(buf), ctGetContactsString("IDS_PB_HEADER_PD_SELECTED_ABB3"), checkedCount); + else + snprintf(buf, sizeof(buf), "%d/%d", checkedCount, __listModel->getLimitCount()); + elm_object_item_part_text_set(naviItem, "elm.text.title", buf); + + return (bool)elm_check_state_get(check); +} + +bool CtListBasicController::__getCheckState(Elm_Object_Item *item) +{ + WHIT(); + Evas_Object* layout = elm_object_item_part_content_get(item,"elm.icon.2"); + Evas_Object* check = elm_layout_content_get(layout, "elm.swallow.content"); + + + return (bool)elm_check_state_get(check); +} + + + +void CtListBasicController::onSelectItem(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState) +{ + WHIT(); + WPRET_M(!view, "invalid view"); + Elm_Object_Item *item = selectedItem; + elm_genlist_item_selected_set(selectedItem, EINA_FALSE); + + CtListView::CtListDataItem* itemData = (CtListView::CtListDataItem*)elm_object_item_data_get(item); + + WDEBUG("__ctrlType %d", __ctrlType); + + switch(__ctrlType){ + case LIST_CTRL_DEFAULT: + { + WView *detailView = new CtDetailView(itemData->personData->getPersonId()); + view->getNaviframe()->push(detailView); + } + break; + case LIST_CTRL_DELETE_CONTACTS: + case LIST_CTRL_SHARE_CONTACTS: + case LIST_CTRL_ADD_FAVORITES: + case LIST_CTRL_REMOVE_FAVORITES: + __changeCheckState(item, checkState); + break; + case LIST_CTRL_SHARE_CONTACT_INFO : + { + if (__detailDllHandle == NULL) { + __detailDllHandle = ctGetDllHandle("libct-detail.so"); + } + + if (__detailDllHandle) { + typedef WView* (*CreateShareContactView)(int, ContactsData*); + CreateShareContactView createShareContactView = (CreateShareContactView)dlsym(__detailDllHandle, "createShareContactView"); + if (createShareContactView) { + WView* shareContactView = createShareContactView(itemData->personData->getPersonId(), NULL); + view->getWNaviframe()->push(shareContactView); + } + } + } + break; + default: + WWARNING("Not handled type=%d", __ctrlType); + break; + } + + elm_genlist_realized_items_update(view->__genlist); +} + +void CtListBasicController::onSelectCreate(void *data, Evas_Object *obj, void *event_info) +{ + launchContactCreate(NULL); +} + +void CtListBasicController::onSelectDone(void *data, Evas_Object *obj, void *event_info) +{ + switch(__ctrlType){ + case LIST_CTRL_DEFAULT: + break; + case LIST_CTRL_DELETE_CONTACTS: + __canceled = false; + __doDeleteContacts(); + break; + case LIST_CTRL_SHARE_CONTACTS: + __doShareContacts(); + break; + case LIST_CTRL_ADD_FAVORITES: + case LIST_CTRL_REMOVE_FAVORITES: + __doFavoritesContacts(true); + break; + case LIST_CTRL_REORDER_FAVORITES: + __doSetFavoritesOrder(); + break; + default: + break; + } +} + +void CtListBasicController::onSelectCancel(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + switch(__ctrlType) + { + case LIST_CTRL_DELETE_CONTACTS : + case LIST_CTRL_SHARE_CONTACTS : + case LIST_CTRL_ADD_FAVORITES : + case LIST_CTRL_REMOVE_FAVORITES : + case LIST_CTRL_REORDER_FAVORITES : + __listView->popOut(); + break; + default: + WWARNING("Not handled type=%d", __ctrlType); + break; + } +} + +void CtListBasicController::onSelectBack(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); +} + +void CtListBasicController::onSwipeLeftItem(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); +} + +void CtListBasicController::onSwipeRightItem(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); +} + +void CtListBasicController::onSelectCheckAll(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState) +{ + WHIT(); + view->__selectAllState = checkState; + + Elm_Object_Item *item = selectedItem; + if (item) + elm_genlist_item_selected_set(item, EINA_FALSE); + + Evas_Object *genlist = view->__genlist; + + WDEBUG("select all %d", checkState); + + __listModel->setSelectAllState((bool)checkState); + + int index = 0; + std::shared_ptr<CtListDataPerson> personData = view->__listModel->getAtPersonData(index, LIST_QUERY_DEFAULT); + while(personData) { + if(checkState == true && !personData->isChecked()) { + __listModel->doCheckedDataNoRelation(personData, true); + } + else if (checkState == false && personData->isChecked()) { + __listModel->doCheckedDataNoRelation(personData, false); + } + personData->setAsChecked(checkState); + index++; + + personData = view->__listModel->getAtPersonData(index, LIST_QUERY_DEFAULT); + } + + if (__ctrlType == LIST_CTRL_REMOVE_FAVORITES) { + index = 0; + personData = view->__listModel->getAtPersonData(index, LIST_QUERY_MFC); + while (personData) { + if(checkState == true && !personData->isChecked()) { + __listModel->doCheckedDataNoRelation(personData, true); + } + else if (checkState == false && personData->isChecked()) { + __listModel->doCheckedDataNoRelation(personData, false); + } + personData->setAsChecked(checkState); + index++; + personData = view->__listModel->getAtPersonData(index, LIST_QUERY_MFC); + } + } + + elm_genlist_realized_items_update(genlist); +} + +void CtListBasicController::moreManageFavoritesItemOperation() +{ + WENTER(); + + Elm_Genlist_Item_Class* itc = elm_genlist_item_class_new(); + WPRET_M(!itc, "elm_genlist_item_class_new() failed"); + itc->item_style = "type1"; + itc->func.text_get = [](void* data, Evas_Object* obj, const char* part)->char* + { + if(!strcmp(part, "elm.text")){ + if (1 == (int)data) + return SAFE_STRDUP(V_("IDS_PB_OPT_ADD")); + else if (2 == (int)data) + return SAFE_STRDUP(V_("IDS_PB_OPT_REMOVE")); + else if (3 == (int)data) + return SAFE_STRDUP(V_("IDS_PB_HEADER_REORDER")); + else + return NULL; + } + return NULL; + }; + + WPopup* popup = new WPopup(); + popup->setTextTranslatable(PACKAGE); + popup->setTitle( "IDS_PB_HEADER_MANAGE_FAVOURITES_ABB"); + popup->setContent([this,itc](Evas_Object* parent)->Evas_Object* + { + Evas_Object* genlist = elm_genlist_add(parent); + elm_object_style_set( genlist, "popup" ); + elm_genlist_homogeneous_set(genlist, EINA_TRUE); + elm_genlist_mode_set( genlist, ELM_LIST_COMPRESS ); + elm_scroller_content_min_limit( genlist, EINA_FALSE, EINA_TRUE ); // Automatically pop-up height is calculated + elm_object_content_set(parent, genlist); + + elm_genlist_item_append(genlist, itc, (void*)1, NULL, ELM_GENLIST_ITEM_NONE,this->__onAddFavoritesSelCb,this); + + Elm_Object_Item *item2 = elm_genlist_item_append(genlist, itc, (void*)2, NULL, ELM_GENLIST_ITEM_NONE,this->__onRemoveFavoritesSelCb,this); + Elm_Object_Item *item3 = elm_genlist_item_append(genlist, itc, (void*)3, NULL, ELM_GENLIST_ITEM_NONE,this->__onReorderFavoritesSelCb,this); + + int count = 0; + count = __listModel->getContactsCount(LIST_QUERY_FAVORITE); + if(count == 0) { + if(0 == __listModel->getContactsCount(LIST_QUERY_MFC)) + elm_object_item_disabled_set(item2, EINA_TRUE); + elm_object_item_disabled_set(item3, EINA_TRUE); + } + else { + if(count == 1) + elm_object_item_disabled_set(item3, EINA_TRUE); + } + + evas_object_show(genlist); + + return genlist; + + }); + + __listView->attachPopup(popup); + + elm_genlist_item_class_free(itc); + + WLEAVE(); + +} + + +void CtListBasicController::onSelectMenu(CtListView* view) +{ + WENTER(); + + WMenuPopup* popup = new WMenuPopup(); + popup->prepare(view->getViewWindow(), view->getViewNaviframe()); + + int listCount = view->__listModel->getPersonListCount(LIST_QUERY_DEFAULT); + if(listCount == 0) // make sure the count + listCount = view->__listModel->getContactsCount(LIST_QUERY_DEFAULT); + + if(listCount > 0) { + popup->appendItem(V_("IDS_PB_BUTTON_DELETE_ABB4"), [view]() + { + int personId = view->getListTopItemPersonId(); + CtListView *deleteView = new CtListView(LIST_VIEW_CHECK, LIST_DATA_ALL_PERSON, LIST_CTRL_DELETE_CONTACTS); + deleteView->setTopItemOnList(personId); + view->getWNaviframe()->push(deleteView, NULL, NULL); + }); + popup->appendItem(V_("IDS_PB_HEADER_SHARE_VIA"), [view]() + { + view->getWNaviframe()->push(new CtListView(LIST_VIEW_CHECK, LIST_DATA_PERSON_EXCEPT_FACEBOOK, LIST_CTRL_SHARE_CONTACTS), NULL, NULL); + }); + popup->appendItem(V_("IDS_PB_HEADER_MANAGE_FAVOURITES_ABB"), [view]() + { + view->__listController->moreManageFavoritesItemOperation(); + }); + } + + popup->appendItem( V_("IDS_PB_OPT_SETTINGS"), [this, view]() + { + WHIT(); + if (__settingDllHandle == NULL) { + __settingDllHandle = ctGetDllHandle("libct-setting.so"); + } + + typedef WView* (*get_setting_view_t)(); + get_setting_view_t createSettingView = (get_setting_view_t)dlsym(__settingDllHandle, "createSettingView"); + if (createSettingView) { + WView* settingView = createSettingView(); + view->getWNaviframe()->push(settingView, NULL, NULL); + } + }); + + view->attachPopup(popup); +} + +void CtListBasicController::__onAddFavoritesSelCb(void *data, Evas_Object *obj, void *event_info) +{ + WENTER(); + //CONTACTS_LOGGING_LOG(LOGGING_LOG_ADD_TO_FAVOR); //DO NOT REMOVE!!! + CtListBasicController * listCtrl = static_cast<CtListBasicController*>(data); + listCtrl->__listView->destroyPopup(); + listCtrl->__listView->getWNaviframe()->push(new CtListView(LIST_VIEW_CHECK, LIST_DATA_PERSON_EXCEPT_SIM, LIST_CTRL_ADD_FAVORITES), NULL, NULL); + +} + +void CtListBasicController::__onRemoveFavoritesSelCb(void *data, Evas_Object *obj, void *event_info) +{ + WENTER(); + //CONTACTS_LOGGING_LOG(LOGGING_LOG_REMOVE_FROM_FAVOR); //DO NOT REMOVE!!! + CtListBasicController * listCtrl = static_cast<CtListBasicController*>(data); + listCtrl->__listView->destroyPopup(); + listCtrl->__listView->getWNaviframe()->push(new CtListView(LIST_VIEW_CHECK, LIST_DATA_ALL_FAVORITES, LIST_CTRL_REMOVE_FAVORITES), NULL, NULL); +} + +void CtListBasicController::__onReorderFavoritesSelCb(void *data, Evas_Object *obj, void *event_info) +{ + WENTER(); + CtListBasicController * listCtrl = static_cast<CtListBasicController*>(data); + listCtrl->__listView->destroyPopup(); + listCtrl->__listView->getWNaviframe()->push(new CtListView(LIST_VIEW_REORDER, LIST_DATA_ALL_FAVORITES, LIST_CTRL_REORDER_FAVORITES), NULL, NULL); +} + +int CtListBasicController::__setImage(contacts_record_h record, char *image) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + + if(image && *image) { + err = contacts_record_set_str(record, _contacts_image.path, image); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + // err = contacts_record_set_int(record, _contacts_image.type, CONTACTS_IMAGE_TYPE_EX_CUSTOM); + // WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_int() Failed(%d)", err); + } + return err; +} + +int CtListBasicController::__removeImage(contacts_record_h contactRecord, contacts_record_h imageRecord) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + + err = contacts_record_remove_child_record(contactRecord, _contacts_contact.image, imageRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_remove_child_record() Failed(%d)", err); + + err = contacts_record_destroy(imageRecord, true); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_destroy() Failed(%d)", err); + + return err; +} + +bool CtListBasicController::__setFavoriteImage(int personId, bool set, contacts_record_h contactRecord) +{ + return true; +} + +//typedef struct { +// contacts_list_h personRecordList; +// contacts_list_h contactRecordList; +//} CtListContactList; + +bool CtListBasicController::__getHasReadOnlyMode(char* addressbookIDs) +{ + WHIT(); + int addressbookId = -1; + char* tok = NULL; + contacts_record_h addressbookRecord = NULL; + int err = CONTACTS_ERROR_NONE; + tok = strtok (addressbookIDs," "); + int addressbookMode = 0; + while (tok != NULL) + { + WDEBUG ("%s",tok); + addressbookId = atoi(tok); + + err = contacts_db_get_record(_contacts_address_book._uri, addressbookId, &addressbookRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, false, "contacts_db_get_record() Failed(%d)", err); + + err = contacts_record_get_int(addressbookRecord, _contacts_address_book.mode, &addressbookMode); + WPRET_VM(CONTACTS_ERROR_NONE != err, false, "contacts_record_get_int() Failed(%d)", err); + + err = contacts_record_destroy(addressbookRecord, true); + WPRET_VM(CONTACTS_ERROR_NONE != err, false, "contacts_record_destroy() Failed(%d)", err); + +// if (CONTACTS_ADDRESS_BOOK_MODE_EX_READONLY & addressbookMode) { + if (CONTACTS_ADDRESS_BOOK_MODE_READONLY & addressbookMode) { + return true; + } + tok = strtok (NULL, " "); + } + return false; +} + +void CtListBasicController::__doFavoritesContacts(bool addFirstOne) +{ + WHIT(); + + bool updateMfc = false; + bool updateFavorite = false; + bool isfavorite = false; + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + contacts_list_h contactRecordList = NULL; + int displayContactId = 0; + const int LIST_BULK_LENGTH = 100; + int count =0; + + if(__progressPopup == NULL) { + __checkedData.reset(__listModel->getCheckedDataList()); + if ((int)__checkedData->size() == 0) + return; + + __listView->setOnProgressOperation(true); + if(__ctrlType == LIST_CTRL_ADD_FAVORITES) + __progressPopup = new CtProgressBarPopup(__checkedData->size(), V_("IDS_PB_BODY_ADD_TO_FAVOURITES"),true); + else if (__ctrlType == LIST_CTRL_REMOVE_FAVORITES) + __progressPopup = new CtProgressBarPopup(__checkedData->size(), V_("IDS_PB_BODY_REMOVE_FROM_FAVOURITES"),true); + if (__progressPopup) { + __progressPopup->addButton(V_("IDS_PB_BUTTON_CANCEL"), [this](bool* destroyPopup)->bool{ + WDEBUG("Cancel"); + __canceled = true; + *destroyPopup = true; + return true; + }); + __progressPopup->create(__listView->getViewNaviframe(), NULL); + __popupMonitor = __progressPopup->getWeakPtr(); + } + } + else if(__popupMonitor.lock()){ + __progressPopup->setProgressRemainCount(__checkedData->size()); + } + else{ + __listView->setOnProgressOperation(false); + __progressPopup = NULL; + __listView->popOut(); + return; + } + + if(__ctrlType == LIST_CTRL_ADD_FAVORITES){ + isfavorite = true; + } + else if (__ctrlType == LIST_CTRL_REMOVE_FAVORITES) { + isfavorite = false; + } + else { + WERROR("__ctrlType() Failed(%d)", __ctrlType); + } + WDEBUG("isfavorite %d", isfavorite); + + err = contacts_list_create(&contactRecordList); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_create() Failed(%d) - contactRecordList", err); + + if((int)__checkedData->size() > LIST_BULK_LENGTH) { + for(auto iter = __checkedData->begin() ;count < LIST_BULK_LENGTH ;++iter) { + int personId = (*iter)->getPersonId(); + displayContactId = 0; + // remove mfc + if (__listModel->checkMostFrequentContact((personId))) { + err = contacts_person_reset_usage(personId, CONTACTS_USAGE_STAT_TYPE_OUTGOING_CALL); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_person_reset_usage() Failed(%d)", err); + count++; + updateMfc = true; + continue; + } + //get person + err = contacts_db_get_record(_contacts_person._uri, personId, &record); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_db_get_record() Failed(%d) - _contacts_person", err); + continue; + } + char *thumbnailPath = NULL; + err = contacts_record_get_str_p(record, _contacts_person.image_thumbnail_path, &thumbnailPath); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + + char *addressbookIDs =NULL; + err = contacts_record_get_str_p(record, _contacts_person.addressbook_ids, &addressbookIDs); + if(CONTACTS_ERROR_NONE != err) + { + WERROR("contacts_record_get_str_p() Failed(%d)", err); + continue; + } + if(__getHasReadOnlyMode(addressbookIDs) == true) + { + err = contacts_record_set_bool(record, _contacts_person.is_favorite, isfavorite); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_set_bool() Failed(%d)", err); + err = contacts_db_update_record(record); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_update_record() Failed(%d)", err); + continue; + } + + err = contacts_record_get_int(record, _contacts_person_contact.display_contact_id, &displayContactId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + contacts_record_destroy(record, true); + + Eina_List *contactList = NULL; + void *data = NULL; + Eina_List *cursor = NULL; + contactList = ctCommonGetContactsList(personId); + + EINA_LIST_FOREACH(contactList, cursor, data) { + contacts_record_h contactRecord = (contacts_record_h)data; + int contactId = -1; + err = contacts_record_set_bool(contactRecord, _contacts_contact.is_favorite, isfavorite); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_set_bool() Failed(%d)", err); + contacts_record_destroy(contactRecord, true); + continue; + } + + err = contacts_record_get_int(contactRecord, _contacts_contact.id, &contactId); + WWARNING ("contactId : %d, displayContactId id :%d",contactId, displayContactId); + //if(contactId == displayContactId) { + contacts_record_h imageRecord = NULL; + err = contacts_record_get_child_record_at_p(contactRecord, _contacts_contact.image, 0, &imageRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_child_record_at_p() Failed(%d) - contact_list", err); + + if(imageRecord) { + int imageType = 0; + err = contacts_record_get_int(imageRecord, _contacts_image.type, &imageType); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_int() Failed(%d)", err); + contacts_record_destroy(contactRecord, true); + continue; + } +// if(imageType != CONTACTS_IMAGE_TYPE_EX_CUSTOM) { + if(imageType != CONTACTS_IMAGE_TYPE_CUSTOM) { + WERROR("imageType is Not Custom(%d)", imageType); + err = contacts_list_add(contactRecordList, contactRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_add() Failed(%d) - contact_list", err); + continue; + } + else { + //remove default image. + if(!isfavorite) { + __removeImage(contactRecord,imageRecord); + } + } + } + else { + if(thumbnailPath == NULL) { + WDEBUG("thumbnailPath is NULL"); + } + } + //} + + err = contacts_list_add(contactRecordList, contactRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_add() Failed(%d) - contact_list", err); + } + + count++; + updateFavorite = true; + if(addFirstOne) + break; + } + if(addFirstOne) + __checkedData->erase(__checkedData->begin(), __checkedData->begin()+(1)); + else + __checkedData->erase(__checkedData->begin(), __checkedData->begin()+(LIST_BULK_LENGTH-1)); + } + else if((int)__checkedData->size() > 0) { + for(auto iter = __checkedData->begin() ;iter != __checkedData->end();++iter) { + int personId = (*iter)->getPersonId(); + displayContactId = 0; + // remove mfc + if (__listModel->checkMostFrequentContact(personId)) { + err = contacts_person_reset_usage(personId, CONTACTS_USAGE_STAT_TYPE_OUTGOING_CALL); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_person_reset_usage() Failed(%d)", err); + updateMfc = true; + continue; + } + WDEBUG("personId %d", personId); + err = contacts_db_get_record(_contacts_person._uri, personId, &record); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_db_get_record() Failed(%d) - _contacts_person", err); + break; + } + + char *thumbnailPath = NULL; + err = contacts_record_get_str_p(record, _contacts_person.image_thumbnail_path, &thumbnailPath); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + + char *addressbookIDs =NULL; + err = contacts_record_get_str_p(record, _contacts_person.addressbook_ids, &addressbookIDs); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + + if(__getHasReadOnlyMode(addressbookIDs) == true) + { + err = contacts_record_set_bool(record, _contacts_person.is_favorite, isfavorite); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_set_bool() Failed(%d)", err); + err = contacts_db_update_record(record); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_update_record() Failed(%d)", err); + continue; + } + err = contacts_record_get_int(record, _contacts_person_contact.display_contact_id, &displayContactId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + contacts_record_destroy(record, true); + WDEBUG("displayContactId %d", displayContactId); + Eina_List *contactList = NULL; + void *data = NULL; + Eina_List *cursor = NULL; + contactList = ctCommonGetContactsList(personId); + EINA_LIST_FOREACH(contactList, cursor, data) { + contacts_record_h contactRecord = (contacts_record_h)data; + + err = contacts_record_set_bool(contactRecord, _contacts_contact.is_favorite, isfavorite); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_set_bool() Failed(%d)", err); + contacts_record_destroy(contactRecord, true); + continue; + } + + int contactId = -1; + err = contacts_record_get_int(contactRecord, _contacts_contact.id, &contactId); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_int() Failed(%d)", err); + contacts_record_destroy(contactRecord, true); + continue; + } + WWARNING ("contactId : %d, displayContactId id :%d",contactId, displayContactId); + //if(contactId == displayContactId) { + contacts_record_h imageRecord = NULL; + err = contacts_record_get_child_record_at_p(contactRecord, _contacts_contact.image, 0, &imageRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_child_record_at_p() Failed(%d) - contact_list", err); + if(imageRecord) { + int imageType = 0; + err = contacts_record_get_int(imageRecord, _contacts_image.type, &imageType); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_int() Failed(%d)", err); + contacts_record_destroy(contactRecord, true); + continue; + } +// if(imageType != CONTACTS_IMAGE_TYPE_EX_CUSTOM) { + if(imageType != CONTACTS_IMAGE_TYPE_CUSTOM) { + WERROR("imageType is Not Custom(%d)", imageType); + err = contacts_list_add(contactRecordList, contactRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_add() Failed(%d) - contact_list", err); + continue; + } + else { + //remove default image. + if(!isfavorite) { + __removeImage(contactRecord,imageRecord); + } + } + } + else { + if(thumbnailPath == NULL) { + WDEBUG("thumbnailPath is NULL"); + } + } + //} + err = contacts_list_add(contactRecordList, contactRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_add() Failed(%d) - contact_list", err); + } + count++; + updateFavorite = true; + } + __checkedData->clear(); + } + + if(__doActionThread){ + __doActionThread->destroy(); + __doActionThread = NULL; + } + __doActionThread = new CtThread(__onDoFavouritesThreadRunCb, contactRecordList, __onDoFavouritesThreadEndCb, this); + __doActionThread->start(); + + WDEBUG("updateFavorite %d updateMfc %d", updateFavorite, updateMfc); + if(updateMfc && false == updateFavorite) { + CtRegistryMgr::getInstance()->setInt(REGISTRY_KEY_MFC_UPDATED, 1); + } +} + +void CtListBasicController:: __onDoFavouritesThreadRunCb(void *data) +{ + WHIT(); + contacts_list_h contactRecordList = (contacts_list_h)data; + + int err = CONTACTS_ERROR_NONE; + + CtRegistryMgr::getInstance()->setInt(REGISTRY_KEY_FAVORITE_UPDATED, 1); + + contacts_connect_on_thread(); + err = contacts_db_update_records(contactRecordList); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_update_records() Failed(%d)", err); + + contacts_list_destroy(contactRecordList, true); + contacts_disconnect_on_thread(); + + WLEAVE(); +} + +void CtListBasicController::__onDoFavouritesThreadEndCb(void *data) +{ + WHIT(); + CtListBasicController * listCtrl = static_cast<CtListBasicController*>(data); + + if (__stopDoAsyncAction) return; + if (listCtrl->__checkedData->empty()){ + if (auto popup = listCtrl->__popupMonitor.lock()) { + popup->destroy(); + } + listCtrl->__listView->setOnProgressOperation(false); + listCtrl->__progressPopup = NULL; + listCtrl->__listView->popOut(); + } + else{ + listCtrl->__doFavoritesContacts(false); + } +} + +void CtListBasicController::__doSetFavoritesOrder() +{ + WENTER(); + + int err = CONTACTS_ERROR_NONE; + + for (auto iter = __listView->__reorderData.begin(); iter != __listView->__reorderData.end(); iter++) { + err = contacts_person_set_favorite_order(iter->personId, iter->prevPersonId, iter->nextPersonId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_person_set_favorite_order() Failed(%d) %d %d %d", err, iter->personId, iter->prevPersonId, iter->nextPersonId); + } + + CtRegistryMgr::getInstance()->setInt(REGISTRY_KEY_FAVORITE_UPDATED, 1); + + __listView->popOut(); + WLEAVE(); +} + +std::string CtListBasicController::__makeCheckedDataPath(int personId) +{ + WENTER(); + contacts_record_h personRecord = NULL; + + std::string vcardPath; + do { + int err = contacts_db_get_record(_contacts_person._uri, personId, &personRecord); + if (err != CONTACTS_ERROR_NONE) { + WDEBUG("contacts_db_get_record FAILED"); + break; + } + + vcardPath = createVcardFile(personRecord); + + if(vcardPath.empty()) { + WDEBUG("createVcardPath FAILED"); + break; + } + + } while(false); + + if (personRecord) { + contacts_record_destroy(personRecord, true); + } + + WLEAVE(); + return vcardPath; +} + +void CtListBasicController::__doShareContacts() +{ + WENTER(); + std::unique_ptr<std::vector<std::shared_ptr<CtListDataPerson>>> checkedData(__listModel->getCheckedDataList()); + int checkedIdCount = checkedData->size(); + WPRET_M(!checkedIdCount, "checked id count is null"); + + std::vector<char *> result; + result.reserve(checkedIdCount); + + for (auto &data : *checkedData) { + char buf[CT_TEXT_SHORT_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%d", data->getPersonId()); + result.push_back(strdup(buf)); + } + + if (launchMultiShareContacts((const char**) result.data(), checkedIdCount) != TIZEN_ERROR_NONE) { + WERROR("launchMultiShareContacts failed"); + } + + for (auto &id : result) { + free(id); + } + + __listView->popOut(); +} + +void CtListBasicController::__doDeleteContacts(void) +{ + WENTER(); + + int checkedIdCount = 0; + + if(__progressPopup == NULL) { + __checkedData.reset(__listModel->getCheckedDataList()); + checkedIdCount = __checkedData->size(); + if ( 0 == checkedIdCount) + return; + std::shared_ptr<CtListDataPerson> personData; + + //delete just only 1 contact for performance + if ( 1 == checkedIdCount) { + int idx = 0; + + __listView->popOut(); + + while(true) { + personData = __listModel->getAtPersonData(idx, LIST_QUERY_DEFAULT); + if(personData == NULL) + break; + if(personData->isChecked()) { + int err = CONTACTS_ERROR_NONE; + int personId = personData->getPersonId(); + CtRegistryMgr::getInstance()->setInt(REGISTRY_KEY_DELETED_PERSON, 1); + CtRegistryMgr::getInstance()->setInt(REGISTRY_KEY_DELETED_PERSON_ID, personId); + err = contacts_db_delete_record(_contacts_person._uri, personId); + WPWARN(err != CONTACTS_ERROR_NONE, "contacts_db_delete_record() fail(%d)",err); + } + idx++; + } + return; + } + + __listView->setOnProgressOperation(true); + __progressPopup = new CtProgressBarPopup(checkedIdCount, V_("IDS_PB_POP_DELETING_CONTACTS_ING"),true); + __progressPopup->addButton(V_("IDS_PB_BUTTON_CANCEL"), [this](bool* destroyPopup)->bool{ + WDEBUG("Cancel"); + __listView->setOnProgressOperation(false); + __canceled = true; + *destroyPopup = true; + return true; + }); + __progressPopup->create(__listView->getViewNaviframe(), NULL); + __popupMonitor = __progressPopup->getWeakPtr(); + } + + if (__canceled) { + WDEBUG("delete is Canceled"); + return; + } + + if(__checkedData->size() > 0){ + __doActionThread = new CtThread(__onDoDeleteThreadRunCb, this, __onDoDeleteThreadEndCb, this); + __doActionThread->start(); + } +} + +void CtListBasicController:: __onDoDeleteThreadRunCb(void *data) +{ + WHIT(); + CtListBasicController * listCtrl = (CtListBasicController*)data; + int err = CONTACTS_ERROR_NONE; + + CtRegistryMgr::getInstance()->setInt(REGISTRY_KEY_DELETED_PERSON, 1); + + for(size_t i = 0; i < listCtrl->__checkedData->size(); ++i) { + err = contacts_db_delete_record(_contacts_person._uri, listCtrl->__checkedData->at(i)->getPersonId()); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_delete_record() Failed(%d)", err); + listCtrl->__progressPopup->setProgressRemainCount(listCtrl->__checkedData->size() - i); + } + + listCtrl->__checkedData->clear(); + WLEAVE(); +} + +void CtListBasicController::__onDoDeleteThreadEndCb(void *data) +{ + WENTER(); + + CtListBasicController * listCtrl = (CtListBasicController*)data; + if (__stopDoAsyncAction) return; + + listCtrl->__listView->setOnProgressOperation(false); + listCtrl->__progressPopup = NULL; + listCtrl->__listView->popOut(); +} + diff --git a/lib-contact/ct-list/src/CtListBasicController.h b/lib-contact/ct-list/src/CtListBasicController.h new file mode 100644 index 0000000..d008987 --- /dev/null +++ b/lib-contact/ct-list/src/CtListBasicController.h @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __CT_LIST_BASIC_CONTROLLER_H_ +#define __CT_LIST_BASIC_CONTROLLER_H_ + +#include "WPopup.h" +#include "ContactsCommon.h" +#include "CtType.h" +#include "CtListController.h" +#include "CtProgressBarPopup.h" +#include "CtListDataPerson.h" + +namespace std { +class thread; +} + +class CtThread; +class CtListView; +class CtListModelDb; +class CtListModelMergeContacts; +class CtProgressController; +class CtListBasicController : public CtListController +{ +public: + CtListBasicController(CtListCtrlType ctrlType, CtListView *listView, CtListModelDb* listModel); + CtListBasicController(); + virtual ~CtListBasicController(); + +public: + virtual void onListUpdated() {}; + virtual void onSelectItem(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState); + virtual void onSelectCreate(void *data, Evas_Object *obj, void *event_info); + virtual void onSelectDone(void *data, Evas_Object *obj, void *event_info); + virtual void onSelectBack(void *data, Evas_Object *obj, void *event_info); + virtual void onSelectCancel(void *data, Evas_Object *obj, void *event_info); + virtual void onSwipeLeftItem(void *data, Evas_Object *obj, void *event_info); + virtual void onSwipeRightItem(void *data, Evas_Object *obj, void *event_info); + virtual void onSelectCheckAll(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState); + virtual void moreManageFavoritesItemOperation(); + virtual void onSelectMenu(CtListView *view); + +private: + int __setImage(contacts_record_h record, char *image); + int __removeImage(contacts_record_h contactRecord, contacts_record_h imageRecord); + bool __setFavoriteImage(int personId, bool set, contacts_record_h contact_record); + void __doDeleteContacts(void); + void __doShareContacts(); + void __doFavoritesContacts(bool addFirstOne); + bool __getHasReadOnlyMode(char* addressbookIDs); + void __doSetFavoritesOrder(); + + std::string __makeCheckedDataPath(int personId); + +private: + static void __onAddFavoritesSelCb(void *data, Evas_Object *obj, void *event_info); + static void __onRemoveFavoritesSelCb(void *data, Evas_Object *obj, void *event_info); + static void __onReorderFavoritesSelCb(void *data, Evas_Object *obj, void *event_info); + static void __onPreferenceChangedCb(const char *key, void *data); + + //for check for data + bool __changeCheckState(Elm_Object_Item *item, bool checkState); + static bool __getCheckState(Elm_Object_Item *item); + + + static void __onDoFavouritesThreadRunCb(void *data); + static void __onDoFavouritesThreadEndCb(void *data); + static void __onDoDeleteThreadRunCb(void *data); + static void __onDoDeleteThreadEndCb(void* data); + + +private: + CtListView* __listView; + CtListModelDb* __listModel; + CtListCtrlType __ctrlType; + static bool __stopDoAsyncAction; + CtThread *__doActionThread; + + std::unique_ptr<std::vector<std::shared_ptr<CtListDataPerson>>> __checkedData; + + CtProgressBarPopup* __progressPopup; + WUiObjectPtr __popupMonitor; + + int __updateDataType; + bool __canceled; + void* __settingDllHandle; + void* __detailDllHandle; + void* __cmDllHandle; +}; + +#endif //__CT_LIST_BASIC_CONTROLLER_H_ + diff --git a/lib-contact/ct-list/src/CtListDataGroup.cpp b/lib-contact/ct-list/src/CtListDataGroup.cpp new file mode 100755 index 0000000..4af1311 --- /dev/null +++ b/lib-contact/ct-list/src/CtListDataGroup.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <string.h> +#include "CtListDataGroup.h" +#include "ContactsDebug.h" +#include "CtString.h" + +using namespace std; + +CtListDataGroup::CtListDataGroup(contacts_record_h record) +{ + __initialize(); + __setDataFromRecord(record); +} + +CtListDataGroup::CtListDataGroup() +{ +} + +CtListDataGroup::~CtListDataGroup() +{ + if (__name) free(__name); +} + +const char* CtListDataGroup::getName(void) +{ + if (SAFE_STRCMP(__name, "System Group: My Contacts") == 0) { + if (__name) free(__name); + __name = strdup(V_("IDS_PB_BODY_MY_CONTACTS")); + } + else if (SAFE_STRCMP(__name, "System Group: Friends") == 0) { + if (__name) free(__name); + __name = strdup(V_("IDS_PB_BODY_DEFAULT_GROUP_FRIENDS")); + } + else if (SAFE_STRCMP(__name, "System Group: Family") == 0) { + if (__name) free(__name); + __name = strdup(V_("IDS_PB_BODY_DEFAULT_GROUP_FAMILY")); + } + else if (SAFE_STRCMP(__name, "System Group: Coworkers") == 0) { + if (__name) free(__name); + __name = strdup(V_("IDS_PB_BODY_CO_WORKERS")); + } + + return __name; +} + +void CtListDataGroup::__initialize(void) +{ + __name = NULL; +} + +void CtListDataGroup::__setDataFromRecord(contacts_record_h record) +{ + int err = CONTACTS_ERROR_NONE; + const char* uri = NULL; + + contacts_record_get_uri_p(record, &uri); + + if(strcmp(uri, _contacts_group_relation._uri) != 0) { + WERROR("INVALID uri!!! uri is not _contacts_group._uri !!!"); + } + + err = contacts_record_get_str(record, _contacts_group_relation.name, &__name); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); +} diff --git a/lib-contact/ct-list/src/CtListDataGroup.h b/lib-contact/ct-list/src/CtListDataGroup.h new file mode 100644 index 0000000..b26ac2e --- /dev/null +++ b/lib-contact/ct-list/src/CtListDataGroup.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __CT_LIST_DATA_GROUP_H_ +#define __CT_LIST_DATA_GROUP_H_ + +#include <contacts.h> +#include <vector> + +class CtListDataGroup +{ +public: + CtListDataGroup(contacts_record_h record); + virtual ~CtListDataGroup(); + +public: + const char* getName(void); + +private: + CtListDataGroup(); + +private: + void __initialize(void); + void __setDataFromRecord(contacts_record_h record); + +private: + char* __name; +}; + +#endif diff --git a/lib-contact/ct-list/src/CtListDataPerson.cpp b/lib-contact/ct-list/src/CtListDataPerson.cpp new file mode 100755 index 0000000..d6d45c2 --- /dev/null +++ b/lib-contact/ct-list/src/CtListDataPerson.cpp @@ -0,0 +1,452 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <string.h> +#include "CtListDataPerson.h" +#include "ContactsDebug.h" +#include "CtCommon.h" +#include "CtType.h" + +using namespace std; + + +CtListDataPerson::CtListDataPerson(contacts_record_h record) +{ + __initialize(); + __setPersonRecord(record); +} + +CtListDataPerson::~CtListDataPerson() +{ + free(__displayName); + free(__displayIndex); + free(__imagePath); + free(__dataString); + contacts_record_destroy(__person, true); +} + +CtListDataPerson* CtListDataPerson::makeClone() +{ + WHIT(); + CtListDataPerson *dataPerson = new CtListDataPerson(__person); + dataPerson->setAsChecked(__checked); + + dataPerson->setDataString(__dataString); + dataPerson->setDataType(__dataType); + dataPerson->setDataId(__dataId); + + return dataPerson; +} + +contacts_record_h CtListDataPerson::getPersonRecord() +{ + return __person; +} + +const char* CtListDataPerson::getDisplayName() +{ + return __displayName; +} + +const char* CtListDataPerson::getDisplayIndex() +{ + return __displayIndex; +} + +const char* CtListDataPerson::getImagePath() +{ + return __imagePath; +} + +void CtListDataPerson::setImagePath(const char *imagePath) +{ + FREEandSTRDUP(__imagePath, imagePath); +} + +int CtListDataPerson::getPersonId() +{ + return __personId; +} + +int CtListDataPerson::getLinkedCount() +{ + return __linkedCount; +} + +bool CtListDataPerson::getFavorite() +{ + return __favorite; +} + +bool isMFC() +{ + return false; +} + +void CtListDataPerson::__initialize() +{ + __displayName = NULL; + __displayIndex = NULL; + __personId = 0; + __person = NULL; + __linkedCount = 1; + __imagePath = NULL; + __addressbookId = 0; + __checked = false; + __dataString = NULL; + __dataType = 0; + __dataId = 0; + __favorite = false; + +} + +void CtListDataPerson::__setPersonRecord(contacts_record_h record) +{ + //WHIT(); + int err = CONTACTS_ERROR_NONE; + const char* uri = NULL; + contacts_record_get_uri_p(record, &uri); + + err = contacts_record_clone(record, &__person); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_clone() Failed(%d)", err); + + if(strcmp(uri, _contacts_contact._uri) == 0) { + err = contacts_record_get_str(record, _contacts_contact.display_name, &__displayName); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + err = contacts_record_get_str(record, _contacts_contact.image_thumbnail_path, &__imagePath); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + err = contacts_record_get_int(record, _contacts_contact.address_book_id, &__addressbookId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + + err = contacts_record_get_bool(record, _contacts_contact.is_favorite, &__favorite); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + + } + else if(strcmp(uri, _contacts_person_number._uri) == 0){ + err = contacts_record_get_str(record, _contacts_person_number.display_name,&__displayName); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + err = contacts_record_get_int(record, _contacts_person_number.person_id, &__personId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + + err = contacts_record_get_str(record, _contacts_person_number.display_name_index, &__displayIndex); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + err = contacts_record_get_str(record, _contacts_person_number.image_thumbnail_path, &__imagePath); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + } + else if(strcmp(uri, _contacts_person_email._uri) == 0){ + err = contacts_record_get_str(record, _contacts_person_email.display_name,&__displayName); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + err = contacts_record_get_int(record, _contacts_person_email.person_id, &__personId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + + err = contacts_record_get_str(record, _contacts_person_email.display_name_index, &__displayIndex); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + err = contacts_record_get_str(record, _contacts_person_email.image_thumbnail_path, &__imagePath); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + } + else if(strcmp(uri, _contacts_person._uri) == 0){ + char* tmpStr = NULL; + err = contacts_record_get_str(record, _contacts_person.display_name,&__displayName); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + err = contacts_record_get_int(record, _contacts_person.id, &__personId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + + err = contacts_record_get_str(record, _contacts_person.display_name_index, &__displayIndex); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + err = contacts_record_get_str(record, _contacts_person.image_thumbnail_path, &__imagePath); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + err = contacts_record_get_str(record, _contacts_person.addressbook_ids, &tmpStr); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + err = contacts_record_get_bool(record, _contacts_person.is_favorite, &__favorite); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + + if(tmpStr) { + int linkCount = 0; + char* ptr = NULL; + char* token = strtok_r(tmpStr, " ", &ptr); + while (token) + { + linkCount++; + if(linkCount == 1) + __addressbookId = atoi(token); + + token = strtok_r(NULL, " ", &ptr); + } + __linkedCount = linkCount; + free(tmpStr); + } + } + else if(strcmp(uri, _contacts_person_contact._uri) == 0){ + char* tmpStr = NULL; + err = contacts_record_get_str(record, _contacts_person_contact.display_name,&__displayName); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + err = contacts_record_get_int(record, _contacts_person_contact.person_id, &__personId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + + err = contacts_record_get_str(record, _contacts_person_contact.display_name_index, &__displayIndex); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + err = contacts_record_get_str(record, _contacts_person_contact.image_thumbnail_path, &__imagePath); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + err = contacts_record_get_str(record, _contacts_person_contact.addressbook_ids, &tmpStr); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + err = contacts_record_get_bool(record, _contacts_person_contact.is_favorite, &__favorite); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + + if(tmpStr) { + int linkCount = 0; + char* ptr = NULL; + char* token = strtok_r(tmpStr, " ", &ptr); + while (token) + { + linkCount++; + if(linkCount == 1) + __addressbookId = atoi(token); + + token = strtok_r(NULL, " ", &ptr); + } + __linkedCount = linkCount; + free(tmpStr); + } + } + else if(strcmp(uri, _contacts_person_usage._uri) == 0){ + err = contacts_record_get_str(record, _contacts_person_usage.display_name,&__displayName); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + err = contacts_record_get_int(record, _contacts_person_usage.person_id, &__personId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + + err = contacts_record_get_str(record, _contacts_person_usage.image_thumbnail_path, &__imagePath); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + } + else if (strcmp(uri, _contacts_person_grouprel._uri) == 0) { + err = contacts_record_get_str(record, _contacts_person_grouprel.display_name,&__displayName); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + err = contacts_record_get_int(record, _contacts_person_grouprel.person_id, &__personId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + + err = contacts_record_get_str(record, _contacts_person_grouprel.image_thumbnail_path, &__imagePath); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + } + + ctCommonRemoveNewline(__displayName); +} + +bool CtListDataPerson::isChecked() +{ + return __checked; +} + +void CtListDataPerson::setAsChecked(bool checked) +{ + __checked = checked; +} + +Eina_List* CtListDataPerson::getNumberList() +{ + if (__personId == 0) return NULL; // vcard + + return __getDataList(__personId, _contacts_person_number._uri); +} + +Eina_List* CtListDataPerson::getEmailList() +{ + if (__personId == 0) return NULL; // vcard + + return __getDataList(__personId, _contacts_person_email._uri); +} + + +const char* CtListDataPerson::getDataString() +{ + return __dataString; +} + +int CtListDataPerson::getDataType() +{ + return __dataType; +} + +int CtListDataPerson::getDataId() +{ + return __dataId; +} + +int CtListDataPerson::getAddressbookId() +{ + return __addressbookId; +} + +void CtListDataPerson::setDataString(const char *data) +{ + __dataString = SAFE_STRDUP(data); +} + +void CtListDataPerson::setDataType(int dataType) +{ + __dataType = dataType; +} + +void CtListDataPerson::setDataId(int dataId) +{ + __dataId = dataId; +} + +bool CtListDataPerson::getSearchNumber(const char *searchStr, std::string &numberStr) +{ + std::string search = searchStr; + bool result = false; + + if(search != __searchStr) { + __searchStr = searchStr; + + char* number = NULL; + int err = CONTACTS_ERROR_NONE; + contacts_list_h list = NULL; + contacts_record_h record = NULL; + contacts_query_h query = NULL; + contacts_filter_h filter = NULL; + contacts_filter_h filter2 = NULL; + + err = contacts_query_create(_contacts_person_number._uri, &query); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_create Failed(%d)", err); + err = contacts_filter_create(_contacts_person_number._uri, &filter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create Failed(%d)", err); + err = contacts_filter_create(_contacts_person_number._uri, &filter2); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create Failed(%d)", err); + err = contacts_filter_add_int(filter, _contacts_person_number.person_id, CONTACTS_MATCH_EQUAL, getPersonId()); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_int Failed(%d)", err); + err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_operator Failed(%d)", err); + err = contacts_filter_add_str(filter2, _contacts_person_number.normalized_number, CONTACTS_MATCH_CONTAINS, __searchStr.c_str()); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_str Failed(%d)", err); + err = contacts_filter_add_filter(filter, filter2); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_filter Failed(%d)", err); + err = contacts_query_set_filter(query, filter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_filter Failed(%d)", err); + err = contacts_db_get_records_with_query(query, 0, 0, &list); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_records_with_query Failed(%d)", err); + + contacts_query_destroy(query); + contacts_filter_destroy(filter); + contacts_filter_destroy(filter2); + if (CONTACTS_ERROR_NONE == contacts_list_get_current_record_p(list, &record)) { + err = contacts_record_get_str_p(record, _contacts_person_number.number, &number); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p Failed(%d)", err); + } + if(SAFE_STRLEN(number) > 0) { + numberStr = number; + __searchNumber = number; + result = true; + } + else { + __searchNumber.clear(); + } + + contacts_list_destroy(list, true); + } + else { + if(__searchNumber.length() > 0) { + numberStr = __searchNumber; + result = true; + } + } + + return result; + + +} + +Eina_List* CtListDataPerson::__getDataList(int personId, const char* viewUri) +{ + WHIT(); + int err = CONTACTS_ERROR_NONE; + contacts_record_h record = NULL; + contacts_record_h recordClone = NULL; + contacts_list_h list = NULL; + Eina_List *result = NULL; + contacts_filter_h filter = NULL; + contacts_query_h query = NULL; + + err = contacts_filter_create(viewUri, &filter); + WPWARN(CONTACTS_ERROR_NONE != err, "contactcs_filter_create() Failed(%d)", err); + + if(strcmp(viewUri, _contacts_person_number._uri) == 0) + err = contacts_filter_add_int(filter, _contacts_person_number.person_id, CONTACTS_MATCH_EQUAL, personId); + else if(strcmp(viewUri, _contacts_person_email._uri) == 0) + err = contacts_filter_add_int(filter, _contacts_person_email.person_id, CONTACTS_MATCH_EQUAL, personId); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_filter_add_int() Failed(%d)", err); + contacts_filter_destroy(filter); + return NULL; + } + err = contacts_query_create(viewUri, &query); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_query_create() Failed(%d)", err); + contacts_filter_destroy(filter); + return NULL; + } + err = contacts_query_set_filter(query, filter); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_query_set_filter() Failed(%d)", err); + contacts_filter_destroy(filter); + contacts_query_destroy(query); + return NULL; + } + err = contacts_db_get_records_with_query(query, 0, 0, &list); + if(CONTACTS_ERROR_NONE != err) { + WERROR("contacts_db_get_records_with_query() Failed(%d)", err); + if(list) + contacts_list_destroy(list, true); + contacts_filter_destroy(filter); + contacts_query_destroy(query); + return NULL; + } + + contacts_filter_destroy(filter); + contacts_query_destroy(query); + + while (CONTACTS_ERROR_NONE == contacts_list_get_current_record_p(list, &record)) { + err = contacts_record_clone(record, &recordClone); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_clone() Failed(%d)", err); + break; + } + result = eina_list_append(result, recordClone); + contacts_list_next(list); + } + contacts_list_destroy(list, true); + return result; +} + diff --git a/lib-contact/ct-list/src/CtListDataPerson.h b/lib-contact/ct-list/src/CtListDataPerson.h new file mode 100644 index 0000000..34da339 --- /dev/null +++ b/lib-contact/ct-list/src/CtListDataPerson.h @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __CT_LIST_DATA_PERSON_H_ +#define __CT_LIST_DATA_PERSON_H_ + +#include <Eina.h> +#include <string> +#include <contacts.h> + + +typedef enum { + CT_LIST_DATA_VCARD = 1 << 0, + CT_LIST_DATA_PERSON = 1 << 1, + CT_LIST_DATA_NUMBER = 1 << 2, + CT_LIST_DATA_EMAIL = 1 << 3, + CT_LIST_DATA_ALL = CT_LIST_DATA_NUMBER | CT_LIST_DATA_EMAIL, +}CtListItemDataType; + +class CtListDataPerson +{ +public: + CtListDataPerson(contacts_record_h record); + virtual ~CtListDataPerson(); + +public: +//getter + CtListDataPerson* makeClone(); + contacts_record_h getPersonRecord(); + const char* getDisplayName(); + const char* getImagePath(); + void setImagePath(const char *imagePath); + int getPersonId(); + int getLinkedCount(); + const char* getDisplayIndex(); + bool isChecked(); + void setAsChecked(bool checked); + // for ug + Eina_List* getNumberList(); + Eina_List* getEmailList(); + const char* getDataString(); + int getDataType(); + int getDataId(); + void setDataString(const char *data); + void setDataType(int dataType); + void setDataId(int dataId); + int getAddressbookId(); + + bool getFavorite(); + bool getSearchNumber(const char *searchStr, std::string &numberStr); + +private: + void __initialize(); + void __setPersonRecord(contacts_record_h record); + Eina_List* __getDataList(int personId, const char* viewUri); + //bool __checkMFC(int personId); +private: + contacts_record_h __person; + char* __displayName; + char* __imagePath; + char* __displayIndex; + bool __favorite; + int __personId; + int __addressbookId; + + std::string __searchStr; + std::string __searchNumber; + + + // TODO: review required + bool __checked; + // for ug + char *__dataString; + int __dataType; + int __dataId; + int __linkedCount; + +}; + +#endif diff --git a/lib-contact/ct-list/src/CtListLinkContactController.cpp b/lib-contact/ct-list/src/CtListLinkContactController.cpp new file mode 100644 index 0000000..d5a29d5 --- /dev/null +++ b/lib-contact/ct-list/src/CtListLinkContactController.cpp @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <vector> +#include <thread> +#include <Elementary.h> +#include <app.h> +#include <contacts.h> + +#include "WView.h" +#include "WNaviframe.h" +#include "WPopup.h" + +#include "ContactsDebug.h" +#include "CtType.h" +#include "CtListDataPerson.h" +#include "CtCommon.h" +#include "CtListView.h" +#include "CtListModelDb.h" +#include "CtProgressBarPopup.h" +#include "CtListLinkContactController.h" + +CtListLinkContactController::CtListLinkContactController(CtListView *listView, CtListModelDb* listData) +: __listView(listView) +, __listModel(listData) +, __checkedItemCount(0) +, __basePersonId(0) +{ + +} + +CtListLinkContactController::~CtListLinkContactController() +{ + WHIT(); +} + +void CtListLinkContactController::onSelectItem(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState) +{ + Elm_Object_Item *item = selectedItem; + elm_genlist_item_selected_set(item, EINA_FALSE); + + Elm_Genlist_Item_Type item_type = elm_genlist_item_type_get(item); + if(item_type == ELM_GENLIST_ITEM_GROUP) { + return; + } + + Evas_Object* layout = elm_object_item_part_content_get(item,"elm.icon.2"); + Evas_Object* check = elm_layout_content_get(layout, "elm.swallow.content"); + + CtListView::CtListDataItem* itemData = static_cast<CtListView::CtListDataItem*>(elm_object_item_data_get(item)); + WPRET_M(itemData == NULL, "itemData is null"); + + if(checkState == CHECK_ON) { + itemData->personData->setAsChecked(true); + elm_check_state_set(check, true); + __checkedItemCount++; + } + else if(checkState == CHECK_OFF) { + itemData->personData->setAsChecked(false); + elm_check_state_set(check, false); + __checkedItemCount--; + } + + Elm_Object_Item *naviItem = elm_naviframe_top_item_get(__listView->getViewNaviframe()); + Evas_Object *btn = elm_object_item_part_content_get(naviItem, "title_right_btn"); + if(__checkedItemCount > 0) + elm_object_disabled_set(btn, EINA_FALSE); + else + elm_object_disabled_set(btn, EINA_TRUE); + + char buf[CT_TEXT_SHORT_LEN] = {0,}; + snprintf(buf, sizeof(buf), ctGetContactsString("IDS_PB_HEADER_PD_SELECTED_ABB3"), __checkedItemCount); + elm_object_item_part_text_set(naviItem, "elm.text.title", buf ); + + WHIT(); +} + +void CtListLinkContactController::onSelectCheckAll(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState) +{ +} + +void CtListLinkContactController::onSelectDone(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + + int err = CONTACTS_ERROR_NONE; + std::vector<std::shared_ptr<CtListDataPerson>>* checkedList = __listModel->getCheckedDataList(); + for (auto iter = checkedList->begin(); iter != checkedList->end(); iter++) { + WDEBUG("Link %d to %d", (*iter)->getPersonId(), __basePersonId); + err = contacts_person_link_person(__basePersonId, (*iter)->getPersonId()); + WPWARN(err != CONTACTS_ERROR_NONE, "contacts_person_link_person() fail(%d)",err); + } + + delete checkedList; + + __listView->popOut(); +} + +void CtListLinkContactController::onSelectCancel(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + __listView->popOut(); +} + +void CtListLinkContactController::onSelectBack(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); +} + +void CtListLinkContactController::onSwipeLeftItem(void *data, Evas_Object *obj, void *event_info) +{ + // empty +} + +void CtListLinkContactController::onSwipeRightItem(void *data, Evas_Object *obj, void *event_info) +{ + // empty +} + +void CtListLinkContactController::moreManageFavoritesItemOperation() +{ + // empty +} diff --git a/lib-contact/ct-list/src/CtListLinkContactController.h b/lib-contact/ct-list/src/CtListLinkContactController.h new file mode 100644 index 0000000..3f86043 --- /dev/null +++ b/lib-contact/ct-list/src/CtListLinkContactController.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __CT_LIST_LINK_CONTACT_CONTROLLER_H_ +#define __CT_LIST_LINK_CONTACT_CONTROLLER_H_ + +#include <string> +#include <app.h> +#include "WPopup.h" + +#include "ContactsCommon.h" +#include "CtListView.h" +#include "CtType.h" +#include "CtListController.h" + + + +class CtListView; +class CtListModelDb; +class CtListLinkContactController : public CtListController +{ +public: + CtListLinkContactController(CtListView *listView, CtListModelDb* listData); + virtual ~CtListLinkContactController(); + +public: + virtual void onListUpdated() {}; + virtual void onSelectItem(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState); + virtual void onSelectDone(void *data, Evas_Object *obj, void *event_info); + virtual void onSelectCancel(void *data, Evas_Object *obj, void *event_info); + virtual void onSelectBack(void *data, Evas_Object *obj, void *event_info); + virtual void onSwipeLeftItem(void *data, Evas_Object *obj, void *event_info); + virtual void onSwipeRightItem(void *data, Evas_Object *obj, void *event_info); + virtual void onSelectCheckAll(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState); + virtual void moreManageFavoritesItemOperation(); + virtual void onSelectMenu(CtListView *view) {} + +private: + CtListLinkContactController(); + +private: + CtListView* __listView; + CtListModelDb* __listModel; + int __checkedItemCount; + int __basePersonId; +}; + +#endif //__CT_LIST_LINK_CONTACT_CONTROLLER_H_ + diff --git a/lib-contact/ct-list/src/CtListLoadingPopup.cpp b/lib-contact/ct-list/src/CtListLoadingPopup.cpp new file mode 100644 index 0000000..937f647 --- /dev/null +++ b/lib-contact/ct-list/src/CtListLoadingPopup.cpp @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +//#include <efl_assist.h> +#include "WControl.h" +#include "ContactsDebug.h" +#include "ContactsCommon.h" +#include "CtListLoadingPopup.h" +#include "CtPath.h" +#include "CtString.h" +#include "CtThemeMgr.h" + +#define __ITEM_HEIGHT 96 + + +CtListLoadingPopup::CtListLoadingPopup() +{ + +} + +const char* CtListLoadingPopup::getClassName() +{ + return "CtListLoadingPopup"; +} + +Evas_Object* CtListLoadingPopup::__createContent(Evas_Object *parent) +{ + WHIT(); + + std::string contactsEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + Evas_Object *layout = elm_layout_add(parent); + CtThemeMgr::getInstance()->setObjectTheme(layout); + elm_layout_file_set(layout, contactsEdjePath.c_str(), "processing_view"); + + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + // TODO: use string id for Progressing + elm_object_part_text_set(layout, "elm.text", "Progressing..."); +// elm_object_domain_translatable_part_text_set(layout, "elm.text", t_title_text.domain, t_title_text.id); + + Evas_Object *progress = elm_progressbar_add(layout); + elm_object_style_set(progress, "process_small"); + elm_progressbar_pulse_set(progress, EINA_TRUE); + elm_progressbar_pulse(progress, EINA_TRUE); + evas_object_show(progress); + + evas_object_size_hint_align_set(progress, EVAS_HINT_FILL, 0.5); + evas_object_size_hint_weight_set(progress, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_part_content_set(layout, "processing", progress); + elm_object_content_set(parent, layout); + + return layout; +} + +Evas_Object* CtListLoadingPopup::onCreate( Evas_Object* parent, void* viewParam) +{ + WHIT(); + + setContent([this](Evas_Object* parent)->Evas_Object* { + return __createContent(parent); + }); + + return WPopup::onCreate(parent, viewParam); +} + +void CtListLoadingPopup::onDestroy() +{ + +} + +CtListLoadingPopup::~CtListLoadingPopup() +{ + +} diff --git a/lib-contact/ct-list/src/CtListLoadingPopup.h b/lib-contact/ct-list/src/CtListLoadingPopup.h new file mode 100644 index 0000000..29bb1bc --- /dev/null +++ b/lib-contact/ct-list/src/CtListLoadingPopup.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_LIST_LOADING_POPUP_H_ +#define _CT_LIST_LOADING_POPUP_H_ + +#include <string> +#include <vector> +#include <functional> +#include "WPopup.h" + +class CtListLoadingPopup : public WPopup +{ +public: + CtListLoadingPopup(); + const char* getClassName(); + +private: + virtual Evas_Object* onCreate( Evas_Object* parent, void* viewParam); + virtual void onDestroy(); + + Evas_Object* __createContent(Evas_Object *parent); + +private: + virtual ~CtListLoadingPopup(); +}; + +#endif //_CT_LIST_LOADING_POPUP_H_ diff --git a/lib-contact/ct-list/src/CtListModel.h b/lib-contact/ct-list/src/CtListModel.h new file mode 100755 index 0000000..ca9176e --- /dev/null +++ b/lib-contact/ct-list/src/CtListModel.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __CT_LIST_MODEL_H_ +#define __CT_LIST_MODEL_H_ + +#include <vector> +#include <memory> +#include "CtListDataPerson.h" +#include "ICtChangeListener.h" + +typedef enum { + GET_AS_SYNC, + GET_AS_ASYNC, + GET_AS_SYNC_ASYNC, +}CtGetContactsType; + + +class CtListModel +{ +public: + virtual ~CtListModel(){}; + +public: + virtual int getContactsCount(CtListQueryType queryType) = 0; //get contacts count from db + virtual int getContacts(CtListQueryType queryType, CtGetContactsType syncType) = 0; + virtual int cancelGetContacts() = 0; + virtual std::shared_ptr<CtListDataPerson> getAtPersonData(int index, CtListQueryType queryType) = 0; + virtual int getPersonListCount(CtListQueryType queryType) = 0; //get contacts count from list + virtual bool getMadePersonListStatus() {return true;}//get status of whether personlist has been updated from DB + virtual void attachListener(ICtChangeListener* listener) = 0; + + virtual void setSelectedPersonId(int selectedPersonId) = 0; + virtual const char* getSearchString(void) = 0; + virtual bool setSearchString(char* search) = 0; + virtual int getCheckedDataCount()= 0; + virtual void getNumberSearchString(const std::shared_ptr<CtListDataPerson>& dataPerson, std::string &numberStr) = 0; + + virtual void initialOriginalCheckedIdList() = 0; + virtual void clearOriginalCheckedIdList() = 0; + virtual bool checkIsSelectAllOnSearching() = 0; + virtual void initialOriginalPersonDataListSize() = 0; + virtual void clearOriginalPersonDataListSize() = 0; + virtual int getOriginalPersonDataListSize() = 0; + virtual int getLimitCount() = 0; + virtual int getCurrentLinkedCount() = 0; +}; + +#endif diff --git a/lib-contact/ct-list/src/CtListModelDb.cpp b/lib-contact/ct-list/src/CtListModelDb.cpp new file mode 100755 index 0000000..2ba6348 --- /dev/null +++ b/lib-contact/ct-list/src/CtListModelDb.cpp @@ -0,0 +1,1222 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <contacts.h> +#include <app_preference.h> +#include <algorithm> +//#include <contacts_product.h> + +#include "ContactsDebug.h" +#include "CtListModelDb.h" +#include "CtListDataPerson.h" +#include "ContactsCommon.h" +#include "CtCommon.h" +#include "CtListModelFilter.h" + +#define MAX_MFC_LIST 5 + +CtListModelDb::CtListModelDb(CtListHasType filterType, int limit) +{ + WENTER(); + __initialize(); + __dataFilter = new CtListModelFilter(filterType); + __dataFilter->attachListener(this); + __limitCount = limit; +} + +CtListModelDb::CtListModelDb(CtListDataType dataType) +{ + WENTER(); + __initialize(); + __dataFilter = new CtListModelFilter(dataType); + __dataFilter->attachListener(this); + __dataType = dataType; //Tdod set dataFilter +} + +CtListModelDb::~CtListModelDb() +{ + WENTER(); + int err = CONTACTS_ERROR_NONE; + + if(__idler) + ecore_idler_del(__idler); + + if(__updateMFCListIdler) + ecore_idler_del(__updateMFCListIdler); + + if(__listThread) + __listThread->destroy(); + + if(__mfcThread) + __mfcThread->destroy(); + + delete __dataFilter; + + if(__listener) { + err = contacts_db_remove_changed_cb( _contacts_person._uri, __onDbChanged ,this); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_remove_changed_cb() Failed(%d)", err); + + err = contacts_db_remove_changed_cb( _contacts_my_profile._uri, __onDbChanged ,this); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_remove_changed_cb() Failed(%d)", err); + + //err = contacts_db_remove_changed_cb( _contacts_person_usage._uri, __onDbChanged ,this); + //WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_remove_changed_cb() Failed(%d)", err); + + err = contacts_db_remove_changed_cb( _contacts_group_relation._uri, __onDbChanged ,this); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_remove_changed_cb() Failed(%d)", err); + + err = contacts_db_remove_changed_cb( _contacts_phone_log._uri, __onDbChanged ,this); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_remove_changed_cb() Failed(%d)", err); + + err = contacts_setting_remove_name_display_order_changed_cb( __onDisplayNameOrderChangedCb ,this); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_setting_remove_name_display_order_changed_cb() Failed(%d)", err); + + err = contacts_setting_remove_name_sorting_order_changed_cb( __onNameSortingOrderChangedCb ,this); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_setting_remove_name_sorting_order_changed_cb() Failed(%d)", err); + } + + __personDataList.clear(); + __checkedDataList.clear(); + __checkedDataListOld.clear(); + __originalCheckedIdList.clear(); + +} + +int CtListModelDb::getContactsCount(CtListQueryType queryType) +{ + int count = 0; + int err = CONTACTS_ERROR_NONE; + contacts_query_h query = __dataFilter->getQuery(queryType); + + if(query) { + err = contacts_db_get_count_with_query(query, &count); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_count_with_query() Failed(%d)", err); + + err = contacts_query_destroy(query); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_destroy() Failed(%d)", err); + } + else{ + err = contacts_db_get_count(_contacts_person._uri, &count); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_count() Failed(%d)", err); + } + + WDEBUG("count %d", count); + + return count; +} + +int CtListModelDb::getContacts(CtListQueryType queryType, CtGetContactsType syncType) +{ + WENTER(); + WDEBUG("queryType %d, syncType %d", queryType, syncType); + + if(queryType == LIST_QUERY_FAVORITE) { + __favoritePersonDataList.clear(); + __getFavoritePersonList(); + } + else if(queryType == LIST_QUERY_MFC) { + WDEBUG("__dataType %d", __dataType); + __mfcPersonDataList.clear(); + __getMfcPersonListFromPreference(); + } + else if(queryType == LIST_QUERY_DEFAULT) { + __personDataList.clear(); + + if(syncType == GET_AS_SYNC_ASYNC){ + __getQueryResult(0, CTLISTDATA_NQUERY_COUNT); + __offset = CTLISTDATA_NQUERY_COUNT; + + if(__listThread) + __listThread->destroy(); + __listThread = NULL; + if(__idler) + ecore_idler_del(__idler); + __idler = ecore_idler_add(__onGetContactsIdlerCb, this); + + WLEAVE(); + return getPersonListCount(LIST_QUERY_DEFAULT); + } + else if(syncType == GET_AS_SYNC){ + __getQueryResult(0, -1); + + WLEAVE(); + return getPersonListCount(LIST_QUERY_DEFAULT); + } + else if(syncType == GET_AS_ASYNC){ + __offset = 0; + if(__listThread) + __listThread->destroy(); + __listThread = NULL; + if(__idler) + ecore_idler_del(__idler); + __idler = NULL; + + __listThread = new CtThread(__onGetContactsThreadRunCb, this, __onGetContactsEndCb, this); + __listThread->start(); + } + } + else + WERROR("no queryType"); + + WLEAVE(); + return 0; +} + +int CtListModelDb::cancelGetContacts() +{ + WENTER(); + + if(__listThread) + __listThread->destroy(); + __listThread = NULL; + if(__idler) + ecore_idler_del(__idler); + __idler = NULL; + + return 0; + WLEAVE(); +} + + +std::shared_ptr<CtListDataPerson> CtListModelDb::getAtPersonData(int index, CtListQueryType queryType) +{ + if(queryType == LIST_QUERY_DEFAULT) { + if(index < (int)__personDataList.size()) + return __personDataList[index].second; + else + return NULL; + } + else if(queryType == LIST_QUERY_MFC) { + if(index < (int)__mfcPersonDataList.size()) + return __mfcPersonDataList[index].second; + else + return NULL; + } + else if(queryType == LIST_QUERY_FAVORITE) { + if(index < (int)__favoritePersonDataList.size()) + return __favoritePersonDataList[index].second; + else + return NULL; + } + else + return NULL; +} + +int CtListModelDb::getPersonListCount(CtListQueryType queryType) +{ + int count = 0; + if(queryType == LIST_QUERY_DEFAULT) + count = (int)__personDataList.size(); + else if(queryType == LIST_QUERY_MFC) + count = (int)__mfcPersonDataList.size(); + else if(queryType == LIST_QUERY_FAVORITE) + count = (int)__favoritePersonDataList.size(); + + WDEBUG("count %d", count); + + return count; +} + +void CtListModelDb::setSelectedPersonId(int selectedPersonId) +{ + __selectedPersonId = selectedPersonId; +} + +bool CtListModelDb::setSearchString(char* search) +{ + WENTER(); + + if(SAFE_STRLEN(search)> 0){ + __search = search; + } + else{ + __search.clear(); + } + + return true; +} + +const char* CtListModelDb::getSearchString(void) +{ + if(__search.length() >0) + return __search.c_str(); + else + return NULL; +} + +void CtListModelDb::getNumberSearchString(const std::shared_ptr<CtListDataPerson>& dataPerson, std::string &numberStr) +{ + char* pos = NULL; + + if (__search.length() <= 0) + return; + + if (ctCommonCheckDirtyPhoneNumber(__search) == false) + return; + + if (dataPerson->getDisplayName()) + pos = strcasestr( (char*)dataPerson->getDisplayName(), __search.c_str()); + + WDEBUG("pos : %x",pos); + if (pos == NULL) { + dataPerson->getSearchNumber(__search.c_str(), numberStr); + } + +} + +int CtListModelDb::getCheckedDataCount() +{ + WENTER(); + return __checkedDataList.size(); +} + +void CtListModelDb::onFilterChanged() +{ + WHIT(); + if (__listener) + __listener->onDbChanged(NULL); +} + +void CtListModelDb::attachListener(ICtChangeListener* listener) +{ + WENTER(); + int err = CONTACTS_ERROR_NONE; + err = contacts_db_add_changed_cb( _contacts_person._uri, __onDbChanged ,this); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_add_changed_cb() _contacts_person Failed(%d)", err); + + err = contacts_db_add_changed_cb( _contacts_my_profile._uri, __onDbChanged ,this); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_add_changed_cb() _contacts_person Failed(%d)", err); + + //err = contacts_db_add_changed_cb( _contacts_person_usage._uri, __onDbChanged ,this); + //WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_add_changed_cb() _contacts_person_usage Failed(%d)", err); + + err = contacts_db_add_changed_cb( _contacts_group_relation._uri, __onDbChanged ,this); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_add_changed_cb() _contacts_group Failed(%d)", err); + + err = contacts_db_add_changed_cb( _contacts_phone_log._uri, __onDbChanged ,this); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_add_changed_cb() _contacts_person Failed(%d)", err); + + err = contacts_setting_add_name_display_order_changed_cb(__onDisplayNameOrderChangedCb, this); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_setting_add_name_display_order_changed_cb() Failed(%d)", err); + + err = contacts_setting_add_name_sorting_order_changed_cb( __onNameSortingOrderChangedCb ,this); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_setting_add_name_sorting_order_changed_cb() Failed(%d)", err); + + __listener = listener; + + WLEAVE(); +} + +void CtListModelDb::pushCheckedData(std::shared_ptr<CtListDataPerson> dataPerson) +{ + __setAsCheck(dataPerson, true, false); +} + +void CtListModelDb::removeCheckedData(std::shared_ptr<CtListDataPerson> dataPerson) +{ + __setAsCheck(dataPerson, false, false); +} + +void CtListModelDb::doCheckedDataNoRelation(std::shared_ptr<CtListDataPerson> dataPerson, bool check) +{ + __setAsCheck(dataPerson, check, true); +} + +std::vector<std::shared_ptr<CtListDataPerson>>* CtListModelDb::getCheckedDataList() const +{ + std::vector<std::shared_ptr<CtListDataPerson>>* checkedDataList(new std::vector<std::shared_ptr<CtListDataPerson>>); + for (auto iter = __checkedDataList.begin(); iter != __checkedDataList.end(); iter++) + { + checkedDataList->push_back((*iter).second); + } + + return checkedDataList; +} + +void CtListModelDb::setDisplayAddressbook(int addressbookId, bool display) +{ + WHIT(); + __dataFilter->setDisplayAddressbook(addressbookId, display); + +} + +std::map<int, CtAddressbookInfo*>& CtListModelDb::getAddressbookList() +{ + return __dataFilter->getAddressbookList(); +} + +int CtListModelDb::getLimitCount() +{ + return __limitCount; +} + +int CtListModelDb::getCurrentLinkedCount() +{ + return __currentLinkedCount; +} + +void CtListModelDb::setSelectAllState(bool selectAll) +{ + WDEBUG("selectAll = %d", selectAll); + __isSelectAll = selectAll; +} + +bool CtListModelDb::getSelectAllState() +{ + WDEBUG("isSeelctAll = %d", __isSelectAll); + return __isSelectAll; +} + + +void CtListModelDb::__onDbChanged(const char* view_uri, void* user_data) +{ + WENTER(); + + CtListModelDb* listModelDb = (CtListModelDb*)user_data; + + if (listModelDb->__listener) + listModelDb->__listener->onDbChanged(view_uri); + +} + +Eina_Bool CtListModelDb::__onGetContactsIdlerCb(void* data) +{ + WENTER(); + CtListModelDb* listModel = (CtListModelDb*)data; + listModel->__idler = NULL; + + if(listModel->__listThread) + listModel->__listThread->destroy(); + listModel->__listThread = NULL; + + listModel->__listThread = new CtThread(__onGetContactsThreadRunCb, listModel, __onGetContactsEndCb, listModel); + listModel->__listThread->start(); + + return ECORE_CALLBACK_CANCEL; +} + +void CtListModelDb::__onGetContactsThreadRunCb(void *data) +{ + WENTER(); + + CtListModelDb* listModel = (CtListModelDb*)data; + + listModel->__getQueryResult(listModel->__offset, -1); + + WLEAVE(); +} + +void CtListModelDb::__onGetContactsEndCb(void *data) +{ + WENTER(); + + CtListModelDb* listModel = (CtListModelDb*)data; + + if(listModel->__listThread) + listModel->__listThread->destroy(); + listModel->__listThread = NULL; + + if (listModel->__listener) + listModel->__listener->onCompleteGetContacts(listModel->__offset); + +} + +void CtListModelDb::__initialize(void) +{ + WENTER(); + __dataType = LIST_DATA_DEFAULT; + __listener = NULL; + __offset = 0; + __listThread = NULL; + __idler = NULL; + __selectedPersonId = -1; + __excludeIdList.clear(); + __checkedDataList.clear(); + __checkedDataListOld.clear(); + __search.clear(); + __personDataList.clear(); + __addressbookList.clear(); + __mfcPersonDataList.clear(); + __favoritePersonDataList.clear(); + __originalCheckedIdList.clear(); + __originalPersonDataListSize = 0; + __limitCount = 0; + __currentLinkedCount = 0; + __madePersonList = false; + __updateMFCListIdler = NULL; + __mfcThread = NULL; + __isSelectAll = false; + __excludeAddressbookId = 0; + __needUpdate = false; + __originalCount = 0; + __curCheckCount = 0; + + WLEAVE(); +} + +void CtListModelDb::__onDisplayNameOrderChangedCb(contacts_name_display_order_e name_display_order, void* user_data) +{ + WENTER(); + + CtListModelDb* listModelDb = (CtListModelDb*)user_data; + + if (listModelDb->__listener) + listModelDb->__listener->onDbChanged(NULL); + +} + +void CtListModelDb::__onNameSortingOrderChangedCb(contacts_name_sorting_order_e name_display_order, void* user_data) +{ + WENTER(); + + CtListModelDb* listModelDb = (CtListModelDb*)user_data; + + if (listModelDb->__listener) + listModelDb->__listener->onDbChanged(NULL); + +} + + +int CtListModelDb::__getQueryResult(int offset, int limit) +{ + WENTER(); + + WDEBUG("offset : %d, limit : %d",offset, limit); + + int err = CONTACTS_ERROR_NONE; + contacts_list_h personList = NULL; + contacts_query_h query = __dataFilter->getQuery(LIST_QUERY_DEFAULT); + + unsigned int search_person_projection[] = { + _contacts_person.id, + _contacts_person.display_name, + _contacts_person.addressbook_ids, + _contacts_person.has_phonenumber, + _contacts_person.image_thumbnail_path, + }; + + if(query) { + if (__search.length() > 0 ) { + err = contacts_query_set_projection(query, search_person_projection, sizeof(search_person_projection)/sizeof(int)); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_projection() Failed(%d)", err); + + err = contacts_db_search_records_with_query(query, __search.c_str(), offset, limit, &personList); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_search_records_with_query() Failed(%d)", err); + } + else { + WDEBUG("contacts_db_get_records_with_query"); + err = contacts_db_get_records_with_query(query, offset, limit, &personList); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_records_with_query() Failed(%d)", err); + } + + err = contacts_query_destroy(query); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_destroy() Failed(%d)", err); + } + else{ + if (__search.length() > 0){ + err = contacts_db_search_records(_contacts_person._uri, __search.c_str(), offset, limit, &personList); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_search_records() Failed(%d)", err); + } + else { + WDEBUG("contacts_db_get_all_records"); + err = contacts_db_get_all_records(_contacts_person._uri, offset, limit, &personList); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_all_records() Failed(%d)", err); + } + } + int count = 0; + err = contacts_list_get_count(personList, &count); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_get_count() Failed(%d)", err); + + WDEBUG("count : %d", count); + + __mutexLock.lock(); + __makePersonList(personList, offset); + __mutexLock.unlock(); + + err = contacts_list_destroy(personList, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_destroy() Failed(%d)", err); + + WLEAVE(); + + return count; +} + +bool CtListModelDb::checkSimAddressbook(int addressbookId) +{ + std::map<int, CtAddressbookInfo*> addressbookList = __dataFilter->getAddressbookList(); + + if(strstr(addressbookList[addressbookId]->addressbookName, CT_SIM_ADDRESSBOOK_NAME)) + return true; + + return false; + +} + +bool CtListModelDb::__makePersonList(contacts_list_h list, int offset) +{ + WENTER(); + WPRET_VM(list == NULL, false, "list is NULL"); + + if(offset == 0) { + __curCheckCount = 0; + __personDataList.clear(); + __checkedDataListOld.clear(); + __checkedDataListOld.insert(__checkedDataList.begin(), __checkedDataList.end()); + if (__search.length() == 0) { // on searching, no change check data + __checkedDataList.clear(); + } + } + + int err = CONTACTS_ERROR_NONE; + contacts_record_h recordPerson = NULL; + while (CONTACTS_ERROR_NONE == contacts_list_get_current_record_p(list, &recordPerson)) { + if(recordPerson){ + std::shared_ptr<CtListDataPerson> dataPerson(std::make_shared<CtListDataPerson>(recordPerson)); + + int personId = 0; + err = contacts_record_get_int(recordPerson, _contacts_person.id, &personId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + if (__selectedPersonId == personId) { + err = contacts_list_next(list); + continue; + } + if(std::find(__excludeIdList.begin(), __excludeIdList.end(), personId) != __excludeIdList.end()) { + err = contacts_list_next(list); + continue; + } + + //reserve check state + std::map<int, std::shared_ptr<CtListDataPerson>>::iterator iter; + iter = __checkedDataListOld.find(dataPerson->getPersonId()); + if(iter != __checkedDataListOld.end()) { + dataPerson->setAsChecked(true); + dataPerson->setDataId((*iter).second->getDataId()); + dataPerson->setDataString((*iter).second->getDataString()); + dataPerson->setDataType((*iter).second->getDataType()); + __setAsCheck(dataPerson, true, false); + __curCheckCount++; + } + + //remove sim contacts + if(__dataFilter->checkConditionWritable() == LIST_FILTER_WRITABLE_EXCEPT_SIM + || LIST_DATA_PERSON_EXCEPT_SIM == __dataType) { + char *value = NULL; + err = contacts_record_get_str_p(recordPerson, _contacts_person.addressbook_ids, &value); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + + int addressbookId = atoi(value); + if(addressbookId > 0) { + if(checkSimAddressbook(addressbookId) == true) { + WDEBUG("addressbookId %d", addressbookId); + err = contacts_list_next(list); + continue; + } + } + } + + if(__excludeAddressbookId > 0) { + char *value = NULL; + err = contacts_record_get_str_p(recordPerson, _contacts_person.addressbook_ids, &value); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + + int addressbookId = atoi(value); + if(addressbookId > 0 ) { + if(__excludeAddressbookId == addressbookId) { + WDEBUG("exclude addressbookId %d", addressbookId); + err = contacts_list_next(list); + continue; + } + } + } + + __personDataList.push_back(std::make_pair(dataPerson->getPersonId(), dataPerson)); + } + err = contacts_list_next(list); + } + + if(__search.length() == 0) { + __originalCount = __personDataList.size(); + } + __madePersonList = true; + + return true; +} + +bool CtListModelDb::getMadePersonListStatus() +{ + return __madePersonList; +} + +bool CtListModelDb::checkMostFrequentContact(int personId) +{ + int mfcPersonCount = __mfcPersonDataList.size(); + if (mfcPersonCount == 0) { + return false; + } + + for (auto iter = __mfcPersonDataList.begin(); iter != __mfcPersonDataList.end(); iter++) { + if (((*iter).second)->getPersonId() == personId) { + return true; + } + } + + return false; +} + +Eina_Bool CtListModelDb::__getCurentMfcListIdlerCb(void* data) +{ + WENTER(); + CtListModelDb* listModel = (CtListModelDb*)data; + + if(listModel->__updateMFCListIdler) + ecore_idler_del(listModel->__updateMFCListIdler); + listModel->__updateMFCListIdler = NULL; + + + if(listModel->__mfcThread) + listModel->__mfcThread->destroy(); + listModel->__mfcThread = NULL; + + listModel->__mfcThread = new CtThread(__onGetCurrentMfcListThreadRunCb, listModel, __onGetCurrentMfcListThreadEndCb, listModel); + listModel->__mfcThread->start(); + + WLEAVE(); + + return ECORE_CALLBACK_CANCEL; +} + +void CtListModelDb::__onGetCurrentMfcListThreadRunCb(void* data) +{ + WENTER(); + CtListModelDb* listModel = (CtListModelDb*)data; + + listModel->__getMfcPersonList(); + + WLEAVE(); +} + +void CtListModelDb::__onGetCurrentMfcListThreadEndCb(void* data) +{ + WENTER(); + CtListModelDb* listModel = (CtListModelDb*)data; + + if(listModel->__mfcThread) + listModel->__mfcThread->destroy(); + listModel->__mfcThread = NULL; + + if(listModel->__needUpdate == true) { + listModel->__needUpdate = false; + if(listModel->__listener) + listModel->__listener->onDbChanged(NULL); + } + + WLEAVE(); +} + +int CtListModelDb::__setImage(contacts_record_h record, char *image) +{ + int err = CONTACTS_ERROR_NONE; + + if(image && *image) { + err = contacts_record_set_str(record, _contacts_image.path, image); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_str() Failed(%d)", err); + //err = contacts_record_set_int(record, _contacts_image.type, CONTACTS_IMAGE_TYPE_EX_CUSTOM); + err = contacts_record_set_int(record, _contacts_image.type, CONTACTS_IMAGE_TYPE_CUSTOM); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_set_int() Failed(%d)", err); + } + return err; +} + +bool CtListModelDb::__setMFCImage(contacts_record_h personRecord, char *imagePath){ + WENTER(); + int err = CONTACTS_ERROR_NONE; + contacts_record_h imageRecord = NULL; + int personId = 0; + char *thumbnailPath = NULL; + bool result = false; + int displayContactId = 0; + + err = contacts_record_get_int(personRecord, _contacts_person.id, &personId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + + err = contacts_record_get_int(personRecord, _contacts_person.display_contact_id, &displayContactId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int(displayContactId) Failed(%d)", err); + + WDEBUG("personId %d, imagePath %s", personId, imagePath); + + if(imagePath) { + err = contacts_record_get_str_p(personRecord, _contacts_person.image_thumbnail_path, &thumbnailPath); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + + if(thumbnailPath) { + WERROR("already image has %s", thumbnailPath); + return false; + } + + Eina_List *contactList = ctCommonGetWritableContactList(personId); + void *data = NULL; + Eina_List *cursor = NULL; + + EINA_LIST_FOREACH(contactList, cursor, data) { + contacts_record_h contactRecord = (contacts_record_h)data; + + int contactId = 0; + err = contacts_record_get_int(contactRecord, _contacts_contact.id, &contactId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + + if(contactId == displayContactId) { + err = contacts_record_create(_contacts_image._uri, &imageRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_create() Failed(%d)", err); + err = contacts_record_set_str(imageRecord, _contacts_image.path, imagePath); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_set_str() Failed(%d)", err); +// err = contacts_record_set_int(imageRecord, _contacts_image.type, CONTACTS_IMAGE_TYPE_EX_CUSTOM); + err = contacts_record_set_int(imageRecord, _contacts_image.type, CONTACTS_IMAGE_TYPE_CUSTOM); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_set_int() Failed(%d)", err); + err = contacts_record_add_child_record(contactRecord, _contacts_contact.image, imageRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_add_child_record() Failed(%d)", err); + + err = contacts_db_update_record(contactRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_update_record() Failed(%d)", err); + result = true; + break; + } + } + + ctCommonDestroyRecordList(contactList); + WDEBUG("image set as %s %d", imagePath, result); + return result; + } + else { + err = contacts_record_get_str_p(personRecord, _contacts_person.image_thumbnail_path, &thumbnailPath); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + + if(thumbnailPath == NULL) { + WERROR("already image absent"); + return false; + } + + Eina_List *contactList = ctCommonGetWritableContactList(personId); + + void *data = NULL; + Eina_List *cursor = NULL; + + //set default image to first contact, it is enough + EINA_LIST_FOREACH(contactList, cursor, data) { + contacts_record_h contactRecord = (contacts_record_h)data; + + int contactId = 0; + err = contacts_record_get_int(contactRecord, _contacts_contact.id, &contactId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + + if(contactId == displayContactId) { + err = contacts_record_get_child_record_at_p(contactRecord, _contacts_contact.image, 0, &imageRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_child_record_at_p() Failed(%d)", err); + + int imageType = 0; + err = contacts_record_get_int(imageRecord, _contacts_image.type, &imageType); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + +// if(imageType != CONTACTS_IMAGE_TYPE_EX_CUSTOM) { + if(imageType != CONTACTS_IMAGE_TYPE_CUSTOM) { + WERROR("not custom default image"); + break; + } + + err = contacts_record_remove_child_record(contactRecord, _contacts_contact.image, imageRecord); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_remove_child_record() Failed(%d)", err); + + err = contacts_record_destroy(imageRecord, true); + WPRET_VM(CONTACTS_ERROR_NONE != err, err, "contacts_record_destroy() Failed(%d)", err); + + err = contacts_db_update_record(contactRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_update_record() Failed(%d)", err); + + result = true; + break; + } + } + + ctCommonDestroyRecordList(contactList); + WDEBUG("image removed %d", result); + return result; + } + + return true; + +} + +bool CtListModelDb::__checkToDisplayMfc(char *addressbookIds) +{ + if(addressbookIds) { + int hideCount = 0; + int addressbookCount = 0; + int addressbookId = 0; + char* ptr = NULL; + char* token = strtok_r(addressbookIds, " ", &ptr); + std::map<int, CtAddressbookInfo*> addressbookList = __dataFilter->getAddressbookList(); + while(token) { + addressbookId = atoi(token); + + if(addressbookList[addressbookId]->display == false) + hideCount++; + addressbookCount++; + + token = strtok_r(NULL, " ", &ptr); + } + + if(hideCount == addressbookCount) + return false; + } + + return true; + +} + + +void CtListModelDb::__getMfcPersonListFromPreference() +{ + WENTER(); + + int mfc_personid = -1; + char *pch = NULL; + char *mfc_personid_list = NULL; + int error = preference_get_string(CT_KEY_LIST_MFC_PERSON_IDS, &mfc_personid_list); + WPRET_M(error != PREFERENCE_ERROR_NONE, "preference_get_string failed error code (%d)", error); + + if(__updateMFCListIdler) + ecore_idler_del(__updateMFCListIdler); + __updateMFCListIdler = NULL; + + if(NULL == mfc_personid_list) { + __updateMFCListIdler = ecore_idler_add(__getCurentMfcListIdlerCb, this); + WLEAVE(); + return; + } + + WDEBUG("mfc_personid_list %s", mfc_personid_list); + pch = strtok (mfc_personid_list," "); + while (pch != NULL) { + mfc_personid = atoi(pch); + pch = strtok (NULL, " "); + + contacts_record_h recordPerson = NULL; + if (CONTACTS_ERROR_NONE == contacts_db_get_record(_contacts_person._uri, mfc_personid, &recordPerson) ) { + if(recordPerson){ + if(std::find(__excludeIdList.begin(), __excludeIdList.end(), mfc_personid) != __excludeIdList.end()) { + continue; + } + + int err = CONTACTS_ERROR_NONE; + char *temp = NULL; + err = contacts_record_get_str_p(recordPerson, _contacts_person.addressbook_ids, &temp); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + if(temp && __checkToDisplayMfc(temp) == false) + continue; + + std::shared_ptr<CtListDataPerson> dataPerson(std::make_shared<CtListDataPerson>(recordPerson)); + + //reserve check state + std::map<int, std::shared_ptr<CtListDataPerson>>::iterator iter; + iter = __checkedDataList.find(dataPerson->getPersonId()); + if(iter != __checkedDataList.end()) { + dataPerson->setAsChecked(true); + dataPerson->setDataId((*iter).second->getDataId()); + dataPerson->setDataString((*iter).second->getDataString()); + dataPerson->setDataType((*iter).second->getDataType()); + } + + __mfcPersonDataList.push_back(std::make_pair(dataPerson->getPersonId(), dataPerson)); + } + } + } + free(mfc_personid_list); + + if (__dataType != LIST_DATA_ALL_FAVORITES) { + __updateMFCListIdler = ecore_idler_add(__getCurentMfcListIdlerCb, this); + } +} + +void CtListModelDb::__getMfcPersonList() +{ + WENTER(); + + int err = CONTACTS_ERROR_NONE; + contacts_list_h personUsageList = NULL; + contacts_query_h query = __dataFilter->getQuery(LIST_QUERY_MFC); + + err = contacts_db_get_records_with_query(query, 0, 5, &personUsageList); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_get_list() Failed(%d)", err); + + contacts_query_destroy(query); + + __makeMfcPersonList(personUsageList); + + err = contacts_list_destroy(personUsageList, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_destroy() Failed(%d)", err); + WLEAVE(); + +} + + +void CtListModelDb::__getFavoritePersonList() +{ + WENTER(); + + int err = CONTACTS_ERROR_NONE; + contacts_list_h personList = NULL; + contacts_query_h query = __dataFilter->getQuery(LIST_QUERY_FAVORITE); + + int queryCount = 0; + err = contacts_db_get_count_with_query(query, &queryCount); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_count_with_query() Failed(%d)", err); + WDEBUG("count : %d", queryCount); + if(queryCount == 0) { + contacts_query_destroy(query); + return; + } + + err = contacts_db_get_records_with_query(query, 0, 0, &personList); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_get_list() Failed(%d)", err); + + contacts_query_destroy(query); + + __makeFavoritePersonList(personList); + + err = contacts_list_destroy(personList, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_destroy() Failed(%d)", err); + WLEAVE(); +} + +bool CtListModelDb::__makeMfcPersonList(contacts_list_h list) +{ + WENTER(); + WPRET_VM(list == NULL, false, "list is NULL"); + + int err = CONTACTS_ERROR_NONE; + contacts_record_h recordPerson = NULL; + std::vector<int> mfcPersonIds; + + while (CONTACTS_ERROR_NONE == contacts_list_get_current_record_p(list, &recordPerson)) { + if(recordPerson){ + int personId = 0; + err = contacts_record_get_int(recordPerson, _contacts_person.id, &personId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + + contacts_record_h record = NULL; + if(CONTACTS_ERROR_NONE == contacts_db_get_record(_contacts_person._uri, personId, &record)) { + char *temp = NULL; + err = contacts_record_get_str_p(record, _contacts_person.addressbook_ids, &temp); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + if(temp && __checkToDisplayMfc(temp) == false) { + contacts_list_next(list); + continue; + } + } + + mfcPersonIds.push_back(personId); + if(find_if( __mfcPersonDataList.begin(), __mfcPersonDataList.end(), + [personId](std::pair<int, std::shared_ptr<CtListDataPerson>> dataPerson)->bool { + if(dataPerson.first == personId) { + return true; + } + return false; + } + ) == __mfcPersonDataList.end()) + __needUpdate = true; + } + contacts_list_next(list); + } + + if(__mfcPersonDataList.size() != mfcPersonIds.size()) { + WDEBUG("count changed old %d, new %d", __mfcPersonDataList.size(), mfcPersonIds.size()); + __needUpdate = true; + } + + //set mfc to preference no matter chaged + WDEBUG("MFC are changed"); + std::string mfcPersonIdsStr; + int index = 0; + for(index=0;index<(int)mfcPersonIds.size();index++) { + std::string tempStr = std::to_string(mfcPersonIds[index]); + + if(mfcPersonIdsStr.size() > 0) + mfcPersonIdsStr += " "; + mfcPersonIdsStr += tempStr; + } + WDEBUG("mfcPersonList %s", mfcPersonIdsStr.c_str()); + preference_set_string(CT_KEY_LIST_MFC_PERSON_IDS, mfcPersonIdsStr.c_str()); + + return true; +} + +bool CtListModelDb::__makeFavoritePersonList(contacts_list_h list) +{ + WENTER(); + WPRET_VM(list == NULL, false, "list is NULL"); + + int err = CONTACTS_ERROR_NONE; + + contacts_record_h recordPerson = NULL; + while (CONTACTS_ERROR_NONE == contacts_list_get_current_record_p(list, &recordPerson)) { + if(recordPerson){ + std::shared_ptr<CtListDataPerson> dataPerson(std::make_shared<CtListDataPerson>(recordPerson)); + + int personId = 0; + err = contacts_record_get_int(recordPerson, _contacts_person.id, &personId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + + if(std::find(__excludeIdList.begin(), __excludeIdList.end(), personId) != __excludeIdList.end()) { + err = contacts_list_next(list); + continue; + } + //reserve check state + std::map<int, std::shared_ptr<CtListDataPerson>>::iterator iter; + iter = __checkedDataList.find(dataPerson->getPersonId()); + if(iter != __checkedDataList.end()) { + dataPerson->setAsChecked(true); + dataPerson->setDataId((*iter).second->getDataId()); + dataPerson->setDataString((*iter).second->getDataString()); + dataPerson->setDataType((*iter).second->getDataType()); + } + + __favoritePersonDataList.push_back(std::make_pair(dataPerson->getPersonId(), dataPerson)); + } + err = contacts_list_next(list); + } + return true; +} + +void CtListModelDb::initialOriginalCheckedIdList() +{ + WENTER(); + + __originalCheckedIdList.clear(); + for (auto iter = __checkedDataList.begin(); iter != __checkedDataList.end(); iter++) + { + __originalCheckedIdList.push_back((*iter).second->getPersonId()); + } +} + +void CtListModelDb::clearOriginalCheckedIdList() +{ + WENTER(); + __originalCheckedIdList.clear(); +} + +bool CtListModelDb::checkIsSelectAllOnSearching() +{ + WENTER(); + WPRET_VM(0 == __originalCheckedIdList.size(), false, "__originalCheckedIdList is empty"); + + int originCheckedCount = __originalCheckedIdList.size(); + int curCheckedCount = __curCheckCount; + int curCount = __personDataList.size(); + int maxCount = __originalCount; + + WDEBUG("originCheckedCount %d, maxCount %d, curCount %d, curCheckedCount %d", originCheckedCount, maxCount, curCount, curCheckedCount); + + return (curCheckedCount == curCount); +} + +void CtListModelDb::initialOriginalPersonDataListSize() +{ + WENTER(); + __originalPersonDataListSize = __personDataList.size(); +} + +void CtListModelDb::clearOriginalPersonDataListSize() +{ + WENTER(); + __originalPersonDataListSize = 0; +} + +int CtListModelDb::getOriginalPersonDataListSize() +{ + WENTER(); + return __originalPersonDataListSize; +} + +void CtListModelDb::__setAsCheck(std::shared_ptr<CtListDataPerson> personData, bool check, bool noRelation) +{ + std::map<int, std::shared_ptr<CtListDataPerson>>::iterator iter; + + iter = __checkedDataList.find(personData->getPersonId()); + + if(check == true) { + if(iter == __checkedDataList.end()) { + __checkedDataList.insert(std::make_pair(personData->getPersonId(), personData)); + __curCheckCount++; + } + + if(std::find(__originalCheckedIdList.begin(), __originalCheckedIdList.end(), personData->getPersonId()) == __originalCheckedIdList.end()) { + __originalCheckedIdList.push_back(personData->getPersonId()); + } + } + else { + if(iter != __checkedDataList.end()) { + __checkedDataList.erase(iter); + __curCheckCount--; + } + + std::vector<int>::iterator originalIter = std::find(__originalCheckedIdList.begin(), __originalCheckedIdList.end(), personData->getPersonId()); + if(originalIter != __originalCheckedIdList.end()) { + __originalCheckedIdList.erase(originalIter); + } + } + + //set check other same person + int personId = personData->getPersonId(); + if(noRelation) { + //for check all performance, consider default contact based check + personData->setAsChecked(check); + } + else { + find_if( __personDataList.begin(), __personDataList.end(), + [personId, check](std::pair<int, std::shared_ptr<CtListDataPerson>> dataPerson)->bool { + if(dataPerson.first == personId) { + dataPerson.second->setAsChecked(check); + return true; + } + return false; + } + ); + } + + find_if( __mfcPersonDataList.begin(), __mfcPersonDataList.end(), + [personId, check](std::pair<int, std::shared_ptr<CtListDataPerson>> dataPerson)->bool { + if(dataPerson.first == personId) { + dataPerson.second->setAsChecked(check); + return true; + } + return false; + } + ); + + find_if( __favoritePersonDataList.begin(), __favoritePersonDataList.end(), + [personId, check](std::pair<int, std::shared_ptr<CtListDataPerson>> dataPerson)->bool { + if(dataPerson.first == personId) { + dataPerson.second->setAsChecked(check); + return true; + } + return false; + } + ); + + +} diff --git a/lib-contact/ct-list/src/CtListModelDb.h b/lib-contact/ct-list/src/CtListModelDb.h new file mode 100755 index 0000000..48cf832 --- /dev/null +++ b/lib-contact/ct-list/src/CtListModelDb.h @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __CT_LIST_MODEL_DB_H_ +#define __CT_LIST_MODEL_DB_H_ + +#include <map> +#include <vector> +#include <string> +#include <contacts.h> +#include <memory> +#include <Ecore.h> +#include <Elementary.h> +#include <mutex> + +#include "ContactsCommon.h" +#include "ICtChangeListener.h" +#include "CtCommon.h" +#include "CtType.h" +#include "CtThread.h" + +#include "CtListModelListener.h" +#include "CtListModel.h" +#include "CtListDataPerson.h" + +#include "CtListModelFilter.h" + + +#define CTLISTDATA_NQUERY_COUNT 20 +#define CTLISTDATA_NQUERY_TIMER_INTERVAL 0.4 + +class CtListModelDb : public CtListModel , public CtListModelListener +{ +public: + CtListModelDb(CtListHasType filterType, int limit); + CtListModelDb(CtListDataType dataType); + + virtual ~CtListModelDb(); + +public: + // CtListModel interfaces + virtual int getContactsCount(CtListQueryType queryType); + virtual int getContacts(CtListQueryType queryType, CtGetContactsType syncType); + virtual int cancelGetContacts(); + virtual std::shared_ptr<CtListDataPerson> getAtPersonData(int index, CtListQueryType queryType); + virtual int getPersonListCount(CtListQueryType queryType); + virtual bool getMadePersonListStatus(); + virtual void attachListener(ICtChangeListener* listener); + + virtual void setSelectedPersonId(int selectedPersonId); + virtual const char* getSearchString(void); + virtual bool setSearchString(char* search); + virtual void pushCheckedData(std::shared_ptr<CtListDataPerson> dataPerson); + virtual void removeCheckedData(std::shared_ptr<CtListDataPerson> dataPerson); + virtual void getNumberSearchString(const std::shared_ptr<CtListDataPerson>& dataPerson, std::string &numberStr); + virtual int getCheckedDataCount(); + virtual int getLimitCount(); + virtual int getCurrentLinkedCount(); + + // CtListModelListener + virtual void onFilterChanged(); + + std::vector<std::shared_ptr<CtListDataPerson>>* getCheckedDataList() const; + std::map<int, CtAddressbookInfo*>& getAddressbookList(); + void setDisplayAddressbook(int addressbookId, bool display); + bool checkSimAddressbook(int addressbookId); + + virtual void initialOriginalCheckedIdList(); + virtual void clearOriginalCheckedIdList(); + virtual bool checkIsSelectAllOnSearching(); + virtual void initialOriginalPersonDataListSize(); + virtual void clearOriginalPersonDataListSize(); + virtual int getOriginalPersonDataListSize(); + + bool checkMostFrequentContact(int personId); + + void setSelectAllState(bool selectAll); + bool getSelectAllState(); + void doCheckedDataNoRelation(std::shared_ptr<CtListDataPerson> dataPerson, bool check); + + + +private: + + void __initialize(void); + int __getQueryResult(int offset, int limit); + CtListDataPerson* __createPersonData(contacts_record_h record); + bool __makePersonList(contacts_list_h list, int offset); + void __getMfcPersonListFromPreference(); + int __setImage(contacts_record_h record, char *image); + bool __setMFCImage(contacts_record_h personRecord, char *imagePath); + void __getMfcPersonList(); + void __getFavoritePersonList(); + bool __makeMfcPersonList(contacts_list_h list); + bool __makeFavoritePersonList(contacts_list_h list); + void __setAsCheck(std::shared_ptr<CtListDataPerson> personData, bool check, bool noRelation); + bool __checkToDisplayMfc(char *addressbookIds); + +private: + static void __onDbChanged(const char* view_uri, void* user_data); + static Eina_Bool __onGetContactsIdlerCb(void* data); + static void __onGetContactsThreadRunCb(void *data); + static void __onGetContactsEndCb(void *data); + static void __onDisplayNameOrderChangedCb(contacts_name_display_order_e name_display_order, void* user_data); + static void __onNameSortingOrderChangedCb(contacts_name_sorting_order_e name_display_order, void* user_data); + static Eina_Bool __getCurentMfcListIdlerCb(void* data); + static void __onGetCurrentMfcListThreadRunCb(void* data); + static void __onGetCurrentMfcListThreadEndCb(void* data); + +private: + std::string __search; + CtListDataType __dataType; + ICtChangeListener *__listener; + + CtThread *__listThread; + CtThread *__mfcThread; + + Ecore_Idler *__idler; + Ecore_Idler *__updateMFCListIdler; + int __offset; + CtListModelFilter *__dataFilter; + int __selectedPersonId; + int __limitCount; + int __currentLinkedCount; + bool __madePersonList; + bool __isSelectAll; + int __excludeAddressbookId; + bool __needUpdate; + int __originalCount; + int __curCheckCount; + + std::vector<std::pair<int, std::shared_ptr<CtListDataPerson>>> __personDataList; + std::vector<std::pair<int, std::shared_ptr<CtListDataPerson>>> __mfcPersonDataList; + std::vector<std::pair<int, std::shared_ptr<CtListDataPerson>>> __favoritePersonDataList; + + std::map<int, std::shared_ptr<CtListDataPerson>> __checkedDataList; + std::map<int, std::shared_ptr<CtListDataPerson>> __checkedDataListOld; + + std::vector<int> __excludeIdList; + std::vector<int> __originalCheckedIdList; // when searching, use this list to check + int __originalPersonDataListSize; // when searching, use this size to check + + std::vector<CtAddressbookInfo*> __addressbookList; + + std::mutex __mutexLock; +}; + +#endif + diff --git a/lib-contact/ct-list/src/CtListModelFilter.cpp b/lib-contact/ct-list/src/CtListModelFilter.cpp new file mode 100644 index 0000000..e9c2810 --- /dev/null +++ b/lib-contact/ct-list/src/CtListModelFilter.cpp @@ -0,0 +1,835 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <contacts.h> +#include <vector> +#include <memory> +#include <algorithm> +#include <app_preference.h> + +#include "CtCommon.h" +#include "CtListModelFilter.h" +#include "CtListModelFilter.h" + +CtListModelFilter::CtListModelFilter(CtListHasType filterType) +{ + WENTER(); + __initialize(); + __initAddressbook(); + if(__getDisplayAddressbookCount() == 0) + __setDisplayAddressbookAll(); + + __hasType = filterType; + WLEAVE(); +} + +CtListModelFilter::CtListModelFilter(CtListDataType dataType) +{ + WENTER(); + __initialize(); + __initAddressbook(); + __getOpFromDataType(dataType); + if(__getDisplayAddressbookCount() == 0) + __setDisplayAddressbookAsPreference(); + __initHasType(); + + +} + +CtListModelFilter::~CtListModelFilter() +{ + WHIT(); + preference_unset_changed_cb(CT_KEY_DISPLAY_WITH_NUMBER); + preference_unset_changed_cb(CT_KEY_LIST_DISPLAY_ADDRESSBOOK); + + for(auto iter = __addressbookList.begin(); iter != __addressbookList.end(); iter++) { + free(iter->second->addressbookName); + delete (*iter).second; + } + __addressbookList.clear(); +} + + +CtListHasType CtListModelFilter::__getListHasType() const +{ + return __hasType; +#if 0 + if(__ugRequest == CT_UG_REQUEST_LIST_FOR_DIAL) + return LIST_HAS_NUMBER; + + if (__listOp == CT_GET_LIST_ALL_PERSON_HAD_NUMBER || + __listOp == CT_GET_LIST_ALL_PERSON_HAD_NUMBER_NO_EXIST) + return LIST_HAS_NUMBER; + + if (__listOp == CT_GET_LIST_ALL_PERSON_HAD_EMAIL) + return LIST_HAS_EMAIL; + + if (__listOp == CT_GET_LIST_ALL_PERSON_HAD_NUMBER_OR_EMAIL) + return LIST_HAS_NUMBER_OR_EMAIL; + + + return LIST_HAS_NONE; +#endif +} + + +CtListFavoriteType CtListModelFilter::__getListFavoriteType() const +{ + if( __listOp == CT_GET_LIST_ALL_PERSON_REMOVE_FAVORITE || + __listOp == CT_GET_LIST_ALL_PERSON_REORDER_FAVORITE) + return LIST_FAVORITE_SET; + else if (__listOp == CT_GET_LIST_ALL_PERSON_ADD_FAVORITE) + return LIST_FAVORITE_UNSET; + else + return LIST_FAVORITE_NONE; +} +void CtListModelFilter::setListHasType(CtListHasType hasType) +{ + WDEBUG("hasType %d", hasType); + __hasType = hasType; +} + +void CtListModelFilter::attachListener(CtListModelListener *listener) +{ + __listener = listener; +} + +contacts_query_h CtListModelFilter::getQuery(CtListQueryType queryType) +{ + WDEBUG("queryType %d", queryType); + + CtListViewUriType uriType = LIST_VIEW_URI_TYPE_PERSON; + contacts_query_h query = NULL; + contacts_filter_h filter = NULL; + contacts_filter_h filter2 = NULL; + contacts_filter_h filter3 = NULL; + contacts_filter_h filter4 = NULL; + int err = CONTACTS_ERROR_NONE; + int conditionCount = 0; + + unsigned int person_projection[] = { + _contacts_person.id, + _contacts_person.display_name, + _contacts_person.display_name_index, + _contacts_person.addressbook_ids, + _contacts_person.image_thumbnail_path, + _contacts_person.is_favorite, + }; + + unsigned int person_contact_projection[] = { + _contacts_person_contact.person_id, + _contacts_person_contact.display_name, + _contacts_person_contact.display_name_index, + _contacts_person_contact.addressbook_ids, + _contacts_person_contact.image_thumbnail_path, + }; + + unsigned int person_usage_projection[] = { + _contacts_person_usage.person_id, + _contacts_person_usage.display_name, + _contacts_person_usage.image_thumbnail_path, + }; + + if(queryType == LIST_QUERY_MFC) { + WDEBUG("person usage uri"); + uriType = LIST_VIEW_URI_TYPE_PERSON_USAGE; + + err = contacts_query_create(_contacts_person_usage._uri, &query); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_create() Failed(%d)", err); + err = contacts_filter_create(_contacts_person_usage._uri, &filter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + err = contacts_filter_create(_contacts_person_usage._uri, &filter2); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + do { + if (CONTACTS_ERROR_NONE != (err = contacts_filter_add_int(filter2, _contacts_person_usage.times_used, CONTACTS_MATCH_GREATER_THAN_OR_EQUAL, 1))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_filter_add_operator(filter2, CONTACTS_FILTER_OPERATOR_AND))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_filter_add_int(filter2, _contacts_person_usage.usage_type, CONTACTS_MATCH_EQUAL, CONTACTS_USAGE_STAT_TYPE_OUTGOING_CALL))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_filter_add_operator(filter2, CONTACTS_FILTER_OPERATOR_AND))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_filter_add_bool(filter2, _contacts_person_usage.is_favorite, false))) break; + } while (0); + err = contacts_filter_add_filter(filter, filter2); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_filter() Failed(%d)", err); + conditionCount++; + // add condition for hastype + WDEBUG("condition hastype %d", __getListHasType()); + if(__getListHasType() == LIST_HAS_NUMBER) { + if(conditionCount > 0) { + err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_operator() Failed(%d)", err); + } + + err = contacts_filter_create(_contacts_person_usage._uri, &filter3); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + err = contacts_filter_add_bool(filter3, _contacts_person_usage.has_phonenumber, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_int() Failed(%d)", err); + err = contacts_filter_add_filter(filter, filter3); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_filter() Failed(%d)", err); + conditionCount++; + } + else if(__getListHasType() == LIST_HAS_EMAIL) { + if(conditionCount > 0) { + err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_operator() Failed(%d)", err); + } + + err = contacts_filter_create(_contacts_person_usage._uri, &filter3); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + err = contacts_filter_add_bool(filter3, _contacts_person_usage.has_email, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_int() Failed(%d)", err); + err = contacts_filter_add_filter(filter, filter3); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_filter() Failed(%d)", err); + conditionCount++; + } + else if(__getListHasType() == LIST_HAS_NUMBER_OR_EMAIL) { + if(conditionCount > 0) { + err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_operator() Failed(%d)", err); + } + + err = contacts_filter_create(_contacts_person_usage._uri, &filter3); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + err = contacts_filter_add_bool(filter3, _contacts_person_usage.has_phonenumber, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_int() Failed(%d)", err); + err = contacts_filter_add_operator(filter3, CONTACTS_FILTER_OPERATOR_OR); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_operator() Failed(%d)", err); + err = contacts_filter_add_bool(filter3, _contacts_person_usage.has_email, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_int() Failed(%d)", err); + err = contacts_filter_add_filter(filter, filter3); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_filter() Failed(%d)", err); + conditionCount++; + } + + err = contacts_query_set_sort(query, _contacts_person_usage.times_used, false); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_sort() Failed(%d)", err); + + err = contacts_query_set_projection(query, person_usage_projection, sizeof(person_usage_projection)/sizeof(int)); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_projection() Failed(%d)", err); + + err = contacts_query_set_distinct(query, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_distinct() Failed(%d)", err); + } + else { + int allAddressbookCount = __addressbookList.size(); + int displayAddressbookCount = __getDisplayAddressbookCount(); + WDEBUG("allAddressbookCount %d, displayAddressbookCount %d", allAddressbookCount, displayAddressbookCount); + // create query and filter + + // create query and filter + if( allAddressbookCount == displayAddressbookCount) { + WDEBUG("person uri"); + uriType = LIST_VIEW_URI_TYPE_PERSON; + err = contacts_query_create(_contacts_person._uri, &query); + WPRET_VM(CONTACTS_ERROR_NONE != err, NULL, "contacts_query_create() Failed(%d)", err); + err = contacts_filter_create(_contacts_person._uri, &filter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + err = contacts_filter_create(_contacts_person._uri, &filter2); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + + // add condition for favorite + CtListFavoriteType favoriteType = LIST_FAVORITE_NONE; + if(queryType == LIST_QUERY_FAVORITE) + favoriteType = LIST_FAVORITE_SET; + else + favoriteType = __getListFavoriteType(); + WDEBUG("condition favoriteType %d", favoriteType); + if(favoriteType == LIST_FAVORITE_SET) { + err = contacts_filter_add_bool(filter2, _contacts_person.is_favorite, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_int() Failed(%d)", err); + err = contacts_filter_add_filter(filter, filter2); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_filter() Failed(%d)", err); + err = contacts_query_set_sort(query, _contacts_person.favorite_priority, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_sort() Failed(%d)", err); + conditionCount++; + } + else if(__getListFavoriteType() == LIST_FAVORITE_UNSET) { + err = contacts_filter_add_bool(filter2, _contacts_person.is_favorite, false); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_int() Failed(%d)", err); + err = contacts_filter_add_filter(filter, filter2); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_filter() Failed(%d)", err); + conditionCount++; + } + + // add condition for hastype + WDEBUG("condition hastype %d", __getListHasType()); + if(__getListHasType() == LIST_HAS_NUMBER) { + if(conditionCount > 0) { + err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_operator() Failed(%d)", err); + } + + err = contacts_filter_create(_contacts_person._uri, &filter3); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + err = contacts_filter_add_bool(filter3, _contacts_person.has_phonenumber, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_int() Failed(%d)", err); + err = contacts_filter_add_filter(filter, filter3); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_filter() Failed(%d)", err); + conditionCount++; + } + else if(__getListHasType() == LIST_HAS_EMAIL) { + if(conditionCount > 0) { + err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_operator() Failed(%d)", err); + } + + err = contacts_filter_create(_contacts_person._uri, &filter3); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + err = contacts_filter_add_bool(filter3, _contacts_person.has_email, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_int() Failed(%d)", err); + err = contacts_filter_add_filter(filter, filter3); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_filter() Failed(%d)", err); + conditionCount++; + } + else if(__getListHasType() == LIST_HAS_NUMBER_OR_EMAIL) { + if(conditionCount > 0) { + err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_operator() Failed(%d)", err); + } + + err = contacts_filter_create(_contacts_person._uri, &filter3); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + err = contacts_filter_add_bool(filter3, _contacts_person.has_phonenumber, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_int() Failed(%d)", err); + err = contacts_filter_add_operator(filter3, CONTACTS_FILTER_OPERATOR_OR); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_operator() Failed(%d)", err); + err = contacts_filter_add_bool(filter3, _contacts_person.has_email, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_int() Failed(%d)", err); + err = contacts_filter_add_filter(filter, filter3); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_filter() Failed(%d)", err); + conditionCount++; + } + err = contacts_query_set_projection(query, person_projection, sizeof(person_projection)/sizeof(int)); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_projection() Failed(%d)", err); + + err = contacts_query_set_distinct(query, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_distinct() Failed(%d)", err); + + } + else { + WDEBUG("person contact uri"); + uriType = LIST_VIEW_URI_TYPE_PERSON_CONTACT; + err = contacts_query_create(_contacts_person_contact._uri, &query); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_create() Failed(%d)", err); + err = contacts_filter_create(_contacts_person_contact._uri, &filter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + err = contacts_filter_create(_contacts_person_contact._uri, &filter2); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + + // add condition for addressbook + for (auto iter = __addressbookList.begin(); iter != __addressbookList.end(); iter++) + { + if((*iter).second->display == true) { + if(conditionCount > 0) { + err = contacts_filter_add_operator(filter2, CONTACTS_FILTER_OPERATOR_OR); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_operator() Failed(%d)", err); + } + + WDEBUG("condition addressbookId %d", (*iter).first); + err = contacts_filter_add_int(filter2, _contacts_person_contact.address_book_id, CONTACTS_MATCH_EQUAL, (*iter).first); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_int() Failed(%d)", err); + conditionCount++; + } + } + err = contacts_filter_add_filter(filter, filter2); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_filter() Failed(%d)", err); + + // add condition for favorite + CtListFavoriteType favoriteType = LIST_FAVORITE_NONE; + if(queryType == LIST_QUERY_FAVORITE) + favoriteType = LIST_FAVORITE_SET; + else + favoriteType = __getListFavoriteType(); + WDEBUG("condition favoriteType %d", favoriteType); + if(favoriteType == LIST_FAVORITE_SET) { + if(conditionCount > 0) { + err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_operator() Failed(%d)", err); + } + + err = contacts_filter_create(_contacts_person_contact._uri, &filter3); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + err = contacts_filter_add_bool(filter3, _contacts_person_contact.is_favorite, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_int() Failed(%d)", err); + err = contacts_filter_add_filter(filter, filter3); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_filter() Failed(%d)", err); + conditionCount++; + } + else if(__getListFavoriteType() == LIST_FAVORITE_UNSET) { + if(conditionCount > 0) { + err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_operator() Failed(%d)", err); + } + + err = contacts_filter_create(_contacts_person_contact._uri, &filter3); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + err = contacts_filter_add_bool(filter3, _contacts_person_contact.is_favorite, false); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_int() Failed(%d)", err); + err = contacts_filter_add_filter(filter, filter3); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_filter() Failed(%d)", err); + conditionCount++; + } + + // add condition for hastype + WDEBUG("condition hastype %d", __getListHasType()); + + if(__getListHasType() == LIST_HAS_NUMBER) { + if(conditionCount > 0) { + err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_operator() Failed(%d)", err); + } + + err = contacts_filter_create(_contacts_person_contact._uri, &filter4); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + err = contacts_filter_add_bool(filter4, _contacts_person_contact.has_phonenumber, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_int() Failed(%d)", err); + err = contacts_filter_add_filter(filter, filter4); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_filter() Failed(%d)", err); + conditionCount++; + } + else if(__getListHasType() == LIST_HAS_EMAIL) { + if(conditionCount > 0) { + err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_operator() Failed(%d)", err); + } + + err = contacts_filter_create(_contacts_person_contact._uri, &filter4); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + err = contacts_filter_add_bool(filter4, _contacts_person_contact.has_email, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_int() Failed(%d)", err); + err = contacts_filter_add_filter(filter, filter4); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_filter() Failed(%d)", err); + conditionCount++; + } + else if(__getListHasType() == LIST_HAS_NUMBER_OR_EMAIL) { + if(conditionCount > 0) { + err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_operator() Failed(%d)", err); + } + conditionCount++; + + err = contacts_filter_create(_contacts_person_contact._uri, &filter4); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + err = contacts_filter_add_bool(filter4, _contacts_person_contact.has_phonenumber, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_int() Failed(%d)", err); + err = contacts_filter_add_operator(filter4, CONTACTS_FILTER_OPERATOR_OR); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_operator() Failed(%d)", err); + err = contacts_filter_add_bool(filter4, _contacts_person_contact.has_email, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_int() Failed(%d)", err); + err = contacts_filter_add_filter(filter, filter4); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_filter() Failed(%d)", err); + } + + err = contacts_query_set_projection(query, person_contact_projection, sizeof(person_contact_projection)/sizeof(int)); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_projection() Failed(%d)", err); + + err = contacts_query_set_distinct(query, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_distinct() Failed(%d)", err); + } + } + WDEBUG("uriType is [%d], conditionCount %d",uriType, conditionCount); + + // set filter to query + if(conditionCount > 0) { + err = contacts_query_set_filter(query, filter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_filter() Failed(%d)", err); + } + else { + if(query) { + err = contacts_query_destroy(query); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_destroy() Failed(%d)", err); + query = NULL; + } + } + + if(filter4) { + err = contacts_filter_destroy(filter4); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_destroy() Failed(%d)", err); + } + if(filter3) { + err = contacts_filter_destroy(filter3); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_destroy() Failed(%d)", err); + } + if(filter2) { + err = contacts_filter_destroy(filter2); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_destroy() Failed(%d)", err); + } + if(filter) { + err = contacts_filter_destroy(filter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_destroy() Failed(%d)", err); + } + + return query; +} + +void CtListModelFilter::__initialize() +{ + __listOp = 0; + __selectedPersonId = 0; + __viewId = 0; + __ugRequest = 0; + __ugData = NULL; + __listener = NULL; + + preference_set_changed_cb(CT_KEY_DISPLAY_WITH_NUMBER, __onDisplayWithNumberChangedCb, this); + preference_set_changed_cb(CT_KEY_LIST_DISPLAY_ADDRESSBOOK, __onDisplayAddressbookChangedCb, this); +} + +void CtListModelFilter::__initHasType() +{ + if (__listOp == CT_GET_LIST_ALL_PERSON_HAD_NUMBER || __listOp == CT_GET_LIST_ALL_PERSON_HAD_NUMBER_NO_EXIST) + __hasType = LIST_HAS_NUMBER; + else if (__listOp == CT_GET_LIST_ALL_PERSON_HAD_EMAIL) + __hasType = LIST_HAS_EMAIL; + else if (__listOp == CT_GET_LIST_ALL_PERSON_HAD_NUMBER_OR_EMAIL) + __hasType = LIST_HAS_NUMBER_OR_EMAIL; + else + { + int showMode = 0; + preference_get_int(CT_KEY_DISPLAY_WITH_NUMBER, &showMode); + WDEBUG("showMode %d", showMode); + + if(showMode == 1) + __hasType = LIST_HAS_NUMBER; + else + __hasType = LIST_HAS_NONE; + } + + WDEBUG("hasType %d", __hasType); +} + +void CtListModelFilter::__onDisplayWithNumberChangedCb(const char *key, void *data) +{ + CtListModelFilter* modelFilter = (CtListModelFilter*)data; + + int showMode = 0; + preference_get_int(CT_KEY_DISPLAY_WITH_NUMBER, &showMode); + WDEBUG("showMode %d", showMode); + + if(showMode == 1) + modelFilter->__hasType = LIST_HAS_NUMBER; + else + modelFilter->__hasType = LIST_HAS_NONE; + + if (modelFilter->__listener) + modelFilter->__listener->onFilterChanged(); +} + +void CtListModelFilter::__onDisplayAddressbookChangedCb(const char *key, void *data) +{ + WHIT(); + CtListModelFilter* modelFilter = (CtListModelFilter*)data; + + if(modelFilter->__ugRequest == 0) { + modelFilter->__initAddressbook(); + modelFilter->__setDisplayAddressbookAsPreference(); + + if (modelFilter->__listener) + modelFilter->__listener->onFilterChanged(); + } + +} + + +bool CtListModelFilter::__checkAddressbook() const +{ + int all = __addressbookIds.size(); + int show = 0; + + for(auto iter = __addressbookIds.begin(); iter != __addressbookIds.end(); iter++) + { + if((*iter).second == true) + show++; + } + + if(all == show) + return true; + else + return false; +} + + +void CtListModelFilter::__initAddressbook() +{ + WENTER(); + int err = CONTACTS_ERROR_NONE; + contacts_list_h list = NULL; + contacts_record_h addressbookRecord = NULL; + CtAddressbookInfo *addressbookInfo = NULL; + + __addressbookList.clear(); + + err = contacts_db_get_all_records(_contacts_address_book._uri, 0, 0, &list); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_all_records() Failed(%d)", err); + while (CONTACTS_ERROR_NONE == contacts_list_get_current_record_p(list, &addressbookRecord)) { + addressbookInfo = new CtAddressbookInfo; + + err = contacts_record_get_int(addressbookRecord, _contacts_address_book.id, &addressbookInfo->addressbookId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int(_contacts_address_book.id) Failed(%d)", err); + + err = contacts_record_get_int(addressbookRecord, _contacts_address_book.account_id, &addressbookInfo->accountId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int(_contacts_address_book.account_id) Failed(%d)", err); + + err = contacts_record_get_int(addressbookRecord, _contacts_address_book.mode, &addressbookInfo->mode); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int(_contacts_address_book.account_id) Failed(%d)", err); + + err = contacts_record_get_str(addressbookRecord, _contacts_address_book.name, &addressbookInfo->addressbookName); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str(_contacts_address_book.name) Failed(%d)", err); + + addressbookInfo->iconPath = NULL; + addressbookInfo->displayName = NULL; + addressbookInfo->display = false; + WDEBUG("addressbookId %d accountId %d", addressbookInfo->addressbookId, addressbookInfo->accountId); + + __addressbookList.insert(std::make_pair(addressbookInfo->addressbookId, addressbookInfo)); + + contacts_list_next(list); + } + err = contacts_list_destroy(list, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_destroy() Failed(%d)", err); + + WLEAVE(); +} + +int CtListModelFilter::__getDisplayAddressbookCount() +{ + int count = 0; + + for(auto iter = __addressbookList.begin(); iter != __addressbookList.end(); iter++) { + if((*iter).second->display == true) + count++; + } + + return count; +} + +void CtListModelFilter::__setDisplayAddressbookAsPreference() +{ + int displayCount = 0; + if(__listOp == CT_GET_LIST_ALL_PERSON_REMOVE_FAVORITE || __listOp == CT_GET_LIST_ALL_PERSON_ADD_FAVORITE + || __listOp == CT_GET_LIST_ALL_PERSON_REORDER_FAVORITE) { + WDEBUG("favorite list is not effected by addressbook setting"); + for(auto iter = __addressbookList.begin(); iter != __addressbookList.end(); iter++) { + (*iter).second->display = true; + displayCount++; + continue; + } + } + else { + char *string = NULL; + preference_get_string(CT_KEY_LIST_DISPLAY_ADDRESSBOOK, &string); + WDEBUG("display addressbookid %s", string); + int hasCondition = SAFE_STRLEN(string); + std::unique_ptr<std::vector<int>> addressbookIds(CtListModelFilter::__makeTokenizeAddressbookList(string, ";")); + free(string); + for(auto iter = __addressbookList.begin(); iter != __addressbookList.end(); iter++) { + if (hasCondition == 0) { // display all + (*iter).second->display = true; + displayCount++; + continue; + } + + if(std::find(addressbookIds->begin(), addressbookIds->end(), (*iter).first) != addressbookIds->end()) { + (*iter).second->display = true; + displayCount++; + } + else { + (*iter).second->display = false; + } + + WDEBUG("addressbookid %d, display %d", (*iter).first, (*iter).second->display); + } + } + + if(displayCount == 0) { + WDEBUG("show all"); + for(auto iter = __addressbookList.begin(); iter != __addressbookList.end(); iter++) { + (*iter).second->display = true; + continue; + } + } +} + +void CtListModelFilter::__setDisplayAddressbookAsAppcontrol(int addressbookId) +{ + WDEBUG("%d", addressbookId); + + for(auto iter = __addressbookList.begin(); iter != __addressbookList.end(); iter++) { + if((*iter).first == addressbookId) { + (*iter).second->display = true; + } + else { + (*iter).second->display = false; + } + } +} + +int addressbookId; +int accountId; + +void CtListModelFilter::__setDisplayAddressbookWithoutSim() +{ + WHIT(); + int displayCount = __getDisplayAddressbookCount(); + + for(auto iter = __addressbookList.begin(); iter != __addressbookList.end(); iter++) { + if ((*iter).second->accountId > 0 || (*iter).second->addressbookId == 0) { + if(displayCount == 0) + (*iter).second->display = true; + } + else { + (*iter).second->display = false; + } + } +} + +void CtListModelFilter::__setDisplayAddressbookWithoutSimAndFacebook() +{ + WHIT(); + int displayCount = __getDisplayAddressbookCount(); + + for(auto iter = __addressbookList.begin(); iter != __addressbookList.end(); iter++) { + if ((*iter).second->mode == 101) { + (*iter).second->display = false; + } + else { + if ((*iter).second->accountId > 0 || (*iter).second->addressbookId == 0) { + if(displayCount == 0) + (*iter).second->display = true; + } + else { + (*iter).second->display = false; + } + } + } +} + +void CtListModelFilter::__setDisplayAddressbookWithoutFacebook() +{ + WHIT(); + int displayCount = __getDisplayAddressbookCount(); + + for(auto iter = __addressbookList.begin(); iter != __addressbookList.end(); iter++) { + if ((*iter).second->mode != 101) { + if(displayCount == 0) + (*iter).second->display = true; + } + else { + (*iter).second->display = false; + } + } +} + +void CtListModelFilter::__setDisplayAddressbookAll() +{ + WHIT(); + for(auto iter = __addressbookList.begin(); iter != __addressbookList.end(); iter++) { + (*iter).second->display = true; + } +} + +std::vector<int>* CtListModelFilter::__makeTokenizeAddressbookList(const char *originString, const char *delimiter) +{ + std::vector<int>* addressbookList(new std::vector<int>); + char *token = NULL; + char *copyString; + char *save; + + if(!originString) { + WDEBUG("Input string is NULL"); + delete addressbookList; + return NULL; + } + + copyString = SAFE_STRDUP(originString); + + if(copyString) { + token = strtok_r(copyString, delimiter, &save); + + if(token) + WDEBUG("list item = %s", token); + + while(token) { + //char *c = SAFE_STRDUP(p); + int id = atoi(token); + + addressbookList->push_back(id); + + token = strtok_r(NULL, delimiter, &save); + + if(token) + WDEBUG("list item = %s", token); + } + free(copyString); + } + return addressbookList; +} + +void CtListModelFilter::setDisplayAddressbook(int addressbookId, bool display) +{ + WDEBUG("addressbookId %d, display show %d", addressbookId, display); + + if(__addressbookList.find(addressbookId) != __addressbookList.end()) { + __addressbookList[addressbookId]->display = display; + } + else + WERROR("no addressbook exist"); +} + +std::map<int, CtAddressbookInfo*>& CtListModelFilter::getAddressbookList() +{ + return __addressbookList; +} + +bool CtListModelFilter::__getOpFromDataType(CtListDataType dataType) +{ + switch(dataType){ + case LIST_DATA_DEFAULT : + case LIST_DATA_ALL_PERSON : + __listOp = CT_GET_LIST_ALL_PERSON; + break; + + case LIST_DATA_PERSON_EXCEPT_SIM: + __listOp = CT_GET_LIST_ALL_PERSON_ADD_FAVORITE; + break; + case LIST_DATA_ALL_FAVORITES: + __listOp = CT_GET_LIST_ALL_PERSON_REMOVE_FAVORITE; + break; + case LIST_DATA_PERSON_WITH_NUMBER: + __listOp = CT_GET_LIST_ALL_PERSON_HAD_NUMBER; + break; + case LIST_DATA_PERSON_EXCEPT_FACEBOOK: + __listOp = CT_GET_LIST_ALL_PERSON; + __setDisplayAddressbookWithoutFacebook(); + break; + + + default: + WERROR("Invalid dataType(%d)", dataType); + return false; + } + + return true; +} + +CtListWritableType CtListModelFilter::checkConditionWritable() +{ + if(__listOp == CT_GET_LIST_PERSON_OF_WRITABLE_EXCEPT_SIM) + return LIST_FILTER_WRITABLE_EXCEPT_SIM; + else if(__listOp == CT_GET_LIST_PERSON_OF_WRITABLE_ADDRBOOK_ID) + return LIST_FILTER_WRITABLE_ALL; + + return LIST_FILTER_WRITABLE_READ_ONLY; +} diff --git a/lib-contact/ct-list/src/CtListModelFilter.h b/lib-contact/ct-list/src/CtListModelFilter.h new file mode 100644 index 0000000..c0c8fbd --- /dev/null +++ b/lib-contact/ct-list/src/CtListModelFilter.h @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __CT_LIST_DATA_FILTER_H_ +#define __CT_LIST_DATA_FILTER_H_ + +#include <vector> +#include <map> + +#include "ContactsCommon.h" +#include "ContactsDebug.h" + +#include "CtType.h" +#include "CtListModelListener.h" + +enum { // this order affects to set list_op in ct_list_create_contact_view_with_info + CT_GET_LIST_ALL_PERSON = 0, + + CT_GET_LIST_PERSON_OF_WRITABLE_EXCEPT_SIM = 4, + CT_GET_LIST_PERSON_OF_WRITABLE_ADDRBOOK_ID = 5, + CT_GET_LIST_PERSON_ASSIGNED_FAVORITE = 6, + CT_GET_LIST_PERSON_OF_BUSINESS_CARD = 7, + + CT_GET_LIST_ALL_PERSON_HAD_NUMBER = 20, + CT_GET_LIST_ALL_PERSON_HAD_EMAIL = 21, + CT_GET_LIST_ALL_PERSON_HAD_NUMBER_OR_EMAIL = 22, + CT_GET_LIST_ALL_PERSON_ADD_FAVORITE = 23, + CT_GET_LIST_ALL_PERSON_REMOVE_FAVORITE = 24, + CT_GET_LIST_ALL_PERSON_REORDER_FAVORITE = 25, + CT_GET_LIST_ALL_PERSON_HAD_NUMBER_NO_EXIST = 26, + CT_GET_LIST_VCARD = 30, +}; //list op + +enum { + CT_LIST_NORMAL = 0x00, + CT_LIST_NORMAL_CONTACT = 0x01, + CT_LIST_NORMAL_FAVORITE = 0x02, + CT_LIST_NORMAL_MEMBER = 0x03, + CT_LIST_NORMAL_SDN = 0x04, + CT_LIST_NORMAL_BUSINESS_CARDS = 0x05, + + CT_LIST_SINGLE = 0x30, + CT_LIST_SINGLE_LINK = 0x31, + CT_LIST_SINGLE_RELATION = 0x32, + + CT_LIST_SINGLE_UG = 0x50, + + CT_LIST_MULTI = 0x70, + CT_LIST_MULTI_DELETE = 0x71, + CT_LIST_MULTI_ADD_MEMBER = 0x72, + CT_LIST_MULTI_REMOVE_MEMBER = 0x73, + CT_LIST_MULTI_ADD_FAVORITE = 0x74, + CT_LIST_MULTI_REMOVE_FAVORITE = 0x75, + CT_LIST_MULTI_REORDER_FAVORITE = 0x76, + CT_LIST_MULTI_EXPORT_TO_SIM = 0x77, + CT_LIST_MULTI_EXPORT_TO_VCARD = 0x78, + CT_LIST_MULTI_IMPORT_FROM_SIM = 0x79, + CT_LIST_MULTI_IMPORT_FROM_VCARD = 0x7A, + CT_LIST_MULTI_RECIPIENT_MESSAGE_INGROUP = 0x7B, + CT_LIST_MULTI_RECIPIENT_EMAIL_INGROUP = 0x7C, + CT_LIST_MULTI_SHARE = 0x7D, + + CT_LIST_MULTI_UG = 0xA0, +}; //view id + +typedef enum { + LIST_FILTER_WRITABLE_ALL, + LIST_FILTER_WRITABLE_EXCEPT_SIM, + LIST_FILTER_WRITABLE_READ_ONLY, +}CtListWritableType; + +typedef enum { + LIST_VIEW_URI_TYPE_NONE, + LIST_VIEW_URI_TYPE_PERSON, + LIST_VIEW_URI_TYPE_PERSON_CONTACT, + LIST_VIEW_URI_TYPE_PERSON_USAGE, +// LIST_VIEW_URI_TYPE_PERSON_BUSINESS_CARD, +}CtListViewUriType; + +typedef enum { + LIST_HAS_NONE, + LIST_HAS_NUMBER, + LIST_HAS_EMAIL, + LIST_HAS_NUMBER_OR_EMAIL, +}CtListHasType; + +typedef enum { + LIST_FAVORITE_NONE, + LIST_FAVORITE_SET, + LIST_FAVORITE_UNSET, +}CtListFavoriteType; + +typedef enum { + LIST_PROJECTION_NONE, + LIST_PERSON_PROJECTION, + LIST_PERSON_SEARCH_PROJECTION, + LIST_PERSON_CONTACT_PROJECTION, + LIST_PERSON_GROUPREL_PROJECTION, + LIST_PERSON_GROUPNOTASSIGNED_PROJECTION, +}CtListProjectionType; + + +class CtListModelFilter +{ +public: + CtListModelFilter(CtListHasType filterType); + CtListModelFilter(CtListDataType dataType); + virtual ~CtListModelFilter(); + +public: + contacts_query_h getQuery(CtListQueryType queryType); + + std::map<int, CtAddressbookInfo*>& getAddressbookList(); + void setDisplayAddressbook(int addressbookId, bool display); + void setListHasType(CtListHasType hasType); + void attachListener(CtListModelListener *listener); + CtListWritableType checkConditionWritable(); + +private: + bool __getOpFromDataType(CtListDataType dataType); + void __initialize(void); + void __initHasType(); + bool __checkAddressbook() const; + + CtListHasType __getListHasType() const; + CtListFavoriteType __getListFavoriteType() const; + + void __initAddressbook(); + int __getDisplayAddressbookCount(); + void __setDisplayAddressbookAsPreference(); + void __setDisplayAddressbookAsAppcontrol(int addressbookId); + void __setDisplayAddressbookWithoutSim(); + void __setDisplayAddressbookWithoutSimAndFacebook(); + void __setDisplayAddressbookWithoutFacebook(); + void __setDisplayAddressbookAll(); + static std::vector<int>* __makeTokenizeAddressbookList(const char *originString, const char *delimiter); + + static void __onDisplayWithNumberChangedCb(const char *key, void *data); + static void __onDisplayAddressbookChangedCb(const char *key, void *data); + +private: + int __listOp; + int __selectedPersonId; + int __viewId; + int __ugRequest; + char* __ugData; + std::vector<int> excludePersonId; + std::map<int, bool> __addressbookIds; + + + CtListHasType __hasType; + bool __IsSearchQuery; + + CtListModelListener *__listener; + std::map<int, CtAddressbookInfo*> __addressbookList; +}; + +#endif + diff --git a/lib-contact/ct-list/src/CtListModelGroup.cpp b/lib-contact/ct-list/src/CtListModelGroup.cpp new file mode 100755 index 0000000..217d98c --- /dev/null +++ b/lib-contact/ct-list/src/CtListModelGroup.cpp @@ -0,0 +1,419 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <contacts.h> + +#include "CtString.h" +#include "ContactsDebug.h" +#include "CtListModelGroup.h" + +CtListModelGroup::CtListModelGroup() +{ + WENTER(); + + __initialize(); +} + +CtListModelGroup::~CtListModelGroup() +{ + WENTER(); + + __groupDataList.clear(); + __groupMemberDataList.clear(); +} + + +std::shared_ptr< CtListDataPerson > CtListModelGroup::getAtPersonData(int index) +{ + if (index < (int)__groupMemberDataList.size()) { + return __groupMemberDataList[index]; + } + else { + return NULL; + } +} + +std::shared_ptr< CtListDataGroup > CtListModelGroup::getAtGroupData(int index) +{ + if (index < (int)__groupDataList.size()) { + return __groupDataList[index]; + } + else { + return NULL; + } +} + +int CtListModelGroup::getAvailableGroupCount(void) +{ + WENTER(); + + int count = 0; + int err = CONTACTS_ERROR_NONE; + + contacts_query_h query = NULL; + + unsigned int group_projection[] = { + _contacts_group_relation.group_id, + }; + + err = contacts_query_create(_contacts_group_relation._uri, &query); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_create() Failed(%d)", err); + err = contacts_query_set_projection(query, group_projection, sizeof(group_projection)/sizeof(int)); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_projection() Failed(%d)", err); + err = contacts_query_set_distinct(query, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_distinct() Failed(%d)", err); + + err = contacts_db_get_count_with_query(query, &count); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_records_with_query() Failed(%d)", err); + + err = contacts_query_destroy(query); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_destroy() Failed(%d)", err); + + WDEBUG("count : %d", count); + + return count; + +} + +int CtListModelGroup::getAvailableGroups(void) +{ + WENTER(); + + int offset = 0; + int limit = 0; + int err = CONTACTS_ERROR_NONE; + + contacts_list_h list = NULL; + contacts_query_h query = NULL; + + __groupDataList.clear(); + + err = contacts_query_create(_contacts_group_relation._uri, &query); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_create() Failed(%d)", err); + err = contacts_query_set_sort(query, _contacts_group_relation.name, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_sort() Failed(%d)", err); + err = contacts_query_set_distinct(query, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_distinct() Failed(%d)", err); + + err = contacts_db_get_records_with_query(query, offset, limit, &list); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_records_with_query() Failed(%d)", err); + + err = contacts_query_destroy(query); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_destroy() Failed(%d)", err); + + int count = 0; + err = contacts_list_get_count(list, &count); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_get_count() Failed(%d)", err); + + if(count > 0) { + count = __makeGroupListUnifiedByName(list, false); + } + + WDEBUG("count : %d", count); + + err = contacts_list_destroy(list, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_destroy() Failed(%d)", err); + + return count; +} + +int CtListModelGroup::getAllMembersByGroupName(char* groupName) +{ + __groupMemberDataList.clear(); + + int err = CONTACTS_ERROR_NONE; + int offset = 0; + int limit = 0; + + contacts_list_h list = NULL; + contacts_query_h query = NULL; + + query = __getQuery(groupName); + + err = contacts_db_get_records_with_query(query, offset, limit, &list); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_records_with_query() Failed(%d)", err); + + err = contacts_query_destroy(query); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_destroy() Failed(%d)", err); + + int count = 0; + err = contacts_list_get_count(list, &count); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_get_count() Failed(%d)", err); + + if (count > 0) { + __makeMemberList(list); + } + + err = contacts_list_destroy(list, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_destroy() Failed(%d)", err); + + return count; +} + +void CtListModelGroup::__initialize(void) +{ + __groupDataList.clear(); + __groupMemberDataList.clear(); +} + +contacts_query_h CtListModelGroup::__getQuery(char* groupName) +{ + unsigned int person_group_projection[] = { + _contacts_person_grouprel.person_id, + _contacts_person_grouprel.status, + _contacts_person_grouprel.display_name, + _contacts_person_grouprel.display_name_index, + _contacts_person_grouprel.addressbook_ids, + _contacts_person_grouprel.has_phonenumber, + _contacts_person_grouprel.image_thumbnail_path, + _contacts_person_grouprel.is_favorite, + }; + + contacts_query_h query = NULL; + contacts_filter_h filter = NULL; + + int err = CONTACTS_ERROR_NONE; + + err = contacts_query_create(_contacts_person_grouprel._uri, &query); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_create() Failed(%d)", err); + err = contacts_filter_create(_contacts_person_grouprel._uri, &filter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + + std::vector<int> groupIds = __getGroupIdsByName(groupName); + + bool isFirst = true; + for (auto iter = groupIds.begin(); iter != groupIds.end(); iter++) { + if (isFirst) { + isFirst = false; + } + else { + err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_OR); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_operator() Failed(%d)", err); + } + err = contacts_filter_add_int(filter, _contacts_person_grouprel.group_id, CONTACTS_MATCH_EQUAL, *iter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_int() Failed(%d)", err); + } + + err = contacts_query_set_projection(query, person_group_projection, sizeof(person_group_projection)/sizeof(int)); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_projection() Failed(%d)", err); + err = contacts_query_set_distinct(query, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_distinct() Failed(%d)", err); + err = contacts_query_set_filter(query, filter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_filter() Failed(%d)", err); + + err = contacts_filter_destroy(filter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_destroy() Failed(%d)", err); + + groupIds.clear(); + + return query; +} + +int CtListModelGroup::__makeGroupListUnifiedByName(contacts_list_h list, bool needNotList) +{ + WENTER(); + + WPRET_VM(list == NULL, 0, "list is NULL"); + + int err = CONTACTS_ERROR_NONE; + int groupCount = 0; + + char* groupName = strdup(""); + + contacts_record_h recordGroup = NULL; + while (CONTACTS_ERROR_NONE == contacts_list_get_current_record_p(list, &recordGroup)) { + if (recordGroup){ + char* currentName = NULL; + + err = contacts_record_get_str_p(recordGroup, _contacts_group_relation.name, ¤tName); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + if ((SAFE_STRCMP(currentName, "") != 0 && SAFE_STRCMP(currentName, groupName)) == 0) { + err = contacts_list_next(list); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_next() Failed(%d)", err); + + continue; + } + + if (needNotList == false) { + std::shared_ptr < CtListDataGroup > dataGroup (std::make_shared < CtListDataGroup > (recordGroup)); + __groupDataList.push_back(dataGroup); + } + + groupCount++; + + if (groupName) { + free(groupName); + groupName = NULL; + } + groupName = SAFE_STRDUP(currentName); + } + err = contacts_list_next(list); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_next() Failed(%d)", err); + } + if (groupName) { + free(groupName); + } + + return groupCount; +} + +int CtListModelGroup::__makeMemberList(contacts_list_h list) +{ + int memberCount = 0; + int err = CONTACTS_ERROR_NONE; + + contacts_record_h recordMember = NULL; + while (CONTACTS_ERROR_NONE == contacts_list_get_current_record_p(list, &recordMember)) { + if (recordMember){ + std::shared_ptr < CtListDataPerson > dataPerson (std::make_shared < CtListDataPerson > (recordMember)); + __groupMemberDataList.push_back(dataPerson); + memberCount++; + } + err = contacts_list_next(list); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_next() Failed(%d)", err); + } + + return memberCount; +} + +std::vector<int> CtListModelGroup::__getGroupIdsByName(char* groupName) +{ + std::vector<int> groupIds; + groupIds.clear(); + + int err = CONTACTS_ERROR_NONE; + + contacts_filter_h filter = NULL; + contacts_query_h query = NULL; + contacts_list_h list = NULL; + contacts_record_h record = NULL; + + unsigned int group_projection[] = { + _contacts_group.id, + _contacts_group.name, + }; + + err = contacts_filter_create(_contacts_group._uri, &filter); + WPRET_VM(CONTACTS_ERROR_NONE != err, groupIds, "contactcs_filter_create() Failed(%d)", err); + + // search records which have same name + err = contacts_filter_add_str(filter, _contacts_group.name, CONTACTS_MATCH_EXACTLY, groupName); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_filter_add_str() Failed(%d)", err); + contacts_filter_destroy(filter); + + return groupIds; + } + + // add filter for google default groups + if (SAFE_STRCMP(groupName, V_("IDS_PB_BODY_MY_CONTACTS")) == 0) { + err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_OR); + WERROR("contacts_filter_add_operator() Failed(%d)", err); + err = contacts_filter_add_str(filter, _contacts_group.name, CONTACTS_MATCH_EXACTLY, "System Group: My Contacts"); + WERROR("contacts_filter_add_str() Failed(%d)", err); + } + else if (SAFE_STRCMP(groupName, V_("IDS_PB_BODY_DEFAULT_GROUP_FRIENDS")) == 0) { + err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_OR); + WERROR("contacts_filter_add_operator() Failed(%d)", err); + err = contacts_filter_add_str(filter, _contacts_group.name, CONTACTS_MATCH_EXACTLY, "System Group: Friends"); + WERROR("contacts_filter_add_str() Failed(%d)", err); + } + else if (SAFE_STRCMP(groupName, V_("IDS_PB_BODY_DEFAULT_GROUP_FAMILY")) == 0) { + err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_OR); + WERROR("contacts_filter_add_operator() Failed(%d)", err); + err = contacts_filter_add_str(filter, _contacts_group.name, CONTACTS_MATCH_EXACTLY, "System Group: Family"); + WERROR("contacts_filter_add_str() Failed(%d)", err); + } + else if (SAFE_STRCMP(groupName, V_("IDS_PB_BODY_CO_WORKERS")) == 0) { + err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_OR); + WERROR("contacts_filter_add_operator() Failed(%d)", err); + err = contacts_filter_add_str(filter, _contacts_group.name, CONTACTS_MATCH_EXACTLY, "System Group: Coworkers"); + WERROR("contacts_filter_add_str() Failed(%d)", err); + } + if (CONTACTS_ERROR_NONE != err) { + contacts_filter_destroy(filter); + + return groupIds; + } + + err = contacts_query_create(_contacts_group._uri, &query); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_query_create() Failed(%d)", err); + contacts_filter_destroy(filter); + + return groupIds; + } + err = contacts_query_set_filter(query, filter); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_query_set_filter() Failed(%d)", err); + contacts_filter_destroy(filter); + contacts_query_destroy(query); + + return groupIds; + } + contacts_filter_destroy(filter); + + err = contacts_query_set_projection(query, group_projection, sizeof(group_projection)/sizeof(int)); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_query_set_projection() Failed(%d)", err); + contacts_query_destroy(query); + + return groupIds; + } + + if (query == NULL) { + WERROR("query is NULL !!"); + return groupIds; + } + + err = contacts_db_get_records_with_query(query, 0, 0, &list); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_db_get_records_with_query() Failed(%d)", err); + contacts_query_destroy(query); + if(list) + contacts_list_destroy(list, true); + return groupIds; + } + contacts_query_destroy(query); + + int count = 0; + + contacts_list_get_count(list, &count); + if (0 == count) { + WERROR("no contact records found"); + if(list) + contacts_list_destroy(list, true); + return groupIds; + } + + int groupId = 0; + + while (CONTACTS_ERROR_NONE == contacts_list_get_current_record_p(list, &record)) { + err = contacts_record_get_int(record, _contacts_group.id, &groupId); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_int Failed(%d)", err); + break; + } + + groupIds.push_back(groupId); + contacts_list_next(list); + } + contacts_list_destroy(list, true); + + return groupIds; +} diff --git a/lib-contact/ct-list/src/CtListModelGroup.h b/lib-contact/ct-list/src/CtListModelGroup.h new file mode 100755 index 0000000..e4f4616 --- /dev/null +++ b/lib-contact/ct-list/src/CtListModelGroup.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __CT_LIST_MODEL_GROUP_H_ +#define __CT_LIST_MODEL_GROUP_H_ + +#include <contacts.h> +#include <memory> +#include <vector> + +#include "CtListDataPerson.h" +#include "CtListDataGroup.h" + +class ICtChangeListener; + +class CtListModelGroup +{ +public: + CtListModelGroup(); + virtual ~CtListModelGroup(); + +public: + int getAvailableGroupCount(void); + int getAvailableGroups(void); + std::shared_ptr< CtListDataGroup > getAtGroupData(int index); + std::shared_ptr< CtListDataPerson > getAtPersonData(int index); + int getAllMembersByGroupName(char* groupName); + +private: + void __initialize(void); + int __makeGroupListUnifiedByName(contacts_list_h list, bool needNotList); + contacts_query_h __getQuery(char* groupName); + int __makeMemberList(contacts_list_h list); + std::vector<int> __getGroupIdsByName(char* groupName); + +private: + std::vector<std::shared_ptr< CtListDataGroup >> __groupDataList; + std::vector<std::shared_ptr< CtListDataPerson >> __groupMemberDataList; +}; + +#endif // __CT_LIST_MODEL_GROUP_H_ diff --git a/lib-contact/ct-list/src/CtListModelLinkSuggest.cpp b/lib-contact/ct-list/src/CtListModelLinkSuggest.cpp new file mode 100755 index 0000000..487237d --- /dev/null +++ b/lib-contact/ct-list/src/CtListModelLinkSuggest.cpp @@ -0,0 +1,495 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <thread> +#include <contacts.h> +#include <algorithm> + +#include "ContactsDebug.h" +#include "CtType.h" +#include "ContactsCommon.h" +#include "CtListDataPerson.h" +#include "CtListModelLinkSuggest.h" + +CtListModelLinkSuggest::CtListModelLinkSuggest(const int selectedPersonId) +: __listener(NULL) +{ + WENTER(); + + __listener = NULL; + __selectedName = NULL; + __selectedPersonId = selectedPersonId; + + __nameQuery = NULL; + __emailQuery = NULL; + __numberQuery = NULL; + + __nameList = NULL; + __emailList = NULL; + __numberList = NULL; + + __setLinkContactData(__selectedPersonId); + __makeQuery(); + + __getQueryResult(); + __makePersonList(); + + +} + +CtListModelLinkSuggest::~CtListModelLinkSuggest() +{ + WENTER(); + int err = CONTACTS_ERROR_NONE; + + err = contacts_list_destroy(__nameList, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_destroy() Failed(%d)", err); + err = contacts_list_destroy(__emailList, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_destroy() Failed(%d)", err); + err = contacts_list_destroy(__numberList, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_destroy() Failed(%d)", err); + + err = contacts_query_destroy(__nameQuery); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_destroy() Failed(%d)", err); + err = contacts_query_destroy(__emailQuery); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_destroy() Failed(%d)", err); + err = contacts_query_destroy(__numberQuery); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_destroy() Failed(%d)", err); + + + for(auto iter = __vcSelectedNumber.begin(); iter != __vcSelectedNumber.end(); iter++) { + free(*iter); + } + + for(auto iter = __vcSelectedEmail.begin(); iter != __vcSelectedEmail.end(); iter++) { + free(*iter); + } + __vcSelectedEmail.clear(); + __vcSelectedNumber.clear(); + __personDataList.clear(); + +} + +int CtListModelLinkSuggest::getContactsCount(CtListQueryType queryType) +{ + + return getPersonListCount(LIST_QUERY_DEFAULT); +} + +int CtListModelLinkSuggest::getContacts(CtListQueryType queryType, CtGetContactsType syncType) +{ + if(queryType == LIST_QUERY_DEFAULT) + return __personDataList.size(); + else + WERROR("wrong queryType %d", queryType); + + return 0; +} + +std::shared_ptr<CtListDataPerson> CtListModelLinkSuggest::getAtPersonData(int index, CtListQueryType queryType) +{ + if(queryType == LIST_QUERY_DEFAULT) { + if(index < (int)__personDataList.size()) + return __personDataList[index].second; + else + return NULL; + } + else { + return NULL; + } +} + +int CtListModelLinkSuggest::getPersonListCount(CtListQueryType queryType) +{ + WENTER(); +/* + int err = CONTACTS_ERROR_NONE; + + + int nameCount =0; + int numberCount =0; + int emailCount =0; + + + err = contacts_db_get_count_with_query(__nameQuery, &nameCount); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_count_with_query() Failed(%d)", err); + err = contacts_db_get_count_with_query(__numberQuery, &numberCount); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_count_with_query() Failed(%d)", err); + err = contacts_db_get_count_with_query(__emailQuery, &emailCount); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_count_with_query() Failed(%d)", err); +*/ + //todo + return __personDataList.size(); +} + +void CtListModelLinkSuggest::attachListener(ICtChangeListener* listener) +{ + WHIT(); + __listener = listener; +} + +void CtListModelLinkSuggest::__setLinkContactData(int personId) +{ + WENTER(); + + int err = CONTACTS_ERROR_NONE; + contacts_record_h contactRecord = NULL; + contacts_record_h selectedRecord = NULL; + contacts_record_h nameRecord = NULL; + contacts_record_h emailRecord = NULL; + contacts_record_h numberRecord = NULL; + char *value = NULL; + int contactId =0; + int count =0; + + + err = contacts_db_get_record(_contacts_person._uri,personId, &selectedRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_record() Failed(%d)", err); + err = contacts_record_get_int(selectedRecord, _contacts_person.display_contact_id, &contactId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + err = contacts_db_get_record(_contacts_contact._uri,contactId, &contactRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_record() Failed(%d)", err); + + err = contacts_record_get_child_record_at_p(contactRecord,_contacts_contact.name,0,&nameRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_child_record_at_p() Failed(%d)", err); + err = contacts_record_get_str(nameRecord,_contacts_name.first, &__selectedName); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + + err = contacts_record_get_child_record_count(contactRecord,_contacts_contact.number,&count); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_child_record_at_p() Failed(%d)", err); + for(int i = 0; i < (int)count ; i++){ + err = contacts_record_get_child_record_at_p(contactRecord,_contacts_contact.number, i, &numberRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_child_record_at_p() Failed(%d)", err); + err = contacts_record_get_str(numberRecord,_contacts_number.number, &value); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + __vcSelectedNumber.push_back(value); + } + + err = contacts_record_get_child_record_count(contactRecord,_contacts_contact.email,&count); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_child_record_at_p() Failed(%d)", err); + for(int i = 0; i < (int)count ; i++){ + err = contacts_record_get_child_record_at_p(contactRecord,_contacts_contact.email, i, &emailRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_child_record_at_p() Failed(%d)", err); + err = contacts_record_get_str(emailRecord,_contacts_email.email, &value); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + __vcSelectedEmail.push_back(value); + } + +} +int CtListModelLinkSuggest::__makeQuery() +{ + + contacts_filter_h filter = NULL; + int err = CONTACTS_ERROR_NONE; + + unsigned int personProjection[] = { + _contacts_person.id, + _contacts_person.addressbook_ids, + _contacts_person.display_name, + _contacts_person.has_phonenumber, + _contacts_person.image_thumbnail_path, + _contacts_person.display_name_index, + _contacts_person.is_favorite, + }; + + unsigned int numberProjection[] = { + _contacts_person_number.person_id, + _contacts_person_number.display_name, + _contacts_person_number.display_contact_id, + _contacts_person_number.has_phonenumber, + _contacts_person_number.image_thumbnail_path, + _contacts_person_number.is_favorite, + _contacts_person_number.display_name_index, + }; + + unsigned int emailProjection[] = { + _contacts_person_email.person_id, + _contacts_person_email.display_name, + _contacts_person_email.display_contact_id, + _contacts_person_email.has_phonenumber, + _contacts_person_email.image_thumbnail_path, + _contacts_person_email.is_favorite, + _contacts_person_email.display_name_index, + }; + + if(__selectedName != NULL){ + err = contacts_query_create(_contacts_person._uri, &__nameQuery); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_create() Failed(%d)", err); + err = contacts_filter_create(_contacts_person._uri, &filter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + err = contacts_filter_add_str(filter, _contacts_person.display_name, CONTACTS_MATCH_CONTAINS, __selectedName); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_str() Failed(%d)", err); + err = contacts_query_set_filter(__nameQuery, filter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_filter() Failed(%d)", err); + err = contacts_query_set_projection(__nameQuery, personProjection, sizeof(personProjection)/sizeof(int)); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_projection() Failed(%d)", err); + err = contacts_filter_destroy(filter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_destroy() Failed(%d)", err); + } + + if(__vcSelectedNumber.size() > 0){ + err = contacts_query_create(_contacts_person_number._uri, &__numberQuery); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_create() Failed(%d)", err); + err = contacts_filter_create(_contacts_person_number._uri, &filter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + for(auto iter = __vcSelectedNumber.begin(); iter != __vcSelectedNumber.end(); iter++) { + + if(iter != __vcSelectedNumber.begin()){ + err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_OR); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_operator() Failed(%d)", err); + } + + err = contacts_filter_add_str(filter, _contacts_person_number.number, CONTACTS_MATCH_EXACTLY, *iter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_str() Failed(%d)", err); + } + err = contacts_query_set_filter(__numberQuery, filter); + WPWARN(CONTACTS_ERROR_NONE != err, "__list_create_filter_bool() Failed(%d)", err); + err = contacts_query_set_projection(__numberQuery, numberProjection, sizeof(numberProjection)/sizeof(int)); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_projection() Failed(%d)", err); + err = contacts_filter_destroy(filter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_destroy() Failed(%d)", err); + + } + + if(__vcSelectedEmail.size() > 0){ + err = contacts_query_create(_contacts_person_email._uri, &__emailQuery); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_create() Failed(%d)", err); + err = contacts_filter_create(_contacts_person_email._uri, &filter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_create() Failed(%d)", err); + for(auto iter = __vcSelectedEmail.begin(); iter != __vcSelectedEmail.end(); iter++) { + + if(iter != __vcSelectedEmail.begin()){ + err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_OR); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_operator() Failed(%d)", err); + } + + err = contacts_filter_add_str(filter, _contacts_person_email.email, CONTACTS_MATCH_EXACTLY, *iter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_add_str() Failed(%d)", err); + } + err = contacts_query_set_filter(__emailQuery, filter); + WPWARN(CONTACTS_ERROR_NONE != err, "__list_create_filter_bool() Failed(%d)", err); + err = contacts_query_set_projection(__emailQuery, emailProjection, sizeof(emailProjection)/sizeof(int)); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_query_set_projection() Failed(%d)", err); + err = contacts_filter_destroy(filter); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_filter_destroy() Failed(%d)", err); + + + } + return err; +} + +int CtListModelLinkSuggest::__getQueryResult() +{ + WENTER(); + int err = CONTACTS_ERROR_NONE; + + + int totalCount =0; + int count =0; + + err = contacts_db_get_records_with_query(__nameQuery, 0, 0, &__nameList); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_records_with_query() Failed(%d)", err); + + err = contacts_db_get_records_with_query(__numberQuery, 0, 0, &__numberList); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_records_with_query() Failed(%d)", err); + + err = contacts_db_get_records_with_query(__emailQuery, 0, 0, &__emailList); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_records_with_query() Failed(%d)", err); + + err = contacts_list_get_count(__nameList, &count); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_get_count() Failed(%d)", err); + totalCount += count; + + err = contacts_list_get_count(__numberList, &count); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_get_count() Failed(%d)", err); + totalCount += count; + + err = contacts_list_get_count(__emailList, &count); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_get_count() Failed(%d)", err); + totalCount += count; + + if(totalCount > 0){ + __makePersonList(); + } + return err; + +} + +int CtListModelLinkSuggest::__makePersonList() +{ + contacts_record_h record = NULL; + int err = CONTACTS_ERROR_NONE; + + while (CONTACTS_ERROR_NONE == contacts_list_get_current_record_p(__nameList, &record)) { + if(record){ + std::shared_ptr<CtListDataPerson> dataPerson(std::make_shared<CtListDataPerson>(record)); + + int personId = 0; + err = contacts_record_get_int(record, _contacts_person.id, &personId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + if (__selectedPersonId == personId) { + contacts_list_next(__nameList); + continue; + } + if(__selectedPersonId == personId) { + contacts_list_next(__nameList); + continue; + } + std::vector<std::pair<int, std::shared_ptr<CtListDataPerson>>>::iterator existIter = std::find_if( __personDataList.begin(), __personDataList.end(), + [personId](std::pair<int, std::shared_ptr<CtListDataPerson>> dataPerson)->bool { + if(dataPerson.first == personId) { + return true; + } + return false; + } + ); + if(existIter != __personDataList.end()){ + contacts_list_next(__nameList); + continue; + } + __personDataList.push_back(std::make_pair(dataPerson->getPersonId(), dataPerson)); + } + err = contacts_list_next(__nameList); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_next() Failed(%d)", err); + } + + while (CONTACTS_ERROR_NONE == contacts_list_get_current_record_p(__numberList, &record)) { + if(record){ + std::shared_ptr<CtListDataPerson> dataPerson(std::make_shared<CtListDataPerson>(record)); + + int personId = 0; + err = contacts_record_get_int(record, _contacts_person_number.person_id, &personId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + if (__selectedPersonId == personId) { + contacts_list_next(__numberList); + continue; + } + if(__selectedPersonId == personId) { + contacts_list_next(__numberList); + continue; + } + + std::vector<std::pair<int, std::shared_ptr<CtListDataPerson>>>::iterator existIter = std::find_if( __personDataList.begin(), __personDataList.end(), + [personId](std::pair<int, std::shared_ptr<CtListDataPerson>> dataPerson)->bool { + if(dataPerson.first == personId) { + return true; + } + return false; + } + ); + if(existIter != __personDataList.end()){ + contacts_list_next(__numberList); + continue; + } + __personDataList.push_back(std::make_pair(dataPerson->getPersonId(), dataPerson)); + } + err = contacts_list_next(__numberList); + } + + while (CONTACTS_ERROR_NONE == contacts_list_get_current_record_p(__emailList, &record)) { + if(record){ + std::shared_ptr<CtListDataPerson> dataPerson(std::make_shared<CtListDataPerson>(record)); + + int personId = 0; + err = contacts_record_get_int(record, _contacts_person_email.person_id, &personId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + if (__selectedPersonId == personId) { + contacts_list_next(__emailList); + continue; + } + if(__selectedPersonId == personId) { + contacts_list_next(__emailList); + continue; + } + + std::vector<std::pair<int, std::shared_ptr<CtListDataPerson>>>::iterator existIter = std::find_if( __personDataList.begin(), __personDataList.end(), + [personId](std::pair<int, std::shared_ptr<CtListDataPerson>> dataPerson)->bool { + if(dataPerson.first == personId) { + return true; + } + return false; + } + ); + if(existIter != __personDataList.end()){ + contacts_list_next(__emailList); + continue; + } + __personDataList.push_back(std::make_pair(dataPerson->getPersonId(), dataPerson)); + } + err = contacts_list_next(__emailList); + } + + + return 0; +} + +void CtListModelLinkSuggest::setSelectedPersonId(int selectedPersonId) +{ + // empty +} + +const char* CtListModelLinkSuggest::getSearchString(void) +{ + return NULL; +} + +bool CtListModelLinkSuggest::setSearchString(char* search) +{ + return false; +} + +void CtListModelLinkSuggest::getNumberSearchString(const std::shared_ptr<CtListDataPerson>& dataPerson, std::string &numberStr) +{ + +} + +int CtListModelLinkSuggest::getCheckedDataCount() +{ + return 0; +} + +int CtListModelLinkSuggest::getLimitCount() +{ + return 0; +} + +void CtListModelLinkSuggest::initialOriginalCheckedIdList() +{ +} + +void CtListModelLinkSuggest::clearOriginalCheckedIdList() +{ +} + +bool CtListModelLinkSuggest::checkIsSelectAllOnSearching() +{ + return false; +} + +void CtListModelLinkSuggest::initialOriginalPersonDataListSize() +{ +} + +void CtListModelLinkSuggest::clearOriginalPersonDataListSize() +{ +} + +int CtListModelLinkSuggest::getOriginalPersonDataListSize() +{ + return 0; +} diff --git a/lib-contact/ct-list/src/CtListModelLinkSuggest.h b/lib-contact/ct-list/src/CtListModelLinkSuggest.h new file mode 100644 index 0000000..73119a8 --- /dev/null +++ b/lib-contact/ct-list/src/CtListModelLinkSuggest.h @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __CT_LIST_MODEL_LINK_SUGGEST_H_ +#define __CT_LIST_MODEL_LINK_SUGGEST_H_ + +#include <vector> +#include <string> +#include <functional> +#include <contacts.h> +#include <memory> +#include <Ecore.h> +#include <Elementary.h> + +#include "CtType.h" +#include "CtCommon.h" +#include "ContactsCommon.h" +#include "CtListModel.h" +#include "CtListDataPerson.h" + +class ICtChangeListener; + +class CtListModelLinkSuggest : public CtListModel +{ +public: + CtListModelLinkSuggest(const int selectedPersonId); + virtual ~CtListModelLinkSuggest(); + +public: + // CtListModel interfaces + virtual int getContactsCount(CtListQueryType queryType); + virtual int getContacts(CtListQueryType queryType, CtGetContactsType syncType); + virtual int cancelGetContacts() { return 0; } + virtual std::shared_ptr<CtListDataPerson> getAtPersonData(int index, CtListQueryType queryType); + virtual int getPersonListCount(CtListQueryType queryType); + virtual void attachListener(ICtChangeListener* listener); + + virtual void setSelectedPersonId(int selectedPersonId); + virtual const char* getSearchString(void); + virtual bool setSearchString(char* search); + virtual void getNumberSearchString(const std::shared_ptr<CtListDataPerson>& dataPerson, std::string &numberStr); + virtual int getCheckedDataCount(); + virtual int getLimitCount(); + virtual int getCurrentLinkedCount() { return 0; } + + void setOnLoadingCb(std::function<void (int, int)> loadingCb); + void resetLoadingCb(); + + std::vector<std::shared_ptr<CtListDataPerson>>* getCheckedDataList() const; + + virtual void initialOriginalCheckedIdList(); + virtual void clearOriginalCheckedIdList(); + virtual bool checkIsSelectAllOnSearching(); + virtual void initialOriginalPersonDataListSize(); + virtual void clearOriginalPersonDataListSize(); + virtual int getOriginalPersonDataListSize(); + +private: + void __setLinkContactData(int personId); + int __makePersonList(); + int __getQueryResult(); + int __makeQuery(); + +private: + ICtChangeListener* __listener; + std::vector<std::pair<int, std::shared_ptr<CtListDataPerson>>> __personDataList; + + int __selectedPersonId; + char *__selectedName; + std::vector<char *>__vcSelectedEmail; + std::vector<char *>__vcSelectedNumber; + + contacts_list_h __nameList; + contacts_list_h __emailList; + contacts_list_h __numberList; + + contacts_query_h __nameQuery; + contacts_query_h __emailQuery; + contacts_query_h __numberQuery; + +}; + +#endif + diff --git a/lib-contact/ct-list/src/CtListModelListener.h b/lib-contact/ct-list/src/CtListModelListener.h new file mode 100644 index 0000000..1197773 --- /dev/null +++ b/lib-contact/ct-list/src/CtListModelListener.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_LIST_MODEL_LISTENER_H_ +#define _CT_LIST_MODEL_LISTENER_H_ + +class CtListModelListener +{ +public: + virtual ~CtListModelListener(){}; + virtual void onFilterChanged() = 0; +}; + +#endif // _CT_LIST_MODEL_LISTENER_H_ + diff --git a/lib-contact/ct-list/src/CtListModelMergeContacts.cpp b/lib-contact/ct-list/src/CtListModelMergeContacts.cpp new file mode 100755 index 0000000..5ec7a82 --- /dev/null +++ b/lib-contact/ct-list/src/CtListModelMergeContacts.cpp @@ -0,0 +1,689 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <map> +#include <string> +#include <list> +#include <thread> +#include <string.h> +#include <contacts.h> +#include "WView.h" +#include "WToastPopup.h" +#include "ContactsDebug.h" +#include "CtType.h" +#include "CtListModelMergeContacts.h" +#include "CtCommon.h" + +__Group::~__Group() +{ +} + +__Person::__Person() +: personId(0) +, addressbookMode(0) +, addressbookId(0) +, representative(false) +,favorite(FALSE) +, group(NULL) +{ +} + +CtListModelMergeContacts::CtListModelMergeContacts() +: __finder(NULL) +, __canceled(false) +, __resultCb(NULL) +{ + WHIT(); + + __simAddressbookIds[0] = -1; + __simAddressbookIds[1] = -1; + __initSimAddressbookIds(); +} + +CtListModelMergeContacts::~CtListModelMergeContacts() +{ + WHIT(); + __canceled = true; + + __finder->join(); + delete __finder; +} + +void CtListModelMergeContacts::findMergeCandidates(std::function<void ()> resultCb) +{ + if (__resultCb) { + return; + } + + __resultCb = resultCb; + + __finder = new std::thread([this]{ + + if (!__canceled) + __makeCandidatesByName(__personInfoMap); + if (!__canceled) + __makeCandidatesByEmail(__personInfoMap); + if (!__canceled) + __makeCandidatesByNumber(__personInfoMap); + + __resultCb(); + }); +} + +std::list<std::unique_ptr<__Group> >& CtListModelMergeContacts::getMergeCandidates() +{ + return __groups; +} + +void CtListModelMergeContacts::lock() +{ + __lock.lock(); +} + +void CtListModelMergeContacts::unlock() +{ + __lock.unlock(); +} + +void CtListModelMergeContacts::__initSimAddressbookIds() +{ + int index = 0; + int addressbookId = 0; + int accountId = 0; + contacts_list_h addressbookList = NULL; + contacts_record_h addressbookRecord = NULL; + + int ret = contacts_db_get_all_records(_contacts_address_book._uri, 0, 0, &addressbookList); + if(ret != CONTACTS_ERROR_NONE) + { + WWARNING("contacts_db_get_all_records() Failed(%d)", ret); + if(addressbookList) + contacts_list_destroy(addressbookList, true); + return; + } + + while(contacts_list_get_current_record_p(addressbookList, &addressbookRecord) == CONTACTS_ERROR_NONE) { + ret = contacts_record_get_int(addressbookRecord, _contacts_address_book.id, &addressbookId); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_int() Failed(%d)", ret); + ret = contacts_record_get_int(addressbookRecord, _contacts_address_book.account_id, &accountId); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_int() Failed(%d)", ret); + + if (accountId == 0 && addressbookId != 0) { + if (index < 2) + __simAddressbookIds[index] = addressbookId; + + index++; + } + + contacts_list_next(addressbookList); + } + ret = contacts_list_destroy(addressbookList, true); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_list_get_count() Failed(%d)", ret); + +} + +bool CtListModelMergeContacts::__isSimAddressbook(int addressbookId) +{ + if (addressbookId == __simAddressbookIds[0] || addressbookId == __simAddressbookIds[1]) { + return true; + } + + return false; +} + +void CtListModelMergeContacts::__appendGroup(std::unique_ptr<__Group> group) +{ + lock(); + __groups.push_back(move(group)); + unlock(); +} + +void CtListModelMergeContacts::__makeCandidatesByName(std::map<int, __PersonInfo>& personInfoMap) +{ + WHIT(); + + unsigned int person_contact_projection[] = { + _contacts_person_contact.person_id, + _contacts_person_contact.display_name, + _contacts_person_contact.display_contact_id, + _contacts_person_contact.image_thumbnail_path, + _contacts_person_contact.addressbook_ids, + _contacts_person_contact.contact_id, + _contacts_person_contact.address_book_id, + _contacts_person_contact.address_book_mode, + _contacts_person_contact.is_favorite, + _contacts_person_contact.link_count + }; + + contacts_query_h query = NULL; + int ret = contacts_query_create(_contacts_person_contact._uri, &query); + WPRET_M(ret != CONTACTS_ERROR_NONE, "contacts_query_create() Failed(%d)", ret); + + ret = contacts_query_set_projection(query, person_contact_projection, sizeof(person_contact_projection)/sizeof(int)); + if (ret != CONTACTS_ERROR_NONE) { + WERROR("contacts_query_set_projection failed"); + contacts_query_destroy(query); + return; + } + + int addressbookMode = 0; + int personId = 0; + int contactId = 0; + int displayContactId = 0; + int addressbookId = 0; + int mergeCount = 0; + bool favorite = false; + char* displayName = NULL; + char* thumbnailPath = NULL; + + std::unique_ptr<__Group> currentGroup; + std::unique_ptr<__Person> pendedPerson; + + contacts_record_h personRecord = NULL; + contacts_list_h personList = NULL; + ret = contacts_db_get_records_with_query(query, 0, 0, &personList); + if (ret != CONTACTS_ERROR_NONE) { + WERROR("contacts_db_get_records_with_query failed"); + contacts_query_destroy(query); + if(personList) + contacts_list_destroy(personList, true); + return; + } + + while(contacts_list_get_current_record_p(personList, &personRecord) == CONTACTS_ERROR_NONE) { + if (__canceled) + break; + + ret = contacts_record_get_int(personRecord, _contacts_person_contact.person_id, &personId); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_int() Failed(%d)", ret); + ret = contacts_record_get_int(personRecord, _contacts_person_contact.link_count, &mergeCount); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_int() Failed(%d)", ret); + ret = contacts_record_get_int(personRecord, _contacts_person_contact.address_book_mode, &addressbookMode); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_int() Failed(%d)", ret); + ret = contacts_record_get_int(personRecord, _contacts_person_contact.contact_id, &contactId); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_int() Failed(%d)", ret); + ret = contacts_record_get_int(personRecord, _contacts_person_contact.display_contact_id, &displayContactId); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_int() Failed(%d)", ret); + ret = contacts_record_get_bool(personRecord, _contacts_person_contact.is_favorite, &favorite); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_int() Failed(%d)", ret); + if (contactId != displayContactId) { // skip + contacts_list_next(personList); + continue; + } + + ret = contacts_record_get_int(personRecord, _contacts_person_contact.address_book_id, &addressbookId); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_int() Failed(%d)", ret); + if (__isSimAddressbook(addressbookId)) { + contacts_list_next(personList); + + __PersonInfo personInfo; + personInfo.grouped = false; + personInfo.inSimAddressbook = true; + personInfo.addressbookId = addressbookId; + personInfo.addressbookMode = addressbookMode; + personInfo.mergeCount = mergeCount; + personInfoMap[personId] = personInfo; + + continue; + } + + ret = contacts_record_get_str_p(personRecord, _contacts_person_contact.display_name, &displayName); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_str_p() Failed(%d)", ret); + ctCommonRemoveNewline(displayName); + + if (displayName == NULL || strlen(displayName) == 0) { + contacts_list_next(personList); + + __PersonInfo personInfo; + personInfo.grouped = false; + personInfo.inSimAddressbook = false; + personInfo.addressbookId = addressbookId; + personInfo.addressbookMode = addressbookMode; + personInfo.mergeCount = mergeCount; + personInfoMap[personId] = personInfo; + + continue; + } + + ret = contacts_record_get_str_p(personRecord, _contacts_person_contact.image_thumbnail_path, &thumbnailPath); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_str_p() Failed(%d)", ret); + std::unique_ptr<__Person> newPerson(new __Person()); + + newPerson->personId = personId; + newPerson->addressbookMode = addressbookMode; + newPerson->addressbookId = addressbookId; + newPerson->mergeCount = mergeCount; + newPerson->displayName = displayName; + newPerson->label = displayName; + newPerson->favorite = favorite; + + if (thumbnailPath) + newPerson->thumbnail = thumbnailPath; + + if (currentGroup == NULL) { + if (pendedPerson == NULL) { + pendedPerson = move(newPerson); + } + else { + if (newPerson->label == pendedPerson->label) { + __PersonInfo personInfo; + + personInfo.grouped = true; + personInfo.inSimAddressbook = false; + personInfo.addressbookId = pendedPerson->addressbookId; + personInfo.addressbookMode = pendedPerson->addressbookMode; + personInfo.mergeCount = pendedPerson->mergeCount; + + personInfoMap[pendedPerson->personId] = personInfo; + + personInfo.grouped = true; + personInfo.inSimAddressbook = false; + personInfo.addressbookId = newPerson->addressbookId; + personInfo.addressbookMode = newPerson->addressbookMode; + personInfo.mergeCount = newPerson->mergeCount; + + personInfoMap[newPerson->personId] = personInfo; + + std::unique_ptr<__Group> newGroup(new __Group); + + newGroup->label = newPerson->label; + newGroup->checkedCount = 0; + + pendedPerson->representative = true; + newGroup->members.push_back(move(pendedPerson)); + newGroup->members.push_back(move(newPerson)); + + currentGroup = move(newGroup); + } + else { + __PersonInfo personInfo; + + personInfo.grouped = false; + personInfo.inSimAddressbook = false; + personInfo.addressbookId = pendedPerson->addressbookId; + personInfo.addressbookMode = pendedPerson->addressbookMode; + personInfo.mergeCount = pendedPerson->mergeCount; + personInfoMap[pendedPerson->personId] = personInfo; + + pendedPerson = move(newPerson); + } + } + } + else { + if (currentGroup->label == newPerson->label) { + __PersonInfo personInfo; + + personInfo.grouped = true; + personInfo.inSimAddressbook = false; + personInfo.addressbookId = newPerson->addressbookId; + personInfo.addressbookMode = newPerson->addressbookMode; + personInfo.mergeCount = newPerson->mergeCount; + personInfoMap[newPerson->personId] = personInfo; + + currentGroup->members.push_back(move(newPerson)); + } + else { + pendedPerson = move(newPerson); + __appendGroup(move(currentGroup)); + } + } + contacts_list_next(personList); + } + + if (currentGroup) { + __appendGroup(move(currentGroup)); + } + + if (pendedPerson) { + __PersonInfo personInfo; + + personInfo.grouped = false; + personInfo.inSimAddressbook = false; + personInfo.addressbookId = pendedPerson->addressbookId; + personInfo.addressbookMode = pendedPerson->addressbookMode; + personInfo.mergeCount = pendedPerson->mergeCount; + + personInfoMap[pendedPerson->personId] = personInfo; + } + + contacts_query_destroy(query); + contacts_list_destroy(personList, true); + + WHIT(); +} + +void CtListModelMergeContacts::__makeCandidatesByEmail(std::map<int, __PersonInfo>& personInfoMap) +{ + WHIT(); + + unsigned int contacts_person_email_projection[] = { + _contacts_person_email.person_id, + _contacts_person_email.display_name, + _contacts_person_email.image_thumbnail_path, + _contacts_person_email.email, + }; + + contacts_query_h query = NULL; + + int personId = 0; + char* displayName = NULL; + char* thumbnailPath = NULL; + char* email = NULL; + + std::unique_ptr<__Group> currentGroup; + std::unique_ptr<__Person> pendedPerson; + + contacts_record_h personRecord = NULL; + contacts_list_h personList = NULL; + + int ret = contacts_query_create(_contacts_person_email._uri, &query); + WPRET_M(ret != CONTACTS_ERROR_NONE, "contacts_query_create() Failed(%d)", ret); + + ret = contacts_query_set_projection(query, contacts_person_email_projection, sizeof(contacts_person_email_projection)/sizeof(int)); + if (ret != CONTACTS_ERROR_NONE) { + WERROR("contacts_query_set_projection failed"); + contacts_query_destroy(query); + return; + } + + ret = contacts_query_set_sort(query, _contacts_person_email.email, true); + if (CONTACTS_ERROR_NONE != ret) { + WERROR("contacts_query_set_sort() Failed(%d)", ret); + contacts_query_destroy(query); + return; + } + + ret = contacts_db_get_records_with_query(query, 0, 0, &personList); + if (ret != CONTACTS_ERROR_NONE) { + WERROR("contacts_db_get_records_with_query failed"); + contacts_query_destroy(query); + if(personList) + contacts_list_destroy(personList, true); + return; + } + + while(contacts_list_get_current_record_p(personList, &personRecord) == CONTACTS_ERROR_NONE) { + if (__canceled) + break; + + ret = contacts_record_get_int(personRecord, _contacts_person_email.person_id, &personId); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_int() Failed(%d)", ret); + if (pendedPerson && pendedPerson->personId == personId) { + contacts_list_next(personList); + continue; + } + + auto iter = personInfoMap.find(personId); + if (iter == personInfoMap.end()) { // person info does not exist + contacts_list_next(personList); + continue; + } + + if (iter->second.grouped) { // already grouped + contacts_list_next(personList); + continue; + } + + if (iter->second.inSimAddressbook) { // sim contact + contacts_list_next(personList); + continue; + } + + ret = contacts_record_get_str_p(personRecord, _contacts_person_email.email, &email); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_str_p() Failed(%d)", ret); + if (email == NULL || strlen(email) == 0) { + contacts_list_next(personList); + continue; + } + + ret = contacts_record_get_str_p(personRecord, _contacts_person_email.display_name, &displayName); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_str_p() Failed(%d)", ret); + if (displayName == NULL || strlen(displayName) == 0) { + contacts_list_next(personList); + continue; + } + + ctCommonRemoveNewline(displayName); + + ret = contacts_record_get_str_p(personRecord, _contacts_person_contact.image_thumbnail_path, &thumbnailPath); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_str_p() Failed(%d)", ret); + + std::unique_ptr<__Person> newPerson(new __Person()); + + newPerson->personId = personId; + newPerson->addressbookId = personInfoMap[personId].addressbookId; + newPerson->addressbookMode = personInfoMap[personId].addressbookMode; + newPerson->mergeCount = personInfoMap[personId].mergeCount; + newPerson->displayName = displayName; + newPerson->label = email; + + if (thumbnailPath) + newPerson->thumbnail = thumbnailPath; + + if (currentGroup == NULL) { + + if (pendedPerson == NULL) { + pendedPerson = move(newPerson); + } + else { + if (newPerson->label == pendedPerson->label) { + personInfoMap[pendedPerson->personId].grouped = true; + personInfoMap[newPerson->personId].grouped = true; + + std::unique_ptr<__Group> newGroup(new __Group); + + newGroup->label = newPerson->label; + newGroup->checkedCount = 0; + + pendedPerson->representative = true; + newGroup->members.push_back(move(pendedPerson)); + newGroup->members.push_back(move(newPerson)); + + currentGroup = move(newGroup); + } + else { + pendedPerson = move(newPerson); + } + } + } + else { + if (currentGroup->label == newPerson->label) { + personInfoMap[newPerson->personId].grouped = true; + currentGroup->members.push_back(move(newPerson)); + } + else { + pendedPerson = move(newPerson); + __appendGroup(move(currentGroup)); + } + } + contacts_list_next(personList); + } + + if (currentGroup) { + __appendGroup(move(currentGroup)); + } + + contacts_query_destroy(query); + contacts_list_destroy(personList, true); + + WHIT(); +} + +void CtListModelMergeContacts::__makeCandidatesByNumber(std::map<int, __PersonInfo>& personInfoMap) +{ + WHIT(); + unsigned int contacts_person_number_projection[] = { + _contacts_person_number.person_id, + _contacts_person_number.display_name, + _contacts_person_number.image_thumbnail_path, + _contacts_person_number.number, + _contacts_person_number.type, + }; + + int personId = 0; + int type = 0; + char* displayName = NULL; + char* thumbnailPath = NULL; + char* number = NULL; + + std::unique_ptr<__Group> currentGroup; + std::unique_ptr<__Person> pendedPerson; + contacts_query_h query = NULL; + + int ret = contacts_query_create(_contacts_person_number._uri, &query); + WPRET_M(ret != CONTACTS_ERROR_NONE, "contacts_query_create() Failed(%d)", ret); + + ret = contacts_query_set_projection(query, contacts_person_number_projection, sizeof(contacts_person_number_projection)/sizeof(int)); + if (CONTACTS_ERROR_NONE != ret) { + WERROR("contacts_query_set_projection() Failed(%d)", ret); + contacts_query_destroy(query); + return; + } + + ret = contacts_query_set_sort(query, _contacts_person_number.number, true); + if (CONTACTS_ERROR_NONE != ret) { + WERROR("contacts_query_set_sort() Failed(%d)", ret); + contacts_query_destroy(query); + return; + } + + contacts_record_h personRecord = NULL; + contacts_list_h personList = NULL; + ret = contacts_db_get_records_with_query(query, 0, 0, &personList); + if(CONTACTS_ERROR_NONE != ret) { + WERROR("contacts_db_get_records_with_query() Failed(%d)", ret); + contacts_query_destroy(query); + if(personList) + contacts_list_destroy(personList, true); + return; + } + + while(contacts_list_get_current_record_p(personList, &personRecord) == CONTACTS_ERROR_NONE) { + if (__canceled) + break; + + ret = contacts_record_get_int(personRecord, _contacts_person_number.type, &type); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_int() Failed(%d)", ret); + if (CONTACTS_NUMBER_TYPE_WORK & type || CONTACTS_NUMBER_TYPE_FAX & type) { + WDEBUG("type: %d", type); + contacts_list_next(personList); + continue; + } + + ret = contacts_record_get_int(personRecord, _contacts_person_number.person_id, &personId); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_int() Failed(%d)", ret); + if (pendedPerson && pendedPerson->personId == personId) { + contacts_list_next(personList); + continue; + } + + auto iter = personInfoMap.find(personId); + if (iter == personInfoMap.end()) { // person info does not exist + contacts_list_next(personList); + continue; + } + + if (iter->second.grouped) { // already grouped + contacts_list_next(personList); + continue; + } + + if (iter->second.inSimAddressbook) { // sim contact + contacts_list_next(personList); + continue; + } + + ret = contacts_record_get_str_p(personRecord, _contacts_person_number.number, &number); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_str_p() Failed(%d)", ret); + if (number == NULL || strlen(number) == 0) { + contacts_list_next(personList); + continue; + } + + ret = contacts_record_get_str_p(personRecord, _contacts_person_number.display_name, &displayName); + + ctCommonRemoveNewline(displayName); + + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_str_p() Failed(%d)", ret); + if (displayName == NULL || strlen(displayName) == 0) { + contacts_list_next(personList); + continue; + } + + ret = contacts_record_get_str_p(personRecord, _contacts_person_number.image_thumbnail_path, &thumbnailPath); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_str_p() Failed(%d)", ret); + + std::unique_ptr<__Person> newPerson(new __Person()); + + newPerson->personId = personId; + newPerson->addressbookId = personInfoMap[personId].addressbookId; + newPerson->addressbookMode = personInfoMap[personId].addressbookMode; + newPerson->mergeCount = personInfoMap[personId].mergeCount; + newPerson->displayName = displayName; + newPerson->label = number; + + if (thumbnailPath) + newPerson->thumbnail = thumbnailPath; + + if (currentGroup == NULL) { + + if (pendedPerson == NULL) { + pendedPerson = move(newPerson); + } + else { + if (newPerson->label == pendedPerson->label) { + personInfoMap[pendedPerson->personId].grouped = true; + personInfoMap[newPerson->personId].grouped = true; + + std::unique_ptr<__Group> newGroup(new __Group); + + newGroup->label = newPerson->label; + newGroup->checkedCount = 0; + + pendedPerson->representative = true; + newGroup->members.push_back(move(pendedPerson)); + newGroup->members.push_back(move(newPerson)); + + currentGroup = move(newGroup); + } + else { + pendedPerson = move(newPerson); + } + } + } + else { + if (currentGroup->label == newPerson->label) { + personInfoMap[newPerson->personId].grouped = true; + currentGroup->members.push_back(move(newPerson)); + } + else { + pendedPerson = move(newPerson); + __appendGroup(move(currentGroup)); + } + } + contacts_list_next(personList); + } + + if (currentGroup) { + __appendGroup(move(currentGroup)); + } + + contacts_query_destroy(query); + contacts_list_destroy(personList, true); + + WHIT(); +} diff --git a/lib-contact/ct-list/src/CtListModelMergeContacts.h b/lib-contact/ct-list/src/CtListModelMergeContacts.h new file mode 100644 index 0000000..8dbe802 --- /dev/null +++ b/lib-contact/ct-list/src/CtListModelMergeContacts.h @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __CT_LIST_MODEL_MERGE_CONTACTS_H_ +#define __CT_LIST_MODEL_MERGE_CONTACTS_H_ + +#include <list> +#include <thread> +#include <memory> +#include <mutex> + +class WView; + +struct __Group; + +struct __Person +{ + __Person(); + int personId; + int addressbookMode; + int addressbookId; + int mergeCount; + std::string label; + std::string displayName; + std::string thumbnail; + bool representative; + bool favorite; + __Group* group; +}; + +struct __Group +{ + ~__Group(); + std::string label; + int checkedCount; + std::list<std::unique_ptr<__Person> > members; + __Person* representative; +}; + +struct __PersonInfo +{ + bool inSimAddressbook; + bool grouped; + int addressbookId; + int addressbookMode; + int mergeCount; +}; + +class CtListModelMergeContacts +{ + +public: + CtListModelMergeContacts(); + ~CtListModelMergeContacts(); + +public: + void findMergeCandidates(std::function<void ()> resultCb); + std::list<std::unique_ptr<__Group> >& getMergeCandidates(); + + void lock(); + void unlock(); + +private: + void __appendGroup(std::unique_ptr<__Group>); + void __initSimAddressbookIds(); + bool __isSimAddressbook(int addressbookId); + + void __makeCandidatesByName(std::map<int, __PersonInfo>& personInfoMap); + void __makeCandidatesByEmail(std::map<int, __PersonInfo>& personInfoMap); + void __makeCandidatesByNumber(std::map<int, __PersonInfo>& personInfoMap); + +private: + int __simAddressbookIds[2]; + +private: + int __numOfMergeableContact; + std::list<std::unique_ptr<__Group> > __groups; + std::map<int, __PersonInfo> __personInfoMap; + std::thread* __finder; + bool __canceled; + std::function<void ()> __resultCb; + std::mutex __lock; +}; + +#endif //__CT_LIST_MODEL_MERGE_CONTACTS_H_ + diff --git a/lib-contact/ct-list/src/CtListModelVcard.cpp b/lib-contact/ct-list/src/CtListModelVcard.cpp new file mode 100755 index 0000000..b1509b6 --- /dev/null +++ b/lib-contact/ct-list/src/CtListModelVcard.cpp @@ -0,0 +1,283 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <thread> +#include <contacts.h> + +#include "ContactsDebug.h" +#include "CtType.h" +#include "ContactsCommon.h" +#include "CtListDataPerson.h" +#include "CtListModelVcard.h" + +CtListModelVcard::CtListModelVcard(const std::string& vcardPath) +: __listener(NULL) +, __parser(NULL) +, __nQuery(false) +, __vcardPath(vcardPath) +, __loadedCount(0) +, __totalCount(-1) +, __realTotalCount(-1) +, __onTerminating(false) +{ + WENTER(); + + __getVcardPathFromUri(); + getPersonListCount(LIST_QUERY_DEFAULT); +} + +CtListModelVcard::~CtListModelVcard() +{ + WENTER(); + + if (__parser) { + __onTerminating = true; + while (__parser) { + sleep(1); + } + } + + __personDataList.clear(); + +} + +int CtListModelVcard::getContactsCount(CtListQueryType queryType) +{ + return getPersonListCount(LIST_QUERY_DEFAULT); +} + +int CtListModelVcard::getContacts(CtListQueryType queryType, CtGetContactsType syncType) +{ + WHIT(); + + if(queryType == LIST_QUERY_DEFAULT) { + if (__personDataList.size() == 0) { + __makePersonListFromVcard(); + } + + return __personDataList.size(); + } + else + WERROR("wrong queryType %d", queryType); + + return 0; +} + +std::shared_ptr<CtListDataPerson> CtListModelVcard::getAtPersonData(int index, CtListQueryType queryType) +{ + if(queryType == LIST_QUERY_DEFAULT) { + if(index < (int)__personDataList.size()) { + return __personDataList[index]; + } + else { + return NULL; + } + } + else + return NULL; +} + +int CtListModelVcard::getPersonListCount(CtListQueryType queryType) +{ + WENTER(); + + if (__totalCount == -1) { + int err = contacts_vcard_get_entity_count(__vcardPath.c_str(), &__realTotalCount); + if (err != CONTACTS_ERROR_NONE) { + return 0; + } + + __totalCount = __realTotalCount; + + // show maximum 100 contacts + if (__totalCount > 100) + __totalCount = 100; + + WDEBUG("real count %d", __realTotalCount); + } + + return __totalCount; +} + +void CtListModelVcard::attachListener(ICtChangeListener* listener) +{ + WHIT(); + __listener = listener; +} + +int CtListModelVcard::__makePersonListFromVcard() +{ + __nQuery = true; + contacts_vcard_parse_to_contact_foreach(__vcardPath.c_str(), __onEachContactInVcard, this); + __nQuery = false; + + WDEBUG("total: %d, loaded: %d", __totalCount, __loadedCount); + if (__loadedCount == __totalCount) + { + return 0; + } + + ecore_idler_add([](void* data)->Eina_Bool{ + WHIT(); + CtListModelVcard* self = static_cast<CtListModelVcard*>(data); + + self->__loadedCount = 0; + self->__parser = ecore_thread_run([](void *data, Ecore_Thread *thread){ // run callback + CtListModelVcard* self = static_cast<CtListModelVcard*>(data); + + contacts_vcard_parse_to_contact_foreach(self->__vcardPath.c_str(), __onEachContactInVcard, data); + + },[](void *data, Ecore_Thread *thread){ // end callback + WHIT(); + CtListModelVcard* self = static_cast<CtListModelVcard*>(data); + self->__parser = NULL; + + if (self->__onTerminating) + return; + + WDEBUG("listener:%x", self->__listener); + if (self->__listener) { + self->__listener->onCompleteGetContacts(20); // nquery + } + },[](void *data, Ecore_Thread *thread){ + WHIT(); + }, self); + + return ECORE_CALLBACK_CANCEL; + }, this); + + return 0; +} + +bool CtListModelVcard::__onEachContactInVcard(contacts_record_h record, void *data) +{ + CtListModelVcard* self = static_cast<CtListModelVcard*>(data); + if (self->__onTerminating) { + WERROR("pending cancel statue..."); + return false; + } + + self->__loadedCount++; + + if (self->__nQuery || self->__loadedCount > 20) + { + int err = CONTACTS_ERROR_NONE; + contacts_record_h newRecord = NULL; + err = contacts_record_clone(record, &newRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_clone() Failed(%d)", err); + self->__personDataList.push_back(std::make_shared<CtListDataPerson>(newRecord)); + } + + if (self->__nQuery) + { + if (self->__loadedCount == 20) + { + WERROR("__loadedCount 20"); + return false; + } + } + + if (self->__loadedCount == self->__totalCount) { + self->__loadCompleteCb(self->__loadedCount, self->__totalCount, self->__realTotalCount > 100); + return false; + } + + return true; +} + +void CtListModelVcard::__getVcardPathFromUri(void) +{ + size_t position = 0; + std::string prefix("file://"); + + if ((position = __vcardPath.find(prefix)) != std::string::npos) { + __vcardPath.erase(position, prefix.length()); + } + + WDEBUG("vcard path is %s", __vcardPath.c_str()); +} + +void CtListModelVcard::setSelectedPersonId(int selectedPersonId) +{ + // empty +} + +const char* CtListModelVcard::getSearchString(void) +{ + return NULL; +} + +bool CtListModelVcard::setSearchString(char* search) +{ + return false; +} + +void CtListModelVcard::getNumberSearchString(const std::shared_ptr<CtListDataPerson>& dataPerson, std::string &numberStr) +{ + +} + +int CtListModelVcard::getCheckedDataCount() +{ + return 0; +} + +void CtListModelVcard::setOnLoadCompleteCb(std::function<void (int, int, bool)> loadCompleteCb) +{ + __loadCompleteCb = loadCompleteCb; +} + +void CtListModelVcard::resetLoadCompleteCb() +{ + __loadCompleteCb = NULL; +} + +void CtListModelVcard::__getMfcPersonList() +{ + +} + +bool CtListModelVcard::__makeUsagePersonList(contacts_list_h list) +{ + return true; +} + +void CtListModelVcard::initialOriginalCheckedIdList() +{ +} + +void CtListModelVcard::clearOriginalCheckedIdList() +{ +} + +bool CtListModelVcard::checkIsSelectAllOnSearching() +{ + return false; +} + +void CtListModelVcard::initialOriginalPersonDataListSize() +{ +} + +void CtListModelVcard::clearOriginalPersonDataListSize() +{ +} + +int CtListModelVcard::getOriginalPersonDataListSize() +{ + return 0; +} diff --git a/lib-contact/ct-list/src/CtListModelVcard.h b/lib-contact/ct-list/src/CtListModelVcard.h new file mode 100644 index 0000000..1ff7783 --- /dev/null +++ b/lib-contact/ct-list/src/CtListModelVcard.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __CT_LIST_MODEL_VCARD_H_ +#define __CT_LIST_MODEL_VCARD_H_ + +#include <vector> +#include <string> +#include <functional> +#include <contacts.h> +#include <memory> +#include <Ecore.h> +#include <Elementary.h> + +#include "CtType.h" +#include "CtCommon.h" +#include "ContactsCommon.h" +#include "CtListModel.h" +#include "CtListDataPerson.h" + +class ICtChangeListener; + +class CtListModelVcard : public CtListModel +{ +public: + CtListModelVcard(const std::string& vcardPath); + virtual ~CtListModelVcard(); + +public: + // CtListModel interfaces + virtual int getContactsCount(CtListQueryType queryType); + virtual int getContacts(CtListQueryType queryType, CtGetContactsType syncType); + virtual int cancelGetContacts() { return 0; } + virtual std::shared_ptr<CtListDataPerson> getAtPersonData(int index, CtListQueryType queryType); + virtual int getPersonListCount(CtListQueryType queryType); + virtual void attachListener(ICtChangeListener* listener); + + virtual void setSelectedPersonId(int selectedPersonId); + virtual const char* getSearchString(void); + virtual bool setSearchString(char* search); + virtual void getNumberSearchString(const std::shared_ptr<CtListDataPerson>& dataPerson, std::string &numberStr); + virtual int getCheckedDataCount(); + virtual int getLimitCount() { return 0;} + virtual int getCurrentLinkedCount() { return 0; } + + void setOnLoadCompleteCb(std::function<void (int, int, bool)> loadingCb); + void resetLoadCompleteCb(); + + std::vector<std::shared_ptr<CtListDataPerson>>* getCheckedDataList() const; + void __getMfcPersonList(); + bool __makeUsagePersonList(contacts_list_h list); + void __getVcardPathFromUri(void); + + virtual void initialOriginalCheckedIdList(); + virtual void clearOriginalCheckedIdList(); + virtual bool checkIsSelectAllOnSearching(); + virtual void initialOriginalPersonDataListSize(); + virtual void clearOriginalPersonDataListSize(); + virtual int getOriginalPersonDataListSize(); + +private: + int __makePersonListFromVcard(); + static bool __onEachContactInVcard(contacts_record_h record, void *data); + +private: + ICtChangeListener* __listener; + Ecore_Thread* __parser; + bool __nQuery; + std::string __vcardPath; + std::vector<std::shared_ptr<CtListDataPerson>> __personDataList; + std::function<void (int count, int total, bool)> __loadCompleteCb; + int __loadedCount; + int __totalCount; + int __realTotalCount; + bool __onTerminating; +}; + +#endif + diff --git a/lib-contact/ct-list/src/CtListUgMultiPickController.cpp b/lib-contact/ct-list/src/CtListUgMultiPickController.cpp new file mode 100644 index 0000000..d3e4101 --- /dev/null +++ b/lib-contact/ct-list/src/CtListUgMultiPickController.cpp @@ -0,0 +1,903 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <vector> +#include <thread> +#include <Elementary.h> +#include <app.h> +#include <contacts.h> +#include <app_preference.h> + +#include "WView.h" +#include "WNaviframe.h" +#include "WPopup.h" + +#include "ContactsDebug.h" +#include "CtType.h" +#include "CtListUgMultiPickController.h" +#include "CtCommon.h" +#include "CtContactsToVcard.h" +#include "CtListView.h" +#include "CtListModelDb.h" +#include "CtProgressBarPopup.h" + +#define __ITEM_HEIGHT 96 +#define CHECKED_INFO_PAUSE_INTERVAL 200*1000 + + +CtListUgMultiPickController::CtListUgMultiPickController(CtListResultType resultType, CtListView *listView, CtListModelDb* listData) +{ + WHIT(); + __listView = listView; + __linkedCount = 1; + + __listModel = listData; + __ctrlType = LIST_CTRL_DEFAULT; + __selectedPersonData = NULL; + + switch (resultType) { + case LIST_RESULT_ID: + __ctrlType = LIST_CTRL_REQUEST_CHECK_FOR_PERSON; + break; + case LIST_RESULT_NUMBER: + case LIST_RESULT_NUMBER_FOR_CALL: + case LIST_RESULT_NUMBER_FOR_MESSAGE: + __ctrlType = LIST_CTRL_REQUEST_CHECK_FOR_NUMBER; + break; + case LIST_RESULT_EMAIL: + __ctrlType = LIST_CTRL_REQUEST_CHECK_FOR_EMAIL; + break; + case LIST_RESULT_VCARD: + __ctrlType = LIST_CTRL_REQUEST_CHECK_FOR_VCARD; + break; + case LIST_RESULT_NUMBER_OR_EMAIL: + __ctrlType = LIST_CTRL_REQUEST_CHECK_FOR_NUMBER_OR_EMAIL; + break; + } +} + +CtListUgMultiPickController::~CtListUgMultiPickController() +{ + WHIT(); + + if(__selectedPersonData) + delete __selectedPersonData; + +} + +void CtListUgMultiPickController::__onSelectDataPopupItem(void *data, Evas_Object *obj, void *event_info) +{ + //WHIT(); + CtListPopupItemData *popupItemData = (CtListPopupItemData*)data; + int personId = popupItemData->controller->__selectedPersonData->getPersonId(); + Elm_Object_Item *seletedItem = popupItemData->controller->__listView->getGenlistItemByPersonId(personId); + + popupItemData->controller->__listView->destroyPopup(); + CtCheckState checkState = CHECK_OFF; + if(popupItemData->controller->__getCheckState(seletedItem) == CHECK_OFF) + checkState = CHECK_ON; + else + checkState = CHECK_OFF; + + popupItemData->controller->__changeCheckState(seletedItem, checkState, true); + + if(popupItemData->dataType == CT_LIST_DATA_NUMBER) { + popupItemData->controller->__setCheckedInfo(seletedItem, popupItemData->record, CT_LIST_DATA_NUMBER); + + } + else if(popupItemData->dataType == CT_LIST_DATA_EMAIL) { + popupItemData->controller->__setCheckedInfo(seletedItem, popupItemData->record, CT_LIST_DATA_EMAIL); + } + + elm_genlist_realized_items_update(popupItemData->controller->__listView->__genlist); +} + +Evas_Object* CtListUgMultiPickController::__createDataListPopup(Elm_Object_Item *item, int dataType) +{ + CtListView::CtListDataItem* itemData = (CtListView::CtListDataItem*)elm_object_item_data_get(item); + WPRET_VM(itemData == NULL, NULL, "itemData is null"); + Eina_List *numberList = NULL; + Eina_List *emailList = NULL; + if(dataType == CT_LIST_DATA_NUMBER) + numberList = __selectedPersonData->getNumberList(); + else if(dataType == CT_LIST_DATA_EMAIL) + emailList = itemData->personData->getEmailList(); + else if(dataType == CT_LIST_DATA_ALL) { + numberList = __selectedPersonData->getNumberList(); + emailList = __selectedPersonData->getEmailList(); + } + else { + WERROR("wrong dataType %d", dataType); + return NULL; + } + + Eina_List *checked_numberList = NULL; + Eina_List *checked_emailList = NULL; + checked_numberList = ctCommonGetChekedDuplicatedNumberList(numberList); + checked_emailList = ctCommonGetChekedDuplicatedEmailList(emailList); + + int count = eina_list_count(checked_numberList) + eina_list_count(checked_emailList); + WDEBUG("data count %d", count); + if(count == 1) { + ctCommonDestroyRecordList(checked_numberList); + ctCommonDestroyRecordList(checked_emailList); + return NULL; + } + + Elm_Genlist_Item_Class* itc = elm_genlist_item_class_new(); + if (!itc) { + WERROR("elm_genlist_item_class_new() failed"); + ctCommonDestroyRecordList(checked_numberList); + ctCommonDestroyRecordList(checked_emailList); + return NULL; + } + + itc->item_style = "type1"; + itc->func.text_get = [](void* data, Evas_Object* obj, const char* part)->char* + { + CtListUgMultiPickController::CtListPopupItemData *popupItemData = (CtListUgMultiPickController::CtListPopupItemData*)data; + if(!strcmp(part, "elm.text")){ + char *value = NULL; + if(popupItemData->dataType == CT_LIST_DATA_NUMBER) + contacts_record_get_str_p(popupItemData->record, _contacts_person_number.number, &value); + else if(popupItemData->dataType == CT_LIST_DATA_EMAIL) + contacts_record_get_str_p(popupItemData->record, _contacts_person_email.email, &value); + else + WPRET_VM(1, NULL, "wrong dataType %d", popupItemData->dataType); + + if (value) + return SAFE_STRDUP(value); + else + return NULL; + } + return NULL; + }; + itc->func.del = [](void* data, Evas_Object* obj)->void + { + CtListPopupItemData *popupItemData = (CtListPopupItemData*)data; + contacts_record_destroy(popupItemData->record, true); + delete popupItemData; + }; + + WPopup* popup = new WPopup(); + popup->setTextTranslatable(PACKAGE); + popup->setTitle(itemData->personData->getDisplayName()); + popup->setContent([this,itc,checked_numberList,checked_emailList,item](Evas_Object* parent)->Evas_Object* + { + Evas_Object* genlist = elm_genlist_add(parent); + elm_object_style_set( genlist, "popup" ); + elm_genlist_homogeneous_set(genlist, EINA_TRUE); + elm_genlist_mode_set( genlist, ELM_LIST_COMPRESS ); + elm_scroller_content_min_limit( genlist, EINA_FALSE, EINA_TRUE ); // Automatically pop-up height is calculated + elm_object_content_set(parent, genlist); + + void *data = NULL; + int count = 0; + int err = CONTACTS_ERROR_NONE; + Eina_List *cursor; + EINA_LIST_FOREACH(checked_numberList, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + + CtListPopupItemData *popupItemData = new CtListPopupItemData; + err = contacts_record_clone(record, &popupItemData->record); + if(err != CONTACTS_ERROR_NONE) + { + WERROR("contacts_record_clone() Failed(%d)", err); + if(popupItemData->record) + contacts_record_destroy(popupItemData->record, true); + delete popupItemData; + break; + } + popupItemData->controller = this; + popupItemData->dataType = CT_LIST_DATA_NUMBER; + + popupItemData->popupItem = elm_genlist_item_append(genlist, itc, (void*)popupItemData, NULL, ELM_GENLIST_ITEM_NONE, CtListUgMultiPickController::__onSelectDataPopupItem, popupItemData); + count++; + } + ctCommonDestroyRecordList(checked_numberList); + + EINA_LIST_FOREACH(checked_emailList, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + + CtListPopupItemData *popupItemData = new CtListPopupItemData; + err = contacts_record_clone(record, &popupItemData->record); + if(err != CONTACTS_ERROR_NONE) + { + WERROR("contacts_record_clone() Failed(%d)", err); + delete popupItemData; + break; + } + popupItemData->controller = this; + popupItemData->dataType = CT_LIST_DATA_EMAIL; + + popupItemData->popupItem = elm_genlist_item_append(genlist, itc, (void*)popupItemData, NULL, ELM_GENLIST_ITEM_NONE, CtListUgMultiPickController::__onSelectDataPopupItem, popupItemData); + count++; + } + ctCommonDestroyRecordList(checked_emailList); + + evas_object_show(genlist); + + return genlist; + + }); + + __listView->attachPopup(popup); + + elm_genlist_item_class_free(itc); + + return popup->getEvasObj(); +} + +void CtListUgMultiPickController::__updateTitleAndDone() +{ + Elm_Object_Item *naviItem = elm_naviframe_top_item_get(__listView->getViewNaviframe()); + Evas_Object *btn = elm_object_item_part_content_get(naviItem, "title_right_btn"); + + int checkedCount = __listModel->getCheckedDataCount(); + + if(btn) { + if(checkedCount > 0) + elm_object_disabled_set(btn, EINA_FALSE); + else + elm_object_disabled_set(btn, EINA_TRUE); + } + + WDEBUG("%d, %d", checkedCount, __listModel->getPersonListCount(LIST_QUERY_DEFAULT)); + //To avoid watchdog + if(checkedCount>500) { + if( checkedCount%500 == 1) + usleep(CHECKED_INFO_PAUSE_INTERVAL); + } + + char buf[CT_TEXT_SHORT_LEN] = {0,}; + if(__listModel->getLimitCount() == 0) + snprintf(buf, sizeof(buf), ctGetContactsString("IDS_PB_HEADER_PD_SELECTED_ABB3"), checkedCount); + else + snprintf(buf, sizeof(buf), "%d/%d", checkedCount, __listModel->getLimitCount()); + + elm_object_item_part_text_set(naviItem, "elm.text.title", buf); +} + +bool CtListUgMultiPickController::__changeCheckState(Elm_Object_Item *item, CtCheckState checkState, bool updateTitleAndDone) +{ + WHIT(); + + Elm_Genlist_Item_Type item_type = elm_genlist_item_type_get(item); + if(item_type == ELM_GENLIST_ITEM_GROUP) { + return false; + } + + CtListView::CtListDataItem* itemData = (CtListView::CtListDataItem*)elm_object_item_data_get(item); + WPRET_VM(itemData == NULL, false, "itemData is null"); + + Evas_Object* layout = elm_object_item_part_content_get(item,"elm.icon.2"); + Evas_Object* check = elm_layout_content_get(layout, "elm.swallow.content"); + elm_check_state_set(check, (Eina_Bool)checkState); + + itemData->personData->setAsChecked((bool)checkState); + if(itemData->personData->isChecked() == true) { + __listModel->pushCheckedData(itemData->personData); + __linkedCount += itemData->personData->getLinkedCount(); + } + else { + __listModel->removeCheckedData(itemData->personData); + __linkedCount -= itemData->personData->getLinkedCount(); + } + + +/* + Elm_Object_Item *naviItem = elm_naviframe_top_item_get(__listView->getViewNaviframe()); + Evas_Object *btn = elm_object_item_part_content_get(naviItem, "title_right_btn"); + + if(btn) { + if(checkedCount > 0) + elm_object_disabled_set(btn, EINA_FALSE); + else + elm_object_disabled_set(btn, EINA_TRUE); + } + + WDEBUG("%d, %d", checkedCount, __listModel->getPersonListCount(LIST_QUERY_DEFAULT)); + //To avoid watchdog + if(checkedCount>500) { + if( checkedCount%500 == 1) + usleep(CHECKED_INFO_PAUSE_INTERVAL); + } +*/ + + if(__listView->__selectAllObj) { + if (__listModel->getSearchString()) { + if (__listModel->checkIsSelectAllOnSearching()) { + __listView->__selectAllState = CHECK_ON; + } + else { + __listView->__selectAllState = CHECK_OFF; + } + } + else { + int checkedCount = __listModel->getCheckedDataCount(); + int maxCount = __listModel->getPersonListCount(LIST_QUERY_DEFAULT); + WDEBUG("%d, %d", checkedCount, maxCount); + + if(checkedCount == maxCount) { + WDEBUG("check select all"); + elm_check_state_set(__listView->__selectAllObj, EINA_TRUE); + __listView->__selectAllState = CHECK_ON; + } + else { + elm_check_state_set(__listView->__selectAllObj, EINA_FALSE); + __listView->__selectAllState = CHECK_OFF; + } + } + } +/* + char buf[CT_TEXT_SHORT_LEN] = {0,}; + if(__listModel->getLimitCount() == 0) + snprintf(buf, sizeof(buf), ctGetContactsString("IDS_PB_HEADER_PD_SELECTED_ABB3"), checkedCount); + else + snprintf(buf, sizeof(buf), "%d/%d", checkedCount, __listModel->getLimitCount()); + + elm_object_item_part_text_set(naviItem, "elm.text.title", buf); +*/ + + if (updateTitleAndDone) { + __updateTitleAndDone(); + } + + + return itemData->personData->isChecked(); +} + +CtCheckState CtListUgMultiPickController::__getCheckState(Elm_Object_Item *item) +{ + WHIT(); + + CtListView::CtListDataItem* itemData = (CtListView::CtListDataItem*)elm_object_item_data_get(item); + WPRET_VM(itemData == NULL, CHECK_OFF, "itemData is null"); + + return (CtCheckState)itemData->personData->isChecked(); +} + +void CtListUgMultiPickController::__setCheckedInfo(Elm_Object_Item *item, contacts_record_h record, CtListItemDataType dataType) +{ + CtListView::CtListDataItem* itemData = (CtListView::CtListDataItem*)elm_object_item_data_get(item); + WPRET_M(itemData == NULL, "itemData is null"); + int dataId = 0; + char *dataString = NULL; + int err = CONTACTS_ERROR_NONE; + + switch(dataType) { + case CT_LIST_DATA_PERSON: + itemData->personData->setDataId(itemData->personData->getPersonId()); + itemData->personData->setDataString(itemData->personData->getDisplayName()); + itemData->personData->setDataType((int)dataType); + break; + case CT_LIST_DATA_NUMBER: + err = contacts_record_get_int(record, _contacts_person_number.number_id, &dataId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + err = contacts_record_get_str_p(record, _contacts_person_number.number, &dataString); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + itemData->personData->setDataId(dataId); + itemData->personData->setDataString(dataString); + itemData->personData->setDataType((int)dataType); + break; + case CT_LIST_DATA_EMAIL: + err = contacts_record_get_int(record, _contacts_person_email.email_id, &dataId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + err = contacts_record_get_str_p(record, _contacts_person_email.email, &dataString); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + itemData->personData->setDataId(dataId); + itemData->personData->setDataString(dataString); + itemData->personData->setDataType((int)dataType); + break; + case CT_LIST_DATA_VCARD: + break; + default: + WERROR("wring data type %d", dataType); + break; + } + +} + +void CtListUgMultiPickController::onSelectItem(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState) +{ + //WHIT(); + Elm_Object_Item *item = selectedItem; + elm_genlist_item_selected_set(item, EINA_FALSE); + + CtListView::CtListDataItem* itemData = (CtListView::CtListDataItem*)elm_object_item_data_get(item); + + if(__selectedPersonData) + delete __selectedPersonData; + __selectedPersonData = itemData->personData->makeClone(); + + WDEBUG("__ctrlType %d", __ctrlType); + + if(checkState == __getCheckState(item)) + return; + + if(checkState == CHECK_ON) { + int checkedNum = 0; + + checkedNum = __listModel->getCheckedDataCount()+1; + + if(__checkLimitCount(checkedNum, __listModel->getLimitCount()) == true) + return; + } + + switch(__ctrlType){ + case LIST_CTRL_REQUEST_CHECK_FOR_VCARD: + { + __changeCheckState(item, checkState, true); + } + break; + case LIST_CTRL_REQUEST_CHECK_FOR_LINK_CONTACTS: + { + if(checkState == CHECK_ON) { + const int currentContactLinkedCount = __listModel->getCurrentLinkedCount(); + const int checkedContactLinkedCount = itemData->personData->getLinkedCount(); + if(__checkMaxLinkCount(currentContactLinkedCount, checkedContactLinkedCount) == true) + return; + } + + if(__changeCheckState(item, checkState, true) == true) { + __setCheckedInfo(item, NULL, CT_LIST_DATA_PERSON); + } + } + break; + case LIST_CTRL_REQUEST_CHECK_FOR_PERSON: + { + if(__changeCheckState(item, checkState, true) == true) { + __setCheckedInfo(item, NULL, CT_LIST_DATA_PERSON); + } + } + break; + case LIST_CTRL_REQUEST_CHECK_FOR_NUMBER: + { + if(checkState == CHECK_OFF) { + __changeCheckState(item, checkState, true); + break; + } + + if(__createDataListPopup(item, CT_LIST_DATA_NUMBER) == NULL) { + if(__changeCheckState(item, checkState, true) == true) { + Eina_List *cursor = NULL; + void *data = NULL; + Eina_List *dataList = __selectedPersonData->getNumberList(); + EINA_LIST_FOREACH(dataList, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + __setCheckedInfo(item, record, CT_LIST_DATA_NUMBER); + break; + } + } + } + } + break; + case LIST_CTRL_REQUEST_CHECK_FOR_EMAIL: + { + if(checkState == CHECK_OFF) { + __changeCheckState(item, checkState, true); + break; + } else if(checkState == CHECK_ON){ + Evas_Object* layout = elm_object_item_part_content_get(item,"elm.icon.2"); + Evas_Object* check = elm_layout_content_get(layout, "elm.swallow.content"); + elm_check_state_set(check, EINA_FALSE); + } + + if(__createDataListPopup(item, CT_LIST_DATA_EMAIL) == NULL) { + if(__changeCheckState(item, checkState, true) == true) { + Eina_List *cursor = NULL; + void *data = NULL; + Eina_List *dataList = __selectedPersonData->getEmailList(); + EINA_LIST_FOREACH(dataList, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + __setCheckedInfo(item, record, CT_LIST_DATA_EMAIL); + break; + } + } + } + } + break; + case LIST_CTRL_REQUEST_CHECK_FOR_NUMBER_OR_EMAIL: + { + if(checkState == CHECK_OFF) { + __changeCheckState(item, checkState, true); + break; + } else if(checkState == CHECK_ON){ + Evas_Object* layout = elm_object_item_part_content_get(item,"elm.icon.2"); + Evas_Object* check = elm_layout_content_get(layout, "elm.swallow.content"); + elm_check_state_set(check, EINA_FALSE); + } + + if(__createDataListPopup(item, CT_LIST_DATA_ALL) == NULL) { + if(__changeCheckState(item, checkState, true) == true) { + + Eina_List *cursor = NULL; + void *data = NULL; + Eina_List *dataList = __selectedPersonData->getNumberList(); + if(dataList == NULL) { + dataList = __selectedPersonData->getEmailList(); + EINA_LIST_FOREACH(dataList, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + __setCheckedInfo(item, record, CT_LIST_DATA_EMAIL); + break; + } + } + else { + EINA_LIST_FOREACH(dataList, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + __setCheckedInfo(item, record, CT_LIST_DATA_NUMBER); + break; + } + } + } + } + } + break; + default: + WWARNING("Not handled type=%d", __ctrlType); + break; + } + + elm_genlist_realized_items_update(view->__genlist); +} + +void CtListUgMultiPickController::onSelectDone(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + + switch(__ctrlType){ + case LIST_CTRL_REQUEST_CHECK_FOR_VCARD: + case LIST_CTRL_REQUEST_CHECK_FOR_PERSON: + case LIST_CTRL_REQUEST_CHECK_FOR_NUMBER: + case LIST_CTRL_REQUEST_CHECK_FOR_EMAIL: + case LIST_CTRL_REQUEST_CHECK_FOR_NUMBER_OR_EMAIL: + case LIST_CTRL_REQUEST_CHECK_FOR_LINK_CONTACTS: + __doReplyCheckedInfo(); + break; + default: + break; + } +} + + +void CtListUgMultiPickController::onSelectCancel(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + __listView->sendMultiResult(NULL, 0); + __listView->popOut(); +} + +void CtListUgMultiPickController::onSelectBack(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + __listView->sendMultiResult(NULL, 0); +} + +void CtListUgMultiPickController::onSwipeLeftItem(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); +} + + +void CtListUgMultiPickController::onSwipeRightItem(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); +} + +void CtListUgMultiPickController::onSelectCheckAll(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState) +{ + WHIT(); + + Elm_Object_Item *item = selectedItem; + if (item) + elm_genlist_item_selected_set(item, EINA_FALSE); + + Evas_Object *genlist = view->__genlist; + int checkedCount = __listModel->getCheckedDataCount(); + int limitCount = __listModel->getLimitCount(); + int maxCount = __listModel->getPersonListCount(LIST_QUERY_DEFAULT); + + if (limitCount > 0 && limitCount < maxCount && checkState == CHECK_ON) { + __checkLimitCount(maxCount, limitCount); + return; + } + + WDEBUG("select all %d", checkState); + if (!item) { + item = elm_genlist_first_item_get(genlist); + if(view->__searchbarItem) { + item = elm_genlist_item_next_get(view->__searchbarItem); + } + } + + while(item) { + if(item == view->__selectAllItem) { + item = elm_genlist_item_next_get(item); + continue; + } + Elm_Genlist_Item_Type item_type = elm_genlist_item_type_get(item); + if(item_type == ELM_GENLIST_ITEM_GROUP) { + item = elm_genlist_item_next_get(item); + continue; + } + + if(__checkItem(item, view, checkState) == false) { + WDEBUG("already checked"); + item = elm_genlist_item_next_get(item); + continue; + } + checkedCount++; + + item = elm_genlist_item_next_get(item); + } + + __updateTitleAndDone(); + + WHIT(); + elm_genlist_realized_items_update(genlist); +} + +void CtListUgMultiPickController::moreManageFavoritesItemOperation() +{ + WHIT(); +} + +bool CtListUgMultiPickController::__checkItem(Elm_Object_Item *item, CtListView *view, CtCheckState checkState) +{ + //WHIT(); + elm_genlist_item_selected_set(item, EINA_FALSE); + + CtListView::CtListDataItem* itemData = (CtListView::CtListDataItem*)elm_object_item_data_get(item); + WPRET_VM(itemData == NULL, false, "itemData is null"); + WDEBUG("__ctrlType %d", __ctrlType); + + if(checkState == __getCheckState(item)) + return false; + + if(checkState == CHECK_ON) { + int checkedNum = 0; + + checkedNum = __listModel->getCheckedDataCount()+1; + + if(__checkLimitCount(checkedNum, __listModel->getLimitCount()) == true) + return false; + } + + switch(__ctrlType){ + case LIST_CTRL_REQUEST_CHECK_FOR_VCARD: + { + __changeCheckState(item, checkState, false); + } + break; + case LIST_CTRL_REQUEST_CHECK_FOR_LINK_CONTACTS: + case LIST_CTRL_REQUEST_CHECK_FOR_PERSON: + { + if(__changeCheckState(item, checkState, false) == true) { + __setCheckedInfo(item, NULL, CT_LIST_DATA_PERSON); + } + } + break; + case LIST_CTRL_REQUEST_CHECK_FOR_NUMBER: + { + if(checkState == CHECK_OFF) { + __changeCheckState(item, checkState, false); + break; + } + + if(__changeCheckState(item, checkState, false) == true) { + Eina_List *cursor = NULL; + void *data = NULL; + Eina_List *dataList = itemData->personData->getNumberList(); + EINA_LIST_FOREACH(dataList, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + __setCheckedInfo(item, record, CT_LIST_DATA_NUMBER); + break; + } + } + } + break; + case LIST_CTRL_REQUEST_CHECK_FOR_EMAIL: + { + if(checkState == CHECK_OFF) { + __changeCheckState(item, checkState, false); + break; + } else if(checkState == CHECK_ON){ + Evas_Object* layout = elm_object_item_part_content_get(item,"elm.icon.2"); + Evas_Object* check = elm_layout_content_get(layout, "elm.swallow.content"); + elm_check_state_set(check, EINA_FALSE); + } + + if(__changeCheckState(item, checkState, false) == true) { + Eina_List *cursor = NULL; + void *data = NULL; + Eina_List *dataList = itemData->personData->getEmailList(); + EINA_LIST_FOREACH(dataList, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + __setCheckedInfo(item, record, CT_LIST_DATA_EMAIL); + break; + } + } + } + break; + case LIST_CTRL_REQUEST_CHECK_FOR_NUMBER_OR_EMAIL: + { + if(checkState == CHECK_OFF) { + __changeCheckState(item, checkState, false); + break; + } else if(checkState == CHECK_ON){ + Evas_Object* layout = elm_object_item_part_content_get(item,"elm.icon.2"); + Evas_Object* check = elm_layout_content_get(layout, "elm.swallow.content"); + elm_check_state_set(check, EINA_FALSE); + } + + if(__changeCheckState(item, checkState, false) == true) { + Eina_List *cursor = NULL; + void *data = NULL; + Eina_List *dataList = itemData->personData->getNumberList(); + if(dataList == NULL) { + dataList = itemData->personData->getEmailList(); + EINA_LIST_FOREACH(dataList, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + __setCheckedInfo(item, record, CT_LIST_DATA_EMAIL); + break; + } + } + else { + EINA_LIST_FOREACH(dataList, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + __setCheckedInfo(item, record, CT_LIST_DATA_NUMBER); + break; + } + } + } + } + break; + default: + WWARNING("Not handled type=%d", __ctrlType); + break; + } + + elm_genlist_realized_items_update(view->__genlist); + + return true; +} + + +bool CtListUgMultiPickController::__checkLimitCount(int checkCount, int limitCount) +{ + WHIT(); + + if(limitCount == 0) + return false; + + if(limitCount < checkCount) { + WPopup* popup = new WPopup(); + popup->setTextTranslatable(PACKAGE); + popup->setTitle("IDS_WMGR_HEADER_UNABLE_TO_SELECT_MORE_ITEMS_ABB"); + char buf[CT_TEXT_MAX_LEN] = {0,}; + snprintf(buf, sizeof(buf), ctGetContactsString("IDS_PB_POP_THE_MAXIMUM_NUMBER_OF_ITEMS_THAT_CAN_BE_SELECTED_HPD_HAS_BEEN_EXCEEDED"), __listModel->getLimitCount()); + popup->setContent(buf); + popup->addButton("IDS_PB_BUTTON_OK_ABB2", NULL ); + + WDEBUG("limitcount %d, checkcount %d", limitCount, checkCount); + __listView->attachPopup(popup); + return true; + } + + return false; +} + +bool CtListUgMultiPickController::__checkMaxLinkCount(const int currentContactLinkedCount, const int checkedContactLinkedCount) +{ + WHIT(); + int sumOfCheckedContactLinkCount = 0; + + std::unique_ptr<std::vector<std::shared_ptr<CtListDataPerson>>> checkedDatas(__listModel->getCheckedDataList()); + int checkedDataCount = checkedDatas->size(); + if (checkedDataCount) { + for(auto iter = checkedDatas->begin();iter != checkedDatas->end();++iter) { + sumOfCheckedContactLinkCount += (*iter)->getLinkedCount(); + } + } + + WDEBUG("current %d checked %d total%d", currentContactLinkedCount, checkedContactLinkedCount, sumOfCheckedContactLinkCount); + if(currentContactLinkedCount+checkedContactLinkedCount+sumOfCheckedContactLinkCount <= 10) + return false; + + WPopup* popup = new WPopup(); + popup->setTextTranslatable(PACKAGE); + popup->setTitle("IDS_WMGR_HEADER_UNABLE_TO_SELECT_MORE_ITEMS_ABB"); + char buf[CT_TEXT_MAX_LEN] = {0,}; + snprintf(buf, sizeof(buf), ctGetContactsString("IDS_PB_POP_UNABLE_TO_ADD_CONTACTS_MAXIMUM_NUMBER_OF_LINKABLE_CONTACTS_HPD_REACHED"), 10); + popup->setContent(buf); + popup->addButton("IDS_PB_BUTTON_OK_ABB2", NULL ); + + __listView->attachPopup(popup); + return true; +} + +void CtListUgMultiPickController::__doReplyCheckedInfo() +{ + WENTER(); + if(__ctrlType == LIST_CTRL_REQUEST_CHECK_FOR_VCARD) { + __vcardReplyCheckedInfo(); + return; + } + + std::unique_ptr<std::vector<std::shared_ptr<CtListDataPerson>>> checkedData(__listModel->getCheckedDataList()); + int checkedDataCount = checkedData->size(); + if (checkedDataCount == 0) { + WERROR("no checked item"); + return; + } + + char **resultArray = new char*[checkedDataCount]; + char **result = resultArray; + + for (auto &&data : *checkedData) { + int dataId = 0; + if (data->getDataType() == CT_LIST_DATA_PERSON) { + dataId = data->getPersonId(); + } else { + dataId = data->getDataId(); + } + + char buf[CT_TEXT_SHORT_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%d", dataId); + *result++ = strdup(buf); + } + + __listView->sendMultiResult((const char**) resultArray, checkedDataCount); + for (int i = 0; i < checkedDataCount; ++i) { + free(resultArray[i]); + } + + delete [] resultArray; + __listView->popOut(); +} + +void CtListUgMultiPickController::__vcardReplyCheckedInfo() +{ + std::unique_ptr<std::vector<std::shared_ptr<CtListDataPerson>>> checkedData(__listModel->getCheckedDataList()); + WPRET_M(!checkedData, "checkedData is null"); + int checkedDataCount = checkedData->size(); + WPRET_M(!checkedDataCount, "checkedDataCount is null"); + + std::vector<int> personIdList; + CtContactsToVcard *vcard = NULL; + + personIdList.reserve(checkedDataCount); + for (auto &item : *checkedData) { + personIdList.push_back(item->getPersonId()); + } + + vcard = new CtContactsToVcard("Pick contacts", TargetStorage::INTERNAL_OTHER, std::move(personIdList)); + vcard->setOnFinish(std::bind(&CtListUgMultiPickController::__sendVcardResult, this, std::placeholders::_1)); + + __listView->attachPopup(vcard->getProgressPopup()); + + vcard->run(); +} + +void CtListUgMultiPickController::__sendVcardResult(CtProgressController& controller) +{ + CtContactsToVcard &vcard = static_cast<CtContactsToVcard&>(controller); + const char *vcardPath = vcard.getVcardPath().c_str(); + + __listView->sendMultiResult(&vcardPath, 1); + __listView->popOut(); +} diff --git a/lib-contact/ct-list/src/CtListUgMultiPickController.h b/lib-contact/ct-list/src/CtListUgMultiPickController.h new file mode 100644 index 0000000..98b2f06 --- /dev/null +++ b/lib-contact/ct-list/src/CtListUgMultiPickController.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __CT_LIST_UG_MULTI_PICK_CONTROLLER_H_ +#define __CT_LIST_UG_MULTI_PICK_CONTROLLER_H_ + +#include "WPopup.h" + +#include "ContactsCommon.h" +#include "CtListView.h" +#include "CtType.h" +#include "CtListController.h" +#include "CtListDataPerson.h" + + +class CtListView; +class CtListModelDb; +class CtProgressController; +class CtListUgMultiPickController : public CtListController +{ +public: + CtListUgMultiPickController(CtListResultType resultType, CtListView *listView, CtListModelDb* listData); + CtListUgMultiPickController(CtListCtrlType ctrlType, CtListView *listView, CtListModelDb* listData); + virtual ~CtListUgMultiPickController(); + +public: + virtual void onListUpdated() {}; + virtual void onSelectItem(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState); + virtual void onSelectDone(void *data, Evas_Object *obj, void *event_info); + virtual void onSelectBack(void *data, Evas_Object *obj, void *event_info); + virtual void onSelectCancel(void *data, Evas_Object *obj, void *event_info); + virtual void onSwipeLeftItem(void *data, Evas_Object *obj, void *event_info); + virtual void onSwipeRightItem(void *data, Evas_Object *obj, void *event_info); + virtual void onSelectCheckAll(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState); + virtual void moreManageFavoritesItemOperation(); + virtual void onSelectMenu(CtListView *view) {} + + +private: + typedef struct { + CtListUgMultiPickController *controller; + + contacts_record_h record; + Elm_Object_Item *popupItem; + int dataType; + }CtListPopupItemData; + + +private: + void __doReplyCheckedInfo(); + bool __checkLimitCount(int checkCount, int limitCount); + bool __checkMaxLinkCount(const int currentContactLinkedCount, const int checkedContactLinkedCount); + bool __checkItem(Elm_Object_Item *item, CtListView *view, CtCheckState checkState); + void __vcardReplyCheckedInfo(); + void __sendVcardResult(CtProgressController &controller); + + +private: + //for check for data + static void __onSelectDataPopupItem(void *data, Evas_Object *obj, void *event_info); + + void __updateTitleAndDone(); + bool __changeCheckState(Elm_Object_Item *item, CtCheckState checkState, bool updateTitleAndDone); + static CtCheckState __getCheckState(Elm_Object_Item *item); + Evas_Object* __createDataListPopup(Elm_Object_Item *item, int dataType); + void __setCheckedInfo(Elm_Object_Item *item, contacts_record_h record, CtListItemDataType dataType); +private: + CtListUgMultiPickController(); +private: + CtListView* __listView; + CtListModelDb* __listModel; + CtListCtrlType __ctrlType; + //use for child data copy + CtListDataPerson *__selectedPersonData; + int __linkedCount; +}; + +#endif //__CT_LIST_UG_MULTI_PICK_CONTROLLER_H_ + diff --git a/lib-contact/ct-list/src/CtListUgSinglePickController.cpp b/lib-contact/ct-list/src/CtListUgSinglePickController.cpp new file mode 100755 index 0000000..035da2c --- /dev/null +++ b/lib-contact/ct-list/src/CtListUgSinglePickController.cpp @@ -0,0 +1,394 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <fcntl.h> +#include <vector> +#include <thread> +#include <Elementary.h> +#include <app.h> +#include <contacts.h> +#include <glib.h> +#include <app_preference.h> + +#include "WView.h" +#include "WNaviframe.h" +#include "WPopup.h" + +#include "ContactsDebug.h" +#include "CtType.h" +#include "CtListUgSinglePickController.h" +#include "CtListDataPerson.h" +#include "CtCommon.h" +#include "CtListView.h" +#include "CtListModelDb.h" +#include "CtProgressBarPopup.h" +#include "CtNumberPopup.h" + +#define __ITEM_HEIGHT 96 + + +CtListUgSinglePickController::CtListUgSinglePickController(CtListResultType resultType, CtListView *listView, CtListModelDb* listData) +{ + WHIT(); + __listView = listView; + __idler = NULL; + __selectedPersonData = NULL; + __listModel = listData; + __resultType = resultType; +} + +CtListUgSinglePickController::~CtListUgSinglePickController() +{ + WHIT(); + + if(__idler) + ecore_idler_del(__idler); + __idler = NULL; + + if(__selectedPersonData) + delete __selectedPersonData; +} + +Eina_Bool CtListUgSinglePickController::__doReplyIdle(void* data) +{ + CtListUgSinglePickController *controller = (CtListUgSinglePickController*)data; + CtListDataPerson *personData = controller->__selectedPersonData; + + switch(controller->__resultType) { + case LIST_RESULT_ID: + case LIST_RESULT_VCARD: + controller->__doReplySelectedInfo(personData); + break; + case LIST_RESULT_NUMBER: + if(controller->__createDataListPopup(personData, CT_LIST_DATA_NUMBER) == NULL) + controller->__doReplySelectedInfo(personData); + break; + case LIST_RESULT_EMAIL: + if(controller->__createDataListPopup(personData, CT_LIST_DATA_EMAIL) == NULL) + controller->__doReplySelectedInfo(personData); + break; + case LIST_RESULT_NUMBER_OR_EMAIL: + if(controller->__createDataListPopup(personData, CT_LIST_DATA_ALL) == NULL) + controller->__doReplySelectedInfo(personData); + break; + default: + WERROR("wrong control type"); + break; + } + + controller->__idler = NULL; + return EINA_FALSE; +} + +void CtListUgSinglePickController::onSelectItem(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState) +{ + WHIT(); + + elm_genlist_item_selected_set(selectedItem, EINA_FALSE); + CtListView::CtListDataItem* itemData = (CtListView::CtListDataItem*)elm_object_item_data_get(selectedItem); + if(__selectedPersonData) + delete __selectedPersonData; + __selectedPersonData = itemData->personData->makeClone(); + + __idler = ecore_idler_add(__doReplyIdle, this); +} + +void CtListUgSinglePickController::onSelectCreate(void *data, Evas_Object *obj, void *event_info) +{ + __listView->sendSingleResult("0", LIST_RESULT_ID); + __listView->popOut(); +} + +void CtListUgSinglePickController::onSelectDone(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); +} + + +void CtListUgSinglePickController::onSelectCancel(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); +} + +void CtListUgSinglePickController::onSelectBack(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + + __listView->sendSingleResult(nullptr, LIST_RESULT_ID); +} + +void CtListUgSinglePickController::onSwipeLeftItem(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); +} + + +void CtListUgSinglePickController::onSwipeRightItem(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); +} + +void CtListUgSinglePickController::onSelectCheckAll(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState) +{ + WHIT(); +} + +void CtListUgSinglePickController::moreManageFavoritesItemOperation() +{ + WHIT(); +} + + +void CtListUgSinglePickController::__doReplySelectedInfo(CtListDataPerson* personData) +{ + WENTER(); + + switch(__resultType) { + case LIST_RESULT_ID: + { + char buf[CT_TEXT_SHORT_LEN] = {0, }; + snprintf(buf, sizeof(buf), "%d", personData->getPersonId()); + __listView->sendSingleResult(buf, __resultType); + } + break; + case LIST_RESULT_NUMBER_OR_EMAIL: + case LIST_RESULT_NUMBER: + case LIST_RESULT_EMAIL: + { + char buf[CT_TEXT_SHORT_LEN] = {0, }; + snprintf(buf, sizeof(buf), "%d", personData->getDataId()); + __listView->sendSingleResult(buf, (CtListResultType) personData->getDataType()); + } + break; + case LIST_RESULT_VCARD: + { + std::string vcardPath = createVcardFile(personData->getPersonRecord()); + __listView->sendSingleResult(vcardPath.c_str(), __resultType); + } + break; + default: + break; + } + + __listView->popOut(); +} + +Evas_Object* CtListUgSinglePickController::__createDataListPopup(CtListDataPerson *personData, int dataType) +{ + WDEBUG("dataType %d", dataType); + + Eina_List *numberList = NULL; + Eina_List *emailList = NULL; + Eina_List *checked_numberList = NULL; + Eina_List *checked_emailList = NULL; + int dataId = 0; + int err = CONTACTS_ERROR_NONE; + if(dataType & CT_LIST_DATA_NUMBER) { + numberList = personData->getNumberList(); + checked_numberList = ctCommonGetChekedDuplicatedNumberList(numberList); + } + + if(dataType & CT_LIST_DATA_EMAIL) { + emailList = personData->getEmailList(); + checked_emailList = ctCommonGetChekedDuplicatedEmailList(emailList); + } + + if(eina_list_count(checked_numberList) == 1 && eina_list_count(checked_emailList) == 0) { + char *dataString = NULL; + err = contacts_record_get_int((contacts_record_h)eina_list_nth(checked_numberList, 0), _contacts_person_number.number_id, &dataId); + WPWARN(err != CONTACTS_ERROR_NONE, "contacts_record_get_int() fail(%d)",err); + err = contacts_record_get_str_p((contacts_record_h)eina_list_nth(checked_numberList, 0), _contacts_person_number.number, &dataString); + WPWARN(err != CONTACTS_ERROR_NONE, "contacts_record_get_str_p() fail(%d)",err); + + personData->setDataId(dataId); + personData->setDataString(dataString); + personData->setDataType(LIST_RESULT_NUMBER); + ctCommonDestroyRecordList(checked_numberList); + + if (__resultType == LIST_RESULT_NUMBER_OR_EMAIL) { + return __createNumberPopup(personData); + } + + return NULL; + } else if(eina_list_count(checked_numberList) == 0 && eina_list_count(checked_emailList) == 1) { + err = contacts_record_get_int((contacts_record_h)eina_list_nth(checked_emailList, 0), _contacts_person_email.email_id, &dataId); + WPWARN(err != CONTACTS_ERROR_NONE, "contacts_record_get_int() fail(%d)",err); + + personData->setDataId(dataId); + personData->setDataType(LIST_RESULT_EMAIL); + ctCommonDestroyRecordList(checked_emailList); + + return NULL; + } + + Elm_Genlist_Item_Class* itc = elm_genlist_item_class_new(); + if (!itc) { + WERROR("elm_genlist_item_class_new() failed"); + ctCommonDestroyRecordList(checked_numberList); + ctCommonDestroyRecordList(checked_emailList); + return NULL; + } + + itc->item_style = "type1"; + itc->func.text_get = [](void* data, Evas_Object* obj, const char* part)->char* + { + CtListUgSinglePickController::CtListPopupItemData *popupItemData = (CtListUgSinglePickController::CtListPopupItemData*)data; + if(!strcmp(part, "elm.text")){ + char *value = NULL; + int err = CONTACTS_ERROR_NONE; + if(popupItemData->dataType == CT_LIST_DATA_NUMBER){ + err = contacts_record_get_str_p(popupItemData->record, _contacts_person_number.number, &value); + WPWARN(err != CONTACTS_ERROR_NONE, "contacts_record_get_str_p() fail(%d)",err); + } + else if(popupItemData->dataType == CT_LIST_DATA_EMAIL){ + err = contacts_record_get_str_p(popupItemData->record, _contacts_person_email.email, &value); + WPWARN(err != CONTACTS_ERROR_NONE, "contacts_record_get_str_p() fail(%d)",err); + } + else + WPRET_VM(1, NULL, "wrong dataType %d", popupItemData->dataType); + + if (value) + return SAFE_STRDUP(value); + else + return NULL; + } + return NULL; + }; + itc->func.del = [](void* data, Evas_Object* obj)->void + { + CtListPopupItemData *popupItemData = (CtListPopupItemData*)data; + contacts_record_destroy(popupItemData->record, true); + delete popupItemData; + }; + + WPopup* popup = new WPopup(); + popup->setTextTranslatable(PACKAGE); + popup->setTitle(personData->getDisplayName()); + popup->setContent([this,itc,checked_numberList,checked_emailList](Evas_Object* parent)->Evas_Object* + { + Evas_Object* genlist = elm_genlist_add(parent); + elm_object_style_set( genlist, "popup" ); + elm_genlist_homogeneous_set(genlist, EINA_TRUE); + elm_genlist_mode_set( genlist, ELM_LIST_COMPRESS ); + elm_scroller_content_min_limit( genlist, EINA_FALSE, EINA_TRUE ); // Automatically pop-up height is calculated + elm_object_content_set(parent, genlist); + + void *data = NULL; + int count = 0; + int err = CONTACTS_ERROR_NONE; + Eina_List *cursor; + EINA_LIST_FOREACH(checked_numberList, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + + CtListPopupItemData *popupItemData = new CtListPopupItemData; + err = contacts_record_clone(record, &popupItemData->record); + if(err != CONTACTS_ERROR_NONE) + { + if(popupItemData->record) + contacts_record_destroy(popupItemData->record, true); + delete popupItemData; + WERROR("contacts_record_clone() Failed(%d)", err); + break; + } + popupItemData->controller = this; + popupItemData->dataType = CT_LIST_DATA_NUMBER; + + popupItemData->popupItem = elm_genlist_item_append(genlist, itc, (void*)popupItemData, NULL, ELM_GENLIST_ITEM_NONE, CtListUgSinglePickController::__onSelectDataPopupItem, popupItemData); + count++; + } + ctCommonDestroyRecordList(checked_numberList); + + EINA_LIST_FOREACH(checked_emailList, cursor, data) { + contacts_record_h record = (contacts_record_h)data; + + CtListPopupItemData *popupItemData = new CtListPopupItemData; + err = contacts_record_clone(record, &popupItemData->record); + if(err != CONTACTS_ERROR_NONE) + { + WERROR("contacts_record_clone() Failed(%d)", err); + if(popupItemData->record) + contacts_record_destroy(popupItemData->record, true); + delete popupItemData; + break; + } + popupItemData->controller = this; + popupItemData->dataType = CT_LIST_DATA_EMAIL; + + popupItemData->popupItem = elm_genlist_item_append(genlist, itc, (void*)popupItemData, NULL, ELM_GENLIST_ITEM_NONE, CtListUgSinglePickController::__onSelectDataPopupItem, popupItemData); + count++; + } + ctCommonDestroyRecordList(checked_emailList); + + evas_object_show(genlist); + + return genlist; + + }); + + __listView->attachPopup(popup); + + elm_genlist_item_class_free(itc); + + return popup->getEvasObj(); +} + +Evas_Object* CtListUgSinglePickController::__createNumberPopup(CtListDataPerson *personData) +{ + CtNumberPopup *popup = new CtNumberPopup(personData); + popup->setOnResult(std::bind(&CtListUgSinglePickController::__doReplySelectedInfo, + this, std::placeholders::_1)); + __listView->attachPopup(popup); + return popup->getEvasObj(); +} + +void CtListUgSinglePickController::__onSelectDataPopupItem(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + CtListPopupItemData *popupItemData = (CtListPopupItemData*)data; + int err = CONTACTS_ERROR_NONE; + + popupItemData->controller->__listView->destroyPopup(); + + int dataId = 0; + char *dataString = NULL; + if(popupItemData->dataType == CT_LIST_DATA_NUMBER) { + err = contacts_record_get_int(popupItemData->record, _contacts_person_number.number_id, &dataId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + err = contacts_record_get_str_p(popupItemData->record, _contacts_person_number.number, &dataString); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + popupItemData->controller->__selectedPersonData->setDataId(dataId); + popupItemData->controller->__selectedPersonData->setDataString(dataString); + popupItemData->controller->__selectedPersonData->setDataType(LIST_RESULT_NUMBER); + + if (popupItemData->controller->__resultType + == LIST_RESULT_NUMBER_OR_EMAIL) { + popupItemData->controller->__createNumberPopup(popupItemData->controller->__selectedPersonData); + return; + } + } + else if(popupItemData->dataType == CT_LIST_DATA_EMAIL) { + err = contacts_record_get_int(popupItemData->record, _contacts_person_email.email_id, &dataId); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + err = contacts_record_get_str_p(popupItemData->record, _contacts_person_email.email, &dataString); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + popupItemData->controller->__selectedPersonData->setDataId(dataId); + popupItemData->controller->__selectedPersonData->setDataString(dataString); + popupItemData->controller->__selectedPersonData->setDataType(LIST_RESULT_EMAIL); + } + + popupItemData->controller->__doReplySelectedInfo(popupItemData->controller->__selectedPersonData); +} diff --git a/lib-contact/ct-list/src/CtListUgSinglePickController.h b/lib-contact/ct-list/src/CtListUgSinglePickController.h new file mode 100644 index 0000000..9735502 --- /dev/null +++ b/lib-contact/ct-list/src/CtListUgSinglePickController.h @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __CT_LIST_UG_SINGLE_PICK_CONTROLLER_H_ +#define __CT_LIST_UG_SINGLE_PICK_CONTROLLER_H_ + +#include "WPopup.h" + +#include "ContactsCommon.h" +#include "CtListView.h" +#include "CtType.h" +#include "CtListController.h" + +class CtListView; +class CtListModelDb; +class CtListUgSinglePickController : public CtListController +{ +public: + CtListUgSinglePickController(CtListResultType resultType, CtListView *listView, CtListModelDb* listData); + virtual ~CtListUgSinglePickController(); + +public: + virtual void onListUpdated() {}; + virtual void onSelectItem(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState); + virtual void onSelectCreate(void *data, Evas_Object *obj, void *event_info); + virtual void onSelectDone(void *data, Evas_Object *obj, void *event_info); + virtual void onSelectBack(void *data, Evas_Object *obj, void *event_info); + virtual void onSelectCancel(void *data, Evas_Object *obj, void *event_info); + virtual void onSwipeLeftItem(void *data, Evas_Object *obj, void *event_info); + virtual void onSwipeRightItem(void *data, Evas_Object *obj, void *event_info); + virtual void onSelectCheckAll(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState); + virtual void moreManageFavoritesItemOperation(); + virtual void onSelectMenu(CtListView *view) {} + +private: + void __doReplySelectedInfo(CtListDataPerson *personData); + Evas_Object* __createDataListPopup(CtListDataPerson *personData, int dataType); + Evas_Object* __createNumberPopup(CtListDataPerson *personData); + static void __onSelectDataPopupItem(void *data, Evas_Object *obj, void *event_info); + static Eina_Bool __doReplyIdle(void* data); +private: + CtListUgSinglePickController(); + +private: + typedef struct { + CtListUgSinglePickController *controller; + + contacts_record_h record; + Elm_Object_Item *popupItem; + int dataType; + }CtListPopupItemData; + +private: + CtListView* __listView; + CtListModelDb* __listModel; + CtListResultType __resultType; + + CtListDataPerson *__selectedPersonData; + Ecore_Idler *__idler; +}; + +#endif //__CT_LIST_UG_SINGLE_PICK_CONTROLLER_H_ + diff --git a/lib-contact/ct-list/src/CtListUgVcardViewController.cpp b/lib-contact/ct-list/src/CtListUgVcardViewController.cpp new file mode 100644 index 0000000..15dcc9a --- /dev/null +++ b/lib-contact/ct-list/src/CtListUgVcardViewController.cpp @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <vector> +#include <thread> +#include <Elementary.h> +#include <app.h> +#include <contacts.h> + +#include "WView.h" +#include "WNaviframe.h" +#include "WPopup.h" +#include "WToastPopup.h" + +#include "ContactsDebug.h" +#include "CtType.h" +#include "CtListDataPerson.h" +#include "CtCommon.h" +#include "CtListView.h" +#include "CtListModelVcard.h" +#include "CtListLoadingPopup.h" +#include "CtListUgVcardViewController.h" +#include "CtImporter.h" +#include "CtProgressBarPopup.h" + + +CtListUgVcardViewController::CtListUgVcardViewController(const std::string& vcardPath, CtListView *listView, CtListModelVcard* listData) +: __vcardPath(vcardPath) +, __listView(listView) +, __listModel(listData) +, __popup(NULL) +, __showLoadingPopup(false) +{ + __getVcardPathFromUri(); + + __listModel->setOnLoadCompleteCb([this](int count, int total, bool showToast){ + if (showToast) { + ecore_job_add([](void* data){ + WENTER(); + CtListUgVcardViewController* self = static_cast<CtListUgVcardViewController*>(data); + WToastPopup* popup = new WToastPopup("Only first 100 contacts displayed."); + self->__listView->attachPopup(popup); + WLEAVE(); + }, this); + } + }); +} + +CtListUgVcardViewController::~CtListUgVcardViewController() +{ + WHIT(); +} + +void CtListUgVcardViewController::onSelectItem(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState) +{ + WHIT(); + elm_genlist_item_selected_set(selectedItem, EINA_FALSE); +} + +void CtListUgVcardViewController::onSelectDone(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + const int deviceAbId = 0; + std::vector<std::string> vcards; + vcards.push_back(__vcardPath); + + CtImporter *contactImporter = new CtImporter(deviceAbId, std::move(vcards), __listModel->getContactsCount(LIST_QUERY_DEFAULT)); + __listView->attachPopup(contactImporter->getProgressPopup()); + __listView->attachHiddenPopup(contactImporter->getCancelPopup()); + contactImporter->run(); +} + +void CtListUgVcardViewController::onSelectCancel(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + __listView->popOut(); +} + +void CtListUgVcardViewController::onSelectBack(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); +} + +void CtListUgVcardViewController::onSwipeLeftItem(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); +} + +void CtListUgVcardViewController::onSwipeRightItem(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); +} + +void CtListUgVcardViewController::onSelectCheckAll(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState) +{ + WHIT(); +} + +void CtListUgVcardViewController::moreManageFavoritesItemOperation() +{ + WHIT(); +} + +void CtListUgVcardViewController::onImportFinished(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data) +{ + WHIT(); + CtListUgVcardViewController* c = static_cast<CtListUgVcardViewController*>(user_data); + + c->__listView->popOut(); +} + +void CtListUgVcardViewController::__getVcardPathFromUri(void) +{ + std::string prefix("file://"); + + size_t position = 0; + if ((position = __vcardPath.find(prefix)) != std::string::npos) { + __vcardPath.erase(position, prefix.length()); + } + + WDEBUG("vcard path is %s", __vcardPath.c_str()); +} diff --git a/lib-contact/ct-list/src/CtListUgVcardViewController.h b/lib-contact/ct-list/src/CtListUgVcardViewController.h new file mode 100644 index 0000000..1f70171 --- /dev/null +++ b/lib-contact/ct-list/src/CtListUgVcardViewController.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __CT_LIST_UG_VCARD_VIEW_CONTROLLER_H_ +#define __CT_LIST_UG_VCARD_VIEW_CONTROLLER_H_ + +#include <string> +#include <app.h> +#include "WPopup.h" + +#include "ContactsCommon.h" +#include "CtListView.h" +#include "CtType.h" +#include "CtListController.h" + + + +class CtListView; +class CtListModelVcard; +class CtListLoadingPopup; + +class CtListUgVcardViewController : public CtListController +{ +public: + CtListUgVcardViewController(const std::string& vcardPath, CtListView *listView, CtListModelVcard* listData); + virtual ~CtListUgVcardViewController(); + +public: + virtual void onListUpdated() {}; + virtual void onSelectItem(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState); + virtual void onSelectDone(void *data, Evas_Object *obj, void *event_info); + virtual void onSelectCancel(void *data, Evas_Object *obj, void *event_info); + virtual void onSelectBack(void *data, Evas_Object *obj, void *event_info); + virtual void onSwipeLeftItem(void *data, Evas_Object *obj, void *event_info); + virtual void onSwipeRightItem(void *data, Evas_Object *obj, void *event_info); + virtual void onSelectCheckAll(Elm_Object_Item *selectedItem, CtListView *view, CtCheckState checkState); + virtual void moreManageFavoritesItemOperation(); + virtual void onSelectMenu(CtListView *view) {} + + static void onImportFinished(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data); +private: + CtListUgVcardViewController(); + void __getVcardPathFromUri(void); + +private: + std::string __vcardPath; + CtListView* __listView; + CtListModelVcard* __listModel; + CtListLoadingPopup* __popup; + bool __showLoadingPopup; +}; + +#endif //__CT_LIST_UG_VCARD_VIEW_CONTROLLER_H_ + diff --git a/lib-contact/ct-list/src/CtListView.cpp b/lib-contact/ct-list/src/CtListView.cpp new file mode 100755 index 0000000..c4fef11 --- /dev/null +++ b/lib-contact/ct-list/src/CtListView.cpp @@ -0,0 +1,3858 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <dlfcn.h> +#include <app.h> +#include <contacts.h> +#include <string> +#include <telephony.h> +#include <system_settings.h> +#include <app_preference.h> + +#include "WNaviframe.h" +#include "WWindow.h" +#include "WMenuPopup.h" +#include "WEditfield.h" +#include "ContactsDebug.h" + +#include "CtPath.h" +#include "CtCommon.h" +#include "ContactsCommon.h" +#include "ContactsAppControl.h" +#include "ContactsAppControlLauncher.h" +#include "ContactsThumbnail.h" + +#include "CtListView.h" +#include "CtListModelDb.h" +#include "CtListModelVcard.h" +#include "CtListModelLinkSuggest.h" +#include "CtListModelGroup.h" + +#include "CtListDataPerson.h" +#include "CtListDataGroup.h" + +#include "CtListBasicController.h" +#include "CtListUgSinglePickController.h" +#include "CtListUgMultiPickController.h" +#include "CtListUgVcardViewController.h" +#include "CtListLinkContactController.h" +#include "CtRegistryMgr.h" +#include "CtThemeMgr.h" + +#ifdef __cplusplus + extern "C" { +#endif +#include <efl_extension.h> +#ifdef __cplusplus + } +#endif + +#ifdef _SDK_BUILD + //#define //ELM_IMAGE_ASYNC_OPEN_SET(ICON,VALUE) WERROR("not support API: //ELM_IMAGE_ASYNC_OPEN_SET()") +#else + //#define //ELM_IMAGE_ASYNC_OPEN_SET(ICON,VALUE) //ELM_IMAGE_ASYNC_OPEN_SET(ICON, VALUE); +#endif + +#define CONTACTS_GAL_SEARCH_LIST 20 +#define CT_LIST_IMAGE_LOAD_TIMER 0.3 + +static const Eina_Unicode __hangulCompatibilityChoseong[14] = { + 12593, 12596, 12599, 12601, 12609, 12610, 12613, //unicode 3131 ~ 314E + 12615, 12616, 12618, 12619, 12620, 12621, 12622}; + +static const Eina_Unicode __hangulJamoChoseong[14] = { + 4352, 4354, 4355, 4357, 4358, 4359, 4361, //unicode 1100 ~ 1112 + 4363, 4364, 4366, 4367, 4368, 4369, 4370}; + +namespace +{ + const char *SYMBOL_MAGNIFIER = "\U0001f50d"; + const char *SYMBOL_STAR = "\uF896"; +} + +CtListView::CtListView(const char *vcardPath) +{ + WENTER(); + __initialize(); + __hasTitle = true; + __hasDefaultList = true; + __hasDoneCancel = true; + __enableDone = true; + + CtListModelVcard *model = new CtListModelVcard(vcardPath); + __listModel = model; + __listController = new CtListUgVcardViewController(vcardPath, this, model); + setTitle(V_("IDS_PB_HEADER_IMPORT_CONTACTS_ABB2")); +} + +CtListView::CtListView(CtListSelectMode selectMode, CtListResultType resultType, int limit) +{ + WENTER(); + __initialize(); + + __hasTitle = true; + __hasSearchbar = true; + __hasDefaultList = true; + __hasGroupTitle = true; + __hasFastscroll = true; + __hasFavoriteList = true; + CtListHasType hasType = LIST_HAS_NONE; + switch (resultType) { + case LIST_RESULT_NUMBER: hasType = LIST_HAS_NUMBER; break; + case LIST_RESULT_EMAIL: hasType = LIST_HAS_EMAIL; break; + case LIST_RESULT_NUMBER_OR_EMAIL: hasType = LIST_HAS_NUMBER_OR_EMAIL; break; + case LIST_RESULT_ID: + case LIST_RESULT_VCARD: + default: + hasType = LIST_HAS_NONE; break; + } + + __listModel = new CtListModelDb(hasType, limit); + __listModel->setSelectedPersonId(__selectedPersonId); + __listGroupModel = new CtListModelGroup(); + + if (selectMode == LIST_SELECT_MULTIPLE) { + char buf[CT_TEXT_SHORT_LEN] = {0, }; + snprintf(buf, sizeof(buf), ctGetContactsString("IDS_PB_HEADER_PD_SELECTED_ABB3"), 0); + setTitle(buf); + + __viewType = LIST_VIEW_CHECK; + __hasSelectAll = true; + __hasDoneCancel = true; + __listController = new CtListUgMultiPickController(resultType, this, (CtListModelDb*) __listModel); + } else { + if (selectMode == LIST_SELECT_SINGLE_OR_CREATE) { + WDEBUG("LIST_SELECT_SINGLE_OR_CREATE"); + __hasCreateButton = true; + } + + setTitle(V_("IDS_PB_HEADER_SELECT")); + __listController = new CtListUgSinglePickController(resultType, this, (CtListModelDb*) __listModel); + } +} + +CtListView::CtListView(CtListViewType viewType, CtListDataType dataType, CtListCtrlType ctrlType) +{ + WENTER(); + __initialize(); + __initViewCondition(viewType, ctrlType); + __ctrlType = ctrlType; + + if (ctrlType == LIST_CTRL_LINK_CONTACT) { + CtListModelDb* model = new CtListModelDb(dataType); + __listModel = model; + + std::map<int, CtAddressbookInfo*>& abInfo = model->getAddressbookList(); + for (auto iter = abInfo.begin(); iter != abInfo.end(); iter++) { + if (iter->second->accountId == 0 && iter->second->addressbookId > 0){ + model->setDisplayAddressbook(iter->first, false); + } + else { + model->setDisplayAddressbook(iter->first, true); + } + WDEBUG("name:%s, id:%d", iter->second->addressbookName, iter->first); + } + __listController = new CtListLinkContactController(this, model); + } + else { + CtListModelDb* model = new CtListModelDb(dataType); + __listModel = model; + __listController = new CtListBasicController(ctrlType, this, model); + } + + __listGroupModel = new CtListModelGroup(); + + __viewType = viewType; +} + +CtListView::~CtListView() +{ + WENTER(); + + Evas_Object *conformant = NULL; + if(getWindow()) + conformant = getWindow()->getConformantEvasObj(); + + if(conformant) { + evas_object_smart_callback_del(conformant, "virtualkeypad,state,on", __onSipUpCb); + evas_object_smart_callback_del(conformant, "virtualkeypad,state,off", __onSipDownCb); + } + + evas_object_smart_callback_del(__genlist, "scroll,anim,start", __onGenlistScrollStartCb); + evas_object_smart_callback_del(__genlist, "scroll,anim,stop", __onGenlistScrollStopCb); + + if(__loadImageTimer) + ecore_timer_del(__loadImageTimer); + + if(__myProfileThread) + __myProfileThread->destroy(); + + if(__myProfileIdler) + ecore_idler_del(__myProfileIdler); + + __freeFastIndexData(); + + if(__listItc) + elm_genlist_item_class_free(__listItc); + if(__groupTitleItc) + elm_genlist_item_class_free(__groupTitleItc); + if(__myProfileItc) + elm_genlist_item_class_free(__myProfileItc); + if(__selectAllItc) + elm_genlist_item_class_free(__selectAllItc); + if(__searchbarItc) + elm_genlist_item_class_free(__searchbarItc); + if (__favoriteTitleItc) + elm_genlist_item_class_free(__favoriteTitleItc); + if (__mfcTitleItc) + elm_genlist_item_class_free(__mfcTitleItc); + if (__linkSuggestTitleItc) + elm_genlist_item_class_free(__linkSuggestTitleItc); + + if(__searchGetContactThread){ + __searchGetContactThread->destroy(); + __searchGetContactThread = NULL; + __listModel->cancelGetContacts(); + } + + SAFE_FREE(__groupName); + + delete __listController; + delete __listModel; + delete __listGroupModel; + + WLEAVE(); +} + +Eina_Bool CtListView::__onInitMyProfileIdlerCb(void *data) +{ + WHIT(); + CtListView* view = (CtListView*)data; + view->__myProfileIdler = NULL; + view->__myProfileThread = new CtThread(__onInitMyProfileThreadRunCb, view, __onInitMyProfileThreadEndCb, view); + view->__myProfileThread->start(); + + return ECORE_CALLBACK_CANCEL; +} + +void CtListView::__onInitMyProfileThreadRunCb(void *data) +{ + WHIT(); + CtListView *view = (CtListView*)data; + view->__initMyProfile(); +} + + +void CtListView::__onInitMyProfileThreadEndCb(void *data) +{ + WHIT(); + CtListView* view = (CtListView*)data; + + if(view->__myProfileItem) + elm_genlist_item_update(view->__myProfileItem); + + if(view->__myProfileThread) + view->__myProfileThread->destroy(); + view->__myProfileThread = NULL; + +} + +char* CtListView::__getMsisdnFromSim() +{ + WENTER(); + char *msisdn = NULL; + int simCount = 0; + telephony_handle_list_s tapiHandleList; + int ret = telephony_init(&tapiHandleList); + if (ret != TELEPHONY_ERROR_NONE) + WDEBUG("no sim"); + else { + simCount = tapiHandleList.count; + + /*my numbers(SIM1 and SIM2)*/ + for(int i=0; i<simCount; i ++){ + if(tapiHandleList.handle[i]) + ret = telephony_sim_get_subscriber_number(tapiHandleList.handle[i], &msisdn); + if (msisdn && *msisdn) { + WDEBUG("msisdn exists"); + break; + } + } + + ret = telephony_deinit(&tapiHandleList); + if (ret != TELEPHONY_ERROR_NONE) { + WERROR( "telephony_deinit failed(%d)", ret); + return NULL; + } + } + WLEAVE(); + return msisdn; +} + +void CtListView::__initMyProfile(void) +{ + WENTER(); + + char *msisdn = __getMsisdnFromSim(); + WPRET_M(msisdn == NULL, "no msisdn"); + + int err = CONTACTS_ERROR_NONE; + contacts_list_h myprofileList = NULL; + contacts_record_h numRecord = NULL; + contacts_record_h myRecord = NULL; + bool changed = false; + bool hasRecord = false; + + err = contacts_db_get_all_records(_contacts_my_profile._uri, 0, 0, &myprofileList); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_all_records() Failed(%d)", err); + + if (myprofileList != NULL) { + contacts_record_h contactRecord = NULL; + int count = 0; + + contacts_list_get_count(myprofileList, &count); + if (count > 0) { + err = contacts_list_get_current_record_p(myprofileList, &contactRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_get_current_record_p() Failed(%d)", err); + } + err = contacts_record_clone(contactRecord, &myRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_clone() Failed(%d)", err); + + err = contacts_list_destroy(myprofileList, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_destroy() Failed(%d)", err); + + int index = 0; + char *number = NULL; + contacts_record_h record = NULL; + + while (CONTACTS_ERROR_NONE == contacts_record_get_child_record_at_p(myRecord, _contacts_my_profile.number, index++, &record)) { + err = contacts_record_get_str_p(record, _contacts_number.number, &number); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_record_get_int() Failed(%d)", err); + continue; + } + + if (strcmp(number, msisdn) == 0) { + changed = true; + break; + } + } + + if(changed) { + SAFE_FREE(msisdn); + err = contacts_record_destroy(myRecord, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_destroy() Failed(%d)", err); + WDEBUG("my profile not changed"); + return; + } + } + + if(myRecord == NULL) { + err = contacts_record_create(_contacts_my_profile._uri, &myRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_create() Failed(%d)", err); + } + else { + hasRecord = true; + } + + if(numRecord == NULL) { + do { + if (CONTACTS_ERROR_NONE != (err = contacts_record_create(_contacts_number._uri, &numRecord))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_set_str(numRecord, _contacts_number.number, msisdn))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_set_int(numRecord, _contacts_number.type, CONTACTS_NUMBER_TYPE_CELL))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_set_bool(numRecord, _contacts_number.is_default, true))) break; + if (CONTACTS_ERROR_NONE != (err = contacts_record_set_str(numRecord, _contacts_number.label, CT_KEY_SIM_CARD_NUMBER))) break; + } while (0); + + if(CONTACTS_ERROR_NONE != err) { + SAFE_FREE(msisdn); + contacts_record_destroy(myRecord, true); + contacts_record_destroy(numRecord, true); + WERROR("contacts_record_set_str() Failed(%d)", err); + return; + } + } + + err = contacts_record_add_child_record(myRecord, _contacts_my_profile.number, numRecord); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_person_set_default_property() Failed(%d)", err); + + + int contactId = 0; + if(hasRecord == true || changed) { + WDEBUG("update my profile"); + err = contacts_db_update_record(myRecord); + } + else { + WDEBUG("insert my profile"); + err = contacts_db_insert_record(myRecord, &contactId); + } + + if (CONTACTS_ERROR_NONE != err) { + SAFE_FREE(msisdn); + contacts_record_destroy(myRecord, true); + WERROR("contacts_db_update_record() Failed(%d)", err); + return; + } + + SAFE_FREE(msisdn); + contacts_record_destroy(myRecord, true); + + WLEAVE(); +} + +const char* CtListView::getClassName() +{ + return "CtListView"; +} + +Evas_Object* CtListView::onCreate( Evas_Object* parent, void* viewParam) +{ + WENTER(); + + Evas_Object *base = createBaseLayout(parent); + __baseLayout = elm_layout_add(base); + + std::string contactsEdjePath; + std::string detailEdjePath; + std::string genlistExtendedEdjePath; + ContactsCommon::getAppEdjePath(CONTACTS_EDJ, contactsEdjePath); + ContactsCommon::getAppEdjePath(GENLIST_EXTENDED_ITEM_EDJ, genlistExtendedEdjePath); + ContactsCommon::getAppEdjePath(DETAIL_LAYOUT_EDJ, detailEdjePath); + + CtThemeMgr::getInstance()->addExtensionTheme(contactsEdjePath.c_str()); + CtThemeMgr::getInstance()->addExtensionTheme(genlistExtendedEdjePath.c_str()); + CtThemeMgr::getInstance()->addExtensionTheme(detailEdjePath.c_str()); + CtThemeMgr::getInstance()->setObjectTheme(__baseLayout); + + elm_layout_file_set(__baseLayout, contactsEdjePath.c_str(), "list/base_layout"); + evas_object_size_hint_weight_set(__baseLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(__baseLayout, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_part_content_set(base, "elm.swallow.content", __baseLayout); + evas_object_show(__baseLayout); + + if(__hasFavoriteList) + __listModel->getContacts(LIST_QUERY_FAVORITE, GET_AS_SYNC); + if(__hasMfcList) + __listModel->getContacts(LIST_QUERY_MFC, GET_AS_SYNC); + + int listCount = __listModel->getContacts(LIST_QUERY_DEFAULT, GET_AS_SYNC_ASYNC); + + // in remove favorites view, it needs to show MFC + if (__ctrlType == LIST_CTRL_REMOVE_FAVORITES) { + listCount += __listModel->getContactsCount(LIST_QUERY_MFC); + } + + if(__hasMyProfile == false && __onSearching == false) { + if(listCount > 0) { + __showGenlist(); + } + else { + __showNoContent(); + } + } + else { + WDEBUG("listCount = %d", listCount); + __showGenlist(); + } + + WLEAVE(); + + return base; +} + +void CtListView::onLanguageChanged() +{ + WHIT(); + + if(__genlist) + elm_genlist_realized_items_update(__genlist); + + if(__viewType == LIST_VIEW_REORDER) + { + elm_object_item_part_text_set(getNaviItem(), "elm.text.title", V_("IDS_PB_OPT_REORDER")); + } + Evas_Object* saveBtn = elm_object_item_part_content_get(getNaviItem(), "title_right_btn"); + if(saveBtn){ + if(__ctrlType == LIST_CTRL_DELETE_CONTACTS) + elm_object_text_set(saveBtn, V_("IDS_TPLATFORM_ACBUTTON_DELETE_ABB")); + else + elm_object_text_set(saveBtn, V_("IDS_TPLATFORM_ACBUTTON_DONE_ABB")); + } + Evas_Object* cancelBtn = elm_object_item_part_content_get(getNaviItem(), "title_left_btn"); + if(cancelBtn){ + elm_object_text_set(cancelBtn, V_("IDS_TPLATFORM_ACBUTTON_CANCEL_ABB")); + } +} + +bool CtListView::onPop() +{ + WHIT(); + + __listController->onSelectBack(this, NULL, NULL); + + return true; +} + +void CtListView::onDestroy() +{ + WENTER(); +} + +void CtListView::onDbChanged(const char* viewUri) +{ + WENTER(); + + if(__loaded == false) { + __updateQueue = 2; + WERROR("not loaded yet"); + return; + } + + // special case for 1 delete item peformace + int deletedPersonId = 0; + CtRegistryMgr::getInstance()->getInt(REGISTRY_KEY_DELETED_PERSON_ID, &deletedPersonId); + if(deletedPersonId > 0) { + Elm_Object_Item *deletedItem = getGenlistItemByPersonId(deletedPersonId); + if(deletedItem) { + WDEBUG("item of personid %d delete early", deletedPersonId); + Elm_Object_Item *nextitem = elm_genlist_item_next_get(deletedItem); + if(nextitem) { + Elm_Genlist_Item_Type itemType = elm_genlist_item_type_get(nextitem); + if(itemType == ELM_GENLIST_ITEM_GROUP) { + Elm_Object_Item *previtem = elm_genlist_item_prev_get(deletedItem); + if(previtem) { + itemType = elm_genlist_item_type_get(previtem); + if(itemType == ELM_GENLIST_ITEM_GROUP) + elm_object_item_del(previtem); + } + } + } + + elm_object_item_del(deletedItem); + } + } + + //while DB is being updated, popup is destroyed + //destroyPopup(); + + if (__onShowGroupList == true) { + if (SAFE_STRCMP(viewUri, _contacts_group_relation._uri) == 0 && __groupUpdateTimer > 10) { + WDEBUG("group changed"); + __groupUpdateTimer = 0; + WLEAVE(); + return; + } + } + if (__onShowMemberList == true) { + if (SAFE_STRCMP(viewUri, _contacts_group_relation._uri) == 0 && __groupUpdateTimer > 10) { + WDEBUG("group changed"); + __groupUpdateTimer = 0; + elm_genlist_clear(__genlist); + WLEAVE(); + return; + } + } + + __groupUpdateTimer++; + + if(__onProgressOperation == true) { + WDEBUG("do not update list on progressing"); + WLEAVE(); + return; + } + + if(__background == true) { + WDEBUG("now is background"); + + int updated = 0; + CtRegistryMgr::getInstance()->getInt(REGISTRY_KEY_FAVORITE_UPDATED, &updated); + + int inserted = 0; + CtRegistryMgr::getInstance()->getInt(REGISTRY_KEY_INSERTED_PERSON, &inserted); + + int deleted = 0; + CtRegistryMgr::getInstance()->getInt(REGISTRY_KEY_DELETED_PERSON, &deleted); + + if(!updated && !inserted && !deleted) { + __updateQueue = 1; + WLEAVE(); + return; + } + else + WDEBUG("updated %d, inserted %d, deleted %d", updated, inserted, deleted); + } + + if (__onShowGroupList == false && __onShowMemberList == false) { + __updateQueue++; + } + + WDEBUG(" __updateQueue %d", __updateQueue); + + if(__updateQueue < 2) { + __updateQueue = 1; + if(__hasFavoriteList) + __listModel->getContacts(LIST_QUERY_FAVORITE, GET_AS_ASYNC); + if(__hasMfcList) + __listModel->getContacts(LIST_QUERY_MFC, GET_AS_ASYNC); + __listModel->getContacts(LIST_QUERY_DEFAULT, GET_AS_ASYNC); + __listController->onListUpdated(); + } + else { + WDEBUG("already update requested %d. wait", __updateQueue); + } + if (__hasMyProfile) { + int updateMyprofile = (int)evas_object_data_del(getViewNaviframe(), "ct_list_update_myprofile"); + if (updateMyprofile) { + __myProfileIdler = ecore_idler_add(__onInitMyProfileIdlerCb, this); + } + } + + WLEAVE(); +} + +void CtListView::onCompleteGetContacts(int offset) +{ + WDEBUG("offset %d", offset); + //Todo We need to more action + + __loaded = true; + + if (__onShowGroupList == true || __onShowMemberList == true) { + return; + } + + bool showNocontent = false; + + if(offset == 0) { + __curAppendIndex = 0; + } + + if(__launched == 0) { + __launched = 1; + } + + int listCount = __listModel->getPersonListCount(LIST_QUERY_DEFAULT); + // in remove favorites view, it needs to show MFC + if (__ctrlType == LIST_CTRL_REMOVE_FAVORITES) { + listCount += __listModel->getContactsCount(LIST_QUERY_MFC); + } + + if (listCount == 0) { + if(__hasMyProfile == false && __onSearching == false) { + __genlist = NULL; + __showNoContent(); + showNocontent = true; + } + } + + if(showNocontent == false) { + if(__genlist == NULL) + __showGenlist(); + else { + __appendGenlistItems(offset); + __updateCheckRelatedInfo(); + // after all item appended, link reset items to fastscroll + __linkItemToRestIndex(); + } + } + + __updateQueue--; + WDEBUG(" %d", __updateQueue); + + if(__updateQueue > 0) { + WDEBUG("update request exist yet %d, update again", __updateQueue); + __updateQueue = 0; + if(__hasFavoriteList) + __listModel->getContacts(LIST_QUERY_FAVORITE, GET_AS_ASYNC); + if(__hasMfcList) + __listModel->getContacts(LIST_QUERY_MFC, GET_AS_ASYNC); + + __listModel->getContacts(LIST_QUERY_DEFAULT, GET_AS_ASYNC); + __listController->onListUpdated(); + } + else { + __updateQueue = 0; + } + + Eina_Bool sipStatus = false; + if(__searchbarItem){ + Evas_Object *entry = elm_object_item_part_content_get(__searchbarItem, "elm.swallow.content"); + sipStatus = elm_object_focus_get(entry); + } + if (false == __onSearching && false == sipStatus) { + elm_genlist_realized_items_update(__genlist); + } + else{ + WDEBUG("sipStatus is TRUE"); + } + + if(__selectedCheckAll == true) { + __listController->onSelectCheckAll(__selectAllItem, this, CHECK_ON); + __updateCheckRelatedInfo(); + __selectedCheckAll = false; + } + + WLEAVE(); +} + +void CtListView::onConditionChagned() +{ + WENTER(); + if(__hasFavoriteList) + __listModel->getContacts(LIST_QUERY_FAVORITE, GET_AS_ASYNC); + if(__hasMfcList) + __listModel->getContacts(LIST_QUERY_MFC, GET_AS_ASYNC); + __listModel->getContacts(LIST_QUERY_DEFAULT, GET_AS_ASYNC); + + __listController->onListUpdated(); +} + + +void CtListView::onPushed(Elm_Object_Item* naviItem) +{ + WHIT(); + + int listCount = __listModel->getPersonListCount(LIST_QUERY_DEFAULT); + // in remove favorites view, it needs to show MFC + if (__ctrlType == LIST_CTRL_REMOVE_FAVORITES) { + listCount += __listModel->getContactsCount(LIST_QUERY_MFC); + } + + if (listCount > 0) + __showTitleButton(true); + else + __showTitleButton(false); + + if (__hasMenu) + enableMoreButton(naviItem, __onSelectMenu, this); + + // set virtual keypad + Evas_Object *conformant = getWindow()->getConformantEvasObj(); + evas_object_smart_callback_add(conformant, "virtualkeypad,state,on", __onSipUpCb, this); + evas_object_smart_callback_add(conformant, "virtualkeypad,state,off", __onSipDownCb, this); + + __listModel->attachListener(this); +} + +Evas_Object* CtListView::__createToolbar(Evas_Object *navi) +{ + Evas_Object *toolbar = NULL; + toolbar = elm_toolbar_add(navi); + elm_object_style_set(toolbar, "default"); + elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_NONE); + elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_EXPAND); + elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE); + evas_object_show(toolbar); + + return toolbar; +} + +void CtListView::onTabSelect(Elm_Object_Item *naviItem) +{ + WHIT(); + + evas_object_smart_callback_add(getNaviframe()->getEvasObj(), "transition,finished", __onNaviTransitionFinishedCb, this); + elm_object_focus_set(getEvasObj(), EINA_TRUE); + + __background = false; + + WDEBUG("__hasTitle %d __hasToolbar %d __hasDoneCancel %", __hasTitle, __hasToolbar, __hasDoneCancel); + + if (naviItem == elm_naviframe_top_item_get(getNaviframe()->getEvasObj())) { + __showCreateButton(); + } + + __cleanSearchbar(); + destroyPopup(); + + if(__hasTitle) { + WDEBUG("item %p, title %s", naviItem, getTitle()); + elm_object_item_part_text_set(getNaviItem(), "elm.text.title", getTitle()); + } + + + if(__hasToolbar) { + WDEBUG("need toobar"); + Evas_Object *toolbar = __createToolbar(getViewNaviframe()); + elm_object_item_part_content_set(naviItem, "toolbar", toolbar); + elm_toolbar_item_append(toolbar, NULL, "IDS_PB_BUTTON_DONE_ABB3", __onToolbarDone, this); + } + + __showTitleButton(true); + + enableMoreButton(naviItem, __onSelectMenu, this); + + if(__updateQueue > 0) { + WDEBUG("update job remains"); + __updateQueue = 0; + onDbChanged(NULL); + } + if(__onSearching) { + __hideCreateButton(); + } +} +void CtListView::onTabUnselect(Elm_Object_Item *naviItem) +{ + WHIT(); + + evas_object_smart_callback_del(getNaviframe()->getEvasObj(), "transition,finished", __onNaviTransitionFinishedCb); + + __background = true; + + destroyPopup(); + + if(__hasCreateButton) { + __hideCreateButton(); + } + + if (__onShowGroupList == true) { + __onShowGroupList = false; + __onShowGroupButton = false; + if(__launched != 0) + elm_object_item_signal_emit(__searchbarItem, "group,button,hide", ""); + + __curAppendIndex = 0; + __appendGenlistItems(0); + } + else if (__onShowMemberList == true) { + __onShowMemberList = false; + __curAppendIndex = 0; + __appendGenlistItems(0); + } + else { + __cleanSearchbar(); + __resetCheckitems(); + } +} + +bool CtListView::onTabPop() +{ + WHIT(); + + if (__onShowGroupList == true) { + __onShowGroupList = false; + __onShowGroupButton = false; + if(__launched != 0) + elm_object_item_signal_emit(__searchbarItem, "group,button,hide", ""); + + __curAppendIndex = 0; + __appendGenlistItems(0); + + return false; + } + else if (__onShowMemberList == true) { + __onShowMemberList = false; + __curAppendIndex = 0; + __appendGenlistItems(0); + + return false; + } + return true; +} + +void CtListView::onEvent(int eventType) +{ + elm_genlist_realized_items_update(__genlist); +} + +void CtListView::__focusInCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + + WPRET_M(NULL == data, "data is NULL!"); + + CtListView *listView = (CtListView*)data; + + if (listView->__onSearching) { + Evas_Object *editfield = elm_object_item_part_content_get(listView->__searchbarItem, "elm.swallow.content"); + WEditfield *weditfield = (WEditfield *)evas_object_data_get(editfield, "weditfield"); + if(weditfield) { + eext_object_event_callback_del(weditfield->getEntry(), EEXT_CALLBACK_BACK, __onEntryBackButton); + eext_object_event_callback_add(weditfield->getEntry(), EEXT_CALLBACK_BACK, __onEntryBackButton, listView); + } else { + WERROR("weditfield is NULL"); + } + } +} + +void CtListView::onSetAsPageContent(Elm_Object_Item* parentNaviItem) +{ + WHIT(); + + evas_object_smart_callback_add(getWindow()->getEvasObj(), "focus,in", __focusInCb, this); + + // set virtual keypad + Evas_Object *conformant = getWindow()->getConformantEvasObj(); + evas_object_smart_callback_add(conformant, "virtualkeypad,state,on", __onSipUpCb, this); + evas_object_smart_callback_add(conformant, "virtualkeypad,state,off", __onSipDownCb, this); + + __listModel->attachListener(this); +} + +Evas_Object* CtListView::getViewWindow(void) +{ + if(getWindow()) + return getWindow()->getEvasObj(); + else + WASSERT_EX(1, "window null"); + + return NULL; +} + +Evas_Object* CtListView::getViewNaviframe(void) +{ + return getNaviframe()->getEvasObj(); +} + +WNaviframe* CtListView::getWNaviframe(void) +{ + return getNaviframe(); +} + +void CtListView::__resetCheckitems() +{ + WHIT(); + + __selectAllState = CHECK_OFF; + + Evas_Object* layout = elm_object_item_part_content_get(__selectAllItem, "elm.icon.2"); + if(layout) { + Evas_Object* check = elm_layout_content_get(layout, "elm.swallow.content"); + if(check) + elm_check_state_set(check, EINA_FALSE); + } + + if(__listModel->getPersonListCount(LIST_QUERY_DEFAULT) > 0) + __listController->onSelectCheckAll(__selectAllItem, this, __selectAllState); +} + + +void CtListView::__initialize(void) +{ + __baseLayout = NULL; + __fastLayout = NULL; + __fastScroll = NULL; + __genlist = NULL; + __selectAllObj = NULL; + __compose_btn = NULL; + __noContentLayout = NULL; + + __searchbarItem = NULL; + __selectAllItem = NULL; + __linkSuggestTitleItem = NULL; + __favoriteTitleItem = NULL; + __mfcTitleItem = NULL; + __myProfileItem = NULL; + + __listController = NULL; + __listModel = NULL; + __listGroupModel = NULL; + __viewType = LIST_VIEW_DEFAULT; + __ctrlType = LIST_CTRL_DEFAULT; + + __onSearching = false; + __onShowGroupButton = false; + __onShowGroupList = false; + __onShowMemberList = false; + + __sipStatus = false; + __launching = false; + __genlistScrolling = false; + __curAppendIndex = 0; + __launched = 0; + __loaded = false; + __selectedCheckAll = false; + __onProgressOperation = false; + __onNoContentLayout = false; + + __updateQueue = 0; + __fastIndexList = NULL; + + __listItc = NULL; + __groupTitleItc = NULL; + __myProfileItc = NULL; + __selectAllItc = NULL; + __searchbarItc = NULL; + __favoriteTitleItc = NULL; + __mfcTitleItc = NULL; + __linkSuggestTitleItc = NULL; + + __hasTitle = false; + __hasSearchbar = false; + __hasFastscroll = false; + __hasToolbar = false; + __hasCreateButton = false; + __hasSelectAll = false; + __hasTotalCount = false; + __hasGroupTitle = false; + __hasMenu = false; + __hasDoneCancel = false; + __hasFavGroupTitle = false; + __hasMyProfile = false; + __enableDone = false; + __hasFavoriteList = false; + __hasMfcList = false; + __hasDefaultList = false; + __hasLinkSuggest = false; + __hasGroupButton = false; + + __selectAllState = CHECK_OFF; + __selectedPersonId = -1; + __topItemPersonId = 0; + __groupName = NULL; + + __myProfileThread = NULL; + __myProfileIdler = NULL; + __loadImageTimer = NULL; + __searchGetContactThread = NULL; + + __detailDllHandle = NULL; + __cmDllHandle = NULL; + + __background = false; + __isFirstGroupSync = false; + __isFirstGroupMemberSync = false; + + __groupUpdateTimer = 0; +} + +void CtListView::__onToolbarDone(void *data, Evas_Object *obj, void *event_info) +{ + WENTER(); + //Do more job in view + CtListView *listView = (CtListView*)data; + listView->__listController->onSelectDone(data, obj,event_info); +} + +void CtListView::__deletePopupDelCb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + WENTER(); + //Do more job in view + CtListView *listView = (CtListView*)data; + listView->__listController->onSelectDone(data, NULL, NULL); + evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL, __deletePopupDelCb, listView); +} + +char *CtListView::__getDelPopupText() +{ + char buf[CT_TEXT_SHORT_LEN] ={0,}; + int listCount = 0; + int checkedCount = 0; + int index = 0; + + if (__onSearching) { + listCount = __listModel->getOriginalPersonDataListSize(); + checkedCount = __listModel->getCheckedDataCount(); + WDEBUG("listCount = %d, checkedCount = %d",listCount,checkedCount); + } + else { + listCount = __listModel->getPersonListCount(LIST_QUERY_DEFAULT); + while( auto personData = __listModel->getAtPersonData(index, LIST_QUERY_DEFAULT) ) + { + if(personData->isChecked()) + checkedCount++; + index++; + } + } + + if(checkedCount == listCount) { + snprintf(buf, sizeof(buf), V_("IDS_PB_POP_ALL_CONTACTS_WILL_BE_DELETED")); + return strdup(buf); + } + else if (checkedCount > 1) { + snprintf(buf, sizeof(buf), ctGetContactsString("IDS_PB_POP_PD_CONTACTS_WILL_BE_DELETED"), checkedCount); + return strdup(buf); + } + else if (checkedCount == 1) { + snprintf(buf, sizeof(buf), V_("IDS_PB_POP_1_CONTACT_WILL_BE_DELETED")); + return strdup(buf); + } + return NULL; +} +void CtListView::__onNaviTitleDone(void *data, Evas_Object *obj, void *event_info) +{ + WENTER(); + //Do more job in view + CtListView *listView = (CtListView*)data; + listView->__listController->onSelectDone(data, obj,event_info); +} + +void CtListView::__onNaviTitleCancel(void *data, Evas_Object *obj, void *event_info) +{ + + WHIT(); + //Do more job in view + CtListView *listView = (CtListView*)data; + listView->__listController->onSelectCancel(data, obj,event_info); +} + +void CtListView::__showTitleButton(bool show) +{ + WHIT(); + if(__hasDoneCancel) { + if(getNaviframe() == NULL) + return; + + WDEBUG("title show %d", show); + if(show) { + Evas_Object* btn = elm_object_item_part_content_get(getNaviItem(), "title_left_btn"); + if(btn == NULL) { + btn = elm_button_add(getViewNaviframe()); + elm_object_style_set(btn, "naviframe/title_left"); + elm_object_text_set(btn, V_("IDS_TPLATFORM_ACBUTTON_CANCEL_ABB")); + evas_object_smart_callback_add(btn, "clicked",__onNaviTitleCancel, this); + elm_object_item_part_content_set(getNaviItem(), "title_left_btn", btn); + } + + btn = elm_object_item_part_content_get(getNaviItem(), "title_right_btn"); + if(btn == NULL) { + btn = elm_button_add(getViewNaviframe()); + elm_object_style_set(btn, "naviframe/title_right"); + elm_object_text_set(btn, V_("IDS_TPLATFORM_ACBUTTON_DONE_ABB")); + + evas_object_smart_callback_add(btn, "clicked", __onNaviTitleDone, this); + elm_object_item_part_content_set(getNaviItem(), "title_right_btn", btn); + if (!__enableDone) + elm_object_disabled_set(btn, EINA_TRUE); + } + else { + if (!__enableDone) + elm_object_disabled_set(btn, EINA_TRUE); + else + elm_object_disabled_set(btn, EINA_FALSE); + } + } + else { + Evas_Object* btn = elm_object_item_part_content_get(getNaviItem(), "title_left_btn"); + if(btn) { + elm_object_item_part_content_unset(getNaviItem(), "title_left_btn"); + evas_object_del(btn); + } + btn = elm_object_item_part_content_get(getNaviItem(), "title_right_btn"); + if(btn) { + elm_object_item_part_content_unset(getNaviItem(), "title_right_btn"); + evas_object_del(btn); + } + } + } +} + +void CtListView::__freeFastIndexData() +{ + WENTER(); + void *data = NULL; + + if(__hasFastscroll == false) + return; + + EINA_LIST_FREE(__fastIndexList, data) { + CtListFastIndexData *fastIndexdata = (CtListFastIndexData*)data; + delete fastIndexdata; + } +} + +void CtListView::__appendFastScrollLetter(const std::string &str) +{ + WENTER(); + + CtListFastIndexData *indexData = new CtListFastIndexData(); + strncpy(indexData->index, str.c_str(), sizeof(indexData->index)); + indexData->index[sizeof(indexData->index)/sizeof(indexData->index[0])-1] = '\0'; + indexData->item = elm_index_item_append(__fastScroll, str.c_str(), NULL, NULL); + __fastIndexList = eina_list_append(__fastIndexList, indexData); + WLEAVE(); +} + +void CtListView::__hideFastScroll(void) +{ + WENTER(); + + elm_object_signal_emit(__fastLayout, "elm,state,fastscroll,hide", ""); +} + +void CtListView::__showFastScroll(void) +{ + WENTER(); + + if(__listModel->getPersonListCount(LIST_QUERY_DEFAULT) > 0) + elm_object_signal_emit(__fastLayout, "elm,state,fastscroll,show", ""); +} + +void CtListView::__onChangedSearchEditField(void *data, Evas_Object *obj, void *event_info) +{ + WENTER(); + + CtListView *listView = (CtListView*)data; + char* search = NULL; + + search = ctCommonMarkupToUtf8(elm_entry_entry_get(obj)); + WDEBUG("search %s, old search %s", search, listView->__listModel->getSearchString()); + + int groupCount = listView->__listGroupModel->getAvailableGroupCount(); + + if (SAFE_STRLEN(search) == 0 && listView->__listModel->getSearchString() == NULL) { + if (SAFE_STRLEN(elm_entry_entry_get(obj)) > 0) { + listView->__onShowGroupList = false; + + listView->__onShowGroupButton = false; + elm_object_item_signal_emit(listView->__searchbarItem, "group,button,hide", ""); + SAFE_FREE(search); + return; + } + else if (SAFE_STRLEN(elm_entry_entry_get(obj)) == 0){ + WDEBUG("no data"); + SAFE_FREE(search); + elm_object_part_text_set(obj, "elm.guide", V_("IDS_PB_NPBODY_SEARCH")); + + if (listView->__sipStatus == false || listView->__ctrlType == LIST_CTRL_DELETE_CONTACTS + || listView->__ctrlType == LIST_CTRL_SHARE_CONTACTS || listView->__ctrlType == LIST_CTRL_LINK_CONTACT) { + return; + } + else { + if (groupCount > 0 && listView->__hasGroupButton == true) { + listView->__onShowGroupList = false; + + listView->__onShowGroupButton = true; + elm_object_item_signal_emit(listView->__searchbarItem, "group,button,show", ""); + } + } + } + } + + if(SAFE_STRLEN(search) > 0) { + listView->__onSearching = true; + listView->__onShowGroupList = false; + listView->__onShowGroupButton = false; + + elm_object_item_signal_emit(listView->__searchbarItem, "group,button,hide", ""); + } + else { + if (listView->__onSearching == true) { + if (groupCount == 0 || listView->__ctrlType == LIST_CTRL_DELETE_CONTACTS + || listView->__ctrlType == LIST_CTRL_SHARE_CONTACTS || listView->__ctrlType == LIST_CTRL_LINK_CONTACT) { + listView->__onShowGroupButton = false; + elm_object_item_signal_emit(listView->__searchbarItem, "group,button,hide", ""); + } + else if (groupCount > 0 && listView->__hasGroupButton == true) { + listView->__onShowGroupButton = true; + elm_object_item_signal_emit(listView->__searchbarItem, "group,button,show", ""); + } + else { + WERROR("getAvailableGroupCount() is failed."); + } + } + + listView->__onSearching = false; + if (listView->__hasCreateButton) { + Evas_Object *editfield = elm_object_item_part_content_get(listView->__searchbarItem, "elm.swallow.content"); + if(!elm_object_focus_get(editfield)) { + listView->__showCreateButton(); + } + } + elm_object_part_text_set(obj, "elm.guide", V_("IDS_PB_NPBODY_SEARCH")); + } + + if (true == listView->__onSearching) { + if (listView->__listModel->getSearchString() && (SAFE_STRCMP(search, listView->__listModel->getSearchString()) == 0)) { + // if search text is not changed + SAFE_FREE(search); + return; + } + } + else { + if (SAFE_STRLEN(search) == 0 && listView->__listModel->getSearchString() == NULL) { + // if search text is not changed + SAFE_FREE(search); + return; + } + } + + if (true == listView->__onSearching) { + if (NULL == listView->__listModel->getSearchString()) { + // if start searching, initial the original checked list at the first time + listView->__listModel->initialOriginalCheckedIdList(); + listView->__listModel->initialOriginalPersonDataListSize(); + } + } + else { + listView->__listModel->clearOriginalCheckedIdList(); + listView->__listModel->clearOriginalPersonDataListSize(); + } + + listView->__listModel->setSearchString(search); + + if(listView->__searchGetContactThread){ + listView->__searchGetContactThread->destroy(); + listView->__searchGetContactThread = NULL; + listView->__listModel->cancelGetContacts(); + } + + listView->__searchGetContactThread = new CtThread(__onSearchGetContactsThreadRunCb, listView, __onSearchGetContactsThreadEndCb, listView); + listView->__searchGetContactThread->start(); + + SAFE_FREE(search); +} + +void CtListView::__onSearchbarActivatedCb(void *data, Evas_Object *obj, void *event_info) +{ + WENTER(); + elm_object_focus_set(obj, EINA_FALSE); +} + +void CtListView::__fastIndexChanged(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + const Elm_Object_Item *item = (Elm_Object_Item*)event_info; + Elm_Object_Item *item2 = (Elm_Object_Item*)elm_object_item_data_get(item); + + elm_index_indicator_disabled_set(obj, EINA_FALSE); + elm_genlist_item_show(item2, ELM_GENLIST_ITEM_SCROLLTO_TOP); +} + +void CtListView::__fastIndexSelected(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + Elm_Object_Item *item = (Elm_Object_Item*)event_info; + Elm_Object_Item *item2 = (Elm_Object_Item*)elm_object_item_data_get(item); + + elm_genlist_item_show(item2, ELM_GENLIST_ITEM_SCROLLTO_TOP); + elm_index_item_selected_set(item, EINA_FALSE); +} + +void CtListView::__showGenlist(void) +{ + WENTER(); + + __setItemClassStyle(); + + Evas_Object* oldLayout = elm_object_part_content_get(__baseLayout, "section.content"); + if(oldLayout){ + WDEBUG("delete old layout"); + elm_object_part_content_unset(__baseLayout, "section.content"); + evas_object_del(oldLayout); + } + + //add list base layout + __fastLayout = elm_layout_add(__baseLayout); + if(__hasCreateButton) { + __showCreateButton(); + } + elm_layout_theme_set(__fastLayout, "layout", "application", "fastscroll"); + + evas_object_size_hint_weight_set(__fastLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_part_content_set(__baseLayout, "section.content", __fastLayout); + evas_object_show(__fastLayout); + + //add fastscroll + Evas_Object* fastscroll = __createFastscroll(__fastLayout); + if(fastscroll) + elm_object_part_content_set(__fastLayout, "elm.swallow.fastscroll", fastscroll); + else + elm_object_signal_emit(__fastLayout, "elm,state,fastscroll,hide", ""); + + Evas_Object* box = elm_box_add(__fastLayout); + elm_object_part_content_set(__fastLayout, "elm.swallow.content", box); + evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(box); + + //add genlist + __genlist = __createGenlist(box); + elm_box_pack_end(box, __genlist); + + __noContentLayout = __setNoContentsLayout(box); + elm_box_pack_end(box, __noContentLayout); + + __curAppendIndex = 0; + __appendGenlistItems(0); + + WLEAVE(); + + return; + +} + +void CtListView::__onGenlistScrollStartCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + CtListView *view = (CtListView*)data; + + view->__genlistScrolling = true; + + if(view->__loadImageTimer) + ecore_timer_del(view->__loadImageTimer); + view->__loadImageTimer = NULL; +} + +void CtListView::__onGenlistScrollStopCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + CtListView *view = (CtListView*)data; + + view->__genlistScrolling = false; + + if(NULL == view->__genlist) + WDEBUG("__genlist is NULL"); + else + WDEBUG("__genlist is NOT NULL"); + + if(view->__loadImageTimer) + ecore_timer_del(view->__loadImageTimer); + view->__loadImageTimer = NULL; + + view->__loadImageTimer = ecore_timer_add(CT_LIST_IMAGE_LOAD_TIMER, __loadImageTimerCb, view); +} + +Eina_Bool CtListView::__loadImageTimerCb(void *user_data) +{ + WHIT(); + CtListView *view = (CtListView*)user_data; + + if(view->__loadImageTimer) + ecore_timer_del(view->__loadImageTimer); + view->__loadImageTimer = NULL; + + if(view->__genlistScrolling == false) { + WDEBUG("load image on scrolling stop"); + elm_genlist_realized_items_update(view->__genlist); + } + else { + WDEBUG("load image pass on scrolling"); + } + + return ECORE_CALLBACK_CANCEL; +} + +void CtListView::__onNaviTransitionFinishedCb(void *data, Evas_Object *obj, void *event_info) +{ + WENTER(); + CtListView *view = (CtListView*)data; + + Elm_Object_Item *item = elm_naviframe_top_item_get(obj); + if(item == view->getNaviItem()) { + WDEBUG("emerged"); + view->__background = false; + + int updatedMFC = 0; + CtRegistryMgr::getInstance()->getInt(REGISTRY_KEY_MFC_UPDATED, &updatedMFC); + + elm_genlist_realized_items_update(view->__genlist); + + if(view->__updateQueue > 0 || updatedMFC>0) { + WDEBUG("update job remains. updatedMFC %d", updatedMFC); + view->__updateQueue = 0; + view->onDbChanged(NULL); + } + + if (view->__hasCreateButton) { + view->__showCreateButton(); + } + } + else { + WDEBUG("set background"); + view->__background = true; + if(view->__hasCreateButton) { + view->__hideCreateButton(); + } + } + + WLEAVE(); +} + +void CtListView::__onSearchGetContactsThreadEndCb(void *data) +{ + WENTER(); + + CtListView* listView = (CtListView*)data; + listView->__curAppendIndex = 0; + listView->__appendGenlistItems(0); + + WLEAVE(); +} + +void CtListView:: __onSearchGetContactsThreadRunCb(void *data) +{ + WENTER(); + + CtListView *listView = (CtListView*)data; + listView->__listModel->getContacts(LIST_QUERY_DEFAULT, GET_AS_SYNC_ASYNC); + + WLEAVE(); +} + +void CtListView:: __genlistReoderCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + CtListView *view = (CtListView*)data; + view->__enableDone = true; + view->__showTitleButton(true); + + Elm_Object_Item *item = NULL; + Elm_Object_Item *previtem = NULL; + Elm_Object_Item *nextitem = NULL; + + int personId = 0; + int prevPersonId = 0; + int nextPersonId = 0; + + CtListView::CtListDataItem* itemData = NULL; + + item = (Elm_Object_Item*) event_info; + + Elm_Genlist_Item_Type itemType = elm_genlist_item_type_get(item); + if(itemType == ELM_GENLIST_ITEM_GROUP) { + return; + } + + itemData = (CtListView::CtListDataItem*)elm_object_item_data_get(item); + if(itemData) { + personId = itemData->personData->getPersonId(); + } + + previtem = elm_genlist_item_prev_get(item); + if(previtem) { + itemType = elm_genlist_item_type_get(previtem); + if(itemType != ELM_GENLIST_ITEM_GROUP) { + itemData = (CtListView::CtListDataItem*)elm_object_item_data_get(previtem); + if(itemData) + prevPersonId = itemData->personData->getPersonId(); + } + } + + nextitem = elm_genlist_item_next_get(item); + if(nextitem) { + itemType = elm_genlist_item_type_get(nextitem); + if(itemType != ELM_GENLIST_ITEM_GROUP) { + itemData = (CtListView::CtListDataItem*)elm_object_item_data_get(nextitem); + if(itemData) + nextPersonId = itemData->personData->getPersonId(); + } + } + + CtListFavoriteReorderData reorderData; + reorderData.personId = personId; + reorderData.prevPersonId = prevPersonId; + reorderData.nextPersonId = nextPersonId; + + view->__reorderData.push_back(reorderData); + +} + +Evas_Object* CtListView::__createGenlist(Evas_Object* parent) +{ + WHIT(); + + Evas_Object* genlist = elm_genlist_add(parent); + 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); + elm_scroller_policy_set(genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); + elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS); + elm_genlist_homogeneous_set(genlist, EINA_TRUE); + //evas_object_smart_callback_add(genlist, "realized", __onGenlistRealizedCb, NULL); + //for speed up scrolling list + evas_object_smart_callback_add(genlist, "scroll,anim,start", __onGenlistScrollStartCb, this); + evas_object_smart_callback_add(genlist, "scroll,anim,stop", __onGenlistScrollStopCb, this); + + evas_object_show(genlist); + + if(__viewType == LIST_VIEW_REORDER){ + elm_genlist_longpress_timeout_set(genlist, 0.3); + //elm_genlist_reorder_mode_set(genlist, EINA_TRUE); + evas_object_smart_callback_add(genlist, "moved", __genlistReoderCb, this); + } + + return genlist; +} + +Evas_Object* CtListView::__createFastscroll(Evas_Object* parent) +{ + WENTER(); + + if(__hasFastscroll == false) { + return NULL; + } + + Evas_Object* fastscroll = elm_index_add(parent); + evas_object_smart_callback_add(fastscroll, "changed", __fastIndexChanged, NULL); + evas_object_smart_callback_add(fastscroll, "selected", __fastIndexSelected, NULL); + evas_object_show(fastscroll); + elm_index_autohide_disabled_set(fastscroll, EINA_TRUE); + elm_index_item_clear(fastscroll); + __appendFastScrollLetter(SYMBOL_MAGNIFIER); + if(__favoriteTitleItem) { + __appendFastScrollLetter(SYMBOL_STAR); + } + __fastScroll = fastscroll; + + WLEAVE(); + return fastscroll; +} + +void CtListView::__hideCreateButton(void) +{ + WENTER(); + if (NULL == __compose_btn) { + WDEBUG("__compose_btn is NULL"); + return; + } + + WWindow *window = getWindow(); + if (!window) { + return; + } + + elm_object_part_content_unset(window->getBaseLayoutEvasObj(), "elm.swallow.floatingbutton"); + evas_object_hide(__compose_btn); +} + +void CtListView::__showCreateButton(void) +{ + WENTER(); + WWindow *window = getWindow(); + if (!window) { + return; + } + + Evas_Object *parent = window->getBaseLayoutEvasObj(); + if (NULL == __compose_btn) { + __compose_btn = __createFloatBtn(parent); + } + + elm_object_part_content_set(parent, "elm.swallow.floatingbutton", __compose_btn); +} + +Evas_Object *CtListView::__createFloatBtn(Evas_Object* parent) +{ + WHIT(); + Evas_Object *floatBtn = eext_floatingbutton_add(parent); + Evas_Object *button= elm_button_add(floatBtn); + if(button) { + elm_object_part_content_set(floatBtn, "button1", button); + Evas_Object *image = elm_image_add(button); + elm_image_file_set(image, CT_IMG_ICON_LIST_ADD_BUTTON, NULL); + elm_object_part_content_set(button, "icon", image); + evas_object_smart_callback_add(button, "clicked", __onSelectFloatBtn, this); + } + return floatBtn; +} + +void CtListView::__onSelectFloatBtn(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + CtListView *listView = (CtListView*)data; + listView->__listController->onSelectCreate(data, obj, event_info); +} + +void CtListView::__cleanSearchbar() +{ + WHIT(); + if(__searchbarItem) { + //elm_genlist_item_show(__searchbarItem, ELM_GENLIST_ITEM_SCROLLTO_TOP); + Evas_Object *editfield = elm_object_item_part_content_get(__searchbarItem, "elm.swallow.content"); + if(editfield) { + if(elm_entry_is_empty(editfield) == EINA_FALSE) + elm_entry_entry_set(editfield, ""); + } + + __showFastScroll(); + } +} + +Evas_Object* CtListView::__createNoContent(Evas_Object* parent) +{ + WHIT(); + + Evas_Object* noContent = elm_layout_add(parent); + elm_layout_theme_set(noContent, "layout", "nocontents", "default"); + evas_object_size_hint_weight_set(noContent, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(noContent, EVAS_HINT_FILL, EVAS_HINT_FILL); + + elm_object_domain_translatable_part_text_set(noContent, "elm.text", PACKAGE, "IDS_PB_NPBODY_NO_CONTACTS"); + elm_object_domain_translatable_part_text_set(noContent, "elm.help.text", PACKAGE, "IDS_PB_BODY_AFTER_YOU_CREATE_CONTACTS_THEY_WILL_BE_SHOWN_HERE"); + + elm_layout_signal_emit(noContent, "text,disabled", ""); + elm_layout_signal_emit(noContent, "align.center", "elm"); + // to work signal directly not on idler + edje_object_message_signal_process(elm_layout_edje_get(noContent)); + + evas_object_show(noContent); + + __showTitleButton(false); + + return noContent; +} + +Eina_Bool CtListView::__createNocontentsPopupCb(void* data) +{ + WHIT(); + CtListView *listView = (CtListView*)data; + listView->__listController->onSelectMenu(listView); + listView->__launching = false; + + return ECORE_CALLBACK_CANCEL; +} + +void CtListView::__showNoContent(void) +{ + WHIT(); + + Evas_Object* oldLayout = elm_object_part_content_get(__baseLayout, "section.content"); + if(oldLayout){ + WDEBUG("delete old layout"); + if(oldLayout == __fastLayout) + __fastLayout = NULL; + evas_object_del(oldLayout); + } + + Evas_Object *noContent = __createNoContent(__baseLayout); + elm_object_part_content_set(__baseLayout, "section.content", noContent); + + __updateCheckRelatedInfo(); + + return; +} + +void CtListView::__updateCheckRelatedInfo() +{ + WHIT(); + + if (__viewType == LIST_VIEW_CHECK) { + char buf[CT_TEXT_SHORT_LEN] = {0}; + + int checkedIdNum = __listModel->getCheckedDataCount(); + if(__listModel->getLimitCount() == 0) + snprintf(buf, sizeof(buf), ctGetContactsString("IDS_PB_HEADER_PD_SELECTED_ABB3"), checkedIdNum); + else + snprintf(buf, sizeof(buf), "%d/%d", checkedIdNum, __listModel->getLimitCount()); + + elm_object_item_part_text_set(getNaviItem(), "elm.text.title", buf); + Evas_Object *btn = elm_object_item_part_content_get(getNaviItem(), "title_right_btn"); + WDEBUG("%i", checkedIdNum); + if(btn) { + if( checkedIdNum > 0) { + elm_object_disabled_set(btn, EINA_FALSE); + __enableDone = true; + } + else { + elm_object_disabled_set(btn, EINA_TRUE); + __enableDone = false; + } + } + + + if (__selectAllItem) { + if (__onSearching) { + if (__listModel->checkIsSelectAllOnSearching()) { + __selectAllState = CHECK_ON; + } + else { + __selectAllState = CHECK_OFF; + } + } + else { + int maxCount = __listModel->getPersonListCount(LIST_QUERY_DEFAULT); + if (__ctrlType == LIST_CTRL_REMOVE_FAVORITES) { + maxCount += __listModel->getPersonListCount(LIST_QUERY_MFC); + } + + if (checkedIdNum == maxCount) { + __selectAllState = CHECK_ON; + } + else { + __selectAllState = CHECK_OFF; + } + } + elm_genlist_item_fields_update( __selectAllItem, "elm.swallow.end", ELM_GENLIST_ITEM_FIELD_CONTENT); + } + } +} + +void CtListView::__updateCheckAllRelatedInfo() +{ + WHIT(); + + if (__viewType == LIST_VIEW_CHECK) { + char buf[CT_TEXT_SHORT_LEN] = {0}; + + int checkedCount = 0; + int limitCount = __listModel->getLimitCount(); + if(__loaded) + checkedCount = __listModel->getCheckedDataCount(); + else + checkedCount = __listModel->getContactsCount(LIST_QUERY_DEFAULT); + + if(!__onSearching && __selectAllState == CHECK_OFF) + checkedCount = 0; + + if(limitCount == 0) + snprintf(buf, sizeof(buf), ctGetContactsString("IDS_PB_HEADER_PD_SELECTED_ABB3"), checkedCount); + else + snprintf(buf, sizeof(buf), "%d/%d", checkedCount, limitCount); + + elm_object_item_part_text_set(getNaviItem(), "elm.text.title", buf); + Evas_Object *btn = elm_object_item_part_content_get(getNaviItem(), "title_right_btn"); + if(btn) { + if(checkedCount > 0) { + elm_object_disabled_set(btn, EINA_FALSE); + __enableDone = true; + } + else { + elm_object_disabled_set(btn, EINA_TRUE); + __enableDone = false; + } + } + } + +} + +void CtListView::__onSelectItem(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + + CtListView *listView = (CtListView*)data; + elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); + + if (listView->__viewType == LIST_VIEW_REORDER) + return; + + Elm_Object_Item *item = (Elm_Object_Item*)event_info; + Evas_Object* check = elm_object_item_part_content_get(item,"elm.swallow.end"); + if (check) { + CtListView::CtListDataItem* itemData = (CtListView::CtListDataItem*)elm_object_item_data_get((Elm_Object_Item*)event_info); + //Eina_Bool state = elm_check_state_get(check); + Eina_Bool state = itemData->personData->isChecked(); + + listView->__listController->onSelectItem((Elm_Object_Item*)event_info, listView, (CtCheckState)(!state)); + listView->__updateCheckRelatedInfo(); + return; + } + + listView->__listController->onSelectItem((Elm_Object_Item*)event_info, listView, CHECK_NONE); + listView->__updateCheckRelatedInfo(); +} +/* +bool CtListView::__checkMFC(int personId) +{ + WHIT(); + std::shared_ptr<CtListDataPerson> dataPerson; + int mfcIndex = 0; + + while(true){ + if (mfcIndex > 5) + break; + dataPerson = __listModel->getAtPersonData(mfcIndex, LIST_QUERY_MFC); + if(dataPerson == NULL) + break; + if(dataPerson->getPersonId() == personId) + return true; + + mfcIndex++; + } + return false; +} +*/ +void CtListView::__onSelectCheckAll(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + + CtListView *listView = (CtListView*)data; + Elm_Object_Item *item = (Elm_Object_Item*)event_info; + + elm_genlist_item_selected_set(item, EINA_FALSE); + + listView->__selectedCheckAll = false; + + if(listView->__loaded == false) { + WDEBUG("not loaded yet"); + listView->__selectedCheckAll = true; + return; + } + + Evas_Object* check = elm_object_item_part_content_get(item, "elm.swallow.end"); + elm_check_state_set(check, !elm_check_state_get(check)); + + listView->__listController->onSelectCheckAll(item, listView, (CtCheckState)elm_check_state_get(check)); + listView->__updateCheckRelatedInfo(); +} + +void CtListView::__onSelectMenu(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + + CtListView *listView = (CtListView*)data; + + listView->destroyPopup(); // Due to some race condition sometime listview menu popup and profile/detail view both appears + + if(listView->__listModel->getMadePersonListStatus()) {//display menu options only id data is received from DB + listView->__listController->onSelectMenu(listView); + } +} + +void CtListView::__onMyProfileSelectCb(void *data, Evas_Object *obj, void *event_info) +{ + WENTER(); + CtListView *listView = (CtListView*)data; + Elm_Object_Item *item = (Elm_Object_Item *)event_info; + + elm_genlist_item_selected_set(item, EINA_FALSE); + bool first = false; + int error = preference_get_boolean(CT_KEY_MYPROFILE_CREATE_FIRST, &first); + if (error != PREFERENCE_ERROR_NONE) + { + WDEBUG("preference_get_boolean failed"); + } + int err = CONTACTS_ERROR_NONE; + contacts_list_h myprofileList = NULL; + int count = 0; + + err = contacts_db_get_all_records(_contacts_my_profile._uri, 0, 0, &myprofileList); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_all_records() Failed(%d)", err); + + if (myprofileList != NULL) { + contacts_list_get_count(myprofileList, &count); + + err = contacts_list_destroy(myprofileList, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_get_count() Failed(%d)", err); + + if (listView->__detailDllHandle == NULL) { + listView->__detailDllHandle = ctGetDllHandle("libct-detail.so"); + } + WPRET_M(!listView->__detailDllHandle, "failed to load libct-detail.so"); + + if (count > 0 && !first) { + typedef WView* (*CreateMyProfileDetailView)(); + CreateMyProfileDetailView createMyProfileDetailView = (CreateMyProfileDetailView)dlsym(listView->__detailDllHandle, "createMyProfileDetailView"); + if (createMyProfileDetailView) { + WView* myProfileDetailView = createMyProfileDetailView(); + listView->getWNaviframe()->push(myProfileDetailView, NULL, NULL); + } + } else { + typedef WView* (*CreateMyProfileInputView)(contacts_record_h); + CreateMyProfileInputView createMyProfileInputView = (CreateMyProfileInputView)dlsym(listView->__detailDllHandle, "createMyProfileInputView"); + if (createMyProfileInputView) { + WView* myProfileInputView = createMyProfileInputView(NULL); + listView->getWNaviframe()->push(myProfileInputView, NULL, NULL); + } + } + } +} + +//should be removed api +void CtListView::__onClickRemoveBtn(void *data, Evas_Object *obj, void *event_info) +{ + WENTER(); + //Do more job in view +// CtListDataItem *item = (CtListDataItem*)data; + //item->listView->__listController->clickRemoveBtnOperation(data, obj,event_info); +} + +void CtListView::__onGenlistRealizedCb(void *data, Evas_Object *obj, void *event_info) +{ + WENTER(); +} + +void CtListView::__updatetGenlistItem() +{ + WENTER(); + +} + +Eina_Unicode CtListView::__hangulCompatibilityToJamo(Eina_Unicode unicode) +{ + int i; + + if(unicode < __hangulCompatibilityChoseong[0] || unicode > __hangulCompatibilityChoseong[13]) + return unicode; + + + for(i=0;i<14;i++) { + if(unicode == __hangulCompatibilityChoseong[i]) + return __hangulJamoChoseong[i]; + } + + return unicode; +} + + +bool CtListView::__compareCharacter(const char *str1, const char *str2) +{ + int tmp_len; + Eina_Unicode *unicode; + Eina_Unicode uniJamo1; + Eina_Unicode *uniJamo2; + bool result = false; + + unicode = eina_unicode_utf8_to_unicode(str1, &tmp_len); + WPRET_VM(!unicode, false, "eina_unicode_utf8_to_unicode failed for %s", str1); + + uniJamo1 = __hangulCompatibilityToJamo(*unicode); + uniJamo2 = eina_unicode_utf8_to_unicode(str2, &tmp_len); + if(!uniJamo2) { + free(unicode); + WERROR("eina_unicode_utf8_to_unicode failed for %s", str2); + return false; + } + + if(uniJamo1 == *uniJamo2 || eina_unicode_strcmp(uniJamo2, unicode) == 0) + result = true; + + free(unicode); + free(uniJamo2); + + return result; +} + +void CtListView::__linkItemToIndex(Elm_Object_Item *groupItem) +{ + void *data = NULL; + bool matched = false; + Eina_List *cusor = NULL; + int i = 0; + int count = 0; + int firstSetIndex = -1; + WPRET_M(NULL == __fastIndexList, "No fastindex"); + + count = eina_list_count(__fastIndexList); + + EINA_LIST_FOREACH(__fastIndexList, cusor, data) { + //leave rest index item as on unlinked from match item + if (matched == true && i < count) + break; + + // skip magnify, star + if(i < 1) { + i++; + continue; + } + + CtListFastIndexData *indexData = (CtListFastIndexData*)data; + + if(__compareCharacter(indexData->index, __curGroupIndex.c_str()) == true) + matched = true; + + //link group item to vacant index items until find match item + Elm_Object_Item *linkedItem = NULL; + linkedItem = (Elm_Object_Item*)elm_object_item_data_get(indexData->item); + if(linkedItem == NULL) { + elm_object_item_data_set(indexData->item, (void*)groupItem); + //keep first index set + if(firstSetIndex < 0) + firstSetIndex = i; + } + i++; + } + + //in case there is unmatch item among the matching letters. + if(matched == false) { + if(__unmatchedGroupTitleItem == NULL) + __unmatchedGroupTitleItem = groupItem; + + //at least '#' need link to first group item what ever + + /* not needed by mgnify, star + if(firstSetIndex == 0) + firstSetIndex++; + */ + if(firstSetIndex > 0) { + Eina_List *cusor2 = NULL; + cusor = NULL; + cusor = eina_list_nth_list(__fastIndexList, firstSetIndex); + EINA_LIST_FOREACH(cusor, cusor2, data) { + CtListFastIndexData *indexData = (CtListFastIndexData*)data; + elm_object_item_data_set(indexData->item, NULL); + } + } + } + else + __unmatchedGroupTitleItem = NULL; +} + +void CtListView::__linkItemsManually(Eina_List *indexItem, Elm_Object_Item *genItem) +{ + WENTER(); + if(indexItem && genItem) { + void *data = eina_list_data_get(indexItem); + elm_object_item_data_set(static_cast<CtListFastIndexData*>(data)->item, (void*)genItem); + } +} + +void CtListView::__linkItemToRestIndex() +{ + WENTER(); + + void *data = NULL; + Eina_List *cusor = NULL; + + if(__hasFastscroll == false) + return; + + if(__unmatchedGroupTitleItem) + __curGroupTitleItem = __unmatchedGroupTitleItem; + + EINA_LIST_FOREACH(__fastIndexList, cusor, data) { + CtListFastIndexData *indexData = (CtListFastIndexData*)data; + Elm_Object_Item *linkedItem = NULL; + linkedItem = (Elm_Object_Item*)elm_object_item_data_get(indexData->item); + if(linkedItem == NULL) { + elm_object_item_data_set(indexData->item, (void*)__curGroupTitleItem); + } + } + + __unmatchedGroupTitleItem = NULL; + + int value = 0; + if(CtRegistryMgr::getInstance()->getInt(REGISTRY_KEY_FAVORITE_UPDATED, &value) == REGISTRY_SUCCESS) { + if(value == 1) { + if(__favoriteTitleItem) + elm_genlist_item_show(__favoriteTitleItem, ELM_GENLIST_ITEM_SCROLLTO_TOP); + else + elm_genlist_item_show(__searchbarItem, ELM_GENLIST_ITEM_SCROLLTO_TOP); + } + } + else if(CtRegistryMgr::getInstance()->getInt(REGISTRY_KEY_INSERTED_PERSON_ID, &value) == REGISTRY_SUCCESS) { + Elm_Object_Item *curItem = getGenlistItemByPersonId(value); + if(curItem) + elm_genlist_item_show(curItem, ELM_GENLIST_ITEM_SCROLLTO_TOP); + } +} + +Elm_Object_Item* CtListView::getGenlistItemByPersonId(int personId) +{ + WDEBUG("personid %d", personId); + Elm_Object_Item *curItem = elm_genlist_first_item_get(__genlist); + while(curItem) { + if(elm_genlist_item_type_get(curItem) == ELM_GENLIST_ITEM_GROUP) { + curItem = elm_genlist_item_next_get(curItem); + continue; + } + else if(curItem == __searchbarItem) { + curItem = elm_genlist_item_next_get(curItem); + continue; + } + else if(curItem == __selectAllItem) { + curItem = elm_genlist_item_next_get(curItem); + continue; + } + else if(curItem == __myProfileItem) { + curItem = elm_genlist_item_next_get(curItem); + continue; + } + + CtListDataItem *dataItem = (CtListDataItem*)elm_object_item_data_get(curItem); + if(dataItem) { + if (dataItem->personData) { + if(dataItem->personData->getPersonId() == personId) { + WDEBUG("find personid item"); + break; + } + } + } + curItem = elm_genlist_item_next_get(curItem); + } + + WDEBUG("curItem %p", curItem); + return curItem; +} + +void CtListView::setOnSingleResult(SingleResultCb handler) +{ + __singleResultCb = std::move(handler); +} + +void CtListView::setOnMultiResult(MultiResultCb handler) +{ + __multiResultCb = std::move(handler); +} + +void CtListView::sendSingleResult(const char *data, CtListResultType type) const +{ + if (__singleResultCb) { + __singleResultCb(data, type); + } +} + +void CtListView::sendMultiResult(const char *data[], size_t count) const +{ + if (__multiResultCb) { + __multiResultCb(data, count); + } +} + +void CtListView::__initFastscrollData() +{ + __curGroupIndex.clear(); + __unmatchedGroupTitleItem = NULL; + __curGroupTitleItem = NULL; + + Eina_List *cursor = NULL; + void *data = NULL; + + EINA_LIST_FOREACH(__fastIndexList, cursor, data) { + CtListFastIndexData *indexData = (CtListFastIndexData*)data; + + elm_object_item_data_set(indexData->item, NULL); + } +} +void CtListView::__initListItems(void) +{ + WHIT(); + + if(__searchbarItem) { + Elm_Object_Item *curItem = elm_genlist_item_next_get(__searchbarItem); + // if while searching or nocontact clear all + if(__onNoContentLayout || elm_genlist_item_type_get(curItem) != ELM_GENLIST_ITEM_GROUP) { + while(curItem) { + Elm_Object_Item *item2 = elm_genlist_item_next_get(curItem); + elm_object_item_del(curItem); + curItem = item2; + } + // init grobal variables + __favoriteTitleItem = NULL; + __linkSuggestTitleItem = NULL; + __mfcTitleItem = NULL; + __myProfileItem = NULL; + __selectAllItem = NULL; + + __selectAllState = CHECK_OFF; + } + } + else { + elm_genlist_clear(__genlist); + // init grobal variables + __favoriteTitleItem = NULL; + __linkSuggestTitleItem = NULL; + __mfcTitleItem = NULL; + __myProfileItem = NULL; + __searchbarItem = NULL; + __selectAllItem = NULL; + + __selectAllState = CHECK_OFF; + } + + __initFastscrollData(); + + __showTitleButton(true); +} + + +Elm_Object_Item* CtListView::__addSearchbarItem(void) +{ + if(__hasSearchbar == true) { + if(__searchbarItem == NULL) { + WDEBUG("searchbar added"); + __searchbarItem = elm_genlist_item_prepend(__genlist, __searchbarItc, this, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + + if (__searchbarItem) { + elm_genlist_item_select_mode_set(__searchbarItem, ELM_OBJECT_SELECT_MODE_NONE); + + CtListFastIndexData *indexData = (CtListFastIndexData*)eina_list_nth(__fastIndexList, 0); + if (indexData) { + elm_object_item_data_set(indexData->item, (void*)__searchbarItem); + } + } + } + else { + WDEBUG("searchbar re link to fastscroll"); + CtListFastIndexData *indexData = (CtListFastIndexData*)eina_list_nth(__fastIndexList, 0); + if (indexData) { + elm_object_item_data_set(indexData->item, (void*)__searchbarItem); + } + } + } + + return __searchbarItem; +} + +Elm_Object_Item* CtListView::__addSelectAllItem(void) +{ + WHIT(); + if(__hasSelectAll == true) { + int listCount = __listModel->getPersonListCount(LIST_QUERY_DEFAULT); + // in remove favorites view, it needs to show MFC + if (__ctrlType == LIST_CTRL_REMOVE_FAVORITES) { + listCount += __listModel->getContactsCount(LIST_QUERY_MFC); + } + if(__selectAllItem == NULL && listCount > 0) { + WDEBUG("selectall added"); + CtListDataItem *itemData = new CtListDataItem; + itemData->personData = NULL; + itemData->listView = this; + itemData->item = elm_genlist_item_append(__genlist, __selectAllItc, itemData, NULL, ELM_GENLIST_ITEM_NONE, __onSelectCheckAll, this); + __selectAllItem = itemData->item; + } + } + + return __selectAllItem; +} + +int CtListView::__addLinkSuggestList(void) +{ + WHIT(); + int index = 0; + if(__hasLinkSuggest){ + std::shared_ptr<CtListDataPerson> dataPerson; + CtListModelLinkSuggest* model = new CtListModelLinkSuggest(__selectedPersonId); + if(model->getContactsCount(LIST_QUERY_DEFAULT) > 0) { + WDEBUG("list suggest added"); + + Elm_Object_Item *curItem = __getStandardItem(LIST_SUB_LINK_SUGGEST); + + if(__linkSuggestTitleItem == NULL) + __linkSuggestTitleItem = __addLinkSuggestTitleItem(curItem); + + curItem = elm_genlist_item_next_get(__linkSuggestTitleItem); + while(true){ + dataPerson = model->getAtPersonData(index, LIST_QUERY_DEFAULT); + if(dataPerson == NULL) + break; + CtListDataItem *itemData = new CtListDataItem; + itemData->personData = dataPerson; + itemData->listView = this; + itemData->item = __addLinkSuggestItem(curItem, itemData); + index++; + + curItem = elm_genlist_item_next_get(itemData->item); + } + + __deleteRestItems(curItem, false); + } + else { + Elm_Object_Item *curItem = elm_genlist_item_next_get(__linkSuggestTitleItem); + elm_object_item_del(__linkSuggestTitleItem); + __linkSuggestTitleItem = NULL; + __deleteRestItems(curItem, false); + } + delete model; + } + + return 0; +} + +Elm_Object_Item* CtListView::__addLinkSuggestItem(Elm_Object_Item *curItem, CtListDataItem* itemData) +{ + Elm_Object_Item *item = NULL; + if(curItem == NULL) { + // insert item + item = elm_genlist_item_append(__genlist, __listItc, itemData, NULL, ELM_GENLIST_ITEM_NONE,__onSelectItem, this); + } + else { + if(elm_genlist_item_type_get(curItem) != ELM_GENLIST_ITEM_GROUP) { + // update item + CtListDataItem *lastData = (CtListDataItem *)elm_object_item_data_get(curItem); + if(lastData) + delete lastData; + elm_object_item_data_set(curItem, itemData); + item = curItem; + } + else { + // insert before item + item = elm_genlist_item_insert_before(__genlist, __listItc, itemData, NULL, curItem, ELM_GENLIST_ITEM_NONE, __onSelectItem, this); + } + } + return item; +} + +Elm_Object_Item* CtListView::__addMyProfileItem(void) +{ + WHIT(); + if (__hasMyProfile && __onSearching == false) { + if(__myProfileItem == NULL) { + WDEBUG("my profile added"); + Elm_Object_Item *item = NULL; + item = elm_genlist_item_append(__genlist, __groupTitleItc, SAFE_STRDUP(V_("IDS_PB_HEADER_ME")), NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL); + elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + __myProfileItem = elm_genlist_item_append(__genlist, __myProfileItc, this, NULL, ELM_GENLIST_ITEM_NONE, __onMyProfileSelectCb, this); + } + else { + WDEBUG("my profile updated"); + elm_object_item_data_set(__myProfileItem, (void*)this); + elm_genlist_item_update(__myProfileItem); + } + } + + return __myProfileItem; +} + +int CtListView::__addFavoriteList(void) +{ + WHIT(); + int favorIndex = 0; + if(__hasFavoriteList && __onSearching == false) { + // for get favorite by order + if(__listModel->getPersonListCount(LIST_QUERY_FAVORITE) > 0) { + WDEBUG("favorite list added"); + std::shared_ptr<CtListDataPerson> dataPerson; + CtListFastIndexData *indexData = (CtListFastIndexData*)eina_list_nth(__fastIndexList, 1); + + Elm_Object_Item *curItem = __getStandardItem(LIST_SUB_FAVORITE); + + if(__favoriteTitleItem == NULL) + __favoriteTitleItem = __addFavoriteTitleItem(curItem); + if(indexData) + elm_object_item_data_set(indexData->item, (void*)__favoriteTitleItem); + + curItem = elm_genlist_item_next_get(__favoriteTitleItem); + while(true){ + dataPerson = __listModel->getAtPersonData(favorIndex, LIST_QUERY_FAVORITE); + + if(dataPerson == NULL) + break; + CtListDataItem *itemData = new CtListDataItem; + itemData->personData = dataPerson; + itemData->listView = this; + itemData->item = __addFavoriteItem(curItem, itemData); + favorIndex++; + + curItem = elm_genlist_item_next_get(itemData->item); + } + + __deleteRestItems(curItem, false); + } + else { + Elm_Object_Item *curItem = elm_genlist_item_next_get(__favoriteTitleItem); + elm_object_item_del(__favoriteTitleItem); + __favoriteTitleItem = NULL; + __deleteRestItems(curItem, false); + + // if no favorites, search bar replace + CtListFastIndexData *indexData = (CtListFastIndexData*)eina_list_nth(__fastIndexList, 1); + if (indexData) + elm_object_item_data_set(indexData->item, (void*)__searchbarItem); + } + } + + return favorIndex; +} + +Elm_Object_Item* CtListView::__addFavoriteItem(Elm_Object_Item *curItem, CtListDataItem* itemData) +{ + Elm_Object_Item *item = NULL; + if(curItem == NULL) { + // append item +// WDEBUG("append"); // remove cause of too many printing logs + item = elm_genlist_item_append(__genlist, __listItc, itemData, NULL, ELM_GENLIST_ITEM_NONE,__onSelectItem, this); + } + else { + if(elm_genlist_item_type_get(curItem) != ELM_GENLIST_ITEM_GROUP) { + // update item + WDEBUG("update"); + elm_object_item_data_set(curItem, itemData); + item = curItem; + } + else { + // insert before item + WDEBUG("insert"); + item = elm_genlist_item_insert_before(__genlist, __listItc, itemData, NULL, curItem, ELM_GENLIST_ITEM_NONE, __onSelectItem, this); + } + } + return item; +} + +int CtListView::__addMfcList(void) +{ + WHIT(); + int mfcIndex = 0; + if(__hasMfcList && __onSearching == false) { + if (__listModel->getAtPersonData(0, LIST_QUERY_MFC)) { + WDEBUG("mfc list added"); + std::shared_ptr<CtListDataPerson> dataPerson; + + Elm_Object_Item *curItem = __getStandardItem(LIST_SUB_MFC); + + if(__mfcTitleItem == NULL) + __mfcTitleItem = __addMfcTitleItem(curItem); + + curItem = elm_genlist_item_next_get(__mfcTitleItem); + while(true){ + if (mfcIndex > 5) + break; + + dataPerson = __listModel->getAtPersonData(mfcIndex, LIST_QUERY_MFC); + if(dataPerson == NULL) + break; + CtListDataItem *itemData = new CtListDataItem; + itemData->personData = dataPerson; + itemData->listView = this; + itemData->item = __addMfcItem(curItem, itemData); + mfcIndex++; + + curItem = elm_genlist_item_next_get(itemData->item); + } + + __deleteRestItems(curItem, false); + } + else { + Elm_Object_Item *curItem = elm_genlist_item_next_get(__mfcTitleItem); + elm_object_item_del(__mfcTitleItem); + __mfcTitleItem = NULL; + __deleteRestItems(curItem, false); + } + } + return mfcIndex; +} + +Elm_Object_Item* CtListView::__addMfcItem(Elm_Object_Item *curItem, CtListDataItem* itemData) +{ + Elm_Object_Item *item = NULL; + if(curItem == NULL) { + // insert item + item = elm_genlist_item_append(__genlist, __listItc, itemData, NULL, ELM_GENLIST_ITEM_NONE,__onSelectItem, this); + } + else { + if(elm_genlist_item_type_get(curItem) != ELM_GENLIST_ITEM_GROUP) { + // update item + elm_object_item_data_set(curItem, itemData); + item = curItem; + } + else { + // insert before item + item = elm_genlist_item_insert_before(__genlist, __listItc, itemData, NULL, curItem, ELM_GENLIST_ITEM_NONE, __onSelectItem, this); + } + } + return item; +} + +Elm_Object_Item* CtListView::__addLinkSuggestTitleItem(Elm_Object_Item *curItem) +{ + WHIT(); + Elm_Object_Item *item = NULL; + + if(curItem == NULL) { + WDEBUG("favorite group title added"); + item = elm_genlist_item_append(__genlist, __linkSuggestTitleItc, this, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL); + } + else { + if(__favoriteTitleItem == curItem) { + WDEBUG("favorite group title exist"); + item = curItem; + } + else { + WDEBUG("favorite group title insert before"); + item = elm_genlist_item_insert_before(__genlist, __linkSuggestTitleItc, this, NULL, curItem, ELM_GENLIST_ITEM_GROUP, NULL, NULL); + } + } + elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + return item; +} + + +Elm_Object_Item* CtListView::__addFavoriteTitleItem(Elm_Object_Item *curItem) +{ + WHIT(); + Elm_Object_Item *item = NULL; + + if(curItem == NULL) { + WDEBUG("favorite group title added"); + item = elm_genlist_item_append(__genlist, __favoriteTitleItc, this, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL); + } + else { + if(__favoriteTitleItem == curItem) { + WDEBUG("favorite group title exist"); + item = curItem; + } + else { + WDEBUG("favorite group title insert before"); + item = elm_genlist_item_insert_before(__genlist, __favoriteTitleItc, this, NULL, curItem, ELM_GENLIST_ITEM_GROUP, NULL, NULL); + } + } + elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + return item; +} + +Elm_Object_Item* CtListView::__addMfcTitleItem(Elm_Object_Item *curItem) +{ + WHIT(); + Elm_Object_Item *item = NULL; + + if(curItem == NULL) { + WDEBUG("mfc group title added"); + item = elm_genlist_item_append(__genlist, __mfcTitleItc, this, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL); + } + else { + if(__favoriteTitleItem == curItem) { + WDEBUG("mfc group title exist"); + item = curItem; + } + else { + WDEBUG("mfc group title insert before"); + item = elm_genlist_item_insert_before(__genlist, __mfcTitleItc, this, NULL, curItem, ELM_GENLIST_ITEM_GROUP, NULL, NULL); + } + } + elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + return item; +} + +int CtListView::__addSearchList(int offset) +{ + WENTER(); + WPRET_VM(__onSearching == false, 0, "no onSearching"); + + int index = 0; + if (__hasDefaultList == true) { + WDEBUG("main list added"); + std::shared_ptr<CtListDataPerson> dataPerson; + + Elm_Object_Item *curItem = NULL; + + if(__selectAllItem) { + WDEBUG("__selectAllItem"); + curItem = __selectAllItem; + curItem = elm_genlist_item_next_get(curItem); + } + else { + WDEBUG("__searchbarItem"); + curItem = __searchbarItem; + curItem = elm_genlist_item_next_get(curItem); + } + + //get searchbar item + if(offset > 0) { + int curIndex = 0; + while(1) { + curItem = elm_genlist_item_next_get(curItem); + curIndex++; + if(curIndex == offset) + break; + } + } + + WDEBUG("1 curitem %p, offset %d", curItem, offset); + + while(true){ + CtListDataItem *itemData = new CtListDataItem; + dataPerson = __listModel->getAtPersonData(__curAppendIndex, LIST_QUERY_DEFAULT); + + if(dataPerson == NULL) { + delete itemData; + break; + } + itemData->personData = dataPerson; + itemData->listView = this; + itemData->item = __addDefaultItem(curItem, itemData, false); + __curAppendIndex++; + index++; + + curItem = elm_genlist_item_next_get(itemData->item); + } + + WDEBUG("2 curitem %p, offset %d", curItem, offset); + + if(offset > 0 || __curAppendIndex < 20) + __deleteRestItems(curItem, true); + + if(__curAppendIndex == 0) { + __showNoContentsLayout(); + __setNoContentsText(V_("IDS_PB_NPBODY_NO_RESULTS_FOUND_ABB")); + } else { + __hideNoContentsLayout(); + } + + WLEAVE(); + return __curAppendIndex; + } + WLEAVE(); + return 0; +} + + +int CtListView::__addDefaultList(int offset) +{ + WHIT(); + if(__onSearching == true) { + return __addSearchList(offset); + } + + int index = 0; + if (__hasDefaultList == true) { + WDEBUG("main list added"); + std::shared_ptr<CtListDataPerson> dataPerson; + + Elm_Object_Item *curItem = __getStandardItem(LIST_SUB_DEFAULT); + + if (__ctrlType == LIST_CTRL_REORDER_FAVORITES && curItem && elm_genlist_item_type_get(curItem) == ELM_GENLIST_ITEM_GROUP) + curItem = NULL; + + if(offset > 0) + curItem = NULL; + + if(__listModel->getAtPersonData(__curAppendIndex, LIST_QUERY_DEFAULT)) { + elm_index_item_clear(__fastScroll); + __freeFastIndexData(); + __fastIndexList = NULL; + __appendFastScrollLetter(SYMBOL_MAGNIFIER); + if(__favoriteTitleItem) { + __appendFastScrollLetter(SYMBOL_STAR); + } + } + __linkItemsManually(eina_list_nth_list(__fastIndexList, 0), __searchbarItem); + if(__favoriteTitleItem) { + __linkItemsManually(eina_list_nth_list(__fastIndexList, 1), __favoriteTitleItem); + } + + while(true){ + dataPerson = __listModel->getAtPersonData(__curAppendIndex, LIST_QUERY_DEFAULT); + + if(dataPerson == NULL) { + break; + } + CtListDataItem *itemData = new CtListDataItem; + itemData->personData = dataPerson; + itemData->listView = this; + itemData->item = __addDefaultItem(curItem, itemData, true); + __curAppendIndex++; + index++; + + curItem = elm_genlist_item_next_get(itemData->item); + } + + if(index > 0) + __deleteRestItems(curItem, true); + + if(__curAppendIndex == 0) { + if(__onSearching) { + __showNoContentsLayout(); + __setNoContentsText(V_("IDS_PB_NPBODY_NO_RESULTS_FOUND_ABB")); + } + else { + if (__hasDefaultList == true) { + if(!__onNoContentLayout) { + Elm_Object_Item *curItem = __getStandardItem(LIST_SUB_DEFAULT); + while(curItem) { + Elm_Object_Item *item = elm_genlist_item_next_get(curItem); + elm_object_item_del(curItem); + curItem = item; + } + __showNoContentsLayout(); + } + __setNoContentsText(V_("IDS_PB_NPBODY_NO_CONTACTS"), V_("IDS_PB_BODY_AFTER_YOU_CREATE_CONTACTS_THEY_WILL_BE_SHOWN_HERE")); + } + } + } else { + __hideNoContentsLayout(); + } + return __curAppendIndex; + } + + return 0; + +} + +Elm_Object_Item* CtListView::__addDefaultItem(Elm_Object_Item *curItem, CtListDataItem* itemData, bool needGroupTitle) +{ + WENTER(); + Elm_Object_Item *item = NULL; + if(needGroupTitle) + item = __appendGroupItem(curItem, itemData); + + if(item) + item = elm_genlist_item_next_get(item); + else + item = curItem; + + if(item == NULL) { + // insert item + //WDEBUG("append"); + item = elm_genlist_item_append(__genlist, __listItc, itemData, NULL, ELM_GENLIST_ITEM_NONE,__onSelectItem, this); + } + else { + if(elm_genlist_item_type_get(item) == ELM_GENLIST_ITEM_GROUP) { + // insert before item + //WDEBUG("insert"); + Elm_Object_Item *prev_item = elm_genlist_item_prev_get(item); + item = elm_genlist_item_insert_after(__genlist, __listItc, itemData, NULL, prev_item, ELM_GENLIST_ITEM_NONE, __onSelectItem, this); + } + else { + // update item + //WDEBUG("update"); + CtListDataItem *lastData = (CtListDataItem *)elm_object_item_data_get(item); + if(lastData) + delete lastData; + elm_object_item_data_set(item, itemData); + } + } + + if(__topItemPersonId > 0) { + int person_id = itemData->personData->getPersonId(); + if(__topItemPersonId == person_id) + elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_TOP); + } + + WLEAVE(); + return item; +} + + +Elm_Object_Item* CtListView::__getStandardItem(CtListSubListType listType) +{ + WDEBUG("list type %d", listType); + Elm_Object_Item *curItem = NULL; + if(listType == LIST_SUB_LINK_SUGGEST) { + if(__linkSuggestTitleItem) { + WDEBUG("__linkSuggestTitleItem"); + curItem = __linkSuggestTitleItem; + } else if(__selectAllItem) { + WDEBUG("__selectAllItem"); + curItem = elm_genlist_item_next_get(__selectAllItem); + } else if(__searchbarItem) { + WDEBUG("__searchbarItem"); + curItem = elm_genlist_item_next_get(__searchbarItem); + } else { + WDEBUG("firstItem"); + curItem = elm_genlist_first_item_get(__genlist); + } + } else if(listType == LIST_SUB_FAVORITE) { + if(__favoriteTitleItem) { + WDEBUG("__favoriteTitleItem"); + curItem = __favoriteTitleItem; + } else if(__myProfileItem) { + WDEBUG("__myProfileItem"); + curItem = elm_genlist_item_next_get(__myProfileItem); + } else if(__linkSuggestTitleItem) { + WDEBUG("__linkSuggestTitleItem"); + curItem = __linkSuggestTitleItem; + } else if(__selectAllItem) { + WDEBUG("__selectAllItem"); + curItem = elm_genlist_item_next_get(__selectAllItem); + } else if(__searchbarItem) { + WDEBUG("__searchbarItem"); + curItem = elm_genlist_item_next_get(__searchbarItem); + } else { + WDEBUG("firstItem"); + curItem = elm_genlist_first_item_get(__genlist); + } + } else if(listType == LIST_SUB_MFC) { + if(__mfcTitleItem) { + WDEBUG("__mfcTitleItem"); + curItem = __mfcTitleItem; + } else if(__favoriteTitleItem) { + WDEBUG("__favoriteTitleItem"); + curItem = elm_genlist_item_next_get(__favoriteTitleItem); + while(curItem && elm_genlist_item_type_get(curItem) != ELM_GENLIST_ITEM_GROUP) { + curItem = elm_genlist_item_next_get(curItem); + } + } else if(__myProfileItem) { + WDEBUG("__myProfileItem"); + curItem = elm_genlist_item_next_get(__myProfileItem); + } else if(__linkSuggestTitleItem) { + WDEBUG("__linkSuggestTitleItem"); + curItem = __linkSuggestTitleItem; + } else if(__selectAllItem) { + WDEBUG("__selectAllItem"); + curItem = elm_genlist_item_next_get(__selectAllItem); + } else if(__searchbarItem) { + WDEBUG("__searchbarItem"); + curItem = elm_genlist_item_next_get(__searchbarItem); + } else { + WDEBUG("firstItem"); + curItem = elm_genlist_first_item_get(__genlist); + } + } else if(listType == LIST_SUB_DEFAULT) { + + if(__onSearching) { + if(__selectAllItem) { + WDEBUG("__selectAllItem onSearching"); + curItem = elm_genlist_item_next_get(__selectAllItem); + } else { + WDEBUG("__searchbarItem onSearching"); + curItem = elm_genlist_item_next_get(__searchbarItem); + } + return curItem; + } + + if(__mfcTitleItem) { + WDEBUG("__mfcTitleItem"); + curItem = elm_genlist_item_next_get(__mfcTitleItem); + while(curItem && elm_genlist_item_type_get(curItem) != ELM_GENLIST_ITEM_GROUP) { + curItem = elm_genlist_item_next_get(curItem); + } + } else if(__favoriteTitleItem) { + WDEBUG("__favoriteTitleItem"); + curItem = elm_genlist_item_next_get(__favoriteTitleItem); + while(curItem && elm_genlist_item_type_get(curItem) != ELM_GENLIST_ITEM_GROUP) { + curItem = elm_genlist_item_next_get(curItem); + } + } else if(__myProfileItem) { + WDEBUG("__myProfileItem"); + curItem = elm_genlist_item_next_get(__myProfileItem); + } else if(__linkSuggestTitleItem) { + WDEBUG("__linkSuggestTitleItem"); + curItem = elm_genlist_item_next_get(__linkSuggestTitleItem); + while(curItem && elm_genlist_item_type_get(curItem) != ELM_GENLIST_ITEM_GROUP) { + curItem = elm_genlist_item_next_get(curItem); + } + } else if(__selectAllItem) { + WDEBUG("__selectAllItem"); + curItem = elm_genlist_item_next_get(__selectAllItem); + } else if(__searchbarItem) { + WDEBUG("__searchbarItem"); + curItem = __searchbarItem; + curItem = elm_genlist_item_next_get(curItem); + } else { + WDEBUG("firstItem"); + curItem = elm_genlist_first_item_get(__genlist); + } + } + + return curItem; +} + +void CtListView::__deleteRestItems(Elm_Object_Item *curItem, bool all) +{ + WDEBUG("all %d", all); + if(curItem) { + int index = 0; + Elm_Object_Item *item = NULL; + while(curItem) { + if(all == false) { + if(elm_genlist_item_type_get(curItem) == ELM_GENLIST_ITEM_GROUP) + break; + } + item = elm_genlist_item_next_get(curItem); + elm_object_item_del(curItem); + curItem = item; + index++; + } + WDEBUG("%d items deleted", index); + } +} + + +void CtListView::__appendGenlistItems(int offset) +{ + WENTER(); + + WDEBUG("offset : %d", offset); + + int mainIndex = 0; + int mfcIndex = 0; + int favorIndex = 0; + std::shared_ptr<CtListDataPerson> dataPerson; + + if(offset == 0) { + // initial before add items + __initListItems(); + + //add searchbar + __addSearchbarItem(); + + //add select all + __addSelectAllItem(); + + //add Link Suggest list + __addLinkSuggestList(); + + //add my profile + __addMyProfileItem(); + + //add Favorites list + favorIndex = __addFavoriteList(); + + //add MFC list + mfcIndex = __addMfcList(); + + //add favorite group title + if(__hasFavGroupTitle) + __addFavoriteTitleItem(NULL); + } + + //add main list + mainIndex = __addDefaultList(offset); + + WDEBUG("%d, %d, %d", favorIndex, mfcIndex, mainIndex); + + if (__onSearching == true || __listModel->getPersonListCount(LIST_QUERY_DEFAULT) == 0 || __onShowGroupButton == true) + __hideFastScroll(); + else if(__hasFastscroll) + __showFastScroll(); + + if(__launched == 1 && __onSearching == false) { + elm_genlist_item_update(__searchbarItem); + __launched = -1; + WDEBUG("launched"); + } + + WLEAVE(); +} + +Elm_Object_Item *CtListView::__appendGroupItem(Elm_Object_Item *curItem, CtListDataItem* itemData) +{ + WENTER(); + if(__onSearching == true) + return NULL; + + if(__hasGroupTitle == false) + return NULL; + + Elm_Object_Item *item = NULL; + std::string curIndex; + + if (NULL == itemData->personData->getDisplayName()) + curIndex = "#"; + else{ + if(itemData->personData->getDisplayIndex()) + curIndex = itemData->personData->getDisplayIndex(); + else + return NULL; + } + + if(__curGroupIndex != curIndex) { + if(curItem == NULL) { + WDEBUG("append %s", curIndex.c_str()); + item = elm_genlist_item_append(__genlist, __groupTitleItc, strdup(curIndex.c_str()), NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL); + } + else { + if(elm_genlist_item_type_get(curItem) != ELM_GENLIST_ITEM_GROUP) { + WDEBUG("insert %s", curIndex.c_str()); + item = elm_genlist_item_insert_before(__genlist, __groupTitleItc, strdup(curIndex.c_str()), NULL, curItem, ELM_GENLIST_ITEM_GROUP, NULL, NULL); + } + else { + WDEBUG("update %s", curIndex.c_str()); + elm_object_item_data_set(curItem, strdup(curIndex.c_str())); + item = curItem; + } + } + elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + + __appendFastScrollLetter(curIndex); + + __curGroupIndex = curIndex; + __curGroupTitleItem = item; + //link to index + __linkItemToIndex(__curGroupTitleItem); + } + elm_index_level_go(__fastScroll, 0); + + WLEAVE(); + return item; +} + +void CtListView::__onEntryFocused(void *data, Evas_Object *obj, void *event_info) +{ + WENTER(); + + CtListView* listView = (CtListView*) data; + eext_object_event_callback_add(obj, EEXT_CALLBACK_BACK, listView->__onEntryBackButton, listView); + + if (listView->__hasGroupButton == false) { + WDEBUG("the view does not support group button"); + return; + } + else if (SAFE_STRLEN(elm_entry_entry_get(obj)) > 0) { + WDEBUG("on searching"); + return; + } + + if (listView->__listGroupModel->getAvailableGroupCount() > 0) { + WDEBUG("group list is more than 0"); + elm_object_item_signal_emit(listView->__searchbarItem, "group,button,show", ""); + + listView->__hideFastScroll(); + listView->__onShowGroupButton = true; + } + if (listView->__hasCreateButton) { + listView->__hideCreateButton(); + } +} + +void CtListView::__onEntryUnfocused(void *data, Evas_Object *obj, void *event_info) +{ + WENTER(); + + CtListView* listView = (CtListView*) data; + + if (listView->__onShowGroupButton == true && listView->__onShowGroupList == false) { + listView->__onShowGroupButton = false; + elm_object_item_signal_emit(listView->__searchbarItem, "group,button,hide", ""); + listView->__showFastScroll(); + } + if (listView->__hasCreateButton) { + if (elm_entry_is_empty(obj)) { + listView->__showCreateButton(); + } + } +} + +void CtListView::__onEntryBackButton(void *data, Evas_Object *obj, void *event_info) +{ + WENTER(); + + CtListView* listView = (CtListView*) data; + eext_object_event_callback_del(obj, EEXT_CALLBACK_BACK, __onEntryBackButton); + elm_entry_entry_set(obj, NULL); + elm_object_focus_set(obj, EINA_FALSE); + listView->__showFastScroll(); +} + +void CtListView::__onCancelButtonClicked(void *data, Evas_Object *obj, void *event_info) +{ + WENTER(); + + CtListView* listView = (CtListView*) data; + + listView->__onShowMemberList = false; + + listView->__curAppendIndex = 0; + listView->__appendGenlistItems(0); + // after all item appended, link reset items to fastscroll + listView->__linkItemToRestIndex(); +} + +void CtListView::__reorderButtonMouseDownCb(void *data, Evas *evas, Evas_Object *obj, void *event_info) +{ + elm_genlist_reorder_mode_set((Evas_Object *)data, EINA_TRUE); +} + +void CtListView::__reorderButtonMouseUpCb(void *data, Evas *evas, Evas_Object *obj, void *event_info) +{ + elm_genlist_reorder_mode_set((Evas_Object *)data, EINA_FALSE); +} + +void CtListView::__setReorderItemClassStyle() +{ + WPRET_M(__listItc, "already set"); + + __listItc = elm_genlist_item_class_new(); + WPRET_M(!__listItc, "elm_genlist_item_class_new() failed"); + __listItc->item_style = "type1"; + __listItc->func.del = [](void *data, Evas_Object *obj)->void + { + delete static_cast<CtListDataItem*>(data); + }; + __listItc->func.text_get = [](void* data, Evas_Object* obj, const char* part)->char* + { + if(!strcmp(part, "elm.text")) { + CtListDataItem* itemData = (CtListDataItem*)data; + const char *name = itemData->personData->getDisplayName(); + if (name) + return elm_entry_utf8_to_markup(name); + else + return SAFE_STRDUP(V_("IDS_LOGS_MBODY_UNKNOWN")); + + } + return NULL; + }; + __listItc->func.content_get = [](void* data, Evas_Object* obj, const char* part)->Evas_Object* + { + if (0 == strcmp(part, "elm.swallow.icon")) { + CtListDataItem* itemData = (CtListDataItem*)data; + Evas_Object *icon = createThumbnail(obj, THUMBNAIL_98, itemData->personData->getImagePath(), true); + return icon; + } + else if (0 == strcmp(part, "elm.swallow.end")) { + CtListDataItem* itemData = (CtListDataItem*)data; + Evas_Object *button = elm_button_add(obj); + elm_object_style_set(button, "icon_reorder"); + evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + evas_object_event_callback_add(button, EVAS_CALLBACK_MOUSE_DOWN, __reorderButtonMouseDownCb, itemData->listView->__genlist); + evas_object_event_callback_add(button, EVAS_CALLBACK_MOUSE_UP, __reorderButtonMouseUpCb, itemData->listView->__genlist); + + return button; + } + else + return NULL; + }; + +} + +void CtListView::__setCheckItemClassStyle() +{ + WPRET_M(__listItc, "already set"); + + __listItc = elm_genlist_item_class_new(); + WPRET_M(!__listItc, "elm_genlist_item_class_new() failed"); + __listItc->item_style = "type1"; + __listItc->func.del = [](void *data, Evas_Object *obj)->void + { + delete static_cast<CtListDataItem*>(data); + }; + __listItc->func.text_get = [](void* data, Evas_Object* obj, const char* part)->char* + { + if(!strcmp(part, "elm.text")) { + CtListDataItem* itemData = (CtListDataItem*)data; + if (SAFE_STRLEN(itemData->listView->__listModel->getSearchString()) > 0){ + std::string name = ContactsCommon::getHighlightText(itemData->personData->getDisplayName(), itemData->listView->__listModel->getSearchString()); + if (!name.empty()) + return strdup(name.c_str()); + else + return SAFE_STRDUP(V_("IDS_LOGS_MBODY_UNKNOWN")); + } + else{ + const char *name = NULL; + name = itemData->personData->getDisplayName(); + if(name) + return elm_entry_utf8_to_markup(name); + else + return SAFE_STRDUP(V_("IDS_LOGS_MBODY_UNKNOWN")); + } + } + return NULL; + }; + __listItc->func.content_get = [](void* data, Evas_Object* obj, const char* part)->Evas_Object* + { + if (0 == strcmp(part, "elm.swallow.icon")) { + CtListDataItem* itemData = (CtListDataItem*)data; + Evas_Object *icon = createThumbnail(obj, THUMBNAIL_98, itemData->personData->getImagePath(), true); + return icon; + } + else if (0 == strcmp(part, "elm.swallow.end")) { + CtListDataItem* itemData = (CtListDataItem*)data; + Evas_Object *check = elm_check_add(obj); + elm_check_state_set(check, itemData->personData->isChecked()); + evas_object_repeat_events_set(check, EINA_TRUE); + evas_object_propagate_events_set(check, EINA_FALSE); + evas_object_freeze_events_set (check, EINA_TRUE); + return check; + } + else + return NULL; + }; + +} + +void CtListView::__setGroupTitleItemClassStyle() +{ + WPRET_M(__groupTitleItc, "already set"); + + __groupTitleItc = elm_genlist_item_class_new(); + WPRET_M(!__groupTitleItc, "elm_genlist_item_class_new() failed"); + + __groupTitleItc->item_style = "group_index"; + + __groupTitleItc->func.text_get = [](void* data, Evas_Object* obj, const char* part)->char* + { + char *groupIndex = (char*)data; + if (0 == strcmp(part, "elm.text") && groupIndex && *groupIndex) + return strdup(groupIndex); + else + return NULL; + }; + __groupTitleItc->func.del = [](void *data, Evas_Object *obj)->void + { + char *groupIndex = (char*)data; + free(groupIndex); + }; + __groupTitleItc->func.content_get = NULL; + +} + +void CtListView::__setFavoriteTitleItemClassStyle() +{ + WPRET_M(__favoriteTitleItc, "already set"); + + __favoriteTitleItc = elm_genlist_item_class_new(); + WPRET_M(!__favoriteTitleItc, "elm_genlist_item_class_new() failed"); + + __favoriteTitleItc->item_style = "group_index"; + + __favoriteTitleItc->func.text_get = [](void* data, Evas_Object* obj, const char* part)->char* + { + if (0 == strcmp(part, "elm.text")) + return strdup(V_("IDS_PB_HEADER_FAVOURITES")); + else + return NULL; + }; + __favoriteTitleItc->func.del = NULL; + __favoriteTitleItc->func.content_get = NULL; +} + +void CtListView::__setMfcTitleItemClassStyle() +{ + WPRET_M(__mfcTitleItc, "already set"); + + __mfcTitleItc = elm_genlist_item_class_new(); + WPRET_M(!__mfcTitleItc, "elm_genlist_item_class_new() failed"); + + __mfcTitleItc->item_style = "group_index"; + + __mfcTitleItc->func.text_get = [](void* data, Evas_Object* obj, const char* part)->char* + { + if (0 == strcmp(part, "elm.text")) + return strdup(V_("IDS_PB_HEADER_MOST_FREQUENT_CONTACTS_ABB2")); + else + return NULL; + }; + __mfcTitleItc->func.del = NULL; + __mfcTitleItc->func.content_get = NULL; + +} + +void CtListView::__setLinkSuggestTitleItemClassStyle() +{ + WPRET_M(__linkSuggestTitleItc, "already set"); + + __linkSuggestTitleItc = elm_genlist_item_class_new(); + WPRET_M(!__linkSuggestTitleItc, "elm_genlist_item_class_new() failed"); + + __linkSuggestTitleItc->item_style = "group_index"; + + __linkSuggestTitleItc->func.text_get = [](void* data, Evas_Object* obj, const char* part)->char* + { + if (0 == strcmp(part, "elm.text")) + return strdup(V_("IDS_PB_HEADER_SUGGESTED_CONTACTS_ABB")); + else + return NULL; + }; + __linkSuggestTitleItc->func.del = NULL; + __linkSuggestTitleItc->func.content_get = NULL; + +} + +void CtListView::__setDefaultItemClassStyle() +{ + WENTER(); + WPRET_M(__listItc, "already set"); + + __listItc = elm_genlist_item_class_new(); + WPRET_M(!__listItc, "elm_genlist_item_class_new() failed"); + __listItc->item_style = "type1"; + __listItc->func.del = [](void *data, Evas_Object *obj)->void + { + delete static_cast<CtListDataItem*>(data); + }; + __listItc->func.text_get = [](void* data, Evas_Object* obj, const char* part)->char* + { + if(!strcmp(part, "elm.text")) { + CtListDataItem* itemData = (CtListDataItem*)data; + if(SAFE_STRLEN(itemData->listView->__listModel->getSearchString()) > 0){ + std::string name = ContactsCommon::getHighlightText(itemData->personData->getDisplayName(), itemData->listView->__listModel->getSearchString()); + if (!name.empty()) + return strdup(name.c_str()); + else + return SAFE_STRDUP(V_("IDS_LOGS_MBODY_UNKNOWN")); + } + else{ + const char *name = NULL; + name = itemData->personData->getDisplayName(); + if(name) + return elm_entry_utf8_to_markup(name); + else + return SAFE_STRDUP(V_("IDS_LOGS_MBODY_UNKNOWN")); + } + } + return NULL; + }; + __listItc->func.content_get = [](void* data, Evas_Object* obj, const char* part)->Evas_Object* + { + if (0 == strcmp(part, "elm.swallow.icon")) { + CtListDataItem* itemData = (CtListDataItem*)data; + Evas_Object *icon = createThumbnail(obj, THUMBNAIL_98, itemData->personData->getImagePath(), true); + return icon; + } + return NULL; + }; + +} + +char *CtListView::__getMyProfileNumber() const +{ + telephony_handle_list_s list; + int err = telephony_init(&list); + WPRET_VM(err != TELEPHONY_ERROR_NONE, nullptr, "telephony_init() failed(%d)", err); + + int sim_count = list.count; + char *ret = nullptr; + + for (int i=0; i < sim_count; ++i) { + char *number = nullptr; + + err = telephony_sim_get_subscriber_number(list.handle[i], &number); + if (TELEPHONY_ERROR_NONE == err && number && *number) { + ret = number; + break; + } + free(number); + } + + err = telephony_deinit(&list); + WPWARN(err != TELEPHONY_ERROR_NONE, "telephony_deinit() failed(%d)", err); + + return ret; +} + +void CtListView::__setMyProfileItemClassStyle() +{ + WENTER(); + + WPRET_M(__myProfileItc, "already set"); + + __myProfileItc = elm_genlist_item_class_new(); + WPRET_M(!__myProfileItc, "elm_genlist_item_class_new() failed"); + __myProfileItc->item_style = "type1"; + __myProfileItc->func.del = NULL; + __myProfileItc->func.text_get = [](void* data, Evas_Object* obj, const char* part)->char* + { + CtListView *self = static_cast<CtListView*>(data); + WPRET_VM(!self, NULL, "invalid this pointer"); + int err = CONTACTS_ERROR_NONE; + contacts_list_h myprofileList = NULL; + int count = 0; + contacts_record_h record = NULL; + char* displayName = NULL; + + if(!strcmp(part, "elm.text")) { + err = contacts_db_get_all_records(_contacts_my_profile._uri, 0, 0, &myprofileList); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_all_records() Failed(%d)", err); + + contacts_list_get_count(myprofileList, &count); + if (count > 0) { + err = contacts_list_get_current_record_p(myprofileList, &record); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_get_current_record_p() Failed(%d)", err); + + err = contacts_record_get_str(record, _contacts_my_profile.display_name, &displayName); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err); + + if (displayName) { + ctCommonRemoveNewline(displayName); + if (*displayName) { + return displayName; + } + + free(displayName); + } + } else { + char *number = self->__getMyProfileNumber(); + if (number && *number) { + return number; + } + + free(number); + } + + err = contacts_list_destroy(myprofileList, true); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_destroy() Failed(%d)", err); + + return SAFE_STRDUP(V_("IDS_PB_MBODY_SET_MY_PROFILE")); + } + return NULL; + }; + __myProfileItc->func.content_get = [](void* data, Evas_Object* obj, const char* part)->Evas_Object* + { + if (0 == strcmp(part, "elm.swallow.icon")) { + char* imagePath = NULL; + int err = CONTACTS_ERROR_NONE; + contacts_list_h myprofileList = NULL; + int count = 0; + contacts_record_h record = NULL; + + err = contacts_db_get_all_records(_contacts_my_profile._uri, 0, 0, &myprofileList); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_all_records() Failed(%d)", err); + + err = contacts_list_get_count(myprofileList, &count); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_get_count() Failed(%d)", err); + if (count > 0) { + err = contacts_list_get_current_record_p(myprofileList, &record); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_list_get_current_record_p() Failed(%d)", err); + + err = contacts_record_get_str_p(record, _contacts_my_profile.image_thumbnail_path, &imagePath); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + } + + Evas_Object *icon = createThumbnail(obj, THUMBNAIL_98, imagePath, true); + contacts_list_destroy(myprofileList, true); + return icon; + } + return NULL; + }; +} + +Evas_Object* CtListView::__setNoContentsLayout(Evas_Object* parent) +{ + Evas_Object* nocontents = elm_layout_add(parent); + elm_layout_theme_set(nocontents, "layout", "nocontents", "default"); + return nocontents; +} + +void CtListView::__setNoContentsText(std::string text, std::string helptext) +{ + if (!__noContentLayout) { + return; + } + elm_object_part_text_set(__noContentLayout, "elm.text", text.c_str()); + elm_object_part_text_set(__noContentLayout, "elm.help.text", helptext.c_str()); + elm_layout_signal_emit(__noContentLayout, "align.center", "elm"); +} + +void CtListView::__hideNoContentsLayout() +{ + if (!__noContentLayout || !__onNoContentLayout) { + return; + } + __onNoContentLayout = false; + evas_object_size_hint_weight_set(__noContentLayout, 0.0, 0.0); + evas_object_size_hint_align_set(__noContentLayout, 0.0, 0.0); + evas_object_hide(__noContentLayout); + 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); + elm_scroller_content_min_limit(__genlist, EINA_FALSE, EINA_FALSE); +} + +void CtListView::__showNoContentsLayout() +{ + if (!__noContentLayout || __onNoContentLayout) { + return; + } + __onNoContentLayout = true; + evas_object_size_hint_weight_set(__noContentLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(__noContentLayout, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(__noContentLayout); + elm_scroller_content_min_limit(__genlist, EINA_FALSE, EINA_TRUE); + evas_object_size_hint_weight_set(__genlist, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(__genlist, EVAS_HINT_FILL, 0.0); +} + +void CtListView::__setSelectAllItemClassStyle() +{ + WHIT(); + WPRET_M(__selectAllItc, "already set"); + + __selectAllItc = elm_genlist_item_class_new(); + WPRET_M(!__selectAllItc, "elm_genlist_item_class_new() failed"); + __selectAllItc->item_style = "type1"; + __selectAllItc->func.del = [](void *data, Evas_Object *obj)->void + { + delete static_cast<CtListDataItem*>(data); + }; + __selectAllItc->func.text_get = [](void* data, Evas_Object* obj, const char* part)->char* + { + if(!strcmp(part, "elm.text")) { + return SAFE_STRDUP(V_("IDS_PB_MBODY_SELECT_ALL")); + } + return NULL; + }; + __selectAllItc->func.content_get = [](void* data, Evas_Object* obj, const char* part)->Evas_Object* + { + if (0 == strcmp(part, "elm.swallow.end")) { + CtListDataItem* itemData = (CtListDataItem*)data; + Evas_Object *check = elm_check_add(obj); + elm_check_state_set(check, (Eina_Bool)itemData->listView->__selectAllState); + evas_object_repeat_events_set(check, EINA_TRUE); + evas_object_propagate_events_set(check, EINA_FALSE); + evas_object_freeze_events_set (check, EINA_TRUE); + itemData->listView->__selectAllObj = check; + + return check; + } + else + return NULL; + }; +} + +void CtListView::__onSipUpCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + + CtListView *listView = (CtListView*)data; + listView->__sipStatus = true; +} + +void CtListView::__onSipDownCb(void *data, Evas_Object *obj, void *event_info) +{ + WHIT(); + + CtListView *listView = (CtListView*)data; + listView->__sipStatus = false; +} + +void CtListView::__setSearchbarItemClassStyle() +{ + WHIT(); + WPRET_M(__searchbarItc, "already set"); + + __searchbarItc = elm_genlist_item_class_new(); + WPRET_M(!__searchbarItc, "elm_genlist_item_class_new() failed"); + __searchbarItc->item_style = "full"; + __searchbarItc->func.del = NULL; + __searchbarItc->func.content_get = [](void* data, Evas_Object* obj, const char* part)->Evas_Object* + { + if (0 == strcmp(part, "elm.swallow.content")) { + CtListView* listView = (CtListView*)data; + + static Elm_Entry_Filter_Limit_Size filter; + WEditfield *editfield = new WEditfield(); + editfield->create(listView->__genlist, NULL); + + Evas_Object *entry = editfield->getEntry(); + + elm_object_domain_translatable_part_text_set(entry, "elm.guide", PACKAGE, "IDS_PB_NPBODY_SEARCH"); + + const char *search = listView->__listModel->getSearchString(); + if(search) { + elm_entry_entry_set(entry, search); + } + + evas_object_smart_callback_add(entry, "changed", listView->__onChangedSearchEditField, listView); + evas_object_smart_callback_add(entry, "preedit,changed", listView->__onChangedSearchEditField, listView); + evas_object_smart_callback_add(entry, "activated", listView->__onSearchbarActivatedCb, listView); + evas_object_smart_callback_add(entry, "focused", listView->__onEntryFocused, listView); + evas_object_smart_callback_add(entry, "unfocused", listView->__onEntryUnfocused, listView); + + Evas_Object *clearBtn = editfield->getClearButton(); + evas_object_smart_callback_add(clearBtn, "clicked", listView->__onChangedSearchEditField, listView); + + elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT); + filter.max_char_count = CT_SEARCHBAR_MAX_CHAR; + elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &filter); + + elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_NORMAL); + elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_NONE); + elm_entry_input_panel_return_key_type_set(entry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH); + + return editfield->getEvasObj(); + } else { + return NULL; + } + }; +} + +void CtListView::__setItemClassStyle() +{ + WDEBUG("__viewType %d", __viewType); + + // set searchbar item class + __setSearchbarItemClassStyle(); + + // set group item class + __setGroupTitleItemClassStyle(); + + // set favorite title item class + __setFavoriteTitleItemClassStyle(); + + // set mfc title item class + __setMfcTitleItemClassStyle(); + + // set my profile item class + __setMyProfileItemClassStyle(); + + // set item class + switch(__viewType){ + case LIST_VIEW_DEFAULT : + __setDefaultItemClassStyle(); + break; + case LIST_VIEW_CHECK : + __setSelectAllItemClassStyle(); + __setCheckItemClassStyle(); + break; + case LIST_VIEW_REORDER : + __setReorderItemClassStyle(); + break; + } +} + +void CtListView::__initViewCondition(CtListViewType viewType, CtListCtrlType ctrlType) +{ + __hasSearchbar = true; + __hasGroupTitle = true; + __hasFastscroll = true; + __hasDefaultList = true; + __hasFavoriteList = true; + __hasMfcList = true; + + WDEBUG("viewType %d, ctrlType %d",viewType, ctrlType); + char buf[CT_TEXT_SHORT_LEN] = {0,}; + switch(viewType) { + case LIST_VIEW_CHECK: + snprintf(buf, sizeof(buf), ctGetContactsString("IDS_PB_HEADER_PD_SELECTED_ABB3"), 0); + setTitle(buf); + __hasTitle = true; + __hasDoneCancel = true; + __hasFavoriteList = true; + __hasMfcList = true; + break; + case LIST_VIEW_REORDER: + setTitle(V_("IDS_PB_OPT_REORDER")); + __hasTitle = true; + __hasDoneCancel = true; + break; + default: + __hasCreateButton = true; + break; + } + + switch(ctrlType) { + case LIST_CTRL_DEFAULT: + __hasMenu = true; + __hasMyProfile = true; + __hasGroupButton = true; + break; + case LIST_CTRL_DELETE_CONTACTS: + case LIST_CTRL_SHARE_CONTACTS: + __hasToolbar = true; + __hasSelectAll = true; + __hasFavoriteList = true; + __hasMfcList = true; + break; + case LIST_CTRL_ADD_FAVORITES: + __hasSelectAll = true; + __hasFavoriteList = false; + __hasMfcList = false; + break; + case LIST_CTRL_REORDER_FAVORITES: + __hasSearchbar = false; + __hasFastscroll = false; + __hasGroupTitle = false; + __hasFavGroupTitle = true; + __hasFavoriteList = false; + __hasMfcList = false; + break; + case LIST_CTRL_REMOVE_FAVORITES: + __hasSearchbar = false; + __hasFastscroll = false; + __hasGroupTitle = false; + __hasSelectAll = true; + __hasDefaultList = false; + __hasFavoriteList = true; + __hasMfcList = true; + break; + default: + break; + } +} + +const int CtListView::getListTopItemPersonId() +{ + Evas_Coord x, y; + Elm_Object_Item *item = NULL; + int nthItem = -1; + int person_id = -1; + if (__fastLayout) { + evas_object_geometry_get(__fastLayout, &x, &y, NULL, NULL); + WDEBUG("layout_fastscroll x = %d, y = %d", x, y); + if (__genlist) { + item = elm_genlist_at_xy_item_get(__genlist, x, y+40, NULL); + if(item) { + while (elm_genlist_item_type_get(item) == ELM_GENLIST_ITEM_GROUP) { + item = elm_genlist_item_next_get(item); + } + if(__searchbarItem == item ||__myProfileItem == item) { + WDEBUG("top of list is searchbar or myprofile item"); + return -1; + } + + int countFavorite = __listModel->getContactsCount(LIST_QUERY_FAVORITE); + if(countFavorite>0) ++countFavorite; + int countMFC = __listModel->getContactsCount(LIST_QUERY_MFC); + if(countMFC>0) ++countMFC; + nthItem = elm_genlist_item_index_get (item); + WDEBUG("nthItem %d", nthItem); + if(nthItem <= (1+countFavorite+countMFC) ) + return -1; + + CtListDataItem *dataItem = (CtListDataItem*)elm_object_item_data_get(item); + if(dataItem) { + person_id = dataItem->personData->getPersonId(); + } + } + } + } + WDEBUG("person_id %d", person_id); + + return person_id; +} + +void CtListView::setOnProgressOperation(bool onProgress) +{ + WDEBUG("onProgress %d", onProgress); + __onProgressOperation = onProgress; +} + +bool CtListView::__checkValidSpecialCharForNumber(char character) +{ + if(character=='*' + ||character=='#' + ||character=='+' + ||character==';' + ||character==',' + ||character=='-') + return true; + else + return false; +} + +bool CtListView::__checkValidCharForNumber(char character) +{ + if(isdigit(character) || __checkValidSpecialCharForNumber(character)) + return true; + else + return false; +} + +char* CtListView::__getSearchHighlightNumber(const char *src) +{ + + WPRET_VM(!src, NULL, "src string is null."); + if(SAFE_STRLEN(__listModel->getSearchString()) <= 0) + return SAFE_STRDUP(src); + + + int pos1 = -1; + int pos2 = -1; + int pos = 0; + const char *s = src; + const char *r = __listModel->getSearchString(); + + const char *match = strstr(s, r); + if(match) { + pos1 = match - s; + pos2 = pos1 + strlen(r); + } + else { + for (s=src;'\0' != *s;s++) { + if (__checkValidCharForNumber(*s)) { + WDEBUG("a %s", s); + + if (*s == *r || __checkValidSpecialCharForNumber(*s)) { + if (-1 == pos1) { + pos1 = pos; + } + pos2 = pos+1; + + if(__checkValidSpecialCharForNumber(*s) == false) + r++; + + if ('\0' == *r) + break; + } + else { + r = __listModel->getSearchString(); + pos1 = -1; + pos2 = -1; + WDEBUG("b %s", r); + } + } + pos++; + } + } + + if (0 <= pos1 && 0 <= pos2) + { + char display[CT_TEXT_MAX_LEN] = {0}; + char first[CT_TEXT_MAX_LEN] = {0}; + char middle[CT_TEXT_MAX_LEN] = {0}; + char color_set_middle[CT_TEXT_MAX_LEN] = {0}; + int r = 0, g = 0, b = 0, a = 255; + + snprintf(first, pos1+1, "%s", src); + snprintf(middle, (pos2 - pos1)+1, "%s", (char *)((int)src+pos1)); + sprintf(color_set_middle, "<color=#%02x%02x%02x%02x>%s</color>", r, g, b, a, middle); + snprintf(display, sizeof(display), "%s%s%s", first, color_set_middle, (char *)(src+pos2)); + + return strdup(display); + } + return SAFE_STRDUP(src); +} diff --git a/lib-contact/ct-list/src/CtNumberPopup.cpp b/lib-contact/ct-list/src/CtNumberPopup.cpp new file mode 100644 index 0000000..8761115 --- /dev/null +++ b/lib-contact/ct-list/src/CtNumberPopup.cpp @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "CtNumberPopup.h" +#include "CtListView.h" +#include "CtListDataPerson.h" +#include "ContactsDebug.h" + +#include <contacts.h> + +CtNumberPopup::CtNumberPopup(CtListDataPerson *personData) + : m_PersonData(personData), m_CallItem(nullptr), m_MessageItem(nullptr) +{ +} + +void CtNumberPopup::setOnResult(ResultCb callback) +{ + m_OnResult = std::move(callback); +} + +Evas_Object *CtNumberPopup::onCreate(Evas_Object *parent, void *param) +{ + setTitle(m_PersonData->getDataString()); + setContent(std::bind(&CtNumberPopup::createGenlist, this, std::placeholders::_1)); + return WPopup::onCreate(parent, param); +} + +Evas_Object *CtNumberPopup::createGenlist(Evas_Object *parent) +{ + Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new(); + WPRET_VM(!itc, NULL, "elm_genlist_item_class_new() failed"); + itc->func.text_get = CtNumberPopup::onItemTextGet; + + Evas_Object *genlist = elm_genlist_add(parent); + elm_genlist_homogeneous_set(genlist, EINA_TRUE); + elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS); + elm_scroller_content_min_limit(genlist, EINA_FALSE, EINA_TRUE); + + m_CallItem = elm_genlist_item_append(genlist, itc, "IDS_PB_OPT_VOICE_CALL", NULL, ELM_GENLIST_ITEM_NONE, + &CtNumberPopup::onItemSelect, this); + m_MessageItem = elm_genlist_item_append(genlist, itc, "IDS_PB_OPT_MESSAGE", NULL, ELM_GENLIST_ITEM_NONE, + &CtNumberPopup::onItemSelect, this); + + elm_genlist_item_class_free(itc); + + return genlist; +} + +char *CtNumberPopup::onItemTextGet(void *data, Evas_Object *obj, const char *part) +{ + if (strcmp(part, "elm.text") == 0) { + return strdup(dgettext(PACKAGE, (char*) data)); + } + + return NULL; +} + +void CtNumberPopup::onItemSelect(void *data, Evas_Object *obj, void *event_info) +{ + CtNumberPopup *popup = (CtNumberPopup*) data; + elm_genlist_item_selected_set((Elm_Object_Item*) event_info, EINA_TRUE); + + if (popup->m_OnResult) { + CtListResultType type = (event_info == popup->m_CallItem + ? LIST_RESULT_NUMBER_FOR_CALL + : LIST_RESULT_NUMBER_FOR_MESSAGE); + + popup->m_PersonData->setDataType(type); + popup->m_OnResult(popup->m_PersonData); + } + + popup->destroy(); +} diff --git a/lib-contact/ct-list/src/CtNumberPopup.h b/lib-contact/ct-list/src/CtNumberPopup.h new file mode 100644 index 0000000..05a9715 --- /dev/null +++ b/lib-contact/ct-list/src/CtNumberPopup.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_NUMBER_POPUP_H_ +#define _CT_NUMBER_POPUP_H_ + +#include "WPopup.h" + +#include <Elementary.h> + +class CtListDataPerson; + +class CtNumberPopup : public WPopup +{ +public: + typedef std::function<void(CtListDataPerson*)> ResultCb; + + CtNumberPopup(CtListDataPerson *personData); + + void setOnResult(ResultCb callback); + +private: + virtual Evas_Object *onCreate(Evas_Object *parent, void *param); + Evas_Object *createGenlist(Evas_Object *parent); + + static char *onItemTextGet(void *data, Evas_Object *obj, const char *part); + static void onItemSelect(void *data, Evas_Object *obj, void *event_info); + + CtListDataPerson *m_PersonData; + ResultCb m_OnResult; + + Elm_Object_Item *m_CallItem; + Elm_Object_Item *m_MessageItem; +}; + +#endif /* _CT_NUMBER_POPUP_H_ */ diff --git a/lib-contact/ct-setting/.cproject b/lib-contact/ct-setting/.cproject new file mode 100644 index 0000000..863d194 --- /dev/null +++ b/lib-contact/ct-setting/.cproject @@ -0,0 +1,516 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage"> + <storageModule moduleId="org.eclipse.cdt.core.settings"> + <cconfiguration id="org.tizen.nativecore.config.sbi.gcc45.so.debug.1583549422"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.tizen.nativecore.config.sbi.gcc45.so.debug.1583549422" moduleId="org.eclipse.cdt.core.settings" name="Debug"> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> + <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + </extensions> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <configuration artifactExtension="so" artifactName="ct-setting" buildArtefactType="org.tizen.nativecore.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.sharedLib" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.so.debug.1583549422" name="Debug" parent="org.tizen.nativecore.config.sbi.gcc45.so.debug"> + <folderInfo id="org.tizen.nativecore.config.sbi.gcc45.so.debug.1583549422." name="/" resourcePath=""> + <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.so.debug.1814914265" name="Tizen Core Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.so.debug"> + <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.1939584135" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/> + <builder autoBuildTarget="all" buildPath="${workspace_loc:/ct-setting}/Debug" enableAutoBuild="true" id="org.tizen.nativecore.target.sbi.gnu.builder.737992255" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" parallelBuildOn="true" parallelizationNumber="unlimited" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/> + <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.534831505" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/> + <tool command="i386-linux-gnueabi-g++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.1139128904" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler"> + <option id="gnu.cpp.compiler.option.optimization.level.599403704" 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.debugging.level.core.288565171" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/> + <option defaultValue="true" id="sbi.gnu.cpp.compiler.option.misc.pic.core.474631780" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.cpp.compiler.option.1552766224" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs"> + <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_gcc46.i386.core.sharedLib"/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.1116913056" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath"> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SDK_INSTALL_PATH}/library""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/EGL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/GLES""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/GLES2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/KHR""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.1048478329" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.core" valueType="stringList"> + <listOptionValue builtIn="false" value=""/> + <listOptionValue builtIn="false" value=""/> + <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-fvisibility=hidden"/> + </option> + <option id="gnu.cpp.compiler.option.include.paths.498261022" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc/app-assist}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/ct-common/inc}""/> + <listOptionValue builtIn="false" value="../../../app-assist-efl/inc"/> + <listOptionValue builtIn="false" value=""${workspace_loc:/common/inc}""/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks.core.1732758547" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + </option> + <option id="gnu.cpp.compiler.option.preprocessor.def.714704059" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols"> + <listOptionValue builtIn="false" value="_DEBUG"/> + <listOptionValue builtIn="false" value="TIZEN_DEBUG_ENABLE"/> + <listOptionValue builtIn="false" value="_SDK_BUILD"/> + </option> + <option id="gnu.cpp.compiler.option.other.other.1169775743" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -std=c++0x" valueType="string"/> + <inputType id="sbi.gnu.cpp.compiler.tizen.inputType.775341789"/> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.683625643" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool command="i386-linux-gnueabi-gcc" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.1090942733" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler"> + <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.1374140377" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/> + <option id="sbi.gnu.c.compiler.option.debugging.level.core.2111497675" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" value="gnu.c.debugging.level.max" valueType="enumerated"/> + <option defaultValue="true" id="sbi.gnu.c.compiler.option.misc.pic.core.1036795257" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.c.compiler.option.2035623177" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs"> + <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_gcc46.i386.core.sharedLib"/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.1605350523" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath"> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SDK_INSTALL_PATH}/library""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/EGL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/GLES""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/GLES2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/KHR""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.1596045558" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.core" valueType="stringList"> + <listOptionValue builtIn="false" value=""/> + <listOptionValue builtIn="false" value=""/> + <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-fvisibility=hidden"/> + </option> + <option id="gnu.c.compiler.option.include.paths.1451330003" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks.core.527585363" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + </option> + <option id="gnu.c.compiler.option.preprocessor.def.symbols.1456121424" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols"> + <listOptionValue builtIn="false" value="_DEBUG"/> + </option> + <inputType id="sbi.gnu.c.compiler.tizen.inputType.689395248"/> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1047407408" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.2086707076" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/> + <tool command="i386-linux-gnueabi-g++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.763774190" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker"> + <option defaultValue="true" id="sbi.gnu.cpp.linker.option.shared_flag.core.1647863912" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" valueType="boolean"/> + <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.2096664081" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList"> + <listOptionValue builtIn="false" value="-Xlinker --as-needed"/> + <listOptionValue builtIn="false" value=""/> + <listOptionValue builtIn="false" value="-lpthread "/> + <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-L"${SBI_SYSROOT}/usr/lib""/> + <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/> + </option> + <option id="gnu.cpp.link.option.paths.1360709528" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lib}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/ct-common/Debug}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/common/Debug}""/> + <listOptionValue builtIn="false" value="../../../app-assist-efl/Debug"/> + </option> + <option id="gnu.cpp.link.option.libs.1506872605" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs"> + <listOptionValue builtIn="false" value="ct-common"/> + <listOptionValue builtIn="false" value="common"/> + <listOptionValue builtIn="false" srcPrefixMapping="" srcRootPath="" value="app-assist-efl"/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.584114942" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input"> + <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> + <additionalInput kind="additionalinput" paths="$(LIBS)"/> + </inputType> + </tool> + <tool command="i386-linux-gnueabi-as" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.1734736725" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1895818063" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + <tool id="org.tizen.nativecore.tool.sbi.po.compiler.739112606" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/> + <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.1268227980" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"/> + <tool id="org.tizen.nativecore.tool.fnmapgen.640573579" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/> + <tool id="org.tizen.nativecore.tool.fnmapgen.cpp.571122874" name="C++ FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen.cpp"/> + <tool id="org.tizen.nativecore.tool.ast.1123734156" name="C Static Analyzer" superClass="org.tizen.nativecore.tool.ast"/> + <tool id="org.tizen.nativecore.tool.ast.cpp.1196360898" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/> + </toolChain> + </folderInfo> + <sourceEntries> + <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/> + <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/> + </sourceEntries> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> + </cconfiguration> + <cconfiguration id="org.tizen.nativecore.config.sbi.gcc45.so.release.560919114"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.tizen.nativecore.config.sbi.gcc45.so.release.560919114" moduleId="org.eclipse.cdt.core.settings" name="Release"> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> + <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + </extensions> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <configuration artifactExtension="so" artifactName="ct-setting" buildArtefactType="org.tizen.nativecore.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.sharedLib" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.so.release.560919114" name="Release" parent="org.tizen.nativecore.config.sbi.gcc45.so.release"> + <folderInfo id="org.tizen.nativecore.config.sbi.gcc45.so.release.560919114." name="/" resourcePath=""> + <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.so.release.1293436351" name="Tizen Core Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.so.release"> + <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.1967541752" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/> + <builder buildPath="${workspace_loc:/ct-setting}/Release" id="org.tizen.nativecore.target.sbi.gnu.builder.1081567233" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/> + <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.64492552" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/> + <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.1462103696" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler"> + <option id="gnu.cpp.compiler.option.optimization.level.1687883989" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/> + <option id="sbi.gnu.cpp.compiler.option.debugging.level.core.876428297" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core"/> + <option defaultValue="true" id="sbi.gnu.cpp.compiler.option.misc.pic.core.259128710" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.cpp.compiler.option.51568983" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs"> + <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_llvm34.i386.core.sharedLib"/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.1459697128" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath"> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SDK_INSTALL_PATH}/library""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/EGL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/GLES""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/GLES2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/KHR""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.1147885256" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.core" valueType="stringList"> + <listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain ${SDK_INSTALL_PATH}/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.6/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/> + <listOptionValue builtIn="false" value=""/> + <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-fvisibility=hidden"/> + </option> + <option id="gnu.cpp.compiler.option.include.paths.2098780947" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks.core.1728404030" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + </option> + <inputType id="sbi.gnu.cpp.compiler.tizen.inputType.1839649671"/> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1723267715" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool command="clang" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.1894468425" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler"> + <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.option.optimization.level.952167404" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/> + <option id="sbi.gnu.c.compiler.option.debugging.level.core.1622361503" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core"/> + <option defaultValue="true" id="sbi.gnu.c.compiler.option.misc.pic.core.1648482383" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.c.compiler.option.270845060" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs"> + <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_llvm34.i386.core.sharedLib"/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.446336947" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath"> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SDK_INSTALL_PATH}/library""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/EGL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/GLES""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/GLES2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/KHR""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.1898775202" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.core" valueType="stringList"> + <listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain ${SDK_INSTALL_PATH}/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.6/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/> + <listOptionValue builtIn="false" value=""/> + <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-fvisibility=hidden"/> + </option> + <option id="gnu.c.compiler.option.include.paths.731244772" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks.core.1100295567" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + </option> + <inputType id="sbi.gnu.c.compiler.tizen.inputType.1409174559"/> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1615494092" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.1202400768" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/> + <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.2053832665" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker"> + <option defaultValue="true" id="sbi.gnu.cpp.linker.option.shared_flag.core.624040053" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" valueType="boolean"/> + <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.407154105" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList"> + <listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain ${SDK_INSTALL_PATH}/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.6/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Xlinker --as-needed"/> + <listOptionValue builtIn="false" value=""/> + <listOptionValue builtIn="false" value="-lpthread "/> + <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-L"${SBI_SYSROOT}/usr/lib""/> + <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/> + </option> + <option id="gnu.cpp.link.option.paths.302230002" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lib}""/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1904375475" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input"> + <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> + <additionalInput kind="additionalinput" paths="$(LIBS)"/> + </inputType> + </tool> + <tool command="i386-linux-gnueabi-as" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.2085383635" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.512673981" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + <tool id="org.tizen.nativecore.tool.sbi.po.compiler.1475490325" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/> + <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.685168164" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"/> + <tool id="org.tizen.nativecore.tool.fnmapgen.225303984" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/> + <tool id="org.tizen.nativecore.tool.fnmapgen.cpp.8703981" name="C++ FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen.cpp"/> + <tool id="org.tizen.nativecore.tool.ast.1265279676" name="C Static Analyzer" superClass="org.tizen.nativecore.tool.ast"/> + <tool id="org.tizen.nativecore.tool.ast.cpp.2058661368" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/> + </toolChain> + </folderInfo> + <sourceEntries> + <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/> + <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/> + </sourceEntries> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> + </cconfiguration> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <project id="ct-setting.org.tizen.nativecore.target.sbi.gcc45.so.402681284" name="Tizen Core Shared Library" projectType="org.tizen.nativecore.target.sbi.gcc45.so"/> + </storageModule> + <storageModule moduleId="scannerConfiguration"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + <scannerConfigBuildInfo instanceId="org.tizen.nativecore.config.sbi.gcc45.so.release.560919114"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.tizen.nativecommon.TizenGCCManagedMakePerProjectProfileCPP"/> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="org.tizen.nativecore.config.sbi.gcc45.so.debug.1583549422"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.tizen.nativecommon.TizenGCCManagedMakePerProjectProfileCPP"/> + </scannerConfigBuildInfo> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/> + <storageModule moduleId="org.tizen.tizen.nativeapp.projectInfo" version="1.0.0"/> + <storageModule moduleId="refreshScope" versionNumber="2"> + <configuration configurationName="Release"> + <resource resourceType="PROJECT" workspacePath="/ct-setting"/> + </configuration> + <configuration configurationName="Debug"> + <resource resourceType="PROJECT" workspacePath="/ct-setting"/> + </configuration> + </storageModule> +</cproject> diff --git a/lib-contact/ct-setting/.project b/lib-contact/ct-setting/.project new file mode 100644 index 0000000..1a2dce5 --- /dev/null +++ b/lib-contact/ct-setting/.project @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>ct-setting</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> + <triggers>full,incremental,</triggers> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.tizen.nativecore.apichecker.core.builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.cdt.core.cnature</nature> + <nature>org.eclipse.cdt.core.ccnature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> + <nature>org.tizen.nativecore.apichecker.core.tizenCppNature</nature> + </natures> + <filteredResources> + <filter> + <id>1413282553158</id> + <name></name> + <type>26</type> + <matcher> + <id>org.eclipse.ui.ide.multiFilter</id> + <arguments>1.0-projectRelativePath-matches-false-false-*/.tpk</arguments> + </matcher> + </filter> + </filteredResources> +</projectDescription> diff --git a/lib-contact/ct-setting/.tproject b/lib-contact/ct-setting/.tproject new file mode 100644 index 0000000..f1cc1fd --- /dev/null +++ b/lib-contact/ct-setting/.tproject @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<tproject xmlns="http://www.tizen.org/tproject"> + <platforms> + <platform> + <name>mobile-2.3</name> + </platform> + </platforms> + <package> + <blacklist/> + </package> +</tproject> diff --git a/lib-contact/ct-setting/CMakeLists.txt b/lib-contact/ct-setting/CMakeLists.txt new file mode 100755 index 0000000..09e84e1 --- /dev/null +++ b/lib-contact/ct-setting/CMakeLists.txt @@ -0,0 +1,24 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(ct-setting CXX) + +INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/app-assist-efl/inc + ${CMAKE_SOURCE_DIR}/lib-common/inc + ${CMAKE_SOURCE_DIR}/lib-contact/ct-common/inc + ${CMAKE_SOURCE_DIR}/lib-contact/ct-importer/inc + ${CMAKE_SOURCE_DIR}/lib-contact/ct-vcard/inc + ${CMAKE_CURRENT_SOURCE_DIR}/inc + ${CMAKE_CURRENT_SOURCE_DIR}/src +) + +FILE(GLOB SRCS "src/*.cpp") +ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${TIZEN_PKGS_LDFLAGS} + "app-assist-efl" + "contacts-common" + "ct-common" + "ct-importer" + "ct-vcard" +) + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_APP_LIB_DIR}) diff --git a/lib-contact/ct-setting/inc/CtSettingDataListener.h b/lib-contact/ct-setting/inc/CtSettingDataListener.h new file mode 100644 index 0000000..a5e447e --- /dev/null +++ b/lib-contact/ct-setting/inc/CtSettingDataListener.h @@ -0,0 +1,31 @@ +/*
+ * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+ +#ifndef _CT_SETTING_DATA_LISTENER_H_
+#define _CT_SETTING_DATA_LISTENER_H_
+ +class CtSettingDataListener
+{ +public: + virtual ~CtSettingDataListener(){WHIT();};
+
+ // this will be called only when send mode chaned..
+ virtual void onChanged() = 0;
+};
+ +#endif //_CT_SETTING_DATA_LISTENER_H_
+
diff --git a/lib-contact/ct-setting/inc/CtSettingView.h b/lib-contact/ct-setting/inc/CtSettingView.h new file mode 100644 index 0000000..1999d71 --- /dev/null +++ b/lib-contact/ct-setting/inc/CtSettingView.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_SETTING_VIEW_H_ +#define _CT_SETTING_VIEW_H_ + +#include <thread> +#include <string> +#include <vector> +#include <memory> +#include "WView.h" +#include "CtSettingDataListener.h" +#include "CtProgressBarPopup.h" + +class CtSettingData; + +class WAPP_ASSIST_EXPORT CtSettingView : public WView, public CtSettingDataListener +{ +public: + CtSettingView(); + virtual const char* getClassName(); + +private: + virtual Evas_Object* onCreate( Evas_Object* parent, void* viewParam); + virtual void onDestroy(); + virtual void onPushed(Elm_Object_Item* naviItem); + virtual void onEvent(int eventType); + + virtual void onChanged(); + + CtSettingData* __getSettingData(); + + static void __onDisplayNameByItemSelectedCb(void *data, Evas_Object *obj, void *event_info); + static void __onImportItemSelectedCb(void *data, Evas_Object *obj, void *event_info); + static void __onExportItemSelectedCb(void *data, Evas_Object *obj, void *event_info); + static void __onSortByItemSelectedCb(void *data, Evas_Object *obj, void *event_info); + + void __importFromStorage(bool phone, int abId); + + void __exportContactsTo(TargetStorage saveTo); + void __excuteContactExporter(TargetStorage saveTo, app_control_h request, app_control_h reply, app_control_result_e result, void *data); + void __createExportResultPopup(CtProgressController &controller); + void __excuteContactImporter(std::vector<std::string> vcards); + + static void __importFromStrorageReplyCb(app_control_h request, app_control_h reply, app_control_result_e result, void *data); + + +private: + WDECLARE_PRIVATE_IMPL(CtSettingView); + WDISABLE_COPY_AND_ASSIGN(CtSettingView); + + virtual ~CtSettingView(); + +private: + Evas_Object* __genlist; + CtSettingData* __settingData; + int __importAbId; + Ecore_Idler *__popupIdler; + Elm_Object_Item* __ctToDispItem; +}; + +#endif //_CT_SETTING_VIEW_H_ diff --git a/lib-contact/ct-setting/src/CtSettingData.cpp b/lib-contact/ct-setting/src/CtSettingData.cpp new file mode 100644 index 0000000..bcfae4f --- /dev/null +++ b/lib-contact/ct-setting/src/CtSettingData.cpp @@ -0,0 +1,412 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <algorithm> +#include <contacts.h> +#include <account.h> +#include <app_preference.h> +#include "ContactsDebug.h" +#include "CtSettingData.h" +#include "CtSettingDataListener.h" +#include "CtType.h" +#include "CtString.h" + +CtSettingData::AbInfo::AbInfo() +: abId(0) +, accountId(0) +, display(false) +{ + +} + +CtSettingData::SdnInfo::SdnInfo() +: simNum(0) +{ + +} + +CtSettingData::CtSettingData() +: __sortMode(SORT_MODE_FIRST_NAME) +, __nameOrder(NAME_ORDER_LAST_NAME_FIRST) +, __showMode(SHOW_MODE_ALL_CONTACTS) +, __sendMode(SEND_MODE_TOGETHER) +, __displayAll(false) +{ + WHIT(); +} + +CtSettingData::~CtSettingData() +{ + WHIT(); +} + +void CtSettingData::init() +{ + // Load data from preference + + int showMode = 0; + preference_get_int(CT_KEY_DISPLAY_WITH_NUMBER, &showMode); + if (showMode == 0) + __showMode = SHOW_MODE_ALL_CONTACTS; + else + __showMode = SHOW_MODE_CONTACTS_WITH_PHONES; + + contacts_name_sorting_order_e sortOrder = CONTACTS_NAME_SORTING_ORDER_FIRSTLAST; + contacts_setting_get_name_sorting_order(&sortOrder); + if (sortOrder == CONTACTS_NAME_SORTING_ORDER_FIRSTLAST) + __sortMode = SORT_MODE_FIRST_NAME; + else + __sortMode = SORT_MODE_LAST_NAME; + + contacts_name_display_order_e displayOrder = CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST; + contacts_setting_get_name_display_order(&displayOrder); + if (displayOrder == CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST) + __nameOrder = NAME_ORDER_FIRST_NAME_FIRST; + else + __nameOrder = NAME_ORDER_LAST_NAME_FIRST; + + int sendMode = 0; + preference_get_int(CT_KEY_SETTING_CONTACT_SHARING_SETTINGS, &sendMode); + if (sendMode == 0) + __sendMode = SEND_MODE_TOGETHER; + else + __sendMode = SEND_MODE_INDIVIDUALLY; + + __initAddressbookInfo(); +} + +void CtSettingData::addListener(CtSettingDataListener* listener) +{ + __listeners.push_back(listener); +} + +void CtSettingData::__notify() +{ + for (auto iter = __listeners.begin(); iter != __listeners.end(); iter++) + { + if(*iter) { + (*iter)->onChanged(); + } + } +} +void CtSettingData::__initAddressbookInfo() +{ + contacts_list_h abList = NULL; + contacts_record_h addressbook = NULL; + char* abName = NULL; + int abId = 0; + int accountId = 0; + std::vector<int> displayAbId; + bool displayAll = false; + int mode = 0; + char *str = NULL; + + preference_get_string(CT_KEY_LIST_DISPLAY_ADDRESSBOOK, &str); + + WDEBUG("display addressbook %s", str); + + if (SAFE_STRLEN(str) == 0) + { + __displayAll = true; + displayAll = true; + } + else + { + WDEBUG("ab: %s", str); + char* ptr = NULL; + char* token = strtok_r(str, ";", &ptr); + while (token) + { + displayAbId.push_back(atoi(token)); + + token = strtok_r(NULL, ";", &ptr); + } + + + } + free(str); + str = NULL; + + int ret = contacts_db_get_all_records(_contacts_address_book._uri, 0, 0, &abList); + if(ret != CONTACTS_ERROR_NONE) + { + WWARNING("contacts_db_get_all_records failed"); + if(abList) + contacts_list_destroy(abList, true); + return; + } + int count = 0; + contacts_list_get_count(abList, &count); + if (count <= 0){ + if(abList) + contacts_list_destroy(abList, true); + return; + } + for (int i = 0; i < count; i++) + { + ret = contacts_list_get_current_record_p(abList, &addressbook); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_list_get_current_record_p() Failed(%d)", ret); + + ret = contacts_record_get_int(addressbook, _contacts_address_book.id, &abId); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_int() Failed(%d)", ret); + ret = contacts_record_get_int(addressbook, _contacts_address_book.account_id, &accountId); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_int() Failed(%d)", ret); + ret = contacts_record_get_int(addressbook, _contacts_address_book.mode, &mode); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_int() Failed(%d)", ret); + ret = contacts_record_get_str_p(addressbook, _contacts_address_book.name, &abName); + WPWARN(CONTACTS_ERROR_NONE != ret, "contacts_record_get_str_p() Failed(%d)", ret); + + WDEBUG("adId %d, name %s", abId, abName); + + AbInfo info; + info.abId = abId; + info.accountId = accountId; + info.mode = mode; + if (abName) + info.abName = abName; + + if (displayAll) + info.display = true; + else if (std::find(displayAbId.begin(), displayAbId.end(), info.abId) != displayAbId.end()) + { + info.display = true; + } + else + { + info.display = false; + } + + if (accountId > 0) + { + account_h account = NULL; + account_create(&account); + char* str = NULL; + + account_query_account_by_account_id(accountId, &account); + if (account) + { + char* appId = NULL; + account_get_user_name(account, &str); + if (str) + { + info.user = str; + free(str); + str = NULL; + } + + account_get_package_name(account, &appId); + account_type_query_label_by_app_id([](char* app_id, char* label, char* locale, void* user_data)->bool{ + AbInfo* pInfo = static_cast<AbInfo*>(user_data); + if(strcmp(locale,"default") == 0){ + pInfo->name = label; + return false; + } + + return true; + }, appId, &info); + + if (info.name.empty()) + { + account_get_domain_name(account, &str); + if (str) + { + info.name = str; + free(str); + } + } + + account_destroy(account); + } + + if(!strcmp(info.name.c_str(), CT_EAS_ADDRESSBOOK_NAME)) { + info.name.clear(); + info.name = CT_EAS_ADDRESSBOOK_DISPLAY_NAME; + info.user.clear(); + info.user = abName; + } + + __abInfo.push_back(info); + } + + contacts_list_next(abList); + + WDEBUG("name:%s, user:%s", info.name.c_str(), info.user.c_str()); + } + + contacts_list_destroy(abList, true); +} + +CtSettingData::SortMode CtSettingData::getSortMode() const +{ + return __sortMode; +} + +void CtSettingData::setSortMode(SortMode sortMode) +{ + if (sortMode == SORT_MODE_FIRST_NAME) + contacts_setting_set_name_sorting_order(CONTACTS_NAME_SORTING_ORDER_FIRSTLAST); + else + contacts_setting_set_name_sorting_order(CONTACTS_NAME_SORTING_ORDER_LASTFIRST); + + __sortMode = sortMode; +} + +CtSettingData::NameOrder CtSettingData::getNameOrder() const +{ + return __nameOrder; +} + +void CtSettingData::setNameOrder(NameOrder nameOrder) +{ + if (nameOrder == NAME_ORDER_FIRST_NAME_FIRST) + contacts_setting_set_name_display_order(CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST); + else + contacts_setting_set_name_display_order(CONTACTS_NAME_DISPLAY_ORDER_LASTFIRST); + + __nameOrder = nameOrder; +} + +CtSettingData::ShowMode CtSettingData::getShowMode() const +{ + return __showMode; +} + +void CtSettingData::setShowMode(ShowMode showMode) +{ + if (showMode == SHOW_MODE_CONTACTS_WITH_PHONES) + preference_set_int(CT_KEY_DISPLAY_WITH_NUMBER, 1); + else + preference_set_int(CT_KEY_DISPLAY_WITH_NUMBER, 0); + + __showMode = showMode; +} + +CtSettingData::SendMode CtSettingData::getSendMode() const +{ + return __sendMode; +} + +void CtSettingData::setSendMode(SendMode mode) +{ + __sendMode = mode; + + if (__sendMode == SEND_MODE_TOGETHER) { + preference_set_int(CT_KEY_SETTING_CONTACT_SHARING_SETTINGS, 0); + } else { + preference_set_int(CT_KEY_SETTING_CONTACT_SHARING_SETTINGS, 1); + } + + __notify(); +} + +const std::list<CtSettingData::AbInfo>& CtSettingData::getAbInfo() const +{ + return __abInfo; +} + +void CtSettingData::setAbInfo(const std::list<CtSettingData::AbInfo>& abInfo) +{ + WHIT(); + __abInfo = abInfo; + + char buf[256]={0,}; + int len = 0; + bool displayAll = true; + + for (auto iter = __abInfo.begin(); iter != __abInfo.end(); ++iter) + { + if (iter->display) + { + if (len > 0) + len += snprintf(buf + len, sizeof(buf) - len, ";%d", iter->abId); + else + len += snprintf(buf + len, sizeof(buf) - len, "%d", iter->abId); + } + else + { + displayAll = false; + } + } + + WDEBUG("abInfo %s", buf); + + if (displayAll) + { + __displayAll = true; + preference_set_string(CT_KEY_LIST_DISPLAY_ADDRESSBOOK, ""); + } + else + { + __displayAll = false; + preference_set_string(CT_KEY_LIST_DISPLAY_ADDRESSBOOK, buf); + } +} + +int CtSettingData::getAbCount() const +{ + return __abInfo.size(); +} + +bool CtSettingData::isDisplayAll() const +{ + return __displayAll; +} + +const std::list<CtSettingData::SdnInfo>& CtSettingData::getSdnInfoList() +{ + WHIT(); + if (__sdnInfo.size() == 0) + { + contacts_list_h sdnList = NULL; + contacts_record_h sdnRecord = NULL; + char* strValue = NULL; + int intValue = 0; + int err = CONTACTS_ERROR_NONE; + + err = contacts_db_get_all_records(_contacts_sdn._uri, 0, 0, &sdnList); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_db_get_all_records() Failed(%d)", err); + + while (CONTACTS_ERROR_NONE == contacts_list_get_current_record_p(sdnList, &sdnRecord)) + { + SdnInfo sdnInfo; + + err = contacts_record_get_str_p(sdnRecord, _contacts_sdn.name, &strValue); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + if (strValue) + sdnInfo.name = strValue; + + err = contacts_record_get_str_p(sdnRecord, _contacts_sdn.number, &strValue); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err); + if (strValue) + sdnInfo.number = strValue; + + err = contacts_record_get_int(sdnRecord, _contacts_sdn.sim_slot_no, &intValue); + WPWARN(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err); + sdnInfo.simNum = intValue; + + __sdnInfo.push_back(sdnInfo); + + contacts_list_next(sdnList); + } + + contacts_list_destroy(sdnList, true); + } + + WDEBUG("count:%d", __sdnInfo.size()); + + return __sdnInfo; +} diff --git a/lib-contact/ct-setting/src/CtSettingData.h b/lib-contact/ct-setting/src/CtSettingData.h new file mode 100644 index 0000000..5e1a4a5 --- /dev/null +++ b/lib-contact/ct-setting/src/CtSettingData.h @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_SETTING_DATA_H_ +#define _CT_SETTING_DATA_H_ +#include <string> +#include <vector> +#include <list> + +class CtSettingDataListener; + +class CtSettingData +{ +public: + CtSettingData(); + ~CtSettingData(); + void init(); + + void addListener(CtSettingDataListener* listener); + + enum SortMode + { + SORT_MODE_FIRST_NAME, + SORT_MODE_LAST_NAME, + }; + + enum NameOrder + { + NAME_ORDER_FIRST_NAME_FIRST, + NAME_ORDER_LAST_NAME_FIRST, + }; + + enum ShowMode + { + SHOW_MODE_CONTACTS_WITH_PHONES, + SHOW_MODE_ALL_CONTACTS, + }; + + enum SendMode + { + SEND_MODE_TOGETHER, + SEND_MODE_INDIVIDUALLY, + }; + + struct AbInfo + { + AbInfo(); + int abId; + int accountId; + bool display; + int mode; + std::string abName; + std::string name; + std::string user; + }; + + struct SdnInfo + { + SdnInfo(); + int simNum; + std::string name; + std::string number; + }; + + SortMode getSortMode() const; + void setSortMode(SortMode sortMode); + + NameOrder getNameOrder() const; + void setNameOrder(NameOrder order); + + ShowMode getShowMode() const; + void setShowMode(ShowMode mode); + + SendMode getSendMode() const; + void setSendMode(SendMode mode); + + const std::list<AbInfo>& getAbInfo() const; + void setAbInfo(const std::list<AbInfo>& abInfo); + + int getAbCount() const; + + bool isDisplayAll() const; + + const std::list<SdnInfo>& getSdnInfoList(); + +private: + void __initAddressbookInfo(); + void __notify(); + +private: + SortMode __sortMode; + NameOrder __nameOrder; + ShowMode __showMode; + SendMode __sendMode; + std::list<AbInfo> __abInfo; + std::list<SdnInfo> __sdnInfo; + std::list<CtSettingDataListener*> __listeners; + bool __displayAll; +}; + +#endif //_CT_SETTING_DATA_H_ diff --git a/lib-contact/ct-setting/src/CtSettingPopup.cpp b/lib-contact/ct-setting/src/CtSettingPopup.cpp new file mode 100644 index 0000000..a1dca2a --- /dev/null +++ b/lib-contact/ct-setting/src/CtSettingPopup.cpp @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "CtString.h" +#include "ContactsDebug.h" +#include "CtSettingPopup.h" + + +CtSettingPopup::__ItemData::__ItemData() : + target(TargetStorage::DEVICE), + iconType(0) +{ + +} + +CtSettingPopup::CtSettingPopup(CtSettingData* settingData, const char* popupTitle) : + __settingData(settingData), + __popupTitle(popupTitle), + __resultCb(NULL), + __genlist(NULL), + __externalStorageId(0) +{ +} + +bool CtSettingPopup::getSupportedStoragesCallback(int storageId, storage_type_e type, storage_state_e state, const char *path, void *userData) +{ + WENTER(); + WPRET_VM(userData == NULL, false, "User data == NULL"); + + if (type == STORAGE_TYPE_EXTERNAL) + { + CtSettingPopup* settigPopup = static_cast<CtSettingPopup*>(userData); + settigPopup->__externalStorageId = storageId; + return false; + } + + return true; +} + +Evas_Object* CtSettingPopup::__createContent(Evas_Object *parent) +{ + // genlist class + Elm_Genlist_Item_Class* itc = elm_genlist_item_class_new(); + WPRET_VM(!itc, NULL, "elm_genlist_item_class_new() failed"); + itc->item_style = "type1"; + itc->func.text_get = [](void* data, Evas_Object* obj, const char* part)->char* + { + __ItemData* itemData = static_cast<__ItemData*>(data); + if(!strcmp(part, "elm.text")) { + return strdup(itemData->label.c_str()); + } + + return NULL; + }; + + itc->func.del = [](void* data, Evas_Object* obj) + { + __ItemData* itemData = static_cast<__ItemData*>(data); + delete itemData; + }; + + __genlist = elm_genlist_add(parent); + elm_object_style_set( __genlist, "popup" ); + elm_genlist_homogeneous_set(__genlist, EINA_TRUE); + elm_genlist_mode_set( __genlist, ELM_LIST_COMPRESS ); + elm_scroller_content_min_limit( __genlist, EINA_FALSE, EINA_TRUE ); // Automatically pop-up height is calculated + + elm_object_content_set(parent, __genlist); + + int itemCount = 0; + __ItemData* itemData = NULL; + + int error = storage_foreach_device_supported(getSupportedStoragesCallback, this); + + if (error == STORAGE_ERROR_NONE) + { + storage_state_e state; + storage_get_state(__externalStorageId, &state); + + if (state == STORAGE_STATE_MOUNTED) + { + itemData = new __ItemData(); + itemData->label = V_("IDS_PB_OPT_SD_CARD"); + itemData->target = TargetStorage::SD_CARD; + elm_genlist_item_append(__genlist, itc, itemData, NULL, ELM_GENLIST_ITEM_NONE, __onItemSelected, this); + itemCount++; + } + } + + itemData = new __ItemData(); + itemData->label = V_("IDS_PB_OPT_DEVICE"); + itemData->target = TargetStorage::DEVICE; + elm_genlist_item_append(__genlist, itc, itemData, NULL, ELM_GENLIST_ITEM_NONE, __onItemSelected, this); + itemCount++; + + elm_genlist_item_class_free(itc); + + evas_object_show(__genlist); + + return __genlist; + +} + +void CtSettingPopup::setOnResultCb(std::function<void (TargetStorage)> resultCb) +{ + __resultCb = resultCb; +} + +Evas_Object* CtSettingPopup::onCreate( Evas_Object* parent, void* viewParam) +{ + WHIT(); + + setTitle(__popupTitle.c_str()); + + setContent([this](Evas_Object* parent)->Evas_Object* { + return __createContent(parent); + }); + + return WPopup::onCreate(parent, viewParam); +} + +void CtSettingPopup::__onItemSelected(void* data, Evas_Object* obj, void* event_info) +{ + Elm_Object_Item *item = (Elm_Object_Item *)event_info; + __ItemData* itemData = (__ItemData*)elm_object_item_data_get(item); + + CtSettingPopup* popup = static_cast<CtSettingPopup*>(data); + if( popup->__resultCb) { + popup->__resultCb(itemData->target); + } +} diff --git a/lib-contact/ct-setting/src/CtSettingPopup.h b/lib-contact/ct-setting/src/CtSettingPopup.h new file mode 100644 index 0000000..ed0b583 --- /dev/null +++ b/lib-contact/ct-setting/src/CtSettingPopup.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_SETTING_POPUP_H_ +#define _CT_SETTING_POPUP_H_ + +#include <string> +#include <storage.h> +#include <functional> + +#include "CtSettingData.h" +#include "CtVcardCommon.h" +#include "WPopup.h" + +class CtSettingPopup : public WPopup +{ +public: + + CtSettingPopup(CtSettingData* settingData, const char* popupTitle); + +private: + virtual Evas_Object* onCreate( Evas_Object* parent, void* viewParam); + + Evas_Object* __createContent(Evas_Object *parent); + + static void __onItemSelected(void* data, Evas_Object* obj, void* event_info); + +public: + void setOnResultCb(std::function<void (TargetStorage)> resultCb); + +private: + struct __ItemData + { + __ItemData(); + TargetStorage target; + std::string label; + std::string subLabel; + int iconType; + }; + + static bool getSupportedStoragesCallback(int storageId, storage_type_e type, storage_state_e state, const char *path, void *userData); + + CtSettingData* __settingData; + std::string __popupTitle; + std::function<void (TargetStorage)> __resultCb; + Evas_Object* __genlist; + int __externalStorageId; +}; + +#endif //_CT_SETTING_POPUP_H_ diff --git a/lib-contact/ct-setting/src/CtSettingRadioPopup.cpp b/lib-contact/ct-setting/src/CtSettingRadioPopup.cpp new file mode 100644 index 0000000..2b6ede6 --- /dev/null +++ b/lib-contact/ct-setting/src/CtSettingRadioPopup.cpp @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +//#include <efl_assist.h> + +#include "ContactsCommon.h" +#include "ContactsDebug.h" +#include "CtSettingRadioPopup.h" +#include "CtString.h" + + +CtSettingRadioPopup::__ItemData::__ItemData() +: index(0) +{ + +} + +CtSettingRadioPopup::CtSettingRadioPopup(const std::vector<std::string>& label, int selectedIndex) +: __label(label) +, __selectedIndex(selectedIndex) +, __resultCb(NULL) +{ + +} +CtSettingRadioPopup::~CtSettingRadioPopup() +{ + +} + +Evas_Object* CtSettingRadioPopup::onCreate( Evas_Object* parent, void* viewParam) +{ + WHIT(); + + setContent([this](Evas_Object* parent)->Evas_Object* { + return __createContent(parent); + }); + + return WPopup::onCreate(parent, viewParam); +} + +void CtSettingRadioPopup::onDestroy() +{ + +} + + +void CtSettingRadioPopup::setOnResultCb( std::function<void (int)> resultCb ) +{ + __resultCb = resultCb; +} + +void CtSettingRadioPopup::__itemSelectedCb(void* data, Evas_Object* obj, void* event_info) +{ + CtSettingRadioPopup* popup = static_cast<CtSettingRadioPopup*>(data); + Elm_Object_Item *item = (Elm_Object_Item *) event_info; + int index = elm_genlist_item_index_get( item ) - 1; // genlist item index is starting from 1! + popup->__selectedIndex = index; + if( popup->__resultCb) + popup->__resultCb(index); +} + + +Evas_Object* CtSettingRadioPopup::__createContent(Evas_Object *parent) +{ + // genlist class + Elm_Genlist_Item_Class* itc = elm_genlist_item_class_new(); + WPRET_VM(!itc, NULL, "elm_genlist_item_class_new() failed"); + itc->item_style = "type1"; + itc->func.text_get = [](void* data, Evas_Object* obj, const char* part)->char* + { + __ItemData* itemData = static_cast<__ItemData*>(data); + if(!strcmp(part, "elm.text")) { + return strdup(itemData->label.c_str()); + } + + return NULL; + }; + + itc->func.content_get = [](void* data, Evas_Object* obj, const char* part)->Evas_Object* + { + if(!strcmp(part, "elm.swallow.end")) { + __ItemData* itemData = static_cast<__ItemData*>(data); + Evas_Object* radio = elm_radio_add(obj); + Evas_Object *radioGroup = (Evas_Object*)evas_object_data_get(obj, "radioGroup"); + + elm_object_style_set(radio, "list"); + elm_radio_state_value_set(radio, itemData->index); + elm_radio_group_add(radio, radioGroup); + + evas_object_size_hint_weight_set(radio, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(radio, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_propagate_events_set(radio, EINA_TRUE); + + if (itemData->popup->__selectedIndex == itemData->index) { + elm_radio_value_set(radio, itemData->index); + } + return radio; + } + + return NULL; + }; + itc->func.del = [](void* data, Evas_Object* obj) + { + __ItemData* itemData = static_cast<__ItemData*>(data); + delete itemData; + }; + + Evas_Object* genlist = elm_genlist_add(parent); + elm_genlist_homogeneous_set(genlist, EINA_TRUE); + elm_genlist_mode_set( genlist, ELM_LIST_COMPRESS ); + elm_scroller_content_min_limit( genlist, EINA_FALSE, EINA_TRUE ); // Automatically pop-up height is calculated + + Evas_Object* radioGroup = elm_radio_add(genlist); + elm_object_style_set(radioGroup, "list"); + elm_radio_state_value_set(radioGroup, -1); + evas_object_data_set(genlist, "radioGroup", radioGroup); + + elm_object_content_set(parent, genlist); + + int index = 0; + for (auto iter = __label.begin(); iter != __label.end(); ++iter) + { + __ItemData* itemData = new __ItemData(); + itemData->label = *iter; + itemData->popup = this; + itemData->index = index++; + elm_genlist_item_append(genlist, itc, itemData, NULL, ELM_GENLIST_ITEM_NONE, __itemSelectedCb, this); + } + + elm_genlist_item_class_free(itc); + + evas_object_show(genlist); + + return genlist; +} + + diff --git a/lib-contact/ct-setting/src/CtSettingRadioPopup.h b/lib-contact/ct-setting/src/CtSettingRadioPopup.h new file mode 100644 index 0000000..0d00d4c --- /dev/null +++ b/lib-contact/ct-setting/src/CtSettingRadioPopup.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_SETTING_RADIO_POPUP_H_ +#define _CT_SETTING_RADIO_POPUP_H_ + +#include "WPopup.h" +#include <string> +#include <vector> +#include <functional> + +class CtSettingRadioPopup : public WPopup +{ +public: + CtSettingRadioPopup(const std::vector<std::string>& label, int selectedIndex); + void setOnResultCb(std::function<void (int)> resultCb); + +private: + virtual Evas_Object* onCreate( Evas_Object* parent, void* viewParam); + virtual void onDestroy(); + Evas_Object* __createContent(Evas_Object *parent); + static void __itemSelectedCb(void* data, Evas_Object* obj, void* event_info); + +private: + virtual ~CtSettingRadioPopup(); + +private: + struct __ItemData + { + __ItemData(); + CtSettingRadioPopup* popup; + std::string label; + int index; + }; + +private: + std::vector<std::string> __label; + int __selectedIndex; + std::function<void (int)> __resultCb; +}; + + +#endif //_CT_SETTING_RADIO_POPUP_H_ diff --git a/lib-contact/ct-setting/src/CtSettingView.cpp b/lib-contact/ct-setting/src/CtSettingView.cpp new file mode 100644 index 0000000..bc846cb --- /dev/null +++ b/lib-contact/ct-setting/src/CtSettingView.cpp @@ -0,0 +1,503 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <map> +#include <string> +#include <vector> + +#include <app.h> +#include <contacts.h> +#include <notification.h> + +#include "WNaviframe.h" +#include "WWindow.h" +#include "WPopup.h" +#include "WToastPopup.h" +#include "WGenlistItem.h" +#include "ContactsDebug.h" +#include "CtType.h" +#include "ContactsAppControlLauncher.h" +#include "ContactsAppControl.h" + +#include "CtContactsToVcard.h" +#include "CtString.h" +#include "CtSettingData.h" +#include "CtSettingView.h" +#include "CtSettingRadioPopup.h" +#include "CtSettingPopup.h" +#include "CtImporter.h" + +#define MYFILE_UG "ug-myfile-efl" + +class __SortByItem: public WGenlistItem +{ +public: + __SortByItem( CtSettingData* data ) { __data = data; } + virtual ~__SortByItem(){} +public: + virtual Elm_Genlist_Item_Class* getItemClassNew() { + Elm_Genlist_Item_Class* itc = elm_genlist_item_class_new(); + WPRET_VM(!itc, NULL, "elm_genlist_item_class_new() failed"); + itc->item_style = "type1"; + itc->func.text_get = [](void* data, Evas_Object* obj, const char* part)->char* + { + __SortByItem* p = static_cast<__SortByItem*>(data); + + if(!strcmp(part, "elm.text")) { + return strdup(V_("IDS_PB_MBODY_SORT_BY")); + } + else if(!strcmp(part, "elm.text.sub")){ + if ( p->__data->getSortMode() == CtSettingData::SORT_MODE_FIRST_NAME) + return strdup(V_("IDS_PB_OPT_FIRST_NAME")); + else + return strdup(V_("IDS_PB_BODY_LAST_NAME_ABB")); + } + return NULL; + }; + itc->func.del = WGENLIST_ITEM_DEL(); + return itc; + } +private: + __SortByItem(); + CtSettingData* __data; +}; + +class __DisplayNameByItem: public WGenlistItem +{ +public: + __DisplayNameByItem( CtSettingData* data ) { __data = data; } + virtual ~__DisplayNameByItem(){} +public: + virtual Elm_Genlist_Item_Class* getItemClassNew() { + Elm_Genlist_Item_Class* itc = elm_genlist_item_class_new(); + WPRET_VM(!itc, NULL, "elm_genlist_item_class_new() failed"); + itc->item_style = "type1"; + itc->func.text_get = __getText; + itc->func.del = WGENLIST_ITEM_DEL(); + return itc; + } +private: + static char* __getText(void* data, Evas_Object* obj, const char* part ) { + __DisplayNameByItem* p = static_cast<__DisplayNameByItem*>(data); + if(!strcmp(part, "elm.text")) { + return strdup(V_("IDS_PB_TMBODY_NAME_FORMAT")); + } + else if(!strcmp(part, "elm.text.sub")) { + if ( p->__data->getNameOrder() == CtSettingData::NAME_ORDER_FIRST_NAME_FIRST) + return strdup(V_("IDS_PB_OPT_FIRST_NAME_FIRST_ABB")); + else + return strdup(V_("IDS_PB_OPT_LAST_NAME_FIRST_ABB")); + } + return NULL; + } +private: + __DisplayNameByItem(); + CtSettingData* __data; +}; + +class __ImportItem : public WGenlistItem +{ +public: + __ImportItem(){} + virtual ~__ImportItem(){} +public: + virtual Elm_Genlist_Item_Class* getItemClassNew() { + Elm_Genlist_Item_Class* itc = elm_genlist_item_class_new(); + WPRET_VM(!itc, NULL, "elm_genlist_item_class_new() failed"); + itc->item_style = "type1"; + itc->func.text_get = [](void* data, Evas_Object* obj, const char* part)->char* { + if(!strcmp(part, "elm.text")) { + return strdup(V_("IDS_PB_MBODY_IMPORT")); + } + return NULL; + }; + itc->func.del = WGENLIST_ITEM_DEL(); + return itc; + } +}; + +class __ExportItem : public WGenlistItem +{ +public: + __ExportItem() {} + virtual ~__ExportItem(){} +public: + virtual Elm_Genlist_Item_Class* getItemClassNew() { + Elm_Genlist_Item_Class* itc = elm_genlist_item_class_new(); + WPRET_VM(!itc, NULL, "elm_genlist_item_class_new() failed"); + itc->item_style = "type1"; + itc->func.text_get = [](void* data, Evas_Object* obj, const char* part)->char* { + if(!strcmp(part, "elm.text")) { + return strdup(V_("IDS_PB_MBODY_EXPORT")); + } + return NULL; + }; + itc->func.del = WGENLIST_ITEM_DEL(); + return itc; + } +}; + +class __SendContactInformationItem: public WGenlistItem +{ +public: + __SendContactInformationItem( CtSettingData* data ) { __data = data; } + virtual ~__SendContactInformationItem(){} +public: + virtual Elm_Genlist_Item_Class* getItemClassNew() { + Elm_Genlist_Item_Class* itc = elm_genlist_item_class_new(); + WPRET_VM(!itc, NULL, "elm_genlist_item_class_new() failed"); + itc->item_style = "type1"; + itc->func.text_get = __getText; + itc->func.del = WGENLIST_ITEM_DEL(); + return itc; + } +private: + static char* __getText( void* data, Evas_Object* obj, const char* part ) { + __SendContactInformationItem* p = static_cast<__SendContactInformationItem*>(data); + if(!strcmp(part, "elm.text")) { + return strdup(V_("IDS_PB_MBODY_SEND_CONTACT_INFORMATION_ABB")); + } + else if(!strcmp(part, "elm.text.sub")) { + if ( p->__data->getSendMode() == CtSettingData::SEND_MODE_TOGETHER) + return strdup(V_("IDS_PB_MBODY_SEND_TOGETHER_ABB")); + else + return strdup(V_("IDS_PB_MBODY_SEND_INDIVIDUALLY_ABB")); + } + + return NULL; + } +private: + __SendContactInformationItem(); + CtSettingData* __data; +}; + +CtSettingView::CtSettingView() +: __genlist(NULL) +, __settingData(NULL) +, __importAbId(0) +, __popupIdler(NULL) +, __ctToDispItem(NULL) +{ + WHIT(); +} + +CtSettingView::~CtSettingView() +{ + WHIT(); + + ContactsAppControlLauncher::getInstance().terminate(); + if(__popupIdler) + ecore_idler_del(__popupIdler); + + delete __settingData; +} + +const char* CtSettingView::getClassName() +{ + return "CtSettingView"; + + +} + +Evas_Object* CtSettingView::onCreate( Evas_Object* parent, void* viewParam) +{ + WHIT(); + + setTitle(V_("IDS_PB_HEADER_SETTINGS")); + + __settingData = new CtSettingData(); + __settingData->init(); + __settingData->addListener(this); + + Evas_Object* layout = elm_layout_add(parent); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_layout_theme_set(layout, "layout", "application", "default"); + + __genlist = elm_genlist_add(parent); + if (__genlist == NULL) { + WERROR("elm_genlist_add failed"); + return NULL; + } + + elm_genlist_mode_set(__genlist, ELM_LIST_COMPRESS); + elm_genlist_homogeneous_set(__genlist, EINA_TRUE); + elm_object_part_content_set(layout, "elm.swallow.content", __genlist); + evas_object_show(layout); + + Elm_Genlist_Item_Class* itc = NULL; + WGenlistItem* item = NULL; + + item = new __SortByItem(__getSettingData() ); + item->setElmObjectItem( elm_genlist_item_append(__genlist, itc = item->getItemClassNew(), item, NULL, ELM_GENLIST_ITEM_NONE, __onSortByItemSelectedCb, this) ); + elm_genlist_item_class_free(itc); + + item = new __DisplayNameByItem(__getSettingData() ); + item->setElmObjectItem( elm_genlist_item_append(__genlist, itc = item->getItemClassNew(), item, NULL, ELM_GENLIST_ITEM_NONE, __onDisplayNameByItemSelectedCb, this)); + elm_genlist_item_class_free(itc); + + item = new __ImportItem(); + item->setElmObjectItem( elm_genlist_item_append(__genlist, itc = item->getItemClassNew(), item, NULL, ELM_GENLIST_ITEM_NONE, __onImportItemSelectedCb, this)); + elm_genlist_item_class_free(itc); + + item = new __ExportItem(); + item->setElmObjectItem( elm_genlist_item_append(__genlist, itc = item->getItemClassNew(), item, NULL, ELM_GENLIST_ITEM_NONE, __onExportItemSelectedCb, this)); + elm_genlist_item_class_free(itc); + + return layout; +} + +void CtSettingView::onDestroy() +{ + WHIT(); + destroyPopup(); + ContactsAppControlLauncher::getInstance().terminate(); +} + +CtSettingData* CtSettingView::__getSettingData() +{ + return __settingData; +} + +void CtSettingView::onPushed(Elm_Object_Item* naviItem) +{ + WHIT(); + + elm_naviframe_item_title_enabled_set(naviItem, EINA_TRUE, EINA_TRUE); +} + +void CtSettingView::onEvent(int eventType) +{ + elm_genlist_realized_items_update(__genlist); +} + +void CtSettingView::__onSortByItemSelectedCb(void *data, Evas_Object *obj, void *event_info) +{ + elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); + CtSettingView* p = static_cast<CtSettingView*>(data); + CtSettingData::SortMode sortMode = p->__getSettingData()->getSortMode(); + + std::vector<std::string> label = {V_("IDS_PB_OPT_FIRST_NAME"), V_("IDS_PB_BODY_LAST_NAME_ABB")}; + + Elm_Object_Item* objItem = (Elm_Object_Item *)event_info; + CtSettingData* settingData = p->__getSettingData(); + + CtSettingRadioPopup* popup = new CtSettingRadioPopup(label, sortMode == CtSettingData::SORT_MODE_FIRST_NAME ? 0 : 1); + popup->setTextTranslatable(PACKAGE); + popup->setTitle( "IDS_PB_MBODY_SORT_BY"); + popup->setOnResultCb([popup,objItem, settingData](int index){ + WDEBUG("item %d selected", index); + if (index == 0) + settingData->setSortMode(CtSettingData::SORT_MODE_FIRST_NAME); + else + settingData->setSortMode(CtSettingData::SORT_MODE_LAST_NAME); + + elm_genlist_item_fields_update( objItem, "elm.text.sub", ELM_GENLIST_ITEM_FIELD_TEXT); + popup->destroy(); + }); + p->attachPopup( popup ); +} + +void CtSettingView::__onDisplayNameByItemSelectedCb(void *data, Evas_Object *obj, void *event_info) +{ + elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); + CtSettingView* p = static_cast<CtSettingView*>(data); + CtSettingData::NameOrder nameOrder = p->__getSettingData()->getNameOrder(); + + std::vector<std::string> label = {V_("IDS_PB_OPT_FIRST_NAME_FIRST_ABB"), V_("IDS_PB_OPT_LAST_NAME_FIRST_ABB")}; + Elm_Object_Item* objItem = (Elm_Object_Item *)event_info; + CtSettingData* settingData = p->__getSettingData(); + + CtSettingRadioPopup* popup = new CtSettingRadioPopup(label, nameOrder == CtSettingData::NAME_ORDER_FIRST_NAME_FIRST ? 0 : 1); + popup->setTextTranslatable(PACKAGE); + popup->setTitle( "IDS_PB_TMBODY_NAME_FORMAT"); + popup->setOnResultCb([popup,objItem, settingData](int index){ + WDEBUG("item %d selected", index); + if (index == 0) + settingData->setNameOrder(CtSettingData::NAME_ORDER_FIRST_NAME_FIRST); + else + settingData->setNameOrder(CtSettingData::NAME_ORDER_LAST_NAME_FIRST); + + elm_genlist_item_fields_update(objItem, "elm.text.sub", ELM_GENLIST_ITEM_FIELD_TEXT); + popup->destroy(); + }); + p->attachPopup( popup ); +} + +void CtSettingView::__onImportItemSelectedCb(void *data, Evas_Object *obj, void *event_info) +{ + const int deviceAbId = 0; + elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); + CtSettingView* view = static_cast<CtSettingView*>(data); + + view->__importFromStorage(true, deviceAbId); +} + +void CtSettingView::__onExportItemSelectedCb(void *data, Evas_Object *obj, void *event_info) +{ + elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); + CtSettingView* p = static_cast<CtSettingView*>(data); + + p->__exportContactsTo(TargetStorage::DEVICE); +} + +void CtSettingView::__importFromStorage(bool phone, int abId) +{ + WHIT(); + __importAbId = abId; + + app_control_h service; + + app_control_create(&service); + if (phone) + app_control_add_extra_data(service, "path", "/opt/usr/media"); + else + app_control_add_extra_data(service, "path", "/opt/storage/sdcard"); + + app_control_add_extra_data(service, "select_type", "IMPORT_PATH_SELECT"); + app_control_add_extra_data(service, "file_type", "vcf"); + + app_control_set_app_id(service, MYFILE_UG); + app_control_set_launch_mode(service, APP_CONTROL_LAUNCH_MODE_GROUP); + + ContactsAppControlLauncher::getInstance().sendLaunchRequest(service, __importFromStrorageReplyCb, this, getNaviframe()->getEvasObj()); +} + +void CtSettingView::__importFromStrorageReplyCb(app_control_h request, app_control_h reply, app_control_result_e result, void *data) +{ + WPRET_M(NULL == data, "data is NULL"); + CtSettingView* view = static_cast<CtSettingView*>(data); + + std::vector<std::string> vcards; + char* val = NULL; + char* last = NULL; + app_control_get_extra_data(reply, "result", &val); + + if (val == NULL) + return; + + char* path = strtok_r(val, "?", &last); + while (path) { + vcards.push_back(path); + WHIT(); + path = strtok_r(NULL, "?", &last); + } + + free(val); + + WHIT(); + view->__excuteContactImporter(std::move(vcards)); + + return; +} + +std::vector<int> __getPersonIdListFromReply(app_control_h reply) +{ + WHIT(); + int length = 0; + char **resultArray = NULL; + std::vector<int> idList; + + app_control_get_extra_data_array(reply, APP_CONTROL_DATA_SELECTED, &resultArray, &length); + idList.reserve(length); + for (int i = 0; i < length; ++i) { + int personId = atoi(resultArray[i]); + idList.push_back(personId); + free(resultArray[i]); + } + free(resultArray); + return idList; +} + +void CtSettingView::__exportContactsTo(TargetStorage exportTo) +{ + WHIT(); + if (exportTo == TargetStorage::DEVICE) + { + launchContactPick(APP_CONTROL_DATA_SELECTION_MODE_MULTIPLE, + APP_CONTROL_DATA_TYPE_ID, [](app_control_h request, app_control_h reply, app_control_result_e result, void *data){ + CtSettingView *view = static_cast<CtSettingView*>(data); + view->__excuteContactExporter(TargetStorage::DEVICE, request, reply, result, data); + }, this); + } + else if (exportTo == TargetStorage::SD_CARD) { + launchContactPick(APP_CONTROL_DATA_SELECTION_MODE_MULTIPLE, + APP_CONTROL_DATA_TYPE_ID, [](app_control_h request, app_control_h reply, app_control_result_e result, void *data){ + CtSettingView *view = static_cast<CtSettingView*>(data); + view->__excuteContactExporter(TargetStorage::SD_CARD, request, reply, result, data); + }, this); + } +} + +void CtSettingView::__excuteContactExporter(TargetStorage saveTo, app_control_h request, app_control_h reply, app_control_result_e result, void *data) +{ + WHIT(); + CtContactsToVcard *vcard = new CtContactsToVcard(V_("IDS_PB_HEADER_EXPORT_CONTACTS_ABB"), saveTo, __getPersonIdListFromReply(reply)); + vcard->setOnFinish(std::bind(&CtSettingView::__createExportResultPopup, this, std::placeholders::_1)); + + attachPopup(vcard->getProgressPopup()); + vcard->run(); +} + +void CtSettingView::__createExportResultPopup(CtProgressController &controller) +{ + WHIT(); + CtContactsToVcard &vcard = static_cast<CtContactsToVcard&>(controller); + + const char *deviceDirName = "Device"; + const char *devicePosition = strstr(vcard.getVcardPath().c_str(), deviceDirName); + char content[CT_TEXT_SHORT_LEN] = { 0, }; + snprintf(content, sizeof(content), ctGetContactsString("IDS_PB_POP_P1SD_CONTACTS_HAVE_BEEN_EXPORTED_TO_P2SS"), vcard.getTotalCount(), devicePosition); + + WPopup *finishPopup = new WPopup(); + finishPopup->setTextTranslatable(PACKAGE); + finishPopup->setTitle("IDS_PB_HEADER_CONTACTS_EXPORTED_ABB"); + finishPopup->setContent(content); + finishPopup->addButton("IDS_PB_BUTTON_OK_ABB2", NULL); + attachPopup(finishPopup); +} + +void CtSettingView::__excuteContactImporter(std::vector<std::string> vcards) +{ + WHIT(); + int totalCount = 0; + for (auto &&vcard : vcards) { + int count = 0; + int err = contacts_vcard_get_entity_count(vcard.c_str(), &count); + if (err != CONTACTS_ERROR_NONE) { + WERROR("contacts_vcard_get_entity_count failed, vcard = %s", vcard.c_str()); + } + totalCount += count; + } + + CtImporter *contactImporter = new CtImporter(__importAbId, std::move(vcards), totalCount); + attachPopup(contactImporter->getProgressPopup()); + attachHiddenPopup(contactImporter->getCancelPopup()); + contactImporter->run(); +} + +void CtSettingView::onChanged() +{ + elm_genlist_realized_items_update(__genlist); +} + +extern "C" { + WAPP_ASSIST_EXPORT WView* createSettingView() { + CtSettingView* view = new CtSettingView; + return view; + } +} + diff --git a/lib-contact/ct-tab/.cproject b/lib-contact/ct-tab/.cproject new file mode 100644 index 0000000..23f9bca --- /dev/null +++ b/lib-contact/ct-tab/.cproject @@ -0,0 +1,516 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage"> + <storageModule moduleId="org.eclipse.cdt.core.settings"> + <cconfiguration id="org.tizen.nativecore.config.sbi.gcc45.so.debug.1768984527"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.tizen.nativecore.config.sbi.gcc45.so.debug.1768984527" moduleId="org.eclipse.cdt.core.settings" name="Debug"> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> + <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + </extensions> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <configuration artifactExtension="so" artifactName="ct-tab" buildArtefactType="org.tizen.nativecore.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.sharedLib,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.so.debug.1768984527" name="Debug" parent="org.tizen.nativecore.config.sbi.gcc45.so.debug"> + <folderInfo id="org.tizen.nativecore.config.sbi.gcc45.so.debug.1768984527." name="/" resourcePath=""> + <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.so.debug.1636878340" name="Tizen Core Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.so.debug"> + <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.867591784" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/> + <builder autoBuildTarget="all" buildPath="${workspace_loc:/ct-tab}/Debug" enableAutoBuild="true" id="org.tizen.nativecore.target.sbi.gnu.builder.545131114" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" parallelBuildOn="true" parallelizationNumber="unlimited" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/> + <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.1615061201" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/> + <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.15567238" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler"> + <option id="gnu.cpp.compiler.option.optimization.level.163803350" 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.debugging.level.core.348859818" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/> + <option defaultValue="true" id="sbi.gnu.cpp.compiler.option.misc.pic.core.223178402" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.cpp.compiler.option.2040257295" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs"> + <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_llvm34.i386.core.sharedLib"/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.478916585" 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.1361404487" 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="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-fvisibility=hidden"/> + </option> + <option id="gnu.cpp.compiler.option.include.paths.1936165721" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc/app-assist}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/ph-common/inc}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/ph-dialer/inc}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/ph-loglist/inc}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/ct-list/inc}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/ct-common/inc}""/> + <listOptionValue builtIn="false" value="../../../app-assist-efl/inc"/> + <listOptionValue builtIn="false" value=""${workspace_loc:/common/inc}""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SDK_PATH}/library""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks.core.1519853536" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + </option> + <option id="gnu.cpp.compiler.option.preprocessor.def.1668079434" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols"> + <listOptionValue builtIn="false" value="_DEBUG"/> + <listOptionValue builtIn="false" value="TIZEN_DEBUG_ENABLE"/> + <listOptionValue builtIn="false" value="_SDK_BUILD"/> + </option> + <option id="gnu.cpp.compiler.option.other.other.1909499339" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -std=c++0x" valueType="string"/> + <inputType id="sbi.gnu.cpp.compiler.tizen.inputType.700678928"/> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1575540006" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool command="clang" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.1214911705" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler"> + <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.247745276" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/> + <option id="sbi.gnu.c.compiler.option.debugging.level.core.1657026015" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" value="gnu.c.debugging.level.max" valueType="enumerated"/> + <option defaultValue="true" id="sbi.gnu.c.compiler.option.misc.pic.core.630491897" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.c.compiler.option.1891578363" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs"> + <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_llvm34.i386.core.sharedLib"/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.358236841" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath"> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SDK_PATH}/library""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.2078881787" 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="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-fvisibility=hidden"/> + </option> + <option id="gnu.c.compiler.option.include.paths.1793668828" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks.core.1588224494" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + </option> + <option id="gnu.c.compiler.option.preprocessor.def.symbols.1841844058" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols"> + <listOptionValue builtIn="false" value="_DEBUG"/> + </option> + <inputType id="sbi.gnu.c.compiler.tizen.inputType.81152802"/> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.704074063" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.7742672" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/> + <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.500371967" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker"> + <option defaultValue="true" id="sbi.gnu.cpp.linker.option.shared_flag.core.927204397" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" valueType="boolean"/> + <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.512895110" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList"> + <listOptionValue builtIn="false" value="${TC_LINKER_MISC}"/> + <listOptionValue builtIn="false" value="${RS_LINKER_MISC}"/> + <listOptionValue builtIn="false" value="-lpthread "/> + <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-L"${SBI_SYSROOT}/usr/lib""/> + <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/> + </option> + <option id="gnu.cpp.link.option.paths.600166275" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lib}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/ct-list/Debug}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/ct-common/Debug}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/common/Debug}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/ph-dialer/Debug}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/ph-loglist/Debug}""/> + <listOptionValue builtIn="false" value="../../../app-assist-efl/Debug"/> + </option> + <option id="gnu.cpp.link.option.libs.280837396" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs"> + <listOptionValue builtIn="false" value="ph-loglist"/> + <listOptionValue builtIn="false" value="ct-common"/> + <listOptionValue builtIn="false" value="ct-list"/> + <listOptionValue builtIn="false" value="ph-dialer"/> + <listOptionValue builtIn="false" value="common"/> + <listOptionValue builtIn="false" srcPrefixMapping="" srcRootPath="" value="app-assist-efl"/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.440567299" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input"> + <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> + <additionalInput kind="additionalinput" paths="$(LIBS)"/> + </inputType> + </tool> + <tool command="i386-linux-gnueabi-as" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.1182891806" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1819789021" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + <tool id="org.tizen.nativecore.tool.sbi.po.compiler.1077793556" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/> + <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.985383878" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"/> + <tool id="org.tizen.nativecore.tool.fnmapgen.1941803177" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/> + <tool id="org.tizen.nativecore.tool.fnmapgen.cpp.605587329" name="C++ FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen.cpp"/> + <tool id="org.tizen.nativecore.tool.ast.1844584808" name="C Static Analyzer" superClass="org.tizen.nativecore.tool.ast"/> + <tool id="org.tizen.nativecore.tool.ast.cpp.348880620" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/> + </toolChain> + </folderInfo> + <sourceEntries> + <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/> + <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/> + </sourceEntries> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"> + <externalSettings containerId="ph-dialer;" factoryId="org.eclipse.cdt.core.cfg.export.settings.sipplier"/> + <externalSettings containerId="ph-loglist;" factoryId="org.eclipse.cdt.core.cfg.export.settings.sipplier"/> + </storageModule> + </cconfiguration> + <cconfiguration id="org.tizen.nativecore.config.sbi.gcc45.so.release.1030804953"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.tizen.nativecore.config.sbi.gcc45.so.release.1030804953" moduleId="org.eclipse.cdt.core.settings" name="Release"> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> + <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + </extensions> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <configuration artifactExtension="so" artifactName="ct-tab" buildArtefactType="org.tizen.nativecore.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.sharedLib,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.so.release.1030804953" name="Release" parent="org.tizen.nativecore.config.sbi.gcc45.so.release"> + <folderInfo id="org.tizen.nativecore.config.sbi.gcc45.so.release.1030804953." name="/" resourcePath=""> + <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.so.release.1408975965" name="Tizen Core Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.so.release"> + <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.1700314959" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/> + <builder buildPath="${workspace_loc:/ct-tab}/Release" id="org.tizen.nativecore.target.sbi.gnu.builder.1741349122" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/> + <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.64450456" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/> + <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.1005340919" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler"> + <option id="gnu.cpp.compiler.option.optimization.level.1701136262" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/> + <option id="sbi.gnu.cpp.compiler.option.debugging.level.core.125740905" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core"/> + <option defaultValue="true" id="sbi.gnu.cpp.compiler.option.misc.pic.core.586059472" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.cpp.compiler.option.1500443273" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs"> + <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_llvm34.i386.core.sharedLib"/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.10877151" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath"> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SDK_PATH}/library""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.1195707919" 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="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-fvisibility=hidden"/> + </option> + <option id="gnu.cpp.compiler.option.include.paths.1075687404" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks.core.399982049" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + </option> + <inputType id="sbi.gnu.cpp.compiler.tizen.inputType.1575664265"/> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.827018146" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool command="clang" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.1348349604" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler"> + <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.option.optimization.level.1548925133" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/> + <option id="sbi.gnu.c.compiler.option.debugging.level.core.1520215684" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core"/> + <option defaultValue="true" id="sbi.gnu.c.compiler.option.misc.pic.core.1376508474" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.c.compiler.option.1562541360" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs"> + <listOptionValue builtIn="false" value="mobile-2.3-emulator.core_llvm34.i386.core.sharedLib"/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.1973359790" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath"> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SDK_PATH}/library""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/AL""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/curl""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/e_dbus-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/edje-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/fontconfig""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/freetype2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0/json-glib""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libexif""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/shortcut""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-manager""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ewebkit2-0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/wifi-direct""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.174759871" 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="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-fvisibility=hidden"/> + </option> + <option id="gnu.c.compiler.option.include.paths.641497877" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks.core.909552811" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + </option> + <option id="gnu.c.compiler.option.dialect.std.1990764188" name="Language standard" superClass="gnu.c.compiler.option.dialect.std" value="gnu.c.compiler.dialect.default" valueType="enumerated"/> + <inputType id="sbi.gnu.c.compiler.tizen.inputType.110668904"/> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1315992130" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.1020317658" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/> + <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.916994458" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker"> + <option defaultValue="true" id="sbi.gnu.cpp.linker.option.shared_flag.core.309841099" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" valueType="boolean"/> + <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.148981646" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList"> + <listOptionValue builtIn="false" value="${TC_LINKER_MISC}"/> + <listOptionValue builtIn="false" value="${RS_LINKER_MISC}"/> + <listOptionValue builtIn="false" value="-lpthread "/> + <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-L"${SBI_SYSROOT}/usr/lib""/> + <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/> + </option> + <option id="gnu.cpp.link.option.paths.1504937088" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lib}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/ph-dialer/Release}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/ph-loglist/Release}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/app-assist-efl/Release}""/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.681770918" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input"> + <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> + <additionalInput kind="additionalinput" paths="$(LIBS)"/> + </inputType> + </tool> + <tool command="i386-linux-gnueabi-as" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.2129852866" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1876839419" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + <tool id="org.tizen.nativecore.tool.sbi.po.compiler.1596431276" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/> + <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.1647200653" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"/> + <tool id="org.tizen.nativecore.tool.fnmapgen.861523146" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/> + <tool id="org.tizen.nativecore.tool.fnmapgen.cpp.985584469" name="C++ FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen.cpp"/> + <tool id="org.tizen.nativecore.tool.ast.1959501868" name="C Static Analyzer" superClass="org.tizen.nativecore.tool.ast"/> + <tool id="org.tizen.nativecore.tool.ast.cpp.1534401119" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/> + </toolChain> + </folderInfo> + <sourceEntries> + <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/> + <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/> + </sourceEntries> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> + </cconfiguration> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <project id="ct-tab.org.tizen.nativecore.target.sbi.gcc45.so.394110347" name="Tizen Core Shared Library" projectType="org.tizen.nativecore.target.sbi.gcc45.so"/> + </storageModule> + <storageModule moduleId="scannerConfiguration"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + <scannerConfigBuildInfo instanceId="org.tizen.nativecore.config.sbi.gcc45.so.release.1030804953"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.tizen.nativecommon.TizenGCCManagedMakePerProjectProfileCPP"/> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="org.tizen.nativecore.config.sbi.gcc45.so.debug.1768984527"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.tizen.nativecommon.TizenGCCManagedMakePerProjectProfileCPP"/> + </scannerConfigBuildInfo> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/> + <storageModule moduleId="org.tizen.tizen.nativeapp.projectInfo" version="1.0.0"/> + <storageModule moduleId="refreshScope" versionNumber="2"> + <configuration configurationName="Release"> + <resource resourceType="PROJECT" workspacePath="/ct-tab"/> + </configuration> + <configuration configurationName="Debug"> + <resource resourceType="PROJECT" workspacePath="/ct-tab"/> + </configuration> + </storageModule> +</cproject> diff --git a/lib-contact/ct-tab/.project b/lib-contact/ct-tab/.project new file mode 100644 index 0000000..bbab8e8 --- /dev/null +++ b/lib-contact/ct-tab/.project @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>ct-tab</name> + <comment></comment> + <projects> + <project>ph-dialer</project> + <project>ph-loglist</project> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> + <triggers>full,incremental,</triggers> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.tizen.nativecore.apichecker.core.builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.cdt.core.cnature</nature> + <nature>org.eclipse.cdt.core.ccnature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> + <nature>org.tizen.nativecore.apichecker.core.tizenCppNature</nature> + </natures> + <filteredResources> + <filter> + <id>1413282572898</id> + <name></name> + <type>26</type> + <matcher> + <id>org.eclipse.ui.ide.multiFilter</id> + <arguments>1.0-projectRelativePath-matches-false-false-*/.tpk</arguments> + </matcher> + </filter> + </filteredResources> +</projectDescription> diff --git a/lib-contact/ct-tab/.tproject b/lib-contact/ct-tab/.tproject new file mode 100644 index 0000000..f1cc1fd --- /dev/null +++ b/lib-contact/ct-tab/.tproject @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<tproject xmlns="http://www.tizen.org/tproject"> + <platforms> + <platform> + <name>mobile-2.3</name> + </platform> + </platforms> + <package> + <blacklist/> + </package> +</tproject> diff --git a/lib-contact/ct-tab/CMakeLists.txt b/lib-contact/ct-tab/CMakeLists.txt new file mode 100755 index 0000000..9cce588 --- /dev/null +++ b/lib-contact/ct-tab/CMakeLists.txt @@ -0,0 +1,27 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(ct-tab CXX) + +INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/app-assist-efl/inc + ${CMAKE_SOURCE_DIR}/lib-common/inc + ${CMAKE_SOURCE_DIR}/lib-contact/ct-list/inc + ${CMAKE_SOURCE_DIR}/lib-contact/ct-common/inc + ${CMAKE_SOURCE_DIR}/lib-phone/ph-common/inc + ${CMAKE_SOURCE_DIR}/lib-phone/ph-dialer/inc + ${CMAKE_SOURCE_DIR}/lib-phone/ph-loglist/inc + ${CMAKE_CURRENT_SOURCE_DIR}/inc + ${CMAKE_CURRENT_SOURCE_DIR}/src +) + +FILE(GLOB SRCS "src/*.cpp") +ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${TIZEN_PKGS_LDFLAGS} + "app-assist-efl" + "contacts-common" + "ct-common" + "ct-list" + "ph-loglist" + "ph-dialer" +) + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_APP_LIB_DIR}) diff --git a/lib-contact/ct-tab/inc/CtTabView.h b/lib-contact/ct-tab/inc/CtTabView.h new file mode 100755 index 0000000..274f654 --- /dev/null +++ b/lib-contact/ct-tab/inc/CtTabView.h @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_TAB_VIEW_H_ +#define _CT_TAB_VIEW_H_ + +#include <vector> +#include <app.h> +#include <string> +#include <memory> +#include <Ecore.h> + +#include "WPageSlideView.h" + +#include "IContactsTabPageView.h" + +typedef enum { + TAB_VIEW_NONE = -1, + TAB_VIEW_DIALER, + TAB_VIEW_LOGS, + TAB_VIEW_LOGS_CHECK, + TAB_VIEW_CONTACTS, + TAB_VIEW_MAX, +} CtTabSubView; + +class WAPP_ASSIST_EXPORT CtTabView: public WPageSlideView +{ +public: + CtTabView(CtTabSubView selectedView, bool title, ContactsData *contactsData); + + +public: + void reset(CtTabSubView selectedView); + void insert(CtTabSubView selectedView, IContactsTabPageView* subView); + + +private: + virtual Evas_Object* onCreate(Evas_Object* parent, void* viewParam); + virtual void onDestroy(); + virtual Elm_Object_Item* onPushToNaviframe( Evas_Object* naviFrame); + virtual void onPushed(Elm_Object_Item* naviItem); + virtual bool onPop(); + +private: + bool __checkViewExist(Elm_Object_Item *tabItem); + int __getPageIndexByViewType(int viewType); + int __getViewTypeByPageIndex(int pageIndex); + + static void __onTabChangedCb(void* data, Evas_Object* obj, void* event_info); + static void __pageScrollStopCb(void* data, Evas_Object* obj, void* event_info); + static void __pageScrollStartCb(void* data, Evas_Object* obj, void* event_info); + + void __tabChanged(Elm_Object_Item *selectedItem); + void __deleteChildView(); + + static Eina_Bool __createRestViewTimerCb(void* data); + +private: + CtTabView(); + ~CtTabView(); + +private: + ContactsData *__contactsData; + + Evas_Object* __tabbar; + Elm_Object_Item* __tabItem[TAB_VIEW_MAX]; + + int __selectedView; + int __lastSelectedView; + bool __subViewLoaded[TAB_VIEW_MAX]; + IContactsTabPageView* __subView[TAB_VIEW_MAX]; + bool __hasTitle; + std::vector<CtTabSubView> __tabSubView; + Ecore_Timer *__timer; + Ecore_Idler *__idler; + +}; + + + +#endif // _PHCT_TAB_PAGE_VIEW_H_ diff --git a/lib-contact/ct-tab/src/CtTabView.cpp b/lib-contact/ct-tab/src/CtTabView.cpp new file mode 100755 index 0000000..33b21ee --- /dev/null +++ b/lib-contact/ct-tab/src/CtTabView.cpp @@ -0,0 +1,445 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <app_preference.h> + +#include "WPageSlideView.h" + +#include "ContactsCommon.h" +#include "ContactsDebug.h" +#include "ContactsAppControlLauncher.h" + +#include "CtThemeMgr.h" +#include "CtRegistryMgr.h" +#include "CtString.h" +#include "CtTabView.h" +#include "CtListView.h" +#include "PhDialerView.h" +#include "PhLogMainListView.h" +#include "PhLogMainListCheckView.h" +//#include <ui_extension.h> + +#define CT_TAB_CREATE_SUB_VIEW_TIMER 4.0 +#define CT_TAB_CREATE_SUB_VIEW_MORE_TIMER 1.0 + +CtTabView::CtTabView(CtTabSubView selectedView, bool title, ContactsData *contactsData) +{ + WENTER(); + __idler = NULL; + __timer = NULL; + __tabbar = NULL; + __contactsData = contactsData; + + for( int i=0; i<TAB_VIEW_MAX; i++) { + __tabItem[i] = NULL; + __subViewLoaded[i] = false; + __subView[i] = NULL; + } + + __hasTitle = title; + __selectedView = selectedView; + __lastSelectedView = selectedView; + + WLEAVE(); +} + +CtTabView::~CtTabView() +{ + WHIT(); + + CtThemeMgr::getInstance()->destroy(); + CtRegistryMgr::getInstance()->destroy(); +} + +void CtTabView::insert(CtTabSubView viewType, IContactsTabPageView *subView) +{ + __subView[viewType] = subView; + __tabSubView.push_back(viewType); +} + +Evas_Object* CtTabView::onCreate(Evas_Object* parent, void* viewParam) +{ + WENTER(); + + Evas_Object* layout = elm_layout_add(parent); + elm_layout_theme_set(layout, "layout", "application", "default"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + setOnInitScroller( [this](Evas_Object* scroller) + { + elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); + //uxt_scroller_set_auto_scroll_enabled(scroller, EINA_FALSE); + }); + + Evas_Object* slideViewObj = WPageSlideView::onCreate(layout, NULL); + + elm_object_part_content_set(layout, "elm.swallow.content", slideViewObj); + evas_object_smart_callback_add(getScroller(), "scroll,anim,stop", __pageScrollStopCb, this ); + evas_object_smart_callback_add(getScroller(), "scroll,drag,start", __pageScrollStartCb, this ); + + evas_object_show(layout); + WDEBUG("layout %p", layout); + + return layout; + +} + +void CtTabView::onDestroy() +{ + if(__idler) + ecore_idler_del(__idler); + __idler = NULL; + + if(__timer) + ecore_timer_del(__timer); + __timer = NULL; +} + +Elm_Object_Item* CtTabView::onPushToNaviframe(Evas_Object* naviFrame) +{ + WENTER(); + + //create tabbar + Evas_Object* tabbar = elm_toolbar_add(naviFrame); + elm_toolbar_shrink_mode_set(tabbar, ELM_TOOLBAR_SHRINK_EXPAND); + elm_toolbar_transverse_expanded_set(tabbar, EINA_TRUE); + WDEBUG("elm_toolbar_add"); + + Elm_Object_Item* naviItem = NULL; + if(__hasTitle) { + elm_object_style_set(tabbar, "tabbar/tabbar_with_title"); + naviItem = elm_naviframe_item_push(naviFrame, NULL, NULL, NULL, getEvasObj(), "tabbar"); + } + else { + elm_object_style_set(tabbar, "tabbar"); + naviItem = elm_naviframe_item_push(naviFrame, NULL, NULL, NULL, getEvasObj(), "tabbar/notitle"); + } + WDEBUG("elm_naviframe_item_push"); + + elm_object_item_part_content_set(naviItem, "tabbar", tabbar); + elm_toolbar_select_mode_set(tabbar, ELM_OBJECT_SELECT_MODE_ALWAYS); + + __tabbar = tabbar; + for(auto iter = __tabSubView.begin();iter != __tabSubView.end();++iter) { + const char *tabName = NULL; + if(*iter == TAB_VIEW_DIALER) + tabName = "IDS_KPD_ITAB3_KEYPAD"; + if(*iter == TAB_VIEW_LOGS || *iter == TAB_VIEW_LOGS_CHECK) + tabName = "IDS_LOGS_ITAB3_LOGS"; + if(*iter == TAB_VIEW_CONTACTS) + tabName = "IDS_PB_ITAB3_CONTACTS"; + + WDEBUG("tabName %s %d", tabName, *iter); + __tabItem[*iter] = elm_toolbar_item_append(tabbar, NULL, tabName, __onTabChangedCb, this); + elm_object_item_domain_text_translatable_set(__tabItem[*iter], PACKAGE, EINA_TRUE); + } + WDEBUG("elm_toolbar_item_append"); + + WLEAVE(); + + return naviItem; + +} + +void CtTabView::onPushed(Elm_Object_Item* naviItem) +{ + WENTER(); + + for(auto iter = __tabSubView.begin();iter != __tabSubView.end();iter++) { + if(__subView[*iter]) + appendPage(); + } + + //set first show page + if(__subView[__selectedView]) { + setPageContent(__getPageIndexByViewType(__selectedView), __subView[__selectedView]); + __subViewLoaded[__selectedView] = true; + + //__timer = ecore_timer_add(CT_TAB_CREATE_SUB_VIEW_TIMER, __createRestViewTimerCb, this); + } + + elm_toolbar_item_selected_set(__tabItem[__selectedView], EINA_TRUE); + + WLEAVE(); +} + +bool CtTabView::onPop( ) +{ + WHIT(); + + bool isTabPop = false; + for(int i = TAB_VIEW_DIALER; i < TAB_VIEW_MAX; i++) + { + if (__subView[i]) + isTabPop = __subView[i]->onTabPop(); + if (isTabPop == false) + return false; + } + return true; +} + +void CtTabView::__onTabChangedCb(void* data, Evas_Object* obj, void* event_info) +{ + WENTER(); + ContactsAppControlLauncher::getInstance().terminate(); + CtTabView* view = (CtTabView*)data; + Elm_Object_Item *selectedItem = elm_toolbar_selected_item_get(obj); + + view->__tabChanged(selectedItem); + + WLEAVE(); + +} + +void CtTabView::__tabChanged(Elm_Object_Item *selectedItem) +{ + WHIT(); + + if(getPageCount() == 0) { + WERROR("page item not added"); + return; + } + + if(selectedItem != __tabItem[__selectedView]) { + int i = 0; + WDEBUG("%d", __selectedView); + + if(selectedItem) { + __deleteChildView(); + + if(__subView[__selectedView] && __subViewLoaded[__selectedView]) + __subView[__selectedView]->onTabUnselect(getNaviItem()); + + for (i=TAB_VIEW_DIALER;i<TAB_VIEW_MAX;i++) { + if (__tabItem[i]) { + if (selectedItem == __tabItem[i]) { + if(__subView[i]) + { + setPageContent(__getPageIndexByViewType(i), __subView[i]); + __subViewLoaded[i] = true; + __subView[i]->onTabSelect(getNaviItem()); + } + + if (!__contactsData->appControl && (i == TAB_VIEW_DIALER || i == TAB_VIEW_LOGS)) + { + preference_set_int(CT_KEY_LAST_SELECTED_TAB_INDEX_FOR_PHONE, i); + WDEBUG("last selectedView saved as %d", i); + } + break; + } + } + } + + __selectedView = i; + } + else {//first selected(launched) + WDEBUG("first launched"); + if(__subView[__selectedView] && __subViewLoaded[__selectedView]) + __subView[__selectedView]->onTabSelect(getNaviItem()); + } + } + + int pageIndex = __getPageIndexByViewType(__selectedView); + + WDEBUG("tabselect %d, pageIndex %d", __selectedView, pageIndex); + + showPage(pageIndex, false); + +} + +void CtTabView::__pageScrollStopCb(void* data, Evas_Object* obj, void* event_info) +{ + CtTabView* view = (CtTabView*)data; + for(int i = TAB_VIEW_DIALER; i < TAB_VIEW_MAX; i++) { + if(view->__subView[i] && view->__subViewLoaded[i]) + view->__subView[i]->onTabScrollStop(); + } + + int hpage = 0; + elm_scroller_current_page_get(obj, &hpage, NULL); + WDEBUG("pagen %d", hpage); + + int viewType = view->__getViewTypeByPageIndex(hpage); + + elm_toolbar_item_selected_set(view->__tabItem[viewType], EINA_TRUE); + return; +} + +void CtTabView::__pageScrollStartCb(void* data, Evas_Object* obj, void* event_info) +{ + WHIT(); + CtTabView* view = (CtTabView*)data; + for (auto iter = view->__tabSubView.begin(); iter != view->__tabSubView.end(); iter++) + { + WDEBUG("subView %d", *iter); + if(view->__subView[*iter] && view->__subViewLoaded[*iter] == false) { + view->setPageContent(view->__getPageIndexByViewType(*iter), view->__subView[*iter]); + view->__subViewLoaded[*iter] = true; + } + view->__subView[*iter]->onTabScrollStart(); + } + + return; +} + +bool CtTabView::__checkViewExist(Elm_Object_Item *tabItem) +{ + bool result = false; + int i = TAB_VIEW_DIALER; + for(i=TAB_VIEW_DIALER;i<TAB_VIEW_MAX;i++) { + if(__tabItem[i] == tabItem) { + if(__subView[i]) { + result = true; + break; + } + } + } + + return result; +} + +int CtTabView::__getPageIndexByViewType(int viewType) +{ + if(viewType >= TAB_VIEW_MAX || __subView[viewType] == NULL) { + WERROR("no sub view"); + return 0; + } + + int i = 0; + + Elm_Object_Item *item = elm_toolbar_first_item_get(__tabbar); + + while(item) { + if(__tabItem[viewType] == item && __subView[viewType]) + break; + + if(__checkViewExist(item) == true) + i++; + item = elm_toolbar_item_next_get(item); + } + + return i; +} + +int CtTabView::__getViewTypeByPageIndex(int pageIndex) +{ + int i = 0; + + Elm_Object_Item *item = elm_toolbar_first_item_get(__tabbar); + + for(i=0;i<pageIndex;i++) { + item = elm_toolbar_item_next_get(item); + } + + for(i=0;i<TAB_VIEW_MAX;i++) { + if(__tabItem[i] == item) + break; + } + + return i; +} + +void CtTabView::reset(CtTabSubView selectedView) +{ + WENTER(); + + if(TAB_VIEW_LOGS == selectedView) { + if(__subView[TAB_VIEW_LOGS_CHECK]) + selectedView = TAB_VIEW_LOGS_CHECK; + } + + if(__selectedView != selectedView || TAB_VIEW_CONTACTS != selectedView) + { + WDEBUG("selectedView was %d and new %d", __selectedView, selectedView); + ContactsAppControlLauncher::getInstance().terminate(); + __deleteChildView(); + //__selectedView = selectedView; + } + + int i = 0; + for(i=TAB_VIEW_DIALER;i<TAB_VIEW_MAX;i++) { + if(__subView[i] && __subViewLoaded[i] && (selectedView != i)) { + __subView[i]->onTabUnselect(getNaviItem()); + } + } + if(__subView[selectedView] && __subViewLoaded[selectedView]) { + __subView[selectedView]->onTabSelect(getNaviItem()); + } + + int pageIndex = __getPageIndexByViewType(selectedView); + + WDEBUG("tabselect %d, pageIndex %d", selectedView, pageIndex); + + showPage(pageIndex, false); + + WDEBUG("toolbar set %d", selectedView); + elm_toolbar_item_selected_set(__tabItem[selectedView], EINA_TRUE); + + WLEAVE(); +} + +void CtTabView::__deleteChildView() +{ + WHIT(); + + Eina_List *itemList = elm_naviframe_items_get(getNaviframe()->getEvasObj()); + int count = eina_list_count(itemList); + Eina_List *cursor = NULL; + void *data = NULL; + if(count > 1) { + EINA_LIST_REVERSE_FOREACH(itemList, cursor, data) { + Elm_Object_Item *item = (Elm_Object_Item*)data; + elm_object_item_del(item); + count--; + if(count == 1) + break; + } + } + eina_list_free(itemList); + + if(__subView[__selectedView]) { + Evas_Object* btn = elm_object_item_part_content_unset(getNaviItem(), "toolbar_more_btn"); + if (btn) + evas_object_del(btn); + } +} + +Eina_Bool CtTabView::__createRestViewTimerCb(void* data) +{ + WHIT(); + CtTabView* view = (CtTabView*)data; + view->__timer = NULL; + static auto iter = view->__tabSubView.begin(); + + if(view->__selectedView == TAB_VIEW_CONTACTS) + //CONTACTS_LOGGING_LOG(LOGGING_LOG_CONTACT_APP); //DO NOT REMOVE!!! + + for (; iter != view->__tabSubView.end(); iter++) + { + if(view->__subView[*iter] && view->__subViewLoaded[*iter] == false) { + WDEBUG("subView %d]%s setPageContent", *iter, view->__subView[*iter]->getName()); + view->setPageContent(view->__getPageIndexByViewType(*iter), view->__subView[*iter]); + view->__subViewLoaded[*iter] = true; + } + else + continue; + + view->__timer = ecore_timer_add(CT_TAB_CREATE_SUB_VIEW_MORE_TIMER, view->__createRestViewTimerCb, data); + return ECORE_CALLBACK_CANCEL; + } + return ECORE_CALLBACK_CANCEL; +} diff --git a/lib-contact/ct-vcard/CMakeLists.txt b/lib-contact/ct-vcard/CMakeLists.txt new file mode 100644 index 0000000..73bb37d --- /dev/null +++ b/lib-contact/ct-vcard/CMakeLists.txt @@ -0,0 +1,20 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(ct-vcard CXX) + +INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/app-assist-efl/inc + ${CMAKE_SOURCE_DIR}/lib-common/inc + ${CMAKE_SOURCE_DIR}/lib-contact/ct-common/inc + ${CMAKE_CURRENT_SOURCE_DIR}/inc + ${CMAKE_CURRENT_SOURCE_DIR}/src +) + +FILE(GLOB SRCS "src/*.cpp") +ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${TIZEN_PKGS_LDFLAGS} + "app-assist-efl" + "contacts-common" + "ct-common" +) + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_APP_LIB_DIR})
\ No newline at end of file diff --git a/lib-contact/ct-vcard/inc/CtContactsToVcard.h b/lib-contact/ct-vcard/inc/CtContactsToVcard.h new file mode 100644 index 0000000..36df407 --- /dev/null +++ b/lib-contact/ct-vcard/inc/CtContactsToVcard.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_CONTACTS_TO_VCARD_H_ +#define _CT_CONTACTS_TO_VCARD_H_ + +#include <string> +#include <vector> + +#include "CtVcardCommon.h" +#include "CtProgressController.h" + +class CtContactsToVcard : public CtProgressController +{ +public: + + /** + * @brief Constructor. + * @param[in] title Progress popup title. + * @param[in] vcardStorage Type of storage where vcard will be created. + * @param[in] personIdList Person id list. + */ + CtContactsToVcard(const char *title, TargetStorage vcardStorage, std::vector<int> personIdList); + + /** + * @brief Get vcard path. + * @return Vcard path. + */ + std::string getVcardPath(); + + /** + * @brief Get total count. + * @return Total count. + */ + int getTotalCount(); + +private: + void createDirectory(); + void vcardFilePathGet(); + + void onStart(Ecore_Thread *thread); + void onCanceled(); + +private: + std::vector<int> m_PersonIdList; + std::string m_VcardPath; + TargetStorage m_VcardStorage; +}; + +#endif /* _CT_CONTACTS_TO_VCARD_H_ */ diff --git a/lib-contact/ct-vcard/inc/CtVcardCommon.h b/lib-contact/ct-vcard/inc/CtVcardCommon.h new file mode 100644 index 0000000..49bee87 --- /dev/null +++ b/lib-contact/ct-vcard/inc/CtVcardCommon.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _CT_VCARD_COMMON_H_ +#define _CT_VCARD_COMMON_H_ + +/** + * @brief Type of storage where vcard will be created. + */ +enum class TargetStorage +{ + DEVICE, + SD_CARD, + INTERNAL_OTHER +}; + +#endif //_CT_VCARD_COMMON_H_ diff --git a/lib-contact/ct-vcard/src/CtContactsToVcard.cpp b/lib-contact/ct-vcard/src/CtContactsToVcard.cpp new file mode 100644 index 0000000..c1b39b1 --- /dev/null +++ b/lib-contact/ct-vcard/src/CtContactsToVcard.cpp @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <fstream> +#include <notification.h> + +#include "ContactsDebug.h" +#include "CtCommon.h" +#include "CtContactsToVcard.h" +#include "CtString.h" +#include "CtType.h" + +#define CT_SETTING_DEVICE_EXPORT_PATH "/opt/usr/media/Device/Contacts/Exported" +#define CT_SETTING_SDCARD_EXPORT_PATH "/opt/storage/sdcard/Device/Contacts/Exported" + +CtContactsToVcard::CtContactsToVcard(const char *title, TargetStorage vcardStorage, std::vector<int> personIdList) +: CtProgressController(title, personIdList.size()) +, m_PersonIdList (std::move(personIdList)) +, m_VcardStorage(vcardStorage) +{ + WHIT(); + createDirectory(); + + vcardFilePathGet(); + if (m_VcardPath.empty()) { + WWARNING("vcard path is NULL"); + return; + } +} + +std::string CtContactsToVcard::getVcardPath() +{ + return m_VcardPath; +} + +int CtContactsToVcard::getTotalCount() +{ + return m_PersonIdList.size(); +} + +void CtContactsToVcard::createDirectory() +{ + if (m_VcardStorage == TargetStorage::DEVICE || m_VcardStorage == TargetStorage::SD_CARD) { + int ret = 0; + if (m_VcardStorage == TargetStorage::DEVICE) { + ret = system("mkdir -p " CT_SETTING_DEVICE_EXPORT_PATH); + } else { + ret = system("mkdir -p " CT_SETTING_SDCARD_EXPORT_PATH); + } + WPRET_M(ret == -1, "failed to create folder"); + } +} + +void CtContactsToVcard::vcardFilePathGet() +{ + const int vcardMaxNumber = 999; + char path[CT_TEXT_MAX_LEN] = {0, }; + int fileNumber = 1; + char *directoryPath = NULL; + + if (m_VcardStorage == TargetStorage::DEVICE) { + directoryPath = strdup(CT_SETTING_DEVICE_EXPORT_PATH); + + } else if (m_VcardStorage == TargetStorage::SD_CARD) { + directoryPath = strdup(CT_SETTING_SDCARD_EXPORT_PATH); + + } else if (m_VcardStorage == TargetStorage::INTERNAL_OTHER){ + directoryPath = getOtherDirectoryPath(); + WPRET_M(!directoryPath, "getOtherDirectoryPath failed"); + } + + while (fileNumber <= vcardMaxNumber) { + struct stat buf; + if (fileNumber == 1) { + snprintf(path, sizeof(path), "%s/Contacts.vcf", directoryPath); + } else { + snprintf(path, sizeof(path), "%s/Contacts_%03d.vcf", directoryPath, fileNumber); + } + + if (stat(path, &buf) == 0) { + ++fileNumber; + } else { + free(directoryPath); + + m_VcardPath = path; + WDEBUG("path = %s", path); + return; + } + } + + if (fileNumber > vcardMaxNumber) { + WERROR("Too many vcards. Delete some before creating new."); + notification_status_message_post(V_("IDS_PB_POP_FAILED")); + } + free(directoryPath); + m_VcardPath.clear(); +} + +void CtContactsToVcard::onStart(Ecore_Thread *thread) +{ + WHIT(); + FILE *file = fopen(m_VcardPath.c_str(), "a"); + WPRET_M(!file, "fopen failed: %s", strerror(errno)); + int currentCount = 0; + + for (auto &&personId : m_PersonIdList) { + + contacts_record_h personRecord = NULL; + int err = contacts_db_get_record(_contacts_person._uri, personId, &personRecord); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_db_get_record failed: %d", err); + continue; + } + + if (personRecord) { + char *vcardStream = NULL; + + err = contacts_vcard_make_from_person(personRecord, &vcardStream); + if (CONTACTS_ERROR_NONE != err) { + WERROR("contacts_vcard_make_from_person failed: %d", err); + contacts_record_destroy(personRecord, true); + continue; + } + + if (vcardStream) { + fputs(vcardStream, file); + free(vcardStream); + + ++currentCount; + if (!onProgress(currentCount)) { + WDEBUG("Creating vcard canceled"); + ecore_thread_cancel(thread); + contacts_record_destroy(personRecord, true); + fclose(file); + return; + } + } + contacts_record_destroy(personRecord, true); + } + } + fclose(file); +} + +void CtContactsToVcard::onCanceled() +{ + WHIT(); + if (!m_VcardPath.empty()) { + remove(m_VcardPath.c_str()); + } + + notification_status_message_post(V_("IDS_PB_SBODY_EXPORTING_CANCELLED_M_STATUS_ABB")); +} |