diff --git a/src/systeminfo/qsystembatteryinfo.cpp b/src/systeminfo/qsystembatteryinfo.cpp index 6fa8f67..7519176 100644 --- a/src/systeminfo/qsystembatteryinfo.cpp +++ b/src/systeminfo/qsystembatteryinfo.cpp @@ -180,6 +180,9 @@ QSystemBatteryInfo::QSystemBatteryInfo(QObject *parent) : QObject(parent) , d(batteryInfoPrivate()) { +#ifdef Q_OS_SYMBIAN + batteryInfoPrivate()->acquire(); +#endif qRegisterMetaType("QSystemBatteryInfo::BatteryStatus"); qRegisterMetaType("QSystemBatteryInfo::ChargingState"); qRegisterMetaType("QSystemBatteryInfo::ChargerType"); @@ -191,6 +194,9 @@ QSystemBatteryInfo::QSystemBatteryInfo(QObject *parent) */ QSystemBatteryInfo::~QSystemBatteryInfo() { +#ifdef Q_OS_SYMBIAN + batteryInfoPrivate()->release(); +#endif } /*! diff --git a/src/systeminfo/qsystemdeviceinfo.cpp b/src/systeminfo/qsystemdeviceinfo.cpp index e1f18cd..40f9235 100644 --- a/src/systeminfo/qsystemdeviceinfo.cpp +++ b/src/systeminfo/qsystemdeviceinfo.cpp @@ -238,6 +238,9 @@ QSystemDeviceInfo::QSystemDeviceInfo(QObject *parent) : QObject(parent) , d(deviceInfoPrivate()) { +#ifdef Q_OS_SYMBIAN + deviceInfoPrivate()->acquire(); +#endif qRegisterMetaType("QSystemDeviceInfo::BatteryStatus"); qRegisterMetaType("QSystemDeviceInfo::PowerState"); qRegisterMetaType("QSystemDeviceInfo::ThermalState"); @@ -254,6 +257,9 @@ QSystemDeviceInfo::QSystemDeviceInfo(QObject *parent) */ QSystemDeviceInfo::~QSystemDeviceInfo() { +#ifdef Q_OS_SYMBIAN + deviceInfoPrivate()->release(); +#endif } /*! diff --git a/src/systeminfo/qsystemdisplayinfo.cpp b/src/systeminfo/qsystemdisplayinfo.cpp index 33109a7..272da35 100644 --- a/src/systeminfo/qsystemdisplayinfo.cpp +++ b/src/systeminfo/qsystemdisplayinfo.cpp @@ -93,6 +93,9 @@ QSystemDisplayInfoPrivate *getSystemDisplayInfoPrivate() { return displayInfoPri QSystemDisplayInfo::QSystemDisplayInfo(QObject *parent) : QObject(parent) { +#ifdef Q_OS_SYMBIAN + displayInfoPrivate()->acquire(); +#endif qRegisterMetaType("QSystemDisplayInfo::DisplayOrientation"); qRegisterMetaType("QSystemDisplayInfo::BacklightState"); connect(displayInfoPrivate(), SIGNAL(orientationChanged(QSystemDisplayInfo::DisplayOrientation)), @@ -104,6 +107,9 @@ QSystemDisplayInfo::QSystemDisplayInfo(QObject *parent) */ QSystemDisplayInfo::~QSystemDisplayInfo() { +#ifdef Q_OS_SYMBIAN + displayInfoPrivate()->release(); +#endif } /*! diff --git a/src/systeminfo/qsystemgeneralinfo.cpp b/src/systeminfo/qsystemgeneralinfo.cpp index b991f3f..0f25ddf 100644 --- a/src/systeminfo/qsystemgeneralinfo.cpp +++ b/src/systeminfo/qsystemgeneralinfo.cpp @@ -104,6 +104,9 @@ QSystemInfo::QSystemInfo(QObject *parent) : QObject(parent) , d(sysinfoPrivate()) { +#ifdef Q_OS_SYMBIAN + sysinfoPrivate()->acquire(); +#endif qRegisterMetaType("QSystemInfo::Version"); qRegisterMetaType("QSystemInfo::Feature"); } @@ -113,6 +116,9 @@ QSystemInfo::QSystemInfo(QObject *parent) */ QSystemInfo::~QSystemInfo() { +#ifdef Q_OS_SYMBIAN + sysinfoPrivate()->release(); +#endif } /*! diff --git a/src/systeminfo/qsysteminfo_s60.cpp b/src/systeminfo/qsysteminfo_s60.cpp index d0fda3e..a4531e6 100644 --- a/src/systeminfo/qsysteminfo_s60.cpp +++ b/src/systeminfo/qsysteminfo_s60.cpp @@ -95,6 +95,16 @@ const float KMMPerTwip = 0.0177f; //Milimeter Per Twip QTM_BEGIN_NAMESPACE +void DeviceInfoReferenceCountingMixin::acquire() +{ + DeviceInfo::instance()->acquire(); +} + +void DeviceInfoReferenceCountingMixin::release() +{ + DeviceInfo::instance()->release(); +} + QSystemInfoPrivate::QSystemInfoPrivate(QObject *parent) : QObject(parent) { @@ -416,7 +426,10 @@ bool QSystemInfoPrivate::hasFeatureSupported(QSystemInfo::Feature feature) QSystemNetworkInfoPrivate::QSystemNetworkInfoPrivate(QObject *parent) : QObject(parent) { - TRACES(qDebug() << "QSystemNetworkInfoPrivate::QSystemNetworkInfoPrivate<---"); + TRACES(qDebug() << "QSystemNetworkInfoPrivate::QSystemNetworkInfoPrivate<---"); + TRACES(qDebug() << "QSystemNetworkInfoPrivate::QSystemNetworkInfoPrivate()" + << ": QThread id = " << QThread::currentThread() + << "Symbian thread id = " << RThread().Id().Id()); DeviceInfo::instance()->cellSignalStrenghtInfo()->addObserver(this); DeviceInfo::instance()->cellNetworkInfo()->addObserver(this); DeviceInfo::instance()->cellNetworkRegistrationInfo()->addObserver(this); @@ -431,21 +444,15 @@ QSystemNetworkInfoPrivate::QSystemNetworkInfoPrivate(QObject *parent) connect(DeviceInfo::instance()->wlanInfo(), SIGNAL(wlanNetworkStatusChanged()), this, SLOT(wlanNetworkStatusChanged()));*/ DeviceInfo::instance()->subscriberInfo(); - TRACES(qDebug() << "QSystemNetworkInfoPrivate::QSystemNetworkInfoPrivate--->"); + TRACES(qDebug() << "QSystemNetworkInfoPrivate::QSystemNetworkInfoPrivate--->"); } QSystemNetworkInfoPrivate::~QSystemNetworkInfoPrivate() { - TRACES(qDebug() << "QSystemNetworkInfoPrivate::~QSystemNetworkInfoPrivate<--"); - - DeviceInfo::instance()->cellSignalStrenghtInfo()->removeObserver(this); - DeviceInfo::instance()->cellNetworkInfo()->removeObserver(this); - DeviceInfo::instance()->cellNetworkRegistrationInfo()->removeObserver(this); -#ifdef ETELMM_SUPPORTED - DeviceInfo::instance()->networkInfo()->removeObserver(this); -#endif - DeviceInfo::instance()->wlanInfo()->removeObserver(this); - TRACES(qDebug() << "QSystemNetworkInfoPrivate::~QSystemNetworkInfoPrivate-->"); + TRACES(qDebug() << "QSystemNetworkInfoPrivate::~QSystemNetworkInfoPrivate()" + << ": QThread id = " << QThread::currentThread() + << "Symbian thread id = " << RThread().Id().Id()); + TRACES(qDebug() << "QSystemNetworkInfoPrivate::~QSystemNetworkInfoPrivate-->"); } QSystemNetworkInfo::NetworkStatus QSystemNetworkInfoPrivate::networkStatus(QSystemNetworkInfo::NetworkMode mode) @@ -835,7 +842,7 @@ bool QSystemDisplayInfoPrivate::getSizeandRotation(int screen, TPixelsTwipsAndRo User::LeaveIfError(err = wsScreenDevice->Construct(screen)); wsScreenDevice->GetScreenModeSizeAndRotation(screen,sizeAndRotation); - qDebug() << "rotation" << sizeAndRotation.iRotation; + TRACES(qDebug() << "rotation" << sizeAndRotation.iRotation); CleanupStack::PopAndDestroy(2, &ws); ) @@ -1054,13 +1061,6 @@ QSystemStorageInfoPrivate::QSystemStorageInfoPrivate(QObject *parent) QSystemStorageInfoPrivate::~QSystemStorageInfoPrivate() { iFs.Close(); - DeviceInfo::instance()->mmcStorageStatus()->removeObserver(this); -#ifdef DISKNOTIFY_SUPPORTED - CStorageDiskNotifier* storageNotifier = DeviceInfo::instance()->storagedisknotifier(); - if (storageNotifier != NULL){ - storageNotifier->RemoveObserver(this); - } -#endif } qlonglong QSystemStorageInfoPrivate::totalDiskSpace(const QString &driveVolume) @@ -1250,21 +1250,10 @@ QSystemDeviceInfoPrivate::QSystemDeviceInfoPrivate(QObject *parent) #ifdef THERMALSTATUS_SUPPORTED DeviceInfo::instance()->thermalStatus()->addObserver(this); #endif - DeviceInfo::instance()->phoneInfo(); - DeviceInfo::instance()->subscriberInfo(); } QSystemDeviceInfoPrivate::~QSystemDeviceInfoPrivate() { - DeviceInfo::instance()->chargingStatus()->removeObserver(this); - DeviceInfo::instance()->batteryInfo()->removeObserver(this); -#ifdef LOCKANDFLIP_SUPPORTED - DeviceInfo::instance()->keylockStatus()->removeObserver(this); - DeviceInfo::instance()->flipStatus()->removeObserver(this); -#endif -#ifdef THERMALSTATUS_SUPPORTED - DeviceInfo::instance()->thermalStatus()->removeObserver(this); -#endif if (m_proEngNotifyHandler) { m_proEngNotifyHandler->CancelProfileActivationNotifications(); delete m_proEngNotifyHandler; @@ -1838,7 +1827,6 @@ QSystemBatteryInfoPrivate::QSystemBatteryInfoPrivate(QObject *parent) QSystemBatteryInfoPrivate::~QSystemBatteryInfoPrivate() { - DeviceInfo::instance()->batteryCommonInfo()->RemoveObserver(this); if (m_batteryHWRM) { delete(m_batteryHWRM); diff --git a/src/systeminfo/qsysteminfo_s60_p.h b/src/systeminfo/qsysteminfo_s60_p.h index 04a32d4..c253d2f 100644 --- a/src/systeminfo/qsysteminfo_s60_p.h +++ b/src/systeminfo/qsysteminfo_s60_p.h @@ -58,10 +58,12 @@ #include #include #include +#include #include "qmobilityglobal.h" #include "qsysteminfo.h" +#include #include #include "telephonyinfo_s60.h" #include "chargingstatus_s60.h" @@ -91,8 +93,15 @@ QTM_BEGIN_NAMESPACE const int KMaxBatteryBars = 7; //Max number of battery bars (7 is fixed for all symbian devices now) +class DeviceInfoReferenceCountingMixin +{ +public: + void acquire(); + void release(); +}; + //////// QSystemInfo -class QSystemInfoPrivate : public QObject +class QSystemInfoPrivate : public QObject, public DeviceInfoReferenceCountingMixin { Q_OBJECT @@ -117,7 +126,7 @@ private: }; //////// QSystemNetworkInfo -class QSystemNetworkInfoPrivate : public QObject, public MTelephonyInfoObserver, public MNetworkInfoObserver, public MWlanInfoObserver +class QSystemNetworkInfoPrivate : public QObject, public DeviceInfoReferenceCountingMixin, public MTelephonyInfoObserver, public MNetworkInfoObserver, public MWlanInfoObserver { Q_OBJECT @@ -183,7 +192,7 @@ protected: //from MTelephonyInfoObserver }; //////// QSystemDisplayInfo -class QSystemDisplayInfoPrivate : public QObject +class QSystemDisplayInfoPrivate : public QObject, public DeviceInfoReferenceCountingMixin { Q_OBJECT @@ -218,6 +227,7 @@ private: //////// QSystemStorageInfo class QSystemStorageInfoPrivate : public QObject, + public DeviceInfoReferenceCountingMixin, public MStorageStatusObserver #ifdef DISKNOTIFY_SUPPORTED ,public MStorageSpaceNotifyObserver @@ -269,6 +279,7 @@ class MProEngNotifyHandler; QTM_BEGIN_NAMESPACE class QSystemDeviceInfoPrivate : public QObject, + public DeviceInfoReferenceCountingMixin, public MTelephonyInfoObserver, public MProEngProfileActivationObserver, public MCenRepNotifyHandlerCallback, @@ -384,7 +395,7 @@ private: }; //////// QSystemScreenSaver -class QSystemScreenSaverPrivate : public QObject +class QSystemScreenSaverPrivate : public QObject, public DeviceInfoReferenceCountingMixin { Q_OBJECT @@ -409,11 +420,14 @@ class DeviceInfo public: static DeviceInfo *instance() { - if (!m_instance) - { - m_instance = new DeviceInfo; - } - return m_instance; + TRACES(qDebug() << "DeviceInfo::instance()" + << ": QThread id = " << QThread::currentThread() + << "Symbian thread id = " << RThread().Id().Id()); + if (!Dll::Tls()) + { + Dll::SetTls(new DeviceInfo()); + } + return static_cast(Dll::Tls()); } CPhoneInfo *phoneInfo() @@ -543,8 +557,23 @@ public: return m_networkInfo; } + void acquire() + { + m_referenceCount++; + } + + void release() + { + m_referenceCount--; + if (m_referenceCount < 1) + { + delete this; + Dll::FreeTls(); + } + } + private: - DeviceInfo() : m_phoneInfo(NULL), m_subscriberInfo(NULL), m_chargingStatus(NULL), + DeviceInfo() : m_referenceCount(0), m_phoneInfo(NULL), m_subscriberInfo(NULL), m_chargingStatus(NULL), m_batteryInfo(NULL), m_cellNetworkInfo(NULL), m_cellNetworkRegistrationInfo(NULL), m_cellSignalStrengthInfo(NULL), m_wlanInfo(NULL), m_mmcStorageStatus(NULL), m_batteryCommonInfo(NULL), m_networkInfo(NULL) #ifdef LOCKANDFLIP_SUPPORTED @@ -557,13 +586,19 @@ private: ,m_thermalStatus(NULL) #endif { - TRACES(qDebug() << "DeviceInfo():Constructor"); + TRACES(qDebug() << "DeviceInfo::DeviceInfo()" + << ": this = " << this + << ": QThread id = " << QThread::currentThread() + << "Symbian thread id = " << RThread().Id().Id()); m_telephony = CTelephony::NewL(); }; ~DeviceInfo() { - TRACES(qDebug() << "DeviceInfo():Destructor"); + TRACES(qDebug() << "DeviceInfo::~DeviceInfo()" + << ": this = " << this + << ": QThread id = " << QThread::currentThread() + << "Symbian thread id = " << RThread().Id().Id()); delete m_cellSignalStrengthInfo; delete m_cellNetworkRegistrationInfo; delete m_cellNetworkInfo; @@ -592,6 +627,7 @@ private: DeviceInfo(const DeviceInfo &); static DeviceInfo *m_instance; + int m_referenceCount; CTelephony *m_telephony; CPhoneInfo *m_phoneInfo; @@ -618,7 +654,7 @@ private: #endif }; -class QSystemBatteryInfoPrivate : public QObject, public MBatteryInfoObserver, public MBatteryHWRMObserver +class QSystemBatteryInfoPrivate : public QObject, public DeviceInfoReferenceCountingMixin, public MBatteryInfoObserver, public MBatteryHWRMObserver { Q_OBJECT public: diff --git a/src/systeminfo/qsystemnetworkinfo.cpp b/src/systeminfo/qsystemnetworkinfo.cpp index 95b9b77..98f95bb 100644 --- a/src/systeminfo/qsystemnetworkinfo.cpp +++ b/src/systeminfo/qsystemnetworkinfo.cpp @@ -154,6 +154,9 @@ QSystemNetworkInfo::QSystemNetworkInfo(QObject *parent) : QObject(parent) , d(netInfoPrivate()) { +#ifdef Q_OS_SYMBIAN + netInfoPrivate()->acquire(); +#endif qRegisterMetaType("QSystemNetworkInfo::NetworkMode"); qRegisterMetaType("QSystemNetworkInfo::NetworkStatus"); } @@ -163,6 +166,9 @@ QSystemNetworkInfo::QSystemNetworkInfo(QObject *parent) */ QSystemNetworkInfo::~QSystemNetworkInfo() { +#ifdef Q_OS_SYMBIAN + netInfoPrivate()->release(); +#endif } /*! diff --git a/src/systeminfo/qsystemscreensaver.cpp b/src/systeminfo/qsystemscreensaver.cpp index 3bfe151..2867c16 100644 --- a/src/systeminfo/qsystemscreensaver.cpp +++ b/src/systeminfo/qsystemscreensaver.cpp @@ -62,6 +62,9 @@ QSystemScreenSaver::QSystemScreenSaver(QObject *parent) : QObject(parent) { d = new QSystemScreenSaverPrivate(parent); +#ifdef Q_OS_SYMBIAN + d->acquire(); +#endif } /*! @@ -69,6 +72,9 @@ QSystemScreenSaver::QSystemScreenSaver(QObject *parent) */ QSystemScreenSaver::~QSystemScreenSaver() { +#ifdef Q_OS_SYMBIAN + d->release(); +#endif delete d; } diff --git a/src/systeminfo/qsystemstorageinfo.cpp b/src/systeminfo/qsystemstorageinfo.cpp index 63b8e0b..8dbc5e6 100644 --- a/src/systeminfo/qsystemstorageinfo.cpp +++ b/src/systeminfo/qsystemstorageinfo.cpp @@ -107,6 +107,9 @@ QSystemStorageInfo::QSystemStorageInfo(QObject *parent) : QObject(parent) , d(storageInfoPrivate()) { +#ifdef Q_OS_SYMBIAN + storageInfoPrivate()->acquire(); +#endif qRegisterMetaType("QSystemStorageInfo::DriveType"); qRegisterMetaType("QSystemStorageInfo::StorageState"); } @@ -116,6 +119,9 @@ QSystemStorageInfo::QSystemStorageInfo(QObject *parent) */ QSystemStorageInfo::~QSystemStorageInfo() { +#ifdef Q_OS_SYMBIAN + storageInfoPrivate()->release(); +#endif } /*! diff --git a/src/systeminfo/symbian/networkinfo_s60.cpp b/src/systeminfo/symbian/networkinfo_s60.cpp index bc25c67..8967744 100644 --- a/src/systeminfo/symbian/networkinfo_s60.cpp +++ b/src/systeminfo/symbian/networkinfo_s60.cpp @@ -71,6 +71,8 @@ iConstructed(EFalse), iObserver(NULL),iDynCaps(0),iPacketdataserviceCaps(true) User::LeaveIfError(err); ) + CleanupClosePushL(iMobilePhone); + #ifdef ETELPACKETSERVICE_SUPPORTED TRAP_IGNORE( TInt packetserviceerr = iPacketService.Open(iMobilePhone); @@ -86,17 +88,18 @@ iConstructed(EFalse), iObserver(NULL),iDynCaps(0),iPacketdataserviceCaps(true) { iConstructed = ETrue; } + CleanupStack::Pop(&iMobilePhone); CleanupStack::Pop(&iTelServer); TRACES(qDebug() << "CNetworkBase::CNetworkBase--->"); } CNetworkBase::~CNetworkBase() { - iMobilePhone.Close(); - iTelServer.Close(); #ifdef ETELPACKETSERVICE_SUPPORTED iPacketService.Close(); #endif + iMobilePhone.Close(); + iTelServer.Close(); } void CNetworkBase::AddObserver(MNetworkObserver *aObserver) @@ -129,7 +132,7 @@ CNetworkMode::CNetworkMode() } CNetworkMode::~CNetworkMode() { - DoCancel(); + Cancel(); } void CNetworkMode::DoCancel() @@ -312,11 +315,18 @@ void CPacketDataStatus::StartMonitoring() CNetworkInfo::CNetworkInfo():iCellDataTechnology(KDefaultBearer) { //Add observers - iNetStat.Add(this); iNetMode.Add(this); + iNetStat.Add(this); if ( iPacketDataStatus.NetworkCtrlCapsenabled() == true ) iPacketDataStatus.Add(this); } +CNetworkInfo::~CNetworkInfo() + { + iNetMode.Remove(); + iNetStat.Remove(); + iPacketDataStatus.Remove(); + } + RMobilePhone::TMobilePhoneNetworkMode CNetworkInfo::GetMode() const { return iNetMode.GetMode(); diff --git a/src/systeminfo/symbian/networkinfo_s60.h b/src/systeminfo/symbian/networkinfo_s60.h index 9390189..3997869 100644 --- a/src/systeminfo/symbian/networkinfo_s60.h +++ b/src/systeminfo/symbian/networkinfo_s60.h @@ -110,7 +110,7 @@ public : void Add(MNetworkObserver *aObserver) { AddObserver(aObserver);} ; void Remove() {RemoveObserver();}; -private : //From CNetworkBase +protected: //From CNetworkBase virtual void DoCancel(); virtual void RunL() ; virtual void StartMonitoring(); @@ -145,7 +145,7 @@ public: void Add(MNetworkObserver *aObserver) { AddObserver(aObserver);} ; void Remove() {RemoveObserver();}; -private : //From CNetworkBase +protected : //From CNetworkBase virtual void DoCancel(); virtual void RunL() ; virtual void StartMonitoring(); @@ -182,7 +182,7 @@ class CPacketDataStatus : private CNetworkBase void Add(MNetworkObserver *aObserver) { AddObserver(aObserver);} ; void Remove() {RemoveObserver();}; bool NetworkCtrlCapsenabled(); - private : //From CNetworkBase + protected: //From CNetworkBase virtual void DoCancel(); virtual void RunL() ; virtual void StartMonitoring(); @@ -190,13 +190,6 @@ class CPacketDataStatus : private CNetworkBase class CNetworkInfo : public CBase, public MNetworkObserver { -private : - CNetworkMode iNetMode; - CNetworkStatus iNetStat; - CPacketDataStatus iPacketDataStatus; - QList iObservers; - TUint32 iCellDataTechnology; - protected : virtual void ChangedNetworkMode() ; virtual void ChangedNetworkStatus(); @@ -204,7 +197,7 @@ protected : public : CNetworkInfo(); - //~CNetworkInfo(); + ~CNetworkInfo(); void addObserver(MNetworkInfoObserver *aObserver); void removeObserver(MNetworkInfoObserver *aObserver); RMobilePhone::TMobilePhoneNetworkMode GetMode() const; @@ -213,6 +206,13 @@ public : #endif TUint32 GetCapability () const; TUint CellDataTechnology(); + +private : + CNetworkMode iNetMode; + CNetworkStatus iNetStat; + CPacketDataStatus iPacketDataStatus; + QList iObservers; + TUint32 iCellDataTechnology; }; diff --git a/src/systeminfo/symbian/pubandsubkey_s60.cpp b/src/systeminfo/symbian/pubandsubkey_s60.cpp index 53ee756..8d4998f 100644 --- a/src/systeminfo/symbian/pubandsubkey_s60.cpp +++ b/src/systeminfo/symbian/pubandsubkey_s60.cpp @@ -61,7 +61,7 @@ CPubSubKeyHandler::CPubSubKeyHandler(const TUid aCategory, const TUint aKey, MCo CPubSubKeyHandler::~CPubSubKeyHandler() { - DoCancel(); + Cancel(); iProperty.Close(); } diff --git a/src/systeminfo/symbian/storagedisknotifier_s60.cpp b/src/systeminfo/symbian/storagedisknotifier_s60.cpp index a3b0cba..eb9c810 100644 --- a/src/systeminfo/symbian/storagedisknotifier_s60.cpp +++ b/src/systeminfo/symbian/storagedisknotifier_s60.cpp @@ -66,8 +66,8 @@ CStorageDiskNotifier::CStorageDiskNotifier() CStorageDiskNotifier::~CStorageDiskNotifier() { - iFs.Close(); delete iStorageDiskNotifyHandler; + iFs.Close(); } void CStorageDiskNotifier::AddObserver(MStorageSpaceNotifyObserver *observer) diff --git a/src/systeminfo/symbian/telephonyinfo_s60.cpp b/src/systeminfo/symbian/telephonyinfo_s60.cpp index de2f1e4..a32b16b 100644 --- a/src/systeminfo/symbian/telephonyinfo_s60.cpp +++ b/src/systeminfo/symbian/telephonyinfo_s60.cpp @@ -55,7 +55,6 @@ CTelephonyInfo::CTelephonyInfo(CTelephony &telephony) : CActive(EPriorityStandar CTelephonyInfo::~CTelephonyInfo() { - Cancel(); delete m_wait; } @@ -103,6 +102,11 @@ CPhoneInfo::CPhoneInfo(CTelephony &telephony) : CTelephonyInfo(telephony), TRACES (qDebug() << "CPhoneInfo::CPhoneInfo--->"); } +CPhoneInfo::~CPhoneInfo() +{ + Cancel(); +} + void CPhoneInfo::DoCancel() { m_telephony.CancelAsync(CTelephony::EGetPhoneIdCancel); @@ -135,6 +139,11 @@ CSubscriberInfo::CSubscriberInfo(CTelephony &telephony) : CTelephonyInfo(telepho TRACES (qDebug() << "CSubscriberInfo::CSubscriberInfo--->"); } +CSubscriberInfo::~CSubscriberInfo() +{ + Cancel(); +} + void CSubscriberInfo::DoCancel() { m_telephony.CancelAsync(CTelephony::EGetSubscriberIdCancel); @@ -160,6 +169,11 @@ CBatteryInfo::CBatteryInfo(CTelephony &telephony) : CTelephonyInfo(telephony), TRACES (qDebug() << "CBatteryInfo::CBatteryInfo--->"); } +CBatteryInfo::~CBatteryInfo() +{ + Cancel(); +} + void CBatteryInfo::RunL() { TRACES (qDebug() << "CBatteryInfo::RunL<---"); @@ -242,6 +256,11 @@ CCellNetworkInfo::CCellNetworkInfo(CTelephony &telephony) : CTelephonyInfo(telep TRACES (qDebug() << "CCellNetworkInfo::CCellNetworkInfo--->"); } +CCellNetworkInfo::~CCellNetworkInfo() +{ + Cancel(); +} + void CCellNetworkInfo::RunL() { TRACES (qDebug() << "CCellNetworkInfo::RunL<---"); @@ -410,6 +429,11 @@ CCellNetworkRegistrationInfo::CCellNetworkRegistrationInfo(CTelephony &telephony TRACES (qDebug() << "CCellNetworkRegistrationInfo::CCellNetworkRegistrationInfo<---"); } +CCellNetworkRegistrationInfo::~CCellNetworkRegistrationInfo() +{ + Cancel(); +} + void CCellNetworkRegistrationInfo::RunL() { TRACES (qDebug() << "CCellNetworkRegistrationInfo::RunL<---"); @@ -474,6 +498,11 @@ CCellSignalStrengthInfo::CCellSignalStrengthInfo(CTelephony &telephony) : CTelep TRACES (qDebug() << "CCellSignalStrengthInfo::CCellSignalStrengthInfo--->"); } +CCellSignalStrengthInfo::~CCellSignalStrengthInfo() +{ + Cancel(); +} + void CCellSignalStrengthInfo::RunL() { TRACES (qDebug() << "CCellSignalStrengthInfo::RunL<---"); diff --git a/src/systeminfo/symbian/telephonyinfo_s60.h b/src/systeminfo/symbian/telephonyinfo_s60.h index 9976cf0..a383ca4 100644 --- a/src/systeminfo/symbian/telephonyinfo_s60.h +++ b/src/systeminfo/symbian/telephonyinfo_s60.h @@ -90,6 +90,7 @@ class CPhoneInfo : public CTelephonyInfo { public: CPhoneInfo(CTelephony &telephony); + ~CPhoneInfo(); protected: void DoCancel(); @@ -112,6 +113,7 @@ class CSubscriberInfo : public CTelephonyInfo { public: CSubscriberInfo(CTelephony &telephony); + ~CSubscriberInfo(); protected: void DoCancel(); @@ -130,6 +132,7 @@ class CBatteryInfo : public CTelephonyInfo { public: CBatteryInfo(CTelephony &telephony); + ~CBatteryInfo(); void startMonitoring(); protected: @@ -153,6 +156,7 @@ class CCellNetworkInfo : public CTelephonyInfo { public: CCellNetworkInfo(CTelephony &telephony); + ~CCellNetworkInfo(); void startMonitoring(); protected: @@ -197,6 +201,7 @@ class CCellNetworkRegistrationInfo : public CTelephonyInfo { public: CCellNetworkRegistrationInfo(CTelephony &telephony); + ~CCellNetworkRegistrationInfo(); void startMonitoring(); protected: @@ -220,6 +225,7 @@ class CCellSignalStrengthInfo : public CTelephonyInfo { public: CCellSignalStrengthInfo(CTelephony &telephony); + ~CCellSignalStrengthInfo(); void startMonitoring(); protected: diff --git a/src/systeminfo/symbian/thermalstatus_s60.cpp b/src/systeminfo/symbian/thermalstatus_s60.cpp index c6028f7..e04a5b2 100644 --- a/src/systeminfo/symbian/thermalstatus_s60.cpp +++ b/src/systeminfo/symbian/thermalstatus_s60.cpp @@ -73,6 +73,7 @@ CThermalStatus::CThermalStatus() : CActive(EPriorityStandard), CThermalStatus::~CThermalStatus() { TRACES(qDebug() << "CThermalStatus::~CThermalStatus()";) + Cancel(); } void CThermalStatus::addObserver(MThermalStatusObserver *observer) diff --git a/src/systeminfo/symbian/tsrc/tst_qsysteminfo_s60_p/tst_qsysteminfo_s60_p.cpp b/src/systeminfo/symbian/tsrc/tst_qsysteminfo_s60_p/tst_qsysteminfo_s60_p.cpp new file mode 100644 index 0000000..f272f7a --- /dev/null +++ b/src/systeminfo/symbian/tsrc/tst_qsysteminfo_s60_p/tst_qsysteminfo_s60_p.cpp @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 +#include "qsysteminfo_s60_p.h" + +class tst_DeviceInfo : public QObject +{ + Q_OBJECT +private slots: + void init(); + void cleanup(); + void tst_phoneInfo(); + void tst_subscriberInfo(); + void tst_chargingStatus(); + void tst_batteryInfo(); + void tst_cellNetworkInfo(); + void tst_cellNetworkRegistrationInfo(); + void tst_cellSignalStrenghtInfo(); + void tst_wlanInfo(); + void tst_mmcStorageStatus(); +#ifdef DISKNOTIFY_SUPPORTED + void tst_storagedisknotifier(); +#endif +#ifdef LOCKANDFLIP_SUPPORTED + void tst_keylockStatus(); + void tst_flipStatus(); +#endif +#ifdef THERMALSTATUS_SUPPORTED + void tst_thermalStatus(); +#endif + void tst_batteryCommonInfo(); + void tst_networkInfo(); + +private: + QtMobility::DeviceInfo* deviceInfo; +}; + +static TAny* gPtr = 0; +TInt Dll::SetTls(TAny* aPtr) +{ + gPtr = aPtr; + return 0; +} + +TAny* Dll::Tls() +{ + return gPtr; +} + +void Dll::FreeTls() +{ + gPtr = 0; +} + +void tst_DeviceInfo::init() { + deviceInfo = QtMobility::DeviceInfo::instance(); + deviceInfo->acquire(); +} + +void tst_DeviceInfo::cleanup() +{ + deviceInfo->release(); + QVERIFY(Dll::Tls() == NULL); + deviceInfo = NULL; +} + +void tst_DeviceInfo::tst_phoneInfo() { + deviceInfo->phoneInfo(); +} + +void tst_DeviceInfo::tst_subscriberInfo() { + deviceInfo->subscriberInfo(); +} + +void tst_DeviceInfo::tst_chargingStatus() { + deviceInfo->chargingStatus(); +} + +void tst_DeviceInfo::tst_batteryInfo() { + deviceInfo->batteryInfo(); +} + +void tst_DeviceInfo::tst_cellNetworkInfo() { + deviceInfo->cellNetworkInfo(); +} + +void tst_DeviceInfo::tst_cellNetworkRegistrationInfo() { + deviceInfo->cellNetworkRegistrationInfo(); +} + +void tst_DeviceInfo::tst_cellSignalStrenghtInfo() { + deviceInfo->cellSignalStrenghtInfo(); +} + +void tst_DeviceInfo::tst_wlanInfo() { + deviceInfo->wlanInfo(); +} + +void tst_DeviceInfo::tst_mmcStorageStatus() { + deviceInfo->mmcStorageStatus(); +} + +#ifdef DISKNOTIFY_SUPPORTED +void tst_DeviceInfo::tst_storagedisknotifier() { + deviceInfo->storagedisknotifier(); +} +#endif + +#ifdef LOCKANDFLIP_SUPPORTED +void tst_DeviceInfo::tst_keylockStatus() { + deviceInfo->keylockStatus(); +} + +void tst_DeviceInfo::tst_flipStatus() { + deviceInfo->flipStatus(); +} +#endif + +#ifdef THERMALSTATUS_SUPPORTED +void tst_DeviceInfo::tst_thermalStatus() { + deviceInfo->thermalStatus(); +} +#endif + +void tst_DeviceInfo::tst_batteryCommonInfo() { + deviceInfo->batteryCommonInfo(); +} + +void tst_DeviceInfo::tst_networkInfo() { + deviceInfo->networkInfo(); +} + +QTEST_MAIN(tst_DeviceInfo) +#include "tst_qsysteminfo_s60_p.moc" diff --git a/src/systeminfo/symbian/tsrc/tst_qsysteminfo_s60_p/tst_qsysteminfo_s60_p.pro b/src/systeminfo/symbian/tsrc/tst_qsysteminfo_s60_p/tst_qsysteminfo_s60_p.pro new file mode 100644 index 0000000..de48fb8 --- /dev/null +++ b/src/systeminfo/symbian/tsrc/tst_qsysteminfo_s60_p/tst_qsysteminfo_s60_p.pro @@ -0,0 +1,126 @@ +TEMPLATE = app + +TARGET = tst_qsysteminfo_s60_p + +QT += testlib + +CONFIG += qtestlib +CONFIG += console + +include(../../../../../common.pri) + +symbian: +{ + INCLUDEPATH += ../../ ../../../ + VPATH += ../../ + HEADERS += qsysteminfo_s60_p.h + SOURCES += tst_qsysteminfo_s60_p.cpp + + # From systeminfo.pro + contains(S60_VERSION, 3.1) { + DEFINES += SYMBIAN_3_1 + } + + contains(S60_VERSION, 5.2) { + DEFINES += SYMBIAN_3_PLATFORM + } + + contains(LockandFlipPSkeys_enabled, yes) { + message("LockandFlipPSKeys available") + DEFINES += LOCKANDFLIP_SUPPORTED + SOURCES += lockandflipstatus_s60.cpp + HEADERS += lockandflipstatus_s60.h + } + + contains(FmTxClient_enabled, yes) { + message("FmTxClient available") + DEFINES += FMTXCLIENT_SUPPORTED + LIBS += -lhwrmfmtxclient + } + + contains(DiskNotifyClient_enabled, yes) { + message("DiskNotiferClient available") + DEFINES += DISKNOTIFY_SUPPORTED + LIBS += -ldisknotifyhandler + SOURCES += storagedisknotifier_s60.cpp + HEADERS += storagedisknotifier_s60.h + } + + contains(hb_symbian_enabled, yes) { + ## for symbian ^4 + CONFIG += qt hb + DEFINES += HB_SUPPORTED + message("s60_HbKeymap enabled") + LIBS += -lhbcore + } else { + LIBS += -lptiengine + } + + INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE + DEPENDPATH += symbian + + SOURCES += \ + #qsysteminfo_s60.cpp \ + telephonyinfo_s60.cpp \ + chargingstatus_s60.cpp \ + wlaninfo_s60.cpp \ + storagestatus_s60.cpp \ + pubandsubkey_s60.cpp \ + batterystatus_s60.cpp \ + networkinfo_s60.cpp + + HEADERS += \ + #qsysteminfo_s60_p.h \ + telephonyinfo_s60.h \ + chargingstatus_s60.h \ + wlaninfo_s60.h \ + storagestatus_s60.h \ + pubandsubkey_s60.h \ + batterystatus_s60.h \ + networkinfo_s60.h + + LIBS += \ + -lprofileengine \ + -letel3rdparty \ + -lsysutil \ + -lcentralrepository \ + -lcenrepnotifhandler \ + -lefsrv \ + -lfeatdiscovery \ + -lhwrmvibraclient \ + -lavkon \ #Used by AknLayoutUtils::PenEnabled(). Try to remove this dependency. + -lcone \ + -lws32 \ + -lcentralrepository \ + -lbluetooth \ + -lgdi \ + -lecom \ + -lplatformenv \ + -lhwrmlightclient \ + -letel + + contains(S60_VERSION, 5.1) | contains(S60_VERSION, 5.2) { + LIBS += -lhwrmpowerclient -lusbman + } + + contains(symbiancntsim_enabled, yes) { + LIBS += -letelmm + DEFINES += ETELMM_SUPPORTED + message("ETELMM enabled") + } + + contains(etelpacketservice_symbian_enabled, yes) { + message("etel packet service enabled") + LIBS += -letelpckt + DEFINES += ETELPACKETSERVICE_SUPPORTED + } + + contains(thermalstatus_symbian_enabled, yes) { + DEFINES += THERMALSTATUS_SUPPORTED + SOURCES += thermalstatus_s60.cpp + HEADERS += thermalstatus_s60.h + message("Thermalstatus enabled") + } + + TARGET.CAPABILITY = ALL -TCB +} diff --git a/src/systeminfo/symbian/wlaninfo_s60.cpp b/src/systeminfo/symbian/wlaninfo_s60.cpp index 2dbf6f0..6bf52d3 100644 --- a/src/systeminfo/symbian/wlaninfo_s60.cpp +++ b/src/systeminfo/symbian/wlaninfo_s60.cpp @@ -72,6 +72,7 @@ CWlanInfo::CWlanInfo() : CActive(EPriorityStandard), CWlanInfo::~CWlanInfo() { + Cancel(); } void CWlanInfo::addObserver(MWlanInfoObserver *observer)