<toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug.1048479076" name="Tizen Native Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug">
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.299151930" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
<builder autoBuildTarget="all" buildPath="${workspace_loc:/call-ui}/Debug" enableAutoBuild="true" id="org.tizen.nativecore.target.sbi.gnu.builder.287909858" 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.850939844" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
+ <tool command="i386-linux-gnueabi-ar" id="org.tizen.nativecore.tool.sbi.gnu.archiver.850939844" 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.66050065" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
<option id="gnu.cpp.compiler.option.optimization.level.1977572256" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option defaultValue="gnu.cpp.compiler.debugging.level.max" id="sbi.gnu.cpp.compiler.option.debugging.level.core.1003532466" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" valueType="enumerated"/>
<option defaultValue="false" id="sbi.gnu.cpp.compiler.option.misc.pic.core.58197076" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/>
<option id="sbi.gnu.cpp.compiler.option.1780411914" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
- <listOptionValue builtIn="false" value="wearable-4.0-emulator.core.private_gcc49.i386.core.app"/>
+ <listOptionValue builtIn="false" value="wearable-4.0-emulator.core.private_gcc49.i386"/>
</option>
<option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.2060575755" 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="--sysroot="${SBI_SYSROOT}""/>
</option>
<option id="gnu.cpp.compiler.option.include.paths.79290911" 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=""${SBI_SYSROOT}/usr/include/libxml2""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/SDL2""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore/""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-watch""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/asp/""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/aul/""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/>
+ <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/call-manager""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/chromium-ewk""/>
+ <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/context-service""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/csr""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dali""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dali-toolkit""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/device""/>
+ <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/ecore-buffer-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-con-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-evas-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-file-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-imf-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-imf-evas-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-input-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-input-evas-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-ipc-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ector-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/efl-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eldbus-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/emile-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eo-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eom""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-client-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/feedback""/>
+ <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/include/harfbuzz""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/iotcon""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/maps""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/metadata-editor""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/>
+ <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/nsd/""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/phonenumber-utils""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/pkgmgr""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/rua/""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/>
+ <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/telephony""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/tzsh""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/>
+ <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/vulkan""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/widget_service""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/widget_viewer_dali""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/widget_viewer_evas""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/yaca""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/>
+ <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}}""/>
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/ucl/inc}""/>
</option>
<option id="sbi.gnu.cpp.compiler.option.frameworks.core.1469916614" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs">
<option defaultValue="gnu.c.debugging.level.max" id="sbi.gnu.c.compiler.option.debugging.level.core.1157370620" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" valueType="enumerated"/>
<option defaultValue="false" id="sbi.gnu.c.compiler.option.misc.pic.core.1654013693" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/>
<option id="sbi.gnu.c.compiler.option.551225658" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
- <listOptionValue builtIn="false" value="wearable-4.0-emulator.core.private_gcc49.i386.core.app"/>
+ <listOptionValue builtIn="false" value="wearable-4.0-emulator.core.private_gcc49.i386"/>
</option>
<option id="sbi.gnu.c.compiler.option.frameworks_inc.core.1481628386" 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="--sysroot="${SBI_SYSROOT}""/>
</option>
<option id="gnu.c.compiler.option.include.paths.368004466" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
- <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/EGL""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/yaca""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore/""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/asp/""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/aul/""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/call-manager""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/pkgmgr""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/rua/""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/>
+ <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}}""/>
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/ucl/inc}""/>
</option>
<option id="sbi.gnu.c.compiler.option.frameworks.core.1478193049" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs">
</toolChain>
</folderInfo>
<sourceEntries>
- <entry excluding="view/SlidingLabel.h" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="call-ui"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="res"/>
- <entry excluding="view/SlidingLabel.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="ucl/inc"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="ucl/src"/>
</sourceEntries>
<toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.app.release.1202011079" name="Tizen Native Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.app.release">
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.1547247838" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
<builder buildPath="${workspace_loc:/call-ui}/Release" id="org.tizen.nativecore.target.sbi.gnu.builder.1410224621" 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.519529023" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
+ <tool command="i386-linux-gnueabi-ar" id="org.tizen.nativecore.tool.sbi.gnu.archiver.519529023" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
<tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.2053654917" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
<option id="gnu.cpp.compiler.option.optimization.level.1574455899" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
<option defaultValue="gnu.cpp.compiler.debugging.level.none" id="sbi.gnu.cpp.compiler.option.debugging.level.core.1268930725" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" valueType="enumerated"/>
<option defaultValue="false" id="sbi.gnu.cpp.compiler.option.misc.pic.core.1954110782" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/>
<option id="sbi.gnu.cpp.compiler.option.1348701994" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
- <listOptionValue builtIn="false" value="wearable-4.0-device.core.private_llvm37.armel.core.app"/>
+ <listOptionValue builtIn="false" value="wearable-4.0-emulator.core_llvm40.i386"/>
</option>
<option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.1432667313" 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=""${SBI_SYSROOT}/usr/include""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/SDL2""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-watch""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/asp/""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/>
+ <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/chromium-ewk""/>
+ <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/context-service""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/csr""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dali""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dali-toolkit""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/device""/>
+ <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/ecore-buffer-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-con-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-evas-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-file-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-imf-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-imf-evas-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-input-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-input-evas-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-ipc-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ector-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/efl-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-extension""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efreet-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eldbus-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/emile-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eo-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eom""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ethumb-client-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/evas-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/feedback""/>
+ <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/include/harfbuzz""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/iotcon""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/location""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/maps""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media-content""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/messaging""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/metadata-editor""/>
+ <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/nsd/""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/phonenumber-utils""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/>
+ <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/telephony""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/tzsh""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vulkan""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/widget_service""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/widget_viewer_dali""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/widget_viewer_evas""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/yaca""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/>
+ </option>
+ <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.1273225121" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.core" valueType="stringList">
+ <listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
+ <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
+ <listOptionValue builtIn="false" value=" -fPIE"/>
+ <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
+ </option>
+ <option id="gnu.cpp.compiler.option.include.paths.382544999" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/SDL2""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/yaca""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/>
- </option>
- <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.1273225121" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.core" valueType="stringList">
- <listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
- <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
- <listOptionValue builtIn="false" value=" -fPIE"/>
- <listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
- <listOptionValue builtIn="false" value="-mthumb"/>
- </option>
- <option id="gnu.cpp.compiler.option.include.paths.382544999" 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}}""/>
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/ucl/inc}""/>
</option>
<option id="sbi.gnu.cpp.compiler.option.frameworks.core.863139267" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs">
<option defaultValue="gnu.c.debugging.level.default" id="sbi.gnu.c.compiler.option.debugging.level.core.1220862817" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" valueType="enumerated"/>
<option defaultValue="false" id="sbi.gnu.c.compiler.option.misc.pic.core.1659164857" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/>
<option id="sbi.gnu.c.compiler.option.207590264" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
- <listOptionValue builtIn="false" value="wearable-4.0-device.core.private_llvm37.armel.core.app"/>
+ <listOptionValue builtIn="false" value="wearable-4.0-emulator.core_llvm40.i386"/>
</option>
<option id="sbi.gnu.c.compiler.option.frameworks_inc.core.1440527129" 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=""${SBI_SYSROOT}/usr/include""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/SDL2""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore/""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-watch""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/asp/""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/aul/""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/badge""/>
<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/call-manager""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/chromium-ewk""/>
<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/messaging""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/metadata-editor""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/>
<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/nsd/""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/phonenumber-utils""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/pkgmgr""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/rua/""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/sensor""/>
<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/telephony""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/tzsh""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/>
<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/vulkan""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/widget_service""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/widget_viewer_dali""/>
<listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
<listOptionValue builtIn="false" value=" -fPIE"/>
<listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
- <listOptionValue builtIn="false" value="-mthumb"/>
</option>
<option id="gnu.c.compiler.option.include.paths.1553190282" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
- <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/EGL""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/yaca""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore/""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/asp/""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/aul/""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/call-manager""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/pkgmgr""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/rua/""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/>
+ <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/>
+ <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}}""/>
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/ucl/inc}""/>
</option>
<option id="sbi.gnu.c.compiler.option.frameworks.core.1251626395" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs">
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
- <tool command="arm-linux-gnueabi-as" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.1040646105" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base">
+ <tool command="#{PLATFORM_DEFAULT_GCC_PREFIX}as" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.1040646105" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1529641874" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
<tool id="org.tizen.nativecore.tool.fnmapgen.1478404041" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/>
</toolChain>
</folderInfo>
<sourceEntries>
- <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="call-ui"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="res"/>
- <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="ucl/inc"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="ucl/src"/>
</sourceEntries>
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_COMMON_H__
+#define __CALL_UI_COMMON_H__
+
+#include <algorithm>
+
+#include <Ecore.h>
+
+#include "ucl/util/helpers.h"
+#include "ucl/util/logging.h"
+#include "ucl/util/shortLogs.h"
+
+#include "ucl/gui/stdTheme.h"
+#include "ucl/gui/helpers.h"
+
+#include "helpers.h"
+
+#undef UCL_LOG_TAG
+#define UCL_LOG_TAG "CALLUI"
+
+namespace callui {
+
+ using namespace ucl;
+
+ constexpr auto PACKAGE = "w-call-ui";
+
+ constexpr SmartEvent WIN_POWER_KEY_UP_EVENT {"callui,powerkey,up"};
+
+}
+
+#endif // __CALL_UI_COMMON_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_CONFIG_H__
+#define __CALL_UI_CONFIG_H__
+
+#define CALLUI_LOG_TAG "CALLUI"
+
+namespace callui {
+
+ constexpr auto WINDOW_NAME = "org.tizen.call-ui";
+
+ constexpr auto BASE_SCALE = 1.3;
+}
+
+#endif // __CALL_UI_CONFIG_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_HELPERS_H__
+#define __CALL_UI_HELPERS_H__
+
+#include "types.h"
+
+namespace callui { namespace util {
+
+ template <class GETTER, class V, class ...ARGS>
+ ucl::Result get(GETTER &&getter, V &result, ARGS &&...args);
+
+ template <class GETTER, class V, class ...ARGS>
+ ucl::Result getNz(GETTER &&getter, V &result, ARGS &&...args);
+
+ template <class FUNC, class ...ARGS>
+ ucl::Result call(FUNC &&func, ARGS &&...args);
+}}
+
+#include "helpers.hpp"
+
+#endif // __CALL_UI_HELPERS_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "ucl/util/helpers.h"
+#include "ucl/util/logging.h"
+
+namespace callui { namespace util { namespace himpl {
+
+ template <class GETTER, class ...ARGS>
+ inline ucl::Result get(GETTER &&getter, bool optional,
+ std::string &result, ARGS &&...args)
+ {
+ char *value = nullptr;
+ const int ret = getter(std::forward<ARGS>(args)..., &value);
+ if ((ret != 0) || (!optional && ucl::isEmpty(value))) {
+ UCL_ELOG("get() failed: %d", ret);
+ return ucl::RES_FAIL;
+ }
+
+ if (value) {
+ result = value;
+ free(value);
+ } else {
+ result.clear();
+ }
+
+ return ucl::RES_OK;
+ }
+
+ template <class GETTER, class V, class ...ARGS>
+ inline ucl::Result get(GETTER &&getter, bool optional,
+ V &result, ARGS &&...args)
+ {
+ typename std::remove_pointer<decltype(&result)>::type value = {};
+
+ const int ret = getter(std::forward<ARGS>(args)..., &value);
+ if ((ret != 0) || (!optional && !value)) {
+ UCL_ELOG("get() failed: %d", ret);
+ return ucl::RES_FAIL;
+ }
+
+ result = value;
+
+ return ucl::RES_OK;
+ }
+}}}
+
+namespace callui { namespace util {
+
+ template <class GETTER, class V, class ...ARGS>
+ inline ucl::Result get(GETTER &&getter, V &result, ARGS &&...args)
+ {
+ return himpl::get(std::forward<GETTER>(getter), true,
+ result, std::forward<ARGS>(args)...);
+ }
+
+ template <class GETTER, class V, class ...ARGS>
+ inline ucl::Result getNz(GETTER &&getter, V &result, ARGS &&...args)
+ {
+ return himpl::get(std::forward<GETTER>(getter), false,
+ result, std::forward<ARGS>(args)...);
+ }
+
+ template <class FUNC, class ...ARGS>
+ inline ucl::Result call(FUNC &&func, ARGS &&...args)
+ {
+ const int ret = func(std::forward<ARGS>(args)...);
+ if (ret != 0) {
+ UCL_ELOG("func() failed: %d", ret);
+ return ucl::RES_FAIL;
+ }
+ return ucl::RES_OK;
+ }
+}}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "ucl/appfw/UIApp.h"
+
+#include "presenters/InstanceManager.h"
+
+#include "common.h"
+
+using namespace ucl;
+using namespace callui;
+
+int main(int argc, char *argv[])
+{
+ ILOG("MAIN START");
+
+ InstanceManager mgr;
+ const int ret = UIApp(mgr).run(argc, argv);
+
+ ILOG("MAIN END. ret[%d]", ret);
+
+ return ret;
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "CallUIBuilder.h"
+
+#include "impl/CallUI.h"
+
+#include "call-ui/common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ CallUIBuilder::CallUIBuilder()
+ {
+ }
+
+ ICallUISRef CallUIBuilder::build() const
+ {
+ auto result = makeShared<CallUI>();
+ FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+ return result;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_CALL_UI_BUILDER_H__
+#define __CALL_UI_MODEL_CALL_UI_BUILDER_H__
+
+#include "ICallUI.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(CallUIBuilder);
+
+ class CallUIBuilder {
+ public:
+ CallUIBuilder();
+ ICallUISRef build() const;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_CALL_UI_BUILDER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_I_ACTIVE_CALL_H__
+#define __CALL_UI_MODEL_I_ACTIVE_CALL_H__
+
+#include "ICallInfo.h"
+#include "IConferenceCallInfo.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(IActiveCall);
+
+ class IActiveCall : public ucl::Polymorphic {
+ public:
+ virtual ICallInfoSCRef getInfo() const = 0;
+ virtual bool isDialingMode() const = 0;
+ virtual ucl::Result hold() = 0;
+ virtual ucl::Result end() = 0;
+ virtual ucl::Result split(const IConferenceCallInfoSCRef &confCallInfo) = 0;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_I_ACTIVE_CALL_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_I_BASE_CALL_INFO_H__
+#define __CALL_UI_MODEL_I_BASE_CALL_INFO_H__
+
+#include "IContactInfo.h"
+
+#include "types.h"
+
+namespace callui {
+
+ class IBaseCallInfo : public ucl::Polymorphic {
+ public:
+ virtual unsigned int getCallId() const = 0;
+ virtual const std::string &getPhoneNumber() const = 0;
+ virtual IContactInfoSCRef getContactInfo() const = 0;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_I_BASE_CALL_INFO_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_I_CALL_INFO_H__
+#define __CALL_UI_MODEL_I_CALL_INFO_H__
+
+#include "IBaseCallInfo.h"
+
+#include <time.h>
+
+#include "IConferenceCallInfo.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(ICallInfo);
+
+ using ConfMemberList = std::vector<IConferenceCallInfoSCRef>;
+
+ class ICallInfo : public IBaseCallInfo {
+ public:
+ virtual struct tm getDuration() const = 0;
+ virtual bool isEmergency() const = 0;
+ virtual bool isHDVoice() const = 0;
+ virtual bool isForwarded() const = 0;
+ virtual bool isVoiceMailNumber() const = 0;
+ virtual int getConferenceMemberCount() const = 0;
+ virtual const ConfMemberList &getConferenceMemberList() const = 0;
+ };
+
+ // Non-member functions
+
+ bool isUnknownCaller(const ICallInfo &info);
+}
+
+#endif // __CALL_UI_MODEL_I_CALL_INFO_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_I_CALL_LISTENER_H__
+#define __CALL_UI_MODEL_I_CALL_LISTENER_H__
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(ICallListener);
+
+ class ICallListener : public ucl::Polymorphic {
+ public:
+ virtual void onCallEvent(CallEventType type) = 0;
+ virtual void onError(CallErr err) = 0;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_I_CALL_LISTENER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_I_STATE_PROVIDER_H__
+#define __CALL_UI_MODEL_I_STATE_PROVIDER_H__
+
+#include "types.h"
+
+#include "IIncomingCall.h"
+#include "IActiveCall.h"
+#include "IHeldCall.h"
+#include "IEndCall.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(ICallManager);
+
+ class ICallManager : public ucl::Polymorphic {
+ public:
+ virtual IIncomingCallSRef getIncomingCall() = 0;
+ virtual IActiveCallSRef getActiveCall() = 0;
+ virtual IHeldCallSRef getHeldCall() = 0;
+ virtual IEndCallSRef getEndCall() = 0;
+ virtual CallMask getAvailableCalls() const = 0;
+ };
+}
+
+#endif // __CALL_UI_MODEL_I_STATE_PROVIDER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_I_CALL_UI_H__
+#define __CALL_UI_MODEL_I_CALL_UI_H__
+
+#include <app_control.h>
+
+#include "ISoundManager.h"
+#include "ICallManager.h"
+#include "IIndicatorStateProvider.h"
+#include "ICallListener.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(ICallUI);
+
+ class ICallUI : public ucl::Polymorphic {
+ public:
+ virtual void setListener(const ICallListenerWRef &listener) = 0;
+ virtual ucl::Result processAppControl(app_control_h appControl) = 0;
+ virtual ISoundManagerSRef getSoundManager() = 0;
+ virtual ICallManagerSRef getCallManager() = 0;
+ virtual IIndicatorStateProviderSRef getIndicatorStateProvider() = 0;
+ };
+}
+
+#endif // __CALL_UI_MODEL_I_CALL_UI_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_I_CONFERENCE_CALL_INFO_H__
+#define __CALL_UI_MODEL_I_CONFERENCE_CALL_INFO_H__
+
+#include "IBaseCallInfo.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(IConferenceCallInfo);
+
+ class IConferenceCallInfo : public IBaseCallInfo {
+ };
+}
+
+#endif // __CALL_UI_MODEL_I_CONFERENCE_CALL_INFO_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_I_CONTACT_INFO_H__
+#define __CALL_UI_MODEL_I_CONTACT_INFO_H__
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(IContactInfo);
+
+ class IContactInfo : public ucl::Polymorphic {
+ public:
+ virtual const std::string &getName() const = 0;
+ virtual const std::string &getImagePath() const = 0;
+ virtual ContactNameSourceType getNameSourceType() const = 0;
+ };
+}
+
+#endif // __CALL_UI_MODEL_I_CONTACT_INFO_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_I_END_CALL_H__
+#define __CALL_UI_MODEL_I_END_CALL_H__
+
+#include "ICallInfo.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(IEndCall);
+
+ class IEndCall : public ucl::Polymorphic {
+ public:
+ virtual ICallInfoSCRef getInfo() const = 0;
+ virtual ucl::Result callBack() = 0;
+ virtual ucl::Result writeMessage() = 0;
+ };
+}
+
+#endif // __CALL_UI_MODEL_I_END_CALL_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_I_HELD_CALL_H__
+#define __CALL_UI_MODEL_I_HELD_CALL_H__
+
+#include "ICallInfo.h"
+#include "IConferenceCallInfo.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(IHeldCall);
+
+ class IHeldCall : public ucl::Polymorphic {
+ public:
+ virtual ICallInfoSCRef getInfo() const = 0;
+ virtual ucl::Result unhold() = 0;
+ virtual ucl::Result joinWithActive() = 0;
+ virtual ucl::Result swapWithActive() = 0;
+ virtual ucl::Result end() = 0;
+ virtual ucl::Result split(const IConferenceCallInfoSCRef &confCallInfo) = 0;
+ };
+}
+
+#endif // __CALL_UI_MODEL_I_HELD_CALL_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_I_INCOMING_CALL_H__
+#define __CALL_UI_MODEL_I_INCOMING_CALL_H__
+
+#include "ICallInfo.h"
+#include "IRejectMsgProvider.h"
+#include "IRejectMsg.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(IIncomingCall);
+
+ class IIncomingCall : public ucl::Polymorphic {
+ public:
+ virtual ICallInfoSCRef getInfo() const = 0;
+ virtual IRejectMsgProviderSRef getRejectMsgProvider() const = 0;
+ virtual ucl::Result answer(CallAnswerType type) = 0;
+ virtual ucl::Result reject() = 0;
+ virtual ucl::Result rejectWithMessage(IRejectMsgSRef message) = 0;
+ virtual ucl::Result stopAlert() = 0;
+ };
+}
+
+#endif // __CALL_UI_MODEL_I_INCOMING_CALL_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_I_INDICATOR_STATE_LISTENER_H__
+#define __CALL_UI_MODEL_I_INDICATOR_STATE_LISTENER_H__
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(IIndicatorStateListener);
+
+ class IIndicatorStateListener: public ucl::Polymorphic {
+ public:
+ virtual void onStateChanged(IndicatorProperty property) = 0;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_I_INDICATOR_STATE_LISTENER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_I_INDICATOR_STATE_PROVIDER_H__
+#define __CALL_UI_MODEL_I_INDICATOR_STATE_PROVIDER_H__
+
+#include "IndicatorState.h"
+#include "IIndicatorStateListener.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(IIndicatorStateProvider);
+
+ class IIndicatorStateProvider : public ucl::Polymorphic {
+ public:
+ virtual IndicatorState getState(IndicatorProperty property) const = 0;
+ virtual void setListener(IIndicatorStateListenerWRef listener) = 0;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_I_INDICATOR_STATE_PROVIDER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_I_REJECT_MSG_H__
+#define __CALL_UI_MODEL_I_REJECT_MSG_H__
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(IRejectMsg);
+
+ class IRejectMsg : public ucl::Polymorphic {
+ public:
+ virtual std::string getText() const = 0;
+
+ };
+
+}
+
+#endif // __CALL_UI_I_REJECT_MSG_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_I_REJECT_MSG_PROVIDER_H__
+#define __CALL_UI_MODEL_I_REJECT_MSG_PROVIDER_H__
+
+#include "IRejectMsg.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(IRejectMsgProvider);
+
+ class IRejectMsgProvider : public ucl::Polymorphic {
+ public:
+ using RejectMsgList = std::vector<IRejectMsgSRef>;
+
+ public:
+ virtual RejectMsgList getMsgList() const = 0;
+ virtual int getMsgCount() const = 0;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_I_REJECT_MSG_PROVIDER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_I_SOUND_MANAGER_H__
+#define __CALL_UI_MODEL_I_SOUND_MANAGER_H__
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(ISoundManager);
+
+ class ISoundManager: public ucl::Polymorphic {
+ public:
+ virtual ucl::Result setSpeakerState(bool isEnable) = 0;
+ virtual ucl::Result setBluetoothState(bool isEnable) = 0;
+ virtual AudioStateType getAudioState() const = 0;
+ virtual ucl::Result setMuteState(bool isEnable) = 0;
+ virtual bool getMuteState() const = 0;
+ virtual ucl::Result startDtmf(const unsigned char dtmfDigit) = 0;
+ virtual ucl::Result stopDtmf() = 0;
+ virtual void addAudioStateHandler(
+ const AudioStateHandler &handler) = 0;
+ virtual void delAudioStateHandler(
+ const AudioStateHandler &handler) = 0;
+ virtual void addMuteStateHandler(
+ const MuteStateHandler &handler) = 0;
+ virtual void delMuteStateHandler(
+ const MuteStateHandler &handler) = 0;
+ virtual void addVolumeStateHandler(
+ const VolumeLevelHandler &handler) = 0;
+ virtual void delVolumeStateHandler(
+ const VolumeLevelHandler &handler) = 0;
+ virtual int getMaxVolume() const = 0;
+ virtual int getVolume() const = 0;
+ virtual ucl::Result setVolume(int value) = 0;
+ virtual bool isBTSupported() const = 0;
+ virtual bool isBTHeadsetConnected() const = 0;
+ virtual void addBTHeadsetConnectionChangeHandler(
+ const NotiHandler &handler) = 0;
+ virtual void delBTHeadsetConnectionChangeHandler(
+ const NotiHandler &handler) = 0;
+ };
+}
+
+#endif // __CALL_UI_MODEL_I_SOUND_MANAGER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_INDICATOR_STATE_H__
+#define __CALL_UI_MODEL_INDICATOR_STATE_H__
+
+#include "types.h"
+
+namespace callui {
+
+ struct IndicatorState {
+ uint64_t value;
+ };
+
+ ConnectionType getConnectionState(IndicatorState state);
+ PacketDirection getPacketDirection(IndicatorState state);
+ RssiState getRssiState(IndicatorState state);
+ bool getRoamingState(IndicatorState state);
+ int getBatteryLevel(IndicatorState state);
+ BatteryState getBatteryState(IndicatorState state);
+ bool getVoiceControlState(IndicatorState state);
+ SimSlot getSimSlotType(IndicatorState state);
+ bool getSimForwardState(IndicatorState state);
+ bool getHDVoiceState(IndicatorState state);
+
+}
+
+#endif // __CALL_UI_MODEL_INDICATOR_STATE_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "ActiveCall.h"
+
+#include "CallManager.h"
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ ActiveCall::ActiveCall(CallManagerWRef cm, cm_call_data_h callData):
+ m_cm(cm),
+ m_isDialing(false)
+ {
+ }
+
+ ActiveCall::~ActiveCall()
+ {
+ }
+
+ ActiveCallSRef ActiveCall::newInstance(CallManagerWRef cm, cm_call_data_h callData)
+ {
+ if (!cm) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "cm is NULL");
+ }
+
+ if (!callData) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "callData is NULL");
+ }
+
+ auto result = makeShared<ActiveCall>(cm, callData);
+ FAIL_RETURN_VALUE(result->prepare(callData), {}, "result->prepare() failed!");
+ return result;
+ }
+
+ Result ActiveCall::prepare(cm_call_data_h callData)
+ {
+ const auto cm = m_cm.lock();
+ if (!cm) {
+ LOG_RETURN(RES_FAIL, "Call Manager is NULL");
+ }
+
+ m_callInfo = CallInfo::newInstance(cm->getCallClient(),
+ callData,
+ cm->getContactInfoProvider());
+ if (!m_callInfo) {
+ LOG_RETURN_VALUE(RES_FAIL, RES_FAIL, "CallInfo::newInstance() failed!");
+ }
+
+ cm_call_state_e callState = CM_CALL_STATE_IDLE;
+ FAIL_RETURN(convertCMResult(
+ cm_call_data_get_call_state(callData, &callState)),
+ "cm_call_data_get_call_state() failed!");
+ m_isDialing = (callState == CM_CALL_STATE_DIALING);
+
+ return RES_OK;
+ }
+
+ ICallInfoSCRef ActiveCall::getInfo() const
+ {
+ return m_callInfo;
+ }
+
+ bool ActiveCall::isDialingMode() const
+ {
+ return m_isDialing;
+ }
+
+ Result ActiveCall::hold()
+ {
+ const auto cm = m_cm.lock();
+ if (!cm) {
+ LOG_RETURN(RES_FAIL, "Call Manager is NULL");
+ }
+
+ return convertCMResult(cm_hold_call(cm->getCallClient()));
+ }
+
+ Result ActiveCall::end()
+ {
+ const auto cm = m_cm.lock();
+ if (!cm) {
+ LOG_RETURN(RES_FAIL, "Call Manager is NULL");
+ }
+
+ if (m_isDialing) {
+ return cm->endCall(m_callInfo->getCallId(),
+ CallReleaseType::BY_CALL_HANDLE);
+ }
+ return cm->endCall(0, CallReleaseType::ALL_ACTIVE);
+ }
+
+ Result ActiveCall::split(const IConferenceCallInfoSCRef &confCallInfo)
+ {
+ const auto cm = m_cm.lock();
+ if (!cm) {
+ LOG_RETURN(RES_FAIL, "Call Manager is NULL");
+ }
+ return cm->splitCalls(m_callInfo, confCallInfo);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_ACTIVE_CALL_H__
+#define __CALL_UI_MODEL_IMPL_ACTIVE_CALL_H__
+
+#include <call-manager-ext.h>
+
+#include "call-ui/model/IActiveCall.h"
+
+#include "CallClient.h"
+#include "CallInfo.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(CallManager);
+
+ UCL_DECLARE_REF_ALIASES(ActiveCall);
+
+ class ActiveCall final : public IActiveCall {
+ public:
+ static ActiveCallSRef newInstance(CallManagerWRef cm, cm_call_data_h callData);
+ virtual ~ActiveCall();
+
+ // IActiveCall
+
+ virtual ICallInfoSCRef getInfo() const override final;
+ virtual bool isDialingMode() const override final;
+ virtual ucl::Result hold() override final;
+ virtual ucl::Result end() override final;
+ virtual ucl::Result split(const IConferenceCallInfoSCRef &confCallInfo) override final;
+
+ private:
+ friend class ucl::ReffedObj<ActiveCall>;
+ ActiveCall(CallManagerWRef cm, cm_call_data_h callData);
+
+ ucl::Result prepare(cm_call_data_h callData);
+
+ private:
+ CallManagerWRef m_cm;
+ CallInfoSRef m_callInfo;
+ bool m_isDialing;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_IMPL_ACTIVE_CALL_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "BatteryStateSource.h"
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ BatteryStateSource::Bits::Bits():
+ property(convertEnumValueToInt(IndicatorProperty::BATTERY)),
+ chargeValue(0),
+ chargingState(convertEnumValueToInt(BatteryState::NORMAL))
+ {
+ }
+
+ BatteryStateSource::Bits::Bits(const IndicatorState &state):
+ value(state.value)
+ {
+ if (property != convertEnumValueToInt(IndicatorProperty::BATTERY)) {
+ ELOG("State of incorrect property type [%d]", property);
+ *this = {};
+ }
+ }
+
+ BatteryStateSource::BatteryStateSource()
+ {
+ }
+
+ BatteryStateSource::~BatteryStateSource()
+ {
+ delSysStateCallbacks();
+ }
+
+ BatteryStateSourceSRef BatteryStateSource::newInstance()
+ {
+ auto result = makeShared<BatteryStateSource>();
+ FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+ return result;
+ }
+
+ Result BatteryStateSource::prepare()
+ {
+ FAIL_RETURN(addSysStateCallbacks(), "addSysStateCallbacks() failed!");
+
+ updateBatteryState();
+
+ return RES_OK;
+ }
+
+ bool BatteryStateSource::updateChargingStateBits(BatteryState state)
+ {
+ int stateInt = convertEnumValueToInt(state);
+ if (stateInt != m_bits.chargingState) {
+ m_bits.chargingState = stateInt;
+ return true;
+ }
+ return false;
+ }
+
+ bool BatteryStateSource::updateChargeLevelBits(int value)
+ {
+ if (value != m_bits.chargeValue) {
+ m_bits.chargeValue = value;
+ return true;
+ }
+ return false;
+ }
+
+ int BatteryStateSource::getCurChargeLevel() const
+ {
+ int capacity = 0;
+ if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CAPACITY, &capacity) == 0) {
+ return capacity;
+ }
+ ELOG("Get battery capacity failed!");
+ return -1;
+ }
+
+ BatteryState BatteryStateSource::getCurChargingState() const
+ {
+ int isCharged = 0;
+ if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, &isCharged) == 0) {
+ switch (isCharged) {
+ case -1: return BatteryState::CHARGING_PROBLEM;
+ case 1: return BatteryState::CHARGING;
+ default: return BatteryState::NORMAL;
+ }
+ }
+ ELOG("Get battery charging status failed!");
+ return BatteryState::NORMAL;
+ }
+
+ bool BatteryStateSource::updateBatteryState()
+ {
+ int chargeLevel = getCurChargeLevel();
+ BatteryState state = getCurChargingState();
+
+ if (chargeLevel < 0) {
+ chargeLevel = 0;
+ if (state == BatteryState::NORMAL) {
+ state = BatteryState::UNKNOWN;
+ }
+ }
+
+ bool wasUpdated = updateChargingStateBits(state);
+ if (updateChargeLevelBits(chargeLevel)) {
+ wasUpdated = true;
+ }
+ return wasUpdated;
+ }
+
+ void BatteryStateSource::onBatteryStateChangedCb(keynode_t *node)
+ {
+ if (updateBatteryState() && m_handler) {
+ m_handler();
+ }
+ }
+
+ Result BatteryStateSource::addSysStateCallbacks()
+ {
+ int res = vconf_notify_key_changed(VCONFKEY_SYSMAN_CHARGER_STATUS,
+ CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ res = vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW,
+ CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ res = vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW,
+ CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ res = vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY,
+ CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ return RES_OK;
+ }
+
+ void BatteryStateSource::delSysStateCallbacks()
+ {
+ vconf_ignore_key_changed(VCONFKEY_SYSMAN_CHARGER_STATUS,
+ CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb));
+ vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW,
+ CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb));
+ vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW,
+ CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb));
+ vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY,
+ CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb));
+ }
+
+ IndicatorState BatteryStateSource::getState() const
+ {
+ return {m_bits.value};
+ }
+
+ void BatteryStateSource::setStateChangeHandler(const NotiHandler &handler)
+ {
+ m_handler = handler;
+ }
+
+ int getBatteryLevel(IndicatorState state)
+ {
+ return static_cast<int>(
+ BatteryStateSource::Bits(state).chargeValue);
+ }
+
+ BatteryState getBatteryState(IndicatorState state)
+ {
+ return static_cast<BatteryState>(
+ BatteryStateSource::Bits(state).chargingState);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_BATTERY_STATE_SOURCE_H__
+#define __CALL_UI_MODEL_IMPL_BATTERY_STATE_SOURCE_H__
+
+#include <vconf.h>
+
+#include "IIndicatorStateSource.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(BatteryStateSource);
+
+ class BatteryStateSource final : public IIndicatorStateSource {
+ public:
+ static BatteryStateSourceSRef newInstance();
+ virtual ~BatteryStateSource();
+
+ // IIndicatorStateSource
+
+ virtual IndicatorState getState() const override final;
+ virtual void setStateChangeHandler(const NotiHandler &handler) override final;
+
+ private:
+ friend class ucl::ReffedObj<BatteryStateSource>;
+ BatteryStateSource();
+
+ ucl::Result prepare();
+
+ ucl::Result addSysStateCallbacks();
+ void delSysStateCallbacks();
+
+ void onBatteryStateChangedCb(keynode_t *node);
+
+ int getCurChargeLevel() const;
+ BatteryState getCurChargingState() const;
+
+ bool updateChargingStateBits(BatteryState state);
+ bool updateChargeLevelBits(int value);
+ bool updateBatteryState();
+
+ public:
+ union Bits {
+ struct {
+ uint8_t property : 4;
+ uint8_t chargeValue : 8;
+ uint8_t chargingState: 4;
+ };
+ uint64_t value;
+
+ Bits();
+ Bits(const IndicatorState &state);
+ };
+
+ private:
+ Bits m_bits;
+ NotiHandler m_handler;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_IMPL_BATTERY_STATE_SOURCE_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "BluetoothManager.h"
+
+#include <bluetooth.h>
+#include <bluetooth_internal.h>
+#include <bluetooth_extension.h>
+#include <sound_manager.h>
+
+#include "common.h"
+
+namespace callui { namespace { namespace impl {
+
+ constexpr auto BT_VOLUME_MAX = 15;
+
+}}}
+
+namespace callui {
+
+ using namespace ucl;
+
+ BluetoothManagerSRef BluetoothManager::newInstance()
+ {
+ auto result = makeShared<BluetoothManager>();
+ FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+ return result;
+ }
+
+ BluetoothManager::BluetoothManager():
+ m_btInitialized(false),
+ m_btAudioInitialized(false),
+ m_isHeadsetConnected(false)
+ {
+ }
+
+ BluetoothManager::~BluetoothManager()
+ {
+ unregisterAudioHandling();
+ unregisterHeadsetConnectionHandling();
+ deinitializeBluetooth();
+ }
+
+ Result BluetoothManager::prepare()
+ {
+ FAIL_RETURN(initializeBluetooth(),
+ "initializeBluetooth() failed!");
+
+ FAIL_RETURN(registerAudioHandling(),
+ "registerAudioHandling() failed");
+
+ FAIL_RETURN(registerHeadsetConnectionHandling(),
+ "registerHeadsetConnectionHandling() failed!");
+
+ m_isHeadsetConnected = getHeadsetConnectionState();
+
+ return RES_OK;
+ }
+
+ Result BluetoothManager::initializeBluetooth()
+ {
+ auto ret = bt_initialize();
+ if (ret != BT_ERROR_NONE) {
+ LOG_RETURN(RES_FAIL, "BT initialize failed! "
+ "ret[%d] msg[%s]", ret, get_error_message(ret));
+
+ }
+ m_btInitialized = true;
+ return RES_OK;
+ }
+
+ void BluetoothManager::deinitializeBluetooth()
+ {
+ bt_deinitialize();
+ }
+
+ int BluetoothManager::getVolume() const
+ {
+ auto vol = 0;
+ auto ret = bt_ag_get_speaker_gain(&vol);
+ if (ret != BT_ERROR_NONE) {
+ LOG_RETURN_VALUE(RES_FAIL, -1, "bt_ag_get_speaker_gain() failed! "
+ "ret[%d] msg[%s]", ret, get_error_message(ret));
+ }
+ DLOG("BT Volume level [%d]", vol);
+ return vol;
+ }
+
+ int BluetoothManager::getMaxVolume() const
+ {
+ return impl::BT_VOLUME_MAX;
+ }
+
+ Result BluetoothManager::setVolume(int volume)
+ {
+ auto ret = bt_ag_notify_speaker_gain(volume);
+ if (ret != BT_ERROR_NONE) {
+ LOG_RETURN(RES_FAIL, "bt_ag_notify_speaker_gain() failed! "
+ "ret[%d] msg[%s]", ret, get_error_message(ret));
+ }
+ return RES_OK;
+ }
+
+ void BluetoothManager::setVolumeStateHandler(
+ const VolumeStateHandler &handler)
+ {
+ m_btVolumeHandler = handler;
+ }
+
+ Result BluetoothManager::registerAudioHandling()
+ {
+ auto ret = bt_audio_initialize();
+ if (ret != BT_ERROR_NONE) {
+ LOG_RETURN(RES_FAIL, "bt_audio_initialize() failed! ",
+ "ret[%d] msg[%s]", ret, get_error_message(ret));
+ }
+ m_btAudioInitialized = true;
+
+ ret = bt_ag_set_speaker_gain_changed_cb(
+ CALLBACK_B(BluetoothManager::onVolumeChanged), this);
+ if (ret != BT_ERROR_NONE) {
+ LOG_RETURN(RES_FAIL, "bt_ag_set_speaker_gain_changed_cb() failed! "
+ "ret[%d] msg[%s]", ret, get_error_message(ret));
+ }
+
+ return RES_OK;
+ }
+
+ void BluetoothManager::unregisterAudioHandling()
+ {
+ bt_ag_unset_speaker_gain_changed_cb();
+
+ if (m_btAudioInitialized) {
+ bt_audio_deinitialize();
+ m_btAudioInitialized = false;
+ }
+ }
+
+ Result BluetoothManager::registerHeadsetConnectionHandling()
+ {
+ auto ret = vconf_notify_key_changed(VCONFKEY_BT_DEVICE,
+ CALLBACK_B(BluetoothManager::onHeadsetConnectionChanged),
+ this);
+ if (ret != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed!");
+ }
+ return RES_OK;
+ }
+
+ void BluetoothManager::unregisterHeadsetConnectionHandling()
+ {
+ vconf_ignore_key_changed(
+ VCONFKEY_BT_DEVICE,
+ CALLBACK_B(BluetoothManager::onHeadsetConnectionChanged));
+ }
+
+ void BluetoothManager::onVolumeChanged(int volume)
+ {
+ sound_type_e soundType = SOUND_TYPE_SYSTEM;
+ auto ret = sound_manager_get_current_sound_type(&soundType);
+ if (ret != SOUND_MANAGER_ERROR_NONE) {
+ LOG_RETURN_VOID(RES_FAIL, "sound_manager_get_current_sound_type() failed! "
+ "ret[%d] msg[%s]", ret, get_error_message(ret));
+ }
+
+ bool isSCOOpened = false;
+ ret = bt_ag_is_sco_opened(&isSCOOpened);
+ if (ret != BT_ERROR_NONE) {
+ LOG_RETURN_VOID(RES_FAIL, "sound_manager_get_current_sound_type() failed! "
+ "ret[%d] msg[%s]", ret, get_error_message(ret));
+ }
+
+ if (isSCOOpened && soundType == SOUND_TYPE_CALL) {
+ if (m_btVolumeHandler) {
+ m_btVolumeHandler(volume);
+ }
+ }
+ }
+
+ bool BluetoothManager::isHeadsetConnected() const
+ {
+ return m_isHeadsetConnected;
+ }
+
+ void BluetoothManager::setHeadsetConnectionChangeHandler(const NotiHandler &handler)
+ {
+ m_btConnectionHandler = handler;
+ }
+
+ bool BluetoothManager::getHeadsetConnectionState()
+ {
+ bt_adapter_state_e adapterState = BT_ADAPTER_DISABLED;
+ auto ret = bt_adapter_get_state(&adapterState);
+ if (ret != BT_ERROR_NONE) {
+ LOG_RETURN_VALUE(RES_FAIL, false, "bt_adapter_get_state() failed! "
+ "ret[%d] msg[%s]", ret, get_error_message(ret));
+ }
+
+ if (adapterState == BT_ADAPTER_DISABLED) {
+ LOG_RETURN_VALUE(RES_FAIL, false, "BT adapter is disabled");
+ }
+
+ auto dev = 0;
+ ret = vconf_get_int(VCONFKEY_BT_DEVICE, &dev);
+ if (ret != 0) {
+ LOG_RETURN_VALUE(RES_FAIL, false, "vconf_get_int() failed! "
+ "ret[%d] msg[%s]", ret, get_error_message(ret));
+ }
+
+ if (dev == VCONFKEY_BT_DEVICE_NONE) {
+ return false;
+ }
+
+ if ((dev & VCONFKEY_BT_DEVICE_HEADSET_CONNECTED) ||
+ (dev & VCONFKEY_BT_DEVICE_A2DP_HEADSET_CONNECTED)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ void BluetoothManager::setHeadsetConnectionState(bool isConnected)
+ {
+ if (m_isHeadsetConnected != isConnected) {
+ m_isHeadsetConnected = isConnected;
+ if (m_btConnectionHandler) {
+ m_btConnectionHandler();
+ }
+ }
+ }
+
+ void BluetoothManager::onHeadsetConnectionChanged(keynode_t *node)
+ {
+ bool isConnected = getHeadsetConnectionState();
+ setHeadsetConnectionState(isConnected);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_BLUETOOTH_MANAGER_H__
+#define __CALL_UI_MODEL_IMPL_BLUETOOTH_MANAGER_H__
+
+#include <vconf.h>
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(BluetoothManager);
+
+ class BluetoothManager final {
+ public:
+ using VolumeStateHandler = ucl::WeakDelegate<void(int)>;
+
+ public:
+ static BluetoothManagerSRef newInstance();
+
+ int getVolume() const;
+ int getMaxVolume() const;
+ ucl::Result setVolume(int volume);
+
+ void setVolumeStateHandler(const VolumeStateHandler &handler);
+
+ bool isHeadsetConnected() const;
+ void setHeadsetConnectionChangeHandler(const NotiHandler &handler);
+
+ private:
+ friend class ucl::ReffedObj<BluetoothManager>;
+ BluetoothManager();
+ virtual ~BluetoothManager();
+
+ ucl::Result prepare();
+
+ ucl::Result initializeBluetooth();
+ void deinitializeBluetooth();
+
+ ucl::Result registerAudioHandling();
+ void unregisterAudioHandling();
+ void onVolumeChanged(int volume);
+
+ ucl::Result registerHeadsetConnectionHandling();
+ void unregisterHeadsetConnectionHandling();
+
+ bool getHeadsetConnectionState();
+ void setHeadsetConnectionState(bool isConnected);
+ void onHeadsetConnectionChanged(keynode_t *node);
+
+ private:
+ VolumeStateHandler m_btVolumeHandler;
+ NotiHandler m_btConnectionHandler;
+ bool m_btInitialized;
+ bool m_btAudioInitialized;
+ bool m_isHeadsetConnected;
+ };
+}
+
+#endif // __CALL_UI_MODEL_IMPL_BLUETOOTH_MANAGER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "CallClient.h"
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ CallClient::CallClient():
+ m_client()
+ {
+ }
+
+ CallClient::~CallClient()
+ {
+ if (m_client) {
+ cm_deinit(m_client);
+ }
+ }
+
+ CallClientSRef CallClient::newInstance()
+ {
+ auto result = makeShared<CallClient>();
+ FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+ return result;
+ }
+
+ ucl::Result CallClient::prepare()
+ {
+ cm_client_h client;
+ FAIL_RETURN(convertCMResult(cm_init(&client)), "cm_init() failed!");
+ m_client = client;
+
+ return RES_OK;
+ }
+
+ cm_client_h CallClient::getCmClient() const
+ {
+ return m_client;
+ }
+
+ CallClient::operator cm_client_h() const
+ {
+ return getCmClient();
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_CALL_CLIENT_H__
+#define __CALL_UI_MODEL_IMPL_CALL_CLIENT_H__
+
+#include <call-manager.h>
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(CallClient);
+
+ class CallClient {
+ public:
+ static CallClientSRef newInstance();
+ virtual ~CallClient();
+ cm_client_h getCmClient() const;
+ operator cm_client_h() const;
+
+ private:
+ friend class ucl::ReffedObj<CallClient>;
+ CallClient();
+ ucl::Result prepare();
+
+ private:
+ cm_client_h m_client;
+ };
+}
+
+#endif // __CALL_UI_MODEL_IMPL_CALL_CLIENT_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "CallInfo.h"
+
+#include <glib/gslist.h>
+#include <glib/gtypes.h>
+#include <sys/sysinfo.h>
+
+#include "common.h"
+
+namespace callui { namespace { namespace impl {
+
+ using namespace ucl;
+
+ Result getCurrTimeDiffInTm(const long time, struct tm &tmTime)
+ {
+ if (time == 0) {
+ ILOG("Call start time does not set");
+ tmTime = {0};
+ return RES_OK;
+ }
+
+ long currTime = 0;
+ struct sysinfo info;
+
+ if (sysinfo(&info) == 0) {
+ currTime = info.uptime;
+ } else {
+ LOG_RETURN(RES_FAIL, "sysinfo() failed!");
+ }
+
+ long callTime = currTime - time;
+ struct tm tmp{0};
+ gmtime_r((const time_t *)&callTime, &tmp);
+ tmTime = tmp;
+
+ return RES_OK;
+ }
+}}}
+
+namespace callui {
+
+ using namespace ucl;
+
+ CallInfo::CallInfo():
+ m_callId(-1),
+ m_startTime(0),
+ m_isEmergency(false),
+ m_isHDVoice(false),
+ m_isForwarded(false),
+ m_isVoiceMailNumber(false),
+ m_confMemberCount(0)
+ {
+ }
+
+ CallInfo::~CallInfo()
+ {
+ }
+
+ CallInfoSRef CallInfo::newInstance(CallClient &client,
+ cm_call_data_h callData,
+ ContactInfoProviderSRef callInfoProvider)
+ {
+ if (!client) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "client is NULL");
+ }
+
+ if (!callData) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "callData is NULL");
+ }
+
+ auto result = makeShared<CallInfo>();
+ FAIL_RETURN_VALUE(result->prepare(client,
+ callData,
+ callInfoProvider),
+ {}, "result->prepare() failed!");
+ return result;
+ }
+
+ Result CallInfo::prepare(CallClient &client,
+ cm_call_data_h callData,
+ ContactInfoProviderSRef callInfoProvider)
+ {
+ Result res = convertCMResult(
+ cm_call_data_get_call_id(callData, &m_callId));
+ FAIL_RETURN(res, "cm_call_data_get_call_id() failed!");
+
+ char *number = nullptr;
+ res = convertCMResult(
+ cm_call_data_get_call_number(callData, &number));
+ FAIL_RETURN(res, "cm_call_data_get_call_number() failed!");
+ m_phoneNum = nz(number);
+ // XXX: According to documentation it must be free, but it leads to crash
+// free(number);
+
+ gboolean isEmergency;
+ res = convertCMResult(
+ cm_call_data_is_emergency_call(callData, &isEmergency));
+ FAIL_RETURN(res, "cm_call_data_is_emergency_call() failed!");
+ m_isEmergency = isEmergency;
+
+ int hdIconState = 0;
+ res = convertCMResult(
+ cm_call_data_get_hd_icon_state(callData, &hdIconState));
+ FAIL_RETURN(res, "cm_call_data_get_hd_icon_state() failed!");
+ m_isHDVoice = hdIconState;
+
+ gboolean isVoiceMailNumber;
+ res = convertCMResult(
+ cm_call_data_is_voicemail_number(callData, &isVoiceMailNumber));
+ FAIL_RETURN(res, "cm_call_data_is_voicemail_number() failed!");
+ m_isVoiceMailNumber = isVoiceMailNumber;
+
+ res = convertCMResult(
+ cm_call_data_get_start_time(callData, &m_startTime));
+ FAIL_RETURN(res, "cm_call_data_get_start_time() failed!");
+
+ int personId = -1;
+ res = convertCMResult(
+ cm_call_data_get_person_id(callData, &personId));
+ FAIL_RETURN(res, "cm_call_data_get_person_id() failed!");
+
+ if (personId >= 0 && callInfoProvider) {
+ m_contactInfo = callInfoProvider->createContactInfo(personId);
+ if (!m_contactInfo) {
+ LOG_RETURN(RES_FAIL, "createContactInfo() failed!");
+ }
+ }
+
+ res = convertCMResult(cm_call_data_get_call_member_count(callData, &m_confMemberCount));
+ FAIL_RETURN(res, "cm_call_data_get_call_member_count() failed!");
+
+ if (m_confMemberCount > 1) {
+ res = initConferenceCallInfoList(client, callInfoProvider);
+ FAIL_RETURN(res, "initConferenceCallInfoList() failed!");
+ }
+
+ return RES_OK;
+ }
+
+ Result CallInfo::initConferenceCallInfoList(CallClient &client,
+ ContactInfoProviderSRef callInfoProvider)
+ {
+ // XXX: must be initialized with nullptr. If not an there is no conference calls
+ // cm_get_conference_callList return CM_ERROR_NONE and pointer will be not changed.
+ GSList *callList = nullptr;
+ Result res = convertCMResult(cm_get_conference_call_list(client, &callList));
+ FAIL_RETURN(res, "cm_get_conference_call_list() failed!");
+
+ if (callList) {
+ res = RES_OK;
+ GSList *l = callList;
+ for (; l != nullptr; l = g_slist_next(l)) {
+ auto confCallInfo = ConferenceCallInfo::newInstance(
+ static_cast<cm_conf_call_data_t *>(l->data),
+ callInfoProvider);
+ if (!confCallInfo) {
+ LOG_BREAK(res = RES_OUT_OF_MEMORY, "ConferenceCallInfo::newInstance() failed!");
+ }
+ m_confMemberList.push_back(confCallInfo);
+ }
+
+ if (res != RES_OK) {
+ m_confMemberList.clear();
+ }
+ g_slist_free_full(callList, [](gpointer data)
+ {
+ cm_conf_call_data_free(static_cast<cm_conf_call_data_t *>(data));
+ });
+ }
+ return res;
+ }
+
+ unsigned int CallInfo::getCallId() const
+ {
+ return m_callId;
+ }
+
+ const std::string &CallInfo::getPhoneNumber() const
+ {
+ return m_phoneNum;
+ }
+
+ IContactInfoSCRef CallInfo::getContactInfo() const
+ {
+ return m_contactInfo;
+ }
+
+ struct tm CallInfo::getDuration() const
+ {
+ struct tm tmp{0};
+ FAIL_RETURN_VALUE(impl::getCurrTimeDiffInTm(m_startTime, tmp),
+ {0}, "getCurrTimeDiffInTm() failed");
+ return tmp;
+ }
+
+ bool CallInfo::isEmergency() const
+ {
+ return m_isEmergency;
+ }
+
+ bool CallInfo::isHDVoice() const
+ {
+ return m_isHDVoice;
+ }
+
+ bool CallInfo::isForwarded() const
+ {
+ return m_isForwarded;
+ }
+
+ bool CallInfo::isVoiceMailNumber() const
+ {
+ return m_isVoiceMailNumber;
+ }
+
+ int CallInfo::getConferenceMemberCount() const
+ {
+ return m_confMemberCount;
+ }
+
+ const ConfMemberList &CallInfo::getConferenceMemberList() const
+ {
+ return m_confMemberList;
+ }
+
+ // Non-member functions
+
+ bool isUnknownCaller(const ICallInfo &info)
+ {
+ auto contactInfo = info.getContactInfo();
+ return (info.getPhoneNumber().empty() &&
+ (!contactInfo || contactInfo->getName().empty()));
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_CALL_INFO_H__
+#define __CALL_UI_MODEL_IMPL_CALL_INFO_H__
+
+#include <call-manager-ext.h>
+
+#include "call-ui/model/ICallInfo.h"
+
+#include "CallClient.h"
+#include "ContactInfoProvider.h"
+#include "ConferenceCallInfo.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(CallInfo);
+
+ class CallInfo final : public ICallInfo {
+ public:
+ static CallInfoSRef newInstance(CallClient &client,
+ cm_call_data_h callData,
+ ContactInfoProviderSRef callInfoProvider);
+ virtual ~CallInfo();
+
+ // ICallInfo
+
+ virtual unsigned int getCallId() const override final;
+ virtual const std::string &getPhoneNumber() const override final;
+ virtual IContactInfoSCRef getContactInfo() const override final;
+ virtual struct tm getDuration() const override final;
+ virtual bool isEmergency() const override final;
+ virtual bool isHDVoice() const override final;
+ virtual bool isForwarded() const override final;
+ virtual bool isVoiceMailNumber() const override final;
+ virtual int getConferenceMemberCount() const override final;
+ virtual const ConfMemberList &getConferenceMemberList() const override final;
+
+ private:
+ friend class ucl::ReffedObj<CallInfo>;
+ CallInfo();
+
+ ucl::Result prepare(CallClient &client,
+ cm_call_data_h callData,
+ ContactInfoProviderSRef callInfoProvider);
+ ucl::Result initConferenceCallInfoList(CallClient &client,
+ ContactInfoProviderSRef callInfoProvider);
+
+ private:
+ unsigned int m_callId;
+ std::string m_phoneNum;
+ ContactInfoSRef m_contactInfo;
+ long m_startTime;
+ bool m_isEmergency;
+ bool m_isHDVoice;
+ bool m_isForwarded;
+ bool m_isVoiceMailNumber;
+ int m_confMemberCount;
+ ConfMemberList m_confMemberList;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_IMPL_CALL_INFO_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "CallManager.h"
+
+#include "common.h"
+
+namespace callui { namespace { namespace impl {
+
+ constexpr auto TEL_NUMBER_MAX_SIZE = 82;
+
+}}}
+
+namespace callui {
+
+ using namespace ucl;
+
+ CallManager::CallManager(IRefCountObj &rc,
+ const CallClientSRef &callClient,
+ ICallManagerListenerWRef listener):
+ RefCountAware(&rc),
+ m_callClient(callClient),
+ m_listener(listener),
+ m_slot(SimSlot::UNDEFINED),
+ m_waitDialing(false),
+ m_confTypeCallReq(CALL_FLAG_NONE),
+ m_blockCMEvents(false)
+ {
+ }
+
+ CallManager::~CallManager()
+ {
+ }
+
+ CallManagerSRef CallManager::newInstance(const CallClientSRef &callClient,
+ ICallManagerListenerWRef listener)
+ {
+ auto result = makeShared<CallManager>(callClient, listener);
+ FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+ return result;
+ }
+
+ Result CallManager::prepare()
+ {
+ m_contactInfoProvider = ContactInfoProvider::newInstance();
+ if (!m_contactInfoProvider) {
+ ELOG("ContactInfoProvider::newInstance() failed");
+ }
+
+ FAIL_RETURN(initCalls(), "initCalls() failed!");
+
+ FAIL_RETURN(convertCMResult(
+ cm_set_dial_status_cb(*m_callClient,
+ CALLBACK_B(CallManager::dialStatusCb), this)),
+ "cm_set_call_event_cb() failed!");
+
+ FAIL_RETURN(convertCMResult(
+ cm_set_call_event_cb(*m_callClient,
+ CALLBACK_B(CallManager::callEventCb), this)),
+ "cm_set_call_event_cb() failed!");
+
+ return RES_OK;
+ }
+
+ Result CallManager::initCalls()
+ {
+ cm_call_data_h incom = nullptr;
+ cm_call_data_h active = nullptr;
+ cm_call_data_h held = nullptr;
+
+ FAIL_RETURN(convertCMResult(
+ cm_get_all_calldata(*m_callClient, &incom, &active, &held)),
+ "cm_get_all_calldata() failed!");
+
+ FAIL_RETURN(updateCall(m_incomingCall, incom), "updateCall() failed!");
+ FAIL_RETURN(updateCall(m_activeCall, active), "updateCall() failed!");
+ FAIL_RETURN(updateCall(m_heldCall, held), "updateCall() failed!");
+
+ cm_call_data_free(incom);
+ cm_call_data_free(active);
+ cm_call_data_free(held);
+
+ return RES_OK;
+ }
+
+ template <class TYPE, class TYPE2>
+ Result CallManager::updateCall(SharedRef<TYPE> &call, TYPE2 &&data)
+ {
+ call.reset();
+
+ if (data) {
+ call = TYPE::newInstance(asWeak(*this), std::forward<TYPE2>(data));
+ if (!call) {
+ LOG_RETURN(RES_FAIL, "newInstance() failed!");
+ }
+ }
+ return RES_OK;
+ }
+
+ CallClient &CallManager::getCallClient()
+ {
+ return *m_callClient;
+ }
+
+ SimSlot CallManager::getSimSlot() const
+ {
+ return m_slot;
+ }
+
+ IIncomingCallSRef CallManager::getIncomingCall()
+ {
+ return m_incomingCall;
+ }
+
+ IActiveCallSRef CallManager::getActiveCall()
+ {
+ return m_activeCall;
+ }
+
+ IHeldCallSRef CallManager::getHeldCall()
+ {
+ return m_heldCall;
+ }
+
+ IEndCallSRef CallManager::getEndCall()
+ {
+ return m_endCall;
+ }
+
+ CallMask CallManager::getAvailableCalls() const
+ {
+ int res = CALL_FLAG_NONE;
+
+ if (m_incomingCall)
+ res |= CALL_FLAG_INCOMING;
+
+ if (m_activeCall)
+ res |= CALL_FLAG_ACTIVE;
+
+ if (m_heldCall)
+ res |= CALL_FLAG_HELD;
+
+ if (m_endCall)
+ res |= CALL_FLAG_END;
+
+ return res;
+ }
+
+ Result CallManager::dialVoiceCall(const std::string &number)
+ {
+ char buff[impl::TEL_NUMBER_MAX_SIZE] = { 0 };
+ snprintf(buff, sizeof(buff), "%s", number.c_str());
+
+ return convertCMResult(
+ cm_dial_call(*m_callClient, buff, CM_CALL_TYPE_VOICE, convertCUISimSlot(m_slot)));
+ }
+
+ Result CallManager::endCall(unsigned int callId, CallReleaseType type)
+ {
+ ICallInfoSCRef info;
+ int flag = CALL_FLAG_NONE;
+ if (type == CallReleaseType::ALL_ACTIVE
+ && !m_incomingCall
+ && !m_heldCall) {
+ info = m_activeCall->getInfo();
+ flag = CALL_FLAG_ACTIVE;
+ } else if (type == CallReleaseType::ALL_HOLD
+ && !m_incomingCall
+ && !m_activeCall) {
+ info = m_heldCall->getInfo();
+ flag = CALL_FLAG_HELD;
+ }
+
+ if (info && info->getConferenceMemberCount() > 1) {
+ m_confTypeCallReq = flag;
+ }
+
+ return convertCMResult(
+ cm_end_call(*m_callClient, callId, convertCUICallReleaseType(type)));
+ }
+
+ Result CallManager::splitCalls(CallInfoSRef callInfo, const IConferenceCallInfoSCRef &confCallInfo)
+ {
+ if (callInfo->getConferenceMemberCount() <= 1) {
+ LOG_RETURN(RES_FAIL, "Not conference call");
+ }
+
+ auto confList = callInfo->getConferenceMemberList();
+ auto iter = std::find(confList.begin(), confList.end(), confCallInfo);
+ if (iter == confList.end()) {
+ LOG_RETURN(RES_FAIL, "Not a member of conference call");
+ }
+
+ return endCall((*iter)->getCallId(), CallReleaseType::BY_CALL_HANDLE);
+ }
+
+ ContactInfoProviderSRef CallManager::getContactInfoProvider()
+ {
+ return m_contactInfoProvider;
+ }
+
+ RejectMsgProviderSRef CallManager::getRejectMsgProvider()
+ {
+ if (!m_rejectMsgProvider) {
+ m_rejectMsgProvider = RejectMsgProvider::newInstance();
+ if (!m_rejectMsgProvider) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "RejectMsgProvider::newInstance() failed!");
+ }
+ }
+
+ return m_rejectMsgProvider;
+ }
+
+ Result CallManager::processEndCallEvent(unsigned int callId,
+ cm_call_data_h cmIncom,
+ cm_call_data_h cmActive,
+ cm_call_data_h cmHeld)
+ {
+ if (m_activeCall &&
+ callId == m_activeCall->getInfo()->getCallId() &&
+ !cmIncom && !cmActive && !cmHeld) {
+ return updateCall(m_endCall, m_activeCall->getInfo());
+ } else if (m_heldCall &&
+ callId == m_heldCall->getInfo()->getCallId() &&
+ !cmIncom && !cmActive && !cmHeld) {
+ return updateCall(m_endCall, m_heldCall->getInfo());
+ } else if (m_activeCall &&
+ m_confTypeCallReq == CALL_FLAG_ACTIVE) {
+
+ m_confTypeCallReq = CALL_FLAG_NONE;
+ m_blockCMEvents = true;
+
+ return updateCall(m_endCall, m_activeCall->getInfo());
+ } else if (m_heldCall &&
+ m_confTypeCallReq == CALL_FLAG_HELD) {
+
+ m_confTypeCallReq = CALL_FLAG_NONE;
+ m_blockCMEvents = true;
+
+ return updateCall(m_endCall, m_heldCall->getInfo());
+ }
+ return RES_OK;
+ }
+
+ Result CallManager::processCommonCallEvent(unsigned int callId,
+ cm_call_data_h cmIncom,
+ cm_call_data_h cmActive,
+ cm_call_data_h cmHeld)
+ {
+ if (m_blockCMEvents) {
+ ILOG("Ignore call manager state");
+
+ m_incomingCall.reset();
+ m_activeCall.reset();
+ m_heldCall.reset();
+
+ return RES_OK;
+ }
+
+ FAIL_RETURN(updateCall(m_incomingCall, cmIncom), "updateCall() failed!");
+ FAIL_RETURN(updateCall(m_activeCall, cmActive), "updateCall() failed!");
+ FAIL_RETURN(updateCall(m_heldCall, cmHeld), "updateCall() failed!");
+
+ return RES_OK;
+ }
+
+ void CallManager::callEventCb(cm_call_event_e callEvent, cm_call_event_data_h callEventData)
+ {
+ m_waitDialing = false;
+
+ if (!callEventData) {
+ ELOG("callEventData is NULL");
+ return;
+ }
+
+ CallEventType type;
+ FAIL_RETURN_VOID(convertCMEventType(callEvent, &type),
+ "convertCallManagerEventType() failed!");
+
+ DLOG("Call event changed on [%d]", type);
+
+ if (m_blockCMEvents) {
+ if (type == CallEventType::END) {
+ ILOG("Ignore call manager state");
+ return;
+ } else {
+ m_blockCMEvents = false;
+ }
+ }
+
+ if (m_slot == SimSlot::UNDEFINED) {
+ cm_multi_sim_slot_type_e cmSimSlot;
+ FAIL_RETURN_VOID(convertCMResult(
+ cm_call_event_data_get_sim_slot(callEventData, &cmSimSlot)),
+ "cm_call_event_data_get_sim_slot() failed!");
+ m_slot = convertCMSimSlot(cmSimSlot);
+ }
+
+ unsigned int callId = 0;
+ cm_call_data_h cmIncom = nullptr;
+ cm_call_data_h cmActive = nullptr;
+ cm_call_data_h cmHeld = nullptr;
+
+ FAIL_RETURN_VOID(convertCMResult(
+ cm_call_event_data_get_call_id(callEventData, &callId)),
+ "cm_call_event_data_get_call_id() failed!");
+
+ FAIL_RETURN_VOID(convertCMResult(
+ cm_call_event_data_get_incom_call(callEventData, &cmIncom)),
+ "cm_call_event_data_get_incom_call() failed!");
+
+ FAIL_RETURN_VOID(convertCMResult(
+ cm_call_event_data_get_active_call(callEventData, &cmActive)),
+ "cm_call_event_data_get_active_call() failed!");
+
+ FAIL_RETURN_VOID(convertCMResult(
+ cm_call_event_data_get_held_call(callEventData, &cmHeld)),
+ "cm_call_event_data_get_held_call() failed!");
+
+ m_endCall.reset();
+
+ switch (type) {
+ case CallEventType::END:
+ FAIL_RETURN_VOID(processEndCallEvent(callId,
+ cmIncom,
+ cmActive,
+ cmHeld),
+ "processEndCallEvent() failed!");
+ case CallEventType::ACTIVE:
+ case CallEventType::INCOMING:
+ case CallEventType::DIALING:
+ case CallEventType::HELD:
+ case CallEventType::RETRIEVED:
+ case CallEventType::SWAPPED:
+ case CallEventType::JOIN:
+ case CallEventType::SPLIT:
+ FAIL_RETURN_VOID(processCommonCallEvent(callId,
+ cmIncom,
+ cmActive,
+ cmHeld),
+ "processCommonCallEvent() failed!");
+ break;
+ default:
+ return;
+ }
+
+ if (const auto listener = m_listener.lock()) {
+ listener->onCallEvent(type);
+ }
+ }
+
+ void CallManager::dialStatusCb(cm_dial_status_e status)
+ {
+ m_waitDialing = false;
+
+ CallManagerErr err = CallManagerErr::DIAL_FAIL;
+ switch (status) {
+ case CM_DIAL_SUCCESS:
+ return;
+ case CM_DIAL_CANCEL:
+ err = CallManagerErr::DIAL_CANCEL;
+ break;
+ case CM_DIAL_FAIL:
+ err = CallManagerErr::DIAL_FAIL;
+ break;
+ case CM_DIAL_FAIL_SS:
+ err = CallManagerErr::DIAL_FAIL_SS;
+ break;
+ case CM_DIAL_FAIL_FDN:
+ err = CallManagerErr::DIAL_FAIL_FDN;
+ break;
+ case CM_DIAL_FAIL_FLIGHT_MODE:
+ err = CallManagerErr::DIAL_FLIGHT_MODE;
+ break;
+ default:
+ err = CallManagerErr::DIAL_FAIL;
+ break;
+ }
+
+ if (const auto listener = m_listener.lock()) {
+ listener->onError(err);
+ }
+ }
+
+ Result CallManager::processOutgoingCall(const std::string &telNum)
+ {
+ if (!m_waitDialing) {
+ m_waitDialing = true;
+ return dialVoiceCall(telNum);
+ }
+ return RES_FAIL;
+ }
+
+ Result CallManager::processIncomingCall(SimSlot slot)
+ {
+ if (m_incomingCall) {
+ if (m_slot == SimSlot::UNDEFINED) {
+ // TODO: need to modify when companion mode will be added
+ m_slot = SimSlot::GEAR;
+ }
+ if (const auto listener = m_listener.lock()) {
+ listener->onCallEvent(CallEventType::INCOMING);
+ }
+ return RES_OK;
+ }
+ ELOG("Incoming call is NULL");
+ return RES_FAIL;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_CALL_MANAGER_H__
+#define __CALL_UI_MODEL_IMPL_CALL_MANAGER_H__
+
+#include <call-manager-ext.h>
+
+#include "call-ui/model/ICallManager.h"
+
+#include "ICallManagerListener.h"
+#include "CallClient.h"
+#include "RejectMsgProvider.h"
+#include "IncomingCall.h"
+#include "ActiveCall.h"
+#include "HeldCall.h"
+#include "EndCall.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(CallManager);
+
+ class CallManager final :
+ public ucl::RefCountAware,
+ public ICallManager {
+ public:
+ static CallManagerSRef newInstance(const CallClientSRef &callClient,
+ ICallManagerListenerWRef listener);
+ virtual ~CallManager();
+
+ CallClient &getCallClient();
+ SimSlot getSimSlot() const;
+ ucl::Result dialVoiceCall(const std::string &number);
+ ucl::Result endCall(unsigned int callId, CallReleaseType type);
+ ucl::Result splitCalls(CallInfoSRef callInfo,
+ const IConferenceCallInfoSCRef &confCallInfo);
+ ContactInfoProviderSRef getContactInfoProvider();
+ RejectMsgProviderSRef getRejectMsgProvider();
+
+ ucl::Result processOutgoingCall(const std::string &telNum);
+ ucl::Result processIncomingCall(SimSlot slot);
+
+ // ICallManager
+
+ virtual IIncomingCallSRef getIncomingCall() override final;
+ virtual IActiveCallSRef getActiveCall() override final;
+ virtual IHeldCallSRef getHeldCall() override final;
+ virtual IEndCallSRef getEndCall() override final;
+ virtual CallMask getAvailableCalls() const override final;
+
+ private:
+ friend class ucl::ReffedObj<CallManager>;
+ CallManager(ucl::IRefCountObj &rc, const CallClientSRef &callClient,
+ ICallManagerListenerWRef listener);
+
+ ucl::Result prepare();
+ ucl::Result initCalls();
+
+ template <class TYPE, class TYPE2>
+ ucl::Result updateCall(ucl::SharedRef<TYPE> &call, TYPE2 &&data);
+
+ ucl::Result processEndCallEvent(unsigned int callId,
+ cm_call_data_h cmIncom,
+ cm_call_data_h cmActive,
+ cm_call_data_h cmHeld);
+
+ ucl::Result processCommonCallEvent(unsigned int callId,
+ cm_call_data_h cmIncom,
+ cm_call_data_h cmActive,
+ cm_call_data_h cmHeld);
+
+ void callEventCb(cm_call_event_e call_event, cm_call_event_data_h call_state_data);
+ void dialStatusCb(cm_dial_status_e status);
+
+ private:
+ CallClientSRef m_callClient;
+ RejectMsgProviderSRef m_rejectMsgProvider;
+ ContactInfoProviderSRef m_contactInfoProvider;
+ ICallManagerListenerWRef m_listener;
+ IncomingCallSRef m_incomingCall;
+ ActiveCallSRef m_activeCall;
+ HeldCallSRef m_heldCall;
+ EndCallSRef m_endCall;
+ SimSlot m_slot;
+ bool m_waitDialing;
+
+ int m_confTypeCallReq;
+ bool m_blockCMEvents;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_IMPL_CALL_MANAGER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "CallUI.h"
+
+#include <app_control.h>
+
+#include "CallClient.h"
+#include "CallManager.h"
+#include "SoundManager.h"
+
+#include "VoiceControlStateProvider.h"
+#include "IndicatorStateProvider.h"
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ CallUI::CallUI(IRefCountObj &rc):
+ RefCountAware(&rc)
+ {
+ }
+
+ CallUI::~CallUI()
+ {
+ }
+
+ void CallUI::setListener(const ICallListenerWRef &listener)
+ {
+ m_listener = listener;
+ }
+
+ Result CallUI::processAppControl(app_control_h appControl)
+ {
+ if (!appControl) {
+ FAIL_RETURN(RES_INVALID_ARGUMENTS, "appControl is NULL");
+ }
+
+ Result ret = RES_FAIL;
+
+ char *operation = nullptr;
+ int res = app_control_get_operation(appControl, &operation);
+ if (res != APP_CONTROL_ERROR_NONE) {
+ LOG_RETURN(RES_FAIL, "app_control_get_operation() failed!");
+ }
+ if (!operation) {
+ LOG_RETURN(RES_FAIL, "operation is NULL!");
+ }
+
+ char *uri = nullptr;
+ res = app_control_get_uri(appControl, &uri);
+ if (res != APP_CONTROL_ERROR_NONE) {
+ free(operation);
+ LOG_RETURN(RES_FAIL, "app_control_get_uri() failed!");
+ }
+ if (!uri) {
+ free(operation);
+ LOG_RETURN(RES_FAIL, "uri is NULL!");
+ }
+
+ if (strcmp(operation, APP_CONTROL_OPERATION_CALL) || strncmp(uri, "tel:", 4)) {
+ free(operation);
+ free(uri);
+ LOG_RETURN(RES_FAIL, "Not processed operation!");
+ }
+
+ char *tmp = nullptr;
+ if (!strncmp(uri, "tel:MT", 6)) {
+ res = app_control_get_extra_data(appControl, "sim_slot", &tmp);
+ if (res != APP_CONTROL_ERROR_NONE) {
+ ELOG("app_control_get_extra_data() failed!");
+ }
+ if (!tmp) {
+ free(operation);
+ free(uri);
+ LOG_RETURN(RES_FAIL, "Sim slot is NULL!");
+ }
+ DLOG("Sim slot [%s]", tmp);
+ free(tmp);
+
+ ret = m_callManager->processIncomingCall(
+ convertCMSimSlot(static_cast<cm_multi_sim_slot_type_e>(atoi(tmp))));
+
+ } else {
+ tmp = static_cast<char *>(uri + 4);
+ DLOG("number [%s]", tmp);
+
+ if (!tmp) {
+ free(operation);
+ free(uri);
+ LOG_RETURN(RES_FAIL, "number is NULL");
+ }
+
+ ret = m_callManager->processOutgoingCall(tmp);
+ }
+
+ free(operation);
+ free(uri);
+
+ return ret;
+ }
+
+ Result CallUI::prepare()
+ {
+ auto callClient = CallClient::newInstance();
+ if (!callClient) {
+ LOG_RETURN(RES_FAIL,
+ "Client::newInstance() failed!");
+ }
+
+ m_callManager = CallManager::newInstance(callClient, asWeak(*this));
+ if (!m_callManager) {
+ LOG_RETURN(RES_FAIL,
+ "CallManager::newInstance() failed!");
+ }
+
+ m_soundManager = SoundManager::newInstance(callClient);
+ if (!m_soundManager) {
+ LOG_RETURN(RES_FAIL,
+ "SoundManage::newInstance() failed!");
+ }
+
+ m_voiceControlPrv = VoiceControlStateProvider::newInstance();
+ if (!m_voiceControlPrv) {
+ LOG_RETURN(RES_FAIL,
+ "VoiceControlStateProvider::newInstance() failed!");
+ }
+
+ FAIL_RETURN(initInidcatorStateProvider(),
+ "Init Indicator State Provider failed!");
+
+ return RES_OK;
+ }
+
+ Result CallUI::initInidcatorStateProvider()
+ {
+ m_indicatorStPrv = IndicatorStateProvider::newInstance();
+ if (!m_indicatorStPrv) {
+ LOG_RETURN(RES_FAIL, "IndicatorStateProvider::newInstance() failed!");
+ }
+
+ auto connStateSource = ConnectionStateSource::newInstance();
+ if (!connStateSource) {
+ LOG_RETURN(RES_FAIL,
+ "ConnectionStateSource::newInstance() failed!");
+ }
+ FAIL_RETURN(m_indicatorStPrv->setStateSource(
+ IndicatorProperty::NW_CONNECTION, connStateSource),
+ "setStateSource() failed!");
+
+ auto rssiStSrc = RssiStateSource::newInstance();
+ if (!rssiStSrc) {
+ LOG_RETURN(RES_FAIL,
+ "RssiStateSource::newInstance() failed!");
+ }
+ FAIL_RETURN(m_indicatorStPrv->setStateSource(
+ IndicatorProperty::RSSI, rssiStSrc),
+ "setStateSource() failed!");
+
+ auto batteryStSrc = BatteryStateSource::newInstance();
+ if (!batteryStSrc) {
+ LOG_RETURN(RES_FAIL,
+ "BatteryStateSource::newInstance() failed!");
+ }
+ FAIL_RETURN(m_indicatorStPrv->setStateSource(
+ IndicatorProperty::BATTERY, batteryStSrc),
+ "setStateSource() failed!");
+
+ auto voiceControlStSrc =
+ VoiceControlStateSource::newInstance(m_voiceControlPrv);
+ if (!voiceControlStSrc) {
+ LOG_RETURN(RES_FAIL,
+ "VoiceControlStateSource::newInstance() failed!");
+ }
+ FAIL_RETURN(m_indicatorStPrv->setStateSource(
+ IndicatorProperty::VOICE_CONTROL, voiceControlStSrc),
+ "setStateSource() failed!");
+
+ m_simSlotStSrc = makeShared<SimSlotStateSource>(
+ m_callManager->getSimSlot(), getForwardedCallStatus());
+ FAIL_RETURN(m_indicatorStPrv->setStateSource(
+ IndicatorProperty::SIM_SLOT, m_simSlotStSrc),
+ "setStateSource() failed!");
+
+ m_hdCallStSrc = makeShared<HdVoiceStateSource>(
+ getHDVoiceStatus());
+ FAIL_RETURN(m_indicatorStPrv->setStateSource(
+ IndicatorProperty::HD_VOICE, m_hdCallStSrc),
+ "setStateSource() failed!");
+
+ return RES_OK;
+ }
+
+ ICallManagerSRef CallUI::getCallManager()
+ {
+ return m_callManager;
+ }
+
+ ISoundManagerSRef CallUI::getSoundManager()
+ {
+ return m_soundManager;
+ }
+
+ IIndicatorStateProviderSRef CallUI::getIndicatorStateProvider()
+ {
+ return m_indicatorStPrv;
+ }
+
+ ICallInfoSCRef CallUI::getCurrentCallInfo() const
+ {
+ CallMask calls = m_callManager->getAvailableCalls();
+ if (!calls) {
+ DLOG("No available calls");
+ return {};
+ } else if (calls & CALL_FLAG_INCOMING) {
+ return m_callManager->getIncomingCall()->getInfo();
+ } else if (calls & CALL_FLAG_ACTIVE) {
+ return m_callManager->getActiveCall()->getInfo();
+ } else if (calls & CALL_FLAG_HELD) {
+ return m_callManager->getHeldCall()->getInfo();
+ } else if (calls & CALL_FLAG_END) {
+ return m_callManager->getEndCall()->getInfo();
+ }
+ return {};
+ }
+
+ bool CallUI::getHDVoiceStatus() const
+ {
+ ICallInfoSCRef info = getCurrentCallInfo();
+ if (info) {
+ return info->isHDVoice();
+ }
+ return false;
+ }
+
+ bool CallUI::getForwardedCallStatus() const
+ {
+ ICallInfoSCRef info = getCurrentCallInfo();
+ if (info) {
+ return info->isForwarded();
+ }
+ return false;
+ }
+
+ void CallUI::updateHdVoiceStateSource()
+ {
+ m_hdCallStSrc->updateState(getHDVoiceStatus());
+ }
+
+ void CallUI::updateSimSlotStateSource()
+ {
+ m_simSlotStSrc->updateSimSlot(m_callManager->getSimSlot(),
+ getForwardedCallStatus());
+ }
+
+ void CallUI::onCallEvent(CallEventType type)
+ {
+ updateSimSlotStateSource();
+ updateHdVoiceStateSource();
+
+ if (const auto listener = m_listener.lock()) {
+ listener->onCallEvent(type);
+ }
+ }
+
+ void CallUI::onError(CallManagerErr err)
+ {
+ auto callErr = CallErr::DIAL_FAIL;
+ switch (err) {
+ case CallManagerErr::DIAL_CANCEL:
+ callErr = CallErr::DIAL_CANCEL;
+ break;
+ case CallManagerErr::DIAL_FLIGHT_MODE:
+ callErr = CallErr::DIAL_FLIGHT_MODE;
+ break;
+ default:
+ callErr = CallErr::DIAL_FAIL;
+ break;
+ }
+
+ if (const auto listener = m_listener.lock()) {
+ listener->onError(callErr);
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_CALL_UI_H__
+#define __CALL_UI_MODEL_IMPL_CALL_UI_H__
+
+#include "call-ui/model/ICallUI.h"
+
+#include "CallManager.h"
+#include "ICallManagerListener.h"
+#include "SoundManager.h"
+#include "ConnectionStateSource.h"
+#include "RssiStateSource.h"
+#include "BatteryStateSource.h"
+#include "VoiceControlStateSource.h"
+#include "SimSlotStateSource.h"
+#include "HdVoiceStateSource.h"
+#include "IndicatorStateProvider.h"
+#include "VoiceControlStateProvider.h"
+
+#include "call-ui/model/types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(CallUI);
+
+ class CallUI final :
+ public ucl::RefCountAware,
+ public ICallUI,
+ public ICallManagerListener {
+ public:
+ virtual ~CallUI();
+
+ // ICallUI
+
+ virtual void setListener(const ICallListenerWRef &listener) override final;
+ virtual ucl::Result processAppControl(app_control_h appControl) override final;
+ virtual ISoundManagerSRef getSoundManager() override final;
+ virtual ICallManagerSRef getCallManager() override final;
+ virtual IIndicatorStateProviderSRef getIndicatorStateProvider() override final;
+
+ // ICallManagerListener
+
+ virtual void onCallEvent(CallEventType type) override final;
+ virtual void onError(CallManagerErr err) override final;
+
+ private:
+ friend class CallUIBuilder;
+ friend class ucl::ReffedObj<CallUI>;
+ CallUI(ucl::IRefCountObj &rc);
+
+ ucl::Result prepare();
+
+ ucl::Result initInidcatorStateProvider();
+
+ void updateHdVoiceStateSource();
+ void updateSimSlotStateSource();
+ ICallInfoSCRef getCurrentCallInfo() const;
+ bool getHDVoiceStatus() const;
+ bool getForwardedCallStatus() const;
+
+ private:
+ CallManagerSRef m_callManager;
+ SoundManagerSRef m_soundManager;
+ ICallListenerWRef m_listener;
+ SimSlotStateSourceSRef m_simSlotStSrc;
+ HdVoiceStateSourceSRef m_hdCallStSrc;
+ IndicatorStateProviderSRef m_indicatorStPrv;
+ VoiceControlStateProviderSRef m_voiceControlPrv;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_IMPL_CALL_UI_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "ConferenceCallInfo.h"
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ ConferenceCallInfo::ConferenceCallInfo():
+ m_callId(-1)
+ {
+ }
+
+ ConferenceCallInfo::~ConferenceCallInfo()
+ {
+ }
+
+ ConferenceCallInfoSRef ConferenceCallInfo::newInstance(
+ cm_conf_call_data_t *confCallData,
+ ContactInfoProviderSRef callInfoProvider)
+ {
+ if (!confCallData) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "callData is NULL");
+ }
+
+ auto result = makeShared<ConferenceCallInfo>();
+ FAIL_RETURN_VALUE(result->prepare(confCallData, callInfoProvider), {}, "result->prepare() failed!");
+ return result;
+ }
+
+ Result ConferenceCallInfo::prepare(
+ cm_conf_call_data_t *confCallData,
+ ContactInfoProviderSRef callInfoProvider)
+ {
+ Result res = convertCMResult(
+ cm_conf_call_data_get_call_id(confCallData, &m_callId));
+ FAIL_RETURN(res, "cm_conf_call_data_get_call_id() failed!");
+
+ char *number = nullptr;
+ res = convertCMResult(
+ cm_conf_call_data_get_call_number(confCallData, &number));
+ FAIL_RETURN(res, "cm_conf_call_data_get_call_number() failed!");
+ m_phoneNum = nz(number);
+ // XXX: According to documentation it must be free, but it leads to crash
+// free(number);
+
+ int personId = -1;
+ res = convertCMResult(
+ cm_conf_call_data_get_person_id(confCallData, &personId));
+ FAIL_RETURN(res, "cm_conf_call_data_get_person_id() failed!");
+
+ if (personId >= 0 && callInfoProvider) {
+ m_contactInfo = callInfoProvider->createContactInfo(personId);
+ if (!m_contactInfo) {
+ LOG_RETURN_VALUE(RES_FAIL, RES_FAIL, "createContactInfo() failed!");
+ }
+ }
+ return RES_OK;
+ }
+
+ unsigned int ConferenceCallInfo::getCallId() const
+ {
+ return m_callId;
+ }
+
+ const std::string &ConferenceCallInfo::getPhoneNumber() const
+ {
+ return m_phoneNum;
+ }
+
+ IContactInfoSCRef ConferenceCallInfo::getContactInfo() const
+ {
+ return m_contactInfo;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_CONFERENCE_CALL_INFO_H__
+#define __CALL_UI_MODEL_IMPL_CONFERENCE_CALL_INFO_H__
+
+#include <call-manager-ext.h>
+
+#include "call-ui/model/IConferenceCallInfo.h"
+
+#include "ContactInfoProvider.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(ConferenceCallInfo);
+
+ class ConferenceCallInfo final : public IConferenceCallInfo {
+ public:
+ static ConferenceCallInfoSRef newInstance(
+ cm_conf_call_data_t *confCallData,
+ ContactInfoProviderSRef callInfoProvider);
+ virtual ~ConferenceCallInfo();
+
+ // IConferenceCallInfo
+
+ virtual unsigned int getCallId() const override final;
+ virtual const std::string &getPhoneNumber() const override final;
+ virtual IContactInfoSCRef getContactInfo() const override final;
+
+ private:
+ friend class ucl::ReffedObj<ConferenceCallInfo>;
+ ConferenceCallInfo();
+
+ ucl::Result prepare(cm_conf_call_data_t *confCallData,
+ ContactInfoProviderSRef callInfoProvider);
+ private:
+ unsigned int m_callId;
+ std::string m_phoneNum;
+ ContactInfoSRef m_contactInfo;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_IMPL_CONFERENCE_CALL_INFO_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "ConnectionStateSource.h"
+
+#include "call-ui/model/IndicatorState.h"
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ ConnectionStateSource::Bits::Bits():
+ property(convertEnumValueToInt(IndicatorProperty::NW_CONNECTION)),
+ connState(convertEnumValueToInt(ConnectionType::NONE)),
+ packetDirection(convertEnumValueToInt(PacketDirection::NONE))
+ {
+ }
+
+ ConnectionStateSource::Bits::Bits(const IndicatorState &state):
+ value(state.value)
+ {
+ if (property != convertEnumValueToInt(IndicatorProperty::NW_CONNECTION)) {
+ ELOG("State of incorrect property type [%d]", property);
+ *this = {};
+ }
+ }
+
+ ConnectionStateSource::ConnectionStateSource()
+ {
+ }
+
+ ConnectionStateSource::~ConnectionStateSource()
+ {
+ unsignSystStateCallbacks();
+ }
+
+ ConnectionStateSourceSRef ConnectionStateSource::newInstance()
+ {
+ auto result = makeShared<ConnectionStateSource>();
+ FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+ return result;
+ }
+
+ Result ConnectionStateSource::prepare()
+ {
+ FAIL_RETURN(addSysStateCallbacks(), "addSysStateCallbacks() failed!");
+
+ updateConnType();
+ updatePacketDir();
+
+ return RES_OK;
+ }
+
+ bool ConnectionStateSource::isWifiConnected() const
+ {
+ int state = VCONFKEY_WIFI_UNCONNECTED;
+ if (vconf_get_int(VCONFKEY_WIFI_STATE, &state) < 0) {
+ ELOG("Get WiFi connection state failed");
+ return false;
+ }
+ return (state == VCONFKEY_WIFI_CONNECTED);
+ }
+
+ bool ConnectionStateSource::isDnetConnected() const
+ {
+ int status = VCONFKEY_DNET_OFF;
+ if (vconf_get_int(VCONFKEY_DNET_STATE, &status) < 0) {
+ ELOG("Get Dnet status failed!");
+ return false;
+ }
+ return (status != VCONFKEY_DNET_OFF);
+ }
+
+ ConnectionType ConnectionStateSource::getConnTypeByWiFiStrength() const
+ {
+ int wifiStrength = 0;
+ if (vconf_get_int(VCONFKEY_WIFI_STRENGTH, &wifiStrength) == 0) {
+ switch (wifiStrength) {
+ case 1: return ConnectionType::WIFI_01;
+ case 2: return ConnectionType::WIFI_02;
+ case 3: return ConnectionType::WIFI_03;
+ case 4: return ConnectionType::WIFI_04;
+ default: return ConnectionType::WIFI_00;
+ }
+ }
+ ELOG("Get WiFi connection type failed!");
+ return ConnectionType::NONE;
+ }
+
+ ConnectionType ConnectionStateSource::getConnTypeByTelephonyPsType() const
+ {
+ int type = 0;
+ if (vconf_get_int(VCONFKEY_TELEPHONY_PSTYPE, &type) == 0) {
+ switch(type) {
+ case VCONFKEY_TELEPHONY_PSTYPE_HSDPA :
+ case VCONFKEY_TELEPHONY_PSTYPE_HSUPA :
+ return ConnectionType::HSDPA_H;
+ case VCONFKEY_TELEPHONY_PSTYPE_HSPA :
+ return ConnectionType::HSPA_H_PLUS;
+ default :
+ return ConnectionType::UMTS_3G;
+ }
+ }
+ ELOG("Get connection PS type failed!");
+ return ConnectionType::NONE;
+ }
+
+ ConnectionType ConnectionStateSource::getConnTypeByTelephonySvcType() const
+ {
+ int svcType = 0;
+ if (vconf_get_int(VCONFKEY_TELEPHONY_SVCTYPE, &svcType) == 0) {
+ switch(svcType) {
+ case VCONFKEY_TELEPHONY_SVCTYPE_2G :
+ case VCONFKEY_TELEPHONY_SVCTYPE_2_5G :
+ return ConnectionType::GPRS_G;
+ case VCONFKEY_TELEPHONY_SVCTYPE_3G :
+ return getConnTypeByTelephonyPsType();
+ case VCONFKEY_TELEPHONY_SVCTYPE_2_5G_EDGE :
+ return ConnectionType::EDGE_E;
+ case VCONFKEY_TELEPHONY_SVCTYPE_LTE :
+ return ConnectionType::LTE_4G;
+ default :
+ return ConnectionType::NONE;
+ }
+ }
+ ELOG("Get connection SVC type failed!");
+ return ConnectionType::NONE;
+ }
+
+ bool ConnectionStateSource::updateConnTypeBits(ConnectionType connType)
+ {
+ int connTypeInt = convertEnumValueToInt(connType);
+ if (connTypeInt != m_bits.connState) {
+ m_bits.connState = connTypeInt;
+ return true;
+ }
+ return false;
+ }
+
+ bool ConnectionStateSource::updatePacketDirBits(PacketDirection direction)
+ {
+ int directionInt = convertEnumValueToInt(direction);
+ if (directionInt != m_bits.packetDirection) {
+ m_bits.packetDirection = directionInt;
+ return true;
+ }
+ return false;
+ }
+
+ bool ConnectionStateSource::updateConnType()
+ {
+ if (isFlightModeActive()) {
+ return updateConnTypeBits(ConnectionType::NONE);
+ }
+
+ if (isWifiConnected()) {
+ return updateConnTypeBits(getConnTypeByWiFiStrength());
+ }
+
+ if (!isDnetConnected()) {
+ return updateConnTypeBits(ConnectionType::NONE);
+ }
+
+ return updateConnTypeBits(getConnTypeByTelephonySvcType());
+ }
+
+ void ConnectionStateSource::onConnTypeChangedCb(keynode_t *node)
+ {
+ bool needNotify = updateConnType();
+ if (updatePacketDir()) {
+ needNotify = true;
+ }
+
+ if (needNotify && m_handler) {
+ m_handler();
+ }
+ }
+
+ PacketDirection ConnectionStateSource::getPacketDirByWiFiState() const
+ {
+ int transferState = 0;
+ if (vconf_get_int(VCONFKEY_WIFI_TRANSFER_STATE, &transferState) == 0) {
+ switch (transferState) {
+ case VCONFKEY_WIFI_TRANSFER_STATE_RX:
+ return PacketDirection::IN;
+ case VCONFKEY_WIFI_TRANSFER_STATE_TX:
+ return PacketDirection::OUT;
+ case VCONFKEY_WIFI_TRANSFER_STATE_TXRX:
+ return PacketDirection::INOUT;
+ default:
+ return PacketDirection::NO_INPUT;
+ }
+ }
+ ELOG("Get WiFi transfer state failed");
+ return PacketDirection::NONE;
+ }
+
+ PacketDirection ConnectionStateSource::getPacketDirByPacketState() const
+ {
+ int state = 0;
+ if (vconf_get_int(VCONFKEY_PACKET_STATE, &state) == 0) {
+ switch (state) {
+ case VCONFKEY_PACKET_RX: return PacketDirection::IN;
+ case VCONFKEY_PACKET_TX: return PacketDirection::OUT;
+ case VCONFKEY_PACKET_RXTX: return PacketDirection::INOUT;
+ default: return PacketDirection::NO_INPUT;
+ }
+ }
+ ELOG("Get packet state failed");
+ return PacketDirection::NONE;
+ }
+
+ bool ConnectionStateSource::updatePacketDir()
+ {
+ PacketDirection direction = PacketDirection::NONE;
+
+ if (isFlightModeActive()) {
+ return updatePacketDirBits(direction);
+ }
+
+ if (isWifiConnected()) {
+ direction = getPacketDirByWiFiState();
+ } else if (isDnetConnected()) {
+ direction = getPacketDirByPacketState();
+ }
+ return updatePacketDirBits(direction);
+ }
+
+ void ConnectionStateSource::onPacketStateChangedCb(keynode_t *node)
+ {
+ ILOG();
+ if (updatePacketDir() && m_handler) {
+ m_handler();
+ }
+ }
+
+ Result ConnectionStateSource::addSysStateCallbacks()
+ {
+ // CONNECTION
+ int res = vconf_notify_key_changed(VCONFKEY_WIFI_STRENGTH,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ res = vconf_notify_key_changed(VCONFKEY_WIFI_STATE,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ res = vconf_notify_key_changed(VCONFKEY_DNET_STATE,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_PSTYPE,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_SVCTYPE,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_SIM_SLOT,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_EMERGENCY_CB_MODE_CDMA,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
+
+ // PACKET
+ res = vconf_notify_key_changed(VCONFKEY_PACKET_STATE,
+ CALLBACK_B(ConnectionStateSource::onPacketStateChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ res = vconf_notify_key_changed(VCONFKEY_WIFI_TRANSFER_STATE,
+ CALLBACK_B(ConnectionStateSource::onPacketStateChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ return RES_OK;
+
+ }
+
+ void ConnectionStateSource::unsignSystStateCallbacks()
+ {
+ // CONNECTION
+ vconf_ignore_key_changed(VCONFKEY_WIFI_STRENGTH,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
+ vconf_ignore_key_changed(VCONFKEY_WIFI_STATE,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
+ vconf_ignore_key_changed(VCONFKEY_DNET_STATE,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_PSTYPE,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_SVCTYPE,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_SIM_SLOT,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_EMERGENCY_CB_MODE_CDMA,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
+
+ // PACKET
+ vconf_ignore_key_changed(VCONFKEY_PACKET_STATE,
+ CALLBACK_B(ConnectionStateSource::onPacketStateChangedCb));
+ vconf_ignore_key_changed(VCONFKEY_WIFI_TRANSFER_STATE,
+ CALLBACK_B(ConnectionStateSource::onPacketStateChangedCb));
+
+ }
+
+ IndicatorState ConnectionStateSource::getState() const
+ {
+ return {m_bits.value};
+ }
+
+ void ConnectionStateSource::setStateChangeHandler(const NotiHandler &handler)
+ {
+ m_handler = handler;
+ }
+
+ ConnectionType getConnectionState(IndicatorState state)
+ {
+ return static_cast<ConnectionType>(
+ ConnectionStateSource::Bits(state).connState);
+ }
+
+ PacketDirection getPacketDirection(IndicatorState state)
+ {
+ return static_cast<PacketDirection>(
+ ConnectionStateSource::Bits(state).packetDirection);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_CONNECTION_STATE_SOURCE_H__
+#define __CALL_UI_MODEL_IMPL_CONNECTION_STATE_SOURCE_H__
+
+#include "IIndicatorStateSource.h"
+
+#include <vconf.h>
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(ConnectionStateSource);
+
+ class ConnectionStateSource final : public IIndicatorStateSource {
+ public:
+ static ConnectionStateSourceSRef newInstance();
+ virtual ~ConnectionStateSource();
+
+ // IIndicatorStateSource
+
+ virtual IndicatorState getState() const override final;
+ virtual void setStateChangeHandler(const NotiHandler &handler) override final;
+
+ private:
+ friend class ucl::ReffedObj<ConnectionStateSource>;
+ ConnectionStateSource();
+
+ ucl::Result prepare();
+
+ ucl::Result addSysStateCallbacks();
+ void unsignSystStateCallbacks();
+
+ void onConnTypeChangedCb(keynode_t *node);
+ void onPacketStateChangedCb(keynode_t *node);
+
+ bool isWifiConnected() const;
+ bool isDnetConnected() const;
+
+ bool updateConnTypeBits(ConnectionType connType);
+ ConnectionType getConnTypeByTelephonyPsType() const;
+ ConnectionType getConnTypeByTelephonySvcType() const;
+ ConnectionType getConnTypeByWiFiStrength() const;
+ bool updateConnType();
+
+ bool updatePacketDirBits(PacketDirection packetType);
+ PacketDirection getPacketDirByWiFiState() const;
+ PacketDirection getPacketDirByPacketState() const;
+ bool updatePacketDir();
+
+ public:
+ union Bits {
+ struct {
+ uint8_t property : 4;
+ uint8_t connState : 8;
+ uint8_t packetDirection : 4;
+ };
+ uint64_t value;
+
+ Bits();
+ Bits(const IndicatorState &state);
+ };
+
+ private:
+ Bits m_bits;
+ NotiHandler m_handler;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_IMPL_CONNECTION_STATE_SOURCE_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "ContactInfo.h"
+
+#include <call-manager-extension.h>
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ ContactInfo::ContactInfo(int personId,
+ const std::string &name,
+ const std::string &imagePath,
+ ContactNameSourceType type):
+ m_personId(personId),
+ m_name(name),
+ m_imagePath(imagePath),
+ m_nameSource(type)
+ {
+ }
+
+ ContactInfo::~ContactInfo()
+ {
+ }
+
+ ContactInfoSRef ContactInfo::newInstance(int personId,
+ const std::string &name,
+ const std::string &imagePath,
+ ContactNameSourceType type)
+ {
+ return makeShared<ContactInfo>(personId, name, imagePath, type);
+ }
+
+ const std::string &ContactInfo::getName() const
+ {
+ return m_name;
+ }
+
+ const std::string &ContactInfo::getImagePath() const
+ {
+ return m_imagePath;
+ }
+
+ ContactNameSourceType ContactInfo::getNameSourceType() const
+ {
+ return m_nameSource;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_CONTACT_INFO_H__
+#define __CALL_UI_MODEL_IMPL_CONTACT_INFO_H__
+
+#include <contacts_types.h>
+
+#include "call-ui/model/IContactInfo.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(ContactInfo);
+
+ class ContactInfo final : public IContactInfo {
+ public:
+ static ContactInfoSRef newInstance(int personId,
+ const std::string &name,
+ const std::string &imagePath,
+ ContactNameSourceType type);
+ virtual ~ContactInfo();
+
+ // IContactInfo
+
+ virtual const std::string &getName() const override final;
+ virtual const std::string &getImagePath() const override final;
+ virtual ContactNameSourceType getNameSourceType() const override final;
+
+ private:
+ friend class ucl::ReffedObj<ContactInfo>;
+ ContactInfo(int personId,
+ const std::string &name,
+ const std::string &imagePath,
+ ContactNameSourceType type);
+
+ private:
+ int m_personId;
+ std::string m_name;
+ std::string m_imagePath;
+ ContactNameSourceType m_nameSource;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_IMPL_CONTACT_INFO_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "ContactInfoProvider.h"
+
+#include <contacts.h>
+#include <contacts_service.h>
+#include <contacts_errors.h>
+
+#include "common.h"
+
+namespace callui { namespace { namespace impl {
+
+ using namespace ucl;
+
+ inline ContactNameSourceType convertContactNameSourceType(contacts_display_name_source_type_e cdbType)
+ {
+ switch (cdbType) {
+ case CONTACTS_DISPLAY_NAME_SOURCE_TYPE_INVALID: return ContactNameSourceType::INVALID;
+ case CONTACTS_DISPLAY_NAME_SOURCE_TYPE_EMAIL: return ContactNameSourceType::EMAIL;
+ case CONTACTS_DISPLAY_NAME_SOURCE_TYPE_NUMBER: return ContactNameSourceType::NUMBER;
+ case CONTACTS_DISPLAY_NAME_SOURCE_TYPE_NICKNAME: return ContactNameSourceType::NICKNAME;
+ case CONTACTS_DISPLAY_NAME_SOURCE_TYPE_COMPANY: return ContactNameSourceType::COMPANY;
+ case CONTACTS_DISPLAY_NAME_SOURCE_TYPE_NAME: return ContactNameSourceType::NAME;
+ default:
+ return ContactNameSourceType::INVALID;
+ }
+ }
+
+}}}
+
+namespace callui {
+
+ using namespace ucl;
+
+ ContactInfoProvider::ContactInfoProvider():
+ m_isConnected(false)
+ {
+
+ }
+
+ ContactInfoProvider::~ContactInfoProvider()
+ {
+ if (m_isConnected) {
+ contacts_disconnect();
+ }
+ }
+
+ ContactInfoProviderSRef ContactInfoProvider::newInstance()
+ {
+ auto result = makeShared<ContactInfoProvider>();
+ FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+ return result;
+ }
+
+ Result ContactInfoProvider::prepare()
+ {
+ auto res = contacts_connect();
+ if (res != CONTACTS_ERROR_NONE) {
+ LOG_RETURN(RES_FAIL, "contacts_connect() failed! res[%d] msg[%s]",
+ res, get_error_message(res));
+ }
+ m_isConnected = true;
+
+ return RES_OK;
+ }
+
+ ContactInfoSRef ContactInfoProvider::createContactInfo(int contactId)
+ {
+ DLOG("Try create contact info for ID [%d]", contactId);
+
+ std::string contactName;
+ std::string contactImagePath;
+ ContactNameSourceType contactNameSource;
+
+ contacts_filter_h filter = nullptr;
+ contacts_list_h list = nullptr;
+ contacts_query_h query = nullptr;
+ contacts_record_h record = nullptr;
+
+ int ret = CONTACTS_ERROR_NONE;
+ do {
+ ret = contacts_filter_create(_contacts_contact._uri,
+ &filter);
+ if (ret != CONTACTS_ERROR_NONE) {
+ LOG_BREAK(RES_FAIL,
+ "contacts_filter_create() failed!"
+ "res[%d] res_msg[%s]",
+ ret, get_error_message(ret));
+ }
+
+ ret = contacts_filter_add_int(filter,
+ _contacts_contact.person_id,
+ CONTACTS_MATCH_EQUAL, contactId);
+ if (ret != CONTACTS_ERROR_NONE) {
+ LOG_BREAK(RES_FAIL,
+ "contacts_filter_add_int() failed!"
+ "res[%d] res_msg[%s]",
+ ret, get_error_message(ret));
+ }
+
+ ret = contacts_query_create(_contacts_contact._uri, &query);
+ if (ret != CONTACTS_ERROR_NONE) {
+ LOG_BREAK(RES_FAIL,
+ "contacts_query_create() failed!"
+ "res[%d] res_msg[%s]",
+ ret, get_error_message(ret));
+ }
+
+ ret = contacts_query_set_filter(query, filter);
+ if (ret != CONTACTS_ERROR_NONE) {
+ LOG_BREAK(RES_FAIL,
+ "contacts_query_set_filter() failed!"
+ "res[%d] res_msg[%s]",
+ ret, get_error_message(ret));
+ }
+
+ ret = contacts_db_get_records_with_query(query, 0, 1, &list);
+ if (ret != CONTACTS_ERROR_NONE) {
+ LOG_BREAK(RES_FAIL,
+ "contacts_db_get_records_with_query() failed!"
+ "res[%d] res_msg[%s]",
+ ret, get_error_message(ret));
+ }
+
+ ret = contacts_list_get_current_record_p(list, &record);
+ if (ret != CONTACTS_ERROR_NONE) {
+ LOG_BREAK(RES_FAIL,
+ "contacts_list_get_current_record_p() failed!"
+ "res[%d] res_msg[%s]",
+ ret, get_error_message(ret));
+ }
+
+ if (record) {
+ char *name = nullptr;
+ contacts_record_get_str_p(record,
+ _contacts_contact.display_name, &name);
+ contactName = nz(name);
+
+ int type = CONTACTS_DISPLAY_NAME_SOURCE_TYPE_INVALID;
+ contacts_record_get_int(record,
+ _contacts_contact.display_source_type, &type);
+ contactNameSource = impl::convertContactNameSourceType(
+ static_cast<contacts_display_name_source_type_e>(type));
+
+ int count = 0;
+ contacts_record_get_child_record_count(record,
+ _contacts_contact.image, &count);
+ if (count > 0) {
+ char *imgPath = nullptr;
+ contacts_record_h childRecord = NULL;
+ contacts_record_get_child_record_at_p(record,
+ _contacts_contact.image, 0, &childRecord);
+ contacts_record_get_str_p(childRecord,
+ _contacts_image.path, &imgPath);
+ contactImagePath = nz(imgPath);
+ }
+ }
+ } while (false);
+
+ contacts_list_destroy(list, true);
+ contacts_filter_destroy(filter);
+ contacts_query_destroy(query);
+
+ if (ret != CONTACTS_ERROR_NONE) {
+ return {};
+ }
+
+ DLOG("Contact ID [%d]", contactId);
+ DLOG("Contact name [%s]", contactName.c_str());
+ DLOG("Contact image path [%s]", contactImagePath.c_str());
+
+ return ContactInfo::newInstance(contactId,
+ contactName,
+ contactImagePath,
+ contactNameSource);
+ }
+
+}
+
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_CONTACT_INFO_PROVIDER_H__
+#define __CALL_UI_MODEL_IMPL_CONTACT_INFO_PROVIDER_H__
+
+#include "ContactInfo.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(ContactInfoProvider);
+
+ class ContactInfoProvider {
+ public:
+ static ContactInfoProviderSRef newInstance();
+ virtual ~ContactInfoProvider();
+
+ ContactInfoSRef createContactInfo(int contactId);
+
+ private:
+ friend class ucl::ReffedObj<ContactInfoProvider>;
+ ContactInfoProvider();
+
+ ucl::Result prepare();
+
+ private:
+ bool m_isConnected;
+ };
+}
+
+#endif // __CALL_UI_MODEL_IMPL_CONTACT_INFO_PROVIDER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "EndCall.h"
+
+#include "CallManager.h"
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ EndCall::EndCall(CallManagerWRef cm, ICallInfoSCRef callInfo):
+ m_cm(cm),
+ m_callInfo(callInfo),
+ m_callbackInProgress(false)
+ {
+ }
+
+ EndCall::~EndCall()
+ {
+ }
+
+ EndCallSRef EndCall::newInstance(CallManagerWRef cm, ICallInfoSCRef callInfo)
+ {
+ if (!cm) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "cm is NULL");
+ }
+
+ if (!callInfo) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "callInfo is NULL");
+ }
+ return makeShared<EndCall>(cm, callInfo);
+ }
+
+ ICallInfoSCRef EndCall::getInfo() const
+ {
+ return m_callInfo;
+ }
+
+ Result EndCall::callBack()
+ {
+ if (m_callbackInProgress) {
+ LOG_RETURN(RES_OK, "Callback already in progress");
+ }
+
+ const auto cm = m_cm.lock();
+ if (!cm) {
+ LOG_RETURN(RES_FAIL, "Call Manager is NULL");
+ }
+
+ auto res = cm->dialVoiceCall(m_callInfo->getPhoneNumber());
+ if (res == RES_OK) {
+ m_callbackInProgress = true;
+ }
+ return res;
+ }
+
+ Result EndCall::writeMessage()
+ {
+ UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_END_CALL_H__
+#define __CALL_UI_MODEL_IMPL_END_CALL_H__
+
+#include <call-manager-ext.h>
+
+#include "call-ui/model/IEndCall.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(CallManager);
+
+ UCL_DECLARE_REF_ALIASES(EndCall);
+
+ class EndCall final : public IEndCall {
+ public:
+ static EndCallSRef newInstance(CallManagerWRef cm, ICallInfoSCRef callInfo);
+
+ virtual ~EndCall();
+
+ // IEndCall
+
+ virtual ICallInfoSCRef getInfo() const override final;
+ virtual ucl::Result callBack() override final;
+ virtual ucl::Result writeMessage() override final;
+
+ private:
+ friend class ucl::ReffedObj<EndCall>;
+ EndCall(CallManagerWRef cm, ICallInfoSCRef callInfo);
+
+ ucl::Result prepare();
+
+ private:
+ CallManagerWRef m_cm;
+ ICallInfoSCRef m_callInfo;
+ bool m_callbackInProgress;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_IMPL_END_CALL_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "HdVoiceStateSource.h"
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ HdVoiceStateSource::Bits::Bits():
+ property(convertEnumValueToInt(IndicatorProperty::HD_VOICE)),
+ isEnable(0)
+ {
+ }
+
+ HdVoiceStateSource::Bits::Bits(const IndicatorState &state):
+ value(state.value)
+ {
+ if (property != convertEnumValueToInt(IndicatorProperty::HD_VOICE)) {
+ ELOG("State of incorrect property type [%d]", property);
+ *this = {};
+ }
+ }
+
+ HdVoiceStateSource::HdVoiceStateSource(bool isEnable)
+ {
+ m_bits.isEnable = isEnable;
+ }
+
+ HdVoiceStateSource::~HdVoiceStateSource()
+ {
+ }
+
+ void HdVoiceStateSource::updateState(bool isEnable)
+ {
+ if (m_bits.isEnable != isEnable) {
+ m_bits.isEnable = isEnable;
+
+ if (m_handler) {
+ m_handler();
+ }
+ }
+ }
+
+ IndicatorState HdVoiceStateSource::getState() const
+ {
+ return {m_bits.value};
+ }
+
+ void HdVoiceStateSource::setStateChangeHandler(const NotiHandler &handler)
+ {
+ m_handler = handler;
+ }
+
+ bool getHDVoiceState(IndicatorState state)
+ {
+ return HdVoiceStateSource::Bits(state).isEnable;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_HD_VOICE_STATE_SOURCE_H__
+#define __CALL_UI_MODEL_IMPL_HD_VOICE_STATE_SOURCE_H__
+
+#include "IIndicatorStateSource.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(HdVoiceStateSource);
+
+ class HdVoiceStateSource final : public IIndicatorStateSource {
+ public:
+ HdVoiceStateSource(bool isEnable);
+ virtual ~HdVoiceStateSource();
+ void updateState(bool isEnable);
+
+ // IIndicatorStateSource
+
+ virtual IndicatorState getState() const override final;
+ virtual void setStateChangeHandler(const NotiHandler &handler) override final;
+
+ public:
+ union Bits {
+ struct {
+ uint8_t property : 4;
+ uint8_t isEnable : 1;
+ };
+ uint64_t value;
+
+ Bits();
+ Bits(const IndicatorState &state);
+ };
+
+ private:
+ Bits m_bits;
+ NotiHandler m_handler;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_IMPL_HD_VOICE_STATE_SOURCE_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "HeldCall.h"
+
+#include "CallManager.h"
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ HeldCall::HeldCall(CallManagerWRef cm, cm_call_data_h callData):
+ m_cm(cm)
+ {
+ }
+
+ HeldCall::~HeldCall()
+ {
+ }
+
+ HeldCallSRef HeldCall::newInstance(CallManagerWRef cm, cm_call_data_h callData)
+ {
+ if (!cm) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "cm is NULL");
+ }
+
+ if (!callData) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "callData is NULL");
+ }
+
+ auto result = makeShared<HeldCall>(cm, callData);
+ FAIL_RETURN_VALUE(result->prepare(callData), {}, "result->prepare() failed!");
+ return result;
+ }
+
+ Result HeldCall::prepare(cm_call_data_h callData)
+ {
+ const auto cm = m_cm.lock();
+ if (!cm) {
+ LOG_RETURN(RES_FAIL, "Call Manager is NULL");
+ }
+ m_callInfo = CallInfo::newInstance(cm->getCallClient(),
+ callData,
+ cm->getContactInfoProvider());
+ if (!m_callInfo) {
+ LOG_RETURN_VALUE(RES_FAIL, RES_FAIL, "CallInfo::newInstance() failed!");
+ }
+ return RES_OK;
+ }
+
+ ICallInfoSCRef HeldCall::getInfo() const
+ {
+ return m_callInfo;
+ }
+
+ Result HeldCall::unhold()
+ {
+ const auto cm = m_cm.lock();
+ if (!cm) {
+ LOG_RETURN(RES_FAIL, "Call Manager is NULL");
+ }
+ return convertCMResult(cm_unhold_call(cm->getCallClient()));
+ }
+
+ Result HeldCall::joinWithActive()
+ {
+ const auto cm = m_cm.lock();
+ if (!cm) {
+ LOG_RETURN(RES_FAIL, "Call Manager is NULL");
+ }
+ return convertCMResult(cm_join_call(cm->getCallClient()));
+ }
+
+ Result HeldCall::swapWithActive()
+ {
+ const auto cm = m_cm.lock();
+ if (!cm) {
+ LOG_RETURN(RES_FAIL, "Call Manager is NULL");
+ }
+ return convertCMResult(cm_swap_call(cm->getCallClient()));
+ }
+
+ Result HeldCall::end()
+ {
+ const auto cm = m_cm.lock();
+ if (!cm) {
+ LOG_RETURN(RES_FAIL, "Call Manager is NULL");
+ }
+ return cm->endCall(0, CallReleaseType::ALL_HOLD);
+ }
+
+ Result HeldCall::split(const IConferenceCallInfoSCRef &confCallInfo)
+ {
+ const auto cm = m_cm.lock();
+ if (!cm) {
+ LOG_RETURN(RES_FAIL, "Call Manager is NULL");
+ }
+ return cm->splitCalls(m_callInfo, confCallInfo);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_HELD_CALL_H__
+#define __CALL_UI_MODEL_IMPL_HELD_CALL_H__
+
+#include <call-manager-ext.h>
+
+#include "call-ui/model/IHeldCall.h"
+#include "CallInfo.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(CallManager);
+
+ UCL_DECLARE_REF_ALIASES(HeldCall);
+
+ class HeldCall final : public IHeldCall {
+ public:
+ static HeldCallSRef newInstance(CallManagerWRef cm, cm_call_data_h callData);
+ virtual ~HeldCall();
+
+ // IHeldCall
+
+ virtual ICallInfoSCRef getInfo() const override final;
+ virtual ucl::Result unhold() override final;
+ virtual ucl::Result joinWithActive() override final;
+ virtual ucl::Result swapWithActive() override final;
+ virtual ucl::Result end() override final;
+ virtual ucl::Result split(const IConferenceCallInfoSCRef &confCallInfo) override final;
+
+ private:
+ friend class ucl::ReffedObj<HeldCall>;
+ HeldCall(CallManagerWRef cm, cm_call_data_h callData);
+
+ ucl::Result prepare(cm_call_data_h callData);
+
+ private:
+ CallManagerWRef m_cm;
+ CallInfoSRef m_callInfo;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_IMPL_HELD_CALL_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_I_CALL_MANAGER_LISTENER_H__
+#define __CALL_UI_MODEL_IMPL_I_CALL_MANAGER_LISTENER_H__
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(ICallManagerListener);
+
+ class ICallManagerListener : public ucl::Polymorphic {
+ public:
+ virtual void onCallEvent(CallEventType type) = 0;
+ virtual void onError(CallManagerErr err) = 0;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_IMPL_I_CALL_MANAGER_LISTENER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_I_STATE_SOURCE_H__
+#define __CALL_UI_MODEL_IMPL_I_STATE_SOURCE_H__
+
+#include "types.h"
+
+#include "call-ui/model/IndicatorState.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(IIndicatorStateSource);
+
+ class IIndicatorStateSource : public ucl::Polymorphic {
+ public:
+ virtual IndicatorState getState() const = 0;
+ virtual void setStateChangeHandler(const NotiHandler &handler) = 0;
+ };
+}
+
+#endif // __CALL_UI_MODEL_IMPL_I_STATE_SOURCE_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "IncomingCall.h"
+
+#include "CallManager.h"
+#include "RejectMsg.h"
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ IncomingCall::IncomingCall(CallManagerWRef cm, cm_call_data_h callData):
+ m_cm(cm)
+ {
+ }
+
+ IncomingCall::~IncomingCall()
+ {
+ }
+
+ IncomingCallSRef IncomingCall::newInstance(CallManagerWRef cm, cm_call_data_h callData)
+ {
+ if (!cm) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "cm is NULL");
+ }
+
+ if (!callData) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "callData is NULL");
+ }
+
+ auto result = makeShared<IncomingCall>(cm, callData);
+ FAIL_RETURN_VALUE(result->prepare(callData), {}, "result->prepare() failed!");
+ return result;
+ }
+
+ Result IncomingCall::prepare(cm_call_data_h callData)
+ {
+ const auto cm = m_cm.lock();
+ if (!cm) {
+ LOG_RETURN(RES_FAIL, "Call Manager is NULL");
+ }
+ m_callInfo = CallInfo::newInstance(cm->getCallClient(),
+ callData,
+ cm->getContactInfoProvider());
+ if (!m_callInfo) {
+ LOG_RETURN_VALUE(RES_FAIL, RES_FAIL, "CallInfo::newInstance() failed!");
+ }
+
+ return RES_OK;
+ }
+
+ ICallInfoSCRef IncomingCall::getInfo() const
+ {
+ return m_callInfo;
+ }
+
+ IRejectMsgProviderSRef IncomingCall::getRejectMsgProvider() const
+ {
+ const auto cm = m_cm.lock();
+ if (!cm) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "Call Manager is NULL");
+ }
+ return cm->getRejectMsgProvider();
+ }
+
+ Result IncomingCall::answer(CallAnswerType type)
+ {
+ const auto cm = m_cm.lock();
+ if (!cm) {
+ LOG_RETURN(RES_FAIL, "Call Manager is NULL");
+ }
+ return convertCMResult(cm_answer_call(cm->getCallClient(), convertCUICallAnswerType(type)));
+ }
+
+ Result IncomingCall::reject()
+ {
+ const auto cm = m_cm.lock();
+ if (!cm) {
+ LOG_RETURN(RES_FAIL, "Call Manager is NULL");
+ }
+ return convertCMResult(cm_reject_call(cm->getCallClient()));
+ }
+
+ Result IncomingCall::rejectWithMessage(IRejectMsgSRef message)
+ {
+ FAIL_RETURN(reject(), "reject() failed!");
+
+ auto msg = dynamicRefCast<RejectMsg>(message);
+ if (!msg) {
+ LOG_RETURN(RES_FAIL, "message is not RejectMsg type!");
+ }
+
+ const auto cm = m_cm.lock();
+ if (!cm) {
+ LOG_RETURN(RES_FAIL, "Call Manager is NULL");
+ }
+ return msg->send(m_callInfo->getPhoneNumber(), cm->getSimSlot());
+ }
+
+ Result IncomingCall::stopAlert()
+ {
+ const auto cm = m_cm.lock();
+ if (!cm) {
+ LOG_RETURN(RES_FAIL, "Call Manager is NULL");
+ }
+ return convertCMResult(cm_stop_alert(cm->getCallClient()));
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_ICOMING_CALL_H__
+#define __CALL_UI_MODEL_IMPL_ICOMING_CALL_H__
+
+#include <call-manager-ext.h>
+
+#include "call-ui/model/IIncomingCall.h"
+#include "CallInfo.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(CallManager);
+
+ UCL_DECLARE_REF_ALIASES(IncomingCall);
+
+ class IncomingCall final : public IIncomingCall {
+ public:
+ static IncomingCallSRef newInstance(CallManagerWRef cm, cm_call_data_h callData);
+
+ virtual ~IncomingCall();
+
+ // IIncomingCall
+
+ virtual ICallInfoSCRef getInfo() const override final;
+ virtual IRejectMsgProviderSRef getRejectMsgProvider() const override final;
+ virtual ucl::Result answer(CallAnswerType type) override final;
+ virtual ucl::Result reject() override final;
+ virtual ucl::Result rejectWithMessage(IRejectMsgSRef message) override final;
+ virtual ucl::Result stopAlert() override final;
+
+ private:
+ friend class ucl::ReffedObj<IncomingCall>;
+ IncomingCall(CallManagerWRef cm, cm_call_data_h callData);
+
+ ucl::Result prepare(cm_call_data_h callData);
+
+ private:
+ CallManagerWRef m_cm;
+ CallInfoSRef m_callInfo;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_IMPL_ICOMING_CALL_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "IndicatorStateProvider.h"
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ class IndicatorStateProvider::SourceHandler :
+ public RefCountAware {
+ public:
+ SourceHandler(IRefCountObj &rc,
+ IndicatorStateProvider &provider,
+ IndicatorProperty property,
+ IIndicatorStateSourceSRef source):
+ RefCountAware(&rc),
+ m_provider(provider),
+ m_property(property),
+ m_source(source)
+ {
+ m_source->setStateChangeHandler(
+ WEAK_DELEGATE(SourceHandler::onStateChanged,
+ asWeak(*this)));
+ }
+
+ IndicatorState getState() const
+ {
+ return m_source->getState();
+ }
+
+ private:
+ void onStateChanged()
+ {
+ m_provider.dispatchStateChanged(m_property);
+ }
+
+ private:
+ const IndicatorStateProvider &m_provider;
+ const IndicatorProperty m_property;
+ const IIndicatorStateSourceSRef m_source;
+ };
+
+ IndicatorStateProvider::IndicatorStateProvider():
+ m_listener(nullptr),
+ m_sources()
+ {
+ }
+
+ IndicatorStateProvider::~IndicatorStateProvider()
+ {
+ }
+
+ IndicatorStateProviderSRef IndicatorStateProvider::newInstance()
+ {
+ return makeShared<IndicatorStateProvider>();
+ }
+
+ Result IndicatorStateProvider::setStateSource(IndicatorProperty property,
+ IIndicatorStateSourceSRef source)
+ {
+ if (!source) {
+ LOG_RETURN(RES_INVALID_ARGUMENTS, "source is empty!");
+ }
+ m_sources[convertEnumValueToInt(property)] =
+ makeShared<SourceHandler>(*this, property, source);
+
+ return RES_OK;
+ }
+
+ IndicatorState IndicatorStateProvider::getState(
+ IndicatorProperty property) const
+ {
+ return m_sources[convertEnumValueToInt(property)]->getState();
+ }
+
+ void IndicatorStateProvider::setListener(
+ IIndicatorStateListenerWRef listener)
+ {
+ m_listener = listener;
+ }
+
+ void IndicatorStateProvider::dispatchStateChanged(
+ IndicatorProperty property) const
+ {
+ if (const auto listener = m_listener.lock()) {
+ listener->onStateChanged(property);
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_INDICATOR_STATE_PROVIDER_H__
+#define __CALL_UI_MODEL_IMPL_INDICATOR_STATE_PROVIDER_H__
+
+#include "call-ui/model/IIndicatorStateProvider.h"
+
+#include "IIndicatorStateSource.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(IndicatorStateProvider);
+
+ class IndicatorStateProvider final: public IIndicatorStateProvider {
+ public:
+ static IndicatorStateProviderSRef newInstance();
+
+ virtual ~IndicatorStateProvider();
+
+ virtual ucl::Result setStateSource(IndicatorProperty property,
+ IIndicatorStateSourceSRef source);
+
+ // IIndicatorStateProvider
+
+ virtual IndicatorState getState(IndicatorProperty property) const override final;
+ virtual void setListener(IIndicatorStateListenerWRef listener) override final;
+
+ private:
+ friend class ucl::ReffedObj<IndicatorStateProvider>;
+ IndicatorStateProvider();
+
+ void dispatchStateChanged(IndicatorProperty property) const;
+
+ private:
+ enum {
+ STATE_COUNT = 6
+ };
+
+ class SourceHandler;
+ UCL_DECLARE_REF_ALIASES(SourceHandler);
+
+ private:
+ IIndicatorStateListenerWRef m_listener;
+ std::array<SourceHandlerSRef, STATE_COUNT> m_sources;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_IMPL_INDICATOR_STATE_PROVIDER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "MsgClient.h"
+
+#include <msg.h>
+#include <msg_transport.h>
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ MsgClient::MsgClient():
+ m_handle()
+ {
+ }
+
+ MsgClient::~MsgClient()
+ {
+ if (m_handle) {
+ msg_close_msg_handle(&m_handle);
+ }
+ }
+
+ MsgClientSRef MsgClient::newInstance()
+ {
+ auto result = makeShared<MsgClient>();
+ FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+ return result;
+ }
+
+ Result MsgClient::prepare()
+ {
+ msg_handle_t handle;
+ msg_error_t err = msg_open_msg_handle(&handle);
+ if (err != MSG_SUCCESS) {
+ LOG_RETURN(RES_FAIL, "msg_open_msg_handle() failed! res[%d]", err);
+ }
+ m_handle = handle;
+
+ err = msg_reg_sent_status_callback(m_handle, [](msg_handle_t msgHandle, msg_struct_t status, void *data)
+ {
+ if(!status)
+ LOG_RETURN_VOID(RES_FAIL, "status is NULL");
+
+ int msgNetworkStatus = MSG_NETWORK_SEND_FAIL;
+ msg_get_int_value(status, MSG_SENT_STATUS_NETWORK_STATUS_INT, &msgNetworkStatus);
+ DLOG("Message sent status [%d]", msgNetworkStatus);
+ }, NULL);
+ if (err != MSG_SUCCESS) {
+ LOG_RETURN(RES_FAIL, "msg_reg_sent_status_callback() failed! res[%d]", err);
+ }
+
+ return RES_OK;
+ }
+
+ msg_handle_t MsgClient::getMsgHandle() const
+ {
+ return m_handle;
+ }
+
+ MsgClient::operator msg_handle_t() const
+ {
+ return getMsgHandle();
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_MSG_CLIENT_H__
+#define __CALL_UI_MODEL_IMPL_MSG_CLIENT_H__
+
+#include <msg_types.h>
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(MsgClient);
+
+ class MsgClient {
+ public:
+ static MsgClientSRef newInstance();
+ virtual ~MsgClient();
+ msg_handle_t getMsgHandle() const;
+ operator msg_handle_t() const;
+
+ private:
+ friend class ucl::ReffedObj<MsgClient>;
+ MsgClient();
+
+ ucl::Result prepare();
+
+ private:
+ msg_handle_t m_handle;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_IMPL_MSG_CLIENT_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "RejectMsg.h"
+
+#include <msg.h>
+#include <msg_transport.h>
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ RejectMsg::RejectMsg(MsgClientWRef client, const TString &string):
+ m_msgClient(client),
+ m_msg(string)
+ {
+ }
+
+ RejectMsg::~RejectMsg()
+ {
+ }
+
+ RejectMsgSRef RejectMsg::newInstance(MsgClientWRef client, const TString &string)
+ {
+ return makeShared<RejectMsg>(client, string);
+ }
+
+ std::string RejectMsg::getText() const
+ {
+ return m_msg;
+ }
+
+ Result RejectMsg::send(const std::string &phoneNumber, SimSlot slot)
+ {
+ if (phoneNumber.empty()) {
+ LOG_RETURN(RES_FAIL, "Phone Number is NULL");
+ }
+
+ const auto msgClient = m_msgClient.lock();
+ if (!msgClient) {
+ LOG_RETURN(RES_FAIL, "Client is NULL");
+ }
+
+ Result res = RES_FAIL;
+
+ msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
+ msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT);
+ msg_struct_t reqInfo = msg_create_struct(MSG_STRUCT_REQUEST_INFO);
+ const char *msgText = m_msg.translate();
+
+ // Set message type to SMS reject
+ msg_set_int_value(msgInfo, MSG_MESSAGE_TYPE_INT, MSG_TYPE_SMS_REJECT);
+
+ // No setting send option
+ msg_set_bool_value(sendOpt, MSG_SEND_OPT_SETTING_BOOL, false);
+
+ // Set message body
+ if (msg_set_str_value(msgInfo, MSG_MESSAGE_SMS_DATA_STR, msgText, strlen(msgText)) != MSG_SUCCESS) {
+ ELOG("msg_set_str_value() failed!");
+ } else {
+ // Create address list
+ msg_struct_list_s *addrList = nullptr;
+ msg_get_list_handle(msgInfo, MSG_MESSAGE_ADDR_LIST_STRUCT, (void **)&addrList);
+ msg_struct_t addrInfo = addrList->msg_struct_info[0];
+ const char *number = phoneNumber.c_str();
+
+ // Set message address
+ msg_set_int_value(addrInfo, MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, MSG_RECIPIENTS_TYPE_TO);
+ msg_set_str_value(addrInfo, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, number, strlen(number));
+ addrList->nCount = 1;
+
+ // Set message struct to Request
+ msg_set_struct_handle(reqInfo, MSG_REQUEST_MESSAGE_HND, msgInfo);
+ msg_set_struct_handle(reqInfo, MSG_REQUEST_SENDOPT_HND, sendOpt);
+
+ // Send message
+ int err = msg_sms_send_message(*msgClient, reqInfo);
+ if (err != MSG_SUCCESS) {
+ ELOG("msg_sms_send_message() failed. err[%d]", err);
+ } else {
+ DLOG("Sending...");
+ res = RES_OK;
+ }
+ }
+ msg_release_struct(&reqInfo);
+ msg_release_struct(&msgInfo);
+ msg_release_struct(&sendOpt);
+
+ return res;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_REJECT_MSG_H__
+#define __CALL_UI_MODEL_IMPL_REJECT_MSG_H__
+
+#include "call-ui/model/IRejectMsg.h"
+
+#include "ucl/misc/TString.h"
+
+#include "MsgClient.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(RejectMsg);
+
+ class RejectMsg : public IRejectMsg {
+ public:
+ static RejectMsgSRef newInstance(MsgClientWRef client, const ucl::TString &string);
+ virtual ~RejectMsg();
+
+ ucl::Result send(const std::string &number, SimSlot slot);
+
+ // IRejectMsg
+ std::string getText() const override final;
+
+ private:
+ friend class ucl::ReffedObj<RejectMsg>;
+ RejectMsg(MsgClientWRef client, const ucl::TString &string);
+
+ ucl::Result prepare();
+
+ private:
+ MsgClientWRef m_msgClient;
+ ucl::TString m_msg;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_IMPL_REJECT_MSG_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "RejectMsgProvider.h"
+
+#include <vconf.h>
+
+#include "RejectMsg.h"
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ RejectMsgProvider::RejectMsgProvider()
+ {
+ }
+
+ RejectMsgProvider::~RejectMsgProvider()
+ {
+ }
+
+ RejectMsgProviderSRef RejectMsgProvider::newInstance()
+ {
+ auto result = makeShared<RejectMsgProvider>();
+ FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+ return result;
+ }
+
+ Result RejectMsgProvider::prepare()
+ {
+ m_msgClient = MsgClient::newInstance();
+ if (!m_msgClient) {
+ LOG_RETURN(RES_FAIL, "msgClient::newInstance() failed!");
+ }
+
+ return RES_OK;
+ }
+
+ const char *getVconfKey(int index)
+ {
+ switch (index) {
+ case 0: return VCONFKEY_CISSAPPL_USER_CREATE_MSG1_STR;
+ case 1: return VCONFKEY_CISSAPPL_USER_CREATE_MSG2_STR;
+ case 2: return VCONFKEY_CISSAPPL_USER_CREATE_MSG3_STR;
+ case 3: return VCONFKEY_CISSAPPL_USER_CREATE_MSG4_STR;
+ case 4: return VCONFKEY_CISSAPPL_USER_CREATE_MSG5_STR;
+ case 5: return VCONFKEY_CISSAPPL_USER_CREATE_MSG6_STR;
+ default:
+ return nullptr;
+ }
+ }
+
+ IRejectMsgSRef RejectMsgProvider::getRejectMsgByIndex(int index) const
+ {
+ const char *vconfKey = getVconfKey(index);
+ if(!vconfKey) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "Key not found");
+ }
+
+ char *message = vconf_get_str(vconfKey);
+ if (!message) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "message is empty");
+ }
+
+ RejectMsgSRef msg = RejectMsg::newInstance(m_msgClient, {message, true});
+ if (!msg) {
+ ELOG("RejectMsg::newInstance() failed!");
+ }
+ free(message);
+ return msg;
+ }
+
+ IRejectMsgProvider::RejectMsgList RejectMsgProvider::getMsgList() const
+ {
+ RejectMsgList list;
+ int count = getMsgCount();
+ int i = 0;
+
+ while (count) {
+ IRejectMsgSRef ref = getRejectMsgByIndex(i);
+ if (ref) {
+ list.push_back(ref);
+ count--;
+ }
+ i++;
+ }
+ return list;
+ }
+
+ int RejectMsgProvider::getMsgCount() const
+ {
+ int count = 0;
+ if (vconf_get_int(VCONFKEY_CISSAPPL_REJECT_CALL_MSG_INT, &count) != 0) {
+ LOG_RETURN_VALUE(RES_FAIL, 0, "vconf_get_int() failed!");
+ }
+ return count;
+ }
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_REJECT_MSG_PROVIDER_H__
+#define __CALL_UI_MODEL_IMPL_REJECT_MSG_PROVIDER_H__
+
+#include "call-ui/model/IRejectMsgProvider.h"
+
+#include "MsgClient.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(RejectMsgProvider);
+
+ class RejectMsgProvider : public IRejectMsgProvider {
+ public:
+ static RejectMsgProviderSRef newInstance();
+ virtual ~RejectMsgProvider();
+
+ // IRejectMsgProvider
+
+ virtual RejectMsgList getMsgList() const override final;
+ virtual int getMsgCount() const override final;
+
+ private:
+ friend class ucl::ReffedObj<RejectMsgProvider>;
+ RejectMsgProvider();
+
+ ucl::Result prepare();
+ IRejectMsgSRef getRejectMsgByIndex(int index) const;
+
+ private:
+ MsgClientSRef m_msgClient;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_IMPL_REJECT_MSG_PROVIDER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "RssiStateSource.h"
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ RssiStateSource::Bits::Bits():
+ property(convertEnumValueToInt(IndicatorProperty::RSSI)),
+ rssiState(convertEnumValueToInt(RssiState::NONE)),
+ isRoamingEnable(0)
+ {
+ }
+
+ RssiStateSource::Bits::Bits(const IndicatorState &state):
+ value(state.value)
+ {
+ if (property != convertEnumValueToInt(IndicatorProperty::RSSI)) {
+ ELOG("State of incorrect property type [%d]", property);
+ *this = {};
+ }
+ }
+
+ RssiStateSource::RssiStateSource()
+ {
+ }
+
+ RssiStateSource::~RssiStateSource()
+ {
+ delSysStateCallbacks();
+ }
+
+ RssiStateSourceSRef RssiStateSource::newInstance()
+ {
+ auto result = makeShared<RssiStateSource>();
+ FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+ return result;
+ }
+
+ Result RssiStateSource::prepare()
+ {
+ FAIL_RETURN(addSysStateCallbacks(), "addSysStateCallbacks() failed!");
+
+ updateRssiState();
+ updateRoamingState();
+
+ return RES_OK;
+ }
+
+ bool RssiStateSource::isRoamingActive() const
+ {
+ int status = 0;
+ if (vconf_get_int(VCONFKEY_TELEPHONY_SVC_ROAM, &status) != 0) {
+ ELOG("Get Flight mode status failed!");
+ return false;
+ }
+ return (status == VCONFKEY_TELEPHONY_SVC_ROAM_ON);
+ }
+
+ bool RssiStateSource::updateRssiStateBits(RssiState state)
+ {
+ int rssiStateInt = convertEnumValueToInt(state);
+ if (rssiStateInt != m_bits.rssiState) {
+ m_bits.rssiState = rssiStateInt;
+ return true;
+ }
+ return false;
+ }
+
+ bool RssiStateSource::updateRoamingStateBits(bool state)
+ {
+ if (state != m_bits.isRoamingEnable) {
+ m_bits.rssiState = state;
+ return true;
+ }
+ return false;
+ }
+
+ RssiState RssiStateSource::getCurRssiState() const
+ {
+ int status = 0;
+ if (vconf_get_int(VCONFKEY_TELEPHONY_SVCTYPE, &status) == 0) {
+ switch (status) {
+ case VCONFKEY_TELEPHONY_SVCTYPE_NONE :
+ case VCONFKEY_TELEPHONY_SVCTYPE_NOSVC :
+ case VCONFKEY_TELEPHONY_SVCTYPE_SEARCH :
+ return RssiState::NO_SIGNAL;
+ default :
+ break;
+ }
+ } else {
+ ELOG("Get telephony SVC type failed!");
+ }
+
+ status = 0;
+ if (vconf_get_int(VCONFKEY_TELEPHONY_RSSI, &status) == 0) {
+ switch (status) {
+ case VCONFKEY_TELEPHONY_RSSI_0: return RssiState::LEVEL_0;
+ case VCONFKEY_TELEPHONY_RSSI_1: return RssiState::LEVEL_1;
+ case VCONFKEY_TELEPHONY_RSSI_2: return RssiState::LEVEL_2;
+ case VCONFKEY_TELEPHONY_RSSI_3: return RssiState::LEVEL_3;
+ case VCONFKEY_TELEPHONY_RSSI_4: return RssiState::LEVEL_4;
+ default:
+ break;
+ }
+ } else {
+ ELOG("Get telephony RSSI level failed!");
+ }
+ return RssiState::NONE;
+ }
+
+ bool RssiStateSource::updateRssiState()
+ {
+ if (isFlightModeActive()) {
+ return updateRssiStateBits(RssiState::FLIGHT_MODE);
+ }
+ return updateRssiStateBits(getCurRssiState());
+ }
+
+ bool RssiStateSource::updateRoamingState()
+ {
+ return updateRoamingStateBits(isRoamingActive());
+ }
+
+ void RssiStateSource::onRssiChangedCb(keynode_t *node)
+ {
+ bool needNotify = updateRssiState();
+ if (updateRoamingState()) {
+ needNotify = true;
+ }
+
+ if (needNotify && m_handler) {
+ m_handler();
+ }
+ }
+
+ Result RssiStateSource::addSysStateCallbacks()
+ {
+ int res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_SVC_ROAM,
+ CALLBACK_B(RssiStateSource::onRssiChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
+ CALLBACK_B(RssiStateSource::onRssiChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_SVCTYPE,
+ CALLBACK_B(RssiStateSource::onRssiChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_RSSI,
+ CALLBACK_B(RssiStateSource::onRssiChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_ROAM_ICON_MODE,
+ CALLBACK_B(RssiStateSource::onRssiChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ return RES_OK;
+ }
+
+ void RssiStateSource::delSysStateCallbacks()
+ {
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_SVC_ROAM,
+ CALLBACK_B(RssiStateSource::onRssiChangedCb));
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
+ CALLBACK_B(RssiStateSource::onRssiChangedCb));
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_SVCTYPE,
+ CALLBACK_B(RssiStateSource::onRssiChangedCb));
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_RSSI,
+ CALLBACK_B(RssiStateSource::onRssiChangedCb));
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_ROAM_ICON_MODE,
+ CALLBACK_B(RssiStateSource::onRssiChangedCb));
+ }
+
+ IndicatorState RssiStateSource::getState() const
+ {
+ return {m_bits.value};
+ }
+
+ void RssiStateSource::setStateChangeHandler(const NotiHandler &handler)
+ {
+ m_handler = handler;
+ }
+
+ RssiState getRssiState(IndicatorState state)
+ {
+ return static_cast<RssiState>(
+ RssiStateSource::Bits(state).rssiState);
+ }
+
+ bool getRoamingState(IndicatorState state)
+ {
+ return RssiStateSource::Bits(state).isRoamingEnable;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_RSSI_STATE_SOURCE_H__
+#define __CALL_UI_MODEL_IMPL_RSSI_STATE_SOURCE_H__
+
+#include "IIndicatorStateSource.h"
+
+#include <vconf.h>
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(RssiStateSource);
+
+ class RssiStateSource final : public IIndicatorStateSource {
+ public:
+ static RssiStateSourceSRef newInstance();
+ virtual ~RssiStateSource();
+
+ // IIndicatorStateSource
+
+ virtual IndicatorState getState() const override final;
+ virtual void setStateChangeHandler(const NotiHandler &handler) override final;
+
+ private:
+ friend class ucl::ReffedObj<RssiStateSource>;
+ RssiStateSource();
+
+ ucl::Result prepare();
+ ucl::Result addSysStateCallbacks();
+ void delSysStateCallbacks();
+
+ bool isRoamingActive() const;
+ bool updateRssiStateBits(RssiState state);
+ bool updateRoamingStateBits(bool state);
+ RssiState getCurRssiState() const;
+ bool updateRssiState();
+ bool updateRoamingState();
+
+ void onRssiChangedCb(keynode_t *node);
+
+ public:
+ union Bits {
+ struct {
+ uint8_t property : 4;
+ uint8_t rssiState : 4;
+ uint8_t isRoamingEnable: 1;
+ };
+ uint64_t value;
+
+ Bits();
+ Bits(const IndicatorState &state);
+ };
+
+ private:
+ Bits m_bits;
+ NotiHandler m_handler;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_IMPL_RSSI_STATE_SOURCE_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "SimSlotStateSource.h"
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ SimSlotStateSource::Bits::Bits():
+ property(convertEnumValueToInt(IndicatorProperty::SIM_SLOT)),
+ simSlot(0)
+ {
+ }
+
+ SimSlotStateSource::Bits::Bits(const IndicatorState &state):
+ value(state.value)
+ {
+ if (property != convertEnumValueToInt(IndicatorProperty::SIM_SLOT)) {
+ ELOG("State of incorrect property type [%d]", property);
+ *this = {};
+ }
+ }
+
+ SimSlotStateSource::SimSlotStateSource(SimSlot slot, bool isForwarded)
+ {
+ m_bits.simSlot = convertEnumValueToInt(slot);
+ m_bits.isForwarded = isForwarded;
+ }
+
+ SimSlotStateSource::~SimSlotStateSource()
+ {
+ }
+
+ void SimSlotStateSource::updateSimSlot(SimSlot slot, bool isForwarded)
+ {
+ int simSlotInt = convertEnumValueToInt(slot);
+ bool needUpdate = false;
+
+ if (simSlotInt != m_bits.simSlot) {
+ m_bits.simSlot = simSlotInt;
+ needUpdate = true;
+ }
+
+ if (isForwarded != m_bits.isForwarded) {
+ m_bits.isForwarded = isForwarded;
+ needUpdate = true;
+ }
+
+ if (needUpdate && m_handler) {
+ m_handler();
+ }
+ }
+
+ IndicatorState SimSlotStateSource::getState() const
+ {
+ return {m_bits.value};
+ }
+
+ void SimSlotStateSource::setStateChangeHandler(const NotiHandler &handler)
+ {
+ m_handler = handler;
+ }
+
+ SimSlot getSimSlotType(IndicatorState state)
+ {
+ return static_cast<SimSlot>(
+ SimSlotStateSource::Bits(state).simSlot);
+ }
+
+ bool getSimForwardState(IndicatorState state)
+ {
+ return SimSlotStateSource::Bits(state).isForwarded;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_SIM_SLOT_STATE_SOURCE_H__
+#define __CALL_UI_MODEL_IMPL_SIM_SLOT_STATE_SOURCE_H__
+
+#include "IIndicatorStateSource.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(SimSlotStateSource);
+
+ class SimSlotStateSource final : public IIndicatorStateSource {
+ public:
+ SimSlotStateSource(SimSlot slot, bool isForwarded);
+ virtual ~SimSlotStateSource();
+ void updateSimSlot(SimSlot slot, bool isForwarded);
+
+ // IIndicatorStateSource
+
+ virtual IndicatorState getState() const override final;
+ virtual void setStateChangeHandler(const NotiHandler &handler) override final;
+
+ public:
+ union Bits {
+ struct {
+ uint8_t property : 4;
+ uint8_t simSlot : 4;
+ uint8_t isForwarded: 1;
+ };
+ uint64_t value;
+
+ Bits();
+ Bits(const IndicatorState &state);
+ };
+
+ private:
+ Bits m_bits;
+ NotiHandler m_handler;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_IMPL_SIM_SLOT_STATE_SOURCE_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "SoundManager.h"
+
+#include "common.h"
+
+namespace callui { namespace { namespace impl {
+
+ using namespace ucl;
+
+ Result getBTHeadsetConnectedState(bool &state)
+ {
+ Result res = RES_FAIL;
+ state = false;
+
+ sound_device_list_h deviceList = nullptr;
+ auto ret = sound_manager_get_device_list(
+ SOUND_DEVICE_ALL_MASK, &deviceList);
+ if (ret != SOUND_MANAGER_ERROR_NONE) {
+ LOG_RETURN(RES_FAIL, "sound_manager_get_device_list() failed. "
+ "[%d][%s]", ret, get_error_message(ret));
+ }
+ sound_device_type_e searchType = SOUND_DEVICE_BLUETOOTH_VOICE;
+ sound_device_h device;
+ sound_device_type_e type;
+
+ while (true) {
+ device = nullptr;
+ ret = sound_manager_get_next_device(deviceList, &device);
+
+ if (ret == SOUND_MANAGER_ERROR_NO_DATA) {
+ res = RES_OK;
+ ILOG("No more device to check");
+ break;
+ } else if (ret != SOUND_MANAGER_ERROR_NONE) {
+ UCL_FAIL_BREAK(res, "sound_manager_get_next_device() failed. "
+ "[%d][%s]", ret, get_error_message(ret));
+ }
+
+ if (!device) {
+ UCL_FAIL_BREAK(res, "device is NULL");
+ }
+
+ sound_manager_get_device_type(device, &type);
+ if (searchType == type) {
+ DLOG("Bluetooth voice device found");
+ state = true;
+ }
+
+ // For debug only
+ int id;
+ char *name;
+ sound_device_io_direction_e direction;
+ sound_manager_get_device_id(device, &id);
+ sound_manager_get_device_name(device, &name);
+ sound_manager_get_device_io_direction(device, &direction);
+ DLOG("--------------------------");
+ DLOG("Device ID [%d]", id);
+ DLOG("Device name [%s]", name);
+ DLOG("Device IO direction [%d]", direction);
+ DLOG("Device type [%d]", type);
+ }
+ sound_manager_free_device_list(deviceList);
+
+ return res;
+ }
+}}}
+
+namespace callui {
+
+ using namespace ucl;
+
+ SoundManager::SoundManager(IRefCountObj &rc, const CallClientSRef &client):
+ RefCountAware(&rc),
+ m_client(client),
+ m_deviceVolumeCbID(-1)
+ {
+ }
+
+ SoundManager::~SoundManager()
+ {
+ if (m_deviceVolumeCbID >= 0) {
+ sound_manager_remove_volume_changed_cb(m_deviceVolumeCbID);
+ }
+ cm_unset_audio_state_changed_cb(*m_client);
+ cm_unset_mute_status_cb(*m_client);
+ }
+
+ SoundManagerSRef SoundManager::newInstance(const CallClientSRef &client)
+ {
+ auto result = makeShared<SoundManager>(client);
+ FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+ return result;
+ }
+
+ void SoundManager::onAudioStateChanged(cm_audio_state_type_e state)
+ {
+ DLOG();
+
+ if (state == CM_AUDIO_STATE_NONE_E) {
+ ILOG("Ignore. Unhandled state [%d]", state);
+ return;
+ }
+ m_audioStateEvent.dispatch(convertCMAudioState(state));
+ }
+
+ void SoundManager::onMuteStateChanged(cm_mute_status_e status)
+ {
+ DLOG();
+
+ m_muteStateEvent.dispatch(status == CM_MUTE_STATUS_ON);
+ }
+
+ Result SoundManager::prepare()
+ {
+ m_btManager = BluetoothManager::newInstance();
+ if (!m_btManager) {
+ ELOG("BluetoothManager::newInstance() failed!");
+ }
+
+ Result res = convertCMResult(cm_set_audio_state_changed_cb(*m_client,
+ CALLBACK_B(SoundManager::onAudioStateChanged), this));
+ FAIL_RETURN(res, "cm_set_audio_state_changed_cb() failed!");
+
+ res = convertCMResult(cm_set_mute_status_cb(*m_client,
+ CALLBACK_B(SoundManager::onMuteStateChanged), this));
+ FAIL_RETURN(res, "cm_set_mute_status_cb() failed!");
+
+ res = registerCallbacks();
+ FAIL_RETURN(res, "registerVolumeCallbacks() failed!");
+
+ return res;
+ }
+
+ Result SoundManager::registerCallbacks()
+ {
+ int ret = sound_manager_add_volume_changed_cb(
+ CALLBACK_B(SoundManager::onGearVolumeChanged),
+ this,
+ &m_deviceVolumeCbID);
+ if (ret != SOUND_MANAGER_ERROR_NONE) {
+ LOG_RETURN(RES_FAIL,
+ "sound_manager_add_volume_changed_cb() failed");
+ }
+
+ if (isBTSupported()) {
+ m_btManager->setVolumeStateHandler(
+ WEAK_DELEGATE(SoundManager::onBTHeadsetVolumeChanged,
+ asWeak(*this)));
+
+ m_btManager->setHeadsetConnectionChangeHandler(
+ WEAK_DELEGATE(SoundManager::onHeadsetConnectionChanged,
+ asWeak(*this)));
+ }
+
+ return RES_OK;
+ }
+
+ void SoundManager::onHeadsetConnectionChanged()
+ {
+ m_btVoiceDeviceConnEvent.dispatch();
+ }
+
+ Result SoundManager::setSpeakerState(bool isEnable)
+ {
+ if (isEnable) {
+ return convertCMResult(cm_speaker_on(*m_client));
+ } else {
+ return convertCMResult(cm_speaker_off(*m_client));
+ }
+ }
+
+ Result SoundManager::setBluetoothState(bool isEnable)
+ {
+ if (!isBTSupported()) {
+ LOG_RETURN(RES_NOT_SUPPORTED, "Bluetooth not supported");
+ }
+
+ bool state = false;
+ Result res = impl::getBTHeadsetConnectedState(state);
+ DLOG("Sound manager BT Headset connection status [%d], res [%s]",
+ state, getResultData(res).name);
+
+ if (!isBTHeadsetConnected()) {
+ LOG_RETURN(RES_NOT_CONNECTED,
+ "Bluetooth headset device not connected");
+ }
+
+ if (isEnable) {
+ return convertCMResult(cm_bluetooth_on(*m_client));
+ } else {
+ return convertCMResult(cm_bluetooth_off(*m_client));
+ }
+ }
+
+ AudioStateType SoundManager::getAudioState() const
+ {
+ cm_audio_state_type_e state = CM_AUDIO_STATE_NONE_E;
+ Result res = convertCMResult(cm_get_audio_state(*m_client, &state));
+ FAIL_RETURN_VALUE(res, AudioStateType::NONE,
+ "cm_get_audio_state() failed!");
+
+ return convertCMAudioState(state);
+ }
+
+ Result SoundManager::setMuteState(bool isEnable)
+ {
+ return convertCMResult(cm_set_mute_state(*m_client, isEnable));
+ }
+
+ bool SoundManager::getMuteState() const
+ {
+ cm_mute_status_e status = CM_MUTE_STATUS_MAX;
+ Result res = convertCMResult(cm_get_mute_status(*m_client, &status));
+ FAIL_RETURN_VALUE(res, false, "cm_get_mute_status() failed!");
+
+ return (status == CM_MUTE_STATUS_ON);
+ }
+
+ Result SoundManager::startDtmf(const unsigned char dtmfDigit)
+ {
+ return convertCMResult(cm_start_dtmf(*m_client, dtmfDigit));
+ }
+
+ Result SoundManager::stopDtmf()
+ {
+ return convertCMResult(cm_stop_dtmf(*m_client));
+ }
+
+ void SoundManager::addAudioStateHandler(const AudioStateHandler &handler)
+ {
+ m_audioStateEvent += handler;
+ }
+
+ void SoundManager::delAudioStateHandler(const AudioStateHandler &handler)
+ {
+ m_audioStateEvent -= handler;
+ }
+
+ void SoundManager::addMuteStateHandler(const MuteStateHandler &handler)
+ {
+ m_muteStateEvent += handler;
+ }
+
+ void SoundManager::delMuteStateHandler(const MuteStateHandler &handler)
+ {
+ m_muteStateEvent -= handler;
+ }
+
+ void SoundManager::addVolumeStateHandler(const VolumeLevelHandler &handler)
+ {
+ m_volumeLevelEvent += handler;
+ }
+
+ void SoundManager::delVolumeStateHandler(const VolumeLevelHandler &handler)
+ {
+ m_volumeLevelEvent -= handler;
+ }
+
+ int SoundManager::getMaxVolume() const
+ {
+ int maxVol = 0;
+ if (getAudioState() == AudioStateType::BT) {
+ if (isBTSupported()) {
+ maxVol = m_btManager->getMaxVolume();
+ } else {
+ ELOG("BT is not supported");
+ }
+ } else {
+ auto ret = sound_manager_get_max_volume(SOUND_TYPE_CALL, &maxVol);
+ if (ret != SOUND_MANAGER_ERROR_NONE) {
+ LOG_RETURN_VALUE(RES_FAIL, 0,
+ "Get max volume failed. ret[%d]", ret);
+ }
+ }
+ DLOG("Max volume [%d]", maxVol);
+ return maxVol;
+ }
+
+ int SoundManager::getVolume() const
+ {
+ int vol = 0;
+ if (getAudioState() == AudioStateType::BT) {
+ if (isBTSupported()) {
+ vol = m_btManager->getVolume();
+ } else {
+ ELOG("BT is not supported");
+ }
+ } else {
+ auto ret = sound_manager_get_volume(SOUND_TYPE_CALL, &vol);
+ if (ret != SOUND_MANAGER_ERROR_NONE) {
+ LOG_RETURN_VALUE(RES_FAIL, 0,
+ "Get volume failed. ret[%d]", ret);
+ }
+ }
+ DLOG("Current volume [%d]", vol);
+ return vol;
+ }
+
+ Result SoundManager::setVolume(int value)
+ {
+ if (getAudioState() == AudioStateType::BT) {
+ if (isBTSupported()) {
+ return m_btManager->setVolume(value);
+ } else {
+ LOG_RETURN(RES_FAIL, "BT is not supported");
+ }
+ } else {
+ auto ret = sound_manager_set_volume(SOUND_TYPE_CALL, value);
+ if (ret != SOUND_MANAGER_ERROR_NONE) {
+ LOG_RETURN(RES_FAIL,
+ "sound_manager_set_volume() failed. ret[%d]", ret);
+ }
+ }
+ return RES_OK;
+ }
+
+ bool SoundManager::isBTSupported() const
+ {
+ return (m_btManager != nullptr);
+ }
+
+ bool SoundManager::isBTHeadsetConnected() const
+ {
+ return (isBTSupported() ? m_btManager->isHeadsetConnected() : false);
+ }
+
+ void SoundManager::addBTHeadsetConnectionChangeHandler(
+ const NotiHandler &handler)
+ {
+ m_btVoiceDeviceConnEvent += handler;
+ }
+
+ void SoundManager::delBTHeadsetConnectionChangeHandler(
+ const NotiHandler &handler)
+ {
+ m_btVoiceDeviceConnEvent -= handler;
+ }
+
+ void SoundManager::onGearVolumeChanged(sound_type_e type, unsigned int volume)
+ {
+ DLOG("Volume [%d]", volume);
+ if (type != SOUND_TYPE_CALL) {
+ ILOG("Ignored. Not type Call.");
+ return;
+ }
+
+ if (getAudioState() != AudioStateType::BT) {
+ m_volumeLevelEvent.dispatch(volume);
+ }
+ }
+
+ void SoundManager::onBTHeadsetVolumeChanged(int volume)
+ {
+ DLOG("Volume [%d]", volume);
+
+ if (getAudioState() == AudioStateType::BT) {
+ m_volumeLevelEvent.dispatch(volume);
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_SOUND_MANAGER_H__
+#define __CALL_UI_MODEL_IMPL_SOUND_MANAGER_H__
+
+#include "call-ui/model/ISoundManager.h"
+
+#include <call-manager-ext.h>
+#include <sound_manager.h>
+
+#include "BluetoothManager.h"
+#include "CallClient.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(SoundManager);
+
+ class SoundManager final :
+ public ucl::RefCountAware,
+ public ISoundManager {
+ public:
+ static SoundManagerSRef newInstance(const CallClientSRef &client);
+ virtual ~SoundManager();
+
+ // ISoundManager
+
+ virtual ucl::Result setSpeakerState(bool isEnable) override final;
+ virtual ucl::Result setBluetoothState(bool isEnable) override final;
+ virtual AudioStateType getAudioState() const override final;
+
+ virtual ucl::Result setMuteState(bool isEnable) override final;
+ virtual bool getMuteState() const override final;
+
+ virtual ucl::Result startDtmf(
+ const unsigned char dtmfDigit) override final;
+ virtual ucl::Result stopDtmf() override final;
+
+ virtual void addAudioStateHandler(
+ const AudioStateHandler &handler) override final;
+ virtual void delAudioStateHandler(
+ const AudioStateHandler &handler) override final;
+
+ virtual void addMuteStateHandler(
+ const MuteStateHandler &handler) override final;
+ virtual void delMuteStateHandler(
+ const MuteStateHandler &handler) override final;
+
+ virtual void addVolumeStateHandler(
+ const VolumeLevelHandler &handler) override final;
+ virtual void delVolumeStateHandler(
+ const VolumeLevelHandler &handler) override final;
+
+ virtual int getMaxVolume() const override final;
+ virtual int getVolume() const override final;
+ virtual ucl::Result setVolume(int value) override final;
+
+ virtual bool isBTSupported() const override final;
+
+ virtual bool isBTHeadsetConnected() const override final;
+ virtual void addBTHeadsetConnectionChangeHandler(
+ const NotiHandler &handler) override final;
+ virtual void delBTHeadsetConnectionChangeHandler(
+ const NotiHandler &handler) override final;
+
+ private:
+ friend class ucl::ReffedObj<SoundManager>;
+ SoundManager(ucl::IRefCountObj &rc, const CallClientSRef &client);
+
+ ucl::Result prepare();
+ ucl::Result registerCallbacks();
+
+ void onAudioStateChanged(cm_audio_state_type_e state);
+ void onMuteStateChanged(cm_mute_status_e status);
+ void onHeadsetConnectionChanged();
+
+ void onBTHeadsetVolumeChanged(int volume);
+ void onGearVolumeChanged(sound_type_e type, unsigned int volume);
+
+ private:
+ CallClientSRef m_client;
+ BluetoothManagerSRef m_btManager;
+ ucl::Event<AudioStateHandler> m_audioStateEvent;
+ ucl::Event<MuteStateHandler> m_muteStateEvent;
+ ucl::Event<VolumeLevelHandler> m_volumeLevelEvent;
+ ucl::Event<NotiHandler> m_btVoiceDeviceConnEvent;
+ int m_deviceVolumeCbID;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_IMPL_SOUND_MANAGER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "VoiceControlStateProvider.h"
+
+#include "common.h"
+
+// Temporary until VCONFLAG will not be added to a system
+#define VCONFKEY_CISSAPPL_CALL_VOICE_ANSWER VCONFKEY_CISSAPPL_ANSWERING_KEY_BOOL
+
+namespace callui {
+
+ using namespace ucl;
+
+ VoiceControlStateProvider::VoiceControlStateProvider():
+ m_enableState(false)
+ {
+ }
+
+ VoiceControlStateProvider::~VoiceControlStateProvider()
+ {
+ delSysStateCallback();
+ }
+
+ VoiceControlStateProviderSRef VoiceControlStateProvider::newInstance()
+ {
+ auto result = makeShared<VoiceControlStateProvider>();
+ FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+ return result;
+ }
+
+ Result VoiceControlStateProvider::prepare()
+ {
+ FAIL_RETURN(addSysStateCallback(),
+ "addSysStateCallbacks() failed!");
+
+ FAIL_RETURN(initState(), "initState() failed!");
+ return RES_OK;
+ }
+
+ Result VoiceControlStateProvider::initState()
+ {
+ auto val = 0;
+ if (vconf_get_bool(VCONFKEY_CISSAPPL_CALL_VOICE_ANSWER, &val) != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_get_bool() failed!"
+ "err[%d]", vconf_get_ext_errno());
+ }
+ updateState(val);
+
+ return RES_OK;
+ }
+
+ bool VoiceControlStateProvider::getState() const
+ {
+ return m_enableState;
+ }
+
+ void VoiceControlStateProvider::addStateChangeHandler(
+ const NotiHandler &handler)
+ {
+ m_event += handler;
+ }
+
+ void VoiceControlStateProvider::removeStateChangeHandler(
+ const NotiHandler &handler)
+ {
+ m_event -= handler;
+ }
+
+ Result VoiceControlStateProvider::addSysStateCallback()
+ {
+ if (vconf_notify_key_changed(VCONFKEY_CISSAPPL_CALL_VOICE_ANSWER,
+ CALLBACK_B(VoiceControlStateProvider::onStateChanged),
+ this) != 0) {
+
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed. "
+ "err[%d]", vconf_get_ext_errno());
+ }
+ return RES_OK;
+ }
+
+ void VoiceControlStateProvider::delSysStateCallback()
+ {
+ vconf_ignore_key_changed(VCONFKEY_CISSAPPL_CALL_VOICE_ANSWER,
+ CALLBACK_B(VoiceControlStateProvider::onStateChanged));
+ }
+
+ void VoiceControlStateProvider::onStateChanged(
+ keynode_t *node)
+ {
+ auto val = 0;
+ if (vconf_get_bool(VCONFKEY_CISSAPPL_CALL_VOICE_ANSWER, &val) != 0) {
+ LOG_RETURN_VOID(RES_FAIL, "vconf_get_bool() failed!"
+ "err[%d]", vconf_get_ext_errno());
+ }
+
+ if (updateState(val) && !m_event.isEmpty()) {
+ m_event.dispatch();
+ }
+ }
+
+ bool VoiceControlStateProvider::updateState(bool isEnable)
+ {
+ if (m_enableState != isEnable) {
+ m_enableState = isEnable;
+ return true;
+ }
+ return false;
+ }
+
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_VOICE_CONTROL_STATE_PROVIDER_H__
+#define __CALL_UI_MODEL_IMPL_VOICE_CONTROL_STATE_PROVIDER_H__
+
+#include <vconf.h>
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(VoiceControlStateProvider);
+
+ class VoiceControlStateProvider final {
+ public:
+ static VoiceControlStateProviderSRef newInstance();
+ virtual ~VoiceControlStateProvider();
+
+ bool getState() const;
+ void addStateChangeHandler(const NotiHandler &handler);
+ void removeStateChangeHandler(const NotiHandler &handler);
+
+ private:
+ friend class ucl::ReffedObj<VoiceControlStateProvider>;
+ VoiceControlStateProvider();
+
+ ucl::Result prepare();
+
+ ucl::Result addSysStateCallback();
+ void delSysStateCallback();
+ ucl::Result initState();
+ bool updateState(bool isEnable);
+
+ void onStateChanged(keynode_t *node);
+
+ private:
+ bool m_enableState;
+ ucl::Event<NotiHandler> m_event;
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_IMPL_VOICE_CONTROL_STATE_PROVIDER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "VoiceControlStateSource.h"
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ VoiceControlStateSource::Bits::Bits():
+ property(convertEnumValueToInt(IndicatorProperty::VOICE_CONTROL)),
+ isEnable(0)
+ {
+ }
+
+ VoiceControlStateSource::Bits::Bits(const IndicatorState &state):
+ value(state.value)
+ {
+ if (property != convertEnumValueToInt(
+ IndicatorProperty::VOICE_CONTROL)) {
+ ELOG("State of incorrect property type [%d]", property);
+ *this = {};
+ }
+ }
+
+ VoiceControlStateSource::VoiceControlStateSource(IRefCountObj &rc,
+ const VoiceControlStateProviderSRef &provider):
+ RefCountAware(&rc),
+ m_vcProvider(provider)
+ {
+ m_vcProvider->addStateChangeHandler(WEAK_DELEGATE(
+ VoiceControlStateSource::onStateChangedEvent,
+ asWeak(*this)));
+
+ updateStateBits(m_vcProvider->getState());
+ }
+
+ VoiceControlStateSource::~VoiceControlStateSource()
+ {
+ m_vcProvider->removeStateChangeHandler(WEAK_DELEGATE(
+ VoiceControlStateSource::onStateChangedEvent,
+ asWeak(*this)));
+ }
+
+ VoiceControlStateSourceSRef VoiceControlStateSource::newInstance(
+ const VoiceControlStateProviderSRef &provider)
+ {
+ if (!provider) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "provider is NULL");
+ }
+
+ return makeShared<VoiceControlStateSource>(provider);
+ }
+
+ void VoiceControlStateSource::onStateChangedEvent()
+ {
+ if (updateStateBits(m_vcProvider->getState()) && m_handler) {
+ m_handler();
+ }
+ }
+
+ Result VoiceControlStateSource::initState()
+ {
+ updateStateBits(m_vcProvider->getState());
+ return RES_OK;
+ }
+
+ IndicatorState VoiceControlStateSource::getState() const
+ {
+ return {m_bits.value};
+ }
+
+ void VoiceControlStateSource::setStateChangeHandler(
+ const NotiHandler &handler)
+ {
+ m_handler = handler;
+ }
+
+ bool VoiceControlStateSource::updateStateBits(bool isEnable)
+ {
+ if (m_bits.isEnable != isEnable) {
+ m_bits.isEnable = isEnable;
+ return true;
+ }
+ return false;
+ }
+
+ bool getVoiceControlState(IndicatorState state)
+ {
+ return VoiceControlStateSource::Bits(state).isEnable;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_VOICE_CONTROL_STATE_SOURCE_H__
+#define __CALL_UI_VOICE_CONTROL_STATE_SOURCE_H__
+
+#include "IIndicatorStateSource.h"
+
+#include "VoiceControlStateProvider.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(VoiceControlStateSource);
+
+ class VoiceControlStateSource final :
+ public IIndicatorStateSource,
+ public ucl::RefCountAware {
+ public:
+ static VoiceControlStateSourceSRef newInstance(
+ const VoiceControlStateProviderSRef &provider);
+ virtual ~VoiceControlStateSource();
+
+ // IIndicatorStateSource
+
+ virtual IndicatorState getState() const override final;
+ virtual void setStateChangeHandler(
+ const NotiHandler &handler) override final;
+
+ private:
+ friend class ucl::ReffedObj<VoiceControlStateSource>;
+ VoiceControlStateSource(ucl::IRefCountObj &rc,
+ const VoiceControlStateProviderSRef &provider);
+
+ ucl::Result prepare();
+
+ void onStateChangedEvent();
+ ucl::Result initState();
+ bool updateStateBits(bool isEnable);
+
+ public:
+ union Bits {
+ struct {
+ uint8_t property : 4;
+ uint8_t isEnable : 1;
+ };
+ uint64_t value;
+
+ Bits();
+ Bits(const IndicatorState &state);
+ };
+
+ private:
+ Bits m_bits;
+ NotiHandler m_handler;
+ VoiceControlStateProviderSRef m_vcProvider;
+ };
+
+}
+
+#endif // __CALL_UI_VOICE_ANSWER_STATE_SOURCE_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_COMMON_H__
+#define __CALL_UI_MODEL_IMPL_COMMON_H__
+
+#include "call-ui/common.h"
+
+#include "helpers.h"
+
+#endif // __CALL_UI_MODEL_IMPL_COMMON_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_HELPERS_H__
+#define __CALL_UI_MODEL_IMPL_HELPERS_H__
+
+#include <call-manager-ext.h>
+#include <type_traits>
+
+#include "types.h"
+
+namespace callui {
+
+ ucl::Result convertCMResult(int cmRes);
+
+ AudioStateType convertCMAudioState(cm_audio_state_type_e state);
+
+ cm_multi_sim_slot_type_e convertCUISimSlot(SimSlot slot);
+
+ SimSlot convertCMSimSlot(cm_multi_sim_slot_type_e slot);
+
+ cm_call_release_type_e convertCUICallReleaseType(CallReleaseType type);
+
+ ucl::Result convertCMEventType(cm_call_event_e cmEvent, CallEventType *appEvent);
+
+ cm_call_answer_type_e convertCUICallAnswerType(CallAnswerType type);
+
+ bool isFlightModeActive();
+
+ template<typename TYPE>
+ constexpr auto convertEnumValueToInt(TYPE e) -> typename std::underlying_type<TYPE>::type
+ {
+ return static_cast<typename std::underlying_type<TYPE>::type>(e);
+ }
+}
+
+#include "helpers.hpp"
+
+#endif // __CALL_UI_MODEL_IMPL_HELPERS_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 <call-manager.h>
+#include <vconf.h>
+
+namespace callui {
+
+ inline ucl::Result convertCMResult(int cmRes)
+ {
+ switch (cmRes) {
+ case CM_ERROR_NONE: return ucl::RES_OK;
+ case CM_ERROR_OUT_OF_MEMORY: return ucl::RES_OUT_OF_MEMORY;
+ case CM_ERROR_INVALID_PARAMETER: return ucl::RES_INVALID_ARGUMENTS;
+ case CM_ERROR_PERMISSION_DENIED: return RES_PERMISSION_DENIED;
+ case CM_ERROR_NOT_SUPPORTED: return ucl::RES_NOT_SUPPORTED;
+ case CM_ERROR_NOT_REGISTERED: return ucl::RES_FATAL;
+ case CM_ERROR_ALREADY_REGISTERED: return RES_ALREADY_REGISTERED;
+ case CM_ERROR_OPERATION_FAILED: return RES_OPERATION_FAILED;
+ default:
+ return ucl::RES_FALSE;
+ }
+ }
+
+ inline AudioStateType convertCMAudioState(cm_audio_state_type_e state)
+ {
+ switch (state) {
+ case CM_AUDIO_STATE_NONE_E: return AudioStateType::NONE;
+ case CM_AUDIO_STATE_SPEAKER_E: return AudioStateType::SPEAKER;
+ case CM_AUDIO_STATE_RECEIVER_E: return AudioStateType::RECEIVER;
+ case CM_AUDIO_STATE_EARJACK_E: return AudioStateType::EARJACK;
+ case CM_AUDIO_STATE_BT_E: return AudioStateType::BT;
+ default:
+ return AudioStateType::NONE;
+ }
+ }
+
+ inline cm_multi_sim_slot_type_e convertCUISimSlot(SimSlot slot)
+ {
+ // TODO: this must be changed after Companion mode will be provided
+ return CM_MULTI_SIM_SLOT_DEFAULT;
+ }
+
+ inline SimSlot convertCMSimSlot(cm_multi_sim_slot_type_e slot)
+ {
+ // TODO: this must be changed after Companion mode will be provided
+ return SimSlot::GEAR;
+ }
+
+ inline cm_call_release_type_e convertCUICallReleaseType(CallReleaseType type)
+ {
+ switch (type) {
+ case CallReleaseType::BY_CALL_HANDLE: return CM_CALL_RELEASE_TYPE_BY_CALL_HANDLE;
+ case CallReleaseType::ALL: return CM_CALL_RELEASE_TYPE_ALL_CALLS;
+ case CallReleaseType::ALL_HOLD: return CM_CALL_RELEASE_TYPE_ALL_HOLD_CALLS;
+ case CallReleaseType::ALL_ACTIVE: return CM_CALL_RELEASE_TYPE_ALL_ACTIVE_CALLS;
+ default:
+ return CM_CALL_RELEASE_TYPE_BY_CALL_HANDLE;
+ }
+ }
+
+ inline ucl::Result convertCMEventType(cm_call_event_e cmEvent, CallEventType *appEvent)
+ {
+ switch (cmEvent) {
+ case CM_CALL_EVENT_IDLE:
+ *appEvent = CallEventType::END;
+ break;
+ case CM_CALL_EVENT_DIALING:
+ *appEvent = CallEventType::DIALING;
+ break;
+ case CM_CALL_EVENT_ACTIVE:
+ *appEvent = CallEventType::ACTIVE;
+ break;
+ case CM_CALL_EVENT_HELD:
+ *appEvent = CallEventType::HELD;
+ break;
+ case CM_CALL_EVENT_ALERT:
+ *appEvent = CallEventType::ALERT;
+ break;
+ case CM_CALL_EVENT_INCOMING:
+ *appEvent = CallEventType::INCOMING;
+ break;
+ case CM_CALL_EVENT_WAITING:
+ *appEvent = CallEventType::WAITING;
+ break;
+ case CM_CALL_EVENT_JOIN:
+ *appEvent = CallEventType::JOIN;
+ break;
+ case CM_CALL_EVENT_SPLIT:
+ *appEvent = CallEventType::SPLIT;
+ break;
+ case CM_CALL_EVENT_SWAPPED:
+ *appEvent = CallEventType::SWAPPED;
+ break;
+ case CM_CALL_EVENT_RETRIEVED:
+ *appEvent = CallEventType::RETRIEVED;
+ break;
+ case CM_CALL_EVENT_SAT_CALL_CONTROL:
+ *appEvent = CallEventType::SAT_CALL_CONTROL;
+ break;
+ default:
+ return ucl::RES_FAIL;
+ }
+ return ucl::RES_OK;
+ }
+
+ inline cm_call_answer_type_e convertCUICallAnswerType(CallAnswerType type)
+ {
+ switch (type) {
+ case CallAnswerType::NORMAL: return CALL_ANSWER_TYPE_NORMAL;
+ case CallAnswerType::HOLD_ACTIVE_AND_ACCEPT: return CALL_ANSWER_TYPE_HOLD_ACTIVE_AND_ACCEPT;
+ case CallAnswerType::RELEASE_ACTIVE_AND_ACCEPT: return CALL_ANSWER_TYPE_RELEASE_ACTIVE_AND_ACCEPT;
+ case CallAnswerType::RELEASE_HOLD_AND_ACCEPT: return CALL_ANSWER_TYPE_RELEASE_HOLD_AND_ACCEPT;
+ case CallAnswerType::RELEASE_ALL_AND_ACCEPT: return CALL_ANSWER_TYPE_RELEASE_ALL_AND_ACCEPT;
+ default:
+ return CALL_ANSWER_TYPE_NORMAL;
+ }
+ }
+
+ inline bool isFlightModeActive()
+ {
+ int status = false;;
+ if (vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &status) != 0) {
+ ELOG("Get Flight mode status failed!");
+ return false;
+ }
+ return status;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_IMPL_TYPES_H__
+#define __CALL_UI_MODEL_IMPL_TYPES_H__
+
+#include "call-ui/model/types.h"
+#include "ucl/misc/Event.h"
+#include "ucl/util/smartDelegation.h"
+
+namespace callui {
+
+ enum class CallReleaseType {
+ BY_CALL_HANDLE,
+ ALL,
+ ALL_HOLD,
+ ALL_ACTIVE
+ };
+
+ enum class CallManagerErr {
+ DIAL_CANCEL,
+ DIAL_FAIL,
+ DIAL_FAIL_SS,
+ DIAL_FAIL_FDN,
+ DIAL_FLIGHT_MODE
+ };
+
+}
+
+#endif // __CALL_UI_MODEL_IMPL_IMPL_TYPES_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_MODEL_TYPES_H__
+#define __CALL_UI_MODEL_TYPES_H__
+
+#include <vector>
+
+#include "call-ui/types.h"
+
+namespace callui {
+
+ enum class CallErr {
+ DIAL_CANCEL,
+ DIAL_FAIL,
+ DIAL_FLIGHT_MODE
+ };
+
+ enum class SimSlot {
+ UNDEFINED = 0,
+ GEAR,
+ MOBILE_FIRST,
+ MOBILE_SECOND,
+ MOBILE_DEFAULT
+ };
+
+ enum class CallAnswerType {
+ NORMAL,
+ HOLD_ACTIVE_AND_ACCEPT,
+ RELEASE_ACTIVE_AND_ACCEPT,
+ RELEASE_HOLD_AND_ACCEPT,
+ RELEASE_ALL_AND_ACCEPT
+ };
+
+ enum class AudioStateType {
+ NONE,
+ SPEAKER,
+ RECEIVER,
+ EARJACK,
+ BT
+ };
+
+ enum {
+ CALL_FLAG_NONE = 0,
+ CALL_FLAG_INCOMING = 1,
+ CALL_FLAG_ACTIVE = 2,
+ CALL_FLAG_HELD = 4,
+ CALL_FLAG_END = 8
+ };
+ using CallMask = int;
+
+ enum class CallEventType {
+ END,
+ DIALING,
+ ACTIVE,
+ HELD,
+ ALERT,
+ INCOMING,
+ WAITING,
+ JOIN,
+ SPLIT,
+ SWAPPED,
+ RETRIEVED,
+ SAT_CALL_CONTROL
+ };
+
+ enum class ContactNameSourceType {
+ INVALID,
+ EMAIL,
+ NUMBER,
+ NICKNAME,
+ COMPANY,
+ NAME
+ };
+
+ enum class ConnectionType {
+ NONE = 0,
+ EDGE_E,
+ GPRS_G,
+ SIMPLE_2G,
+ HSDPA_H,
+ HSPA_H_PLUS,
+ LTE_4G,
+ UMTS_3G,
+ UMTS_3G_PLUS,
+ NO_SIM,
+ WIFI_00,
+ WIFI_01,
+ WIFI_02,
+ WIFI_03,
+ WIFI_04,
+ NO_SIGNAL
+ };
+
+ enum class PacketDirection {
+ NONE = 0,
+ NO_INPUT,
+ IN,
+ OUT,
+ INOUT
+ };
+
+ enum class RssiState {
+ NONE = 0,
+ LEVEL_0,
+ LEVEL_1,
+ LEVEL_2,
+ LEVEL_3,
+ LEVEL_4,
+ NO_SIGNAL,
+ FLIGHT_MODE
+ };
+
+ enum class BatteryState {
+ NORMAL = 0,
+ CHARGING,
+ CHARGING_PROBLEM,
+ UNKNOWN
+ };
+
+ enum class IndicatorProperty {
+ NW_CONNECTION = 0,
+ RSSI,
+ BATTERY,
+ VOICE_CONTROL,
+ SIM_SLOT,
+ HD_VOICE
+ };
+
+ using AudioStateHandler = ucl::WeakDelegate<void(AudioStateType)>;
+ using MuteStateHandler = ucl::WeakDelegate<void(bool)>;
+ using VolumeLevelHandler = ucl::WeakDelegate<void(int)>;
+
+}
+
+#endif // __CALL_UI_MODEL_TYPES_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "Instance.h"
+
+#include "ucl/util/memory.h"
+#include "ucl/appfw/SysEventProvider.h"
+#include "ucl/appfw/helpers.h"
+
+#include <system_settings.h>
+
+#include "call-ui/model/CallUIBuilder.h"
+#include "call-ui/model/ICallUI.h"
+#include "call-ui/model/ICallManager.h"
+#include "pages/MainPage.h"
+
+#include "call-ui/resources.h"
+#include "common.h"
+
+namespace callui { namespace { namespace impl {
+
+ using namespace ucl;
+
+ const char *STR_POWER_KEY = "XF86PowerOff";
+
+}}}
+
+namespace callui {
+
+ using namespace ucl;
+
+ Instance::Instance(IRefCountObj &rc,
+ SysEventProvider &sysEventProvider) :
+ RefCountAware(&rc),
+ m_sysEventProvider(sysEventProvider),
+ m_context(nullptr),
+ m_keyUpEventHandler(nullptr)
+ {
+ }
+
+ Instance::~Instance()
+ {
+ elm_win_keygrab_unset(*m_win, impl::STR_POWER_KEY, 0, 0);
+
+ if (m_keyUpEventHandler) {
+ ecore_event_handler_del(m_keyUpEventHandler);
+ }
+
+ if (const auto page = m_page.lock()) {
+ page->exitNoTransition();
+ }
+ }
+
+ Result Instance::onCreate(IInstanceContext *const context)
+ {
+ m_context = context;
+
+ m_win = m_context->getWindow();
+
+ elm_win_keygrab_set(*m_win, impl::STR_POWER_KEY, 0, 0, 0,
+ ELM_WIN_KEYGRAB_EXCLUSIVE);
+
+ m_keyUpEventHandler = ecore_event_handler_add(ECORE_EVENT_KEY_UP,
+ CALLBACK_A(Instance::onKeyUpEventCb), this);
+ if (!m_keyUpEventHandler) {
+ LOG_RETURN(RES_FAIL, "m_eventHandler is NULL");
+ }
+
+ FAIL_RETURN(setupTheme(), "setupTheme() failed!");
+
+ m_call = CallUIBuilder().build();
+ if (!m_call) {
+ LOG_RETURN(RES_FAIL, "m_call is NULL");
+ }
+
+ m_navi = Naviframe::Builder().
+ build(m_win->getConformant());
+ if (!m_navi) {
+ LOG_RETURN(RES_FAIL, "Naviframe::build() failed!");
+ }
+
+ m_win->getConformant().setContent(*m_navi);
+ elm_atspi_accessible_translation_domain_set(*m_win, PACKAGE);
+ elm_atspi_accessible_name_set(*m_win, AO_STR_CALL);
+
+ FAIL_RETURN(utils::createCircleSurface(*m_navi),
+ "createCircleSurface() failed!");
+
+ m_sysEventProvider.addEventHandler(
+ WEAK_DELEGATE(Instance::onSysEvent, asWeak(*this)));
+
+ return RES_OK;
+ }
+
+ void Instance::onPause()
+ {
+ ILOG("PAUSED");
+ }
+
+ void Instance::onResume()
+ {
+ ILOG("RESUMED");
+ }
+
+ void Instance::onAppControl(app_control_h appControl)
+ {
+ if (!m_page) {
+ auto page = MainPage::Builder().
+ setNaviframe(m_navi).
+ setCallUI(m_call).
+ build(WEAK_DELEGATE(Instance::onPageExitRequest,
+ asWeak(*this)));
+ if (!page) {
+ ELOG("Create page failed! Exit application");
+ m_context->exitApp();
+ }
+ m_call->setListener(page);
+ m_page = page;
+ }
+
+ Result res = m_call->processAppControl(appControl);
+ if (res != RES_OK) {
+ ELOG("processAppControl() failed!");
+ ICallManagerSRef callManager = m_call->getCallManager();
+ if (!callManager->getAvailableCalls()) {
+ ILOG("No calls. Exit application");
+ m_context->exitApp();
+ }
+ }
+ }
+
+ Result Instance::setupTheme()
+ {
+ m_theme = Theme::create();
+ if (isNotValid(m_theme)) {
+ LOG_RETURN(RES_FAIL, "Theme::create() failed!");
+ }
+
+ m_theme.addExtension(getResPath(THEME_EDJE_PATH));
+
+ m_win->setTheme(m_theme);
+
+ return RES_OK;
+ }
+
+ Eina_Bool Instance::onKeyUpEventCb(int type, void *event)
+ {
+ if (!event) {
+ LOG_RETURN_VALUE(RES_FAIL, ECORE_CALLBACK_DONE, "event is NULL");
+ }
+
+ Ecore_Event_Key *ev = static_cast<Ecore_Event_Key *>(event);
+ if (!strcmp(ev->keyname, impl::STR_POWER_KEY)) {
+ DLOG("Key power [Up]");
+ m_win->callEvent(WIN_POWER_KEY_UP_EVENT, nullptr);
+ }
+ return ECORE_CALLBACK_DONE;
+ }
+
+ void Instance::onPageExitRequest(Page &page)
+ {
+ m_context->exitApp();
+ }
+
+ void Instance::onSysEvent(const SysEvent sysEvent)
+ {
+ switch(sysEvent) {
+ case SysEvent::LANGUAGE_CHANGED:
+ ILOG("SysEvent::LANGUAGE_CHANGED");
+ {
+ char *locale = NULL;
+ system_settings_get_value_string(
+ SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
+ elm_language_set(locale);
+ free(locale);
+ }
+ break;
+ default:
+ ILOG("sysEvent: %d", sysEvent);
+ break;
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_INSTANCE_H__
+#define __CALL_UI_PRESENTERS_INSTANCE_H__
+
+#include "ucl/appfw/IInstance.h"
+#include "ucl/appfw/IInstanceAppControlExt.h"
+#include "ucl/appfw/SysEventProvider.h"
+#include "ucl/gui/Theme.h"
+#include "ucl/gui/Naviframe.h"
+
+#include "call-ui/model/ICallUI.h"
+
+#include "base/Page.h"
+
+namespace callui {
+
+ class Instance final : public ucl::RefCountAware,
+ public ucl::IInstance,
+ public ucl::IInstanceAppControlExt {
+ public:
+ Instance(ucl::IRefCountObj &rc,
+ ucl::SysEventProvider &sysEventProvider);
+ virtual ~Instance();
+
+ // IInstance //
+
+ virtual ucl::Result onCreate(
+ ucl::IInstanceContext *context) final override;
+ virtual void onPause() final override;
+ virtual void onResume() final override;
+
+ // IInstanceAppControlExt //
+
+ virtual void onAppControl(app_control_h appControl) final override;
+
+ private:
+ ucl::Result setupTheme();
+
+ void onSysEvent(const ucl::SysEvent sysEvent);
+ void onPageExitRequest(Page &page);
+
+ Eina_Bool onKeyUpEventCb(int type, void *event);
+
+ private:
+ ucl::SysEventProvider &m_sysEventProvider;
+ ucl::IInstanceContext *m_context;
+
+ ICallUISRef m_call;
+
+ ucl::WindowSRef m_win;
+ ucl::NaviframeSRef m_navi;
+ ucl::Theme m_theme;
+
+ PageWRef m_page;
+
+ Ecore_Event_Handler *m_keyUpEventHandler;
+ };
+}
+
+#endif // __CALL_UI_PRESENTERS_INSTANCE_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "InstanceManager.h"
+
+#include "Instance.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ InstanceManager::InstanceManager() :
+ InstanceManagerBase(AppParams().
+ set(AppParam::WINDOW_NAME, WINDOW_NAME).
+ set(AppParam::BASE_SCALE, BASE_SCALE))
+ {
+ }
+
+ IInstanceSRef InstanceManager::newInstance() const
+ {
+ return makeShared<Instance>(getSysEventProvider());
+ }
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_INSTANCE_MANAGER_H__
+#define __CALL_UI_PRESENTERS_INSTANCE_MANAGER_H__
+
+#include "call-ui/model/types.h"
+
+#include "ucl/appfw/InstanceManagerBase.h"
+
+namespace callui {
+
+ class InstanceManager : public ucl::InstanceManagerBase {
+ public:
+ InstanceManager();
+
+ // ucl::InstanceManagerBase //
+
+ virtual ucl::IInstanceSRef newInstance() const final override;
+ };
+}
+
+#endif // __CALL_UI_PRESENTERS_INSTANCE_MANAGER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "Page.h"
+
+#include "common.h"
+
+namespace callui { namespace { namespace impl {
+
+ constexpr SmartEvent TOP_PAGE_CHANGED {"ucl,top,page,changed"};
+}}}
+
+namespace callui {
+
+ using namespace ucl;
+
+ Page::Page(IRefCountObj &rc, const NaviframeSRef &navi,
+ const ExitRequestHandler &onExitRequest) :
+ GuiPresenter(rc),
+ m_navi(navi),
+ m_onExitRequest(onExitRequest)
+ {
+ UCL_ASSERT(navi, "navi is NULL!");
+ UCL_ASSERT(onExitRequest, "onExitRequest is NULL!");
+
+ deactivateBy(m_navi.get());
+ }
+
+ Page::~Page()
+ {
+ }
+
+ Result Page::preparePart2()
+ {
+ if (!m_item) {
+ UCL_LOG_RETURN(ucl::RES_FAIL, "m_item is NULL");
+ }
+
+ Evas_Object *content = m_item.getContent();
+ if (!content) {
+ LOG_RETURN(RES_FAIL, "content is NULL");
+ }
+
+ m_navi->addEventHandler(NAVI_TRANSITION_STARTED,
+ WEAK_DELEGATE(Page::onTransitionStarted, asWeak(*this)));
+
+ m_navi->addEventHandler(NAVI_TRANSITION_FINISHED,
+ WEAK_DELEGATE(Page::onTransitionFinished, asWeak(*this)));
+
+ m_navi->addEventHandler(impl::TOP_PAGE_CHANGED,
+ WEAK_DELEGATE(Page::onTopPageChanged, asWeak(*this)));
+
+ eext_object_event_callback_add(content, EEXT_CALLBACK_BACK,
+ CALLBACK_A(Page::onHWBackKey), this);
+
+ m_item.setData(this);
+ m_item.setDelCallback(CALLBACK_A(Page::onItemDel));
+
+ m_selfRef = asShared(*this);
+
+ if (!m_navi->isInTransition() && isAtTop()) {
+ dispatchTopPageChanged();
+ }
+
+ return RES_OK;
+ }
+
+ void Page::dispatchTopPageChanged()
+ {
+ if (!m_navi->isInTransition()) {
+ m_navi->callEvent(impl::TOP_PAGE_CHANGED, nullptr);
+ } else {
+ WLOG("Forcig Transition Finished!");
+ m_navi->setInTransition(false);
+ }
+ }
+
+ void Page::onItemDel(Evas_Object *obj, void *eventInfo)
+ {
+ m_item = nullptr;
+ m_selfRef.reset();
+ }
+
+ void Page::exit()
+ {
+ if (isAtTop() && !isAtBottom() && !m_navi->isInTransition()) {
+ m_navi->pop();
+ m_item = nullptr;
+ } else {
+ exitNoTransition();
+ }
+ }
+
+ void Page::exitNoTransition()
+ {
+ if (isAtTop()) {
+ m_item.del();
+ dispatchTopPageChanged();
+ } else if (m_item) {
+ m_item.del();
+ }
+ }
+
+ void Page::popTo()
+ {
+ if (m_item && !isAtTop()) {
+ m_item.popTo();
+ }
+ }
+
+ void Page::deleteTo()
+ {
+ if (m_item && !isAtTop()) {
+ while (!isAtTop()) {
+ m_navi->getTopItem().del();
+ }
+ dispatchTopPageChanged();
+ }
+ }
+
+ void Page::promote()
+ {
+ if (m_item && !isAtTop()) {
+ m_item.promote();
+ }
+ }
+
+ NaviItem Page::getItem()
+ {
+ return m_item;
+ }
+
+ void Page::requestExit()
+ {
+ if (m_onExitRequest) {
+ m_onExitRequest(*this);
+ } else {
+ WLOG("m_onExitRequest is NULL");
+ exit();
+ }
+ }
+
+ void Page::updateActiveState()
+ {
+ if (isAtTop()) {
+ activateBy(m_navi.get());
+ } else {
+ deactivateBy(m_navi.get());
+ }
+ }
+
+ void Page::onTransitionStarted(Widget &widget, void *eventInfo)
+ {
+ deactivateBy(m_navi.get());
+ }
+
+ void Page::onTransitionFinished(Widget &widget, void *eventInfo)
+ {
+ updateActiveState();
+ }
+
+ void Page::onTopPageChanged(Widget &widget, void *eventInfo)
+ {
+ updateActiveState();
+ }
+
+ void Page::onHWBackKey(Evas_Object *obj, void *eventInfo)
+ {
+ if (isActive()) {
+ onBackKey();
+ }
+ }
+
+ void Page::onBackKey()
+ {
+ requestExit();
+ }
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_BASE_PAGE_H__
+#define __CALL_UI_PRESENTERS_BASE_PAGE_H__
+
+#include "ucl/gui/Naviframe.h"
+
+#include "ucl/mvp/GuiPresenter.h"
+
+#include "call-ui/types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(Page);
+
+ class Page : public ucl::GuiPresenter {
+ public:
+ using ExitRequestHandler = ucl::WeakDelegate<void(Page &page)>;
+
+ public:
+ ucl::Naviframe &getNaviframe();
+
+ bool isAtTop() const;
+ bool isAtBottom() const;
+
+ void exit();
+ void exitNoTransition();
+
+ void popTo();
+ void deleteTo();
+ void promote();
+
+ template <class ...ARGS>
+ ucl::NaviItem insertAfter(ARGS &&...args);
+
+ template <class ...ARGS>
+ ucl::NaviItem insertBefore(ARGS &&...args);
+
+ protected:
+ Page(ucl::IRefCountObj &rc, const ucl::NaviframeSRef &navi,
+ const ExitRequestHandler &onExitRequest);
+ virtual ~Page();
+
+ template <class ON_PREPARE>
+ ucl::Result prepare(ON_PREPARE &&onPrepare);
+
+ ucl::NaviItem getItem();
+
+ void requestExit();
+
+ virtual void onBackKey();
+
+ private:
+ ucl::Result preparePart2();
+
+ void dispatchTopPageChanged();
+
+ void updateActiveState();
+
+ void onTransitionStarted(ucl::Widget &widget, void *eventInfo);
+ void onTransitionFinished(ucl::Widget &widget, void *eventInfo);
+ void onTopPageChanged(ucl::Widget &widget, void *eventInfo);
+
+ void onHWBackKey(Evas_Object *obj, void *eventInfo);
+ void onItemDel(Evas_Object *obj, void *eventInfo);
+
+ private:
+ const ucl::NaviframeSRef m_navi;
+ const ExitRequestHandler m_onExitRequest;
+ ucl::NaviItem m_item;
+ PageSRef m_selfRef;
+ };
+
+ // Non-member functions
+
+ bool isLast(const Page &page);
+}
+
+#include "Page.hpp"
+
+#endif // __CALL_UI_PRESENTERS_BASE_PAGE_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "ucl/util/logging.h"
+
+namespace callui {
+
+ template <class ON_PREPARE>
+ inline ucl::Result Page::prepare(ON_PREPARE &&onPrepare)
+ {
+ UCL_FAIL_RETURN(GuiPresenter::prepare(*m_navi),
+ "GuiPresenter::prepare() failed!");
+
+ UCL_FAIL_RETURN(onPrepare(m_item), "onPrepare() failed!");
+
+ return preparePart2();
+ }
+
+ template <class ...ARGS>
+ inline ucl::NaviItem Page::insertAfter(ARGS &&...args)
+ {
+ return m_navi->insertAfter(m_item, std::forward<ARGS>(args)...);
+ }
+
+ template <class ...ARGS>
+ inline ucl::NaviItem Page::insertBefore(ARGS &&...args)
+ {
+ return m_navi->insertBefore(m_item, std::forward<ARGS>(args)...);
+ }
+
+ inline ucl::Naviframe &Page::getNaviframe()
+ {
+ UCL_ASSERT(m_navi, "m_navi is NULL");
+ return *m_navi;
+ }
+
+ inline bool Page::isAtTop() const
+ {
+ return (m_navi->getTopItem() == m_item);
+ }
+
+ inline bool Page::isAtBottom() const
+ {
+ return (m_navi->getBottomItem() == m_item);
+ }
+
+ // Non-member functions
+
+ inline bool isLast(const Page &page)
+ {
+ return (page.isAtBottom() && page.isAtTop());
+ }
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_BASE_COMMON_H__
+#define __CALL_UI_PRESENTERS_BASE_COMMON_H__
+
+#include "call-ui/presenters/common.h"
+
+#endif // __CALL_UI_PRESENTERS_BASE_COMMON_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_COMMON_H__
+#define __CALL_UI_PRESENTERS_COMMON_H__
+
+#include "ucl/gui/stdTheme.h"
+
+#include "call-ui/view/helpers.h"
+
+#include "misc/helpers.h"
+
+#include "call-ui/view/common.h"
+
+namespace callui {
+ constexpr auto CALL_VC_TIMER_INTERVAL = 1.5;
+ constexpr auto CALL_VC_SCREEN_READER_TIMER_INTERVAL = 5.0;
+ constexpr auto VOLUME_LEVEL_MIN = 1;
+}
+
+#endif // __CALL_UI_PRESENTERS_COMMON_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "AcceptDialog.h"
+
+#include "call-ui/resources.h"
+
+#include "common.h"
+
+namespace callui { namespace { namespace impl {
+
+ using namespace ucl;
+
+ constexpr ElmStyle POPUP_STYLE {"circle"};
+
+ constexpr SmartEvent POPUP_DISMISSED {"dismissed"};
+
+ constexpr EdjePart PART_SWL_CONTENT{"elm.swallow.content"};
+
+ void *asData(const AcceptDialog::Event event)
+ {
+ return reinterpret_cast<void *>(static_cast<intptr_t>(event));
+ }
+
+ AcceptDialog::Event asEvent(void *const data)
+ {
+ return static_cast<AcceptDialog::Event>(
+ reinterpret_cast<intptr_t>(data));
+ }
+
+}}}
+
+namespace callui {
+
+ using namespace ucl;
+
+ AcceptDialog::Builder::Builder()
+ {
+ }
+
+ AcceptDialog::Builder::~Builder()
+ {
+ }
+
+ AcceptDialog::Builder &
+ AcceptDialog::Builder::setHandler(EventHandler handler)
+ {
+ m_handler = handler;
+ return *this;
+ }
+
+ AcceptDialogWRef AcceptDialog::Builder::build(ElmWidget &parent) const
+ {
+ if (!m_handler) {
+ LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_handler is NULL");
+ }
+
+ auto result = makeShared<AcceptDialog>(m_handler);
+ FAIL_RETURN_VALUE(result->prepare(parent), {},
+ "result->prepare() failed!");
+
+ return result;
+ }
+
+ AcceptDialog::AcceptDialog(IRefCountObj &rc,
+ const EventHandler &handler):
+ GuiPresenter(rc),
+ m_handler(handler),
+ m_isDismissed(false)
+ {
+ }
+
+ AcceptDialog::~AcceptDialog()
+ {
+ }
+
+ Result AcceptDialog::prepare(ElmWidget &parent)
+ {
+ FAIL_RETURN(GuiPresenter::prepare(parent, PF_DEACTIVATOR),
+ "Presenter::prepare() failed!");
+
+ FAIL_RETURN(createPopup(parent, impl::POPUP_STYLE),
+ "createPopup() failed!");
+
+ FAIL_RETURN(createGenlist(),
+ "createGenlist() failed!");
+
+ m_selfRef = asShared(*this);
+
+ addDeactivatorException(this);
+ broadcastDeactivate();
+
+ return RES_OK;
+ }
+
+ Result AcceptDialog::createPopup(ElmWidget &parent, ElmStyle style)
+ {
+ Evas_Object *const popupEo = elm_popup_add(parent);
+ if (!popupEo) {
+ LOG_RETURN(RES_FAIL, "elm_popup_add() failed!");
+ }
+ m_popup = makeShared<StyledWidget>(popupEo, true);
+ m_popup->setStyle(style);
+ m_popup->setWeight(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ show(*m_popup);
+
+ m_popup->addEventHandler(impl::POPUP_DISMISSED, WEAK_DELEGATE(
+ AcceptDialog::onPopupDismissed, asWeak(*this)));
+
+ eext_object_event_callback_add(*m_popup, EEXT_CALLBACK_BACK,
+ CALLBACK_A(AcceptDialog::onPopupHWBackKey), this);
+
+ return RES_OK;
+ }
+
+ void AcceptDialog::onGenlistItemClickedCb(Evas_Object *obj, void *eventInfo)
+ {
+ if (!eventInfo)
+ LOG_RETURN_VOID(RES_FAIL, "eventInfo is NULL");
+
+ Elm_Object_Item *item = static_cast<Elm_Object_Item *>(eventInfo);
+ handleEvent(impl::asEvent(elm_object_item_data_get(item)));
+ }
+
+ Result AcceptDialog::createGenlist()
+ {
+ Evas_Object *const glEo = elm_genlist_add(*m_popup);
+ if (!glEo) {
+ LOG_RETURN(RES_FAIL, "elm_genlist_add() failed!");
+ }
+ elm_genlist_mode_set(glEo, ELM_LIST_COMPRESS);
+ elm_genlist_homogeneous_set(glEo, EINA_TRUE);
+
+ m_genlist = makeShared<StyledWidget>(glEo);
+ m_genlist->setWeight(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ m_genlist->setAlign(EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ Evas_Object *circleGlEo = eext_circle_object_genlist_add(glEo,
+ utils::getCircleSurface(*m_genlist));
+ eext_circle_object_genlist_scroller_policy_set(circleGlEo,
+ ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
+ eext_rotary_object_event_activated_set(circleGlEo, EINA_TRUE);
+
+ FAIL_RETURN(fillGenlist(), "fillGenlist() failed!");
+
+ m_popup->setContent(glEo, impl::PART_SWL_CONTENT);
+
+ return RES_OK;
+ }
+
+ Result AcceptDialog::addGenlistTitleItem()
+ {
+ static Elm_Genlist_Item_Class titleItc =
+ utils::createGenlistItemClass("title",
+ [](void *data, Evas_Object *obj, const char *part) -> char * {
+ return strdup(STR_ANSWER_CALL.translate());
+ });
+
+ Elm_Object_Item *item = elm_genlist_item_append(*m_genlist, &titleItc,
+ nullptr,
+ nullptr,
+ ELM_GENLIST_ITEM_NONE,
+ nullptr,
+ nullptr);
+ if (!item)
+ LOG_RETURN(RES_FAIL, "elm_genlist_item_append() failed!");
+
+ return RES_OK;
+ }
+
+ Result AcceptDialog::addGenlistTextItem(Event event)
+ {
+ static Elm_Genlist_Item_Class textItc =
+ utils::createGenlistItemClass("1text.1icon",
+ [](void *data, Evas_Object *obj, const char *part) -> char * {
+ switch (impl::asEvent(data)) {
+ case Event::HOLD_AND_ACCEPT:
+ return strdup(STR_HOLD_AND_ACCEPT.translate());
+ case Event::END_AND_ACCEPT:
+ return strdup(STR_END_AND_ACCEPT.translate());
+ default:
+ return nullptr;
+ }
+ });
+
+ Elm_Object_Item *item = elm_genlist_item_append(*m_genlist, &textItc,
+ impl::asData(event),
+ nullptr,
+ ELM_GENLIST_ITEM_NONE,
+ CALLBACK_A(AcceptDialog::onGenlistItemClickedCb),
+ this);
+ if (!item)
+ LOG_RETURN(RES_FAIL, "elm_genlist_item_append() failed!");
+
+ return RES_OK;
+ }
+
+ Result AcceptDialog::addGenlistBottomItem()
+ {
+ static Elm_Genlist_Item_Class paddingItc =
+ utils::createGenlistItemClass("1text.1icon");
+ Elm_Object_Item *item = elm_genlist_item_append(*m_genlist, &paddingItc,
+ nullptr,
+ nullptr,
+ ELM_GENLIST_ITEM_NONE,
+ nullptr,
+ nullptr);
+ if (!item)
+ LOG_RETURN(RES_FAIL, "elm_genlist_item_append() failed!");
+
+ return RES_OK;
+ }
+
+
+ Result AcceptDialog::fillGenlist()
+ {
+ FAIL_RETURN(addGenlistTitleItem(), "addGenlistTitleItem() failed!");
+
+ FAIL_RETURN(addGenlistTextItem(Event::HOLD_AND_ACCEPT),
+ "addGenlistTextItem() failed!");
+
+ FAIL_RETURN(addGenlistTextItem(Event::END_AND_ACCEPT),
+ "addGenlistTextItem() failed!");
+
+ FAIL_RETURN(addGenlistBottomItem(), "addGenlistBottomItem() failed!");
+
+ return RES_OK;
+ }
+
+ void AcceptDialog::handleEvent(Event event)
+ {
+ const auto keepAliver = asShared(*this);
+ if (dispatchEvent(event)) {
+ dismiss();
+ }
+ }
+
+ bool AcceptDialog::dispatchEvent(Event event)
+ {
+ if (!m_handler) {
+ WLOG("Handler was destroyed!");
+ return true;
+ }
+ return m_handler(*this, event);
+ }
+
+ void AcceptDialog::onPopupDismissed(ucl::Widget &widget, void *eventInfo)
+ {
+ dispose();
+ }
+
+ void AcceptDialog::onPopupHWBackKey(Evas_Object *obj, void *eventInfo)
+ {
+ if (!m_isDismissed) {
+ handleEvent(Event::BACK);
+ }
+ }
+
+ void AcceptDialog::dismiss()
+ {
+ if (m_popup && !m_isDismissed) {
+ m_isDismissed = true;
+ deactivateBy(m_popup.get());
+ elm_popup_dismiss(*m_popup);
+ }
+ }
+
+ void AcceptDialog::dispose()
+ {
+ if (m_popup) {
+
+ eext_object_event_callback_del(*m_popup, EEXT_CALLBACK_BACK,
+ CALLBACK_A(AcceptDialog::onPopupHWBackKey));
+
+ deactivateBy(m_popup.get());
+ broadcastActivate();
+
+ m_popup.reset();
+
+ m_selfRef.reset();
+ }
+ }
+
+ bool AcceptDialog::isDisposed() const
+ {
+ return (!m_popup);
+ }
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_DIALOGS_ACCEPT_DIALOG_H__
+#define __CALL_UI_PRESENTERS_DIALOGS_ACCEPT_DIALOG_H__
+
+#include "ucl/mvp/GuiPresenter.h"
+
+#include "ucl/gui/StyledWidget.h"
+
+#include "call-ui/types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(AcceptDialog);
+
+ class AcceptDialog final : public ucl::GuiPresenter,
+ public ucl::IDisposable {
+ public:
+ enum class Event {
+ HOLD_AND_ACCEPT,
+ END_AND_ACCEPT,
+ BACK
+ };
+ using EventHandler = ucl::WeakDelegate<bool(
+ AcceptDialog &, Event)>;
+
+ public:
+ class Builder {
+ public:
+ Builder();
+ ~Builder();
+ Builder &setHandler(EventHandler handler);
+ AcceptDialogWRef build(ucl::ElmWidget &parent) const;
+ private:
+ EventHandler m_handler;
+ };
+
+ public:
+ virtual ~AcceptDialog();
+
+ void dismiss();
+
+ // ucl::IDisposable
+
+ virtual void dispose() final override;
+ virtual bool isDisposed() const final override;
+
+ private:
+ friend class ucl::ReffedObj<AcceptDialog>;
+ AcceptDialog(ucl::IRefCountObj &rc,
+ const EventHandler &handler);
+
+ ucl::Result prepare(ucl::ElmWidget &parent);
+
+ ucl::Result createPopup(ucl::ElmWidget &parent, ucl::ElmStyle style);
+ ucl::Result createGenlist();
+ ucl::Result fillGenlist();
+ ucl::Result addGenlistTitleItem();
+ ucl::Result addGenlistTextItem(Event event);
+ ucl::Result addGenlistBottomItem();
+
+ void handleEvent(Event event);
+ bool dispatchEvent(Event event);
+
+ void onPopupDismissed(ucl::Widget &widget, void *eventInfo);
+ void onPopupHWBackKey(Evas_Object *obj, void *eventInfo);
+
+ void onGenlistItemClickedCb(Evas_Object *obj, void *eventInfo);
+
+ private:
+ ucl::StyledWidgetSRef m_popup;
+ ucl::StyledWidgetSRef m_genlist;
+ EventHandler m_handler;
+ AcceptDialogSRef m_selfRef;
+ bool m_isDismissed;
+ };
+}
+
+#endif // __CALL_UI_PRESENTERS_DIALOGS_ACCEPT_DIALOG_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_DIALOGS_COMMON_H__
+#define __CALL_UI_PRESENTERS_DIALOGS_COMMON_H__
+
+#include "call-ui/presenters/common.h"
+
+#endif // __CALL_UI_PRESENTERS_DIALOGS_COMMON_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "AcceptRejectPresenter.h"
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ // AcceptRejectPresenter::Builder
+
+ AcceptRejectPresenter::Builder::Builder():
+ m_callMask(CALL_FLAG_NONE)
+ {
+ }
+
+ AcceptRejectPresenter::Builder::~Builder()
+ {
+ }
+
+ AcceptRejectPresenter::Builder &
+ AcceptRejectPresenter::Builder::setIncomingCall(
+ const IIncomingCallSRef &call)
+ {
+ m_call = call;
+ return *this;
+ }
+
+ AcceptRejectPresenter::Builder &
+ AcceptRejectPresenter::Builder::setAvailableCallsFlag(CallMask mask)
+ {
+ m_callMask = mask;
+ return *this;
+ }
+
+ AcceptRejectPresenter::Builder &
+ AcceptRejectPresenter::Builder::setSoundManager(
+ const ISoundManagerSRef &sm)
+ {
+ m_sm = sm;
+ return *this;
+ }
+
+ AcceptRejectPresenter::Builder &
+ AcceptRejectPresenter::Builder::setParentWidget(
+ const ElmWidgetSRef &parentWidget)
+ {
+ m_parentWidget = parentWidget;
+ return *this;
+ }
+
+ AcceptRejectPresenterSRef
+ AcceptRejectPresenter::Builder::build(GuiPresenter &parent) const
+ {
+ if (!m_parentWidget || !m_call || !m_sm) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "Main params are not set");
+ }
+
+ auto result = makeShared<AcceptRejectPresenter>(m_call,
+ m_callMask,
+ m_sm);
+ FAIL_RETURN_VALUE(result->prepare(parent, *m_parentWidget),
+ {}, "result->prepare() failed!");
+ return result;
+ }
+
+ // AcceptRejectPresenter
+
+ AcceptRejectPresenter::AcceptRejectPresenter(IRefCountObj &rc,
+ const IIncomingCallSRef &call,
+ CallMask calls,
+ const ISoundManagerSRef &sm):
+ GuiPresenter(rc),
+ m_call(call),
+ m_callMask(calls),
+ m_sm(sm)
+ {
+ }
+
+ AcceptRejectPresenter::~AcceptRejectPresenter()
+ {
+ if (const auto popup = m_popup.lock()) {
+ popup->dispose();
+ }
+
+ if (m_widget) {
+ m_widget->deactivateRotary();
+ }
+
+ m_sm->delBTHeadsetConnectionChangeHandler(
+ WEAK_DELEGATE(AcceptRejectPresenter::
+ onBTHeadsetConnectionChanged,
+ asWeak(*this)));
+ }
+
+ Result AcceptRejectPresenter::prepare(GuiPresenter &parent,
+ ElmWidget &parentWidget)
+ {
+ FAIL_RETURN(GuiPresenter::prepare(parent),
+ "Presenter::prepare() failed!");
+
+ m_sm->addBTHeadsetConnectionChangeHandler(
+ WEAK_DELEGATE(AcceptRejectPresenter::
+ onBTHeadsetConnectionChanged,
+ asWeak(*this)));
+
+ FAIL_RETURN(createWidget(parentWidget),
+ "createWidget() failed!");
+
+ // Motion sensor not supported on Emulator
+ if (createMotionSensorPresenter() != RES_OK) {
+ ELOG("createMotionSensorPresenter() failed!");
+ }
+
+ return RES_OK;
+ }
+
+ Widget &AcceptRejectPresenter::getWidget()
+ {
+ return *m_widget;
+ }
+
+ void AcceptRejectPresenter::update(CallMask calls)
+ {
+ if (m_callMask != calls) {
+ m_callMask = calls;
+ if (const auto popup = m_popup.lock()) {
+ m_widget->reset();
+ popup->dismiss();
+ }
+ }
+ }
+
+ Result AcceptRejectPresenter::createWidget(ElmWidget &parent)
+ {
+ m_widget = AcceptRejectWidget::Builder().
+ setAcceptEventHandler(WEAK_DELEGATE(
+ AcceptRejectPresenter::onAcceptEvent,
+ asWeak(*this))).
+ setRejectEventHandler(WEAK_DELEGATE(
+ AcceptRejectPresenter::onRejectEvent,
+ asWeak(*this))).
+ setAcceptBtnType(m_sm->isBTHeadsetConnected() ?
+ AcceptButtonType::BT_HEADSET :
+ AcceptButtonType::SIMPLE).
+ build(parent);
+ if (!m_widget) {
+ LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+ }
+
+ m_widget->activateRotary();
+
+ return RES_OK;
+ }
+
+ Result AcceptRejectPresenter::createMotionSensorPresenter()
+ {
+ m_motionPrs = MotionSensorPresenter::Builder().
+ build(WEAK_DELEGATE(AcceptRejectPresenter::onMotionEvent,
+ asWeak(*this)));
+
+ if (!m_motionPrs) {
+ LOG_RETURN(RES_FAIL,
+ "MotionSensorPresenter::build() failed!");
+ }
+
+ return RES_OK;
+ }
+
+ void AcceptRejectPresenter::onMotionEvent()
+ {
+ m_widget->startBezelCueAnimation();
+ }
+
+ void AcceptRejectPresenter::processAccept()
+ {
+ if (m_callMask & CALL_FLAG_ACTIVE) {
+ if (m_callMask & CALL_FLAG_HELD) {
+ m_call->answer(CallAnswerType::RELEASE_ACTIVE_AND_ACCEPT);
+ } else {
+ showPopup();
+ }
+ } else {
+ m_call->answer(CallAnswerType::NORMAL);
+ }
+ }
+
+ void AcceptRejectPresenter::processReject() const
+ {
+ m_call->reject();
+ }
+
+ bool AcceptRejectPresenter::onAcceptPopupEvent(AcceptDialog &popup,
+ AcceptDialog::Event event)
+ {
+ m_widget->reset();
+
+ switch (event) {
+ case AcceptDialog::Event::HOLD_AND_ACCEPT:
+ FAIL_RETURN_VALUE(
+ m_call->answer(CallAnswerType::HOLD_ACTIVE_AND_ACCEPT),
+ true,
+ "incom->answer() failed!");
+ return false;
+ case AcceptDialog::Event::END_AND_ACCEPT:
+ FAIL_RETURN_VALUE(
+ m_call->answer(CallAnswerType::RELEASE_ACTIVE_AND_ACCEPT),
+ true,
+ "incom->answer() failed!");
+ return false;
+ default:
+ return true;
+ }
+ }
+
+ void AcceptRejectPresenter::showPopup()
+ {
+ if (!m_popup) {
+ m_popup = AcceptDialog::Builder().
+ setHandler(WEAK_DELEGATE(
+ AcceptRejectPresenter::onAcceptPopupEvent,
+ asWeak(*this))).
+ build(*m_widget);
+ } else {
+ WLOG("Popup already shown!");
+ }
+ }
+
+ void AcceptRejectPresenter::onAcceptEvent()
+ {
+ processAccept();
+ }
+
+ void AcceptRejectPresenter::onRejectEvent()
+ {
+ processReject();
+ }
+
+ void AcceptRejectPresenter::onActivate()
+ {
+ DLOG();
+ m_widget->activateRotary();
+ }
+
+ void AcceptRejectPresenter::onDeactivate()
+ {
+ DLOG();
+ m_widget->deactivateRotary();
+ }
+
+ void AcceptRejectPresenter::onBTHeadsetConnectionChanged()
+ {
+ m_widget->setAcceptBtnType(m_sm->isBTHeadsetConnected() ?
+ AcceptButtonType::BT_HEADSET :
+ AcceptButtonType::SIMPLE);
+ }
+
+ // Screen Reader
+ ElmWidget *AcceptRejectPresenter::getAcceptAo()
+ {
+ return m_widget->getAcceptAo();
+ }
+
+ ElmWidget *AcceptRejectPresenter::getRejectAo()
+ {
+ return m_widget->getRejectAo();
+ }
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_MISC_ACCEPT_REJECT_PRESENTER_H__
+#define __CALL_UI_PRESENTERS_MISC_ACCEPT_REJECT_PRESENTER_H__
+
+#include "ucl/mvp/GuiPresenter.h"
+
+#include "ucl/gui/Layout.h"
+#include "ucl/gui/StyledWidget.h"
+
+#include "call-ui/model/IIncomingCall.h"
+#include "call-ui/model/ISoundManager.h"
+#include "call-ui/view/AcceptRejectWidget.h"
+#include "call-ui/presenters/dialogs/AcceptDialog.h"
+#include "MotionSensorPresenter.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(AcceptRejectPresenter);
+
+ class AcceptRejectPresenter final : public ucl::GuiPresenter {
+ public:
+ class Builder {
+ public:
+ Builder();
+ ~Builder();
+ Builder &setIncomingCall(const IIncomingCallSRef &call);
+ Builder &setSoundManager(const ISoundManagerSRef &sm);
+ Builder &setAvailableCallsFlag(CallMask calls);
+ Builder &setParentWidget(const ucl::ElmWidgetSRef &parentWidget);
+ AcceptRejectPresenterSRef build(ucl::GuiPresenter &parent) const;
+
+ private:
+ IIncomingCallSRef m_call;
+ CallMask m_callMask;
+ ucl::ElmWidgetSRef m_parentWidget;
+ ISoundManagerSRef m_sm;
+ };
+
+ public:
+ virtual ~AcceptRejectPresenter();
+
+ ucl::Widget &getWidget();
+
+ void update(CallMask calls);
+
+ ucl::ElmWidget *getAcceptAo();
+ ucl::ElmWidget *getRejectAo();
+
+ private:
+ friend class ucl::ReffedObj<AcceptRejectPresenter>;
+ AcceptRejectPresenter(ucl::IRefCountObj &rc,
+ const IIncomingCallSRef &call,
+ CallMask calls,
+ const ISoundManagerSRef &sm);
+
+ ucl::Result prepare(ucl::GuiPresenter &parent,
+ ucl::ElmWidget &parentWidget);
+
+ ucl::Result createWidget(ucl::ElmWidget &parent);
+ ucl::Result createMotionSensorPresenter();
+
+ void showPopup();
+
+ void processAccept();
+ void processReject() const;
+
+ void onMotionEvent();
+
+ bool onAcceptPopupEvent(AcceptDialog &popup, AcceptDialog::Event event);
+ void onAcceptEvent();
+ void onRejectEvent();
+ void onBTHeadsetConnectionChanged();
+
+ // GuiPresenter
+ virtual void onActivate() final override;
+ virtual void onDeactivate() final override;
+
+ private:
+ AcceptRejectWidgetSRef m_widget;
+ AcceptDialogWRef m_popup;
+ MotionSensorPresenterSRef m_motionPrs;
+
+ IIncomingCallSRef m_call;
+ CallMask m_callMask;
+ ISoundManagerSRef m_sm;
+ };
+}
+
+#endif // __CALL_UI_PRESENTERS_MISC_ACCEPT_REJECT_PRESENTER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "AccessoryPresenter.h"
+
+#include "ucl/appfw/types.h"
+
+#include "call-ui/resources.h"
+#include "common.h"
+
+#define CU_APP_CONTROL_MIME_CONTACT "application/vnd.tizen.contact"
+
+namespace callui { namespace { namespace impl {
+
+ using namespace ucl;
+
+ constexpr LayoutTheme LAYOUT_ACCESSORY_WIDGET
+ {"layout", "callui", "accessory"};
+
+ constexpr EdjePart PART_SWL_VOLUME_SLIDER {"swl.volume_control"};
+
+ constexpr EdjePart PART_SWL_SLOT1 {"swl.slot.1"};
+ constexpr EdjePart PART_SWL_SLOT2 {"swl.slot.2"};
+ constexpr EdjePart PART_SWL_SLOT3 {"swl.slot.3"};
+
+ constexpr ElmStyle STYLE_BTN_VOLUME {"callui/volume"};
+ constexpr ElmStyle STYLE_BTN_MUTE {"callui/mute"};
+ constexpr ElmStyle STYLE_BTN_BT {"callui/bluetooth"};
+ constexpr ElmStyle STYLE_BTN_ADD_CONTACT {"callui/add_contact"};
+
+ constexpr EdjeSignal SIGNAL_TURN_ON {"turn.on"};
+ constexpr EdjeSignal SIGNAL_TURN_OFF {"turn.off"};
+}}}
+
+namespace callui {
+
+ using namespace ucl;
+
+ AccessoryPresenter::Builder::Builder()
+ {
+ }
+
+ AccessoryPresenter::Builder &
+ AccessoryPresenter::Builder::setSoundManager(const ISoundManagerSRef &sm)
+ {
+ m_sm = sm;
+ return *this;
+ }
+
+ AccessoryPresenter::Builder &
+ AccessoryPresenter::Builder::setCallManager(const ICallManagerSRef &cm)
+ {
+ m_cm = cm;
+ return *this;
+ }
+
+ AccessoryPresenter::Builder &
+ AccessoryPresenter::Builder::setRequestExitHandler(const NotiHandler &handler)
+ {
+ m_exitHandler = handler;
+ return *this;
+ }
+
+ AccessoryPresenter::Builder &
+ AccessoryPresenter::Builder::setParentWidget(
+ const ElmWidgetSRef &parentWidget)
+ {
+ m_parentWidget = parentWidget;
+ return *this;
+ }
+
+ AccessoryPresenterSRef
+ AccessoryPresenter::Builder::build(GuiPresenter &parent) const
+ {
+ if (!m_sm || !m_cm || !m_parentWidget) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "Main params are not set");
+ }
+
+ auto result = makeShared<AccessoryPresenter>(m_sm, m_exitHandler);
+ FAIL_RETURN_VALUE(result->prepare(parent, *m_parentWidget, m_cm),
+ {}, "result->prepare() failed!");
+
+ return result;
+ }
+
+ AccessoryPresenter::AccessoryPresenter(IRefCountObj &rc,
+ const ISoundManagerSRef &sm,
+ const NotiHandler &handler):
+ GuiPresenter(rc),
+ m_sm(sm),
+ m_vcTimer(nullptr),
+ m_audioState(m_sm->getAudioState()),
+ m_mode(ComponentsMode::UNDEFINED),
+ m_exitHandler(handler),
+ m_isVcShowOnRotaryEvent(false)
+ {
+ }
+
+ AccessoryPresenter::~AccessoryPresenter()
+ {
+ stopVCTimer();
+ unregisterCallbacks();
+ }
+
+ Result AccessoryPresenter::prepare(GuiPresenter &parent,
+ ElmWidget &parentWidget, const ICallManagerSRef &cm)
+ {
+ FAIL_RETURN(GuiPresenter::prepare(parent),
+ "Presenter::prepare() failed");
+
+ FAIL_RETURN(createWidget(parentWidget),
+ "createWidget() failed");
+
+ FAIL_RETURN(createSlider(),
+ "createSlider() failed");
+
+ FAIL_RETURN(createVolumeControl(),
+ "createVolumeControl() failed");
+
+ updateVolume(m_sm->getVolume());
+
+ registerCallbacks();
+
+ updateMode(cm);
+
+ FAIL_RETURN(updateModeRelativeComponents(cm),
+ "updateComponents() failed");
+
+ return RES_OK;
+ }
+
+ void AccessoryPresenter::updateMode(const ICallManagerSRef &cm)
+ {
+ m_mode = getCurrentMode(cm);
+ }
+
+ AccessoryPresenter::ComponentsMode AccessoryPresenter::getCurrentMode(
+ const ICallManagerSRef &cm)
+ {
+ auto active = cm->getActiveCall();
+ auto held = cm->getHeldCall();
+ auto end = cm->getEndCall();
+
+ if (active && active->isDialingMode()) {
+ return ComponentsMode::OUTGOING;
+ } else if (active || held) {
+ return ComponentsMode::DURING;
+ } else if (end) {
+ return ComponentsMode::END;
+ }
+ return ComponentsMode::UNDEFINED;
+ }
+
+ void AccessoryPresenter::setVolumeSliderVisiblity(bool isVisible)
+ {
+ if (isVisible) {
+ m_widget->setContent(*m_slider, impl::PART_SWL_VOLUME_SLIDER);
+ show(*m_slider);
+ } else {
+ m_widget->unsetContent(impl::PART_SWL_VOLUME_SLIDER);
+ hide(*m_slider);
+ }
+ }
+
+ Result AccessoryPresenter::update(const ICallManagerSRef &cm)
+ {
+ updateMode(cm);
+
+ FAIL_RETURN(updateModeRelativeComponents(cm),
+ "updateModeRelativeComponents() failed");
+
+ return RES_OK;
+ }
+
+ Result AccessoryPresenter::updateModeRelativeComponents(
+ const ICallManagerSRef &cm)
+ {
+ m_volumeBtn.reset();
+ m_muteBtn.reset();
+ m_bluetoothBtn.reset();
+ m_addContactBtn.reset();
+ m_unsavedPhoneNumber.clear();
+
+ setVolumeSliderVisiblity(m_mode != ComponentsMode::END);
+
+ switch (m_mode) {
+ case ComponentsMode::OUTGOING:
+ case ComponentsMode::DURING:
+ return setActiveCallCompomnents();
+ case ComponentsMode::END:
+ return setEndCallCompomnents(cm);
+ default:
+ return RES_OK;
+ }
+ return RES_OK;
+ }
+
+ Result AccessoryPresenter::setActiveCallCompomnents()
+ {
+ FAIL_RETURN(createVolumeBtn(), "createVolumeBtn() failed");
+ m_widget->setContent(*m_volumeBtn, impl::PART_SWL_SLOT1);
+
+ FAIL_RETURN(createMuteBtn(), "createMuteBtn create failed");
+ m_widget->setContent(*m_muteBtn, impl::PART_SWL_SLOT3);
+
+ FAIL_RETURN(createBluetoothBtn(), "createBluetoothBtn() failed");
+ m_widget->setContent(*m_bluetoothBtn, impl::PART_SWL_SLOT2);
+
+ if (m_mode == ComponentsMode::OUTGOING) {
+ disable(*m_muteBtn);
+ } else {
+ enable(*m_muteBtn);
+ }
+
+ return RES_OK;
+ }
+
+ Result AccessoryPresenter::setEndCallCompomnents(const ICallManagerSRef &cm)
+ {
+ auto endCall = cm->getEndCall();
+ if (!endCall) {
+ FAIL_RETURN(RES_FAIL, "endCall is NULL");
+ }
+ auto callInfo = endCall->getInfo();
+ if (!callInfo) {
+ FAIL_RETURN(RES_FAIL, "callInfo is NULL");
+ }
+ if (!(callInfo->isEmergency())
+ && !(callInfo->getConferenceMemberCount() > 1)
+ && !(callInfo->getContactInfo())) {
+ FAIL_RETURN(createAddContactBtn(), "createAddContactBtn() failed");
+ m_widget->setContent(*m_addContactBtn, impl::PART_SWL_SLOT2);
+ m_unsavedPhoneNumber = callInfo->getPhoneNumber();
+ }
+ return RES_OK;
+ }
+
+
+ Widget &AccessoryPresenter::getWidget()
+ {
+ return *m_widget;
+ }
+
+ void AccessoryPresenter::hideVolumeControls()
+ {
+ stopVCTimer();
+ hide(*m_vc);
+ }
+
+ Result AccessoryPresenter::createWidget(ElmWidget &parent)
+ {
+ m_widget = Layout::Builder().
+ setTheme(impl::LAYOUT_ACCESSORY_WIDGET).
+ setIsOwner(true).
+ build(parent);
+ if (!m_widget) {
+ LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+ }
+
+ return RES_OK;
+ }
+
+ Result AccessoryPresenter::createSlider()
+ {
+ m_slider = Slider::Builder().
+ setMaxValue(m_sm->getMaxVolume()).
+ build(*m_widget);
+ if (!m_slider) {
+ LOG_RETURN(RES_FAIL, "Slider::build() failed");
+ }
+ m_widget->setContent(*m_slider, impl::PART_SWL_VOLUME_SLIDER);
+
+ return RES_OK;
+ }
+
+ Result AccessoryPresenter::createVolumeControl()
+ {
+ m_vc = VolumeControl::Builder().
+ setInfoText(STR_VOLUME).
+ setMaxValue(m_sm->getMaxVolume()).
+ setEventHandler(WEAK_DELEGATE(
+ AccessoryPresenter::onVolumeControlEventCb,
+ asWeak(*this))).
+ build(*m_widget);
+ if (!m_vc) {
+ LOG_RETURN(RES_FAIL, "VolumeControl::build() failed");
+ }
+
+ auto window = m_vc->getWindow();
+ if (!window) {
+ LOG_RETURN(RES_FAIL, "Window is NULL!");
+ }
+ int w = 0, h = 0;
+ window->getScreenSize(&w, &h);
+
+ m_vc->move(0, 0);
+ m_vc->resize(w, h);
+ hide(*m_vc);
+
+ registerVolumeControlAo();
+
+ return RES_OK;
+ }
+
+ Result AccessoryPresenter::createVolumeBtn()
+ {
+ Evas_Object *eo = elm_button_add(*m_widget);
+ if (!eo) {
+ LOG_RETURN(RES_FAIL, "eo is NULL");
+ }
+
+ m_volumeBtn = makeShared<StyledWidget>(eo, true);
+ m_volumeBtn->setStyle(impl::STYLE_BTN_VOLUME);
+ m_volumeBtn->addEventHandler(BTN_CLICKED,
+ WEAK_DELEGATE(AccessoryPresenter::onVolumeBtnClicked,
+ asWeak(*this)));
+ show(*m_volumeBtn);
+
+ // Screen Reader
+ elm_atspi_accessible_translation_domain_set(*m_volumeBtn, PACKAGE);
+ elm_atspi_accessible_name_set(*m_volumeBtn, AO_STR_VOLUME);
+
+ return RES_OK;
+ }
+
+ Result AccessoryPresenter::createMuteBtn()
+ {
+ Evas_Object *eo = elm_button_add(*m_widget);
+ if (!eo) {
+ LOG_RETURN(RES_FAIL, "eo is NULL");
+ }
+ m_muteBtn = makeShared<StyledWidget>(eo, true);
+ m_muteBtn->setStyle(impl::STYLE_BTN_MUTE);
+ m_muteBtn->addEventHandler(BTN_CLICKED,
+ WEAK_DELEGATE(AccessoryPresenter::onMuteBtnClicked,
+ asWeak(*this)));
+
+ show(*m_muteBtn);
+
+ // Screen Reader
+ elm_atspi_accessible_translation_domain_set(*m_muteBtn, PACKAGE);
+ elm_atspi_accessible_name_set(*m_muteBtn, AO_STR_MUTE);
+
+ return RES_OK;
+ }
+
+ Result AccessoryPresenter::createBluetoothBtn()
+ {
+ Evas_Object *eo = elm_button_add(*m_widget);
+ if (!eo) {
+ LOG_RETURN(RES_FAIL, "eo is NULL");
+ }
+ m_bluetoothBtn = makeShared<StyledWidget>(eo, true);
+ m_bluetoothBtn->setStyle(impl::STYLE_BTN_BT);
+ m_bluetoothBtn->addEventHandler(BTN_CLICKED,
+ WEAK_DELEGATE(AccessoryPresenter::onBluetoothBtnClicked,
+ asWeak(*this)));
+
+ show(*m_bluetoothBtn);
+
+ // Screen Reader
+ elm_atspi_accessible_translation_domain_set(*m_bluetoothBtn, PACKAGE);
+ if (m_audioState == AudioStateType::BT) {
+ m_bluetoothBtn->emit(impl::SIGNAL_TURN_ON);
+ // Screen Reader
+ elm_atspi_accessible_name_set(*m_bluetoothBtn,
+ AO_STR_GEAR_SPK);
+ } else {
+ m_bluetoothBtn->emit(impl::SIGNAL_TURN_OFF);
+ // Screen Reader
+ elm_atspi_accessible_name_set(*m_bluetoothBtn,
+ AO_STR_HEADSET);
+ }
+
+ if (!m_sm->isBTSupported()) {
+ disable(*m_bluetoothBtn);
+ }
+
+ return RES_OK;
+ }
+
+ Result AccessoryPresenter::createAddContactBtn()
+ {
+ Evas_Object *eo = elm_button_add(*m_widget);
+ if (!eo) {
+ LOG_RETURN(RES_FAIL, "eo is NULL");
+ }
+ m_addContactBtn = makeShared<StyledWidget>(eo, true);
+ m_addContactBtn->setStyle(impl::STYLE_BTN_ADD_CONTACT);
+ m_addContactBtn->addEventHandler(BTN_CLICKED,
+ WEAK_DELEGATE(AccessoryPresenter::onAddContactBtnClicked,
+ asWeak(*this)));
+ show(*m_addContactBtn);
+
+ // Screen Reader
+ elm_atspi_accessible_translation_domain_set(*m_addContactBtn, PACKAGE);
+ elm_atspi_accessible_name_set(*m_addContactBtn,
+ AO_STR_ADD_TO_CONTACTS);
+
+ return RES_OK;
+ }
+
+ void AccessoryPresenter::onVolumeBtnClicked(Widget &widget, void *eventInfo)
+ {
+ if (!isActive()) {
+ ILOG("Presenter is not active. Ignore");
+ return;
+ }
+
+ show(*m_vc);
+ startVCTimer();
+
+ elm_atspi_component_highlight_grab(*m_vc);
+ }
+
+ void AccessoryPresenter::onMuteBtnClicked(Widget &widget, void *eventInfo)
+ {
+ if (!isActive()) {
+ ILOG("Presenter is not active. Ignore");
+ return;
+ }
+
+ m_sm->setMuteState(!m_sm->getMuteState());
+ }
+
+ void AccessoryPresenter::onBluetoothBtnClicked(Widget &widget,
+ void *eventInfo)
+ {
+ if (m_audioState == AudioStateType::BT) {
+ auto res = m_sm->setBluetoothState(false);
+ if (res != RES_OK && res != RES_NOT_CONNECTED) {
+ FAIL_RETURN_VOID(res, "setBluetoothState(false) failed");
+ }
+ } else {
+ auto res = m_sm->setBluetoothState(true);
+ if (res == RES_NOT_CONNECTED) {
+ FAIL_RETURN_VOID(launchBluetoothSettings(),
+ "launchBluetoothSettings() failed");
+ } else {
+ FAIL_RETURN_VOID(res, "setBluetoothState(true) failed");
+ }
+ }
+ }
+
+ Result AccessoryPresenter::launchBluetoothSettings()
+ {
+ AutoAppCtrl appCtrl;
+
+ FAIL_RETURN(util::getNz(app_control_create, appCtrl),
+ "app_control_create() failed!");
+
+ FAIL_RETURN(util::call(app_control_set_app_id,
+ appCtrl, "org.tizen.bluetooth"),
+ "app_control_set_app_id() failed!");
+
+ FAIL_RETURN(util::call(app_control_add_extra_data,
+ appCtrl, "launch-type", "call"),
+ "app_control_add_extra_data() failed!");
+
+ FAIL_RETURN(util::call(app_control_send_launch_request,
+ appCtrl, nullptr, nullptr),
+ "app_control_send_launch_request() failed!");
+
+ return RES_OK;
+ }
+
+ Result AccessoryPresenter::launchContacts()
+ {
+ AutoAppCtrl appCtrl;
+
+ FAIL_RETURN(util::getNz(app_control_create, appCtrl),
+ "app_control_create() failed!");
+
+ FAIL_RETURN(util::call(app_control_set_operation,
+ appCtrl, APP_CONTROL_OPERATION_ADD),
+ "app_control_set_app_id() failed!");
+
+ FAIL_RETURN(util::call(app_control_set_mime,
+ appCtrl, CU_APP_CONTROL_MIME_CONTACT),
+ "app_control_set_app_id() failed!");
+
+ FAIL_RETURN(util::call(app_control_add_extra_data,
+ appCtrl, APP_CONTROL_DATA_PHONE, m_unsavedPhoneNumber.c_str()),
+ "app_control_add_extra_data() failed!");
+
+ FAIL_RETURN(util::call(app_control_send_launch_request,
+ appCtrl, nullptr, nullptr),
+ "app_control_send_launch_request() failed!");
+
+ return RES_OK;
+ }
+
+ void AccessoryPresenter::onAddContactBtnClicked(Widget &widget, void *eventInfo)
+ {
+ launchContacts();
+
+ if (m_exitHandler) {
+ m_exitHandler();
+ }
+ }
+
+ void AccessoryPresenter::registerCallbacks()
+ {
+ addRotaryEventHandler(CALLBACK_A(
+ AccessoryPresenter::onRotaryEvent), this);
+
+ m_sm->addAudioStateHandler(WEAK_DELEGATE(
+ AccessoryPresenter::onAudioStateChanged, asWeak(*this)));
+
+ m_sm->addVolumeStateHandler(WEAK_DELEGATE(
+ AccessoryPresenter::onVolumeLevelChanged, asWeak(*this)));
+
+ m_sm->addMuteStateHandler(WEAK_DELEGATE(
+ AccessoryPresenter::onMuteStateChanged, asWeak(*this)));
+ }
+
+ void AccessoryPresenter::unregisterCallbacks()
+ {
+ delRotaryEventHandler(
+ CALLBACK_A(AccessoryPresenter::onRotaryEvent), this);
+
+ m_sm->delAudioStateHandler(WEAK_DELEGATE(
+ AccessoryPresenter::onAudioStateChanged, asWeak(*this)));
+
+ m_sm->delVolumeStateHandler(WEAK_DELEGATE(
+ AccessoryPresenter::onVolumeLevelChanged, asWeak(*this)));
+
+ m_sm->delMuteStateHandler(WEAK_DELEGATE(
+ AccessoryPresenter::onMuteStateChanged, asWeak(*this)));
+ }
+
+ Eina_Bool AccessoryPresenter::onVCTimerCb()
+ {
+ hide(*m_vc);
+ m_vcTimer = nullptr;
+
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ void AccessoryPresenter::startVCTimer()
+ {
+ stopVCTimer();
+
+ auto timerInterval = CALL_VC_TIMER_INTERVAL;
+ if (elm_atspi_bridge_utils_is_screen_reader_enabled()) {
+ timerInterval = CALL_VC_SCREEN_READER_TIMER_INTERVAL;
+ }
+
+ m_vcTimer = ecore_timer_add(timerInterval,
+ CALLBACK_B(AccessoryPresenter::onVCTimerCb),
+ this);
+ }
+
+ void AccessoryPresenter::restartVCTimer()
+ {
+ if (m_vcTimer) {
+ ecore_timer_reset(m_vcTimer);
+ }
+ }
+
+ void AccessoryPresenter::stopVCTimer()
+ {
+ if (m_vcTimer) {
+ ecore_timer_del(m_vcTimer);
+ m_vcTimer = nullptr;
+ }
+ }
+
+ Eina_Bool AccessoryPresenter::onRotaryEvent(Eext_Rotary_Event_Info *info)
+ {
+ if (!isActive()) {
+ LOG_RETURN_VALUE(RES_OK, EINA_TRUE,
+ "Presenter is not active. Ignore");
+ }
+
+ if (m_vcTimer) {
+ restartVCTimer();
+ } else {
+ show(*m_vc);
+ startVCTimer();
+ m_isVcShowOnRotaryEvent = true;
+ elm_atspi_component_highlight_grab(*m_vc);
+ }
+
+ if (m_isVcShowOnRotaryEvent) {
+ m_isVcShowOnRotaryEvent = checkPossibilityToModifyVolume(
+ m_sm->getVolume(),
+ info->direction ==
+ EEXT_ROTARY_DIRECTION_CLOCKWISE);
+ }
+
+ if (info->direction == EEXT_ROTARY_DIRECTION_CLOCKWISE) {
+ tryIncreaseVolume();
+ } else {
+ tryDecreaseVolume();
+ }
+
+ return EINA_TRUE;
+ }
+
+ void AccessoryPresenter::onVolumeControlEventCb(VolumeControl::Event event)
+ {
+ if (!isActive()) {
+ LOG_RETURN_VOID(RES_OK, "Presenter is not active. Ignore");
+ }
+
+ if (!m_vcTimer) {
+ DLOG("Ignore as control is hidden");
+ return;
+ }
+
+ restartVCTimer();
+
+ switch (event) {
+ case VolumeControl::Event::INCREASE:
+ tryIncreaseVolume();
+ break;
+ case VolumeControl::Event::DECREASE:
+ tryDecreaseVolume();
+ break;
+ default:
+ break;
+ }
+ }
+
+ bool AccessoryPresenter::checkPossibilityToModifyVolume(int volume, bool needIncrease)
+ {
+ if (needIncrease) {
+ auto max = m_sm->getMaxVolume();
+ return (max >= volume);
+ } else {
+ return (volume - 1 >= VOLUME_LEVEL_MIN);
+ }
+ return false;
+ }
+
+ void AccessoryPresenter::tryIncreaseVolume()
+ {
+ auto cur = m_sm->getVolume();
+ if (checkPossibilityToModifyVolume(cur, true)) {
+ FAIL_RETURN_VOID(m_sm->setVolume(cur + 1),
+ "setVolume() failed");
+ }
+ }
+
+ void AccessoryPresenter::tryDecreaseVolume()
+ {
+ auto cur = m_sm->getVolume();
+ if (checkPossibilityToModifyVolume(cur, false)) {
+ FAIL_RETURN_VOID(m_sm->setVolume(cur - 1),
+ "setVolume() failed");
+ }
+ }
+
+ void AccessoryPresenter::onAudioStateChanged(AudioStateType state)
+ {
+ if ((m_audioState != AudioStateType::BT &&
+ state == AudioStateType::BT) ||
+ (m_audioState == AudioStateType::BT &&
+ state != AudioStateType::BT)) {
+ m_audioState = state;
+
+ m_vc->setValue(0);
+ m_slider->setValue(0);
+
+ auto maxVol = m_sm->getMaxVolume();
+ m_vc->setMaxValue(maxVol);
+ m_slider->setMaxValue(maxVol);
+
+ updateVolume(m_sm->getVolume());
+
+ if (m_bluetoothBtn) {
+
+ if (m_audioState == AudioStateType::BT) {
+ m_bluetoothBtn->emit(impl::SIGNAL_TURN_ON);
+ // Screen Reader
+ elm_atspi_accessible_name_set(*m_bluetoothBtn,
+ AO_STR_GEAR_SPK);
+ } else {
+ m_bluetoothBtn->emit(impl::SIGNAL_TURN_OFF);
+ // Screen Reader
+ elm_atspi_accessible_name_set(*m_bluetoothBtn,
+ AO_STR_HEADSET);
+ }
+ }
+ }
+ }
+
+ void AccessoryPresenter::updateVolume(int value)
+ {
+ m_vc->setValue(value);
+ m_slider->setValue(value);
+
+ auto max = m_sm->getMaxVolume();
+ auto cur = m_sm->getVolume();
+
+ if (cur == max) {
+ m_vc->setIncreaseBtnEnable(false);
+ m_vc->setDecreaseBtnEnable(true);
+ } else if (cur <= VOLUME_LEVEL_MIN) {
+ m_vc->setIncreaseBtnEnable(true);
+ m_vc->setDecreaseBtnEnable(false);
+ } else {
+ m_vc->setIncreaseBtnEnable(true);
+ m_vc->setDecreaseBtnEnable(true);
+ }
+
+ // Screen Reader
+ if (m_vc->isVisible()) {
+ if (!m_isVcShowOnRotaryEvent) {
+ elm_atspi_bridge_utils_say(std::to_string(cur).c_str(),
+ EINA_FALSE, nullptr, nullptr);
+ }
+ m_isVcShowOnRotaryEvent = false;
+ }
+ }
+
+ void AccessoryPresenter::onVolumeLevelChanged(int value)
+ {
+ updateVolume(value);
+ }
+
+ void AccessoryPresenter::onMuteStateChanged(bool isMuted)
+ {
+ if (!m_muteBtn) {
+ return;
+ }
+ if (!elm_object_disabled_get(*m_muteBtn))
+ updateMuteBtn(isMuted);
+ }
+
+ void AccessoryPresenter::updateMuteBtn(bool isMuted)
+ {
+ if (!m_muteBtn) {
+ return;
+ }
+ isMuted ? m_muteBtn->emit(impl::SIGNAL_TURN_ON) :
+ m_muteBtn->emit(impl::SIGNAL_TURN_OFF);
+ }
+
+ // Screen Reader
+ ElmWidget *AccessoryPresenter::getVolumBtn()
+ {
+ return m_volumeBtn.get();
+ }
+
+ ElmWidget *AccessoryPresenter::getBluetoothBtn()
+ {
+ return m_bluetoothBtn.get();
+ }
+
+ ElmWidget *AccessoryPresenter::getMuteBtn()
+ {
+ return m_muteBtn.get();
+ }
+
+ ElmWidget *AccessoryPresenter::getAddContactBtn()
+ {
+ return m_addContactBtn.get();
+ }
+
+ ElmWidget *AccessoryPresenter::getVolumeControlLy()
+ {
+ return m_vc.get();
+ }
+
+ ElmWidget *AccessoryPresenter::getVolumeControlDecreaseBtn()
+ {
+ return m_vc->getDecreaseBtn();
+ }
+
+ ElmWidget *AccessoryPresenter::getVolumeControlIncreaseBtn()
+ {
+ return m_vc->getIncreaseBtn();
+ }
+
+ ElmWidget *AccessoryPresenter::getVolumeControlValueTxtAo()
+ {
+ return m_vc->getValueTxtAo();
+ }
+
+ void AccessoryPresenter::registerVolumeControlAo()
+ {
+ auto decrBtn = m_vc->getDecreaseBtn();
+ if (decrBtn) {
+ decrBtn->addEventHandler(ATSPI_HIGHLIGHTED,
+ WEAK_DELEGATE(AccessoryPresenter::
+ onVolumeControlScreenReaderReadStart,
+ asWeak(*this)));
+ }
+
+ auto incrBtn = m_vc->getIncreaseBtn();
+ if (incrBtn) {
+ incrBtn->addEventHandler(ATSPI_HIGHLIGHTED,
+ WEAK_DELEGATE(AccessoryPresenter::
+ onVolumeControlScreenReaderReadStart,
+ asWeak(*this)));
+ }
+ }
+
+ void AccessoryPresenter::onVolumeControlScreenReaderReadStart(
+ Widget &widget,
+ void *eventInfo)
+ {
+ restartVCTimer();
+ }
+
+}
+
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_MISC_ACCESSORY_PRESENTER_H__
+#define __CALL_UI_PRESENTERS_MISC_ACCESSORY_PRESENTER_H__
+
+#include "ucl/mvp/GuiPresenter.h"
+
+#include "ucl/gui/Layout.h"
+#include "ucl/gui/StyledWidget.h"
+
+#include <app_control.h>
+
+#include "call-ui/model/ISoundManager.h"
+#include "call-ui/model/ICallManager.h"
+#include "call-ui/view/VolumeControl.h"
+#include "call-ui/view/Slider.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(AccessoryPresenter);
+
+ class AccessoryPresenter final : public ucl::GuiPresenter {
+ public:
+ class Builder {
+ public:
+ Builder();
+ Builder &setSoundManager(const ISoundManagerSRef &sm);
+ Builder &setCallManager(const ICallManagerSRef &cm);
+ Builder &setRequestExitHandler(const NotiHandler &handler);
+ Builder &setParentWidget(const ucl::ElmWidgetSRef &parentWidget);
+ AccessoryPresenterSRef build(ucl::GuiPresenter &parent) const;
+
+ private:
+ ISoundManagerSRef m_sm;
+ ICallManagerSRef m_cm;
+ ucl::ElmWidgetSRef m_parentWidget;
+ NotiHandler m_exitHandler;
+ };
+
+ public:
+ virtual ~AccessoryPresenter();
+
+ ucl::Widget &getWidget();
+ void hideVolumeControls();
+ ucl::Result update(const ICallManagerSRef &cm);
+
+ // Screen Reader
+ ucl::ElmWidget *getVolumBtn();
+ ucl::ElmWidget *getBluetoothBtn();
+ ucl::ElmWidget *getMuteBtn();
+ ucl::ElmWidget *getAddContactBtn();
+ ucl::ElmWidget *getVolumeControlLy();
+ ucl::ElmWidget *getVolumeControlDecreaseBtn();
+ ucl::ElmWidget *getVolumeControlIncreaseBtn();
+ ucl::ElmWidget *getVolumeControlValueTxtAo();
+
+ private:
+ enum class ComponentsMode {
+ UNDEFINED,
+ OUTGOING,
+ DURING,
+ END
+ };
+ private:
+ friend class ucl::ReffedObj<AccessoryPresenter>;
+ AccessoryPresenter(ucl::IRefCountObj &rc, const ISoundManagerSRef &sm,
+ const NotiHandler &handler);
+
+ ucl::Result prepare(ucl::GuiPresenter &parent,
+ ucl::ElmWidget &parentWidget, const ICallManagerSRef &cm);
+
+ ucl::Result createWidget(ucl::ElmWidget &parent);
+ ucl::Result createSlider();
+ ucl::Result createVolumeControl();
+
+ ucl::Result createVolumeBtn();
+ ucl::Result createMuteBtn();
+ ucl::Result createBluetoothBtn();
+ ucl::Result createAddContactBtn();
+
+ void onVolumeBtnClicked(ucl::Widget &widget, void *eventInfo);
+ void onMuteBtnClicked(ucl::Widget &widget, void *eventInfo);
+ void onBluetoothBtnClicked(ucl::Widget &widget, void *eventInfo);
+ void onAddContactBtnClicked(ucl::Widget &widget, void *eventInfo);
+
+ ucl::Result launchContacts();
+ ucl::Result launchBluetoothSettings();
+
+ void registerCallbacks();
+ void unregisterCallbacks();
+ void onVolumeControlEventCb(VolumeControl::Event event);
+ Eina_Bool onRotaryEvent(Eext_Rotary_Event_Info *info);
+
+ bool checkPossibilityToModifyVolume(int volume,
+ bool needIncrease);
+ void tryIncreaseVolume();
+ void tryDecreaseVolume();
+
+ void onAudioStateChanged(AudioStateType state);
+ void onVolumeLevelChanged(int value);
+ void onMuteStateChanged(bool isMuted);
+ void updateMuteBtn(bool isMuted);
+
+ Eina_Bool onVCTimerCb();
+ void startVCTimer();
+ void restartVCTimer();
+ void stopVCTimer();
+
+ void updateVolume(int value);
+
+ void updateMode(const ICallManagerSRef &cm);
+ AccessoryPresenter::ComponentsMode getCurrentMode(const ICallManagerSRef &cm);
+ void setVolumeSliderVisiblity(bool isVisible);
+
+ ucl::Result updateModeRelativeComponents(const ICallManagerSRef &cm);
+ ucl::Result setActiveCallCompomnents();
+ ucl::Result setEndCallCompomnents(const ICallManagerSRef &cm);
+
+ // Screen Reader
+ void registerVolumeControlAo();
+ void onVolumeControlScreenReaderReadStart(ucl::Widget &widget, void *eventInfo);
+
+ private:
+ ucl::LayoutSRef m_widget;
+ ucl::StyledWidgetSRef m_volumeBtn;
+ ucl::StyledWidgetSRef m_muteBtn;
+ ucl::StyledWidgetSRef m_bluetoothBtn;
+ ucl::StyledWidgetSRef m_addContactBtn;
+
+ SliderSRef m_slider;
+ VolumeControlSRef m_vc;
+ ISoundManagerSRef m_sm;
+
+ Ecore_Timer *m_vcTimer;
+ AudioStateType m_audioState;
+ ComponentsMode m_mode;
+ std::string m_unsavedPhoneNumber;
+ NotiHandler m_exitHandler;
+
+ bool m_isVcShowOnRotaryEvent;
+ };
+}
+
+#endif // __CALL_UI_PRESENTERS_MISC_ACCESSORY_PRESENTER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "AtspiHighlightHelper.h"
+
+#include "common.h"
+
+namespace callui { namespace { namespace impl {
+
+ constexpr EoDataKey ATSPI_HELPER_DATA {"callui,atspi,highlight,helper"};
+}}}
+
+namespace callui {
+
+ using ucl::AtspiGestureEventInfo;
+
+ using ucl::ATSPI_ON_GESTURE;
+
+ AtspiHighlightHelperSRef AtspiHighlightHelper::newInstance(
+ GuiPresenter &parent, ElmWidget &rootWidget)
+ {
+ auto result = makeShared<AtspiHighlightHelper>();
+
+ FAIL_RETURN_VALUE(result->prepare(parent, rootWidget), {},
+ "result->prepare() failed!");
+
+ return result;
+ }
+
+ AtspiHighlightHelper::AtspiHighlightHelper(IRefCountObj &rc) :
+ GuiPresenter(rc)
+ {
+ }
+
+ AtspiHighlightHelper::~AtspiHighlightHelper()
+ {
+ }
+
+ Result AtspiHighlightHelper::prepare(GuiPresenter &parent,
+ ElmWidget &rootWidget)
+ {
+ FAIL_RETURN(GuiPresenter::prepare(parent),
+ "GuiPresenter::prepare() failed!");
+
+ registerWidget(rootWidget);
+
+ return RES_OK;
+ }
+
+ void AtspiHighlightHelper::setRelationEventHandler(RelationEventHandler handler)
+ {
+ m_relationEventHandler = handler;
+ }
+
+ void AtspiHighlightHelper::setGestureEventHandler(GestureEventHandler handler)
+ {
+ m_gestureEventHandler = handler;
+ }
+
+ void AtspiHighlightHelper::registerWidget(ElmWidget &widget)
+ {
+ DLOG("this [%p] widget [%p]", this, widget.getEo());
+
+ widget.addEventHandler(ATSPI_ON_GESTURE, WEAK_DELEGATE(
+ AtspiHighlightHelper::onAtspiGesture, asWeak(*this)));
+ }
+
+ void AtspiHighlightHelper::handleAtspiGesture(
+ Elm_Interface_Atspi_Accessible *ao,
+ AtspiGestureEventInfo &e)
+ {
+ DLOG("this [%p] ao [%p]", this, ao);
+
+ if (e.stopPropagation) {
+ DLOG("e.stopPropagation");
+ return;
+ }
+
+ if (!isActive()) {
+ DLOG("!isActive()");
+ if (e.gestureInfo.type != ELM_ATSPI_GESTURE_ONE_FINGER_SINGLE_TAP) {
+ e.preventDefault = true;
+ }
+ return;
+ }
+
+ e.stopPropagation = true;
+
+ if (m_gestureEventHandler) {
+ DLOG("m_gestureEventHandler");
+ if (m_gestureEventHandler(ao, e.gestureInfo.type)) {
+ e.preventDefault = true;
+ return;
+ }
+ }
+
+ e.preventDefault = false;
+
+ if (!m_relationEventHandler) {
+ DLOG("!m_relationEventHandler");
+ return;
+ }
+
+ const Elm_Atspi_Relation_Type relation = getFlowRelation(e.gestureInfo);
+ if (relation == ELM_ATSPI_RELATION_NULL) {
+ return;
+ }
+
+ const auto relationObj = m_relationEventHandler(ao, relation);
+ if (!relationObj) {
+ return;
+ }
+
+ auto &win = getWindow();
+ auto atspiHelper = static_cast<Elm_Interface_Atspi_Accessible *>
+ (win.getData(impl::ATSPI_HELPER_DATA));
+
+ if (!atspiHelper) {
+ const auto obj = utils::createFakeAccessObject(win);
+ if (!obj) {
+ LOG_RETURN_VOID(RES_FAIL, "createFakeAccessObject() failed!");
+ }
+ obj->setIsOwner(false);
+ atspiHelper = obj->getEo();
+ win.setData(impl::ATSPI_HELPER_DATA, atspiHelper);
+ }
+
+ if (ao == win) {
+ ao = atspiHelper;
+ elm_atspi_component_highlight_grab(ao);
+ }
+
+ elm_atspi_accessible_relationships_clear(ao);
+ elm_atspi_accessible_relationship_append(ao, relation, relationObj);
+ }
+
+ void AtspiHighlightHelper::onAtspiGesture(
+ Widget &widget, void *eventInfo)
+ {
+ handleAtspiGesture(widget,
+ *static_cast<AtspiGestureEventInfo *>(eventInfo));
+ }
+
+ bool AtspiHighlightHelper::handleGesture(Elm_Interface_Atspi_Accessible *ao,
+ const Elm_Atspi_Gesture_Info &info)
+ {
+ AtspiGestureEventInfo eventInfo {};
+ eventInfo.gestureInfo = info;
+
+ handleAtspiGesture(ao, eventInfo);
+
+ return eventInfo.preventDefault;
+ }
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_MISC_ATSPI_HIGHLIGHT_HELPER_H__
+#define __CALL_UI_PRESENTERS_MISC_ATSPI_HIGHLIGHT_HELPER_H__
+
+#include "ucl/mvp/GuiPresenter.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(AtspiHighlightHelper);
+
+ class AtspiHighlightHelper final : public ucl::GuiPresenter {
+ public:
+ using RelationEventHandler = ucl::WeakDelegate<Elm_Interface_Atspi_Accessible *(
+ Elm_Interface_Atspi_Accessible *ao,
+ Elm_Atspi_Relation_Type flowRelation)>;
+
+ using GestureEventHandler = ucl::WeakDelegate<bool (
+ Elm_Interface_Atspi_Accessible *ao,
+ Elm_Atspi_Gesture_Type gestureType)>;
+ public:
+ static AtspiHighlightHelperSRef newInstance(GuiPresenter &parent,
+ ucl::ElmWidget &rootWidget);
+
+ void setRelationEventHandler(RelationEventHandler handler);
+ void setGestureEventHandler(GestureEventHandler handler);
+ void registerWidget(ucl::ElmWidget &widget);
+ bool handleGesture(Elm_Interface_Atspi_Accessible *widget,
+ const Elm_Atspi_Gesture_Info &info);
+
+ private:
+ friend class ucl::ReffedObj<AtspiHighlightHelper>;
+ AtspiHighlightHelper(ucl::IRefCountObj &rc);
+ virtual ~AtspiHighlightHelper();
+
+ ucl::Result prepare(GuiPresenter &parent, ucl::ElmWidget &rootWidget);
+
+ void handleAtspiGesture(Elm_Interface_Atspi_Accessible *widget,
+ ucl::AtspiGestureEventInfo &e);
+
+ private:
+ void onAtspiGesture(ucl::Widget &widget, void *eventInfo);
+
+ private:
+ RelationEventHandler m_relationEventHandler;
+ GestureEventHandler m_gestureEventHandler;
+ };
+}
+
+#endif // __CALL_UI_PRESENTERS_MISC_ATSPI_HIGHLIGHT_HELPER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "CallInfoPresenter.h"
+
+#include "ucl/gui/Window.h"
+
+#include "call-ui/resources.h"
+#include "common.h"
+
+namespace callui { namespace { namespace impl {
+
+ using namespace ucl;
+
+ constexpr int SUB_TXT_WIDTH = 208;
+ constexpr int INCOM_MAIN_TXT_WIDTH = 190;
+ constexpr int SLIDE_LABEL_DURATION_KOEFF = 8;
+
+ const char *CU_BIG_FONT_STYLE = "Tizen:style=Condensed";
+ constexpr int CU_BIG_FONT_SIZE = 40;
+
+ constexpr LayoutTheme LAYOUT_CALLER_INFO_WIDGET
+ {"layout", "callui", "call_info"};
+
+ constexpr ElmStyle STYLE_SLIDING_LABEL {"slide_roll"};
+
+ constexpr EdjePart PART_TXT_MAIN {"text_1line"};
+ constexpr EdjePart PART_SWL_CALLER_ID {"caller_id"};
+ constexpr EdjePart PART_SWL_2LINE {"text_2line"};
+
+ constexpr EdjeSignal SIGN_RESET {"reset"};
+ constexpr EdjeSignal SIGN_DEFAULT {"default"};
+ constexpr EdjeSignal SIGN_CID_ENABLE {"caller_id_enable"};
+ constexpr EdjeSignal SIGN_CID_DISABLE {"caller_id_disable"};
+ constexpr EdjeSignal SIGN_EMERGENCY {"emergency"};
+ constexpr EdjeSignal SIGN_EMERGENCY_BIG_TXT {"big_txt_emergency"};
+ constexpr EdjeSignal SIGN_BIG_TXT {"big_txt"};
+ constexpr EdjeSignal SIGN_CENTRE_1LINE {"centre_1line"};
+ constexpr EdjeSignal SIGN_CENTRE_2LINE {"centre_2line"};
+ constexpr EdjeSignal SIGN_INCOMING {"incoming"};
+
+ constexpr EdjeSignalSrc SRC_TOP_PAD {"top_padding"};
+ constexpr EdjeSignalSrc SRC_TXT_1LINE {"text_1line"};
+ constexpr EdjeSignalSrc SRC_TXT_2LINE {"text_2line"};
+ constexpr EdjeSignalSrc SRC_CALLER_ID {"caller_id"};
+
+ const TString STR_LABEL_SUB_CID_ENABLE{
+ "<align=center><color=#ffffff99><font_size=24>%s"
+ "</color></font_size></align>"};
+
+ const TString STR_LABEL_SUB_DEFAULT_STYLE{
+ "<align=center><color=#ffffff99><font_size=24>%s"
+ "</color></font_size></align>"};
+
+ const TString STR_LABEL_SUB_ON_HOLD{
+ "<align=center><color=#4dcfffff><font_size=24>%s"
+ "</color></font_size></align>"};
+
+ constexpr EdjePart PART_AO_MAIN_TXT {"ao_text_1line"};
+ constexpr EdjePart PART_AO_SUB_TXT {"ao_text_2line"};
+
+ int getTextWidth(ElmWidget &parent, const char *fontStyle,
+ int fontSize, const std::string &text)
+ {
+ auto eoText = evas_object_text_add(evas_object_evas_get(parent));
+ evas_object_text_font_set(eoText, fontStyle, fontSize);
+ evas_object_text_style_set(eoText, EVAS_TEXT_STYLE_PLAIN);
+ evas_object_text_text_set(eoText, text.c_str());
+
+ auto size = evas_object_text_horiz_width_without_ellipsis_get(eoText);
+ evas_object_del(eoText);
+ return size;
+ }
+
+}}}
+
+namespace callui {
+
+ using namespace ucl;
+
+ CallInfoPresenter::Builder::Builder():
+ m_mode(CallMode::UNDEFINED)
+ {
+ }
+
+ CallInfoPresenter::Builder::~Builder()
+ {
+ }
+
+ CallInfoPresenter::Builder &
+ CallInfoPresenter::Builder::setCallManager(const ICallManagerSRef &cm)
+ {
+ m_cm = cm;
+ return *this;
+ }
+
+ CallInfoPresenter::Builder &
+ CallInfoPresenter::Builder::setMode(CallMode mode)
+ {
+ m_mode = mode;
+ return *this;
+ }
+
+ CallInfoPresenter::Builder &
+ CallInfoPresenter::Builder::setParentWidget(
+ const ucl::ElmWidgetSRef &parentWidget)
+ {
+ m_parentWidget = parentWidget;
+ return *this;
+ }
+
+ CallInfoPresenterSRef
+ CallInfoPresenter::Builder::build(GuiPresenter &parent) const
+ {
+ if (m_mode == CallMode::UNDEFINED || !m_cm || !m_parentWidget) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "Main params are are set");
+ }
+
+ auto result = makeShared<CallInfoPresenter>(m_cm, m_mode);
+ FAIL_RETURN_VALUE(result->prepare(parent, *m_parentWidget), {},
+ "result->prepare() failed!");
+
+ return result;
+ }
+
+ CallInfoPresenter::CallInfoPresenter(IRefCountObj &rc,
+ const ICallManagerSRef &cm,
+ CallMode mode):
+ GuiPresenter(rc),
+ m_mode(mode),
+ m_isSubTxtEnable(false),
+ m_needModifyCallStatus(false)
+ {
+ initCallInfos(cm);
+ }
+
+ CallInfoPresenter::~CallInfoPresenter()
+ {
+ }
+
+ Result CallInfoPresenter::prepare(GuiPresenter &parent,
+ ElmWidget &parentWidget)
+ {
+ FAIL_RETURN(GuiPresenter::prepare(parent, PF_PASSIVE),
+ "Presenter::prepare() failed!");
+
+ m_parent = asWeak(parent);
+
+ FAIL_RETURN(createWidget(parentWidget),
+ "createWidget() failed!");
+
+ FAIL_RETURN(createCallStatus(parent),
+ "createCallStatus() failed!");
+
+ FAIL_RETURN(update(), "update() failed!");
+
+ return RES_OK;
+ }
+
+ Result CallInfoPresenter::createWidget(ElmWidget &parent)
+ {
+ m_widget = Layout::Builder().
+ setTheme(impl::LAYOUT_CALLER_INFO_WIDGET).
+ setIsOwner(true).
+ build(parent);
+ if (!m_widget) {
+ LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+ }
+ return RES_OK;
+ }
+
+ Widget &CallInfoPresenter::getWidget()
+ {
+ return *m_widget;
+ }
+
+ CallMode CallInfoPresenter::getMode() const
+ {
+ return m_mode;
+ }
+
+ void CallInfoPresenter::initCallInfos(const ICallManagerSRef &cm)
+ {
+ auto incom = cm->getIncomingCall();
+ if (incom) {
+ m_incomCallInfo = incom->getInfo();
+ } else {
+ m_incomCallInfo.reset();
+ }
+
+ auto active = cm->getActiveCall();
+ if (active) {
+ m_activeCallInfo = active->getInfo();
+ } else {
+ m_activeCallInfo.reset();
+ }
+
+ auto held = cm->getHeldCall();
+ if (held) {
+ m_heldCallInfo = held->getInfo();
+ } else {
+ m_heldCallInfo.reset();
+ }
+
+ auto end = cm->getEndCall();
+ if (end) {
+ m_endCallInfo = end->getInfo();
+ } else {
+ m_endCallInfo.reset();
+ }
+ }
+
+ Result CallInfoPresenter::update(CallMode mode, const ICallManagerSRef &cm)
+ {
+ m_needModifyCallStatus = false;
+ if (mode != m_mode || mode == CallMode::DURING) {
+ m_needModifyCallStatus = true;
+ }
+
+ m_mode = mode;
+ initCallInfos(cm);
+ m_isSubTxtEnable = false;
+
+ return update();
+ }
+
+ std::string CallInfoPresenter::getNumberSubText(
+ const ICallInfoSCRef &callInfo) const
+ {
+ if (!callInfo) {
+ FAIL_RETURN_VALUE(RES_FAIL, "", "callInfo is NULL!");
+ }
+
+ IContactInfoSCRef contactInfo = callInfo->getContactInfo();
+ if (contactInfo) {
+ return callInfo->getPhoneNumber();
+ }
+ return "";
+ }
+
+
+ std::string CallInfoPresenter::getIncomingCallSubText() const
+ {
+ if (!m_incomCallInfo) {
+ FAIL_RETURN_VALUE(RES_FAIL, "", "incom is NULL!");
+ }
+ if (m_activeCallInfo && m_heldCallInfo) {
+ auto displStr = m_activeCallInfo->getPhoneNumber();
+ auto contactInfo = m_activeCallInfo->getContactInfo();
+ if (contactInfo) {
+ const auto contName = contactInfo->getName();
+ if (!contName.empty()) {
+ displStr = contName;
+ }
+ }
+ if (displStr.empty()) {
+ displStr = STR_UNKNOWN.translate();
+ }
+ return TString{STR_CALL_WITH_PS_WILL_END.translate()}.
+ format(displStr.c_str());
+ }
+
+ if (m_incomCallInfo->isVoiceMailNumber() ||
+ m_incomCallInfo->isEmergency()) {
+ return "";
+ }
+
+ return getNumberSubText(m_incomCallInfo);
+ }
+
+ std::string CallInfoPresenter::getDuringCallSubText() const
+ {
+ if (m_activeCallInfo) {
+ auto confMemberCount =
+ m_activeCallInfo->getConferenceMemberCount();
+ if (m_heldCallInfo) {
+ return STR_CALL_ON_HOLD.translate();
+ } else if (confMemberCount > 1) {
+ return TString{STR_WITH_PD_PEOPLE.translate()}.
+ format(confMemberCount);
+ }
+ } else if (m_heldCallInfo) {
+ auto confMemberCount =
+ m_heldCallInfo->getConferenceMemberCount();
+ if (confMemberCount > 1) {
+ return TString{STR_WITH_PD_PEOPLE.translate()}.
+ format(confMemberCount);
+ }
+ } else {
+ ELOG("Invalid call data");
+ }
+
+ return "";
+ }
+
+ std::string CallInfoPresenter::getEndCallSubText() const
+ {
+ if (!m_endCallInfo) {
+ FAIL_RETURN_VALUE(RES_FAIL, "", "end is NULL!");
+ }
+
+ auto confMemberCount =
+ m_endCallInfo->getConferenceMemberCount();
+ if (confMemberCount > 1) {
+ return TString{STR_WITH_PD_PEOPLE.translate()}.
+ format(confMemberCount);
+ }
+
+ return "";
+ }
+
+ Result CallInfoPresenter::createLabel(const std::string &text)
+ {
+ auto *eo = elm_label_add(*m_widget);
+ if (!eo) {
+ LOG_RETURN(RES_FAIL, "elm_label_add() failed!");
+ }
+
+ TString txtStyle = impl::STR_LABEL_SUB_DEFAULT_STYLE;
+ if (m_mode == CallMode::DURING) {
+ txtStyle = impl::STR_LABEL_SUB_ON_HOLD;
+ } else if (m_callerId) {
+ txtStyle = impl::STR_LABEL_SUB_CID_ENABLE;
+ }
+
+ m_label = makeShared<StyledWidget>(eo, true);
+ m_label->setStyle(impl::STYLE_SLIDING_LABEL);
+ m_label->setText(txtStyle.format(text.c_str()));
+
+ elm_label_slide_mode_set(*m_label,ELM_LABEL_SLIDE_MODE_AUTO);
+ elm_label_wrap_width_set(*m_label,ELM_SCALE_SIZE(impl::SUB_TXT_WIDTH));
+
+ double duration = (static_cast<double>(text.size())) /
+ impl::SLIDE_LABEL_DURATION_KOEFF;
+ elm_label_slide_duration_set(*m_label, duration);
+ elm_label_slide_go(*m_label);
+
+ m_widget->setContent(*m_label, impl::PART_SWL_2LINE);
+
+ elm_atspi_accessible_can_highlight_set(*m_label, EINA_FALSE);
+
+ return RES_OK;
+ }
+
+ Result CallInfoPresenter::createCallerIdImage(const std::string &imagePath)
+ {
+ auto *eo = elm_image_add(*m_widget);
+ if (!eo) {
+ LOG_RETURN(RES_FAIL, "elm_image_add() failed");
+ }
+ auto callerId = makeShared<StyledWidget>(eo, true);
+ elm_image_file_set(*callerId, imagePath.c_str(), NULL);
+ elm_image_aspect_fixed_set(*callerId, EINA_TRUE);
+ elm_image_fill_outside_set(*callerId, EINA_TRUE);
+
+ auto window = callerId->getWindow();
+ if (!window) {
+ LOG_RETURN(RES_FAIL, "Window is NULL!");
+ }
+ int w = 0, h = 0;
+ window->getScreenSize(&w, &h);
+ evas_object_size_hint_min_set(*callerId, w, h);
+
+ m_widget->setContent(*callerId, impl::PART_SWL_CALLER_ID);
+
+ m_callerId = callerId;
+
+ return RES_OK;
+ }
+
+ Result CallInfoPresenter::updateCallerId()
+ {
+ m_callerId.reset();
+ m_widget->emit(impl::SIGN_CID_DISABLE,impl::SRC_CALLER_ID);
+
+ if (m_mode == CallMode::INCOMING) {
+
+ if (!m_incomCallInfo) {
+ LOG_RETURN(RES_FAIL, "m_incomCallInfo is NULL");
+ }
+
+ auto contactInfo = m_incomCallInfo->getContactInfo();
+ if (!contactInfo) {
+ LOG_RETURN(RES_OK, "No contact info");
+ }
+
+ auto callerIdPath = contactInfo->getImagePath();
+ if (callerIdPath.empty()) {
+ LOG_RETURN(RES_OK, "No caller id content to set");
+ }
+
+ FAIL_RETURN(createCallerIdImage(callerIdPath),
+ "createCallerIdImage() failed");
+
+ m_widget->emit(impl::SIGN_CID_ENABLE, impl::SRC_CALLER_ID);
+ }
+
+ return RES_OK;
+ }
+
+ Result CallInfoPresenter::updateSubText()
+ {
+ std::string subTxt;
+ m_isSubTxtEnable = false;
+ m_label.reset();
+
+ switch (m_mode) {
+ case CallMode::INCOMING:
+ subTxt = getIncomingCallSubText();
+ break;
+ case CallMode::DURING:
+ subTxt = getDuringCallSubText();
+ break;
+ case CallMode::OUTGOING:
+ ILOG("Outgoing call not supported");
+ break;
+ case CallMode::END:
+ subTxt = getEndCallSubText();
+ break;
+ case CallMode::UNDEFINED:
+ LOG_RETURN(RES_FAIL, "Undefined caller info mode!");
+ break;
+ default:
+ break;
+ }
+
+ if (!subTxt.empty()) {
+ m_isSubTxtEnable = true;
+ FAIL_RETURN(createLabel(subTxt), "createLabel() failed");
+ }
+
+ if (m_mode == CallMode::INCOMING) {
+ m_widget->emit(impl::SIGN_INCOMING, impl::SRC_TXT_2LINE);
+ } else {
+ m_widget->emit(impl::SIGN_DEFAULT, impl::SRC_TXT_2LINE);
+ }
+
+ FAIL_RETURN(setSubTxtAccessObject(subTxt),
+ "setSubTxtAccessObject() failed!");
+
+ return RES_OK;
+ }
+
+ std::string CallInfoPresenter::generateMainTxt(
+ const ICallInfoSCRef &callInfo)
+ {
+ if (!callInfo) {
+ LOG_RETURN_VALUE(RES_FAIL, "", "callInfo is NULL");
+ }
+
+ if (callInfo->getConferenceMemberCount() > 1) {
+ return STR_CONFERENCE_CALL.translate();
+ }
+
+ if (callInfo->isEmergency()) {
+ return STR_EMERGENCY_CALL.translate();
+ }
+
+ if (callInfo->isVoiceMailNumber()) {
+ return STR_VOICEMAIL.translate();
+ }
+
+ std::string mainTxt;
+ auto contactInfo = callInfo->getContactInfo();
+ if (contactInfo) {
+ mainTxt = contactInfo->getName();
+ }
+
+ if (mainTxt.empty()) {
+ mainTxt = callInfo->getPhoneNumber();
+ if (mainTxt.empty()) {
+ return STR_UNKNOWN.translate();
+ }
+ }
+ return mainTxt;
+ }
+
+ void CallInfoPresenter::displayMainTxt(const ICallInfoSCRef &info,
+ const std::string &text)
+ {
+ m_widget->setText(text.c_str(), impl::PART_TXT_MAIN);
+
+ FAIL_RETURN_VOID(setMainTxtAccessObject(text),
+ "setMainTxtAccessObject() failed!");
+
+ if (m_mode == CallMode::INCOMING) {
+ // Font size and color
+ if (m_callerId) {
+ m_widget->emit(impl::SIGN_CID_ENABLE, impl::SRC_TXT_1LINE);
+ } else {
+ m_widget->emit(impl::SIGN_CID_DISABLE, impl::SRC_TXT_1LINE);
+ }
+ // Info text top padding
+ if (impl::getTextWidth(*m_widget,
+ impl::CU_BIG_FONT_STYLE,
+ impl::CU_BIG_FONT_SIZE,
+ text) <= impl::INCOM_MAIN_TXT_WIDTH) {
+ m_widget->emit(impl::SIGN_CENTRE_1LINE, impl::SRC_TOP_PAD);
+ } else {
+ m_widget->emit(impl::SIGN_CENTRE_2LINE, impl::SRC_TOP_PAD);
+ }
+ return;
+ } else if (m_mode == CallMode::END) {
+ if (info->isEmergency()
+ || info->getContactInfo()
+ || (info->getConferenceMemberCount() > 1)) {
+ // Font size and color
+ if (info->isEmergency()) {
+ m_widget->emit(impl::SIGN_EMERGENCY_BIG_TXT,
+ impl::SRC_TXT_1LINE);
+ } else {
+ m_widget->emit(impl::SIGN_BIG_TXT, impl::SRC_TXT_1LINE);
+ }
+ // Info text top padding
+ if (impl::getTextWidth(*m_widget,
+ impl::CU_BIG_FONT_STYLE,
+ impl::CU_BIG_FONT_SIZE,
+ text) <= impl::SUB_TXT_WIDTH) {
+ m_widget->emit(impl::SIGN_CENTRE_1LINE, impl::SRC_TOP_PAD);
+ } else {
+ m_widget->emit(impl::SIGN_CENTRE_2LINE, impl::SRC_TOP_PAD);
+ }
+ return;
+ }
+ }
+ // Font size and color
+ if (info->isEmergency()) {
+ m_widget->emit(impl::SIGN_EMERGENCY, impl::SRC_TXT_1LINE);
+ } else {
+ m_widget->emit(impl::SIGN_DEFAULT, impl::SRC_TXT_1LINE);
+ }
+ // Info text top padding
+ m_widget->emit(impl::SIGN_DEFAULT, impl::SRC_TOP_PAD);
+ }
+
+ Result CallInfoPresenter::updateMainTxt()
+ {
+ std::string mainTxt;
+
+ ICallInfoSCRef info;
+
+ switch (m_mode) {
+ case CallMode::INCOMING:
+ info = m_incomCallInfo;
+ break;
+ case CallMode::OUTGOING:
+ info = m_activeCallInfo;
+ break;
+ case CallMode::DURING:
+ if (m_activeCallInfo) {
+ info = m_activeCallInfo;
+ } else if (m_heldCallInfo) {
+ info = m_heldCallInfo;
+ }
+ break;
+ case CallMode::END:
+ info = m_endCallInfo;
+ break;
+ default:
+ LOG_RETURN(RES_FAIL, "Unknown mode");
+ break;
+ }
+ if (!info) {
+ LOG_RETURN(RES_FAIL, "info is NULL");
+ }
+
+ mainTxt = generateMainTxt(info);
+
+ if (mainTxt.empty()) {
+ LOG_RETURN(RES_FAIL, "Main text is empty");
+ }
+
+ displayMainTxt(info, mainTxt);
+
+ return RES_OK;
+ }
+
+ Result CallInfoPresenter::createCallStatus(GuiPresenter &parent)
+ {
+ ICallInfoWCRef callInfo;
+ bool isOnHold = false;
+
+ m_callStatus.reset();
+
+ switch (m_mode) {
+ case CallMode::INCOMING:
+ callInfo = m_incomCallInfo;
+ break;
+ case CallMode::OUTGOING:
+ callInfo = m_activeCallInfo;
+ break;
+ case CallMode::DURING:
+ if (m_activeCallInfo) {
+ callInfo = m_activeCallInfo;
+ } else if (m_heldCallInfo) {
+ callInfo = m_heldCallInfo;
+ isOnHold = true;
+ }
+ break;
+ case CallMode::END:
+ callInfo = m_endCallInfo;
+ break;
+ default:
+ LOG_RETURN(RES_FAIL, "Unknown mode");
+ break;
+ }
+
+ m_callStatus = CallStatusPresenter::Builder().
+ setLayout(m_widget).
+ setMode(m_mode).
+ setCallInfo(callInfo).
+ setCallHoldState(isOnHold).
+ build(parent);
+
+ if (!m_callStatus) {
+ LOG_RETURN(RES_FAIL, "CallStatus::build() failed!");
+ }
+
+ return RES_OK;
+ }
+
+ Result CallInfoPresenter::update()
+ {
+ m_widget->emit(impl::SIGN_RESET, impl::SRC_TOP_PAD);
+
+ FAIL_RETURN(updateCallerId(), "displayCallerId() failed!");
+ FAIL_RETURN(updateSubText(), "diplaySubText() failed!");
+ FAIL_RETURN(updateMainTxt(), "diplayMainTxt() failed!");
+
+ if (m_needModifyCallStatus) {
+ if (const auto parent = m_parent.lock())
+ return createCallStatus(*parent);
+ }
+
+ return RES_OK;
+ }
+
+ // Screen Reader
+ ElmWidget *CallInfoPresenter::getMainTxtAo()
+ {
+ return m_mainTxtAO.get();
+ }
+
+ ElmWidget *CallInfoPresenter::getSubTxtAo()
+ {
+ return m_subTxtAO.get();
+ }
+
+ ElmWidget *CallInfoPresenter::getStatusTxtAo()
+ {
+ return m_callStatus->getStatusTextAo();
+ }
+
+ Result CallInfoPresenter::setMainTxtAccessObject(const std::string &text)
+ {
+ if (!m_mainTxtAO) {
+ m_mainTxtAO = utils::createAccessObjectFromLyPart(*m_widget,
+ *m_widget,
+ impl::PART_AO_MAIN_TXT);
+ if (!m_mainTxtAO) {
+ LOG_RETURN(RES_FAIL, "createAccessObjectFromLyPart() failed!");
+ }
+
+ }
+ elm_atspi_accessible_reading_info_type_set(*m_mainTxtAO,
+ ELM_ACCESSIBLE_READING_INFO_TYPE_NAME);
+ elm_atspi_accessible_name_set(*m_mainTxtAO, text.c_str());
+
+ return RES_OK;
+ }
+
+ Result CallInfoPresenter::setSubTxtAccessObject(const std::string &text)
+ {
+ if (!text.empty()) {
+ if (!m_subTxtAO) {
+ m_subTxtAO = utils::createAccessObjectFromLyPart(*m_widget,
+ *m_widget,
+ impl::PART_AO_SUB_TXT);
+ if (!m_subTxtAO) {
+ LOG_RETURN(RES_FAIL, "createAccessObjectFromLyPart() failed!");
+ }
+ }
+
+ elm_atspi_accessible_reading_info_type_set(*m_subTxtAO,
+ ELM_ACCESSIBLE_READING_INFO_TYPE_NAME);
+ elm_atspi_accessible_name_set(*m_subTxtAO, text.c_str());
+
+ } else if (m_subTxtAO) {
+ utils::destroyAccessObject(*m_subTxtAO);
+ m_subTxtAO.reset();
+ }
+
+ return RES_OK;
+ }
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_MISC_CALL_INFO_PRESENTER_H__
+#define __CALL_UI_PRESENTERS_MISC_CALL_INFO_PRESENTER_H__
+
+#include "ucl/mvp/GuiPresenter.h"
+
+#include "ucl/gui/Layout.h"
+#include "ucl/gui/StyledWidget.h"
+
+#include "call-ui/model/ICallManager.h"
+#include "CallStatusPresenter.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(CallInfoPresenter);
+
+ class CallInfoPresenter final : public ucl::GuiPresenter {
+ public:
+ class Builder {
+ public:
+ Builder();
+ virtual ~Builder();
+ Builder &setCallManager(const ICallManagerSRef &cm);
+ Builder &setMode(CallMode mode);
+ Builder &setParentWidget(const ucl::ElmWidgetSRef &parentWidget);
+ CallInfoPresenterSRef build(ucl::GuiPresenter &parent) const;
+ private:
+ ICallManagerSRef m_cm;
+ CallMode m_mode;
+ ucl::ElmWidgetSRef m_parentWidget;
+ };
+
+ public:
+ virtual ~CallInfoPresenter();
+
+ ucl::Widget &getWidget();
+ CallMode getMode() const;
+ ucl::Result update(CallMode mode, const ICallManagerSRef &cm);
+
+ // Screen Reader
+ ucl::ElmWidget *getStatusTxtAo();
+ ucl::ElmWidget *getMainTxtAo();
+ ucl::ElmWidget *getSubTxtAo();
+
+ private:
+ friend class ucl::ReffedObj<CallInfoPresenter>;
+ CallInfoPresenter(ucl::IRefCountObj &rc,
+ const ICallManagerSRef &cm,
+ CallMode mode);
+
+ ucl::Result prepare(ucl::GuiPresenter &parent,
+ ucl::ElmWidget &parentWidget);
+
+ void initCallInfos(const ICallManagerSRef &cm);
+
+ ucl::Result createWidget(ucl::ElmWidget &parent);
+ ucl::Result createLabel(const std::string &text);
+ ucl::Result createCallerIdImage(const std::string &imagePath);
+ ucl::Result createCallStatus(ucl::GuiPresenter &parent);
+
+ ucl::Result update();
+ ucl::Result updateCallerId();
+ ucl::Result updateSubText();
+ ucl::Result updateMainTxt();
+ std::string getNumberSubText(const ICallInfoSCRef &callInfo) const;
+ std::string getIncomingCallSubText() const;
+ std::string getOutgoingCallSubText() const;
+ std::string getDuringCallSubText() const;
+ std::string getEndCallSubText() const;
+
+ std::string generateMainTxt(const ICallInfoSCRef &callInfo);
+
+ void displayMainTxt(const ICallInfoSCRef &info, const std::string &text);
+
+ // Screen Reader
+ ucl::Result setMainTxtAccessObject(const std::string &text);
+ ucl::Result setSubTxtAccessObject(const std::string &text);
+
+ private:
+ ucl::LayoutSRef m_widget;
+ ucl::StyledWidgetSRef m_callerId;
+ ucl::StyledWidgetSRef m_label;
+ ucl::GuiPresenterWRef m_parent;
+ CallMode m_mode;
+ ICallInfoSCRef m_incomCallInfo;
+ ICallInfoSCRef m_activeCallInfo;
+ ICallInfoSCRef m_heldCallInfo;
+ ICallInfoSCRef m_endCallInfo;
+ CallStatusPresenterSRef m_callStatus;
+ bool m_isSubTxtEnable;
+ bool m_needModifyCallStatus;
+
+ // Screen Reader
+ ucl::ElmWidgetSRef m_statusAO;
+ ucl::ElmWidgetSRef m_mainTxtAO;
+ ucl::ElmWidgetSRef m_subTxtAO;
+ };
+
+}
+
+#endif // __CALL_UI_PRESENTERS_MISC_CALL_INFO_PRESENTER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "CallStatusPresenter.h"
+
+#include "call-ui/resources.h"
+#include "common.h"
+
+namespace callui { namespace { namespace impl {
+
+ using namespace ucl;
+
+ constexpr double CALL_DURATION_TIMER_INTERVAL = 0.1;
+ constexpr double END_CALL_BLINKING_TIMER_INTERVAL = 0.5;
+ constexpr int END_CALL_BLINKING_MAX_COUNT = 5;
+
+ constexpr EdjePart PART_TXT_TEXT_INFO {"text_info"};
+
+ constexpr EdjeSignal SIGN_DOT_RTL {"default:RTL"};
+ constexpr EdjeSignal SIGN_DOT_LTR {"default:LTR"};
+ constexpr EdjeSignal SIGN_RESET {"reset"};
+
+ constexpr EdjePart PART_AO_STATUS {"ao_text_info"};
+
+ constexpr EdjeSignalSrc SIGN_SRC_DOT {"dot"};
+
+}}}
+
+namespace callui {
+
+ using namespace ucl;
+
+ CallStatusPresenter::Builder::Builder():
+ m_mode(CallMode::UNDEFINED),
+ m_isOnHold(false)
+ {
+ }
+
+ CallStatusPresenter::Builder::~Builder()
+ {
+ }
+
+ CallStatusPresenter::Builder &
+ CallStatusPresenter::Builder::setMode(CallMode mode)
+ {
+ m_mode = mode;
+ return *this;
+ }
+
+ CallStatusPresenter::Builder &
+ CallStatusPresenter::Builder::setCallInfo(const ICallInfoWCRef &info)
+ {
+ m_info = info;
+ return *this;
+ }
+
+ CallStatusPresenter::Builder &
+ CallStatusPresenter::Builder::setCallHoldState(bool isOnHold)
+ {
+ m_isOnHold = isOnHold;
+ return *this;
+ }
+
+ CallStatusPresenter::Builder &
+ CallStatusPresenter::Builder::setLayout(const LayoutSRef &layout)
+ {
+ m_ly = layout;
+ return *this;
+ }
+
+ CallStatusPresenterSRef
+ CallStatusPresenter::Builder::build(GuiPresenter &parent) const
+ {
+ if (m_mode == CallMode::UNDEFINED || !m_ly) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "Not all params are set");
+ }
+
+ auto result = makeShared<CallStatusPresenter>(m_ly, m_mode,
+ m_info, m_isOnHold);
+
+ FAIL_RETURN_VALUE(result->prepare(parent), {},
+ "result->prepare() failed!");
+ return result;
+ }
+
+
+ CallStatusPresenter::CallStatusPresenter(IRefCountObj &rc,
+ const LayoutSRef &layout,
+ CallMode mode,
+ const ICallInfoWCRef &info,
+ bool isHeld):
+ GuiPresenter(rc),
+ m_ly(layout),
+ m_mode(mode),
+ m_info(info),
+ m_isOnHold(isHeld),
+ m_timer(nullptr),
+ m_duration{0},
+ m_blinkCount(0)
+ {
+ }
+
+ CallStatusPresenter::~CallStatusPresenter()
+ {
+ m_ly.reset();
+ if (m_timer) {
+ ecore_timer_del(m_timer);
+ m_timer = nullptr;
+ }
+ }
+
+ Result CallStatusPresenter::prepare(GuiPresenter &parent)
+ {
+ FAIL_RETURN(GuiPresenter::prepare(parent, PF_PASSIVE),
+ "Presenter::prepare() failed!");
+
+ m_ly->emit(impl::SIGN_RESET, impl::SIGN_SRC_DOT);
+ m_ly->setText("", impl::PART_TXT_TEXT_INFO);
+ createStatusTxtAo();
+
+ switch (m_mode) {
+ case CallMode::INCOMING: return processIncomingMode();
+ case CallMode::OUTGOING: return processOutgoingMode();
+ case CallMode::DURING: return processDuringMode();
+ case CallMode::END: return processEndMode();
+ default:
+ LOG_RETURN(RES_FAIL, "Unknown mode");
+ break;
+ }
+
+ return RES_OK;
+ }
+
+ Result CallStatusPresenter::processIncomingMode()
+ {
+ m_ly->setText(STR_INCOMING_CALL, impl::PART_TXT_TEXT_INFO);
+
+ // TODO: need add logic for RTL mode in the future
+ m_ly->emit(impl::SIGN_DOT_LTR, impl::SIGN_SRC_DOT);
+
+ return RES_OK;
+ }
+
+ Result CallStatusPresenter::processOutgoingMode()
+ {
+ m_ly->setText(STR_DIALING_CALL, impl::PART_TXT_TEXT_INFO);
+
+ // TODO: need add logic for RTL mode in the future
+ m_ly->emit(impl::SIGN_DOT_LTR, impl::SIGN_SRC_DOT);
+
+ return RES_OK;
+ }
+
+ Eina_Bool CallStatusPresenter::onCallDurationTimerCb()
+ {
+ const auto info = m_info.lock();
+ if (!info) {
+ m_timer = nullptr;
+ LOG_RETURN_VALUE(RES_FAIL, ECORE_CALLBACK_CANCEL, "m_info is NULL");
+ }
+
+ struct tm tmp = info->getDuration();
+ tryUpdateCallDurationTime(
+ m_duration,
+ tmp,
+ *m_ly,
+ impl::PART_TXT_TEXT_INFO);
+
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ Result CallStatusPresenter::processDuringMode()
+ {
+
+ if (m_isOnHold) {
+ m_ly->setText(STR_ON_HOLD, impl::PART_TXT_TEXT_INFO);
+ } else {
+ if (const auto info = m_info.lock()) {
+ m_duration = info->getDuration();
+ }
+ m_ly->setText(getCallDuration(m_duration),
+ impl::PART_TXT_TEXT_INFO);
+
+ if (m_timer) {
+ ecore_timer_del(m_timer);
+ m_timer = nullptr;
+ }
+
+ m_timer = ecore_timer_add(impl::CALL_DURATION_TIMER_INTERVAL,
+ CALLBACK_B(CallStatusPresenter::onCallDurationTimerCb),
+ this);
+
+ if (!m_timer) {
+ LOG_RETURN(RES_FAIL, "m_timer is NULL");
+ }
+ }
+ return RES_OK;
+ }
+
+ Eina_Bool CallStatusPresenter::onBlinkingTimerCb()
+ {
+ if ((m_blinkCount % 2) == 0) {
+ m_ly->setText(getCallDuration(m_duration),
+ impl::PART_TXT_TEXT_INFO);
+ } else if ((m_blinkCount % 2) == 1) {
+ m_ly->setText("", impl::PART_TXT_TEXT_INFO);
+ }
+
+ m_blinkCount++;
+
+ if (m_blinkCount == impl::END_CALL_BLINKING_MAX_COUNT) {
+ m_ly->setText(STR_CALL_ENDED, impl::PART_TXT_TEXT_INFO);
+ m_timer = nullptr;
+ return ECORE_CALLBACK_CANCEL;
+ }
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ Result CallStatusPresenter::processEndMode()
+ {
+ if (m_timer) {
+ ecore_timer_del(m_timer);
+ m_timer = nullptr;
+ }
+
+ if (const auto info = m_info.lock()) {
+ m_duration = info->getDuration();
+ }
+
+ m_timer = ecore_timer_add(impl::END_CALL_BLINKING_TIMER_INTERVAL,
+ CALLBACK_B(CallStatusPresenter::onBlinkingTimerCb), this);
+ if (!m_timer) {
+ LOG_RETURN(RES_FAIL, "m_timer is NULL");
+ }
+
+ return RES_OK;
+ }
+
+ // Screen Reader
+ Result CallStatusPresenter::createStatusTxtAo()
+ {
+ if (!m_statusTxtAo) {
+ m_statusTxtAo = utils::createAccessObjectFromLyPart(*m_ly,
+ *m_ly,
+ impl::PART_AO_STATUS);
+ if (!m_statusTxtAo) {
+ LOG_RETURN(RES_FAIL, "createAccessObjectFromLyPart() failed!");
+ }
+
+ elm_atspi_accessible_reading_info_type_set(*m_statusTxtAo,
+ ELM_ACCESSIBLE_READING_INFO_TYPE_NAME);
+ elm_atspi_accessible_name_cb_set(*m_statusTxtAo,
+ [](void *data, Evas_Object *obj) -> char *
+ {
+ auto self = static_cast<CallStatusPresenter *>(data);
+ if (!self) {
+ return nullptr;
+ }
+ auto txt = self->m_ly->
+ getText(impl::PART_TXT_TEXT_INFO).getCStr();
+ return (txt) ? strdup(txt) : nullptr;
+ },
+ this);
+ }
+ return RES_OK;
+ }
+
+ ElmWidget *CallStatusPresenter::getStatusTextAo()
+ {
+ return m_statusTxtAo.get();
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_MISC_CALL_STATUS_PRESENTER_H__
+#define __CALL_UI_PRESENTERS_MISC_CALL_STATUS_PRESENTER_H__
+
+#include "ucl/mvp/GuiPresenter.h"
+
+#include <time.h>
+
+#include "ucl/gui/Layout.h"
+
+#include "call-ui/model/ICallInfo.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(CallStatusPresenter);
+
+ class CallStatusPresenter final : public ucl::GuiPresenter {
+ public:
+ class Builder {
+ public:
+ Builder();
+ virtual ~Builder();
+ Builder &setMode(CallMode mode);
+ Builder &setCallInfo(const ICallInfoWCRef &info);
+ Builder &setCallHoldState(bool isOnHold);
+ Builder &setLayout(const ucl::LayoutSRef &layout);
+ CallStatusPresenterSRef build(ucl::GuiPresenter &parent) const;
+ private:
+ ucl::LayoutSRef m_ly;
+ CallMode m_mode;
+ ICallInfoWCRef m_info;
+ bool m_isOnHold;
+ };
+ public:
+ virtual ~CallStatusPresenter();
+
+ // Screen Reader
+ ucl::ElmWidget *getStatusTextAo();
+
+ private:
+ friend class ucl::ReffedObj<CallStatusPresenter>;
+ CallStatusPresenter(ucl::IRefCountObj &rc,
+ const ucl::LayoutSRef &layout,
+ CallMode mode,
+ const ICallInfoWCRef &info,
+ bool isOnHold);
+
+ ucl::Result prepare(ucl::GuiPresenter &parent);
+
+ ucl::Result processIncomingMode();
+ ucl::Result processOutgoingMode();
+ ucl::Result processDuringMode();
+ ucl::Result processEndMode();
+
+ Eina_Bool onCallDurationTimerCb();
+ Eina_Bool onBlinkingTimerCb();
+
+ // Screen Reader
+ ucl::Result createStatusTxtAo();
+
+ private:
+ ucl::LayoutSRef m_ly;
+ CallMode m_mode;
+ ICallInfoWCRef m_info;
+ bool m_isOnHold;
+ Ecore_Timer *m_timer;
+ struct tm m_duration;
+ int m_blinkCount;
+
+ // Screen Reader
+ ucl::ElmWidgetSRef m_statusTxtAo;
+ };
+
+}
+
+#endif // __CALL_UI_PRESENTERS_MISC_CALL_STATUS_PRESENTER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "DeviceStatePresenter.h"
+
+#include <device/power.h>
+#include <device/display.h>
+#include <efl_util.h>
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ // DeviceStatePresenter::Builder
+
+ DeviceStatePresenter::Builder::Builder():
+ m_state(DisplayState::UNDEFINED),
+ m_mode(DisplayMode::UNDEFINED),
+ m_lockState(false)
+ {
+ }
+
+ DeviceStatePresenter::Builder &
+ DeviceStatePresenter::Builder::setDisplayState(DisplayState state)
+ {
+ m_state = state;
+ return *this;
+ }
+
+ DeviceStatePresenter::Builder &
+ DeviceStatePresenter::Builder::setDisplayMode(DisplayMode mode)
+ {
+ m_mode = mode;
+ return *this;
+ }
+
+ DeviceStatePresenter::Builder &
+ DeviceStatePresenter::Builder::setCpuLockState(bool lockState)
+ {
+ m_lockState = lockState;
+ return *this;
+ }
+
+ DeviceStatePresenterSRef
+ DeviceStatePresenter::Builder::build(const ucl::WindowSRef &window) const
+ {
+ auto result = makeShared<DeviceStatePresenter>(window);
+ FAIL_RETURN_VALUE(result->prepare(m_state,
+ m_mode, m_lockState), {},
+ "result->prepare() failed!");
+ return result;
+ }
+
+ // DeviceStatePresenter
+
+ DeviceStatePresenter::DeviceStatePresenter(const ucl::WindowSRef &window):
+ m_window(window),
+ m_mode(DisplayMode::UNDEFINED),
+ m_lockState(false)
+ {
+ }
+
+ Result DeviceStatePresenter::prepare(DisplayState state,
+ DisplayMode mode,
+ bool lockState)
+ {
+ if (state != DisplayState::UNDEFINED) {
+ FAIL_RETURN(setDisplayState(state, true),
+ "setDisplayState() failed");
+ }
+
+ if (mode != DisplayMode::UNDEFINED) {
+ FAIL_RETURN(setDisplayMode(mode),
+ "setDisplayMode() failed");
+ }
+
+ if (lockState) {
+ FAIL_RETURN(setCpuLockState(lockState),
+ "setCpuLockState() failed");
+ }
+
+ return RES_OK;
+ }
+
+ Result DeviceStatePresenter::setDisplayState(DisplayState state, bool forse)
+ {
+ if (state == DisplayState::UNDEFINED) {
+ LOG_RETURN(RES_FAIL, "State is undefined");
+ }
+
+ display_state_e dispState = DISPLAY_STATE_NORMAL;
+
+ if (!forse) {
+ int res = device_display_get_state(&dispState);
+ if (res != DEVICE_ERROR_NONE) {
+ LOG_RETURN(RES_FAIL, "device_display_get_state() failed."
+ "res[%d] msg[%s]", res, get_error_message(res));
+ }
+ if ((state == DisplayState::ON
+ && dispState == DISPLAY_STATE_NORMAL)
+ || (state == DisplayState::DIM
+ && dispState == DISPLAY_STATE_SCREEN_DIM)
+ || (state == DisplayState::OFF
+ && dispState == DISPLAY_STATE_SCREEN_OFF)) {
+ LOG_RETURN(RES_OK,
+ "Display state already set into needed state");
+ }
+ }
+
+ switch (state) {
+ case DisplayState::ON:
+ dispState = DISPLAY_STATE_NORMAL;
+ break;
+ case DisplayState::DIM:
+ dispState = DISPLAY_STATE_SCREEN_DIM;
+ break;
+ case DisplayState::OFF:
+ dispState = DISPLAY_STATE_SCREEN_OFF;
+ break;
+ default:
+ LOG_RETURN(RES_FAIL, "Undefined state");
+ break;
+ }
+
+ int res = device_display_change_state(dispState);
+ if (res != DEVICE_ERROR_NONE) {
+ LOG_RETURN(RES_FAIL, "device_display_change_state() failed."
+ "res[%d] msg[%s]", res, get_error_message(res));
+ }
+
+ return RES_OK;
+ }
+
+ Result DeviceStatePresenter::setDisplayMode(DisplayMode mode)
+ {
+ if (mode == DisplayMode::UNDEFINED) {
+ LOG_RETURN(RES_FAIL, "Mode is undefined");
+ }
+
+ if (mode == m_mode) {
+ LOG_RETURN(RES_OK, "Display mode already set");
+ }
+
+ m_mode = mode;
+
+ efl_util_screen_mode_e setScreenMode =
+ (m_mode == DisplayMode::TOP_PRIORITY) ?
+ EFL_UTIL_SCREEN_MODE_ALWAYS_ON :
+ EFL_UTIL_SCREEN_MODE_DEFAULT;
+
+ int res = efl_util_set_window_screen_mode(*m_window, setScreenMode);
+ if (res != EFL_UTIL_ERROR_NONE) {
+ LOG_RETURN(RES_FAIL, "Set window screen mode failed."
+ "res[%d] msg[%s]", res, get_error_message(res));
+ }
+
+ return RES_OK;
+ }
+
+ Result DeviceStatePresenter::setCpuLockState(bool lockState)
+ {
+ if (lockState == m_lockState) {
+ LOG_RETURN(RES_OK, "Cpu lock state already set %s",
+ lockState ? "locked" : "unlocked");
+ }
+
+ m_lockState = lockState;
+
+ int res = m_lockState ?
+ device_power_request_lock(POWER_LOCK_CPU, 0) :
+ device_power_release_lock(POWER_LOCK_CPU);
+
+ if (res != DEVICE_ERROR_NONE) {
+ LOG_RETURN(RES_FAIL, "Device power request %s failed.",
+ m_lockState ? "lock" : "unlock",
+ "res[%d] msg[%s]", res, get_error_message(res));
+ }
+
+ return RES_OK;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_MISC_DEVICE_STATE_PRESENTER_H__
+#define __CALL_UI_PRESENTERS_MISC_DEVICE_STATE_PRESENTER_H__
+
+#include "ucl/gui/Window.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(DeviceStatePresenter);
+
+ class DeviceStatePresenter final {
+ public:
+ enum class DisplayState {
+ UNDEFINED,
+ ON,
+ OFF,
+ DIM
+ };
+
+ enum class DisplayMode {
+ UNDEFINED,
+ REGULAR,
+ TOP_PRIORITY
+ };
+
+ public:
+ class Builder {
+ public:
+ Builder();
+ Builder &setDisplayState(DisplayState state);
+ Builder &setDisplayMode(DisplayMode mode);
+ Builder &setCpuLockState(bool lockState);
+ DeviceStatePresenterSRef build(
+ const ucl::WindowSRef &window) const;
+ private:
+ DisplayState m_state;
+ DisplayMode m_mode;
+ bool m_lockState;
+ };
+
+ public:
+ ucl::Result setDisplayState(DisplayState state,
+ bool forse = false);
+ ucl::Result setDisplayMode(DisplayMode mode);
+ ucl::Result setCpuLockState(bool lockState);
+
+ private:
+ friend class ucl::ReffedObj<DeviceStatePresenter>;
+ DeviceStatePresenter(const ucl::WindowSRef &window);
+ ~DeviceStatePresenter() = default;
+
+ ucl::Result prepare(DisplayState state,
+ DisplayMode mode,
+ bool lockState);
+
+ private:
+ ucl::WindowSRef m_window;
+ DisplayMode m_mode;
+ bool m_lockState;
+ };
+}
+
+#endif // __CALL_UI_PRESENTERS_MISC_DEVICE_STATE_PRESENTER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "IndicatorPresenter.h"
+
+#include <string>
+
+#include "common.h"
+
+namespace callui { namespace { namespace impl {
+ using namespace ucl;
+
+ constexpr int BATTERY_LOW_LIMIT = 5;
+
+ constexpr LayoutTheme LAYOUT_INDICATOR_WIDGET
+ {"layout", "callui", "indicator"};
+
+ constexpr LayoutTheme LAYOUT_CONNECTION
+ {"layout", "callui", "connection"};
+
+ constexpr LayoutTheme LAYOUT_RSSI
+ {"layout", "callui", "rssi"};
+
+ constexpr LayoutTheme LAYOUT_BATTERY
+ {"layout", "callui", "battery"};
+
+ constexpr LayoutTheme LAYOUT_SIM
+ {"layout", "callui", "sim"};
+
+ constexpr LayoutTheme LAYOUT_HD_CALL
+ {"layout", "callui", "hd_voice"};
+
+ constexpr LayoutTheme LAYOUT_VOICE_CONTROL
+ {"layout", "callui", "voice_control"};
+
+ constexpr EdjePart PART_SWL_CONN {"swl.connection"};
+ constexpr EdjePart PART_SWL_RSSI {"swl.rssi"};
+ constexpr EdjePart PART_SWL_BATTERY {"swl.battery"};
+ constexpr EdjePart PART_SWL_VOICE_CONTROL {"swl.voice_control"};
+ constexpr EdjePart PART_SWL_SIM {"swl.sim"};
+ constexpr EdjePart PART_SWL_HD_VOICE {"swl.hd_voice"};
+
+ constexpr EdjeSignal SIGL_BATT_LVL_HIDE {"batt_lvl_hide"};
+
+ EdjeSignal getConnUpdateSignal(ConnectionType connection)
+ {
+ switch (connection) {
+ case ConnectionType::EDGE_E: return EdjeSignal{"conn_edge_connected"};
+ case ConnectionType::GPRS_G: return EdjeSignal{"conn_gprs_connected"};
+ case ConnectionType::SIMPLE_2G: return EdjeSignal{"conn_2g_connected"};
+ case ConnectionType::HSDPA_H: return EdjeSignal{"conn_hsdpa_connected"};
+ case ConnectionType::HSPA_H_PLUS: return EdjeSignal{"conn_hspa_connected"};
+ case ConnectionType::LTE_4G: return EdjeSignal{"conn_lte_connected"};
+ case ConnectionType::UMTS_3G: return EdjeSignal{"conn_umts_connected"};
+ case ConnectionType::UMTS_3G_PLUS: return EdjeSignal{"conn_3g_plus_connected"};
+ case ConnectionType::WIFI_00: return EdjeSignal{"conn_wifi_connected_00"};
+ case ConnectionType::WIFI_01: return EdjeSignal{"conn_wifi_connected_01"};
+ case ConnectionType::WIFI_02: return EdjeSignal{"conn_wifi_connected_02"};
+ case ConnectionType::WIFI_03: return EdjeSignal{"conn_wifi_connected_03"};
+ case ConnectionType::WIFI_04: return EdjeSignal{"conn_wifi_connected_04"};
+ case ConnectionType::NO_SIGNAL: return EdjeSignal{"conn_no_signal"};
+ default: return EdjeSignal{"conn_none"};
+ }
+ }
+
+ EdjeSignal getPacketUpdateSignal(PacketDirection direction)
+ {
+ switch (direction) {
+ case PacketDirection::NO_INPUT: return EdjeSignal{"packet_no_inout_connected"};
+ case PacketDirection::IN: return EdjeSignal{"packet_in_connected"};
+ case PacketDirection::OUT: return EdjeSignal{"packet_out_connected"};
+ case PacketDirection::INOUT: return EdjeSignal{"packet_inout_connected"};
+ default: return EdjeSignal{"packet_none"};
+ }
+ }
+
+ EdjeSignal getRssiUpdateSignal(RssiState state, bool isRoaming)
+ {
+ switch (state) {
+ case RssiState::LEVEL_0: return EdjeSignal{ isRoaming ? "rssi_roaming_00" : "rssi_00"};
+ case RssiState::LEVEL_1: return EdjeSignal{ isRoaming ? "rssi_roaming_01" : "rssi_01"};
+ case RssiState::LEVEL_2: return EdjeSignal{ isRoaming ? "rssi_roaming_02" : "rssi_02"};
+ case RssiState::LEVEL_3: return EdjeSignal{ isRoaming ? "rssi_roaming_03" : "rssi_03"};
+ case RssiState::LEVEL_4: return EdjeSignal{ isRoaming ? "rssi_roaming_04" : "rssi_04"};
+ case RssiState::NO_SIGNAL: return EdjeSignal{"rssi_no_signal"};
+ case RssiState::FLIGHT_MODE: return EdjeSignal{"rssi_flight_mode"};
+ default: return EdjeSignal{"rssi_none"};
+ }
+ }
+
+ EdjeSignal getBatteryStateUpdateSignal(BatteryState state, int battLvl)
+ {
+ switch (state) {
+ case BatteryState::CHARGING: return EdjeSignal{"batt_state_charging"};
+ case BatteryState::CHARGING_PROBLEM: return EdjeSignal{"batt_state_charging_problem"};
+ case BatteryState::UNKNOWN: return EdjeSignal{"batt_state_unknown"};
+ default:
+ if (battLvl > BATTERY_LOW_LIMIT)
+ return EdjeSignal{"batt_state_normal"};
+ else
+ return EdjeSignal{"batt_state_low_battery"};
+ }
+ }
+
+ EdjeSignal getBatteryLevelUpdateSignal(int level, bool isLevelUnknown)
+ {
+ if (isLevelUnknown) {
+ return impl::SIGL_BATT_LVL_HIDE;
+ }
+
+ auto battLvl = level;
+ if (battLvl <= BATTERY_LOW_LIMIT) {
+ battLvl /= BATTERY_LOW_LIMIT;
+ battLvl *= BATTERY_LOW_LIMIT;
+ } else {
+ battLvl += BATTERY_LOW_LIMIT - 1;
+ battLvl /= BATTERY_LOW_LIMIT;
+ battLvl *= BATTERY_LOW_LIMIT;
+ }
+
+ if (battLvl <= BATTERY_LOW_LIMIT - 1) {
+ return impl::SIGL_BATT_LVL_HIDE;
+ }
+ return EdjeSignal{std::string("batt_lvl_").
+ append(std::to_string(battLvl)).
+ c_str()};
+
+ }
+
+ EdjeSignal getSimSlotUpdateSignal(SimSlot slot, bool isForwarded)
+ {
+ switch (slot) {
+ case SimSlot::GEAR:
+ if (isForwarded) {
+ return EdjeSignal{"sim_gear_forwarded"};
+ } else {
+ return EdjeSignal{"sim_gear"};
+ }
+ case SimSlot::MOBILE_DEFAULT: return EdjeSignal{"sim_mobile"};
+ case SimSlot::MOBILE_FIRST: return EdjeSignal{"sim_mobile_01"};
+ case SimSlot::MOBILE_SECOND: return EdjeSignal{"sim_mobile_02"};
+ default: return EdjeSignal{"sim_unknown"};
+ }
+ }
+
+}}}
+
+namespace callui {
+
+ using namespace ucl;
+
+ IndicatorPresenter::Builder::Builder()
+ {
+ }
+
+ IndicatorPresenter::Builder::~Builder()
+ {
+ }
+
+ IndicatorPresenter::Builder &
+ IndicatorPresenter::Builder::setIndicatorStateProvider(
+ const IIndicatorStateProviderSRef &provider)
+ {
+ m_provider = provider;
+ return *this;
+ }
+
+ IndicatorPresenter::Builder &
+ IndicatorPresenter::Builder::setParentWidget(const ucl::ElmWidgetSRef &parentWidget)
+ {
+ m_parentWidget = parentWidget;
+ return *this;
+ }
+
+ IndicatorPresenterSRef
+ IndicatorPresenter::Builder::build(GuiPresenter &parent) const
+ {
+ if (!m_provider || !m_parentWidget) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "Main params are not set");
+ }
+
+ auto result = makeShared<IndicatorPresenter>(m_provider);
+ FAIL_RETURN_VALUE(result->prepare(parent, *m_parentWidget), {},
+ "result->prepare() failed!");
+ return result;
+ }
+
+ IndicatorPresenter::IndicatorPresenter(IRefCountObj &rc,
+ const IIndicatorStateProviderSRef &provider):
+ GuiPresenter(rc),
+ m_provider(provider),
+ m_isIncomingCallMode(false)
+ {
+ }
+
+ IndicatorPresenter::~IndicatorPresenter()
+ {
+ }
+
+ Result IndicatorPresenter::prepare(GuiPresenter &parent,
+ ElmWidget &parentWidget)
+ {
+ FAIL_RETURN(GuiPresenter::prepare(parent, PF_PASSIVE),
+ "Presenter::prepare() failed!");
+ FAIL_RETURN(createWidget(parentWidget),
+ "createWidget() failed!");
+ FAIL_RETURN(createConnectionLayout(),
+ "createConnectionLayout() failed!");
+ FAIL_RETURN(createRssiLayout(),
+ "createRssiLayout() failed!");
+ FAIL_RETURN(createBatteryLayout(),
+ "createBatteryLayout() failed!");
+ FAIL_RETURN(createVoiceControlLayout(),
+ "createBatteryLayout() failed!");
+ FAIL_RETURN(createSimLayout(),
+ "createSimLayout() failed!");
+ FAIL_RETURN(createHdVoiceLayout(),
+ "createHdCallLayout() failed!");
+
+ updateCentralIcon();
+
+ m_provider->setListener(asWeak(*this));
+
+ return RES_OK;
+ }
+
+ Result IndicatorPresenter::createWidget(ElmWidget &parent)
+ {
+ m_widget = Layout::Builder().
+ setTheme(impl::LAYOUT_INDICATOR_WIDGET).
+ setIsOwner(true).
+ build(parent);
+ if (!m_widget) {
+ LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+ }
+
+ return RES_OK;
+ }
+
+ Result IndicatorPresenter::createConnectionLayout()
+ {
+ m_connLayout = Layout::Builder().
+ setTheme(impl::LAYOUT_CONNECTION).
+ build(*m_widget);
+ if (!m_connLayout) {
+ LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+ }
+ m_widget->setContent(*m_connLayout, impl::PART_SWL_CONN);
+
+ updateConnectionState();
+
+ return RES_OK;
+ }
+
+ Result IndicatorPresenter::createRssiLayout()
+ {
+ m_rssiLayout = Layout::Builder().
+ setTheme(impl::LAYOUT_RSSI).
+ build(*m_widget);
+ if (!m_rssiLayout) {
+ LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+ }
+ m_widget->setContent(*m_rssiLayout, impl::PART_SWL_RSSI);
+
+ updateRssiState();
+
+ return RES_OK;
+ }
+
+ Result IndicatorPresenter::createBatteryLayout()
+ {
+ m_batteryLayout = Layout::Builder().
+ setTheme(impl::LAYOUT_BATTERY).
+ build(*m_widget);
+ if (!m_batteryLayout) {
+ LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+ }
+ m_widget->setContent(*m_batteryLayout, impl::PART_SWL_BATTERY);
+
+ updateBatteryState();
+
+ return RES_OK;
+ }
+
+ Result IndicatorPresenter::createVoiceControlLayout()
+ {
+ m_voiceControlLayout = Layout::Builder().
+ setTheme(impl::LAYOUT_VOICE_CONTROL).
+ build(*m_widget);
+ if (!m_voiceControlLayout) {
+ LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+ }
+
+ m_widget->setContent(*m_voiceControlLayout, impl::PART_SWL_VOICE_CONTROL);
+
+ return RES_OK;
+ }
+
+ Result IndicatorPresenter::createSimLayout()
+ {
+ m_simLayout = Layout::Builder().
+ setTheme(impl::LAYOUT_SIM).
+ build(*m_widget);
+ if (!m_simLayout) {
+ LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+ }
+ m_widget->setContent(*m_simLayout, impl::PART_SWL_SIM);
+
+ updateSimState();
+
+ return RES_OK;
+ }
+
+ Result IndicatorPresenter::createHdVoiceLayout()
+ {
+ m_hdCallLayout = Layout::Builder().
+ setTheme(impl::LAYOUT_HD_CALL).
+ build(*m_widget);
+ if (!m_hdCallLayout) {
+ LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+ }
+
+ m_widget->setContent(*m_hdCallLayout, impl::PART_SWL_HD_VOICE);
+
+ updateHdVoiceState();
+
+ return RES_OK;
+ }
+
+ void IndicatorPresenter::updateConnectionState()
+ {
+ auto state = m_provider->getState(IndicatorProperty::NW_CONNECTION);
+
+ m_connLayout->emit(impl::getConnUpdateSignal(
+ getConnectionState(state)));
+
+ m_connLayout->emit(impl::getPacketUpdateSignal(
+ getPacketDirection(state)));
+ }
+
+ void IndicatorPresenter::updateRssiState()
+ {
+ auto state = m_provider->getState(IndicatorProperty::RSSI);
+
+ m_rssiLayout->emit(impl::getRssiUpdateSignal(
+ getRssiState(state),
+ getRoamingState(state)));
+ }
+
+ void IndicatorPresenter::updateBatteryState()
+ {
+ auto state = m_provider->getState(IndicatorProperty::BATTERY);
+ auto battState = getBatteryState(state);
+ auto battLvl = getBatteryLevel(state);
+
+ m_batteryLayout->emit(
+ impl::getBatteryStateUpdateSignal(battState, battLvl));
+ m_batteryLayout->emit(
+ impl::getBatteryLevelUpdateSignal(battLvl,
+ (battState == BatteryState::UNKNOWN)));
+ }
+
+ void IndicatorPresenter::updateSimState()
+ {
+ auto state = m_provider->getState(IndicatorProperty::SIM_SLOT);
+
+ m_simLayout->emit(impl::getSimSlotUpdateSignal(
+ getSimSlotType(state),
+ getSimForwardState(state)));
+ }
+
+ void IndicatorPresenter::updateHdVoiceState()
+ {
+ auto state = m_provider->getState(IndicatorProperty::HD_VOICE);
+ m_hdCallLayout->emit(EdjeSignal{
+ (getHDVoiceState(state) ? "hd_voice_show" : "hd_voice_hide")});
+ }
+
+ Widget &IndicatorPresenter::getWidget()
+ {
+ return *m_widget;
+ }
+
+ void IndicatorPresenter::udapteIncomingCallMode(bool isIncomingCallMode)
+ {
+ if (m_isIncomingCallMode == isIncomingCallMode) {
+ return;
+ }
+ m_isIncomingCallMode = isIncomingCallMode;
+ updateCentralIcon();
+ }
+
+ void IndicatorPresenter::updateCentralIcon()
+ {
+ if (m_isIncomingCallMode) {
+ auto state = m_provider->getState(
+ IndicatorProperty::VOICE_CONTROL);
+
+ if (getVoiceControlState(state)) {
+ m_widget->setContent(*m_voiceControlLayout,
+ impl::PART_SWL_VOICE_CONTROL);
+ show(*m_voiceControlLayout);
+
+ m_widget->unsetContent(impl::PART_SWL_BATTERY);
+ hide(*m_batteryLayout);
+ return;
+ }
+ }
+ m_widget->unsetContent(impl::PART_SWL_VOICE_CONTROL);
+ hide(*m_voiceControlLayout);
+
+ m_widget->setContent(*m_batteryLayout,
+ impl::PART_SWL_BATTERY);
+ show(*m_batteryLayout);
+ }
+
+ void IndicatorPresenter::onStateChanged(IndicatorProperty property)
+ {
+ switch (property) {
+ case IndicatorProperty::NW_CONNECTION:
+ updateConnectionState();
+ break;
+ case IndicatorProperty::RSSI:
+ updateRssiState();
+ break;
+ case IndicatorProperty::BATTERY:
+ updateBatteryState();
+ break;
+ case IndicatorProperty::VOICE_CONTROL:
+ updateCentralIcon();
+ break;
+ case IndicatorProperty::SIM_SLOT:
+ updateSimState();
+ break;
+ case IndicatorProperty::HD_VOICE:
+ updateHdVoiceState();
+ break;
+ default:
+ ELOG("Unhandled state");
+ return;
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_MISC_MISC_INDICATOR_PRESENTER_H__
+#define __CALL_UI_PRESENTERS_MISC_MISC_INDICATOR_PRESENTER_H__
+
+#include "ucl/mvp/GuiPresenter.h"
+
+#include "ucl/gui/Layout.h"
+#include "ucl/gui/StyledWidget.h"
+
+#include "call-ui/model/IIndicatorStateProvider.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(IndicatorPresenter);
+
+ class IndicatorPresenter final : public ucl::GuiPresenter,
+ public IIndicatorStateListener {
+ public:
+ class Builder {
+ public:
+ Builder();
+ ~Builder();
+ Builder &setIndicatorStateProvider(
+ const IIndicatorStateProviderSRef &provider);
+ Builder &setParentWidget(const ucl::ElmWidgetSRef
+ &parentWidget);
+ IndicatorPresenterSRef build(ucl::GuiPresenter &parent) const;
+ private:
+ IIndicatorStateProviderSRef m_provider;
+ ucl::ElmWidgetSRef m_parentWidget;
+ };
+
+ public:
+ virtual ~IndicatorPresenter();
+
+ ucl::Widget &getWidget();
+
+ void udapteIncomingCallMode(bool isIncomingCallMode);
+
+ private:
+ friend class ucl::ReffedObj<IndicatorPresenter>;
+ IndicatorPresenter(ucl::IRefCountObj &rc,
+ const IIndicatorStateProviderSRef &provider);
+
+ ucl::Result prepare(ucl::GuiPresenter &parent, ucl::ElmWidget &parentWidget);
+
+ ucl::Result createWidget(ucl::ElmWidget &parent);
+ ucl::Result createConnectionLayout();
+ ucl::Result createRssiLayout();
+ ucl::Result createBatteryLayout();
+ ucl::Result createVoiceControlLayout();
+ ucl::Result createSimLayout();
+ ucl::Result createHdVoiceLayout();
+
+ void updateConnectionState();
+ void updateRssiState();
+ void updateBatteryState();
+ void updateSimState();
+ void updateHdVoiceState();
+
+ void updateCentralIcon();
+
+ // IIndicatorStateListener
+
+ virtual void onStateChanged(IndicatorProperty property) override final;
+
+ private:
+ ucl::LayoutSRef m_widget;
+ ucl::LayoutSRef m_connLayout;
+ ucl::LayoutSRef m_rssiLayout;
+ ucl::LayoutSRef m_batteryLayout;
+ ucl::LayoutSRef m_simLayout;
+ ucl::LayoutSRef m_hdCallLayout;
+ ucl::LayoutSRef m_voiceControlLayout;
+ IIndicatorStateProviderSRef m_provider;
+ bool m_isIncomingCallMode;
+ };
+
+ ucl::EdjeSignal getConnectionSignal(ConnectionType type);
+}
+
+#endif // __CALL_UI_PRESENTERS_MISC_MISC_INDICATOR_PRESENTER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "MoreOptionsPresenter.h"
+
+#include <app_control.h>
+
+#include "ucl/appfw/types.h"
+
+#include "call-ui/presenters/pages/KeypadPage.h"
+
+#include "call-ui/resources.h"
+#include "common.h"
+
+namespace callui { namespace { namespace impl {
+
+ using namespace ucl;
+
+ constexpr auto CALL_DURATION_TIMER_INTERVAL = 0.1;
+
+ constexpr LayoutTheme LAYOUT_DRAWER_PANEL
+ {"layout", "drawer", "panel"};
+
+ constexpr LayoutTheme LAYOUT_MORE_OPTION_WIDGET
+ {"layout", "callui", "more_option"};
+
+ constexpr EdjePart PART_SWL_RIGHT {"elm.swallow.right"};
+
+ constexpr ElmStyle STYLE_BTN_SWAP {"callui/swap"};
+ constexpr ElmStyle STYLE_BTN_UNHOLD {"callui/unhold"};
+ constexpr ElmStyle STYLE_BTN_KEYPAD {"callui/keypad"};
+
+ constexpr EdjePart PART_SWL_SLOT1 {"swl.slot.1"};
+ constexpr EdjePart PART_SWL_SLOT2 {"swl.slot.2"};
+ constexpr EdjePart PART_TXT_STATUS {"txt.status"};
+
+ constexpr EdjePart PART_AO_TXT_STATUS {"ao_txt.status"};
+
+ constexpr EdjePart PART_ACCESS {"access"};
+
+ constexpr EdjeSignal SIGNAL_ODD {"odd"};
+ constexpr EdjeSignal SIGNAL_EVEN {"even"};
+
+ constexpr EdjeSignalSrc SIGNAL_SRC_MORE_OPTION {"more_option"};
+
+}}}
+
+namespace callui {
+
+ using namespace ucl;
+
+ // MoreOptionsPresenter::Builder
+
+ MoreOptionsPresenter::Builder::Builder()
+ {
+ }
+
+ MoreOptionsPresenter::Builder &
+ MoreOptionsPresenter::Builder::setCallManager(const ICallManagerSRef &cm)
+ {
+ m_cm = cm;
+ return *this;
+ }
+
+ MoreOptionsPresenter::Builder &
+ MoreOptionsPresenter::Builder::setSoundManager(const ISoundManagerSRef &sm)
+ {
+ m_sm = sm;
+ return *this;
+ }
+
+ MoreOptionsPresenter::Builder &
+ MoreOptionsPresenter::Builder::setNaviframe(const NaviframeSRef &navi)
+ {
+ m_navi = navi;
+ return *this;
+ }
+
+ MoreOptionsPresenter::Builder &
+ MoreOptionsPresenter::Builder::setParentWidget(
+ const ElmWidgetSRef &parentWidget)
+ {
+ m_parentWidget = parentWidget;
+ return *this;
+ }
+
+ MoreOptionsPresenterSRef
+ MoreOptionsPresenter::Builder::build(GuiPresenter &parent) const
+ {
+ if (!m_cm || !m_sm || !m_navi || !m_parentWidget) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "Main params are not set");
+ }
+
+ auto result = makeShared<MoreOptionsPresenter>(m_cm, m_sm, m_navi);
+ FAIL_RETURN_VALUE(result->prepare(parent, *m_parentWidget), {},
+ "result->prepare() failed!");
+
+ return result;
+ }
+
+ // MoreOptionsPresenter
+
+ MoreOptionsPresenter::MoreOptionsPresenter(IRefCountObj &rc,
+ const ICallManagerSRef &cm,
+ const ISoundManagerSRef &sm,
+ const NaviframeSRef &navi):
+ GuiPresenter(rc),
+ m_cm(cm),
+ m_sm(sm),
+ m_navi(navi),
+ m_timer(nullptr)
+ {
+ }
+
+ MoreOptionsPresenter::~MoreOptionsPresenter()
+ {
+ stopCallDurationTimer();
+
+ if (m_widget) {
+ eext_object_event_callback_del(*m_widget, EEXT_CALLBACK_BACK,
+ CALLBACK_A(MoreOptionsPresenter::onBackKey));
+
+ sendActivate(*m_widget);
+ }
+
+ if (const auto keypad = m_keypad.lock()) {
+ keypad->exitNoTransition();
+ }
+ }
+
+ Result MoreOptionsPresenter::prepare(GuiPresenter &parent,
+ ElmWidget &parentWidget)
+ {
+ FAIL_RETURN(GuiPresenter::prepare(parent, PF_DEACTIVATOR),
+ "Presenter::prepare() failed!");
+
+ FAIL_RETURN(createWidget(parentWidget), "createWidget() failed!");
+
+ FAIL_RETURN(createPanel(), "createPanel() failed!");
+
+ FAIL_RETURN(createPanelLayout(), "createPanelContent() failed!");
+
+ FAIL_RETURN(createAccessObjects(), "createStaticAo() failed!");
+
+ updateComponents();
+
+ FAIL_RETURN(createAtspiHighlightHelper(), "createAtspiHighlightHelper() failed!");
+
+ deactivateBy(m_widget.get());
+
+ parent.addDeactivatorSource(*m_widget);
+
+ return RES_OK;
+ }
+
+ Result MoreOptionsPresenter::createWidget(ElmWidget &parent)
+ {
+ m_widget = Layout::Builder().
+ setTheme(impl::LAYOUT_DRAWER_PANEL).
+ setIsOwner(true).
+ build(parent);
+
+ if (!m_widget) {
+ LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+ }
+
+ return RES_OK;
+ }
+
+ void MoreOptionsPresenter::onCueClicked(Evas_Object *obj,
+ const char *emission,
+ const char *source)
+ {
+ show(*m_fakeAo);
+ m_panel->setContent(*m_panelLy);
+ show(*m_panelLy);
+
+ createStatusTxtAo();
+ if (m_statusTxtAo) {
+ m_atspiHelper->registerWidget(*m_statusTxtAo);
+ }
+ }
+
+ Result MoreOptionsPresenter::createPanel()
+ {
+ auto *eo = elm_panel_add(*m_widget);
+ if (!eo) {
+ LOG_RETURN(RES_FAIL, "elm_panel_add() failed!");
+ }
+ m_panel = makeShared<StyledWidget>(eo, true);
+ elm_panel_orient_set(*m_panel, ELM_PANEL_ORIENT_RIGHT);
+ show(*m_panel);
+
+ m_widget->setContent(*m_panel, impl::PART_SWL_RIGHT);
+
+ elm_panel_toggle(*m_panel);
+
+ elm_layout_signal_callback_add(*m_panel, "elm,state,active,finished",
+ "elm", CALLBACK_A(MoreOptionsPresenter::onPanelActivate), this);
+
+ elm_layout_signal_callback_add(*m_panel, "elm,state,inactive,finished",
+ "elm", CALLBACK_A(MoreOptionsPresenter::onPanelInactivate), this);
+
+ setDeactivatorSink(m_panel);
+
+ elm_layout_signal_callback_add(*m_panel, "cue,clicked",
+ "elm", CALLBACK_A(MoreOptionsPresenter::onCueClicked), this);
+
+ return RES_OK;
+ }
+
+ Result MoreOptionsPresenter::createPanelLayout()
+ {
+ m_panelLy = Layout::Builder().
+ setTheme(impl::LAYOUT_MORE_OPTION_WIDGET).
+ build(*m_panel);
+ if (!m_panelLy) {
+ LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+ }
+ show(*m_panelLy);
+ m_panel->setContent(*m_panelLy);
+
+ return RES_OK;
+ }
+
+ void MoreOptionsPresenter::updateSlots()
+ {
+ unsetPanelContent(impl::PART_SWL_SLOT1);
+ unsetPanelContent(impl::PART_SWL_SLOT2);
+
+ auto active = m_cm->getActiveCall();
+ auto held = m_cm->getHeldCall();
+
+ FAIL_RETURN_VOID(createKeypadButton(),
+ "createKeypadButton() failed");
+
+ if (held) {
+ m_panelLy->emit(impl::SIGNAL_EVEN, impl::SIGNAL_SRC_MORE_OPTION);
+
+ if (active) {
+ FAIL_RETURN_VOID(createSwapButton(),
+ "createSwapButton() failed");
+ setPanelContent(*m_btnSwap, impl::PART_SWL_SLOT1);
+ } else {
+ FAIL_RETURN_VOID(createUnholdButton(),
+ "createUnholdButton() failed");
+ setPanelContent(*m_btnUnhold, impl::PART_SWL_SLOT1);
+ }
+ setPanelContent(*m_btnKeypad, impl::PART_SWL_SLOT2);
+ } else {
+ m_panelLy->emit(impl::SIGNAL_ODD, impl::SIGNAL_SRC_MORE_OPTION);
+
+ setPanelContent(*m_btnKeypad, impl::PART_SWL_SLOT1);
+ }
+ }
+
+ Result MoreOptionsPresenter::createSwapButton()
+ {
+ m_btnSwap = createButton(impl::STYLE_BTN_SWAP, STR_MORE_SWAP,
+ WEAK_DELEGATE(MoreOptionsPresenter::onSwapBtnClick,
+ asWeak(*this)));
+ if (!m_btnSwap) {
+ LOG_RETURN(RES_FAIL, "Create Swap button failed!");
+ }
+
+ return RES_OK;
+ }
+
+ Result MoreOptionsPresenter::createUnholdButton()
+ {
+ m_btnUnhold = createButton(impl::STYLE_BTN_UNHOLD, STR_MORE_UNHOLD,
+ WEAK_DELEGATE(MoreOptionsPresenter::onUnholdBtnClick,
+ asWeak(*this)));
+ if (!m_btnUnhold) {
+ LOG_RETURN(RES_FAIL, "Create Unhold button failed!");
+ }
+
+ return RES_OK;
+ }
+
+ Result MoreOptionsPresenter::createKeypadButton()
+ {
+ m_btnKeypad = createButton(impl::STYLE_BTN_KEYPAD, STR_MORE_KEYPAD,
+ WEAK_DELEGATE(MoreOptionsPresenter::onKeypadBtnClick,
+ asWeak(*this)));
+ if (!m_btnKeypad) {
+ LOG_RETURN(RES_FAIL, "Create Keypad button failed!");
+ }
+
+ return RES_OK;
+ }
+
+ void MoreOptionsPresenter::onSwapBtnClick(Widget &sender, void *eventInfo)
+ {
+ auto held = m_cm->getHeldCall();
+ if (!held) {
+ LOG_RETURN_VOID(RES_FAIL, "Held call is NULL");
+ }
+ FAIL_RETURN_VOID(held->swapWithActive(), "swapWithActive() failed");
+ }
+
+ void MoreOptionsPresenter::onUnholdBtnClick(Widget &sender, void *eventInfo)
+ {
+ auto held = m_cm->getHeldCall();
+ if (!held) {
+ LOG_RETURN_VOID(RES_FAIL, "Held call is NULL");
+ }
+ FAIL_RETURN_VOID(held->unhold(), "unhold() failed");
+ }
+
+ void MoreOptionsPresenter::onKeypadBtnClick(Widget &sender, void *eventInfo)
+ {
+ KeypadPage::Builder builder;
+ if (m_navi) {
+ builder.setNaviframe(m_navi);
+ } else {
+ LOG_RETURN_VOID(RES_FAIL, "Naviframe is NULL");
+ }
+ m_keypad = builder.setSoundManager(m_sm)
+ .build(WEAK_DELEGATE(
+ MoreOptionsPresenter::onPageExitRequest,
+ asWeak(*this)));
+ }
+
+ void MoreOptionsPresenter::onPageExitRequest(Page &page)
+ {
+ m_keypad.reset();
+ page.exit();
+ }
+
+ StyledWidgetSRef MoreOptionsPresenter::createButton(
+ const ElmStyle &style,
+ const TString &txt,
+ const WidgetEventHandler &handler)
+ {
+ auto *eo = elm_button_add(*m_panelLy);
+ if (!eo) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "elm_button_add() failed!");
+ }
+ auto btn = makeShared<StyledWidget>(eo, true);
+ btn->setStyle(style);
+ btn->setText(txt);
+ btn->addEventHandler(BTN_CLICKED, handler);
+ hide(*btn);
+
+ btn->bindToEo();
+
+ return btn;
+ }
+
+ Widget &MoreOptionsPresenter::getWidget()
+ {
+ return *m_widget;
+ }
+
+ void MoreOptionsPresenter::update()
+ {
+ updateComponents();
+ }
+
+ void MoreOptionsPresenter::updateComponents()
+ {
+ updateSlots();
+ updateStatusText();
+ }
+
+ void MoreOptionsPresenter::onPanelActivate(Evas_Object *obj,
+ const char *emission,
+ const char *source)
+ {
+ eext_object_event_callback_add(*m_widget, EEXT_CALLBACK_BACK,
+ CALLBACK_A(MoreOptionsPresenter::onBackKey), this);
+
+ const auto keepAliver = asShared(*this);
+ sendDeactivate(*m_widget);
+ activateBy(m_widget.get());
+
+ elm_atspi_component_highlight_grab(*m_fakeAo);
+ }
+
+ void MoreOptionsPresenter::onPanelInactivate(Evas_Object *obj,
+ const char *emission,
+ const char *source)
+ {
+ eext_object_event_callback_del(*m_widget, EEXT_CALLBACK_BACK,
+ CALLBACK_A(MoreOptionsPresenter::onBackKey));
+
+ const auto keepAliver = asShared(*this);
+ deactivateBy(m_widget.get());
+ sendActivate(*m_widget);
+
+ m_panel->unsetContent();
+ hide(*m_panelLy);
+ m_statusTxtAo.reset();
+
+ elm_atspi_accessible_can_highlight_set(*m_cueAo, EINA_TRUE);
+ hide(*m_fakeAo);
+ }
+
+ void MoreOptionsPresenter::onBackKey(Evas_Object *obj, void *eventInfo)
+ {
+ if (isActive() && !elm_panel_hidden_get(*m_panel)) {
+ elm_panel_toggle(*m_panel);
+ }
+ }
+
+ void MoreOptionsPresenter::updateStatusText()
+ {
+ m_panelLy->setText("", impl::PART_TXT_STATUS);
+
+ auto active = m_cm->getActiveCall();
+ auto held = m_cm->getHeldCall();
+
+ if (held && !active) {
+ m_panelLy->setText(STR_ON_HOLD, impl::PART_TXT_STATUS);
+ } else if (active) {
+ if (active->isDialingMode()) {
+ m_panelLy->setText(STR_DIALING_CALL, impl::PART_TXT_STATUS);
+ return;
+ }
+ auto info = active->getInfo();
+ if (!info) {
+ LOG_RETURN_VOID(RES_FAIL, "Call Info is NULL");
+ }
+ m_info = info;
+ m_duration = info->getDuration();
+ auto temp = getCallDuration(m_duration);
+ m_panelLy->setText(temp, impl::PART_TXT_STATUS);
+
+ FAIL_RETURN_VOID(startCallDurationTimer(), "startTimer() failed!");
+
+ } else {
+ LOG_RETURN_VOID(RES_FAIL, "Undefined state");
+ }
+ }
+
+ Eina_Bool MoreOptionsPresenter::onCallDurationTimerCb()
+ {
+ const auto info = m_info.lock();
+ if (!info) {
+ m_timer = nullptr;
+ LOG_RETURN_VALUE(RES_FAIL, ECORE_CALLBACK_CANCEL, "m_info is NULL");
+ }
+
+ struct tm tmp = info->getDuration();
+ tryUpdateCallDurationTime(
+ m_duration,
+ tmp,
+ *m_panelLy,
+ impl::PART_TXT_STATUS);
+
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ Result MoreOptionsPresenter::startCallDurationTimer()
+ {
+ stopCallDurationTimer();
+
+ m_timer = ecore_timer_add(impl::CALL_DURATION_TIMER_INTERVAL,
+ CALLBACK_B(MoreOptionsPresenter::onCallDurationTimerCb),
+ this);
+
+ if (!m_timer) {
+ LOG_RETURN(RES_FAIL, "m_timer is NULL");
+ }
+
+ return RES_OK;
+ }
+
+ void MoreOptionsPresenter::stopCallDurationTimer()
+ {
+ if (m_timer) {
+ ecore_timer_del(m_timer);
+ m_timer = nullptr;
+ }
+ }
+
+ void MoreOptionsPresenter::unsetPanelContent(const EdjePart &part)
+ {
+ auto *eo = m_panelLy->unsetContent(part);
+ if (eo) {
+ hide(*asWidget(eo));
+ }
+ }
+
+ void MoreOptionsPresenter::setPanelContent(StyledWidget &widget, const EdjePart &part)
+ {
+ m_panelLy->setContent(widget, part);
+ show(widget);
+ }
+
+ // Screen Reader
+ Result MoreOptionsPresenter::createAtspiHighlightHelper()
+ {
+ DLOG("ENTER");
+ m_atspiHelper = AtspiHighlightHelper::newInstance(*this, getWindow());
+ if (!m_atspiHelper) {
+ LOG_RETURN(RES_FAIL,
+ "AtspiHighlightHelper::newInstance() failed!");
+ }
+
+ m_atspiHelper->setRelationEventHandler(WEAK_DELEGATE(
+ MoreOptionsPresenter::onAtspiHighlight, asWeak(*this)));
+
+ if (m_panelLy) {
+ m_atspiHelper->registerWidget(*m_fakeAo);
+ }
+
+ if (m_panelLy) {
+ m_atspiHelper->registerWidget(*m_panelLy);
+ }
+
+ if (m_btnSwap) {
+ m_atspiHelper->registerWidget(*m_btnSwap);
+ }
+
+ if (m_btnUnhold) {
+ m_atspiHelper->registerWidget(*m_btnUnhold);
+ }
+
+ if (m_btnKeypad) {
+ m_atspiHelper->registerWidget(*m_btnKeypad);
+ }
+
+ if (m_statusTxtAo) {
+ m_atspiHelper->registerWidget(*m_statusTxtAo);
+ }
+ DLOG("EXIT");
+ return RES_OK;
+ }
+
+ Elm_Interface_Atspi_Accessible *MoreOptionsPresenter::onAtspiHighlight(
+ Elm_Interface_Atspi_Accessible *ao,
+ Elm_Atspi_Relation_Type flowRelation)
+ {
+ DLOG("FlowRelation [%s]",
+ flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM ?
+ "FROM" :
+ "TO");
+
+ if (m_btnSwap && ao == *m_btnSwap) {
+ DLOG("Swap button");
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return *m_btnKeypad;
+ }
+ } else if (m_btnUnhold && ao == *m_btnUnhold) {
+ DLOG("Unhold button");
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return *m_btnKeypad;
+ }
+ } else if (ao == *m_btnKeypad) {
+ DLOG("Keypad button");
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return *m_statusTxtAo;
+ } else {
+ if (m_btnSwap) {
+ return *m_btnSwap;
+ } else if (m_btnUnhold) {
+ return *m_btnUnhold;
+ }
+ }
+ } else if (ao == *m_statusTxtAo) {
+ DLOG("Status text");
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
+ return *m_btnKeypad;
+ }
+ } else if (ao == getWindow() || ao == *m_fakeAo) {
+ DLOG("window or panelLy");
+ if (m_btnSwap) {
+ return *m_btnSwap;
+ } else if (m_btnUnhold) {
+ return *m_btnUnhold;
+ } else {
+ return *m_btnKeypad;
+ }
+ } else {
+ LOG_RETURN_VALUE(RES_FAIL, nullptr, "Unknown object!");
+ }
+
+ return ao;
+ }
+
+ Result MoreOptionsPresenter::createAccessObjects()
+ {
+ FAIL_RETURN(createCueAo(), "createCueAo() failed");
+ FAIL_RETURN(createStatusTxtAo(), "createStatusTxtAo() failed");
+ FAIL_RETURN(createFakeAo(), "createFakeAo() failed");
+
+ return RES_OK;
+ }
+
+ Result MoreOptionsPresenter::createCueAo()
+ {
+ m_cueAo = utils::createAccessObjectFromLyPart(*m_widget,
+ *m_panel,
+ impl::PART_ACCESS);
+ if (!m_cueAo) {
+ LOG_RETURN(RES_FAIL,
+ "createAccessObjectFromLyPart() failed!");
+ }
+ elm_access_action_cb_set(*m_cueAo,
+ ELM_ACCESS_ACTION_ACTIVATE,
+ CALLBACK_A(MoreOptionsPresenter::onCueAoActionCb),
+ this);
+
+ elm_atspi_accessible_translation_domain_set(*m_cueAo, PACKAGE);
+ elm_atspi_accessible_reading_info_type_set(*m_cueAo,
+ ELM_ACCESSIBLE_READING_INFO_TYPE_NAME |
+ ELM_ACCESSIBLE_READING_INFO_TYPE_ROLE);
+ elm_atspi_accessible_name_set(*m_cueAo, AO_STR_MORE_OPTIONS);
+ elm_atspi_accessible_role_set(*m_cueAo, ELM_ATSPI_ROLE_PUSH_BUTTON);
+
+ return RES_OK;
+ }
+
+ ElmWidget *MoreOptionsPresenter::getCueAo()
+ {
+ return m_cueAo.get();
+ }
+
+ Result MoreOptionsPresenter::createFakeAo()
+ {
+ m_fakeAo = utils::createFakeAccessObject(*m_panel);
+ if (!m_fakeAo) {
+ LOG_RETURN(RES_FAIL, "createFakeAccessObject() failed!");
+ }
+
+ return RES_OK;
+ }
+
+ Result MoreOptionsPresenter::createStatusTxtAo()
+ {
+ m_statusTxtAo = utils::createAccessObjectFromLyPart(*m_widget,
+ *m_panelLy,
+ impl::PART_AO_TXT_STATUS);
+ if (!m_statusTxtAo) {
+ LOG_RETURN(RES_FAIL,
+ "createAccessObjectFromLyPart() failed!");
+ }
+
+ elm_atspi_accessible_reading_info_type_set(*m_statusTxtAo,
+ ELM_ACCESSIBLE_READING_INFO_TYPE_NAME);
+ elm_atspi_accessible_name_cb_set(*m_statusTxtAo,
+ [](void *data, Evas_Object *obj) -> char *
+ {
+ auto self = static_cast<MoreOptionsPresenter *>(data);
+ if (!self) {
+ return nullptr;
+ }
+ auto txt = self->m_panelLy->
+ getText(impl::PART_TXT_STATUS).getCStr();
+ return (txt) ? strdup(txt) : nullptr;
+ },
+ this);
+
+ return RES_OK;
+ }
+
+ Eina_Bool MoreOptionsPresenter::onCueAoActionCb(Evas_Object *obj,
+ Elm_Access_Action_Info *actionInfo)
+ {
+ switch (actionInfo->action_type) {
+ case ELM_ACCESS_ACTION_ACTIVATE:
+
+ show(*m_fakeAo);
+ m_panel->setContent(*m_panelLy);
+ show(*m_panelLy);
+ createStatusTxtAo();
+ if (m_statusTxtAo) {
+ m_atspiHelper->registerWidget(*m_statusTxtAo);
+ }
+
+ elm_panel_toggle(*m_panel);
+ elm_atspi_component_highlight_clear(*m_cueAo);
+ elm_atspi_accessible_can_highlight_set(*m_cueAo, EINA_FALSE);
+
+ return EINA_TRUE;
+ break;
+ default:
+ break;
+ }
+
+ return EINA_FALSE;
+ }
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_MISC_MORE_OPTIONS_PRESENTER_H__
+#define __CALL_UI_PRESENTERS_MISC_MORE_OPTIONS_PRESENTER_H__
+
+#include "ucl/mvp/GuiPresenter.h"
+
+#include "ucl/gui/Layout.h"
+#include "ucl/gui/Naviframe.h"
+
+#include "call-ui/model/ICallManager.h"
+#include "call-ui/model/ISoundManager.h"
+#include "call-ui/presenters/base/Page.h"
+#include "AtspiHighlightHelper.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(MoreOptionsPresenter);
+
+ class MoreOptionsPresenter final : public ucl::GuiPresenter {
+ public:
+ class Builder {
+ public:
+ Builder();
+ Builder &setCallManager(const ICallManagerSRef &cm);
+ Builder &setSoundManager(const ISoundManagerSRef &sm);
+ Builder &setNaviframe(const ucl::NaviframeSRef &navi);
+ Builder &setParentWidget(const ucl::ElmWidgetSRef &parentWidget);
+ MoreOptionsPresenterSRef build(ucl::GuiPresenter &parent) const;
+
+ private:
+ ICallManagerSRef m_cm;
+ ISoundManagerSRef m_sm;
+ ucl::NaviframeSRef m_navi;
+ ucl::ElmWidgetSRef m_parentWidget;
+ };
+
+ public:
+ ucl::Widget &getWidget();
+ void update();
+
+ // Screen Reader
+ ucl::ElmWidget *getCueAo();
+
+ private:
+ friend class ucl::ReffedObj<MoreOptionsPresenter>;
+ MoreOptionsPresenter(ucl::IRefCountObj &rc,
+ const ICallManagerSRef &cm,
+ const ISoundManagerSRef &sm,
+ const ucl::NaviframeSRef &navi);
+ virtual ~MoreOptionsPresenter();
+
+ ucl::Result prepare(ucl::GuiPresenter &parent,
+ ucl::ElmWidget &parentWidget);
+
+ void updateComponents();
+
+ ucl::Result createWidget(ucl::ElmWidget &parent);
+ ucl::Result createPanel();
+ ucl::Result createPanelLayout();
+
+ ucl::Result createSwapButton();
+ ucl::Result createUnholdButton();
+ ucl::Result createKeypadButton();
+
+ ucl::StyledWidgetSRef createButton(const ucl::ElmStyle &style,
+ const ucl::TString &txt,
+ const ucl::WidgetEventHandler &handler);
+
+ void updateSlots();
+ void updateStatusText();
+
+ void onSwapBtnClick(ucl::Widget &sender, void *eventInfo);
+ void onUnholdBtnClick(ucl::Widget &sender, void *eventInfo);
+ void onKeypadBtnClick(ucl::Widget &sender, void *eventInfo);
+
+ void onBackKey(Evas_Object *obj, void *eventInfo);
+
+ void onPanelActivate(Evas_Object *obj,
+ const char *emission,
+ const char *source);
+ void onPanelInactivate(Evas_Object *obj,
+ const char *emission,
+ const char *source);
+ void onCueClicked(Evas_Object *obj,
+ const char *emission,
+ const char *source);
+
+ ucl::Result startCallDurationTimer();
+ void stopCallDurationTimer();
+ Eina_Bool onCallDurationTimerCb();
+
+ void unsetPanelContent(const ucl::EdjePart &part);
+ void setPanelContent(ucl::StyledWidget &widget,
+ const ucl::EdjePart &part);
+
+ void onPageExitRequest(Page &page);
+
+ // Screen Reader
+ ucl::Result createAccessObjects();
+ ucl::Result createCueAo();
+ ucl::Result createStatusTxtAo();
+ ucl::Result createFakeAo();
+ ucl::Result createAtspiHighlightHelper();
+ Elm_Interface_Atspi_Accessible *onAtspiHighlight(
+ Elm_Interface_Atspi_Accessible *ao,
+ Elm_Atspi_Relation_Type flowRelation);
+ Eina_Bool onCueAoActionCb(Evas_Object *obj,
+ Elm_Access_Action_Info *actionInfo);
+
+ private:
+ ucl::LayoutSRef m_widget;
+ ucl::StyledWidgetSRef m_panel;
+ ucl::LayoutSRef m_panelLy;
+ ucl::StyledWidgetSRef m_btnSwap;
+ ucl::StyledWidgetSRef m_btnUnhold;
+ ucl::StyledWidgetSRef m_btnKeypad;
+
+ PageWRef m_keypad;
+ ICallManagerSRef m_cm;
+ ISoundManagerSRef m_sm;
+ ucl::NaviframeSRef m_navi;
+ ICallInfoWCRef m_info;
+
+ Ecore_Timer *m_timer;
+ struct tm m_duration;
+
+ // Screen Reader
+ AtspiHighlightHelperSRef m_atspiHelper;
+ ucl::ElmWidgetSRef m_fakeAo;
+ ucl::ElmWidgetSRef m_cueAo;
+ ucl::ElmWidgetSRef m_statusTxtAo;
+ };
+}
+
+#endif // __CALL_UI_PRESENTERS_MISC_MORE_OPTIONS_PRESENTER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "MotionSensorPresenter.h"
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ MotionSensorPresenter::Builder::Builder()
+ {
+ }
+
+ MotionSensorPresenter::Builder::~Builder()
+ {
+ }
+
+ MotionSensorPresenterSRef
+ MotionSensorPresenter::Builder::build(
+ const NotiHandler handler) const
+ {
+ auto result = makeShared<MotionSensorPresenter>(handler);
+ FAIL_RETURN_VALUE(result->prepare(),
+ {}, "result->prepare() failed!");
+ return result;
+ }
+
+ MotionSensorPresenter::MotionSensorPresenter(
+ const NotiHandler &handler):
+ m_handler(handler),
+ m_gesture(nullptr)
+ {
+ }
+
+ MotionSensorPresenter::~MotionSensorPresenter()
+ {
+ if (m_gesture) {
+ gesture_stop_recognition(m_gesture);
+ gesture_release(m_gesture);
+ }
+ }
+
+ Result MotionSensorPresenter::prepare()
+ {
+ int res = gesture_create(&m_gesture);
+ if (res != GESTURE_ERROR_NONE) {
+ LOG_RETURN(RES_FAIL, "gesture_create() failed. "
+ "res[%d] msg[%s]", res, get_error_message(res));
+ }
+
+ res = gesture_start_recognition(m_gesture, GESTURE_WRIST_UP,
+ GESTURE_OPTION_ALWAYS_ON,
+ CALLBACK_B(MotionSensorPresenter::onGestureCb),
+ this);
+ if (res != GESTURE_ERROR_NONE) {
+ LOG_RETURN(RES_FAIL, "gesture_start_recognition() failed. "
+ "res[%d] msg[%s]", res, get_error_message(res));
+ }
+ return RES_OK;
+ }
+
+ void MotionSensorPresenter::onGestureCb(gesture_type_e motion,
+ const gesture_data_h data,
+ double timeStamp,
+ gesture_error_e error)
+ {
+ if (error) {
+ LOG_RETURN_VOID(RES_FAIL, "Error occured. "
+ "err[%d] msg[%s]", error, get_error_message(error));
+ }
+
+ if (motion == GESTURE_WRIST_UP) {
+ gesture_event_e event;
+ int res = gesture_get_event(data, &event);
+ if (res != GESTURE_ERROR_NONE) {
+ LOG_RETURN_VOID(RES_FAIL, "gesture_get_event() failed. "
+ "err[%d] msg[%s]", res, get_error_message(res));
+ }
+
+ if (event == GESTURE_EVENT_DETECTED && m_handler) {
+ m_handler();
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_MISC_MOTION_SENSOR_PRESENTER_H__
+#define __CALL_UI_PRESENTERS_MISC_MOTION_SENSOR_PRESENTER_H__
+
+#include <gesture_recognition.h>
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(MotionSensorPresenter);
+
+ class MotionSensorPresenter final {
+ public:
+ class Builder {
+ public:
+ Builder();
+ ~Builder();
+ MotionSensorPresenterSRef build(const NotiHandler handler) const;
+ };
+ private:
+ friend class ucl::ReffedObj<MotionSensorPresenter>;
+ MotionSensorPresenter(const NotiHandler &handler);
+ virtual ~MotionSensorPresenter();
+
+ ucl::Result prepare();
+
+ void onGestureCb(gesture_type_e motion,
+ const gesture_data_h data,
+ double timeStamp,
+ gesture_error_e error);
+
+ private:
+ NotiHandler m_handler;
+ gesture_h m_gesture;
+ };
+
+}
+
+#endif // __CALL_UI_PRESENTERS_MISC_MOTION_SENSOR_PRESENTER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "RejectMsgPresenter.h"
+
+#include "call-ui/resources.h"
+#include "common.h"
+
+namespace callui { namespace { namespace impl {
+
+ using namespace ucl;
+
+ const int ALPHA_CHANNEL_MAX = 255;
+
+ constexpr LayoutTheme LAYOUT_DRAWER_PANEL
+ {"layout", "drawer", "panel"};
+
+ constexpr LayoutTheme LAYOUT_RM_PANEL_CONTENT
+ {"layout", "callui", "rm_panel_content"};
+
+ constexpr EdjePart PART_SWL_RIGHT {"elm.swallow.right"};
+ constexpr EdjePart PART_SWL_BG {"elm.swallow.bg"};
+
+ constexpr EdjePart PART_SWL_CONTENT {"swl.content"};
+ constexpr EdjePart PART_SWL_SCROLLER {"swl.scroller"};
+
+ constexpr SmartEvent EVENT_SCROLL {"scroll"};
+
+}}}
+
+namespace callui {
+
+ using namespace ucl;
+
+ class RejectMsgPresenter::RejectMsgItem : public NonCopyable {
+ public:
+ RejectMsgItem(const IRejectMsgSRef &rm):
+ m_rm(rm)
+ {
+ }
+
+ virtual ~RejectMsgItem()
+ {
+ }
+
+ std::string getDisplayText() const
+ {
+ auto trnsTxt = TString{m_rm->getText(), true}.translate();
+
+ auto markupTxt = elm_entry_utf8_to_markup(trnsTxt);
+ std::string resStr(markupTxt);
+ replaceSubstringInString(resStr, "<br/>", " ");
+ free(markupTxt);
+
+ return resStr;
+ }
+
+ IRejectMsgSRef getRejectMsg() const
+ {
+ return m_rm;
+ }
+
+ private:
+ IRejectMsgSRef m_rm;
+ };
+
+ RejectMsgPresenter::Builder::Builder()
+ {
+ }
+
+ RejectMsgPresenter::Builder::~Builder()
+ {
+ }
+
+ RejectMsgPresenter::Builder &
+ RejectMsgPresenter::Builder::setProvider(
+ const IRejectMsgProviderSRef &provider)
+ {
+ m_provider = provider;
+ return *this;
+ }
+
+ RejectMsgPresenter::Builder &
+ RejectMsgPresenter::Builder::setStateHandler(
+ const StateHandler &handler)
+ {
+ m_stateHandler = handler;
+ return *this;
+ }
+
+ RejectMsgPresenter::Builder &
+ RejectMsgPresenter::Builder::setSelectHandler(
+ const SelectHandler &handler)
+ {
+ m_selectHandler = handler;
+ return *this;
+ }
+
+ RejectMsgPresenter::Builder &
+ RejectMsgPresenter::Builder::setParentWidget(
+ const ElmWidgetSRef &parentWidget)
+ {
+ m_parentWidget = parentWidget;
+ return *this;
+ }
+
+ RejectMsgPresenterSRef
+ RejectMsgPresenter::Builder::build(GuiPresenter &parent) const
+ {
+ if (!m_provider || !m_parentWidget) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "Main params are not set");
+ }
+
+ auto result = makeShared<RejectMsgPresenter>(m_provider,
+ m_stateHandler,
+ m_selectHandler);
+ FAIL_RETURN_VALUE(result->prepare(parent, *m_parentWidget), {},
+ "result->prepare() failed!");
+
+ return result;
+ }
+
+ RejectMsgPresenter::RejectMsgPresenter(IRefCountObj &rc,
+ const IRejectMsgProviderSRef &provider,
+ const StateHandler &stateHandler,
+ const SelectHandler &selectHandler):
+ GuiPresenter(rc),
+ m_circleEo(nullptr),
+ m_provider(provider),
+ m_stateHandler(stateHandler),
+ m_selectHandler(selectHandler),
+ m_state(State::HIDDEN)
+ {
+ }
+
+ RejectMsgPresenter::~RejectMsgPresenter()
+ {
+ if (m_widget) {
+ sendActivate(*m_widget);
+ }
+ }
+
+ Result RejectMsgPresenter::prepare(GuiPresenter &parent,
+ ElmWidget &parentWidget)
+ {
+ FAIL_RETURN(GuiPresenter::prepare(parent, PF_DEACTIVATOR),
+ "Presenter::prepare() failed!");
+
+ FAIL_RETURN(createWidget(parentWidget),
+ "createWidget() failed!");
+
+ FAIL_RETURN(createPanel(),
+ "createPanel() failed!");
+
+ FAIL_RETURN(createPanelBg(),
+ "createPanelBg() failed!");
+
+ FAIL_RETURN(createPanelLy(),
+ "createPanelLy() failed!");
+
+ FAIL_RETURN(createAtspiHighlightHelper(),
+ "createScreenReaderRoute() failed!");
+
+ deactivateBy(m_widget.get());
+
+ parent.addDeactivatorSource(*m_widget);
+
+ return RES_OK;
+ }
+
+ Result RejectMsgPresenter::createWidget(ElmWidget &parent)
+ {
+ m_widget = Layout::Builder().
+ setTheme(impl::LAYOUT_DRAWER_PANEL).
+ setIsOwner(true).
+ build(parent);
+
+ if (!m_widget) {
+ LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+ }
+
+ eext_object_event_callback_add(m_widget->getEo(), EEXT_CALLBACK_BACK,
+ CALLBACK_A(RejectMsgPresenter::onBackKey), this);
+
+ return RES_OK;
+ }
+
+ void RejectMsgPresenter::onBackKey(Evas_Object *obj, void *eventInfo)
+ {
+ if (isActive()) {
+ hidePanel();
+ }
+ }
+
+ void RejectMsgPresenter::panelScrollCb(Widget &widget, void *eventInfo)
+ {
+ Elm_Panel_Scroll_Info *ev = static_cast<Elm_Panel_Scroll_Info *>(eventInfo);
+ DLOG("pos x[%f] y[%f]", ev->rel_x, ev->rel_y);
+ auto prevState = m_state;
+
+ if (ev->rel_y == 1.0) {
+ m_state = State::SHOWN;
+ // Prevent panel scrolling
+ elm_object_scroll_freeze_push(m_panel->getEo());
+ } else if (ev->rel_y == 0.0) {
+ m_state = State::HIDDEN;
+ m_genlist.reset();
+ } else {
+ if (!m_genlist) {
+ FAIL_RETURN_VOID(createGenlist(),
+ "createGenlist() failed!");
+ }
+
+ m_state = State::IN_TRANSITION;
+ const auto alphaValue =
+ static_cast<int>(impl::ALPHA_CHANNEL_MAX * ev->rel_y);
+ m_panelBg->setColor(0, alphaValue);
+ }
+
+ if (prevState != m_state) {
+ if (m_state == State::SHOWN) {
+ activateBy(m_widget.get());
+ } else {
+ deactivateBy(m_widget.get());
+ }
+
+ if (m_state == State::HIDDEN) {
+ sendActivate(*m_widget);
+ } else {
+ sendDeactivate(*m_widget);
+ }
+
+ if (m_stateHandler) {
+ m_stateHandler(m_state);
+ }
+ }
+ }
+
+ Result RejectMsgPresenter::createPanel()
+ {
+ m_panel = makeShared<StyledWidget>(elm_panel_add(*m_widget), true);
+ if (!m_panel) {
+ LOG_RETURN(RES_FAIL, "elm_panel_add() failed!");
+ }
+ elm_panel_scrollable_set(*m_panel, EINA_TRUE);
+ elm_panel_scrollable_content_size_set(*m_panel, 1.0);
+ elm_panel_hidden_set(*m_panel, EINA_TRUE);
+ elm_panel_orient_set(*m_panel, ELM_PANEL_ORIENT_BOTTOM);
+ show(*m_panel);
+
+ m_panel->addEventHandler(impl::EVENT_SCROLL,
+ WEAK_DELEGATE(RejectMsgPresenter::panelScrollCb,
+ asWeak(*this)));
+
+ m_widget->setContent(*m_panel, impl::PART_SWL_RIGHT);
+
+ setDeactivatorSink(m_panel);
+
+ return RES_OK;
+ }
+
+ Result RejectMsgPresenter::createPanelBg()
+ {
+ m_panelBg = makeShared<ElmWidget>(
+ evas_object_rectangle_add(evas_object_evas_get(*m_widget)));
+ if (!m_panelBg) {
+ LOG_RETURN(RES_FAIL, "evas_object_rectangle_add() failed!");
+ }
+ m_panelBg->setColor(0, 0);
+ show(*m_panelBg);
+
+ m_widget->setContent(m_panelBg->getEo(), impl::PART_SWL_BG);
+
+ return RES_OK;
+ }
+
+ Result RejectMsgPresenter::createPanelLy()
+ {
+ m_panelLy = Layout::Builder().
+ setTheme(impl::LAYOUT_RM_PANEL_CONTENT).
+ setIsOwner(true).
+ build(*m_panel);
+ if (!m_panelLy) {
+ LOG_RETURN(RES_FAIL, "Layout::build failed!");
+ }
+ m_panel->setContent(*m_panelLy);
+
+ return RES_OK;
+ }
+
+ Result RejectMsgPresenter::createGenlist()
+ {
+ // Genlist scroller Layout
+ auto circlLy = Layout::Builder().build(*m_panelLy);
+ if (!circlLy) {
+ LOG_RETURN(RES_FAIL, "Layout::build failed!");
+ }
+ // Circular surface
+ Eext_Circle_Surface *const circleSurf =
+ eext_circle_surface_layout_add(*circlLy);
+ if (!circleSurf) {
+ LOG_RETURN(RES_FAIL, "eext_circle_surface_layout_add() failed!");
+ }
+ // Genlist
+ Evas_Object *const glEo = elm_genlist_add(*m_panelLy);
+ if (!glEo) {
+ LOG_RETURN(RES_FAIL, "elm_genlist_add() failed!");
+ }
+ elm_genlist_mode_set(glEo, ELM_LIST_COMPRESS);
+ elm_genlist_homogeneous_set(glEo, EINA_TRUE);
+
+ m_genlist = makeShared<StyledWidget>(glEo, true);
+ m_genlist->setWeight(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ m_genlist->setAlign(EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ m_circleEo = eext_circle_object_genlist_add(m_genlist->getEo(),
+ circleSurf);
+ if (!m_circleEo) {
+ LOG_RETURN(RES_FAIL, "elm_genlist_add() failed!");
+ }
+ eext_circle_object_genlist_scroller_policy_set(m_circleEo,
+ ELM_SCROLLER_POLICY_OFF,
+ ELM_SCROLLER_POLICY_AUTO);
+ deactivateRotary();
+
+ FAIL_RETURN(fillGenlist(), "fillGenlist() failed!");
+
+ m_panelLy->setContent(*circlLy, impl::PART_SWL_SCROLLER);
+
+ m_panelLy->setContent(*m_genlist, impl::PART_SWL_CONTENT);
+
+ registerGenlistAtspiGestureCallbacks();
+
+ return RES_OK;
+ }
+
+ Result RejectMsgPresenter::fillGenlist()
+ {
+ FAIL_RETURN(addGenlistTitleItem(), "addGenlistTitleItem() failed!");
+
+ auto msgList = m_provider->getMsgList();
+ for (auto &iter : msgList) {
+ FAIL_RETURN(addGenlistTextItem(iter), "addGenlistTextItem() failed!");
+ }
+
+ FAIL_RETURN(addGenlistBottomItem(), "addGenlistBottomItem() failed!");
+
+ return RES_OK;
+ }
+
+ Result RejectMsgPresenter::addGenlistTitleItem()
+ {
+ static auto titleItc = utils::createGenlistItemClass("title",
+ [](void *data, Evas_Object *obj, const char *part) -> char * {
+ return strdup(STR_DECLINE_MESSAGES.translate());
+ });
+
+ auto *item = elm_genlist_item_append(*m_genlist, &titleItc,
+ nullptr,
+ nullptr,
+ ELM_GENLIST_ITEM_NONE,
+ nullptr,
+ nullptr);
+ if (!item) {
+ LOG_RETURN(RES_FAIL, "elm_genlist_item_append() failed!");
+ }
+
+ return RES_OK;
+ }
+
+ Result RejectMsgPresenter::addGenlistTextItem(const IRejectMsgSRef &rm)
+ {
+ static auto textItc = utils::createGenlistItemClass("1text.1icon",
+ [](void *data, Evas_Object *obj, const char *part) -> char * {
+ if (!data) {
+ LOG_RETURN_VALUE(RES_FAIL, nullptr, "Data is NULL");
+ }
+ RejectMsgItem *rm = static_cast<RejectMsgItem *>(data);
+ return strdup(rm->getDisplayText().c_str());
+ },
+ nullptr,
+ nullptr,
+ [](void *data, Evas_Object *obj) -> void {
+ RejectMsgItem *rm = static_cast<RejectMsgItem *>(data);
+ delete rm;
+ });
+
+ auto *rmItem = new RejectMsgItem(rm);
+ if (!rmItem) {
+ LOG_RETURN(RES_FAIL, "Create RejectMsgItem failed!");
+ }
+
+ auto *item = elm_genlist_item_append(*m_genlist, &textItc,
+ static_cast<void *>(rmItem),
+ nullptr,
+ ELM_GENLIST_ITEM_NONE,
+ CALLBACK_A(RejectMsgPresenter::onGenlistItemClickedCb),
+ this);
+ if (!item) {
+ delete rmItem;
+ LOG_RETURN(RES_FAIL, "elm_genlist_item_append() failed!");
+ }
+
+ return RES_OK;
+ }
+
+ Result RejectMsgPresenter::addGenlistBottomItem()
+ {
+ static auto paddingItc = utils::createGenlistItemClass("1text.1icon");
+
+ auto *item = elm_genlist_item_append(*m_genlist, &paddingItc,
+ nullptr,
+ nullptr,
+ ELM_GENLIST_ITEM_NONE,
+ nullptr,
+ nullptr);
+ if (!item) {
+ LOG_RETURN(RES_FAIL, "elm_genlist_item_append() failed!");
+ }
+
+ return RES_OK;
+ }
+
+ void RejectMsgPresenter::handleSelectEvent(const RejectMsgItem &item)
+ {
+ if (m_selectHandler) {
+ m_selectHandler(item.getRejectMsg());
+ }
+ }
+
+ void RejectMsgPresenter::onGenlistItemClickedCb(Evas_Object *obj, void *eventInfo)
+ {
+ if (!eventInfo) {
+ LOG_RETURN_VOID(RES_FAIL, "eventInfo is NULL");
+ }
+
+ auto *item = static_cast<Elm_Object_Item *>(eventInfo);
+ auto *rmItem = static_cast<RejectMsgItem *>(
+ elm_object_item_data_get(item));
+
+ handleSelectEvent(*rmItem);
+ }
+
+ Widget &RejectMsgPresenter::getWidget()
+ {
+ return *m_widget;
+ }
+
+ RejectMsgPresenter::State RejectMsgPresenter::getState()
+ {
+ return m_state;
+ }
+
+ void RejectMsgPresenter::showPanel()
+ {
+ DLOG();
+ if (m_state != State::SHOWN) {
+ DLOG("Panel state [NOT SHOWN]");
+ elm_panel_hidden_set(m_panel->getEo(), EINA_FALSE);
+ }
+ }
+
+ void RejectMsgPresenter::hidePanel()
+ {
+ DLOG();
+ if (m_state == State::SHOWN) {
+ DLOG("Panel state [SHOWN]");
+ elm_object_scroll_freeze_pop(m_panel->getEo());
+ elm_panel_hidden_set(m_panel->getEo(), EINA_TRUE);
+ }
+ }
+
+ void RejectMsgPresenter::setStateHandler(
+ const RejectMsgPresenter::StateHandler &handler)
+ {
+ m_stateHandler = handler;
+ }
+
+ void RejectMsgPresenter::setSelectHandler(
+ const SelectHandler &handler)
+ {
+ m_selectHandler = handler;
+ }
+
+ void RejectMsgPresenter::onActivate()
+ {
+ DLOG();
+ activateRotary();
+ }
+
+ void RejectMsgPresenter::onDeactivate()
+ {
+ DLOG();
+ deactivateRotary();
+ }
+
+ void RejectMsgPresenter::activateRotary()
+ {
+ if (m_circleEo) {
+ eext_rotary_object_event_activated_set(m_circleEo, EINA_TRUE);
+ }
+ }
+
+ void RejectMsgPresenter::deactivateRotary()
+ {
+ if (m_circleEo) {
+ eext_rotary_object_event_activated_set(m_circleEo, EINA_FALSE);
+ }
+ }
+
+ // Screen Reader
+ Elm_Interface_Atspi_Accessible *RejectMsgPresenter::getFirstAo()
+ {
+ return (m_genlist) ?
+ elm_genlist_first_item_get(*m_genlist) :
+ nullptr;
+ }
+
+ Elm_Interface_Atspi_Accessible *RejectMsgPresenter::getLastAo()
+ {
+ return (m_genlist) ?
+ elm_genlist_last_item_get(*m_genlist) :
+ nullptr;
+ }
+
+ Result RejectMsgPresenter::createAtspiHighlightHelper()
+ {
+ m_atspiHelper = AtspiHighlightHelper::newInstance(*this, getWindow());
+ if (!m_atspiHelper) {
+ LOG_RETURN(RES_FAIL, "AtspiHighlightHelper::newInstance() failed!");
+ }
+
+ m_atspiHelper->setRelationEventHandler(WEAK_DELEGATE(
+ RejectMsgPresenter::onAtspiHighlight, asWeak(*this)));
+
+ return RES_OK;
+ }
+
+ void RejectMsgPresenter::registerGenlistAtspiGestureCallbacks()
+ {
+ auto item = getFirstAo();
+ elm_atspi_accessible_gesture_cb_set(item,
+ CALLBACK_A(RejectMsgPresenter::onAtspiGesture), this);
+
+ item = getLastAo();
+ elm_atspi_accessible_gesture_cb_set(item,
+ CALLBACK_A(RejectMsgPresenter::onAtspiGesture), this);
+ }
+
+ Elm_Interface_Atspi_Accessible *RejectMsgPresenter::onAtspiHighlight(
+ Elm_Interface_Atspi_Accessible *ao,
+ Elm_Atspi_Relation_Type flowRelation)
+ {
+ DLOG("ENTER");
+
+ DLOG("FlowRelation [%s]",
+ flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM ?
+ "FROM" :
+ "TO");
+
+ if (ao == getFirstAo()) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return nullptr;
+ }
+ } else if (ao == getLastAo()) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
+ return nullptr;
+ }
+ } else if (ao == getWindow()) {
+ return getFirstAo();
+ } else {
+ LOG_RETURN_VALUE(RES_FAIL, nullptr, "Unknown object!");
+ }
+ return ao;
+ }
+
+ Eina_Bool RejectMsgPresenter::onAtspiGesture(
+ Elm_Atspi_Gesture_Info gestureInfo,
+ Elm_Interface_Atspi_Accessible *ao)
+ {
+ return toEina(
+ m_atspiHelper->handleGesture(ao, gestureInfo));
+ }
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_MISC_REJECT_MESSAGE_PRESENTER_H__
+#define __CALL_UI_PRESENTERS_MISC_REJECT_MESSAGE_PRESENTER_H__
+
+#include "ucl/mvp/GuiPresenter.h"
+
+#include "ucl/gui/Layout.h"
+#include "ucl/gui/StyledWidget.h"
+
+#include "call-ui/model/IRejectMsgProvider.h"
+#include "AtspiHighlightHelper.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(RejectMsgPresenter);
+
+ class RejectMsgPresenter final : public ucl::GuiPresenter {
+ public:
+ enum class State {
+ HIDDEN,
+ IN_TRANSITION,
+ SHOWN
+ };
+ using StateHandler = ucl::WeakDelegate<void(State)>;
+ using SelectHandler = ucl::WeakDelegate<void(
+ const IRejectMsgSRef &rm)>;
+
+ public:
+ class Builder {
+ public:
+ Builder();
+ virtual ~Builder();
+ Builder &setProvider(const IRejectMsgProviderSRef &provider);
+ Builder &setStateHandler(const StateHandler &handler);
+ Builder &setSelectHandler(const SelectHandler &handler);
+ Builder &setParentWidget(const ucl::ElmWidgetSRef &parentWidget);
+ RejectMsgPresenterSRef build(ucl::GuiPresenter &parent) const;
+
+ private:
+ IRejectMsgProviderSRef m_provider;
+ StateHandler m_stateHandler;
+ SelectHandler m_selectHandler;
+ ucl::ElmWidgetSRef m_parentWidget;
+ };
+
+ public:
+ virtual ~RejectMsgPresenter();
+
+ ucl::Widget &getWidget();
+
+ State getState();
+
+ void showPanel();
+ void hidePanel();
+
+ void setStateHandler(const StateHandler &handler);
+ void setSelectHandler(const SelectHandler &handler);
+
+ private:
+ class RejectMsgItem;
+
+ private:
+ friend class ucl::ReffedObj<RejectMsgPresenter>;
+ RejectMsgPresenter(ucl::IRefCountObj &rc,
+ const IRejectMsgProviderSRef &provider,
+ const StateHandler &stateHandler,
+ const SelectHandler &selectHandler);
+
+ ucl::Result prepare(ucl::GuiPresenter &parent,
+ ucl::ElmWidget &parentWidget);
+
+ ucl::Result createWidget(ucl::ElmWidget &parent);
+ ucl::Result createPanel();
+ ucl::Result createPanelBg();
+ ucl::Result createPanelLy();
+ ucl::Result createGenlist();
+
+ ucl::Result fillGenlist();
+ ucl::Result addGenlistTitleItem();
+ ucl::Result addGenlistTextItem(const IRejectMsgSRef &rm);
+ ucl::Result addGenlistBottomItem();
+
+ void onGenlistItemClickedCb(Evas_Object *obj, void *eventInfo);
+ void handleSelectEvent(const RejectMsgItem &item);
+
+ void panelScrollCb(ucl::Widget &widget, void *eventInfo);
+
+ void activateRotary();
+ void deactivateRotary();
+
+ void onBackKey(Evas_Object *obj, void *eventInfo);
+
+ // Screen Reader
+ ucl::Result createAtspiHighlightHelper();
+ void registerGenlistAtspiGestureCallbacks();
+ Elm_Interface_Atspi_Accessible *getFirstAo();
+ Elm_Interface_Atspi_Accessible *getLastAo();
+ Eina_Bool onAtspiGesture(
+ Elm_Atspi_Gesture_Info gestureInfo,
+ Elm_Interface_Atspi_Accessible *ao);
+ Elm_Interface_Atspi_Accessible *onAtspiHighlight(
+ Elm_Interface_Atspi_Accessible *ao,
+ Elm_Atspi_Relation_Type flowRelation);
+
+ // Presenter
+
+ virtual void onActivate() final override;
+ virtual void onDeactivate() final override;
+
+ private:
+ ucl::LayoutSRef m_widget;
+ ucl::StyledWidgetSRef m_panel;
+ ucl::ElmWidgetSRef m_panelBg;
+ ucl::LayoutSRef m_panelLy;
+ ucl::StyledWidgetSRef m_genlist;
+ Evas_Object *m_circleEo;
+
+ IRejectMsgProviderSRef m_provider;
+ StateHandler m_stateHandler;
+ SelectHandler m_selectHandler;
+ State m_state;
+
+ // Screen Reader
+ AtspiHighlightHelperSRef m_atspiHelper;
+ };
+
+}
+
+#endif // __CALL_UI_PRESENTERS_MISC_REJECT_MESSAGE_PRESENTER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_MISC_MISC_COMMON_H__
+#define __CALL_UI_PRESENTERS_MISC_MISC_COMMON_H__
+
+#include "call-ui/presenters/common.h"
+
+#endif // __CALL_UI_PRESENTERS_MISC_MISC_COMMON_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "common.h"
+
+namespace callui { namespace { namespace himpl {
+
+ const TString STR_HH_MM_SS_TIME{"%02d:%02d:%02d"};
+ const TString STR_MM_SS_TIME{"%02d:%02d"};
+
+}}}
+
+namespace callui {
+
+ using namespace ucl;
+
+ void replaceSubstringInString(std::string &str,
+ const std::string &from, const std::string &to)
+ {
+ if (from.empty()) {
+ LOG_RETURN_VOID(RES_FAIL, "Parameter from is empty");
+ }
+
+ size_t start_pos = 0;
+ while((start_pos = str.find(from, start_pos)) != std::string::npos) {
+ str.replace(start_pos, from.length(), to);
+ start_pos += to.length();
+ }
+ }
+
+ TString getCallDuration(const struct tm &time)
+ {
+ TString tmp;
+ if (time.tm_hour > 0) {
+ tmp = himpl::STR_HH_MM_SS_TIME.format(time.tm_hour, time.tm_min, time.tm_sec);
+ } else {
+ tmp = himpl::STR_MM_SS_TIME.format(time.tm_min, time.tm_sec);
+ }
+ return tmp;
+ }
+
+ void tryUpdateCallDurationTime(
+ struct tm &curTime,
+ struct tm &compTime,
+ EdjeWidget &widget,
+ const EdjePart &part)
+ {
+ if ((compTime.tm_sec - curTime.tm_sec) != 0) {
+ curTime = compTime;
+ auto tmp = getCallDuration(curTime);
+ widget.setText(tmp, part);
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_MISC_HELPERS_H__
+#define __CALL_UI_PRESENTERS_MISC_HELPERS_H__
+
+#include <string>
+#include <time.h>
+
+#include "ucl/gui/EdjeWidget.h"
+#include "ucl/gui/types.h"
+
+namespace callui {
+
+ void replaceSubstringInString(std::string &str,
+ const std::string &from, const std::string &to);
+
+ ucl::TString getCallDuration(const struct tm &time);
+
+ void tryUpdateCallDurationTime(
+ struct tm &curTime, struct tm &compTime,
+ ucl::EdjeWidget &widget, const ucl::EdjePart &part);
+
+}
+
+#endif // __CALL_UI_PRESENTERS_MISC_HELPERS_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_MISC_TYPES_H__
+#define __CALL_UI_PRESENTERS_MISC_TYPES_H__
+
+#include "call-ui/model/types.h"
+
+namespace callui {
+
+ enum class CallMode {
+ UNDEFINED,
+ INCOMING,
+ OUTGOING,
+ DURING,
+ END
+ };
+}
+
+#endif // __CALL_UI_PRESENTERS_MISC_TYPES_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "KeypadPage.h"
+
+#include "call-ui/resources.h"
+#include "common.h"
+
+namespace callui { namespace { namespace impl {
+
+ using namespace ucl;
+
+ constexpr LayoutTheme LAYOUT_KEYPAD_WIDGET
+ {"layout", "callui", "keypad"};
+
+ constexpr EdjePart PART_SWL_ENTRY {"swl.entry"};
+
+ constexpr SmartEvent BTN_PRESSED {"pressed"};
+ constexpr SmartEvent BTN_UNPRESSED {"unpressed"};
+
+ constexpr EoDataKey BTN_DATA_KEY {"btnData"};
+
+ enum {
+ KEYPAD_BTN_MAX_COUNT = 13
+ };
+
+ enum class OperationType {
+ DTMF,
+ VOLUME
+ };
+
+ struct ButtonInfo {
+ OperationType type;
+ const char *str;
+ ElmStyle style;
+ EdjePart swlPart;
+ };
+
+ static ButtonInfo buttonsInfo[KEYPAD_BTN_MAX_COUNT] =
+ {
+ { OperationType::DTMF, "1",
+ ElmStyle {"callui/keypad_one"}, EdjePart {"swl.one"} },
+ { OperationType::DTMF, "2",
+ ElmStyle {"callui/keypad_two"}, EdjePart {"swl.two"} },
+ { OperationType::DTMF, "3",
+ ElmStyle {"callui/keypad_three"}, EdjePart {"swl.three"} },
+ { OperationType::DTMF, "4",
+ ElmStyle {"callui/keypad_four"}, EdjePart {"swl.four"} },
+ { OperationType::DTMF, "5",
+ ElmStyle {"callui/keypad_five"}, EdjePart {"swl.five"} },
+ { OperationType::DTMF, "6",
+ ElmStyle {"callui/keypad_six"}, EdjePart {"swl.six"} },
+ { OperationType::DTMF, "7",
+ ElmStyle {"callui/keypad_seven"}, EdjePart {"swl.seven"} },
+ { OperationType::DTMF, "8",
+ ElmStyle {"callui/keypad_eight"}, EdjePart {"swl.eight"} },
+ { OperationType::DTMF, "9",
+ ElmStyle {"callui/keypad_nine"}, EdjePart {"swl.nine"} },
+ { OperationType::DTMF, "0",
+ ElmStyle {"callui/keypad_zero"}, EdjePart {"swl.zero"} },
+ { OperationType::DTMF, "#",
+ ElmStyle {"callui/keypad_sharp"}, EdjePart {"swl.sharp"} },
+ { OperationType::DTMF, "*",
+ ElmStyle {"callui/keypad_asterix"}, EdjePart {"swl.asterix"} },
+ { OperationType::VOLUME, "",
+ ElmStyle {"callui/keypad_speaker"}, EdjePart {"swl.speaker"} }
+ };
+}}}
+
+namespace callui {
+ using namespace ucl;
+
+ // KeypadPage::Builder
+
+ KeypadPage::Builder::Builder()
+ {
+ }
+
+ KeypadPage::Builder::~Builder()
+ {
+ }
+
+ KeypadPage::Builder &KeypadPage::Builder::setNaviframe(
+ const NaviframeSRef &navi)
+ {
+ m_navi = navi;
+ return *this;
+ }
+
+ KeypadPage::Builder
+ &KeypadPage::Builder::setSoundManager(const ISoundManagerSRef &sm)
+ {
+ m_sm = sm;
+ return *this;
+ }
+
+ KeypadPageSRef KeypadPage::Builder::build(
+ const ExitRequestHandler onExitRequest) const
+ {
+ if (!onExitRequest) {
+ LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
+ "onExitRequest is NULL");
+ }
+ if (!m_navi) {
+ LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
+ "m_navi is NULL");
+ }
+
+ if (!m_sm) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "m_sm is NULL");
+ }
+
+ auto result = makeShared<KeypadPage>(m_sm, m_navi, onExitRequest);
+
+ FAIL_RETURN_VALUE(result->prepare([&result](NaviItem &item)
+ {
+ return result->doPrepare(item);
+ }),
+ {}, "result->prepare() failed!");
+
+ return result;
+ }
+
+ // KeypadPage
+
+ KeypadPage::KeypadPage(IRefCountObj &rc,
+ const ISoundManagerSRef &sm,
+ const NaviframeSRef &navi,
+ const ExitRequestHandler onExitRequest):
+ Page(rc, navi, onExitRequest),
+ m_sm(sm),
+ m_smInUse(false),
+ m_vcTimer(nullptr),
+ m_audioState(m_sm->getAudioState())
+ {
+ }
+
+ KeypadPage::~KeypadPage()
+ {
+ stopDtmf();
+ stopVCTimer();
+ unregisterCallbacks();
+ }
+
+ Result KeypadPage::doPrepare(NaviItem &item)
+ {
+ FAIL_RETURN(createWidget(), "createWidget() failed!");
+
+ FAIL_RETURN(createEntry(), "createEntry() failed!");
+
+ FAIL_RETURN(createButtons(), "createButtons() failed!");
+
+ FAIL_RETURN(createVolumeControl(), "createVolumeControl() failed!");
+
+ registerCallbacks();
+
+ updateVolume(m_sm->getVolume());
+
+ FAIL_RETURN(createAtspiHighlightHelper(),
+ "createAtspiHighlightHelper() failed!");
+
+ item = getNaviframe().push(*m_widget);
+ if (!item) {
+ LOG_RETURN(RES_FAIL, "Naviframe::push() failed!");
+ }
+
+ return RES_OK;
+ }
+
+ void KeypadPage::onBtnPressed(Widget &widget, void *eventInfo)
+ {
+ impl::ButtonInfo *info =
+ static_cast<impl::ButtonInfo*>(widget.getData(impl::BTN_DATA_KEY));
+ DLOG("Button pressed [%c]", *(info->str));
+
+ if (info->type == impl::OperationType::DTMF) {
+ elm_entry_entry_append(*m_entry, info->str);
+ elm_entry_cursor_end_set(*m_entry);
+ startDtmf(*(info->str));
+ }
+ }
+
+ void KeypadPage::onBtnUnpressed(Widget &widget, void *eventInfo)
+ {
+ impl::ButtonInfo *info =
+ static_cast<impl::ButtonInfo*>(widget.getData(impl::BTN_DATA_KEY));
+ DLOG("Button unpressed [%c]", *(info->str));
+ stopDtmf();
+ }
+
+ void KeypadPage::onBtnClicked(Widget &widget, void *eventInfo)
+ {
+ impl::ButtonInfo *info =
+ static_cast<impl::ButtonInfo*>(widget.getData(impl::BTN_DATA_KEY));
+
+ if(info->type == impl::OperationType::VOLUME) {
+ DLOG("Button clicked [volume]");
+ show(*m_vc);
+ startVCTimer();
+
+ elm_atspi_component_highlight_grab(*m_vc);
+ }
+ }
+
+ Result KeypadPage::createWidget()
+ {
+ m_widget = Layout::Builder().
+ setTheme(impl::LAYOUT_KEYPAD_WIDGET).
+ setIsOwner(true).
+ build(getNaviframe());
+
+ if (!m_widget) {
+ LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+ }
+
+ setDeactivatorSink(m_widget);
+
+ return RES_OK;
+ }
+
+ ucl::Result KeypadPage::createEntry()
+ {
+ Evas_Object *entry = elm_entry_add(*m_widget);
+ if (!entry) {
+ LOG_RETURN(RES_FAIL, "elm_entry_add() failed!");
+ }
+ m_entry = makeShared<ElmWidget>(entry, true);
+
+ static Elm_Entry_Filter_Accept_Set digitsFilterData;
+
+ digitsFilterData.accepted = "0123456789*#";
+ digitsFilterData.rejected = nullptr;
+
+ elm_entry_single_line_set(entry, EINA_TRUE);
+ elm_entry_editable_set(entry, EINA_FALSE);
+ elm_entry_scrollable_set(entry, EINA_TRUE);
+ elm_entry_markup_filter_append(entry,
+ elm_entry_filter_accept_set, &digitsFilterData);
+
+ m_widget->setContent(entry, impl::PART_SWL_ENTRY);
+ show(*m_entry);
+
+ return RES_OK;
+ }
+
+ ucl::Result KeypadPage::createButtons()
+ {
+ Evas_Object *button;
+ StyledWidgetSRef buttonSRef;
+
+ for (int i = 0; i < impl::KEYPAD_BTN_MAX_COUNT; ++i) {
+ button = elm_button_add(*m_widget);
+
+ if (!button) {
+ LOG_RETURN(RES_FAIL, "elm_button_add() failed!");
+ }
+
+ buttonSRef = makeShared<StyledWidget>(button);
+ buttonSRef->bindToEo();
+ buttonSRef->setData(impl::BTN_DATA_KEY, &(impl::buttonsInfo[i]));
+ buttonSRef->setStyle(impl::buttonsInfo[i].style);
+
+ if (impl::buttonsInfo[i].type == impl::OperationType::DTMF) {
+ buttonSRef->addEventHandler(impl::BTN_PRESSED,
+ WEAK_DELEGATE(KeypadPage::onBtnPressed,
+ asWeak(*this)));
+
+ buttonSRef->addEventHandler(impl::BTN_UNPRESSED,
+ WEAK_DELEGATE(KeypadPage::onBtnUnpressed,
+ asWeak(*this)));
+ } else {
+ buttonSRef->addEventHandler(BTN_CLICKED,
+ WEAK_DELEGATE(KeypadPage::onBtnClicked,
+ asWeak(*this)));
+ }
+
+ // Screen Reader
+ elm_atspi_accessible_name_cb_set(*buttonSRef,
+ [](void *data, Evas_Object *obj) -> char *
+ {
+ impl::ButtonInfo *info =
+ static_cast<impl::ButtonInfo*>(asWidget(obj)->
+ getData(impl::BTN_DATA_KEY));
+ if (info->type == impl::OperationType::DTMF) {
+ return strdup(info->str);
+ } else {
+ return strdup(AO_STR_VOLUME.translate());
+ }
+ return nullptr;
+ },
+ this);
+
+ m_widget->setContent(button, impl::buttonsInfo[i].swlPart);
+ show(*buttonSRef);
+ }
+
+ return RES_OK;
+ }
+
+ void KeypadPage::startDtmf(const unsigned char digit)
+ {
+ stopDtmf();
+ m_smInUse = true;
+ m_sm->startDtmf(digit);
+ }
+
+ void KeypadPage::stopDtmf()
+ {
+ if (m_smInUse) {
+ m_sm->stopDtmf();
+ m_smInUse = false;
+ }
+ }
+
+ Result KeypadPage::createVolumeControl()
+ {
+ m_vc = VolumeControl::Builder().
+ setInfoText(STR_VOLUME).
+ setMaxValue(m_sm->getMaxVolume()).
+ setEventHandler(WEAK_DELEGATE(
+ KeypadPage::onVolumeControlEventCb,
+ asWeak(*this))).
+ build(*m_widget);
+ if (!m_vc) {
+ LOG_RETURN(RES_FAIL, "VolumeControl::build() failed");
+ }
+
+ auto window = m_vc->getWindow();
+ if (!window) {
+ LOG_RETURN(RES_FAIL, "Window is NULL!");
+ }
+ int w = 0, h = 0;
+ window->getScreenSize(&w, &h);
+
+ m_vc->move(0, 0);
+ m_vc->resize(w, h);
+ hide(*m_vc);
+
+ registerVolumeControlAo();
+
+ return RES_OK;
+ }
+
+ void KeypadPage::onBackKey()
+ {
+ if (m_vcTimer) {
+ stopVCTimer();
+ hide(*m_vc);
+ } else {
+ requestExit();
+ }
+ }
+
+ void KeypadPage::onVolumeControlEventCb(VolumeControl::Event event)
+ {
+ if (!isActive()) {
+ LOG_RETURN_VOID(RES_OK, "Presenter is not active. Ignore");
+ }
+
+ if (!m_vcTimer) {
+ DLOG("Ignore as control is hidden");
+ return;
+ }
+
+ restartVCTimer();
+
+ switch (event) {
+ case VolumeControl::Event::INCREASE:
+ tryIncreaseVolume();
+ break;
+ case VolumeControl::Event::DECREASE:
+ tryDecreaseVolume();
+ break;
+ default:
+ break;
+ }
+ }
+
+ void KeypadPage::updateVolume(int value)
+ {
+ m_vc->setValue(value);
+
+ auto max = m_sm->getMaxVolume();
+ auto cur = m_sm->getVolume();
+
+ if (cur == max) {
+ m_vc->setIncreaseBtnEnable(false);
+ m_vc->setDecreaseBtnEnable(true);
+ } else if (cur <= VOLUME_LEVEL_MIN) {
+ m_vc->setIncreaseBtnEnable(true);
+ m_vc->setDecreaseBtnEnable(false);
+ } else {
+ m_vc->setIncreaseBtnEnable(true);
+ m_vc->setDecreaseBtnEnable(true);
+ }
+
+ // Screen Reader
+ if (m_vc->isVisible()) {
+ elm_atspi_bridge_utils_say(std::to_string(cur).c_str(),
+ EINA_FALSE, nullptr, nullptr);
+ }
+ }
+
+ void KeypadPage::onAudioStateChanged(AudioStateType state)
+ {
+ if ((m_audioState != AudioStateType::BT &&
+ state == AudioStateType::BT) ||
+ (m_audioState == AudioStateType::BT &&
+ state != AudioStateType::BT)) {
+ m_audioState = state;
+
+ m_vc->setValue(0);
+
+ auto maxVol = m_sm->getMaxVolume();
+ m_vc->setMaxValue(maxVol);
+
+ updateVolume(m_sm->getVolume());
+ }
+ }
+
+ void KeypadPage::onVolumeLevelChanged(int value)
+ {
+ updateVolume(value);
+ }
+
+ Eina_Bool KeypadPage::onVCTimerCb()
+ {
+ hide(*m_vc);
+ m_vcTimer = nullptr;
+
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ void KeypadPage::startVCTimer()
+ {
+ stopVCTimer();
+
+ auto timerInterval = CALL_VC_TIMER_INTERVAL;
+ if (elm_atspi_bridge_utils_is_screen_reader_enabled()) {
+ timerInterval = CALL_VC_SCREEN_READER_TIMER_INTERVAL;
+ }
+
+ m_vcTimer = ecore_timer_add(timerInterval,
+ CALLBACK_B(KeypadPage::onVCTimerCb),
+ this);
+ }
+
+ void KeypadPage::restartVCTimer()
+ {
+ if (m_vcTimer) {
+ ecore_timer_reset(m_vcTimer);
+ }
+ }
+
+ void KeypadPage::stopVCTimer()
+ {
+ if (m_vcTimer) {
+ ecore_timer_del(m_vcTimer);
+ m_vcTimer = nullptr;
+ }
+ }
+
+ void KeypadPage::tryIncreaseVolume()
+ {
+ auto max = m_sm->getMaxVolume();
+ auto cur = m_sm->getVolume();
+
+ if (max != cur) {
+ m_sm->setVolume(cur + 1);
+ }
+ }
+
+ void KeypadPage::tryDecreaseVolume()
+ {
+ auto cur = m_sm->getVolume();
+
+ if (cur - 1 >= VOLUME_LEVEL_MIN) {
+ m_sm->setVolume(cur - 1);
+ }
+ }
+
+ Eina_Bool KeypadPage::onRotaryEvent(Eext_Rotary_Event_Info *info)
+ {
+ if (!isActive()) {
+ LOG_RETURN_VALUE(RES_OK,
+ EINA_TRUE,
+ "Presenter is not active. Ignore");
+ }
+
+ if (!m_vcTimer) {
+ DLOG("Ignore as control is hidden");
+ return EINA_FALSE;
+ }
+
+ restartVCTimer();
+
+ if (info->direction == EEXT_ROTARY_DIRECTION_CLOCKWISE) {
+ tryIncreaseVolume();
+ } else {
+ tryDecreaseVolume();
+ }
+
+ return EINA_TRUE;
+ }
+
+ void KeypadPage::registerCallbacks()
+ {
+ addRotaryEventHandler(CALLBACK_A(
+ KeypadPage::onRotaryEvent), this);
+
+ m_sm->addAudioStateHandler(WEAK_DELEGATE(
+ KeypadPage::onAudioStateChanged, asWeak(*this)));
+
+ m_sm->addVolumeStateHandler(WEAK_DELEGATE(
+ KeypadPage::onVolumeLevelChanged, asWeak(*this)));
+ }
+
+ void KeypadPage::unregisterCallbacks()
+ {
+ delRotaryEventHandler(
+ CALLBACK_A(KeypadPage::onRotaryEvent), this);
+
+ m_sm->delAudioStateHandler(WEAK_DELEGATE(
+ KeypadPage::onAudioStateChanged, asWeak(*this)));
+
+ m_sm->delVolumeStateHandler(WEAK_DELEGATE(
+ KeypadPage::onVolumeLevelChanged, asWeak(*this)));
+ }
+
+ // Screen Reader
+ Result KeypadPage::createAtspiHighlightHelper()
+ {
+ m_atspiHelper = AtspiHighlightHelper::newInstance(*this, getWindow());
+ if (!m_atspiHelper) {
+ LOG_RETURN(RES_FAIL,
+ "AtspiHighlightHelper::newInstance() failed!");
+ }
+
+ m_atspiHelper->setRelationEventHandler(WEAK_DELEGATE(
+ KeypadPage::onAtspiHighlight, asWeak(*this)));
+
+ m_atspiHelper->registerWidget(*getFirstButton());
+ m_atspiHelper->registerWidget(*getLastButton());
+ m_atspiHelper->registerWidget(*m_vc.get());
+ m_atspiHelper->registerWidget(*m_vc->getDecreaseBtn());
+ m_atspiHelper->registerWidget(*m_vc->getIncreaseBtn());
+ m_atspiHelper->registerWidget(*m_vc->getValueTxtAo());
+
+ return RES_OK;
+ }
+
+ Elm_Interface_Atspi_Accessible *KeypadPage::onAtspiHighlight(
+ Elm_Interface_Atspi_Accessible *ao,
+ Elm_Atspi_Relation_Type flowRelation)
+ {
+ DLOG("FlowRelation [%s]",
+ flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM ?
+ "FROM" : "TO");
+
+ auto firstBtn = getFirstButton();
+ auto lastBtn = getLastButton();
+ auto vcLayout = m_vc.get();
+ auto vcDecrVolumeBtn = m_vc->getDecreaseBtn();
+ auto vcIncrVolumeBtn = m_vc->getIncreaseBtn();
+ auto vcVolumeValueAo = m_vc->getValueTxtAo();
+
+ if (ao == *firstBtn) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return nullptr;
+ }
+ } else if (ao == *lastBtn) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
+ return nullptr;
+ }
+ } else if (ao == *vcLayout) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return *vcDecrVolumeBtn;
+ }
+ } else if (ao == *vcDecrVolumeBtn) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return *vcVolumeValueAo;
+ } else {
+ return *vcLayout;
+ }
+ } else if (ao == *vcVolumeValueAo) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return *vcIncrVolumeBtn;
+ } else {
+ return *vcDecrVolumeBtn;
+ }
+ } else if (ao == *vcIncrVolumeBtn) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
+ return *vcVolumeValueAo;
+ }
+ } else if (ao == getWindow()) {
+ return *firstBtn;
+ } else {
+ LOG_RETURN_VALUE(RES_FAIL, nullptr, "Unknown object!");
+ }
+
+ return ao;
+ }
+
+ ElmWidget *KeypadPage::getFirstButton()
+ {
+ return dynamicWidgetCast<ElmWidget>(
+ m_widget->getContent(impl::buttonsInfo[0].swlPart));
+ }
+
+ ElmWidget *KeypadPage::getLastButton()
+ {
+ return dynamicWidgetCast<ElmWidget>(
+ m_widget->getContent(impl::buttonsInfo[(
+ impl::KEYPAD_BTN_MAX_COUNT - 1)].swlPart));
+ }
+
+ void KeypadPage::registerVolumeControlAo()
+ {
+ auto decrBtn = m_vc->getDecreaseBtn();
+
+ if (decrBtn) {
+ decrBtn->addEventHandler(ATSPI_HIGHLIGHTED,
+ WEAK_DELEGATE(KeypadPage::
+ onVolumeControlScreenReaderReadStart,
+ asWeak(*this)));
+ }
+
+ auto incrBtn = m_vc->getIncreaseBtn();
+ if (incrBtn) {
+ incrBtn->addEventHandler(ATSPI_HIGHLIGHTED,
+ WEAK_DELEGATE(KeypadPage::
+ onVolumeControlScreenReaderReadStart,
+ asWeak(*this)));
+ }
+ }
+
+ void KeypadPage::onVolumeControlScreenReaderReadStart(
+ Widget &widget,
+ void *eventInfo)
+ {
+ restartVCTimer();
+ }
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_PAGES_KEYPAD_PAGE_H__
+#define __CALL_UI_PRESENTERS_PAGES_KEYPAD_PAGE_H__
+
+#include "call-ui/presenters/base/Page.h"
+
+#include "ucl/gui/Layout.h"
+
+#include "call-ui/model/ISoundManager.h"
+#include "call-ui/view/VolumeControl.h"
+#include "call-ui/presenters/misc/AtspiHighlightHelper.h"
+
+#include "call-ui/presenters/misc/types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(KeypadPage);
+
+ class KeypadPage final : public Page {
+ public:
+ class Builder {
+ public:
+ Builder();
+ ~Builder();
+ Builder &setNaviframe(const ucl::NaviframeSRef &navi);
+ Builder &setSoundManager(const ISoundManagerSRef &sm);
+ KeypadPageSRef build(const ExitRequestHandler onExitRequest) const;
+ private:
+ ISoundManagerSRef m_sm;
+ ucl::NaviframeSRef m_navi;
+ };
+
+ private:
+ friend class ucl::ReffedObj<KeypadPage>;
+ KeypadPage(ucl::IRefCountObj &rc,
+ const ISoundManagerSRef &sm,
+ const ucl::NaviframeSRef &navi,
+ const ExitRequestHandler onExitRequest);
+ virtual ~KeypadPage();
+
+ ucl::Result doPrepare(ucl::NaviItem &item);
+
+ void onBtnPressed(ucl::Widget &widget, void *eventInfo);
+ void onBtnUnpressed(ucl::Widget &widget, void *eventInfo);
+ void onBtnClicked(ucl::Widget &widget, void *eventInfo);
+
+ ucl::Result createWidget();
+ ucl::Result createEntry();
+ ucl::Result createButtons();
+ ucl::Result createVolumeControl();
+
+ void startDtmf(const unsigned char digit);
+ void stopDtmf();
+
+ void onAudioStateChanged(AudioStateType state);
+ void onVolumeControlEventCb(VolumeControl::Event event);
+ Eina_Bool onVCTimerCb();
+ void startVCTimer();
+ void restartVCTimer();
+ void stopVCTimer();
+ void tryIncreaseVolume();
+ void tryDecreaseVolume();
+ void updateVolume(int value);
+ void onVolumeLevelChanged(int value);
+ Eina_Bool onRotaryEvent(Eext_Rotary_Event_Info *info);
+
+ void registerCallbacks();
+ void unregisterCallbacks();
+
+ // Screen Reader
+ ucl::Result createAtspiHighlightHelper();
+ Elm_Interface_Atspi_Accessible *onAtspiHighlight(
+ Elm_Interface_Atspi_Accessible *ao,
+ Elm_Atspi_Relation_Type flowRelation);
+ ucl::ElmWidget *getFirstButton();
+ ucl::ElmWidget *getLastButton();
+ void registerVolumeControlAo();
+ void onVolumeControlScreenReaderReadStart(
+ ucl::Widget &widget,
+ void *eventInfo);
+
+
+ // Page
+
+ virtual void onBackKey() override final;
+
+ private:
+ ucl::LayoutSRef m_widget;
+ ucl::ElmWidgetSRef m_entry;
+
+ ISoundManagerSRef m_sm;
+ bool m_smInUse;
+
+ VolumeControlSRef m_vc;
+ Ecore_Timer *m_vcTimer;
+
+ AudioStateType m_audioState;
+
+ // Screen Reader
+ AtspiHighlightHelperSRef m_atspiHelper;
+ };
+}
+
+#endif // __CALL_UI_PRESENTERS_PAGES_KEYPAD_PAGE_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "MainPage.h"
+
+#include "ucl/gui/Window.h"
+#include "ucl/gui/Widget.h"
+
+#include "call-ui/resources.h"
+#include "common.h"
+
+namespace callui { namespace { namespace impl {
+
+ using namespace ucl;
+
+ constexpr double CU_RECALL_BTN_SHOW_TIMEOUT = 1.0;
+ constexpr double CU_EXIT_APP_TIMEOUT = 4.0;
+
+ constexpr LayoutTheme LAYOUT_MAIN_WIDGET
+ {"layout", "callui", "main"};
+
+ constexpr LayoutTheme LAYOUT_REJECT_MSG_WIDGET
+ {"layout", "callui", "reject_msg"};
+
+ constexpr EdjePart PART_SWL_INDICATOR {"swl.indicator"};
+ constexpr EdjePart PART_SWL_ACCEPT_REJECT {"swl.accept_reject"};
+ constexpr EdjePart PART_SWL_CALL_INFO {"swl.call_info"};
+ constexpr EdjePart PART_SWL_REJECT_MSG {"swl.rm"};
+ constexpr EdjePart PART_SWL_BOTTOM_BTN {"swl.bottom_btn"};
+ constexpr EdjePart PART_SWL_OVERLAY {"swl.overlay"};
+ constexpr EdjePart PART_SWL_MORE_OPTION {"swl.more_option"};
+
+ constexpr EdjePart PART_TXT_REJECT_MSG_CUE_AO {"ao_cue"};
+
+ constexpr EdjePart PART_TXT_REJECT_MSG {"reject_msg_text"};
+ constexpr ElmStyle STYLE_BB_END_CALL {"callui/end_call"};
+ constexpr ElmStyle STYLE_BB_RECALL {"callui/call_back"};
+}}}
+
+namespace callui {
+
+ using namespace ucl;
+
+ // MainPage::Builder
+
+ MainPage::Builder::Builder()
+ {
+ }
+
+ MainPage::Builder::~Builder()
+ {
+ }
+
+ MainPage::Builder &MainPage::Builder::setNaviframe(
+ const NaviframeSRef &navi)
+ {
+ m_navi = navi;
+ return *this;
+ }
+
+ MainPage::Builder &MainPage::Builder::setCallUI(
+ const ICallUISRef &call)
+ {
+ m_call = call;
+ return *this;
+ }
+
+ MainPageSRef MainPage::Builder::build(
+ const ExitRequestHandler handler) const
+ {
+ if (!handler) {
+ LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
+ "onExitRequest is NULL");
+ }
+ if (!m_navi) {
+ LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
+ "m_navi is NULL");
+ }
+ if (!m_call) {
+ LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
+ "m_call is NULL");
+ }
+
+ auto result = makeShared<MainPage>(
+ m_navi, handler, m_call);
+
+ FAIL_RETURN_VALUE(result->prepare([&result](NaviItem &item)
+ {
+ return result->doPrepare(item);
+ }),
+ {}, "result->prepare() failed!");
+
+ return result;
+ }
+
+ // MainPage
+
+ MainPage::MainPage(IRefCountObj &rc,
+ const NaviframeSRef &navi,
+ const ExitRequestHandler handler,
+ const ICallUISRef &call) :
+ Page(rc, navi, handler),
+ m_call(call),
+ m_mode(CallMode::UNDEFINED),
+ m_ecTimer(nullptr),
+ m_ecTimerBtnReq(false)
+ {
+ }
+
+ MainPage::~MainPage()
+ {
+ }
+
+ Result MainPage::doPrepare(NaviItem &item)
+ {
+ m_cm = m_call->getCallManager();
+ if (!m_cm) {
+ LOG_RETURN(RES_FAIL, "Call manager is NULL!");
+ }
+
+ FAIL_RETURN(createWidget(), "createWidget() failed!");
+ FAIL_RETURN(createIndicatorPresenter(), "createIndicatorPresenter() failed!");
+ FAIL_RETURN(createDisplayPresenter(), "createDisplayPresenter() failed!");
+
+ auto win = m_widget->getWindow();
+ if (!win) {
+ LOG_RETURN(RES_FAIL, "win is NULL!");
+ }
+ win->addEventHandler(WIN_POWER_KEY_UP_EVENT, WEAK_DELEGATE(
+ MainPage::onPowerKeyUp, asWeak(*this)));
+
+ item = getNaviframe().push(*m_widget);
+ if (!item) {
+ LOG_RETURN(RES_FAIL, "Naviframe::push() failed!");
+ }
+
+ return RES_OK;
+ }
+
+ void MainPage::processKeyPress()
+ {
+ switch (m_mode) {
+ case CallMode::INCOMING:
+ {
+ auto incom = m_cm->getIncomingCall();
+ if (!incom) {
+ LOG_RETURN_VOID(RES_FAIL, "incom is NULL");
+ }
+ incom->stopAlert();
+ break;
+ }
+ case CallMode::END:
+ requestExit();
+ break;
+ default:
+ if (m_accessoryPrs) {
+ m_accessoryPrs->hideVolumeControls();
+ }
+ break;
+ }
+ }
+
+ void MainPage::onBackKey()
+ {
+ processKeyPress();
+ }
+
+ void MainPage::onPowerKeyUp(Widget &widget, void *eventInfo)
+ {
+ if (isActive()) {
+ processKeyPress();
+ }
+ }
+
+ Result MainPage::processIncomingCallMode()
+ {
+ m_accessoryPrs.reset();
+
+ auto call = m_cm->getIncomingCall();
+ if (!call) {
+ LOG_RETURN(RES_FAIL, "incom is NULL");
+ }
+
+ FAIL_RETURN(createAcceptRejectPresenter(),
+ "createAcceptRejectPresenter() failed!");
+
+ auto provider = call->getRejectMsgProvider();
+ if (!provider) {
+ ELOG("Reject message provider is NULL");
+ }
+
+ if (!isUnknownCaller(*call->getInfo())
+ && (provider && provider->getMsgCount() > 0)) {
+
+ FAIL_RETURN(createRejectMsgPresenter(provider),
+ "createRejectMsgPresenter() failed!");
+
+ FAIL_RETURN(createRejectMsgCue(),
+ "craeteRejectMsgCue() failed!");
+
+ if (createRejectMsgCueAo() != RES_OK) {
+ ELOG("createRejectMsgCueAo() failed!");
+ }
+ }
+
+ if (m_indicator) {
+ m_indicator->udapteIncomingCallMode(true);
+ }
+
+ return RES_OK;
+ }
+
+ Result MainPage::createRejectMsgCue()
+ {
+ m_rmLy = Layout::Builder().
+ setTheme(impl::LAYOUT_REJECT_MSG_WIDGET).
+ setIsOwner(true).
+ build(*m_widget);
+ if (!m_rmLy) {
+ LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+ }
+
+ m_rmLy->setText(STR_DECLINE_MESSAGES, impl::PART_TXT_REJECT_MSG);
+ m_widget->setContent(*m_rmLy, impl::PART_SWL_REJECT_MSG);
+
+ return RES_OK;
+ }
+
+ Result MainPage::processEndCallMode()
+ {
+ if (m_indicator) {
+ m_indicator->udapteIncomingCallMode(false);
+ }
+
+ FAIL_RETURN(createAccessoryPresenter(),
+ "createAccessoryPresenter() failed");
+
+
+ auto end = m_cm->getEndCall();
+ if (end) {
+ auto info = end->getInfo();
+ if (info && info->getConferenceMemberCount() == 1) {
+ FAIL_RETURN(createBottomBtn(impl::STYLE_BB_RECALL, false),
+ "createBottomBtn() failed");
+ hide(*m_bottomBtn);
+ }
+ } else {
+ ELOG("End call is NULL!");
+ }
+
+ startEndCallTimer();
+
+ return RES_OK;
+ }
+
+ Result MainPage::processRegularCallModes()
+ {
+ m_rmPrs.reset();
+ m_acceptRejectPrs.reset();
+ m_rmLy.reset();
+ m_rmCueAo.reset();
+
+ if (m_indicator) {
+ m_indicator->udapteIncomingCallMode(false);
+ }
+
+ FAIL_RETURN(createAccessoryPresenter(),
+ "createAccessoryPresenter() failed");
+ FAIL_RETURN(createMoreOptionsPresenter(),
+ "createMoreOptionsPresenter() failed");
+ FAIL_RETURN(createBottomBtn(impl::STYLE_BB_END_CALL),
+ "createBottomBtn() failed");
+
+ return RES_OK;
+ }
+
+ void MainPage::updateCallMode()
+ {
+ auto incom = m_cm->getIncomingCall();
+ auto active = m_cm->getActiveCall();
+ auto held = m_cm->getHeldCall();
+ auto end = m_cm->getEndCall();
+
+ m_mode = CallMode::UNDEFINED;
+
+ if (incom) {
+ DLOG("Mode [Incoming call]");
+ m_mode = CallMode::INCOMING;
+ } else if (active && active->isDialingMode()) {
+ DLOG("Mode [Outgoing call]");
+ m_mode = CallMode::OUTGOING;
+ } else if (active || held) {
+ DLOG("Mode [During call]");
+ m_mode = CallMode::DURING;
+ } else if (end) {
+ DLOG("Mode [End call]");
+ m_mode = CallMode::END;
+ } else {
+ DLOG("Mode [Undefined]");
+ }
+ }
+
+ Result MainPage::showWindow()
+ {
+ auto win = getNaviframe().getWindow();
+ if (!win) {
+ LOG_RETURN(RES_FAIL, "win is NULL");
+ }
+
+ if (!win->isVisible() &&
+ (m_mode == CallMode::INCOMING
+ || m_mode == CallMode::OUTGOING)) {
+ show(*win);
+ }
+ return RES_OK;
+ }
+
+ void MainPage::onBottomBtnClicked(Widget &widget, void *eventInfo)
+ {
+ auto active = m_cm->getActiveCall();
+ auto held = m_cm->getHeldCall();
+ auto end = m_cm->getEndCall();
+
+ if (active) {
+ active->end();
+ } else if (held) {
+ held->end();
+ } else if (end) {
+ stopEndCallTimer();
+ end->callBack();
+ }
+ }
+
+ void MainPage::startEndCallTimer()
+ {
+ stopEndCallTimer();
+
+ m_ecTimer = ecore_timer_add(
+ impl::CU_RECALL_BTN_SHOW_TIMEOUT,
+ CALLBACK_B(MainPage::onEndCallTimerCb),
+ this);
+ }
+
+ void MainPage::stopEndCallTimer()
+ {
+ m_ecTimerBtnReq = false;
+
+ if (m_ecTimer) {
+ ecore_timer_del(m_ecTimer);
+ m_ecTimer = nullptr;
+ }
+ }
+
+ Result MainPage::createBottomBtn(const ElmStyle &style, bool setVisible)
+ {
+ m_bottomBtn = makeShared<StyledWidget>(
+ elm_button_add(*m_widget), true);
+ m_bottomBtn->setStyle(style);
+
+ m_bottomBtn->addEventHandler(BTN_CLICKED,
+ WEAK_DELEGATE(MainPage::onBottomBtnClicked,
+ asWeak(*this)));
+
+ elm_atspi_accessible_translation_domain_set(*m_bottomBtn, PACKAGE);
+ if (style == impl::STYLE_BB_RECALL) {
+ elm_atspi_accessible_name_set(*m_bottomBtn, AO_STR_CALLBACK);
+ } else {
+ elm_atspi_accessible_name_set(*m_bottomBtn, AO_STR_END_CALL);
+ }
+
+ if (setVisible) {
+ m_widget->setContent(*m_bottomBtn, impl::PART_SWL_BOTTOM_BTN);
+ show(*m_bottomBtn);
+ } else {
+ hide(*m_bottomBtn);
+ }
+
+ return RES_OK;
+ }
+
+ Eina_Bool MainPage::onEndCallTimerCb()
+ {
+ if (!m_ecTimerBtnReq) {
+ if (!m_bottomBtn) {
+ m_ecTimer = nullptr;
+ requestExit();
+ LOG_RETURN_VALUE(RES_FAIL, ECORE_CALLBACK_CANCEL, "bottom button is NULL!");
+ }
+ m_widget->setContent(*m_bottomBtn, impl::PART_SWL_BOTTOM_BTN);
+ show(*m_bottomBtn);
+
+ ecore_timer_interval_set(m_ecTimer, impl::CU_EXIT_APP_TIMEOUT);
+ m_ecTimerBtnReq = true;
+
+ return ECORE_CALLBACK_RENEW;
+ } else {
+ m_ecTimer = nullptr;
+ requestExit();
+
+ return ECORE_CALLBACK_CANCEL;
+ }
+ }
+
+ void MainPage::onCallEvent(CallEventType type)
+ {
+ ILOG("CallEventType [%d]", static_cast<int>(type));
+
+ stopEndCallTimer();
+
+ CallMode prevMode = m_mode;
+ updateCallMode();
+
+ if (m_mode == CallMode::UNDEFINED) {
+ requestExit();
+ return;
+ }
+
+ FAIL_RETURN_VOID(showWindow(), "showWindow failed!");
+
+ m_acceptRejectPrs.reset();
+ m_rmPrs.reset();
+ m_moreOptionsPrs.reset();
+ m_callInfoPrs.reset();
+
+ m_rmLy.reset();
+ m_rmCueAo.reset();
+ m_bottomBtn.reset();
+
+ switch (m_mode) {
+ case CallMode::INCOMING:
+ FAIL_RETURN_VOID(processIncomingCallMode(),
+ "processIncomingCall() failed!");
+ break;
+ case CallMode::END:
+ FAIL_RETURN_VOID(processEndCallMode(),
+ "processEndCallMode() failed!");
+ break;
+ default:
+ FAIL_RETURN_VOID(processRegularCallModes(),
+ "processRegularCallModes() failed!");
+ break;
+ }
+
+ FAIL_RETURN_VOID(createCallInfoPresenter(m_mode),
+ "createCallInfoPresenter() failed!");
+
+ FAIL_RETURN_VOID(updateDeviceState(prevMode, m_mode),
+ "updateDeviceState() failed!");
+
+ createAtspiHighlightHelper();
+ }
+
+ Result MainPage::updateDeviceState(CallMode prevMode, CallMode curMode)
+ {
+ if (curMode == CallMode::INCOMING && curMode != prevMode) {
+ m_devicePrs->setDisplayState(
+ DeviceStatePresenter::DisplayState::ON);
+ m_devicePrs->setDisplayMode(
+ DeviceStatePresenter::DisplayMode::TOP_PRIORITY);
+ m_devicePrs->setCpuLockState(true);
+ } else if (prevMode == CallMode::INCOMING && prevMode != curMode) {
+ m_devicePrs->setDisplayMode(
+ DeviceStatePresenter::DisplayMode::REGULAR);
+ m_devicePrs->setCpuLockState(false);
+ }
+
+ if (curMode == CallMode::END) {
+ m_devicePrs->setDisplayState(
+ DeviceStatePresenter::DisplayState::ON);
+ }
+
+ return RES_OK;
+ }
+
+ Result MainPage::createWidget()
+ {
+ m_widget = Layout::Builder().
+ setTheme(impl::LAYOUT_MAIN_WIDGET).
+ setIsOwner(true).
+ build(getNaviframe());
+
+ if (!m_widget) {
+ LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+ }
+
+ setDeactivatorSink(m_widget);
+
+ return RES_OK;
+ }
+
+ Result MainPage::createIndicatorPresenter()
+ {
+ m_indicator = IndicatorPresenter::Builder().
+ setIndicatorStateProvider(
+ m_call->getIndicatorStateProvider()).
+ setParentWidget(m_widget).
+ build(*this);
+
+ if (!m_indicator) {
+ LOG_RETURN(RES_FAIL, "Indicator::build() failed!");
+ }
+
+ m_widget->setContent(m_indicator->getWidget(),
+ impl::PART_SWL_INDICATOR);
+
+ return RES_OK;
+ }
+
+ Result MainPage::createDisplayPresenter()
+ {
+ auto win = m_widget->getWindow();
+ if (!win) {
+ LOG_RETURN(RES_FAIL, "win is NULL!");
+ }
+
+ m_devicePrs = DeviceStatePresenter::Builder().
+ setDisplayState(DeviceStatePresenter::DisplayState::ON).
+ build(asShared(win));
+
+ if (!m_devicePrs) {
+ LOG_RETURN(RES_FAIL, "DisplayPresenter::build() failed!");
+ }
+
+ return RES_OK;
+ }
+
+ void MainPage::onExitAppRequest()
+ {
+ requestExit();
+ }
+
+ Result MainPage::createAccessoryPresenter()
+ {
+ if (m_accessoryPrs) {
+ ILOG("Already exists. No need to create new one. Just update.");
+ m_accessoryPrs->update(m_cm);
+ return RES_OK;
+ }
+
+ m_accessoryPrs = AccessoryPresenter::Builder().
+ setSoundManager(m_call->getSoundManager()).
+ setCallManager(m_cm).
+ setRequestExitHandler(WEAK_DELEGATE(MainPage::onExitAppRequest,
+ asWeak(*this))).
+ setParentWidget(m_widget).
+ build(*this);
+
+ if (!m_accessoryPrs) {
+ LOG_RETURN(RES_FAIL,
+ "AccessoryPresenter::build() failed!");
+ }
+
+ m_widget->setContent(m_accessoryPrs->getWidget(),
+ impl::PART_SWL_OVERLAY);
+
+ return RES_OK;
+ }
+
+ Result MainPage::createMoreOptionsPresenter()
+ {
+ if (m_moreOptionsPrs) {
+ ILOG("Already exists. No need to create new one. Just update.");
+ m_moreOptionsPrs->update();
+ return RES_OK;
+ }
+
+ m_moreOptionsPrs = MoreOptionsPresenter::Builder().
+ setCallManager(m_cm).
+ setSoundManager(m_call->getSoundManager()).
+ setNaviframe(asShared(getNaviframe())).
+ setParentWidget(m_widget).
+ build(*this);
+
+ if (!m_moreOptionsPrs) {
+ LOG_RETURN(RES_FAIL,
+ "MoreOptionsPresenter::build() failed!");
+ }
+
+ m_widget->setContent(m_moreOptionsPrs->getWidget(),
+ impl::PART_SWL_MORE_OPTION);
+
+ return RES_OK;
+ }
+
+ Result MainPage::createAcceptRejectPresenter()
+ {
+ if (m_acceptRejectPrs) {
+ m_acceptRejectPrs->update(m_cm->getAvailableCalls());
+ return RES_OK;
+ }
+
+ m_acceptRejectPrs = AcceptRejectPresenter::Builder().
+ setIncomingCall(m_cm->getIncomingCall()).
+ setAvailableCallsFlag(m_cm->getAvailableCalls()).
+ setSoundManager(m_call->getSoundManager()).
+ setParentWidget(m_widget).
+ build(*this);
+
+ if (!m_acceptRejectPrs) {
+ LOG_RETURN(RES_FAIL,
+ "AcceptRejectPresenter::build() failed!");
+ }
+
+ m_widget->setContent(m_acceptRejectPrs->getWidget(),
+ impl::PART_SWL_ACCEPT_REJECT);
+
+ return RES_OK;
+ }
+
+ void MainPage::RejectMsgPresenterStateCb(RejectMsgPresenter::State state)
+ {
+ if (state == RejectMsgPresenter::State::HIDDEN) {
+ show(*m_rmLy);
+ show(*m_rmCueAo);
+ } else {
+ hide(*m_rmLy);
+ hide(*m_rmCueAo);
+ }
+ }
+
+ void MainPage::RejectMsgSelectCb(const IRejectMsgSRef &rm)
+ {
+ auto incom = m_cm->getIncomingCall();
+ if (incom) {
+ incom->rejectWithMessage(rm);
+ }
+ }
+
+ Result MainPage::createRejectMsgPresenter(
+ const IRejectMsgProviderSRef &provider)
+ {
+ m_rmPrs = RejectMsgPresenter::Builder().
+ setProvider(provider).
+ setStateHandler(WEAK_DELEGATE(MainPage::RejectMsgPresenterStateCb,
+ asWeak(*this))).
+ setSelectHandler(WEAK_DELEGATE(MainPage::RejectMsgSelectCb,
+ asWeak(*this))).
+ setParentWidget(m_widget).
+ build(*this);
+
+ if (!m_rmPrs) {
+ LOG_RETURN(RES_FAIL,
+ "RejectMessagePresenter::build() failed!");
+ }
+
+ m_widget->setContent(m_rmPrs->getWidget(),
+ impl::PART_SWL_OVERLAY);
+
+ return RES_OK;
+ }
+
+ Result MainPage::createCallInfoPresenter(CallMode mode)
+ {
+ if (m_callInfoPrs) {
+ return m_callInfoPrs->update(mode, m_cm);
+ }
+
+ m_callInfoPrs = CallInfoPresenter::Builder().
+ setCallManager(m_cm).
+ setMode(mode).
+ setParentWidget(m_widget).
+ build(*this);
+
+ if (!m_callInfoPrs) {
+ LOG_RETURN(RES_FAIL, "CallerInfo::build() failed!");
+ }
+ m_widget->setContent(m_callInfoPrs->getWidget(),
+ impl::PART_SWL_CALL_INFO);
+
+ return RES_OK;
+ }
+
+ void MainPage::onError(CallErr err)
+ {
+ if (!m_cm->getAvailableCalls()) {
+ requestExit();
+ }
+ }
+
+ // Screen Reader
+ Result MainPage::createRejectMsgCueAo()
+ {
+ m_rmCueAo = utils::createAccessObjectFromLyPart(*m_widget,
+ *m_rmLy,
+ impl::PART_TXT_REJECT_MSG_CUE_AO);
+ if (!m_rmCueAo) {
+ LOG_RETURN(RES_FAIL, "createAccessObjectFromLyPart() failed!");
+ }
+ elm_atspi_accessible_translation_domain_set(*m_rmCueAo, PACKAGE);
+ elm_atspi_accessible_reading_info_type_set(*m_rmCueAo,
+ ELM_ACCESSIBLE_READING_INFO_TYPE_NAME |
+ ELM_ACCESSIBLE_READING_INFO_TYPE_DESCRIPTION);
+ elm_atspi_accessible_name_set(*m_rmCueAo, AO_STR_DECLINE_MESSAGES);
+ elm_atspi_accessible_description_set(*m_rmCueAo,
+ AO_STR_SWIPE_UP_WITH_TWO_FINGERS_TO_SEND_A_DECLINE_MESSAGE);
+
+ elm_atspi_accessible_gesture_cb_set(*m_rmCueAo,
+ [](void *data, Elm_Atspi_Gesture_Info gesture, Evas_Object *obj) {
+ // TODO: ELM_ATSPI_GESTURE_TWO_FINGERS_HOVER must be replaced
+ if (gesture.type == ELM_ATSPI_GESTURE_TWO_FINGERS_HOVER) {
+ auto page = (MainPage *)data;
+ page->m_rmPrs->showPanel();
+ return EINA_TRUE;
+ }
+
+ return EINA_FALSE;
+ }, this);
+
+ return RES_OK;
+ }
+
+ Result MainPage::createAtspiHighlightHelper()
+ {
+ m_atspiHelper = AtspiHighlightHelper::newInstance(*this, getWindow());
+ if (!m_atspiHelper) {
+ LOG_RETURN(RES_FAIL,
+ "AtspiHighlightHelper::newInstance() failed!");
+ }
+
+ switch (m_mode) {
+ case CallMode::INCOMING:
+ registerIncomingCallModeAo();
+ break;
+ case CallMode::OUTGOING:
+ case CallMode::DURING:
+ registerActiveCallModeAo();
+ break;
+ case CallMode::END:
+ registerEndCallModeAo();
+ default:
+ break;
+ }
+ return RES_OK;
+ }
+
+ void MainPage::registerIncomingCallModeAo()
+ {
+ DLOG("ENTER");
+ m_atspiHelper->setRelationEventHandler(WEAK_DELEGATE(
+ MainPage::onIncomingCallModeAtspiHighlight, asWeak(*this)));
+
+ m_atspiHelper->setGestureEventHandler(WEAK_DELEGATE(
+ MainPage::onIncomingModeAtspiGesture, asWeak(*this)));
+
+ auto acceptAO = m_acceptRejectPrs->getAcceptAo();
+ if (!acceptAO) {
+ DLOG("acceptAO is NULL");
+ } else {
+ m_atspiHelper->registerWidget(*acceptAO);
+ }
+
+ auto rejectAo = m_acceptRejectPrs->getRejectAo();
+ if (!rejectAo) {
+ DLOG("rejectAo is NULL");
+ } else {
+ m_atspiHelper->registerWidget(*rejectAo);
+ }
+
+ auto statusTxtAo = m_callInfoPrs->getStatusTxtAo();
+ if (!statusTxtAo) {
+ DLOG("statusTxtAo is NULL");
+ } else {
+ m_atspiHelper->registerWidget(*statusTxtAo);
+ }
+
+ auto mainTxtAo = m_callInfoPrs->getMainTxtAo();
+ if (!mainTxtAo) {
+ DLOG("mainTxtAo is NULL");
+ } else {
+ m_atspiHelper->registerWidget(*mainTxtAo);
+ }
+
+ auto subTxtAo = m_callInfoPrs->getSubTxtAo();
+ if (!subTxtAo) {
+ DLOG("subTxtAo is NULL");
+ } else {
+ m_atspiHelper->registerWidget(*subTxtAo);
+ }
+
+ if (!m_rmCueAo) {
+ DLOG("m_rmCueAo is NULL");
+ } else {
+ m_atspiHelper->registerWidget(*m_rmCueAo);
+ }
+
+ DLOG("EXIT");
+ }
+
+ bool MainPage::onIncomingModeAtspiGesture(Elm_Interface_Atspi_Accessible *widget,
+ Elm_Atspi_Gesture_Type gestureType)
+ {
+ DLOG(" GESTURE TYPE [%d]", gestureType);
+
+ if (m_rmCueAo && widget == *m_rmCueAo) {
+ if (gestureType == ELM_ATSPI_GESTURE_TWO_FINGERS_HOVER) {
+ m_rmPrs->showPanel();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ Elm_Interface_Atspi_Accessible *MainPage::onIncomingCallModeAtspiHighlight(
+ Elm_Interface_Atspi_Accessible *ao,
+ Elm_Atspi_Relation_Type flowRelation)
+ {
+ DLOG("FlowRelation [%s]",
+ flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM ?
+ "FROM" : "TO");
+
+ auto acceptAo = m_acceptRejectPrs->getAcceptAo();
+ auto rejectAo = m_acceptRejectPrs->getRejectAo();
+ auto statusTxtAo = m_callInfoPrs->getStatusTxtAo();
+ auto mainTxtAo = m_callInfoPrs->getMainTxtAo();
+ auto subTxtAo = m_callInfoPrs->getSubTxtAo();
+
+ if (ao == *acceptAo) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return *statusTxtAo;
+ }
+ } else if (ao == *statusTxtAo) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return *mainTxtAo;
+ } else if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
+ return *acceptAo;
+ }
+ } else if (ao == *mainTxtAo) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return (subTxtAo) ? *subTxtAo : *rejectAo;
+ } else if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
+ return *statusTxtAo;
+ }
+ } else if (subTxtAo && ao == *subTxtAo) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return *rejectAo;
+ } else if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
+ return *mainTxtAo;
+ }
+ } else if (ao == *rejectAo) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return m_rmCueAo ? *m_rmCueAo : ao;
+ } else if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
+ return (subTxtAo) ? *subTxtAo : *mainTxtAo;
+ }
+ } else if (m_rmCueAo && ao == *m_rmCueAo) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
+ return *rejectAo;
+ }
+ } else if (ao == getWindow()) {
+ return *acceptAo;
+ } else {
+ LOG_RETURN_VALUE(RES_FAIL, nullptr, "Unknown object!");
+ }
+
+ return ao;
+ }
+
+ void MainPage::registerActiveCallModeAo()
+ {
+ DLOG("ENTER");
+ m_atspiHelper->setRelationEventHandler(WEAK_DELEGATE(
+ MainPage::onActiveCallModeAtspiHighlight, asWeak(*this)));
+
+ auto statusTxtAo = m_callInfoPrs->getStatusTxtAo();
+ if (!statusTxtAo) {
+ DLOG("statusTxtAo is NULL");
+ } else {
+ m_atspiHelper->registerWidget(*statusTxtAo);
+ }
+
+ auto mainTxtAo = m_callInfoPrs->getMainTxtAo();
+ if (!mainTxtAo) {
+ DLOG("mainTxtAo is NULL");
+ } else {
+ m_atspiHelper->registerWidget(*mainTxtAo);
+ }
+
+ auto subTxtAo = m_callInfoPrs->getSubTxtAo();
+ if (!subTxtAo) {
+ DLOG("subTxtAo is NULL");
+ } else {
+ m_atspiHelper->registerWidget(*subTxtAo);
+ }
+
+ auto volumeBtnAo = m_accessoryPrs->getVolumBtn();
+ if (!volumeBtnAo) {
+ DLOG("volumeBtnAo is NULL");
+ } else {
+ m_atspiHelper->registerWidget(*volumeBtnAo);
+ }
+
+ auto bluetoothBtnAo = m_accessoryPrs->getBluetoothBtn();
+ if (!bluetoothBtnAo) {
+ DLOG("bluetoothBtnAo is NULL");
+ } else {
+ m_atspiHelper->registerWidget(*bluetoothBtnAo);
+ }
+
+ auto muteBtnAo = m_accessoryPrs->getMuteBtn();
+ if (!muteBtnAo) {
+ DLOG("muteBtnAo is NULL");
+ } else {
+ m_atspiHelper->registerWidget(*muteBtnAo);
+ }
+
+ auto moreOptCueAo = m_moreOptionsPrs->getCueAo();
+ if (!moreOptCueAo) {
+ DLOG("moreCueAo is NULL");
+ } else {
+ m_atspiHelper->registerWidget(*moreOptCueAo);
+ }
+
+ if (!m_bottomBtn) {
+ DLOG("m_bottomBtn is NULL");
+ } else {
+ m_atspiHelper->registerWidget(*m_bottomBtn);
+ }
+
+ auto vcLayout = m_accessoryPrs->getVolumeControlLy();
+ if (!vcLayout) {
+ DLOG("vcLayout is NULL");
+ } else {
+ m_atspiHelper->registerWidget(*vcLayout);
+ }
+
+ auto vcDecrVolumeBtn = m_accessoryPrs->getVolumeControlDecreaseBtn();
+ if (!vcDecrVolumeBtn) {
+ DLOG("vcDecrVolumeBtn is NULL");
+ } else {
+ m_atspiHelper->registerWidget(*vcDecrVolumeBtn);
+ }
+
+ auto vcIncrVolumeBtn = m_accessoryPrs->getVolumeControlIncreaseBtn();
+ if (!vcIncrVolumeBtn) {
+ DLOG("vcIncrVolumeBtn is NULL");
+ } else {
+ m_atspiHelper->registerWidget(*vcIncrVolumeBtn);
+ }
+
+ auto vcVolumeValueAo = m_accessoryPrs->getVolumeControlValueTxtAo();
+ if (!vcVolumeValueAo) {
+ DLOG("vcVolumeValueAo is NULL");
+ } else {
+ m_atspiHelper->registerWidget(*vcVolumeValueAo);
+ }
+
+ DLOG("EXIT");
+ }
+
+ Elm_Interface_Atspi_Accessible *MainPage::onActiveCallModeAtspiHighlight(
+ Elm_Interface_Atspi_Accessible *ao,
+ Elm_Atspi_Relation_Type flowRelation)
+ {
+ DLOG("FlowRelation [%s]",
+ flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM ?
+ "FROM" : "TO");
+
+ auto statusTxtAo = m_callInfoPrs->getStatusTxtAo();
+ auto mainTxtAo = m_callInfoPrs->getMainTxtAo();
+ auto subTxtAo = m_callInfoPrs->getSubTxtAo();
+ auto volumeBtnAo = m_accessoryPrs->getVolumBtn();
+ auto bluetoothBtnAo = m_accessoryPrs->getBluetoothBtn();
+ auto muteBtnAo = m_accessoryPrs->getMuteBtn();
+ auto moreOptCueAo = m_moreOptionsPrs->getCueAo();
+ auto vcLayout = m_accessoryPrs->getVolumeControlLy();
+ auto vcDecrVolumeBtn = m_accessoryPrs->getVolumeControlDecreaseBtn();
+ auto vcIncrVolumeBtn = m_accessoryPrs->getVolumeControlIncreaseBtn();
+ auto vcVolumeValueAo = m_accessoryPrs->getVolumeControlValueTxtAo();
+
+ if (ao == *statusTxtAo) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return *mainTxtAo;
+ }
+ } else if (ao == *mainTxtAo) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ if (subTxtAo) {
+ return *subTxtAo;
+ } else {
+ return *volumeBtnAo;
+ }
+ } else {
+ return *statusTxtAo;
+ }
+ } else if (subTxtAo && ao == *subTxtAo) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return *volumeBtnAo;
+ } else {
+ return *mainTxtAo;
+ }
+ } else if (ao == *volumeBtnAo) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return *bluetoothBtnAo;
+ } else {
+ if (subTxtAo) {
+ return *subTxtAo;
+ } else {
+ return *mainTxtAo;
+ }
+ }
+ } else if (ao == *bluetoothBtnAo) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return *muteBtnAo;
+ } else {
+ return *volumeBtnAo;
+ }
+ } else if (ao == *muteBtnAo) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return *moreOptCueAo;
+ } else {
+ return *bluetoothBtnAo;
+ }
+ } else if (ao == *moreOptCueAo) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return *m_bottomBtn;
+ } else {
+ return *muteBtnAo;
+ }
+ } else if (ao == *m_bottomBtn) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
+ return *moreOptCueAo;
+ }
+ } else if (ao == *vcLayout) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return *vcDecrVolumeBtn;
+ }
+ } else if (ao == *vcDecrVolumeBtn) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return *vcVolumeValueAo;
+ } else {
+ return *vcLayout;
+ }
+ } else if (ao == *vcVolumeValueAo) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return *vcIncrVolumeBtn;
+ } else {
+ return *vcDecrVolumeBtn;
+ }
+ } else if (ao == *vcIncrVolumeBtn) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
+ return *vcVolumeValueAo;
+ }
+ } else if (ao == getWindow()) {
+ return *statusTxtAo;
+ } else {
+ LOG_RETURN_VALUE(RES_FAIL, nullptr, "Unknown object!");
+ }
+
+ return ao;
+ }
+
+ void MainPage::registerEndCallModeAo()
+ {
+ m_atspiHelper->setRelationEventHandler(WEAK_DELEGATE(
+ MainPage::onEndCallModeAtspiHighlight, asWeak(*this)));
+
+ auto statusTxtAo = m_callInfoPrs->getStatusTxtAo();
+ if (!statusTxtAo) {
+ DLOG("statusTxtAo is NULL");
+ } else {
+ m_atspiHelper->registerWidget(*statusTxtAo);
+ }
+
+ auto mainTxtAo = m_callInfoPrs->getMainTxtAo();
+ if (!mainTxtAo) {
+ DLOG("mainTxtAo is NULL");
+ } else {
+ m_atspiHelper->registerWidget(*mainTxtAo);
+ }
+
+ auto addContactsBtnAo = m_accessoryPrs->getAddContactBtn();
+ if (!addContactsBtnAo) {
+ DLOG("addContactsBtnAo is NULL");
+ } else {
+ m_atspiHelper->registerWidget(*addContactsBtnAo);
+ }
+
+ if (!m_bottomBtn) {
+ DLOG("m_bottomBtn is NULL");
+ } else {
+ m_atspiHelper->registerWidget(*m_bottomBtn);
+ }
+
+ DLOG("EXIT");
+ }
+
+ Elm_Interface_Atspi_Accessible *MainPage::onEndCallModeAtspiHighlight(
+ Elm_Interface_Atspi_Accessible *ao,
+ Elm_Atspi_Relation_Type flowRelation)
+ {
+ DLOG("FlowRelation [%s]",
+ flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM ?
+ "FROM" : "TO");
+
+ auto statusTxtAo = m_callInfoPrs->getStatusTxtAo();
+ auto mainTxtAo = m_callInfoPrs->getMainTxtAo();
+ auto addContactsBtnAo = m_accessoryPrs->getAddContactBtn();
+
+ if (ao == *statusTxtAo) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return *mainTxtAo;
+ }
+ } else if (ao == *mainTxtAo) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ if (addContactsBtnAo) {
+ return *addContactsBtnAo;
+ } else {
+ return *m_bottomBtn;
+ }
+ } else {
+ return *statusTxtAo;
+ }
+ } else if (addContactsBtnAo && ao == *addContactsBtnAo) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return *m_bottomBtn;
+ } else {
+ return *mainTxtAo;
+ }
+ } else if (ao == *m_bottomBtn) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
+ if (addContactsBtnAo) {
+ return *addContactsBtnAo;
+ } else {
+ return *mainTxtAo;
+ }
+ }
+ } else if (ao == getWindow()) {
+ return *statusTxtAo;
+ } else {
+ LOG_RETURN_VALUE(RES_FAIL, nullptr, "Unknown object!");
+ }
+
+ return ao;
+ }
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_PAGES_MAIN_PAGE_H__
+#define __CALL_UI_PRESENTERS_PAGES_MAIN_PAGE_H__
+
+#include "call-ui/presenters/base/Page.h"
+#include "call-ui/model/ICallListener.h"
+
+#include "ucl/gui/Layout.h"
+
+#include "call-ui/model/ICallUI.h"
+
+#include "call-ui/presenters/misc/IndicatorPresenter.h"
+#include "call-ui/presenters/misc/AcceptRejectPresenter.h"
+#include "call-ui/presenters/misc/CallInfoPresenter.h"
+#include "call-ui/presenters/misc/RejectMsgPresenter.h"
+#include "call-ui/presenters/misc/AccessoryPresenter.h"
+#include "call-ui/presenters/misc/MoreOptionsPresenter.h"
+#include "call-ui/presenters/misc/DeviceStatePresenter.h"
+#include "call-ui/presenters/misc/AtspiHighlightHelper.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(MainPage);
+
+ class MainPage final : public Page,
+ public ICallListener {
+ public:
+ class Builder {
+ public:
+ Builder();
+ ~Builder();
+ Builder &setNaviframe(const ucl::NaviframeSRef &navi);
+ Builder &setCallUI(const ICallUISRef &call);
+ MainPageSRef build(const ExitRequestHandler handler) const;
+ private:
+ ucl::NaviframeSRef m_navi;
+ ICallUISRef m_call;
+ };
+
+ private:
+ friend class ucl::ReffedObj<MainPage>;
+ MainPage(ucl::IRefCountObj &rc,
+ const ucl::NaviframeSRef &navi,
+ const ExitRequestHandler handler,
+ const ICallUISRef &call);
+ virtual ~MainPage();
+
+ ucl::Result doPrepare(ucl::NaviItem &item);
+
+ ucl::Result showWindow();
+ void updateCallMode();
+
+ ucl::Result processIncomingCallMode();
+ ucl::Result processEndCallMode();
+ ucl::Result processRegularCallModes();
+
+ ucl::Result createCallInfoPresenter(CallMode mode);
+ ucl::Result createAccessoryPresenter();
+ ucl::Result createMoreOptionsPresenter();
+ ucl::Result createAcceptRejectPresenter();
+ ucl::Result createRejectMsgPresenter(
+ const IRejectMsgProviderSRef &provider);
+
+ ucl::Result createRejectMsgCue();
+ void RejectMsgPresenterStateCb(RejectMsgPresenter::State state);
+ void RejectMsgSelectCb(const IRejectMsgSRef &rm);
+
+ ucl::Result createBottomBtn(const ucl::ElmStyle &style,
+ bool setVisible = true);
+ void onBottomBtnClicked(ucl::Widget &widget, void *eventInfo);
+
+ void startEndCallTimer();
+ void stopEndCallTimer();
+ Eina_Bool onEndCallTimerCb();
+
+ void onPowerKeyUp(ucl::Widget &widget, void *eventInfo);
+ void processKeyPress();
+
+ ucl::Result updateDeviceState(CallMode prevMode, CallMode curMode);
+
+ ucl::Result createWidget();
+ ucl::Result createIndicatorPresenter();
+ ucl::Result createDisplayPresenter();
+
+ void onExitAppRequest();
+
+ // Screen Reader
+ ucl::Result createRejectMsgCueAo();
+ ucl::Result createAtspiHighlightHelper();
+ void registerIncomingCallModeAo();
+ void registerActiveCallModeAo();
+ void registerEndCallModeAo();
+ Elm_Interface_Atspi_Accessible *onIncomingCallModeAtspiHighlight(
+ Elm_Interface_Atspi_Accessible *widget,
+ Elm_Atspi_Relation_Type flowRelation);
+ Elm_Interface_Atspi_Accessible *onActiveCallModeAtspiHighlight(
+ Elm_Interface_Atspi_Accessible *widget,
+ Elm_Atspi_Relation_Type flowRelation);
+ Elm_Interface_Atspi_Accessible *onEndCallModeAtspiHighlight(
+ Elm_Interface_Atspi_Accessible *ao,
+ Elm_Atspi_Relation_Type flowRelation);
+ bool onIncomingModeAtspiGesture(
+ Elm_Interface_Atspi_Accessible *widget,
+ Elm_Atspi_Gesture_Type gestureType);
+
+ // Page
+
+ virtual void onBackKey() final override;
+
+ // ICallListener
+
+ virtual void onCallEvent(CallEventType type) final override;
+ virtual void onError(CallErr err) final override;
+
+ private:
+ ucl::LayoutSRef m_widget;
+ ucl::LayoutSRef m_rmLy;
+ ucl::StyledWidgetSRef m_bottomBtn;
+
+ ICallUISRef m_call;
+ ICallManagerSRef m_cm;
+ IndicatorPresenterSRef m_indicator;
+ CallInfoPresenterSRef m_callInfoPrs;
+ AcceptRejectPresenterSRef m_acceptRejectPrs;
+ RejectMsgPresenterSRef m_rmPrs;
+ AccessoryPresenterSRef m_accessoryPrs;
+ MoreOptionsPresenterSRef m_moreOptionsPrs;
+ DeviceStatePresenterSRef m_devicePrs;
+
+ CallMode m_mode;
+ Ecore_Timer *m_ecTimer;
+ bool m_ecTimerBtnReq;
+
+ // Screen Reader
+ ucl::ElmWidgetSRef m_rmCueAo;
+ AtspiHighlightHelperSRef m_atspiHelper;
+ };
+}
+
+#endif // __CALL_UI_PRESENTERS_PAGES_MAIN_PAGE_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_PAGES_PAGES_COMMON_H__
+#define __CALL_UI_PRESENTERS_PAGES_PAGES_COMMON_H__
+
+#include "call-ui/presenters/common.h"
+
+#endif // __CALL_UI_PRESENTERS_PAGES_PAGES_COMMON_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_PRESENTERS_TYPES_H__
+#define __CALL_UI_PRESENTERS_TYPES_H__
+
+#include "call-ui/view/types.h"
+#include "call-ui/model/types.h"
+
+#endif // __CALL_UI_PRESENTERS_TYPES_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "call-ui/resources.h"
+
+namespace callui {
+
+ // TODO: Need replace with IDS
+
+ const ucl::TString STR_ANSWER_CALL {"Answer call"};
+ const ucl::TString STR_HOLD_AND_ACCEPT {"Hold and Accept"};
+ const ucl::TString STR_END_AND_ACCEPT {"End and Accept"};
+
+ const ucl::TString STR_CALL_WITH_PS_WILL_END {"Call with %s will end."};
+ const ucl::TString STR_CALL_ON_HOLD {"Call on hold"};
+ const ucl::TString STR_WITH_PD_PEOPLE {"With %d people"};
+ const ucl::TString STR_CONFERENCE_CALL {"Conference call"};
+ const ucl::TString STR_UNKNOWN {"Unknown"};
+ const ucl::TString STR_EMERGENCY_CALL {"Emergency call"};
+ const ucl::TString STR_VOICEMAIL {"Voicemail"};
+
+ const ucl::TString STR_INCOMING_CALL {"Incoming call"};
+ const ucl::TString STR_DIALING_CALL {"Dialing"};
+ const ucl::TString STR_ON_HOLD {"On hold"};
+ const ucl::TString STR_CALL_ENDED {"Call ended"};
+
+ const ucl::TString STR_DECLINE_MESSAGES {"Decline messages"};
+
+ const ucl::TString STR_VOLUME {"Volume"};
+
+ const ucl::TString STR_MORE_SWAP {"Swap"};
+ const ucl::TString STR_MORE_HEADSET {"Headset"};
+ const ucl::TString STR_MORE_PHONE {"Phone"};
+ const ucl::TString STR_MORE_KEYPAD {"Keypad"};
+ const ucl::TString STR_MORE_HOLD {"Hold"};
+ const ucl::TString STR_MORE_UNHOLD {"Unhold"};
+ const ucl::TString STR_MORE_GEAR {"Gear"};
+
+ // Screen Reader
+ const ucl::TString AO_STR_CALL {"Call"};
+ const ucl::TString AO_STR_VOLUME {"Volume"};
+ const ucl::TString AO_STR_HEADSET {"Headset"};
+ const ucl::TString AO_STR_GEAR_SPK {"Gear speaker"};
+ const ucl::TString AO_STR_MUTE {"Mute"};
+ const ucl::TString AO_STR_MORE_OPTIONS {"More options"};
+ const ucl::TString AO_STR_END_CALL {"End call"};
+ const ucl::TString AO_STR_CALLBACK {"Callback"};
+ const ucl::TString AO_STR_ADD_TO_CONTACTS {"Add to contacts"};
+ const ucl::TString AO_STR_ROTATE_BEZEL_TO_ADJUST {"Rotate bezel to adjust"};
+ const ucl::TString AO_STR_DECREASE_VOLUME {"Decrease volume"};
+ const ucl::TString AO_STR_INCREASE_VOLUME {"Increase volume"};
+ const ucl::TString AO_STR_ACCEPT_CALL {"Accept call"};
+ const ucl::TString AO_STR_SWIPE_RIGHT_WITH_TWO_FINGERS_TO_ACCEPT
+ {"Swipe right with two fingers to accept"};
+ const ucl::TString AO_STR_REJECT_CALL {"Reject call"};
+ const ucl::TString AO_STR_SWIPE_LEFT_WITH_TWO_FINGERS_TO_REJECT
+ {"Swipe left with two fingers to reject"};
+ const ucl::TString AO_STR_DECLINE_MESSAGES {"Decline messages"};
+ const ucl::TString AO_STR_SWIPE_UP_WITH_TWO_FINGERS_TO_SEND_A_DECLINE_MESSAGE
+ {"Swipe up with two fingers to send a decline message"};
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_RESOURCES_H__
+#define __CALL_UI_RESOURCES_H__
+
+#include "ucl/misc/TString.h"
+
+#include "config.h"
+
+namespace callui {
+
+ constexpr auto THEME_EDJE_PATH = "edje/theme.edj";
+
+ extern const ucl::TString STR_ANSWER_CALL;
+ extern const ucl::TString STR_HOLD_AND_ACCEPT;
+ extern const ucl::TString STR_END_AND_ACCEPT;
+
+ extern const ucl::TString STR_CALL_WITH_PS_WILL_END;
+ extern const ucl::TString STR_CALL_ON_HOLD;
+ extern const ucl::TString STR_WITH_PD_PEOPLE;
+ extern const ucl::TString STR_CONFERENCE_CALL;
+ extern const ucl::TString STR_UNKNOWN;
+ extern const ucl::TString STR_EMERGENCY_CALL;
+ extern const ucl::TString STR_VOICEMAIL;
+
+ extern const ucl::TString STR_INCOMING_CALL;
+ extern const ucl::TString STR_DIALING_CALL;
+ extern const ucl::TString STR_ON_HOLD;
+ extern const ucl::TString STR_CALL_ENDED;
+
+ extern const ucl::TString STR_DECLINE_MESSAGES;
+
+ extern const ucl::TString STR_VOLUME;
+
+ extern const ucl::TString STR_MORE_SWAP;
+ extern const ucl::TString STR_MORE_HEADSET;
+ extern const ucl::TString STR_MORE_PHONE;
+ extern const ucl::TString STR_MORE_KEYPAD;
+ extern const ucl::TString STR_MORE_HOLD;
+ extern const ucl::TString STR_MORE_UNHOLD;
+ extern const ucl::TString STR_MORE_TRANSFER;
+ extern const ucl::TString STR_MORE_GEAR;
+
+ // Screen Reader
+ extern const ucl::TString AO_STR_CALL;
+ extern const ucl::TString AO_STR_VOLUME;
+ extern const ucl::TString AO_STR_HEADSET;
+ extern const ucl::TString AO_STR_GEAR_SPK;
+ extern const ucl::TString AO_STR_MUTE;
+ extern const ucl::TString AO_STR_MORE_OPTIONS;
+ extern const ucl::TString AO_STR_END_CALL;
+ extern const ucl::TString AO_STR_CALLBACK;
+ extern const ucl::TString AO_STR_ADD_TO_CONTACTS;
+ extern const ucl::TString AO_STR_ROTATE_BEZEL_TO_ADJUST;
+ extern const ucl::TString AO_STR_DECREASE_VOLUME;
+ extern const ucl::TString AO_STR_INCREASE_VOLUME;
+ extern const ucl::TString AO_STR_ACCEPT_CALL;
+ extern const ucl::TString AO_STR_SWIPE_RIGHT_WITH_TWO_FINGERS_TO_ACCEPT;
+ extern const ucl::TString AO_STR_REJECT_CALL;
+ extern const ucl::TString AO_STR_SWIPE_LEFT_WITH_TWO_FINGERS_TO_REJECT;
+ extern const ucl::TString AO_STR_DECLINE_MESSAGES;
+ extern const ucl::TString AO_STR_SWIPE_UP_WITH_TWO_FINGERS_TO_SEND_A_DECLINE_MESSAGE;
+
+}
+
+#endif // __CALL_UI_RESOURCES_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "ucl/util/logging.h"
+#include "types.h"
+
+ucl::ResultData getUCLResultData(const ucl::Result result)
+{
+ switch (result.value) {
+ case callui::RES_PERMISSION_DENIED: return {"RES_PERMISSION_DENIED", DLOG_FATAL};
+ case callui::RES_NOT_REGISTERED: return {"RES_NOT_REGISTERED", DLOG_FATAL};
+ case callui::RES_ALREADY_REGISTERED: return {"RES_ALREADY_REGISTERED", DLOG_FATAL};
+ case callui::RES_OPERATION_FAILED: return {"RES_OPERATION_FAILED", DLOG_FATAL};
+ case callui::RES_NOT_CONNECTED: return {"RES_NOT_CONNECTED", DLOG_FATAL};
+ default:
+ return ucl::getResultData(result);
+ }
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_TYPES_H__
+#define __CALL_UI_TYPES_H__
+
+#include "config.h"
+
+#include "ucl/util/types.h"
+#include "ucl/util/memory.h"
+#include "ucl/util/delegation.h"
+#include "ucl/util/smartDelegation.h"
+#include "ucl/misc/RefCountAware.h"
+
+namespace callui {
+ enum {
+ _UCL_RESULT,
+
+ RES_PERMISSION_DENIED = ucl::_RES_BEGIN - 1,
+ RES_NOT_REGISTERED = ucl::_RES_BEGIN - 2,
+ RES_ALREADY_REGISTERED = ucl::_RES_BEGIN - 3,
+ RES_OPERATION_FAILED = ucl::_RES_BEGIN - 4,
+ RES_NOT_CONNECTED = ucl::_RES_BEGIN - 5
+ };
+
+ using NotiHandler = ucl::WeakDelegate<void()>;
+}
+
+#endif // __CALL_UI_TYPES_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "call-ui/view/AcceptRejectWidget.h"
+
+#include "common.h"
+#include "call-ui/resources.h"
+
+#define CU_COL_TRANSPARENT 0, 0, 0, 0
+#define CU_COL_WHITE 255, 255, 255, 255
+
+#define CU_COL_AO0115 222, 11, 0, 255
+#define CU_COL_AO0115T 222, 11, 0, 0
+#define CU_COL_AO0115D 222, 11, 0, 63
+#define CU_COL_AO01151 222, 11, 0, 175
+#define CU_COL_AO01152 222, 11, 0, 77
+
+#define CU_COL_AO0113 77, 185, 39, 255
+#define CU_COL_AO0113T 77, 185, 39, 0
+#define CU_COL_AO0113D 77, 185, 39, 63
+#define CU_COL_AO01131 97, 237, 50, 175
+#define CU_COL_AO01132 97, 237, 50, 77
+
+namespace callui { namespace { namespace impl {
+
+ using namespace ucl;
+
+ constexpr LayoutTheme LAYOUT_IMG_ACCEPT_REJECT
+ {"layout", "callui", "accept_reject_main"};
+
+ constexpr LayoutTheme LAYOUT_EVENT_ACCEPT_REJECT
+ {"layout", "callui", "event_accept_reject"};
+
+ constexpr LayoutTheme LAYOUT_IMG_ACTION_BG
+ {"layout", "callui_image", "accept_reject_action_bg"};
+
+ constexpr LayoutTheme LAYOUT_IMG_ACCEPT
+ {"layout", "callui_image", "accept"};
+
+ constexpr LayoutTheme LAYOUT_IMG_ACCEPT_BT_HEADSET
+ {"layout", "callui_image", "accept_bt_headset"};
+
+ constexpr LayoutTheme LAYOUT_IMG_REJECT
+ {"layout", "callui_image", "reject"};
+
+ constexpr auto BC_ITEM_COUNT = 4;
+
+ constexpr auto BC_ANIMATE_COUNT_MAX = 3;
+
+ constexpr auto FINGER_TRACER_DIM = 130;
+ constexpr auto FINGER_TRACER_HALF_DIM = FINGER_TRACER_DIM / 2;
+
+ constexpr auto FINGER_STROKE_DIM = 480;
+ constexpr auto FINGER_STROKE_HALF_DIM = FINGER_STROKE_DIM / 2;
+
+ constexpr auto INIT_MOVE_DISTANCE_VAL = 65;
+
+ constexpr double BC_ANIMATION_DURATION[BC_ITEM_COUNT] = {
+ 0.23, 0.16, 0.30, 0.16 };
+
+ constexpr auto BC_ANIM_DUR_HIDE = 0.16;
+
+ constexpr auto ROTARY_ACTION_ANIM_DUR = 0.15;
+
+ constexpr auto EXPAND_WAITING_TIMEOUT = 0.6;
+
+ constexpr auto ICON_ZOOM_EFF_VAL_MIN = 1.0;
+ constexpr auto ICON_ZOOM_EFF_VAL_MID = 2.0;
+ constexpr auto ICON_ZOOM_EFF_VAL_MAX = 3.7;
+
+ constexpr auto ACC_ICON_RIGHT_PAD_X = 13;
+ constexpr auto REJ_ICON_RIGHT_PAD_X = 293;
+ constexpr auto ACC_REJ_ICON_HIDE_THRESHOLD_W = 70;
+
+ struct BezelCueParams {
+ const EdjePart part;
+ const LayoutTheme theme;
+ };
+
+ static const BezelCueParams ACCEPT_BC_PARAMS[BC_ITEM_COUNT] = {
+ { EdjePart {"swl.accept.bezel.1"},
+ LayoutTheme {"layout", "callui_image",
+ "bezel_cue_accept_1"} },
+ { EdjePart {"swl.accept.bezel.2"},
+ LayoutTheme {"layout", "callui_image",
+ "bezel_cue_accept_2"} },
+ { EdjePart {"swl.accept.bezel.3"},
+ LayoutTheme {"layout", "callui_image",
+ "bezel_cue_accept_3"} },
+ { EdjePart {"swl.accept.bezel.4"},
+ LayoutTheme {"layout", "callui_image",
+ "bezel_cue_accept_4"} },
+ };
+
+ static const BezelCueParams REJECT_BC_PARAMS[BC_ITEM_COUNT] = {
+ { EdjePart {"swl.reject.bezel.1"},
+ LayoutTheme {"layout", "callui_image",
+ "bezel_cue_reject_1"} },
+ { EdjePart {"swl.reject.bezel.2"},
+ LayoutTheme {"layout", "callui_image",
+ "bezel_cue_reject_2"} },
+ { EdjePart {"swl.reject.bezel.3"},
+ LayoutTheme {"layout", "callui_image",
+ "bezel_cue_reject_3"} },
+ { EdjePart {"swl.reject.bezel.4"},
+ LayoutTheme {"layout", "callui_image",
+ "bezel_cue_reject_4"} },
+ };
+
+ constexpr EdjePart PART_SWL_ACCEPT_FINGER_TRACER
+ {"swl.accept.finger.tracer"};
+ constexpr EdjePart PART_SWL_ACCEPT_FINGER_GUIDE_BG
+ {"swl.accept.finger.guide.bg"};
+ constexpr EdjePart PART_SWL_ACCEPT_FINGER_EVENT
+ {"swl.accept.finger.event"};
+ constexpr EdjePart PART_SWL_ACCEPT_ICON
+ {"swl.accept.icon"};
+
+ constexpr EdjePart PART_SWL_REJECT_FINGER_TRACER
+ {"swl.reject.finger.tracer"};
+ constexpr EdjePart PART_SWL_REJECT_FINGER_GUIDE_BG
+ {"swl.reject.finger.guide.bg"};
+ constexpr EdjePart PART_SWL_REJECT_FINGER_EVENT
+ {"swl.reject.finger.event"};
+ constexpr EdjePart PART_SWL_REJECT_ICON
+ {"swl.reject.icon"};
+
+ LayoutSRef createImage(ElmWidget &parent, const LayoutTheme &theme)
+ {
+ auto layout = Layout::Builder().
+ setTheme(theme).
+ setIsOwner(true).
+ build(parent);
+ if (!layout) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "Layout::build() failed!");
+ }
+ return layout;
+ }
+
+ void resizeImage(ElmWidget &image, int size)
+ {
+ Evas_Coord x, y, w, h;
+ image.getGeometry(&x, &y, &w, &h);
+ image.move((x + (w / 2)) - (size / 2), (y + (h / 2)) - (size / 2));
+ image.resize(size, size);
+ }
+
+}}}
+
+namespace callui {
+
+ using namespace ucl;
+
+ AcceptRejectWidget::Builder::Builder() :
+ m_acceptBtnType(AcceptButtonType::SIMPLE)
+ {
+ }
+
+ AcceptRejectWidget::Builder &
+ AcceptRejectWidget::Builder::setAcceptEventHandler(
+ const NotiHandler &handler)
+ {
+ m_acceptHandler = handler;
+ return *this;
+ }
+
+ AcceptRejectWidget::Builder &
+ AcceptRejectWidget::Builder::setRejectEventHandler(
+ const NotiHandler &handler)
+ {
+ m_rejectHandler = handler;
+ return *this;
+ }
+
+ AcceptRejectWidget::Builder &
+ AcceptRejectWidget::Builder::setAcceptBtnType(AcceptButtonType type)
+ {
+ m_acceptBtnType = type;
+ return *this;
+ }
+
+ AcceptRejectWidgetSRef
+ AcceptRejectWidget::Builder::build(ElmWidget &parent) const
+ {
+ auto layout = Layout::Builder().
+ setTheme(impl::LAYOUT_IMG_ACCEPT_REJECT).
+ setIsOwner(true).
+ build(parent);
+ if (!layout) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "Layout::build() failed!");
+ }
+
+ auto result = makeShared<AcceptRejectWidget>(layout,
+ m_acceptHandler, m_rejectHandler, m_acceptBtnType);
+
+ FAIL_RETURN_VALUE(result->registerAccessObjects(parent), {},
+ "registerScreenReaderObjects() failed!");
+
+ result->bindToEo();
+
+ return result;
+ }
+
+ AcceptRejectWidget::AcceptRejectWidget(IRefCountObj &rc,
+ const LayoutSRef &layout,
+ const NotiHandler &acceptHandler,
+ const NotiHandler &rejectHandler,
+ AcceptButtonType acceptBtnType):
+ ElmWidget(&rc, *layout, true),
+ m_layout(layout.get()),
+ m_accHandler(acceptHandler),
+ m_rejHandler(rejectHandler),
+ m_accBezelCueImg(impl::BC_ITEM_COUNT),
+ m_rejBezelCueImg(impl::BC_ITEM_COUNT),
+ m_isFreezed(false),
+ m_isAccPressed(false),
+ m_isRejPressed(false),
+ m_lastMoveDistance(impl::INIT_MOVE_DISTANCE_VAL),
+ m_rotaryClockwiseCount(0),
+ m_rotaryCounterClockwiseCount(0),
+ m_isContracting(false),
+ m_accTracerTr(nullptr),
+ m_accGuideTr(nullptr),
+ m_accIconTr(nullptr),
+ m_rejTracerTr(nullptr),
+ m_rejGuideTr(nullptr),
+ m_rejIconTr(nullptr),
+ m_lastAccBezelTr1(nullptr),
+ m_lastAccBezelTr2(nullptr),
+ m_lastRejBezelTr1(nullptr),
+ m_lastRejBezelTr2(nullptr),
+ m_accBCAnimCount(0),
+ m_rejBCAnimCount(0),
+ m_accBCAnimIndex(impl::BC_ITEM_COUNT - 1),
+ m_rejBCAnimIndex(impl::BC_ITEM_COUNT - 1),
+ m_acceptBtnType(acceptBtnType)
+ {
+ prepare();
+ }
+
+ AcceptRejectWidget::~AcceptRejectWidget()
+ {
+ m_expandTimeout.reset();
+
+ m_accEventLy->delEventHandler(WidgetEvent::MOUSE_DOWN,
+ WEAK_DELEGATE(AcceptRejectWidget::onMouseDown, asWeak(*this)));
+ m_accEventLy->delEventHandler(WidgetEvent::MOUSE_UP,
+ WEAK_DELEGATE(AcceptRejectWidget::onMouseUp, asWeak(*this)));
+ m_accEventLy->delEventHandler(WidgetEvent::MOUSE_MOVE,
+ WEAK_DELEGATE(AcceptRejectWidget::onMouseMove, asWeak(*this)));
+
+ m_rejEventLy->delEventHandler(WidgetEvent::MOUSE_DOWN,
+ WEAK_DELEGATE(AcceptRejectWidget::onMouseDown, asWeak(*this)));
+ m_rejEventLy->delEventHandler(WidgetEvent::MOUSE_UP,
+ WEAK_DELEGATE(AcceptRejectWidget::onMouseUp, asWeak(*this)));
+ m_rejEventLy->delEventHandler(WidgetEvent::MOUSE_MOVE,
+ WEAK_DELEGATE(AcceptRejectWidget::onMouseMove, asWeak(*this)));
+
+ DEL_TRANSIT(m_lastAccBezelTr1);
+ DEL_TRANSIT(m_lastAccBezelTr2);
+ DEL_TRANSIT(m_lastRejBezelTr1);
+ DEL_TRANSIT(m_lastRejBezelTr2);
+
+ DEL_TRANSIT(m_accTracerTr);
+ DEL_TRANSIT(m_accGuideTr);
+ DEL_TRANSIT(m_accIconTr);
+
+ DEL_TRANSIT(m_rejTracerTr);
+ DEL_TRANSIT(m_rejGuideTr);
+ DEL_TRANSIT(m_rejIconTr);
+
+ eext_rotary_object_event_callback_del(*m_layout, CALLBACK_A(
+ AcceptRejectWidget::onRotaryEvent));
+ }
+
+ void AcceptRejectWidget::prepare()
+ {
+ FAIL_RETURN_VOID(createAcceptComponents(),
+ "createAcceptComponents() failed!");
+
+ FAIL_RETURN_VOID(createRejectComponents(),
+ "createRejectComponents() failed!");
+
+ FAIL_RETURN_VOID(createBezelCueComponents(),
+ "createBezelCueImages() failed!");
+
+ eext_rotary_object_event_callback_add(*m_layout, CALLBACK_A(
+ AcceptRejectWidget::onRotaryEvent), this);
+ }
+
+ Result AcceptRejectWidget::createAcceptComponents()
+ {
+ m_accTracer = impl::createImage(*m_layout, impl::LAYOUT_IMG_ACTION_BG);
+ if (!m_accTracer) {
+ LOG_RETURN(RES_FAIL, "createImage() failed");
+ }
+ m_accTracer->setColor(CU_COL_TRANSPARENT);
+ m_layout->setContent(*m_accTracer,
+ impl::PART_SWL_ACCEPT_FINGER_TRACER);
+
+ m_accGuide = impl::createImage(*m_layout, impl::LAYOUT_IMG_ACTION_BG);
+ if (!m_accGuide) {
+ LOG_RETURN(RES_FAIL, "createImage() failed");
+ }
+ m_accGuide->setColor(CU_COL_TRANSPARENT);
+ m_layout->setContent(*m_accGuide,
+ impl::PART_SWL_ACCEPT_FINGER_GUIDE_BG);
+
+ switch (m_acceptBtnType) {
+ case AcceptButtonType::BT_HEADSET:
+ m_accIcon = impl::createImage(*m_layout,
+ impl::LAYOUT_IMG_ACCEPT_BT_HEADSET);
+ break;
+ default:
+ m_accIcon = impl::createImage(*m_layout,
+ impl::LAYOUT_IMG_ACCEPT);
+ break;
+ }
+ if (!m_accIcon) {
+ LOG_RETURN(RES_FAIL, "createImage() failed");
+ }
+ m_accIcon->setColor(CU_COL_AO0113);
+ m_layout->setContent(*m_accIcon,
+ impl::PART_SWL_ACCEPT_ICON);
+
+ m_accEventLy = Layout::Builder().
+ setTheme(impl::LAYOUT_EVENT_ACCEPT_REJECT).
+ build(*m_layout);
+ m_accEventLy->setWeight(EXPAND, EXPAND);
+ m_accEventLy->addEventHandler(WidgetEvent::MOUSE_DOWN,
+ WEAK_DELEGATE(AcceptRejectWidget::onMouseDown, asWeak(*this)));
+ m_accEventLy->addEventHandler(WidgetEvent::MOUSE_UP,
+ WEAK_DELEGATE(AcceptRejectWidget::onMouseUp, asWeak(*this)));
+ m_accEventLy->addEventHandler(WidgetEvent::MOUSE_MOVE,
+ WEAK_DELEGATE(AcceptRejectWidget::onMouseMove, asWeak(*this)));
+ m_layout->setContent(*m_accEventLy,
+ impl::PART_SWL_ACCEPT_FINGER_EVENT);
+
+ return RES_OK;
+ }
+
+ Result AcceptRejectWidget::createRejectComponents()
+ {
+ m_rejTracer = impl::createImage(*m_layout, impl::LAYOUT_IMG_ACTION_BG);
+ if (!m_rejTracer) {
+ LOG_RETURN(RES_FAIL, "createImage() failed");
+ }
+ m_rejTracer->setColor(CU_COL_TRANSPARENT);
+ m_layout->setContent(*m_rejTracer,
+ impl::PART_SWL_REJECT_FINGER_TRACER);
+
+ m_rejGuide = impl::createImage(*m_layout, impl::LAYOUT_IMG_ACTION_BG);
+ if (!m_rejGuide) {
+ LOG_RETURN(RES_FAIL, "createImage() failed");
+ }
+ m_rejGuide->setColor(CU_COL_TRANSPARENT);
+ m_layout->setContent(*m_rejGuide,
+ impl::PART_SWL_REJECT_FINGER_GUIDE_BG);
+
+ m_rejIcon = impl::createImage(*m_layout, impl::LAYOUT_IMG_REJECT);
+ if (!m_rejIcon) {
+ LOG_RETURN(RES_FAIL, "createImage() failed");
+ }
+ m_rejIcon->setColor(CU_COL_AO0115);
+ m_layout->setContent(*m_rejIcon,
+ impl::PART_SWL_REJECT_ICON);
+
+ m_rejEventLy = Layout::Builder().
+ setTheme(impl::LAYOUT_EVENT_ACCEPT_REJECT).
+ build(*m_layout);
+
+ m_rejEventLy->addEventHandler(WidgetEvent::MOUSE_DOWN,
+ WEAK_DELEGATE(AcceptRejectWidget::onMouseDown, asWeak(*this)));
+
+ m_rejEventLy->addEventHandler(WidgetEvent::MOUSE_UP,
+ WEAK_DELEGATE(AcceptRejectWidget::onMouseUp, asWeak(*this)));
+
+ m_rejEventLy->addEventHandler(WidgetEvent::MOUSE_MOVE,
+ WEAK_DELEGATE(AcceptRejectWidget::onMouseMove, asWeak(*this)));
+
+ m_layout->setContent(*m_rejEventLy,
+ impl::PART_SWL_REJECT_FINGER_EVENT);
+
+ return RES_OK;
+ }
+
+ void AcceptRejectWidget::onMouseDown(Widget &widget, void *eventInfo)
+ {
+ if (m_isFreezed) {
+ DLOG("Freezed");
+ return;
+ }
+
+ if (m_rotaryClockwiseCount > 0
+ || m_rotaryCounterClockwiseCount) {
+ DLOG("Rotary event is ongoing. Ignore touch callback");
+ return;
+ }
+
+ if (m_isAccPressed || m_isRejPressed) {
+ LOG_RETURN_VOID(RES_FAIL, "Down signal already got");
+ }
+
+ DEL_TRANSIT(m_accTracerTr);
+ DEL_TRANSIT(m_accGuideTr);
+ DEL_TRANSIT(m_accIconTr);
+
+ DEL_TRANSIT(m_rejTracerTr);
+ DEL_TRANSIT(m_rejGuideTr);
+ DEL_TRANSIT(m_rejIconTr);
+
+ bool needTransition = true;
+ if (m_rotaryClockwiseCount != 0
+ || m_rotaryCounterClockwiseCount != 0) {
+ m_rotaryClockwiseCount = 0;
+ m_rotaryCounterClockwiseCount = 0;
+ DLOG("Already expanded first step");
+ needTransition = false;
+ }
+
+ if (widget == *m_accEventLy) {
+ DLOG("Accept button down");
+ m_isAccPressed = true;
+ if (needTransition) {
+ setAcceptPressedState();
+ }
+ } else if (widget == *m_rejEventLy) {
+ DLOG("Reject button down");
+ m_isRejPressed = true;
+ if (needTransition) {
+ setRejectPressedState();
+ }
+ }
+ }
+
+ void AcceptRejectWidget::onMouseUp(Widget &widget, void *eventInfo)
+ {
+ if (m_isFreezed) {
+ DLOG("Freezed");
+ return;
+ }
+
+ if (m_rotaryClockwiseCount > 0 || m_rotaryCounterClockwiseCount) {
+ DLOG("Rotary event is ongoing. Ignore touch callback");
+ return;
+ }
+
+ if (m_isAccPressed) {
+ DEL_TRANSIT(m_accTracerTr);
+ DEL_TRANSIT(m_accGuideTr);
+ DEL_TRANSIT(m_accIconTr);
+ } else {
+ DEL_TRANSIT(m_rejTracerTr);
+ DEL_TRANSIT(m_rejGuideTr);
+ DEL_TRANSIT(m_rejIconTr);
+ }
+
+ m_lastMoveDistance = impl::INIT_MOVE_DISTANCE_VAL;
+
+ if (widget == *m_accEventLy) {
+ if (m_isAccPressed) {
+ DLOG("Accept button released");
+ setAcceptUnpressedState();
+ } else {
+ LOG_RETURN_VOID(RES_FAIL, "Accept button was not pressed");
+ }
+ } else if (widget == *m_rejEventLy) {
+ if (m_isRejPressed) {
+ DLOG("Reject button released");
+ setRejectUnpressedState();
+ } else {
+ LOG_RETURN_VOID(RES_FAIL, "Reject button was not pressed");
+ }
+ }
+ }
+
+ int AcceptRejectWidget::getTracerMoveDistance(
+ const ElmWidget &widget, int curX, int curY) const
+ {
+ Evas_Coord x, y, w, h;
+ widget.getGeometry(&x, &y, &w, &h);
+ int dx = curX - (x + (w / 2));
+ int dy = curY - (y + (h / 2));
+
+ int distance = pow(dx, 2);
+ distance += pow(dy, 2);
+ distance = sqrt(distance);
+
+ if (distance > impl::FINGER_STROKE_HALF_DIM) {
+ distance = impl::FINGER_STROKE_HALF_DIM;
+ }
+ return distance;
+ }
+
+ void AcceptRejectWidget::onMouseMove(Widget &widget, void *eventInfo)
+ {
+ if (m_isFreezed) {
+ DLOG("Freezed");
+ return;
+ }
+
+ if (m_rotaryClockwiseCount > 0 || m_rotaryCounterClockwiseCount) {
+ DLOG("Rotary event is ongoing. Ignore touch callback");
+ return;
+ }
+
+ ElmWidgetSRef img;
+ if (widget == *m_accEventLy) {
+ if (!m_isAccPressed) {
+ LOG_RETURN_VOID(RES_FAIL, "Down callback is not come");
+ }
+ img = m_accTracer;
+ } else if (widget == *m_rejEventLy) {
+ if (!m_isRejPressed) {
+ LOG_RETURN_VOID(RES_FAIL, "Down callback is not come");
+ }
+ img = m_rejTracer;
+ }
+
+ Evas_Event_Mouse_Move *ev =
+ static_cast<Evas_Event_Mouse_Move *>(eventInfo);
+ int distance = getTracerMoveDistance(*img,
+ ev->cur.canvas.x, ev->cur.canvas.y);
+
+ if (distance < impl::FINGER_TRACER_HALF_DIM) {
+ return;
+ }
+ if (m_isAccPressed) {
+ DEL_TRANSIT(m_accTracerTr);
+ } else {
+ DEL_TRANSIT(m_rejTracerTr);
+ }
+ m_lastMoveDistance = distance;
+
+ impl::resizeImage(*img, m_lastMoveDistance * 2);
+
+ if (m_lastMoveDistance >= impl::FINGER_STROKE_HALF_DIM) {
+ m_isFreezed = true;
+ if (m_accTracer == img && m_accHandler) {
+ m_accHandler();
+ } else if (m_rejTracer == img && m_rejHandler) {
+ m_rejHandler();
+ }
+ }
+ }
+
+ void AcceptRejectWidget::startBezelCueAnimation()
+ {
+ if (m_lastAccBezelTr1 || m_lastAccBezelTr2 ||
+ m_lastRejBezelTr1 || m_lastRejBezelTr2) {
+ ILOG("Bezel cue is already animating");
+ return;
+ }
+
+ // Accept bezel cue animation
+ for (int i = 0 ; i < impl::BC_ITEM_COUNT ; i++) {
+ m_accBezelCueImg[i]->setColor(CU_COL_AO0113D);
+ m_rejBezelCueImg[i]->setColor(CU_COL_AO0115D);
+ }
+
+ m_accBCAnimIndex = impl::BC_ITEM_COUNT - 1;
+ Elm_Transit *tr1 = elm_transit_add();
+ elm_transit_effect_color_add(tr1, CU_COL_AO0113D, CU_COL_AO0113);
+ elm_transit_object_add(tr1, *m_accBezelCueImg[m_accBCAnimIndex]);
+ elm_transit_duration_set(tr1,
+ impl::BC_ANIMATION_DURATION[m_accBCAnimIndex]);
+ elm_transit_objects_final_state_keep_set(tr1, EINA_TRUE);
+ elm_transit_del_cb_set(tr1,
+ CALLBACK_A(AcceptRejectWidget::onAcceptBCTransitDel),
+ this);
+ elm_transit_go(tr1);
+ m_lastAccBezelTr1 = tr1;
+
+ m_rejBCAnimIndex = impl::BC_ITEM_COUNT - 1;
+ Elm_Transit *tr2 = elm_transit_add();
+ elm_transit_effect_color_add(tr2, CU_COL_AO0115D, CU_COL_AO0115);
+ elm_transit_object_add(tr2, *m_rejBezelCueImg[m_rejBCAnimIndex]);
+ elm_transit_duration_set(tr2,
+ impl::BC_ANIMATION_DURATION[m_rejBCAnimIndex]);
+ elm_transit_objects_final_state_keep_set(tr2, EINA_TRUE);
+ elm_transit_del_cb_set(tr2,
+ CALLBACK_A(AcceptRejectWidget::onRejectBCTransitDel),
+ this);
+ elm_transit_go(tr2);
+ m_lastRejBezelTr1 = tr2;
+ }
+
+ void AcceptRejectWidget::setAcceptPressedTransitions()
+ {
+ setBezelCueVisible(false);
+
+ setAcceptTracerPressedTransition();
+ setAcceptGuidePressedTransition();
+ setAcceptIconPressedTransition();
+ setRejectIconHideTransition();
+ }
+
+ void AcceptRejectWidget::setAcceptTracerPressedTransition()
+ {
+ DEL_TRANSIT(m_accTracerTr);
+ m_accTracerTr = elm_transit_add();
+ elm_transit_effect_zoom_add(m_accTracerTr,
+ impl::ICON_ZOOM_EFF_VAL_MIN, impl::ICON_ZOOM_EFF_VAL_MID);
+ elm_transit_object_add(m_accTracerTr, *m_accTracer);
+ elm_transit_duration_set(m_accTracerTr, impl::ROTARY_ACTION_ANIM_DUR);
+ elm_transit_objects_final_state_keep_set(m_accTracerTr, EINA_FALSE);
+ elm_transit_del_cb_set(m_accTracerTr,
+ CALLBACK_A(AcceptRejectWidget::onAcceptTransitDel),
+ this);
+ elm_transit_go(m_accTracerTr);
+ }
+
+ void AcceptRejectWidget::setAcceptGuidePressedTransition()
+ {
+ DEL_TRANSIT(m_accGuideTr);
+ m_accGuideTr = elm_transit_add();
+ elm_transit_effect_zoom_add(m_accGuideTr,
+ impl::ICON_ZOOM_EFF_VAL_MIN, impl::ICON_ZOOM_EFF_VAL_MAX);
+ elm_transit_object_add(m_accGuideTr, *m_accGuide);
+ elm_transit_duration_set(m_accGuideTr, impl::ROTARY_ACTION_ANIM_DUR);
+ elm_transit_objects_final_state_keep_set(m_accGuideTr, EINA_FALSE);
+ elm_transit_del_cb_set(m_accGuideTr,
+ CALLBACK_A(AcceptRejectWidget::onAcceptBgExpandTransitDel),
+ this);
+ elm_transit_go(m_accGuideTr);
+ }
+
+ void AcceptRejectWidget::setAcceptIconPressedTransition()
+ {
+ DEL_TRANSIT(m_accIconTr);
+ m_accIconTr = elm_transit_add();
+ elm_transit_effect_color_add(m_accIconTr, CU_COL_AO0113, CU_COL_WHITE);
+ elm_transit_object_add(m_accIconTr, *m_accIcon);
+ elm_transit_duration_set(m_accIconTr, impl::ROTARY_ACTION_ANIM_DUR);
+ elm_transit_objects_final_state_keep_set(m_accIconTr, EINA_TRUE);
+ elm_transit_del_cb_set(m_accIconTr,
+ CALLBACK_A(AcceptRejectWidget::onAcceptIconTransitDel),
+ this);
+ elm_transit_go(m_accIconTr);
+ }
+
+ void AcceptRejectWidget::setRejectIconHideTransition()
+ {
+ DEL_TRANSIT(m_rejIconTr);
+
+ Evas_Coord x;
+ m_rejIcon->getGeometry(&x, nullptr, nullptr, nullptr);
+ int dx = x - impl::REJ_ICON_RIGHT_PAD_X;
+
+ int animTrace = impl::ACC_REJ_ICON_HIDE_THRESHOLD_W - dx;
+ if (animTrace <= 0) {
+ DLOG("No need to add transition");
+ return;
+ }
+
+ m_rejIconTr = elm_transit_add();
+ elm_transit_effect_translation_add(m_rejIconTr, 0, 0, animTrace, 0);
+ elm_transit_object_add(m_rejIconTr, *m_rejIcon);
+ elm_transit_duration_set(m_rejIconTr, impl::ROTARY_ACTION_ANIM_DUR);
+ elm_transit_objects_final_state_keep_set(m_rejIconTr, EINA_TRUE);
+ elm_transit_del_cb_set(m_rejIconTr,
+ CALLBACK_A(AcceptRejectWidget::onRejectIconTransitDel),
+ this);
+ elm_transit_go(m_rejIconTr);
+ }
+
+ void AcceptRejectWidget::setAcceptFullExpensionTransition()
+ {
+ DEL_TRANSIT(m_accTracerTr);
+ m_accTracerTr = elm_transit_add();
+ elm_transit_effect_zoom_add(m_accTracerTr,
+ impl::ICON_ZOOM_EFF_VAL_MIN, impl::ICON_ZOOM_EFF_VAL_MAX);
+ elm_transit_object_add(m_accTracerTr, *m_accTracer);
+ elm_transit_duration_set(m_accTracerTr, impl::ROTARY_ACTION_ANIM_DUR);
+ elm_transit_objects_final_state_keep_set(m_accTracerTr, EINA_FALSE);
+ elm_transit_del_cb_set(m_accTracerTr,
+ CALLBACK_A(AcceptRejectWidget::
+ onAcceptFullExpensionTransitDel),
+ this);
+ elm_transit_go(m_accTracerTr);
+
+ }
+
+ void AcceptRejectWidget::setAcceptGuideUnpressedTransition()
+ {
+ DEL_TRANSIT(m_accGuideTr);
+ m_accGuideTr = elm_transit_add();
+ elm_transit_effect_zoom_add(m_accGuideTr,
+ impl::ICON_ZOOM_EFF_VAL_MAX, impl::ICON_ZOOM_EFF_VAL_MIN);
+ elm_transit_object_add(m_accGuideTr, *m_accGuide);
+ elm_transit_duration_set(m_accGuideTr, impl::ROTARY_ACTION_ANIM_DUR);
+ elm_transit_objects_final_state_keep_set(m_accGuideTr, EINA_FALSE);
+ elm_transit_del_cb_set(m_accGuideTr,
+ CALLBACK_A(AcceptRejectWidget::onAcceptBgContractTransitDel),
+ this);
+ elm_transit_go(m_accGuideTr);
+ }
+
+ void AcceptRejectWidget::setRejectIconShowTransition()
+ {
+ DEL_TRANSIT(m_rejIconTr);
+
+ Evas_Coord x;
+ m_rejIcon->getGeometry(&x, nullptr, nullptr, nullptr);
+ int dx = impl::REJ_ICON_RIGHT_PAD_X - x;
+
+ if (dx >= 0) {
+ DLOG("No need to add transition");
+ return;
+ }
+
+ m_rejIconTr = elm_transit_add();
+ elm_transit_effect_translation_add(m_rejIconTr, 0, 0, dx, 0);
+ elm_transit_object_add(m_rejIconTr, *m_rejIcon);
+ elm_transit_duration_set(m_rejIconTr, impl::ROTARY_ACTION_ANIM_DUR);
+ elm_transit_objects_final_state_keep_set(m_rejIconTr, EINA_TRUE);
+ elm_transit_del_cb_set(m_rejIconTr,
+ CALLBACK_A(AcceptRejectWidget::onRejectIconTransitDel),
+ this);
+ elm_transit_go(m_rejIconTr);
+ }
+
+ void AcceptRejectWidget::setAcceptUnpressedTransitions()
+ {
+ setAcceptGuideUnpressedTransition();
+ setRejectIconShowTransition();
+ }
+
+ void AcceptRejectWidget::setRejectPressedTransitions()
+ {
+ setBezelCueVisible(false);
+
+ setRejectTracerPressedTransition();
+ setRejectGuidePressedTransition();
+ setRejectIconPressedTransition();
+ setAcceptIconHideTransition();
+ }
+
+ void AcceptRejectWidget::setRejectTracerPressedTransition()
+ {
+ DEL_TRANSIT(m_rejTracerTr);
+ m_rejTracerTr = elm_transit_add();
+ elm_transit_effect_zoom_add(m_rejTracerTr,
+ impl::ICON_ZOOM_EFF_VAL_MIN, impl::ICON_ZOOM_EFF_VAL_MID);
+ elm_transit_object_add(m_rejTracerTr, *m_rejTracer);
+ elm_transit_duration_set(m_rejTracerTr, impl::ROTARY_ACTION_ANIM_DUR);
+ elm_transit_objects_final_state_keep_set(m_rejTracerTr, EINA_FALSE);
+ elm_transit_del_cb_set(m_rejTracerTr,
+ CALLBACK_A(AcceptRejectWidget::onRejectTransitDel),
+ this);
+ elm_transit_go(m_rejTracerTr);
+ }
+
+ void AcceptRejectWidget::setRejectGuidePressedTransition()
+ {
+ DEL_TRANSIT(m_rejGuideTr);
+ m_rejGuideTr = elm_transit_add();
+ elm_transit_effect_zoom_add(m_rejGuideTr,
+ impl::ICON_ZOOM_EFF_VAL_MIN, impl::ICON_ZOOM_EFF_VAL_MAX);
+ elm_transit_object_add(m_rejGuideTr, *m_rejGuide);
+ elm_transit_duration_set(m_rejGuideTr, impl::ROTARY_ACTION_ANIM_DUR);
+ elm_transit_objects_final_state_keep_set(m_rejGuideTr, EINA_FALSE);
+ elm_transit_del_cb_set(m_rejGuideTr,
+ CALLBACK_A(AcceptRejectWidget::onRejectBgExpandTransitDel),
+ this);
+ elm_transit_go(m_rejGuideTr);
+ }
+
+ void AcceptRejectWidget::setRejectIconPressedTransition()
+ {
+ DEL_TRANSIT(m_rejIconTr);
+ m_rejIconTr = elm_transit_add();
+ elm_transit_effect_color_add(m_rejIconTr, CU_COL_AO0115, CU_COL_WHITE);
+ elm_transit_object_add(m_rejIconTr, *m_rejIcon);
+ elm_transit_duration_set(m_rejIconTr, impl::ROTARY_ACTION_ANIM_DUR);
+ elm_transit_objects_final_state_keep_set(m_rejIconTr, EINA_TRUE);
+ elm_transit_del_cb_set(m_rejIconTr,
+ CALLBACK_A(AcceptRejectWidget::onRejectIconTransitDel),
+ this);
+ elm_transit_go(m_rejIconTr);
+ }
+
+ void AcceptRejectWidget::setAcceptIconHideTransition()
+ {
+ DEL_TRANSIT(m_accIconTr);
+
+ Evas_Coord x;
+ m_accIcon->getGeometry(&x, nullptr, nullptr, nullptr);
+ int dx = impl::ACC_ICON_RIGHT_PAD_X - x;
+
+ int animTrace = dx - impl::ACC_REJ_ICON_HIDE_THRESHOLD_W;
+ if (animTrace >= 0) {
+ DLOG("No need to add transition");
+ return;
+ }
+ m_accIconTr = elm_transit_add();
+ elm_transit_effect_translation_add(m_accIconTr, 0, 0, animTrace, 0);
+ elm_transit_object_add(m_accIconTr, *m_accIcon);
+ elm_transit_duration_set(m_accIconTr, impl::ROTARY_ACTION_ANIM_DUR);
+ elm_transit_objects_final_state_keep_set(m_accIconTr, EINA_TRUE);
+ elm_transit_del_cb_set(m_accIconTr,
+ CALLBACK_A(AcceptRejectWidget::onAcceptIconTransitDel),
+ this);
+ elm_transit_go(m_accIconTr);
+ }
+
+ void AcceptRejectWidget::setAcceptIconShowTransition()
+ {
+ DEL_TRANSIT(m_accIconTr);
+
+ Evas_Coord x;
+ m_accIcon->getGeometry(&x, nullptr, nullptr, nullptr);
+ int dx = impl::ACC_ICON_RIGHT_PAD_X - x;
+
+ if (dx <= 0) {
+ DLOG("No need to add transition");
+ return;
+ }
+
+ m_accIconTr = elm_transit_add();
+ elm_transit_effect_translation_add(m_accIconTr, 0, 0, dx, 0);
+ elm_transit_object_add(m_accIconTr, *m_accIcon);
+ elm_transit_duration_set(m_accIconTr, impl::ROTARY_ACTION_ANIM_DUR);
+ elm_transit_objects_final_state_keep_set(m_accIconTr, EINA_TRUE);
+ elm_transit_del_cb_set(m_accIconTr,
+ CALLBACK_A(AcceptRejectWidget::onAcceptIconTransitDel),
+ this);
+ elm_transit_go(m_accIconTr);
+ }
+
+ void AcceptRejectWidget::setRejectFullExpensionTransition()
+ {
+ DEL_TRANSIT(m_rejTracerTr);
+ m_rejTracerTr = elm_transit_add();
+ elm_transit_effect_zoom_add(m_rejTracerTr,
+ impl::ICON_ZOOM_EFF_VAL_MIN, impl::ICON_ZOOM_EFF_VAL_MAX);
+ elm_transit_object_add(m_rejTracerTr, *m_rejTracer);
+ elm_transit_duration_set(m_rejTracerTr, impl::ROTARY_ACTION_ANIM_DUR);
+ elm_transit_objects_final_state_keep_set(m_rejTracerTr, EINA_FALSE);
+ elm_transit_del_cb_set(m_rejTracerTr,
+ CALLBACK_A(AcceptRejectWidget::
+ onRejectFullExpensionTransitDel),
+ this);
+ elm_transit_go(m_rejTracerTr);
+ }
+
+ void AcceptRejectWidget::setRejectUnpressedTransitions()
+ {
+ setRejectGuideUnpressedTransition();
+ setAcceptIconShowTransition();
+ }
+
+ void AcceptRejectWidget::setRejectGuideUnpressedTransition()
+ {
+ DEL_TRANSIT(m_rejGuideTr);
+ m_rejGuideTr = elm_transit_add();
+ elm_transit_effect_zoom_add(m_rejGuideTr,
+ impl::ICON_ZOOM_EFF_VAL_MAX, impl::ICON_ZOOM_EFF_VAL_MIN);
+ elm_transit_object_add(m_rejGuideTr, *m_rejGuide);
+ elm_transit_duration_set(m_rejGuideTr, impl::ROTARY_ACTION_ANIM_DUR);
+ elm_transit_objects_final_state_keep_set(m_rejGuideTr, EINA_FALSE);
+ elm_transit_del_cb_set(m_rejGuideTr,
+ CALLBACK_A(AcceptRejectWidget::onRejectBgContractTransitDel),
+ this);
+ elm_transit_go(m_rejGuideTr);
+ }
+
+ Result AcceptRejectWidget::createBezelCueComponents()
+ {
+ for (int i = 0; i < impl::BC_ITEM_COUNT; i++) {
+ // Accept
+ m_accBezelCueImg[i] = impl::createImage(*m_layout,
+ impl::ACCEPT_BC_PARAMS[i].theme);
+ if (!m_accBezelCueImg[i]) {
+ LOG_RETURN(RES_FAIL, "Create bezel cue image failed");
+ }
+ m_accBezelCueImg[i]->setColor(CU_COL_AO0113T);
+ show(*m_accBezelCueImg[i]);
+ m_layout->setContent(*m_accBezelCueImg[i],
+ impl::ACCEPT_BC_PARAMS[i].part);
+
+ // Reject
+ m_rejBezelCueImg[i] = impl::createImage(*m_layout,
+ impl::REJECT_BC_PARAMS[i].theme);
+ if (!m_rejBezelCueImg[i]) {
+ LOG_RETURN(RES_FAIL, "Create bezel cue image failed");
+ }
+ m_rejBezelCueImg[i]->setColor(CU_COL_AO0113T);
+ show(*m_rejBezelCueImg[i]);
+ m_layout->setContent(*m_rejBezelCueImg[i],
+ impl::REJECT_BC_PARAMS[i].part);
+ }
+ return RES_OK;
+ }
+
+ void AcceptRejectWidget::setBezelCueVisible(bool isVisible)
+ {
+ if (isVisible) {
+ for (int i = 0; i < impl::BC_ITEM_COUNT; i++) {
+ show(*m_accBezelCueImg[i]);
+ show(*m_rejBezelCueImg[i]);
+ }
+ } else {
+ for (int i = 0; i < impl::BC_ITEM_COUNT; i++) {
+ hide(*m_accBezelCueImg[i]);
+ hide(*m_rejBezelCueImg[i]);
+ }
+ }
+ }
+
+ void AcceptRejectWidget::onAcceptTransitDel(Elm_Transit *transit)
+ {
+ m_accTracerTr = nullptr;
+
+ impl::resizeImage(*m_accTracer, impl::FINGER_TRACER_DIM);
+ }
+
+ void AcceptRejectWidget::onAcceptFullExpensionTransitDel(
+ Elm_Transit *transit)
+ {
+ m_accTracerTr = nullptr;
+
+ m_isFreezed = true;
+ impl::resizeImage(*m_accTracer, impl::FINGER_STROKE_DIM);
+
+ if (m_accHandler) {
+ m_accHandler();
+ }
+ }
+
+ void AcceptRejectWidget::onAcceptBgExpandTransitDel(Elm_Transit *transit)
+ {
+ m_accGuideTr = nullptr;
+
+ impl::resizeImage(*m_accGuide, impl::FINGER_STROKE_DIM);
+ }
+
+ void AcceptRejectWidget::onAcceptBgContractTransitDel(
+ Elm_Transit *transit)
+ {
+ m_accGuideTr = nullptr;
+
+ m_accGuide->setColor(CU_COL_TRANSPARENT);
+ impl::resizeImage(*m_accGuide, impl::FINGER_TRACER_DIM);
+
+ m_isAccPressed = false;
+ m_isRejPressed = false;
+ m_isContracting = false;
+
+ setBezelCueVisible(true);
+ }
+
+ void AcceptRejectWidget::onAcceptIconTransitDel(Elm_Transit *transit)
+ {
+ m_accIconTr = nullptr;
+ }
+
+ void AcceptRejectWidget::onRejectTransitDel(Elm_Transit *transit)
+ {
+ m_rejTracerTr = nullptr;
+
+ impl::resizeImage(*m_rejTracer, impl::FINGER_TRACER_DIM);
+ }
+
+ void AcceptRejectWidget::onRejectFullExpensionTransitDel(
+ Elm_Transit *transit)
+ {
+ m_rejTracerTr = nullptr;
+
+ m_isFreezed = true;
+ impl::resizeImage(*m_rejTracer, impl::FINGER_STROKE_DIM);
+
+ if (m_rejHandler) {
+ m_rejHandler();
+ }
+
+ }
+
+ void AcceptRejectWidget::onRejectBgExpandTransitDel(Elm_Transit *transit)
+ {
+ m_rejGuideTr = nullptr;
+
+ impl::resizeImage(*m_rejGuide, impl::FINGER_STROKE_DIM);
+ }
+
+ void AcceptRejectWidget::onRejectBgContractTransitDel(
+ Elm_Transit *transit)
+ {
+ m_rejGuideTr = nullptr;
+
+ m_rejGuide->setColor(CU_COL_TRANSPARENT);
+ impl::resizeImage(*m_rejGuide, impl::FINGER_TRACER_DIM);
+
+ m_isAccPressed = false;
+ m_isRejPressed = false;
+ m_isContracting = false;
+
+ setBezelCueVisible(true);
+ }
+
+ void AcceptRejectWidget::onRejectIconTransitDel(Elm_Transit *transit)
+ {
+ m_rejIconTr = nullptr;
+ }
+
+ void AcceptRejectWidget::onAcceptBCTransitDel(Elm_Transit *transit)
+ {
+ if (m_accBCAnimIndex == 0) {
+ Elm_Transit *tr1 = elm_transit_add();
+ elm_transit_effect_color_add(tr1, CU_COL_AO0113, CU_COL_AO0113D);
+ elm_transit_object_add(tr1, *m_accBezelCueImg[m_accBCAnimIndex]);
+ elm_transit_duration_set(tr1,
+ impl::BC_ANIMATION_DURATION[impl::BC_ITEM_COUNT - 1]);
+ elm_transit_objects_final_state_keep_set(tr1, EINA_TRUE);
+ elm_transit_del_cb_set(tr1,
+ CALLBACK_A(AcceptRejectWidget::onAcceptBCTransitDelLast),
+ this);
+ elm_transit_go(tr1);
+
+ m_lastAccBezelTr1 = tr1;
+ m_lastAccBezelTr2 = nullptr;
+ return;
+ }
+
+ int oldIndex = m_accBCAnimIndex;
+ m_accBCAnimIndex--;
+
+ Elm_Transit *tr1 = elm_transit_add();
+ elm_transit_effect_color_add(tr1, CU_COL_AO0113, CU_COL_AO0113D);
+ elm_transit_object_add(tr1, *m_accBezelCueImg[oldIndex]);
+ elm_transit_duration_set(tr1,
+ impl::BC_ANIMATION_DURATION[m_accBCAnimIndex]);
+ elm_transit_objects_final_state_keep_set(tr1, EINA_TRUE);
+ elm_transit_go(tr1);
+
+ Elm_Transit *tr2 = elm_transit_add();
+ elm_transit_effect_color_add(tr2, CU_COL_AO0113D, CU_COL_AO0113);
+ elm_transit_object_add(tr2, *m_accBezelCueImg[m_accBCAnimIndex]);
+ elm_transit_duration_set(tr2,
+ impl::BC_ANIMATION_DURATION[m_accBCAnimIndex]);
+ elm_transit_objects_final_state_keep_set(tr2, EINA_TRUE);
+ elm_transit_del_cb_set(tr2,
+ CALLBACK_A(AcceptRejectWidget::onAcceptBCTransitDel),
+ this);
+ elm_transit_go(tr2);
+
+ m_lastAccBezelTr1 = tr1;
+ m_lastAccBezelTr2 = tr2;
+ }
+
+ void AcceptRejectWidget::onAcceptBCTransitDelLast(Elm_Transit *transit)
+ {
+ m_accBCAnimCount++;
+
+ if (m_accBCAnimCount >= impl::BC_ANIMATE_COUNT_MAX) {
+ ILOG("Max count accept bezel animation reached. Hide all image");
+ m_accBCAnimCount = 0;
+
+ Elm_Transit *hideTransit = elm_transit_add();
+ elm_transit_effect_color_add(hideTransit,
+ CU_COL_AO0113D, CU_COL_AO0113T);
+ for (int i = 0; i < impl::BC_ITEM_COUNT; i++) {
+ m_accBezelCueImg[i]->setColor(CU_COL_AO0113D);
+ elm_transit_object_add(hideTransit, *m_accBezelCueImg[i]);
+ }
+ elm_transit_duration_set(hideTransit, impl::BC_ANIM_DUR_HIDE);
+ elm_transit_objects_final_state_keep_set(hideTransit, EINA_TRUE);
+ elm_transit_del_cb_set(hideTransit,
+ [](void *data, Elm_Transit *transit) -> void
+ {
+ auto self = static_cast<AcceptRejectWidget *>(data);
+ self->m_lastAccBezelTr1 = nullptr;
+ self->m_lastAccBezelTr2 = nullptr;
+ }, this);
+ elm_transit_go(hideTransit);
+
+ m_lastAccBezelTr1 = hideTransit;
+ m_lastAccBezelTr2 = nullptr;
+ return;
+ }
+
+ m_accBCAnimIndex = impl::BC_ITEM_COUNT - 1;
+ Elm_Transit *tr1 = elm_transit_add();
+ elm_transit_effect_color_add(tr1, CU_COL_AO0113D, CU_COL_AO0113);
+ elm_transit_object_add(tr1, *m_accBezelCueImg[m_accBCAnimIndex]);
+ elm_transit_duration_set(tr1,
+ impl::BC_ANIMATION_DURATION[m_accBCAnimIndex]);
+ elm_transit_objects_final_state_keep_set(tr1, EINA_TRUE);
+ elm_transit_del_cb_set(tr1,
+ CALLBACK_A(AcceptRejectWidget::onAcceptBCTransitDel),
+ this);
+ elm_transit_go(tr1);
+
+ m_lastAccBezelTr1 = tr1;
+ m_lastAccBezelTr2 = nullptr;
+ }
+
+ void AcceptRejectWidget::onRejectBCTransitDel(Elm_Transit *transit)
+ {
+ if (m_rejBCAnimIndex == 0) {
+ Elm_Transit *tr1 = elm_transit_add();
+ elm_transit_effect_color_add(tr1, CU_COL_AO0115, CU_COL_AO0115D);
+ elm_transit_object_add(tr1, *m_rejBezelCueImg[m_rejBCAnimIndex]);
+ elm_transit_duration_set(tr1,
+ impl::BC_ANIMATION_DURATION[impl::BC_ITEM_COUNT - 1]);
+ elm_transit_objects_final_state_keep_set(tr1, EINA_TRUE);
+ elm_transit_del_cb_set(tr1,
+ CALLBACK_A(AcceptRejectWidget::onRejectBCTransitDelLast),
+ this);
+ elm_transit_go(tr1);
+ m_lastRejBezelTr1 = tr1;
+ m_lastRejBezelTr2 = nullptr;
+ return;
+ }
+
+ int oldIndex = m_rejBCAnimIndex;
+ m_rejBCAnimIndex--;
+
+ Elm_Transit *tr1 = elm_transit_add();
+ elm_transit_effect_color_add(tr1, CU_COL_AO0115, CU_COL_AO0115D);
+ elm_transit_object_add(tr1, *m_rejBezelCueImg[oldIndex]);
+ elm_transit_duration_set(tr1,
+ impl::BC_ANIMATION_DURATION[m_rejBCAnimIndex]);
+ elm_transit_objects_final_state_keep_set(tr1, EINA_TRUE);
+ elm_transit_go(tr1);
+
+ Elm_Transit *tr2 = elm_transit_add();
+ elm_transit_effect_color_add(tr2, CU_COL_AO0115D, CU_COL_AO0115);
+ elm_transit_object_add(tr2, *m_rejBezelCueImg[m_rejBCAnimIndex]);
+ elm_transit_duration_set(tr2,
+ impl::BC_ANIMATION_DURATION[m_rejBCAnimIndex]);
+ elm_transit_objects_final_state_keep_set(tr2, EINA_TRUE);
+ elm_transit_del_cb_set(tr2,
+ CALLBACK_A(AcceptRejectWidget::onRejectBCTransitDel),
+ this);
+ elm_transit_go(tr2);
+
+ m_lastRejBezelTr1 = tr1;
+ m_lastRejBezelTr2 = tr2;
+ }
+
+ void AcceptRejectWidget::onRejectBCTransitDelLast(Elm_Transit *transit)
+ {
+ m_rejBCAnimCount++;
+
+ if (m_rejBCAnimCount >= impl::BC_ANIMATE_COUNT_MAX) {
+ ILOG("Max count accept bezel animation reached. Hide all image");
+ m_rejBCAnimCount = 0;
+
+ Elm_Transit *hideTransit = elm_transit_add();
+ elm_transit_effect_color_add(hideTransit,
+ CU_COL_AO0115D, CU_COL_AO0115T);
+ for (int i = 0; i < impl::BC_ITEM_COUNT; i++) {
+ m_rejBezelCueImg[i]->setColor(CU_COL_AO0115D);
+ elm_transit_object_add(hideTransit, *m_rejBezelCueImg[i]);
+ }
+ elm_transit_duration_set(hideTransit, impl::BC_ANIM_DUR_HIDE);
+ elm_transit_objects_final_state_keep_set(hideTransit, EINA_TRUE);
+ elm_transit_del_cb_set(hideTransit,
+ [](void *data, Elm_Transit *transit) -> void
+ {
+ auto self = static_cast<AcceptRejectWidget *>(data);
+ self->m_lastRejBezelTr1 = nullptr;
+ self->m_lastRejBezelTr2 = nullptr;
+ }, this);
+ elm_transit_go(hideTransit);
+
+ m_lastRejBezelTr1 = hideTransit;
+ m_lastRejBezelTr2 = nullptr;
+ return;
+ }
+
+ m_rejBCAnimIndex = impl::BC_ITEM_COUNT - 1;
+ Elm_Transit *tr1 = elm_transit_add();
+ elm_transit_effect_color_add(tr1, CU_COL_AO0115D, CU_COL_AO0115);
+ elm_transit_object_add(tr1, *m_rejBezelCueImg[m_rejBCAnimIndex]);
+ elm_transit_duration_set(tr1,
+ impl::BC_ANIMATION_DURATION[m_rejBCAnimIndex]);
+ elm_transit_objects_final_state_keep_set(tr1, EINA_TRUE);
+ elm_transit_del_cb_set(tr1,
+ CALLBACK_A(AcceptRejectWidget::onRejectBCTransitDel),
+ this);
+ elm_transit_go(tr1);
+
+ m_lastRejBezelTr1 = tr1;
+ m_lastRejBezelTr2 = nullptr;
+ }
+
+ void AcceptRejectWidget::onAcceptExpandTimeout(Timeout *sender)
+ {
+ if (m_rotaryClockwiseCount > 0) {
+ m_rotaryClockwiseCount = 0;
+ m_isContracting = true;
+ setAcceptUnpressedState();
+ } else {
+ DLOG("Counter is 0. Ignored");
+ }
+ m_expandTimeout.reset();
+ }
+
+ void AcceptRejectWidget::onRejectExpandTimeout(Timeout *sender)
+ {
+ if (m_rotaryCounterClockwiseCount > 0) {
+ m_rotaryCounterClockwiseCount = 0;
+ m_isContracting = true;
+ setRejectUnpressedState();
+ } else {
+ DLOG("Counter is 0. Ignored");
+ }
+ m_expandTimeout.reset();
+ }
+
+ Eina_Bool AcceptRejectWidget::processClockwiseRotaryEvent()
+ {
+ if (m_rotaryCounterClockwiseCount > 0) {
+ m_rotaryCounterClockwiseCount = 0;
+ setRejectUnpressedState();
+ return EINA_TRUE;
+ }
+
+ m_rotaryClockwiseCount++;
+
+ if (m_rotaryClockwiseCount == 1) {
+ setAcceptPressedState();
+ m_expandTimeout = Timeout::create(impl::EXPAND_WAITING_TIMEOUT,
+ WEAK_DELEGATE(AcceptRejectWidget::onAcceptExpandTimeout,
+ asWeak(*this)));
+ } else if (m_rotaryClockwiseCount == 2) {
+ m_expandTimeout.reset();
+ impl::resizeImage(*m_accTracer, impl::FINGER_TRACER_DIM);
+ setAcceptFullExpensionTransition();
+ return EINA_TRUE;
+ } else {
+ LOG_RETURN_VALUE(RES_FAIL, EINA_TRUE, "Illegal state");
+ }
+ return EINA_TRUE;
+ }
+
+ Eina_Bool AcceptRejectWidget::processCounterClockwiseRotaryEvent()
+ {
+ if (m_rotaryClockwiseCount > 0) {
+ m_rotaryClockwiseCount = 0;
+ setAcceptUnpressedState();
+ return EINA_TRUE;
+ }
+
+ m_rotaryCounterClockwiseCount ++;
+
+ if (m_rotaryCounterClockwiseCount == 1) {
+ setRejectPressedState();
+ m_expandTimeout = Timeout::create(impl::EXPAND_WAITING_TIMEOUT,
+ WEAK_DELEGATE(AcceptRejectWidget::onRejectExpandTimeout,
+ asWeak(*this)));
+
+ } else if (m_rotaryCounterClockwiseCount == 2) {
+ m_expandTimeout.reset();
+ impl::resizeImage(*m_rejTracer, impl::FINGER_TRACER_DIM);
+ setRejectFullExpensionTransition();
+ return EINA_TRUE;
+ } else {
+ LOG_RETURN_VALUE(RES_FAIL, EINA_TRUE, "Illegal state");
+ }
+ return EINA_TRUE;
+ }
+
+ Eina_Bool AcceptRejectWidget::onRotaryEvent(Evas_Object *obj,
+ Eext_Rotary_Event_Info *info)
+ {
+ if (m_isFreezed) {
+ DLOG("Freezed");
+ return EINA_TRUE;
+ }
+
+ if (m_isAccPressed || m_isRejPressed) {
+ LOG_RETURN_VALUE(RES_FAIL, EINA_TRUE,
+ "Button accept/reject button already pressed");
+ }
+
+ m_expandTimeout.reset();
+
+ if (m_isContracting) {
+ DLOG("Contracting. Ignore");
+ return EINA_TRUE;
+ }
+
+ if (info->direction == EEXT_ROTARY_DIRECTION_CLOCKWISE) {
+ DLOG("Rotary event [CLOCKWISE]");
+ return processClockwiseRotaryEvent();
+ } else {
+ DLOG("Rotary event [COUNTER_CLOCKWISE]");
+ return processCounterClockwiseRotaryEvent();
+ }
+ }
+
+ void AcceptRejectWidget::activateRotary()
+ {
+ eext_rotary_object_event_activated_set(*m_layout, EINA_TRUE);
+ }
+ void AcceptRejectWidget::deactivateRotary()
+ {
+ eext_rotary_object_event_activated_set(*m_layout, EINA_FALSE);
+ }
+
+ void AcceptRejectWidget::setAcceptBtnType(AcceptButtonType type)
+ {
+ if (m_acceptBtnType == type) {
+ DLOG("Accept icon type is already set");
+ }
+
+ if (!m_accIcon) {
+ return;
+ }
+
+ switch (m_acceptBtnType) {
+ case AcceptButtonType::BT_HEADSET:
+ m_accIcon->setTheme(impl::LAYOUT_IMG_ACCEPT_BT_HEADSET);
+ break;
+ default:
+ m_accIcon->setTheme(impl::LAYOUT_IMG_ACCEPT);
+ break;
+ }
+ }
+
+ void AcceptRejectWidget::reset()
+ {
+ m_isFreezed = false;
+
+ DEL_TRANSIT(m_accTracerTr);
+ DEL_TRANSIT(m_accGuideTr);
+ DEL_TRANSIT(m_accIconTr);
+
+ DEL_TRANSIT(m_rejTracerTr);
+ DEL_TRANSIT(m_rejGuideTr);
+ DEL_TRANSIT(m_rejIconTr);
+
+ m_lastMoveDistance = impl::INIT_MOVE_DISTANCE_VAL;
+
+ setAcceptUnpressedState();
+ setRejectUnpressedState();
+
+ m_rotaryClockwiseCount = 0;
+ m_rotaryCounterClockwiseCount = 0;
+ }
+
+ void AcceptRejectWidget::setAcceptPressedState()
+ {
+ impl::resizeImage(*m_accTracer, impl::FINGER_TRACER_HALF_DIM);
+ m_accTracer->setColor(CU_COL_AO01131);
+
+ impl::resizeImage(*m_accGuide, impl::FINGER_TRACER_DIM);
+ m_accGuide->setColor(CU_COL_AO01132);
+
+ setAcceptPressedTransitions();
+ }
+
+ void AcceptRejectWidget::setRejectPressedState()
+ {
+ impl::resizeImage(*m_rejTracer, impl::FINGER_TRACER_HALF_DIM);
+ m_rejTracer->setColor(CU_COL_AO01151);
+
+ impl::resizeImage(*m_rejGuide, impl::FINGER_TRACER_DIM);
+ m_rejGuide->setColor(CU_COL_AO01152);
+
+ setRejectPressedTransitions();
+ }
+
+ void AcceptRejectWidget::setAcceptUnpressedState()
+ {
+ impl::resizeImage(*m_accTracer, impl::FINGER_TRACER_HALF_DIM);
+ m_accTracer->setColor(CU_COL_TRANSPARENT);
+
+ m_accIcon->setColor(CU_COL_AO0113);
+
+ impl::resizeImage(*m_accGuide, impl::FINGER_TRACER_DIM);
+
+ setAcceptUnpressedTransitions();
+ }
+
+ void AcceptRejectWidget::setRejectUnpressedState()
+ {
+ impl::resizeImage(*m_rejTracer, impl::FINGER_TRACER_HALF_DIM);
+ m_rejTracer->setColor(CU_COL_TRANSPARENT);
+
+ m_rejIcon->setColor(CU_COL_AO0115);
+
+ impl::resizeImage(*m_rejGuide, impl::FINGER_TRACER_DIM);
+
+ setRejectUnpressedTransitions();
+ }
+
+ // Screen Reader
+ ElmWidget *AcceptRejectWidget::getAcceptAo()
+ {
+ return m_accAo.get();
+ }
+
+ ElmWidget *AcceptRejectWidget::getRejectAo()
+ {
+ return m_rejAo.get();
+ }
+
+ Result AcceptRejectWidget::registerAccessObjects(ElmWidget &parent)
+ {
+ m_accAo = utils::createAccessObject(parent, *m_accEventLy);
+ if (!m_accAo) {
+ LOG_RETURN(RES_FAIL, "createAccessObject() failed!");
+ }
+ elm_atspi_accessible_translation_domain_set(*m_accAo, PACKAGE);
+ elm_atspi_accessible_reading_info_type_set(*m_accAo,
+ ELM_ACCESSIBLE_READING_INFO_TYPE_NAME |
+ ELM_ACCESSIBLE_READING_INFO_TYPE_DESCRIPTION);
+ elm_atspi_accessible_name_set(*m_accAo, AO_STR_ACCEPT_CALL);
+ elm_atspi_accessible_description_set(*m_accAo,
+ AO_STR_SWIPE_RIGHT_WITH_TWO_FINGERS_TO_ACCEPT);
+
+ m_rejAo = utils::createAccessObject(parent, *m_rejEventLy);
+ if (!m_rejAo) {
+ LOG_RETURN(RES_FAIL, "createAccessObject() failed!");
+ }
+ elm_atspi_accessible_translation_domain_set(*m_rejAo, PACKAGE);
+ elm_atspi_accessible_reading_info_type_set(*m_rejAo,
+ ELM_ACCESSIBLE_READING_INFO_TYPE_NAME |
+ ELM_ACCESSIBLE_READING_INFO_TYPE_DESCRIPTION);
+ elm_atspi_accessible_name_set(*m_rejAo, AO_STR_REJECT_CALL);
+ elm_atspi_accessible_description_set(*m_rejAo,
+ AO_STR_SWIPE_LEFT_WITH_TWO_FINGERS_TO_REJECT);
+
+ return RES_OK;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_VIEW_ACCEPT_REJECT_WIDGET_H__
+#define __CALL_UI_VIEW_ACCEPT_REJECT_WIDGET_H__
+
+#include "ucl/gui/ElmWidget.h"
+
+#include "ucl/gui/Layout.h"
+#include "ucl/gui/StyledWidget.h"
+#include "ucl/misc/Timeout.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(AcceptRejectWidget);
+
+ class AcceptRejectWidget final : public ucl::ElmWidget {
+ public:
+ class Builder {
+ public:
+ Builder();
+ Builder &setAcceptEventHandler(const NotiHandler &handler);
+ Builder &setRejectEventHandler(const NotiHandler &handler);
+ Builder &setAcceptBtnType(AcceptButtonType type);
+ AcceptRejectWidgetSRef build(ucl::ElmWidget &parent) const;
+
+ private:
+ NotiHandler m_acceptHandler;
+ NotiHandler m_rejectHandler;
+ AcceptButtonType m_acceptBtnType;
+ };
+
+ public:
+ ~AcceptRejectWidget();
+
+ void startBezelCueAnimation();
+ void reset();
+ void activateRotary();
+ void deactivateRotary();
+ void setAcceptBtnType(AcceptButtonType type);
+
+ // Screen Reader
+ ucl::ElmWidget *getAcceptAo();
+ ucl::ElmWidget *getRejectAo();
+
+ private:
+ friend class ucl::ReffedObj<AcceptRejectWidget>;
+ AcceptRejectWidget(ucl::IRefCountObj &rc,
+ const ucl::LayoutSRef &layout,
+ const NotiHandler &acceptHandler,
+ const NotiHandler &rejectHandler,
+ AcceptButtonType acceptBtnType);
+
+ void prepare();
+
+ ucl::Result createAcceptComponents();
+ ucl::Result createRejectComponents();
+ ucl::Result createBezelCueComponents();
+
+ void setBezelCueVisible(bool isVisible);
+
+ void onMouseDown(ucl::Widget &widget, void *eventInfo);
+ void onMouseUp(ucl::Widget &widget, void *eventInfo);
+ void onMouseMove(ucl::Widget &widget, void *eventInfo);
+
+ int getTracerMoveDistance(
+ const ElmWidget &widget, int curX, int curY) const;
+
+ void onAcceptBCTransitDel(Elm_Transit *transit);
+ void onAcceptBCTransitDelLast(Elm_Transit *transit);
+
+ void onRejectBCTransitDel(Elm_Transit *transit);
+ void onRejectBCTransitDelLast(Elm_Transit *transit);
+
+ void setAcceptPressedTransitions();
+ void setAcceptTracerPressedTransition();
+ void setAcceptGuidePressedTransition();
+ void setAcceptGuideUnpressedTransition();
+ void setAcceptIconPressedTransition();
+ void setRejectIconHideTransition();
+ void setRejectIconShowTransition();
+ void setAcceptFullExpensionTransition();
+ void setAcceptUnpressedTransitions();
+
+ void setRejectPressedTransitions();
+ void setRejectTracerPressedTransition();
+ void setRejectGuidePressedTransition();
+ void setRejectGuideUnpressedTransition();
+ void setRejectIconPressedTransition();
+ void setAcceptIconHideTransition();
+ void setAcceptIconShowTransition();
+ void setRejectFullExpensionTransition();
+ void setRejectUnpressedTransitions();
+
+ void onAcceptTransitDel(Elm_Transit *transit);
+ void onAcceptFullExpensionTransitDel(Elm_Transit *transit);
+ void onAcceptBgExpandTransitDel(Elm_Transit *transit);
+ void onAcceptBgContractTransitDel(Elm_Transit *transit);
+ void onAcceptIconTransitDel(Elm_Transit *transit);
+
+ void onRejectTransitDel(Elm_Transit *transit);
+ void onRejectFullExpensionTransitDel(Elm_Transit *transit);
+ void onRejectBgExpandTransitDel(Elm_Transit *transit);
+ void onRejectBgContractTransitDel(Elm_Transit *transit);
+ void onRejectIconTransitDel(Elm_Transit *transit);
+
+ void onAcceptExpandTimeout(ucl::Timeout *sender);
+ void onRejectExpandTimeout(ucl::Timeout *sender);
+
+ Eina_Bool onRotaryEvent(Evas_Object *obj, Eext_Rotary_Event_Info *info);
+ Eina_Bool processClockwiseRotaryEvent();
+ Eina_Bool processCounterClockwiseRotaryEvent();
+
+ void setAcceptPressedState();
+ void setRejectPressedState();
+ void setAcceptUnpressedState();
+ void setRejectUnpressedState();
+
+ // Screen Reader
+ ucl::Result registerAccessObjects(
+ ucl::ElmWidget &widget);
+
+ private:
+ ucl::Layout *m_layout;
+ NotiHandler m_accHandler;
+ NotiHandler m_rejHandler;
+
+ std::vector<ucl::ElmWidgetSRef> m_accBezelCueImg;
+ std::vector<ucl::ElmWidgetSRef> m_rejBezelCueImg;
+
+ ucl::LayoutSRef m_accTracer;
+ ucl::LayoutSRef m_accGuide;
+ ucl::LayoutSRef m_accIcon;
+ ucl::LayoutSRef m_accEventLy;
+
+ ucl::LayoutSRef m_rejTracer;
+ ucl::LayoutSRef m_rejGuide;
+ ucl::LayoutSRef m_rejIcon;
+ ucl::LayoutSRef m_rejEventLy;
+
+ bool m_isFreezed;
+ bool m_isAccPressed;
+ bool m_isRejPressed;
+ int m_lastMoveDistance;
+ int m_rotaryClockwiseCount;
+ int m_rotaryCounterClockwiseCount;
+ bool m_isContracting;
+
+ Elm_Transit *m_accTracerTr;
+ Elm_Transit *m_accGuideTr;
+ Elm_Transit *m_accIconTr;
+
+ Elm_Transit *m_rejTracerTr;
+ Elm_Transit *m_rejGuideTr;
+ Elm_Transit *m_rejIconTr;
+
+ Elm_Transit *m_lastAccBezelTr1;
+ Elm_Transit *m_lastAccBezelTr2;
+ Elm_Transit *m_lastRejBezelTr1;
+ Elm_Transit *m_lastRejBezelTr2;
+
+ int m_accBCAnimCount;
+ int m_rejBCAnimCount;
+
+ ucl::TimeoutSRef m_expandTimeout;
+
+ int m_accBCAnimIndex;
+ int m_rejBCAnimIndex;
+
+ AcceptButtonType m_acceptBtnType;
+
+ // Screen Reader
+ ucl::ElmWidgetSRef m_accAo;
+ ucl::ElmWidgetSRef m_rejAo;
+ };
+
+}
+
+#endif // __CALL_UI_VIEW_ACCEPT_REJECT_WIDGET_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "call-ui/view/Slider.h"
+
+#include "common.h"
+
+namespace callui { namespace { namespace impl {
+
+ using namespace ucl;
+
+ constexpr LayoutTheme LAYOUT_SLIDER
+ {"layout", "callui", "slider"};
+
+ constexpr EdjePart PART_SWL_SLIDER {"swl.slider"};
+}}}
+
+namespace callui {
+
+ using namespace ucl;
+
+ Slider::Builder::Builder():
+ m_maxValue(0),
+ m_curValue(0)
+ {
+ }
+
+ Slider::Builder &Slider::Builder::setMaxValue(int maxValue)
+ {
+ m_maxValue = maxValue;
+ return *this;
+ }
+
+ Slider::Builder &Slider::Builder::setValue(int curValue)
+ {
+ m_curValue = curValue;
+ return *this;
+ }
+
+ SliderSRef Slider::Builder::build(ElmWidget &parent) const
+ {
+ auto layout = Layout::Builder().
+ setTheme(impl::LAYOUT_SLIDER).
+ setIsOwner(true).
+ build(parent);
+ if (!layout) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "Layout::build() failed!");
+ }
+
+ auto result = makeShared<Slider>(layout, m_maxValue, m_curValue);
+
+ result->bindToEo();
+
+ return result;
+ }
+
+ Slider::Slider(IRefCountObj &rc,
+ const LayoutSRef &layout,
+ int maxValue,
+ int curValue):
+ ElmWidget(&rc, *layout, true),
+ m_layout(layout.get()),
+ m_circleLy(elm_layout_add(*m_layout)),
+ m_circleSurf(eext_circle_surface_layout_add(m_circleLy)),
+ m_slider(eext_circle_object_slider_add(*m_layout, m_circleSurf))
+ {
+ prepare(maxValue, curValue);
+ }
+
+ Slider::~Slider()
+ {
+ }
+
+ void Slider::prepare(int maxValue, int curValue)
+ {
+ m_layout->setIsOwner(false);
+
+ m_slider.setAlign(EVAS_HINT_FILL, EVAS_HINT_FILL);
+ m_slider.setWeight(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ m_layout->setContent(m_circleLy, impl::PART_SWL_SLIDER);
+ show(m_circleLy);
+ show(m_slider);
+ show(*m_layout);
+
+ setMaxValue(maxValue);
+ setValue(curValue);
+
+ // Screen Reader
+ elm_atspi_accessible_role_set(m_slider,
+ ELM_ATSPI_ROLE_REDUNDANT_OBJECT);
+ elm_atspi_accessible_role_set(m_circleLy,
+ ELM_ATSPI_ROLE_REDUNDANT_OBJECT);
+ elm_atspi_accessible_role_set(*m_layout,
+ ELM_ATSPI_ROLE_REDUNDANT_OBJECT);
+ }
+
+ void Slider::setValue(int value)
+ {
+ eext_circle_object_value_set(m_slider, static_cast<double>(value));
+ }
+
+ void Slider::setMaxValue(int maxValue)
+ {
+ eext_circle_object_value_min_max_set(m_slider, 0, maxValue);
+ }
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_VIEW_SLIDER_H__
+#define __CALL_UI_VIEW_SLIDER_H__
+
+#include "ucl/gui/Layout.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(Slider);
+
+ class Slider : public ucl::ElmWidget {
+ public:
+ class Builder {
+ public:
+ Builder();
+ Builder &setMaxValue(int maxValue);
+ Builder &setValue(int curValue);
+ SliderSRef build(ucl::ElmWidget &parent) const;
+
+ private:
+ int m_maxValue;
+ int m_curValue;
+ };
+
+ public:
+ virtual void setValue(int value);
+ virtual void setMaxValue(int maxValue);
+
+ protected:
+ friend class ucl::ReffedObj<Slider>;
+ Slider(ucl::IRefCountObj &rc,
+ const ucl::LayoutSRef &layout,
+ int maxValue,
+ int curValue);
+ virtual ~Slider();
+
+ private:
+ void prepare(int maxValue, int curValue);
+
+ protected:
+ ucl::Layout *m_layout;
+ ucl::Layout m_circleLy;
+ Eext_Circle_Surface *m_circleSurf;
+ ucl::ElmWidget m_slider;
+ };
+
+}
+
+#endif // __CALL_UI_VIEW_SLIDER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "call-ui/view/VolumeControl.h"
+
+#include "call-ui/resources.h"
+#include "common.h"
+
+namespace callui { namespace { namespace impl {
+
+ using namespace ucl;
+
+ constexpr LayoutTheme LAYOUT_VOLUME
+ {"layout", "callui", "volume_control"};
+
+ constexpr ElmStyle STYLE_BTN_MINUS {"callui/minus"};
+ constexpr ElmStyle STYLE_BTN_PLUS {"callui/plus"};
+
+ constexpr EdjePart PART_SWL_MINUS {"swl.minus"};
+ constexpr EdjePart PART_SWL_PLUS {"swl.plus"};
+
+ constexpr EdjePart PART_TXT_INFO {"txt.info"};
+ constexpr EdjePart PART_TXT_VALUE {"txt.value"};
+ constexpr EdjePart PART_TXT_VALUE_AO {"ao_txt.value"};
+
+}}}
+
+namespace callui {
+
+ using namespace ucl;
+
+ VolumeControl::Builder::Builder():
+ m_maxValue(0),
+ m_curValue(0)
+ {
+ }
+
+ VolumeControl::Builder &VolumeControl::Builder::setInfoText(const TString &info)
+ {
+ m_info = info;
+ return *this;
+ }
+
+ VolumeControl::Builder &VolumeControl::Builder::setMaxValue(int maxValue)
+ {
+ m_maxValue = maxValue;
+ return *this;
+ }
+
+ VolumeControl::Builder &VolumeControl::Builder::setValue(int curValue)
+ {
+ m_curValue = curValue;
+ return *this;
+ }
+
+ VolumeControl::Builder &VolumeControl::Builder::setEventHandler(
+ const EventHandler &handler)
+ {
+ m_handler = handler;
+ return *this;
+ }
+
+ VolumeControlSRef VolumeControl::Builder::build(ElmWidget &parent) const
+ {
+ auto layout = Layout::Builder().
+ setTheme(impl::LAYOUT_VOLUME).
+ setIsOwner(true).
+ build(parent);
+ if (!layout) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "Layout::build() failed!");
+ }
+
+ auto result = makeShared<VolumeControl>(layout,
+ m_info,
+ m_maxValue,
+ m_curValue,
+ m_handler);
+
+ result->bindToEo();
+
+ return result;
+ }
+
+ VolumeControl::VolumeControl(IRefCountObj &rc,
+ const LayoutSRef &layout,
+ const TString &info,
+ int maxValue,
+ int curValue,
+ const EventHandler &handler):
+ Slider(rc, layout, maxValue, curValue),
+ m_decreaseBtn(elm_button_add(*m_layout)),
+ m_increaseBtn(elm_button_add(*m_layout)),
+ m_handler(handler)
+ {
+ prepare(info, curValue);
+ }
+
+ VolumeControl::~VolumeControl()
+ {
+ }
+
+ void VolumeControl::prepare(const TString &info, int curValue)
+ {
+ m_layout->addEventHandler(WidgetEvent::SHOW, WEAK_DELEGATE(
+ VolumeControl::onWidgetShowCb, asWeak(*this)));
+ m_layout->addEventHandler(WidgetEvent::HIDE, WEAK_DELEGATE(
+ VolumeControl::onWidgetHideCb, asWeak(*this)));
+
+ m_decreaseBtn.setStyle(impl::STYLE_BTN_MINUS);
+ m_decreaseBtn.addEventHandler(BTN_CLICKED, WEAK_DELEGATE(
+ VolumeControl::onDecreaseBtnClickedCb, asWeak(*this)));
+ m_layout->setContent(m_decreaseBtn, impl::PART_SWL_MINUS);
+ show(m_decreaseBtn);
+
+ m_increaseBtn.setStyle(impl::STYLE_BTN_PLUS);
+ m_increaseBtn.addEventHandler(BTN_CLICKED, WEAK_DELEGATE(
+ VolumeControl::onIncreaseBtnClickedCb, asWeak(*this)));
+ m_layout->setContent(m_increaseBtn, impl::PART_SWL_PLUS);
+ show(m_increaseBtn);
+
+ setInfoText(info);
+ setValue(curValue);
+
+ registerAccessObjectInformation();
+ }
+
+ void VolumeControl::onWidgetShowCb(Widget &widget, void *eventInfo)
+ {
+ if (m_valueTxtAo)
+ show(*m_valueTxtAo);
+ }
+
+ void VolumeControl::onWidgetHideCb(Widget &widget, void *eventInfo)
+ {
+ if (m_valueTxtAo)
+ hide(*m_valueTxtAo);
+ }
+
+ void VolumeControl::setInfoText(const TString &info)
+ {
+ m_layout->setText(info.translate(), impl::PART_TXT_INFO);
+ }
+
+ void VolumeControl::setValue(int value)
+ {
+ eext_circle_object_value_set(m_slider, static_cast<double>(value));
+ m_layout->setText(std::to_string(value), impl::PART_TXT_VALUE);
+ }
+
+ void VolumeControl::setIncreaseBtnEnable(bool isEnable)
+ {
+ isEnable ? enable(m_increaseBtn) : disable(m_increaseBtn);
+ }
+
+ void VolumeControl::setDecreaseBtnEnable(bool isEnable)
+ {
+ isEnable ? enable(m_decreaseBtn) : disable(m_decreaseBtn);
+ }
+
+ void VolumeControl::setEventHandler(
+ const EventHandler &handler)
+ {
+ m_handler = handler;
+ }
+
+ void VolumeControl::onDecreaseBtnClickedCb(Widget &widget, void *eventInfo)
+ {
+ if (m_handler) {
+ m_handler(Event::DECREASE);
+ }
+ }
+
+ void VolumeControl::onIncreaseBtnClickedCb(Widget &widget, void *eventInfo)
+ {
+ if (m_handler) {
+ m_handler(Event::INCREASE);
+ }
+ }
+
+ // Screen Reader
+ ElmWidget *VolumeControl::getDecreaseBtn()
+ {
+ return &m_decreaseBtn;
+ }
+
+ ElmWidget *VolumeControl::getIncreaseBtn()
+ {
+ return &m_increaseBtn;
+ }
+
+ ElmWidget *VolumeControl::getValueTxtAo()
+ {
+ return m_valueTxtAo.get();
+ }
+
+ void VolumeControl::registerAccessObjectInformation()
+ {
+ elm_atspi_accessible_translation_domain_set(m_slider, PACKAGE);
+ elm_atspi_accessible_reading_info_type_set(m_slider,
+ ELM_ACCESSIBLE_READING_INFO_TYPE_NAME
+ | ELM_ACCESSIBLE_READING_INFO_TYPE_DESCRIPTION);
+ elm_atspi_accessible_name_set(m_slider, AO_STR_VOLUME);
+ elm_atspi_accessible_description_set(m_slider,
+ AO_STR_ROTATE_BEZEL_TO_ADJUST);
+
+ elm_atspi_accessible_translation_domain_set(m_decreaseBtn, PACKAGE);
+ elm_atspi_accessible_name_set(m_decreaseBtn,
+ AO_STR_DECREASE_VOLUME);
+
+ elm_atspi_accessible_translation_domain_set(m_increaseBtn, PACKAGE);
+ elm_atspi_accessible_name_set(m_increaseBtn,
+ AO_STR_INCREASE_VOLUME);
+
+ m_valueTxtAo = utils::createAccessObjectFromLyPart(
+ *m_layout,
+ *m_layout,
+ impl::PART_TXT_VALUE_AO);
+ if (!m_valueTxtAo) {
+ ELOG("createAccessObjectFromLyPart() failed");
+ } else {
+ elm_atspi_accessible_translation_domain_set(*m_valueTxtAo,
+ PACKAGE);
+ elm_atspi_accessible_reading_info_type_set(*m_valueTxtAo,
+ ELM_ACCESSIBLE_READING_INFO_TYPE_NAME);
+ elm_atspi_accessible_name_cb_set(*m_valueTxtAo,
+ [](void *data, Evas_Object *obj) -> char *
+ {
+ auto self = static_cast<VolumeControl *>(data);
+ if (!self) {
+ return nullptr;
+ }
+ auto txt = self->m_layout->
+ getText(impl::PART_TXT_VALUE).getCStr();
+ return (txt) ? strdup(txt) : nullptr;
+ },
+ this);
+ }
+
+ elm_atspi_accessible_role_set(*m_layout, ELM_ATSPI_ROLE_TEXT);
+ }
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_VIEW_VOLUME_CONTROL_H__
+#define __CALL_UI_VIEW_VOLUME_CONTROL_H__
+
+#include "call-ui/view/Slider.h"
+
+#include "ucl/gui/StyledWidget.h"
+#include "ucl/gui/Layout.h"
+
+#include "types.h"
+
+namespace callui {
+
+ UCL_DECLARE_REF_ALIASES(VolumeControl);
+
+ class VolumeControl final : public Slider {
+ public:
+ enum class Event {
+ INCREASE,
+ DECREASE
+ };
+
+ using EventHandler = ucl::WeakDelegate<void(Event)>;
+ public:
+ class Builder {
+ public:
+ Builder();
+ Builder &setInfoText(const ucl::TString &info);
+ Builder &setMaxValue(int maxValue);
+ Builder &setValue(int curValue);
+ Builder &setEventHandler(const EventHandler &handler);
+ VolumeControlSRef build(ucl::ElmWidget &parent) const;
+
+ private:
+ ucl::TString m_info;
+ int m_maxValue;
+ int m_curValue;
+ EventHandler m_handler;
+ };
+
+ public:
+ void setInfoText(const ucl::TString &info);
+ void setDecreaseBtnEnable(bool isEnable);
+ void setIncreaseBtnEnable(bool isEnable);
+ void setEventHandler(const EventHandler &handler);
+
+ // Slider
+
+ virtual void setValue(int value) override final;
+
+ // Screen Reader
+ ucl::ElmWidget *getDecreaseBtn();
+ ucl::ElmWidget *getIncreaseBtn();
+ ucl::ElmWidget *getValueTxtAo();
+
+ private:
+ friend class ucl::ReffedObj<VolumeControl>;
+ VolumeControl(ucl::IRefCountObj &rc,
+ const ucl::LayoutSRef &layout,
+ const ucl::TString &info,
+ int maxValue,
+ int curValue,
+ const EventHandler &handler);
+
+ virtual ~VolumeControl();
+
+ void prepare(const ucl::TString &info, int curValue);
+
+ void onDecreaseBtnClickedCb(ucl::Widget &widget, void *eventInfo);
+ void onIncreaseBtnClickedCb(ucl::Widget &widget, void *eventInfo);
+
+ void onWidgetShowCb(Widget &widget, void *eventInfo);
+ void onWidgetHideCb(Widget &widget, void *eventInfo);
+
+ // Screen Reader
+ void registerAccessObjectInformation();
+
+ private:
+ ucl::StyledWidget m_decreaseBtn;
+ ucl::StyledWidget m_increaseBtn;
+ EventHandler m_handler;
+
+ // Screen Reader
+ ucl::ElmWidgetSRef m_valueTxtAo;
+ };
+
+}
+
+#endif // __CALL_UI_VIEW_VOLUME_CONTROL_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_VIEW_COMMON_H__
+#define __CALL_UI_VIEW_COMMON_H__
+
+#include "ucl/gui/stdTheme.h"
+#include "ucl/gui/helpers.h"
+
+#include "call-ui/view/helpers.h"
+
+#include "call-ui/common.h"
+
+#define DEL_TRANSIT(ptr) \
+ do { \
+ if (ptr) { \
+ elm_transit_del_cb_set(ptr, nullptr, nullptr); \
+ elm_transit_del(ptr); \
+ ptr = nullptr; \
+ } \
+ } while (0)
+
+namespace callui {
+
+ constexpr ucl::SmartEvent BTN_CLICKED {"clicked"};
+ constexpr ucl::SmartEvent ATSPI_HIGHLIGHTED {"atspi,highlighted"};
+}
+
+#endif // __CALL_UI_VIEW_COMMON_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "call-ui/view/helpers.h"
+
+#include "ucl/gui/Window.h"
+#include "ucl/gui/Naviframe.h"
+#include "ucl/gui/Layout.h"
+
+#include "common.h"
+
+namespace callui { namespace { namespace impl {
+
+ using namespace ucl;
+
+ constexpr EoDataKey CIRCLE_SURFACE {"callui,eext,circle,surface"};
+
+ constexpr LayoutTheme LAYOUT_FAKE_ACCESS_OBJECT
+ {"layout", "callui", "fake_access_object"};
+}}}
+
+namespace callui { namespace utils {
+
+ using namespace ucl;
+
+ Result createCircleSurface(Naviframe &navi)
+ {
+ const auto win = navi.getWindow();
+ if (!win) {
+ LOG_RETURN(RES_FAIL, "Failed to get Window from Naviframe!");
+ }
+
+ if (win->getData(impl::CIRCLE_SURFACE)) {
+ LOG_RETURN(RES_ILLEGAL_STATE, "Circle Surface data already set!");
+ }
+
+ const auto sfc = eext_circle_surface_conformant_add(win->getConformant());
+ if (!sfc) {
+ LOG_RETURN(RES_FAIL,
+ "eext_circle_surface_conformant_add() failed!");
+ }
+
+ win->setData(impl::CIRCLE_SURFACE, sfc);
+
+ return RES_OK;
+ }
+
+ Eext_Circle_Surface *getCircleSurface(const ElmWidget &widget)
+ {
+ const auto win = widget.getWindow();
+ if (!win) {
+ LOG_RETURN_VALUE(RES_FAIL, nullptr,
+ "Failed to get Window from widget!");
+ }
+
+ const auto sfc = static_cast<Eext_Circle_Surface *>(
+ win->getData(impl::CIRCLE_SURFACE));
+ if (!sfc) {
+ LOG_RETURN_VALUE(RES_FAIL, nullptr,
+ "Failed to get Eext_Circle_Surface from window!");
+ }
+
+ return sfc;
+ }
+
+ ElmWidgetSRef createFakeAccessObject(ElmWidget &parent)
+ {
+ const auto result = Layout::Builder().
+ setTheme(impl::LAYOUT_FAKE_ACCESS_OBJECT).
+ setIsOwner(true).
+ setNeedBindToEo(true).
+ build(parent);
+ if (!result) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "Layout::build() failed!");
+ }
+
+ result->setGeometry(0, 0, 1, 1);
+ show(*result);
+
+ elm_atspi_accessible_reading_info_type_set(*result, 0);
+
+ elm_atspi_accessible_gesture_cb_set(*result,
+ [](void *, Elm_Atspi_Gesture_Info, Evas_Object *) -> Eina_Bool
+ {
+ return EINA_TRUE;
+ },
+ nullptr);
+
+ return result;
+ }
+
+
+ Elm_Genlist_Item_Class createGenlistItemClass(const char *style,
+ Elm_Gen_Item_Text_Get_Cb txtCb,
+ Elm_Gen_Item_Content_Get_Cb contentCb,
+ Elm_Gen_Item_State_Get_Cb stateCb,
+ Elm_Gen_Item_Del_Cb delCb)
+ {
+ Elm_Genlist_Item_Class itc = { ELM_GEN_ITEM_CLASS_HEADER };
+ itc.item_style = style;
+ itc.func.text_get = txtCb;
+ itc.func.content_get = contentCb;
+ itc.func.state_get = stateCb;
+ itc.func.del = delCb;
+
+ return itc;
+ }
+
+ ElmWidgetSRef createAccessObject(ElmWidget &parent, Widget &ly)
+ {
+ auto ao = elm_access_object_register(ly, parent);
+ if (!ao) {
+ LOG_RETURN_VALUE(RES_FAIL, {},
+ "elm_access_object_register() failed!");
+ }
+
+ return makeShared<ElmWidget>(ao, true);
+ }
+
+ ElmWidgetSRef createAccessObjectFromLyPart(ElmWidget &parent,
+ Widget &ly,
+ const EdjePart &lyPart)
+ {
+ auto po = const_cast<Evas_Object *>(
+ edje_object_part_object_get(
+ elm_layout_edje_get(ly), lyPart));
+ if (!po) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "Part object is NULL");
+ }
+
+ auto ao = elm_access_object_register(po, parent);
+ if (!ao) {
+ LOG_RETURN_VALUE(RES_FAIL, {},
+ "elm_access_object_register() failed!");
+ }
+
+ return makeShared<ElmWidget>(ao, true);
+ }
+
+ void destroyAccessObject(ElmWidget &ao)
+ {
+ elm_access_object_unregister(ao);
+ }
+
+}}
+
+namespace callui {
+
+ void addRotaryEventHandler(Eext_Rotary_Handler_Cb func, void *data)
+ {
+ eext_rotary_event_handler_add(func, data);
+ }
+
+ void delRotaryEventHandler(Eext_Rotary_Handler_Cb func, void *data)
+ {
+ std::vector<void *> backup;
+ while (true) {
+ void *const oldData = eext_rotary_event_handler_del(func);
+ if (!oldData || (oldData == data)) {
+ break;
+ }
+ backup.push_back(oldData);
+ }
+ for (auto i = backup.size(); i-- > 0; ) {
+ eext_rotary_event_handler_add(func, backup[i]);
+ }
+ }
+
+ LayoutTheme getImageTheme(const char *const fileName)
+ {
+ return {"layout", "callui_image", fileName};
+ }
+
+ Elm_Atspi_Relation_Type getFlowRelation(Elm_Atspi_Gesture_Info gestureInfo)
+ {
+ switch (gestureInfo.type) {
+ case ELM_ATSPI_GESTURE_ONE_FINGER_FLICK_RIGHT:
+ case ELM_ATSPI_GESTURE_ONE_FINGER_FLICK_DOWN:
+ return ELM_ATSPI_RELATION_FLOWS_TO;
+ case ELM_ATSPI_GESTURE_ONE_FINGER_FLICK_LEFT:
+ case ELM_ATSPI_GESTURE_ONE_FINGER_FLICK_UP:
+ return ELM_ATSPI_RELATION_FLOWS_FROM;
+ default:
+ break;
+ }
+ return ELM_ATSPI_RELATION_NULL;
+ }
+
+}
+
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_VIEW_HELPERS_H__
+#define __CALL_UI_VIEW_HELPERS_H__
+
+#include <efl_extension.h>
+
+#include "ucl/gui/ElmWidget.h"
+#include "ucl/gui/Naviframe.h"
+#include "ucl/gui/Layout.h"
+
+#include "types.h"
+
+namespace callui { namespace utils {
+
+ ucl::Result createCircleSurface(ucl::Naviframe &navi);
+
+ Eext_Circle_Surface *getCircleSurface(const ucl::ElmWidget &widget);
+
+ ucl::ElmWidgetSRef createFakeAccessObject(ucl::ElmWidget &parent);
+
+ Elm_Genlist_Item_Class createGenlistItemClass(const char *style,
+ Elm_Gen_Item_Text_Get_Cb txtCb = nullptr,
+ Elm_Gen_Item_Content_Get_Cb contentCb = nullptr,
+ Elm_Gen_Item_State_Get_Cb stateCb = nullptr,
+ Elm_Gen_Item_Del_Cb delCb = nullptr);
+
+ ucl::ElmWidgetSRef createAccessObject(ucl::ElmWidget &parent,
+ ucl::Widget &ly);
+
+ ucl::ElmWidgetSRef createAccessObjectFromLyPart(ucl::ElmWidget &parent,
+ ucl::Widget &ly,
+ const ucl::EdjePart &lyPart);
+
+ void destroyAccessObject(ucl::ElmWidget &ao);
+
+}}
+
+namespace callui {
+
+ void addRotaryEventHandler(Eext_Rotary_Handler_Cb func, void *data);
+
+ void delRotaryEventHandler(Eext_Rotary_Handler_Cb func, void *data);
+
+ ucl::LayoutTheme getImageTheme(const char *fileName);
+
+ Elm_Atspi_Relation_Type getFlowRelation(Elm_Atspi_Gesture_Info gestureInfo);
+
+}
+
+#endif // __CALL_UI_VIEW_HELPERS_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 __CALL_UI_VIEW_TYPES_H__
+#define __CALL_UI_VIEW_TYPES_H__
+
+#include <efl_extension.h>
+
+#include "ucl/gui/types.h"
+
+#include "call-ui/types.h"
+
+namespace callui {
+
+ enum class AcceptButtonType {
+ SIMPLE,
+ BT_HEADSET
+ };
+}
+
+#endif // __CALL_UI_VIEW_TYPES_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_CONFIG_H__
-#define __CALLUI_CONFIG_H__
-
-#define CALLUI_LOG_TAG "CALLUI"
-
-namespace callui {
-
- constexpr auto PACKAGE = "w-call-ui";
-
- constexpr auto WINDOW_NAME = "org.tizen.call-ui";
-
- constexpr auto BASE_SCALE = 1.3;
-}
-
-#endif // __CALLUI_CONFIG_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_CALL_UI_BUILDER_H__
-#define __CALLUI_MODEL_CALL_UI_BUILDER_H__
-
-#include "types.h"
-
-namespace callui {
-
- class CallUIBuilder {
- public:
- CallUIBuilder();
- ICallUISRef build() const;
- };
-
-}
-
-#endif // __CALLUI_MODEL_CALL_UI_BUILDER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_I_ACTIVE_CALL_H__
-#define __CALLUI_MODEL_I_ACTIVE_CALL_H__
-
-#include "types.h"
-
-namespace callui {
-
- class IActiveCall : public ucl::Polymorphic {
- public:
- virtual ICallInfoSCRef getInfo() const = 0;
- virtual bool isDialingMode() const = 0;
- virtual ucl::Result hold() = 0;
- virtual ucl::Result end() = 0;
- virtual ucl::Result split(const IConferenceCallInfoSCRef &confCallInfo) = 0;
- };
-
-}
-
-#endif // __CALLUI_MODEL_I_ACTIVE_CALL_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_I_BASE_CALL_INFO_H__
-#define __CALLUI_MODEL_I_BASE_CALL_INFO_H__
-
-#include "types.h"
-
-namespace callui {
-
- class IBaseCallInfo : public ucl::Polymorphic {
- public:
- virtual unsigned int getCallId() const = 0;
- virtual const std::string &getPhoneNumber() const = 0;
- virtual IContactInfoSCRef getContactInfo() const = 0;
- };
-
-}
-
-#endif // __CALLUI_MODEL_I_BASE_CALL_INFO_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_I_CALL_INFO_H__
-#define __CALLUI_MODEL_I_CALL_INFO_H__
-
-#include "IBaseCallInfo.h"
-
-#include <time.h>
-
-#include "types.h"
-
-namespace callui {
-
- class ICallInfo : public IBaseCallInfo {
- public:
- virtual struct tm getDuration() const = 0;
- virtual bool isEmergency() const = 0;
- virtual bool isHDVoice() const = 0;
- virtual bool isForwarded() const = 0;
- virtual bool isVoiceMailNumber() const = 0;
- virtual int getConferenceMemberCount() const = 0;
- virtual const ConfMemberList &getConferenceMemberList() const = 0;
- };
-
- // Non-member functions
-
- bool isUnknownCaller(const ICallInfo &info);
-}
-
-#endif // __CALLUI_MODEL_I_CALL_INFO_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_I_CALL_LISTENER_H__
-#define __CALLUI_MODEL_I_CALL_LISTENER_H__
-
-#include "types.h"
-
-namespace callui {
-
- class ICallListener : public ucl::Polymorphic {
- public:
- virtual void onCallEvent(CallEventType type) = 0;
- virtual void onError(CallErr err) = 0;
- };
-
-}
-
-#endif // __CALLUI_MODEL_I_CALL_LISTENER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_I_STATE_PROVIDER_H__
-#define __CALLUI_MODEL_I_STATE_PROVIDER_H__
-
-#include "types.h"
-
-namespace callui {
-
- class ICallManager : public ucl::Polymorphic {
- public:
- virtual IIncomingCallSRef getIncomingCall() = 0;
- virtual IActiveCallSRef getActiveCall() = 0;
- virtual IHeldCallSRef getHeldCall() = 0;
- virtual IEndCallSRef getEndCall() = 0;
- virtual CallMask getAvailableCalls() const = 0;
- };
-}
-
-#endif // __CALLUI_MODEL_I_STATE_PROVIDER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_I_CALL_UI_H__
-#define __CALLUI_MODEL_I_CALL_UI_H__
-
-#include <app_control.h>
-
-#include "types.h"
-
-namespace callui {
-
- class ICallUI : public ucl::Polymorphic {
- public:
- virtual void setListener(const ICallListenerWRef &listener) = 0;
- virtual ucl::Result processAppControl(app_control_h appControl) = 0;
- virtual ISoundManagerSRef getSoundManager() = 0;
- virtual ICallManagerSRef getCallManager() = 0;
- virtual IIndicatorStateProviderSRef getIndicatorStateProvider() = 0;
- };
-}
-
-#endif // __CALLUI_MODEL_I_CALL_UI_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_I_CONFERENCE_CALL_INFO_H__
-#define __CALLUI_MODEL_I_CONFERENCE_CALL_INFO_H__
-
-#include "IBaseCallInfo.h"
-
-#include "types.h"
-
-namespace callui {
-
- class IConferenceCallInfo : public IBaseCallInfo {
- };
-}
-
-#endif // __CALLUI_MODEL_I_CONFERENCE_CALL_INFO_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_I_CONTACT_INFO_H__
-#define __CALLUI_MODEL_I_CONTACT_INFO_H__
-
-#include "types.h"
-
-namespace callui {
-
- class IContactInfo : public ucl::Polymorphic {
- public:
- virtual const std::string &getName() const = 0;
- virtual const std::string &getImagePath() const = 0;
- virtual ContactNameSourceType getNameSourceType() const = 0;
- };
-}
-
-#endif // __CALLUI_MODEL_I_CONTACT_INFO_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_I_END_CALL_H__
-#define __CALLUI_MODEL_I_END_CALL_H__
-
-#include "types.h"
-
-namespace callui {
-
- class IEndCall : public ucl::Polymorphic {
- public:
- virtual ICallInfoSCRef getInfo() const = 0;
- virtual ucl::Result callBack() = 0;
- virtual ucl::Result writeMessage() = 0;
- };
-}
-
-#endif // __CALLUI_MODEL_I_END_CALL_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_I_HELD_CALL_H__
-#define __CALLUI_MODEL_I_HELD_CALL_H__
-
-#include "types.h"
-
-namespace callui {
-
- class IHeldCall : public ucl::Polymorphic {
- public:
- virtual ICallInfoSCRef getInfo() const = 0;
- virtual ucl::Result unhold() = 0;
- virtual ucl::Result joinWithActive() = 0;
- virtual ucl::Result swapWithActive() = 0;
- virtual ucl::Result end() = 0;
- virtual ucl::Result split(const IConferenceCallInfoSCRef &confCallInfo) = 0;
- };
-}
-
-#endif // __CALLUI_MODEL_I_HELD_CALL_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_I_INCOMING_CALL_H__
-#define __CALLUI_MODEL_I_INCOMING_CALL_H__
-
-#include "types.h"
-
-namespace callui {
-
- class IIncomingCall : public ucl::Polymorphic {
- public:
- virtual ICallInfoSCRef getInfo() const = 0;
- virtual IRejectMsgProviderSRef getRejectMsgProvider() const = 0;
- virtual ucl::Result answer(CallAnswerType type) = 0;
- virtual ucl::Result reject() = 0;
- virtual ucl::Result rejectWithMessage(IRejectMsgSRef message) = 0;
- virtual ucl::Result stopAlert() = 0;
- };
-}
-
-#endif // __CALLUI_MODEL_I_INCOMING_CALL_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_I_INDICATOR_STATE_LISTENER_H__
-#define __CALLUI_MODEL_I_INDICATOR_STATE_LISTENER_H__
-
-#include "types.h"
-
-namespace callui {
-
- class IIndicatorStateListener: public ucl::Polymorphic {
- public:
- virtual void onStateChanged(IndicatorProperty property) = 0;
- };
-
-}
-
-#endif // __CALLUI_MODEL_I_INDICATOR_STATE_LISTENER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_I_INDICATOR_STATE_PROVIDER_H__
-#define __CALLUI_MODEL_I_INDICATOR_STATE_PROVIDER_H__
-
-#include <model/IndicatorState.h>
-#include "types.h"
-
-namespace callui {
-
- class IIndicatorStateProvider : public ucl::Polymorphic {
- public:
- virtual IndicatorState getState(IndicatorProperty property) const = 0;
- virtual void setListener(IIndicatorStateListenerWRef listener) = 0;
- };
-
-}
-
-#endif // __CALLUI_MODEL_I_INDICATOR_STATE_PROVIDER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_I_REJECT_MSG_H__
-#define __CALLUI_MODEL_I_REJECT_MSG_H__
-
-#include "types.h"
-
-namespace callui {
-
- class IRejectMsg : public ucl::Polymorphic {
- public:
- virtual std::string getText() const = 0;
-
- };
-
-}
-
-#endif // __CALLUI_I_REJECT_MSG_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_I_REJECT_MSG_PROVIDER_H__
-#define __CALLUI_MODEL_I_REJECT_MSG_PROVIDER_H__
-
-#include "types.h"
-
-namespace callui {
-
- class IRejectMsgProvider : public ucl::Polymorphic {
- public:
- virtual RejectMsgList getMsgList() const = 0;
- virtual int getMsgCount() const = 0;
- };
-
-}
-
-#endif // __CALLUI_MODEL_I_REJECT_MSG_PROVIDER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_I_SOUND_MANAGER_H__
-#define __CALLUI_MODEL_I_SOUND_MANAGER_H__
-
-#include "types.h"
-
-namespace callui {
-
- class ISoundManager: public ucl::Polymorphic {
- public:
- virtual ucl::Result setSpeakerState(bool isEnable) = 0;
- virtual ucl::Result setBluetoothState(bool isEnable) = 0;
- virtual AudioStateType getAudioState() const = 0;
- virtual ucl::Result setMuteState(bool isEnable) = 0;
- virtual bool getMuteState() const = 0;
- virtual ucl::Result startDtmf(const unsigned char dtmfDigit) = 0;
- virtual ucl::Result stopDtmf() = 0;
- virtual void addAudioStateHandler(
- const AudioStateHandler &handler) = 0;
- virtual void delAudioStateHandler(
- const AudioStateHandler &handler) = 0;
- virtual void addMuteStateHandler(
- const MuteStateHandler &handler) = 0;
- virtual void delMuteStateHandler(
- const MuteStateHandler &handler) = 0;
- virtual void addVolumeStateHandler(
- const VolumeLevelHandler &handler) = 0;
- virtual void delVolumeStateHandler(
- const VolumeLevelHandler &handler) = 0;
- virtual int getMaxVolume() const = 0;
- virtual int getVolume() const = 0;
- virtual ucl::Result setVolume(int value) = 0;
- virtual bool isBTSupported() const = 0;
- virtual bool isBTHeadsetConnected() const = 0;
- virtual void addBTHeadsetConnectionChangeHandler(
- const NotiHandler &handler) = 0;
- virtual void delBTHeadsetConnectionChangeHandler(
- const NotiHandler &handler) = 0;
- };
-}
-
-#endif // __CALLUI_MODEL_I_SOUND_MANAGER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_INDICATOR_STATE_H__
-#define __CALLUI_MODEL_INDICATOR_STATE_H__
-
-#include "types.h"
-
-namespace callui {
-
- struct IndicatorState {
- uint64_t value;
- };
-
- ConnectionType getConnectionState(IndicatorState state);
- PacketDirection getPacketDirection(IndicatorState state);
- RssiState getRssiState(IndicatorState state);
- bool getRoamingState(IndicatorState state);
- int getBatteryLevel(IndicatorState state);
- BatteryState getBatteryState(IndicatorState state);
- bool getVoiceControlState(IndicatorState state);
- SimSlot getSimSlotType(IndicatorState state);
- bool getSimForwardState(IndicatorState state);
- bool getHDVoiceState(IndicatorState state);
-
-}
-
-#endif // __CALLUI_MODEL_INDICATOR_STATE_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_TYPES_H__
-#define __CALLUI_MODEL_TYPES_H__
-
-#include <vector>
-
-#include "../types.h"
-
-namespace callui {
-
- enum class CallErr {
- DIAL_CANCEL,
- DIAL_FAIL,
- DIAL_FLIGHT_MODE
- };
-
- enum class SimSlot {
- UNDEFINED = 0,
- GEAR,
- MOBILE_FIRST,
- MOBILE_SECOND,
- MOBILE_DEFAULT
- };
-
- enum class CallAnswerType {
- NORMAL,
- HOLD_ACTIVE_AND_ACCEPT,
- RELEASE_ACTIVE_AND_ACCEPT,
- RELEASE_HOLD_AND_ACCEPT,
- RELEASE_ALL_AND_ACCEPT
- };
-
- enum class AudioStateType {
- NONE,
- SPEAKER,
- RECEIVER,
- EARJACK,
- BT
- };
-
- enum {
- CALL_FLAG_NONE = 0,
- CALL_FLAG_INCOMING = 1,
- CALL_FLAG_ACTIVE = 2,
- CALL_FLAG_HELD = 4,
- CALL_FLAG_END = 8
- };
- using CallMask = int;
-
- enum class CallEventType {
- END,
- DIALING,
- ACTIVE,
- HELD,
- ALERT,
- INCOMING,
- WAITING,
- JOIN,
- SPLIT,
- SWAPPED,
- RETRIEVED,
- SAT_CALL_CONTROL
- };
-
- enum class ContactNameSourceType {
- INVALID,
- EMAIL,
- NUMBER,
- NICKNAME,
- COMPANY,
- NAME
- };
-
- enum class ConnectionType {
- NONE = 0,
- EDGE_E,
- GPRS_G,
- SIMPLE_2G,
- HSDPA_H,
- HSPA_H_PLUS,
- LTE_4G,
- UMTS_3G,
- UMTS_3G_PLUS,
- NO_SIM,
- WIFI_00,
- WIFI_01,
- WIFI_02,
- WIFI_03,
- WIFI_04,
- NO_SIGNAL
- };
-
- enum class PacketDirection {
- NONE = 0,
- NO_INPUT,
- IN,
- OUT,
- INOUT
- };
-
- enum class RssiState {
- NONE = 0,
- LEVEL_0,
- LEVEL_1,
- LEVEL_2,
- LEVEL_3,
- LEVEL_4,
- NO_SIGNAL,
- FLIGHT_MODE
- };
-
- enum class BatteryState {
- NORMAL = 0,
- CHARGING,
- CHARGING_PROBLEM,
- UNKNOWN
- };
-
- enum class IndicatorProperty {
- NW_CONNECTION = 0,
- RSSI,
- BATTERY,
- VOICE_CONTROL,
- SIM_SLOT,
- HD_VOICE
- };
-
- UCL_DECLARE_REF_ALIASES(ICallUI);
- UCL_DECLARE_REF_ALIASES(ICallListener);
-
- UCL_DECLARE_REF_ALIASES(ICallManager);
- UCL_DECLARE_REF_ALIASES(ISoundManager);
-
- UCL_DECLARE_REF_ALIASES(IIncomingCall);
- UCL_DECLARE_REF_ALIASES(IActiveCall);
- UCL_DECLARE_REF_ALIASES(IHeldCall);
- UCL_DECLARE_REF_ALIASES(IEndCall);
-
- UCL_DECLARE_REF_ALIASES(ICallInfo);
- UCL_DECLARE_REF_ALIASES(IContactInfo);
- UCL_DECLARE_REF_ALIASES(IConferenceCallInfo);
-
- UCL_DECLARE_REF_ALIASES(IRejectMsgProvider);
- UCL_DECLARE_REF_ALIASES(IRejectMsg);
-
- UCL_DECLARE_REF_ALIASES(IIndicatorStateProvider);
- UCL_DECLARE_REF_ALIASES(IIndicatorStateListener);
-
- using AudioStateHandler = ucl::Delegate<void(AudioStateType)>;
- using MuteStateHandler = ucl::Delegate<void(bool)>;
- using VolumeLevelHandler = ucl::Delegate<void(int)>;
-
- using ConfMemberList = std::vector<IConferenceCallInfoSCRef>;
- using RejectMsgList = std::vector<IRejectMsgSRef>;
-}
-
-#endif // __CALLUI_MODEL_TYPES_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_VIEW_ACCEPT_DIALOG_H__
-#define __CALLUI_VIEW_ACCEPT_DIALOG_H__
-
-#include "ucl/mvp/GuiPresenter.h"
-
-#include "ucl/gui/StyledWidget.h"
-#include "ucl/gui/ElmWidget.h"
-#include "ucl/gui/ElmWidget.h"
-
-#include "types.h"
-
-namespace callui {
-
- class AcceptDialog final : public ucl::GuiPresenter,
- public ucl::IDisposable {
- public:
- class Builder {
- public:
- Builder();
- ~Builder();
- Builder &setHandler(AcceptDialogHandler handler);
- AcceptDialogWRef build(ucl::ElmWidget &parent) const;
- private:
- AcceptDialogHandler m_handler;
- };
-
- public:
- virtual ~AcceptDialog();
-
- void dismiss();
-
- // ucl::IDisposable
-
- virtual void dispose() final override;
- virtual bool isDisposed() const final override;
-
- private:
- friend class ucl::ReffedObj<AcceptDialog>;
- AcceptDialog(ucl::IRefCountObj &rc,
- const AcceptDialogHandler &handler);
-
- ucl::Result prepare(ucl::ElmWidget &parent);
-
- ucl::Result createPopup(ucl::ElmWidget &parent, ucl::ElmStyle style);
- ucl::Result createGenlist();
- ucl::Result fillGenlist();
- ucl::Result addGenlistTitleItem();
- ucl::Result addGenlistTextItem(AcceptDialogEvent event);
- ucl::Result addGenlistBottomItem();
-
- void handleEvent(AcceptDialogEvent event);
- bool dispatchEvent(AcceptDialogEvent event);
-
- void onPopupDismissed(ucl::Widget &widget, void *eventInfo);
- void onPopupHWBackKey(Evas_Object *obj, void *eventInfo);
-
- void onGenlistItemClickedCb(Evas_Object *obj, void *eventInfo);
-
- private:
- ucl::StyledWidgetSRef m_popup;
- ucl::StyledWidgetSRef m_genlist;
- AcceptDialogHandler m_handler;
- AcceptDialogSRef m_selfRef;
- bool m_isDismissed;
- };
-
-}
-
-#endif // __CALLUI_VIEW_ACCEPT_DIALOG_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_PRESENTERS_ACCEPT_REJECT_PRESENTER_H__
-#define __CALLUI_PRESENTERS_ACCEPT_REJECT_PRESENTER_H__
-
-#include "ucl/mvp/GuiPresenter.h"
-
-#include "ucl/gui/Layout.h"
-#include "ucl/gui/StyledWidget.h"
-
-#include "types.h"
-
-namespace callui {
-
- class AcceptRejectPresenter final : public ucl::GuiPresenter {
- public:
- class Builder {
- public:
- Builder();
- ~Builder();
- Builder &setIncomingCall(const IIncomingCallSRef &call);
- Builder &setSoundManager(const ISoundManagerSRef &sm);
- Builder &setAvailableCallsFlag(CallMask calls);
- Builder &setParentWidget(const ucl::ElmWidgetSRef &parentWidget);
- AcceptRejectPresenterSRef build(ucl::GuiPresenter &parent) const;
-
- private:
- IIncomingCallSRef m_call;
- CallMask m_callMask;
- ucl::ElmWidgetSRef m_parentWidget;
- ISoundManagerSRef m_sm;
- };
-
- public:
- virtual ~AcceptRejectPresenter();
-
- ucl::Widget &getWidget();
-
- void update(CallMask calls);
-
- ucl::ElmWidget *getAcceptAo();
- ucl::ElmWidget *getRejectAo();
-
- private:
- friend class ucl::ReffedObj<AcceptRejectPresenter>;
- AcceptRejectPresenter(ucl::IRefCountObj &rc,
- const IIncomingCallSRef &call,
- CallMask calls,
- const ISoundManagerSRef &sm);
-
- ucl::Result prepare(ucl::GuiPresenter &parent,
- ucl::ElmWidget &parentWidget);
-
- ucl::Result createWidget(ucl::ElmWidget &parent);
- ucl::Result createMotionSensorPresenter();
-
- void showPopup();
-
- void processAccept();
- void processReject() const;
-
- void onMotionEvent();
-
- bool onAcceptPopupEvent(AcceptDialog &popup, AcceptDialogEvent event);
- void onAcceptEvent();
- void onRejectEvent();
- void onBTHeadsetConnectionChanged();
-
- // GuiPresenter
- virtual void onActivate() final override;
- virtual void onDeactivate() final override;
-
- private:
- AcceptRejectWidgetSRef m_widget;
- AcceptDialogWRef m_popup;
- MotionSensorPresenterSRef m_motionPrs;
-
- IIncomingCallSRef m_call;
- CallMask m_callMask;
- ISoundManagerSRef m_sm;
- };
-}
-
-
-
-#endif // __CALLUI_PRESENTERS_ACCEPT_REJECT_PRESENTER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_PRESENTERS_ACCESSORY_PRESENTER_H__
-#define __CALLUI_PRESENTERS_ACCESSORY_PRESENTER_H__
-
-#include "ucl/mvp/GuiPresenter.h"
-
-#include "ucl/gui/Layout.h"
-#include "ucl/gui/StyledWidget.h"
-
-#include <app_control.h>
-
-#include "types.h"
-
-namespace callui {
-
- class AccessoryPresenter final : public ucl::GuiPresenter {
- public:
- class Builder {
- public:
- Builder();
- Builder &setSoundManager(const ISoundManagerSRef &sm);
- Builder &setCallManager(const ICallManagerSRef &cm);
- Builder &setRequestExitHandler(const NotiHandler &handler);
- Builder &setParentWidget(const ucl::ElmWidgetSRef &parentWidget);
- AccessoryPresenterSRef build(ucl::GuiPresenter &parent) const;
-
- private:
- ISoundManagerSRef m_sm;
- ICallManagerSRef m_cm;
- ucl::ElmWidgetSRef m_parentWidget;
- NotiHandler m_exitHandler;
- };
-
- public:
- virtual ~AccessoryPresenter();
-
- ucl::Widget &getWidget();
- void hideVolumeControls();
- ucl::Result update(const ICallManagerSRef &cm);
-
- // Screen Reader
- ucl::ElmWidget *getVolumBtn();
- ucl::ElmWidget *getBluetoothBtn();
- ucl::ElmWidget *getMuteBtn();
- ucl::ElmWidget *getAddContactBtn();
- ucl::ElmWidget *getVolumeControlLy();
- ucl::ElmWidget *getVolumeControlDecreaseBtn();
- ucl::ElmWidget *getVolumeControlIncreaseBtn();
- ucl::ElmWidget *getVolumeControlValueTxtAo();
-
- private:
- enum class ComponentsMode {
- UNDEFINED,
- OUTGOING,
- DURING,
- END
- };
- private:
- friend class ucl::ReffedObj<AccessoryPresenter>;
- AccessoryPresenter(ucl::IRefCountObj &rc, const ISoundManagerSRef &sm,
- const NotiHandler &handler);
-
- ucl::Result prepare(ucl::GuiPresenter &parent,
- ucl::ElmWidget &parentWidget, const ICallManagerSRef &cm);
-
- ucl::Result createWidget(ucl::ElmWidget &parent);
- ucl::Result createSlider();
- ucl::Result createVolumeControl();
-
- ucl::Result createVolumeBtn();
- ucl::Result createMuteBtn();
- ucl::Result createBluetoothBtn();
- ucl::Result createAddContactBtn();
-
- void onVolumeBtnClicked(ucl::Widget &widget, void *eventInfo);
- void onMuteBtnClicked(ucl::Widget &widget, void *eventInfo);
- void onBluetoothBtnClicked(ucl::Widget &widget, void *eventInfo);
- void onAddContactBtnClicked(ucl::Widget &widget, void *eventInfo);
-
- ucl::Result launchContacts();
- ucl::Result launchBluetoothSettings();
-
- void registerCallbacks();
- void unregisterCallbacks();
- void onVolumeControlEventCb(VolumeControlEvent event);
- Eina_Bool onRotaryEvent(Eext_Rotary_Event_Info *info);
-
- bool checkPossibilityToModifyVolume(int volume,
- bool needIncrease);
- void tryIncreaseVolume();
- void tryDecreaseVolume();
-
- void onAudioStateChanged(AudioStateType state);
- void onVolumeLevelChanged(int value);
- void onMuteStateChanged(bool isMuted);
- void updateMuteBtn(bool isMuted);
-
- Eina_Bool onVCTimerCb();
- void startVCTimer();
- void restartVCTimer();
- void stopVCTimer();
-
- void updateVolume(int value);
-
- void updateMode(const ICallManagerSRef &cm);
- AccessoryPresenter::ComponentsMode getCurrentMode(const ICallManagerSRef &cm);
- void setVolumeSliderVisiblity(bool isVisible);
-
- ucl::Result updateModeRelativeComponents(const ICallManagerSRef &cm);
- ucl::Result setActiveCallCompomnents();
- ucl::Result setEndCallCompomnents(const ICallManagerSRef &cm);
-
- // Screen Reader
- void registerVolumeControlAo();
- void onVolumeControlScreenReaderReadStart(ucl::Widget &widget, void *eventInfo);
-
- private:
- ucl::LayoutSRef m_widget;
- ucl::StyledWidgetSRef m_volumeBtn;
- ucl::StyledWidgetSRef m_muteBtn;
- ucl::StyledWidgetSRef m_bluetoothBtn;
- ucl::StyledWidgetSRef m_addContactBtn;
-
- SliderSRef m_slider;
- VolumeControlSRef m_vc;
- ISoundManagerSRef m_sm;
-
- Ecore_Timer *m_vcTimer;
- AudioStateType m_audioState;
- ComponentsMode m_mode;
- std::string m_unsavedPhoneNumber;
- NotiHandler m_exitHandler;
-
- bool m_isVcShowOnRotaryEvent;
- };
-}
-
-#endif // __CALLUI_PRESENTERS_ACCESSORY_PRESENTER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_PRESENTERS_ATSPI_HIGHLIGHT_HELPER_H__
-#define __CALLUI_PRESENTERS_ATSPI_HIGHLIGHT_HELPER_H__
-
-#include "ucl/mvp/GuiPresenter.h"
-
-#include "types.h"
-
-namespace callui {
-
- class AtspiHighlightHelper final : public ucl::GuiPresenter {
- public:
- using RelationEventHandler = ucl::WeakDelegate<Elm_Interface_Atspi_Accessible *(
- Elm_Interface_Atspi_Accessible *ao,
- Elm_Atspi_Relation_Type flowRelation)>;
-
- using GestureEventHandler = ucl::WeakDelegate<bool (
- Elm_Interface_Atspi_Accessible *ao,
- Elm_Atspi_Gesture_Type gestureType)>;
- public:
- static AtspiHighlightHelperSRef newInstance(GuiPresenter &parent,
- ucl::ElmWidget &rootWidget);
-
- void setRelationEventHandler(RelationEventHandler handler);
- void setGestureEventHandler(GestureEventHandler handler);
- void registerWidget(ucl::ElmWidget &widget);
- bool handleGesture(Elm_Interface_Atspi_Accessible *widget,
- const Elm_Atspi_Gesture_Info &info);
-
- private:
- friend class ucl::ReffedObj<AtspiHighlightHelper>;
- AtspiHighlightHelper(ucl::IRefCountObj &rc);
- virtual ~AtspiHighlightHelper();
-
- ucl::Result prepare(GuiPresenter &parent, ucl::ElmWidget &rootWidget);
-
- void handleAtspiGesture(Elm_Interface_Atspi_Accessible *widget,
- ucl::AtspiGestureEventInfo &e);
-
- private:
- void onAtspiGesture(ucl::Widget &widget, void *eventInfo);
-
- private:
- RelationEventHandler m_relationEventHandler;
- GestureEventHandler m_gestureEventHandler;
- };
-}
-
-#endif // __CALLUI_PRESENTERS_ATSPI_HIGHLIGHT_HELPER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_PRESENTERS_CALL_INFO_PRESENTER_H__
-#define __CALLUI_PRESENTERS_CALL_INFO_PRESENTER_H__
-
-#include "ucl/mvp/GuiPresenter.h"
-
-#include "ucl/gui/Layout.h"
-#include "ucl/gui/StyledWidget.h"
-
-#include "types.h"
-
-namespace callui {
-
- class CallInfoPresenter final : public ucl::GuiPresenter {
- public:
- class Builder {
- public:
- Builder();
- virtual ~Builder();
- Builder &setCallManager(const ICallManagerSRef &cm);
- Builder &setMode(CallMode mode);
- Builder &setParentWidget(const ucl::ElmWidgetSRef &parentWidget);
- CallInfoPresenterSRef build(ucl::GuiPresenter &parent) const;
- private:
- ICallManagerSRef m_cm;
- CallMode m_mode;
- ucl::ElmWidgetSRef m_parentWidget;
- };
-
- public:
- virtual ~CallInfoPresenter();
-
- ucl::Widget &getWidget();
- CallMode getMode() const;
- ucl::Result update(CallMode mode, const ICallManagerSRef &cm);
-
- // Screen Reader
- ucl::ElmWidget *getStatusTxtAo();
- ucl::ElmWidget *getMainTxtAo();
- ucl::ElmWidget *getSubTxtAo();
-
- private:
- friend class ucl::ReffedObj<CallInfoPresenter>;
- CallInfoPresenter(ucl::IRefCountObj &rc,
- const ICallManagerSRef &cm,
- CallMode mode);
-
- ucl::Result prepare(ucl::GuiPresenter &parent,
- ucl::ElmWidget &parentWidget);
-
- void initCallInfos(const ICallManagerSRef &cm);
-
- ucl::Result createWidget(ucl::ElmWidget &parent);
- ucl::Result createLabel(const std::string &text);
- ucl::Result createCallerIdImage(const std::string &imagePath);
- ucl::Result createCallStatus(ucl::GuiPresenter &parent);
-
- ucl::Result update();
- ucl::Result updateCallerId();
- ucl::Result updateSubText();
- ucl::Result updateMainTxt();
- std::string getNumberSubText(const ICallInfoSCRef &callInfo) const;
- std::string getIncomingCallSubText() const;
- std::string getOutgoingCallSubText() const;
- std::string getDuringCallSubText() const;
- std::string getEndCallSubText() const;
-
- std::string generateMainTxt(const ICallInfoSCRef &callInfo);
-
- void displayMainTxt(const ICallInfoSCRef &info, const std::string &text);
-
- // Screen Reader
- ucl::Result setMainTxtAccessObject(const std::string &text);
- ucl::Result setSubTxtAccessObject(const std::string &text);
-
- private:
- ucl::LayoutSRef m_widget;
- ucl::StyledWidgetSRef m_callerId;
- ucl::StyledWidgetSRef m_label;
- ucl::GuiPresenterWRef m_parent;
- CallMode m_mode;
- ICallInfoSCRef m_incomCallInfo;
- ICallInfoSCRef m_activeCallInfo;
- ICallInfoSCRef m_heldCallInfo;
- ICallInfoSCRef m_endCallInfo;
- CallStatusPresenterSRef m_callStatus;
- bool m_isSubTxtEnable;
- bool m_needModifyCallStatus;
-
- // Screen Reader
- ucl::ElmWidgetSRef m_statusAO;
- ucl::ElmWidgetSRef m_mainTxtAO;
- ucl::ElmWidgetSRef m_subTxtAO;
- };
-
-}
-
-#endif // __CALLUI_PRESENTERS_CALL_INFO_PRESENTER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_PRESENTERS_CALL_STATUS_PRESENTER_H__
-#define __CALLUI_PRESENTERS_CALL_STATUS_PRESENTER_H__
-
-#include "ucl/mvp/GuiPresenter.h"
-
-#include <time.h>
-
-#include "ucl/gui/Layout.h"
-
-#include "types.h"
-
-namespace callui {
-
- class CallStatusPresenter final : public ucl::GuiPresenter {
- public:
- class Builder {
- public:
- Builder();
- virtual ~Builder();
- Builder &setMode(CallMode mode);
- Builder &setCallInfo(const ICallInfoWCRef &info);
- Builder &setCallHoldState(bool isOnHold);
- Builder &setLayout(const ucl::LayoutSRef &layout);
- CallStatusPresenterSRef build(ucl::GuiPresenter &parent) const;
- private:
- ucl::LayoutSRef m_ly;
- CallMode m_mode;
- ICallInfoWCRef m_info;
- bool m_isOnHold;
- };
- public:
- virtual ~CallStatusPresenter();
-
- // Screen Reader
- ucl::ElmWidget *getStatusTextAo();
-
- private:
- friend class ucl::ReffedObj<CallStatusPresenter>;
- CallStatusPresenter(ucl::IRefCountObj &rc,
- const ucl::LayoutSRef &layout,
- CallMode mode,
- const ICallInfoWCRef &info,
- bool isOnHold);
-
- ucl::Result prepare(ucl::GuiPresenter &parent);
-
- ucl::Result processIncomingMode();
- ucl::Result processOutgoingMode();
- ucl::Result processDuringMode();
- ucl::Result processEndMode();
-
- Eina_Bool onCallDurationTimerCb();
- Eina_Bool onBlinkingTimerCb();
-
- // Screen Reader
- ucl::Result createStatusTxtAo();
-
- private:
- ucl::LayoutSRef m_ly;
- CallMode m_mode;
- ICallInfoWCRef m_info;
- bool m_isOnHold;
- Ecore_Timer *m_timer;
- struct tm m_duration;
- int m_blinkCount;
-
- // Screen Reader
- ucl::ElmWidgetSRef m_statusTxtAo;
- };
-
-}
-
-#endif // __CALLUI_PRESENTERS_CALL_STATUS_PRESENTER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_PRESENTERS_DEVICE_STATE_PRESENTER_H__
-#define __CALLUI_PRESENTERS_DEVICE_STATE_PRESENTER_H__
-
-#include "ucl/gui/Window.h"
-
-#include "types.h"
-
-namespace callui {
-
- class DeviceStatePresenter final {
- public:
- class Builder {
- public:
- Builder();
- Builder &setDisplayState(DisplayState state);
- Builder &setDisplayMode(DisplayMode mode);
- Builder &setCpuLockState(bool lockState);
- DeviceStatePresenterSRef build(
- const ucl::WindowSRef &window) const;
- private:
- DisplayState m_state;
- DisplayMode m_mode;
- bool m_lockState;
- };
-
- public:
- ucl::Result setDisplayState(DisplayState state,
- bool forse = false);
- ucl::Result setDisplayMode(DisplayMode mode);
- ucl::Result setCpuLockState(bool lockState);
-
- private:
- friend class ucl::ReffedObj<DeviceStatePresenter>;
- DeviceStatePresenter(const ucl::WindowSRef &window);
- ~DeviceStatePresenter() = default;
-
- ucl::Result prepare(DisplayState state,
- DisplayMode mode,
- bool lockState);
-
- private:
- ucl::WindowSRef m_window;
- DisplayMode m_mode;
- bool m_lockState;
- };
-}
-
-#endif // __CALLUI_PRESENTERS_DEVICE_STATE_PRESENTER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_PRESENTERS_INDICATOR_PRESENTER_H__
-#define __CALLUI_PRESENTERS_INDICATOR_PRESENTER_H__
-
-#include "ucl/mvp/GuiPresenter.h"
-#include "model/IIndicatorStateListener.h"
-
-#include "ucl/gui/Layout.h"
-#include "ucl/gui/StyledWidget.h"
-
-#include "types.h"
-
-namespace callui {
-
- class IndicatorPresenter final : public ucl::GuiPresenter,
- public IIndicatorStateListener {
- public:
- class Builder {
- public:
- Builder();
- ~Builder();
- Builder &setIndicatorStateProvider(
- const IIndicatorStateProviderSRef &provider);
- Builder &setParentWidget(const ucl::ElmWidgetSRef
- &parentWidget);
- IndicatorPresenterSRef build(ucl::GuiPresenter &parent) const;
- private:
- IIndicatorStateProviderSRef m_provider;
- ucl::ElmWidgetSRef m_parentWidget;
- };
-
- public:
- virtual ~IndicatorPresenter();
-
- ucl::Widget &getWidget();
-
- void udapteIncomingCallMode(bool isIncomingCallMode);
-
- private:
- friend class ucl::ReffedObj<IndicatorPresenter>;
- IndicatorPresenter(ucl::IRefCountObj &rc,
- const IIndicatorStateProviderSRef &provider);
-
- ucl::Result prepare(ucl::GuiPresenter &parent, ucl::ElmWidget &parentWidget);
-
- ucl::Result createWidget(ucl::ElmWidget &parent);
- ucl::Result createConnectionLayout();
- ucl::Result createRssiLayout();
- ucl::Result createBatteryLayout();
- ucl::Result createVoiceControlLayout();
- ucl::Result createSimLayout();
- ucl::Result createHdVoiceLayout();
-
- void updateConnectionState();
- void updateRssiState();
- void updateBatteryState();
- void updateSimState();
- void updateHdVoiceState();
-
- void updateCentralIcon();
-
- // IIndicatorStateListener
-
- virtual void onStateChanged(IndicatorProperty property) override final;
-
- private:
- ucl::LayoutSRef m_widget;
- ucl::LayoutSRef m_connLayout;
- ucl::LayoutSRef m_rssiLayout;
- ucl::LayoutSRef m_batteryLayout;
- ucl::LayoutSRef m_simLayout;
- ucl::LayoutSRef m_hdCallLayout;
- ucl::LayoutSRef m_voiceControlLayout;
- IIndicatorStateProviderSRef m_provider;
- bool m_isIncomingCallMode;
- };
-
- ucl::EdjeSignal getConnectionSignal(ConnectionType type);
-}
-
-#endif // __CALLUI_PRESENTERS_INDICATOR_PRESENTER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_PRESENTERS_INSTANCE_H__
-#define __CALLUI_PRESENTERS_INSTANCE_H__
-
-#include "ucl/appfw/IInstance.h"
-#include "ucl/appfw/IInstanceAppControlExt.h"
-#include "ucl/appfw/SysEventProvider.h"
-
-#include "ucl/gui/Theme.h"
-#include "ucl/gui/Naviframe.h"
-
-#include "types.h"
-
-namespace callui {
-
- class Instance final : public ucl::RefCountAware,
- public ucl::IInstance,
- public ucl::IInstanceAppControlExt {
- public:
- Instance(ucl::IRefCountObj &rc,
- ucl::SysEventProvider &sysEventProvider);
- virtual ~Instance();
-
- // IInstance //
-
- virtual ucl::Result onCreate(
- ucl::IInstanceContext *context) final override;
- virtual void onPause() final override;
- virtual void onResume() final override;
-
- // IInstanceAppControlExt //
-
- virtual void onAppControl(app_control_h appControl) final override;
-
- private:
- ucl::Result setupTheme();
-
- void onSysEvent(const ucl::SysEvent sysEvent);
- void onPageExitRequest(Page &page);
-
- Eina_Bool onKeyUpEventCb(int type, void *event);
-
- private:
- ucl::SysEventProvider &m_sysEventProvider;
- ucl::IInstanceContext *m_context;
-
- ICallUISRef m_call;
-
- ucl::WindowSRef m_win;
- ucl::NaviframeSRef m_navi;
- ucl::Theme m_theme;
-
- PageWRef m_page;
-
- Ecore_Event_Handler *m_keyUpEventHandler;
- };
-}
-
-#endif // __CALLUI_PRESENTERS_INSTANCE_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_PRESENTERS_INSTANCE_MANAGER_H__
-#define __CALLUI_PRESENTERS_INSTANCE_MANAGER_H__
-
-#include "types.h"
-
-#include "ucl/appfw/InstanceManagerBase.h"
-
-namespace callui {
-
- class InstanceManager : public ucl::InstanceManagerBase {
- public:
- InstanceManager();
-
- // ucl::InstanceManagerBase //
-
- virtual ucl::IInstanceSRef newInstance() const final override;
- };
-}
-
-#endif // __CALLUI_PRESENTERS_INSTANCE_MANAGER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_PRESENTERS_KEYPAD_PAGE_H__
-#define __CALLUI_PRESENTERS_KEYPAD_PAGE_H__
-
-#include "Page.h"
-
-#include "ucl/gui/Layout.h"
-#include "ucl/gui/NaviItem.h"
-
-#include "types.h"
-
-#include "model/ISoundManager.h"
-
-namespace callui {
-
- class KeypadPage final : public Page {
- public:
- class Builder {
- public:
- Builder();
- ~Builder();
- Builder &setNaviframe(const ucl::NaviframeSRef &navi);
- Builder &setSoundManager(const ISoundManagerSRef &sm);
- KeypadPageSRef build(const ExitRequestHandler onExitRequest) const;
- private:
- ISoundManagerSRef m_sm;
- ucl::NaviframeSRef m_navi;
- };
-
- private:
- friend class ucl::ReffedObj<KeypadPage>;
- KeypadPage(ucl::IRefCountObj &rc,
- const ISoundManagerSRef &sm,
- const ucl::NaviframeSRef &navi,
- const ExitRequestHandler onExitRequest);
- virtual ~KeypadPage();
-
- ucl::Result doPrepare(ucl::NaviItem &item);
-
- void onBtnPressed(ucl::Widget &widget, void *eventInfo);
- void onBtnUnpressed(ucl::Widget &widget, void *eventInfo);
- void onBtnClicked(ucl::Widget &widget, void *eventInfo);
-
- ucl::Result createWidget();
- ucl::Result createEntry();
- ucl::Result createButtons();
- ucl::Result createVolumeControl();
-
- void startDtmf(const unsigned char digit);
- void stopDtmf();
-
- void onAudioStateChanged(AudioStateType state);
- void onVolumeControlEventCb(VolumeControlEvent event);
- Eina_Bool onVCTimerCb();
- void startVCTimer();
- void restartVCTimer();
- void stopVCTimer();
- void tryIncreaseVolume();
- void tryDecreaseVolume();
- void updateVolume(int value);
- void onVolumeLevelChanged(int value);
- Eina_Bool onRotaryEvent(Eext_Rotary_Event_Info *info);
-
- void registerCallbacks();
- void unregisterCallbacks();
-
- // Screen Reader
- ucl::Result createAtspiHighlightHelper();
- Elm_Interface_Atspi_Accessible *onAtspiHighlight(
- Elm_Interface_Atspi_Accessible *ao,
- Elm_Atspi_Relation_Type flowRelation);
- ucl::ElmWidget *getFirstButton();
- ucl::ElmWidget *getLastButton();
- void registerVolumeControlAo();
- void onVolumeControlScreenReaderReadStart(
- ucl::Widget &widget,
- void *eventInfo);
-
-
- // Page
-
- virtual void onBackKey() override final;
-
- private:
- ucl::LayoutSRef m_widget;
- ucl::ElmWidgetSRef m_entry;
-
- ISoundManagerSRef m_sm;
- bool m_smInUse;
-
- VolumeControlSRef m_vc;
- Ecore_Timer *m_vcTimer;
-
- AudioStateType m_audioState;
-
- // Screen Reader
- AtspiHighlightHelperSRef m_atspiHelper;
- };
-}
-
-#endif // __CALLUI_PRESENTERS_KEYPAD_PAGE_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_PRESENTERS_MAIN_PAGE_H__
-#define __CALLUI_PRESENTERS_MAIN_PAGE_H__
-
-#include "Page.h"
-#include "model/ICallListener.h"
-
-#include "ucl/gui/Layout.h"
-#include "ucl/gui/StyledWidget.h"
-#include "ucl/gui/NaviItem.h"
-
-#include "types.h"
-
-namespace callui {
-
- class MainPage final : public Page,
- public ICallListener {
- public:
- class Builder {
- public:
- Builder();
- ~Builder();
- Builder &setNaviframe(const ucl::NaviframeSRef &navi);
- Builder &setCallUI(const ICallUISRef &call);
- MainPageSRef build(const ExitRequestHandler handler) const;
- private:
- ucl::NaviframeSRef m_navi;
- ICallUISRef m_call;
- };
-
- private:
- friend class ucl::ReffedObj<MainPage>;
- MainPage(ucl::IRefCountObj &rc,
- const ucl::NaviframeSRef &navi,
- const ExitRequestHandler handler,
- const ICallUISRef &call);
- virtual ~MainPage();
-
- ucl::Result doPrepare(ucl::NaviItem &item);
-
- ucl::Result showWindow();
- void updateCallMode();
-
- ucl::Result processIncomingCallMode();
- ucl::Result processEndCallMode();
- ucl::Result processRegularCallModes();
-
- ucl::Result createCallInfoPresenter(CallMode mode);
- ucl::Result createAccessoryPresenter();
- ucl::Result createMoreOptionsPresenter();
- ucl::Result createAcceptRejectPresenter();
- ucl::Result createRejectMsgPresenter(
- const IRejectMsgProviderSRef &provider);
-
- ucl::Result createRejectMsgCue();
- void RejectMsgStateCb(RejectMsgState state);
- void RejectMsgSelectCb(const IRejectMsgSRef &rm);
-
- ucl::Result createBottomBtn(const ucl::ElmStyle &style,
- bool setVisible = true);
- void onBottomBtnClicked(ucl::Widget &widget, void *eventInfo);
-
- void startEndCallTimer();
- void stopEndCallTimer();
- Eina_Bool onEndCallTimerCb();
-
- void onPowerKeyUp(ucl::Widget &widget, void *eventInfo);
- void processKeyPress();
-
- ucl::Result updateDeviceState(CallMode prevMode, CallMode curMode);
-
- ucl::Result createWidget();
- ucl::Result createIndicatorPresenter();
- ucl::Result createDisplayPresenter();
-
- void onExitAppRequest();
-
- // Screen Reader
- ucl::Result createRejectMsgCueAo();
- ucl::Result createAtspiHighlightHelper();
- void registerIncomingCallModeAo();
- void registerActiveCallModeAo();
- void registerEndCallModeAo();
- Elm_Interface_Atspi_Accessible *onIncomingCallModeAtspiHighlight(
- Elm_Interface_Atspi_Accessible *widget,
- Elm_Atspi_Relation_Type flowRelation);
- Elm_Interface_Atspi_Accessible *onActiveCallModeAtspiHighlight(
- Elm_Interface_Atspi_Accessible *widget,
- Elm_Atspi_Relation_Type flowRelation);
- Elm_Interface_Atspi_Accessible *onEndCallModeAtspiHighlight(
- Elm_Interface_Atspi_Accessible *ao,
- Elm_Atspi_Relation_Type flowRelation);
- bool onIncomingModeAtspiGesture(
- Elm_Interface_Atspi_Accessible *widget,
- Elm_Atspi_Gesture_Type gestureType);
-
- // Page
-
- virtual void onBackKey() final override;
-
- // ICallListener
-
- virtual void onCallEvent(CallEventType type) final override;
- virtual void onError(CallErr err) final override;
-
- private:
- ucl::LayoutSRef m_widget;
- ucl::LayoutSRef m_rmLy;
- ucl::StyledWidgetSRef m_bottomBtn;
-
- ICallUISRef m_call;
- ICallManagerSRef m_cm;
- IndicatorPresenterSRef m_indicator;
- CallInfoPresenterSRef m_callInfoPrs;
- AcceptRejectPresenterSRef m_acceptRejectPrs;
- RejectMsgPresenterSRef m_rmPrs;
- AccessoryPresenterSRef m_accessoryPrs;
- MoreOptionsPresenterSRef m_moreOptionsPrs;
- DeviceStatePresenterSRef m_devicePrs;
-
- CallMode m_mode;
- Ecore_Timer *m_ecTimer;
- bool m_ecTimerBtnReq;
-
- // Screen Reader
- ucl::ElmWidgetSRef m_rmCueAo;
- AtspiHighlightHelperSRef m_atspiHelper;
- };
-}
-
-#endif // __CALLUI_PRESENTERS_MAIN_PAGE_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_PRESENTERS_MORE_OPTIONS_PRESENTER_H__
-#define __CALLUI_PRESENTERS_MORE_OPTIONS_PRESENTER_H__
-
-#include "ucl/mvp/GuiPresenter.h"
-
-#include "ucl/gui/Layout.h"
-#include "ucl/gui/StyledWidget.h"
-#include "ucl/gui/Naviframe.h"
-
-#include "Page.h"
-
-#include "types.h"
-
-namespace callui {
-
- class MoreOptionsPresenter final : public ucl::GuiPresenter {
- public:
- class Builder {
- public:
- Builder();
- Builder &setCallManager(const ICallManagerSRef &cm);
- Builder &setSoundManager(const ISoundManagerSRef &sm);
- Builder &setNaviframe(const ucl::NaviframeSRef &navi);
- Builder &setParentWidget(const ucl::ElmWidgetSRef &parentWidget);
- MoreOptionsPresenterSRef build(ucl::GuiPresenter &parent) const;
-
- private:
- ICallManagerSRef m_cm;
- ISoundManagerSRef m_sm;
- ucl::NaviframeSRef m_navi;
- ucl::ElmWidgetSRef m_parentWidget;
- };
-
- public:
- ucl::Widget &getWidget();
- void update();
-
- // Screen Reader
- ucl::ElmWidget *getCueAo();
-
- private:
- friend class ucl::ReffedObj<MoreOptionsPresenter>;
- MoreOptionsPresenter(ucl::IRefCountObj &rc,
- const ICallManagerSRef &cm,
- const ISoundManagerSRef &sm,
- const ucl::NaviframeSRef &navi);
- virtual ~MoreOptionsPresenter();
-
- ucl::Result prepare(ucl::GuiPresenter &parent,
- ucl::ElmWidget &parentWidget);
-
- void updateComponents();
-
- ucl::Result createWidget(ucl::ElmWidget &parent);
- ucl::Result createPanel();
- ucl::Result createPanelLayout();
-
- ucl::Result createSwapButton();
- ucl::Result createUnholdButton();
- ucl::Result createKeypadButton();
-
- ucl::StyledWidgetSRef createButton(const ucl::ElmStyle &style,
- const ucl::TString &txt,
- const ucl::WidgetEventHandler &handler);
-
- void updateSlots();
- void updateStatusText();
-
- void onSwapBtnClick(ucl::Widget &sender, void *eventInfo);
- void onUnholdBtnClick(ucl::Widget &sender, void *eventInfo);
- void onKeypadBtnClick(ucl::Widget &sender, void *eventInfo);
-
- void onBackKey(Evas_Object *obj, void *eventInfo);
-
- void onPanelActivate(Evas_Object *obj,
- const char *emission,
- const char *source);
- void onPanelInactivate(Evas_Object *obj,
- const char *emission,
- const char *source);
- void onCueClicked(Evas_Object *obj,
- const char *emission,
- const char *source);
-
- ucl::Result startCallDurationTimer();
- void stopCallDurationTimer();
- Eina_Bool onCallDurationTimerCb();
-
- void unsetPanelContent(const ucl::EdjePart &part);
- void setPanelContent(ucl::StyledWidget &widget,
- const ucl::EdjePart &part);
-
- void onPageExitRequest(Page &page);
-
- // Screen Reader
- ucl::Result createAccessObjects();
- ucl::Result createCueAo();
- ucl::Result createStatusTxtAo();
- ucl::Result createFakeAo();
- ucl::Result createAtspiHighlightHelper();
- Elm_Interface_Atspi_Accessible *onAtspiHighlight(
- Elm_Interface_Atspi_Accessible *ao,
- Elm_Atspi_Relation_Type flowRelation);
- Eina_Bool onCueAoActionCb(Evas_Object *obj,
- Elm_Access_Action_Info *actionInfo);
-
- private:
- ucl::LayoutSRef m_widget;
- ucl::StyledWidgetSRef m_panel;
- ucl::LayoutSRef m_panelLy;
- ucl::StyledWidgetSRef m_btnSwap;
- ucl::StyledWidgetSRef m_btnUnhold;
- ucl::StyledWidgetSRef m_btnKeypad;
-
- PageWRef m_keypad;
- ICallManagerSRef m_cm;
- ISoundManagerSRef m_sm;
- ucl::NaviframeSRef m_navi;
- ICallInfoWCRef m_info;
-
- Ecore_Timer *m_timer;
- struct tm m_duration;
-
- // Screen Reader
- AtspiHighlightHelperSRef m_atspiHelper;
- ucl::ElmWidgetSRef m_fakeAo;
- ucl::ElmWidgetSRef m_cueAo;
- ucl::ElmWidgetSRef m_statusTxtAo;
- };
-}
-
-#endif // __CALLUI_PRESENTERS_MORE_OPTIONS_PRESENTER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_PRESENTERS_MOTION_SENSOR_PRESENTER_H__
-#define __CALLUI_PRESENTERS_MOTION_SENSOR_PRESENTER_H__
-
-#include <gesture_recognition.h>
-
-#include "types.h"
-
-namespace callui {
-
- class MotionSensorPresenter final {
- public:
- class Builder {
- public:
- Builder();
- ~Builder();
- MotionSensorPresenterSRef build(const MotionSensorHandler handler) const;
- };
- private:
- friend class ucl::ReffedObj<MotionSensorPresenter>;
- MotionSensorPresenter(const MotionSensorHandler &handler);
- virtual ~MotionSensorPresenter();
-
- ucl::Result prepare();
-
- void onGestureCb(gesture_type_e motion,
- const gesture_data_h data,
- double timeStamp,
- gesture_error_e error);
-
- private:
- MotionSensorHandler m_handler;
- gesture_h m_gesture;
- };
-
-}
-
-#endif // __CALLUI_PRESENTERS_MOTION_SENSOR_PRESENTER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_PRESENTERS_PAGE_H__
-#define __CALLUI_PRESENTERS_PAGE_H__
-
-#include "ucl/gui/Naviframe.h"
-
-#include "ucl/mvp/GuiPresenter.h"
-
-namespace callui {
-
- UCL_DECLARE_REF_ALIASES(Page);
-
- class Page : public ucl::GuiPresenter {
- public:
- using ExitRequestHandler = ucl::WeakDelegate<void(Page &page)>;
-
- public:
- ucl::Naviframe &getNaviframe();
-
- bool isAtTop() const;
- bool isAtBottom() const;
-
- void exit();
- void exitNoTransition();
-
- void popTo();
- void deleteTo();
- void promote();
-
- template <class ...ARGS>
- ucl::NaviItem insertAfter(ARGS &&...args);
-
- template <class ...ARGS>
- ucl::NaviItem insertBefore(ARGS &&...args);
-
- protected:
- Page(ucl::IRefCountObj &rc, const ucl::NaviframeSRef &navi,
- const ExitRequestHandler &onExitRequest);
- virtual ~Page();
-
- template <class ON_PREPARE>
- ucl::Result prepare(ON_PREPARE &&onPrepare);
-
- ucl::NaviItem getItem();
-
- void requestExit();
-
- virtual void onBackKey();
-
- private:
- ucl::Result preparePart2();
-
- void dispatchTopPageChanged();
-
- void updateActiveState();
-
- void onTransitionStarted(ucl::Widget &widget, void *eventInfo);
- void onTransitionFinished(ucl::Widget &widget, void *eventInfo);
- void onTopPageChanged(ucl::Widget &widget, void *eventInfo);
-
- void onHWBackKey(Evas_Object *obj, void *eventInfo);
- void onItemDel(Evas_Object *obj, void *eventInfo);
-
- private:
- const ucl::NaviframeSRef m_navi;
- const ExitRequestHandler m_onExitRequest;
- ucl::NaviItem m_item;
- PageSRef m_selfRef;
- };
-
- // Non-member functions
-
- bool isLast(const Page &page);
-}
-
-#include "Page.hpp"
-
-#endif // __CALLUI_PRESENTERS_PAGE_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "ucl/util/logging.h"
-
-namespace callui {
-
- template <class ON_PREPARE>
- inline ucl::Result Page::prepare(ON_PREPARE &&onPrepare)
- {
- UCL_FAIL_RETURN(GuiPresenter::prepare(*m_navi),
- "GuiPresenter::prepare() failed!");
-
- UCL_FAIL_RETURN(onPrepare(m_item), "onPrepare() failed!");
-
- return preparePart2();
- }
-
- template <class ...ARGS>
- inline ucl::NaviItem Page::insertAfter(ARGS &&...args)
- {
- return m_navi->insertAfter(m_item, std::forward<ARGS>(args)...);
- }
-
- template <class ...ARGS>
- inline ucl::NaviItem Page::insertBefore(ARGS &&...args)
- {
- return m_navi->insertBefore(m_item, std::forward<ARGS>(args)...);
- }
-
- inline ucl::Naviframe &Page::getNaviframe()
- {
- UCL_ASSERT(m_navi, "m_navi is NULL");
- return *m_navi;
- }
-
- inline bool Page::isAtTop() const
- {
- return (m_navi->getTopItem() == m_item);
- }
-
- inline bool Page::isAtBottom() const
- {
- return (m_navi->getBottomItem() == m_item);
- }
-
- // Non-member functions
-
- inline bool isLast(const Page &page)
- {
- return (page.isAtBottom() && page.isAtTop());
- }
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_PRESENTERS_REJECT_MESSAGE_PRESENTER_H__
-#define __CALLUI_PRESENTERS_REJECT_MESSAGE_PRESENTER_H__
-
-#include "ucl/mvp/GuiPresenter.h"
-
-#include "ucl/gui/Layout.h"
-#include "ucl/gui/StyledWidget.h"
-
-#include "types.h"
-
-namespace callui {
-
- class RejectMsgPresenter final : public ucl::GuiPresenter {
- public:
- class Builder {
- public:
- Builder();
- virtual ~Builder();
- Builder &setProvider(const IRejectMsgProviderSRef &provider);
- Builder &setStateHandler(const RejectMsgStateHandler &handler);
- Builder &setSelectHandler(const RejectMsgSelectHandler &handler);
- Builder &setParentWidget(const ucl::ElmWidgetSRef &parentWidget);
- RejectMsgPresenterSRef build(ucl::GuiPresenter &parent) const;
-
- private:
- IRejectMsgProviderSRef m_provider;
- RejectMsgStateHandler m_stateHandler;
- RejectMsgSelectHandler m_selectHandler;
- ucl::ElmWidgetSRef m_parentWidget;
- };
-
- public:
- virtual ~RejectMsgPresenter();
-
- ucl::Widget &getWidget();
-
- RejectMsgState getState();
-
- void showPanel();
- void hidePanel();
-
- void setStateHandler(const RejectMsgStateHandler &handler);
- void setSelectHandler(const RejectMsgSelectHandler &handler);
-
- private:
- class RejectMsgItem;
-
- private:
- friend class ucl::ReffedObj<RejectMsgPresenter>;
- RejectMsgPresenter(ucl::IRefCountObj &rc,
- const IRejectMsgProviderSRef &provider,
- const RejectMsgStateHandler &stateHandler,
- const RejectMsgSelectHandler &selectHandler);
-
- ucl::Result prepare(ucl::GuiPresenter &parent,
- ucl::ElmWidget &parentWidget);
-
- ucl::Result createWidget(ucl::ElmWidget &parent);
- ucl::Result createPanel();
- ucl::Result createPanelBg();
- ucl::Result createPanelLy();
- ucl::Result createGenlist();
-
- ucl::Result fillGenlist();
- ucl::Result addGenlistTitleItem();
- ucl::Result addGenlistTextItem(const IRejectMsgSRef &rm);
- ucl::Result addGenlistBottomItem();
-
- void onGenlistItemClickedCb(Evas_Object *obj, void *eventInfo);
- void handleSelectEvent(const RejectMsgItem &item);
-
- void panelScrollCb(ucl::Widget &widget, void *eventInfo);
-
- void activateRotary();
- void deactivateRotary();
-
- void onBackKey(Evas_Object *obj, void *eventInfo);
-
- // Screen Reader
- ucl::Result createAtspiHighlightHelper();
- void registerGenlistAtspiGestureCallbacks();
- Elm_Interface_Atspi_Accessible *getFirstAo();
- Elm_Interface_Atspi_Accessible *getLastAo();
- Eina_Bool onAtspiGesture(
- Elm_Atspi_Gesture_Info gestureInfo,
- Elm_Interface_Atspi_Accessible *ao);
- Elm_Interface_Atspi_Accessible *onAtspiHighlight(
- Elm_Interface_Atspi_Accessible *ao,
- Elm_Atspi_Relation_Type flowRelation);
-
- // Presenter
-
- virtual void onActivate() final override;
- virtual void onDeactivate() final override;
-
- private:
- ucl::LayoutSRef m_widget;
- ucl::StyledWidgetSRef m_panel;
- ucl::ElmWidgetSRef m_panelBg;
- ucl::LayoutSRef m_panelLy;
- ucl::StyledWidgetSRef m_genlist;
- Evas_Object *m_circleEo;
-
- IRejectMsgProviderSRef m_provider;
- RejectMsgStateHandler m_stateHandler;
- RejectMsgSelectHandler m_selectHandler;
- RejectMsgState m_state;
-
- // Screen Reader
- AtspiHighlightHelperSRef m_atspiHelper;
- };
-
-}
-
-#endif // __CALLUI_PRESENTERS_REJECT_MESSAGE_PRESENTER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_PRESENTERS_TYPES_H__
-#define __CALLUI_PRESENTERS_TYPES_H__
-
-#include "../types.h"
-
-#include "view/types.h"
-#include "model/types.h"
-
-namespace callui {
-
- enum class AcceptDialogEvent {
- HOLD_AND_ACCEPT,
- END_AND_ACCEPT,
- BACK
- };
-
- enum class CallMode {
- UNDEFINED,
- INCOMING,
- OUTGOING,
- DURING,
- END
- };
-
- enum class RejectMsgState {
- HIDDEN,
- IN_TRANSITION,
- SHOWN
- };
-
- enum class DisplayState {
- UNDEFINED,
- ON,
- OFF,
- DIM
- };
-
- enum class DisplayMode {
- UNDEFINED,
- REGULAR,
- TOP_PRIORITY
- };
-
- using AccessoryBtnMask = int;
-
- UCL_DECLARE_REF_ALIASES(Page);
-
- UCL_DECLARE_REF_ALIASES(MainPage);
- UCL_DECLARE_REF_ALIASES(KeypadPage);
-
- UCL_DECLARE_REF_ALIASES(AcceptRejectPresenter);
- UCL_DECLARE_REF_ALIASES(AcceptDialog);
-
- UCL_DECLARE_REF_ALIASES(IndicatorPresenter);
- UCL_DECLARE_REF_ALIASES(CallInfoPresenter);
- UCL_DECLARE_REF_ALIASES(CallStatusPresenter);
-
- UCL_DECLARE_REF_ALIASES(RejectMsgPresenter);
-
- UCL_DECLARE_REF_ALIASES(AccessoryPresenter);
- UCL_DECLARE_REF_ALIASES(MoreOptionsPresenter);
-
- UCL_DECLARE_REF_ALIASES(DeviceStatePresenter);
- UCL_DECLARE_REF_ALIASES(MotionSensorPresenter);
-
- UCL_DECLARE_REF_ALIASES(AtspiHighlightHelper);
-
- using AcceptDialogHandler = ucl::WeakDelegate<bool(AcceptDialog &, AcceptDialogEvent)>;
- using RejectMsgStateHandler = ucl::WeakDelegate<void(RejectMsgState)>;
- using RejectMsgSelectHandler = ucl::WeakDelegate<void(const IRejectMsgSRef &rm)>;
- using MotionSensorHandler = ucl::WeakDelegate<void()>;
-}
-
-#endif // __CALLUI_PRESENTERS_TYPES_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_RESOURCES_H__
-#define __CALLUI_RESOURCES_H__
-
-#include "ucl/misc/TString.h"
-
-#include "config.h"
-
-namespace callui {
-
- constexpr auto THEME_EDJE_PATH = "edje/theme.edj";
-
- extern const ucl::TString STR_ANSWER_CALL;
- extern const ucl::TString STR_HOLD_AND_ACCEPT;
- extern const ucl::TString STR_END_AND_ACCEPT;
-
- extern const ucl::TString STR_CALL_WITH_PS_WILL_END;
- extern const ucl::TString STR_CALL_ON_HOLD;
- extern const ucl::TString STR_WITH_PD_PEOPLE;
- extern const ucl::TString STR_CONFERENCE_CALL;
- extern const ucl::TString STR_UNKNOWN;
- extern const ucl::TString STR_EMERGENCY_CALL;
- extern const ucl::TString STR_VOICEMAIL;
-
- extern const ucl::TString STR_INCOMING_CALL;
- extern const ucl::TString STR_DIALING_CALL;
- extern const ucl::TString STR_ON_HOLD;
- extern const ucl::TString STR_CALL_ENDED;
-
- extern const ucl::TString STR_DECLINE_MESSAGES;
-
- extern const ucl::TString STR_VOLUME;
-
- extern const ucl::TString STR_MORE_SWAP;
- extern const ucl::TString STR_MORE_HEADSET;
- extern const ucl::TString STR_MORE_PHONE;
- extern const ucl::TString STR_MORE_KEYPAD;
- extern const ucl::TString STR_MORE_HOLD;
- extern const ucl::TString STR_MORE_UNHOLD;
- extern const ucl::TString STR_MORE_TRANSFER;
- extern const ucl::TString STR_MORE_GEAR;
-
- // Screen Reader
- extern const ucl::TString AO_STR_CALL;
- extern const ucl::TString AO_STR_VOLUME;
- extern const ucl::TString AO_STR_HEADSET;
- extern const ucl::TString AO_STR_GEAR_SPK;
- extern const ucl::TString AO_STR_MUTE;
- extern const ucl::TString AO_STR_MORE_OPTIONS;
- extern const ucl::TString AO_STR_END_CALL;
- extern const ucl::TString AO_STR_CALLBACK;
- extern const ucl::TString AO_STR_ADD_TO_CONTACTS;
- extern const ucl::TString AO_STR_ROTATE_BEZEL_TO_ADJUST;
- extern const ucl::TString AO_STR_DECREASE_VOLUME;
- extern const ucl::TString AO_STR_INCREASE_VOLUME;
- extern const ucl::TString AO_STR_ACCEPT_CALL;
- extern const ucl::TString AO_STR_SWIPE_RIGHT_WITH_TWO_FINGERS_TO_ACCEPT;
- extern const ucl::TString AO_STR_REJECT_CALL;
- extern const ucl::TString AO_STR_SWIPE_LEFT_WITH_TWO_FINGERS_TO_REJECT;
- extern const ucl::TString AO_STR_DECLINE_MESSAGES;
- extern const ucl::TString AO_STR_SWIPE_UP_WITH_TWO_FINGERS_TO_SEND_A_DECLINE_MESSAGE;
-
-}
-
-#endif // __CALLUI_RESOURCES_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_TYPES_H__
-#define __CALLUI_TYPES_H__
-
-#include "config.h"
-
-#include "ucl/util/types.h"
-#include "ucl/util/memory.h"
-#include "ucl/util/delegation.h"
-#include "ucl/util/smartDelegation.h"
-#include "ucl/misc/RefCountAware.h"
-
-namespace callui {
- enum {
- _UCL_RESULT,
-
- RES_PERMISSION_DENIED = ucl::_RES_BEGIN - 1,
- RES_NOT_REGISTERED = ucl::_RES_BEGIN - 2,
- RES_ALREADY_REGISTERED = ucl::_RES_BEGIN - 3,
- RES_OPERATION_FAILED = ucl::_RES_BEGIN - 4,
- RES_NOT_CONNECTED = ucl::_RES_BEGIN - 5
- };
-
- using NotiHandler = ucl::WeakDelegate<void()>;
-}
-
-#endif // __CALLUI_TYPES_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_VIEW_ACCEPT_REJECT_WIDGET_H__
-#define __CALLUI_VIEW_ACCEPT_REJECT_WIDGET_H__
-
-#include "ucl/gui/ElmWidget.h"
-
-#include "ucl/gui/Layout.h"
-#include "ucl/gui/StyledWidget.h"
-#include "ucl/misc/Timeout.h"
-
-#include "types.h"
-
-namespace callui {
-
- class AcceptRejectWidget final : public ucl::ElmWidget {
- public:
- class Builder {
- public:
- Builder();
- Builder &setAcceptEventHandler(const NotiHandler &handler);
- Builder &setRejectEventHandler(const NotiHandler &handler);
- Builder &setAcceptBtnType(AcceptButtonType type);
- AcceptRejectWidgetSRef build(ucl::ElmWidget &parent) const;
-
- private:
- NotiHandler m_acceptHandler;
- NotiHandler m_rejectHandler;
- AcceptButtonType m_acceptBtnType;
- };
-
- public:
- ~AcceptRejectWidget();
-
- void startBezelCueAnimation();
- void reset();
- void activateRotary();
- void deactivateRotary();
- void setAcceptBtnType(AcceptButtonType type);
-
- // Screen Reader
- ucl::ElmWidget *getAcceptAo();
- ucl::ElmWidget *getRejectAo();
-
- private:
- friend class ucl::ReffedObj<AcceptRejectWidget>;
- AcceptRejectWidget(ucl::IRefCountObj &rc,
- const ucl::LayoutSRef &layout,
- const NotiHandler &acceptHandler,
- const NotiHandler &rejectHandler,
- AcceptButtonType acceptBtnType);
-
- void prepare();
-
- ucl::Result createAcceptComponents();
- ucl::Result createRejectComponents();
- ucl::Result createBezelCueComponents();
-
- void setBezelCueVisible(bool isVisible);
-
- void onMouseDown(ucl::Widget &widget, void *eventInfo);
- void onMouseUp(ucl::Widget &widget, void *eventInfo);
- void onMouseMove(ucl::Widget &widget, void *eventInfo);
-
- int getTracerMoveDistance(
- const ElmWidget &widget, int curX, int curY) const;
-
- void onAcceptBCTransitDel(Elm_Transit *transit);
- void onAcceptBCTransitDelLast(Elm_Transit *transit);
-
- void onRejectBCTransitDel(Elm_Transit *transit);
- void onRejectBCTransitDelLast(Elm_Transit *transit);
-
- void setAcceptPressedTransitions();
- void setAcceptTracerPressedTransition();
- void setAcceptGuidePressedTransition();
- void setAcceptGuideUnpressedTransition();
- void setAcceptIconPressedTransition();
- void setRejectIconHideTransition();
- void setRejectIconShowTransition();
- void setAcceptFullExpensionTransition();
- void setAcceptUnpressedTransitions();
-
- void setRejectPressedTransitions();
- void setRejectTracerPressedTransition();
- void setRejectGuidePressedTransition();
- void setRejectGuideUnpressedTransition();
- void setRejectIconPressedTransition();
- void setAcceptIconHideTransition();
- void setAcceptIconShowTransition();
- void setRejectFullExpensionTransition();
- void setRejectUnpressedTransitions();
-
- void onAcceptTransitDel(Elm_Transit *transit);
- void onAcceptFullExpensionTransitDel(Elm_Transit *transit);
- void onAcceptBgExpandTransitDel(Elm_Transit *transit);
- void onAcceptBgContractTransitDel(Elm_Transit *transit);
- void onAcceptIconTransitDel(Elm_Transit *transit);
-
- void onRejectTransitDel(Elm_Transit *transit);
- void onRejectFullExpensionTransitDel(Elm_Transit *transit);
- void onRejectBgExpandTransitDel(Elm_Transit *transit);
- void onRejectBgContractTransitDel(Elm_Transit *transit);
- void onRejectIconTransitDel(Elm_Transit *transit);
-
- void onAcceptExpandTimeout(ucl::Timeout *sender);
- void onRejectExpandTimeout(ucl::Timeout *sender);
-
- Eina_Bool onRotaryEvent(Evas_Object *obj, Eext_Rotary_Event_Info *info);
- Eina_Bool processClockwiseRotaryEvent();
- Eina_Bool processCounterClockwiseRotaryEvent();
-
- void setAcceptPressedState();
- void setRejectPressedState();
- void setAcceptUnpressedState();
- void setRejectUnpressedState();
-
- // Screen Reader
- ucl::Result registerAccessObjects(
- ucl::ElmWidget &widget);
-
- private:
- ucl::Layout *m_layout;
- NotiHandler m_accHandler;
- NotiHandler m_rejHandler;
-
- std::vector<ucl::ElmWidgetSRef> m_accBezelCueImg;
- std::vector<ucl::ElmWidgetSRef> m_rejBezelCueImg;
-
- ucl::LayoutSRef m_accTracer;
- ucl::LayoutSRef m_accGuide;
- ucl::LayoutSRef m_accIcon;
- ucl::LayoutSRef m_accEventLy;
-
- ucl::LayoutSRef m_rejTracer;
- ucl::LayoutSRef m_rejGuide;
- ucl::LayoutSRef m_rejIcon;
- ucl::LayoutSRef m_rejEventLy;
-
- bool m_isFreezed;
- bool m_isAccPressed;
- bool m_isRejPressed;
- int m_lastMoveDistance;
- int m_rotaryClockwiseCount;
- int m_rotaryCounterClockwiseCount;
- bool m_isContracting;
-
- Elm_Transit *m_accTracerTr;
- Elm_Transit *m_accGuideTr;
- Elm_Transit *m_accIconTr;
-
- Elm_Transit *m_rejTracerTr;
- Elm_Transit *m_rejGuideTr;
- Elm_Transit *m_rejIconTr;
-
- Elm_Transit *m_lastAccBezelTr1;
- Elm_Transit *m_lastAccBezelTr2;
- Elm_Transit *m_lastRejBezelTr1;
- Elm_Transit *m_lastRejBezelTr2;
-
- int m_accBCAnimCount;
- int m_rejBCAnimCount;
-
- ucl::TimeoutSRef m_expandTimeout;
-
- int m_accBCAnimIndex;
- int m_rejBCAnimIndex;
-
- AcceptButtonType m_acceptBtnType;
-
- // Screen Reader
- ucl::ElmWidgetSRef m_accAo;
- ucl::ElmWidgetSRef m_rejAo;
- };
-
-}
-
-#endif // __CALLUI_VIEW_ACCEPT_REJECT_WIDGET_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_VIEW_SLIDER_H__
-#define __CALLUI_VIEW_SLIDER_H__
-
-#include "ucl/gui/Layout.h"
-
-#include "types.h"
-
-namespace callui {
-
- class Slider : public ucl::ElmWidget {
- public:
- class Builder {
- public:
- Builder();
- Builder &setMaxValue(int maxValue);
- Builder &setValue(int curValue);
- SliderSRef build(ucl::ElmWidget &parent) const;
-
- private:
- int m_maxValue;
- int m_curValue;
- };
-
- public:
- virtual void setValue(int value);
- virtual void setMaxValue(int maxValue);
-
- protected:
- friend class ucl::ReffedObj<Slider>;
- Slider(ucl::IRefCountObj &rc,
- const ucl::LayoutSRef &layout,
- int maxValue,
- int curValue);
- virtual ~Slider();
-
- private:
- void prepare(int maxValue, int curValue);
-
- protected:
- ucl::Layout *m_layout;
- ucl::Layout m_circleLy;
- Eext_Circle_Surface *m_circleSurf;
- ucl::ElmWidget m_slider;
- };
-
-}
-
-#endif // __CALLUI_VIEW_SLIDER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_VIEW_VOLUME_CONTROL_H__
-#define __CALLUI_VIEW_VOLUME_CONTROL_H__
-
-#include "view/Slider.h"
-
-#include "ucl/gui/StyledWidget.h"
-#include "ucl/gui/Layout.h"
-
-#include "types.h"
-
-namespace callui {
-
- class VolumeControl final : public Slider {
- public:
- class Builder {
- public:
- Builder();
- Builder &setInfoText(const ucl::TString &info);
- Builder &setMaxValue(int maxValue);
- Builder &setValue(int curValue);
- Builder &setEventHandler(const VolumeControlEventHandler &handler);
- VolumeControlSRef build(ucl::ElmWidget &parent) const;
-
- private:
- ucl::TString m_info;
- int m_maxValue;
- int m_curValue;
- VolumeControlEventHandler m_handler;
- };
-
- public:
- void setInfoText(const ucl::TString &info);
- void setDecreaseBtnEnable(bool isEnable);
- void setIncreaseBtnEnable(bool isEnable);
- void setEventHandler(const VolumeControlEventHandler &handler);
-
- // Slider
-
- virtual void setValue(int value) override final;
-
- // Screen Reader
- ucl::ElmWidget *getDecreaseBtn();
- ucl::ElmWidget *getIncreaseBtn();
- ucl::ElmWidget *getValueTxtAo();
-
- private:
- friend class ucl::ReffedObj<VolumeControl>;
- VolumeControl(ucl::IRefCountObj &rc,
- const ucl::LayoutSRef &layout,
- const ucl::TString &info,
- int maxValue,
- int curValue,
- const VolumeControlEventHandler &handler);
-
- virtual ~VolumeControl();
-
- void prepare(const ucl::TString &info, int curValue);
-
- void onDecreaseBtnClickedCb(ucl::Widget &widget, void *eventInfo);
- void onIncreaseBtnClickedCb(ucl::Widget &widget, void *eventInfo);
-
- void onWidgetShowCb(Widget &widget, void *eventInfo);
- void onWidgetHideCb(Widget &widget, void *eventInfo);
-
- // Screen Reader
- void registerAccessObjectInformation();
-
- private:
- ucl::StyledWidget m_decreaseBtn;
- ucl::StyledWidget m_increaseBtn;
- VolumeControlEventHandler m_handler;
-
- // Screen Reader
- ucl::ElmWidgetSRef m_valueTxtAo;
- };
-
-}
-
-#endif // __CALLUI_VIEW_VOLUME_CONTROL_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_VIEW_HELPERS_H__
-#define __CALLUI_VIEW_HELPERS_H__
-
-#include <efl_extension.h>
-
-#include "ucl/gui/ElmWidget.h"
-#include "ucl/gui/Naviframe.h"
-#include "ucl/gui/Layout.h"
-
-#include "types.h"
-
-namespace callui { namespace utils {
-
- ucl::Result createCircleSurface(ucl::Naviframe &navi);
-
- Eext_Circle_Surface *getCircleSurface(const ucl::ElmWidget &widget);
-
- ucl::ElmWidgetSRef createFakeAccessObject(ucl::ElmWidget &parent);
-
- Elm_Genlist_Item_Class createGenlistItemClass(const char *style,
- Elm_Gen_Item_Text_Get_Cb txtCb = nullptr,
- Elm_Gen_Item_Content_Get_Cb contentCb = nullptr,
- Elm_Gen_Item_State_Get_Cb stateCb = nullptr,
- Elm_Gen_Item_Del_Cb delCb = nullptr);
-
- ucl::ElmWidgetSRef createAccessObject(ucl::ElmWidget &parent,
- ucl::Widget &ly);
-
- ucl::ElmWidgetSRef createAccessObjectFromLyPart(ucl::ElmWidget &parent,
- ucl::Widget &ly,
- const ucl::EdjePart &lyPart);
-
- void destroyAccessObject(ucl::ElmWidget &ao);
-
-}}
-
-namespace callui {
-
- void addRotaryEventHandler(Eext_Rotary_Handler_Cb func, void *data);
-
- void delRotaryEventHandler(Eext_Rotary_Handler_Cb func, void *data);
-
- ucl::LayoutTheme getImageTheme(const char *fileName);
-
- Elm_Atspi_Relation_Type getFlowRelation(Elm_Atspi_Gesture_Info gestureInfo);
-
-}
-
-#endif // __CALLUI_VIEW_HELPERS_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_VIEW_TYPES_H__
-#define __CALLUI_VIEW_TYPES_H__
-
-#include <efl_extension.h>
-
-#include "ucl/gui/types.h"
-
-#include "../types.h"
-
-namespace callui {
-
- enum class VolumeControlEvent {
- INCREASE,
- DECREASE
- };
-
- enum class AcceptButtonType {
- SIMPLE,
- BT_HEADSET
- };
-
- UCL_DECLARE_REF_ALIASES(Slider);
- UCL_DECLARE_REF_ALIASES(VolumeControl);
- UCL_DECLARE_REF_ALIASES(AcceptRejectWidget);
-
- using VolumeControlEventHandler = ucl::WeakDelegate<void(VolumeControlEvent)>;
-}
-
-#endif // __CALLUI_VIEW_TYPES_H__
USER_C_INC_DIRS =
USER_INC_FILES =
## C++ Compiler
-USER_CPP_INC_DIRS = inc ucl/inc
+USER_CPP_INC_DIRS = . ucl/inc
USER_CPP_INC_FILES =
USER_INC_DIRS = $(USER_C_INC_DIRS) $(USER_CPP_INC_DIRS)
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_COMMON_H__
-#define __CALLUI_COMMON_H__
-
-#include <algorithm>
-
-#include <Ecore.h>
-
-#include "ucl/util/helpers.h"
-#include "ucl/util/logging.h"
-#include "ucl/util/shortLogs.h"
-
-#include "ucl/gui/stdTheme.h"
-#include "ucl/gui/helpers.h"
-
-#include "helpers.h"
-
-#undef UCL_LOG_TAG
-#define UCL_LOG_TAG "CALLUI"
-
-namespace callui {
-
- using namespace ucl;
-
- constexpr SmartEvent WIN_POWER_KEY_UP_EVENT {"callui,powerkey,up"};
-
-}
-
-#endif // __CALLUI_COMMON_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_HELPERS_H__
-#define __CALLUI_HELPERS_H__
-
-#include "types.h"
-
-namespace callui { namespace util {
-
- template <class GETTER, class V, class ...ARGS>
- ucl::Result get(GETTER &&getter, V &result, ARGS &&...args);
-
- template <class GETTER, class V, class ...ARGS>
- ucl::Result getNz(GETTER &&getter, V &result, ARGS &&...args);
-
- template <class FUNC, class ...ARGS>
- ucl::Result call(FUNC &&func, ARGS &&...args);
-}}
-
-#include "helpers.hpp"
-
-#endif // __CALLUI_HELPERS_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "ucl/util/helpers.h"
-#include "ucl/util/logging.h"
-
-namespace callui { namespace util { namespace himpl {
-
- template <class GETTER, class ...ARGS>
- inline ucl::Result get(GETTER &&getter, bool optional,
- std::string &result, ARGS &&...args)
- {
- char *value = nullptr;
- const int ret = getter(std::forward<ARGS>(args)..., &value);
- if ((ret != 0) || (!optional && ucl::isEmpty(value))) {
- UCL_ELOG("get() failed: %d", ret);
- return ucl::RES_FAIL;
- }
-
- if (value) {
- result = value;
- free(value);
- } else {
- result.clear();
- }
-
- return ucl::RES_OK;
- }
-
- template <class GETTER, class V, class ...ARGS>
- inline ucl::Result get(GETTER &&getter, bool optional,
- V &result, ARGS &&...args)
- {
- typename std::remove_pointer<decltype(&result)>::type value = {};
-
- const int ret = getter(std::forward<ARGS>(args)..., &value);
- if ((ret != 0) || (!optional && !value)) {
- UCL_ELOG("get() failed: %d", ret);
- return ucl::RES_FAIL;
- }
-
- result = value;
-
- return ucl::RES_OK;
- }
-}}}
-
-namespace callui { namespace util {
-
- template <class GETTER, class V, class ...ARGS>
- inline ucl::Result get(GETTER &&getter, V &result, ARGS &&...args)
- {
- return himpl::get(std::forward<GETTER>(getter), true,
- result, std::forward<ARGS>(args)...);
- }
-
- template <class GETTER, class V, class ...ARGS>
- inline ucl::Result getNz(GETTER &&getter, V &result, ARGS &&...args)
- {
- return himpl::get(std::forward<GETTER>(getter), false,
- result, std::forward<ARGS>(args)...);
- }
-
- template <class FUNC, class ...ARGS>
- inline ucl::Result call(FUNC &&func, ARGS &&...args)
- {
- const int ret = func(std::forward<ARGS>(args)...);
- if (ret != 0) {
- UCL_ELOG("func() failed: %d", ret);
- return ucl::RES_FAIL;
- }
- return ucl::RES_OK;
- }
-}}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "ucl/appfw/UIApp.h"
-
-#include "presenters/InstanceManager.h"
-
-#include "common.h"
-
-using namespace ucl;
-using namespace callui;
-
-int main(int argc, char *argv[])
-{
- ILOG("MAIN START");
-
- InstanceManager mgr;
- const int ret = UIApp(mgr).run(argc, argv);
-
- ILOG("MAIN END. ret[%d]", ret);
-
- return ret;
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "ActiveCall.h"
-
-#include <call-manager-extension.h>
-
-#include "CallManager.h"
-#include "CallClient.h"
-#include "CallInfo.h"
-
-#include "common.h"
-
-namespace callui {
-
- using namespace ucl;
-
- ActiveCall::ActiveCall(CallManagerWRef cm, cm_call_data_h callData):
- m_cm(cm),
- m_isDialing(false)
- {
- }
-
- ActiveCall::~ActiveCall()
- {
- }
-
- ActiveCallSRef ActiveCall::newInstance(CallManagerWRef cm, cm_call_data_h callData)
- {
- if (!cm) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "cm is NULL");
- }
-
- if (!callData) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "callData is NULL");
- }
-
- auto result = makeShared<ActiveCall>(cm, callData);
- FAIL_RETURN_VALUE(result->prepare(callData), {}, "result->prepare() failed!");
- return result;
- }
-
- Result ActiveCall::prepare(cm_call_data_h callData)
- {
- const auto cm = m_cm.lock();
- if (!cm) {
- LOG_RETURN(RES_FAIL, "Call Manager is NULL");
- }
-
- m_callInfo = CallInfo::newInstance(cm->getCallClient(),
- callData,
- cm->getContactInfoProvider());
- if (!m_callInfo) {
- LOG_RETURN_VALUE(RES_FAIL, RES_FAIL, "CallInfo::newInstance() failed!");
- }
-
- cm_call_state_e callState = CM_CALL_STATE_IDLE;
- FAIL_RETURN(convertCMResult(
- cm_call_data_get_call_state(callData, &callState)),
- "cm_call_data_get_call_state() failed!");
- m_isDialing = (callState == CM_CALL_STATE_DIALING);
-
- return RES_OK;
- }
-
- ICallInfoSCRef ActiveCall::getInfo() const
- {
- return m_callInfo;
- }
-
- bool ActiveCall::isDialingMode() const
- {
- return m_isDialing;
- }
-
- Result ActiveCall::hold()
- {
- const auto cm = m_cm.lock();
- if (!cm) {
- LOG_RETURN(RES_FAIL, "Call Manager is NULL");
- }
-
- return convertCMResult(cm_hold_call(cm->getCallClient()));
- }
-
- Result ActiveCall::end()
- {
- const auto cm = m_cm.lock();
- if (!cm) {
- LOG_RETURN(RES_FAIL, "Call Manager is NULL");
- }
-
- if (m_isDialing) {
- return cm->endCall(m_callInfo->getCallId(),
- CallReleaseType::BY_CALL_HANDLE);
- }
- return cm->endCall(0, CallReleaseType::ALL_ACTIVE);
- }
-
- Result ActiveCall::split(const IConferenceCallInfoSCRef &confCallInfo)
- {
- const auto cm = m_cm.lock();
- if (!cm) {
- LOG_RETURN(RES_FAIL, "Call Manager is NULL");
- }
- return cm->splitCalls(m_callInfo, confCallInfo);
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_ACTIVE_CALL_H__
-#define __CALLUI_MODEL_ACTIVE_CALL_H__
-
-#include <call-manager-ext.h>
-
-#include "model/IActiveCall.h"
-
-#include "implTypes.h"
-
-namespace callui {
-
- class ActiveCall final : public IActiveCall {
- public:
- static ActiveCallSRef newInstance(CallManagerWRef cm, cm_call_data_h callData);
- virtual ~ActiveCall();
-
- // IActiveCall
-
- virtual ICallInfoSCRef getInfo() const override final;
- virtual bool isDialingMode() const override final;
- virtual ucl::Result hold() override final;
- virtual ucl::Result end() override final;
- virtual ucl::Result split(const IConferenceCallInfoSCRef &confCallInfo) override final;
-
- private:
- friend class ucl::ReffedObj<ActiveCall>;
- ActiveCall(CallManagerWRef cm, cm_call_data_h callData);
-
- ucl::Result prepare(cm_call_data_h callData);
-
- private:
- CallManagerWRef m_cm;
- CallInfoSRef m_callInfo;
- bool m_isDialing;
- };
-
-}
-
-#endif // __CALLUI_MODEL_ACTIVE_CALL_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "BatteryStateSource.h"
-
-#include "common.h"
-
-namespace callui {
-
- using namespace ucl;
-
- BatteryStateSource::Bits::Bits():
- property(convertEnumValueToInt(IndicatorProperty::BATTERY)),
- chargeValue(0),
- chargingState(convertEnumValueToInt(BatteryState::NORMAL))
- {
- }
-
- BatteryStateSource::Bits::Bits(const IndicatorState &state):
- value(state.value)
- {
- if (property != convertEnumValueToInt(IndicatorProperty::BATTERY)) {
- ELOG("State of incorrect property type [%d]", property);
- *this = {};
- }
- }
-
- BatteryStateSource::BatteryStateSource()
- {
- }
-
- BatteryStateSource::~BatteryStateSource()
- {
- delSysStateCallbacks();
- }
-
- BatteryStateSourceSRef BatteryStateSource::newInstance()
- {
- auto result = makeShared<BatteryStateSource>();
- FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
- return result;
- }
-
- Result BatteryStateSource::prepare()
- {
- FAIL_RETURN(addSysStateCallbacks(), "addSysStateCallbacks() failed!");
-
- updateBatteryState();
-
- return RES_OK;
- }
-
- bool BatteryStateSource::updateChargingStateBits(BatteryState state)
- {
- int stateInt = convertEnumValueToInt(state);
- if (stateInt != m_bits.chargingState) {
- m_bits.chargingState = stateInt;
- return true;
- }
- return false;
- }
-
- bool BatteryStateSource::updateChargeLevelBits(int value)
- {
- if (value != m_bits.chargeValue) {
- m_bits.chargeValue = value;
- return true;
- }
- return false;
- }
-
- int BatteryStateSource::getCurChargeLevel() const
- {
- int capacity = 0;
- if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CAPACITY, &capacity) == 0) {
- return capacity;
- }
- ELOG("Get battery capacity failed!");
- return -1;
- }
-
- BatteryState BatteryStateSource::getCurChargingState() const
- {
- int isCharged = 0;
- if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, &isCharged) == 0) {
- switch (isCharged) {
- case -1: return BatteryState::CHARGING_PROBLEM;
- case 1: return BatteryState::CHARGING;
- default: return BatteryState::NORMAL;
- }
- }
- ELOG("Get battery charging status failed!");
- return BatteryState::NORMAL;
- }
-
- bool BatteryStateSource::updateBatteryState()
- {
- int chargeLevel = getCurChargeLevel();
- BatteryState state = getCurChargingState();
-
- if (chargeLevel < 0) {
- chargeLevel = 0;
- if (state == BatteryState::NORMAL) {
- state = BatteryState::UNKNOWN;
- }
- }
-
- bool wasUpdated = updateChargingStateBits(state);
- if (updateChargeLevelBits(chargeLevel)) {
- wasUpdated = true;
- }
- return wasUpdated;
- }
-
- void BatteryStateSource::onBatteryStateChangedCb(keynode_t *node)
- {
- if (updateBatteryState() && m_handler) {
- m_handler();
- }
- }
-
- Result BatteryStateSource::addSysStateCallbacks()
- {
- int res = vconf_notify_key_changed(VCONFKEY_SYSMAN_CHARGER_STATUS,
- CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb), this);
- if (res != 0) {
- LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
- }
-
- res = vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW,
- CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb), this);
- if (res != 0) {
- LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
- }
-
- res = vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW,
- CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb), this);
- if (res != 0) {
- LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
- }
-
- res = vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY,
- CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb), this);
- if (res != 0) {
- LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
- }
-
- return RES_OK;
- }
-
- void BatteryStateSource::delSysStateCallbacks()
- {
- vconf_ignore_key_changed(VCONFKEY_SYSMAN_CHARGER_STATUS,
- CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb));
- vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW,
- CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb));
- vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW,
- CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb));
- vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY,
- CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb));
- }
-
- IndicatorState BatteryStateSource::getState() const
- {
- return {m_bits.value};
- }
-
- void BatteryStateSource::setStateChangeHandler(const NotiHandler &handler)
- {
- m_handler = handler;
- }
-
- int getBatteryLevel(IndicatorState state)
- {
- return static_cast<int>(
- BatteryStateSource::Bits(state).chargeValue);
- }
-
- BatteryState getBatteryState(IndicatorState state)
- {
- return static_cast<BatteryState>(
- BatteryStateSource::Bits(state).chargingState);
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_BATTERY_STATE_SOURCE_H__
-#define __CALLUI_MODEL_BATTERY_STATE_SOURCE_H__
-
-#include "IIndicatorStateSource.h"
-
-#include <vconf.h>
-
-#include "implTypes.h"
-
-namespace callui {
-
- class BatteryStateSource final : public IIndicatorStateSource {
- public:
- static BatteryStateSourceSRef newInstance();
- virtual ~BatteryStateSource();
-
- // IIndicatorStateSource
-
- virtual IndicatorState getState() const override final;
- virtual void setStateChangeHandler(const NotiHandler &handler) override final;
-
- private:
- friend class ucl::ReffedObj<BatteryStateSource>;
- BatteryStateSource();
-
- ucl::Result prepare();
-
- ucl::Result addSysStateCallbacks();
- void delSysStateCallbacks();
-
- void onBatteryStateChangedCb(keynode_t *node);
-
- int getCurChargeLevel() const;
- BatteryState getCurChargingState() const;
-
- bool updateChargingStateBits(BatteryState state);
- bool updateChargeLevelBits(int value);
- bool updateBatteryState();
-
- public:
- union Bits {
- struct {
- uint8_t property : 4;
- uint8_t chargeValue : 8;
- uint8_t chargingState: 4;
- };
- uint64_t value;
-
- Bits();
- Bits(const IndicatorState &state);
- };
-
- private:
- Bits m_bits;
- NotiHandler m_handler;
- };
-
-}
-
-#endif // __CALLUI_MODEL_BATTERY_STATE_SOURCE_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "BluetoothManager.h"
-
-#include <bluetooth.h>
-#include <bluetooth_internal.h>
-#include <bluetooth_extension.h>
-#include <sound_manager.h>
-
-#include "common.h"
-
-namespace callui { namespace { namespace impl {
-
- using namespace ucl;
-
- constexpr auto BT_VOLUME_MAX = 15;
-
-}}}
-
-namespace callui {
-
- using namespace ucl;
-
- BluetoothManagerSRef BluetoothManager::newInstance()
- {
- auto result = makeShared<BluetoothManager>();
- FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
- return result;
- }
-
- BluetoothManager::BluetoothManager():
- m_btInitialized(false),
- m_btAudioInitialized(false),
- m_isHeadsetConnected(false)
- {
- }
-
- BluetoothManager::~BluetoothManager()
- {
- unregisterAudioHandling();
- unregisterHeadsetConnectionHandling();
- deinitializeBluetooth();
- }
-
- Result BluetoothManager::prepare()
- {
- FAIL_RETURN(initializeBluetooth(),
- "initializeBluetooth() failed!");
-
- FAIL_RETURN(registerAudioHandling(),
- "registerAudioHandling() failed");
-
- FAIL_RETURN(registerHeadsetConnectionHandling(),
- "registerHeadsetConnectionHandling() failed!");
-
- m_isHeadsetConnected = getHeadsetConnectionState();
-
- return RES_OK;
- }
-
- Result BluetoothManager::initializeBluetooth()
- {
- auto ret = bt_initialize();
- if (ret != BT_ERROR_NONE) {
- LOG_RETURN(RES_FAIL, "BT initialize failed! "
- "ret[%d] msg[%s]", ret, get_error_message(ret));
-
- }
- m_btInitialized = true;
- return RES_OK;
- }
-
- void BluetoothManager::deinitializeBluetooth()
- {
- bt_deinitialize();
- }
-
- int BluetoothManager::getVolume() const
- {
- auto vol = 0;
- auto ret = bt_ag_get_speaker_gain(&vol);
- if (ret != BT_ERROR_NONE) {
- LOG_RETURN_VALUE(RES_FAIL, -1, "bt_ag_get_speaker_gain() failed! "
- "ret[%d] msg[%s]", ret, get_error_message(ret));
- }
- DLOG("BT Volume level [%d]", vol);
- return vol;
- }
-
- int BluetoothManager::getMaxVolume() const
- {
- return impl::BT_VOLUME_MAX;
- }
-
- Result BluetoothManager::setVolume(int volume)
- {
- auto ret = bt_ag_notify_speaker_gain(volume);
- if (ret != BT_ERROR_NONE) {
- LOG_RETURN(RES_FAIL, "bt_ag_notify_speaker_gain() failed! "
- "ret[%d] msg[%s]", ret, get_error_message(ret));
- }
- return RES_OK;
- }
-
- void BluetoothManager::setVolumeStateHandler(
- const BluetoothVolumeHandler &handler)
- {
- m_btVolumeHandler = handler;
- }
-
- Result BluetoothManager::registerAudioHandling()
- {
- auto ret = bt_audio_initialize();
- if (ret != BT_ERROR_NONE) {
- LOG_RETURN(RES_FAIL, "bt_audio_initialize() failed! ",
- "ret[%d] msg[%s]", ret, get_error_message(ret));
- }
- m_btAudioInitialized = true;
-
- ret = bt_ag_set_speaker_gain_changed_cb(
- CALLBACK_B(BluetoothManager::onVolumeChanged), this);
- if (ret != BT_ERROR_NONE) {
- LOG_RETURN(RES_FAIL, "bt_ag_set_speaker_gain_changed_cb() failed! "
- "ret[%d] msg[%s]", ret, get_error_message(ret));
- }
-
- return RES_OK;
- }
-
- void BluetoothManager::unregisterAudioHandling()
- {
- bt_ag_unset_speaker_gain_changed_cb();
-
- if (m_btAudioInitialized) {
- bt_audio_deinitialize();
- m_btAudioInitialized = false;
- }
- }
-
- Result BluetoothManager::registerHeadsetConnectionHandling()
- {
- auto ret = vconf_notify_key_changed(VCONFKEY_BT_DEVICE,
- CALLBACK_B(BluetoothManager::onHeadsetConnectionChanged),
- this);
- if (ret != 0) {
- LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed!");
- }
- return RES_OK;
- }
-
- void BluetoothManager::unregisterHeadsetConnectionHandling()
- {
- vconf_ignore_key_changed(
- VCONFKEY_BT_DEVICE,
- CALLBACK_B(BluetoothManager::onHeadsetConnectionChanged));
- }
-
- void BluetoothManager::onVolumeChanged(int volume)
- {
- sound_type_e soundType = SOUND_TYPE_SYSTEM;
- auto ret = sound_manager_get_current_sound_type(&soundType);
- if (ret != SOUND_MANAGER_ERROR_NONE) {
- LOG_RETURN_VOID(RES_FAIL, "sound_manager_get_current_sound_type() failed! "
- "ret[%d] msg[%s]", ret, get_error_message(ret));
- }
-
- bool isSCOOpened = false;
- ret = bt_ag_is_sco_opened(&isSCOOpened);
- if (ret != BT_ERROR_NONE) {
- LOG_RETURN_VOID(RES_FAIL, "sound_manager_get_current_sound_type() failed! "
- "ret[%d] msg[%s]", ret, get_error_message(ret));
- }
-
- if (isSCOOpened && soundType == SOUND_TYPE_CALL) {
- if (m_btVolumeHandler) {
- m_btVolumeHandler(volume);
- }
- }
- }
-
- bool BluetoothManager::isHeadsetConnected() const
- {
- return m_isHeadsetConnected;
- }
-
- void BluetoothManager::setHeadsetConnectionChangeHandler(const NotiHandler &handler)
- {
- m_btConnectionHandler = handler;
- }
-
- bool BluetoothManager::getHeadsetConnectionState()
- {
- bt_adapter_state_e adapterState = BT_ADAPTER_DISABLED;
- auto ret = bt_adapter_get_state(&adapterState);
- if (ret != BT_ERROR_NONE) {
- LOG_RETURN_VALUE(RES_FAIL, false, "bt_adapter_get_state() failed! "
- "ret[%d] msg[%s]", ret, get_error_message(ret));
- }
-
- if (adapterState == BT_ADAPTER_DISABLED) {
- LOG_RETURN_VALUE(RES_FAIL, false, "BT adapter is disabled");
- }
-
- auto dev = 0;
- ret = vconf_get_int(VCONFKEY_BT_DEVICE, &dev);
- if (ret != 0) {
- LOG_RETURN_VALUE(RES_FAIL, false, "vconf_get_int() failed! "
- "ret[%d] msg[%s]", ret, get_error_message(ret));
- }
-
- if (dev == VCONFKEY_BT_DEVICE_NONE) {
- return false;
- }
-
- if ((dev & VCONFKEY_BT_DEVICE_HEADSET_CONNECTED) ||
- (dev & VCONFKEY_BT_DEVICE_A2DP_HEADSET_CONNECTED)) {
- return true;
- }
-
- return false;
- }
-
- void BluetoothManager::setHeadsetConnectionState(bool isConnected)
- {
- if (m_isHeadsetConnected != isConnected) {
- m_isHeadsetConnected = isConnected;
- if (m_btConnectionHandler) {
- m_btConnectionHandler();
- }
- }
- }
-
- void BluetoothManager::onHeadsetConnectionChanged(keynode_t *node)
- {
- bool isConnected = getHeadsetConnectionState();
- setHeadsetConnectionState(isConnected);
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_BLUETOOTH_MANAGER_H__
-#define __CALLUI_MODEL_BLUETOOTH_MANAGER_H__
-
-#include <vconf.h>
-
-#include "implTypes.h"
-
-namespace callui {
-
- class BluetoothManager final {
- public:
- static BluetoothManagerSRef newInstance();
-
- int getVolume() const;
- int getMaxVolume() const;
- ucl::Result setVolume(int volume);
-
- void setVolumeStateHandler(const BluetoothVolumeHandler &handler);
-
- bool isHeadsetConnected() const;
- void setHeadsetConnectionChangeHandler(const NotiHandler &handler);
-
- private:
- friend class ucl::ReffedObj<BluetoothManager>;
- BluetoothManager();
- virtual ~BluetoothManager();
-
- ucl::Result prepare();
-
- ucl::Result initializeBluetooth();
- void deinitializeBluetooth();
-
- ucl::Result registerAudioHandling();
- void unregisterAudioHandling();
- void onVolumeChanged(int volume);
-
- ucl::Result registerHeadsetConnectionHandling();
- void unregisterHeadsetConnectionHandling();
-
- bool getHeadsetConnectionState();
- void setHeadsetConnectionState(bool isConnected);
- void onHeadsetConnectionChanged(keynode_t *node);
-
- private:
- BluetoothVolumeHandler m_btVolumeHandler;
- NotiHandler m_btConnectionHandler;
- bool m_btInitialized;
- bool m_btAudioInitialized;
- bool m_isHeadsetConnected;
- };
-}
-
-#endif // __CALLUI_MODEL_BLUETOOTH_MANAGER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "CallClient.h"
-
-#include "common.h"
-
-namespace callui {
-
- using namespace ucl;
-
- CallClient::CallClient():
- m_client()
- {
- }
-
- CallClient::~CallClient()
- {
- if (m_client) {
- cm_deinit(m_client);
- }
- }
-
- CallClientSRef CallClient::newInstance()
- {
- auto result = makeShared<CallClient>();
- FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
- return result;
- }
-
- ucl::Result CallClient::prepare()
- {
- cm_client_h client;
- FAIL_RETURN(convertCMResult(cm_init(&client)), "cm_init() failed!");
- m_client = client;
-
- return RES_OK;
- }
-
- cm_client_h CallClient::getCmClient() const
- {
- return m_client;
- }
-
- CallClient::operator cm_client_h() const
- {
- return getCmClient();
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_CALL_CLIENT_H__
-#define __CALLUI_MODEL_CALL_CLIENT_H__
-
-#include <call-manager.h>
-
-#include "implTypes.h"
-
-namespace callui {
-
- class CallClient {
- public:
- static CallClientSRef newInstance();
- virtual ~CallClient();
- cm_client_h getCmClient() const;
- operator cm_client_h() const;
-
- private:
- friend class ucl::ReffedObj<CallClient>;
- CallClient();
- ucl::Result prepare();
-
- private:
- cm_client_h m_client;
- };
-}
-
-#endif // __CALLUI_MODEL_CALL_CLIENT_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "CallInfo.h"
-
-#include <call-manager-extension.h>
-#include <glib/gslist.h>
-#include <glib/gtypes.h>
-#include <sys/sysinfo.h>
-
-#include "CallClient.h"
-#include "ContactInfoProvider.h"
-#include "ContactInfo.h"
-#include "ConferenceCallInfo.h"
-
-#include "common.h"
-
-namespace callui { namespace { namespace impl {
-
- using namespace ucl;
-
- Result getCurrTimeDiffInTm(const long time, struct tm &tmTime)
- {
- if (time == 0) {
- ILOG("Call start time does not set");
- tmTime = {0};
- return RES_OK;
- }
-
- long currTime = 0;
- struct sysinfo info;
-
- if (sysinfo(&info) == 0) {
- currTime = info.uptime;
- } else {
- LOG_RETURN(RES_FAIL, "sysinfo() failed!");
- }
-
- long callTime = currTime - time;
- struct tm tmp{0};
- gmtime_r((const time_t *)&callTime, &tmp);
- tmTime = tmp;
-
- return RES_OK;
- }
-}}}
-
-namespace callui {
-
- using namespace ucl;
-
- CallInfo::CallInfo():
- m_callId(-1),
- m_startTime(0),
- m_isEmergency(false),
- m_isHDVoice(false),
- m_isForwarded(false),
- m_isVoiceMailNumber(false),
- m_confMemberCount(0)
- {
- }
-
- CallInfo::~CallInfo()
- {
- }
-
- CallInfoSRef CallInfo::newInstance(CallClient &client,
- cm_call_data_h callData,
- ContactInfoProviderSRef callInfoProvider)
- {
- if (!client) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "client is NULL");
- }
-
- if (!callData) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "callData is NULL");
- }
-
- auto result = makeShared<CallInfo>();
- FAIL_RETURN_VALUE(result->prepare(client,
- callData,
- callInfoProvider),
- {}, "result->prepare() failed!");
- return result;
- }
-
- Result CallInfo::prepare(CallClient &client,
- cm_call_data_h callData,
- ContactInfoProviderSRef callInfoProvider)
- {
- Result res = convertCMResult(
- cm_call_data_get_call_id(callData, &m_callId));
- FAIL_RETURN(res, "cm_call_data_get_call_id() failed!");
-
- char *number = nullptr;
- res = convertCMResult(
- cm_call_data_get_call_number(callData, &number));
- FAIL_RETURN(res, "cm_call_data_get_call_number() failed!");
- m_phoneNum = nz(number);
- // XXX: According to documentation it must be free, but it leads to crash
-// free(number);
-
- gboolean isEmergency;
- res = convertCMResult(
- cm_call_data_is_emergency_call(callData, &isEmergency));
- FAIL_RETURN(res, "cm_call_data_is_emergency_call() failed!");
- m_isEmergency = isEmergency;
-
- int hdIconState = 0;
- res = convertCMResult(
- cm_call_data_get_hd_icon_state(callData, &hdIconState));
- FAIL_RETURN(res, "cm_call_data_get_hd_icon_state() failed!");
- m_isHDVoice = hdIconState;
-
- gboolean isVoiceMailNumber;
- res = convertCMResult(
- cm_call_data_is_voicemail_number(callData, &isVoiceMailNumber));
- FAIL_RETURN(res, "cm_call_data_is_voicemail_number() failed!");
- m_isVoiceMailNumber = isVoiceMailNumber;
-
- res = convertCMResult(
- cm_call_data_get_start_time(callData, &m_startTime));
- FAIL_RETURN(res, "cm_call_data_get_start_time() failed!");
-
- int personId = -1;
- res = convertCMResult(
- cm_call_data_get_person_id(callData, &personId));
- FAIL_RETURN(res, "cm_call_data_get_person_id() failed!");
-
- if (personId >= 0 && callInfoProvider) {
- m_contactInfo = callInfoProvider->createContactInfo(personId);
- if (!m_contactInfo) {
- LOG_RETURN(RES_FAIL, "createContactInfo() failed!");
- }
- }
-
- res = convertCMResult(cm_call_data_get_call_member_count(callData, &m_confMemberCount));
- FAIL_RETURN(res, "cm_call_data_get_call_member_count() failed!");
-
- if (m_confMemberCount > 1) {
- res = initConferenceCallInfoList(client, callInfoProvider);
- FAIL_RETURN(res, "initConferenceCallInfoList() failed!");
- }
-
- return RES_OK;
- }
-
- Result CallInfo::initConferenceCallInfoList(CallClient &client,
- ContactInfoProviderSRef callInfoProvider)
- {
- // XXX: must be initialized with nullptr. If not an there is no conference calls
- // cm_get_conference_callList return CM_ERROR_NONE and pointer will be not changed.
- GSList *callList = nullptr;
- Result res = convertCMResult(cm_get_conference_call_list(client, &callList));
- FAIL_RETURN(res, "cm_get_conference_call_list() failed!");
-
- if (callList) {
- res = RES_OK;
- GSList *l = callList;
- for (; l != nullptr; l = g_slist_next(l)) {
- auto confCallInfo = ConferenceCallInfo::newInstance(
- static_cast<cm_conf_call_data_t *>(l->data),
- callInfoProvider);
- if (!confCallInfo) {
- LOG_BREAK(res = RES_OUT_OF_MEMORY, "ConferenceCallInfo::newInstance() failed!");
- }
- m_confMemberList.push_back(confCallInfo);
- }
-
- if (res != RES_OK) {
- m_confMemberList.clear();
- }
- g_slist_free_full(callList, [](gpointer data)
- {
- cm_conf_call_data_free(static_cast<cm_conf_call_data_t *>(data));
- });
- }
- return res;
- }
-
- unsigned int CallInfo::getCallId() const
- {
- return m_callId;
- }
-
- const std::string &CallInfo::getPhoneNumber() const
- {
- return m_phoneNum;
- }
-
- IContactInfoSCRef CallInfo::getContactInfo() const
- {
- return m_contactInfo;
- }
-
- struct tm CallInfo::getDuration() const
- {
- struct tm tmp{0};
- FAIL_RETURN_VALUE(impl::getCurrTimeDiffInTm(m_startTime, tmp),
- {0}, "getCurrTimeDiffInTm() failed");
- return tmp;
- }
-
- bool CallInfo::isEmergency() const
- {
- return m_isEmergency;
- }
-
- bool CallInfo::isHDVoice() const
- {
- return m_isHDVoice;
- }
-
- bool CallInfo::isForwarded() const
- {
- return m_isForwarded;
- }
-
- bool CallInfo::isVoiceMailNumber() const
- {
- return m_isVoiceMailNumber;
- }
-
- int CallInfo::getConferenceMemberCount() const
- {
- return m_confMemberCount;
- }
-
- const ConfMemberList &CallInfo::getConferenceMemberList() const
- {
- return m_confMemberList;
- }
-
- // Non-member functions
-
- bool isUnknownCaller(const ICallInfo &info)
- {
- auto contactInfo = info.getContactInfo();
- return (info.getPhoneNumber().empty() &&
- (!contactInfo || contactInfo->getName().empty()));
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_CALL_INFO_H__
-#define __CALLUI_MODEL_CALL_INFO_H__
-
-#include <call-manager-ext.h>
-
-#include "model/ICallInfo.h"
-
-#include "implTypes.h"
-
-namespace callui {
-
- class CallInfo final : public ICallInfo {
- public:
- static CallInfoSRef newInstance(CallClient &client,
- cm_call_data_h callData,
- ContactInfoProviderSRef callInfoProvider);
- virtual ~CallInfo();
-
- // ICallInfo
-
- virtual unsigned int getCallId() const override final;
- virtual const std::string &getPhoneNumber() const override final;
- virtual IContactInfoSCRef getContactInfo() const override final;
- virtual struct tm getDuration() const override final;
- virtual bool isEmergency() const override final;
- virtual bool isHDVoice() const override final;
- virtual bool isForwarded() const override final;
- virtual bool isVoiceMailNumber() const override final;
- virtual int getConferenceMemberCount() const override final;
- virtual const ConfMemberList &getConferenceMemberList() const override final;
-
- private:
- friend class ucl::ReffedObj<CallInfo>;
- CallInfo();
-
- ucl::Result prepare(CallClient &client,
- cm_call_data_h callData,
- ContactInfoProviderSRef callInfoProvider);
- ucl::Result initConferenceCallInfoList(CallClient &client,
- ContactInfoProviderSRef callInfoProvider);
-
- private:
- unsigned int m_callId;
- std::string m_phoneNum;
- ContactInfoSRef m_contactInfo;
- long m_startTime;
- bool m_isEmergency;
- bool m_isHDVoice;
- bool m_isForwarded;
- bool m_isVoiceMailNumber;
- int m_confMemberCount;
- ConfMemberList m_confMemberList;
- };
-
-}
-
-#endif // __CALLUI_MODEL_CALL_INFO_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "CallManager.h"
-
-#include "ICallManagerListener.h"
-
-#include "CallClient.h"
-#include "RejectMsgProvider.h"
-#include "IncomingCall.h"
-#include "ActiveCall.h"
-#include "HeldCall.h"
-#include "EndCall.h"
-
-#include "ContactInfoProvider.h"
-
-#include "CallInfo.h"
-#include "ConferenceCallInfo.h"
-
-#include "common.h"
-
-namespace callui { namespace { namespace impl {
-
- constexpr auto TEL_NUMBER_MAX_SIZE = 82;
-
-}}}
-
-namespace callui {
-
- using namespace ucl;
-
- CallManager::CallManager(IRefCountObj &rc,
- const CallClientSRef &callClient,
- ICallManagerListenerWRef listener):
- RefCountAware(&rc),
- m_callClient(callClient),
- m_listener(listener),
- m_slot(SimSlot::UNDEFINED),
- m_waitDialing(false),
- m_confTypeCallReq(CALL_FLAG_NONE),
- m_blockCMEvents(false)
- {
- }
-
- CallManager::~CallManager()
- {
- }
-
- CallManagerSRef CallManager::newInstance(const CallClientSRef &callClient,
- ICallManagerListenerWRef listener)
- {
- auto result = makeShared<CallManager>(callClient, listener);
- FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
- return result;
- }
-
- Result CallManager::prepare()
- {
- m_contactInfoProvider = ContactInfoProvider::newInstance();
- if (!m_contactInfoProvider) {
- ELOG("ContactInfoProvider::newInstance() failed");
- }
-
- FAIL_RETURN(initCalls(), "initCalls() failed!");
-
- FAIL_RETURN(convertCMResult(
- cm_set_dial_status_cb(*m_callClient,
- CALLBACK_B(CallManager::dialStatusCb), this)),
- "cm_set_call_event_cb() failed!");
-
- FAIL_RETURN(convertCMResult(
- cm_set_call_event_cb(*m_callClient,
- CALLBACK_B(CallManager::callEventCb), this)),
- "cm_set_call_event_cb() failed!");
-
- return RES_OK;
- }
-
- Result CallManager::initCalls()
- {
- cm_call_data_h incom = nullptr;
- cm_call_data_h active = nullptr;
- cm_call_data_h held = nullptr;
-
- FAIL_RETURN(convertCMResult(
- cm_get_all_calldata(*m_callClient, &incom, &active, &held)),
- "cm_get_all_calldata() failed!");
-
- FAIL_RETURN(updateCall(m_incomingCall, incom), "updateCall() failed!");
- FAIL_RETURN(updateCall(m_activeCall, active), "updateCall() failed!");
- FAIL_RETURN(updateCall(m_heldCall, held), "updateCall() failed!");
-
- cm_call_data_free(incom);
- cm_call_data_free(active);
- cm_call_data_free(held);
-
- return RES_OK;
- }
-
- template <class TYPE, class TYPE2>
- Result CallManager::updateCall(SharedRef<TYPE> &call, TYPE2 &&data)
- {
- call.reset();
-
- if (data) {
- call = TYPE::newInstance(asWeak(*this), std::forward<TYPE2>(data));
- if (!call) {
- LOG_RETURN(RES_FAIL, "newInstance() failed!");
- }
- }
- return RES_OK;
- }
-
- CallClient &CallManager::getCallClient()
- {
- return *m_callClient;
- }
-
- SimSlot CallManager::getSimSlot() const
- {
- return m_slot;
- }
-
- IIncomingCallSRef CallManager::getIncomingCall()
- {
- return m_incomingCall;
- }
-
- IActiveCallSRef CallManager::getActiveCall()
- {
- return m_activeCall;
- }
-
- IHeldCallSRef CallManager::getHeldCall()
- {
- return m_heldCall;
- }
-
- IEndCallSRef CallManager::getEndCall()
- {
- return m_endCall;
- }
-
- CallMask CallManager::getAvailableCalls() const
- {
- int res = CALL_FLAG_NONE;
-
- if (m_incomingCall)
- res |= CALL_FLAG_INCOMING;
-
- if (m_activeCall)
- res |= CALL_FLAG_ACTIVE;
-
- if (m_heldCall)
- res |= CALL_FLAG_HELD;
-
- if (m_endCall)
- res |= CALL_FLAG_END;
-
- return res;
- }
-
- Result CallManager::dialVoiceCall(const std::string &number)
- {
- char buff[impl::TEL_NUMBER_MAX_SIZE] = { 0 };
- snprintf(buff, sizeof(buff), "%s", number.c_str());
-
- return convertCMResult(
- cm_dial_call(*m_callClient, buff, CM_CALL_TYPE_VOICE, convertCUISimSlot(m_slot)));
- }
-
- Result CallManager::endCall(unsigned int callId, CallReleaseType type)
- {
- ICallInfoSCRef info;
- int flag = CALL_FLAG_NONE;
- if (type == CallReleaseType::ALL_ACTIVE
- && !m_incomingCall
- && !m_heldCall) {
- info = m_activeCall->getInfo();
- flag = CALL_FLAG_ACTIVE;
- } else if (type == CallReleaseType::ALL_HOLD
- && !m_incomingCall
- && !m_activeCall) {
- info = m_heldCall->getInfo();
- flag = CALL_FLAG_HELD;
- }
-
- if (info && info->getConferenceMemberCount() > 1) {
- m_confTypeCallReq = flag;
- }
-
- return convertCMResult(
- cm_end_call(*m_callClient, callId, convertCUICallReleaseType(type)));
- }
-
- Result CallManager::splitCalls(CallInfoSRef callInfo, const IConferenceCallInfoSCRef &confCallInfo)
- {
- if (callInfo->getConferenceMemberCount() <= 1) {
- LOG_RETURN(RES_FAIL, "Not conference call");
- }
-
- auto confList = callInfo->getConferenceMemberList();
- auto iter = std::find(confList.begin(), confList.end(), confCallInfo);
- if (iter == confList.end()) {
- LOG_RETURN(RES_FAIL, "Not a member of conference call");
- }
-
- return endCall((*iter)->getCallId(), CallReleaseType::BY_CALL_HANDLE);
- }
-
- ContactInfoProviderSRef CallManager::getContactInfoProvider()
- {
- return m_contactInfoProvider;
- }
-
- RejectMsgProviderSRef CallManager::getRejectMsgProvider()
- {
- if (!m_rejectMsgProvider) {
- m_rejectMsgProvider = RejectMsgProvider::newInstance();
- if (!m_rejectMsgProvider) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "RejectMsgProvider::newInstance() failed!");
- }
- }
-
- return m_rejectMsgProvider;
- }
-
- Result CallManager::processEndCallEvent(unsigned int callId,
- cm_call_data_h cmIncom,
- cm_call_data_h cmActive,
- cm_call_data_h cmHeld)
- {
- if (m_activeCall &&
- callId == m_activeCall->getInfo()->getCallId() &&
- !cmIncom && !cmActive && !cmHeld) {
- return updateCall(m_endCall, m_activeCall->getInfo());
- } else if (m_heldCall &&
- callId == m_heldCall->getInfo()->getCallId() &&
- !cmIncom && !cmActive && !cmHeld) {
- return updateCall(m_endCall, m_heldCall->getInfo());
- } else if (m_activeCall &&
- m_confTypeCallReq == CALL_FLAG_ACTIVE) {
-
- m_confTypeCallReq = CALL_FLAG_NONE;
- m_blockCMEvents = true;
-
- return updateCall(m_endCall, m_activeCall->getInfo());
- } else if (m_heldCall &&
- m_confTypeCallReq == CALL_FLAG_HELD) {
-
- m_confTypeCallReq = CALL_FLAG_NONE;
- m_blockCMEvents = true;
-
- return updateCall(m_endCall, m_heldCall->getInfo());
- }
- return RES_OK;
- }
-
- Result CallManager::processCommonCallEvent(unsigned int callId,
- cm_call_data_h cmIncom,
- cm_call_data_h cmActive,
- cm_call_data_h cmHeld)
- {
- if (m_blockCMEvents) {
- ILOG("Ignore call manager state");
-
- m_incomingCall.reset();
- m_activeCall.reset();
- m_heldCall.reset();
-
- return RES_OK;
- }
-
- FAIL_RETURN(updateCall(m_incomingCall, cmIncom), "updateCall() failed!");
- FAIL_RETURN(updateCall(m_activeCall, cmActive), "updateCall() failed!");
- FAIL_RETURN(updateCall(m_heldCall, cmHeld), "updateCall() failed!");
-
- return RES_OK;
- }
-
- void CallManager::callEventCb(cm_call_event_e callEvent, cm_call_event_data_h callEventData)
- {
- m_waitDialing = false;
-
- if (!callEventData) {
- ELOG("callEventData is NULL");
- return;
- }
-
- CallEventType type;
- FAIL_RETURN_VOID(convertCMEventType(callEvent, &type),
- "convertCallManagerEventType() failed!");
-
- DLOG("Call event changed on [%d]", type);
-
- if (m_blockCMEvents) {
- if (type == CallEventType::END) {
- ILOG("Ignore call manager state");
- return;
- } else {
- m_blockCMEvents = false;
- }
- }
-
- if (m_slot == SimSlot::UNDEFINED) {
- cm_multi_sim_slot_type_e cmSimSlot;
- FAIL_RETURN_VOID(convertCMResult(
- cm_call_event_data_get_sim_slot(callEventData, &cmSimSlot)),
- "cm_call_event_data_get_sim_slot() failed!");
- m_slot = convertCMSimSlot(cmSimSlot);
- }
-
- unsigned int callId = 0;
- cm_call_data_h cmIncom = nullptr;
- cm_call_data_h cmActive = nullptr;
- cm_call_data_h cmHeld = nullptr;
-
- FAIL_RETURN_VOID(convertCMResult(
- cm_call_event_data_get_call_id(callEventData, &callId)),
- "cm_call_event_data_get_call_id() failed!");
-
- FAIL_RETURN_VOID(convertCMResult(
- cm_call_event_data_get_incom_call(callEventData, &cmIncom)),
- "cm_call_event_data_get_incom_call() failed!");
-
- FAIL_RETURN_VOID(convertCMResult(
- cm_call_event_data_get_active_call(callEventData, &cmActive)),
- "cm_call_event_data_get_active_call() failed!");
-
- FAIL_RETURN_VOID(convertCMResult(
- cm_call_event_data_get_held_call(callEventData, &cmHeld)),
- "cm_call_event_data_get_held_call() failed!");
-
- m_endCall.reset();
-
- switch (type) {
- case CallEventType::END:
- FAIL_RETURN_VOID(processEndCallEvent(callId,
- cmIncom,
- cmActive,
- cmHeld),
- "processEndCallEvent() failed!");
- case CallEventType::ACTIVE:
- case CallEventType::INCOMING:
- case CallEventType::DIALING:
- case CallEventType::HELD:
- case CallEventType::RETRIEVED:
- case CallEventType::SWAPPED:
- case CallEventType::JOIN:
- case CallEventType::SPLIT:
- FAIL_RETURN_VOID(processCommonCallEvent(callId,
- cmIncom,
- cmActive,
- cmHeld),
- "processCommonCallEvent() failed!");
- break;
- default:
- return;
- }
-
- if (const auto listener = m_listener.lock()) {
- listener->onCallEvent(type);
- }
- }
-
- void CallManager::dialStatusCb(cm_dial_status_e status)
- {
- m_waitDialing = false;
-
- CallManagerErr err = CallManagerErr::DIAL_FAIL;
- switch (status) {
- case CM_DIAL_SUCCESS:
- return;
- case CM_DIAL_CANCEL:
- err = CallManagerErr::DIAL_CANCEL;
- break;
- case CM_DIAL_FAIL:
- err = CallManagerErr::DIAL_FAIL;
- break;
- case CM_DIAL_FAIL_SS:
- err = CallManagerErr::DIAL_FAIL_SS;
- break;
- case CM_DIAL_FAIL_FDN:
- err = CallManagerErr::DIAL_FAIL_FDN;
- break;
- case CM_DIAL_FAIL_FLIGHT_MODE:
- err = CallManagerErr::DIAL_FLIGHT_MODE;
- break;
- default:
- err = CallManagerErr::DIAL_FAIL;
- break;
- }
-
- if (const auto listener = m_listener.lock()) {
- listener->onError(err);
- }
- }
-
- Result CallManager::processOutgoingCall(const std::string &telNum)
- {
- if (!m_waitDialing) {
- m_waitDialing = true;
- return dialVoiceCall(telNum);
- }
- return RES_FAIL;
- }
-
- Result CallManager::processIncomingCall(SimSlot slot)
- {
- if (m_incomingCall) {
- if (m_slot == SimSlot::UNDEFINED) {
- // TODO: need to modify when companion mode will be added
- m_slot = SimSlot::GEAR;
- }
- if (const auto listener = m_listener.lock()) {
- listener->onCallEvent(CallEventType::INCOMING);
- }
- return RES_OK;
- }
- ELOG("Incoming call is NULL");
- return RES_FAIL;
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_CALL_MANAGER_H__
-#define __CALLUI_MODEL_CALL_MANAGER_H__
-
-#include <call-manager-ext.h>
-
-#include "model/ICallManager.h"
-
-#include "implTypes.h"
-
-namespace callui {
-
- class CallManager final :
- public ucl::RefCountAware,
- public ICallManager {
- public:
- static CallManagerSRef newInstance(const CallClientSRef &callClient,
- ICallManagerListenerWRef listener);
- virtual ~CallManager();
-
- CallClient &getCallClient();
- SimSlot getSimSlot() const;
- ucl::Result dialVoiceCall(const std::string &number);
- ucl::Result endCall(unsigned int callId, CallReleaseType type);
- ucl::Result splitCalls(CallInfoSRef callInfo,
- const IConferenceCallInfoSCRef &confCallInfo);
- ContactInfoProviderSRef getContactInfoProvider();
- RejectMsgProviderSRef getRejectMsgProvider();
-
- ucl::Result processOutgoingCall(const std::string &telNum);
- ucl::Result processIncomingCall(SimSlot slot);
-
- // ICallManager
-
- virtual IIncomingCallSRef getIncomingCall() override final;
- virtual IActiveCallSRef getActiveCall() override final;
- virtual IHeldCallSRef getHeldCall() override final;
- virtual IEndCallSRef getEndCall() override final;
- virtual CallMask getAvailableCalls() const override final;
-
- private:
- friend class ucl::ReffedObj<CallManager>;
- CallManager(ucl::IRefCountObj &rc, const CallClientSRef &callClient,
- ICallManagerListenerWRef listener);
-
- ucl::Result prepare();
- ucl::Result initCalls();
-
- template <class TYPE, class TYPE2>
- ucl::Result updateCall(ucl::SharedRef<TYPE> &call, TYPE2 &&data);
-
- ucl::Result processEndCallEvent(unsigned int callId,
- cm_call_data_h cmIncom,
- cm_call_data_h cmActive,
- cm_call_data_h cmHeld);
-
- ucl::Result processCommonCallEvent(unsigned int callId,
- cm_call_data_h cmIncom,
- cm_call_data_h cmActive,
- cm_call_data_h cmHeld);
-
- void callEventCb(cm_call_event_e call_event, cm_call_event_data_h call_state_data);
- void dialStatusCb(cm_dial_status_e status);
-
- private:
- CallClientSRef m_callClient;
- RejectMsgProviderSRef m_rejectMsgProvider;
- ContactInfoProviderSRef m_contactInfoProvider;
- ICallManagerListenerWRef m_listener;
- IncomingCallSRef m_incomingCall;
- ActiveCallSRef m_activeCall;
- HeldCallSRef m_heldCall;
- EndCallSRef m_endCall;
- SimSlot m_slot;
- bool m_waitDialing;
-
- int m_confTypeCallReq;
- bool m_blockCMEvents;
- };
-
-}
-
-#endif // __CALLUI_MODEL_CALL_MANAGER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "CallUI.h"
-
-#include <app_control.h>
-
-#include "model/ICallListener.h"
-#include "model/IIncomingCall.h"
-#include "model/IActiveCall.h"
-#include "model/IHeldCall.h"
-#include "model/IEndCall.h"
-#include "model/ICallInfo.h"
-
-#include "CallClient.h"
-#include "CallManager.h"
-#include "SoundManager.h"
-
-#include "VoiceControlStateProvider.h"
-#include "IndicatorStateProvider.h"
-
-#include "ConnectionStateSource.h"
-#include "RssiStateSource.h"
-#include "BatteryStateSource.h"
-#include "VoiceControlStateSource.h"
-#include "SimSlotStateSource.h"
-#include "HdVoiceStateSource.h"
-
-#include "common.h"
-
-namespace callui {
-
- using namespace ucl;
-
- CallUI::CallUI(IRefCountObj &rc):
- RefCountAware(&rc)
- {
- }
-
- CallUI::~CallUI()
- {
- }
-
- void CallUI::setListener(const ICallListenerWRef &listener)
- {
- m_listener = listener;
- }
-
- Result CallUI::processAppControl(app_control_h appControl)
- {
- if (!appControl) {
- FAIL_RETURN(RES_INVALID_ARGUMENTS, "appControl is NULL");
- }
-
- Result ret = RES_FAIL;
-
- char *operation = nullptr;
- int res = app_control_get_operation(appControl, &operation);
- if (res != APP_CONTROL_ERROR_NONE) {
- LOG_RETURN(RES_FAIL, "app_control_get_operation() failed!");
- }
- if (!operation) {
- LOG_RETURN(RES_FAIL, "operation is NULL!");
- }
-
- char *uri = nullptr;
- res = app_control_get_uri(appControl, &uri);
- if (res != APP_CONTROL_ERROR_NONE) {
- free(operation);
- LOG_RETURN(RES_FAIL, "app_control_get_uri() failed!");
- }
- if (!uri) {
- free(operation);
- LOG_RETURN(RES_FAIL, "uri is NULL!");
- }
-
- if (strcmp(operation, APP_CONTROL_OPERATION_CALL) || strncmp(uri, "tel:", 4)) {
- free(operation);
- free(uri);
- LOG_RETURN(RES_FAIL, "Not processed operation!");
- }
-
- char *tmp = nullptr;
- if (!strncmp(uri, "tel:MT", 6)) {
- res = app_control_get_extra_data(appControl, "sim_slot", &tmp);
- if (res != APP_CONTROL_ERROR_NONE) {
- ELOG("app_control_get_extra_data() failed!");
- }
- if (!tmp) {
- free(operation);
- free(uri);
- LOG_RETURN(RES_FAIL, "Sim slot is NULL!");
- }
- DLOG("Sim slot [%s]", tmp);
- free(tmp);
-
- ret = m_callManager->processIncomingCall(
- convertCMSimSlot(static_cast<cm_multi_sim_slot_type_e>(atoi(tmp))));
-
- } else {
- tmp = static_cast<char *>(uri + 4);
- DLOG("number [%s]", tmp);
-
- if (!tmp) {
- free(operation);
- free(uri);
- LOG_RETURN(RES_FAIL, "number is NULL");
- }
-
- ret = m_callManager->processOutgoingCall(tmp);
- }
-
- free(operation);
- free(uri);
-
- return ret;
- }
-
- Result CallUI::prepare()
- {
- auto callClient = CallClient::newInstance();
- if (!callClient) {
- LOG_RETURN(RES_FAIL,
- "Client::newInstance() failed!");
- }
-
- m_callManager = CallManager::newInstance(callClient, asWeak(*this));
- if (!m_callManager) {
- LOG_RETURN(RES_FAIL,
- "CallManager::newInstance() failed!");
- }
-
- m_soundManager = SoundManager::newInstance(callClient);
- if (!m_soundManager) {
- LOG_RETURN(RES_FAIL,
- "SoundManage::newInstance() failed!");
- }
-
- m_voiceControlPrv = VoiceControlStateProvider::newInstance();
- if (!m_voiceControlPrv) {
- LOG_RETURN(RES_FAIL,
- "VoiceControlStateProvider::newInstance() failed!");
- }
-
- FAIL_RETURN(initInidcatorStateProvider(),
- "Init Indicator State Provider failed!");
-
- return RES_OK;
- }
-
- Result CallUI::initInidcatorStateProvider()
- {
- m_indicatorStPrv = IndicatorStateProvider::newInstance();
- if (!m_indicatorStPrv) {
- LOG_RETURN(RES_FAIL, "IndicatorStateProvider::newInstance() failed!");
- }
-
- auto connStateSource = ConnectionStateSource::newInstance();
- if (!connStateSource) {
- LOG_RETURN(RES_FAIL,
- "ConnectionStateSource::newInstance() failed!");
- }
- FAIL_RETURN(m_indicatorStPrv->setStateSource(
- IndicatorProperty::NW_CONNECTION, connStateSource),
- "setStateSource() failed!");
-
- auto rssiStSrc = RssiStateSource::newInstance();
- if (!rssiStSrc) {
- LOG_RETURN(RES_FAIL,
- "RssiStateSource::newInstance() failed!");
- }
- FAIL_RETURN(m_indicatorStPrv->setStateSource(
- IndicatorProperty::RSSI, rssiStSrc),
- "setStateSource() failed!");
-
- auto batteryStSrc = BatteryStateSource::newInstance();
- if (!batteryStSrc) {
- LOG_RETURN(RES_FAIL,
- "BatteryStateSource::newInstance() failed!");
- }
- FAIL_RETURN(m_indicatorStPrv->setStateSource(
- IndicatorProperty::BATTERY, batteryStSrc),
- "setStateSource() failed!");
-
- auto voiceControlStSrc =
- VoiceControlStateSource::newInstance(m_voiceControlPrv);
- if (!voiceControlStSrc) {
- LOG_RETURN(RES_FAIL,
- "VoiceControlStateSource::newInstance() failed!");
- }
- FAIL_RETURN(m_indicatorStPrv->setStateSource(
- IndicatorProperty::VOICE_CONTROL, voiceControlStSrc),
- "setStateSource() failed!");
-
- m_simSlotStSrc = makeShared<SimSlotStateSource>(
- m_callManager->getSimSlot(), getForwardedCallStatus());
- FAIL_RETURN(m_indicatorStPrv->setStateSource(
- IndicatorProperty::SIM_SLOT, m_simSlotStSrc),
- "setStateSource() failed!");
-
- m_hdCallStSrc = makeShared<HdVoiceStateSource>(
- getHDVoiceStatus());
- FAIL_RETURN(m_indicatorStPrv->setStateSource(
- IndicatorProperty::HD_VOICE, m_hdCallStSrc),
- "setStateSource() failed!");
-
- return RES_OK;
- }
-
- ICallManagerSRef CallUI::getCallManager()
- {
- return m_callManager;
- }
-
- ISoundManagerSRef CallUI::getSoundManager()
- {
- return m_soundManager;
- }
-
- IIndicatorStateProviderSRef CallUI::getIndicatorStateProvider()
- {
- return m_indicatorStPrv;
- }
-
- ICallInfoSCRef CallUI::getCurrentCallInfo() const
- {
- CallMask calls = m_callManager->getAvailableCalls();
- if (!calls) {
- DLOG("No available calls");
- return {};
- } else if (calls & CALL_FLAG_INCOMING) {
- return m_callManager->getIncomingCall()->getInfo();
- } else if (calls & CALL_FLAG_ACTIVE) {
- return m_callManager->getActiveCall()->getInfo();
- } else if (calls & CALL_FLAG_HELD) {
- return m_callManager->getHeldCall()->getInfo();
- } else if (calls & CALL_FLAG_END) {
- return m_callManager->getEndCall()->getInfo();
- }
- return {};
- }
-
- bool CallUI::getHDVoiceStatus() const
- {
- ICallInfoSCRef info = getCurrentCallInfo();
- if (info) {
- return info->isHDVoice();
- }
- return false;
- }
-
- bool CallUI::getForwardedCallStatus() const
- {
- ICallInfoSCRef info = getCurrentCallInfo();
- if (info) {
- return info->isForwarded();
- }
- return false;
- }
-
- void CallUI::updateHdVoiceStateSource()
- {
- m_hdCallStSrc->updateState(getHDVoiceStatus());
- }
-
- void CallUI::updateSimSlotStateSource()
- {
- m_simSlotStSrc->updateSimSlot(m_callManager->getSimSlot(),
- getForwardedCallStatus());
- }
-
- void CallUI::onCallEvent(CallEventType type)
- {
- updateSimSlotStateSource();
- updateHdVoiceStateSource();
-
- if (const auto listener = m_listener.lock()) {
- listener->onCallEvent(type);
- }
- }
-
- void CallUI::onError(CallManagerErr err)
- {
- auto callErr = CallErr::DIAL_FAIL;
- switch (err) {
- case CallManagerErr::DIAL_CANCEL:
- callErr = CallErr::DIAL_CANCEL;
- break;
- case CallManagerErr::DIAL_FLIGHT_MODE:
- callErr = CallErr::DIAL_FLIGHT_MODE;
- break;
- default:
- callErr = CallErr::DIAL_FAIL;
- break;
- }
-
- if (const auto listener = m_listener.lock()) {
- listener->onError(callErr);
- }
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_CALL_UI_H__
-#define __CALLUI_MODEL_CALL_UI_H__
-
-#include "model/ICallUI.h"
-
-#include "ICallManagerListener.h"
-
-#include "types.h"
-
-namespace callui {
-
- UCL_DECLARE_REF_ALIASES(CallManager);
- UCL_DECLARE_REF_ALIASES(SoundManager);
-
- class CallUI final :
- public ucl::RefCountAware,
- public ICallUI,
- public ICallManagerListener {
- public:
- virtual ~CallUI();
-
- // ICallUI
-
- virtual void setListener(const ICallListenerWRef &listener) override final;
- virtual ucl::Result processAppControl(app_control_h appControl) override final;
- virtual ISoundManagerSRef getSoundManager() override final;
- virtual ICallManagerSRef getCallManager() override final;
- virtual IIndicatorStateProviderSRef getIndicatorStateProvider() override final;
-
- // ICallManagerListener
-
- virtual void onCallEvent(CallEventType type) override final;
- virtual void onError(CallManagerErr err) override final;
-
- private:
- friend class CallUIBuilder;
- friend class ucl::ReffedObj<CallUI>;
- CallUI(ucl::IRefCountObj &rc);
-
- ucl::Result prepare();
-
- ucl::Result initInidcatorStateProvider();
-
- void updateHdVoiceStateSource();
- void updateSimSlotStateSource();
- ICallInfoSCRef getCurrentCallInfo() const;
- bool getHDVoiceStatus() const;
- bool getForwardedCallStatus() const;
-
- private:
- CallManagerSRef m_callManager;
- SoundManagerSRef m_soundManager;
- ICallListenerWRef m_listener;
- SimSlotStateSourceSRef m_simSlotStSrc;
- HdVoiceStateSourceSRef m_hdCallStSrc;
- IndicatorStateProviderSRef m_indicatorStPrv;
- VoiceControlStateProviderSRef m_voiceControlPrv;
- };
-
-}
-
-#endif // __CALLUI_MODEL_CALL_UI_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "model/CallUIBuilder.h"
-
-#include "CallUI.h"
-
-#include "common.h"
-
-namespace callui {
-
- using namespace ucl;
-
- CallUIBuilder::CallUIBuilder()
- {
- }
-
- ICallUISRef CallUIBuilder::build() const
- {
- auto result = makeShared<CallUI>();
- FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
- return result;
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "ConferenceCallInfo.h"
-
-#include <call-manager-ext.h>
-
-#include "ContactInfoProvider.h"
-#include "ContactInfo.h"
-
-#include "common.h"
-
-namespace callui {
-
- using namespace ucl;
-
- ConferenceCallInfo::ConferenceCallInfo():
- m_callId(-1)
- {
- }
-
- ConferenceCallInfo::~ConferenceCallInfo()
- {
- }
-
- ConferenceCallInfoSRef ConferenceCallInfo::newInstance(
- cm_conf_call_data_t *confCallData,
- ContactInfoProviderSRef callInfoProvider)
- {
- if (!confCallData) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "callData is NULL");
- }
-
- auto result = makeShared<ConferenceCallInfo>();
- FAIL_RETURN_VALUE(result->prepare(confCallData, callInfoProvider), {}, "result->prepare() failed!");
- return result;
- }
-
- Result ConferenceCallInfo::prepare(
- cm_conf_call_data_t *confCallData,
- ContactInfoProviderSRef callInfoProvider)
- {
- Result res = convertCMResult(
- cm_conf_call_data_get_call_id(confCallData, &m_callId));
- FAIL_RETURN(res, "cm_conf_call_data_get_call_id() failed!");
-
- char *number = nullptr;
- res = convertCMResult(
- cm_conf_call_data_get_call_number(confCallData, &number));
- FAIL_RETURN(res, "cm_conf_call_data_get_call_number() failed!");
- m_phoneNum = nz(number);
- // XXX: According to documentation it must be free, but it leads to crash
-// free(number);
-
- int personId = -1;
- res = convertCMResult(
- cm_conf_call_data_get_person_id(confCallData, &personId));
- FAIL_RETURN(res, "cm_conf_call_data_get_person_id() failed!");
-
- if (personId >= 0 && callInfoProvider) {
- m_contactInfo = callInfoProvider->createContactInfo(personId);
- if (!m_contactInfo) {
- LOG_RETURN_VALUE(RES_FAIL, RES_FAIL, "createContactInfo() failed!");
- }
- }
- return RES_OK;
- }
-
- unsigned int ConferenceCallInfo::getCallId() const
- {
- return m_callId;
- }
-
- const std::string &ConferenceCallInfo::getPhoneNumber() const
- {
- return m_phoneNum;
- }
-
- IContactInfoSCRef ConferenceCallInfo::getContactInfo() const
- {
- return m_contactInfo;
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_CONFERENCE_CALL_INFO_H__
-#define __CALLUI_MODEL_CONFERENCE_CALL_INFO_H__
-
-#include <call-manager-ext.h>
-
-#include "model/IConferenceCallInfo.h"
-
-#include "implTypes.h"
-
-namespace callui {
-
- class ConferenceCallInfo final : public IConferenceCallInfo {
- public:
- static ConferenceCallInfoSRef newInstance(
- cm_conf_call_data_t *confCallData,
- ContactInfoProviderSRef callInfoProvider);
- virtual ~ConferenceCallInfo();
-
- // IConferenceCallInfo
-
- virtual unsigned int getCallId() const override final;
- virtual const std::string &getPhoneNumber() const override final;
- virtual IContactInfoSCRef getContactInfo() const override final;
-
- private:
- friend class ucl::ReffedObj<ConferenceCallInfo>;
- ConferenceCallInfo();
-
- ucl::Result prepare(cm_conf_call_data_t *confCallData,
- ContactInfoProviderSRef callInfoProvider);
- private:
- unsigned int m_callId;
- std::string m_phoneNum;
- ContactInfoSRef m_contactInfo;
- };
-
-}
-
-#endif // __CALLUI_MODEL_CONFERENCE_CALL_INFO_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "ConnectionStateSource.h"
-
-#include "model/IndicatorState.h"
-
-#include "common.h"
-
-namespace callui {
-
- using namespace ucl;
-
- ConnectionStateSource::Bits::Bits():
- property(convertEnumValueToInt(IndicatorProperty::NW_CONNECTION)),
- connState(convertEnumValueToInt(ConnectionType::NONE)),
- packetDirection(convertEnumValueToInt(PacketDirection::NONE))
- {
- }
-
- ConnectionStateSource::Bits::Bits(const IndicatorState &state):
- value(state.value)
- {
- if (property != convertEnumValueToInt(IndicatorProperty::NW_CONNECTION)) {
- ELOG("State of incorrect property type [%d]", property);
- *this = {};
- }
- }
-
- ConnectionStateSource::ConnectionStateSource()
- {
- }
-
- ConnectionStateSource::~ConnectionStateSource()
- {
- unsignSystStateCallbacks();
- }
-
- ConnectionStateSourceSRef ConnectionStateSource::newInstance()
- {
- auto result = makeShared<ConnectionStateSource>();
- FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
- return result;
- }
-
- Result ConnectionStateSource::prepare()
- {
- FAIL_RETURN(addSysStateCallbacks(), "addSysStateCallbacks() failed!");
-
- updateConnType();
- updatePacketDir();
-
- return RES_OK;
- }
-
- bool ConnectionStateSource::isWifiConnected() const
- {
- int state = VCONFKEY_WIFI_UNCONNECTED;
- if (vconf_get_int(VCONFKEY_WIFI_STATE, &state) < 0) {
- ELOG("Get WiFi connection state failed");
- return false;
- }
- return (state == VCONFKEY_WIFI_CONNECTED);
- }
-
- bool ConnectionStateSource::isDnetConnected() const
- {
- int status = VCONFKEY_DNET_OFF;
- if (vconf_get_int(VCONFKEY_DNET_STATE, &status) < 0) {
- ELOG("Get Dnet status failed!");
- return false;
- }
- return (status != VCONFKEY_DNET_OFF);
- }
-
- ConnectionType ConnectionStateSource::getConnTypeByWiFiStrength() const
- {
- int wifiStrength = 0;
- if (vconf_get_int(VCONFKEY_WIFI_STRENGTH, &wifiStrength) == 0) {
- switch (wifiStrength) {
- case 1: return ConnectionType::WIFI_01;
- case 2: return ConnectionType::WIFI_02;
- case 3: return ConnectionType::WIFI_03;
- case 4: return ConnectionType::WIFI_04;
- default: return ConnectionType::WIFI_00;
- }
- }
- ELOG("Get WiFi connection type failed!");
- return ConnectionType::NONE;
- }
-
- ConnectionType ConnectionStateSource::getConnTypeByTelephonyPsType() const
- {
- int type = 0;
- if (vconf_get_int(VCONFKEY_TELEPHONY_PSTYPE, &type) == 0) {
- switch(type) {
- case VCONFKEY_TELEPHONY_PSTYPE_HSDPA :
- case VCONFKEY_TELEPHONY_PSTYPE_HSUPA :
- return ConnectionType::HSDPA_H;
- case VCONFKEY_TELEPHONY_PSTYPE_HSPA :
- return ConnectionType::HSPA_H_PLUS;
- default :
- return ConnectionType::UMTS_3G;
- }
- }
- ELOG("Get connection PS type failed!");
- return ConnectionType::NONE;
- }
-
- ConnectionType ConnectionStateSource::getConnTypeByTelephonySvcType() const
- {
- int svcType = 0;
- if (vconf_get_int(VCONFKEY_TELEPHONY_SVCTYPE, &svcType) == 0) {
- switch(svcType) {
- case VCONFKEY_TELEPHONY_SVCTYPE_2G :
- case VCONFKEY_TELEPHONY_SVCTYPE_2_5G :
- return ConnectionType::GPRS_G;
- case VCONFKEY_TELEPHONY_SVCTYPE_3G :
- return getConnTypeByTelephonyPsType();
- case VCONFKEY_TELEPHONY_SVCTYPE_2_5G_EDGE :
- return ConnectionType::EDGE_E;
- case VCONFKEY_TELEPHONY_SVCTYPE_LTE :
- return ConnectionType::LTE_4G;
- default :
- return ConnectionType::NONE;
- }
- }
- ELOG("Get connection SVC type failed!");
- return ConnectionType::NONE;
- }
-
- bool ConnectionStateSource::updateConnTypeBits(ConnectionType connType)
- {
- int connTypeInt = convertEnumValueToInt(connType);
- if (connTypeInt != m_bits.connState) {
- m_bits.connState = connTypeInt;
- return true;
- }
- return false;
- }
-
- bool ConnectionStateSource::updatePacketDirBits(PacketDirection direction)
- {
- int directionInt = convertEnumValueToInt(direction);
- if (directionInt != m_bits.packetDirection) {
- m_bits.packetDirection = directionInt;
- return true;
- }
- return false;
- }
-
- bool ConnectionStateSource::updateConnType()
- {
- if (isFlightModeActive()) {
- return updateConnTypeBits(ConnectionType::NONE);
- }
-
- if (isWifiConnected()) {
- return updateConnTypeBits(getConnTypeByWiFiStrength());
- }
-
- if (!isDnetConnected()) {
- return updateConnTypeBits(ConnectionType::NONE);
- }
-
- return updateConnTypeBits(getConnTypeByTelephonySvcType());
- }
-
- void ConnectionStateSource::onConnTypeChangedCb(keynode_t *node)
- {
- bool needNotify = updateConnType();
- if (updatePacketDir()) {
- needNotify = true;
- }
-
- if (needNotify && m_handler) {
- m_handler();
- }
- }
-
- PacketDirection ConnectionStateSource::getPacketDirByWiFiState() const
- {
- int transferState = 0;
- if (vconf_get_int(VCONFKEY_WIFI_TRANSFER_STATE, &transferState) == 0) {
- switch (transferState) {
- case VCONFKEY_WIFI_TRANSFER_STATE_RX:
- return PacketDirection::IN;
- case VCONFKEY_WIFI_TRANSFER_STATE_TX:
- return PacketDirection::OUT;
- case VCONFKEY_WIFI_TRANSFER_STATE_TXRX:
- return PacketDirection::INOUT;
- default:
- return PacketDirection::NO_INPUT;
- }
- }
- ELOG("Get WiFi transfer state failed");
- return PacketDirection::NONE;
- }
-
- PacketDirection ConnectionStateSource::getPacketDirByPacketState() const
- {
- int state = 0;
- if (vconf_get_int(VCONFKEY_PACKET_STATE, &state) == 0) {
- switch (state) {
- case VCONFKEY_PACKET_RX: return PacketDirection::IN;
- case VCONFKEY_PACKET_TX: return PacketDirection::OUT;
- case VCONFKEY_PACKET_RXTX: return PacketDirection::INOUT;
- default: return PacketDirection::NO_INPUT;
- }
- }
- ELOG("Get packet state failed");
- return PacketDirection::NONE;
- }
-
- bool ConnectionStateSource::updatePacketDir()
- {
- PacketDirection direction = PacketDirection::NONE;
-
- if (isFlightModeActive()) {
- return updatePacketDirBits(direction);
- }
-
- if (isWifiConnected()) {
- direction = getPacketDirByWiFiState();
- } else if (isDnetConnected()) {
- direction = getPacketDirByPacketState();
- }
- return updatePacketDirBits(direction);
- }
-
- void ConnectionStateSource::onPacketStateChangedCb(keynode_t *node)
- {
- ILOG();
- if (updatePacketDir() && m_handler) {
- m_handler();
- }
- }
-
- Result ConnectionStateSource::addSysStateCallbacks()
- {
- // CONNECTION
- int res = vconf_notify_key_changed(VCONFKEY_WIFI_STRENGTH,
- CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
- if (res != 0) {
- LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
- }
-
- res = vconf_notify_key_changed(VCONFKEY_WIFI_STATE,
- CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
- if (res != 0) {
- LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
- }
-
- res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
- CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
- if (res != 0) {
- LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
- }
-
- res = vconf_notify_key_changed(VCONFKEY_DNET_STATE,
- CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
- if (res != 0) {
- LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
- }
-
- res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_PSTYPE,
- CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
- if (res != 0) {
- LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
- }
-
- res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_SVCTYPE,
- CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
- if (res != 0) {
- LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
- }
-
- res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_SIM_SLOT,
- CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
- if (res != 0) {
- LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
- }
-
- res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_EMERGENCY_CB_MODE_CDMA,
- CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
-
- // PACKET
- res = vconf_notify_key_changed(VCONFKEY_PACKET_STATE,
- CALLBACK_B(ConnectionStateSource::onPacketStateChangedCb), this);
- if (res != 0) {
- LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
- }
-
- res = vconf_notify_key_changed(VCONFKEY_WIFI_TRANSFER_STATE,
- CALLBACK_B(ConnectionStateSource::onPacketStateChangedCb), this);
- if (res != 0) {
- LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
- }
-
- return RES_OK;
-
- }
-
- void ConnectionStateSource::unsignSystStateCallbacks()
- {
- // CONNECTION
- vconf_ignore_key_changed(VCONFKEY_WIFI_STRENGTH,
- CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
- vconf_ignore_key_changed(VCONFKEY_WIFI_STATE,
- CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
- vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
- CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
- vconf_ignore_key_changed(VCONFKEY_DNET_STATE,
- CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
- vconf_ignore_key_changed(VCONFKEY_TELEPHONY_PSTYPE,
- CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
- vconf_ignore_key_changed(VCONFKEY_TELEPHONY_SVCTYPE,
- CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
- vconf_ignore_key_changed(VCONFKEY_TELEPHONY_SIM_SLOT,
- CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
- vconf_ignore_key_changed(VCONFKEY_TELEPHONY_EMERGENCY_CB_MODE_CDMA,
- CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
-
- // PACKET
- vconf_ignore_key_changed(VCONFKEY_PACKET_STATE,
- CALLBACK_B(ConnectionStateSource::onPacketStateChangedCb));
- vconf_ignore_key_changed(VCONFKEY_WIFI_TRANSFER_STATE,
- CALLBACK_B(ConnectionStateSource::onPacketStateChangedCb));
-
- }
-
- IndicatorState ConnectionStateSource::getState() const
- {
- return {m_bits.value};
- }
-
- void ConnectionStateSource::setStateChangeHandler(const NotiHandler &handler)
- {
- m_handler = handler;
- }
-
- ConnectionType getConnectionState(IndicatorState state)
- {
- return static_cast<ConnectionType>(
- ConnectionStateSource::Bits(state).connState);
- }
-
- PacketDirection getPacketDirection(IndicatorState state)
- {
- return static_cast<PacketDirection>(
- ConnectionStateSource::Bits(state).packetDirection);
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_CONNECTION_STATE_SOURCE_H__
-#define __CALLUI_MODEL_CONNECTION_STATE_SOURCE_H__
-
-#include "IIndicatorStateSource.h"
-
-#include <vconf.h>
-
-#include "implTypes.h"
-
-namespace callui {
-
- class ConnectionStateSource final : public IIndicatorStateSource {
- public:
- static ConnectionStateSourceSRef newInstance();
- virtual ~ConnectionStateSource();
-
- // IIndicatorStateSource
-
- virtual IndicatorState getState() const override final;
- virtual void setStateChangeHandler(const NotiHandler &handler) override final;
-
- private:
- friend class ucl::ReffedObj<ConnectionStateSource>;
- ConnectionStateSource();
-
- ucl::Result prepare();
-
- ucl::Result addSysStateCallbacks();
- void unsignSystStateCallbacks();
-
- void onConnTypeChangedCb(keynode_t *node);
- void onPacketStateChangedCb(keynode_t *node);
-
- bool isWifiConnected() const;
- bool isDnetConnected() const;
-
- bool updateConnTypeBits(ConnectionType connType);
- ConnectionType getConnTypeByTelephonyPsType() const;
- ConnectionType getConnTypeByTelephonySvcType() const;
- ConnectionType getConnTypeByWiFiStrength() const;
- bool updateConnType();
-
- bool updatePacketDirBits(PacketDirection packetType);
- PacketDirection getPacketDirByWiFiState() const;
- PacketDirection getPacketDirByPacketState() const;
- bool updatePacketDir();
-
- public:
- union Bits {
- struct {
- uint8_t property : 4;
- uint8_t connState : 8;
- uint8_t packetDirection : 4;
- };
- uint64_t value;
-
- Bits();
- Bits(const IndicatorState &state);
- };
-
- private:
- Bits m_bits;
- NotiHandler m_handler;
- };
-
-}
-
-#endif // __CALLUI_MODEL_CONNECTION_STATE_SOURCE_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 <call-manager-extension.h>
-
-#include "ContactInfo.h"
-
-#include "common.h"
-
-namespace callui {
-
- using namespace ucl;
-
- ContactInfo::ContactInfo(int personId,
- const std::string &name,
- const std::string &imagePath,
- ContactNameSourceType type):
- m_personId(personId),
- m_name(name),
- m_imagePath(imagePath),
- m_nameSource(type)
- {
- }
-
- ContactInfo::~ContactInfo()
- {
- }
-
- ContactInfoSRef ContactInfo::newInstance(int personId,
- const std::string &name,
- const std::string &imagePath,
- ContactNameSourceType type)
- {
- return makeShared<ContactInfo>(personId, name, imagePath, type);
- }
-
- const std::string &ContactInfo::getName() const
- {
- return m_name;
- }
-
- const std::string &ContactInfo::getImagePath() const
- {
- return m_imagePath;
- }
-
- ContactNameSourceType ContactInfo::getNameSourceType() const
- {
- return m_nameSource;
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_CONTACT_INFO_H__
-#define __CALLUI_MODEL_CONTACT_INFO_H__
-
-#include "contacts_types.h"
-
-#include "model/IContactInfo.h"
-
-#include "implTypes.h"
-
-namespace callui {
-
- class ContactInfo final : public IContactInfo {
- public:
- static ContactInfoSRef newInstance(int personId,
- const std::string &name,
- const std::string &imagePath,
- ContactNameSourceType type);
- virtual ~ContactInfo();
-
- // IContactInfo
-
- virtual const std::string &getName() const override final;
- virtual const std::string &getImagePath() const override final;
- virtual ContactNameSourceType getNameSourceType() const override final;
-
- private:
- friend class ucl::ReffedObj<ContactInfo>;
- ContactInfo(int personId,
- const std::string &name,
- const std::string &imagePath,
- ContactNameSourceType type);
-
- private:
- int m_personId;
- std::string m_name;
- std::string m_imagePath;
- ContactNameSourceType m_nameSource;
- };
-
-}
-
-#endif // __CALLUI_MODEL_CONTACT_INFO_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "ContactInfoProvider.h"
-
-#include <contacts.h>
-#include <contacts_service.h>
-#include <contacts_errors.h>
-
-#include "ContactInfo.h"
-
-#include "common.h"
-
-namespace callui { namespace { namespace impl {
-
- using namespace ucl;
-
- inline ContactNameSourceType convertContactNameSourceType(contacts_display_name_source_type_e cdbType)
- {
- switch (cdbType) {
- case CONTACTS_DISPLAY_NAME_SOURCE_TYPE_INVALID: return ContactNameSourceType::INVALID;
- case CONTACTS_DISPLAY_NAME_SOURCE_TYPE_EMAIL: return ContactNameSourceType::EMAIL;
- case CONTACTS_DISPLAY_NAME_SOURCE_TYPE_NUMBER: return ContactNameSourceType::NUMBER;
- case CONTACTS_DISPLAY_NAME_SOURCE_TYPE_NICKNAME: return ContactNameSourceType::NICKNAME;
- case CONTACTS_DISPLAY_NAME_SOURCE_TYPE_COMPANY: return ContactNameSourceType::COMPANY;
- case CONTACTS_DISPLAY_NAME_SOURCE_TYPE_NAME: return ContactNameSourceType::NAME;
- default:
- return ContactNameSourceType::INVALID;
- }
- }
-
-}}}
-
-namespace callui {
-
- using namespace ucl;
-
- ContactInfoProvider::ContactInfoProvider():
- m_isConnected(false)
- {
-
- }
-
- ContactInfoProvider::~ContactInfoProvider()
- {
- if (m_isConnected) {
- contacts_disconnect();
- }
- }
-
- ContactInfoProviderSRef ContactInfoProvider::newInstance()
- {
- auto result = makeShared<ContactInfoProvider>();
- FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
- return result;
- }
-
- Result ContactInfoProvider::prepare()
- {
- auto res = contacts_connect();
- if (res != CONTACTS_ERROR_NONE) {
- LOG_RETURN(RES_FAIL, "contacts_connect() failed! res[%d] msg[%s]",
- res, get_error_message(res));
- }
- m_isConnected = true;
-
- return RES_OK;
- }
-
- ContactInfoSRef ContactInfoProvider::createContactInfo(int contactId)
- {
- DLOG("Try create contact info for ID [%d]", contactId);
-
- std::string contactName;
- std::string contactImagePath;
- ContactNameSourceType contactNameSource;
-
- contacts_filter_h filter = nullptr;
- contacts_list_h list = nullptr;
- contacts_query_h query = nullptr;
- contacts_record_h record = nullptr;
-
- int ret = CONTACTS_ERROR_NONE;
- do {
- ret = contacts_filter_create(_contacts_contact._uri,
- &filter);
- if (ret != CONTACTS_ERROR_NONE) {
- LOG_BREAK(RES_FAIL,
- "contacts_filter_create() failed!"
- "res[%d] res_msg[%s]",
- ret, get_error_message(ret));
- }
-
- ret = contacts_filter_add_int(filter,
- _contacts_contact.person_id,
- CONTACTS_MATCH_EQUAL, contactId);
- if (ret != CONTACTS_ERROR_NONE) {
- LOG_BREAK(RES_FAIL,
- "contacts_filter_add_int() failed!"
- "res[%d] res_msg[%s]",
- ret, get_error_message(ret));
- }
-
- ret = contacts_query_create(_contacts_contact._uri, &query);
- if (ret != CONTACTS_ERROR_NONE) {
- LOG_BREAK(RES_FAIL,
- "contacts_query_create() failed!"
- "res[%d] res_msg[%s]",
- ret, get_error_message(ret));
- }
-
- ret = contacts_query_set_filter(query, filter);
- if (ret != CONTACTS_ERROR_NONE) {
- LOG_BREAK(RES_FAIL,
- "contacts_query_set_filter() failed!"
- "res[%d] res_msg[%s]",
- ret, get_error_message(ret));
- }
-
- ret = contacts_db_get_records_with_query(query, 0, 1, &list);
- if (ret != CONTACTS_ERROR_NONE) {
- LOG_BREAK(RES_FAIL,
- "contacts_db_get_records_with_query() failed!"
- "res[%d] res_msg[%s]",
- ret, get_error_message(ret));
- }
-
- ret = contacts_list_get_current_record_p(list, &record);
- if (ret != CONTACTS_ERROR_NONE) {
- LOG_BREAK(RES_FAIL,
- "contacts_list_get_current_record_p() failed!"
- "res[%d] res_msg[%s]",
- ret, get_error_message(ret));
- }
-
- if (record) {
- char *name = nullptr;
- contacts_record_get_str_p(record,
- _contacts_contact.display_name, &name);
- contactName = nz(name);
-
- int type = CONTACTS_DISPLAY_NAME_SOURCE_TYPE_INVALID;
- contacts_record_get_int(record,
- _contacts_contact.display_source_type, &type);
- contactNameSource = impl::convertContactNameSourceType(
- static_cast<contacts_display_name_source_type_e>(type));
-
- int count = 0;
- contacts_record_get_child_record_count(record,
- _contacts_contact.image, &count);
- if (count > 0) {
- char *imgPath = nullptr;
- contacts_record_h childRecord = NULL;
- contacts_record_get_child_record_at_p(record,
- _contacts_contact.image, 0, &childRecord);
- contacts_record_get_str_p(childRecord,
- _contacts_image.path, &imgPath);
- contactImagePath = nz(imgPath);
- }
- }
- } while (false);
-
- contacts_list_destroy(list, true);
- contacts_filter_destroy(filter);
- contacts_query_destroy(query);
-
- if (ret != CONTACTS_ERROR_NONE) {
- return {};
- }
-
- DLOG("Contact ID [%d]", contactId);
- DLOG("Contact name [%s]", contactName.c_str());
- DLOG("Contact image path [%s]", contactImagePath.c_str());
-
- return ContactInfo::newInstance(contactId,
- contactName,
- contactImagePath,
- contactNameSource);
- }
-
-}
-
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_CONTACT_INFO_PROVIDER_H__
-#define __CALLUI_MODEL_CONTACT_INFO_PROVIDER_H__
-
-#include "implTypes.h"
-
-namespace callui {
-
- class ContactInfoProvider {
- public:
- static ContactInfoProviderSRef newInstance();
- virtual ~ContactInfoProvider();
-
- ContactInfoSRef createContactInfo(int contactId);
-
- private:
- friend class ucl::ReffedObj<ContactInfoProvider>;
- ContactInfoProvider();
-
- ucl::Result prepare();
-
- private:
- bool m_isConnected;
- };
-}
-
-#endif // __CALLUI_MODEL_CONTACT_INFO_PROVIDER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "EndCall.h"
-
-#include "CallClient.h"
-#include "CallManager.h"
-#include "CallInfo.h"
-
-#include "common.h"
-
-namespace callui {
-
- using namespace ucl;
-
- EndCall::EndCall(CallManagerWRef cm, ICallInfoSCRef callInfo):
- m_cm(cm),
- m_callInfo(callInfo),
- m_callbackInProgress(false)
- {
- }
-
- EndCall::~EndCall()
- {
- }
-
- EndCallSRef EndCall::newInstance(CallManagerWRef cm, ICallInfoSCRef callInfo)
- {
- if (!cm) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "cm is NULL");
- }
-
- if (!callInfo) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "callInfo is NULL");
- }
- return makeShared<EndCall>(cm, callInfo);
- }
-
- ICallInfoSCRef EndCall::getInfo() const
- {
- return m_callInfo;
- }
-
- Result EndCall::callBack()
- {
- if (m_callbackInProgress) {
- LOG_RETURN(RES_OK, "Callback already in progress");
- }
-
- const auto cm = m_cm.lock();
- if (!cm) {
- LOG_RETURN(RES_FAIL, "Call Manager is NULL");
- }
-
- auto res = cm->dialVoiceCall(m_callInfo->getPhoneNumber());
- if (res == RES_OK) {
- m_callbackInProgress = true;
- }
- return res;
- }
-
- Result EndCall::writeMessage()
- {
- UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_END_CALL_H__
-#define __CALLUI_MODEL_END_CALL_H__
-
-#include <call-manager-ext.h>
-
-#include "model/IEndCall.h"
-
-#include "implTypes.h"
-
-namespace callui {
-
- class CallManager;
-
- class EndCall final : public IEndCall {
- public:
- static EndCallSRef newInstance(CallManagerWRef cm, ICallInfoSCRef callInfo);
-
- virtual ~EndCall();
-
- // IEndCall
-
- virtual ICallInfoSCRef getInfo() const override final;
- virtual ucl::Result callBack() override final;
- virtual ucl::Result writeMessage() override final;
-
- private:
- friend class ucl::ReffedObj<EndCall>;
- EndCall(CallManagerWRef cm, ICallInfoSCRef callInfo);
-
- ucl::Result prepare();
-
- private:
- CallManagerWRef m_cm;
- ICallInfoSCRef m_callInfo;
- bool m_callbackInProgress;
- };
-
-}
-
-#endif // __CALLUI_MODEL_END_CALL_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "HdVoiceStateSource.h"
-
-#include "common.h"
-
-namespace callui {
-
- using namespace ucl;
-
- HdVoiceStateSource::Bits::Bits():
- property(convertEnumValueToInt(IndicatorProperty::HD_VOICE)),
- isEnable(0)
- {
- }
-
- HdVoiceStateSource::Bits::Bits(const IndicatorState &state):
- value(state.value)
- {
- if (property != convertEnumValueToInt(IndicatorProperty::HD_VOICE)) {
- ELOG("State of incorrect property type [%d]", property);
- *this = {};
- }
- }
-
- HdVoiceStateSource::HdVoiceStateSource(bool isEnable)
- {
- m_bits.isEnable = isEnable;
- }
-
- HdVoiceStateSource::~HdVoiceStateSource()
- {
- }
-
- void HdVoiceStateSource::updateState(bool isEnable)
- {
- if (m_bits.isEnable != isEnable) {
- m_bits.isEnable = isEnable;
-
- if (m_handler) {
- m_handler();
- }
- }
- }
-
- IndicatorState HdVoiceStateSource::getState() const
- {
- return {m_bits.value};
- }
-
- void HdVoiceStateSource::setStateChangeHandler(const NotiHandler &handler)
- {
- m_handler = handler;
- }
-
- bool getHDVoiceState(IndicatorState state)
- {
- return HdVoiceStateSource::Bits(state).isEnable;
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_HD_VOICE_STATE_SOURCE_H__
-#define __CALLUI_MODEL_HD_VOICE_STATE_SOURCE_H__
-
-#include "IIndicatorStateSource.h"
-
-namespace callui {
-
- class HdVoiceStateSource final : public IIndicatorStateSource {
- public:
- HdVoiceStateSource(bool isEnable);
- virtual ~HdVoiceStateSource();
- void updateState(bool isEnable);
-
- // IIndicatorStateSource
-
- virtual IndicatorState getState() const override final;
- virtual void setStateChangeHandler(const NotiHandler &handler) override final;
-
- public:
- union Bits {
- struct {
- uint8_t property : 4;
- uint8_t isEnable : 1;
- };
- uint64_t value;
-
- Bits();
- Bits(const IndicatorState &state);
- };
-
- private:
- Bits m_bits;
- NotiHandler m_handler;
- };
-
-}
-
-#endif // __CALLUI_MODEL_HD_VOICE_STATE_SOURCE_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "HeldCall.h"
-
-#include "CallClient.h"
-#include "CallManager.h"
-#include "CallInfo.h"
-#include "CallClient.h"
-
-#include "common.h"
-
-namespace callui {
-
- using namespace ucl;
-
- HeldCall::HeldCall(CallManagerWRef cm, cm_call_data_h callData):
- m_cm(cm)
- {
- }
-
- HeldCall::~HeldCall()
- {
- }
-
- HeldCallSRef HeldCall::newInstance(CallManagerWRef cm, cm_call_data_h callData)
- {
- if (!cm) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "cm is NULL");
- }
-
- if (!callData) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "callData is NULL");
- }
-
- auto result = makeShared<HeldCall>(cm, callData);
- FAIL_RETURN_VALUE(result->prepare(callData), {}, "result->prepare() failed!");
- return result;
- }
-
- Result HeldCall::prepare(cm_call_data_h callData)
- {
- const auto cm = m_cm.lock();
- if (!cm) {
- LOG_RETURN(RES_FAIL, "Call Manager is NULL");
- }
- m_callInfo = CallInfo::newInstance(cm->getCallClient(),
- callData,
- cm->getContactInfoProvider());
- if (!m_callInfo) {
- LOG_RETURN_VALUE(RES_FAIL, RES_FAIL, "CallInfo::newInstance() failed!");
- }
- return RES_OK;
- }
-
- ICallInfoSCRef HeldCall::getInfo() const
- {
- return m_callInfo;
- }
-
- Result HeldCall::unhold()
- {
- const auto cm = m_cm.lock();
- if (!cm) {
- LOG_RETURN(RES_FAIL, "Call Manager is NULL");
- }
- return convertCMResult(cm_unhold_call(cm->getCallClient()));
- }
-
- Result HeldCall::joinWithActive()
- {
- const auto cm = m_cm.lock();
- if (!cm) {
- LOG_RETURN(RES_FAIL, "Call Manager is NULL");
- }
- return convertCMResult(cm_join_call(cm->getCallClient()));
- }
-
- Result HeldCall::swapWithActive()
- {
- const auto cm = m_cm.lock();
- if (!cm) {
- LOG_RETURN(RES_FAIL, "Call Manager is NULL");
- }
- return convertCMResult(cm_swap_call(cm->getCallClient()));
- }
-
- Result HeldCall::end()
- {
- const auto cm = m_cm.lock();
- if (!cm) {
- LOG_RETURN(RES_FAIL, "Call Manager is NULL");
- }
- return cm->endCall(0, CallReleaseType::ALL_HOLD);
- }
-
- Result HeldCall::split(const IConferenceCallInfoSCRef &confCallInfo)
- {
- const auto cm = m_cm.lock();
- if (!cm) {
- LOG_RETURN(RES_FAIL, "Call Manager is NULL");
- }
- return cm->splitCalls(m_callInfo, confCallInfo);
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_HELD_CALL_H__
-#define __CALLUI_MODEL_HELD_CALL_H__
-
-#include <call-manager-ext.h>
-
-#include "model/IHeldCall.h"
-
-#include "implTypes.h"
-
-namespace callui {
-
- class HeldCall final : public IHeldCall {
- public:
- static HeldCallSRef newInstance(CallManagerWRef cm, cm_call_data_h callData);
- virtual ~HeldCall();
-
- // IHeldCall
-
- virtual ICallInfoSCRef getInfo() const override final;
- virtual ucl::Result unhold() override final;
- virtual ucl::Result joinWithActive() override final;
- virtual ucl::Result swapWithActive() override final;
- virtual ucl::Result end() override final;
- virtual ucl::Result split(const IConferenceCallInfoSCRef &confCallInfo) override final;
-
- private:
- friend class ucl::ReffedObj<HeldCall>;
- HeldCall(CallManagerWRef cm, cm_call_data_h callData);
-
- ucl::Result prepare(cm_call_data_h callData);
-
- private:
- CallManagerWRef m_cm;
- CallInfoSRef m_callInfo;
- };
-
-}
-
-#endif // __CALLUI_MODEL_HELD_CALL_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_I_CALL_MANAGER_LISTENER_H__
-#define __CALLUI_MODEL_I_CALL_MANAGER_LISTENER_H__
-
-#include "implTypes.h"
-
-namespace callui {
-
- class ICallManagerListener : public ucl::Polymorphic {
- public:
- virtual void onCallEvent(CallEventType type) = 0;
- virtual void onError(CallManagerErr err) = 0;
- };
-
-}
-
-#endif // __CALLUI_MODEL_I_CALL_MANAGER_LISTENER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_I_STATE_SOURCE_H__
-#define __CALLUI_MODEL_I_STATE_SOURCE_H__
-
-#include "implTypes.h"
-
-#include "model/IndicatorState.h"
-
-namespace callui {
-
- class IIndicatorStateSource : public ucl::Polymorphic {
- public:
- virtual IndicatorState getState() const = 0;
- virtual void setStateChangeHandler(const NotiHandler &handler) = 0;
- };
-}
-
-#endif // __CALLUI_MODEL_I_STATE_SOURCE_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "IncomingCall.h"
-
-#include "CallClient.h"
-#include "CallManager.h"
-#include "CallClient.h"
-#include "CallInfo.h"
-#include "RejectMsgProvider.h"
-#include "RejectMsg.h"
-
-#include "common.h"
-
-namespace callui {
-
- using namespace ucl;
-
- IncomingCall::IncomingCall(CallManagerWRef cm, cm_call_data_h callData):
- m_cm(cm)
- {
- }
-
- IncomingCall::~IncomingCall()
- {
- }
-
- IncomingCallSRef IncomingCall::newInstance(CallManagerWRef cm, cm_call_data_h callData)
- {
- if (!cm) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "cm is NULL");
- }
-
- if (!callData) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "callData is NULL");
- }
-
- auto result = makeShared<IncomingCall>(cm, callData);
- FAIL_RETURN_VALUE(result->prepare(callData), {}, "result->prepare() failed!");
- return result;
- }
-
- Result IncomingCall::prepare(cm_call_data_h callData)
- {
- const auto cm = m_cm.lock();
- if (!cm) {
- LOG_RETURN(RES_FAIL, "Call Manager is NULL");
- }
- m_callInfo = CallInfo::newInstance(cm->getCallClient(),
- callData,
- cm->getContactInfoProvider());
- if (!m_callInfo) {
- LOG_RETURN_VALUE(RES_FAIL, RES_FAIL, "CallInfo::newInstance() failed!");
- }
-
- return RES_OK;
- }
-
- ICallInfoSCRef IncomingCall::getInfo() const
- {
- return m_callInfo;
- }
-
- IRejectMsgProviderSRef IncomingCall::getRejectMsgProvider() const
- {
- const auto cm = m_cm.lock();
- if (!cm) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "Call Manager is NULL");
- }
- return cm->getRejectMsgProvider();
- }
-
- Result IncomingCall::answer(CallAnswerType type)
- {
- const auto cm = m_cm.lock();
- if (!cm) {
- LOG_RETURN(RES_FAIL, "Call Manager is NULL");
- }
- return convertCMResult(cm_answer_call(cm->getCallClient(), convertCUICallAnswerType(type)));
- }
-
- Result IncomingCall::reject()
- {
- const auto cm = m_cm.lock();
- if (!cm) {
- LOG_RETURN(RES_FAIL, "Call Manager is NULL");
- }
- return convertCMResult(cm_reject_call(cm->getCallClient()));
- }
-
- Result IncomingCall::rejectWithMessage(IRejectMsgSRef message)
- {
- FAIL_RETURN(reject(), "reject() failed!");
-
- auto msg = dynamicRefCast<RejectMsg>(message);
- if (!msg) {
- LOG_RETURN(RES_FAIL, "message is not RejectMsg type!");
- }
-
- const auto cm = m_cm.lock();
- if (!cm) {
- LOG_RETURN(RES_FAIL, "Call Manager is NULL");
- }
- return msg->send(m_callInfo->getPhoneNumber(), cm->getSimSlot());
- }
-
- Result IncomingCall::stopAlert()
- {
- const auto cm = m_cm.lock();
- if (!cm) {
- LOG_RETURN(RES_FAIL, "Call Manager is NULL");
- }
- return convertCMResult(cm_stop_alert(cm->getCallClient()));
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_ICOMING_CALL_H__
-#define __CALLUI_MODEL_ICOMING_CALL_H__
-
-#include <call-manager-ext.h>
-
-#include "model/IIncomingCall.h"
-
-#include "implTypes.h"
-
-namespace callui {
-
- class IncomingCall final : public IIncomingCall {
- public:
- static IncomingCallSRef newInstance(CallManagerWRef cm, cm_call_data_h callData);
-
- virtual ~IncomingCall();
-
- // IIncomingCall
-
- virtual ICallInfoSCRef getInfo() const override final;
- virtual IRejectMsgProviderSRef getRejectMsgProvider() const override final;
- virtual ucl::Result answer(CallAnswerType type) override final;
- virtual ucl::Result reject() override final;
- virtual ucl::Result rejectWithMessage(IRejectMsgSRef message) override final;
- virtual ucl::Result stopAlert() override final;
-
- private:
- friend class ucl::ReffedObj<IncomingCall>;
- IncomingCall(CallManagerWRef cm, cm_call_data_h callData);
-
- ucl::Result prepare(cm_call_data_h callData);
-
- private:
- CallManagerWRef m_cm;
- CallInfoSRef m_callInfo;
- };
-
-}
-
-#endif // __CALLUI_MODEL_ICOMING_CALL_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "IndicatorStateProvider.h"
-
-#include "model/IIndicatorStateListener.h"
-#include "IIndicatorStateSource.h"
-
-#include "common.h"
-
-namespace callui {
-
- using namespace ucl;
-
- class IndicatorStateProvider::SourceHandler :
- public RefCountAware {
- public:
- SourceHandler(IRefCountObj &rc,
- IndicatorStateProvider &provider,
- IndicatorProperty property,
- IIndicatorStateSourceSRef source):
- RefCountAware(&rc),
- m_provider(provider),
- m_property(property),
- m_source(source)
- {
- m_source->setStateChangeHandler(
- WEAK_DELEGATE(SourceHandler::onStateChanged,
- asWeak(*this)));
- }
-
- IndicatorState getState() const
- {
- return m_source->getState();
- }
-
- private:
- void onStateChanged()
- {
- m_provider.dispatchStateChanged(m_property);
- }
-
- private:
- const IndicatorStateProvider &m_provider;
- const IndicatorProperty m_property;
- const IIndicatorStateSourceSRef m_source;
- };
-
- IndicatorStateProvider::IndicatorStateProvider():
- m_listener(nullptr),
- m_sources()
- {
- }
-
- IndicatorStateProvider::~IndicatorStateProvider()
- {
- }
-
- IndicatorStateProviderSRef IndicatorStateProvider::newInstance()
- {
- return makeShared<IndicatorStateProvider>();
- }
-
- Result IndicatorStateProvider::setStateSource(IndicatorProperty property,
- IIndicatorStateSourceSRef source)
- {
- if (!source) {
- LOG_RETURN(RES_INVALID_ARGUMENTS, "source is empty!");
- }
- m_sources[convertEnumValueToInt(property)] =
- makeShared<SourceHandler>(*this, property, source);
-
- return RES_OK;
- }
-
- IndicatorState IndicatorStateProvider::getState(
- IndicatorProperty property) const
- {
- return m_sources[convertEnumValueToInt(property)]->getState();
- }
-
- void IndicatorStateProvider::setListener(
- IIndicatorStateListenerWRef listener)
- {
- m_listener = listener;
- }
-
- void IndicatorStateProvider::dispatchStateChanged(
- IndicatorProperty property) const
- {
- if (const auto listener = m_listener.lock()) {
- listener->onStateChanged(property);
- }
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_INDICATOR_STATE_PROVIDER_H__
-#define __CALLUI_MODEL_INDICATOR_STATE_PROVIDER_H__
-
-#include "model/IIndicatorStateProvider.h"
-
-#include "implTypes.h"
-
-namespace callui {
-
- class IIndicatorStateListener;
-
- class IndicatorStateProvider final: public IIndicatorStateProvider {
- public:
- static IndicatorStateProviderSRef newInstance();
-
- virtual ~IndicatorStateProvider();
-
- virtual ucl::Result setStateSource(IndicatorProperty property,
- IIndicatorStateSourceSRef source);
-
- // IIndicatorStateProvider
-
- virtual IndicatorState getState(IndicatorProperty property) const override final;
- virtual void setListener(IIndicatorStateListenerWRef listener) override final;
-
- private:
- friend class ucl::ReffedObj<IndicatorStateProvider>;
- IndicatorStateProvider();
-
- void dispatchStateChanged(IndicatorProperty property) const;
-
- private:
- enum {
- STATE_COUNT = 6
- };
-
- class SourceHandler;
- UCL_DECLARE_REF_ALIASES(SourceHandler);
-
- private:
- IIndicatorStateListenerWRef m_listener;
- std::array<SourceHandlerSRef, STATE_COUNT> m_sources;
- };
-
-}
-
-#endif // __CALLUI_MODEL_INDICATOR_STATE_PROVIDER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "MsgClient.h"
-
-#include <msg.h>
-#include <msg_transport.h>
-
-#include "common.h"
-
-namespace callui {
-
- using namespace ucl;
-
- MsgClient::MsgClient():
- m_handle()
- {
- }
-
- MsgClient::~MsgClient()
- {
- if (m_handle) {
- msg_close_msg_handle(&m_handle);
- }
- }
-
- MsgClientSRef MsgClient::newInstance()
- {
- auto result = makeShared<MsgClient>();
- FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
- return result;
- }
-
- Result MsgClient::prepare()
- {
- msg_handle_t handle;
- msg_error_t err = msg_open_msg_handle(&handle);
- if (err != MSG_SUCCESS) {
- LOG_RETURN(RES_FAIL, "msg_open_msg_handle() failed! res[%d]", err);
- }
- m_handle = handle;
-
- err = msg_reg_sent_status_callback(m_handle, [](msg_handle_t msgHandle, msg_struct_t status, void *data)
- {
- if(!status)
- LOG_RETURN_VOID(RES_FAIL, "status is NULL");
-
- int msgNetworkStatus = MSG_NETWORK_SEND_FAIL;
- msg_get_int_value(status, MSG_SENT_STATUS_NETWORK_STATUS_INT, &msgNetworkStatus);
- DLOG("Message sent status [%d]", msgNetworkStatus);
- }, NULL);
- if (err != MSG_SUCCESS) {
- LOG_RETURN(RES_FAIL, "msg_reg_sent_status_callback() failed! res[%d]", err);
- }
-
- return RES_OK;
- }
-
- msg_handle_t MsgClient::getMsgHandle() const
- {
- return m_handle;
- }
-
- MsgClient::operator msg_handle_t() const
- {
- return getMsgHandle();
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_MSG_CLIENT_H__
-#define __CALLUI_MODEL_MSG_CLIENT_H__
-
-#include <msg_types.h>
-
-#include "implTypes.h"
-
-namespace callui {
-
- class MsgClient {
- public:
- static MsgClientSRef newInstance();
- virtual ~MsgClient();
- msg_handle_t getMsgHandle() const;
- operator msg_handle_t() const;
-
- private:
- friend class ucl::ReffedObj<MsgClient>;
- MsgClient();
-
- ucl::Result prepare();
-
- private:
- msg_handle_t m_handle;
- };
-
-}
-
-#endif // __CALLUI_MODEL_MSG_CLIENT_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "RejectMsg.h"
-
-#include <msg.h>
-#include <msg_transport.h>
-
-#include "MsgClient.h"
-
-#include "common.h"
-
-namespace callui {
-
- using namespace ucl;
-
- RejectMsg::RejectMsg(MsgClientWRef client, const TString &string):
- m_msgClient(client),
- m_msg(string)
- {
- }
-
- RejectMsg::~RejectMsg()
- {
- }
-
- RejectMsgSRef RejectMsg::newInstance(MsgClientWRef client, const TString &string)
- {
- return makeShared<RejectMsg>(client, string);
- }
-
- std::string RejectMsg::getText() const
- {
- return m_msg;
- }
-
- Result RejectMsg::send(const std::string &phoneNumber, SimSlot slot)
- {
- if (phoneNumber.empty()) {
- LOG_RETURN(RES_FAIL, "Phone Number is NULL");
- }
-
- const auto msgClient = m_msgClient.lock();
- if (!msgClient) {
- LOG_RETURN(RES_FAIL, "Client is NULL");
- }
-
- Result res = RES_FAIL;
-
- msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
- msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT);
- msg_struct_t reqInfo = msg_create_struct(MSG_STRUCT_REQUEST_INFO);
- const char *msgText = m_msg.translate();
-
- // Set message type to SMS reject
- msg_set_int_value(msgInfo, MSG_MESSAGE_TYPE_INT, MSG_TYPE_SMS_REJECT);
-
- // No setting send option
- msg_set_bool_value(sendOpt, MSG_SEND_OPT_SETTING_BOOL, false);
-
- // Set message body
- if (msg_set_str_value(msgInfo, MSG_MESSAGE_SMS_DATA_STR, msgText, strlen(msgText)) != MSG_SUCCESS) {
- ELOG("msg_set_str_value() failed!");
- } else {
- // Create address list
- msg_struct_list_s *addrList = nullptr;
- msg_get_list_handle(msgInfo, MSG_MESSAGE_ADDR_LIST_STRUCT, (void **)&addrList);
- msg_struct_t addrInfo = addrList->msg_struct_info[0];
- const char *number = phoneNumber.c_str();
-
- // Set message address
- msg_set_int_value(addrInfo, MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, MSG_RECIPIENTS_TYPE_TO);
- msg_set_str_value(addrInfo, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, number, strlen(number));
- addrList->nCount = 1;
-
- // Set message struct to Request
- msg_set_struct_handle(reqInfo, MSG_REQUEST_MESSAGE_HND, msgInfo);
- msg_set_struct_handle(reqInfo, MSG_REQUEST_SENDOPT_HND, sendOpt);
-
- // Send message
- int err = msg_sms_send_message(*msgClient, reqInfo);
- if (err != MSG_SUCCESS) {
- ELOG("msg_sms_send_message() failed. err[%d]", err);
- } else {
- DLOG("Sending...");
- res = RES_OK;
- }
- }
- msg_release_struct(&reqInfo);
- msg_release_struct(&msgInfo);
- msg_release_struct(&sendOpt);
-
- return res;
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_REJECT_MSG_H__
-#define __CALLUI_MODEL_REJECT_MSG_H__
-
-#include "model/IRejectMsg.h"
-
-#include "ucl/misc/TString.h"
-
-#include "implTypes.h"
-
-namespace callui {
-
- class RejectMsg : public IRejectMsg {
- public:
- static RejectMsgSRef newInstance(MsgClientWRef client, const ucl::TString &string);
- virtual ~RejectMsg();
-
- ucl::Result send(const std::string &number, SimSlot slot);
-
- // IRejectMsg
- std::string getText() const override final;
-
- private:
- friend class ucl::ReffedObj<RejectMsg>;
- RejectMsg(MsgClientWRef client, const ucl::TString &string);
-
- ucl::Result prepare();
-
- private:
- MsgClientWRef m_msgClient;
- ucl::TString m_msg;
- };
-
-}
-
-#endif // __CALLUI_MODEL_REJECT_MSG_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "RejectMsgProvider.h"
-
-#include <vconf.h>
-
-#include "MsgClient.h"
-#include "RejectMsg.h"
-
-#include "common.h"
-
-namespace callui {
-
- using namespace ucl;
-
- RejectMsgProvider::RejectMsgProvider()
- {
- }
-
- RejectMsgProvider::~RejectMsgProvider()
- {
- }
-
- RejectMsgProviderSRef RejectMsgProvider::newInstance()
- {
- auto result = makeShared<RejectMsgProvider>();
- FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
- return result;
- }
-
- Result RejectMsgProvider::prepare()
- {
- m_msgClient = MsgClient::newInstance();
- if (!m_msgClient) {
- LOG_RETURN(RES_FAIL, "msgClient::newInstance() failed!");
- }
-
- return RES_OK;
- }
-
- const char *getVconfKey(int index)
- {
- switch (index) {
- case 0: return VCONFKEY_CISSAPPL_USER_CREATE_MSG1_STR;
- case 1: return VCONFKEY_CISSAPPL_USER_CREATE_MSG2_STR;
- case 2: return VCONFKEY_CISSAPPL_USER_CREATE_MSG3_STR;
- case 3: return VCONFKEY_CISSAPPL_USER_CREATE_MSG4_STR;
- case 4: return VCONFKEY_CISSAPPL_USER_CREATE_MSG5_STR;
- case 5: return VCONFKEY_CISSAPPL_USER_CREATE_MSG6_STR;
- default:
- return nullptr;
- }
- }
-
- IRejectMsgSRef RejectMsgProvider::getRejectMsgByIndex(int index) const
- {
- const char *vconfKey = getVconfKey(index);
- if(!vconfKey) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "Key not found");
- }
-
- char *message = vconf_get_str(vconfKey);
- if (!message) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "message is empty");
- }
-
- RejectMsgSRef msg = RejectMsg::newInstance(m_msgClient, {message, true});
- if (!msg) {
- ELOG("RejectMsg::newInstance() failed!");
- }
- free(message);
- return msg;
- }
-
- RejectMsgList RejectMsgProvider::getMsgList() const
- {
- RejectMsgList list;
- int count = getMsgCount();
- int i = 0;
-
- while (count) {
- IRejectMsgSRef ref = getRejectMsgByIndex(i);
- if (ref) {
- list.push_back(ref);
- count--;
- }
- i++;
- }
- return list;
- }
-
- int RejectMsgProvider::getMsgCount() const
- {
- int count = 0;
- if (vconf_get_int(VCONFKEY_CISSAPPL_REJECT_CALL_MSG_INT, &count) != 0) {
- LOG_RETURN_VALUE(RES_FAIL, 0, "vconf_get_int() failed!");
- }
- return count;
- }
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_REJECT_MSG_PROVIDER_H__
-#define __CALLUI_MODEL_REJECT_MSG_PROVIDER_H__
-
-#include "model/IRejectMsgProvider.h"
-
-#include "implTypes.h"
-
-namespace callui {
-
- class RejectMsgProvider : public IRejectMsgProvider {
- public:
- static RejectMsgProviderSRef newInstance();
- virtual ~RejectMsgProvider();
-
- // IRejectMsgProvider
-
- virtual RejectMsgList getMsgList() const override final;
- virtual int getMsgCount() const override final;
-
- private:
- friend class ucl::ReffedObj<RejectMsgProvider>;
- RejectMsgProvider();
-
- ucl::Result prepare();
- IRejectMsgSRef getRejectMsgByIndex(int index) const;
-
- private:
- MsgClientSRef m_msgClient;
- };
-
-}
-
-#endif // __CALLUI_MODEL_REJECT_MSG_PROVIDER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "RssiStateSource.h"
-
-#include "common.h"
-
-namespace callui {
-
- using namespace ucl;
-
- RssiStateSource::Bits::Bits():
- property(convertEnumValueToInt(IndicatorProperty::RSSI)),
- rssiState(convertEnumValueToInt(RssiState::NONE)),
- isRoamingEnable(0)
- {
- }
-
- RssiStateSource::Bits::Bits(const IndicatorState &state):
- value(state.value)
- {
- if (property != convertEnumValueToInt(IndicatorProperty::RSSI)) {
- ELOG("State of incorrect property type [%d]", property);
- *this = {};
- }
- }
-
- RssiStateSource::RssiStateSource()
- {
- }
-
- RssiStateSource::~RssiStateSource()
- {
- delSysStateCallbacks();
- }
-
- RssiStateSourceSRef RssiStateSource::newInstance()
- {
- auto result = makeShared<RssiStateSource>();
- FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
- return result;
- }
-
- Result RssiStateSource::prepare()
- {
- FAIL_RETURN(addSysStateCallbacks(), "addSysStateCallbacks() failed!");
-
- updateRssiState();
- updateRoamingState();
-
- return RES_OK;
- }
-
- bool RssiStateSource::isRoamingActive() const
- {
- int status = 0;
- if (vconf_get_int(VCONFKEY_TELEPHONY_SVC_ROAM, &status) != 0) {
- ELOG("Get Flight mode status failed!");
- return false;
- }
- return (status == VCONFKEY_TELEPHONY_SVC_ROAM_ON);
- }
-
- bool RssiStateSource::updateRssiStateBits(RssiState state)
- {
- int rssiStateInt = convertEnumValueToInt(state);
- if (rssiStateInt != m_bits.rssiState) {
- m_bits.rssiState = rssiStateInt;
- return true;
- }
- return false;
- }
-
- bool RssiStateSource::updateRoamingStateBits(bool state)
- {
- if (state != m_bits.isRoamingEnable) {
- m_bits.rssiState = state;
- return true;
- }
- return false;
- }
-
- RssiState RssiStateSource::getCurRssiState() const
- {
- int status = 0;
- if (vconf_get_int(VCONFKEY_TELEPHONY_SVCTYPE, &status) == 0) {
- switch (status) {
- case VCONFKEY_TELEPHONY_SVCTYPE_NONE :
- case VCONFKEY_TELEPHONY_SVCTYPE_NOSVC :
- case VCONFKEY_TELEPHONY_SVCTYPE_SEARCH :
- return RssiState::NO_SIGNAL;
- default :
- break;
- }
- } else {
- ELOG("Get telephony SVC type failed!");
- }
-
- status = 0;
- if (vconf_get_int(VCONFKEY_TELEPHONY_RSSI, &status) == 0) {
- switch (status) {
- case VCONFKEY_TELEPHONY_RSSI_0: return RssiState::LEVEL_0;
- case VCONFKEY_TELEPHONY_RSSI_1: return RssiState::LEVEL_1;
- case VCONFKEY_TELEPHONY_RSSI_2: return RssiState::LEVEL_2;
- case VCONFKEY_TELEPHONY_RSSI_3: return RssiState::LEVEL_3;
- case VCONFKEY_TELEPHONY_RSSI_4: return RssiState::LEVEL_4;
- default:
- break;
- }
- } else {
- ELOG("Get telephony RSSI level failed!");
- }
- return RssiState::NONE;
- }
-
- bool RssiStateSource::updateRssiState()
- {
- if (isFlightModeActive()) {
- return updateRssiStateBits(RssiState::FLIGHT_MODE);
- }
- return updateRssiStateBits(getCurRssiState());
- }
-
- bool RssiStateSource::updateRoamingState()
- {
- return updateRoamingStateBits(isRoamingActive());
- }
-
- void RssiStateSource::onRssiChangedCb(keynode_t *node)
- {
- bool needNotify = updateRssiState();
- if (updateRoamingState()) {
- needNotify = true;
- }
-
- if (needNotify && m_handler) {
- m_handler();
- }
- }
-
- Result RssiStateSource::addSysStateCallbacks()
- {
- int res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_SVC_ROAM,
- CALLBACK_B(RssiStateSource::onRssiChangedCb), this);
- if (res != 0) {
- LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
- }
-
- res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
- CALLBACK_B(RssiStateSource::onRssiChangedCb), this);
- if (res != 0) {
- LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
- }
-
- res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_SVCTYPE,
- CALLBACK_B(RssiStateSource::onRssiChangedCb), this);
- if (res != 0) {
- LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
- }
-
- res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_RSSI,
- CALLBACK_B(RssiStateSource::onRssiChangedCb), this);
- if (res != 0) {
- LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
- }
-
- res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_ROAM_ICON_MODE,
- CALLBACK_B(RssiStateSource::onRssiChangedCb), this);
- if (res != 0) {
- LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
- }
-
- return RES_OK;
- }
-
- void RssiStateSource::delSysStateCallbacks()
- {
- vconf_ignore_key_changed(VCONFKEY_TELEPHONY_SVC_ROAM,
- CALLBACK_B(RssiStateSource::onRssiChangedCb));
- vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
- CALLBACK_B(RssiStateSource::onRssiChangedCb));
- vconf_ignore_key_changed(VCONFKEY_TELEPHONY_SVCTYPE,
- CALLBACK_B(RssiStateSource::onRssiChangedCb));
- vconf_ignore_key_changed(VCONFKEY_TELEPHONY_RSSI,
- CALLBACK_B(RssiStateSource::onRssiChangedCb));
- vconf_ignore_key_changed(VCONFKEY_TELEPHONY_ROAM_ICON_MODE,
- CALLBACK_B(RssiStateSource::onRssiChangedCb));
- }
-
- IndicatorState RssiStateSource::getState() const
- {
- return {m_bits.value};
- }
-
- void RssiStateSource::setStateChangeHandler(const NotiHandler &handler)
- {
- m_handler = handler;
- }
-
- RssiState getRssiState(IndicatorState state)
- {
- return static_cast<RssiState>(
- RssiStateSource::Bits(state).rssiState);
- }
-
- bool getRoamingState(IndicatorState state)
- {
- return RssiStateSource::Bits(state).isRoamingEnable;
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_RSSI_STATE_SOURCE_H__
-#define __CALLUI_MODEL_RSSI_STATE_SOURCE_H__
-
-#include "IIndicatorStateSource.h"
-
-#include <vconf.h>
-
-#include "implTypes.h"
-
-namespace callui {
-
- class RssiStateSource final : public IIndicatorStateSource {
- public:
- static RssiStateSourceSRef newInstance();
- virtual ~RssiStateSource();
-
- // IIndicatorStateSource
-
- virtual IndicatorState getState() const override final;
- virtual void setStateChangeHandler(const NotiHandler &handler) override final;
-
- private:
- friend class ucl::ReffedObj<RssiStateSource>;
- RssiStateSource();
-
- ucl::Result prepare();
- ucl::Result addSysStateCallbacks();
- void delSysStateCallbacks();
-
- bool isRoamingActive() const;
- bool updateRssiStateBits(RssiState state);
- bool updateRoamingStateBits(bool state);
- RssiState getCurRssiState() const;
- bool updateRssiState();
- bool updateRoamingState();
-
- void onRssiChangedCb(keynode_t *node);
-
- public:
- union Bits {
- struct {
- uint8_t property : 4;
- uint8_t rssiState : 4;
- uint8_t isRoamingEnable: 1;
- };
- uint64_t value;
-
- Bits();
- Bits(const IndicatorState &state);
- };
-
- private:
- Bits m_bits;
- NotiHandler m_handler;
- };
-
-}
-
-#endif // __CALLUI_MODEL_RSSI_STATE_SOURCE_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "SimSlotStateSource.h"
-
-#include "common.h"
-
-namespace callui {
-
- using namespace ucl;
-
- SimSlotStateSource::Bits::Bits():
- property(convertEnumValueToInt(IndicatorProperty::SIM_SLOT)),
- simSlot(0)
- {
- }
-
- SimSlotStateSource::Bits::Bits(const IndicatorState &state):
- value(state.value)
- {
- if (property != convertEnumValueToInt(IndicatorProperty::SIM_SLOT)) {
- ELOG("State of incorrect property type [%d]", property);
- *this = {};
- }
- }
-
- SimSlotStateSource::SimSlotStateSource(SimSlot slot, bool isForwarded)
- {
- m_bits.simSlot = convertEnumValueToInt(slot);
- m_bits.isForwarded = isForwarded;
- }
-
- SimSlotStateSource::~SimSlotStateSource()
- {
- }
-
- void SimSlotStateSource::updateSimSlot(SimSlot slot, bool isForwarded)
- {
- int simSlotInt = convertEnumValueToInt(slot);
- bool needUpdate = false;
-
- if (simSlotInt != m_bits.simSlot) {
- m_bits.simSlot = simSlotInt;
- needUpdate = true;
- }
-
- if (isForwarded != m_bits.isForwarded) {
- m_bits.isForwarded = isForwarded;
- needUpdate = true;
- }
-
- if (needUpdate && m_handler) {
- m_handler();
- }
- }
-
- IndicatorState SimSlotStateSource::getState() const
- {
- return {m_bits.value};
- }
-
- void SimSlotStateSource::setStateChangeHandler(const NotiHandler &handler)
- {
- m_handler = handler;
- }
-
- SimSlot getSimSlotType(IndicatorState state)
- {
- return static_cast<SimSlot>(
- SimSlotStateSource::Bits(state).simSlot);
- }
-
- bool getSimForwardState(IndicatorState state)
- {
- return SimSlotStateSource::Bits(state).isForwarded;
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_SIM_SLOT_STATE_SOURCE_H__
-#define __CALLUI_MODEL_SIM_SLOT_STATE_SOURCE_H__
-
-#include "IIndicatorStateSource.h"
-
-namespace callui {
-
- class SimSlotStateSource final : public IIndicatorStateSource {
- public:
- SimSlotStateSource(SimSlot slot, bool isForwarded);
- virtual ~SimSlotStateSource();
- void updateSimSlot(SimSlot slot, bool isForwarded);
-
- // IIndicatorStateSource
-
- virtual IndicatorState getState() const override final;
- virtual void setStateChangeHandler(const NotiHandler &handler) override final;
-
- public:
- union Bits {
- struct {
- uint8_t property : 4;
- uint8_t simSlot : 4;
- uint8_t isForwarded: 1;
- };
- uint64_t value;
-
- Bits();
- Bits(const IndicatorState &state);
- };
-
- private:
- Bits m_bits;
- NotiHandler m_handler;
- };
-
-}
-
-#endif // __CALLUI_MODEL_SIM_SLOT_STATE_SOURCE_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "SoundManager.h"
-
-#include "BluetoothManager.h"
-#include "CallClient.h"
-
-#include "common.h"
-
-namespace callui { namespace { namespace impl {
-
- using namespace ucl;
-
- Result getBTHeadsetConnectedState(bool &state)
- {
- Result res = RES_FAIL;
- state = false;
-
- sound_device_list_h deviceList = nullptr;
- auto ret = sound_manager_get_device_list(
- SOUND_DEVICE_ALL_MASK, &deviceList);
- if (ret != SOUND_MANAGER_ERROR_NONE) {
- LOG_RETURN(RES_FAIL, "sound_manager_get_device_list() failed. "
- "[%d][%s]", ret, get_error_message(ret));
- }
- sound_device_type_e searchType = SOUND_DEVICE_BLUETOOTH_VOICE;
- sound_device_h device;
- sound_device_type_e type;
-
- while (true) {
- device = nullptr;
- ret = sound_manager_get_next_device(deviceList, &device);
-
- if (ret == SOUND_MANAGER_ERROR_NO_DATA) {
- res = RES_OK;
- ILOG("No more device to check");
- break;
- } else if (ret != SOUND_MANAGER_ERROR_NONE) {
- UCL_FAIL_BREAK(res, "sound_manager_get_next_device() failed. "
- "[%d][%s]", ret, get_error_message(ret));
- }
-
- if (!device) {
- UCL_FAIL_BREAK(res, "device is NULL");
- }
-
- sound_manager_get_device_type(device, &type);
- if (searchType == type) {
- DLOG("Bluetooth voice device found");
- state = true;
- }
-
- // For debug only
- int id;
- char *name;
- sound_device_io_direction_e direction;
- sound_manager_get_device_id(device, &id);
- sound_manager_get_device_name(device, &name);
- sound_manager_get_device_io_direction(device, &direction);
- DLOG("--------------------------");
- DLOG("Device ID [%d]", id);
- DLOG("Device name [%s]", name);
- DLOG("Device IO direction [%d]", direction);
- DLOG("Device type [%d]", type);
- }
- sound_manager_free_device_list(deviceList);
-
- return res;
- }
-}}}
-
-namespace callui {
-
- using namespace ucl;
-
- SoundManager::SoundManager(IRefCountObj &rc, const CallClientSRef &client):
- RefCountAware(&rc),
- m_client(client),
- m_deviceVolumeCbID(-1)
- {
- }
-
- SoundManager::~SoundManager()
- {
- if (m_deviceVolumeCbID >= 0) {
- sound_manager_remove_volume_changed_cb(m_deviceVolumeCbID);
- }
- cm_unset_audio_state_changed_cb(*m_client);
- cm_unset_mute_status_cb(*m_client);
- }
-
- SoundManagerSRef SoundManager::newInstance(const CallClientSRef &client)
- {
- auto result = makeShared<SoundManager>(client);
- FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
- return result;
- }
-
- void SoundManager::onAudioStateChanged(cm_audio_state_type_e state)
- {
- DLOG();
-
- if (state == CM_AUDIO_STATE_NONE_E) {
- ILOG("Ignore. Unhandled state [%d]", state);
- return;
- }
- m_audioStateEvent.dispatch(convertCMAudioState(state));
- }
-
- void SoundManager::onMuteStateChanged(cm_mute_status_e status)
- {
- DLOG();
-
- m_muteStateEvent.dispatch(status == CM_MUTE_STATUS_ON);
- }
-
- Result SoundManager::prepare()
- {
- m_btManager = BluetoothManager::newInstance();
- if (!m_btManager) {
- ELOG("BluetoothManager::newInstance() failed!");
- }
-
- Result res = convertCMResult(cm_set_audio_state_changed_cb(*m_client,
- CALLBACK_B(SoundManager::onAudioStateChanged), this));
- FAIL_RETURN(res, "cm_set_audio_state_changed_cb() failed!");
-
- res = convertCMResult(cm_set_mute_status_cb(*m_client,
- CALLBACK_B(SoundManager::onMuteStateChanged), this));
- FAIL_RETURN(res, "cm_set_mute_status_cb() failed!");
-
- res = registerCallbacks();
- FAIL_RETURN(res, "registerVolumeCallbacks() failed!");
-
- return res;
- }
-
- Result SoundManager::registerCallbacks()
- {
- int ret = sound_manager_add_volume_changed_cb(
- CALLBACK_B(SoundManager::onGearVolumeChanged),
- this,
- &m_deviceVolumeCbID);
- if (ret != SOUND_MANAGER_ERROR_NONE) {
- LOG_RETURN(RES_FAIL,
- "sound_manager_add_volume_changed_cb() failed");
- }
-
- if (isBTSupported()) {
- m_btManager->setVolumeStateHandler(
- WEAK_DELEGATE(SoundManager::onBTHeadsetVolumeChanged,
- asWeak(*this)));
-
- m_btManager->setHeadsetConnectionChangeHandler(
- WEAK_DELEGATE(SoundManager::onHeadsetConnectionChanged,
- asWeak(*this)));
- }
-
- return RES_OK;
- }
-
- void SoundManager::onHeadsetConnectionChanged()
- {
- m_btVoiceDeviceConnEvent.dispatch();
- }
-
- Result SoundManager::setSpeakerState(bool isEnable)
- {
- if (isEnable) {
- return convertCMResult(cm_speaker_on(*m_client));
- } else {
- return convertCMResult(cm_speaker_off(*m_client));
- }
- }
-
- Result SoundManager::setBluetoothState(bool isEnable)
- {
- if (!isBTSupported()) {
- LOG_RETURN(RES_NOT_SUPPORTED, "Bluetooth not supported");
- }
-
- bool state = false;
- Result res = impl::getBTHeadsetConnectedState(state);
- DLOG("Sound manager BT Headset connection status [%d], res [%s]",
- state, getResultData(res).name);
-
- if (!isBTHeadsetConnected()) {
- LOG_RETURN(RES_NOT_CONNECTED,
- "Bluetooth headset device not connected");
- }
-
- if (isEnable) {
- return convertCMResult(cm_bluetooth_on(*m_client));
- } else {
- return convertCMResult(cm_bluetooth_off(*m_client));
- }
- }
-
- AudioStateType SoundManager::getAudioState() const
- {
- cm_audio_state_type_e state = CM_AUDIO_STATE_NONE_E;
- Result res = convertCMResult(cm_get_audio_state(*m_client, &state));
- FAIL_RETURN_VALUE(res, AudioStateType::NONE,
- "cm_get_audio_state() failed!");
-
- return convertCMAudioState(state);
- }
-
- Result SoundManager::setMuteState(bool isEnable)
- {
- return convertCMResult(cm_set_mute_state(*m_client, isEnable));
- }
-
- bool SoundManager::getMuteState() const
- {
- cm_mute_status_e status = CM_MUTE_STATUS_MAX;
- Result res = convertCMResult(cm_get_mute_status(*m_client, &status));
- FAIL_RETURN_VALUE(res, false, "cm_get_mute_status() failed!");
-
- return (status == CM_MUTE_STATUS_ON);
- }
-
- Result SoundManager::startDtmf(const unsigned char dtmfDigit)
- {
- return convertCMResult(cm_start_dtmf(*m_client, dtmfDigit));
- }
-
- Result SoundManager::stopDtmf()
- {
- return convertCMResult(cm_stop_dtmf(*m_client));
- }
-
- void SoundManager::addAudioStateHandler(const AudioStateHandler &handler)
- {
- m_audioStateEvent += handler;
- }
-
- void SoundManager::delAudioStateHandler(const AudioStateHandler &handler)
- {
- m_audioStateEvent -= handler;
- }
-
- void SoundManager::addMuteStateHandler(const MuteStateHandler &handler)
- {
- m_muteStateEvent += handler;
- }
-
- void SoundManager::delMuteStateHandler(const MuteStateHandler &handler)
- {
- m_muteStateEvent -= handler;
- }
-
- void SoundManager::addVolumeStateHandler(const VolumeLevelHandler &handler)
- {
- m_volumeLevelEvent += handler;
- }
-
- void SoundManager::delVolumeStateHandler(const VolumeLevelHandler &handler)
- {
- m_volumeLevelEvent -= handler;
- }
-
- int SoundManager::getMaxVolume() const
- {
- int maxVol = 0;
- if (getAudioState() == AudioStateType::BT) {
- if (isBTSupported()) {
- maxVol = m_btManager->getMaxVolume();
- } else {
- ELOG("BT is not supported");
- }
- } else {
- auto ret = sound_manager_get_max_volume(SOUND_TYPE_CALL, &maxVol);
- if (ret != SOUND_MANAGER_ERROR_NONE) {
- LOG_RETURN_VALUE(RES_FAIL, 0,
- "Get max volume failed. ret[%d]", ret);
- }
- }
- DLOG("Max volume [%d]", maxVol);
- return maxVol;
- }
-
- int SoundManager::getVolume() const
- {
- int vol = 0;
- if (getAudioState() == AudioStateType::BT) {
- if (isBTSupported()) {
- vol = m_btManager->getVolume();
- } else {
- ELOG("BT is not supported");
- }
- } else {
- auto ret = sound_manager_get_volume(SOUND_TYPE_CALL, &vol);
- if (ret != SOUND_MANAGER_ERROR_NONE) {
- LOG_RETURN_VALUE(RES_FAIL, 0,
- "Get volume failed. ret[%d]", ret);
- }
- }
- DLOG("Current volume [%d]", vol);
- return vol;
- }
-
- Result SoundManager::setVolume(int value)
- {
- if (getAudioState() == AudioStateType::BT) {
- if (isBTSupported()) {
- return m_btManager->setVolume(value);
- } else {
- LOG_RETURN(RES_FAIL, "BT is not supported");
- }
- } else {
- auto ret = sound_manager_set_volume(SOUND_TYPE_CALL, value);
- if (ret != SOUND_MANAGER_ERROR_NONE) {
- LOG_RETURN(RES_FAIL,
- "sound_manager_set_volume() failed. ret[%d]", ret);
- }
- }
- return RES_OK;
- }
-
- bool SoundManager::isBTSupported() const
- {
- return (m_btManager != nullptr);
- }
-
- bool SoundManager::isBTHeadsetConnected() const
- {
- return (isBTSupported() ? m_btManager->isHeadsetConnected() : false);
- }
-
- void SoundManager::addBTHeadsetConnectionChangeHandler(
- const NotiHandler &handler)
- {
- m_btVoiceDeviceConnEvent += handler;
- }
-
- void SoundManager::delBTHeadsetConnectionChangeHandler(
- const NotiHandler &handler)
- {
- m_btVoiceDeviceConnEvent -= handler;
- }
-
- void SoundManager::onGearVolumeChanged(sound_type_e type, unsigned int volume)
- {
- DLOG("Volume [%d]", volume);
- if (type != SOUND_TYPE_CALL) {
- ILOG("Ignored. Not type Call.");
- return;
- }
-
- if (getAudioState() != AudioStateType::BT) {
- m_volumeLevelEvent.dispatch(volume);
- }
- }
-
- void SoundManager::onBTHeadsetVolumeChanged(int volume)
- {
- DLOG("Volume [%d]", volume);
-
- if (getAudioState() == AudioStateType::BT) {
- m_volumeLevelEvent.dispatch(volume);
- }
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_SOUND_MANAGER_H__
-#define __CALLUI_MODEL_SOUND_MANAGER_H__
-
-#include <call-manager-ext.h>
-#include <sound_manager.h>
-
-#include "model/ISoundManager.h"
-
-#include "implTypes.h"
-
-namespace callui {
-
- class SoundManager final :
- public ucl::RefCountAware,
- public ISoundManager {
- public:
- static SoundManagerSRef newInstance(const CallClientSRef &client);
- virtual ~SoundManager();
-
- // ISoundManager
-
- virtual ucl::Result setSpeakerState(bool isEnable) override final;
- virtual ucl::Result setBluetoothState(bool isEnable) override final;
- virtual AudioStateType getAudioState() const override final;
-
- virtual ucl::Result setMuteState(bool isEnable) override final;
- virtual bool getMuteState() const override final;
-
- virtual ucl::Result startDtmf(
- const unsigned char dtmfDigit) override final;
- virtual ucl::Result stopDtmf() override final;
-
- virtual void addAudioStateHandler(
- const AudioStateHandler &handler) override final;
- virtual void delAudioStateHandler(
- const AudioStateHandler &handler) override final;
-
- virtual void addMuteStateHandler(
- const MuteStateHandler &handler) override final;
- virtual void delMuteStateHandler(
- const MuteStateHandler &handler) override final;
-
- virtual void addVolumeStateHandler(
- const VolumeLevelHandler &handler) override final;
- virtual void delVolumeStateHandler(
- const VolumeLevelHandler &handler) override final;
-
- virtual int getMaxVolume() const override final;
- virtual int getVolume() const override final;
- virtual ucl::Result setVolume(int value) override final;
-
- virtual bool isBTSupported() const override final;
-
- virtual bool isBTHeadsetConnected() const override final;
- virtual void addBTHeadsetConnectionChangeHandler(
- const NotiHandler &handler) override final;
- virtual void delBTHeadsetConnectionChangeHandler(
- const NotiHandler &handler) override final;
-
- private:
- friend class ucl::ReffedObj<SoundManager>;
- SoundManager(ucl::IRefCountObj &rc, const CallClientSRef &client);
-
- ucl::Result prepare();
- ucl::Result registerCallbacks();
-
- void onAudioStateChanged(cm_audio_state_type_e state);
- void onMuteStateChanged(cm_mute_status_e status);
- void onHeadsetConnectionChanged();
-
- void onBTHeadsetVolumeChanged(int volume);
- void onGearVolumeChanged(sound_type_e type, unsigned int volume);
-
- private:
- CallClientSRef m_client;
- BluetoothManagerSRef m_btManager;
- AudioStateEvent m_audioStateEvent;
- MuteStateEvent m_muteStateEvent;
- VolumeLevelEvent m_volumeLevelEvent;
- ucl::Event<NotiHandler> m_btVoiceDeviceConnEvent;
- int m_deviceVolumeCbID;
- };
-
-}
-
-#endif // __CALLUI_MODEL_SOUND_MANAGER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "VoiceControlStateProvider.h"
-
-#include "common.h"
-
-// Temporary until VCONFLAG will not be added to a system
-#define VCONFKEY_CISSAPPL_CALL_VOICE_ANSWER VCONFKEY_CISSAPPL_ANSWERING_KEY_BOOL
-
-namespace callui {
-
- using namespace ucl;
-
- VoiceControlStateProvider::VoiceControlStateProvider():
- m_enableState(false)
- {
- }
-
- VoiceControlStateProvider::~VoiceControlStateProvider()
- {
- delSysStateCallback();
- }
-
- VoiceControlStateProviderSRef VoiceControlStateProvider::newInstance()
- {
- auto result = makeShared<VoiceControlStateProvider>();
- FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
- return result;
- }
-
- Result VoiceControlStateProvider::prepare()
- {
- FAIL_RETURN(addSysStateCallback(),
- "addSysStateCallbacks() failed!");
-
- FAIL_RETURN(initState(), "initState() failed!");
- return RES_OK;
- }
-
- Result VoiceControlStateProvider::initState()
- {
- auto val = 0;
- if (vconf_get_bool(VCONFKEY_CISSAPPL_CALL_VOICE_ANSWER, &val) != 0) {
- LOG_RETURN(RES_FAIL, "vconf_get_bool() failed!");
- }
- updateState(val);
-
- return RES_OK;
- }
-
- bool VoiceControlStateProvider::getState() const
- {
- return m_enableState;
- }
-
- void VoiceControlStateProvider::addStateChangeHandler(
- const NotiHandler &handler)
- {
- m_event += handler;
- }
-
- void VoiceControlStateProvider::removeStateChangeHandler(
- const NotiHandler &handler)
- {
- m_event -= handler;
- }
-
- Result VoiceControlStateProvider::addSysStateCallback()
- {
- if (vconf_notify_key_changed(VCONFKEY_CISSAPPL_CALL_VOICE_ANSWER,
- CALLBACK_B(VoiceControlStateProvider::onStateChanged),
- this) != 0) {
- LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
- }
- return RES_OK;
- }
-
- void VoiceControlStateProvider::delSysStateCallback()
- {
- vconf_ignore_key_changed(VCONFKEY_CISSAPPL_CALL_VOICE_ANSWER,
- CALLBACK_B(VoiceControlStateProvider::onStateChanged));
- }
-
- void VoiceControlStateProvider::onStateChanged(
- keynode_t *node)
- {
- auto val = 0;
- if (vconf_get_bool(VCONFKEY_CISSAPPL_CALL_VOICE_ANSWER, &val) != 0) {
- LOG_RETURN_VOID(RES_FAIL, "vconf_get_bool() failed!");
- }
-
- if (updateState(val) && !m_event.isEmpty()) {
- m_event.dispatch();
- }
- }
-
- bool VoiceControlStateProvider::updateState(bool isEnable)
- {
- if (m_enableState != isEnable) {
- m_enableState = isEnable;
- return true;
- }
- return false;
- }
-
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_VOICE_CONTROL_STATE_PROVIDER_H__
-#define __CALLUI_MODEL_VOICE_CONTROL_STATE_PROVIDER_H__
-
-#include <vconf.h>
-
-#include "implTypes.h"
-
-namespace callui {
-
- class VoiceControlStateProvider final {
- public:
- static VoiceControlStateProviderSRef newInstance();
- virtual ~VoiceControlStateProvider();
-
- bool getState() const;
- void addStateChangeHandler(const NotiHandler &handler);
- void removeStateChangeHandler(const NotiHandler &handler);
-
- private:
- friend class ucl::ReffedObj<VoiceControlStateProvider>;
- VoiceControlStateProvider();
-
- ucl::Result prepare();
-
- ucl::Result addSysStateCallback();
- void delSysStateCallback();
- ucl::Result initState();
- bool updateState(bool isEnable);
-
- void onStateChanged(keynode_t *node);
-
- private:
- bool m_enableState;
- ucl::Event<NotiHandler> m_event;
- };
-
-}
-
-#endif // __CALLUI_MODEL_VOICE_CONTROL_STATE_PROVIDER_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "VoiceControlStateSource.h"
-
-#include "VoiceControlStateProvider.h"
-
-#include "common.h"
-
-namespace callui {
-
- using namespace ucl;
-
- VoiceControlStateSource::Bits::Bits():
- property(convertEnumValueToInt(IndicatorProperty::VOICE_CONTROL)),
- isEnable(0)
- {
- }
-
- VoiceControlStateSource::Bits::Bits(const IndicatorState &state):
- value(state.value)
- {
- if (property != convertEnumValueToInt(
- IndicatorProperty::VOICE_CONTROL)) {
- ELOG("State of incorrect property type [%d]", property);
- *this = {};
- }
- }
-
- VoiceControlStateSource::VoiceControlStateSource(IRefCountObj &rc,
- const VoiceControlStateProviderSRef &provider):
- RefCountAware(&rc),
- m_vcProvider(provider)
- {
- m_vcProvider->addStateChangeHandler(WEAK_DELEGATE(
- VoiceControlStateSource::onStateChangedEvent,
- asWeak(*this)));
-
- updateStateBits(m_vcProvider->getState());
- }
-
- VoiceControlStateSource::~VoiceControlStateSource()
- {
- m_vcProvider->removeStateChangeHandler(WEAK_DELEGATE(
- VoiceControlStateSource::onStateChangedEvent,
- asWeak(*this)));
- }
-
- VoiceControlStateSourceSRef VoiceControlStateSource::newInstance(
- const VoiceControlStateProviderSRef &provider)
- {
- if (!provider) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "provider is NULL");
- }
-
- return makeShared<VoiceControlStateSource>(provider);
- }
-
- void VoiceControlStateSource::onStateChangedEvent()
- {
- if (updateStateBits(m_vcProvider->getState()) && m_handler) {
- m_handler();
- }
- }
-
- Result VoiceControlStateSource::initState()
- {
- updateStateBits(m_vcProvider->getState());
- return RES_OK;
- }
-
- IndicatorState VoiceControlStateSource::getState() const
- {
- return {m_bits.value};
- }
-
- void VoiceControlStateSource::setStateChangeHandler(
- const NotiHandler &handler)
- {
- m_handler = handler;
- }
-
- bool VoiceControlStateSource::updateStateBits(bool isEnable)
- {
- if (m_bits.isEnable != isEnable) {
- m_bits.isEnable = isEnable;
- return true;
- }
- return false;
- }
-
- bool getVoiceControlState(IndicatorState state)
- {
- return VoiceControlStateSource::Bits(state).isEnable;
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_VOICE_CONTROL_STATE_SOURCE_H__
-#define __CALLUI_VOICE_CONTROL_STATE_SOURCE_H__
-
-#include "IIndicatorStateSource.h"
-
-#include <vconf.h>
-
-#include "implTypes.h"
-
-namespace callui {
-
- class VoiceControlStateSource final :
- public IIndicatorStateSource,
- public ucl::RefCountAware {
- public:
- static VoiceControlStateSourceSRef newInstance(
- const VoiceControlStateProviderSRef &provider);
- virtual ~VoiceControlStateSource();
-
- // IIndicatorStateSource
-
- virtual IndicatorState getState() const override final;
- virtual void setStateChangeHandler(
- const NotiHandler &handler) override final;
-
- private:
- friend class ucl::ReffedObj<VoiceControlStateSource>;
- VoiceControlStateSource(ucl::IRefCountObj &rc,
- const VoiceControlStateProviderSRef &provider);
-
- ucl::Result prepare();
-
- void onStateChangedEvent();
- ucl::Result initState();
- bool updateStateBits(bool isEnable);
-
- public:
- union Bits {
- struct {
- uint8_t property : 4;
- uint8_t isEnable : 1;
- };
- uint64_t value;
-
- Bits();
- Bits(const IndicatorState &state);
- };
-
- private:
- Bits m_bits;
- NotiHandler m_handler;
- VoiceControlStateProviderSRef m_vcProvider;
- };
-
-}
-
-#endif // __CALLUI_VOICE_ANSWER_STATE_SOURCE_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_COMMON_H__
-#define __CALLUI_MODEL_COMMON_H__
-
-#include "../common.h"
-
-#include "helpers.h"
-
-#endif // __CALLUI_MODEL_COMMON_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_HELPERS_H__
-#define __CALLUI_MODEL_HELPERS_H__
-
-#include <call-manager-ext.h>
-#include <type_traits>
-
-#include "implTypes.h"
-
-namespace callui {
-
- ucl::Result convertCMResult(int cmRes);
-
- AudioStateType convertCMAudioState(cm_audio_state_type_e state);
-
- cm_multi_sim_slot_type_e convertCUISimSlot(SimSlot slot);
-
- SimSlot convertCMSimSlot(cm_multi_sim_slot_type_e slot);
-
- cm_call_release_type_e convertCUICallReleaseType(CallReleaseType type);
-
- ucl::Result convertCMEventType(cm_call_event_e cmEvent, CallEventType *appEvent);
-
- cm_call_answer_type_e convertCUICallAnswerType(CallAnswerType type);
-
- bool isFlightModeActive();
-
- template<typename TYPE>
- constexpr auto convertEnumValueToInt(TYPE e) -> typename std::underlying_type<TYPE>::type
- {
- return static_cast<typename std::underlying_type<TYPE>::type>(e);
- }
-}
-
-#include "helpers.hpp"
-
-#endif // __CALLUI_MODEL_HELPERS_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 <call-manager.h>
-#include <vconf.h>
-
-namespace callui {
-
- inline ucl::Result convertCMResult(int cmRes)
- {
- switch (cmRes) {
- case CM_ERROR_NONE: return ucl::RES_OK;
- case CM_ERROR_OUT_OF_MEMORY: return ucl::RES_OUT_OF_MEMORY;
- case CM_ERROR_INVALID_PARAMETER: return ucl::RES_INVALID_ARGUMENTS;
- case CM_ERROR_PERMISSION_DENIED: return RES_PERMISSION_DENIED;
- case CM_ERROR_NOT_SUPPORTED: return ucl::RES_NOT_SUPPORTED;
- case CM_ERROR_NOT_REGISTERED: return ucl::RES_FATAL;
- case CM_ERROR_ALREADY_REGISTERED: return RES_ALREADY_REGISTERED;
- case CM_ERROR_OPERATION_FAILED: return RES_OPERATION_FAILED;
- default:
- return ucl::RES_FALSE;
- }
- }
-
- inline AudioStateType convertCMAudioState(cm_audio_state_type_e state)
- {
- switch (state) {
- case CM_AUDIO_STATE_NONE_E: return AudioStateType::NONE;
- case CM_AUDIO_STATE_SPEAKER_E: return AudioStateType::SPEAKER;
- case CM_AUDIO_STATE_RECEIVER_E: return AudioStateType::RECEIVER;
- case CM_AUDIO_STATE_EARJACK_E: return AudioStateType::EARJACK;
- case CM_AUDIO_STATE_BT_E: return AudioStateType::BT;
- default:
- return AudioStateType::NONE;
- }
- }
-
- inline cm_multi_sim_slot_type_e convertCUISimSlot(SimSlot slot)
- {
- // TODO: this must be changed after Companion mode will be provided
- return CM_MULTI_SIM_SLOT_DEFAULT;
- }
-
- inline SimSlot convertCMSimSlot(cm_multi_sim_slot_type_e slot)
- {
- // TODO: this must be changed after Companion mode will be provided
- return SimSlot::GEAR;
- }
-
- inline cm_call_release_type_e convertCUICallReleaseType(CallReleaseType type)
- {
- switch (type) {
- case CallReleaseType::BY_CALL_HANDLE: return CM_CALL_RELEASE_TYPE_BY_CALL_HANDLE;
- case CallReleaseType::ALL: return CM_CALL_RELEASE_TYPE_ALL_CALLS;
- case CallReleaseType::ALL_HOLD: return CM_CALL_RELEASE_TYPE_ALL_HOLD_CALLS;
- case CallReleaseType::ALL_ACTIVE: return CM_CALL_RELEASE_TYPE_ALL_ACTIVE_CALLS;
- default:
- return CM_CALL_RELEASE_TYPE_BY_CALL_HANDLE;
- }
- }
-
- inline ucl::Result convertCMEventType(cm_call_event_e cmEvent, CallEventType *appEvent)
- {
- switch (cmEvent) {
- case CM_CALL_EVENT_IDLE:
- *appEvent = CallEventType::END;
- break;
- case CM_CALL_EVENT_DIALING:
- *appEvent = CallEventType::DIALING;
- break;
- case CM_CALL_EVENT_ACTIVE:
- *appEvent = CallEventType::ACTIVE;
- break;
- case CM_CALL_EVENT_HELD:
- *appEvent = CallEventType::HELD;
- break;
- case CM_CALL_EVENT_ALERT:
- *appEvent = CallEventType::ALERT;
- break;
- case CM_CALL_EVENT_INCOMING:
- *appEvent = CallEventType::INCOMING;
- break;
- case CM_CALL_EVENT_WAITING:
- *appEvent = CallEventType::WAITING;
- break;
- case CM_CALL_EVENT_JOIN:
- *appEvent = CallEventType::JOIN;
- break;
- case CM_CALL_EVENT_SPLIT:
- *appEvent = CallEventType::SPLIT;
- break;
- case CM_CALL_EVENT_SWAPPED:
- *appEvent = CallEventType::SWAPPED;
- break;
- case CM_CALL_EVENT_RETRIEVED:
- *appEvent = CallEventType::RETRIEVED;
- break;
- case CM_CALL_EVENT_SAT_CALL_CONTROL:
- *appEvent = CallEventType::SAT_CALL_CONTROL;
- break;
- default:
- return ucl::RES_FAIL;
- }
- return ucl::RES_OK;
- }
-
- inline cm_call_answer_type_e convertCUICallAnswerType(CallAnswerType type)
- {
- switch (type) {
- case CallAnswerType::NORMAL: return CALL_ANSWER_TYPE_NORMAL;
- case CallAnswerType::HOLD_ACTIVE_AND_ACCEPT: return CALL_ANSWER_TYPE_HOLD_ACTIVE_AND_ACCEPT;
- case CallAnswerType::RELEASE_ACTIVE_AND_ACCEPT: return CALL_ANSWER_TYPE_RELEASE_ACTIVE_AND_ACCEPT;
- case CallAnswerType::RELEASE_HOLD_AND_ACCEPT: return CALL_ANSWER_TYPE_RELEASE_HOLD_AND_ACCEPT;
- case CallAnswerType::RELEASE_ALL_AND_ACCEPT: return CALL_ANSWER_TYPE_RELEASE_ALL_AND_ACCEPT;
- default:
- return CALL_ANSWER_TYPE_NORMAL;
- }
- }
-
- inline bool isFlightModeActive()
- {
- int status = false;;
- if (vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &status) != 0) {
- ELOG("Get Flight mode status failed!");
- return false;
- }
- return status;
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_MODEL_IMPL_TYPES_H__
-#define __CALLUI_MODEL_IMPL_TYPES_H__
-
-#include "model/types.h"
-#include "ucl/misc/Event.h"
-#include "ucl/util/smartDelegation.h"
-
-namespace callui {
-
- enum class CallReleaseType {
- BY_CALL_HANDLE,
- ALL,
- ALL_HOLD,
- ALL_ACTIVE
- };
-
- enum class CallManagerErr {
- DIAL_CANCEL,
- DIAL_FAIL,
- DIAL_FAIL_SS,
- DIAL_FAIL_FDN,
- DIAL_FLIGHT_MODE
- };
-
- UCL_DECLARE_REF_ALIASES(CallClient);
-
- UCL_DECLARE_REF_ALIASES(SoundManager);
- UCL_DECLARE_REF_ALIASES(CallManager);
-
- UCL_DECLARE_REF_ALIASES(ICallManagerListener);
-
- UCL_DECLARE_REF_ALIASES(IncomingCall);
- UCL_DECLARE_REF_ALIASES(ActiveCall);
- UCL_DECLARE_REF_ALIASES(HeldCall);
- UCL_DECLARE_REF_ALIASES(EndCall);
-
- UCL_DECLARE_REF_ALIASES(CallInfo);
- UCL_DECLARE_REF_ALIASES(ContactInfo);
- UCL_DECLARE_REF_ALIASES(ConferenceCallInfo);
-
- UCL_DECLARE_REF_ALIASES(MsgClient);
- UCL_DECLARE_REF_ALIASES(RejectMsgProvider);
- UCL_DECLARE_REF_ALIASES(RejectMsg);
-
- UCL_DECLARE_REF_ALIASES(IndicatorStateProvider);
- UCL_DECLARE_REF_ALIASES(IIndicatorStateSource);
-
- UCL_DECLARE_REF_ALIASES(ConnectionStateSource);
- UCL_DECLARE_REF_ALIASES(RssiStateSource);
- UCL_DECLARE_REF_ALIASES(BatteryStateSource);
- UCL_DECLARE_REF_ALIASES(SimSlotStateSource);
- UCL_DECLARE_REF_ALIASES(HdVoiceStateSource);
- UCL_DECLARE_REF_ALIASES(VoiceControlStateSource);
-
- UCL_DECLARE_REF_ALIASES(VoiceControlStateProvider);
-
- UCL_DECLARE_REF_ALIASES(ContactInfoProvider);
-
- UCL_DECLARE_REF_ALIASES(BluetoothManager);
-
- using AudioStateEvent = ucl::Event<AudioStateHandler>;
- using MuteStateEvent = ucl::Event<MuteStateHandler>;
- using VolumeLevelEvent = ucl::Event<VolumeLevelHandler>;
-
- using BluetoothVolumeHandler = ucl::WeakDelegate<void(int)>;
-}
-
-#endif // __CALLUI_MODEL_IMPL_TYPES_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "presenters/AcceptDialog.h"
-
-#include "resources.h"
-#include "common.h"
-
-namespace callui { namespace { namespace impl {
-
- using namespace ucl;
-
- constexpr ElmStyle POPUP_STYLE {"circle"};
-
- constexpr SmartEvent POPUP_DISMISSED {"dismissed"};
-
- constexpr EdjePart PART_SWL_CONTENT{"elm.swallow.content"};
-
- void *asData(const AcceptDialogEvent event)
- {
- return reinterpret_cast<void *>(static_cast<intptr_t>(event));
- }
-
- AcceptDialogEvent asEvent(void *const data)
- {
- return static_cast<AcceptDialogEvent>(
- reinterpret_cast<intptr_t>(data));
- }
-
-}}}
-
-namespace callui {
-
- using namespace ucl;
-
- AcceptDialog::Builder::Builder()
- {
- }
-
- AcceptDialog::Builder::~Builder()
- {
- }
-
- AcceptDialog::Builder &
- AcceptDialog::Builder::setHandler(AcceptDialogHandler handler)
- {
- m_handler = handler;
- return *this;
- }
-
- AcceptDialogWRef AcceptDialog::Builder::build(ElmWidget &parent) const
- {
- if (!m_handler) {
- LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_handler is NULL");
- }
-
- auto result = makeShared<AcceptDialog>(m_handler);
- FAIL_RETURN_VALUE(result->prepare(parent), {},
- "result->prepare() failed!");
-
- return result;
- }
-
- AcceptDialog::AcceptDialog(IRefCountObj &rc,
- const AcceptDialogHandler &handler):
- GuiPresenter(rc),
- m_handler(handler),
- m_isDismissed(false)
- {
- }
-
- AcceptDialog::~AcceptDialog()
- {
- }
-
- Result AcceptDialog::prepare(ElmWidget &parent)
- {
- FAIL_RETURN(GuiPresenter::prepare(parent, PF_DEACTIVATOR),
- "Presenter::prepare() failed!");
-
- FAIL_RETURN(createPopup(parent, impl::POPUP_STYLE),
- "createPopup() failed!");
-
- FAIL_RETURN(createGenlist(),
- "createGenlist() failed!");
-
- m_selfRef = asShared(*this);
-
- addDeactivatorException(this);
- broadcastDeactivate();
-
- return RES_OK;
- }
-
- Result AcceptDialog::createPopup(ElmWidget &parent, ElmStyle style)
- {
- Evas_Object *const popupEo = elm_popup_add(parent);
- if (!popupEo) {
- LOG_RETURN(RES_FAIL, "elm_popup_add() failed!");
- }
- m_popup = makeShared<StyledWidget>(popupEo, true);
- m_popup->setStyle(style);
- m_popup->setWeight(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- show(*m_popup);
-
- m_popup->addEventHandler(impl::POPUP_DISMISSED, WEAK_DELEGATE(
- AcceptDialog::onPopupDismissed, asWeak(*this)));
-
- eext_object_event_callback_add(*m_popup, EEXT_CALLBACK_BACK,
- CALLBACK_A(AcceptDialog::onPopupHWBackKey), this);
-
- return RES_OK;
- }
-
- void AcceptDialog::onGenlistItemClickedCb(Evas_Object *obj, void *eventInfo)
- {
- if (!eventInfo)
- LOG_RETURN_VOID(RES_FAIL, "eventInfo is NULL");
-
- Elm_Object_Item *item = static_cast<Elm_Object_Item *>(eventInfo);
- handleEvent(impl::asEvent(elm_object_item_data_get(item)));
- }
-
- Result AcceptDialog::createGenlist()
- {
- Evas_Object *const glEo = elm_genlist_add(*m_popup);
- if (!glEo) {
- LOG_RETURN(RES_FAIL, "elm_genlist_add() failed!");
- }
- elm_genlist_mode_set(glEo, ELM_LIST_COMPRESS);
- elm_genlist_homogeneous_set(glEo, EINA_TRUE);
-
- m_genlist = makeShared<StyledWidget>(glEo);
- m_genlist->setWeight(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- m_genlist->setAlign(EVAS_HINT_FILL, EVAS_HINT_FILL);
-
- Evas_Object *circleGlEo = eext_circle_object_genlist_add(glEo,
- utils::getCircleSurface(*m_genlist));
- eext_circle_object_genlist_scroller_policy_set(circleGlEo,
- ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
- eext_rotary_object_event_activated_set(circleGlEo, EINA_TRUE);
-
- FAIL_RETURN(fillGenlist(), "fillGenlist() failed!");
-
- m_popup->setContent(glEo, impl::PART_SWL_CONTENT);
-
- return RES_OK;
- }
-
- Result AcceptDialog::addGenlistTitleItem()
- {
- static Elm_Genlist_Item_Class titleItc =
- utils::createGenlistItemClass("title",
- [](void *data, Evas_Object *obj, const char *part) -> char * {
- return strdup(STR_ANSWER_CALL.translate());
- });
-
- Elm_Object_Item *item = elm_genlist_item_append(*m_genlist, &titleItc,
- nullptr,
- nullptr,
- ELM_GENLIST_ITEM_NONE,
- nullptr,
- nullptr);
- if (!item)
- LOG_RETURN(RES_FAIL, "elm_genlist_item_append() failed!");
-
- return RES_OK;
- }
-
- Result AcceptDialog::addGenlistTextItem(AcceptDialogEvent event)
- {
- static Elm_Genlist_Item_Class textItc =
- utils::createGenlistItemClass("1text.1icon",
- [](void *data, Evas_Object *obj, const char *part) -> char * {
- switch (impl::asEvent(data)) {
- case AcceptDialogEvent::HOLD_AND_ACCEPT:
- return strdup(STR_HOLD_AND_ACCEPT.translate());
- case AcceptDialogEvent::END_AND_ACCEPT:
- return strdup(STR_END_AND_ACCEPT.translate());
- default:
- return nullptr;
- }
- });
-
- Elm_Object_Item *item = elm_genlist_item_append(*m_genlist, &textItc,
- impl::asData(event),
- nullptr,
- ELM_GENLIST_ITEM_NONE,
- CALLBACK_A(AcceptDialog::onGenlistItemClickedCb),
- this);
- if (!item)
- LOG_RETURN(RES_FAIL, "elm_genlist_item_append() failed!");
-
- return RES_OK;
- }
-
- Result AcceptDialog::addGenlistBottomItem()
- {
- static Elm_Genlist_Item_Class paddingItc =
- utils::createGenlistItemClass("1text.1icon");
- Elm_Object_Item *item = elm_genlist_item_append(*m_genlist, &paddingItc,
- nullptr,
- nullptr,
- ELM_GENLIST_ITEM_NONE,
- nullptr,
- nullptr);
- if (!item)
- LOG_RETURN(RES_FAIL, "elm_genlist_item_append() failed!");
-
- return RES_OK;
- }
-
-
- Result AcceptDialog::fillGenlist()
- {
- FAIL_RETURN(addGenlistTitleItem(), "addGenlistTitleItem() failed!");
-
- FAIL_RETURN(addGenlistTextItem(AcceptDialogEvent::HOLD_AND_ACCEPT),
- "addGenlistTextItem() failed!");
-
- FAIL_RETURN(addGenlistTextItem(AcceptDialogEvent::END_AND_ACCEPT),
- "addGenlistTextItem() failed!");
-
- FAIL_RETURN(addGenlistBottomItem(), "addGenlistBottomItem() failed!");
-
- return RES_OK;
- }
-
- void AcceptDialog::handleEvent(AcceptDialogEvent event)
- {
- const auto keepAliver = asShared(*this);
- if (dispatchEvent(event)) {
- dismiss();
- }
- }
-
- bool AcceptDialog::dispatchEvent(AcceptDialogEvent event)
- {
- if (!m_handler) {
- WLOG("Handler was destroyed!");
- return true;
- }
- return m_handler(*this, event);
- }
-
- void AcceptDialog::onPopupDismissed(ucl::Widget &widget, void *eventInfo)
- {
- dispose();
- }
-
- void AcceptDialog::onPopupHWBackKey(Evas_Object *obj, void *eventInfo)
- {
- if (!m_isDismissed) {
- handleEvent(AcceptDialogEvent::BACK);
- }
- }
-
- void AcceptDialog::dismiss()
- {
- if (m_popup && !m_isDismissed) {
- m_isDismissed = true;
- deactivateBy(m_popup.get());
- elm_popup_dismiss(*m_popup);
- }
- }
-
- void AcceptDialog::dispose()
- {
- if (m_popup) {
-
- eext_object_event_callback_del(*m_popup, EEXT_CALLBACK_BACK,
- CALLBACK_A(AcceptDialog::onPopupHWBackKey));
-
- deactivateBy(m_popup.get());
- broadcastActivate();
-
- m_popup.reset();
-
- m_selfRef.reset();
- }
- }
-
- bool AcceptDialog::isDisposed() const
- {
- return (!m_popup);
- }
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "presenters/AcceptRejectPresenter.h"
-
-#include "model/IIncomingCall.h"
-#include "model/ISoundManager.h"
-
-#include "presenters/AcceptDialog.h"
-#include "presenters/MotionSensorPresenter.h"
-
-#include "view/AcceptRejectWidget.h"
-
-#include "common.h"
-
-namespace callui {
-
- using namespace ucl;
-
- // AcceptRejectPresenter::Builder
-
- AcceptRejectPresenter::Builder::Builder():
- m_callMask(CALL_FLAG_NONE)
- {
- }
-
- AcceptRejectPresenter::Builder::~Builder()
- {
- }
-
- AcceptRejectPresenter::Builder &
- AcceptRejectPresenter::Builder::setIncomingCall(
- const IIncomingCallSRef &call)
- {
- m_call = call;
- return *this;
- }
-
- AcceptRejectPresenter::Builder &
- AcceptRejectPresenter::Builder::setAvailableCallsFlag(CallMask mask)
- {
- m_callMask = mask;
- return *this;
- }
-
- AcceptRejectPresenter::Builder &
- AcceptRejectPresenter::Builder::setSoundManager(
- const ISoundManagerSRef &sm)
- {
- m_sm = sm;
- return *this;
- }
-
- AcceptRejectPresenter::Builder &
- AcceptRejectPresenter::Builder::setParentWidget(
- const ElmWidgetSRef &parentWidget)
- {
- m_parentWidget = parentWidget;
- return *this;
- }
-
- AcceptRejectPresenterSRef
- AcceptRejectPresenter::Builder::build(GuiPresenter &parent) const
- {
- if (!m_parentWidget || !m_call || !m_sm) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "Main params are not set");
- }
-
- auto result = makeShared<AcceptRejectPresenter>(m_call,
- m_callMask,
- m_sm);
- FAIL_RETURN_VALUE(result->prepare(parent, *m_parentWidget),
- {}, "result->prepare() failed!");
- return result;
- }
-
- // AcceptRejectPresenter
-
- AcceptRejectPresenter::AcceptRejectPresenter(IRefCountObj &rc,
- const IIncomingCallSRef &call,
- CallMask calls,
- const ISoundManagerSRef &sm):
- GuiPresenter(rc),
- m_call(call),
- m_callMask(calls),
- m_sm(sm)
- {
- }
-
- AcceptRejectPresenter::~AcceptRejectPresenter()
- {
- if (const auto popup = m_popup.lock()) {
- popup->dispose();
- }
-
- if (m_widget) {
- m_widget->deactivateRotary();
- }
-
- m_sm->delBTHeadsetConnectionChangeHandler(
- WEAK_DELEGATE(AcceptRejectPresenter::
- onBTHeadsetConnectionChanged,
- asWeak(*this)));
- }
-
- Result AcceptRejectPresenter::prepare(GuiPresenter &parent,
- ElmWidget &parentWidget)
- {
- FAIL_RETURN(GuiPresenter::prepare(parent),
- "Presenter::prepare() failed!");
-
- m_sm->addBTHeadsetConnectionChangeHandler(
- WEAK_DELEGATE(AcceptRejectPresenter::
- onBTHeadsetConnectionChanged,
- asWeak(*this)));
-
- FAIL_RETURN(createWidget(parentWidget),
- "createWidget() failed!");
-
- // Motion sensor not supported on Emulator
- if (createMotionSensorPresenter() != RES_OK) {
- ELOG("createMotionSensorPresenter() failed!");
- }
-
- return RES_OK;
- }
-
- Widget &AcceptRejectPresenter::getWidget()
- {
- return *m_widget;
- }
-
- void AcceptRejectPresenter::update(CallMask calls)
- {
- if (m_callMask != calls) {
- m_callMask = calls;
- if (const auto popup = m_popup.lock()) {
- m_widget->reset();
- popup->dismiss();
- }
- }
- }
-
- Result AcceptRejectPresenter::createWidget(ElmWidget &parent)
- {
- m_widget = AcceptRejectWidget::Builder().
- setAcceptEventHandler(WEAK_DELEGATE(
- AcceptRejectPresenter::onAcceptEvent,
- asWeak(*this))).
- setRejectEventHandler(WEAK_DELEGATE(
- AcceptRejectPresenter::onRejectEvent,
- asWeak(*this))).
- setAcceptBtnType(m_sm->isBTHeadsetConnected() ?
- AcceptButtonType::BT_HEADSET :
- AcceptButtonType::SIMPLE).
- build(parent);
- if (!m_widget) {
- LOG_RETURN(RES_FAIL, "Layout::build() failed!");
- }
-
- m_widget->activateRotary();
-
- return RES_OK;
- }
-
- Result AcceptRejectPresenter::createMotionSensorPresenter()
- {
- m_motionPrs = MotionSensorPresenter::Builder().
- build(WEAK_DELEGATE(AcceptRejectPresenter::onMotionEvent,
- asWeak(*this)));
-
- if (!m_motionPrs) {
- LOG_RETURN(RES_FAIL,
- "MotionSensorPresenter::build() failed!");
- }
-
- return RES_OK;
- }
-
- void AcceptRejectPresenter::onMotionEvent()
- {
- m_widget->startBezelCueAnimation();
- }
-
- void AcceptRejectPresenter::processAccept()
- {
- if (m_callMask & CALL_FLAG_ACTIVE) {
- if (m_callMask & CALL_FLAG_HELD) {
- m_call->answer(CallAnswerType::RELEASE_ACTIVE_AND_ACCEPT);
- } else {
- showPopup();
- }
- } else {
- m_call->answer(CallAnswerType::NORMAL);
- }
- }
-
- void AcceptRejectPresenter::processReject() const
- {
- m_call->reject();
- }
-
- bool AcceptRejectPresenter::onAcceptPopupEvent(AcceptDialog &popup,
- AcceptDialogEvent event)
- {
- m_widget->reset();
-
- switch (event) {
- case AcceptDialogEvent::HOLD_AND_ACCEPT:
- FAIL_RETURN_VALUE(
- m_call->answer(CallAnswerType::HOLD_ACTIVE_AND_ACCEPT),
- true,
- "incom->answer() failed!");
- return false;
- case AcceptDialogEvent::END_AND_ACCEPT:
- FAIL_RETURN_VALUE(
- m_call->answer(CallAnswerType::RELEASE_ACTIVE_AND_ACCEPT),
- true,
- "incom->answer() failed!");
- return false;
- default:
- return true;
- }
- }
-
- void AcceptRejectPresenter::showPopup()
- {
- if (!m_popup) {
- m_popup = AcceptDialog::Builder().
- setHandler(WEAK_DELEGATE(
- AcceptRejectPresenter::onAcceptPopupEvent,
- asWeak(*this))).
- build(*m_widget);
- } else {
- WLOG("Popup already shown!");
- }
- }
-
- void AcceptRejectPresenter::onAcceptEvent()
- {
- processAccept();
- }
-
- void AcceptRejectPresenter::onRejectEvent()
- {
- processReject();
- }
-
- void AcceptRejectPresenter::onActivate()
- {
- DLOG();
- m_widget->activateRotary();
- }
-
- void AcceptRejectPresenter::onDeactivate()
- {
- DLOG();
- m_widget->deactivateRotary();
- }
-
- void AcceptRejectPresenter::onBTHeadsetConnectionChanged()
- {
- m_widget->setAcceptBtnType(m_sm->isBTHeadsetConnected() ?
- AcceptButtonType::BT_HEADSET :
- AcceptButtonType::SIMPLE);
- }
-
- // Screen Reader
- ElmWidget *AcceptRejectPresenter::getAcceptAo()
- {
- return m_widget->getAcceptAo();
- }
-
- ElmWidget *AcceptRejectPresenter::getRejectAo()
- {
- return m_widget->getRejectAo();
- }
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "presenters/AccessoryPresenter.h"
-
-#include "ucl/appfw/types.h"
-
-#include "model/ISoundManager.h"
-#include "model/ICallManager.h"
-#include "model/IActiveCall.h"
-#include "model/IEndCall.h"
-#include "model/ICallInfo.h"
-
-#include "view/VolumeControl.h"
-
-#include "resources.h"
-#include "common.h"
-
-#define CU_APP_CONTROL_MIME_CONTACT "application/vnd.tizen.contact"
-
-namespace callui { namespace { namespace impl {
-
- using namespace ucl;
-
- constexpr LayoutTheme LAYOUT_ACCESSORY_WIDGET
- {"layout", "callui", "accessory"};
-
- constexpr EdjePart PART_SWL_VOLUME_SLIDER {"swl.volume_control"};
-
- constexpr EdjePart PART_SWL_SLOT1 {"swl.slot.1"};
- constexpr EdjePart PART_SWL_SLOT2 {"swl.slot.2"};
- constexpr EdjePart PART_SWL_SLOT3 {"swl.slot.3"};
-
- constexpr ElmStyle STYLE_BTN_VOLUME {"callui/volume"};
- constexpr ElmStyle STYLE_BTN_MUTE {"callui/mute"};
- constexpr ElmStyle STYLE_BTN_BT {"callui/bluetooth"};
- constexpr ElmStyle STYLE_BTN_ADD_CONTACT {"callui/add_contact"};
-
- constexpr EdjeSignal SIGNAL_TURN_ON {"turn.on"};
- constexpr EdjeSignal SIGNAL_TURN_OFF {"turn.off"};
-}}}
-
-namespace callui {
-
- using namespace ucl;
-
- AccessoryPresenter::Builder::Builder()
- {
- }
-
- AccessoryPresenter::Builder &
- AccessoryPresenter::Builder::setSoundManager(const ISoundManagerSRef &sm)
- {
- m_sm = sm;
- return *this;
- }
-
- AccessoryPresenter::Builder &
- AccessoryPresenter::Builder::setCallManager(const ICallManagerSRef &cm)
- {
- m_cm = cm;
- return *this;
- }
-
- AccessoryPresenter::Builder &
- AccessoryPresenter::Builder::setRequestExitHandler(const NotiHandler &handler)
- {
- m_exitHandler = handler;
- return *this;
- }
-
- AccessoryPresenter::Builder &
- AccessoryPresenter::Builder::setParentWidget(
- const ElmWidgetSRef &parentWidget)
- {
- m_parentWidget = parentWidget;
- return *this;
- }
-
- AccessoryPresenterSRef
- AccessoryPresenter::Builder::build(GuiPresenter &parent) const
- {
- if (!m_sm || !m_cm || !m_parentWidget) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "Main params are not set");
- }
-
- auto result = makeShared<AccessoryPresenter>(m_sm, m_exitHandler);
- FAIL_RETURN_VALUE(result->prepare(parent, *m_parentWidget, m_cm),
- {}, "result->prepare() failed!");
-
- return result;
- }
-
- AccessoryPresenter::AccessoryPresenter(IRefCountObj &rc,
- const ISoundManagerSRef &sm,
- const NotiHandler &handler):
- GuiPresenter(rc),
- m_sm(sm),
- m_vcTimer(nullptr),
- m_audioState(m_sm->getAudioState()),
- m_mode(ComponentsMode::UNDEFINED),
- m_exitHandler(handler),
- m_isVcShowOnRotaryEvent(false)
- {
- }
-
- AccessoryPresenter::~AccessoryPresenter()
- {
- stopVCTimer();
- unregisterCallbacks();
- }
-
- Result AccessoryPresenter::prepare(GuiPresenter &parent,
- ElmWidget &parentWidget, const ICallManagerSRef &cm)
- {
- FAIL_RETURN(GuiPresenter::prepare(parent),
- "Presenter::prepare() failed");
-
- FAIL_RETURN(createWidget(parentWidget),
- "createWidget() failed");
-
- FAIL_RETURN(createSlider(),
- "createSlider() failed");
-
- FAIL_RETURN(createVolumeControl(),
- "createVolumeControl() failed");
-
- updateVolume(m_sm->getVolume());
-
- registerCallbacks();
-
- updateMode(cm);
-
- FAIL_RETURN(updateModeRelativeComponents(cm),
- "updateComponents() failed");
-
- return RES_OK;
- }
-
- void AccessoryPresenter::updateMode(const ICallManagerSRef &cm)
- {
- m_mode = getCurrentMode(cm);
- }
-
- AccessoryPresenter::ComponentsMode AccessoryPresenter::getCurrentMode(
- const ICallManagerSRef &cm)
- {
- auto active = cm->getActiveCall();
- auto held = cm->getHeldCall();
- auto end = cm->getEndCall();
-
- if (active && active->isDialingMode()) {
- return ComponentsMode::OUTGOING;
- } else if (active || held) {
- return ComponentsMode::DURING;
- } else if (end) {
- return ComponentsMode::END;
- }
- return ComponentsMode::UNDEFINED;
- }
-
- void AccessoryPresenter::setVolumeSliderVisiblity(bool isVisible)
- {
- if (isVisible) {
- m_widget->setContent(*m_slider, impl::PART_SWL_VOLUME_SLIDER);
- show(*m_slider);
- } else {
- m_widget->unsetContent(impl::PART_SWL_VOLUME_SLIDER);
- hide(*m_slider);
- }
- }
-
- Result AccessoryPresenter::update(const ICallManagerSRef &cm)
- {
- updateMode(cm);
-
- FAIL_RETURN(updateModeRelativeComponents(cm),
- "updateModeRelativeComponents() failed");
-
- return RES_OK;
- }
-
- Result AccessoryPresenter::updateModeRelativeComponents(
- const ICallManagerSRef &cm)
- {
- m_volumeBtn.reset();
- m_muteBtn.reset();
- m_bluetoothBtn.reset();
- m_addContactBtn.reset();
- m_unsavedPhoneNumber.clear();
-
- setVolumeSliderVisiblity(m_mode != ComponentsMode::END);
-
- switch (m_mode) {
- case ComponentsMode::OUTGOING:
- case ComponentsMode::DURING:
- return setActiveCallCompomnents();
- case ComponentsMode::END:
- return setEndCallCompomnents(cm);
- default:
- return RES_OK;
- }
- return RES_OK;
- }
-
- Result AccessoryPresenter::setActiveCallCompomnents()
- {
- FAIL_RETURN(createVolumeBtn(), "createVolumeBtn() failed");
- m_widget->setContent(*m_volumeBtn, impl::PART_SWL_SLOT1);
-
- FAIL_RETURN(createMuteBtn(), "createMuteBtn create failed");
- m_widget->setContent(*m_muteBtn, impl::PART_SWL_SLOT3);
-
- FAIL_RETURN(createBluetoothBtn(), "createBluetoothBtn() failed");
- m_widget->setContent(*m_bluetoothBtn, impl::PART_SWL_SLOT2);
-
- if (m_mode == ComponentsMode::OUTGOING) {
- disable(*m_muteBtn);
- } else {
- enable(*m_muteBtn);
- }
-
- return RES_OK;
- }
-
- Result AccessoryPresenter::setEndCallCompomnents(const ICallManagerSRef &cm)
- {
- auto endCall = cm->getEndCall();
- if (!endCall) {
- FAIL_RETURN(RES_FAIL, "endCall is NULL");
- }
- auto callInfo = endCall->getInfo();
- if (!callInfo) {
- FAIL_RETURN(RES_FAIL, "callInfo is NULL");
- }
- if (!(callInfo->isEmergency())
- && !(callInfo->getConferenceMemberCount() > 1)
- && !(callInfo->getContactInfo())) {
- FAIL_RETURN(createAddContactBtn(), "createAddContactBtn() failed");
- m_widget->setContent(*m_addContactBtn, impl::PART_SWL_SLOT2);
- m_unsavedPhoneNumber = callInfo->getPhoneNumber();
- }
- return RES_OK;
- }
-
-
- Widget &AccessoryPresenter::getWidget()
- {
- return *m_widget;
- }
-
- void AccessoryPresenter::hideVolumeControls()
- {
- stopVCTimer();
- hide(*m_vc);
- }
-
- Result AccessoryPresenter::createWidget(ElmWidget &parent)
- {
- m_widget = Layout::Builder().
- setTheme(impl::LAYOUT_ACCESSORY_WIDGET).
- setIsOwner(true).
- build(parent);
- if (!m_widget) {
- LOG_RETURN(RES_FAIL, "Layout::build() failed!");
- }
-
- return RES_OK;
- }
-
- Result AccessoryPresenter::createSlider()
- {
- m_slider = Slider::Builder().
- setMaxValue(m_sm->getMaxVolume()).
- build(*m_widget);
- if (!m_slider) {
- LOG_RETURN(RES_FAIL, "Slider::build() failed");
- }
- m_widget->setContent(*m_slider, impl::PART_SWL_VOLUME_SLIDER);
-
- return RES_OK;
- }
-
- Result AccessoryPresenter::createVolumeControl()
- {
- m_vc = VolumeControl::Builder().
- setInfoText(STR_VOLUME).
- setMaxValue(m_sm->getMaxVolume()).
- setEventHandler(WEAK_DELEGATE(
- AccessoryPresenter::onVolumeControlEventCb,
- asWeak(*this))).
- build(*m_widget);
- if (!m_vc) {
- LOG_RETURN(RES_FAIL, "VolumeControl::build() failed");
- }
-
- auto window = m_vc->getWindow();
- if (!window) {
- LOG_RETURN(RES_FAIL, "Window is NULL!");
- }
- int w = 0, h = 0;
- window->getScreenSize(&w, &h);
-
- m_vc->move(0, 0);
- m_vc->resize(w, h);
- hide(*m_vc);
-
- registerVolumeControlAo();
-
- return RES_OK;
- }
-
- Result AccessoryPresenter::createVolumeBtn()
- {
- Evas_Object *eo = elm_button_add(*m_widget);
- if (!eo) {
- LOG_RETURN(RES_FAIL, "eo is NULL");
- }
-
- m_volumeBtn = makeShared<StyledWidget>(eo, true);
- m_volumeBtn->setStyle(impl::STYLE_BTN_VOLUME);
- m_volumeBtn->addEventHandler(BTN_CLICKED,
- WEAK_DELEGATE(AccessoryPresenter::onVolumeBtnClicked,
- asWeak(*this)));
- show(*m_volumeBtn);
-
- // Screen Reader
- elm_atspi_accessible_translation_domain_set(*m_volumeBtn, PACKAGE);
- elm_atspi_accessible_name_set(*m_volumeBtn, AO_STR_VOLUME);
-
- return RES_OK;
- }
-
- Result AccessoryPresenter::createMuteBtn()
- {
- Evas_Object *eo = elm_button_add(*m_widget);
- if (!eo) {
- LOG_RETURN(RES_FAIL, "eo is NULL");
- }
- m_muteBtn = makeShared<StyledWidget>(eo, true);
- m_muteBtn->setStyle(impl::STYLE_BTN_MUTE);
- m_muteBtn->addEventHandler(BTN_CLICKED,
- WEAK_DELEGATE(AccessoryPresenter::onMuteBtnClicked,
- asWeak(*this)));
-
- show(*m_muteBtn);
-
- // Screen Reader
- elm_atspi_accessible_translation_domain_set(*m_muteBtn, PACKAGE);
- elm_atspi_accessible_name_set(*m_muteBtn, AO_STR_MUTE);
-
- return RES_OK;
- }
-
- Result AccessoryPresenter::createBluetoothBtn()
- {
- Evas_Object *eo = elm_button_add(*m_widget);
- if (!eo) {
- LOG_RETURN(RES_FAIL, "eo is NULL");
- }
- m_bluetoothBtn = makeShared<StyledWidget>(eo, true);
- m_bluetoothBtn->setStyle(impl::STYLE_BTN_BT);
- m_bluetoothBtn->addEventHandler(BTN_CLICKED,
- WEAK_DELEGATE(AccessoryPresenter::onBluetoothBtnClicked,
- asWeak(*this)));
-
- show(*m_bluetoothBtn);
-
- // Screen Reader
- elm_atspi_accessible_translation_domain_set(*m_bluetoothBtn, PACKAGE);
- if (m_audioState == AudioStateType::BT) {
- m_bluetoothBtn->emit(impl::SIGNAL_TURN_ON);
- // Screen Reader
- elm_atspi_accessible_name_set(*m_bluetoothBtn,
- AO_STR_GEAR_SPK);
- } else {
- m_bluetoothBtn->emit(impl::SIGNAL_TURN_OFF);
- // Screen Reader
- elm_atspi_accessible_name_set(*m_bluetoothBtn,
- AO_STR_HEADSET);
- }
-
- if (!m_sm->isBTSupported()) {
- disable(*m_bluetoothBtn);
- }
-
- return RES_OK;
- }
-
- Result AccessoryPresenter::createAddContactBtn()
- {
- Evas_Object *eo = elm_button_add(*m_widget);
- if (!eo) {
- LOG_RETURN(RES_FAIL, "eo is NULL");
- }
- m_addContactBtn = makeShared<StyledWidget>(eo, true);
- m_addContactBtn->setStyle(impl::STYLE_BTN_ADD_CONTACT);
- m_addContactBtn->addEventHandler(BTN_CLICKED,
- WEAK_DELEGATE(AccessoryPresenter::onAddContactBtnClicked,
- asWeak(*this)));
- show(*m_addContactBtn);
-
- // Screen Reader
- elm_atspi_accessible_translation_domain_set(*m_addContactBtn, PACKAGE);
- elm_atspi_accessible_name_set(*m_addContactBtn,
- AO_STR_ADD_TO_CONTACTS);
-
- return RES_OK;
- }
-
- void AccessoryPresenter::onVolumeBtnClicked(Widget &widget, void *eventInfo)
- {
- if (!isActive()) {
- ILOG("Presenter is not active. Ignore");
- return;
- }
-
- show(*m_vc);
- startVCTimer();
-
- elm_atspi_component_highlight_grab(*m_vc);
- }
-
- void AccessoryPresenter::onMuteBtnClicked(Widget &widget, void *eventInfo)
- {
- if (!isActive()) {
- ILOG("Presenter is not active. Ignore");
- return;
- }
-
- m_sm->setMuteState(!m_sm->getMuteState());
- }
-
- void AccessoryPresenter::onBluetoothBtnClicked(Widget &widget,
- void *eventInfo)
- {
- if (m_audioState == AudioStateType::BT) {
- auto res = m_sm->setBluetoothState(false);
- if (res != RES_OK && res != RES_NOT_CONNECTED) {
- FAIL_RETURN_VOID(res, "setBluetoothState(false) failed");
- }
- } else {
- auto res = m_sm->setBluetoothState(true);
- if (res == RES_NOT_CONNECTED) {
- FAIL_RETURN_VOID(launchBluetoothSettings(),
- "launchBluetoothSettings() failed");
- } else {
- FAIL_RETURN_VOID(res, "setBluetoothState(true) failed");
- }
- }
- }
-
- Result AccessoryPresenter::launchBluetoothSettings()
- {
- AutoAppCtrl appCtrl;
-
- FAIL_RETURN(util::getNz(app_control_create, appCtrl),
- "app_control_create() failed!");
-
- FAIL_RETURN(util::call(app_control_set_app_id,
- appCtrl, "org.tizen.bluetooth"),
- "app_control_set_app_id() failed!");
-
- FAIL_RETURN(util::call(app_control_add_extra_data,
- appCtrl, "launch-type", "call"),
- "app_control_add_extra_data() failed!");
-
- FAIL_RETURN(util::call(app_control_send_launch_request,
- appCtrl, nullptr, nullptr),
- "app_control_send_launch_request() failed!");
-
- return RES_OK;
- }
-
- Result AccessoryPresenter::launchContacts()
- {
- AutoAppCtrl appCtrl;
-
- FAIL_RETURN(util::getNz(app_control_create, appCtrl),
- "app_control_create() failed!");
-
- FAIL_RETURN(util::call(app_control_set_operation,
- appCtrl, APP_CONTROL_OPERATION_ADD),
- "app_control_set_app_id() failed!");
-
- FAIL_RETURN(util::call(app_control_set_mime,
- appCtrl, CU_APP_CONTROL_MIME_CONTACT),
- "app_control_set_app_id() failed!");
-
- FAIL_RETURN(util::call(app_control_add_extra_data,
- appCtrl, APP_CONTROL_DATA_PHONE, m_unsavedPhoneNumber.c_str()),
- "app_control_add_extra_data() failed!");
-
- FAIL_RETURN(util::call(app_control_send_launch_request,
- appCtrl, nullptr, nullptr),
- "app_control_send_launch_request() failed!");
-
- return RES_OK;
- }
-
- void AccessoryPresenter::onAddContactBtnClicked(Widget &widget, void *eventInfo)
- {
- launchContacts();
-
- if (m_exitHandler) {
- m_exitHandler();
- }
- }
-
- void AccessoryPresenter::registerCallbacks()
- {
- addRotaryEventHandler(CALLBACK_A(
- AccessoryPresenter::onRotaryEvent), this);
-
- m_sm->addAudioStateHandler(DELEGATE(
- AccessoryPresenter::onAudioStateChanged, this));
-
- m_sm->addVolumeStateHandler(DELEGATE(
- AccessoryPresenter::onVolumeLevelChanged, this));
-
- m_sm->addMuteStateHandler(DELEGATE(
- AccessoryPresenter::onMuteStateChanged, this));
- }
-
- void AccessoryPresenter::unregisterCallbacks()
- {
- delRotaryEventHandler(
- CALLBACK_A(AccessoryPresenter::onRotaryEvent), this);
-
- m_sm->delAudioStateHandler(DELEGATE(
- AccessoryPresenter::onAudioStateChanged, this));
-
- m_sm->delVolumeStateHandler(DELEGATE(
- AccessoryPresenter::onVolumeLevelChanged, this));
-
- m_sm->delMuteStateHandler(DELEGATE(
- AccessoryPresenter::onMuteStateChanged, this));
- }
-
- Eina_Bool AccessoryPresenter::onVCTimerCb()
- {
- hide(*m_vc);
- m_vcTimer = nullptr;
-
- return ECORE_CALLBACK_CANCEL;
- }
-
- void AccessoryPresenter::startVCTimer()
- {
- stopVCTimer();
-
- auto timerInterval = CALL_VC_TIMER_INTERVAL;
- if (elm_atspi_bridge_utils_is_screen_reader_enabled()) {
- timerInterval = CALL_VC_SCREEN_READER_TIMER_INTERVAL;
- }
-
- m_vcTimer = ecore_timer_add(timerInterval,
- CALLBACK_B(AccessoryPresenter::onVCTimerCb),
- this);
- }
-
- void AccessoryPresenter::restartVCTimer()
- {
- if (m_vcTimer) {
- ecore_timer_reset(m_vcTimer);
- }
- }
-
- void AccessoryPresenter::stopVCTimer()
- {
- if (m_vcTimer) {
- ecore_timer_del(m_vcTimer);
- m_vcTimer = nullptr;
- }
- }
-
- Eina_Bool AccessoryPresenter::onRotaryEvent(Eext_Rotary_Event_Info *info)
- {
- if (!isActive()) {
- LOG_RETURN_VALUE(RES_OK, EINA_TRUE,
- "Presenter is not active. Ignore");
- }
-
- if (m_vcTimer) {
- restartVCTimer();
- } else {
- show(*m_vc);
- startVCTimer();
- m_isVcShowOnRotaryEvent = true;
- elm_atspi_component_highlight_grab(*m_vc);
- }
-
- if (m_isVcShowOnRotaryEvent) {
- m_isVcShowOnRotaryEvent = checkPossibilityToModifyVolume(
- m_sm->getVolume(),
- info->direction ==
- EEXT_ROTARY_DIRECTION_CLOCKWISE);
- }
-
- if (info->direction == EEXT_ROTARY_DIRECTION_CLOCKWISE) {
- tryIncreaseVolume();
- } else {
- tryDecreaseVolume();
- }
-
- return EINA_TRUE;
- }
-
- void AccessoryPresenter::onVolumeControlEventCb(VolumeControlEvent event)
- {
- if (!isActive()) {
- LOG_RETURN_VOID(RES_OK, "Presenter is not active. Ignore");
- }
-
- if (!m_vcTimer) {
- DLOG("Ignore as control is hidden");
- return;
- }
-
- restartVCTimer();
-
- switch (event) {
- case VolumeControlEvent::INCREASE:
- tryIncreaseVolume();
- break;
- case VolumeControlEvent::DECREASE:
- tryDecreaseVolume();
- break;
- default:
- break;
- }
- }
-
- bool AccessoryPresenter::checkPossibilityToModifyVolume(int volume, bool needIncrease)
- {
- if (needIncrease) {
- auto max = m_sm->getMaxVolume();
- return (max >= volume);
- } else {
- return (volume - 1 >= VOLUME_LEVEL_MIN);
- }
- return false;
- }
-
- void AccessoryPresenter::tryIncreaseVolume()
- {
- auto cur = m_sm->getVolume();
- if (checkPossibilityToModifyVolume(cur, true)) {
- FAIL_RETURN_VOID(m_sm->setVolume(cur + 1),
- "setVolume() failed");
- }
- }
-
- void AccessoryPresenter::tryDecreaseVolume()
- {
- auto cur = m_sm->getVolume();
- if (checkPossibilityToModifyVolume(cur, false)) {
- FAIL_RETURN_VOID(m_sm->setVolume(cur - 1),
- "setVolume() failed");
- }
- }
-
- void AccessoryPresenter::onAudioStateChanged(AudioStateType state)
- {
- if ((m_audioState != AudioStateType::BT &&
- state == AudioStateType::BT) ||
- (m_audioState == AudioStateType::BT &&
- state != AudioStateType::BT)) {
- m_audioState = state;
-
- m_vc->setValue(0);
- m_slider->setValue(0);
-
- auto maxVol = m_sm->getMaxVolume();
- m_vc->setMaxValue(maxVol);
- m_slider->setMaxValue(maxVol);
-
- updateVolume(m_sm->getVolume());
-
- if (m_bluetoothBtn) {
-
- if (m_audioState == AudioStateType::BT) {
- m_bluetoothBtn->emit(impl::SIGNAL_TURN_ON);
- // Screen Reader
- elm_atspi_accessible_name_set(*m_bluetoothBtn,
- AO_STR_GEAR_SPK);
- } else {
- m_bluetoothBtn->emit(impl::SIGNAL_TURN_OFF);
- // Screen Reader
- elm_atspi_accessible_name_set(*m_bluetoothBtn,
- AO_STR_HEADSET);
- }
- }
- }
- }
-
- void AccessoryPresenter::updateVolume(int value)
- {
- m_vc->setValue(value);
- m_slider->setValue(value);
-
- auto max = m_sm->getMaxVolume();
- auto cur = m_sm->getVolume();
-
- if (cur == max) {
- m_vc->setIncreaseBtnEnable(false);
- m_vc->setDecreaseBtnEnable(true);
- } else if (cur <= VOLUME_LEVEL_MIN) {
- m_vc->setIncreaseBtnEnable(true);
- m_vc->setDecreaseBtnEnable(false);
- } else {
- m_vc->setIncreaseBtnEnable(true);
- m_vc->setDecreaseBtnEnable(true);
- }
-
- // Screen Reader
- if (m_vc->isVisible()) {
- if (!m_isVcShowOnRotaryEvent) {
- elm_atspi_bridge_utils_say(std::to_string(cur).c_str(),
- EINA_FALSE, nullptr, nullptr);
- }
- m_isVcShowOnRotaryEvent = false;
- }
- }
-
- void AccessoryPresenter::onVolumeLevelChanged(int value)
- {
- updateVolume(value);
- }
-
- void AccessoryPresenter::onMuteStateChanged(bool isMuted)
- {
- if (!m_muteBtn) {
- return;
- }
- if (!elm_object_disabled_get(*m_muteBtn))
- updateMuteBtn(isMuted);
- }
-
- void AccessoryPresenter::updateMuteBtn(bool isMuted)
- {
- if (!m_muteBtn) {
- return;
- }
- isMuted ? m_muteBtn->emit(impl::SIGNAL_TURN_ON) :
- m_muteBtn->emit(impl::SIGNAL_TURN_OFF);
- }
-
- // Screen Reader
- ElmWidget *AccessoryPresenter::getVolumBtn()
- {
- return m_volumeBtn.get();
- }
-
- ElmWidget *AccessoryPresenter::getBluetoothBtn()
- {
- return m_bluetoothBtn.get();
- }
-
- ElmWidget *AccessoryPresenter::getMuteBtn()
- {
- return m_muteBtn.get();
- }
-
- ElmWidget *AccessoryPresenter::getAddContactBtn()
- {
- return m_addContactBtn.get();
- }
-
- ElmWidget *AccessoryPresenter::getVolumeControlLy()
- {
- return m_vc.get();
- }
-
- ElmWidget *AccessoryPresenter::getVolumeControlDecreaseBtn()
- {
- return m_vc->getDecreaseBtn();
- }
-
- ElmWidget *AccessoryPresenter::getVolumeControlIncreaseBtn()
- {
- return m_vc->getIncreaseBtn();
- }
-
- ElmWidget *AccessoryPresenter::getVolumeControlValueTxtAo()
- {
- return m_vc->getValueTxtAo();
- }
-
- void AccessoryPresenter::registerVolumeControlAo()
- {
- auto decrBtn = m_vc->getDecreaseBtn();
- if (decrBtn) {
- decrBtn->addEventHandler(ATSPI_HIGHLIGHTED,
- WEAK_DELEGATE(AccessoryPresenter::
- onVolumeControlScreenReaderReadStart,
- asWeak(*this)));
- }
-
- auto incrBtn = m_vc->getIncreaseBtn();
- if (incrBtn) {
- incrBtn->addEventHandler(ATSPI_HIGHLIGHTED,
- WEAK_DELEGATE(AccessoryPresenter::
- onVolumeControlScreenReaderReadStart,
- asWeak(*this)));
- }
- }
-
- void AccessoryPresenter::onVolumeControlScreenReaderReadStart(
- Widget &widget,
- void *eventInfo)
- {
- restartVCTimer();
- }
-
-}
-
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "presenters/AtspiHighlightHelper.h"
-
-#include "common.h"
-
-namespace callui { namespace { namespace impl {
-
- constexpr EoDataKey ATSPI_HELPER_DATA {"callui,atspi,highlight,helper"};
-}}}
-
-namespace callui {
-
- using ucl::AtspiGestureEventInfo;
-
- using ucl::ATSPI_ON_GESTURE;
-
- AtspiHighlightHelperSRef AtspiHighlightHelper::newInstance(
- GuiPresenter &parent, ElmWidget &rootWidget)
- {
- auto result = makeShared<AtspiHighlightHelper>();
-
- FAIL_RETURN_VALUE(result->prepare(parent, rootWidget), {},
- "result->prepare() failed!");
-
- return result;
- }
-
- AtspiHighlightHelper::AtspiHighlightHelper(IRefCountObj &rc) :
- GuiPresenter(rc)
- {
- }
-
- AtspiHighlightHelper::~AtspiHighlightHelper()
- {
- }
-
- Result AtspiHighlightHelper::prepare(GuiPresenter &parent,
- ElmWidget &rootWidget)
- {
- FAIL_RETURN(GuiPresenter::prepare(parent),
- "GuiPresenter::prepare() failed!");
-
- registerWidget(rootWidget);
-
- return RES_OK;
- }
-
- void AtspiHighlightHelper::setRelationEventHandler(RelationEventHandler handler)
- {
- m_relationEventHandler = handler;
- }
-
- void AtspiHighlightHelper::setGestureEventHandler(GestureEventHandler handler)
- {
- m_gestureEventHandler = handler;
- }
-
- void AtspiHighlightHelper::registerWidget(ElmWidget &widget)
- {
- DLOG("this [%p] widget [%p]", this, widget.getEo());
-
- widget.addEventHandler(ATSPI_ON_GESTURE, WEAK_DELEGATE(
- AtspiHighlightHelper::onAtspiGesture, asWeak(*this)));
- }
-
- void AtspiHighlightHelper::handleAtspiGesture(
- Elm_Interface_Atspi_Accessible *ao,
- AtspiGestureEventInfo &e)
- {
- DLOG("this [%p] ao [%p]", this, ao);
-
- if (e.stopPropagation) {
- DLOG("e.stopPropagation");
- return;
- }
-
- if (!isActive()) {
- DLOG("!isActive()");
- if (e.gestureInfo.type != ELM_ATSPI_GESTURE_ONE_FINGER_SINGLE_TAP) {
- e.preventDefault = true;
- }
- return;
- }
-
- e.stopPropagation = true;
-
- if (m_gestureEventHandler) {
- DLOG("m_gestureEventHandler");
- if (m_gestureEventHandler(ao, e.gestureInfo.type)) {
- e.preventDefault = true;
- return;
- }
- }
-
- e.preventDefault = false;
-
- if (!m_relationEventHandler) {
- DLOG("!m_relationEventHandler");
- return;
- }
-
- const Elm_Atspi_Relation_Type relation = getFlowRelation(e.gestureInfo);
- if (relation == ELM_ATSPI_RELATION_NULL) {
- return;
- }
-
- const auto relationObj = m_relationEventHandler(ao, relation);
- if (!relationObj) {
- return;
- }
-
- auto &win = getWindow();
- auto atspiHelper = static_cast<Elm_Interface_Atspi_Accessible *>
- (win.getData(impl::ATSPI_HELPER_DATA));
-
- if (!atspiHelper) {
- const auto obj = utils::createFakeAccessObject(win);
- if (!obj) {
- LOG_RETURN_VOID(RES_FAIL, "createFakeAccessObject() failed!");
- }
- obj->setIsOwner(false);
- atspiHelper = obj->getEo();
- win.setData(impl::ATSPI_HELPER_DATA, atspiHelper);
- }
-
- if (ao == win) {
- ao = atspiHelper;
- elm_atspi_component_highlight_grab(ao);
- }
-
- elm_atspi_accessible_relationships_clear(ao);
- elm_atspi_accessible_relationship_append(ao, relation, relationObj);
- }
-
- void AtspiHighlightHelper::onAtspiGesture(
- Widget &widget, void *eventInfo)
- {
- handleAtspiGesture(widget,
- *static_cast<AtspiGestureEventInfo *>(eventInfo));
- }
-
- bool AtspiHighlightHelper::handleGesture(Elm_Interface_Atspi_Accessible *ao,
- const Elm_Atspi_Gesture_Info &info)
- {
- AtspiGestureEventInfo eventInfo {};
- eventInfo.gestureInfo = info;
-
- handleAtspiGesture(ao, eventInfo);
-
- return eventInfo.preventDefault;
- }
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "presenters/CallStatusPresenter.h"
-#include "presenters/CallInfoPresenter.h"
-
-#include "ucl/gui/Window.h"
-
-#include "model/ICallManager.h"
-#include "model/IIncomingCall.h"
-#include "model/IActiveCall.h"
-#include "model/IHeldCall.h"
-#include "model/IEndCall.h"
-#include "model/ICallInfo.h"
-#include "model/IContactInfo.h"
-
-#include "common.h"
-#include "resources.h"
-
-namespace callui { namespace { namespace impl {
-
- using namespace ucl;
-
- constexpr int SUB_TXT_WIDTH = 208;
- constexpr int INCOM_MAIN_TXT_WIDTH = 190;
- constexpr int SLIDE_LABEL_DURATION_KOEFF = 8;
-
- const char *CU_BIG_FONT_STYLE = "Tizen:style=Condensed";
- constexpr int CU_BIG_FONT_SIZE = 40;
-
- constexpr LayoutTheme LAYOUT_CALLER_INFO_WIDGET
- {"layout", "callui", "call_info"};
-
- constexpr ElmStyle STYLE_SLIDING_LABEL {"slide_roll"};
-
- constexpr EdjePart PART_TXT_MAIN {"text_1line"};
- constexpr EdjePart PART_SWL_CALLER_ID {"caller_id"};
- constexpr EdjePart PART_SWL_2LINE {"text_2line"};
-
- constexpr EdjeSignal SIGN_RESET {"reset"};
- constexpr EdjeSignal SIGN_DEFAULT {"default"};
- constexpr EdjeSignal SIGN_CID_ENABLE {"caller_id_enable"};
- constexpr EdjeSignal SIGN_CID_DISABLE {"caller_id_disable"};
- constexpr EdjeSignal SIGN_EMERGENCY {"emergency"};
- constexpr EdjeSignal SIGN_EMERGENCY_BIG_TXT {"big_txt_emergency"};
- constexpr EdjeSignal SIGN_BIG_TXT {"big_txt"};
- constexpr EdjeSignal SIGN_CENTRE_1LINE {"centre_1line"};
- constexpr EdjeSignal SIGN_CENTRE_2LINE {"centre_2line"};
- constexpr EdjeSignal SIGN_INCOMING {"incoming"};
-
- constexpr EdjeSignalSrc SRC_TOP_PAD {"top_padding"};
- constexpr EdjeSignalSrc SRC_TXT_1LINE {"text_1line"};
- constexpr EdjeSignalSrc SRC_TXT_2LINE {"text_2line"};
- constexpr EdjeSignalSrc SRC_CALLER_ID {"caller_id"};
-
- const TString STR_LABEL_SUB_CID_ENABLE{
- "<align=center><color=#ffffff99><font_size=24>%s"
- "</color></font_size></align>"};
-
- const TString STR_LABEL_SUB_DEFAULT_STYLE{
- "<align=center><color=#ffffff99><font_size=24>%s"
- "</color></font_size></align>"};
-
- const TString STR_LABEL_SUB_ON_HOLD{
- "<align=center><color=#4dcfffff><font_size=24>%s"
- "</color></font_size></align>"};
-
- constexpr EdjePart PART_AO_MAIN_TXT {"ao_text_1line"};
- constexpr EdjePart PART_AO_SUB_TXT {"ao_text_2line"};
-
- int getTextWidth(ElmWidget &parent, const char *fontStyle,
- int fontSize, const std::string &text)
- {
- auto eoText = evas_object_text_add(evas_object_evas_get(parent));
- evas_object_text_font_set(eoText, fontStyle, fontSize);
- evas_object_text_style_set(eoText, EVAS_TEXT_STYLE_PLAIN);
- evas_object_text_text_set(eoText, text.c_str());
-
- auto size = evas_object_text_horiz_width_without_ellipsis_get(eoText);
- evas_object_del(eoText);
- return size;
- }
-
-}}}
-
-namespace callui {
-
- using namespace ucl;
-
- CallInfoPresenter::Builder::Builder():
- m_mode(CallMode::UNDEFINED)
- {
- }
-
- CallInfoPresenter::Builder::~Builder()
- {
- }
-
- CallInfoPresenter::Builder &
- CallInfoPresenter::Builder::setCallManager(const ICallManagerSRef &cm)
- {
- m_cm = cm;
- return *this;
- }
-
- CallInfoPresenter::Builder &
- CallInfoPresenter::Builder::setMode(CallMode mode)
- {
- m_mode = mode;
- return *this;
- }
-
- CallInfoPresenter::Builder &
- CallInfoPresenter::Builder::setParentWidget(
- const ucl::ElmWidgetSRef &parentWidget)
- {
- m_parentWidget = parentWidget;
- return *this;
- }
-
- CallInfoPresenterSRef
- CallInfoPresenter::Builder::build(GuiPresenter &parent) const
- {
- if (m_mode == CallMode::UNDEFINED || !m_cm || !m_parentWidget) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "Main params are are set");
- }
-
- auto result = makeShared<CallInfoPresenter>(m_cm, m_mode);
- FAIL_RETURN_VALUE(result->prepare(parent, *m_parentWidget), {},
- "result->prepare() failed!");
-
- return result;
- }
-
- CallInfoPresenter::CallInfoPresenter(IRefCountObj &rc,
- const ICallManagerSRef &cm,
- CallMode mode):
- GuiPresenter(rc),
- m_mode(mode),
- m_isSubTxtEnable(false),
- m_needModifyCallStatus(false)
- {
- initCallInfos(cm);
- }
-
- CallInfoPresenter::~CallInfoPresenter()
- {
- }
-
- Result CallInfoPresenter::prepare(GuiPresenter &parent,
- ElmWidget &parentWidget)
- {
- FAIL_RETURN(GuiPresenter::prepare(parent, PF_PASSIVE),
- "Presenter::prepare() failed!");
-
- m_parent = asWeak(parent);
-
- FAIL_RETURN(createWidget(parentWidget),
- "createWidget() failed!");
-
- FAIL_RETURN(createCallStatus(parent),
- "createCallStatus() failed!");
-
- FAIL_RETURN(update(), "update() failed!");
-
- return RES_OK;
- }
-
- Result CallInfoPresenter::createWidget(ElmWidget &parent)
- {
- m_widget = Layout::Builder().
- setTheme(impl::LAYOUT_CALLER_INFO_WIDGET).
- setIsOwner(true).
- build(parent);
- if (!m_widget) {
- LOG_RETURN(RES_FAIL, "Layout::build() failed!");
- }
- return RES_OK;
- }
-
- Widget &CallInfoPresenter::getWidget()
- {
- return *m_widget;
- }
-
- CallMode CallInfoPresenter::getMode() const
- {
- return m_mode;
- }
-
- void CallInfoPresenter::initCallInfos(const ICallManagerSRef &cm)
- {
- auto incom = cm->getIncomingCall();
- if (incom) {
- m_incomCallInfo = incom->getInfo();
- } else {
- m_incomCallInfo.reset();
- }
-
- auto active = cm->getActiveCall();
- if (active) {
- m_activeCallInfo = active->getInfo();
- } else {
- m_activeCallInfo.reset();
- }
-
- auto held = cm->getHeldCall();
- if (held) {
- m_heldCallInfo = held->getInfo();
- } else {
- m_heldCallInfo.reset();
- }
-
- auto end = cm->getEndCall();
- if (end) {
- m_endCallInfo = end->getInfo();
- } else {
- m_endCallInfo.reset();
- }
- }
-
- Result CallInfoPresenter::update(CallMode mode, const ICallManagerSRef &cm)
- {
- m_needModifyCallStatus = false;
- if (mode != m_mode || mode == CallMode::DURING) {
- m_needModifyCallStatus = true;
- }
-
- m_mode = mode;
- initCallInfos(cm);
- m_isSubTxtEnable = false;
-
- return update();
- }
-
- std::string CallInfoPresenter::getNumberSubText(
- const ICallInfoSCRef &callInfo) const
- {
- if (!callInfo) {
- FAIL_RETURN_VALUE(RES_FAIL, "", "callInfo is NULL!");
- }
-
- IContactInfoSCRef contactInfo = callInfo->getContactInfo();
- if (contactInfo) {
- return callInfo->getPhoneNumber();
- }
- return "";
- }
-
-
- std::string CallInfoPresenter::getIncomingCallSubText() const
- {
- if (!m_incomCallInfo) {
- FAIL_RETURN_VALUE(RES_FAIL, "", "incom is NULL!");
- }
- if (m_activeCallInfo && m_heldCallInfo) {
- auto displStr = m_activeCallInfo->getPhoneNumber();
- auto contactInfo = m_activeCallInfo->getContactInfo();
- if (contactInfo) {
- const auto contName = contactInfo->getName();
- if (!contName.empty()) {
- displStr = contName;
- }
- }
- if (displStr.empty()) {
- displStr = STR_UNKNOWN.translate();
- }
- return TString{STR_CALL_WITH_PS_WILL_END.translate()}.
- format(displStr.c_str());
- }
-
- if (m_incomCallInfo->isVoiceMailNumber() ||
- m_incomCallInfo->isEmergency()) {
- return "";
- }
-
- return getNumberSubText(m_incomCallInfo);
- }
-
- std::string CallInfoPresenter::getDuringCallSubText() const
- {
- if (m_activeCallInfo) {
- auto confMemberCount =
- m_activeCallInfo->getConferenceMemberCount();
- if (m_heldCallInfo) {
- return STR_CALL_ON_HOLD.translate();
- } else if (confMemberCount > 1) {
- return TString{STR_WITH_PD_PEOPLE.translate()}.
- format(confMemberCount);
- }
- } else if (m_heldCallInfo) {
- auto confMemberCount =
- m_heldCallInfo->getConferenceMemberCount();
- if (confMemberCount > 1) {
- return TString{STR_WITH_PD_PEOPLE.translate()}.
- format(confMemberCount);
- }
- } else {
- ELOG("Invalid call data");
- }
-
- return "";
- }
-
- std::string CallInfoPresenter::getEndCallSubText() const
- {
- if (!m_endCallInfo) {
- FAIL_RETURN_VALUE(RES_FAIL, "", "end is NULL!");
- }
-
- auto confMemberCount =
- m_endCallInfo->getConferenceMemberCount();
- if (confMemberCount > 1) {
- return TString{STR_WITH_PD_PEOPLE.translate()}.
- format(confMemberCount);
- }
-
- return "";
- }
-
- Result CallInfoPresenter::createLabel(const std::string &text)
- {
- auto *eo = elm_label_add(*m_widget);
- if (!eo) {
- LOG_RETURN(RES_FAIL, "elm_label_add() failed!");
- }
-
- TString txtStyle = impl::STR_LABEL_SUB_DEFAULT_STYLE;
- if (m_mode == CallMode::DURING) {
- txtStyle = impl::STR_LABEL_SUB_ON_HOLD;
- } else if (m_callerId) {
- txtStyle = impl::STR_LABEL_SUB_CID_ENABLE;
- }
-
- m_label = makeShared<StyledWidget>(eo, true);
- m_label->setStyle(impl::STYLE_SLIDING_LABEL);
- m_label->setText(txtStyle.format(text.c_str()));
-
- elm_label_slide_mode_set(*m_label,ELM_LABEL_SLIDE_MODE_AUTO);
- elm_label_wrap_width_set(*m_label,ELM_SCALE_SIZE(impl::SUB_TXT_WIDTH));
-
- double duration = (static_cast<double>(text.size())) /
- impl::SLIDE_LABEL_DURATION_KOEFF;
- elm_label_slide_duration_set(*m_label, duration);
- elm_label_slide_go(*m_label);
-
- m_widget->setContent(*m_label, impl::PART_SWL_2LINE);
-
- elm_atspi_accessible_can_highlight_set(*m_label, EINA_FALSE);
-
- return RES_OK;
- }
-
- Result CallInfoPresenter::createCallerIdImage(const std::string &imagePath)
- {
- auto *eo = elm_image_add(*m_widget);
- if (!eo) {
- LOG_RETURN(RES_FAIL, "elm_image_add() failed");
- }
- auto callerId = makeShared<StyledWidget>(eo, true);
- elm_image_file_set(*callerId, imagePath.c_str(), NULL);
- elm_image_aspect_fixed_set(*callerId, EINA_TRUE);
- elm_image_fill_outside_set(*callerId, EINA_TRUE);
-
- auto window = callerId->getWindow();
- if (!window) {
- LOG_RETURN(RES_FAIL, "Window is NULL!");
- }
- int w = 0, h = 0;
- window->getScreenSize(&w, &h);
- evas_object_size_hint_min_set(*callerId, w, h);
-
- m_widget->setContent(*callerId, impl::PART_SWL_CALLER_ID);
-
- m_callerId = callerId;
-
- return RES_OK;
- }
-
- Result CallInfoPresenter::updateCallerId()
- {
- m_callerId.reset();
- m_widget->emit(impl::SIGN_CID_DISABLE,impl::SRC_CALLER_ID);
-
- if (m_mode == CallMode::INCOMING) {
-
- if (!m_incomCallInfo) {
- LOG_RETURN(RES_FAIL, "m_incomCallInfo is NULL");
- }
-
- auto contactInfo = m_incomCallInfo->getContactInfo();
- if (!contactInfo) {
- LOG_RETURN(RES_OK, "No contact info");
- }
-
- auto callerIdPath = contactInfo->getImagePath();
- if (callerIdPath.empty()) {
- LOG_RETURN(RES_OK, "No caller id content to set");
- }
-
- FAIL_RETURN(createCallerIdImage(callerIdPath),
- "createCallerIdImage() failed");
-
- m_widget->emit(impl::SIGN_CID_ENABLE, impl::SRC_CALLER_ID);
- }
-
- return RES_OK;
- }
-
- Result CallInfoPresenter::updateSubText()
- {
- std::string subTxt;
- m_isSubTxtEnable = false;
- m_label.reset();
-
- switch (m_mode) {
- case CallMode::INCOMING:
- subTxt = getIncomingCallSubText();
- break;
- case CallMode::DURING:
- subTxt = getDuringCallSubText();
- break;
- case CallMode::OUTGOING:
- ILOG("Outgoing call not supported");
- break;
- case CallMode::END:
- subTxt = getEndCallSubText();
- break;
- case CallMode::UNDEFINED:
- LOG_RETURN(RES_FAIL, "Undefined caller info mode!");
- break;
- default:
- break;
- }
-
- if (!subTxt.empty()) {
- m_isSubTxtEnable = true;
- FAIL_RETURN(createLabel(subTxt), "createLabel() failed");
- }
-
- if (m_mode == CallMode::INCOMING) {
- m_widget->emit(impl::SIGN_INCOMING, impl::SRC_TXT_2LINE);
- } else {
- m_widget->emit(impl::SIGN_DEFAULT, impl::SRC_TXT_2LINE);
- }
-
- FAIL_RETURN(setSubTxtAccessObject(subTxt),
- "setSubTxtAccessObject() failed!");
-
- return RES_OK;
- }
-
- std::string CallInfoPresenter::generateMainTxt(
- const ICallInfoSCRef &callInfo)
- {
- if (!callInfo) {
- LOG_RETURN_VALUE(RES_FAIL, "", "callInfo is NULL");
- }
-
- if (callInfo->getConferenceMemberCount() > 1) {
- return STR_CONFERENCE_CALL.translate();
- }
-
- if (callInfo->isEmergency()) {
- return STR_EMERGENCY_CALL.translate();
- }
-
- if (callInfo->isVoiceMailNumber()) {
- return STR_VOICEMAIL.translate();
- }
-
- std::string mainTxt;
- auto contactInfo = callInfo->getContactInfo();
- if (contactInfo) {
- mainTxt = contactInfo->getName();
- }
-
- if (mainTxt.empty()) {
- mainTxt = callInfo->getPhoneNumber();
- if (mainTxt.empty()) {
- return STR_UNKNOWN.translate();
- }
- }
- return mainTxt;
- }
-
- void CallInfoPresenter::displayMainTxt(const ICallInfoSCRef &info,
- const std::string &text)
- {
- m_widget->setText(text.c_str(), impl::PART_TXT_MAIN);
-
- FAIL_RETURN_VOID(setMainTxtAccessObject(text),
- "setMainTxtAccessObject() failed!");
-
- if (m_mode == CallMode::INCOMING) {
- // Font size and color
- if (m_callerId) {
- m_widget->emit(impl::SIGN_CID_ENABLE, impl::SRC_TXT_1LINE);
- } else {
- m_widget->emit(impl::SIGN_CID_DISABLE, impl::SRC_TXT_1LINE);
- }
- // Info text top padding
- if (impl::getTextWidth(*m_widget,
- impl::CU_BIG_FONT_STYLE,
- impl::CU_BIG_FONT_SIZE,
- text) <= impl::INCOM_MAIN_TXT_WIDTH) {
- m_widget->emit(impl::SIGN_CENTRE_1LINE, impl::SRC_TOP_PAD);
- } else {
- m_widget->emit(impl::SIGN_CENTRE_2LINE, impl::SRC_TOP_PAD);
- }
- return;
- } else if (m_mode == CallMode::END) {
- if (info->isEmergency()
- || info->getContactInfo()
- || (info->getConferenceMemberCount() > 1)) {
- // Font size and color
- if (info->isEmergency()) {
- m_widget->emit(impl::SIGN_EMERGENCY_BIG_TXT,
- impl::SRC_TXT_1LINE);
- } else {
- m_widget->emit(impl::SIGN_BIG_TXT, impl::SRC_TXT_1LINE);
- }
- // Info text top padding
- if (impl::getTextWidth(*m_widget,
- impl::CU_BIG_FONT_STYLE,
- impl::CU_BIG_FONT_SIZE,
- text) <= impl::SUB_TXT_WIDTH) {
- m_widget->emit(impl::SIGN_CENTRE_1LINE, impl::SRC_TOP_PAD);
- } else {
- m_widget->emit(impl::SIGN_CENTRE_2LINE, impl::SRC_TOP_PAD);
- }
- return;
- }
- }
- // Font size and color
- if (info->isEmergency()) {
- m_widget->emit(impl::SIGN_EMERGENCY, impl::SRC_TXT_1LINE);
- } else {
- m_widget->emit(impl::SIGN_DEFAULT, impl::SRC_TXT_1LINE);
- }
- // Info text top padding
- m_widget->emit(impl::SIGN_DEFAULT, impl::SRC_TOP_PAD);
- }
-
- Result CallInfoPresenter::updateMainTxt()
- {
- std::string mainTxt;
-
- ICallInfoSCRef info;
-
- switch (m_mode) {
- case CallMode::INCOMING:
- info = m_incomCallInfo;
- break;
- case CallMode::OUTGOING:
- info = m_activeCallInfo;
- break;
- case CallMode::DURING:
- if (m_activeCallInfo) {
- info = m_activeCallInfo;
- } else if (m_heldCallInfo) {
- info = m_heldCallInfo;
- }
- break;
- case CallMode::END:
- info = m_endCallInfo;
- break;
- default:
- LOG_RETURN(RES_FAIL, "Unknown mode");
- break;
- }
- if (!info) {
- LOG_RETURN(RES_FAIL, "info is NULL");
- }
-
- mainTxt = generateMainTxt(info);
-
- if (mainTxt.empty()) {
- LOG_RETURN(RES_FAIL, "Main text is empty");
- }
-
- displayMainTxt(info, mainTxt);
-
- return RES_OK;
- }
-
- Result CallInfoPresenter::createCallStatus(GuiPresenter &parent)
- {
- ICallInfoWCRef callInfo;
- bool isOnHold = false;
-
- m_callStatus.reset();
-
- switch (m_mode) {
- case CallMode::INCOMING:
- callInfo = m_incomCallInfo;
- break;
- case CallMode::OUTGOING:
- callInfo = m_activeCallInfo;
- break;
- case CallMode::DURING:
- if (m_activeCallInfo) {
- callInfo = m_activeCallInfo;
- } else if (m_heldCallInfo) {
- callInfo = m_heldCallInfo;
- isOnHold = true;
- }
- break;
- case CallMode::END:
- callInfo = m_endCallInfo;
- break;
- default:
- LOG_RETURN(RES_FAIL, "Unknown mode");
- break;
- }
-
- m_callStatus = CallStatusPresenter::Builder().
- setLayout(m_widget).
- setMode(m_mode).
- setCallInfo(callInfo).
- setCallHoldState(isOnHold).
- build(parent);
-
- if (!m_callStatus) {
- LOG_RETURN(RES_FAIL, "CallStatus::build() failed!");
- }
-
- return RES_OK;
- }
-
- Result CallInfoPresenter::update()
- {
- m_widget->emit(impl::SIGN_RESET, impl::SRC_TOP_PAD);
-
- FAIL_RETURN(updateCallerId(), "displayCallerId() failed!");
- FAIL_RETURN(updateSubText(), "diplaySubText() failed!");
- FAIL_RETURN(updateMainTxt(), "diplayMainTxt() failed!");
-
- if (m_needModifyCallStatus) {
- if (const auto parent = m_parent.lock())
- return createCallStatus(*parent);
- }
-
- return RES_OK;
- }
-
- // Screen Reader
- ElmWidget *CallInfoPresenter::getMainTxtAo()
- {
- return m_mainTxtAO.get();
- }
-
- ElmWidget *CallInfoPresenter::getSubTxtAo()
- {
- return m_subTxtAO.get();
- }
-
- ElmWidget *CallInfoPresenter::getStatusTxtAo()
- {
- return m_callStatus->getStatusTextAo();
- }
-
- Result CallInfoPresenter::setMainTxtAccessObject(const std::string &text)
- {
- if (!m_mainTxtAO) {
- m_mainTxtAO = utils::createAccessObjectFromLyPart(*m_widget,
- *m_widget,
- impl::PART_AO_MAIN_TXT);
- if (!m_mainTxtAO) {
- LOG_RETURN(RES_FAIL, "createAccessObjectFromLyPart() failed!");
- }
-
- }
- elm_atspi_accessible_reading_info_type_set(*m_mainTxtAO,
- ELM_ACCESSIBLE_READING_INFO_TYPE_NAME);
- elm_atspi_accessible_name_set(*m_mainTxtAO, text.c_str());
-
- return RES_OK;
- }
-
- Result CallInfoPresenter::setSubTxtAccessObject(const std::string &text)
- {
- if (!text.empty()) {
- if (!m_subTxtAO) {
- m_subTxtAO = utils::createAccessObjectFromLyPart(*m_widget,
- *m_widget,
- impl::PART_AO_SUB_TXT);
- if (!m_subTxtAO) {
- LOG_RETURN(RES_FAIL, "createAccessObjectFromLyPart() failed!");
- }
- }
-
- elm_atspi_accessible_reading_info_type_set(*m_subTxtAO,
- ELM_ACCESSIBLE_READING_INFO_TYPE_NAME);
- elm_atspi_accessible_name_set(*m_subTxtAO, text.c_str());
-
- } else if (m_subTxtAO) {
- utils::destroyAccessObject(*m_subTxtAO);
- m_subTxtAO.reset();
- }
-
- return RES_OK;
- }
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "presenters/CallStatusPresenter.h"
-
-#include "model/ICallInfo.h"
-
-#include "common.h"
-#include "resources.h"
-
-namespace callui { namespace { namespace impl {
-
- using namespace ucl;
-
- constexpr double CALL_DURATION_TIMER_INTERVAL = 0.1;
- constexpr double END_CALL_BLINKING_TIMER_INTERVAL = 0.5;
- constexpr int END_CALL_BLINKING_MAX_COUNT = 5;
-
- constexpr EdjePart PART_TXT_TEXT_INFO {"text_info"};
-
- constexpr EdjeSignal SIGN_DOT_RTL {"default:RTL"};
- constexpr EdjeSignal SIGN_DOT_LTR {"default:LTR"};
- constexpr EdjeSignal SIGN_RESET {"reset"};
-
- constexpr EdjePart PART_AO_STATUS {"ao_text_info"};
-
- constexpr EdjeSignalSrc SIGN_SRC_DOT {"dot"};
-
-}}}
-
-namespace callui {
-
- using namespace ucl;
-
- CallStatusPresenter::Builder::Builder():
- m_mode(CallMode::UNDEFINED),
- m_isOnHold(false)
- {
- }
-
- CallStatusPresenter::Builder::~Builder()
- {
- }
-
- CallStatusPresenter::Builder &
- CallStatusPresenter::Builder::setMode(CallMode mode)
- {
- m_mode = mode;
- return *this;
- }
-
- CallStatusPresenter::Builder &
- CallStatusPresenter::Builder::setCallInfo(const ICallInfoWCRef &info)
- {
- m_info = info;
- return *this;
- }
-
- CallStatusPresenter::Builder &
- CallStatusPresenter::Builder::setCallHoldState(bool isOnHold)
- {
- m_isOnHold = isOnHold;
- return *this;
- }
-
- CallStatusPresenter::Builder &
- CallStatusPresenter::Builder::setLayout(const LayoutSRef &layout)
- {
- m_ly = layout;
- return *this;
- }
-
- CallStatusPresenterSRef
- CallStatusPresenter::Builder::build(GuiPresenter &parent) const
- {
- if (m_mode == CallMode::UNDEFINED || !m_ly) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "Not all params are set");
- }
-
- auto result = makeShared<CallStatusPresenter>(m_ly, m_mode,
- m_info, m_isOnHold);
-
- FAIL_RETURN_VALUE(result->prepare(parent), {},
- "result->prepare() failed!");
- return result;
- }
-
-
- CallStatusPresenter::CallStatusPresenter(IRefCountObj &rc,
- const LayoutSRef &layout,
- CallMode mode,
- const ICallInfoWCRef &info,
- bool isHeld):
- GuiPresenter(rc),
- m_ly(layout),
- m_mode(mode),
- m_info(info),
- m_isOnHold(isHeld),
- m_timer(nullptr),
- m_duration{0},
- m_blinkCount(0)
- {
- }
-
- CallStatusPresenter::~CallStatusPresenter()
- {
- m_ly.reset();
- if (m_timer) {
- ecore_timer_del(m_timer);
- m_timer = nullptr;
- }
- }
-
- Result CallStatusPresenter::prepare(GuiPresenter &parent)
- {
- FAIL_RETURN(GuiPresenter::prepare(parent, PF_PASSIVE),
- "Presenter::prepare() failed!");
-
- m_ly->emit(impl::SIGN_RESET, impl::SIGN_SRC_DOT);
- m_ly->setText("", impl::PART_TXT_TEXT_INFO);
- createStatusTxtAo();
-
- switch (m_mode) {
- case CallMode::INCOMING: return processIncomingMode();
- case CallMode::OUTGOING: return processOutgoingMode();
- case CallMode::DURING: return processDuringMode();
- case CallMode::END: return processEndMode();
- default:
- LOG_RETURN(RES_FAIL, "Unknown mode");
- break;
- }
-
- return RES_OK;
- }
-
- Result CallStatusPresenter::processIncomingMode()
- {
- m_ly->setText(STR_INCOMING_CALL, impl::PART_TXT_TEXT_INFO);
-
- // TODO: need add logic for RTL mode in the future
- m_ly->emit(impl::SIGN_DOT_LTR, impl::SIGN_SRC_DOT);
-
- return RES_OK;
- }
-
- Result CallStatusPresenter::processOutgoingMode()
- {
- m_ly->setText(STR_DIALING_CALL, impl::PART_TXT_TEXT_INFO);
-
- // TODO: need add logic for RTL mode in the future
- m_ly->emit(impl::SIGN_DOT_LTR, impl::SIGN_SRC_DOT);
-
- return RES_OK;
- }
-
- Eina_Bool CallStatusPresenter::onCallDurationTimerCb()
- {
- const auto info = m_info.lock();
- if (!info) {
- m_timer = nullptr;
- LOG_RETURN_VALUE(RES_FAIL, ECORE_CALLBACK_CANCEL, "m_info is NULL");
- }
-
- struct tm tmp = info->getDuration();
- tryUpdateCallDurationTime(
- m_duration,
- tmp,
- *m_ly,
- impl::PART_TXT_TEXT_INFO);
-
- return ECORE_CALLBACK_RENEW;
- }
-
- Result CallStatusPresenter::processDuringMode()
- {
-
- if (m_isOnHold) {
- m_ly->setText(STR_ON_HOLD, impl::PART_TXT_TEXT_INFO);
- } else {
- if (const auto info = m_info.lock()) {
- m_duration = info->getDuration();
- }
- m_ly->setText(getCallDuration(m_duration),
- impl::PART_TXT_TEXT_INFO);
-
- if (m_timer) {
- ecore_timer_del(m_timer);
- m_timer = nullptr;
- }
-
- m_timer = ecore_timer_add(impl::CALL_DURATION_TIMER_INTERVAL,
- CALLBACK_B(CallStatusPresenter::onCallDurationTimerCb),
- this);
-
- if (!m_timer) {
- LOG_RETURN(RES_FAIL, "m_timer is NULL");
- }
- }
- return RES_OK;
- }
-
- Eina_Bool CallStatusPresenter::onBlinkingTimerCb()
- {
- if ((m_blinkCount % 2) == 0) {
- m_ly->setText(getCallDuration(m_duration),
- impl::PART_TXT_TEXT_INFO);
- } else if ((m_blinkCount % 2) == 1) {
- m_ly->setText("", impl::PART_TXT_TEXT_INFO);
- }
-
- m_blinkCount++;
-
- if (m_blinkCount == impl::END_CALL_BLINKING_MAX_COUNT) {
- m_ly->setText(STR_CALL_ENDED, impl::PART_TXT_TEXT_INFO);
- m_timer = nullptr;
- return ECORE_CALLBACK_CANCEL;
- }
- return ECORE_CALLBACK_RENEW;
- }
-
- Result CallStatusPresenter::processEndMode()
- {
- if (m_timer) {
- ecore_timer_del(m_timer);
- m_timer = nullptr;
- }
-
- if (const auto info = m_info.lock()) {
- m_duration = info->getDuration();
- }
-
- m_timer = ecore_timer_add(impl::END_CALL_BLINKING_TIMER_INTERVAL,
- CALLBACK_B(CallStatusPresenter::onBlinkingTimerCb), this);
- if (!m_timer) {
- LOG_RETURN(RES_FAIL, "m_timer is NULL");
- }
-
- return RES_OK;
- }
-
- // Screen Reader
- Result CallStatusPresenter::createStatusTxtAo()
- {
- if (!m_statusTxtAo) {
- m_statusTxtAo = utils::createAccessObjectFromLyPart(*m_ly,
- *m_ly,
- impl::PART_AO_STATUS);
- if (!m_statusTxtAo) {
- LOG_RETURN(RES_FAIL, "createAccessObjectFromLyPart() failed!");
- }
-
- elm_atspi_accessible_reading_info_type_set(*m_statusTxtAo,
- ELM_ACCESSIBLE_READING_INFO_TYPE_NAME);
- elm_atspi_accessible_name_cb_set(*m_statusTxtAo,
- [](void *data, Evas_Object *obj) -> char *
- {
- auto self = static_cast<CallStatusPresenter *>(data);
- if (!self) {
- return nullptr;
- }
- auto txt = self->m_ly->
- getText(impl::PART_TXT_TEXT_INFO).getCStr();
- return (txt) ? strdup(txt) : nullptr;
- },
- this);
- }
- return RES_OK;
- }
-
- ElmWidget *CallStatusPresenter::getStatusTextAo()
- {
- return m_statusTxtAo.get();
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "presenters/DeviceStatePresenter.h"
-
-#include <device/power.h>
-#include <device/display.h>
-#include <efl_util.h>
-
-#include "common.h"
-
-namespace callui {
-
- using namespace ucl;
-
- // DeviceStatePresenter::Builder
-
- DeviceStatePresenter::Builder::Builder():
- m_state(DisplayState::UNDEFINED),
- m_mode(DisplayMode::UNDEFINED),
- m_lockState(false)
- {
- }
-
- DeviceStatePresenter::Builder &
- DeviceStatePresenter::Builder::setDisplayState(DisplayState state)
- {
- m_state = state;
- return *this;
- }
-
- DeviceStatePresenter::Builder &
- DeviceStatePresenter::Builder::setDisplayMode(DisplayMode mode)
- {
- m_mode = mode;
- return *this;
- }
-
- DeviceStatePresenter::Builder &
- DeviceStatePresenter::Builder::setCpuLockState(bool lockState)
- {
- m_lockState = lockState;
- return *this;
- }
-
- DeviceStatePresenterSRef
- DeviceStatePresenter::Builder::build(const ucl::WindowSRef &window) const
- {
- auto result = makeShared<DeviceStatePresenter>(window);
- FAIL_RETURN_VALUE(result->prepare(m_state,
- m_mode, m_lockState), {},
- "result->prepare() failed!");
- return result;
- }
-
- // DeviceStatePresenter
-
- DeviceStatePresenter::DeviceStatePresenter(const ucl::WindowSRef &window):
- m_window(window),
- m_mode(DisplayMode::UNDEFINED),
- m_lockState(false)
- {
- }
-
- Result DeviceStatePresenter::prepare(DisplayState state,
- DisplayMode mode,
- bool lockState)
- {
- if (state != DisplayState::UNDEFINED) {
- FAIL_RETURN(setDisplayState(state, true),
- "setDisplayState() failed");
- }
-
- if (mode != DisplayMode::UNDEFINED) {
- FAIL_RETURN(setDisplayMode(mode),
- "setDisplayMode() failed");
- }
-
- if (lockState) {
- FAIL_RETURN(setCpuLockState(lockState),
- "setCpuLockState() failed");
- }
-
- return RES_OK;
- }
-
- Result DeviceStatePresenter::setDisplayState(DisplayState state, bool forse)
- {
- if (state == DisplayState::UNDEFINED) {
- LOG_RETURN(RES_FAIL, "State is undefined");
- }
-
- display_state_e dispState = DISPLAY_STATE_NORMAL;
-
- if (!forse) {
- int res = device_display_get_state(&dispState);
- if (res != DEVICE_ERROR_NONE) {
- LOG_RETURN(RES_FAIL, "device_display_get_state() failed."
- "res[%d] msg[%s]", res, get_error_message(res));
- }
- if ((state == DisplayState::ON
- && dispState == DISPLAY_STATE_NORMAL)
- || (state == DisplayState::DIM
- && dispState == DISPLAY_STATE_SCREEN_DIM)
- || (state == DisplayState::OFF
- && dispState == DISPLAY_STATE_SCREEN_OFF)) {
- LOG_RETURN(RES_OK,
- "Display state already set into needed state");
- }
- }
-
- switch (state) {
- case DisplayState::ON:
- dispState = DISPLAY_STATE_NORMAL;
- break;
- case DisplayState::DIM:
- dispState = DISPLAY_STATE_SCREEN_DIM;
- break;
- case DisplayState::OFF:
- dispState = DISPLAY_STATE_SCREEN_OFF;
- break;
- default:
- LOG_RETURN(RES_FAIL, "Undefined state");
- break;
- }
-
- int res = device_display_change_state(dispState);
- if (res != DEVICE_ERROR_NONE) {
- LOG_RETURN(RES_FAIL, "device_display_change_state() failed."
- "res[%d] msg[%s]", res, get_error_message(res));
- }
-
- return RES_OK;
- }
-
- Result DeviceStatePresenter::setDisplayMode(DisplayMode mode)
- {
- if (mode == DisplayMode::UNDEFINED) {
- LOG_RETURN(RES_FAIL, "Mode is undefined");
- }
-
- if (mode == m_mode) {
- LOG_RETURN(RES_OK, "Display mode already set");
- }
-
- m_mode = mode;
-
- efl_util_screen_mode_e setScreenMode =
- (m_mode == DisplayMode::TOP_PRIORITY) ?
- EFL_UTIL_SCREEN_MODE_ALWAYS_ON :
- EFL_UTIL_SCREEN_MODE_DEFAULT;
-
- int res = efl_util_set_window_screen_mode(*m_window, setScreenMode);
- if (res != EFL_UTIL_ERROR_NONE) {
- LOG_RETURN(RES_FAIL, "Set window screen mode failed."
- "res[%d] msg[%s]", res, get_error_message(res));
- }
-
- return RES_OK;
- }
-
- Result DeviceStatePresenter::setCpuLockState(bool lockState)
- {
- if (lockState == m_lockState) {
- LOG_RETURN(RES_OK, "Cpu lock state already set %s",
- lockState ? "locked" : "unlocked");
- }
-
- m_lockState = lockState;
-
- int res = m_lockState ?
- device_power_request_lock(POWER_LOCK_CPU, 0) :
- device_power_release_lock(POWER_LOCK_CPU);
-
- if (res != DEVICE_ERROR_NONE) {
- LOG_RETURN(RES_FAIL, "Device power request %s failed.",
- m_lockState ? "lock" : "unlock",
- "res[%d] msg[%s]", res, get_error_message(res));
- }
-
- return RES_OK;
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "presenters/IndicatorPresenter.h"
-
-#include <string>
-
-#include "model/IIndicatorStateProvider.h"
-
-#include "common.h"
-
-namespace callui { namespace { namespace impl {
- using namespace ucl;
-
- constexpr int BATTERY_LOW_LIMIT = 5;
-
- constexpr LayoutTheme LAYOUT_INDICATOR_WIDGET
- {"layout", "callui", "indicator"};
-
- constexpr LayoutTheme LAYOUT_CONNECTION
- {"layout", "callui", "connection"};
-
- constexpr LayoutTheme LAYOUT_RSSI
- {"layout", "callui", "rssi"};
-
- constexpr LayoutTheme LAYOUT_BATTERY
- {"layout", "callui", "battery"};
-
- constexpr LayoutTheme LAYOUT_SIM
- {"layout", "callui", "sim"};
-
- constexpr LayoutTheme LAYOUT_HD_CALL
- {"layout", "callui", "hd_voice"};
-
- constexpr LayoutTheme LAYOUT_VOICE_CONTROL
- {"layout", "callui", "voice_control"};
-
- constexpr EdjePart PART_SWL_CONN {"swl.connection"};
- constexpr EdjePart PART_SWL_RSSI {"swl.rssi"};
- constexpr EdjePart PART_SWL_BATTERY {"swl.battery"};
- constexpr EdjePart PART_SWL_VOICE_CONTROL {"swl.voice_control"};
- constexpr EdjePart PART_SWL_SIM {"swl.sim"};
- constexpr EdjePart PART_SWL_HD_VOICE {"swl.hd_voice"};
-
- constexpr EdjeSignal SIGL_BATT_LVL_HIDE {"batt_lvl_hide"};
-
- EdjeSignal getConnUpdateSignal(ConnectionType connection)
- {
- switch (connection) {
- case ConnectionType::EDGE_E: return EdjeSignal{"conn_edge_connected"};
- case ConnectionType::GPRS_G: return EdjeSignal{"conn_gprs_connected"};
- case ConnectionType::SIMPLE_2G: return EdjeSignal{"conn_2g_connected"};
- case ConnectionType::HSDPA_H: return EdjeSignal{"conn_hsdpa_connected"};
- case ConnectionType::HSPA_H_PLUS: return EdjeSignal{"conn_hspa_connected"};
- case ConnectionType::LTE_4G: return EdjeSignal{"conn_lte_connected"};
- case ConnectionType::UMTS_3G: return EdjeSignal{"conn_umts_connected"};
- case ConnectionType::UMTS_3G_PLUS: return EdjeSignal{"conn_3g_plus_connected"};
- case ConnectionType::WIFI_00: return EdjeSignal{"conn_wifi_connected_00"};
- case ConnectionType::WIFI_01: return EdjeSignal{"conn_wifi_connected_01"};
- case ConnectionType::WIFI_02: return EdjeSignal{"conn_wifi_connected_02"};
- case ConnectionType::WIFI_03: return EdjeSignal{"conn_wifi_connected_03"};
- case ConnectionType::WIFI_04: return EdjeSignal{"conn_wifi_connected_04"};
- case ConnectionType::NO_SIGNAL: return EdjeSignal{"conn_no_signal"};
- default: return EdjeSignal{"conn_none"};
- }
- }
-
- EdjeSignal getPacketUpdateSignal(PacketDirection direction)
- {
- switch (direction) {
- case PacketDirection::NO_INPUT: return EdjeSignal{"packet_no_inout_connected"};
- case PacketDirection::IN: return EdjeSignal{"packet_in_connected"};
- case PacketDirection::OUT: return EdjeSignal{"packet_out_connected"};
- case PacketDirection::INOUT: return EdjeSignal{"packet_inout_connected"};
- default: return EdjeSignal{"packet_none"};
- }
- }
-
- EdjeSignal getRssiUpdateSignal(RssiState state, bool isRoaming)
- {
- switch (state) {
- case RssiState::LEVEL_0: return EdjeSignal{ isRoaming ? "rssi_roaming_00" : "rssi_00"};
- case RssiState::LEVEL_1: return EdjeSignal{ isRoaming ? "rssi_roaming_01" : "rssi_01"};
- case RssiState::LEVEL_2: return EdjeSignal{ isRoaming ? "rssi_roaming_02" : "rssi_02"};
- case RssiState::LEVEL_3: return EdjeSignal{ isRoaming ? "rssi_roaming_03" : "rssi_03"};
- case RssiState::LEVEL_4: return EdjeSignal{ isRoaming ? "rssi_roaming_04" : "rssi_04"};
- case RssiState::NO_SIGNAL: return EdjeSignal{"rssi_no_signal"};
- case RssiState::FLIGHT_MODE: return EdjeSignal{"rssi_flight_mode"};
- default: return EdjeSignal{"rssi_none"};
- }
- }
-
- EdjeSignal getBatteryStateUpdateSignal(BatteryState state, int battLvl)
- {
- switch (state) {
- case BatteryState::CHARGING: return EdjeSignal{"batt_state_charging"};
- case BatteryState::CHARGING_PROBLEM: return EdjeSignal{"batt_state_charging_problem"};
- case BatteryState::UNKNOWN: return EdjeSignal{"batt_state_unknown"};
- default:
- if (battLvl > BATTERY_LOW_LIMIT)
- return EdjeSignal{"batt_state_normal"};
- else
- return EdjeSignal{"batt_state_low_battery"};
- }
- }
-
- EdjeSignal getBatteryLevelUpdateSignal(int level, bool isLevelUnknown)
- {
- if (isLevelUnknown) {
- return impl::SIGL_BATT_LVL_HIDE;
- }
-
- auto battLvl = level;
- if (battLvl <= BATTERY_LOW_LIMIT) {
- battLvl /= BATTERY_LOW_LIMIT;
- battLvl *= BATTERY_LOW_LIMIT;
- } else {
- battLvl += BATTERY_LOW_LIMIT - 1;
- battLvl /= BATTERY_LOW_LIMIT;
- battLvl *= BATTERY_LOW_LIMIT;
- }
-
- if (battLvl <= BATTERY_LOW_LIMIT - 1) {
- return impl::SIGL_BATT_LVL_HIDE;
- }
- return EdjeSignal{std::string("batt_lvl_").
- append(std::to_string(battLvl)).
- c_str()};
-
- }
-
- EdjeSignal getSimSlotUpdateSignal(SimSlot slot, bool isForwarded)
- {
- switch (slot) {
- case SimSlot::GEAR:
- if (isForwarded) {
- return EdjeSignal{"sim_gear_forwarded"};
- } else {
- return EdjeSignal{"sim_gear"};
- }
- case SimSlot::MOBILE_DEFAULT: return EdjeSignal{"sim_mobile"};
- case SimSlot::MOBILE_FIRST: return EdjeSignal{"sim_mobile_01"};
- case SimSlot::MOBILE_SECOND: return EdjeSignal{"sim_mobile_02"};
- default: return EdjeSignal{"sim_unknown"};
- }
- }
-
-}}}
-
-namespace callui {
-
- using namespace ucl;
-
- IndicatorPresenter::Builder::Builder()
- {
- }
-
- IndicatorPresenter::Builder::~Builder()
- {
- }
-
- IndicatorPresenter::Builder &
- IndicatorPresenter::Builder::setIndicatorStateProvider(
- const IIndicatorStateProviderSRef &provider)
- {
- m_provider = provider;
- return *this;
- }
-
- IndicatorPresenter::Builder &
- IndicatorPresenter::Builder::setParentWidget(const ucl::ElmWidgetSRef &parentWidget)
- {
- m_parentWidget = parentWidget;
- return *this;
- }
-
- IndicatorPresenterSRef
- IndicatorPresenter::Builder::build(GuiPresenter &parent) const
- {
- if (!m_provider || !m_parentWidget) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "Main params are not set");
- }
-
- auto result = makeShared<IndicatorPresenter>(m_provider);
- FAIL_RETURN_VALUE(result->prepare(parent, *m_parentWidget), {},
- "result->prepare() failed!");
- return result;
- }
-
- IndicatorPresenter::IndicatorPresenter(IRefCountObj &rc,
- const IIndicatorStateProviderSRef &provider):
- GuiPresenter(rc),
- m_provider(provider),
- m_isIncomingCallMode(false)
- {
- }
-
- IndicatorPresenter::~IndicatorPresenter()
- {
- }
-
- Result IndicatorPresenter::prepare(GuiPresenter &parent,
- ElmWidget &parentWidget)
- {
- FAIL_RETURN(GuiPresenter::prepare(parent, PF_PASSIVE),
- "Presenter::prepare() failed!");
- FAIL_RETURN(createWidget(parentWidget),
- "createWidget() failed!");
- FAIL_RETURN(createConnectionLayout(),
- "createConnectionLayout() failed!");
- FAIL_RETURN(createRssiLayout(),
- "createRssiLayout() failed!");
- FAIL_RETURN(createBatteryLayout(),
- "createBatteryLayout() failed!");
- FAIL_RETURN(createVoiceControlLayout(),
- "createBatteryLayout() failed!");
- FAIL_RETURN(createSimLayout(),
- "createSimLayout() failed!");
- FAIL_RETURN(createHdVoiceLayout(),
- "createHdCallLayout() failed!");
-
- updateCentralIcon();
-
- m_provider->setListener(asWeak(*this));
-
- return RES_OK;
- }
-
- Result IndicatorPresenter::createWidget(ElmWidget &parent)
- {
- m_widget = Layout::Builder().
- setTheme(impl::LAYOUT_INDICATOR_WIDGET).
- setIsOwner(true).
- build(parent);
- if (!m_widget) {
- LOG_RETURN(RES_FAIL, "Layout::build() failed!");
- }
-
- return RES_OK;
- }
-
- Result IndicatorPresenter::createConnectionLayout()
- {
- m_connLayout = Layout::Builder().
- setTheme(impl::LAYOUT_CONNECTION).
- build(*m_widget);
- if (!m_connLayout) {
- LOG_RETURN(RES_FAIL, "Layout::build() failed!");
- }
- m_widget->setContent(*m_connLayout, impl::PART_SWL_CONN);
-
- updateConnectionState();
-
- return RES_OK;
- }
-
- Result IndicatorPresenter::createRssiLayout()
- {
- m_rssiLayout = Layout::Builder().
- setTheme(impl::LAYOUT_RSSI).
- build(*m_widget);
- if (!m_rssiLayout) {
- LOG_RETURN(RES_FAIL, "Layout::build() failed!");
- }
- m_widget->setContent(*m_rssiLayout, impl::PART_SWL_RSSI);
-
- updateRssiState();
-
- return RES_OK;
- }
-
- Result IndicatorPresenter::createBatteryLayout()
- {
- m_batteryLayout = Layout::Builder().
- setTheme(impl::LAYOUT_BATTERY).
- build(*m_widget);
- if (!m_batteryLayout) {
- LOG_RETURN(RES_FAIL, "Layout::build() failed!");
- }
- m_widget->setContent(*m_batteryLayout, impl::PART_SWL_BATTERY);
-
- updateBatteryState();
-
- return RES_OK;
- }
-
- Result IndicatorPresenter::createVoiceControlLayout()
- {
- m_voiceControlLayout = Layout::Builder().
- setTheme(impl::LAYOUT_VOICE_CONTROL).
- build(*m_widget);
- if (!m_voiceControlLayout) {
- LOG_RETURN(RES_FAIL, "Layout::build() failed!");
- }
-
- m_widget->setContent(*m_voiceControlLayout, impl::PART_SWL_VOICE_CONTROL);
-
- return RES_OK;
- }
-
- Result IndicatorPresenter::createSimLayout()
- {
- m_simLayout = Layout::Builder().
- setTheme(impl::LAYOUT_SIM).
- build(*m_widget);
- if (!m_simLayout) {
- LOG_RETURN(RES_FAIL, "Layout::build() failed!");
- }
- m_widget->setContent(*m_simLayout, impl::PART_SWL_SIM);
-
- updateSimState();
-
- return RES_OK;
- }
-
- Result IndicatorPresenter::createHdVoiceLayout()
- {
- m_hdCallLayout = Layout::Builder().
- setTheme(impl::LAYOUT_HD_CALL).
- build(*m_widget);
- if (!m_hdCallLayout) {
- LOG_RETURN(RES_FAIL, "Layout::build() failed!");
- }
-
- m_widget->setContent(*m_hdCallLayout, impl::PART_SWL_HD_VOICE);
-
- updateHdVoiceState();
-
- return RES_OK;
- }
-
- void IndicatorPresenter::updateConnectionState()
- {
- auto state = m_provider->getState(IndicatorProperty::NW_CONNECTION);
-
- m_connLayout->emit(impl::getConnUpdateSignal(
- getConnectionState(state)));
-
- m_connLayout->emit(impl::getPacketUpdateSignal(
- getPacketDirection(state)));
- }
-
- void IndicatorPresenter::updateRssiState()
- {
- auto state = m_provider->getState(IndicatorProperty::RSSI);
-
- m_rssiLayout->emit(impl::getRssiUpdateSignal(
- getRssiState(state),
- getRoamingState(state)));
- }
-
- void IndicatorPresenter::updateBatteryState()
- {
- auto state = m_provider->getState(IndicatorProperty::BATTERY);
- auto battState = getBatteryState(state);
- auto battLvl = getBatteryLevel(state);
-
- m_batteryLayout->emit(
- impl::getBatteryStateUpdateSignal(battState, battLvl));
- m_batteryLayout->emit(
- impl::getBatteryLevelUpdateSignal(battLvl,
- (battState == BatteryState::UNKNOWN)));
- }
-
- void IndicatorPresenter::updateSimState()
- {
- auto state = m_provider->getState(IndicatorProperty::SIM_SLOT);
-
- m_simLayout->emit(impl::getSimSlotUpdateSignal(
- getSimSlotType(state),
- getSimForwardState(state)));
- }
-
- void IndicatorPresenter::updateHdVoiceState()
- {
- auto state = m_provider->getState(IndicatorProperty::HD_VOICE);
- m_hdCallLayout->emit(EdjeSignal{
- (getHDVoiceState(state) ? "hd_voice_show" : "hd_voice_hide")});
- }
-
- Widget &IndicatorPresenter::getWidget()
- {
- return *m_widget;
- }
-
- void IndicatorPresenter::udapteIncomingCallMode(bool isIncomingCallMode)
- {
- if (m_isIncomingCallMode == isIncomingCallMode) {
- return;
- }
- m_isIncomingCallMode = isIncomingCallMode;
- updateCentralIcon();
- }
-
- void IndicatorPresenter::updateCentralIcon()
- {
- if (m_isIncomingCallMode) {
- auto state = m_provider->getState(
- IndicatorProperty::VOICE_CONTROL);
-
- if (getVoiceControlState(state)) {
- m_widget->setContent(*m_voiceControlLayout,
- impl::PART_SWL_VOICE_CONTROL);
- show(*m_voiceControlLayout);
-
- m_widget->unsetContent(impl::PART_SWL_BATTERY);
- hide(*m_batteryLayout);
- return;
- }
- }
- m_widget->unsetContent(impl::PART_SWL_VOICE_CONTROL);
- hide(*m_voiceControlLayout);
-
- m_widget->setContent(*m_batteryLayout,
- impl::PART_SWL_BATTERY);
- show(*m_batteryLayout);
- }
-
- void IndicatorPresenter::onStateChanged(IndicatorProperty property)
- {
- switch (property) {
- case IndicatorProperty::NW_CONNECTION:
- updateConnectionState();
- break;
- case IndicatorProperty::RSSI:
- updateRssiState();
- break;
- case IndicatorProperty::BATTERY:
- updateBatteryState();
- break;
- case IndicatorProperty::VOICE_CONTROL:
- updateCentralIcon();
- break;
- case IndicatorProperty::SIM_SLOT:
- updateSimState();
- break;
- case IndicatorProperty::HD_VOICE:
- updateHdVoiceState();
- break;
- default:
- ELOG("Unhandled state");
- return;
- }
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "presenters/Instance.h"
-
-#include "ucl/util/memory.h"
-#include "ucl/appfw/SysEventProvider.h"
-#include "ucl/appfw/helpers.h"
-
-#include <system_settings.h>
-
-#include "model/CallUIBuilder.h"
-#include "model/ICallUI.h"
-#include "model/ICallManager.h"
-#include "presenters/MainPage.h"
-
-#include "resources.h"
-#include "common.h"
-
-namespace callui { namespace { namespace impl {
-
- using namespace ucl;
-
- const char *STR_POWER_KEY = "XF86PowerOff";
-
-}}}
-
-namespace callui {
-
- using namespace ucl;
-
- Instance::Instance(IRefCountObj &rc,
- SysEventProvider &sysEventProvider) :
- RefCountAware(&rc),
- m_sysEventProvider(sysEventProvider),
- m_context(nullptr),
- m_keyUpEventHandler(nullptr)
- {
- }
-
- Instance::~Instance()
- {
- elm_win_keygrab_unset(*m_win, impl::STR_POWER_KEY, 0, 0);
-
- if (m_keyUpEventHandler) {
- ecore_event_handler_del(m_keyUpEventHandler);
- }
-
- if (const auto page = m_page.lock()) {
- page->exitNoTransition();
- }
- }
-
- Result Instance::onCreate(IInstanceContext *const context)
- {
- m_context = context;
-
- m_win = m_context->getWindow();
-
- elm_win_keygrab_set(*m_win, impl::STR_POWER_KEY, 0, 0, 0,
- ELM_WIN_KEYGRAB_EXCLUSIVE);
-
- m_keyUpEventHandler = ecore_event_handler_add(ECORE_EVENT_KEY_UP,
- CALLBACK_A(Instance::onKeyUpEventCb), this);
- if (!m_keyUpEventHandler) {
- LOG_RETURN(RES_FAIL, "m_eventHandler is NULL");
- }
-
- FAIL_RETURN(setupTheme(), "setupTheme() failed!");
-
- m_call = CallUIBuilder().build();
- if (!m_call) {
- LOG_RETURN(RES_FAIL, "m_call is NULL");
- }
-
- m_navi = Naviframe::Builder().
- build(m_win->getConformant());
- if (!m_navi) {
- LOG_RETURN(RES_FAIL, "Naviframe::build() failed!");
- }
-
- m_win->getConformant().setContent(*m_navi);
- elm_atspi_accessible_translation_domain_set(*m_win, PACKAGE);
- elm_atspi_accessible_name_set(*m_win, AO_STR_CALL);
-
- FAIL_RETURN(utils::createCircleSurface(*m_navi),
- "createCircleSurface() failed!");
-
- m_sysEventProvider.addEventHandler(
- WEAK_DELEGATE(Instance::onSysEvent, asWeak(*this)));
-
- return RES_OK;
- }
-
- void Instance::onPause()
- {
- ILOG("PAUSED");
- }
-
- void Instance::onResume()
- {
- ILOG("RESUMED");
- }
-
- void Instance::onAppControl(app_control_h appControl)
- {
- if (!m_page) {
- auto page = MainPage::Builder().
- setNaviframe(m_navi).
- setCallUI(m_call).
- build(WEAK_DELEGATE(Instance::onPageExitRequest,
- asWeak(this)));
- if (!page) {
- ELOG("Create page failed! Exit application");
- m_context->exitApp();
- }
- m_call->setListener(page);
- m_page = page;
- }
-
- Result res = m_call->processAppControl(appControl);
- if (res != RES_OK) {
- ELOG("processAppControl() failed!");
- ICallManagerSRef callManager = m_call->getCallManager();
- if (!callManager->getAvailableCalls()) {
- ILOG("No calls. Exit application");
- m_context->exitApp();
- }
- }
- }
-
- Result Instance::setupTheme()
- {
- m_theme = Theme::create();
- if (isNotValid(m_theme)) {
- LOG_RETURN(RES_FAIL, "Theme::create() failed!");
- }
-
- m_theme.addExtension(getResPath(THEME_EDJE_PATH));
-
- m_win->setTheme(m_theme);
-
- return RES_OK;
- }
-
- Eina_Bool Instance::onKeyUpEventCb(int type, void *event)
- {
- if (!event) {
- LOG_RETURN_VALUE(RES_FAIL, ECORE_CALLBACK_DONE, "event is NULL");
- }
-
- Ecore_Event_Key *ev = static_cast<Ecore_Event_Key *>(event);
- if (!strcmp(ev->keyname, impl::STR_POWER_KEY)) {
- DLOG("Key power [Up]");
- m_win->callEvent(WIN_POWER_KEY_UP_EVENT, nullptr);
- }
- return ECORE_CALLBACK_DONE;
- }
-
- void Instance::onPageExitRequest(Page &page)
- {
- m_context->exitApp();
- }
-
- void Instance::onSysEvent(const SysEvent sysEvent)
- {
- switch(sysEvent) {
- case SysEvent::LANGUAGE_CHANGED:
- ILOG("SysEvent::LANGUAGE_CHANGED");
- {
- char *locale = NULL;
- system_settings_get_value_string(
- SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
- elm_language_set(locale);
- free(locale);
- }
- break;
- default:
- ILOG("sysEvent: %d", sysEvent);
- break;
- }
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "presenters/InstanceManager.h"
-
-#include "presenters/Instance.h"
-
-namespace callui {
-
- using namespace ucl;
-
- InstanceManager::InstanceManager() :
- InstanceManagerBase(AppParams().
- set(AppParam::WINDOW_NAME, WINDOW_NAME).
- set(AppParam::BASE_SCALE, BASE_SCALE))
- {
- }
-
- IInstanceSRef InstanceManager::newInstance() const
- {
- return makeShared<Instance>(getSysEventProvider());
- }
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "presenters/KeypadPage.h"
-#include "view/VolumeControl.h"
-
-#include "presenters/AtspiHighlightHelper.h"
-
-#include "resources.h"
-#include "common.h"
-
-namespace callui { namespace { namespace impl {
-
- using namespace ucl;
-
- constexpr LayoutTheme LAYOUT_KEYPAD_WIDGET
- {"layout", "callui", "keypad"};
-
- constexpr EdjePart PART_SWL_ENTRY {"swl.entry"};
-
- constexpr SmartEvent BTN_PRESSED {"pressed"};
- constexpr SmartEvent BTN_UNPRESSED {"unpressed"};
-
- constexpr EoDataKey BTN_DATA_KEY {"btnData"};
-
- enum {
- KEYPAD_BTN_MAX_COUNT = 13
- };
-
- enum class OperationType {
- DTMF,
- VOLUME
- };
-
- struct ButtonInfo {
- OperationType type;
- const char *str;
- ElmStyle style;
- EdjePart swlPart;
- };
-
- static ButtonInfo buttonsInfo[KEYPAD_BTN_MAX_COUNT] =
- {
- { OperationType::DTMF, "1",
- ElmStyle {"callui/keypad_one"}, EdjePart {"swl.one"} },
- { OperationType::DTMF, "2",
- ElmStyle {"callui/keypad_two"}, EdjePart {"swl.two"} },
- { OperationType::DTMF, "3",
- ElmStyle {"callui/keypad_three"}, EdjePart {"swl.three"} },
- { OperationType::DTMF, "4",
- ElmStyle {"callui/keypad_four"}, EdjePart {"swl.four"} },
- { OperationType::DTMF, "5",
- ElmStyle {"callui/keypad_five"}, EdjePart {"swl.five"} },
- { OperationType::DTMF, "6",
- ElmStyle {"callui/keypad_six"}, EdjePart {"swl.six"} },
- { OperationType::DTMF, "7",
- ElmStyle {"callui/keypad_seven"}, EdjePart {"swl.seven"} },
- { OperationType::DTMF, "8",
- ElmStyle {"callui/keypad_eight"}, EdjePart {"swl.eight"} },
- { OperationType::DTMF, "9",
- ElmStyle {"callui/keypad_nine"}, EdjePart {"swl.nine"} },
- { OperationType::DTMF, "0",
- ElmStyle {"callui/keypad_zero"}, EdjePart {"swl.zero"} },
- { OperationType::DTMF, "#",
- ElmStyle {"callui/keypad_sharp"}, EdjePart {"swl.sharp"} },
- { OperationType::DTMF, "*",
- ElmStyle {"callui/keypad_asterix"}, EdjePart {"swl.asterix"} },
- { OperationType::VOLUME, "",
- ElmStyle {"callui/keypad_speaker"}, EdjePart {"swl.speaker"} }
- };
-}}}
-
-namespace callui {
- using namespace ucl;
-
- // KeypadPage::Builder
-
- KeypadPage::Builder::Builder()
- {
- }
-
- KeypadPage::Builder::~Builder()
- {
- }
-
- KeypadPage::Builder &KeypadPage::Builder::setNaviframe(
- const NaviframeSRef &navi)
- {
- m_navi = navi;
- return *this;
- }
-
- KeypadPage::Builder
- &KeypadPage::Builder::setSoundManager(const ISoundManagerSRef &sm)
- {
- m_sm = sm;
- return *this;
- }
-
- KeypadPageSRef KeypadPage::Builder::build(
- const ExitRequestHandler onExitRequest) const
- {
- if (!onExitRequest) {
- LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
- "onExitRequest is NULL");
- }
- if (!m_navi) {
- LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
- "m_navi is NULL");
- }
-
- if (!m_sm) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "m_sm is NULL");
- }
-
- auto result = makeShared<KeypadPage>(m_sm, m_navi, onExitRequest);
-
- FAIL_RETURN_VALUE(result->prepare([&result](NaviItem &item)
- {
- return result->doPrepare(item);
- }),
- {}, "result->prepare() failed!");
-
- return result;
- }
-
- // KeypadPage
-
- KeypadPage::KeypadPage(IRefCountObj &rc,
- const ISoundManagerSRef &sm,
- const NaviframeSRef &navi,
- const ExitRequestHandler onExitRequest):
- Page(rc, navi, onExitRequest),
- m_sm(sm),
- m_smInUse(false),
- m_vcTimer(nullptr),
- m_audioState(m_sm->getAudioState())
- {
- }
-
- KeypadPage::~KeypadPage()
- {
- stopDtmf();
- stopVCTimer();
- unregisterCallbacks();
- }
-
- Result KeypadPage::doPrepare(NaviItem &item)
- {
- FAIL_RETURN(createWidget(), "createWidget() failed!");
-
- FAIL_RETURN(createEntry(), "createEntry() failed!");
-
- FAIL_RETURN(createButtons(), "createButtons() failed!");
-
- FAIL_RETURN(createVolumeControl(), "createVolumeControl() failed!");
-
- registerCallbacks();
-
- updateVolume(m_sm->getVolume());
-
- FAIL_RETURN(createAtspiHighlightHelper(),
- "createAtspiHighlightHelper() failed!");
-
- item = getNaviframe().push(*m_widget);
- if (!item) {
- LOG_RETURN(RES_FAIL, "Naviframe::push() failed!");
- }
-
- return RES_OK;
- }
-
- void KeypadPage::onBtnPressed(Widget &widget, void *eventInfo)
- {
- impl::ButtonInfo *info =
- static_cast<impl::ButtonInfo*>(widget.getData(impl::BTN_DATA_KEY));
- DLOG("Button pressed [%c]", *(info->str));
-
- if (info->type == impl::OperationType::DTMF) {
- elm_entry_entry_append(*m_entry, info->str);
- elm_entry_cursor_end_set(*m_entry);
- startDtmf(*(info->str));
- }
- }
-
- void KeypadPage::onBtnUnpressed(Widget &widget, void *eventInfo)
- {
- impl::ButtonInfo *info =
- static_cast<impl::ButtonInfo*>(widget.getData(impl::BTN_DATA_KEY));
- DLOG("Button unpressed [%c]", *(info->str));
- stopDtmf();
- }
-
- void KeypadPage::onBtnClicked(Widget &widget, void *eventInfo)
- {
- impl::ButtonInfo *info =
- static_cast<impl::ButtonInfo*>(widget.getData(impl::BTN_DATA_KEY));
-
- if(info->type == impl::OperationType::VOLUME) {
- DLOG("Button clicked [volume]");
- show(*m_vc);
- startVCTimer();
-
- elm_atspi_component_highlight_grab(*m_vc);
- }
- }
-
- Result KeypadPage::createWidget()
- {
- m_widget = Layout::Builder().
- setTheme(impl::LAYOUT_KEYPAD_WIDGET).
- setIsOwner(true).
- build(getNaviframe());
-
- if (!m_widget) {
- LOG_RETURN(RES_FAIL, "Layout::build() failed!");
- }
-
- setDeactivatorSink(m_widget);
-
- return RES_OK;
- }
-
- ucl::Result KeypadPage::createEntry()
- {
- Evas_Object *entry = elm_entry_add(*m_widget);
- if (!entry) {
- LOG_RETURN(RES_FAIL, "elm_entry_add() failed!");
- }
- m_entry = makeShared<ElmWidget>(entry, true);
-
- static Elm_Entry_Filter_Accept_Set digitsFilterData;
-
- digitsFilterData.accepted = "0123456789*#";
- digitsFilterData.rejected = nullptr;
-
- elm_entry_single_line_set(entry, EINA_TRUE);
- elm_entry_editable_set(entry, EINA_FALSE);
- elm_entry_scrollable_set(entry, EINA_TRUE);
- elm_entry_markup_filter_append(entry,
- elm_entry_filter_accept_set, &digitsFilterData);
-
- m_widget->setContent(entry, impl::PART_SWL_ENTRY);
- show(*m_entry);
-
- return RES_OK;
- }
-
- ucl::Result KeypadPage::createButtons()
- {
- Evas_Object *button;
- StyledWidgetSRef buttonSRef;
-
- for (int i = 0; i < impl::KEYPAD_BTN_MAX_COUNT; ++i) {
- button = elm_button_add(*m_widget);
-
- if (!button) {
- LOG_RETURN(RES_FAIL, "elm_button_add() failed!");
- }
-
- buttonSRef = makeShared<StyledWidget>(button);
- buttonSRef->bindToEo();
- buttonSRef->setData(impl::BTN_DATA_KEY, &(impl::buttonsInfo[i]));
- buttonSRef->setStyle(impl::buttonsInfo[i].style);
-
- if (impl::buttonsInfo[i].type == impl::OperationType::DTMF) {
- buttonSRef->addEventHandler(impl::BTN_PRESSED,
- WEAK_DELEGATE(KeypadPage::onBtnPressed,
- asWeak(*this)));
-
- buttonSRef->addEventHandler(impl::BTN_UNPRESSED,
- WEAK_DELEGATE(KeypadPage::onBtnUnpressed,
- asWeak(*this)));
- } else {
- buttonSRef->addEventHandler(BTN_CLICKED,
- WEAK_DELEGATE(KeypadPage::onBtnClicked,
- asWeak(*this)));
- }
-
- // Screen Reader
- elm_atspi_accessible_name_cb_set(*buttonSRef,
- [](void *data, Evas_Object *obj) -> char *
- {
- impl::ButtonInfo *info =
- static_cast<impl::ButtonInfo*>(asWidget(obj)->
- getData(impl::BTN_DATA_KEY));
- if (info->type == impl::OperationType::DTMF) {
- return strdup(info->str);
- } else {
- return strdup(AO_STR_VOLUME.translate());
- }
- return nullptr;
- },
- this);
-
- m_widget->setContent(button, impl::buttonsInfo[i].swlPart);
- show(*buttonSRef);
- }
-
- return RES_OK;
- }
-
- void KeypadPage::startDtmf(const unsigned char digit)
- {
- stopDtmf();
- m_smInUse = true;
- m_sm->startDtmf(digit);
- }
-
- void KeypadPage::stopDtmf()
- {
- if (m_smInUse) {
- m_sm->stopDtmf();
- m_smInUse = false;
- }
- }
-
- Result KeypadPage::createVolumeControl()
- {
- m_vc = VolumeControl::Builder().
- setInfoText(STR_VOLUME).
- setMaxValue(m_sm->getMaxVolume()).
- setEventHandler(WEAK_DELEGATE(
- KeypadPage::onVolumeControlEventCb,
- asWeak(*this))).
- build(*m_widget);
- if (!m_vc) {
- LOG_RETURN(RES_FAIL, "VolumeControl::build() failed");
- }
-
- auto window = m_vc->getWindow();
- if (!window) {
- LOG_RETURN(RES_FAIL, "Window is NULL!");
- }
- int w = 0, h = 0;
- window->getScreenSize(&w, &h);
-
- m_vc->move(0, 0);
- m_vc->resize(w, h);
- hide(*m_vc);
-
- registerVolumeControlAo();
-
- return RES_OK;
- }
-
- void KeypadPage::onBackKey()
- {
- if (m_vcTimer) {
- stopVCTimer();
- hide(*m_vc);
- } else {
- requestExit();
- }
- }
-
- void KeypadPage::onVolumeControlEventCb(VolumeControlEvent event)
- {
- if (!isActive()) {
- LOG_RETURN_VOID(RES_OK, "Presenter is not active. Ignore");
- }
-
- if (!m_vcTimer) {
- DLOG("Ignore as control is hidden");
- return;
- }
-
- restartVCTimer();
-
- switch (event) {
- case VolumeControlEvent::INCREASE:
- tryIncreaseVolume();
- break;
- case VolumeControlEvent::DECREASE:
- tryDecreaseVolume();
- break;
- default:
- break;
- }
- }
-
- void KeypadPage::updateVolume(int value)
- {
- m_vc->setValue(value);
-
- auto max = m_sm->getMaxVolume();
- auto cur = m_sm->getVolume();
-
- if (cur == max) {
- m_vc->setIncreaseBtnEnable(false);
- m_vc->setDecreaseBtnEnable(true);
- } else if (cur <= VOLUME_LEVEL_MIN) {
- m_vc->setIncreaseBtnEnable(true);
- m_vc->setDecreaseBtnEnable(false);
- } else {
- m_vc->setIncreaseBtnEnable(true);
- m_vc->setDecreaseBtnEnable(true);
- }
-
- // Screen Reader
- if (m_vc->isVisible()) {
- elm_atspi_bridge_utils_say(std::to_string(cur).c_str(),
- EINA_FALSE, nullptr, nullptr);
- }
- }
-
- void KeypadPage::onAudioStateChanged(AudioStateType state)
- {
- if ((m_audioState != AudioStateType::BT &&
- state == AudioStateType::BT) ||
- (m_audioState == AudioStateType::BT &&
- state != AudioStateType::BT)) {
- m_audioState = state;
-
- m_vc->setValue(0);
-
- auto maxVol = m_sm->getMaxVolume();
- m_vc->setMaxValue(maxVol);
-
- updateVolume(m_sm->getVolume());
- }
- }
-
- void KeypadPage::onVolumeLevelChanged(int value)
- {
- updateVolume(value);
- }
-
- Eina_Bool KeypadPage::onVCTimerCb()
- {
- hide(*m_vc);
- m_vcTimer = nullptr;
-
- return ECORE_CALLBACK_CANCEL;
- }
-
- void KeypadPage::startVCTimer()
- {
- stopVCTimer();
-
- auto timerInterval = CALL_VC_TIMER_INTERVAL;
- if (elm_atspi_bridge_utils_is_screen_reader_enabled()) {
- timerInterval = CALL_VC_SCREEN_READER_TIMER_INTERVAL;
- }
-
- m_vcTimer = ecore_timer_add(timerInterval,
- CALLBACK_B(KeypadPage::onVCTimerCb),
- this);
- }
-
- void KeypadPage::restartVCTimer()
- {
- if (m_vcTimer) {
- ecore_timer_reset(m_vcTimer);
- }
- }
-
- void KeypadPage::stopVCTimer()
- {
- if (m_vcTimer) {
- ecore_timer_del(m_vcTimer);
- m_vcTimer = nullptr;
- }
- }
-
- void KeypadPage::tryIncreaseVolume()
- {
- auto max = m_sm->getMaxVolume();
- auto cur = m_sm->getVolume();
-
- if (max != cur) {
- m_sm->setVolume(cur + 1);
- }
- }
-
- void KeypadPage::tryDecreaseVolume()
- {
- auto cur = m_sm->getVolume();
-
- if (cur - 1 >= VOLUME_LEVEL_MIN) {
- m_sm->setVolume(cur - 1);
- }
- }
-
- Eina_Bool KeypadPage::onRotaryEvent(Eext_Rotary_Event_Info *info)
- {
- if (!isActive()) {
- LOG_RETURN_VALUE(RES_OK,
- EINA_TRUE,
- "Presenter is not active. Ignore");
- }
-
- if (!m_vcTimer) {
- DLOG("Ignore as control is hidden");
- return EINA_FALSE;
- }
-
- restartVCTimer();
-
- if (info->direction == EEXT_ROTARY_DIRECTION_CLOCKWISE) {
- tryIncreaseVolume();
- } else {
- tryDecreaseVolume();
- }
-
- return EINA_TRUE;
- }
-
- void KeypadPage::registerCallbacks()
- {
- addRotaryEventHandler(CALLBACK_A(
- KeypadPage::onRotaryEvent), this);
-
- m_sm->addAudioStateHandler(DELEGATE(
- KeypadPage::onAudioStateChanged, this));
-
- m_sm->addVolumeStateHandler(DELEGATE(
- KeypadPage::onVolumeLevelChanged, this));
- }
-
- void KeypadPage::unregisterCallbacks()
- {
- delRotaryEventHandler(
- CALLBACK_A(KeypadPage::onRotaryEvent), this);
-
- m_sm->delAudioStateHandler(DELEGATE(
- KeypadPage::onAudioStateChanged, this));
-
- m_sm->delVolumeStateHandler(DELEGATE(
- KeypadPage::onVolumeLevelChanged, this));
- }
-
- // Screen Reader
- Result KeypadPage::createAtspiHighlightHelper()
- {
- m_atspiHelper = AtspiHighlightHelper::newInstance(*this, getWindow());
- if (!m_atspiHelper) {
- LOG_RETURN(RES_FAIL,
- "AtspiHighlightHelper::newInstance() failed!");
- }
-
- m_atspiHelper->setRelationEventHandler(WEAK_DELEGATE(
- KeypadPage::onAtspiHighlight, asWeak(*this)));
-
- m_atspiHelper->registerWidget(*getFirstButton());
- m_atspiHelper->registerWidget(*getLastButton());
- m_atspiHelper->registerWidget(*m_vc.get());
- m_atspiHelper->registerWidget(*m_vc->getDecreaseBtn());
- m_atspiHelper->registerWidget(*m_vc->getIncreaseBtn());
- m_atspiHelper->registerWidget(*m_vc->getValueTxtAo());
-
- return RES_OK;
- }
-
- Elm_Interface_Atspi_Accessible *KeypadPage::onAtspiHighlight(
- Elm_Interface_Atspi_Accessible *ao,
- Elm_Atspi_Relation_Type flowRelation)
- {
- DLOG("FlowRelation [%s]",
- flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM ?
- "FROM" : "TO");
-
- auto firstBtn = getFirstButton();
- auto lastBtn = getLastButton();
- auto vcLayout = m_vc.get();
- auto vcDecrVolumeBtn = m_vc->getDecreaseBtn();
- auto vcIncrVolumeBtn = m_vc->getIncreaseBtn();
- auto vcVolumeValueAo = m_vc->getValueTxtAo();
-
- if (ao == *firstBtn) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return nullptr;
- }
- } else if (ao == *lastBtn) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
- return nullptr;
- }
- } else if (ao == *vcLayout) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return *vcDecrVolumeBtn;
- }
- } else if (ao == *vcDecrVolumeBtn) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return *vcVolumeValueAo;
- } else {
- return *vcLayout;
- }
- } else if (ao == *vcVolumeValueAo) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return *vcIncrVolumeBtn;
- } else {
- return *vcDecrVolumeBtn;
- }
- } else if (ao == *vcIncrVolumeBtn) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
- return *vcVolumeValueAo;
- }
- } else if (ao == getWindow()) {
- return *firstBtn;
- } else {
- LOG_RETURN_VALUE(RES_FAIL, nullptr, "Unknown object!");
- }
-
- return ao;
- }
-
- ElmWidget *KeypadPage::getFirstButton()
- {
- return dynamicWidgetCast<ElmWidget>(
- m_widget->getContent(impl::buttonsInfo[0].swlPart));
- }
-
- ElmWidget *KeypadPage::getLastButton()
- {
- return dynamicWidgetCast<ElmWidget>(
- m_widget->getContent(impl::buttonsInfo[(
- impl::KEYPAD_BTN_MAX_COUNT - 1)].swlPart));
- }
-
- void KeypadPage::registerVolumeControlAo()
- {
- auto decrBtn = m_vc->getDecreaseBtn();
-
- if (decrBtn) {
- decrBtn->addEventHandler(ATSPI_HIGHLIGHTED,
- WEAK_DELEGATE(KeypadPage::
- onVolumeControlScreenReaderReadStart,
- asWeak(*this)));
- }
-
- auto incrBtn = m_vc->getIncreaseBtn();
- if (incrBtn) {
- incrBtn->addEventHandler(ATSPI_HIGHLIGHTED,
- WEAK_DELEGATE(KeypadPage::
- onVolumeControlScreenReaderReadStart,
- asWeak(*this)));
- }
- }
-
- void KeypadPage::onVolumeControlScreenReaderReadStart(
- Widget &widget,
- void *eventInfo)
- {
- restartVCTimer();
- }
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "presenters/MainPage.h"
-
-#include "ucl/gui/Window.h"
-#include "ucl/gui/Widget.h"
-
-#include "model/ICallUI.h"
-#include "model/ICallManager.h"
-#include "model/IIncomingCall.h"
-#include "model/IActiveCall.h"
-#include "model/IHeldCall.h"
-#include "model/IEndCall.h"
-#include "model/IIndicatorStateProvider.h"
-#include "model/ICallInfo.h"
-#include "model/IRejectMsgProvider.h"
-
-#include "presenters/IndicatorPresenter.h"
-#include "presenters/AcceptRejectPresenter.h"
-#include "presenters/CallInfoPresenter.h"
-#include "presenters/RejectMsgPresenter.h"
-#include "presenters/AccessoryPresenter.h"
-#include "presenters/MoreOptionsPresenter.h"
-#include "presenters/DeviceStatePresenter.h"
-
-#include "presenters/AtspiHighlightHelper.h"
-
-#include "resources.h"
-#include "common.h"
-
-namespace callui { namespace { namespace impl {
-
- using namespace ucl;
-
- constexpr double CU_RECALL_BTN_SHOW_TIMEOUT = 1.0;
- constexpr double CU_EXIT_APP_TIMEOUT = 4.0;
-
- constexpr LayoutTheme LAYOUT_MAIN_WIDGET
- {"layout", "callui", "main"};
-
- constexpr LayoutTheme LAYOUT_REJECT_MSG_WIDGET
- {"layout", "callui", "reject_msg"};
-
- constexpr EdjePart PART_SWL_INDICATOR {"swl.indicator"};
- constexpr EdjePart PART_SWL_ACCEPT_REJECT {"swl.accept_reject"};
- constexpr EdjePart PART_SWL_CALL_INFO {"swl.call_info"};
- constexpr EdjePart PART_SWL_REJECT_MSG {"swl.rm"};
- constexpr EdjePart PART_SWL_BOTTOM_BTN {"swl.bottom_btn"};
- constexpr EdjePart PART_SWL_OVERLAY {"swl.overlay"};
- constexpr EdjePart PART_SWL_MORE_OPTION {"swl.more_option"};
-
- constexpr EdjePart PART_TXT_REJECT_MSG_CUE_AO {"ao_cue"};
-
- constexpr EdjePart PART_TXT_REJECT_MSG {"reject_msg_text"};
- constexpr ElmStyle STYLE_BB_END_CALL {"callui/end_call"};
- constexpr ElmStyle STYLE_BB_RECALL {"callui/call_back"};
-}}}
-
-namespace callui {
-
- using namespace ucl;
-
- // MainPage::Builder
-
- MainPage::Builder::Builder()
- {
- }
-
- MainPage::Builder::~Builder()
- {
- }
-
- MainPage::Builder &MainPage::Builder::setNaviframe(
- const NaviframeSRef &navi)
- {
- m_navi = navi;
- return *this;
- }
-
- MainPage::Builder &MainPage::Builder::setCallUI(
- const ICallUISRef &call)
- {
- m_call = call;
- return *this;
- }
-
- MainPageSRef MainPage::Builder::build(
- const ExitRequestHandler handler) const
- {
- if (!handler) {
- LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
- "onExitRequest is NULL");
- }
- if (!m_navi) {
- LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
- "m_navi is NULL");
- }
- if (!m_call) {
- LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
- "m_call is NULL");
- }
-
- auto result = makeShared<MainPage>(
- m_navi, handler, m_call);
-
- FAIL_RETURN_VALUE(result->prepare([&result](NaviItem &item)
- {
- return result->doPrepare(item);
- }),
- {}, "result->prepare() failed!");
-
- return result;
- }
-
- // MainPage
-
- MainPage::MainPage(IRefCountObj &rc,
- const NaviframeSRef &navi,
- const ExitRequestHandler handler,
- const ICallUISRef &call) :
- Page(rc, navi, handler),
- m_call(call),
- m_mode(CallMode::UNDEFINED),
- m_ecTimer(nullptr),
- m_ecTimerBtnReq(false)
- {
- }
-
- MainPage::~MainPage()
- {
- }
-
- Result MainPage::doPrepare(NaviItem &item)
- {
- m_cm = m_call->getCallManager();
- if (!m_cm) {
- LOG_RETURN(RES_FAIL, "Call manager is NULL!");
- }
-
- FAIL_RETURN(createWidget(), "createWidget() failed!");
- FAIL_RETURN(createIndicatorPresenter(), "createIndicatorPresenter() failed!");
- FAIL_RETURN(createDisplayPresenter(), "createDisplayPresenter() failed!");
-
- auto win = m_widget->getWindow();
- if (!win) {
- LOG_RETURN(RES_FAIL, "win is NULL!");
- }
- win->addEventHandler(WIN_POWER_KEY_UP_EVENT, WEAK_DELEGATE(
- MainPage::onPowerKeyUp, asWeak(*this)));
-
- item = getNaviframe().push(*m_widget);
- if (!item) {
- LOG_RETURN(RES_FAIL, "Naviframe::push() failed!");
- }
-
- return RES_OK;
- }
-
- void MainPage::processKeyPress()
- {
- switch (m_mode) {
- case CallMode::INCOMING:
- {
- auto incom = m_cm->getIncomingCall();
- if (!incom) {
- LOG_RETURN_VOID(RES_FAIL, "incom is NULL");
- }
- incom->stopAlert();
- break;
- }
- case CallMode::END:
- requestExit();
- break;
- default:
- if (m_accessoryPrs) {
- m_accessoryPrs->hideVolumeControls();
- }
- break;
- }
- }
-
- void MainPage::onBackKey()
- {
- processKeyPress();
- }
-
- void MainPage::onPowerKeyUp(Widget &widget, void *eventInfo)
- {
- if (isActive()) {
- processKeyPress();
- }
- }
-
- Result MainPage::processIncomingCallMode()
- {
- m_accessoryPrs.reset();
-
- auto call = m_cm->getIncomingCall();
- if (!call) {
- LOG_RETURN(RES_FAIL, "incom is NULL");
- }
-
- FAIL_RETURN(createAcceptRejectPresenter(),
- "createAcceptRejectPresenter() failed!");
-
- auto provider = call->getRejectMsgProvider();
- if (!provider) {
- ELOG("Reject message provider is NULL");
- }
-
- if (!isUnknownCaller(*call->getInfo())
- && (provider && provider->getMsgCount() > 0)) {
-
- FAIL_RETURN(createRejectMsgPresenter(provider),
- "createRejectMsgPresenter() failed!");
-
- FAIL_RETURN(createRejectMsgCue(),
- "craeteRejectMsgCue() failed!");
-
- if (createRejectMsgCueAo() != RES_OK) {
- ELOG("createRejectMsgCueAo() failed!");
- }
- }
-
- if (m_indicator) {
- m_indicator->udapteIncomingCallMode(true);
- }
-
- return RES_OK;
- }
-
- Result MainPage::createRejectMsgCue()
- {
- m_rmLy = Layout::Builder().
- setTheme(impl::LAYOUT_REJECT_MSG_WIDGET).
- setIsOwner(true).
- build(*m_widget);
- if (!m_rmLy) {
- LOG_RETURN(RES_FAIL, "Layout::build() failed!");
- }
-
- m_rmLy->setText(STR_DECLINE_MESSAGES, impl::PART_TXT_REJECT_MSG);
- m_widget->setContent(*m_rmLy, impl::PART_SWL_REJECT_MSG);
-
- return RES_OK;
- }
-
- Result MainPage::processEndCallMode()
- {
- if (m_indicator) {
- m_indicator->udapteIncomingCallMode(false);
- }
-
- FAIL_RETURN(createAccessoryPresenter(),
- "createAccessoryPresenter() failed");
-
-
- auto end = m_cm->getEndCall();
- if (end) {
- auto info = end->getInfo();
- if (info && info->getConferenceMemberCount() == 1) {
- FAIL_RETURN(createBottomBtn(impl::STYLE_BB_RECALL, false),
- "createBottomBtn() failed");
- hide(*m_bottomBtn);
- }
- } else {
- ELOG("End call is NULL!");
- }
-
- startEndCallTimer();
-
- return RES_OK;
- }
-
- Result MainPage::processRegularCallModes()
- {
- m_rmPrs.reset();
- m_acceptRejectPrs.reset();
- m_rmLy.reset();
- m_rmCueAo.reset();
-
- if (m_indicator) {
- m_indicator->udapteIncomingCallMode(false);
- }
-
- FAIL_RETURN(createAccessoryPresenter(),
- "createAccessoryPresenter() failed");
- FAIL_RETURN(createMoreOptionsPresenter(),
- "createMoreOptionsPresenter() failed");
- FAIL_RETURN(createBottomBtn(impl::STYLE_BB_END_CALL),
- "createBottomBtn() failed");
-
- return RES_OK;
- }
-
- void MainPage::updateCallMode()
- {
- auto incom = m_cm->getIncomingCall();
- auto active = m_cm->getActiveCall();
- auto held = m_cm->getHeldCall();
- auto end = m_cm->getEndCall();
-
- m_mode = CallMode::UNDEFINED;
-
- if (incom) {
- DLOG("Mode [Incoming call]");
- m_mode = CallMode::INCOMING;
- } else if (active && active->isDialingMode()) {
- DLOG("Mode [Outgoing call]");
- m_mode = CallMode::OUTGOING;
- } else if (active || held) {
- DLOG("Mode [During call]");
- m_mode = CallMode::DURING;
- } else if (end) {
- DLOG("Mode [End call]");
- m_mode = CallMode::END;
- } else {
- DLOG("Mode [Undefined]");
- }
- }
-
- Result MainPage::showWindow()
- {
- auto win = getNaviframe().getWindow();
- if (!win) {
- LOG_RETURN(RES_FAIL, "win is NULL");
- }
-
- if (!win->isVisible() &&
- (m_mode == CallMode::INCOMING
- || m_mode == CallMode::OUTGOING)) {
- show(*win);
- }
- return RES_OK;
- }
-
- void MainPage::onBottomBtnClicked(Widget &widget, void *eventInfo)
- {
- auto active = m_cm->getActiveCall();
- auto held = m_cm->getHeldCall();
- auto end = m_cm->getEndCall();
-
- if (active) {
- active->end();
- } else if (held) {
- held->end();
- } else if (end) {
- stopEndCallTimer();
- end->callBack();
- }
- }
-
- void MainPage::startEndCallTimer()
- {
- stopEndCallTimer();
-
- m_ecTimer = ecore_timer_add(
- impl::CU_RECALL_BTN_SHOW_TIMEOUT,
- CALLBACK_B(MainPage::onEndCallTimerCb),
- this);
- }
-
- void MainPage::stopEndCallTimer()
- {
- m_ecTimerBtnReq = false;
-
- if (m_ecTimer) {
- ecore_timer_del(m_ecTimer);
- m_ecTimer = nullptr;
- }
- }
-
- Result MainPage::createBottomBtn(const ElmStyle &style, bool setVisible)
- {
- m_bottomBtn = makeShared<StyledWidget>(
- elm_button_add(*m_widget), true);
- m_bottomBtn->setStyle(style);
-
- m_bottomBtn->addEventHandler(BTN_CLICKED,
- WEAK_DELEGATE(MainPage::onBottomBtnClicked,
- asWeak(*this)));
-
- elm_atspi_accessible_translation_domain_set(*m_bottomBtn, PACKAGE);
- if (style == impl::STYLE_BB_RECALL) {
- elm_atspi_accessible_name_set(*m_bottomBtn, AO_STR_CALLBACK);
- } else {
- elm_atspi_accessible_name_set(*m_bottomBtn, AO_STR_END_CALL);
- }
-
- if (setVisible) {
- m_widget->setContent(*m_bottomBtn, impl::PART_SWL_BOTTOM_BTN);
- show(*m_bottomBtn);
- } else {
- hide(*m_bottomBtn);
- }
-
- return RES_OK;
- }
-
- Eina_Bool MainPage::onEndCallTimerCb()
- {
- if (!m_ecTimerBtnReq) {
- if (!m_bottomBtn) {
- m_ecTimer = nullptr;
- requestExit();
- LOG_RETURN_VALUE(RES_FAIL, ECORE_CALLBACK_CANCEL, "bottom button is NULL!");
- }
- m_widget->setContent(*m_bottomBtn, impl::PART_SWL_BOTTOM_BTN);
- show(*m_bottomBtn);
-
- ecore_timer_interval_set(m_ecTimer, impl::CU_EXIT_APP_TIMEOUT);
- m_ecTimerBtnReq = true;
-
- return ECORE_CALLBACK_RENEW;
- } else {
- m_ecTimer = nullptr;
- requestExit();
-
- return ECORE_CALLBACK_CANCEL;
- }
- }
-
- void MainPage::onCallEvent(CallEventType type)
- {
- ILOG("CallEventType [%d]", static_cast<int>(type));
-
- stopEndCallTimer();
-
- CallMode prevMode = m_mode;
- updateCallMode();
-
- if (m_mode == CallMode::UNDEFINED) {
- requestExit();
- return;
- }
-
- FAIL_RETURN_VOID(showWindow(), "showWindow failed!");
-
- m_acceptRejectPrs.reset();
- m_rmPrs.reset();
- m_moreOptionsPrs.reset();
- m_callInfoPrs.reset();
-
- m_rmLy.reset();
- m_rmCueAo.reset();
- m_bottomBtn.reset();
-
- switch (m_mode) {
- case CallMode::INCOMING:
- FAIL_RETURN_VOID(processIncomingCallMode(),
- "processIncomingCall() failed!");
- break;
- case CallMode::END:
- FAIL_RETURN_VOID(processEndCallMode(),
- "processEndCallMode() failed!");
- break;
- default:
- FAIL_RETURN_VOID(processRegularCallModes(),
- "processRegularCallModes() failed!");
- break;
- }
-
- FAIL_RETURN_VOID(createCallInfoPresenter(m_mode),
- "createCallInfoPresenter() failed!");
-
- FAIL_RETURN_VOID(updateDeviceState(prevMode, m_mode),
- "updateDeviceState() failed!");
-
- createAtspiHighlightHelper();
- }
-
- Result MainPage::updateDeviceState(CallMode prevMode, CallMode curMode)
- {
- if (curMode == CallMode::INCOMING && curMode != prevMode) {
- m_devicePrs->setDisplayState(DisplayState::ON);
- m_devicePrs->setDisplayMode(DisplayMode::TOP_PRIORITY);
- m_devicePrs->setCpuLockState(true);
- } else if (prevMode == CallMode::INCOMING && prevMode != curMode) {
- m_devicePrs->setDisplayMode(DisplayMode::REGULAR);
- m_devicePrs->setCpuLockState(false);
- }
-
- if (curMode == CallMode::END) {
- m_devicePrs->setDisplayState(DisplayState::ON);
- }
-
- return RES_OK;
- }
-
- Result MainPage::createWidget()
- {
- m_widget = Layout::Builder().
- setTheme(impl::LAYOUT_MAIN_WIDGET).
- setIsOwner(true).
- build(getNaviframe());
-
- if (!m_widget) {
- LOG_RETURN(RES_FAIL, "Layout::build() failed!");
- }
-
- setDeactivatorSink(m_widget);
-
- return RES_OK;
- }
-
- Result MainPage::createIndicatorPresenter()
- {
- m_indicator = IndicatorPresenter::Builder().
- setIndicatorStateProvider(
- m_call->getIndicatorStateProvider()).
- setParentWidget(m_widget).
- build(*this);
-
- if (!m_indicator) {
- LOG_RETURN(RES_FAIL, "Indicator::build() failed!");
- }
-
- m_widget->setContent(m_indicator->getWidget(),
- impl::PART_SWL_INDICATOR);
-
- return RES_OK;
- }
-
- Result MainPage::createDisplayPresenter()
- {
- auto win = m_widget->getWindow();
- if (!win) {
- LOG_RETURN(RES_FAIL, "win is NULL!");
- }
-
- m_devicePrs = DeviceStatePresenter::Builder().
- setDisplayState(DisplayState::ON).
- build(asShared(win));
-
- if (!m_devicePrs) {
- LOG_RETURN(RES_FAIL, "DisplayPresenter::build() failed!");
- }
-
- return RES_OK;
- }
-
- void MainPage::onExitAppRequest()
- {
- requestExit();
- }
-
- Result MainPage::createAccessoryPresenter()
- {
- if (m_accessoryPrs) {
- ILOG("Already exists. No need to create new one. Just update.");
- m_accessoryPrs->update(m_cm);
- return RES_OK;
- }
-
- m_accessoryPrs = AccessoryPresenter::Builder().
- setSoundManager(m_call->getSoundManager()).
- setCallManager(m_cm).
- setRequestExitHandler(WEAK_DELEGATE(MainPage::onExitAppRequest,
- asWeak(*this))).
- setParentWidget(m_widget).
- build(*this);
-
- if (!m_accessoryPrs) {
- LOG_RETURN(RES_FAIL,
- "AccessoryPresenter::build() failed!");
- }
-
- m_widget->setContent(m_accessoryPrs->getWidget(),
- impl::PART_SWL_OVERLAY);
-
- return RES_OK;
- }
-
- Result MainPage::createMoreOptionsPresenter()
- {
- if (m_moreOptionsPrs) {
- ILOG("Already exists. No need to create new one. Just update.");
- m_moreOptionsPrs->update();
- return RES_OK;
- }
-
- m_moreOptionsPrs = MoreOptionsPresenter::Builder().
- setCallManager(m_cm).
- setSoundManager(m_call->getSoundManager()).
- setNaviframe(asShared(getNaviframe())).
- setParentWidget(m_widget).
- build(*this);
-
- if (!m_moreOptionsPrs) {
- LOG_RETURN(RES_FAIL,
- "MoreOptionsPresenter::build() failed!");
- }
-
- m_widget->setContent(m_moreOptionsPrs->getWidget(),
- impl::PART_SWL_MORE_OPTION);
-
- return RES_OK;
- }
-
- Result MainPage::createAcceptRejectPresenter()
- {
- if (m_acceptRejectPrs) {
- m_acceptRejectPrs->update(m_cm->getAvailableCalls());
- return RES_OK;
- }
-
- m_acceptRejectPrs = AcceptRejectPresenter::Builder().
- setIncomingCall(m_cm->getIncomingCall()).
- setAvailableCallsFlag(m_cm->getAvailableCalls()).
- setSoundManager(m_call->getSoundManager()).
- setParentWidget(m_widget).
- build(*this);
-
- if (!m_acceptRejectPrs) {
- LOG_RETURN(RES_FAIL,
- "AcceptRejectPresenter::build() failed!");
- }
-
- m_widget->setContent(m_acceptRejectPrs->getWidget(),
- impl::PART_SWL_ACCEPT_REJECT);
-
- return RES_OK;
- }
-
- void MainPage::RejectMsgStateCb(RejectMsgState state)
- {
- if (state == RejectMsgState::HIDDEN) {
- show(*m_rmLy);
- show(*m_rmCueAo);
- } else {
- hide(*m_rmLy);
- hide(*m_rmCueAo);
- }
- }
-
- void MainPage::RejectMsgSelectCb(const IRejectMsgSRef &rm)
- {
- auto incom = m_cm->getIncomingCall();
- if (incom) {
- incom->rejectWithMessage(rm);
- }
- }
-
- Result MainPage::createRejectMsgPresenter(
- const IRejectMsgProviderSRef &provider)
- {
- m_rmPrs = RejectMsgPresenter::Builder().
- setProvider(provider).
- setStateHandler(WEAK_DELEGATE(MainPage::RejectMsgStateCb,
- asWeak(*this))).
- setSelectHandler(WEAK_DELEGATE(MainPage::RejectMsgSelectCb,
- asWeak(*this))).
- setParentWidget(m_widget).
- build(*this);
-
- if (!m_rmPrs) {
- LOG_RETURN(RES_FAIL,
- "RejectMessagePresenter::build() failed!");
- }
-
- m_widget->setContent(m_rmPrs->getWidget(),
- impl::PART_SWL_OVERLAY);
-
- return RES_OK;
- }
-
- Result MainPage::createCallInfoPresenter(CallMode mode)
- {
- if (m_callInfoPrs) {
- return m_callInfoPrs->update(mode, m_cm);
- }
-
- m_callInfoPrs = CallInfoPresenter::Builder().
- setCallManager(m_cm).
- setMode(mode).
- setParentWidget(m_widget).
- build(*this);
-
- if (!m_callInfoPrs) {
- LOG_RETURN(RES_FAIL, "CallerInfo::build() failed!");
- }
- m_widget->setContent(m_callInfoPrs->getWidget(),
- impl::PART_SWL_CALL_INFO);
-
- return RES_OK;
- }
-
- void MainPage::onError(CallErr err)
- {
- if (!m_cm->getAvailableCalls()) {
- requestExit();
- }
- }
-
- // Screen Reader
- Result MainPage::createRejectMsgCueAo()
- {
- m_rmCueAo = utils::createAccessObjectFromLyPart(*m_widget,
- *m_rmLy,
- impl::PART_TXT_REJECT_MSG_CUE_AO);
- if (!m_rmCueAo) {
- LOG_RETURN(RES_FAIL, "createAccessObjectFromLyPart() failed!");
- }
- elm_atspi_accessible_translation_domain_set(*m_rmCueAo, PACKAGE);
- elm_atspi_accessible_reading_info_type_set(*m_rmCueAo,
- ELM_ACCESSIBLE_READING_INFO_TYPE_NAME |
- ELM_ACCESSIBLE_READING_INFO_TYPE_DESCRIPTION);
- elm_atspi_accessible_name_set(*m_rmCueAo, AO_STR_DECLINE_MESSAGES);
- elm_atspi_accessible_description_set(*m_rmCueAo,
- AO_STR_SWIPE_UP_WITH_TWO_FINGERS_TO_SEND_A_DECLINE_MESSAGE);
-
- elm_atspi_accessible_gesture_cb_set(*m_rmCueAo,
- [](void *data, Elm_Atspi_Gesture_Info gesture, Evas_Object *obj) {
- // TODO: ELM_ATSPI_GESTURE_TWO_FINGERS_HOVER must be replaced
- if (gesture.type == ELM_ATSPI_GESTURE_TWO_FINGERS_HOVER) {
- auto page = (MainPage *)data;
- page->m_rmPrs->showPanel();
- return EINA_TRUE;
- }
-
- return EINA_FALSE;
- }, this);
-
- return RES_OK;
- }
-
- Result MainPage::createAtspiHighlightHelper()
- {
- m_atspiHelper = AtspiHighlightHelper::newInstance(*this, getWindow());
- if (!m_atspiHelper) {
- LOG_RETURN(RES_FAIL,
- "AtspiHighlightHelper::newInstance() failed!");
- }
-
- switch (m_mode) {
- case CallMode::INCOMING:
- registerIncomingCallModeAo();
- break;
- case CallMode::OUTGOING:
- case CallMode::DURING:
- registerActiveCallModeAo();
- break;
- case CallMode::END:
- registerEndCallModeAo();
- default:
- break;
- }
- return RES_OK;
- }
-
- void MainPage::registerIncomingCallModeAo()
- {
- DLOG("ENTER");
- m_atspiHelper->setRelationEventHandler(WEAK_DELEGATE(
- MainPage::onIncomingCallModeAtspiHighlight, asWeak(*this)));
-
- m_atspiHelper->setGestureEventHandler(WEAK_DELEGATE(
- MainPage::onIncomingModeAtspiGesture, asWeak(*this)));
-
- auto acceptAO = m_acceptRejectPrs->getAcceptAo();
- if (!acceptAO) {
- DLOG("acceptAO is NULL");
- } else {
- m_atspiHelper->registerWidget(*acceptAO);
- }
-
- auto rejectAo = m_acceptRejectPrs->getRejectAo();
- if (!rejectAo) {
- DLOG("rejectAo is NULL");
- } else {
- m_atspiHelper->registerWidget(*rejectAo);
- }
-
- auto statusTxtAo = m_callInfoPrs->getStatusTxtAo();
- if (!statusTxtAo) {
- DLOG("statusTxtAo is NULL");
- } else {
- m_atspiHelper->registerWidget(*statusTxtAo);
- }
-
- auto mainTxtAo = m_callInfoPrs->getMainTxtAo();
- if (!mainTxtAo) {
- DLOG("mainTxtAo is NULL");
- } else {
- m_atspiHelper->registerWidget(*mainTxtAo);
- }
-
- auto subTxtAo = m_callInfoPrs->getSubTxtAo();
- if (!subTxtAo) {
- DLOG("subTxtAo is NULL");
- } else {
- m_atspiHelper->registerWidget(*subTxtAo);
- }
-
- if (!m_rmCueAo) {
- DLOG("m_rmCueAo is NULL");
- } else {
- m_atspiHelper->registerWidget(*m_rmCueAo);
- }
-
- DLOG("EXIT");
- }
-
- bool MainPage::onIncomingModeAtspiGesture(Elm_Interface_Atspi_Accessible *widget,
- Elm_Atspi_Gesture_Type gestureType)
- {
- DLOG(" GESTURE TYPE [%d]", gestureType);
-
- if (m_rmCueAo && widget == *m_rmCueAo) {
- if (gestureType == ELM_ATSPI_GESTURE_TWO_FINGERS_HOVER) {
- m_rmPrs->showPanel();
- return true;
- }
- }
- return false;
- }
-
- Elm_Interface_Atspi_Accessible *MainPage::onIncomingCallModeAtspiHighlight(
- Elm_Interface_Atspi_Accessible *ao,
- Elm_Atspi_Relation_Type flowRelation)
- {
- DLOG("FlowRelation [%s]",
- flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM ?
- "FROM" : "TO");
-
- auto acceptAo = m_acceptRejectPrs->getAcceptAo();
- auto rejectAo = m_acceptRejectPrs->getRejectAo();
- auto statusTxtAo = m_callInfoPrs->getStatusTxtAo();
- auto mainTxtAo = m_callInfoPrs->getMainTxtAo();
- auto subTxtAo = m_callInfoPrs->getSubTxtAo();
-
- if (ao == *acceptAo) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return *statusTxtAo;
- }
- } else if (ao == *statusTxtAo) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return *mainTxtAo;
- } else if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
- return *acceptAo;
- }
- } else if (ao == *mainTxtAo) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return (subTxtAo) ? *subTxtAo : *rejectAo;
- } else if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
- return *statusTxtAo;
- }
- } else if (subTxtAo && ao == *subTxtAo) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return *rejectAo;
- } else if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
- return *mainTxtAo;
- }
- } else if (ao == *rejectAo) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return m_rmCueAo ? *m_rmCueAo : ao;
- } else if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
- return (subTxtAo) ? *subTxtAo : *mainTxtAo;
- }
- } else if (m_rmCueAo && ao == *m_rmCueAo) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
- return *rejectAo;
- }
- } else if (ao == getWindow()) {
- return *acceptAo;
- } else {
- LOG_RETURN_VALUE(RES_FAIL, nullptr, "Unknown object!");
- }
-
- return ao;
- }
-
- void MainPage::registerActiveCallModeAo()
- {
- DLOG("ENTER");
- m_atspiHelper->setRelationEventHandler(WEAK_DELEGATE(
- MainPage::onActiveCallModeAtspiHighlight, asWeak(*this)));
-
- auto statusTxtAo = m_callInfoPrs->getStatusTxtAo();
- if (!statusTxtAo) {
- DLOG("statusTxtAo is NULL");
- } else {
- m_atspiHelper->registerWidget(*statusTxtAo);
- }
-
- auto mainTxtAo = m_callInfoPrs->getMainTxtAo();
- if (!mainTxtAo) {
- DLOG("mainTxtAo is NULL");
- } else {
- m_atspiHelper->registerWidget(*mainTxtAo);
- }
-
- auto subTxtAo = m_callInfoPrs->getSubTxtAo();
- if (!subTxtAo) {
- DLOG("subTxtAo is NULL");
- } else {
- m_atspiHelper->registerWidget(*subTxtAo);
- }
-
- auto volumeBtnAo = m_accessoryPrs->getVolumBtn();
- if (!volumeBtnAo) {
- DLOG("volumeBtnAo is NULL");
- } else {
- m_atspiHelper->registerWidget(*volumeBtnAo);
- }
-
- auto bluetoothBtnAo = m_accessoryPrs->getBluetoothBtn();
- if (!bluetoothBtnAo) {
- DLOG("bluetoothBtnAo is NULL");
- } else {
- m_atspiHelper->registerWidget(*bluetoothBtnAo);
- }
-
- auto muteBtnAo = m_accessoryPrs->getMuteBtn();
- if (!muteBtnAo) {
- DLOG("muteBtnAo is NULL");
- } else {
- m_atspiHelper->registerWidget(*muteBtnAo);
- }
-
- auto moreOptCueAo = m_moreOptionsPrs->getCueAo();
- if (!moreOptCueAo) {
- DLOG("moreCueAo is NULL");
- } else {
- m_atspiHelper->registerWidget(*moreOptCueAo);
- }
-
- if (!m_bottomBtn) {
- DLOG("m_bottomBtn is NULL");
- } else {
- m_atspiHelper->registerWidget(*m_bottomBtn);
- }
-
- auto vcLayout = m_accessoryPrs->getVolumeControlLy();
- if (!vcLayout) {
- DLOG("vcLayout is NULL");
- } else {
- m_atspiHelper->registerWidget(*vcLayout);
- }
-
- auto vcDecrVolumeBtn = m_accessoryPrs->getVolumeControlDecreaseBtn();
- if (!vcDecrVolumeBtn) {
- DLOG("vcDecrVolumeBtn is NULL");
- } else {
- m_atspiHelper->registerWidget(*vcDecrVolumeBtn);
- }
-
- auto vcIncrVolumeBtn = m_accessoryPrs->getVolumeControlIncreaseBtn();
- if (!vcIncrVolumeBtn) {
- DLOG("vcIncrVolumeBtn is NULL");
- } else {
- m_atspiHelper->registerWidget(*vcIncrVolumeBtn);
- }
-
- auto vcVolumeValueAo = m_accessoryPrs->getVolumeControlValueTxtAo();
- if (!vcVolumeValueAo) {
- DLOG("vcVolumeValueAo is NULL");
- } else {
- m_atspiHelper->registerWidget(*vcVolumeValueAo);
- }
-
- DLOG("EXIT");
- }
-
- Elm_Interface_Atspi_Accessible *MainPage::onActiveCallModeAtspiHighlight(
- Elm_Interface_Atspi_Accessible *ao,
- Elm_Atspi_Relation_Type flowRelation)
- {
- DLOG("FlowRelation [%s]",
- flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM ?
- "FROM" : "TO");
-
- auto statusTxtAo = m_callInfoPrs->getStatusTxtAo();
- auto mainTxtAo = m_callInfoPrs->getMainTxtAo();
- auto subTxtAo = m_callInfoPrs->getSubTxtAo();
- auto volumeBtnAo = m_accessoryPrs->getVolumBtn();
- auto bluetoothBtnAo = m_accessoryPrs->getBluetoothBtn();
- auto muteBtnAo = m_accessoryPrs->getMuteBtn();
- auto moreOptCueAo = m_moreOptionsPrs->getCueAo();
- auto vcLayout = m_accessoryPrs->getVolumeControlLy();
- auto vcDecrVolumeBtn = m_accessoryPrs->getVolumeControlDecreaseBtn();
- auto vcIncrVolumeBtn = m_accessoryPrs->getVolumeControlIncreaseBtn();
- auto vcVolumeValueAo = m_accessoryPrs->getVolumeControlValueTxtAo();
-
- if (ao == *statusTxtAo) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return *mainTxtAo;
- }
- } else if (ao == *mainTxtAo) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- if (subTxtAo) {
- return *subTxtAo;
- } else {
- return *volumeBtnAo;
- }
- } else {
- return *statusTxtAo;
- }
- } else if (subTxtAo && ao == *subTxtAo) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return *volumeBtnAo;
- } else {
- return *mainTxtAo;
- }
- } else if (ao == *volumeBtnAo) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return *bluetoothBtnAo;
- } else {
- if (subTxtAo) {
- return *subTxtAo;
- } else {
- return *mainTxtAo;
- }
- }
- } else if (ao == *bluetoothBtnAo) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return *muteBtnAo;
- } else {
- return *volumeBtnAo;
- }
- } else if (ao == *muteBtnAo) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return *moreOptCueAo;
- } else {
- return *bluetoothBtnAo;
- }
- } else if (ao == *moreOptCueAo) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return *m_bottomBtn;
- } else {
- return *muteBtnAo;
- }
- } else if (ao == *m_bottomBtn) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
- return *moreOptCueAo;
- }
- } else if (ao == *vcLayout) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return *vcDecrVolumeBtn;
- }
- } else if (ao == *vcDecrVolumeBtn) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return *vcVolumeValueAo;
- } else {
- return *vcLayout;
- }
- } else if (ao == *vcVolumeValueAo) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return *vcIncrVolumeBtn;
- } else {
- return *vcDecrVolumeBtn;
- }
- } else if (ao == *vcIncrVolumeBtn) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
- return *vcVolumeValueAo;
- }
- } else if (ao == getWindow()) {
- return *statusTxtAo;
- } else {
- LOG_RETURN_VALUE(RES_FAIL, nullptr, "Unknown object!");
- }
-
- return ao;
- }
-
- void MainPage::registerEndCallModeAo()
- {
- m_atspiHelper->setRelationEventHandler(WEAK_DELEGATE(
- MainPage::onEndCallModeAtspiHighlight, asWeak(*this)));
-
- auto statusTxtAo = m_callInfoPrs->getStatusTxtAo();
- if (!statusTxtAo) {
- DLOG("statusTxtAo is NULL");
- } else {
- m_atspiHelper->registerWidget(*statusTxtAo);
- }
-
- auto mainTxtAo = m_callInfoPrs->getMainTxtAo();
- if (!mainTxtAo) {
- DLOG("mainTxtAo is NULL");
- } else {
- m_atspiHelper->registerWidget(*mainTxtAo);
- }
-
- auto addContactsBtnAo = m_accessoryPrs->getAddContactBtn();
- if (!addContactsBtnAo) {
- DLOG("addContactsBtnAo is NULL");
- } else {
- m_atspiHelper->registerWidget(*addContactsBtnAo);
- }
-
- if (!m_bottomBtn) {
- DLOG("m_bottomBtn is NULL");
- } else {
- m_atspiHelper->registerWidget(*m_bottomBtn);
- }
-
- DLOG("EXIT");
- }
-
- Elm_Interface_Atspi_Accessible *MainPage::onEndCallModeAtspiHighlight(
- Elm_Interface_Atspi_Accessible *ao,
- Elm_Atspi_Relation_Type flowRelation)
- {
- DLOG("FlowRelation [%s]",
- flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM ?
- "FROM" : "TO");
-
- auto statusTxtAo = m_callInfoPrs->getStatusTxtAo();
- auto mainTxtAo = m_callInfoPrs->getMainTxtAo();
- auto addContactsBtnAo = m_accessoryPrs->getAddContactBtn();
-
- if (ao == *statusTxtAo) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return *mainTxtAo;
- }
- } else if (ao == *mainTxtAo) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- if (addContactsBtnAo) {
- return *addContactsBtnAo;
- } else {
- return *m_bottomBtn;
- }
- } else {
- return *statusTxtAo;
- }
- } else if (addContactsBtnAo && ao == *addContactsBtnAo) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return *m_bottomBtn;
- } else {
- return *mainTxtAo;
- }
- } else if (ao == *m_bottomBtn) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
- if (addContactsBtnAo) {
- return *addContactsBtnAo;
- } else {
- return *mainTxtAo;
- }
- }
- } else if (ao == getWindow()) {
- return *statusTxtAo;
- } else {
- LOG_RETURN_VALUE(RES_FAIL, nullptr, "Unknown object!");
- }
-
- return ao;
- }
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "presenters/MoreOptionsPresenter.h"
-
-#include <app_control.h>
-
-#include "ucl/gui/Layout.h"
-#include "ucl/appfw/types.h"
-
-#include "model/ICallManager.h"
-#include "model/IHeldCall.h"
-#include "model/IActiveCall.h"
-#include "model/ICallInfo.h"
-#include "model/ISoundManager.h"
-
-#include "presenters/KeypadPage.h"
-#include "presenters/AtspiHighlightHelper.h"
-
-#include "resources.h"
-#include "common.h"
-
-namespace callui { namespace { namespace impl {
-
- using namespace ucl;
-
- constexpr auto CALL_DURATION_TIMER_INTERVAL = 0.1;
-
- constexpr LayoutTheme LAYOUT_DRAWER_PANEL
- {"layout", "drawer", "panel"};
-
- constexpr LayoutTheme LAYOUT_MORE_OPTION_WIDGET
- {"layout", "callui", "more_option"};
-
- constexpr EdjePart PART_SWL_RIGHT {"elm.swallow.right"};
-
- constexpr ElmStyle STYLE_BTN_SWAP {"callui/swap"};
- constexpr ElmStyle STYLE_BTN_UNHOLD {"callui/unhold"};
- constexpr ElmStyle STYLE_BTN_KEYPAD {"callui/keypad"};
-
- constexpr EdjePart PART_SWL_SLOT1 {"swl.slot.1"};
- constexpr EdjePart PART_SWL_SLOT2 {"swl.slot.2"};
- constexpr EdjePart PART_TXT_STATUS {"txt.status"};
-
- constexpr EdjePart PART_AO_TXT_STATUS {"ao_txt.status"};
-
- constexpr EdjePart PART_ACCESS {"access"};
-
- constexpr EdjeSignal SIGNAL_ODD {"odd"};
- constexpr EdjeSignal SIGNAL_EVEN {"even"};
-
- constexpr EdjeSignalSrc SIGNAL_SRC_MORE_OPTION {"more_option"};
-
-}}}
-
-namespace callui {
-
- using namespace ucl;
-
- // MoreOptionsPresenter::Builder
-
- MoreOptionsPresenter::Builder::Builder()
- {
- }
-
- MoreOptionsPresenter::Builder &
- MoreOptionsPresenter::Builder::setCallManager(const ICallManagerSRef &cm)
- {
- m_cm = cm;
- return *this;
- }
-
- MoreOptionsPresenter::Builder &
- MoreOptionsPresenter::Builder::setSoundManager(const ISoundManagerSRef &sm)
- {
- m_sm = sm;
- return *this;
- }
-
- MoreOptionsPresenter::Builder &
- MoreOptionsPresenter::Builder::setNaviframe(const NaviframeSRef &navi)
- {
- m_navi = navi;
- return *this;
- }
-
- MoreOptionsPresenter::Builder &
- MoreOptionsPresenter::Builder::setParentWidget(
- const ElmWidgetSRef &parentWidget)
- {
- m_parentWidget = parentWidget;
- return *this;
- }
-
- MoreOptionsPresenterSRef
- MoreOptionsPresenter::Builder::build(GuiPresenter &parent) const
- {
- if (!m_cm || !m_sm || !m_navi || !m_parentWidget) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "Main params are not set");
- }
-
- auto result = makeShared<MoreOptionsPresenter>(m_cm, m_sm, m_navi);
- FAIL_RETURN_VALUE(result->prepare(parent, *m_parentWidget), {},
- "result->prepare() failed!");
-
- return result;
- }
-
- // MoreOptionsPresenter
-
- MoreOptionsPresenter::MoreOptionsPresenter(IRefCountObj &rc,
- const ICallManagerSRef &cm,
- const ISoundManagerSRef &sm,
- const NaviframeSRef &navi):
- GuiPresenter(rc),
- m_cm(cm),
- m_sm(sm),
- m_navi(navi),
- m_timer(nullptr)
- {
- }
-
- MoreOptionsPresenter::~MoreOptionsPresenter()
- {
- stopCallDurationTimer();
-
- if (m_widget) {
- eext_object_event_callback_del(*m_widget, EEXT_CALLBACK_BACK,
- CALLBACK_A(MoreOptionsPresenter::onBackKey));
-
- sendActivate(*m_widget);
- }
-
- if (const auto keypad = m_keypad.lock()) {
- keypad->exitNoTransition();
- }
- }
-
- Result MoreOptionsPresenter::prepare(GuiPresenter &parent,
- ElmWidget &parentWidget)
- {
- FAIL_RETURN(GuiPresenter::prepare(parent, PF_DEACTIVATOR),
- "Presenter::prepare() failed!");
-
- FAIL_RETURN(createWidget(parentWidget), "createWidget() failed!");
-
- FAIL_RETURN(createPanel(), "createPanel() failed!");
-
- FAIL_RETURN(createPanelLayout(), "createPanelContent() failed!");
-
- FAIL_RETURN(createAccessObjects(), "createStaticAo() failed!");
-
- updateComponents();
-
- FAIL_RETURN(createAtspiHighlightHelper(), "createAtspiHighlightHelper() failed!");
-
- deactivateBy(m_widget.get());
-
- parent.addDeactivatorSource(*m_widget);
-
- return RES_OK;
- }
-
- Result MoreOptionsPresenter::createWidget(ElmWidget &parent)
- {
- m_widget = Layout::Builder().
- setTheme(impl::LAYOUT_DRAWER_PANEL).
- setIsOwner(true).
- build(parent);
-
- if (!m_widget) {
- LOG_RETURN(RES_FAIL, "Layout::build() failed!");
- }
-
- return RES_OK;
- }
-
- void MoreOptionsPresenter::onCueClicked(Evas_Object *obj,
- const char *emission,
- const char *source)
- {
- show(*m_fakeAo);
- m_panel->setContent(*m_panelLy);
- show(*m_panelLy);
-
- createStatusTxtAo();
- if (m_statusTxtAo) {
- m_atspiHelper->registerWidget(*m_statusTxtAo);
- }
- }
-
- Result MoreOptionsPresenter::createPanel()
- {
- auto *eo = elm_panel_add(*m_widget);
- if (!eo) {
- LOG_RETURN(RES_FAIL, "elm_panel_add() failed!");
- }
- m_panel = makeShared<StyledWidget>(eo, true);
- elm_panel_orient_set(*m_panel, ELM_PANEL_ORIENT_RIGHT);
- show(*m_panel);
-
- m_widget->setContent(*m_panel, impl::PART_SWL_RIGHT);
-
- elm_panel_toggle(*m_panel);
-
- elm_layout_signal_callback_add(*m_panel, "elm,state,active,finished",
- "elm", CALLBACK_A(MoreOptionsPresenter::onPanelActivate), this);
-
- elm_layout_signal_callback_add(*m_panel, "elm,state,inactive,finished",
- "elm", CALLBACK_A(MoreOptionsPresenter::onPanelInactivate), this);
-
- setDeactivatorSink(m_panel);
-
- elm_layout_signal_callback_add(*m_panel, "cue,clicked",
- "elm", CALLBACK_A(MoreOptionsPresenter::onCueClicked), this);
-
- return RES_OK;
- }
-
- Result MoreOptionsPresenter::createPanelLayout()
- {
- m_panelLy = Layout::Builder().
- setTheme(impl::LAYOUT_MORE_OPTION_WIDGET).
- build(*m_panel);
- if (!m_panelLy) {
- LOG_RETURN(RES_FAIL, "Layout::build() failed!");
- }
- show(*m_panelLy);
- m_panel->setContent(*m_panelLy);
-
- return RES_OK;
- }
-
- void MoreOptionsPresenter::updateSlots()
- {
- unsetPanelContent(impl::PART_SWL_SLOT1);
- unsetPanelContent(impl::PART_SWL_SLOT2);
-
- auto active = m_cm->getActiveCall();
- auto held = m_cm->getHeldCall();
-
- FAIL_RETURN_VOID(createKeypadButton(),
- "createKeypadButton() failed");
-
- if (held) {
- m_panelLy->emit(impl::SIGNAL_EVEN, impl::SIGNAL_SRC_MORE_OPTION);
-
- if (active) {
- FAIL_RETURN_VOID(createSwapButton(),
- "createSwapButton() failed");
- setPanelContent(*m_btnSwap, impl::PART_SWL_SLOT1);
- } else {
- FAIL_RETURN_VOID(createUnholdButton(),
- "createUnholdButton() failed");
- setPanelContent(*m_btnUnhold, impl::PART_SWL_SLOT1);
- }
- setPanelContent(*m_btnKeypad, impl::PART_SWL_SLOT2);
- } else {
- m_panelLy->emit(impl::SIGNAL_ODD, impl::SIGNAL_SRC_MORE_OPTION);
-
- setPanelContent(*m_btnKeypad, impl::PART_SWL_SLOT1);
- }
- }
-
- Result MoreOptionsPresenter::createSwapButton()
- {
- m_btnSwap = createButton(impl::STYLE_BTN_SWAP, STR_MORE_SWAP,
- WEAK_DELEGATE(MoreOptionsPresenter::onSwapBtnClick,
- asWeak(*this)));
- if (!m_btnSwap) {
- LOG_RETURN(RES_FAIL, "Create Swap button failed!");
- }
-
- return RES_OK;
- }
-
- Result MoreOptionsPresenter::createUnholdButton()
- {
- m_btnUnhold = createButton(impl::STYLE_BTN_UNHOLD, STR_MORE_UNHOLD,
- WEAK_DELEGATE(MoreOptionsPresenter::onUnholdBtnClick,
- asWeak(*this)));
- if (!m_btnUnhold) {
- LOG_RETURN(RES_FAIL, "Create Unhold button failed!");
- }
-
- return RES_OK;
- }
-
- Result MoreOptionsPresenter::createKeypadButton()
- {
- m_btnKeypad = createButton(impl::STYLE_BTN_KEYPAD, STR_MORE_KEYPAD,
- WEAK_DELEGATE(MoreOptionsPresenter::onKeypadBtnClick,
- asWeak(*this)));
- if (!m_btnKeypad) {
- LOG_RETURN(RES_FAIL, "Create Keypad button failed!");
- }
-
- return RES_OK;
- }
-
- void MoreOptionsPresenter::onSwapBtnClick(Widget &sender, void *eventInfo)
- {
- auto held = m_cm->getHeldCall();
- if (!held) {
- LOG_RETURN_VOID(RES_FAIL, "Held call is NULL");
- }
- FAIL_RETURN_VOID(held->swapWithActive(), "swapWithActive() failed");
- }
-
- void MoreOptionsPresenter::onUnholdBtnClick(Widget &sender, void *eventInfo)
- {
- auto held = m_cm->getHeldCall();
- if (!held) {
- LOG_RETURN_VOID(RES_FAIL, "Held call is NULL");
- }
- FAIL_RETURN_VOID(held->unhold(), "unhold() failed");
- }
-
- void MoreOptionsPresenter::onKeypadBtnClick(Widget &sender, void *eventInfo)
- {
- KeypadPage::Builder builder;
- if (m_navi) {
- builder.setNaviframe(m_navi);
- } else {
- LOG_RETURN_VOID(RES_FAIL, "Naviframe is NULL");
- }
- m_keypad = builder.setSoundManager(m_sm)
- .build(WEAK_DELEGATE(
- MoreOptionsPresenter::onPageExitRequest,
- asWeak(*this)));
- }
-
- void MoreOptionsPresenter::onPageExitRequest(Page &page)
- {
- m_keypad.reset();
- page.exit();
- }
-
- StyledWidgetSRef MoreOptionsPresenter::createButton(
- const ElmStyle &style,
- const TString &txt,
- const WidgetEventHandler &handler)
- {
- auto *eo = elm_button_add(*m_panelLy);
- if (!eo) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "elm_button_add() failed!");
- }
- auto btn = makeShared<StyledWidget>(eo, true);
- btn->setStyle(style);
- btn->setText(txt);
- btn->addEventHandler(BTN_CLICKED, handler);
- hide(*btn);
-
- btn->bindToEo();
-
- return btn;
- }
-
- Widget &MoreOptionsPresenter::getWidget()
- {
- return *m_widget;
- }
-
- void MoreOptionsPresenter::update()
- {
- updateComponents();
- }
-
- void MoreOptionsPresenter::updateComponents()
- {
- updateSlots();
- updateStatusText();
- }
-
- void MoreOptionsPresenter::onPanelActivate(Evas_Object *obj,
- const char *emission,
- const char *source)
- {
- eext_object_event_callback_add(*m_widget, EEXT_CALLBACK_BACK,
- CALLBACK_A(MoreOptionsPresenter::onBackKey), this);
-
- const auto keepAliver = asShared(*this);
- sendDeactivate(*m_widget);
- activateBy(m_widget.get());
-
- elm_atspi_component_highlight_grab(*m_fakeAo);
- }
-
- void MoreOptionsPresenter::onPanelInactivate(Evas_Object *obj,
- const char *emission,
- const char *source)
- {
- eext_object_event_callback_del(*m_widget, EEXT_CALLBACK_BACK,
- CALLBACK_A(MoreOptionsPresenter::onBackKey));
-
- const auto keepAliver = asShared(*this);
- deactivateBy(m_widget.get());
- sendActivate(*m_widget);
-
- m_panel->unsetContent();
- hide(*m_panelLy);
- m_statusTxtAo.reset();
-
- elm_atspi_accessible_can_highlight_set(*m_cueAo, EINA_TRUE);
- hide(*m_fakeAo);
- }
-
- void MoreOptionsPresenter::onBackKey(Evas_Object *obj, void *eventInfo)
- {
- if (isActive() && !elm_panel_hidden_get(*m_panel)) {
- elm_panel_toggle(*m_panel);
- }
- }
-
- void MoreOptionsPresenter::updateStatusText()
- {
- m_panelLy->setText("", impl::PART_TXT_STATUS);
-
- auto active = m_cm->getActiveCall();
- auto held = m_cm->getHeldCall();
-
- if (held && !active) {
- m_panelLy->setText(STR_ON_HOLD, impl::PART_TXT_STATUS);
- } else if (active) {
- if (active->isDialingMode()) {
- m_panelLy->setText(STR_DIALING_CALL, impl::PART_TXT_STATUS);
- return;
- }
- auto info = active->getInfo();
- if (!info) {
- LOG_RETURN_VOID(RES_FAIL, "Call Info is NULL");
- }
- m_info = info;
- m_duration = info->getDuration();
- auto temp = getCallDuration(m_duration);
- m_panelLy->setText(temp, impl::PART_TXT_STATUS);
-
- FAIL_RETURN_VOID(startCallDurationTimer(), "startTimer() failed!");
-
- } else {
- LOG_RETURN_VOID(RES_FAIL, "Undefined state");
- }
- }
-
- Eina_Bool MoreOptionsPresenter::onCallDurationTimerCb()
- {
- const auto info = m_info.lock();
- if (!info) {
- m_timer = nullptr;
- LOG_RETURN_VALUE(RES_FAIL, ECORE_CALLBACK_CANCEL, "m_info is NULL");
- }
-
- struct tm tmp = info->getDuration();
- tryUpdateCallDurationTime(
- m_duration,
- tmp,
- *m_panelLy,
- impl::PART_TXT_STATUS);
-
- return ECORE_CALLBACK_RENEW;
- }
-
- Result MoreOptionsPresenter::startCallDurationTimer()
- {
- stopCallDurationTimer();
-
- m_timer = ecore_timer_add(impl::CALL_DURATION_TIMER_INTERVAL,
- CALLBACK_B(MoreOptionsPresenter::onCallDurationTimerCb),
- this);
-
- if (!m_timer) {
- LOG_RETURN(RES_FAIL, "m_timer is NULL");
- }
-
- return RES_OK;
- }
-
- void MoreOptionsPresenter::stopCallDurationTimer()
- {
- if (m_timer) {
- ecore_timer_del(m_timer);
- m_timer = nullptr;
- }
- }
-
- void MoreOptionsPresenter::unsetPanelContent(const EdjePart &part)
- {
- auto *eo = m_panelLy->unsetContent(part);
- if (eo) {
- hide(*asWidget(eo));
- }
- }
-
- void MoreOptionsPresenter::setPanelContent(StyledWidget &widget, const EdjePart &part)
- {
- m_panelLy->setContent(widget, part);
- show(widget);
- }
-
- // Screen Reader
- Result MoreOptionsPresenter::createAtspiHighlightHelper()
- {
- DLOG("ENTER");
- m_atspiHelper = AtspiHighlightHelper::newInstance(*this, getWindow());
- if (!m_atspiHelper) {
- LOG_RETURN(RES_FAIL,
- "AtspiHighlightHelper::newInstance() failed!");
- }
-
- m_atspiHelper->setRelationEventHandler(WEAK_DELEGATE(
- MoreOptionsPresenter::onAtspiHighlight, asWeak(*this)));
-
- if (m_panelLy) {
- m_atspiHelper->registerWidget(*m_fakeAo);
- }
-
- if (m_panelLy) {
- m_atspiHelper->registerWidget(*m_panelLy);
- }
-
- if (m_btnSwap) {
- m_atspiHelper->registerWidget(*m_btnSwap);
- }
-
- if (m_btnUnhold) {
- m_atspiHelper->registerWidget(*m_btnUnhold);
- }
-
- if (m_btnKeypad) {
- m_atspiHelper->registerWidget(*m_btnKeypad);
- }
-
- if (m_statusTxtAo) {
- m_atspiHelper->registerWidget(*m_statusTxtAo);
- }
- DLOG("EXIT");
- return RES_OK;
- }
-
- Elm_Interface_Atspi_Accessible *MoreOptionsPresenter::onAtspiHighlight(
- Elm_Interface_Atspi_Accessible *ao,
- Elm_Atspi_Relation_Type flowRelation)
- {
- DLOG("FlowRelation [%s]",
- flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM ?
- "FROM" :
- "TO");
-
- if (m_btnSwap && ao == *m_btnSwap) {
- DLOG("Swap button");
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return *m_btnKeypad;
- }
- } else if (m_btnUnhold && ao == *m_btnUnhold) {
- DLOG("Unhold button");
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return *m_btnKeypad;
- }
- } else if (ao == *m_btnKeypad) {
- DLOG("Keypad button");
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return *m_statusTxtAo;
- } else {
- if (m_btnSwap) {
- return *m_btnSwap;
- } else if (m_btnUnhold) {
- return *m_btnUnhold;
- }
- }
- } else if (ao == *m_statusTxtAo) {
- DLOG("Status text");
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
- return *m_btnKeypad;
- }
- } else if (ao == getWindow() || ao == *m_fakeAo) {
- DLOG("window or panelLy");
- if (m_btnSwap) {
- return *m_btnSwap;
- } else if (m_btnUnhold) {
- return *m_btnUnhold;
- } else {
- return *m_btnKeypad;
- }
- } else {
- LOG_RETURN_VALUE(RES_FAIL, nullptr, "Unknown object!");
- }
-
- return ao;
- }
-
- Result MoreOptionsPresenter::createAccessObjects()
- {
- FAIL_RETURN(createCueAo(), "createCueAo() failed");
- FAIL_RETURN(createStatusTxtAo(), "createStatusTxtAo() failed");
- FAIL_RETURN(createFakeAo(), "createFakeAo() failed");
-
- return RES_OK;
- }
-
- Result MoreOptionsPresenter::createCueAo()
- {
- m_cueAo = utils::createAccessObjectFromLyPart(*m_widget,
- *m_panel,
- impl::PART_ACCESS);
- if (!m_cueAo) {
- LOG_RETURN(RES_FAIL,
- "createAccessObjectFromLyPart() failed!");
- }
- elm_access_action_cb_set(*m_cueAo,
- ELM_ACCESS_ACTION_ACTIVATE,
- CALLBACK_A(MoreOptionsPresenter::onCueAoActionCb),
- this);
-
- elm_atspi_accessible_translation_domain_set(*m_cueAo, PACKAGE);
- elm_atspi_accessible_reading_info_type_set(*m_cueAo,
- ELM_ACCESSIBLE_READING_INFO_TYPE_NAME |
- ELM_ACCESSIBLE_READING_INFO_TYPE_ROLE);
- elm_atspi_accessible_name_set(*m_cueAo, AO_STR_MORE_OPTIONS);
- elm_atspi_accessible_role_set(*m_cueAo, ELM_ATSPI_ROLE_PUSH_BUTTON);
-
- return RES_OK;
- }
-
- ElmWidget *MoreOptionsPresenter::getCueAo()
- {
- return m_cueAo.get();
- }
-
- Result MoreOptionsPresenter::createFakeAo()
- {
- m_fakeAo = utils::createFakeAccessObject(*m_panel);
- if (!m_fakeAo) {
- LOG_RETURN(RES_FAIL, "createFakeAccessObject() failed!");
- }
-
- return RES_OK;
- }
-
- Result MoreOptionsPresenter::createStatusTxtAo()
- {
- m_statusTxtAo = utils::createAccessObjectFromLyPart(*m_widget,
- *m_panelLy,
- impl::PART_AO_TXT_STATUS);
- if (!m_statusTxtAo) {
- LOG_RETURN(RES_FAIL,
- "createAccessObjectFromLyPart() failed!");
- }
-
- elm_atspi_accessible_reading_info_type_set(*m_statusTxtAo,
- ELM_ACCESSIBLE_READING_INFO_TYPE_NAME);
- elm_atspi_accessible_name_cb_set(*m_statusTxtAo,
- [](void *data, Evas_Object *obj) -> char *
- {
- auto self = static_cast<MoreOptionsPresenter *>(data);
- if (!self) {
- return nullptr;
- }
- auto txt = self->m_panelLy->
- getText(impl::PART_TXT_STATUS).getCStr();
- return (txt) ? strdup(txt) : nullptr;
- },
- this);
-
- return RES_OK;
- }
-
- Eina_Bool MoreOptionsPresenter::onCueAoActionCb(Evas_Object *obj,
- Elm_Access_Action_Info *actionInfo)
- {
- switch (actionInfo->action_type) {
- case ELM_ACCESS_ACTION_ACTIVATE:
-
- show(*m_fakeAo);
- m_panel->setContent(*m_panelLy);
- show(*m_panelLy);
- createStatusTxtAo();
- if (m_statusTxtAo) {
- m_atspiHelper->registerWidget(*m_statusTxtAo);
- }
-
- elm_panel_toggle(*m_panel);
- elm_atspi_component_highlight_clear(*m_cueAo);
- elm_atspi_accessible_can_highlight_set(*m_cueAo, EINA_FALSE);
-
- return EINA_TRUE;
- break;
- default:
- break;
- }
-
- return EINA_FALSE;
- }
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "presenters/MotionSensorPresenter.h"
-
-#include "common.h"
-
-namespace callui {
-
- using namespace ucl;
-
- MotionSensorPresenter::Builder::Builder()
- {
- }
-
- MotionSensorPresenter::Builder::~Builder()
- {
- }
-
- MotionSensorPresenterSRef
- MotionSensorPresenter::Builder::build(
- const MotionSensorHandler handler) const
- {
- auto result = makeShared<MotionSensorPresenter>(handler);
- FAIL_RETURN_VALUE(result->prepare(),
- {}, "result->prepare() failed!");
- return result;
- }
-
- MotionSensorPresenter::MotionSensorPresenter(
- const MotionSensorHandler &handler):
- m_handler(handler),
- m_gesture(nullptr)
- {
- }
-
- MotionSensorPresenter::~MotionSensorPresenter()
- {
- if (m_gesture) {
- gesture_stop_recognition(m_gesture);
- gesture_release(m_gesture);
- }
- }
-
- Result MotionSensorPresenter::prepare()
- {
- int res = gesture_create(&m_gesture);
- if (res != GESTURE_ERROR_NONE) {
- LOG_RETURN(RES_FAIL, "gesture_create() failed. "
- "res[%d] msg[%s]", res, get_error_message(res));
- }
-
- res = gesture_start_recognition(m_gesture, GESTURE_WRIST_UP,
- GESTURE_OPTION_ALWAYS_ON,
- CALLBACK_B(MotionSensorPresenter::onGestureCb),
- this);
- if (res != GESTURE_ERROR_NONE) {
- LOG_RETURN(RES_FAIL, "gesture_start_recognition() failed. "
- "res[%d] msg[%s]", res, get_error_message(res));
- }
- return RES_OK;
- }
-
- void MotionSensorPresenter::onGestureCb(gesture_type_e motion,
- const gesture_data_h data,
- double timeStamp,
- gesture_error_e error)
- {
- if (error) {
- LOG_RETURN_VOID(RES_FAIL, "Error occured. "
- "err[%d] msg[%s]", error, get_error_message(error));
- }
-
- if (motion == GESTURE_WRIST_UP) {
- gesture_event_e event;
- int res = gesture_get_event(data, &event);
- if (res != GESTURE_ERROR_NONE) {
- LOG_RETURN_VOID(RES_FAIL, "gesture_get_event() failed. "
- "err[%d] msg[%s]", res, get_error_message(res));
- }
-
- if (event == GESTURE_EVENT_DETECTED && m_handler) {
- m_handler();
- }
- }
- }
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "presenters/Page.h"
-
-#include "common.h"
-
-namespace callui { namespace { namespace impl {
-
- constexpr SmartEvent TOP_PAGE_CHANGED {"ucl,top,page,changed"};
-}}}
-
-namespace callui {
-
- using namespace ucl;
-
- Page::Page(IRefCountObj &rc, const NaviframeSRef &navi,
- const ExitRequestHandler &onExitRequest) :
- GuiPresenter(rc),
- m_navi(navi),
- m_onExitRequest(onExitRequest)
- {
- UCL_ASSERT(navi, "navi is NULL!");
- UCL_ASSERT(onExitRequest, "onExitRequest is NULL!");
-
- deactivateBy(m_navi.get());
- }
-
- Page::~Page()
- {
- }
-
- Result Page::preparePart2()
- {
- if (!m_item) {
- UCL_LOG_RETURN(ucl::RES_FAIL, "m_item is NULL");
- }
-
- Evas_Object *content = m_item.getContent();
- if (!content) {
- LOG_RETURN(RES_FAIL, "content is NULL");
- }
-
- m_navi->addEventHandler(NAVI_TRANSITION_STARTED,
- WEAK_DELEGATE(Page::onTransitionStarted, asWeak(*this)));
-
- m_navi->addEventHandler(NAVI_TRANSITION_FINISHED,
- WEAK_DELEGATE(Page::onTransitionFinished, asWeak(*this)));
-
- m_navi->addEventHandler(impl::TOP_PAGE_CHANGED,
- WEAK_DELEGATE(Page::onTopPageChanged, asWeak(*this)));
-
- eext_object_event_callback_add(content, EEXT_CALLBACK_BACK,
- CALLBACK_A(Page::onHWBackKey), this);
-
- m_item.setData(this);
- m_item.setDelCallback(CALLBACK_A(Page::onItemDel));
-
- m_selfRef = asShared(*this);
-
- if (!m_navi->isInTransition() && isAtTop()) {
- dispatchTopPageChanged();
- }
-
- return RES_OK;
- }
-
- void Page::dispatchTopPageChanged()
- {
- if (!m_navi->isInTransition()) {
- m_navi->callEvent(impl::TOP_PAGE_CHANGED, nullptr);
- } else {
- WLOG("Forcig Transition Finished!");
- m_navi->setInTransition(false);
- }
- }
-
- void Page::onItemDel(Evas_Object *obj, void *eventInfo)
- {
- m_item = nullptr;
- m_selfRef.reset();
- }
-
- void Page::exit()
- {
- if (isAtTop() && !isAtBottom() && !m_navi->isInTransition()) {
- m_navi->pop();
- m_item = nullptr;
- } else {
- exitNoTransition();
- }
- }
-
- void Page::exitNoTransition()
- {
- if (isAtTop()) {
- m_item.del();
- dispatchTopPageChanged();
- } else if (m_item) {
- m_item.del();
- }
- }
-
- void Page::popTo()
- {
- if (m_item && !isAtTop()) {
- m_item.popTo();
- }
- }
-
- void Page::deleteTo()
- {
- if (m_item && !isAtTop()) {
- while (!isAtTop()) {
- m_navi->getTopItem().del();
- }
- dispatchTopPageChanged();
- }
- }
-
- void Page::promote()
- {
- if (m_item && !isAtTop()) {
- m_item.promote();
- }
- }
-
- NaviItem Page::getItem()
- {
- return m_item;
- }
-
- void Page::requestExit()
- {
- if (m_onExitRequest) {
- m_onExitRequest(*this);
- } else {
- WLOG("m_onExitRequest is NULL");
- exit();
- }
- }
-
- void Page::updateActiveState()
- {
- if (isAtTop()) {
- activateBy(m_navi.get());
- } else {
- deactivateBy(m_navi.get());
- }
- }
-
- void Page::onTransitionStarted(Widget &widget, void *eventInfo)
- {
- deactivateBy(m_navi.get());
- }
-
- void Page::onTransitionFinished(Widget &widget, void *eventInfo)
- {
- updateActiveState();
- }
-
- void Page::onTopPageChanged(Widget &widget, void *eventInfo)
- {
- updateActiveState();
- }
-
- void Page::onHWBackKey(Evas_Object *obj, void *eventInfo)
- {
- if (isActive()) {
- onBackKey();
- }
- }
-
- void Page::onBackKey()
- {
- requestExit();
- }
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "presenters/RejectMsgPresenter.h"
-
-#include "model/IRejectMsgProvider.h"
-#include "model/IRejectMsg.h"
-
-#include "presenters/AtspiHighlightHelper.h"
-
-#include "resources.h"
-#include "common.h"
-
-namespace callui { namespace { namespace impl {
-
- using namespace ucl;
-
- const int ALPHA_CHANNEL_MAX = 255;
-
- constexpr LayoutTheme LAYOUT_DRAWER_PANEL
- {"layout", "drawer", "panel"};
-
- constexpr LayoutTheme LAYOUT_RM_PANEL_CONTENT
- {"layout", "callui", "rm_panel_content"};
-
- constexpr EdjePart PART_SWL_RIGHT {"elm.swallow.right"};
- constexpr EdjePart PART_SWL_BG {"elm.swallow.bg"};
-
- constexpr EdjePart PART_SWL_CONTENT {"swl.content"};
- constexpr EdjePart PART_SWL_SCROLLER {"swl.scroller"};
-
- constexpr SmartEvent EVENT_SCROLL {"scroll"};
-
-}}}
-
-namespace callui {
-
- using namespace ucl;
-
- class RejectMsgPresenter::RejectMsgItem : public NonCopyable {
- public:
- RejectMsgItem(const IRejectMsgSRef &rm):
- m_rm(rm)
- {
- }
-
- virtual ~RejectMsgItem()
- {
- }
-
- std::string getDisplayText() const
- {
- auto trnsTxt = TString{m_rm->getText(), true}.translate();
-
- auto markupTxt = elm_entry_utf8_to_markup(trnsTxt);
- std::string resStr(markupTxt);
- replaceSubstringInString(resStr, "<br/>", " ");
- free(markupTxt);
-
- return resStr;
- }
-
- IRejectMsgSRef getRejectMsg() const
- {
- return m_rm;
- }
-
- private:
- IRejectMsgSRef m_rm;
- };
-
- RejectMsgPresenter::Builder::Builder()
- {
- }
-
- RejectMsgPresenter::Builder::~Builder()
- {
- }
-
- RejectMsgPresenter::Builder &
- RejectMsgPresenter::Builder::setProvider(
- const IRejectMsgProviderSRef &provider)
- {
- m_provider = provider;
- return *this;
- }
-
- RejectMsgPresenter::Builder &
- RejectMsgPresenter::Builder::setStateHandler(
- const RejectMsgStateHandler &handler)
- {
- m_stateHandler = handler;
- return *this;
- }
-
- RejectMsgPresenter::Builder &
- RejectMsgPresenter::Builder::setSelectHandler(
- const RejectMsgSelectHandler &handler)
- {
- m_selectHandler = handler;
- return *this;
- }
-
- RejectMsgPresenter::Builder &
- RejectMsgPresenter::Builder::setParentWidget(
- const ElmWidgetSRef &parentWidget)
- {
- m_parentWidget = parentWidget;
- return *this;
- }
-
- RejectMsgPresenterSRef
- RejectMsgPresenter::Builder::build(GuiPresenter &parent) const
- {
- if (!m_provider || !m_parentWidget) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "Main params are not set");
- }
-
- auto result = makeShared<RejectMsgPresenter>(m_provider,
- m_stateHandler,
- m_selectHandler);
- FAIL_RETURN_VALUE(result->prepare(parent, *m_parentWidget), {},
- "result->prepare() failed!");
-
- return result;
- }
-
- RejectMsgPresenter::RejectMsgPresenter(IRefCountObj &rc,
- const IRejectMsgProviderSRef &provider,
- const RejectMsgStateHandler &stateHandler,
- const RejectMsgSelectHandler &selectHandler):
- GuiPresenter(rc),
- m_circleEo(nullptr),
- m_provider(provider),
- m_stateHandler(stateHandler),
- m_selectHandler(selectHandler),
- m_state(RejectMsgState::HIDDEN)
- {
- }
-
- RejectMsgPresenter::~RejectMsgPresenter()
- {
- if (m_widget) {
- sendActivate(*m_widget);
- }
- }
-
- Result RejectMsgPresenter::prepare(GuiPresenter &parent,
- ElmWidget &parentWidget)
- {
- FAIL_RETURN(GuiPresenter::prepare(parent, PF_DEACTIVATOR),
- "Presenter::prepare() failed!");
-
- FAIL_RETURN(createWidget(parentWidget),
- "createWidget() failed!");
-
- FAIL_RETURN(createPanel(),
- "createPanel() failed!");
-
- FAIL_RETURN(createPanelBg(),
- "createPanelBg() failed!");
-
- FAIL_RETURN(createPanelLy(),
- "createPanelLy() failed!");
-
- FAIL_RETURN(createAtspiHighlightHelper(),
- "createScreenReaderRoute() failed!");
-
- deactivateBy(m_widget.get());
-
- parent.addDeactivatorSource(*m_widget);
-
- return RES_OK;
- }
-
- Result RejectMsgPresenter::createWidget(ElmWidget &parent)
- {
- m_widget = Layout::Builder().
- setTheme(impl::LAYOUT_DRAWER_PANEL).
- setIsOwner(true).
- build(parent);
-
- if (!m_widget) {
- LOG_RETURN(RES_FAIL, "Layout::build() failed!");
- }
-
- eext_object_event_callback_add(m_widget->getEo(), EEXT_CALLBACK_BACK,
- CALLBACK_A(RejectMsgPresenter::onBackKey), this);
-
- return RES_OK;
- }
-
- void RejectMsgPresenter::onBackKey(Evas_Object *obj, void *eventInfo)
- {
- if (isActive()) {
- hidePanel();
- }
- }
-
- void RejectMsgPresenter::panelScrollCb(Widget &widget, void *eventInfo)
- {
- Elm_Panel_Scroll_Info *ev = static_cast<Elm_Panel_Scroll_Info *>(eventInfo);
- DLOG("pos x[%f] y[%f]", ev->rel_x, ev->rel_y);
- auto prevState = m_state;
-
- if (ev->rel_y == 1.0) {
- m_state = RejectMsgState::SHOWN;
- // Prevent panel scrolling
- elm_object_scroll_freeze_push(m_panel->getEo());
- } else if (ev->rel_y == 0.0) {
- m_state = RejectMsgState::HIDDEN;
- m_genlist.reset();
- } else {
- if (!m_genlist) {
- FAIL_RETURN_VOID(createGenlist(),
- "createGenlist() failed!");
- }
-
- m_state = RejectMsgState::IN_TRANSITION;
- const auto alphaValue =
- static_cast<int>(impl::ALPHA_CHANNEL_MAX * ev->rel_y);
- m_panelBg->setColor(0, alphaValue);
- }
-
- if (prevState != m_state) {
- if (m_state == RejectMsgState::SHOWN) {
- activateBy(m_widget.get());
- } else {
- deactivateBy(m_widget.get());
- }
-
- if (m_state == RejectMsgState::HIDDEN) {
- sendActivate(*m_widget);
- } else {
- sendDeactivate(*m_widget);
- }
-
- if (m_stateHandler) {
- m_stateHandler(m_state);
- }
- }
- }
-
- Result RejectMsgPresenter::createPanel()
- {
- m_panel = makeShared<StyledWidget>(elm_panel_add(*m_widget), true);
- if (!m_panel) {
- LOG_RETURN(RES_FAIL, "elm_panel_add() failed!");
- }
- elm_panel_scrollable_set(*m_panel, EINA_TRUE);
- elm_panel_scrollable_content_size_set(*m_panel, 1.0);
- elm_panel_hidden_set(*m_panel, EINA_TRUE);
- elm_panel_orient_set(*m_panel, ELM_PANEL_ORIENT_BOTTOM);
- show(*m_panel);
-
- m_panel->addEventHandler(impl::EVENT_SCROLL,
- WEAK_DELEGATE(RejectMsgPresenter::panelScrollCb,
- asWeak(*this)));
-
- m_widget->setContent(*m_panel, impl::PART_SWL_RIGHT);
-
- setDeactivatorSink(m_panel);
-
- return RES_OK;
- }
-
- Result RejectMsgPresenter::createPanelBg()
- {
- m_panelBg = makeShared<ElmWidget>(
- evas_object_rectangle_add(evas_object_evas_get(*m_widget)));
- if (!m_panelBg) {
- LOG_RETURN(RES_FAIL, "evas_object_rectangle_add() failed!");
- }
- m_panelBg->setColor(0, 0);
- show(*m_panelBg);
-
- m_widget->setContent(m_panelBg->getEo(), impl::PART_SWL_BG);
-
- return RES_OK;
- }
-
- Result RejectMsgPresenter::createPanelLy()
- {
- m_panelLy = Layout::Builder().
- setTheme(impl::LAYOUT_RM_PANEL_CONTENT).
- setIsOwner(true).
- build(*m_panel);
- if (!m_panelLy) {
- LOG_RETURN(RES_FAIL, "Layout::build failed!");
- }
- m_panel->setContent(*m_panelLy);
-
- return RES_OK;
- }
-
- Result RejectMsgPresenter::createGenlist()
- {
- // Genlist scroller Layout
- auto circlLy = Layout::Builder().build(*m_panelLy);
- if (!circlLy) {
- LOG_RETURN(RES_FAIL, "Layout::build failed!");
- }
- // Circular surface
- Eext_Circle_Surface *const circleSurf =
- eext_circle_surface_layout_add(*circlLy);
- if (!circleSurf) {
- LOG_RETURN(RES_FAIL, "eext_circle_surface_layout_add() failed!");
- }
- // Genlist
- Evas_Object *const glEo = elm_genlist_add(*m_panelLy);
- if (!glEo) {
- LOG_RETURN(RES_FAIL, "elm_genlist_add() failed!");
- }
- elm_genlist_mode_set(glEo, ELM_LIST_COMPRESS);
- elm_genlist_homogeneous_set(glEo, EINA_TRUE);
-
- m_genlist = makeShared<StyledWidget>(glEo, true);
- m_genlist->setWeight(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- m_genlist->setAlign(EVAS_HINT_FILL, EVAS_HINT_FILL);
-
- m_circleEo = eext_circle_object_genlist_add(m_genlist->getEo(),
- circleSurf);
- if (!m_circleEo) {
- LOG_RETURN(RES_FAIL, "elm_genlist_add() failed!");
- }
- eext_circle_object_genlist_scroller_policy_set(m_circleEo,
- ELM_SCROLLER_POLICY_OFF,
- ELM_SCROLLER_POLICY_AUTO);
- deactivateRotary();
-
- FAIL_RETURN(fillGenlist(), "fillGenlist() failed!");
-
- m_panelLy->setContent(*circlLy, impl::PART_SWL_SCROLLER);
-
- m_panelLy->setContent(*m_genlist, impl::PART_SWL_CONTENT);
-
- registerGenlistAtspiGestureCallbacks();
-
- return RES_OK;
- }
-
- Result RejectMsgPresenter::fillGenlist()
- {
- FAIL_RETURN(addGenlistTitleItem(), "addGenlistTitleItem() failed!");
-
- auto msgList = m_provider->getMsgList();
- for (auto &iter : msgList) {
- FAIL_RETURN(addGenlistTextItem(iter), "addGenlistTextItem() failed!");
- }
-
- FAIL_RETURN(addGenlistBottomItem(), "addGenlistBottomItem() failed!");
-
- return RES_OK;
- }
-
- Result RejectMsgPresenter::addGenlistTitleItem()
- {
- static auto titleItc = utils::createGenlistItemClass("title",
- [](void *data, Evas_Object *obj, const char *part) -> char * {
- return strdup(STR_DECLINE_MESSAGES.translate());
- });
-
- auto *item = elm_genlist_item_append(*m_genlist, &titleItc,
- nullptr,
- nullptr,
- ELM_GENLIST_ITEM_NONE,
- nullptr,
- nullptr);
- if (!item) {
- LOG_RETURN(RES_FAIL, "elm_genlist_item_append() failed!");
- }
-
- return RES_OK;
- }
-
- Result RejectMsgPresenter::addGenlistTextItem(const IRejectMsgSRef &rm)
- {
- static auto textItc = utils::createGenlistItemClass("1text.1icon",
- [](void *data, Evas_Object *obj, const char *part) -> char * {
- if (!data) {
- LOG_RETURN_VALUE(RES_FAIL, nullptr, "Data is NULL");
- }
- RejectMsgItem *rm = static_cast<RejectMsgItem *>(data);
- return strdup(rm->getDisplayText().c_str());
- },
- nullptr,
- nullptr,
- [](void *data, Evas_Object *obj) -> void {
- RejectMsgItem *rm = static_cast<RejectMsgItem *>(data);
- delete rm;
- });
-
- auto *rmItem = new RejectMsgItem(rm);
- if (!rmItem) {
- LOG_RETURN(RES_FAIL, "Create RejectMsgItem failed!");
- }
-
- auto *item = elm_genlist_item_append(*m_genlist, &textItc,
- static_cast<void *>(rmItem),
- nullptr,
- ELM_GENLIST_ITEM_NONE,
- CALLBACK_A(RejectMsgPresenter::onGenlistItemClickedCb),
- this);
- if (!item) {
- delete rmItem;
- LOG_RETURN(RES_FAIL, "elm_genlist_item_append() failed!");
- }
-
- return RES_OK;
- }
-
- Result RejectMsgPresenter::addGenlistBottomItem()
- {
- static auto paddingItc = utils::createGenlistItemClass("1text.1icon");
-
- auto *item = elm_genlist_item_append(*m_genlist, &paddingItc,
- nullptr,
- nullptr,
- ELM_GENLIST_ITEM_NONE,
- nullptr,
- nullptr);
- if (!item) {
- LOG_RETURN(RES_FAIL, "elm_genlist_item_append() failed!");
- }
-
- return RES_OK;
- }
-
- void RejectMsgPresenter::handleSelectEvent(const RejectMsgItem &item)
- {
- if (m_selectHandler) {
- m_selectHandler(item.getRejectMsg());
- }
- }
-
- void RejectMsgPresenter::onGenlistItemClickedCb(Evas_Object *obj, void *eventInfo)
- {
- if (!eventInfo) {
- LOG_RETURN_VOID(RES_FAIL, "eventInfo is NULL");
- }
-
- auto *item = static_cast<Elm_Object_Item *>(eventInfo);
- auto *rmItem = static_cast<RejectMsgItem *>(
- elm_object_item_data_get(item));
-
- handleSelectEvent(*rmItem);
- }
-
- Widget &RejectMsgPresenter::getWidget()
- {
- return *m_widget;
- }
-
- RejectMsgState RejectMsgPresenter::getState()
- {
- return m_state;
- }
-
- void RejectMsgPresenter::showPanel()
- {
- DLOG();
- if (m_state != RejectMsgState::SHOWN) {
- DLOG("Panel state [NOT SHOWN]");
- elm_panel_hidden_set(m_panel->getEo(), EINA_FALSE);
- }
- }
-
- void RejectMsgPresenter::hidePanel()
- {
- DLOG();
- if (m_state == RejectMsgState::SHOWN) {
- DLOG("Panel state [SHOWN]");
- elm_object_scroll_freeze_pop(m_panel->getEo());
- elm_panel_hidden_set(m_panel->getEo(), EINA_TRUE);
- }
- }
-
- void RejectMsgPresenter::setStateHandler(
- const RejectMsgStateHandler &handler)
- {
- m_stateHandler = handler;
- }
-
- void RejectMsgPresenter::setSelectHandler(
- const RejectMsgSelectHandler &handler)
- {
- m_selectHandler = handler;
- }
-
- void RejectMsgPresenter::onActivate()
- {
- DLOG();
- activateRotary();
- }
-
- void RejectMsgPresenter::onDeactivate()
- {
- DLOG();
- deactivateRotary();
- }
-
- void RejectMsgPresenter::activateRotary()
- {
- if (m_circleEo) {
- eext_rotary_object_event_activated_set(m_circleEo, EINA_TRUE);
- }
- }
-
- void RejectMsgPresenter::deactivateRotary()
- {
- if (m_circleEo) {
- eext_rotary_object_event_activated_set(m_circleEo, EINA_FALSE);
- }
- }
-
- // Screen Reader
- Elm_Interface_Atspi_Accessible *RejectMsgPresenter::getFirstAo()
- {
- return (m_genlist) ?
- elm_genlist_first_item_get(*m_genlist) :
- nullptr;
- }
-
- Elm_Interface_Atspi_Accessible *RejectMsgPresenter::getLastAo()
- {
- return (m_genlist) ?
- elm_genlist_last_item_get(*m_genlist) :
- nullptr;
- }
-
- Result RejectMsgPresenter::createAtspiHighlightHelper()
- {
- m_atspiHelper = AtspiHighlightHelper::newInstance(*this, getWindow());
- if (!m_atspiHelper) {
- LOG_RETURN(RES_FAIL, "AtspiHighlightHelper::newInstance() failed!");
- }
-
- m_atspiHelper->setRelationEventHandler(WEAK_DELEGATE(
- RejectMsgPresenter::onAtspiHighlight, asWeak(*this)));
-
- return RES_OK;
- }
-
- void RejectMsgPresenter::registerGenlistAtspiGestureCallbacks()
- {
- auto item = getFirstAo();
- elm_atspi_accessible_gesture_cb_set(item,
- CALLBACK_A(RejectMsgPresenter::onAtspiGesture), this);
-
- item = getLastAo();
- elm_atspi_accessible_gesture_cb_set(item,
- CALLBACK_A(RejectMsgPresenter::onAtspiGesture), this);
- }
-
- Elm_Interface_Atspi_Accessible *RejectMsgPresenter::onAtspiHighlight(
- Elm_Interface_Atspi_Accessible *ao,
- Elm_Atspi_Relation_Type flowRelation)
- {
- DLOG("ENTER");
-
- DLOG("FlowRelation [%s]",
- flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM ?
- "FROM" :
- "TO");
-
- if (ao == getFirstAo()) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
- return nullptr;
- }
- } else if (ao == getLastAo()) {
- if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
- return nullptr;
- }
- } else if (ao == getWindow()) {
- return getFirstAo();
- } else {
- LOG_RETURN_VALUE(RES_FAIL, nullptr, "Unknown object!");
- }
- return ao;
- }
-
- Eina_Bool RejectMsgPresenter::onAtspiGesture(
- Elm_Atspi_Gesture_Info gestureInfo,
- Elm_Interface_Atspi_Accessible *ao)
- {
- return toEina(
- m_atspiHelper->handleGesture(ao, gestureInfo));
- }
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_PRESENTERS_COMMON_H__
-#define __CALLUI_PRESENTERS_COMMON_H__
-
-#include "ucl/gui/stdTheme.h"
-
-#include "view/helpers.h"
-
-#include "helpers.h"
-
-#include "../common.h"
-
-#include "../view/common.h"
-
-namespace callui {
- constexpr auto CALL_VC_TIMER_INTERVAL = 1.5;
- constexpr auto CALL_VC_SCREEN_READER_TIMER_INTERVAL = 5.0;
- constexpr auto VOLUME_LEVEL_MIN = 1;
-}
-
-#endif // __CALLUI_PRESENTERS_COMMON_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "common.h"
-
-namespace callui { namespace { namespace himpl {
-
- const TString STR_HH_MM_SS_TIME{"%02d:%02d:%02d"};
- const TString STR_MM_SS_TIME{"%02d:%02d"};
-
-}}}
-
-namespace callui {
-
- using namespace ucl;
-
- void replaceSubstringInString(std::string &str,
- const std::string &from, const std::string &to)
- {
- if (from.empty()) {
- LOG_RETURN_VOID(RES_FAIL, "Parameter from is empty");
- }
-
- size_t start_pos = 0;
- while((start_pos = str.find(from, start_pos)) != std::string::npos) {
- str.replace(start_pos, from.length(), to);
- start_pos += to.length();
- }
- }
-
- TString getCallDuration(const struct tm &time)
- {
- TString tmp;
- if (time.tm_hour > 0) {
- tmp = himpl::STR_HH_MM_SS_TIME.format(time.tm_hour, time.tm_min, time.tm_sec);
- } else {
- tmp = himpl::STR_MM_SS_TIME.format(time.tm_min, time.tm_sec);
- }
- return tmp;
- }
-
- void tryUpdateCallDurationTime(
- struct tm &curTime,
- struct tm &compTime,
- EdjeWidget &widget,
- const EdjePart &part)
- {
- if ((compTime.tm_sec - curTime.tm_sec) != 0) {
- curTime = compTime;
- auto tmp = getCallDuration(curTime);
- widget.setText(tmp, part);
- }
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_PRESENTERS_HELPERS_H__
-#define __CALLUI_PRESENTERS_HELPERS_H__
-
-#include <string>
-#include <time.h>
-
-#include "ucl/gui/EdjeWidget.h"
-#include "ucl/gui/types.h"
-
-namespace callui {
-
- void replaceSubstringInString(std::string &str,
- const std::string &from, const std::string &to);
-
- ucl::TString getCallDuration(const struct tm &time);
-
- void tryUpdateCallDurationTime(
- struct tm &curTime, struct tm &compTime,
- ucl::EdjeWidget &widget, const ucl::EdjePart &part);
-
-}
-
-#endif // __CALLUI_PRESENTERS_HELPERS_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "resources.h"
-
-namespace callui {
-
- // TODO: Need replace with IDS
-
- const ucl::TString STR_ANSWER_CALL {"Answer call"};
- const ucl::TString STR_HOLD_AND_ACCEPT {"Hold and Accept"};
- const ucl::TString STR_END_AND_ACCEPT {"End and Accept"};
-
- const ucl::TString STR_CALL_WITH_PS_WILL_END {"Call with %s will end."};
- const ucl::TString STR_CALL_ON_HOLD {"Call on hold"};
- const ucl::TString STR_WITH_PD_PEOPLE {"With %d people"};
- const ucl::TString STR_CONFERENCE_CALL {"Conference call"};
- const ucl::TString STR_UNKNOWN {"Unknown"};
- const ucl::TString STR_EMERGENCY_CALL {"Emergency call"};
- const ucl::TString STR_VOICEMAIL {"Voicemail"};
-
- const ucl::TString STR_INCOMING_CALL {"Incoming call"};
- const ucl::TString STR_DIALING_CALL {"Dialing"};
- const ucl::TString STR_ON_HOLD {"On hold"};
- const ucl::TString STR_CALL_ENDED {"Call ended"};
-
- const ucl::TString STR_DECLINE_MESSAGES {"Decline messages"};
-
- const ucl::TString STR_VOLUME {"Volume"};
-
- const ucl::TString STR_MORE_SWAP {"Swap"};
- const ucl::TString STR_MORE_HEADSET {"Headset"};
- const ucl::TString STR_MORE_PHONE {"Phone"};
- const ucl::TString STR_MORE_KEYPAD {"Keypad"};
- const ucl::TString STR_MORE_HOLD {"Hold"};
- const ucl::TString STR_MORE_UNHOLD {"Unhold"};
- const ucl::TString STR_MORE_GEAR {"Gear"};
-
- // Screen Reader
- const ucl::TString AO_STR_CALL {"Call"};
- const ucl::TString AO_STR_VOLUME {"Volume"};
- const ucl::TString AO_STR_HEADSET {"Headset"};
- const ucl::TString AO_STR_GEAR_SPK {"Gear speaker"};
- const ucl::TString AO_STR_MUTE {"Mute"};
- const ucl::TString AO_STR_MORE_OPTIONS {"More options"};
- const ucl::TString AO_STR_END_CALL {"End call"};
- const ucl::TString AO_STR_CALLBACK {"Callback"};
- const ucl::TString AO_STR_ADD_TO_CONTACTS {"Add to contacts"};
- const ucl::TString AO_STR_ROTATE_BEZEL_TO_ADJUST {"Rotate bezel to adjust"};
- const ucl::TString AO_STR_DECREASE_VOLUME {"Decrease volume"};
- const ucl::TString AO_STR_INCREASE_VOLUME {"Increase volume"};
- const ucl::TString AO_STR_ACCEPT_CALL {"Accept call"};
- const ucl::TString AO_STR_SWIPE_RIGHT_WITH_TWO_FINGERS_TO_ACCEPT
- {"Swipe right with two fingers to accept"};
- const ucl::TString AO_STR_REJECT_CALL {"Reject call"};
- const ucl::TString AO_STR_SWIPE_LEFT_WITH_TWO_FINGERS_TO_REJECT
- {"Swipe left with two fingers to reject"};
- const ucl::TString AO_STR_DECLINE_MESSAGES {"Decline messages"};
- const ucl::TString AO_STR_SWIPE_UP_WITH_TWO_FINGERS_TO_SEND_A_DECLINE_MESSAGE
- {"Swipe up with two fingers to send a decline message"};
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "ucl/util/logging.h"
-#include "types.h"
-
-ucl::ResultData getUCLResultData(const ucl::Result result)
-{
- switch (result.value) {
- case callui::RES_PERMISSION_DENIED: return {"RES_PERMISSION_DENIED", DLOG_FATAL};
- case callui::RES_NOT_REGISTERED: return {"RES_NOT_REGISTERED", DLOG_FATAL};
- case callui::RES_ALREADY_REGISTERED: return {"RES_ALREADY_REGISTERED", DLOG_FATAL};
- case callui::RES_OPERATION_FAILED: return {"RES_OPERATION_FAILED", DLOG_FATAL};
- case callui::RES_NOT_CONNECTED: return {"RES_NOT_CONNECTED", DLOG_FATAL};
- default:
- return ucl::getResultData(result);
- }
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "view/AcceptRejectWidget.h"
-
-#include "common.h"
-#include "resources.h"
-
-#define CU_COL_TRANSPARENT 0, 0, 0, 0
-#define CU_COL_WHITE 255, 255, 255, 255
-
-#define CU_COL_AO0115 222, 11, 0, 255
-#define CU_COL_AO0115T 222, 11, 0, 0
-#define CU_COL_AO0115D 222, 11, 0, 63
-#define CU_COL_AO01151 222, 11, 0, 175
-#define CU_COL_AO01152 222, 11, 0, 77
-
-#define CU_COL_AO0113 77, 185, 39, 255
-#define CU_COL_AO0113T 77, 185, 39, 0
-#define CU_COL_AO0113D 77, 185, 39, 63
-#define CU_COL_AO01131 97, 237, 50, 175
-#define CU_COL_AO01132 97, 237, 50, 77
-
-namespace callui { namespace { namespace impl {
-
- using namespace ucl;
-
- constexpr LayoutTheme LAYOUT_IMG_ACCEPT_REJECT
- {"layout", "callui", "accept_reject_main"};
-
- constexpr LayoutTheme LAYOUT_EVENT_ACCEPT_REJECT
- {"layout", "callui", "event_accept_reject"};
-
- constexpr LayoutTheme LAYOUT_IMG_ACTION_BG
- {"layout", "callui_image", "accept_reject_action_bg"};
-
- constexpr LayoutTheme LAYOUT_IMG_ACCEPT
- {"layout", "callui_image", "accept"};
-
- constexpr LayoutTheme LAYOUT_IMG_ACCEPT_BT_HEADSET
- {"layout", "callui_image", "accept_bt_headset"};
-
- constexpr LayoutTheme LAYOUT_IMG_REJECT
- {"layout", "callui_image", "reject"};
-
- constexpr auto BC_ITEM_COUNT = 4;
-
- constexpr auto BC_ANIMATE_COUNT_MAX = 3;
-
- constexpr auto FINGER_TRACER_DIM = 130;
- constexpr auto FINGER_TRACER_HALF_DIM = FINGER_TRACER_DIM / 2;
-
- constexpr auto FINGER_STROKE_DIM = 480;
- constexpr auto FINGER_STROKE_HALF_DIM = FINGER_STROKE_DIM / 2;
-
- constexpr auto INIT_MOVE_DISTANCE_VAL = 65;
-
- constexpr double BC_ANIMATION_DURATION[BC_ITEM_COUNT] = {
- 0.23, 0.16, 0.30, 0.16 };
-
- constexpr auto BC_ANIM_DUR_HIDE = 0.16;
-
- constexpr auto ROTARY_ACTION_ANIM_DUR = 0.15;
-
- constexpr auto EXPAND_WAITING_TIMEOUT = 0.6;
-
- constexpr auto ICON_ZOOM_EFF_VAL_MIN = 1.0;
- constexpr auto ICON_ZOOM_EFF_VAL_MID = 2.0;
- constexpr auto ICON_ZOOM_EFF_VAL_MAX = 3.7;
-
- constexpr auto ACC_ICON_RIGHT_PAD_X = 13;
- constexpr auto REJ_ICON_RIGHT_PAD_X = 293;
- constexpr auto ACC_REJ_ICON_HIDE_THRESHOLD_W = 70;
-
- struct BezelCueParams {
- const EdjePart part;
- const LayoutTheme theme;
- };
-
- static const BezelCueParams ACCEPT_BC_PARAMS[BC_ITEM_COUNT] = {
- { EdjePart {"swl.accept.bezel.1"},
- LayoutTheme {"layout", "callui_image",
- "bezel_cue_accept_1"} },
- { EdjePart {"swl.accept.bezel.2"},
- LayoutTheme {"layout", "callui_image",
- "bezel_cue_accept_2"} },
- { EdjePart {"swl.accept.bezel.3"},
- LayoutTheme {"layout", "callui_image",
- "bezel_cue_accept_3"} },
- { EdjePart {"swl.accept.bezel.4"},
- LayoutTheme {"layout", "callui_image",
- "bezel_cue_accept_4"} },
- };
-
- static const BezelCueParams REJECT_BC_PARAMS[BC_ITEM_COUNT] = {
- { EdjePart {"swl.reject.bezel.1"},
- LayoutTheme {"layout", "callui_image",
- "bezel_cue_reject_1"} },
- { EdjePart {"swl.reject.bezel.2"},
- LayoutTheme {"layout", "callui_image",
- "bezel_cue_reject_2"} },
- { EdjePart {"swl.reject.bezel.3"},
- LayoutTheme {"layout", "callui_image",
- "bezel_cue_reject_3"} },
- { EdjePart {"swl.reject.bezel.4"},
- LayoutTheme {"layout", "callui_image",
- "bezel_cue_reject_4"} },
- };
-
- constexpr EdjePart PART_SWL_ACCEPT_FINGER_TRACER
- {"swl.accept.finger.tracer"};
- constexpr EdjePart PART_SWL_ACCEPT_FINGER_GUIDE_BG
- {"swl.accept.finger.guide.bg"};
- constexpr EdjePart PART_SWL_ACCEPT_FINGER_EVENT
- {"swl.accept.finger.event"};
- constexpr EdjePart PART_SWL_ACCEPT_ICON
- {"swl.accept.icon"};
-
- constexpr EdjePart PART_SWL_REJECT_FINGER_TRACER
- {"swl.reject.finger.tracer"};
- constexpr EdjePart PART_SWL_REJECT_FINGER_GUIDE_BG
- {"swl.reject.finger.guide.bg"};
- constexpr EdjePart PART_SWL_REJECT_FINGER_EVENT
- {"swl.reject.finger.event"};
- constexpr EdjePart PART_SWL_REJECT_ICON
- {"swl.reject.icon"};
-
- LayoutSRef createImage(ElmWidget &parent, const LayoutTheme &theme)
- {
- auto layout = Layout::Builder().
- setTheme(theme).
- setIsOwner(true).
- build(parent);
- if (!layout) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "Layout::build() failed!");
- }
- return layout;
- }
-
- void resizeImage(ElmWidget &image, int size)
- {
- Evas_Coord x, y, w, h;
- image.getGeometry(&x, &y, &w, &h);
- image.move((x + (w / 2)) - (size / 2), (y + (h / 2)) - (size / 2));
- image.resize(size, size);
- }
-
-}}}
-
-namespace callui {
-
- using namespace ucl;
-
- AcceptRejectWidget::Builder::Builder() :
- m_acceptBtnType(AcceptButtonType::SIMPLE)
- {
- }
-
- AcceptRejectWidget::Builder &
- AcceptRejectWidget::Builder::setAcceptEventHandler(
- const NotiHandler &handler)
- {
- m_acceptHandler = handler;
- return *this;
- }
-
- AcceptRejectWidget::Builder &
- AcceptRejectWidget::Builder::setRejectEventHandler(
- const NotiHandler &handler)
- {
- m_rejectHandler = handler;
- return *this;
- }
-
- AcceptRejectWidget::Builder &
- AcceptRejectWidget::Builder::setAcceptBtnType(AcceptButtonType type)
- {
- m_acceptBtnType = type;
- return *this;
- }
-
- AcceptRejectWidgetSRef
- AcceptRejectWidget::Builder::build(ElmWidget &parent) const
- {
- auto layout = Layout::Builder().
- setTheme(impl::LAYOUT_IMG_ACCEPT_REJECT).
- setIsOwner(true).
- build(parent);
- if (!layout) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "Layout::build() failed!");
- }
-
- auto result = makeShared<AcceptRejectWidget>(layout,
- m_acceptHandler, m_rejectHandler, m_acceptBtnType);
-
- FAIL_RETURN_VALUE(result->registerAccessObjects(parent), {},
- "registerScreenReaderObjects() failed!");
-
- result->bindToEo();
-
- return result;
- }
-
- AcceptRejectWidget::AcceptRejectWidget(IRefCountObj &rc,
- const LayoutSRef &layout,
- const NotiHandler &acceptHandler,
- const NotiHandler &rejectHandler,
- AcceptButtonType acceptBtnType):
- ElmWidget(&rc, *layout, true),
- m_layout(layout.get()),
- m_accHandler(acceptHandler),
- m_rejHandler(rejectHandler),
- m_accBezelCueImg(impl::BC_ITEM_COUNT),
- m_rejBezelCueImg(impl::BC_ITEM_COUNT),
- m_isFreezed(false),
- m_isAccPressed(false),
- m_isRejPressed(false),
- m_lastMoveDistance(impl::INIT_MOVE_DISTANCE_VAL),
- m_rotaryClockwiseCount(0),
- m_rotaryCounterClockwiseCount(0),
- m_isContracting(false),
- m_accTracerTr(nullptr),
- m_accGuideTr(nullptr),
- m_accIconTr(nullptr),
- m_rejTracerTr(nullptr),
- m_rejGuideTr(nullptr),
- m_rejIconTr(nullptr),
- m_lastAccBezelTr1(nullptr),
- m_lastAccBezelTr2(nullptr),
- m_lastRejBezelTr1(nullptr),
- m_lastRejBezelTr2(nullptr),
- m_accBCAnimCount(0),
- m_rejBCAnimCount(0),
- m_accBCAnimIndex(impl::BC_ITEM_COUNT - 1),
- m_rejBCAnimIndex(impl::BC_ITEM_COUNT - 1),
- m_acceptBtnType(acceptBtnType)
- {
- prepare();
- }
-
- AcceptRejectWidget::~AcceptRejectWidget()
- {
- m_expandTimeout.reset();
-
- m_accEventLy->delEventHandler(WidgetEvent::MOUSE_DOWN,
- WEAK_DELEGATE(AcceptRejectWidget::onMouseDown, asWeak(*this)));
- m_accEventLy->delEventHandler(WidgetEvent::MOUSE_UP,
- WEAK_DELEGATE(AcceptRejectWidget::onMouseUp, asWeak(*this)));
- m_accEventLy->delEventHandler(WidgetEvent::MOUSE_MOVE,
- WEAK_DELEGATE(AcceptRejectWidget::onMouseMove, asWeak(*this)));
-
- m_rejEventLy->delEventHandler(WidgetEvent::MOUSE_DOWN,
- WEAK_DELEGATE(AcceptRejectWidget::onMouseDown, asWeak(*this)));
- m_rejEventLy->delEventHandler(WidgetEvent::MOUSE_UP,
- WEAK_DELEGATE(AcceptRejectWidget::onMouseUp, asWeak(*this)));
- m_rejEventLy->delEventHandler(WidgetEvent::MOUSE_MOVE,
- WEAK_DELEGATE(AcceptRejectWidget::onMouseMove, asWeak(*this)));
-
- DEL_TRANSIT(m_lastAccBezelTr1);
- DEL_TRANSIT(m_lastAccBezelTr2);
- DEL_TRANSIT(m_lastRejBezelTr1);
- DEL_TRANSIT(m_lastRejBezelTr2);
-
- DEL_TRANSIT(m_accTracerTr);
- DEL_TRANSIT(m_accGuideTr);
- DEL_TRANSIT(m_accIconTr);
-
- DEL_TRANSIT(m_rejTracerTr);
- DEL_TRANSIT(m_rejGuideTr);
- DEL_TRANSIT(m_rejIconTr);
-
- eext_rotary_object_event_callback_del(*m_layout, CALLBACK_A(
- AcceptRejectWidget::onRotaryEvent));
- }
-
- void AcceptRejectWidget::prepare()
- {
- FAIL_RETURN_VOID(createAcceptComponents(),
- "createAcceptComponents() failed!");
-
- FAIL_RETURN_VOID(createRejectComponents(),
- "createRejectComponents() failed!");
-
- FAIL_RETURN_VOID(createBezelCueComponents(),
- "createBezelCueImages() failed!");
-
- eext_rotary_object_event_callback_add(*m_layout, CALLBACK_A(
- AcceptRejectWidget::onRotaryEvent), this);
- }
-
- Result AcceptRejectWidget::createAcceptComponents()
- {
- m_accTracer = impl::createImage(*m_layout, impl::LAYOUT_IMG_ACTION_BG);
- if (!m_accTracer) {
- LOG_RETURN(RES_FAIL, "createImage() failed");
- }
- m_accTracer->setColor(CU_COL_TRANSPARENT);
- m_layout->setContent(*m_accTracer,
- impl::PART_SWL_ACCEPT_FINGER_TRACER);
-
- m_accGuide = impl::createImage(*m_layout, impl::LAYOUT_IMG_ACTION_BG);
- if (!m_accGuide) {
- LOG_RETURN(RES_FAIL, "createImage() failed");
- }
- m_accGuide->setColor(CU_COL_TRANSPARENT);
- m_layout->setContent(*m_accGuide,
- impl::PART_SWL_ACCEPT_FINGER_GUIDE_BG);
-
- switch (m_acceptBtnType) {
- case AcceptButtonType::BT_HEADSET:
- m_accIcon = impl::createImage(*m_layout,
- impl::LAYOUT_IMG_ACCEPT_BT_HEADSET);
- break;
- default:
- m_accIcon = impl::createImage(*m_layout,
- impl::LAYOUT_IMG_ACCEPT);
- break;
- }
- if (!m_accIcon) {
- LOG_RETURN(RES_FAIL, "createImage() failed");
- }
- m_accIcon->setColor(CU_COL_AO0113);
- m_layout->setContent(*m_accIcon,
- impl::PART_SWL_ACCEPT_ICON);
-
- m_accEventLy = Layout::Builder().
- setTheme(impl::LAYOUT_EVENT_ACCEPT_REJECT).
- build(*m_layout);
- m_accEventLy->setWeight(EXPAND, EXPAND);
- m_accEventLy->addEventHandler(WidgetEvent::MOUSE_DOWN,
- WEAK_DELEGATE(AcceptRejectWidget::onMouseDown, asWeak(*this)));
- m_accEventLy->addEventHandler(WidgetEvent::MOUSE_UP,
- WEAK_DELEGATE(AcceptRejectWidget::onMouseUp, asWeak(*this)));
- m_accEventLy->addEventHandler(WidgetEvent::MOUSE_MOVE,
- WEAK_DELEGATE(AcceptRejectWidget::onMouseMove, asWeak(*this)));
- m_layout->setContent(*m_accEventLy,
- impl::PART_SWL_ACCEPT_FINGER_EVENT);
-
- return RES_OK;
- }
-
- Result AcceptRejectWidget::createRejectComponents()
- {
- m_rejTracer = impl::createImage(*m_layout, impl::LAYOUT_IMG_ACTION_BG);
- if (!m_rejTracer) {
- LOG_RETURN(RES_FAIL, "createImage() failed");
- }
- m_rejTracer->setColor(CU_COL_TRANSPARENT);
- m_layout->setContent(*m_rejTracer,
- impl::PART_SWL_REJECT_FINGER_TRACER);
-
- m_rejGuide = impl::createImage(*m_layout, impl::LAYOUT_IMG_ACTION_BG);
- if (!m_rejGuide) {
- LOG_RETURN(RES_FAIL, "createImage() failed");
- }
- m_rejGuide->setColor(CU_COL_TRANSPARENT);
- m_layout->setContent(*m_rejGuide,
- impl::PART_SWL_REJECT_FINGER_GUIDE_BG);
-
- m_rejIcon = impl::createImage(*m_layout, impl::LAYOUT_IMG_REJECT);
- if (!m_rejIcon) {
- LOG_RETURN(RES_FAIL, "createImage() failed");
- }
- m_rejIcon->setColor(CU_COL_AO0115);
- m_layout->setContent(*m_rejIcon,
- impl::PART_SWL_REJECT_ICON);
-
- m_rejEventLy = Layout::Builder().
- setTheme(impl::LAYOUT_EVENT_ACCEPT_REJECT).
- build(*m_layout);
-
- m_rejEventLy->addEventHandler(WidgetEvent::MOUSE_DOWN,
- WEAK_DELEGATE(AcceptRejectWidget::onMouseDown, asWeak(*this)));
-
- m_rejEventLy->addEventHandler(WidgetEvent::MOUSE_UP,
- WEAK_DELEGATE(AcceptRejectWidget::onMouseUp, asWeak(*this)));
-
- m_rejEventLy->addEventHandler(WidgetEvent::MOUSE_MOVE,
- WEAK_DELEGATE(AcceptRejectWidget::onMouseMove, asWeak(*this)));
-
- m_layout->setContent(*m_rejEventLy,
- impl::PART_SWL_REJECT_FINGER_EVENT);
-
- return RES_OK;
- }
-
- void AcceptRejectWidget::onMouseDown(Widget &widget, void *eventInfo)
- {
- if (m_isFreezed) {
- DLOG("Freezed");
- return;
- }
-
- if (m_rotaryClockwiseCount > 0
- || m_rotaryCounterClockwiseCount) {
- DLOG("Rotary event is ongoing. Ignore touch callback");
- return;
- }
-
- if (m_isAccPressed || m_isRejPressed) {
- LOG_RETURN_VOID(RES_FAIL, "Down signal already got");
- }
-
- DEL_TRANSIT(m_accTracerTr);
- DEL_TRANSIT(m_accGuideTr);
- DEL_TRANSIT(m_accIconTr);
-
- DEL_TRANSIT(m_rejTracerTr);
- DEL_TRANSIT(m_rejGuideTr);
- DEL_TRANSIT(m_rejIconTr);
-
- bool needTransition = true;
- if (m_rotaryClockwiseCount != 0
- || m_rotaryCounterClockwiseCount != 0) {
- m_rotaryClockwiseCount = 0;
- m_rotaryCounterClockwiseCount = 0;
- DLOG("Already expanded first step");
- needTransition = false;
- }
-
- if (widget == *m_accEventLy) {
- DLOG("Accept button down");
- m_isAccPressed = true;
- if (needTransition) {
- setAcceptPressedState();
- }
- } else if (widget == *m_rejEventLy) {
- DLOG("Reject button down");
- m_isRejPressed = true;
- if (needTransition) {
- setRejectPressedState();
- }
- }
- }
-
- void AcceptRejectWidget::onMouseUp(Widget &widget, void *eventInfo)
- {
- if (m_isFreezed) {
- DLOG("Freezed");
- return;
- }
-
- if (m_rotaryClockwiseCount > 0 || m_rotaryCounterClockwiseCount) {
- DLOG("Rotary event is ongoing. Ignore touch callback");
- return;
- }
-
- if (m_isAccPressed) {
- DEL_TRANSIT(m_accTracerTr);
- DEL_TRANSIT(m_accGuideTr);
- DEL_TRANSIT(m_accIconTr);
- } else {
- DEL_TRANSIT(m_rejTracerTr);
- DEL_TRANSIT(m_rejGuideTr);
- DEL_TRANSIT(m_rejIconTr);
- }
-
- m_lastMoveDistance = impl::INIT_MOVE_DISTANCE_VAL;
-
- if (widget == *m_accEventLy) {
- if (m_isAccPressed) {
- DLOG("Accept button released");
- setAcceptUnpressedState();
- } else {
- LOG_RETURN_VOID(RES_FAIL, "Accept button was not pressed");
- }
- } else if (widget == *m_rejEventLy) {
- if (m_isRejPressed) {
- DLOG("Reject button released");
- setRejectUnpressedState();
- } else {
- LOG_RETURN_VOID(RES_FAIL, "Reject button was not pressed");
- }
- }
- }
-
- int AcceptRejectWidget::getTracerMoveDistance(
- const ElmWidget &widget, int curX, int curY) const
- {
- Evas_Coord x, y, w, h;
- widget.getGeometry(&x, &y, &w, &h);
- int dx = curX - (x + (w / 2));
- int dy = curY - (y + (h / 2));
-
- int distance = pow(dx, 2);
- distance += pow(dy, 2);
- distance = sqrt(distance);
-
- if (distance > impl::FINGER_STROKE_HALF_DIM) {
- distance = impl::FINGER_STROKE_HALF_DIM;
- }
- return distance;
- }
-
- void AcceptRejectWidget::onMouseMove(Widget &widget, void *eventInfo)
- {
- if (m_isFreezed) {
- DLOG("Freezed");
- return;
- }
-
- if (m_rotaryClockwiseCount > 0 || m_rotaryCounterClockwiseCount) {
- DLOG("Rotary event is ongoing. Ignore touch callback");
- return;
- }
-
- ElmWidgetSRef img;
- if (widget == *m_accEventLy) {
- if (!m_isAccPressed) {
- LOG_RETURN_VOID(RES_FAIL, "Down callback is not come");
- }
- img = m_accTracer;
- } else if (widget == *m_rejEventLy) {
- if (!m_isRejPressed) {
- LOG_RETURN_VOID(RES_FAIL, "Down callback is not come");
- }
- img = m_rejTracer;
- }
-
- Evas_Event_Mouse_Move *ev =
- static_cast<Evas_Event_Mouse_Move *>(eventInfo);
- int distance = getTracerMoveDistance(*img,
- ev->cur.canvas.x, ev->cur.canvas.y);
-
- if (distance < impl::FINGER_TRACER_HALF_DIM) {
- return;
- }
- if (m_isAccPressed) {
- DEL_TRANSIT(m_accTracerTr);
- } else {
- DEL_TRANSIT(m_rejTracerTr);
- }
- m_lastMoveDistance = distance;
-
- impl::resizeImage(*img, m_lastMoveDistance * 2);
-
- if (m_lastMoveDistance >= impl::FINGER_STROKE_HALF_DIM) {
- m_isFreezed = true;
- if (m_accTracer == img && m_accHandler) {
- m_accHandler();
- } else if (m_rejTracer == img && m_rejHandler) {
- m_rejHandler();
- }
- }
- }
-
- void AcceptRejectWidget::startBezelCueAnimation()
- {
- if (m_lastAccBezelTr1 || m_lastAccBezelTr2 ||
- m_lastRejBezelTr1 || m_lastRejBezelTr2) {
- ILOG("Bezel cue is already animating");
- return;
- }
-
- // Accept bezel cue animation
- for (int i = 0 ; i < impl::BC_ITEM_COUNT ; i++) {
- m_accBezelCueImg[i]->setColor(CU_COL_AO0113D);
- m_rejBezelCueImg[i]->setColor(CU_COL_AO0115D);
- }
-
- m_accBCAnimIndex = impl::BC_ITEM_COUNT - 1;
- Elm_Transit *tr1 = elm_transit_add();
- elm_transit_effect_color_add(tr1, CU_COL_AO0113D, CU_COL_AO0113);
- elm_transit_object_add(tr1, *m_accBezelCueImg[m_accBCAnimIndex]);
- elm_transit_duration_set(tr1,
- impl::BC_ANIMATION_DURATION[m_accBCAnimIndex]);
- elm_transit_objects_final_state_keep_set(tr1, EINA_TRUE);
- elm_transit_del_cb_set(tr1,
- CALLBACK_A(AcceptRejectWidget::onAcceptBCTransitDel),
- this);
- elm_transit_go(tr1);
- m_lastAccBezelTr1 = tr1;
-
- m_rejBCAnimIndex = impl::BC_ITEM_COUNT - 1;
- Elm_Transit *tr2 = elm_transit_add();
- elm_transit_effect_color_add(tr2, CU_COL_AO0115D, CU_COL_AO0115);
- elm_transit_object_add(tr2, *m_rejBezelCueImg[m_rejBCAnimIndex]);
- elm_transit_duration_set(tr2,
- impl::BC_ANIMATION_DURATION[m_rejBCAnimIndex]);
- elm_transit_objects_final_state_keep_set(tr2, EINA_TRUE);
- elm_transit_del_cb_set(tr2,
- CALLBACK_A(AcceptRejectWidget::onRejectBCTransitDel),
- this);
- elm_transit_go(tr2);
- m_lastRejBezelTr1 = tr2;
- }
-
- void AcceptRejectWidget::setAcceptPressedTransitions()
- {
- setBezelCueVisible(false);
-
- setAcceptTracerPressedTransition();
- setAcceptGuidePressedTransition();
- setAcceptIconPressedTransition();
- setRejectIconHideTransition();
- }
-
- void AcceptRejectWidget::setAcceptTracerPressedTransition()
- {
- DEL_TRANSIT(m_accTracerTr);
- m_accTracerTr = elm_transit_add();
- elm_transit_effect_zoom_add(m_accTracerTr,
- impl::ICON_ZOOM_EFF_VAL_MIN, impl::ICON_ZOOM_EFF_VAL_MID);
- elm_transit_object_add(m_accTracerTr, *m_accTracer);
- elm_transit_duration_set(m_accTracerTr, impl::ROTARY_ACTION_ANIM_DUR);
- elm_transit_objects_final_state_keep_set(m_accTracerTr, EINA_FALSE);
- elm_transit_del_cb_set(m_accTracerTr,
- CALLBACK_A(AcceptRejectWidget::onAcceptTransitDel),
- this);
- elm_transit_go(m_accTracerTr);
- }
-
- void AcceptRejectWidget::setAcceptGuidePressedTransition()
- {
- DEL_TRANSIT(m_accGuideTr);
- m_accGuideTr = elm_transit_add();
- elm_transit_effect_zoom_add(m_accGuideTr,
- impl::ICON_ZOOM_EFF_VAL_MIN, impl::ICON_ZOOM_EFF_VAL_MAX);
- elm_transit_object_add(m_accGuideTr, *m_accGuide);
- elm_transit_duration_set(m_accGuideTr, impl::ROTARY_ACTION_ANIM_DUR);
- elm_transit_objects_final_state_keep_set(m_accGuideTr, EINA_FALSE);
- elm_transit_del_cb_set(m_accGuideTr,
- CALLBACK_A(AcceptRejectWidget::onAcceptBgExpandTransitDel),
- this);
- elm_transit_go(m_accGuideTr);
- }
-
- void AcceptRejectWidget::setAcceptIconPressedTransition()
- {
- DEL_TRANSIT(m_accIconTr);
- m_accIconTr = elm_transit_add();
- elm_transit_effect_color_add(m_accIconTr, CU_COL_AO0113, CU_COL_WHITE);
- elm_transit_object_add(m_accIconTr, *m_accIcon);
- elm_transit_duration_set(m_accIconTr, impl::ROTARY_ACTION_ANIM_DUR);
- elm_transit_objects_final_state_keep_set(m_accIconTr, EINA_TRUE);
- elm_transit_del_cb_set(m_accIconTr,
- CALLBACK_A(AcceptRejectWidget::onAcceptIconTransitDel),
- this);
- elm_transit_go(m_accIconTr);
- }
-
- void AcceptRejectWidget::setRejectIconHideTransition()
- {
- DEL_TRANSIT(m_rejIconTr);
-
- Evas_Coord x;
- m_rejIcon->getGeometry(&x, nullptr, nullptr, nullptr);
- int dx = x - impl::REJ_ICON_RIGHT_PAD_X;
-
- int animTrace = impl::ACC_REJ_ICON_HIDE_THRESHOLD_W - dx;
- if (animTrace <= 0) {
- DLOG("No need to add transition");
- return;
- }
-
- m_rejIconTr = elm_transit_add();
- elm_transit_effect_translation_add(m_rejIconTr, 0, 0, animTrace, 0);
- elm_transit_object_add(m_rejIconTr, *m_rejIcon);
- elm_transit_duration_set(m_rejIconTr, impl::ROTARY_ACTION_ANIM_DUR);
- elm_transit_objects_final_state_keep_set(m_rejIconTr, EINA_TRUE);
- elm_transit_del_cb_set(m_rejIconTr,
- CALLBACK_A(AcceptRejectWidget::onRejectIconTransitDel),
- this);
- elm_transit_go(m_rejIconTr);
- }
-
- void AcceptRejectWidget::setAcceptFullExpensionTransition()
- {
- DEL_TRANSIT(m_accTracerTr);
- m_accTracerTr = elm_transit_add();
- elm_transit_effect_zoom_add(m_accTracerTr,
- impl::ICON_ZOOM_EFF_VAL_MIN, impl::ICON_ZOOM_EFF_VAL_MAX);
- elm_transit_object_add(m_accTracerTr, *m_accTracer);
- elm_transit_duration_set(m_accTracerTr, impl::ROTARY_ACTION_ANIM_DUR);
- elm_transit_objects_final_state_keep_set(m_accTracerTr, EINA_FALSE);
- elm_transit_del_cb_set(m_accTracerTr,
- CALLBACK_A(AcceptRejectWidget::
- onAcceptFullExpensionTransitDel),
- this);
- elm_transit_go(m_accTracerTr);
-
- }
-
- void AcceptRejectWidget::setAcceptGuideUnpressedTransition()
- {
- DEL_TRANSIT(m_accGuideTr);
- m_accGuideTr = elm_transit_add();
- elm_transit_effect_zoom_add(m_accGuideTr,
- impl::ICON_ZOOM_EFF_VAL_MAX, impl::ICON_ZOOM_EFF_VAL_MIN);
- elm_transit_object_add(m_accGuideTr, *m_accGuide);
- elm_transit_duration_set(m_accGuideTr, impl::ROTARY_ACTION_ANIM_DUR);
- elm_transit_objects_final_state_keep_set(m_accGuideTr, EINA_FALSE);
- elm_transit_del_cb_set(m_accGuideTr,
- CALLBACK_A(AcceptRejectWidget::onAcceptBgContractTransitDel),
- this);
- elm_transit_go(m_accGuideTr);
- }
-
- void AcceptRejectWidget::setRejectIconShowTransition()
- {
- DEL_TRANSIT(m_rejIconTr);
-
- Evas_Coord x;
- m_rejIcon->getGeometry(&x, nullptr, nullptr, nullptr);
- int dx = impl::REJ_ICON_RIGHT_PAD_X - x;
-
- if (dx >= 0) {
- DLOG("No need to add transition");
- return;
- }
-
- m_rejIconTr = elm_transit_add();
- elm_transit_effect_translation_add(m_rejIconTr, 0, 0, dx, 0);
- elm_transit_object_add(m_rejIconTr, *m_rejIcon);
- elm_transit_duration_set(m_rejIconTr, impl::ROTARY_ACTION_ANIM_DUR);
- elm_transit_objects_final_state_keep_set(m_rejIconTr, EINA_TRUE);
- elm_transit_del_cb_set(m_rejIconTr,
- CALLBACK_A(AcceptRejectWidget::onRejectIconTransitDel),
- this);
- elm_transit_go(m_rejIconTr);
- }
-
- void AcceptRejectWidget::setAcceptUnpressedTransitions()
- {
- setAcceptGuideUnpressedTransition();
- setRejectIconShowTransition();
- }
-
- void AcceptRejectWidget::setRejectPressedTransitions()
- {
- setBezelCueVisible(false);
-
- setRejectTracerPressedTransition();
- setRejectGuidePressedTransition();
- setRejectIconPressedTransition();
- setAcceptIconHideTransition();
- }
-
- void AcceptRejectWidget::setRejectTracerPressedTransition()
- {
- DEL_TRANSIT(m_rejTracerTr);
- m_rejTracerTr = elm_transit_add();
- elm_transit_effect_zoom_add(m_rejTracerTr,
- impl::ICON_ZOOM_EFF_VAL_MIN, impl::ICON_ZOOM_EFF_VAL_MID);
- elm_transit_object_add(m_rejTracerTr, *m_rejTracer);
- elm_transit_duration_set(m_rejTracerTr, impl::ROTARY_ACTION_ANIM_DUR);
- elm_transit_objects_final_state_keep_set(m_rejTracerTr, EINA_FALSE);
- elm_transit_del_cb_set(m_rejTracerTr,
- CALLBACK_A(AcceptRejectWidget::onRejectTransitDel),
- this);
- elm_transit_go(m_rejTracerTr);
- }
-
- void AcceptRejectWidget::setRejectGuidePressedTransition()
- {
- DEL_TRANSIT(m_rejGuideTr);
- m_rejGuideTr = elm_transit_add();
- elm_transit_effect_zoom_add(m_rejGuideTr,
- impl::ICON_ZOOM_EFF_VAL_MIN, impl::ICON_ZOOM_EFF_VAL_MAX);
- elm_transit_object_add(m_rejGuideTr, *m_rejGuide);
- elm_transit_duration_set(m_rejGuideTr, impl::ROTARY_ACTION_ANIM_DUR);
- elm_transit_objects_final_state_keep_set(m_rejGuideTr, EINA_FALSE);
- elm_transit_del_cb_set(m_rejGuideTr,
- CALLBACK_A(AcceptRejectWidget::onRejectBgExpandTransitDel),
- this);
- elm_transit_go(m_rejGuideTr);
- }
-
- void AcceptRejectWidget::setRejectIconPressedTransition()
- {
- DEL_TRANSIT(m_rejIconTr);
- m_rejIconTr = elm_transit_add();
- elm_transit_effect_color_add(m_rejIconTr, CU_COL_AO0115, CU_COL_WHITE);
- elm_transit_object_add(m_rejIconTr, *m_rejIcon);
- elm_transit_duration_set(m_rejIconTr, impl::ROTARY_ACTION_ANIM_DUR);
- elm_transit_objects_final_state_keep_set(m_rejIconTr, EINA_TRUE);
- elm_transit_del_cb_set(m_rejIconTr,
- CALLBACK_A(AcceptRejectWidget::onRejectIconTransitDel),
- this);
- elm_transit_go(m_rejIconTr);
- }
-
- void AcceptRejectWidget::setAcceptIconHideTransition()
- {
- DEL_TRANSIT(m_accIconTr);
-
- Evas_Coord x;
- m_accIcon->getGeometry(&x, nullptr, nullptr, nullptr);
- int dx = impl::ACC_ICON_RIGHT_PAD_X - x;
-
- int animTrace = dx - impl::ACC_REJ_ICON_HIDE_THRESHOLD_W;
- if (animTrace >= 0) {
- DLOG("No need to add transition");
- return;
- }
- m_accIconTr = elm_transit_add();
- elm_transit_effect_translation_add(m_accIconTr, 0, 0, animTrace, 0);
- elm_transit_object_add(m_accIconTr, *m_accIcon);
- elm_transit_duration_set(m_accIconTr, impl::ROTARY_ACTION_ANIM_DUR);
- elm_transit_objects_final_state_keep_set(m_accIconTr, EINA_TRUE);
- elm_transit_del_cb_set(m_accIconTr,
- CALLBACK_A(AcceptRejectWidget::onAcceptIconTransitDel),
- this);
- elm_transit_go(m_accIconTr);
- }
-
- void AcceptRejectWidget::setAcceptIconShowTransition()
- {
- DEL_TRANSIT(m_accIconTr);
-
- Evas_Coord x;
- m_accIcon->getGeometry(&x, nullptr, nullptr, nullptr);
- int dx = impl::ACC_ICON_RIGHT_PAD_X - x;
-
- if (dx <= 0) {
- DLOG("No need to add transition");
- return;
- }
-
- m_accIconTr = elm_transit_add();
- elm_transit_effect_translation_add(m_accIconTr, 0, 0, dx, 0);
- elm_transit_object_add(m_accIconTr, *m_accIcon);
- elm_transit_duration_set(m_accIconTr, impl::ROTARY_ACTION_ANIM_DUR);
- elm_transit_objects_final_state_keep_set(m_accIconTr, EINA_TRUE);
- elm_transit_del_cb_set(m_accIconTr,
- CALLBACK_A(AcceptRejectWidget::onAcceptIconTransitDel),
- this);
- elm_transit_go(m_accIconTr);
- }
-
- void AcceptRejectWidget::setRejectFullExpensionTransition()
- {
- DEL_TRANSIT(m_rejTracerTr);
- m_rejTracerTr = elm_transit_add();
- elm_transit_effect_zoom_add(m_rejTracerTr,
- impl::ICON_ZOOM_EFF_VAL_MIN, impl::ICON_ZOOM_EFF_VAL_MAX);
- elm_transit_object_add(m_rejTracerTr, *m_rejTracer);
- elm_transit_duration_set(m_rejTracerTr, impl::ROTARY_ACTION_ANIM_DUR);
- elm_transit_objects_final_state_keep_set(m_rejTracerTr, EINA_FALSE);
- elm_transit_del_cb_set(m_rejTracerTr,
- CALLBACK_A(AcceptRejectWidget::
- onRejectFullExpensionTransitDel),
- this);
- elm_transit_go(m_rejTracerTr);
- }
-
- void AcceptRejectWidget::setRejectUnpressedTransitions()
- {
- setRejectGuideUnpressedTransition();
- setAcceptIconShowTransition();
- }
-
- void AcceptRejectWidget::setRejectGuideUnpressedTransition()
- {
- DEL_TRANSIT(m_rejGuideTr);
- m_rejGuideTr = elm_transit_add();
- elm_transit_effect_zoom_add(m_rejGuideTr,
- impl::ICON_ZOOM_EFF_VAL_MAX, impl::ICON_ZOOM_EFF_VAL_MIN);
- elm_transit_object_add(m_rejGuideTr, *m_rejGuide);
- elm_transit_duration_set(m_rejGuideTr, impl::ROTARY_ACTION_ANIM_DUR);
- elm_transit_objects_final_state_keep_set(m_rejGuideTr, EINA_FALSE);
- elm_transit_del_cb_set(m_rejGuideTr,
- CALLBACK_A(AcceptRejectWidget::onRejectBgContractTransitDel),
- this);
- elm_transit_go(m_rejGuideTr);
- }
-
- Result AcceptRejectWidget::createBezelCueComponents()
- {
- for (int i = 0; i < impl::BC_ITEM_COUNT; i++) {
- // Accept
- m_accBezelCueImg[i] = impl::createImage(*m_layout,
- impl::ACCEPT_BC_PARAMS[i].theme);
- if (!m_accBezelCueImg[i]) {
- LOG_RETURN(RES_FAIL, "Create bezel cue image failed");
- }
- m_accBezelCueImg[i]->setColor(CU_COL_AO0113T);
- show(*m_accBezelCueImg[i]);
- m_layout->setContent(*m_accBezelCueImg[i],
- impl::ACCEPT_BC_PARAMS[i].part);
-
- // Reject
- m_rejBezelCueImg[i] = impl::createImage(*m_layout,
- impl::REJECT_BC_PARAMS[i].theme);
- if (!m_rejBezelCueImg[i]) {
- LOG_RETURN(RES_FAIL, "Create bezel cue image failed");
- }
- m_rejBezelCueImg[i]->setColor(CU_COL_AO0113T);
- show(*m_rejBezelCueImg[i]);
- m_layout->setContent(*m_rejBezelCueImg[i],
- impl::REJECT_BC_PARAMS[i].part);
- }
- return RES_OK;
- }
-
- void AcceptRejectWidget::setBezelCueVisible(bool isVisible)
- {
- if (isVisible) {
- for (int i = 0; i < impl::BC_ITEM_COUNT; i++) {
- show(*m_accBezelCueImg[i]);
- show(*m_rejBezelCueImg[i]);
- }
- } else {
- for (int i = 0; i < impl::BC_ITEM_COUNT; i++) {
- hide(*m_accBezelCueImg[i]);
- hide(*m_rejBezelCueImg[i]);
- }
- }
- }
-
- void AcceptRejectWidget::onAcceptTransitDel(Elm_Transit *transit)
- {
- m_accTracerTr = nullptr;
-
- impl::resizeImage(*m_accTracer, impl::FINGER_TRACER_DIM);
- }
-
- void AcceptRejectWidget::onAcceptFullExpensionTransitDel(
- Elm_Transit *transit)
- {
- m_accTracerTr = nullptr;
-
- m_isFreezed = true;
- impl::resizeImage(*m_accTracer, impl::FINGER_STROKE_DIM);
-
- if (m_accHandler) {
- m_accHandler();
- }
- }
-
- void AcceptRejectWidget::onAcceptBgExpandTransitDel(Elm_Transit *transit)
- {
- m_accGuideTr = nullptr;
-
- impl::resizeImage(*m_accGuide, impl::FINGER_STROKE_DIM);
- }
-
- void AcceptRejectWidget::onAcceptBgContractTransitDel(
- Elm_Transit *transit)
- {
- m_accGuideTr = nullptr;
-
- m_accGuide->setColor(CU_COL_TRANSPARENT);
- impl::resizeImage(*m_accGuide, impl::FINGER_TRACER_DIM);
-
- m_isAccPressed = false;
- m_isRejPressed = false;
- m_isContracting = false;
-
- setBezelCueVisible(true);
- }
-
- void AcceptRejectWidget::onAcceptIconTransitDel(Elm_Transit *transit)
- {
- m_accIconTr = nullptr;
- }
-
- void AcceptRejectWidget::onRejectTransitDel(Elm_Transit *transit)
- {
- m_rejTracerTr = nullptr;
-
- impl::resizeImage(*m_rejTracer, impl::FINGER_TRACER_DIM);
- }
-
- void AcceptRejectWidget::onRejectFullExpensionTransitDel(
- Elm_Transit *transit)
- {
- m_rejTracerTr = nullptr;
-
- m_isFreezed = true;
- impl::resizeImage(*m_rejTracer, impl::FINGER_STROKE_DIM);
-
- if (m_rejHandler) {
- m_rejHandler();
- }
-
- }
-
- void AcceptRejectWidget::onRejectBgExpandTransitDel(Elm_Transit *transit)
- {
- m_rejGuideTr = nullptr;
-
- impl::resizeImage(*m_rejGuide, impl::FINGER_STROKE_DIM);
- }
-
- void AcceptRejectWidget::onRejectBgContractTransitDel(
- Elm_Transit *transit)
- {
- m_rejGuideTr = nullptr;
-
- m_rejGuide->setColor(CU_COL_TRANSPARENT);
- impl::resizeImage(*m_rejGuide, impl::FINGER_TRACER_DIM);
-
- m_isAccPressed = false;
- m_isRejPressed = false;
- m_isContracting = false;
-
- setBezelCueVisible(true);
- }
-
- void AcceptRejectWidget::onRejectIconTransitDel(Elm_Transit *transit)
- {
- m_rejIconTr = nullptr;
- }
-
- void AcceptRejectWidget::onAcceptBCTransitDel(Elm_Transit *transit)
- {
- if (m_accBCAnimIndex == 0) {
- Elm_Transit *tr1 = elm_transit_add();
- elm_transit_effect_color_add(tr1, CU_COL_AO0113, CU_COL_AO0113D);
- elm_transit_object_add(tr1, *m_accBezelCueImg[m_accBCAnimIndex]);
- elm_transit_duration_set(tr1,
- impl::BC_ANIMATION_DURATION[impl::BC_ITEM_COUNT - 1]);
- elm_transit_objects_final_state_keep_set(tr1, EINA_TRUE);
- elm_transit_del_cb_set(tr1,
- CALLBACK_A(AcceptRejectWidget::onAcceptBCTransitDelLast),
- this);
- elm_transit_go(tr1);
-
- m_lastAccBezelTr1 = tr1;
- m_lastAccBezelTr2 = nullptr;
- return;
- }
-
- int oldIndex = m_accBCAnimIndex;
- m_accBCAnimIndex--;
-
- Elm_Transit *tr1 = elm_transit_add();
- elm_transit_effect_color_add(tr1, CU_COL_AO0113, CU_COL_AO0113D);
- elm_transit_object_add(tr1, *m_accBezelCueImg[oldIndex]);
- elm_transit_duration_set(tr1,
- impl::BC_ANIMATION_DURATION[m_accBCAnimIndex]);
- elm_transit_objects_final_state_keep_set(tr1, EINA_TRUE);
- elm_transit_go(tr1);
-
- Elm_Transit *tr2 = elm_transit_add();
- elm_transit_effect_color_add(tr2, CU_COL_AO0113D, CU_COL_AO0113);
- elm_transit_object_add(tr2, *m_accBezelCueImg[m_accBCAnimIndex]);
- elm_transit_duration_set(tr2,
- impl::BC_ANIMATION_DURATION[m_accBCAnimIndex]);
- elm_transit_objects_final_state_keep_set(tr2, EINA_TRUE);
- elm_transit_del_cb_set(tr2,
- CALLBACK_A(AcceptRejectWidget::onAcceptBCTransitDel),
- this);
- elm_transit_go(tr2);
-
- m_lastAccBezelTr1 = tr1;
- m_lastAccBezelTr2 = tr2;
- }
-
- void AcceptRejectWidget::onAcceptBCTransitDelLast(Elm_Transit *transit)
- {
- m_accBCAnimCount++;
-
- if (m_accBCAnimCount >= impl::BC_ANIMATE_COUNT_MAX) {
- ILOG("Max count accept bezel animation reached. Hide all image");
- m_accBCAnimCount = 0;
-
- Elm_Transit *hideTransit = elm_transit_add();
- elm_transit_effect_color_add(hideTransit,
- CU_COL_AO0113D, CU_COL_AO0113T);
- for (int i = 0; i < impl::BC_ITEM_COUNT; i++) {
- m_accBezelCueImg[i]->setColor(CU_COL_AO0113D);
- elm_transit_object_add(hideTransit, *m_accBezelCueImg[i]);
- }
- elm_transit_duration_set(hideTransit, impl::BC_ANIM_DUR_HIDE);
- elm_transit_objects_final_state_keep_set(hideTransit, EINA_TRUE);
- elm_transit_del_cb_set(hideTransit,
- [](void *data, Elm_Transit *transit) -> void
- {
- auto self = static_cast<AcceptRejectWidget *>(data);
- self->m_lastAccBezelTr1 = nullptr;
- self->m_lastAccBezelTr2 = nullptr;
- }, this);
- elm_transit_go(hideTransit);
-
- m_lastAccBezelTr1 = hideTransit;
- m_lastAccBezelTr2 = nullptr;
- return;
- }
-
- m_accBCAnimIndex = impl::BC_ITEM_COUNT - 1;
- Elm_Transit *tr1 = elm_transit_add();
- elm_transit_effect_color_add(tr1, CU_COL_AO0113D, CU_COL_AO0113);
- elm_transit_object_add(tr1, *m_accBezelCueImg[m_accBCAnimIndex]);
- elm_transit_duration_set(tr1,
- impl::BC_ANIMATION_DURATION[m_accBCAnimIndex]);
- elm_transit_objects_final_state_keep_set(tr1, EINA_TRUE);
- elm_transit_del_cb_set(tr1,
- CALLBACK_A(AcceptRejectWidget::onAcceptBCTransitDel),
- this);
- elm_transit_go(tr1);
-
- m_lastAccBezelTr1 = tr1;
- m_lastAccBezelTr2 = nullptr;
- }
-
- void AcceptRejectWidget::onRejectBCTransitDel(Elm_Transit *transit)
- {
- if (m_rejBCAnimIndex == 0) {
- Elm_Transit *tr1 = elm_transit_add();
- elm_transit_effect_color_add(tr1, CU_COL_AO0115, CU_COL_AO0115D);
- elm_transit_object_add(tr1, *m_rejBezelCueImg[m_rejBCAnimIndex]);
- elm_transit_duration_set(tr1,
- impl::BC_ANIMATION_DURATION[impl::BC_ITEM_COUNT - 1]);
- elm_transit_objects_final_state_keep_set(tr1, EINA_TRUE);
- elm_transit_del_cb_set(tr1,
- CALLBACK_A(AcceptRejectWidget::onRejectBCTransitDelLast),
- this);
- elm_transit_go(tr1);
- m_lastRejBezelTr1 = tr1;
- m_lastRejBezelTr2 = nullptr;
- return;
- }
-
- int oldIndex = m_rejBCAnimIndex;
- m_rejBCAnimIndex--;
-
- Elm_Transit *tr1 = elm_transit_add();
- elm_transit_effect_color_add(tr1, CU_COL_AO0115, CU_COL_AO0115D);
- elm_transit_object_add(tr1, *m_rejBezelCueImg[oldIndex]);
- elm_transit_duration_set(tr1,
- impl::BC_ANIMATION_DURATION[m_rejBCAnimIndex]);
- elm_transit_objects_final_state_keep_set(tr1, EINA_TRUE);
- elm_transit_go(tr1);
-
- Elm_Transit *tr2 = elm_transit_add();
- elm_transit_effect_color_add(tr2, CU_COL_AO0115D, CU_COL_AO0115);
- elm_transit_object_add(tr2, *m_rejBezelCueImg[m_rejBCAnimIndex]);
- elm_transit_duration_set(tr2,
- impl::BC_ANIMATION_DURATION[m_rejBCAnimIndex]);
- elm_transit_objects_final_state_keep_set(tr2, EINA_TRUE);
- elm_transit_del_cb_set(tr2,
- CALLBACK_A(AcceptRejectWidget::onRejectBCTransitDel),
- this);
- elm_transit_go(tr2);
-
- m_lastRejBezelTr1 = tr1;
- m_lastRejBezelTr2 = tr2;
- }
-
- void AcceptRejectWidget::onRejectBCTransitDelLast(Elm_Transit *transit)
- {
- m_rejBCAnimCount++;
-
- if (m_rejBCAnimCount >= impl::BC_ANIMATE_COUNT_MAX) {
- ILOG("Max count accept bezel animation reached. Hide all image");
- m_rejBCAnimCount = 0;
-
- Elm_Transit *hideTransit = elm_transit_add();
- elm_transit_effect_color_add(hideTransit,
- CU_COL_AO0115D, CU_COL_AO0115T);
- for (int i = 0; i < impl::BC_ITEM_COUNT; i++) {
- m_rejBezelCueImg[i]->setColor(CU_COL_AO0115D);
- elm_transit_object_add(hideTransit, *m_rejBezelCueImg[i]);
- }
- elm_transit_duration_set(hideTransit, impl::BC_ANIM_DUR_HIDE);
- elm_transit_objects_final_state_keep_set(hideTransit, EINA_TRUE);
- elm_transit_del_cb_set(hideTransit,
- [](void *data, Elm_Transit *transit) -> void
- {
- auto self = static_cast<AcceptRejectWidget *>(data);
- self->m_lastRejBezelTr1 = nullptr;
- self->m_lastRejBezelTr2 = nullptr;
- }, this);
- elm_transit_go(hideTransit);
-
- m_lastRejBezelTr1 = hideTransit;
- m_lastRejBezelTr2 = nullptr;
- return;
- }
-
- m_rejBCAnimIndex = impl::BC_ITEM_COUNT - 1;
- Elm_Transit *tr1 = elm_transit_add();
- elm_transit_effect_color_add(tr1, CU_COL_AO0115D, CU_COL_AO0115);
- elm_transit_object_add(tr1, *m_rejBezelCueImg[m_rejBCAnimIndex]);
- elm_transit_duration_set(tr1,
- impl::BC_ANIMATION_DURATION[m_rejBCAnimIndex]);
- elm_transit_objects_final_state_keep_set(tr1, EINA_TRUE);
- elm_transit_del_cb_set(tr1,
- CALLBACK_A(AcceptRejectWidget::onRejectBCTransitDel),
- this);
- elm_transit_go(tr1);
-
- m_lastRejBezelTr1 = tr1;
- m_lastRejBezelTr2 = nullptr;
- }
-
- void AcceptRejectWidget::onAcceptExpandTimeout(Timeout *sender)
- {
- if (m_rotaryClockwiseCount > 0) {
- m_rotaryClockwiseCount = 0;
- m_isContracting = true;
- setAcceptUnpressedState();
- } else {
- DLOG("Counter is 0. Ignored");
- }
- m_expandTimeout.reset();
- }
-
- void AcceptRejectWidget::onRejectExpandTimeout(Timeout *sender)
- {
- if (m_rotaryCounterClockwiseCount > 0) {
- m_rotaryCounterClockwiseCount = 0;
- m_isContracting = true;
- setRejectUnpressedState();
- } else {
- DLOG("Counter is 0. Ignored");
- }
- m_expandTimeout.reset();
- }
-
- Eina_Bool AcceptRejectWidget::processClockwiseRotaryEvent()
- {
- if (m_rotaryCounterClockwiseCount > 0) {
- m_rotaryCounterClockwiseCount = 0;
- setRejectUnpressedState();
- return EINA_TRUE;
- }
-
- m_rotaryClockwiseCount++;
-
- if (m_rotaryClockwiseCount == 1) {
- setAcceptPressedState();
- m_expandTimeout = Timeout::create(impl::EXPAND_WAITING_TIMEOUT,
- WEAK_DELEGATE(AcceptRejectWidget::onAcceptExpandTimeout,
- asWeak(*this)));
- } else if (m_rotaryClockwiseCount == 2) {
- m_expandTimeout.reset();
- impl::resizeImage(*m_accTracer, impl::FINGER_TRACER_DIM);
- setAcceptFullExpensionTransition();
- return EINA_TRUE;
- } else {
- LOG_RETURN_VALUE(RES_FAIL, EINA_TRUE, "Illegal state");
- }
- return EINA_TRUE;
- }
-
- Eina_Bool AcceptRejectWidget::processCounterClockwiseRotaryEvent()
- {
- if (m_rotaryClockwiseCount > 0) {
- m_rotaryClockwiseCount = 0;
- setAcceptUnpressedState();
- return EINA_TRUE;
- }
-
- m_rotaryCounterClockwiseCount ++;
-
- if (m_rotaryCounterClockwiseCount == 1) {
- setRejectPressedState();
- m_expandTimeout = Timeout::create(impl::EXPAND_WAITING_TIMEOUT,
- WEAK_DELEGATE(AcceptRejectWidget::onRejectExpandTimeout,
- asWeak(*this)));
-
- } else if (m_rotaryCounterClockwiseCount == 2) {
- m_expandTimeout.reset();
- impl::resizeImage(*m_rejTracer, impl::FINGER_TRACER_DIM);
- setRejectFullExpensionTransition();
- return EINA_TRUE;
- } else {
- LOG_RETURN_VALUE(RES_FAIL, EINA_TRUE, "Illegal state");
- }
- return EINA_TRUE;
- }
-
- Eina_Bool AcceptRejectWidget::onRotaryEvent(Evas_Object *obj,
- Eext_Rotary_Event_Info *info)
- {
- if (m_isFreezed) {
- DLOG("Freezed");
- return EINA_TRUE;
- }
-
- if (m_isAccPressed || m_isRejPressed) {
- LOG_RETURN_VALUE(RES_FAIL, EINA_TRUE,
- "Button accept/reject button already pressed");
- }
-
- m_expandTimeout.reset();
-
- if (m_isContracting) {
- DLOG("Contracting. Ignore");
- return EINA_TRUE;
- }
-
- if (info->direction == EEXT_ROTARY_DIRECTION_CLOCKWISE) {
- DLOG("Rotary event [CLOCKWISE]");
- return processClockwiseRotaryEvent();
- } else {
- DLOG("Rotary event [COUNTER_CLOCKWISE]");
- return processCounterClockwiseRotaryEvent();
- }
- }
-
- void AcceptRejectWidget::activateRotary()
- {
- eext_rotary_object_event_activated_set(*m_layout, EINA_TRUE);
- }
- void AcceptRejectWidget::deactivateRotary()
- {
- eext_rotary_object_event_activated_set(*m_layout, EINA_FALSE);
- }
-
- void AcceptRejectWidget::setAcceptBtnType(AcceptButtonType type)
- {
- if (m_acceptBtnType == type) {
- DLOG("Accept icon type is already set");
- }
-
- if (!m_accIcon) {
- return;
- }
-
- switch (m_acceptBtnType) {
- case AcceptButtonType::BT_HEADSET:
- m_accIcon->setTheme(impl::LAYOUT_IMG_ACCEPT_BT_HEADSET);
- break;
- default:
- m_accIcon->setTheme(impl::LAYOUT_IMG_ACCEPT);
- break;
- }
- }
-
- void AcceptRejectWidget::reset()
- {
- m_isFreezed = false;
-
- DEL_TRANSIT(m_accTracerTr);
- DEL_TRANSIT(m_accGuideTr);
- DEL_TRANSIT(m_accIconTr);
-
- DEL_TRANSIT(m_rejTracerTr);
- DEL_TRANSIT(m_rejGuideTr);
- DEL_TRANSIT(m_rejIconTr);
-
- m_lastMoveDistance = impl::INIT_MOVE_DISTANCE_VAL;
-
- setAcceptUnpressedState();
- setRejectUnpressedState();
-
- m_rotaryClockwiseCount = 0;
- m_rotaryCounterClockwiseCount = 0;
- }
-
- void AcceptRejectWidget::setAcceptPressedState()
- {
- impl::resizeImage(*m_accTracer, impl::FINGER_TRACER_HALF_DIM);
- m_accTracer->setColor(CU_COL_AO01131);
-
- impl::resizeImage(*m_accGuide, impl::FINGER_TRACER_DIM);
- m_accGuide->setColor(CU_COL_AO01132);
-
- setAcceptPressedTransitions();
- }
-
- void AcceptRejectWidget::setRejectPressedState()
- {
- impl::resizeImage(*m_rejTracer, impl::FINGER_TRACER_HALF_DIM);
- m_rejTracer->setColor(CU_COL_AO01151);
-
- impl::resizeImage(*m_rejGuide, impl::FINGER_TRACER_DIM);
- m_rejGuide->setColor(CU_COL_AO01152);
-
- setRejectPressedTransitions();
- }
-
- void AcceptRejectWidget::setAcceptUnpressedState()
- {
- impl::resizeImage(*m_accTracer, impl::FINGER_TRACER_HALF_DIM);
- m_accTracer->setColor(CU_COL_TRANSPARENT);
-
- m_accIcon->setColor(CU_COL_AO0113);
-
- impl::resizeImage(*m_accGuide, impl::FINGER_TRACER_DIM);
-
- setAcceptUnpressedTransitions();
- }
-
- void AcceptRejectWidget::setRejectUnpressedState()
- {
- impl::resizeImage(*m_rejTracer, impl::FINGER_TRACER_HALF_DIM);
- m_rejTracer->setColor(CU_COL_TRANSPARENT);
-
- m_rejIcon->setColor(CU_COL_AO0115);
-
- impl::resizeImage(*m_rejGuide, impl::FINGER_TRACER_DIM);
-
- setRejectUnpressedTransitions();
- }
-
- // Screen Reader
- ElmWidget *AcceptRejectWidget::getAcceptAo()
- {
- return m_accAo.get();
- }
-
- ElmWidget *AcceptRejectWidget::getRejectAo()
- {
- return m_rejAo.get();
- }
-
- Result AcceptRejectWidget::registerAccessObjects(ElmWidget &parent)
- {
- m_accAo = utils::createAccessObject(parent, *m_accEventLy);
- if (!m_accAo) {
- LOG_RETURN(RES_FAIL, "createAccessObject() failed!");
- }
- elm_atspi_accessible_translation_domain_set(*m_accAo, PACKAGE);
- elm_atspi_accessible_reading_info_type_set(*m_accAo,
- ELM_ACCESSIBLE_READING_INFO_TYPE_NAME |
- ELM_ACCESSIBLE_READING_INFO_TYPE_DESCRIPTION);
- elm_atspi_accessible_name_set(*m_accAo, AO_STR_ACCEPT_CALL);
- elm_atspi_accessible_description_set(*m_accAo,
- AO_STR_SWIPE_RIGHT_WITH_TWO_FINGERS_TO_ACCEPT);
-
- m_rejAo = utils::createAccessObject(parent, *m_rejEventLy);
- if (!m_rejAo) {
- LOG_RETURN(RES_FAIL, "createAccessObject() failed!");
- }
- elm_atspi_accessible_translation_domain_set(*m_rejAo, PACKAGE);
- elm_atspi_accessible_reading_info_type_set(*m_rejAo,
- ELM_ACCESSIBLE_READING_INFO_TYPE_NAME |
- ELM_ACCESSIBLE_READING_INFO_TYPE_DESCRIPTION);
- elm_atspi_accessible_name_set(*m_rejAo, AO_STR_REJECT_CALL);
- elm_atspi_accessible_description_set(*m_rejAo,
- AO_STR_SWIPE_LEFT_WITH_TWO_FINGERS_TO_REJECT);
-
- return RES_OK;
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "view/Slider.h"
-
-#include "common.h"
-
-namespace callui { namespace { namespace impl {
-
- using namespace ucl;
-
- constexpr LayoutTheme LAYOUT_SLIDER
- {"layout", "callui", "slider"};
-
- constexpr EdjePart PART_SWL_SLIDER {"swl.slider"};
-}}}
-
-namespace callui {
-
- using namespace ucl;
-
- Slider::Builder::Builder():
- m_maxValue(0),
- m_curValue(0)
- {
- }
-
- Slider::Builder &Slider::Builder::setMaxValue(int maxValue)
- {
- m_maxValue = maxValue;
- return *this;
- }
-
- Slider::Builder &Slider::Builder::setValue(int curValue)
- {
- m_curValue = curValue;
- return *this;
- }
-
- SliderSRef Slider::Builder::build(ElmWidget &parent) const
- {
- auto layout = Layout::Builder().
- setTheme(impl::LAYOUT_SLIDER).
- setIsOwner(true).
- build(parent);
- if (!layout) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "Layout::build() failed!");
- }
-
- auto result = makeShared<Slider>(layout, m_maxValue, m_curValue);
-
- result->bindToEo();
-
- return result;
- }
-
- Slider::Slider(IRefCountObj &rc,
- const LayoutSRef &layout,
- int maxValue,
- int curValue):
- ElmWidget(&rc, *layout, true),
- m_layout(layout.get()),
- m_circleLy(elm_layout_add(*m_layout)),
- m_circleSurf(eext_circle_surface_layout_add(m_circleLy)),
- m_slider(eext_circle_object_slider_add(*m_layout, m_circleSurf))
- {
- prepare(maxValue, curValue);
- }
-
- Slider::~Slider()
- {
- }
-
- void Slider::prepare(int maxValue, int curValue)
- {
- m_layout->setIsOwner(false);
-
- m_slider.setAlign(EVAS_HINT_FILL, EVAS_HINT_FILL);
- m_slider.setWeight(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
- m_layout->setContent(m_circleLy, impl::PART_SWL_SLIDER);
- show(m_circleLy);
- show(m_slider);
- show(*m_layout);
-
- setMaxValue(maxValue);
- setValue(curValue);
-
- // Screen Reader
- elm_atspi_accessible_role_set(m_slider,
- ELM_ATSPI_ROLE_REDUNDANT_OBJECT);
- elm_atspi_accessible_role_set(m_circleLy,
- ELM_ATSPI_ROLE_REDUNDANT_OBJECT);
- elm_atspi_accessible_role_set(*m_layout,
- ELM_ATSPI_ROLE_REDUNDANT_OBJECT);
- }
-
- void Slider::setValue(int value)
- {
- eext_circle_object_value_set(m_slider, static_cast<double>(value));
- }
-
- void Slider::setMaxValue(int maxValue)
- {
- eext_circle_object_value_min_max_set(m_slider, 0, maxValue);
- }
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "view/VolumeControl.h"
-
-#include "common.h"
-#include "resources.h"
-
-namespace callui { namespace { namespace impl {
-
- using namespace ucl;
-
- constexpr LayoutTheme LAYOUT_VOLUME
- {"layout", "callui", "volume_control"};
-
- constexpr ElmStyle STYLE_BTN_MINUS {"callui/minus"};
- constexpr ElmStyle STYLE_BTN_PLUS {"callui/plus"};
-
- constexpr EdjePart PART_SWL_MINUS {"swl.minus"};
- constexpr EdjePart PART_SWL_PLUS {"swl.plus"};
-
- constexpr EdjePart PART_TXT_INFO {"txt.info"};
- constexpr EdjePart PART_TXT_VALUE {"txt.value"};
- constexpr EdjePart PART_TXT_VALUE_AO {"ao_txt.value"};
-
-}}}
-
-namespace callui {
-
- using namespace ucl;
-
- VolumeControl::Builder::Builder():
- m_maxValue(0),
- m_curValue(0)
- {
- }
-
- VolumeControl::Builder &VolumeControl::Builder::setInfoText(const TString &info)
- {
- m_info = info;
- return *this;
- }
-
- VolumeControl::Builder &VolumeControl::Builder::setMaxValue(int maxValue)
- {
- m_maxValue = maxValue;
- return *this;
- }
-
- VolumeControl::Builder &VolumeControl::Builder::setValue(int curValue)
- {
- m_curValue = curValue;
- return *this;
- }
-
- VolumeControl::Builder &VolumeControl::Builder::setEventHandler(
- const VolumeControlEventHandler &handler)
- {
- m_handler = handler;
- return *this;
- }
-
- VolumeControlSRef VolumeControl::Builder::build(ElmWidget &parent) const
- {
- auto layout = Layout::Builder().
- setTheme(impl::LAYOUT_VOLUME).
- setIsOwner(true).
- build(parent);
- if (!layout) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "Layout::build() failed!");
- }
-
- auto result = makeShared<VolumeControl>(layout,
- m_info,
- m_maxValue,
- m_curValue,
- m_handler);
-
- result->bindToEo();
-
- return result;
- }
-
- VolumeControl::VolumeControl(IRefCountObj &rc,
- const LayoutSRef &layout,
- const TString &info,
- int maxValue,
- int curValue,
- const VolumeControlEventHandler &handler):
- Slider(rc, layout, maxValue, curValue),
- m_decreaseBtn(elm_button_add(*m_layout)),
- m_increaseBtn(elm_button_add(*m_layout)),
- m_handler(handler)
- {
- prepare(info, curValue);
- }
-
- VolumeControl::~VolumeControl()
- {
- }
-
- void VolumeControl::prepare(const TString &info, int curValue)
- {
- m_layout->addEventHandler(WidgetEvent::SHOW, WEAK_DELEGATE(
- VolumeControl::onWidgetShowCb, asWeak(*this)));
- m_layout->addEventHandler(WidgetEvent::HIDE, WEAK_DELEGATE(
- VolumeControl::onWidgetHideCb, asWeak(*this)));
-
- m_decreaseBtn.setStyle(impl::STYLE_BTN_MINUS);
- m_decreaseBtn.addEventHandler(BTN_CLICKED, WEAK_DELEGATE(
- VolumeControl::onDecreaseBtnClickedCb, asWeak(*this)));
- m_layout->setContent(m_decreaseBtn, impl::PART_SWL_MINUS);
- show(m_decreaseBtn);
-
- m_increaseBtn.setStyle(impl::STYLE_BTN_PLUS);
- m_increaseBtn.addEventHandler(BTN_CLICKED, WEAK_DELEGATE(
- VolumeControl::onIncreaseBtnClickedCb, asWeak(*this)));
- m_layout->setContent(m_increaseBtn, impl::PART_SWL_PLUS);
- show(m_increaseBtn);
-
- setInfoText(info);
- setValue(curValue);
-
- registerAccessObjectInformation();
- }
-
- void VolumeControl::onWidgetShowCb(Widget &widget, void *eventInfo)
- {
- if (m_valueTxtAo)
- show(*m_valueTxtAo);
- }
-
- void VolumeControl::onWidgetHideCb(Widget &widget, void *eventInfo)
- {
- if (m_valueTxtAo)
- hide(*m_valueTxtAo);
- }
-
- void VolumeControl::setInfoText(const TString &info)
- {
- m_layout->setText(info.translate(), impl::PART_TXT_INFO);
- }
-
- void VolumeControl::setValue(int value)
- {
- eext_circle_object_value_set(m_slider, static_cast<double>(value));
- m_layout->setText(std::to_string(value), impl::PART_TXT_VALUE);
- }
-
- void VolumeControl::setIncreaseBtnEnable(bool isEnable)
- {
- isEnable ? enable(m_increaseBtn) : disable(m_increaseBtn);
- }
-
- void VolumeControl::setDecreaseBtnEnable(bool isEnable)
- {
- isEnable ? enable(m_decreaseBtn) : disable(m_decreaseBtn);
- }
-
- void VolumeControl::setEventHandler(
- const VolumeControlEventHandler &handler)
- {
- m_handler = handler;
- }
-
- void VolumeControl::onDecreaseBtnClickedCb(Widget &widget, void *eventInfo)
- {
- if (m_handler) {
- m_handler(VolumeControlEvent::DECREASE);
- }
- }
-
- void VolumeControl::onIncreaseBtnClickedCb(Widget &widget, void *eventInfo)
- {
- if (m_handler) {
- m_handler(VolumeControlEvent::INCREASE);
- }
- }
-
- // Screen Reader
- ElmWidget *VolumeControl::getDecreaseBtn()
- {
- return &m_decreaseBtn;
- }
-
- ElmWidget *VolumeControl::getIncreaseBtn()
- {
- return &m_increaseBtn;
- }
-
- ElmWidget *VolumeControl::getValueTxtAo()
- {
- return m_valueTxtAo.get();
- }
-
- void VolumeControl::registerAccessObjectInformation()
- {
- elm_atspi_accessible_translation_domain_set(m_slider, PACKAGE);
- elm_atspi_accessible_reading_info_type_set(m_slider,
- ELM_ACCESSIBLE_READING_INFO_TYPE_NAME
- | ELM_ACCESSIBLE_READING_INFO_TYPE_DESCRIPTION);
- elm_atspi_accessible_name_set(m_slider, AO_STR_VOLUME);
- elm_atspi_accessible_description_set(m_slider,
- AO_STR_ROTATE_BEZEL_TO_ADJUST);
-
- elm_atspi_accessible_translation_domain_set(m_decreaseBtn, PACKAGE);
- elm_atspi_accessible_name_set(m_decreaseBtn,
- AO_STR_DECREASE_VOLUME);
-
- elm_atspi_accessible_translation_domain_set(m_increaseBtn, PACKAGE);
- elm_atspi_accessible_name_set(m_increaseBtn,
- AO_STR_INCREASE_VOLUME);
-
- m_valueTxtAo = utils::createAccessObjectFromLyPart(
- *m_layout,
- *m_layout,
- impl::PART_TXT_VALUE_AO);
- if (!m_valueTxtAo) {
- ELOG("createAccessObjectFromLyPart() failed");
- } else {
- elm_atspi_accessible_translation_domain_set(*m_valueTxtAo,
- PACKAGE);
- elm_atspi_accessible_reading_info_type_set(*m_valueTxtAo,
- ELM_ACCESSIBLE_READING_INFO_TYPE_NAME);
- elm_atspi_accessible_name_cb_set(*m_valueTxtAo,
- [](void *data, Evas_Object *obj) -> char *
- {
- auto self = static_cast<VolumeControl *>(data);
- if (!self) {
- return nullptr;
- }
- auto txt = self->m_layout->
- getText(impl::PART_TXT_VALUE).getCStr();
- return (txt) ? strdup(txt) : nullptr;
- },
- this);
- }
-
- elm_atspi_accessible_role_set(*m_layout, ELM_ATSPI_ROLE_TEXT);
- }
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __CALLUI_VIEW_COMMON_H__
-#define __CALLUI_VIEW_COMMON_H__
-
-#include "ucl/gui/stdTheme.h"
-#include "ucl/gui/helpers.h"
-
-#include "view/helpers.h"
-
-#include "../common.h"
-
-#define DEL_TRANSIT(ptr) \
- do { \
- if (ptr) { \
- elm_transit_del_cb_set(ptr, nullptr, nullptr); \
- elm_transit_del(ptr); \
- ptr = nullptr; \
- } \
- } while (0)
-
-namespace callui {
-
- constexpr ucl::SmartEvent BTN_CLICKED {"clicked"};
- constexpr ucl::SmartEvent ATSPI_HIGHLIGHTED {"atspi,highlighted"};
-}
-
-#endif // __CALLUI_VIEW_COMMON_H__
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 "view/helpers.h"
-
-#include "ucl/gui/Window.h"
-#include "ucl/gui/Naviframe.h"
-#include "ucl/gui/Layout.h"
-
-#include "common.h"
-
-namespace callui { namespace { namespace impl {
-
- using namespace ucl;
-
- constexpr EoDataKey CIRCLE_SURFACE {"callui,eext,circle,surface"};
-
- constexpr LayoutTheme LAYOUT_FAKE_ACCESS_OBJECT
- {"layout", "callui", "fake_access_object"};
-}}}
-
-namespace callui { namespace utils {
-
- using namespace ucl;
-
- Result createCircleSurface(Naviframe &navi)
- {
- const auto win = navi.getWindow();
- if (!win) {
- LOG_RETURN(RES_FAIL, "Failed to get Window from Naviframe!");
- }
-
- if (win->getData(impl::CIRCLE_SURFACE)) {
- LOG_RETURN(RES_ILLEGAL_STATE, "Circle Surface data already set!");
- }
-
- const auto sfc = eext_circle_surface_conformant_add(win->getConformant());
- if (!sfc) {
- LOG_RETURN(RES_FAIL,
- "eext_circle_surface_conformant_add() failed!");
- }
-
- win->setData(impl::CIRCLE_SURFACE, sfc);
-
- return RES_OK;
- }
-
- Eext_Circle_Surface *getCircleSurface(const ElmWidget &widget)
- {
- const auto win = widget.getWindow();
- if (!win) {
- LOG_RETURN_VALUE(RES_FAIL, nullptr,
- "Failed to get Window from widget!");
- }
-
- const auto sfc = static_cast<Eext_Circle_Surface *>(
- win->getData(impl::CIRCLE_SURFACE));
- if (!sfc) {
- LOG_RETURN_VALUE(RES_FAIL, nullptr,
- "Failed to get Eext_Circle_Surface from window!");
- }
-
- return sfc;
- }
-
- ElmWidgetSRef createFakeAccessObject(ElmWidget &parent)
- {
- const auto result = Layout::Builder().
- setTheme(impl::LAYOUT_FAKE_ACCESS_OBJECT).
- setIsOwner(true).
- setNeedBindToEo(true).
- build(parent);
- if (!result) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "Layout::build() failed!");
- }
-
- result->setGeometry(0, 0, 1, 1);
- show(*result);
-
- elm_atspi_accessible_reading_info_type_set(*result, 0);
-
- elm_atspi_accessible_gesture_cb_set(*result,
- [](void *, Elm_Atspi_Gesture_Info, Evas_Object *) -> Eina_Bool
- {
- return EINA_TRUE;
- },
- nullptr);
-
- return result;
- }
-
-
- Elm_Genlist_Item_Class createGenlistItemClass(const char *style,
- Elm_Gen_Item_Text_Get_Cb txtCb,
- Elm_Gen_Item_Content_Get_Cb contentCb,
- Elm_Gen_Item_State_Get_Cb stateCb,
- Elm_Gen_Item_Del_Cb delCb)
- {
- Elm_Genlist_Item_Class itc = { ELM_GEN_ITEM_CLASS_HEADER };
- itc.item_style = style;
- itc.func.text_get = txtCb;
- itc.func.content_get = contentCb;
- itc.func.state_get = stateCb;
- itc.func.del = delCb;
-
- return itc;
- }
-
- ElmWidgetSRef createAccessObject(ElmWidget &parent, Widget &ly)
- {
- auto ao = elm_access_object_register(ly, parent);
- if (!ao) {
- LOG_RETURN_VALUE(RES_FAIL, {},
- "elm_access_object_register() failed!");
- }
-
- return makeShared<ElmWidget>(ao, true);
- }
-
- ElmWidgetSRef createAccessObjectFromLyPart(ElmWidget &parent,
- Widget &ly,
- const EdjePart &lyPart)
- {
- auto po = const_cast<Evas_Object *>(
- edje_object_part_object_get(
- elm_layout_edje_get(ly), lyPart));
- if (!po) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "Part object is NULL");
- }
-
- auto ao = elm_access_object_register(po, parent);
- if (!ao) {
- LOG_RETURN_VALUE(RES_FAIL, {},
- "elm_access_object_register() failed!");
- }
-
- return makeShared<ElmWidget>(ao, true);
- }
-
- void destroyAccessObject(ElmWidget &ao)
- {
- elm_access_object_unregister(ao);
- }
-
-}}
-
-namespace callui {
-
- void addRotaryEventHandler(Eext_Rotary_Handler_Cb func, void *data)
- {
- eext_rotary_event_handler_add(func, data);
- }
-
- void delRotaryEventHandler(Eext_Rotary_Handler_Cb func, void *data)
- {
- std::vector<void *> backup;
- while (true) {
- void *const oldData = eext_rotary_event_handler_del(func);
- if (!oldData || (oldData == data)) {
- break;
- }
- backup.push_back(oldData);
- }
- for (auto i = backup.size(); i-- > 0; ) {
- eext_rotary_event_handler_add(func, backup[i]);
- }
- }
-
- LayoutTheme getImageTheme(const char *const fileName)
- {
- return {"layout", "callui_image", fileName};
- }
-
- Elm_Atspi_Relation_Type getFlowRelation(Elm_Atspi_Gesture_Info gestureInfo)
- {
- switch (gestureInfo.type) {
- case ELM_ATSPI_GESTURE_ONE_FINGER_FLICK_RIGHT:
- case ELM_ATSPI_GESTURE_ONE_FINGER_FLICK_DOWN:
- return ELM_ATSPI_RELATION_FLOWS_TO;
- case ELM_ATSPI_GESTURE_ONE_FINGER_FLICK_LEFT:
- case ELM_ATSPI_GESTURE_ONE_FINGER_FLICK_UP:
- return ELM_ATSPI_RELATION_FLOWS_FROM;
- default:
- break;
- }
- return ELM_ATSPI_RELATION_NULL;
- }
-
-}
-