TizenRefApp-8415 [Call UI] Implement BatteryStateSource 03/126203/4
authorIgor Olshevskyi <i.olshevskyi@samsung.com>
Thu, 20 Apr 2017 11:22:17 +0000 (14:22 +0300)
committerIgor Olshevskyi <i.olshevskyi@samsung.com>
Fri, 21 Apr 2017 13:12:47 +0000 (16:12 +0300)
Change-Id: Iaa192d0eaf04ff27d8a520dabc757e86e1e26836

inc/model/IndicatorState.h
inc/model/types.h
src/model/BatteryStateSource.cpp [new file with mode: 0644]
src/model/BatteryStateSource.h [new file with mode: 0644]
src/model/Call.cpp
src/model/ConnectionStateSource.cpp
src/model/ConnectionStateSource.h
src/model/RssiStateSource.cpp
src/model/RssiStateSource.h
src/model/implTypes.h

index baf6b60d849b99747102bd5c8cdae414b628b6d7..d842d420486f6293339194a5d221c6064253d46d 100644 (file)
@@ -29,7 +29,8 @@ namespace callui {
        PacketDirection getPacketDirection(IndicatorState state);
        RssiState getRssiState(IndicatorState state);
        bool getRoamingState(IndicatorState state);
-
+       int getBatteryLevel(IndicatorState state);
+       BatteryState getBatteryState(IndicatorState state);
 }
 
 #endif // __CALLUI_MODEL_INDICATOR_STATE_H__
index 867774a256f10e88237164e24e30312b75a98c29..c2db8a26efd81f670658c2c59ccf03265629d5ac 100644 (file)
@@ -122,6 +122,13 @@ namespace callui {
                FLIGHT_MODE
        };
 
