From 586f49001cdac814cb96bb7ff4b983bb497f451a Mon Sep 17 00:00:00 2001 From: Igor Olshevskyi Date: Fri, 21 Apr 2017 16:27:50 +0300 Subject: [PATCH] TizenRefApp-8420 [Call UI] Implement SimSlotStateSource TizenRefApp-8419 [Call UI] Implement HdVoiceStateSource Change-Id: I16ddf836e65e91c9cd470b4be56dc0c3bddd3b03 --- inc/model/ICallInfo.h | 1 + inc/model/ICallManager.h | 1 + inc/model/IndicatorState.h | 3 + inc/model/types.h | 12 ++-- src/model/Call.cpp | 88 ++++++++++++++++++++++------ src/model/Call.h | 7 ++- src/model/CallInfo.cpp | 10 ++++ src/model/CallInfo.h | 2 + src/model/CallManager.cpp | 19 ++++++ src/model/CallManager.h | 1 + src/model/HdVoiceStateSource.cpp | 75 ++++++++++++++++++++++++ src/model/HdVoiceStateSource.h | 54 +++++++++++++++++ src/model/IndicatorStateProvider.cpp | 1 + src/model/IndicatorStateProvider.h | 2 +- src/model/SimSlotStateSource.cpp | 76 ++++++++++++++++++++++++ src/model/SimSlotStateSource.h | 54 +++++++++++++++++ src/model/helpers.hpp | 16 ++--- src/model/implTypes.h | 2 + 18 files changed, 387 insertions(+), 37 deletions(-) create mode 100644 src/model/HdVoiceStateSource.cpp create mode 100644 src/model/HdVoiceStateSource.h create mode 100644 src/model/SimSlotStateSource.cpp create mode 100644 src/model/SimSlotStateSource.h diff --git a/inc/model/ICallInfo.h b/inc/model/ICallInfo.h index 4a30b11..fa9508b 100644 --- a/inc/model/ICallInfo.h +++ b/inc/model/ICallInfo.h @@ -27,6 +27,7 @@ namespace callui { public: virtual long getStartTime() const = 0; virtual bool isEmergency() const = 0; + virtual bool isHDVoice() const = 0; virtual int getConferenceMemberCount() const = 0; virtual const ConfMemberList &getConferenceMemberList() const = 0; }; diff --git a/inc/model/ICallManager.h b/inc/model/ICallManager.h index 92bcbe8..89afd91 100644 --- a/inc/model/ICallManager.h +++ b/inc/model/ICallManager.h @@ -27,6 +27,7 @@ namespace callui { virtual IActiveCallWRef getActiveCall() = 0; virtual IHeldCallWRef getHeldCall() = 0; virtual IEndCallWRef getEndCall() = 0; + virtual CallMask getAvailableCalls() const = 0; }; } diff --git a/inc/model/IndicatorState.h b/inc/model/IndicatorState.h index d842d42..3b4e851 100644 --- a/inc/model/IndicatorState.h +++ b/inc/model/IndicatorState.h @@ -31,6 +31,9 @@ namespace callui { bool getRoamingState(IndicatorState state); int getBatteryLevel(IndicatorState state); BatteryState getBatteryState(IndicatorState state); + SimSlot getSimSlotType(IndicatorState state); + bool getHDVoiceState(IndicatorState state); + } #endif // __CALLUI_MODEL_INDICATOR_STATE_H__ diff --git a/inc/model/types.h b/inc/model/types.h index c2db8a2..c3dd7d2 100644 --- a/inc/model/types.h +++ b/inc/model/types.h @@ -30,10 +30,11 @@ namespace callui { }; enum class SimSlot { - UNDEFINED, - FIRST, - SECOND, - DEFAULT + UNDEFINED = 0, + GEAR, + MOBILE_FIRST, + MOBILE_SECOND, + MOBILE_DEFAULT }; enum class CallAnswerType { @@ -134,8 +135,7 @@ namespace callui { RSSI, BATTERY, SIM_SLOT, - HD_CALL, - VOICE_ANSWER, + HD_VOICE }; UCL_DECLARE_REF_ALIASES(ICall); diff --git a/src/model/Call.cpp b/src/model/Call.cpp index 55027f0..4349208 100644 --- a/src/model/Call.cpp +++ b/src/model/Call.cpp @@ -18,15 +18,22 @@ #include +#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 "model/ICallListener.h" - #include "IndicatorStateProvider.h" #include "ConnectionStateSource.h" #include "RssiStateSource.h" #include "BatteryStateSource.h" +#include "SimSlotStateSource.h" +#include "HdVoiceStateSource.h" #include "common.h" @@ -138,33 +145,48 @@ namespace callui { Result Call::initInidcatorStateProvider() { - m_indicatorStateProvider = IndicatorStateProvider::newInstance(); - if (!m_indicatorStateProvider) { + 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!"); + LOG_RETURN(RES_FAIL, + "ConnectionStateSource::newInstance() failed!"); } - FAIL_RETURN(m_indicatorStateProvider->setStateSource( + FAIL_RETURN(m_indicatorStPrv->setStateSource( IndicatorProperty::NW_CONNECTION, connStateSource), "setStateSource() failed!"); - auto rssiStateSource = RssiStateSource::newInstance(); - if (!rssiStateSource) { - LOG_RETURN(RES_FAIL, "ConnectionStateSource::newInstance() failed!"); + auto rssiStSrc = RssiStateSource::newInstance(); + if (!rssiStSrc) { + LOG_RETURN(RES_FAIL, + "RssiStateSource::newInstance() failed!"); } - FAIL_RETURN(m_indicatorStateProvider->setStateSource( - IndicatorProperty::RSSI, rssiStateSource), + FAIL_RETURN(m_indicatorStPrv->setStateSource( + IndicatorProperty::RSSI, rssiStSrc), "setStateSource() failed!"); - auto batteryStateSource = BatteryStateSource::newInstance(); - if (!batteryStateSource) { - LOG_RETURN(RES_FAIL, "ConnectionStateSource::newInstance() failed!"); + auto batteryStSrc = BatteryStateSource::newInstance(); + if (!batteryStSrc) { + LOG_RETURN(RES_FAIL, + "BatteryStateSource::newInstance() failed!"); } - FAIL_RETURN(m_indicatorStateProvider->setStateSource( - IndicatorProperty::BATTERY, batteryStateSource), + FAIL_RETURN(m_indicatorStPrv->setStateSource( + IndicatorProperty::BATTERY, batteryStSrc), + "setStateSource() failed!"); + + m_simSlotStSrc = makeShared( + m_callManager->getSimSlot()); + FAIL_RETURN(m_indicatorStPrv->setStateSource( + IndicatorProperty::SIM_SLOT, m_simSlotStSrc), + "setStateSource() failed!"); + + m_hdCallStSrc = makeShared( + getHDVoiceStatus()); + FAIL_RETURN(m_indicatorStPrv->setStateSource( + IndicatorProperty::HD_VOICE, m_hdCallStSrc), "setStateSource() failed!"); return RES_OK; @@ -182,11 +204,43 @@ namespace callui { IIndicatorStateProviderSRef Call::getIndicatorStateProvider() { - return m_indicatorStateProvider; + return m_indicatorStPrv; + } + + bool Call::getHDVoiceStatus() const + { + ICallInfoSCRef info; + CallMask calls = m_callManager->getAvailableCalls(); + if (!calls) { + DLOG("No available calls"); + return false; + } else if (calls & CALL_FLAG_INCOMING) { + info = m_callManager->getIncomingCall()->getInfo(); + } else if (calls & CALL_FLAG_ACTIVE) { + info = m_callManager->getActiveCall()->getInfo(); + } else if (calls & CALL_FLAG_HELD) { + info = m_callManager->getHeldCall()->getInfo(); + } else if (calls & CALL_FLAG_END) { + info = m_callManager->getEndCall()->getInfo(); + } + return info->isHDVoice(); + } + + void Call::updateHdVoiceStateSource() + { + m_hdCallStSrc->updateState(getHDVoiceStatus()); + } + + void Call::updateSimSlotStateSource() + { + m_simSlotStSrc->updateSimSlot(m_callManager->getSimSlot()); } void Call::onCallEvent(CallEventType type) { + updateSimSlotStateSource(); + updateHdVoiceStateSource(); + if (m_listener) { m_listener->onCallEvent(type); } diff --git a/src/model/Call.h b/src/model/Call.h index d03bf5d..0871d0a 100644 --- a/src/model/Call.h +++ b/src/model/Call.h @@ -56,12 +56,17 @@ namespace callui { ucl::Result prepare(); ucl::Result initInidcatorStateProvider(); + bool getHDVoiceStatus() const; + void updateHdVoiceStateSource(); + void updateSimSlotStateSource(); private: CallManagerSRef m_callManager; SoundManagerSRef m_soundManager; ICallListenerWRef m_listener; - IndicatorStateProviderSRef m_indicatorStateProvider; + SimSlotStateSourceSRef m_simSlotStSrc; + HdVoiceStateSourceSRef m_hdCallStSrc; + IndicatorStateProviderSRef m_indicatorStPrv; }; } diff --git a/src/model/CallInfo.cpp b/src/model/CallInfo.cpp index 4659a8d..78b5bad 100644 --- a/src/model/CallInfo.cpp +++ b/src/model/CallInfo.cpp @@ -74,6 +74,11 @@ namespace callui { 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; + res = convertCMResult(cm_call_data_get_start_time(callData, &m_startTime)); FAIL_RETURN(res, "cm_call_data_get_start_time() failed!"); @@ -154,6 +159,11 @@ namespace callui { return m_isEmergency; } + bool CallInfo::isHDVoice() const + { + return m_isHDVoice; + } + int CallInfo::getConferenceMemberCount() const { return m_confMemberCount; diff --git a/src/model/CallInfo.h b/src/model/CallInfo.h index 72b0c38..c208612 100644 --- a/src/model/CallInfo.h +++ b/src/model/CallInfo.h @@ -37,6 +37,7 @@ namespace callui { virtual IContactInfoSCRef getContactInfo() const override final; virtual long getStartTime() const override final; virtual bool isEmergency() const override final; + virtual bool isHDVoice() const override final; virtual int getConferenceMemberCount() const override final; virtual const ConfMemberList &getConferenceMemberList() const override final; @@ -53,6 +54,7 @@ namespace callui { ContactInfoSRef m_contactInfo; long m_startTime; bool m_isEmergency; + bool m_isHDVoice; int m_confMemberCount; ConfMemberList m_confMemberList; }; diff --git a/src/model/CallManager.cpp b/src/model/CallManager.cpp index d8a49ec5..8835dfa 100644 --- a/src/model/CallManager.cpp +++ b/src/model/CallManager.cpp @@ -133,6 +133,25 @@ namespace callui { return m_endCall; } + CallMask CallManager::getAvailableCalls() const + { + int res = 0; + + 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[TEL_NUMBER_MAX_SIZE] = { 0 }; diff --git a/src/model/CallManager.h b/src/model/CallManager.h index 6dba3f7..242c607 100644 --- a/src/model/CallManager.h +++ b/src/model/CallManager.h @@ -48,6 +48,7 @@ namespace callui { virtual IActiveCallWRef getActiveCall() override final; virtual IHeldCallWRef getHeldCall() override final; virtual IEndCallWRef getEndCall() override final; + virtual CallMask getAvailableCalls() const override final; private: friend class ucl::RefCountObj; diff --git a/src/model/HdVoiceStateSource.cpp b/src/model/HdVoiceStateSource.cpp new file mode 100644 index 0000000..396ee05 --- /dev/null +++ b/src/model/HdVoiceStateSource.cpp @@ -0,0 +1,75 @@ +/* + * Copyright 2017 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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(StateChangeHandler handler) + { + m_handler = handler; + } + + bool getHDVoiceState(IndicatorState state) + { + return HdVoiceStateSource::Bits(state).isEnable; + } + +} diff --git a/src/model/HdVoiceStateSource.h b/src/model/HdVoiceStateSource.h new file mode 100644 index 0000000..678fad6 --- /dev/null +++ b/src/model/HdVoiceStateSource.h @@ -0,0 +1,54 @@ +/* + * Copyright 2017 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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(StateChangeHandler 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; + StateChangeHandler m_handler; + }; + +} + +#endif // __CALLUI_MODEL_HD_VOICE_STATE_SOURCE_H__ diff --git a/src/model/IndicatorStateProvider.cpp b/src/model/IndicatorStateProvider.cpp index 6839269..0be9e5b 100644 --- a/src/model/IndicatorStateProvider.cpp +++ b/src/model/IndicatorStateProvider.cpp @@ -45,6 +45,7 @@ namespace callui { { return m_source->getState(); } + private: void onStateChanged() { diff --git a/src/model/IndicatorStateProvider.h b/src/model/IndicatorStateProvider.h index cbf9b6d..0f9f2e6 100644 --- a/src/model/IndicatorStateProvider.h +++ b/src/model/IndicatorStateProvider.h @@ -47,7 +47,7 @@ namespace callui { private: enum { - STATE_COUNT = 6 + STATE_COUNT = 5 }; class SourceHandler; diff --git a/src/model/SimSlotStateSource.cpp b/src/model/SimSlotStateSource.cpp new file mode 100644 index 0000000..55cb37f --- /dev/null +++ b/src/model/SimSlotStateSource.cpp @@ -0,0 +1,76 @@ +/* + * Copyright 2017 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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) + { + m_bits.simSlot = convertEnumValueToInt(slot); + } + + SimSlotStateSource::~SimSlotStateSource() + { + } + + void SimSlotStateSource::updateSimSlot(SimSlot slot) + { + int simSlotInt = convertEnumValueToInt(slot); + if (simSlotInt != m_bits.simSlot) { + m_bits.simSlot = simSlotInt; + if (m_handler) { + m_handler(); + } + } + } + + IndicatorState SimSlotStateSource::getState() const + { + return {m_bits.value}; + } + + void SimSlotStateSource::setStateChangeHandler(StateChangeHandler handler) + { + m_handler = handler; + } + + SimSlot getSimSlotType(IndicatorState state) + { + return static_cast( + SimSlotStateSource::Bits(state).simSlot); + } + +} diff --git a/src/model/SimSlotStateSource.h b/src/model/SimSlotStateSource.h new file mode 100644 index 0000000..9620f2c --- /dev/null +++ b/src/model/SimSlotStateSource.h @@ -0,0 +1,54 @@ +/* + * Copyright 2017 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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); + virtual ~SimSlotStateSource(); + void updateSimSlot(SimSlot slot); + + // IIndicatorStateSource + + virtual IndicatorState getState() const override final; + virtual void setStateChangeHandler(StateChangeHandler handler) override final; + + public: + union Bits { + struct { + uint8_t property : 4; + uint8_t simSlot : 4; + }; + uint64_t value; + + Bits(); + Bits(const IndicatorState &state); + }; + + private: + Bits m_bits; + StateChangeHandler m_handler; + }; + +} + +#endif // __CALLUI_MODEL_SIM_SLOT_STATE_SOURCE_H__ diff --git a/src/model/helpers.hpp b/src/model/helpers.hpp index 42f7e10..302350b 100644 --- a/src/model/helpers.hpp +++ b/src/model/helpers.hpp @@ -50,22 +50,14 @@ namespace callui { inline cm_multi_sim_slot_type_e convertCUISimSlot(SimSlot slot) { - switch (slot) { - case SimSlot::FIRST: return CM_MULTI_SIM_SLOT_1; - case SimSlot::SECOND: return CM_MULTI_SIM_SLOT_2; - default: - return CM_MULTI_SIM_SLOT_DEFAULT; - } + // 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) { - switch (slot) { - case CM_MULTI_SIM_SLOT_1: return SimSlot::FIRST; - case CM_MULTI_SIM_SLOT_2: return SimSlot::SECOND; - default: - return SimSlot::DEFAULT; - } + // TODO: this must be changed after Companion mode will be provided + return SimSlot::GEAR; } inline cm_call_release_type_e convertCUICallReleaseType(CallReleaseType type) diff --git a/src/model/implTypes.h b/src/model/implTypes.h index 5c5ef9d..952af96 100644 --- a/src/model/implTypes.h +++ b/src/model/implTypes.h @@ -64,6 +64,8 @@ namespace callui { 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); using AudioStateEvent = ucl::Event; using MuteStateEvent = ucl::Event; -- 2.34.1