virtual int getMaxVolume() const = 0;
virtual int getVolume() const = 0;
virtual ucl::Result setVolume(int value) = 0;
+ virtual bool isBluetoothSupported() const = 0;
};
}
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>;
- 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);
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);
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;
ucl::StyledWidgetSRef m_btnGear;
ICallManagerSRef m_cm;
+ ISoundManagerSRef m_sm;
ICallInfoWCRef m_info;
Ecore_Timer *m_timer;
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
};
}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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)
- {
- }
-
- BluetoothManager::~BluetoothManager()
- {
- unregisterAudioHandling();
-
- bt_deinitialize();
- }
-
- Result BluetoothManager::prepare()
- {
- if (BT_ERROR_NONE != bt_initialize()) {
- LOG_RETURN(RES_FAIL, "BT initialize failed");
- }
- m_btInitialized = true;
-
- FAIL_RETURN(registerAudioHandling(),
- "registerAudioHandling() failed");
-
- return RES_OK;
- }
-
- 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!");
- }
- 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!");
- }
- return RES_OK;
- }
-
- void BluetoothManager::setVolumeStateHandler(
- const BluetoothVolumeHandler &handler)
- {
- m_handler = handler;
- }
-
- Result BluetoothManager::registerAudioHandling()
- {
- auto ret = bt_audio_initialize();
- if (ret != BT_ERROR_NONE) {
- LOG_RETURN(RES_FAIL, "bt_audio_initialize() failed");
- }
- 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");
- }
-
- return RES_OK;
- }
-
- void BluetoothManager::unregisterAudioHandling()
- {
- bt_ag_unset_speaker_gain_changed_cb();
-
- if (m_btAudioInitialized) {
- bt_audio_deinitialize();
- m_btAudioInitialized = false;
- }
- }
-
- 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");
- }
-
- 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");
- }
-
- if (isSCOOpened && soundType == SOUND_TYPE_CALL) {
- if (m_handler) {
- m_handler(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_BLUETOOTH_MANAGER_H__
-#define __CALLUI_MODEL_BLUETOOTH_MANAGER_H__
-
-#include "implTypes.h"
-
-namespace callui {
-
- class BluetoothManager final {
- public:
- static BluetoothManagerSRef newInstance();
- virtual ~BluetoothManager();
-
- int getVolume() const;
- int getMaxVolume() const;
- ucl::Result setVolume(int volume);
-
- void setVolumeStateHandler(const BluetoothVolumeHandler &handler);
-
- private:
- friend class ucl::RefCountObj<BluetoothManager>;
- BluetoothManager();
-
- ucl::Result prepare();
-
- ucl::Result registerAudioHandling();
- void unregisterAudioHandling();
- void onVolumeChanged(int volume);
-
- private:
- BluetoothVolumeHandler m_handler;
- bool m_btInitialized;
- bool m_btAudioInitialized;
- };
-
-}
-
-#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 "BluetoothVolume.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;
+
+ BluetoothVolumeSRef BluetoothVolume::newInstance()
+ {
+ auto result = makeShared<BluetoothVolume>();
+ FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+ return result;
+ }
+
+ BluetoothVolume::BluetoothVolume():
+ m_btInitialized(false),
+ m_btAudioInitialized(false)
+ {
+ }
+
+ BluetoothVolume::~BluetoothVolume()
+ {
+ unregisterAudioHandling();
+
+ bt_deinitialize();
+ }
+
+ Result BluetoothVolume::prepare()
+ {
+ if (BT_ERROR_NONE != bt_initialize()) {
+ LOG_RETURN(RES_FAIL, "BT initialize failed");
+ }
+ m_btInitialized = true;
+
+ FAIL_RETURN(registerAudioHandling(),
+ "registerAudioHandling() failed");
+
+ return RES_OK;
+ }
+
+ int BluetoothVolume::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!");
+ }
+ DLOG("BT Volume level [%d]", vol);
+ return vol;
+ }
+
+ int BluetoothVolume::getMaxVolume() const
+ {
+ return impl::BT_VOLUME_MAX;
+ }
+
+ Result BluetoothVolume::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!");
+ }
+ return RES_OK;
+ }
+
+ void BluetoothVolume::setVolumeStateHandler(
+ const BluetoothVolumeHandler &handler)
+ {
+ m_handler = handler;
+ }
+
+ Result BluetoothVolume::registerAudioHandling()
+ {
+ auto ret = bt_audio_initialize();
+ if (ret != BT_ERROR_NONE) {
+ LOG_RETURN(RES_FAIL, "bt_audio_initialize() failed");
+ }
+ m_btAudioInitialized = true;
+
+ ret = bt_ag_set_speaker_gain_changed_cb(
+ CALLBACK_B(BluetoothVolume::onVolumeChanged), this);
+ if (ret != BT_ERROR_NONE) {
+ LOG_RETURN(RES_FAIL, "bt_ag_set_speaker_gain_changed_cb() failed");
+ }
+
+ return RES_OK;
+ }
+
+ void BluetoothVolume::unregisterAudioHandling()
+ {
+ bt_ag_unset_speaker_gain_changed_cb();
+
+ if (m_btAudioInitialized) {
+ bt_audio_deinitialize();
+ m_btAudioInitialized = false;
+ }
+ }
+
+ void BluetoothVolume::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");
+ }
+
+ 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");
+ }
+
+ if (isSCOOpened && soundType == SOUND_TYPE_CALL) {
+ if (m_handler) {
+ m_handler(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_BLUETOOTH_VOLUME_H__
+#define __CALLUI_MODEL_BLUETOOTH_VOLUME_H__
+
+#include "implTypes.h"
+
+namespace callui {
+
+ class BluetoothVolume final {
+ public:
+ static BluetoothVolumeSRef newInstance();
+
+ int getVolume() const;
+ int getMaxVolume() const;
+ ucl::Result setVolume(int volume);
+
+ void setVolumeStateHandler(const BluetoothVolumeHandler &handler);
+
+ private:
+ friend class ucl::RefCountObj<BluetoothVolume>;
+ BluetoothVolume();
+ ~BluetoothVolume();
+
+ ucl::Result prepare();
+
+ ucl::Result registerAudioHandling();
+ void unregisterAudioHandling();
+ void onVolumeChanged(int volume);
+
+ private:
+ BluetoothVolumeHandler m_handler;
+ bool m_btInitialized;
+ bool m_btAudioInitialized;
+ };
+
+}
+
+#endif // __CALLUI_MODEL_BLUETOOTH_MANAGER_H__
#include "BatteryStateSource.h"
#include "SimSlotStateSource.h"
#include "HdVoiceStateSource.h"
-#include "BluetoothManager.h"
#include "common.h"
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!");
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!");
}
private:
CallManagerSRef m_callManager;
SoundManagerSRef m_soundManager;
- BluetoothManagerSRef m_btManager;
ICallListenerWRef m_listener;
SimSlotStateSourceSRef m_simSlotStSrc;
HdVoiceStateSourceSRef m_hdCallStSrc;
#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)
{
}
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<SoundManager>(client, btManager);
+ auto result = makeShared<SoundManager>(client);
FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
return result;
}
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!");
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;
}
"sound_manager_add_volume_changed_cb() failed");
}
- if (m_btManager) {
- m_btManager->setVolumeStateHandler(
+ if (isBluetoothSupported()) {
+ m_btVolume->setVolumeStateHandler(
WEAK_DELEGATE(SoundManager::onBluetoothVolumeChanged,
asWeak(*this)));
}
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 {
{
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);
{
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);
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);
return RES_OK;
}
+ bool SoundManager::isBluetoothSupported() const
+ {
+ return (m_btVolume != nullptr);
+ }
void SoundManager::onDeviceVolumeChanged(sound_type_e type, unsigned int volume)
{
public ucl::RefCountAware,
public ISoundManager {
public:
- static SoundManagerSRef newInstance(const CallClientSRef &client,
- const BluetoothManagerSRef &btManager);
+ static SoundManagerSRef newInstance(const CallClientSRef &client);
virtual ~SoundManager();
// ISoundManager
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>;
SoundManager(ucl::RefCountObjBase &rc,
- const CallClientSRef &client,
- const BluetoothManagerSRef &btManager);
+ const CallClientSRef &client);
ucl::Result prepare();
ucl::Result registerVolumeCallbacks();
private:
CallClientSRef m_client;
- BluetoothManagerSRef m_btManager;
+ BluetoothVolumeSRef m_btVolume;
AudioStateEvent m_audioStateEvent;
MuteStateEvent m_muteStateEvent;
VolumeLevelEvent m_volumeLevelEvent;
UCL_DECLARE_REF_ALIASES(SimSlotStateSource);
UCL_DECLARE_REF_ALIASES(HdVoiceStateSource);
- UCL_DECLARE_REF_ALIASES(BluetoothManager);
+ UCL_DECLARE_REF_ALIASES(BluetoothVolume);
using AudioStateEvent = ucl::Event<AudioStateHandler>;
using MuteStateEvent = ucl::Event<MuteStateHandler>;
{
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) {
#include "presenters/MoreOptionsPresenter.h"
+#include <app_control.h>
+
#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"
{
}
- 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<MoreOptionsPresenter>(m_cm);
+ auto result = makeShared<MoreOptionsPresenter>(m_cm, m_sm);
FAIL_RETURN_VALUE(result->prepare(parent), {},
"result->prepare() failed!");
// 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)
{
}
sendActivateBy(*m_widget, this);
}
+
+ m_sm->removeAudioStateHandler(DELEGATE(
+ MoreOptionsPresenter::onAudioStateChanged, this));
}
Result MoreOptionsPresenter::prepare(ElmWidget &parent)
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().
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()
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)
void MoreOptionsPresenter::onGearBtnClick(Widget &sender, void *eventInfo)
{
- ELOG("Not implemented");
+ FAIL_RETURN_VOID(m_sm->setBluetoothState(false),"setBluetoothState() failed");
}
StyledWidgetSRef MoreOptionsPresenter::createButton(
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)
}
}
- Result MoreOptionsPresenter::updateStatusText()
+ void MoreOptionsPresenter::updateStatusText()
{
m_panelLy->setText("", impl::PART_TXT_STATUS);
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()
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);
+ }
}
"createGenlist() failed!");
addDeactivatorException(this);
-
deactivateBy(m_widget.get());
return RES_OK;
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!");