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;
};
virtual IActiveCallWRef getActiveCall() = 0;
virtual IHeldCallWRef getHeldCall() = 0;
virtual IEndCallWRef getEndCall() = 0;
+ virtual CallMask getAvailableCalls() const = 0;
};
}
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__
};
enum class SimSlot {
- UNDEFINED,
- FIRST,
- SECOND,
- DEFAULT
+ UNDEFINED = 0,
+ GEAR,
+ MOBILE_FIRST,
+ MOBILE_SECOND,
+ MOBILE_DEFAULT
};
enum class CallAnswerType {
RSSI,
BATTERY,
SIM_SLOT,
- HD_CALL,
- VOICE_ANSWER,
+ HD_VOICE
};
UCL_DECLARE_REF_ALIASES(ICall);
#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"
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;
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);
}
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;
};
}
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!");
return m_isEmergency;
}
+ bool CallInfo::isHDVoice() const
+ {
+ return m_isHDVoice;
+ }
+
int CallInfo::getConferenceMemberCount() const
{
return m_confMemberCount;
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;
ContactInfoSRef m_contactInfo;
long m_startTime;
bool m_isEmergency;
+ bool m_isHDVoice;
int m_confMemberCount;
ConfMemberList m_confMemberList;
};
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 };
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>;
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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__
{
return m_source->getState();
}
+
private:
void onStateChanged()
{
private:
enum {
- STATE_COUNT = 6
+ STATE_COUNT = 5
};
class SourceHandler;
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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__
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)
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>;