virtual ucl::Result processAppControl(app_control_h appControl) = 0;
virtual ISoundManagerSRef getSoundManager() = 0;
virtual ICallManagerSRef getCallManager() = 0;
+ virtual IIndicatorStateProviderSRef getIndicatorStateProvider() = 0;
};
}
--- /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_I_INDICATOR_STATE_LISTENER_H__
+#define __CALLUI_MODEL_I_INDICATOR_STATE_LISTENER_H__
+
+#include "types.h"
+
+namespace callui {
+
+ class IIndicatorStateListener: public ucl::Polymorphic {
+ public:
+ virtual void onStateChanged(IndicatorProperty property) const = 0;
+ };
+
+}
+
+#endif // __CALLUI_MODEL_I_INDICATOR_STATE_LISTENER_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.
+ */
+
+#ifndef __CALLUI_MODEL_I_INDICATOR_STATE_PROVIDER_H__
+#define __CALLUI_MODEL_I_INDICATOR_STATE_PROVIDER_H__
+
+#include <model/IndicatorState.h>
+#include "types.h"
+
+namespace callui {
+
+ class IIndicatorStateProvider : public ucl::Polymorphic {
+ public:
+ virtual IndicatorState getState(IndicatorProperty property) const = 0;
+ virtual void setListener(IIndicatorStateListenerWRef listener) = 0;
+ };
+
+}
+
+#endif // __CALLUI_MODEL_I_INDICATOR_STATE_PROVIDER_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.
+ */
+
+#ifndef __CALLUI_MODEL_INDICATOR_STATE_H__
+#define __CALLUI_MODEL_INDICATOR_STATE_H__
+
+#include "types.h"
+
+namespace callui {
+
+ struct IndicatorState {
+ uint64_t value;
+ };
+
+ ConnectionType getConnectionState(IndicatorState state);
+ PacketDirection getPacketDirection(IndicatorState state);
+}
+
+#endif // __CALLUI_MODEL_INDICATOR_STATE_H__
NAME
};
+ enum class ConnectionType {
+ NONE = 0,
+ EDGE_E,
+ GPRS_G,
+ SIMPLE_2G,
+ HSDPA_H,
+ HSPA_H_PLUS,
+ LTE_4G,
+ UMTS_3G,
+ UMTS_3G_PLUS,
+ NO_SIM,
+ WIFI_00,
+ WIFI_01,
+ WIFI_02,
+ WIFI_03,
+ WIFI_04,
+ NO_SIGNAL
+ };
+
+ enum class PacketDirection {
+ NONE = 0,
+ NO_INPUT,
+ IN,
+ OUT,
+ INOUT
+ };
+
+ enum class IndicatorProperty {
+ NW_CONNECTION = 0,
+ RSSI,
+ BATTERY,
+ SIM_SLOT,
+ HD_CALL,
+ VOICE_ANSWER,
+ };
+
UCL_DECLARE_REF_ALIASES(ICall);
UCL_DECLARE_REF_ALIASES(ICallListener);
UCL_DECLARE_REF_ALIASES(IRejectMsgProvider);
UCL_DECLARE_REF_ALIASES(IRejectMsg);
+ UCL_DECLARE_REF_ALIASES(IIndicatorStateProvider);
+ UCL_DECLARE_REF_ALIASES(IIndicatorStateListener);
+
using AudioStateHandler = ucl::Delegate<void(AudioStateType)>;
using MuteStateHandler = ucl::Delegate<void(bool)>;
#include "SoundManager.h"
#include "model/ICallListener.h"
+#include "IndicatorStateProvider.h"
+#include "ConnectionStateSource.h"
+
#include "common.h"
namespace callui {
Result Call::prepare()
{
- CallClientSRef callClient = CallClient::newInstance();
+ auto callClient = CallClient::newInstance();
if (!callClient) {
LOG_RETURN(RES_FAIL, "Client::newInstance() failed!");
}
LOG_RETURN(RES_FAIL, "SoundManage::newInstance() failed!");
}
+ FAIL_RETURN(initInidcatorStateProvider(), "Init Indicator State Provider failed!");
+
+ return RES_OK;
+ }
+
+ Result Call::initInidcatorStateProvider()
+ {
+ m_indicatorStateProvider = IndicatorStateProvider::newInstance();
+ if (!m_indicatorStateProvider) {
+ LOG_RETURN(RES_FAIL, "IndicatorStateProvider::newInstance() failed!");
+ }
+
+ auto connectionStateSource = ConnectionStateSource::newInstance();
+ if (!connectionStateSource) {
+ LOG_RETURN(RES_FAIL, "ConnectionStateSource::newInstance() failed!");
+ }
+
+ FAIL_RETURN(m_indicatorStateProvider->setStateSource(
+ IndicatorProperty::NW_CONNECTION, connectionStateSource),
+ "setStateSource() failed!");
+
return RES_OK;
}
return m_soundManager;
}
+ IIndicatorStateProviderSRef Call::getIndicatorStateProvider()
+ {
+ return m_indicatorStateProvider;
+ }
+
void Call::onCallEvent(CallEventType type)
{
if (m_listener) {
void Call::onError(CallManagerErr err)
{
- CallErr callErr = CallErr::DIAL_FAIL;
+ auto callErr = CallErr::DIAL_FAIL;
switch (err) {
case CallManagerErr::DIAL_CANCEL:
callErr = CallErr::DIAL_CANCEL;
virtual ucl::Result processAppControl(app_control_h appControl) override final;
virtual ISoundManagerSRef getSoundManager() override final;
virtual ICallManagerSRef getCallManager() override final;
+ virtual IIndicatorStateProviderSRef getIndicatorStateProvider() override final;
// ICallManagerListener
ucl::Result prepare();
+ ucl::Result initInidcatorStateProvider();
+
private:
CallManagerSRef m_callManager;
SoundManagerSRef m_soundManager;
ICallListenerWRef m_listener;
+ IndicatorStateProviderSRef m_indicatorStateProvider;
};
}
--- /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 "ConnectionStateSource.h"
+
+#include "model/IndicatorState.h"
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ ConnectionStateSource::Bits::Bits():
+ value(0)
+ {
+ property = convertEnumValueToInt(IndicatorProperty::NW_CONNECTION);
+ }
+
+ ConnectionStateSource::Bits::Bits(const IndicatorState &state):
+ value(state.value)
+ {
+ }
+
+ ConnectionStateSource::ConnectionStateSource()
+ {
+ }
+
+ ConnectionStateSource::~ConnectionStateSource()
+ {
+ unsignSystStateCallbacks();
+ }
+
+ IIndicatorStateSourceSRef ConnectionStateSource::newInstance()
+ {
+ auto result = makeShared<ConnectionStateSource>();
+ FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+ return result;
+ }
+
+ Result ConnectionStateSource::prepare()
+ {
+ FAIL_RETURN(signSysStateCallbacks(), "signSysStateCallbacks() failed!");
+
+ updateConnType();
+ updatePacketDir();
+
+ return RES_OK;
+ }
+
+ bool ConnectionStateSource::isWifiConnected() const
+ {
+ int state = VCONFKEY_WIFI_UNCONNECTED;
+ if (vconf_get_int(VCONFKEY_WIFI_STATE, &state) < 0) {
+ ELOG("Get WiFi connection state failed");
+ return false;
+ }
+ return (state == VCONFKEY_WIFI_CONNECTED);
+ }
+
+ bool ConnectionStateSource::isFlightMode() const
+ {
+ int status = false;;
+ if (vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &status) < 0) {
+ ELOG("Get Flight mode status failed!");
+ return false;
+ }
+ return status;
+ }
+
+ bool ConnectionStateSource::isDnetConnected() const
+ {
+ int status = VCONFKEY_DNET_OFF;
+ if (vconf_get_int(VCONFKEY_DNET_STATE, &status) < 0) {
+ ELOG("Get Dnet status failed!");
+ return false;
+ }
+ return (status != VCONFKEY_DNET_OFF);
+ }
+
+ ConnectionType ConnectionStateSource::getConnTypeByWiFiStrength() const
+ {
+ int wifiStrength = 0;
+ if (vconf_get_int(VCONFKEY_WIFI_STRENGTH, &wifiStrength) == 0) {
+ switch (wifiStrength) {
+ case 1:
+ return ConnectionType::WIFI_01;
+ case 2:
+ return ConnectionType::WIFI_02;
+ case 3:
+ return ConnectionType::WIFI_03;
+ case 4:
+ return ConnectionType::WIFI_04;
+ default:
+ return ConnectionType::WIFI_00;
+ }
+ } else {
+ ELOG("Get WiFi connection type failed!");
+ }
+ return ConnectionType::NONE;
+ }
+
+ ConnectionType ConnectionStateSource::getConnTypeByTelephonyPsType() const
+ {
+ int type = 0;
+ if (vconf_get_int(VCONFKEY_TELEPHONY_PSTYPE, &type) == 0) {
+ switch (type) {
+ case VCONFKEY_TELEPHONY_PSTYPE_HSDPA:
+ case VCONFKEY_TELEPHONY_PSTYPE_HSUPA:
+ return ConnectionType::HSDPA_H;
+ case VCONFKEY_TELEPHONY_PSTYPE_HSPA:
+ case VCONFKEY_TELEPHONY_PSTYPE_HSPAP:
+ return ConnectionType::HSPA_H_PLUS;
+ default:
+ break;
+ }
+ } else {
+ ELOG("Get connection PS type failed!");
+ }
+ return ConnectionType::NONE;
+ }
+
+ ConnectionType ConnectionStateSource::getConnTypeByTelephonySvcType() const
+ {
+ int svcType = 0;
+ if (vconf_get_int(VCONFKEY_TELEPHONY_SVCTYPE, &svcType) == 0) {
+ switch (svcType) {
+ case VCONFKEY_TELEPHONY_SVCTYPE_2G:
+ return ConnectionType::SIMPLE_2G;
+ case VCONFKEY_TELEPHONY_SVCTYPE_2_5G:
+ return ConnectionType::GPRS_G;
+ case VCONFKEY_TELEPHONY_SVCTYPE_3G:
+ return ConnectionType::UMTS_3G;
+ case VCONFKEY_TELEPHONY_SVCTYPE_2_5G_EDGE:
+ return ConnectionType::EDGE_E;
+ case VCONFKEY_TELEPHONY_SVCTYPE_LTE:
+ return ConnectionType::LTE_4G;
+ default:
+ break;
+ }
+ } else {
+ ELOG("Get connection SVC type failed!");
+ }
+ return ConnectionType::NONE;
+ }
+
+ bool ConnectionStateSource::updateConnTypeBits(ConnectionType connType)
+ {
+ int connTypeInt = convertEnumValueToInt(connType);
+ if (connTypeInt != m_bits.connState) {
+ m_bits.connState = connTypeInt;
+ return true;
+ }
+ return false;
+ }
+
+ bool ConnectionStateSource::updatePacketDirBits(PacketDirection direction)
+ {
+ int directionInt = convertEnumValueToInt(direction);
+ if (directionInt != m_bits.packetDirection) {
+ m_bits.packetDirection = directionInt;
+ return true;
+ }
+ return false;
+ }
+
+ bool ConnectionStateSource::updateConnType()
+ {
+ if (isFlightMode()) {
+ return updateConnTypeBits(ConnectionType::NONE);
+ }
+
+ if (isWifiConnected()) {
+ return updateConnTypeBits(getConnTypeByWiFiStrength());
+ }
+
+ if (!isDnetConnected()) {
+ return updateConnTypeBits(ConnectionType::NONE);
+ }
+
+ ConnectionType connType = getConnTypeByTelephonyPsType();
+ if (connType != ConnectionType::NONE) {
+ return updateConnTypeBits(connType);
+ }
+
+ connType = getConnTypeByTelephonySvcType();
+ if (connType != ConnectionType::NONE) {
+ return updateConnTypeBits(connType);
+ }
+
+ return updateConnTypeBits(ConnectionType::NONE);
+ }
+
+ void ConnectionStateSource::onConnTypeChangedCb(keynode_t *node)
+ {
+ ILOG();
+
+ bool needNotify = updateConnType();
+ if (updatePacketDir()) {
+ needNotify = true;
+ }
+
+ if (needNotify && m_handler) {
+ m_handler();
+ }
+ }
+
+ PacketDirection ConnectionStateSource::getPacketDirByWiFiState() const
+ {
+ int transferState = 0;
+ if (vconf_get_int(VCONFKEY_WIFI_TRANSFER_STATE, &transferState) == 0) {
+ switch (transferState) {
+ case VCONFKEY_WIFI_TRANSFER_STATE_RX:
+ return PacketDirection::IN;
+ case VCONFKEY_WIFI_TRANSFER_STATE_TX:
+ return PacketDirection::OUT;
+ case VCONFKEY_WIFI_TRANSFER_STATE_TXRX:
+ return PacketDirection::INOUT;
+ default:
+ return PacketDirection::NO_INPUT;
+ }
+ } else {
+ ELOG("Get WiFi transfer state failed");
+ }
+ return PacketDirection::NONE;
+ }
+
+ PacketDirection ConnectionStateSource::getPacketDirByPacketState() const
+ {
+ int state = 0;
+ if (vconf_get_int(VCONFKEY_PACKET_STATE, &state) == 0) {
+ switch (state) {
+ case VCONFKEY_PACKET_RX:
+ return PacketDirection::IN;
+ case VCONFKEY_PACKET_TX:
+ return PacketDirection::OUT;
+ case VCONFKEY_PACKET_RXTX:
+ return PacketDirection::INOUT;
+ default:
+ return PacketDirection::NO_INPUT;
+ }
+ } else {
+ ELOG("Get packet state failed");
+ }
+ return PacketDirection::NONE;
+ }
+
+ bool ConnectionStateSource::updatePacketDir()
+ {
+ ILOG();
+ PacketDirection direction = PacketDirection::NONE;
+
+ if (isFlightMode()) {
+ return updatePacketDirBits(direction);
+ }
+
+ if (isWifiConnected()) {
+ direction = getPacketDirByWiFiState();
+ } else if (isDnetConnected()) {
+ direction = getPacketDirByPacketState();
+ }
+ return updatePacketDirBits(direction);
+ }
+
+ void ConnectionStateSource::onPacketStateChangedCb(keynode_t *node)
+ {
+ ILOG();
+ if (updatePacketDir() && m_handler) {
+ m_handler();
+ }
+ }
+
+ Result ConnectionStateSource::signSysStateCallbacks()
+ {
+ // CONNECTION
+ int res = vconf_notify_key_changed(VCONFKEY_WIFI_STRENGTH,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ res = vconf_notify_key_changed(VCONFKEY_WIFI_STATE,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ res = vconf_notify_key_changed(VCONFKEY_DNET_STATE,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_PSTYPE,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_SVCTYPE,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_SIM_SLOT,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_EMERGENCY_CB_MODE_CDMA,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this);
+
+ // PACKET
+ res = vconf_notify_key_changed(VCONFKEY_PACKET_STATE,
+ CALLBACK_B(ConnectionStateSource::onPacketStateChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ res = vconf_notify_key_changed(VCONFKEY_WIFI_TRANSFER_STATE,
+ CALLBACK_B(ConnectionStateSource::onPacketStateChangedCb), this);
+ if (res != 0) {
+ LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+ }
+
+ return RES_OK;
+
+ }
+
+ void ConnectionStateSource::unsignSystStateCallbacks()
+ {
+ // CONNECTION
+ vconf_ignore_key_changed(VCONFKEY_WIFI_STRENGTH,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
+ vconf_ignore_key_changed(VCONFKEY_WIFI_STATE,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
+ vconf_ignore_key_changed(VCONFKEY_DNET_STATE,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_PSTYPE,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_SVCTYPE,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_SIM_SLOT,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_EMERGENCY_CB_MODE_CDMA,
+ CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb));
+
+ // PACKET
+ vconf_ignore_key_changed(VCONFKEY_PACKET_STATE,
+ CALLBACK_B(ConnectionStateSource::onPacketStateChangedCb));
+ vconf_ignore_key_changed(VCONFKEY_WIFI_TRANSFER_STATE,
+ CALLBACK_B(ConnectionStateSource::onPacketStateChangedCb));
+
+ }
+
+ IndicatorState ConnectionStateSource::getState() const
+ {
+ return {m_bits.value};
+ }
+
+ void ConnectionStateSource::setStateChangeHandler(StateChangeHandler handler)
+ {
+ m_handler = handler;
+ }
+
+ ConnectionStateSource::Bits ConnectionStateSource::asBits(IndicatorState state)
+ {
+ Bits bits(state);
+ if (static_cast<IndicatorProperty>(bits.property) != IndicatorProperty::NW_CONNECTION) {
+ ELOG("State of incorrect property type [%d]", bits.property);
+ return {};
+ }
+
+ return bits;
+ }
+
+ ConnectionType getConnectionState(IndicatorState state)
+ {
+ return static_cast<ConnectionType>(
+ ConnectionStateSource::asBits(state).connState);
+ }
+
+ PacketDirection getPacketDirection(IndicatorState state)
+ {
+ return static_cast<PacketDirection>(
+ ConnectionStateSource::asBits(state).packetDirection);
+ }
+
+}
--- /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_CONNECTION_STATE_SOURCE_H__
+#define __CALLUI_MODEL_CONNECTION_STATE_SOURCE_H__
+
+#include "IIndicatorStateSource.h"
+
+#include <vconf.h>
+
+namespace callui {
+
+ class ConnectionStateSource final : public IIndicatorStateSource {
+ public:
+ static IIndicatorStateSourceSRef newInstance();
+ virtual ~ConnectionStateSource();
+
+ // IIndicatorStateSource
+
+ virtual IndicatorState getState() const override final;
+ virtual void setStateChangeHandler(StateChangeHandler handler) override final;
+
+ private:
+ friend class ucl::RefCountObj<ConnectionStateSource>;
+ ConnectionStateSource();
+
+ ucl::Result prepare();
+
+ ucl::Result signSysStateCallbacks();
+ void unsignSystStateCallbacks();
+
+ void onConnTypeChangedCb(keynode_t *node);
+ void onPacketStateChangedCb(keynode_t *node);
+
+ bool isWifiConnected() const;
+ bool isFlightMode() const;
+ bool isDnetConnected() const;
+
+ bool updateConnTypeBits(ConnectionType connType);
+ ConnectionType getConnTypeByTelephonyPsType() const;
+ ConnectionType getConnTypeByTelephonySvcType() const;
+ ConnectionType getConnTypeByWiFiStrength() const;
+ bool updateConnType();
+
+ bool updatePacketDirBits(PacketDirection packetType);
+ PacketDirection getPacketDirByWiFiState() const;
+ PacketDirection getPacketDirByPacketState() const;
+ bool updatePacketDir();
+
+ private:
+ union Bits {
+ struct {
+ uint8_t property : 4;
+ uint8_t connState : 8;
+ uint8_t packetDirection : 4;
+ };
+ uint64_t value;
+
+ Bits();
+ Bits(const IndicatorState &state);
+ };
+ public:
+ static Bits asBits(IndicatorState state);
+
+ private:
+ Bits m_bits;
+ StateChangeHandler m_handler;
+ };
+
+}
+
+#endif // __CALLUI_MODEL_CONNECTION_STATE_SOURCE_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.
+ */
+
+#ifndef __CALLUI_MODEL_I_STATE_SOURCE_H__
+#define __CALLUI_MODEL_I_STATE_SOURCE_H__
+
+#include "implTypes.h"
+
+#include "model/IndicatorState.h"
+
+namespace callui {
+
+ class IIndicatorStateSource : public ucl::Polymorphic {
+ public:
+ virtual IndicatorState getState() const = 0;
+ virtual void setStateChangeHandler(StateChangeHandler handler) = 0;
+ };
+}
+
+#endif // __CALLUI_MODEL_I_STATE_SOURCE_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 "IndicatorStateProvider.h"
+
+#include "model/IIndicatorStateListener.h"
+#include "IIndicatorStateSource.h"
+
+#include "common.h"
+
+namespace callui {
+
+ using namespace ucl;
+
+ class IndicatorStateProvider::SourceHandler :
+ public RefCountAware {
+ public:
+ SourceHandler(RefCountObjBase &rc,
+ IndicatorStateProvider &provider,
+ IndicatorProperty property,
+ IIndicatorStateSourceSRef source):
+ RefCountAware(&rc),
+ m_provider(provider),
+ m_property(property),
+ m_source(source)
+ {
+ m_source->setStateChangeHandler(
+ WEAK_DELEGATE(SourceHandler::onStateChanged, asWeak(*this)));
+ }
+
+ IndicatorState getState() const
+ {
+ return m_source->getState();
+ }
+ private:
+ void onStateChanged()
+ {
+ m_provider.dispatchStateChanged(m_property);
+ }
+
+ private:
+ const IndicatorStateProvider &m_provider;
+ const IndicatorProperty m_property;
+ const IIndicatorStateSourceSRef m_source;
+ };
+
+ IndicatorStateProvider::IndicatorStateProvider():
+ m_listener(nullptr),
+ m_sources()
+ {
+ }
+
+ IndicatorStateProvider::~IndicatorStateProvider()
+ {
+ }
+
+ IndicatorStateProviderSRef IndicatorStateProvider::newInstance()
+ {
+ return makeShared<IndicatorStateProvider>();
+ }
+
+ Result IndicatorStateProvider::setStateSource(IndicatorProperty property,
+ IIndicatorStateSourceSRef source)
+ {
+ if (!source) {
+ LOG_RETURN(RES_INVALID_ARGUMENTS, "source is empty!");
+ }
+ m_sources[convertEnumValueToInt(property)] =
+ makeShared<SourceHandler>(*this, property, source);
+
+ return RES_OK;
+ }
+
+ IndicatorState IndicatorStateProvider::getState(IndicatorProperty property) const
+ {
+ return m_sources[convertEnumValueToInt(property)]->getState();
+ }
+
+ void IndicatorStateProvider::setListener(IIndicatorStateListenerWRef listener)
+ {
+ m_listener = listener;
+ }
+
+ void IndicatorStateProvider::dispatchStateChanged(IndicatorProperty property) const
+ {
+ if (m_listener) {
+ m_listener->onStateChanged(property);
+ }
+ }
+
+}
--- /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_INDICATOR_STATE_PROVIDER_H__
+#define __CALLUI_MODEL_INDICATOR_STATE_PROVIDER_H__
+
+#include "model/IIndicatorStateProvider.h"
+
+#include "implTypes.h"
+
+namespace callui {
+
+ class IIndicatorStateListener;
+
+ class IndicatorStateProvider final: public IIndicatorStateProvider {
+ public:
+ static IndicatorStateProviderSRef newInstance();
+
+ virtual ~IndicatorStateProvider();
+
+ virtual ucl::Result setStateSource(IndicatorProperty property,
+ IIndicatorStateSourceSRef source);
+
+ // IIndicatorStateProvider
+
+ virtual IndicatorState getState(IndicatorProperty property) const override final;
+ virtual void setListener(IIndicatorStateListenerWRef listener) override final;
+
+ private:
+ friend class ucl::RefCountObj<IndicatorStateProvider>;
+ IndicatorStateProvider();
+
+ void dispatchStateChanged(IndicatorProperty property) const;
+
+ private:
+ enum {
+ STATE_COUNT = 6
+ };
+
+ class SourceHandler;
+ UCL_DECLARE_REF_ALIASES(SourceHandler);
+
+ private:
+ IIndicatorStateListenerWRef m_listener;
+ std::array<SourceHandlerSRef, STATE_COUNT> m_sources;
+ };
+
+}
+
+#endif // __CALLUI_MODEL_INDICATOR_STATE_PROVIDER_H__
#include "model/types.h"
#include "ucl/misc/Event.h"
+#include "ucl/misc/smartDelegation.h"
namespace callui {
UCL_DECLARE_REF_ALIASES(RejectMsgProvider);
UCL_DECLARE_REF_ALIASES(RejectMsg);
+ UCL_DECLARE_REF_ALIASES(IndicatorStateProvider);
+ UCL_DECLARE_REF_ALIASES(IIndicatorStateSource);
+
using AudioStateEvent = ucl::Event<AudioStateHandler>;
using MuteStateEvent = ucl::Event<MuteStateHandler>;
+ using StateChangeHandler = ucl::WeakDelegate<void()>;
}
#endif // __CALLUI_MODEL_IMPL_TYPES_H__
<privilege>http://tizen.org/privilege/notification</privilege>
<privilege>http://tizen.org/privilege/message.read</privilege>
<privilege>http://tizen.org/privilege/display</privilege>
+ <privilege>http://tizen.org/privilege/telephony</privilege>
+ <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+ <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
</privileges>
</manifest>