From 902d6dc35fc076d951897bf76793f93ba378cd38 Mon Sep 17 00:00:00 2001 From: Igor Olshevskyi Date: Wed, 7 Jun 2017 08:58:40 +0300 Subject: [PATCH] TizenRefApp-8644 [Call UI] Implement headset connection check logic Change-Id: Ibfc6adfe53c70e2c43139c3a5b83d6e6effb9a61 --- inc/model/ISoundManager.h | 1 + inc/presenters/MoreOptionsPresenter.h | 29 ++- inc/types.h | 3 +- ...uetoothManager.cpp => BluetoothVolume.cpp} | 29 ++- .../{BluetoothManager.h => BluetoothVolume.h} | 14 +- src/model/Call.cpp | 8 +- src/model/Call.h | 1 - src/model/SoundManager.cpp | 104 ++++++++--- src/model/SoundManager.h | 9 +- src/model/implTypes.h | 2 +- src/presenters/MainPage.cpp | 4 +- src/presenters/MoreOptionsPresenter.cpp | 169 ++++++++++-------- src/presenters/RejectMsgPresenter.cpp | 2 +- 13 files changed, 233 insertions(+), 142 deletions(-) rename src/model/{BluetoothManager.cpp => BluetoothVolume.cpp} (81%) rename src/model/{BluetoothManager.h => BluetoothVolume.h} (80%) diff --git a/inc/model/ISoundManager.h b/inc/model/ISoundManager.h index 8114ae2..a95b18f 100644 --- a/inc/model/ISoundManager.h +++ b/inc/model/ISoundManager.h @@ -39,6 +39,7 @@ namespace callui { virtual int getMaxVolume() const = 0; virtual int getVolume() const = 0; virtual ucl::Result setVolume(int value) = 0; + virtual bool isBluetoothSupported() const = 0; }; } diff --git a/inc/presenters/MoreOptionsPresenter.h b/inc/presenters/MoreOptionsPresenter.h index c3b748f..2955e52 100644 --- a/inc/presenters/MoreOptionsPresenter.h +++ b/inc/presenters/MoreOptionsPresenter.h @@ -31,20 +31,23 @@ namespace callui { class Builder { public: Builder(); - ~Builder(); Builder &setCallManager(const ICallManagerSRef &cm); + Builder &setSoundManager(const ISoundManagerSRef &sm); MoreOptionsPresenterSRef build(ucl::ElmWidget &parent) const; private: ICallManagerSRef m_cm; + ISoundManagerSRef m_sm; }; public: ucl::Widget &getWidget(); - ucl::Result update(); + void update(); private: friend class ucl::RefCountObj; - MoreOptionsPresenter(ucl::RefCountObjBase &rc, const ICallManagerSRef &cm); + MoreOptionsPresenter(ucl::RefCountObjBase &rc, + const ICallManagerSRef &cm, + const ISoundManagerSRef &sm); virtual ~MoreOptionsPresenter(); ucl::Result prepare(ucl::ElmWidget &parent); @@ -57,13 +60,13 @@ namespace callui { const ucl::TString &txt, const ucl::WidgetEventHandler &handler); - ucl::Result updateSlots(); - ucl::Result updateTopSlot(); - ucl::Result updateLeftSlot(); - ucl::Result updateRightSlot(); - ucl::Result updateBottomSlot(); + void updateSlots(); + void updateTopSlot(); + void updateLeftSlot(); + void updateRightSlot(); + void updateBottomSlot(); - ucl::Result updateStatusText(); + void updateStatusText(); void updateStatusFontSize(); void onSwapBtnClick(ucl::Widget &sender, void *eventInfo); @@ -82,6 +85,13 @@ namespace callui { void stopCallDurationTimer(); Eina_Bool onCallDurationTimerCb(); + ucl::Result launchBluetoothSettings(); + + void onAudioStateChanged(AudioStateType state); + + void unsetPanelContent(const ucl::EdjePart &part); + void setPanelContent(ucl::StyledWidgetSRef &widget, const ucl::EdjePart &part); + private: ucl::LayoutSRef m_widget; ucl::StyledWidgetSRef m_panel; @@ -94,6 +104,7 @@ namespace callui { ucl::StyledWidgetSRef m_btnGear; ICallManagerSRef m_cm; + ISoundManagerSRef m_sm; ICallInfoWCRef m_info; Ecore_Timer *m_timer; diff --git a/inc/types.h b/inc/types.h index fcccaaa..890fc08 100644 --- a/inc/types.h +++ b/inc/types.h @@ -31,7 +31,8 @@ namespace callui { 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_OPERATION_FAILED = ucl::_RES_BEGIN - 4, + RES_NOT_CONNECTED = ucl::_RES_BEGIN - 5 }; } diff --git a/src/model/BluetoothManager.cpp b/src/model/BluetoothVolume.cpp similarity index 81% rename from src/model/BluetoothManager.cpp rename to src/model/BluetoothVolume.cpp index 7ef9959..633a849 100644 --- a/src/model/BluetoothManager.cpp +++ b/src/model/BluetoothVolume.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "BluetoothManager.h" +#include "BluetoothVolume.h" #include #include @@ -35,27 +35,27 @@ namespace callui { using namespace ucl; - BluetoothManagerSRef BluetoothManager::newInstance() + BluetoothVolumeSRef BluetoothVolume::newInstance() { - auto result = makeShared(); + auto result = makeShared(); FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!"); return result; } - BluetoothManager::BluetoothManager(): + BluetoothVolume::BluetoothVolume(): m_btInitialized(false), m_btAudioInitialized(false) { } - BluetoothManager::~BluetoothManager() + BluetoothVolume::~BluetoothVolume() { unregisterAudioHandling(); bt_deinitialize(); } - Result BluetoothManager::prepare() + Result BluetoothVolume::prepare() { if (BT_ERROR_NONE != bt_initialize()) { LOG_RETURN(RES_FAIL, "BT initialize failed"); @@ -68,7 +68,7 @@ namespace callui { return RES_OK; } - int BluetoothManager::getVolume() const + int BluetoothVolume::getVolume() const { auto vol = 0; auto ret = bt_ag_get_speaker_gain(&vol); @@ -79,12 +79,12 @@ namespace callui { return vol; } - int BluetoothManager::getMaxVolume() const + int BluetoothVolume::getMaxVolume() const { return impl::BT_VOLUME_MAX; } - Result BluetoothManager::setVolume(int volume) + Result BluetoothVolume::setVolume(int volume) { auto ret = bt_ag_notify_speaker_gain(volume); if (ret != BT_ERROR_NONE) { @@ -93,13 +93,13 @@ namespace callui { return RES_OK; } - void BluetoothManager::setVolumeStateHandler( + void BluetoothVolume::setVolumeStateHandler( const BluetoothVolumeHandler &handler) { m_handler = handler; } - Result BluetoothManager::registerAudioHandling() + Result BluetoothVolume::registerAudioHandling() { auto ret = bt_audio_initialize(); if (ret != BT_ERROR_NONE) { @@ -108,7 +108,7 @@ namespace callui { m_btAudioInitialized = true; ret = bt_ag_set_speaker_gain_changed_cb( - CALLBACK_B(BluetoothManager::onVolumeChanged), this); + CALLBACK_B(BluetoothVolume::onVolumeChanged), this); if (ret != BT_ERROR_NONE) { LOG_RETURN(RES_FAIL, "bt_ag_set_speaker_gain_changed_cb() failed"); } @@ -116,7 +116,7 @@ namespace callui { return RES_OK; } - void BluetoothManager::unregisterAudioHandling() + void BluetoothVolume::unregisterAudioHandling() { bt_ag_unset_speaker_gain_changed_cb(); @@ -126,7 +126,7 @@ namespace callui { } } - void BluetoothManager::onVolumeChanged(int volume) + void BluetoothVolume::onVolumeChanged(int volume) { sound_type_e soundType = SOUND_TYPE_SYSTEM; auto ret = sound_manager_get_current_sound_type(&soundType); @@ -146,5 +146,4 @@ namespace callui { } } } - } diff --git a/src/model/BluetoothManager.h b/src/model/BluetoothVolume.h similarity index 80% rename from src/model/BluetoothManager.h rename to src/model/BluetoothVolume.h index 06478b0..95e6d7a 100644 --- a/src/model/BluetoothManager.h +++ b/src/model/BluetoothVolume.h @@ -14,17 +14,16 @@ * limitations under the License. */ -#ifndef __CALLUI_MODEL_BLUETOOTH_MANAGER_H__ -#define __CALLUI_MODEL_BLUETOOTH_MANAGER_H__ +#ifndef __CALLUI_MODEL_BLUETOOTH_VOLUME_H__ +#define __CALLUI_MODEL_BLUETOOTH_VOLUME_H__ #include "implTypes.h" namespace callui { - class BluetoothManager final { + class BluetoothVolume final { public: - static BluetoothManagerSRef newInstance(); - virtual ~BluetoothManager(); + static BluetoothVolumeSRef newInstance(); int getVolume() const; int getMaxVolume() const; @@ -33,8 +32,9 @@ namespace callui { void setVolumeStateHandler(const BluetoothVolumeHandler &handler); private: - friend class ucl::RefCountObj; - BluetoothManager(); + friend class ucl::RefCountObj; + BluetoothVolume(); + ~BluetoothVolume(); ucl::Result prepare(); diff --git a/src/model/Call.cpp b/src/model/Call.cpp index 7d54f7b..a54f03a 100644 --- a/src/model/Call.cpp +++ b/src/model/Call.cpp @@ -34,7 +34,6 @@ #include "BatteryStateSource.h" #include "SimSlotStateSource.h" #include "HdVoiceStateSource.h" -#include "BluetoothManager.h" #include "common.h" @@ -128,11 +127,6 @@ namespace callui { Result Call::prepare() { - m_btManager = BluetoothManager::newInstance(); - if (!m_btManager) { - ELOG("BluetoothManager::newInstance() failed!"); - } - auto callClient = CallClient::newInstance(); if (!callClient) { LOG_RETURN(RES_FAIL, "Client::newInstance() failed!"); @@ -143,7 +137,7 @@ namespace callui { LOG_RETURN(RES_FAIL, "CallManager::newInstance() failed!"); } - m_soundManager = SoundManager::newInstance(callClient, m_btManager); + m_soundManager = SoundManager::newInstance(callClient); if (!m_soundManager) { LOG_RETURN(RES_FAIL, "SoundManage::newInstance() failed!"); } diff --git a/src/model/Call.h b/src/model/Call.h index 08429c0..ff5a406 100644 --- a/src/model/Call.h +++ b/src/model/Call.h @@ -67,7 +67,6 @@ namespace callui { private: CallManagerSRef m_callManager; SoundManagerSRef m_soundManager; - BluetoothManagerSRef m_btManager; ICallListenerWRef m_listener; SimSlotStateSourceSRef m_simSlotStSrc; HdVoiceStateSourceSRef m_hdCallStSrc; diff --git a/src/model/SoundManager.cpp b/src/model/SoundManager.cpp index b7bc96f..491ea9a 100644 --- a/src/model/SoundManager.cpp +++ b/src/model/SoundManager.cpp @@ -16,21 +16,64 @@ #include "SoundManager.h" +#include "BluetoothVolume.h" #include "CallClient.h" -#include "BluetoothManager.h" - #include "common.h" +namespace callui { namespace { namespace impl { + + using namespace ucl; + + Result getBTVolumeDeviceCount(int &deviceCount) + { + Result res = RES_FAIL; + int count = 0; + + 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; + LOG_BREAK(res, "No more device to check"); + } else if (ret != SOUND_MANAGER_ERROR_NONE) { + LOG_BREAK(res, "sound_manager_get_next_device() failed. [%d][%s]", + ret, get_error_message(ret)); + } + if (!device) { + LOG_BREAK(res, "device is NULL"); + } + sound_manager_get_device_type(device, &type); + if (searchType == type) { + DLOG("Bluetooth voice device found"); + count++; + } + } + sound_manager_free_device_list(deviceList); + deviceCount = count; + + return res; + } +}}} + namespace callui { using namespace ucl; SoundManager::SoundManager(RefCountObjBase &rc, - const CallClientSRef &client, - const BluetoothManagerSRef &btManager): + const CallClientSRef &client): RefCountAware(&rc), m_client(client), - m_btManager(btManager), m_deviceVolumeCbID(-1) { } @@ -44,10 +87,9 @@ namespace callui { cm_unset_mute_status_cb(*m_client); } - SoundManagerSRef SoundManager::newInstance(const CallClientSRef &client, - const BluetoothManagerSRef &btManager) + SoundManagerSRef SoundManager::newInstance(const CallClientSRef &client) { - auto result = makeShared(client, btManager); + auto result = makeShared(client); FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!"); return result; } @@ -68,6 +110,11 @@ namespace callui { Result SoundManager::prepare() { + m_btVolume = BluetoothVolume::newInstance(); + if (!m_btVolume) { + ELOG("BluetoothVolume::newInstance() failed!"); + } + Result res = convertCMResult(cm_set_audio_state_changed_cb(*m_client, CALLBACK_B(SoundManager::audioStateChangedCb), this)); FAIL_RETURN(res, "cm_set_audio_state_changed_cb() failed!"); @@ -76,8 +123,8 @@ namespace callui { CALLBACK_B(SoundManager::muteStateChangedCb), this)); FAIL_RETURN(res, "cm_set_mute_status_cb() failed!"); - FAIL_RETURN(registerVolumeCallbacks(), - "registerVolumeCallbacks() failed!"); + res = registerVolumeCallbacks(); + FAIL_RETURN(res, "registerVolumeCallbacks() failed!"); return res; } @@ -93,8 +140,8 @@ namespace callui { "sound_manager_add_volume_changed_cb() failed"); } - if (m_btManager) { - m_btManager->setVolumeStateHandler( + if (isBluetoothSupported()) { + m_btVolume->setVolumeStateHandler( WEAK_DELEGATE(SoundManager::onBluetoothVolumeChanged, asWeak(*this))); } @@ -113,6 +160,17 @@ namespace callui { Result SoundManager::setBluetoothState(bool isEnable) { + if (!isBluetoothSupported()) { + LOG_RETURN(RES_NOT_SUPPORTED, "Bluetooth not supported"); + } + + int count = 0; + FAIL_RETURN(impl::getBTVolumeDeviceCount(count), "getBTVolumeDeviceCount() failed"); + + if (count == 0) { + LOG_RETURN(RES_NOT_CONNECTED, "Bluetooth headset device not connected"); + } + if (isEnable) { return convertCMResult(cm_bluetooth_on(*m_client)); } else { @@ -190,10 +248,10 @@ namespace callui { { int maxVol = 0; if (getAudioState() == AudioStateType::BT) { - if (m_btManager) { - maxVol = m_btManager->getMaxVolume(); + if (isBluetoothSupported()) { + maxVol = m_btVolume->getMaxVolume(); } else { - ELOG("BT is not set"); + ELOG("BT is not supported"); } } else { auto ret = sound_manager_get_max_volume(SOUND_TYPE_CALL, &maxVol); @@ -210,10 +268,10 @@ namespace callui { { int vol = 0; if (getAudioState() == AudioStateType::BT) { - if (m_btManager) { - vol = m_btManager->getVolume(); + if (isBluetoothSupported()) { + vol = m_btVolume->getVolume(); } else { - ELOG("BT is not set"); + ELOG("BT is not supported"); } } else { auto ret = sound_manager_get_volume(SOUND_TYPE_CALL, &vol); @@ -229,10 +287,10 @@ namespace callui { Result SoundManager::setVolume(int value) { if (getAudioState() == AudioStateType::BT) { - if (m_btManager) { - return m_btManager->setVolume(value); + if (isBluetoothSupported()) { + return m_btVolume->setVolume(value); } else { - LOG_RETURN(RES_FAIL, "BT is not set"); + LOG_RETURN(RES_FAIL, "BT is not supported"); } } else { auto ret = sound_manager_set_volume(SOUND_TYPE_CALL, value); @@ -244,6 +302,10 @@ namespace callui { return RES_OK; } + bool SoundManager::isBluetoothSupported() const + { + return (m_btVolume != nullptr); + } void SoundManager::onDeviceVolumeChanged(sound_type_e type, unsigned int volume) { diff --git a/src/model/SoundManager.h b/src/model/SoundManager.h index 2e1766a..c8f6901 100644 --- a/src/model/SoundManager.h +++ b/src/model/SoundManager.h @@ -30,8 +30,7 @@ namespace callui { public ucl::RefCountAware, public ISoundManager { public: - static SoundManagerSRef newInstance(const CallClientSRef &client, - const BluetoothManagerSRef &btManager); + static SoundManagerSRef newInstance(const CallClientSRef &client); virtual ~SoundManager(); // ISoundManager @@ -52,12 +51,12 @@ namespace callui { virtual int getMaxVolume() const override final; virtual int getVolume() const override final; virtual ucl::Result setVolume(int value) override final; + virtual bool isBluetoothSupported() const override final; private: friend class ucl::RefCountObj; SoundManager(ucl::RefCountObjBase &rc, - const CallClientSRef &client, - const BluetoothManagerSRef &btManager); + const CallClientSRef &client); ucl::Result prepare(); ucl::Result registerVolumeCallbacks(); @@ -70,7 +69,7 @@ namespace callui { private: CallClientSRef m_client; - BluetoothManagerSRef m_btManager; + BluetoothVolumeSRef m_btVolume; AudioStateEvent m_audioStateEvent; MuteStateEvent m_muteStateEvent; VolumeLevelEvent m_volumeLevelEvent; diff --git a/src/model/implTypes.h b/src/model/implTypes.h index ad3e1ef..a26c7a8 100644 --- a/src/model/implTypes.h +++ b/src/model/implTypes.h @@ -67,7 +67,7 @@ namespace callui { UCL_DECLARE_REF_ALIASES(SimSlotStateSource); UCL_DECLARE_REF_ALIASES(HdVoiceStateSource); - UCL_DECLARE_REF_ALIASES(BluetoothManager); + UCL_DECLARE_REF_ALIASES(BluetoothVolume); using AudioStateEvent = ucl::Event; using MuteStateEvent = ucl::Event; diff --git a/src/presenters/MainPage.cpp b/src/presenters/MainPage.cpp index 85262b5..ef15cb9 100644 --- a/src/presenters/MainPage.cpp +++ b/src/presenters/MainPage.cpp @@ -494,11 +494,13 @@ namespace callui { { if (m_moreOptions) { ILOG("Already exists. No need to create new one. Just update."); - return m_moreOptions->update(); + m_moreOptions->update(); + return RES_OK; } m_moreOptions = MoreOptionsPresenter::Builder(). setCallManager(m_cm). + setSoundManager(m_call->getSoundManager()). build(*m_widget); if (!m_moreOptions) { diff --git a/src/presenters/MoreOptionsPresenter.cpp b/src/presenters/MoreOptionsPresenter.cpp index 556433b..a0b236e 100644 --- a/src/presenters/MoreOptionsPresenter.cpp +++ b/src/presenters/MoreOptionsPresenter.cpp @@ -16,12 +16,15 @@ #include "presenters/MoreOptionsPresenter.h" +#include + #include "ucl/gui/Layout.h" #include "model/ICallManager.h" #include "model/IHeldCall.h" #include "model/IActiveCall.h" #include "model/ICallInfo.h" +#include "model/ISoundManager.h" #include "resources.h" #include "common.h" @@ -69,23 +72,28 @@ namespace callui { { } - MoreOptionsPresenter::Builder::~Builder() + MoreOptionsPresenter::Builder & + MoreOptionsPresenter::Builder::setCallManager(const ICallManagerSRef &cm) { + m_cm = cm; + return *this; } - MoreOptionsPresenter::Builder &MoreOptionsPresenter::Builder::setCallManager(const ICallManagerSRef &cm) + MoreOptionsPresenter::Builder & + MoreOptionsPresenter::Builder::setSoundManager(const ISoundManagerSRef &sm) { - m_cm = cm; + m_sm = sm; return *this; } - MoreOptionsPresenterSRef MoreOptionsPresenter::Builder::build(ElmWidget &parent) const + MoreOptionsPresenterSRef + MoreOptionsPresenter::Builder::build(ElmWidget &parent) const { - if (!m_cm) { - LOG_RETURN_VALUE(RES_FAIL, {}, "Call Manager is not set"); + if (!m_cm || !m_sm) { + LOG_RETURN_VALUE(RES_FAIL, {}, "Main params are not set"); } - auto result = makeShared(m_cm); + auto result = makeShared(m_cm, m_sm); FAIL_RETURN_VALUE(result->prepare(parent), {}, "result->prepare() failed!"); @@ -94,9 +102,12 @@ namespace callui { // MoreOptionsPresenter - MoreOptionsPresenter::MoreOptionsPresenter(RefCountObjBase &rc, const ICallManagerSRef &cm): + MoreOptionsPresenter::MoreOptionsPresenter(RefCountObjBase &rc, + const ICallManagerSRef &cm, + const ISoundManagerSRef &sm): Presenter(rc), m_cm(cm), + m_sm(sm), m_timer(nullptr) { } @@ -111,6 +122,9 @@ namespace callui { sendActivateBy(*m_widget, this); } + + m_sm->removeAudioStateHandler(DELEGATE( + MoreOptionsPresenter::onAudioStateChanged, this)); } Result MoreOptionsPresenter::prepare(ElmWidget &parent) @@ -125,13 +139,21 @@ namespace callui { FAIL_RETURN(createButtons(), "createButtons() failed!"); - FAIL_RETURN(update(), "update() failed!"); + m_sm->addAudioStateHandler(DELEGATE( + MoreOptionsPresenter::onAudioStateChanged, this)); + + update(); addDeactivatorException(this); return RES_OK; } + void MoreOptionsPresenter::onAudioStateChanged(AudioStateType state) + { + updateLeftSlot(); + } + Result MoreOptionsPresenter::createWidget(ElmWidget &parent) { m_widget = Layout::Builder(). @@ -183,81 +205,60 @@ namespace callui { return RES_OK; } - Result MoreOptionsPresenter::updateSlots() + void MoreOptionsPresenter::updateSlots() { - FAIL_RETURN(updateTopSlot(), "updateTopSlot() failed"); - FAIL_RETURN(updateLeftSlot(), "updateLeftSlot() failed"); - FAIL_RETURN(updateRightSlot(), "updateRightSlot() failed"); - FAIL_RETURN(updateBottomSlot(), "updateBottomSlot() failed"); - - return RES_OK; + updateTopSlot(); + updateLeftSlot(); + updateRightSlot(); + updateBottomSlot(); } - Result MoreOptionsPresenter::updateTopSlot() + void MoreOptionsPresenter::updateTopSlot() { auto active = m_cm->getActiveCall(); auto held = m_cm->getHeldCall(); - auto *eo = m_panelLy->unsetContent(impl::PART_SWL_PANEL_LY_TOP); - if (eo) { - hide(*asWidget(eo)); - } + unsetPanelContent(impl::PART_SWL_PANEL_LY_TOP); if (active) { if (held) { - m_panelLy->setContent(*m_btnSwap, impl::PART_SWL_PANEL_LY_TOP); - show(*m_btnSwap); + setPanelContent(m_btnSwap, impl::PART_SWL_PANEL_LY_TOP); } } else if (held) { - m_panelLy->setContent(*m_btnUnhold, impl::PART_SWL_PANEL_LY_TOP); - show(*m_btnUnhold); + setPanelContent(m_btnUnhold, impl::PART_SWL_PANEL_LY_TOP); } else { - LOG_RETURN(RES_FAIL, "Undefined state"); + LOG_RETURN_VOID(RES_FAIL, "Undefined state"); } - - return RES_OK; } - Result MoreOptionsPresenter::updateLeftSlot() + void MoreOptionsPresenter::updateLeftSlot() { - auto *eo = m_panelLy->unsetContent(impl::PART_SWL_PANEL_LY_LEFT); - if (eo) { - hide(*asWidget(eo)); - } - - m_panelLy->setContent(*m_btnHeadset, impl::PART_SWL_PANEL_LY_LEFT); - show(*m_btnHeadset); - disable(*m_btnHeadset); + unsetPanelContent(impl::PART_SWL_PANEL_LY_LEFT); - return RES_OK; + if (m_sm->getAudioState() != AudioStateType::BT) { + setPanelContent(m_btnHeadset, impl::PART_SWL_PANEL_LY_LEFT); + if (!m_sm->isBluetoothSupported()) { + disable(*m_btnHeadset); + } + } else { + setPanelContent(m_btnGear, impl::PART_SWL_PANEL_LY_LEFT); + } } - Result MoreOptionsPresenter::updateRightSlot() + void MoreOptionsPresenter::updateRightSlot() { - auto *eo = m_panelLy->unsetContent(impl::PART_SWL_PANEL_LY_RIGHT); - if (eo) { - hide(*asWidget(eo)); + if (!m_panelLy->getContent(impl::PART_SWL_PANEL_LY_RIGHT)) { + setPanelContent(m_btnPhone, impl::PART_SWL_PANEL_LY_RIGHT); + disable(*m_btnPhone); } - - m_panelLy->setContent(*m_btnPhone, impl::PART_SWL_PANEL_LY_RIGHT); - show(*m_btnPhone); - disable(*m_btnPhone); - - return RES_OK; } - Result MoreOptionsPresenter::updateBottomSlot() + void MoreOptionsPresenter::updateBottomSlot() { - auto *eo = m_panelLy->unsetContent(impl::PART_SWL_PANEL_LY_BOTTOM); - if (eo) { - hide(*asWidget(eo)); + if (!m_panelLy->getContent(impl::PART_SWL_PANEL_LY_BOTTOM)) { + setPanelContent(m_btnKeypad, impl::PART_SWL_PANEL_LY_BOTTOM); + disable(*m_btnKeypad); } - - m_panelLy->setContent(*m_btnKeypad, impl::PART_SWL_PANEL_LY_BOTTOM); - show(*m_btnKeypad); - disable(*m_btnKeypad); - - return RES_OK; } Result MoreOptionsPresenter::createButtons() @@ -333,7 +334,15 @@ namespace callui { void MoreOptionsPresenter::onHeadsetBtnClick(Widget &sender, void *eventInfo) { - ELOG("Not implemented"); + auto res = m_sm->setBluetoothState(true); + + if (res == RES_NOT_CONNECTED) { + FAIL_RETURN_VOID(launchBluetoothSettings(), + "launchBluetoothSettings() failed"); + } else { + FAIL_RETURN_VOID(res, + "setBluetoothState() failed"); + } } void MoreOptionsPresenter::onPhoneBtnClick(Widget &sender, void *eventInfo) @@ -348,7 +357,7 @@ namespace callui { void MoreOptionsPresenter::onGearBtnClick(Widget &sender, void *eventInfo) { - ELOG("Not implemented"); + FAIL_RETURN_VOID(m_sm->setBluetoothState(false),"setBluetoothState() failed"); } StyledWidgetSRef MoreOptionsPresenter::createButton( @@ -376,13 +385,10 @@ namespace callui { return *m_widget; } - Result MoreOptionsPresenter::update() + void MoreOptionsPresenter::update() { - FAIL_RETURN(updateSlots(), "updateSlots() failed!"); - - FAIL_RETURN(updateStatusText(), "updateStatusText() failed!"); - - return RES_OK; + updateSlots(); + updateStatusText(); } void MoreOptionsPresenter::onActivate(Evas_Object *obj, const char *emission, const char *source) @@ -412,7 +418,7 @@ namespace callui { } } - Result MoreOptionsPresenter::updateStatusText() + void MoreOptionsPresenter::updateStatusText() { m_panelLy->setText("", impl::PART_TXT_STATUS); @@ -426,23 +432,21 @@ namespace callui { if (active->isDialingMode()) { m_panelLy->setText(STR_DIALING_CALL, impl::PART_TXT_STATUS); m_panelLy->emit(impl::SIGNAL_STATUS_TXT_BIG); - return RES_OK; + return; } m_info = active->getInfo(); if (!m_info) { - LOG_RETURN(RES_FAIL, "Call Info is NULL"); + LOG_RETURN_VOID(RES_FAIL, "Call Info is NULL"); } m_duration = m_info->getDuration(); setCallDuration(m_duration, *m_panelLy, impl::PART_TXT_STATUS); updateStatusFontSize(); - FAIL_RETURN(startCallDurationTimer(), "startTimer() failed!"); + FAIL_RETURN_VOID(startCallDurationTimer(), "startTimer() failed!"); } else { - LOG_RETURN(RES_FAIL, "Undefined state"); + LOG_RETURN_VOID(RES_FAIL, "Undefined state"); } - - return RES_OK; } void MoreOptionsPresenter::updateStatusFontSize() @@ -494,4 +498,23 @@ namespace callui { m_timer = nullptr; } } + + Result MoreOptionsPresenter::launchBluetoothSettings() + { + LOG_RETURN(RES_FAIL, "Not implemented"); + } + + void MoreOptionsPresenter::unsetPanelContent(const EdjePart &part) + { + auto *eo = m_panelLy->unsetContent(part); + if (eo) { + hide(*asWidget(eo)); + } + } + + void MoreOptionsPresenter::setPanelContent(StyledWidgetSRef &widget, const EdjePart &part) + { + m_panelLy->setContent(*widget, part); + show(*widget); + } } diff --git a/src/presenters/RejectMsgPresenter.cpp b/src/presenters/RejectMsgPresenter.cpp index 1395274..637b4ee 100644 --- a/src/presenters/RejectMsgPresenter.cpp +++ b/src/presenters/RejectMsgPresenter.cpp @@ -169,7 +169,6 @@ namespace callui { "createGenlist() failed!"); addDeactivatorException(this); - deactivateBy(m_widget.get()); return RES_OK; @@ -308,6 +307,7 @@ namespace callui { 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!"); -- 2.34.1