summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaakko Vuori <qt-info@nokia.com>2010-04-07 15:10:42 +0300
committerJaakko Vuori <qt-info@nokia.com>2010-04-07 15:10:42 +0300
commitb0aeb3cb1f75d07b1551915e100dea540aa2c522 (patch)
tree3d6d7e56ccdf04e1c971f585acd64d9f185f4177
parentccd90e152cb548df9876d97cb3a66bfc31953514 (diff)
MOBILITY-642 fix: Retrieve powerState from RProperty instead of CTelephony
-rw-r--r--src/systeminfo/qsysteminfo_s60.cpp37
-rw-r--r--src/systeminfo/qsysteminfo_s60_p.h23
-rw-r--r--src/systeminfo/symbian/chargingstatus_s60.cpp99
-rw-r--r--src/systeminfo/symbian/chargingstatus_s60.h79
-rw-r--r--src/systeminfo/symbian/telephonyinfo_s60.cpp36
-rw-r--r--src/systeminfo/symbian/telephonyinfo_s60.h23
-rw-r--r--src/systeminfo/systeminfo.pro6
7 files changed, 216 insertions, 87 deletions
diff --git a/src/systeminfo/qsysteminfo_s60.cpp b/src/systeminfo/qsysteminfo_s60.cpp
index 7ad1689ad1..2c130b6205 100644
--- a/src/systeminfo/qsysteminfo_s60.cpp
+++ b/src/systeminfo/qsysteminfo_s60.cpp
@@ -719,10 +719,12 @@ QSystemDeviceInfoPrivate::QSystemDeviceInfoPrivate(QObject *parent)
m_bluetoothRepository(NULL), m_bluetoothNotifyHandler(NULL)
{
DeviceInfo::instance()->batteryInfo()->addObserver(this);
+ DeviceInfo::instance()->chargingStatus()->addObserver(this);
}
QSystemDeviceInfoPrivate::~QSystemDeviceInfoPrivate()
{
+ DeviceInfo::instance()->chargingStatus()->removeObserver(this);
DeviceInfo::instance()->batteryInfo()->removeObserver(this);
if (m_proEngNotifyHandler) {
@@ -853,26 +855,19 @@ QSystemDeviceInfo::InputMethodFlags QSystemDeviceInfoPrivate::inputMethodType()
QSystemDeviceInfo::PowerState QSystemDeviceInfoPrivate::currentPowerState()
{
- CTelephony::TBatteryStatus powerState = DeviceInfo::instance()->batteryInfo()->powerState();
-
- switch (powerState) {
- case CTelephony::EPoweredByBattery:
- return QSystemDeviceInfo::BatteryPower;
-
- case CTelephony::EBatteryConnectedButExternallyPowered:
- {
- if (DeviceInfo::instance()->batteryInfo()->batteryLevel() < 100) { //TODO: Use real indicator, EPSHWRMChargingStatus::EChargingStatusNotCharging?
- return QSystemDeviceInfo::WallPowerChargingBattery;
- }
- return QSystemDeviceInfo::WallPower;
- }
- case CTelephony::ENoBatteryConnected:
- return QSystemDeviceInfo::WallPower;
-
- case CTelephony::EPowerFault:
- case CTelephony::EPowerStatusUnknown:
- default:
- return QSystemDeviceInfo::UnknownPower;
+ switch (DeviceInfo::instance()->chargingStatus()->chargingStatus()) {
+ case EChargingStatusNotConnected:
+ case EChargingStatusNotCharging:
+ case EChargingStatusError:
+ return QSystemDeviceInfo::BatteryPower;
+ case EChargingStatusCharging:
+ case EChargingStatusChargingContinued:
+ case EChargingStatusAlmostComplete:
+ return QSystemDeviceInfo::WallPowerChargingBattery;
+ case EChargingStatusChargingComplete:
+ return QSystemDeviceInfo::WallPower;
+ default:
+ return QSystemDeviceInfo::UnknownPower;
}
}
@@ -966,7 +961,7 @@ void QSystemDeviceInfoPrivate::batteryLevelChanged()
}
}
-void QSystemDeviceInfoPrivate::powerStateChanged()
+void QSystemDeviceInfoPrivate::chargingStatusChanged()
{
emit powerStateChanged(currentPowerState());
}
diff --git a/src/systeminfo/qsysteminfo_s60_p.h b/src/systeminfo/qsysteminfo_s60_p.h
index 471fe1dbac..b8bd7e34c3 100644
--- a/src/systeminfo/qsysteminfo_s60_p.h
+++ b/src/systeminfo/qsysteminfo_s60_p.h
@@ -62,6 +62,7 @@
#include <f32file.h>
#include "telephonyinfo_s60.h"
+#include "chargingstatus_s60.h"
QT_BEGIN_HEADER
@@ -129,7 +130,6 @@ Q_SIGNALS:
protected: //from MTelephonyInfoObserver
void batteryLevelChanged(){};
- void powerStateChanged(){};
void countryCodeChanged();
void networkCodeChanged();
@@ -189,7 +189,8 @@ QTM_BEGIN_NAMESPACE
class QSystemDeviceInfoPrivate : public QObject,
public MTelephonyInfoObserver,
public MProEngProfileActivationObserver,
- public MCenRepNotifyHandlerCallback
+ public MCenRepNotifyHandlerCallback,
+ public MChargingStatusObserver
{
Q_OBJECT
@@ -237,7 +238,6 @@ private:
protected: //from MTelephonyInfoObserver
void batteryLevelChanged();
- void powerStateChanged();
void countryCodeChanged(){};
void networkCodeChanged(){};
@@ -247,6 +247,9 @@ protected: //from MTelephonyInfoObserver
void cellNetworkSignalStrengthChanged(){};
void cellNetworkStatusChanged(){};
+protected: //from MChargingStatusObserver
+ void chargingStatusChanged();
+
private: //data
MProEngEngine *m_profileEngine;
MProEngNotifyHandler* m_proEngNotifyHandler;
@@ -303,6 +306,14 @@ public:
return m_subscriberInfo;
}
+ CChargingStatus *chargingStatus()
+ {
+ if (!m_chargingStatus) {
+ m_chargingStatus = new CChargingStatus;
+ }
+ return m_chargingStatus;
+ }
+
CBatteryInfo *batteryInfo()
{
if (!m_batteryInfo) {
@@ -336,8 +347,8 @@ public:
}
private:
- DeviceInfo() : m_phoneInfo(NULL), m_subscriberInfo(NULL), m_batteryInfo(NULL),
- m_cellNetworkInfo(NULL), m_cellNetworkRegistrationInfo(NULL),
+ DeviceInfo() : m_phoneInfo(NULL), m_subscriberInfo(NULL), m_chargingStatus(NULL),
+ m_batteryInfo(NULL), m_cellNetworkInfo(NULL), m_cellNetworkRegistrationInfo(NULL),
m_cellSignalStrengthInfo(NULL)
{
m_telephony = CTelephony::NewL();
@@ -349,6 +360,7 @@ private:
delete m_cellNetworkRegistrationInfo;
delete m_cellNetworkInfo;
delete m_batteryInfo;
+ delete m_chargingStatus;
delete m_subscriberInfo;
delete m_phoneInfo;
delete m_telephony;
@@ -359,6 +371,7 @@ private:
CTelephony *m_telephony;
CPhoneInfo *m_phoneInfo;
CSubscriberInfo *m_subscriberInfo;
+ CChargingStatus *m_chargingStatus;
CBatteryInfo *m_batteryInfo;
CCellNetworkInfo *m_cellNetworkInfo;
CCellNetworkRegistrationInfo *m_cellNetworkRegistrationInfo;
diff --git a/src/systeminfo/symbian/chargingstatus_s60.cpp b/src/systeminfo/symbian/chargingstatus_s60.cpp
new file mode 100644
index 0000000000..31d0e7ab6b
--- /dev/null
+++ b/src/systeminfo/symbian/chargingstatus_s60.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "chargingstatus_s60.h"
+
+CChargingStatus::CChargingStatus() : CActive(EPriorityStandard),
+ m_currentStatus(EChargingStatusError)
+{
+ CActiveScheduler::Add(this);
+ TInt err = m_chargingProperty.Attach(KPSUidHWRMPowerState, KHWRMChargingStatus, EOwnerThread);
+ if (err == KErrNone) {
+ int status = EChargingStatusError;
+ m_chargingProperty.Get(status);
+ m_currentStatus = (EPSHWRMChargingStatus)status;
+ startMonitoring();
+ }
+}
+
+CChargingStatus::~CChargingStatus()
+{
+ Cancel();
+ m_chargingProperty.Close();
+}
+
+EPSHWRMChargingStatus CChargingStatus::chargingStatus() const
+{
+ return m_currentStatus;
+}
+
+void CChargingStatus::addObserver(MChargingStatusObserver *observer)
+{
+ m_observers.append(observer);
+}
+
+void CChargingStatus::removeObserver(MChargingStatusObserver *observer)
+{
+ m_observers.removeOne(observer);
+}
+
+void CChargingStatus::DoCancel()
+{
+ m_chargingProperty.Cancel();
+}
+
+void CChargingStatus::RunL()
+{
+ int status = EChargingStatusError;
+ m_chargingProperty.Get(status);
+ m_currentStatus = (EPSHWRMChargingStatus)status;
+
+ foreach (MChargingStatusObserver *observer, m_observers)
+ observer->chargingStatusChanged();
+
+ startMonitoring();
+}
+
+void CChargingStatus::startMonitoring()
+{
+ m_chargingProperty.Subscribe(iStatus);
+ SetActive();
+}
diff --git a/src/systeminfo/symbian/chargingstatus_s60.h b/src/systeminfo/symbian/chargingstatus_s60.h
new file mode 100644
index 0000000000..aa99d38c6d
--- /dev/null
+++ b/src/systeminfo/symbian/chargingstatus_s60.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CHARGINGSTATUS_S60_H
+#define CHARGINGSTATUS_S60_H
+
+#include <e32base.h>
+#include <e32property.h>
+#include <hwrmpowerstatesdkpskeys.h>
+#include <QList>
+
+class MChargingStatusObserver
+{
+public:
+ virtual void chargingStatusChanged() = 0;
+};
+
+class CChargingStatus : public CActive
+{
+public:
+ CChargingStatus();
+ ~CChargingStatus();
+ EPSHWRMChargingStatus chargingStatus() const;
+
+ void addObserver(MChargingStatusObserver *observer);
+ void removeObserver(MChargingStatusObserver *observer);
+
+protected: //from CActive
+ void DoCancel();
+ void RunL();
+
+private:
+ void startMonitoring();
+
+private:
+ RProperty m_chargingProperty;
+ EPSHWRMChargingStatus m_currentStatus;
+ QList<MChargingStatusObserver *> m_observers;
+};
+
+#endif //CHARGINGSTATUS_S60_H
diff --git a/src/systeminfo/symbian/telephonyinfo_s60.cpp b/src/systeminfo/symbian/telephonyinfo_s60.cpp
index e6cef492e8..b2ba01cb16 100644
--- a/src/systeminfo/symbian/telephonyinfo_s60.cpp
+++ b/src/systeminfo/symbian/telephonyinfo_s60.cpp
@@ -134,29 +134,6 @@ QString CSubscriberInfo::imsi() const
return m_imsi;
}
-/*
-CIndicatorInfo::CIndicatorInfo(CTelephony &telephony) : CTelephonyInfo(telephony),
- m_batteryInfoV1Pckg(m_batteryInfoV1)
-{
-}
-
-void CIndicatorInfo::DoCancel()
-{
- m_telephony.CancelAsync(CTelephony::EGetIndicatorCancel);
-}
-
-bool CIndicatorInfo::isBatteryCharging() const
-{
- m_telephony.GetIndicator(iStatus,iIndicatorV1Pckg);
- makeRequest();
-
- if (iIndicatorV1.iIndicator & CTelephony::KIndChargerConnected) {
- chargeStatus = true;
- }
- return chargeStatus;
-}
-*/
-
CBatteryInfo::CBatteryInfo(CTelephony &telephony) : CTelephonyInfo(telephony),
m_initializing(true), m_batteryInfoV1Pckg(m_batteryInfoV1)
{
@@ -166,9 +143,6 @@ CBatteryInfo::CBatteryInfo(CTelephony &telephony) : CTelephonyInfo(telephony),
m_batteryLevel = m_batteryInfoV1.iChargeLevel;
m_previousBatteryLevel = m_batteryLevel;
- m_powerState = m_batteryInfoV1.iStatus;
- m_previousPowerState = m_powerState;
-
m_initializing = false;
startMonitoring();
@@ -180,18 +154,13 @@ void CBatteryInfo::RunL()
CTelephonyInfo::RunL();
} else {
m_batteryLevel = m_batteryInfoV1.iChargeLevel;
- m_powerState = m_batteryInfoV1.iStatus;
foreach (MTelephonyInfoObserver *observer, m_observers) {
if (m_batteryLevel != m_previousBatteryLevel) {
observer->batteryLevelChanged();
}
- if (m_powerState != m_previousPowerState) {
- observer->powerStateChanged();
- }
}
m_previousBatteryLevel = m_batteryLevel;
- m_previousPowerState = m_powerState;
startMonitoring();
}
}
@@ -210,11 +179,6 @@ int CBatteryInfo::batteryLevel() const
return m_batteryLevel;
}
-CTelephony::TBatteryStatus CBatteryInfo::powerState() const
-{
- return m_powerState;
-}
-
void CBatteryInfo::startMonitoring()
{
m_telephony.NotifyChange(iStatus, CTelephony::EBatteryInfoChange, m_batteryInfoV1Pckg);
diff --git a/src/systeminfo/symbian/telephonyinfo_s60.h b/src/systeminfo/symbian/telephonyinfo_s60.h
index b0b88bbfaa..19696f039a 100644
--- a/src/systeminfo/symbian/telephonyinfo_s60.h
+++ b/src/systeminfo/symbian/telephonyinfo_s60.h
@@ -53,7 +53,6 @@ class MTelephonyInfoObserver
{
public:
virtual void batteryLevelChanged() = 0;
- virtual void powerStateChanged() = 0;
virtual void countryCodeChanged() = 0;
virtual void networkCodeChanged() = 0;
@@ -125,24 +124,6 @@ private:
QString m_imsi;
};
-/*
-class CIndicatorInfo : public CTelephonyInfo
-{
-public:
- CIndicatorInfo(CTelephony &telephony);
-
-protected:
- void DoCancel();
-
-public:
- bool isBatteryCharging() const;
-
-private:
- CTelephony::TBatteryInfoV1Pckg m_batteryInfoV1Pckg;
- CTelephony::TBatteryInfoV1 m_batteryInfoV1;
-};
-*/
-
class CBatteryInfo : public CTelephonyInfo
{
public:
@@ -155,7 +136,6 @@ protected:
public:
int batteryLevel() const;
- CTelephony::TBatteryStatus powerState() const;
private:
bool m_initializing;
@@ -165,9 +145,6 @@ private:
int m_batteryLevel;
int m_previousBatteryLevel;
-
- CTelephony::TBatteryStatus m_powerState;
- CTelephony::TBatteryStatus m_previousPowerState;
};
class CCellNetworkInfo : public CTelephonyInfo
diff --git a/src/systeminfo/systeminfo.pro b/src/systeminfo/systeminfo.pro
index a0ed62bdb7..9ab0052fdd 100644
--- a/src/systeminfo/systeminfo.pro
+++ b/src/systeminfo/systeminfo.pro
@@ -112,10 +112,12 @@ unix: {
DEPENDPATH += symbian
SOURCES += qsysteminfo_s60.cpp \
- telephonyinfo_s60.cpp
+ telephonyinfo_s60.cpp \
+ chargingstatus_s60.cpp
HEADERS += qsysteminfo_s60_p.h \
- telephonyinfo_s60.h
+ telephonyinfo_s60.h \
+ chargingstatus_s60.h
LIBS += -lprofileengine \
-letel3rdparty \