+       enum class BatteryState {
+               NORMAL = 0,
+               CHARGING,
+               CHARGING_PROBLEM,
+               UNKNOWN
+       };
+
        enum class IndicatorProperty {
                NW_CONNECTION = 0,
                RSSI,
diff --git a/src/model/BatteryStateSource.cpp b/src/model/BatteryStateSource.cpp
new file mode 100644 (file)
index 0000000..6c146a1
--- /dev/null
@@ -0,0 +1,198 @@
+/*
+ * 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 "BatteryStateSource.h"
+
+#include "common.h"
+
+namespace callui {
+
+       using namespace ucl;
+
+       BatteryStateSource::Bits::Bits():
+               property(convertEnumValueToInt(IndicatorProperty::BATTERY)),
+               chargeValue(0),
+               chargingState(convertEnumValueToInt(BatteryState::NORMAL))
+       {
+       }
+
+       BatteryStateSource::Bits::Bits(const IndicatorState &state):
+                       value(state.value)
+       {
+               if (property != convertEnumValueToInt(IndicatorProperty::BATTERY)) {
+                       ELOG("State of incorrect property type [%d]", property);
+                       *this = {};
+               }
+       }
+
+       BatteryStateSource::BatteryStateSource()
+       {
+       }
+
+       BatteryStateSource::~BatteryStateSource()
+       {
+               delSysStateCallbacks();
+       }
+
+       BatteryStateSourceSRef BatteryStateSource::newInstance()
+       {
+               auto result = makeShared<BatteryStateSource>();
+               FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+               return result;
+       }
+
+       Result BatteryStateSource::prepare()
+       {
+               FAIL_RETURN(addSysStateCallbacks(), "addSysStateCallbacks() failed!");
+
+               updateBatteryState();
+
+               return RES_OK;
+       }
+
+       bool BatteryStateSource::updateChargingStateBits(BatteryState state)
+       {
+               int stateInt = convertEnumValueToInt(state);
+               if (stateInt != m_bits.chargingState) {
+                       m_bits.chargingState = stateInt;
+                       return true;
+               }
+               return false;
+       }
+
+       bool BatteryStateSource::updateChargeLevelBits(int value)
+       {
+               if (value != m_bits.chargeValue) {
+                       m_bits.chargeValue = value;
+                       return true;
+               }
+               return false;
+       }
+
+       int BatteryStateSource::getCurChargeLevel() const
+       {
+               int capacity = 0;
+               if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CAPACITY, &capacity) == 0) {
+                       return capacity;
+               }
+               ELOG("Get battery capacity failed!");
+               return -1;
+       }
+
+       BatteryState BatteryStateSource::getCurChargingState() const
+       {
+               int isCharged = 0;
+               if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, &isCharged) == 0) {
+                       switch (isCharged) {
+                       case -1: return BatteryState::CHARGING_PROBLEM;
+                       case 1:  return BatteryState::CHARGING;
+                       default: return BatteryState::NORMAL;
+                       }
+               }
+               ELOG("Get battery charging status failed!");
+               return BatteryState::NORMAL;
+       }
+
+       bool BatteryStateSource::updateBatteryState()
+       {
+               int chargeLevel = getCurChargeLevel();
+               BatteryState state = getCurChargingState();
+
+               if (chargeLevel < 0) {
+                       chargeLevel = 0;
+                       if (state == BatteryState::NORMAL) {
+                               state = BatteryState::UNKNOWN;
+                       }
+               }
+
+               bool wasUpdated = updateChargingStateBits(state);
+               if (updateChargeLevelBits(chargeLevel)) {
+                       wasUpdated = true;
+               }
+               return wasUpdated;
+       }
+
+       void BatteryStateSource::onBatteryStateChangedCb(keynode_t *node)
+       {
+               if (updateBatteryState() && m_handler) {
+                       m_handler();
+               }
+       }
+
+       Result BatteryStateSource::addSysStateCallbacks()
+       {
+               int res = vconf_notify_key_changed(VCONFKEY_SYSMAN_CHARGER_STATUS,
+                               CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb), this);
+               if (res != 0) {
+                       LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+               }
+
+               res = vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW,
+                               CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb), this);
+               if (res != 0) {
+                       LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+               }
+
+               res = vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW,
+                               CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb), this);
+               if (res != 0) {
+                       LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+               }
+
+               res = vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY,
+                               CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb), this);
+               if (res != 0) {
+                       LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed");
+               }
+
+               return RES_OK;
+       }
+
+       void BatteryStateSource::delSysStateCallbacks()
+       {
+               vconf_ignore_key_changed(VCONFKEY_SYSMAN_CHARGER_STATUS,
+                               CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb));
+               vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW,
+                               CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb));
+               vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW,
+                               CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb));
+               vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY,
+                               CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb));
+       }
+
+       IndicatorState BatteryStateSource::getState() const
+       {
+               return {m_bits.value};
+       }
+
+       void BatteryStateSource::setStateChangeHandler(StateChangeHandler handler)
+       {
+               m_handler = handler;
+       }
+
+       int getBatteryLevel(IndicatorState state)
+       {
+               return static_cast<int>(
+                               BatteryStateSource::Bits(state).chargeValue);
+       }
+
+       BatteryState getBatteryState(IndicatorState state)
+       {
+               return static_cast<BatteryState>(
+                               BatteryStateSource::Bits(state).chargingState);
+       }
+
+}
diff --git a/src/model/BatteryStateSource.h b/src/model/BatteryStateSource.h
new file mode 100644 (file)
index 0000000..4ba260e
--- /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.
+ */
+
+#ifndef __CALLUI_MODEL_BATTERY_STATE_SOURCE_H__
+#define __CALLUI_MODEL_BATTERY_STATE_SOURCE_H__
+
+#include "IIndicatorStateSource.h"
+
+#include <vconf.h>
+
+#include "implTypes.h"
+
+namespace callui {
+
+       class BatteryStateSource final : public IIndicatorStateSource {
+       public:
+               static BatteryStateSourceSRef newInstance();
+               virtual ~BatteryStateSource();
+
+               // IIndicatorStateSource
+
+               virtual IndicatorState getState() const override final;
+               virtual void setStateChangeHandler(StateChangeHandler handler) override final;
+       private:
+               friend class ucl::RefCountObj<BatteryStateSource>;
+               BatteryStateSource();
+
+               ucl::Result prepare();
+
+               ucl::Result addSysStateCallbacks();
+               void delSysStateCallbacks();
+
+               void onBatteryStateChangedCb(keynode_t *node);
+
+               int getCurChargeLevel() const;
+               BatteryState getCurChargingState() const;
+
+               bool updateChargingStateBits(BatteryState state);
+               bool updateChargeLevelBits(int value);
+               bool updateBatteryState();
+
+       public:
+               union Bits {
+                       struct {
+                               uint8_t property : 4;
+                               uint8_t chargeValue : 8;
+                               uint8_t chargingState: 4;
+                       };
+                       uint64_t value;
+
+                       Bits();
+                       Bits(const IndicatorState &state);
+               };
+
+       private:
+               Bits m_bits;
+               StateChangeHandler m_handler;
+       };
+
+}
+
+#endif // __CALLUI_MODEL_BATTERY_STATE_SOURCE_H__
index d24fe62209a15ad87cf50b52ef3d56df37e421da..55027f0e4b08fff75765ce514d1791612893a4b4 100644 (file)
@@ -26,6 +26,7 @@
 #include "IndicatorStateProvider.h"
 #include "ConnectionStateSource.h"
 #include "RssiStateSource.h"
+#include "BatteryStateSource.h"
 
 #include "common.h"
 
@@ -158,6 +159,14 @@ namespace callui {
                                IndicatorProperty::RSSI, rssiStateSource),
                                "setStateSource() failed!");
 
