TizenRefApp-8420 [Call UI] Implement SimSlotStateSource 65/126465/1
authorIgor Olshevskyi <i.olshevskyi@samsung.com>
Fri, 21 Apr 2017 13:27:50 +0000 (16:27 +0300)
committerIgor Olshevskyi <i.olshevskyi@samsung.com>
Fri, 21 Apr 2017 13:28:40 +0000 (16:28 +0300)
TizenRefApp-8419 [Call UI] Implement HdVoiceStateSource

Change-Id: I16ddf836e65e91c9cd470b4be56dc0c3bddd3b03

18 files changed:
inc/model/ICallInfo.h
inc/model/ICallManager.h
inc/model/IndicatorState.h
inc/model/types.h
src/model/Call.cpp
src/model/Call.h
src/model/CallInfo.cpp
src/model/CallInfo.h
src/model/CallManager.cpp
src/model/CallManager.h
src/model/HdVoiceStateSource.cpp [new file with mode: 0644]
src/model/HdVoiceStateSource.h [new file with mode: 0644]
src/model/IndicatorStateProvider.cpp
src/model/IndicatorStateProvider.h
src/model/SimSlotStateSource.cpp [new file with mode: 0644]
src/model/SimSlotStateSource.h [new file with mode: 0644]
src/model/helpers.hpp
src/model/implTypes.h

index 4a30b11b8aba93c0e3e0d91cb098b4be19076bb9..fa9508b2541e37cbaba561411bd800c6842cb880 100644 (file)
@@ -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;
        };
index 92bcbe86f18e60f5eaa792c267b152d49a66af82..89afd9150285df08f7b6de912c2458a71496f471 100644 (file)
@@ -27,6 +27,7 @@ namespace callui {
                virtual IActiveCallWRef getActiveCall() = 0;
                virtual IHeldCallWRef getHeldCall() = 0;
                virtual IEndCallWRef getEndCall() = 0;
+               virtual CallMask getAvailableCalls() const = 0;
        };
 }
 
index d842d420486f6293339194a5d221c6064253d46d..3b4e851ee75ecdf6280faf02ee48f3a10b21a325 100644 (file)
@@ -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__
index c2db8a26efd81f670658c2c59ccf03265629d5ac..c3dd7d28ef6508ba1f47360a14be71106880e3af 100644 (file)
@@ -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);
index 55027f0e4b08fff75765ce514d1791612893a4b4..434920802d1099566e4c355cebb471dfc2b440f8 100644 (file)
 
 #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 "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<SimSlotStateSource>(
+                               m_callManager->getSimSlot());
+               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;
@@ -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);
                }
index d03bf5d3f122fc9607440b8814187624bef8e00e..0871d0af3a9842941fd9bf876f86945d18cc3347 100644 (file)
@@ -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;
        };
 
 }
index 4659a8d91cf29f0174db9a7aaa98aa7707985799..78b5bad9f713f0374429f363ee2be2833374af6f 100644 (file)
@@ -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;
index 72b0c389e428fd06b5321b31c08baa95cf9cc2b2..c2086127a014e7b770b122a8d44bde7727255784 100644 (file)
@@ -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;
        };
index d8a49ec50964ba5c2f1930423699aa73d3a9034f..8835dfadd1040858ccc80f3081cd3e50f84c034e 100644 (file)
@@ -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 };
index 6dba3f7b93563e9ec6c6ea11a809b690d0aa341f..242c607ebb846c19b071c88c80ed95764fa84e19 100644 (file)
@@ -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<CallManager>;
diff --git a/src/model/HdVoiceStateSource.cpp b/src/model/HdVoiceStateSource.cpp
new file mode 100644 (file)
index 0000000..396ee05
--- /dev/null
@@ -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 (file)
index 0000000..678fad6
--- /dev/null
@@ -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__
index 68392692c0ec46a24ae128f16ecffa8e1f0db1f1..0be9e5b339ce1b71d054604ceba0d4d873685ee8 100644 (file)
@@ -45,6 +45,7 @@ namespace callui {
                {
                        return m_source->getState();
                }
+
        private:
                void onStateChanged()
                {
index cbf9b6d5d358069924d412f02a8a2d51cffb4d99..0f9f2e6c0e705f4fbcb2e12d51b029d4a8c4ced7 100644 (file)
@@ -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 (file)
index 0000000..55cb37f
--- /dev/null
@@ -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<SimSlot>(
+                               SimSlotStateSource::Bits(state).simSlot);
+       }
+
+}
diff --git a/src/model/SimSlotStateSource.h b/src/model/SimSlotStateSource.h
new file mode 100644 (file)
index 0000000..9620f2c
--- /dev/null
@@ -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__
index 42f7e10a2dad4ee969ef4128e590eda8e0163bae..302350b9970088a0017fc460a0b2b670880cb7e6 100644 (file)
@@ -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)
index 5c5ef9d72e589fc4a655d1e70608548fe29b06db..952af96f18240a23e830df7309adcd62ae1b60d4 100644 (file)
@@ -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<AudioStateHandler>;
        using MuteStateEvent = ucl::Event<MuteStateHandler>;