+               auto batteryStateSource = BatteryStateSource::newInstance();
+               if (!batteryStateSource) {
+                       LOG_RETURN(RES_FAIL, "ConnectionStateSource::newInstance() failed!");
+               }
+               FAIL_RETURN(m_indicatorStateProvider->setStateSource(
+                               IndicatorProperty::BATTERY, batteryStateSource),
+                               "setStateSource() failed!");
+
                return RES_OK;
        }
 
index 24e3ec00987b2299e870e3c553102fa06e03e0e4..ff33839db919c231bf15416c02274779492b4b50 100644 (file)
@@ -25,14 +25,19 @@ namespace callui {
        using namespace ucl;
 
        ConnectionStateSource::Bits::Bits():
-                       value(0)
+                       property(convertEnumValueToInt(IndicatorProperty::NW_CONNECTION)),
+                       connState(convertEnumValueToInt(ConnectionType::NONE)),
+                       packetDirection(convertEnumValueToInt(PacketDirection::NONE))
        {
-               property = convertEnumValueToInt(IndicatorProperty::NW_CONNECTION);
        }
 
        ConnectionStateSource::Bits::Bits(const IndicatorState &state):
                        value(state.value)
        {
+               if (property != convertEnumValueToInt(IndicatorProperty::NW_CONNECTION)) {
+                       ELOG("State of incorrect property type [%d]", property);
+                       *this = {};
+               }
        }
 
        ConnectionStateSource::ConnectionStateSource()
@@ -44,7 +49,7 @@ namespace callui {
                unsignSystStateCallbacks();
        }
 
-       IIndicatorStateSourceSRef ConnectionStateSource::newInstance()
+       ConnectionStateSourceSRef ConnectionStateSource::newInstance()
        {
                auto result = makeShared<ConnectionStateSource>();
                FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
@@ -53,7 +58,7 @@ namespace callui {
 
        Result ConnectionStateSource::prepare()
        {
-               FAIL_RETURN(signSysStateCallbacks(), "signSysStateCallbacks() failed!");
+               FAIL_RETURN(addSysStateCallbacks(), "addSysStateCallbacks() failed!");
 
                updateConnType();
                updatePacketDir();
@@ -86,20 +91,14 @@ namespace callui {
                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;
+                       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!");
                }
+               ELOG("Get WiFi connection type failed!");
                return ConnectionType::NONE;
        }
 
@@ -107,19 +106,17 @@ namespace callui {
        {
                int type = 0;
                if (vconf_get_int(VCONFKEY_TELEPHONY_PSTYPE, &type) == 0) {
-                       switch (type) {
-                       case VCONFKEY_TELEPHONY_PSTYPE_HSDPA:
-                       case VCONFKEY_TELEPHONY_PSTYPE_HSUPA:
+                       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:
+                       case VCONFKEY_TELEPHONY_PSTYPE_HSPA :
                                return ConnectionType::HSPA_H_PLUS;
-                       default:
-                               break;
+                       default :
+                               return ConnectionType::UMTS_3G;
                        }
-               } else {
-                       ELOG("Get connection PS type failed!");
                }
+               ELOG("Get connection PS type failed!");
                return ConnectionType::NONE;
        }
 
@@ -127,23 +124,21 @@ namespace callui {
        {
                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:
+                       switch(svcType) {
+                       case VCONFKEY_TELEPHONY_SVCTYPE_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:
+                       case VCONFKEY_TELEPHONY_SVCTYPE_3G :
+                               return getConnTypeByTelephonyPsType();
+                       case VCONFKEY_TELEPHONY_SVCTYPE_2_5G_EDGE :
                                return ConnectionType::EDGE_E;
-                       case VCONFKEY_TELEPHONY_SVCTYPE_LTE:
+                       case VCONFKEY_TELEPHONY_SVCTYPE_LTE :
                                return ConnectionType::LTE_4G;
-                       default:
-                               break;
+                       default :
+                               return ConnectionType::NONE;
                        }
-               } else {
-                       ELOG("Get connection SVC type failed!");
                }
+               ELOG("Get connection SVC type failed!");
                return ConnectionType::NONE;
        }
 
@@ -181,17 +176,7 @@ namespace callui {
                        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);
+               return updateConnTypeBits(getConnTypeByTelephonySvcType());
        }
 
        void ConnectionStateSource::onConnTypeChangedCb(keynode_t *node)
@@ -220,9 +205,8 @@ namespace callui {
                        default:
                                return PacketDirection::NO_INPUT;
                        }
-               } else {
-                       ELOG("Get WiFi transfer state failed");
                }
+               ELOG("Get WiFi transfer state failed");
                return PacketDirection::NONE;
        }
 
@@ -231,18 +215,13 @@ namespace callui {
                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;
+                       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");
                }
+               ELOG("Get packet state failed");
                return PacketDirection::NONE;
        }
 
@@ -270,7 +249,7 @@ namespace callui {
                }
        }
 
-       Result ConnectionStateSource::signSysStateCallbacks()
+       Result ConnectionStateSource::addSysStateCallbacks()
        {
                // CONNECTION
                int res = vconf_notify_key_changed(VCONFKEY_WIFI_STRENGTH,
@@ -373,27 +352,16 @@ namespace callui {
                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);
+                               ConnectionStateSource::Bits(state).connState);
        }
 
        PacketDirection getPacketDirection(IndicatorState state)
        {
                return static_cast<PacketDirection>(
-                               ConnectionStateSource::asBits(state).packetDirection);
+                               ConnectionStateSource::Bits(state).packetDirection);
        }
 
 }
index ba6c7498a43e3dd21740670a9122f84755d25915..45981218124c79a70d2d2bf0259147edb065918e 100644 (file)
 
 #include <vconf.h>
 
+#include "implTypes.h"
+
 namespace callui {
 
        class ConnectionStateSource final : public IIndicatorStateSource {
        public:
-               static IIndicatorStateSourceSRef newInstance();
+               static ConnectionStateSourceSRef newInstance();
                virtual ~ConnectionStateSource();
 
                // IIndicatorStateSource
@@ -39,7 +41,7 @@ namespace callui {
 
                ucl::Result prepare();
 
-               ucl::Result signSysStateCallbacks();
+               ucl::Result addSysStateCallbacks();
                void unsignSystStateCallbacks();
 
                void onConnTypeChangedCb(keynode_t *node);
@@ -59,7 +61,7 @@ namespace callui {
                PacketDirection getPacketDirByPacketState() const;
                bool updatePacketDir();
 
-       private:
+       public:
                union Bits {
                        struct {
                                uint8_t property : 4;
@@ -71,8 +73,6 @@ namespace callui {
                        Bits();
                        Bits(const IndicatorState &state);
                };
-       public:
-               static Bits asBits(IndicatorState state);
 
        private:
                Bits m_bits;
index 58ae978481b0d7eca6999bdecb38cc16e1b2b91c..ef83230f7611fe22eb62d55f595b7163a8279f3f 100644 (file)
@@ -23,14 +23,19 @@ namespace callui {
        using namespace ucl;
 
        RssiStateSource::Bits::Bits():
-                       value(0)
+               property(convertEnumValueToInt(IndicatorProperty::RSSI)),
+               rssiState(convertEnumValueToInt(RssiState::NONE)),
+               isRoamingEnable(0)
        {
-               property = convertEnumValueToInt(IndicatorProperty::RSSI);
        }
 
        RssiStateSource::Bits::Bits(const IndicatorState &state):
                        value(state.value)
        {
+               if (property != convertEnumValueToInt(IndicatorProperty::RSSI)) {
+                       ELOG("State of incorrect property type [%d]", property);
+                       *this = {};
+               }
        }
 
        RssiStateSource::RssiStateSource()
@@ -39,10 +44,10 @@ namespace callui {
 
        RssiStateSource::~RssiStateSource()
        {
-               unsignSysStateCallbacks();
+               delSysStateCallbacks();
        }
 
-       IIndicatorStateSourceSRef RssiStateSource::newInstance()
+       RssiStateSourceSRef RssiStateSource::newInstance()
        {
                auto result = makeShared<RssiStateSource>();
                FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
@@ -51,7 +56,7 @@ namespace callui {
 
        Result RssiStateSource::prepare()
        {
-               FAIL_RETURN(signSysStateCallbacks(), "signSysStateCallbacks() failed!");
+               FAIL_RETURN(addSysStateCallbacks(), "addSysStateCallbacks() failed!");
 
                updateRssiState();
                updateRoamingState();
@@ -146,7 +151,7 @@ namespace callui {
                }
        }
 
-       Result RssiStateSource::signSysStateCallbacks()
+       Result RssiStateSource::addSysStateCallbacks()
        {
                int res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_SVC_ROAM,
                                CALLBACK_B(RssiStateSource::onRssiChangedCb), this);
@@ -181,7 +186,7 @@ namespace callui {
                return RES_OK;
        }
 
-       void RssiStateSource::unsignSysStateCallbacks()
+       void RssiStateSource::delSysStateCallbacks()
        {
                vconf_ignore_key_changed(VCONFKEY_TELEPHONY_SVC_ROAM,
                                                CALLBACK_B(RssiStateSource::onRssiChangedCb));
@@ -205,26 +210,15 @@ namespace callui {
                m_handler = handler;
        }
 
-       RssiStateSource::Bits RssiStateSource::asBits(IndicatorState state)
-       {
-               Bits bits(state);
-               if (static_cast<IndicatorProperty>(bits.property) != IndicatorProperty::RSSI) {
-                       ELOG("State of incorrect property type [%d]", bits.property);
-                       return {};
-               }
-
-               return bits;
-       }
-
        RssiState getRssiState(IndicatorState state)
        {
                return static_cast<RssiState>(
-                               RssiStateSource::asBits(state).rssiState);
+                               RssiStateSource::Bits(state).rssiState);
        }
 
        bool getRoamingState(IndicatorState state)
        {
-               return RssiStateSource::asBits(state).isRoamingEnable;
+               return RssiStateSource::Bits(state).isRoamingEnable;
        }
 
 }
index 58d1fda46a15343157331906c5cf2885d3ed3776..862e9320c17397b01e33442e7d3ff07620f0a2a4 100644 (file)
 
 #include <vconf.h>
 
+#include "implTypes.h"
+
 namespace callui {
 
        class RssiStateSource final : public IIndicatorStateSource {
        public:
-               static IIndicatorStateSourceSRef newInstance();
+               static RssiStateSourceSRef newInstance();
                virtual ~RssiStateSource();
 
                // IIndicatorStateSource
@@ -38,8 +40,8 @@ namespace callui {
                RssiStateSource();
 
                ucl::Result prepare();
-               ucl::Result signSysStateCallbacks();
-               void unsignSysStateCallbacks();
+               ucl::Result addSysStateCallbacks();
+               void delSysStateCallbacks();
 
                bool isRoamingActive() const;
                bool updateRssiStateBits(RssiState state);
@@ -50,7 +52,7 @@ namespace callui {
 
                void onRssiChangedCb(keynode_t *node);
 
-       private:
+       public:
                union Bits {
                        struct {
                                uint8_t property : 4;
@@ -58,13 +60,11 @@ namespace callui {
                                uint8_t isRoamingEnable: 1;
                        };
                        uint64_t value;
+
                        Bits();
                        Bits(const IndicatorState &state);
                };
 
-       public:
-               static Bits asBits(IndicatorState state);
-
        private:
                Bits m_bits;
                StateChangeHandler m_handler;
index 701d4f8ea83605c8ce6393302008fc30d1acd723..5c5ef9d72e589fc4a655d1e70608548fe29b06db 100644 (file)
@@ -61,6 +61,10 @@ namespace callui {
        UCL_DECLARE_REF_ALIASES(IndicatorStateProvider);
        UCL_DECLARE_REF_ALIASES(IIndicatorStateSource);
 
+       UCL_DECLARE_REF_ALIASES(ConnectionStateSource);
+       UCL_DECLARE_REF_ALIASES(RssiStateSource);
+       UCL_DECLARE_REF_ALIASES(BatteryStateSource);
+
        using AudioStateEvent = ucl::Event<AudioStateHandler>;
        using MuteStateEvent = ucl::Event<MuteStateHandler>;