src/systeminfo/qsysteminfo_s60.cpp
changeset 0 876b1a06bc25
child 5 603d3f8b6302
equal deleted inserted replaced
-1:000000000000 0:876b1a06bc25
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 #include "qsysteminfo.h"
       
    42 #include "qsysteminfo_s60_p.h"
       
    43 
       
    44 #include <QStringList>
       
    45 #include <QDir>
       
    46 #include <QRegExp>
       
    47 #include <QTimer>
       
    48 #include <QList>
       
    49 
       
    50 #include <sysutil.h>
       
    51 #ifdef HB_SUPPORTED
       
    52 #include <hbinputkeymapfactory.h>
       
    53 #include <hbinputlanguage.h>
       
    54 #else
       
    55 #include <ptiengine.h>
       
    56 #endif // HB_SUPPORTED
       
    57 #include <featdiscovery.h>
       
    58 #ifndef KFeatureIdMmc
       
    59 #include <featureinfo.h>
       
    60 #endif
       
    61 #include <hwrmvibra.h>
       
    62 #include <AknUtils.h>
       
    63 #include <w32std.h>
       
    64 #include <centralrepository.h>
       
    65 #include <MProEngEngine.h>
       
    66 #include <ProEngFactory.h>
       
    67 #include <MProEngNotifyHandler.h>
       
    68 #include <btserversdkcrkeys.h>
       
    69 #include <bt_subscribe.h>
       
    70 #include <bttypes.h>
       
    71 #include <etel3rdparty.h>
       
    72 #include <aknkeylock.h>
       
    73 #define RD_STARTUP_CHANGE
       
    74 #include <startupdomainpskeys.h>
       
    75 
       
    76 QTM_BEGIN_NAMESPACE
       
    77 
       
    78 QSystemInfoPrivate::QSystemInfoPrivate(QObject *parent)
       
    79     : QObject(parent)
       
    80 {
       
    81 }
       
    82 
       
    83 QSystemInfoPrivate::~QSystemInfoPrivate()
       
    84 {
       
    85 }
       
    86 
       
    87 QString QSystemInfoPrivate::currentLanguage() const
       
    88 {
       
    89     return TLanguageToISO639_1(User::Language());
       
    90 }
       
    91 
       
    92 #ifdef HB_SUPPORTED
       
    93 QStringList QSystemInfoPrivate::availableLanguages() const
       
    94 {
       
    95     QStringList languages;
       
    96     QList<HbInputLanguage> hblanguages = HbKeymapFactory::availableLanguages();
       
    97     foreach(HbInputLanguage lang, hblanguages) {       
       
    98         QString language = QLocaleToISO639_1(lang.language());
       
    99         if (!language.isEmpty()) {
       
   100             languages << language;
       
   101         }
       
   102     }
       
   103     languages.removeDuplicates();
       
   104     return languages;
       
   105 }  
       
   106 #else
       
   107 QStringList QSystemInfoPrivate::availableLanguages() const
       
   108 {
       
   109     QStringList languages;
       
   110     TRAP_IGNORE(
       
   111         CPtiEngine *ptiEngine = CPtiEngine::NewL();
       
   112         CleanupStack::PushL(ptiEngine);
       
   113         RArray<TInt> languageCodes;
       
   114         CleanupClosePushL(languageCodes);
       
   115         ptiEngine->GetAvailableLanguagesL(languageCodes);
       
   116         for (int i = 0; i < languageCodes.Count(); ++i) {
       
   117             QString language = TLanguageToISO639_1(TLanguage(languageCodes[i]));
       
   118             if (!language.isEmpty()) {
       
   119                 languages << language;
       
   120             }
       
   121         }
       
   122         CleanupStack::PopAndDestroy(2, ptiEngine);
       
   123     )
       
   124     languages.removeDuplicates();
       
   125     return languages;
       
   126 }
       
   127 #endif //HB_SUPPORTED
       
   128 
       
   129 QString QSystemInfoPrivate::QLocaleToISO639_1(QLocale::Language language) const    
       
   130 {
       
   131        switch(language) {
       
   132        case QLocale::English: return "en";
       
   133        case QLocale::Lithuanian: return "lt";
       
   134        case QLocale::Malay: return "ms";
       
   135        case QLocale::Polish: return "pl";
       
   136        case QLocale::Portuguese: return "pt";
       
   137        case QLocale::Romanian: return "ro";
       
   138        case QLocale::Serbian: return "sr";
       
   139        case QLocale::Slovak: return "sk";
       
   140        case QLocale::Slovenian: return "sl";
       
   141        case QLocale::Spanish: return "es";
       
   142        case QLocale::Swedish: return "sv";
       
   143        case QLocale::Tagalog: return "tl";
       
   144        case QLocale::Czech: return "cs";
       
   145        case QLocale::Dutch: return "nl";
       
   146        case QLocale::Turkish: return "tr";
       
   147        case QLocale::Estonian: return "et";
       
   148        case QLocale::French: return "fr";
       
   149        case QLocale::Greek: return "el";
       
   150        case QLocale::Icelandic: return "is";
       
   151        case QLocale::Indonesian: return "id";
       
   152        case QLocale::Italian: return "it";
       
   153        case QLocale::Latvian: return "lv";
       
   154        case QLocale::Croatian: return "hr";
       
   155        case QLocale::German: return "de";
       
   156        case QLocale::Hungarian: return "hu";
       
   157        case QLocale::Bulgarian: return "bg";
       
   158        case QLocale::Finnish: return "fi";
       
   159        case QLocale::Russian: return "ru";
       
   160        case QLocale::Danish: return "da";
       
   161        case QLocale::Norwegian: return "no";
       
   162        case QLocale::Ukrainian: return "uk";
       
   163        case QLocale::Arabic: return "ar";
       
   164        case QLocale::Hebrew: return "he";
       
   165        case QLocale::Thai: return "th";
       
   166        case QLocale::Japanese: return "ja";
       
   167        case QLocale::Vietnamese: return "vi";
       
   168        case QLocale::Persian: return "fa";
       
   169        case QLocale::Hindi: return "hi";
       
   170        case QLocale::Urdu: return "ur";
       
   171        case QLocale::Catalan: return "ca";
       
   172        case QLocale::Galician: return "gl";
       
   173        case QLocale::Basque: return "eu";
       
   174        case QLocale::Marathi: return "mr";
       
   175        case QLocale::Korean: return "ko";       
       
   176        default:
       
   177            break;
       
   178        }
       
   179     return "";        
       
   180 }
       
   181 
       
   182 QString QSystemInfoPrivate::TLanguageToISO639_1(TLanguage language) const
       
   183 {
       
   184     switch (language) {
       
   185         case ELangAmerican:
       
   186         case ELangCanadianEnglish:
       
   187         case ELangInternationalEnglish:
       
   188         case ELangSouthAfricanEnglish:
       
   189         case ELangAustralian:
       
   190         case ELangEnglish: return "en";
       
   191         case ELangSwissFrench:
       
   192         case ELangInternationalFrench:
       
   193         case ELangCanadianFrench:
       
   194         case ELangBelgianFrench:
       
   195         case ELangFrench: return "fr";
       
   196         case ELangSwissGerman:
       
   197         case ELangAustrian:
       
   198         case ELangGerman: return "de";
       
   199         case ELangInternationalSpanish:
       
   200         case ELangLatinAmericanSpanish:
       
   201         case ELangSpanish: return "es";
       
   202         case ELangSwissItalian:
       
   203         case ELangItalian: return "it";
       
   204         case ELangFinlandSwedish:
       
   205         case ELangSwedish: return "sv";
       
   206         case ELangDanish: return "da";
       
   207         case ELangNorwegian: return "no";
       
   208         case ELangFinnish: return "fi";
       
   209         case ELangBrazilianPortuguese:
       
   210         case ELangPortuguese: return "pt";
       
   211         case ELangCyprusTurkish:
       
   212         case ELangTurkish: return "tr";
       
   213         case ELangIcelandic: return "is";
       
   214         case ELangRussian: return "ru";
       
   215         case ELangHungarian: return "hu";
       
   216         case ELangBelgianFlemish:
       
   217         case ELangDutch: return "nl";
       
   218         case ELangNewZealand: return "mi";  //Maori
       
   219         case ELangCzech: return "cs";
       
   220         case ELangSlovak: return "sk";
       
   221         case ELangPolish: return "pl";
       
   222         case ELangSlovenian: return "sl";
       
   223         case ELangTaiwanChinese:
       
   224         case ELangHongKongChinese:
       
   225         case ELangPrcChinese: return "zh";
       
   226         case ELangJapanese: return "ja";
       
   227         case ELangThai: return "th";
       
   228         case ELangAfrikaans: return "af";
       
   229         case ELangAlbanian: return "sq";
       
   230         case ELangAmharic: return "am";
       
   231         case ELangArabic: return "ar";
       
   232         case ELangArmenian: return "hy";
       
   233         case ELangTagalog: return "tl";
       
   234         case ELangBelarussian: return "be";
       
   235         case ELangBengali:  return "bn";
       
   236         case ELangBulgarian: return "bg";
       
   237         case ELangBurmese: return "my";
       
   238         case ELangCatalan: return "ca";
       
   239         case ELangCroatian: return "hr";
       
   240         case ELangEstonian: return "et";
       
   241         case ELangFarsi: return "fa";
       
   242         case ELangScotsGaelic: return "gd";
       
   243         case ELangGeorgian: return "ka";
       
   244         case ELangGreek:
       
   245         case ELangCyprusGreek: return "el";
       
   246         case ELangGujarati: return "gu";
       
   247         case ELangHebrew: return "he";
       
   248         case ELangHindi: return "hi";
       
   249         case ELangIndonesian: return "id";
       
   250         case ELangIrish: return "ga";
       
   251         case ELangKannada: return "kn";
       
   252         case ELangKazakh: return "kk";
       
   253         case ELangKhmer: return "km";
       
   254         case ELangKorean: return "ko";
       
   255         case ELangLao: return "lo";
       
   256         case ELangLatvian: return "lv";
       
   257         case ELangLithuanian: return "lt";
       
   258         case ELangMacedonian: return "mk";
       
   259         case ELangMalay: return "ms";
       
   260         case ELangMalayalam: return "ml";
       
   261         case ELangMarathi: return "mr";
       
   262         case ELangMoldavian: return "ro";
       
   263         case ELangMongolian: return "mn";
       
   264         case ELangNorwegianNynorsk: return "nn";
       
   265         case ELangPunjabi: return "pa";
       
   266         case ELangRomanian: return "ro";
       
   267         case ELangSerbian: return "sr";
       
   268         case ELangSomali: return "so";
       
   269         case ELangSwahili: return "sw";
       
   270         case ELangTamil: return "ta";
       
   271         case ELangTelugu: return "te";
       
   272         case ELangTibetan: return "bo";
       
   273         case ELangTigrinya: return "ti";
       
   274         case ELangTurkmen: return "tk";
       
   275         case ELangUkrainian: return "uk";
       
   276         case ELangUrdu: return "ur";
       
   277         case ELangVietnamese: return "vi";
       
   278         case ELangWelsh: return "cy";
       
   279         case ELangZulu: return "zu";
       
   280         case ELangSinhalese: return "si";
       
   281         case ELangTest:
       
   282         case ELangReserved1:
       
   283         case ELangReserved2:
       
   284         case ELangOther:
       
   285         case ELangNone:
       
   286         default:
       
   287             break;
       
   288     }
       
   289     return "";
       
   290 }
       
   291 
       
   292 QString QSystemInfoPrivate::version(QSystemInfo::Version type,  const QString & /*parameter*/)
       
   293 {
       
   294     switch (type) {
       
   295         case QSystemInfo::Os:
       
   296         {
       
   297             return S60Version();
       
   298         }
       
   299         case QSystemInfo::QtCore:
       
   300         {
       
   301             return qVersion();
       
   302         }
       
   303         case QSystemInfo::Firmware:
       
   304         {
       
   305             QString versionText;
       
   306             TBuf<KSysUtilVersionTextLength> versionBuf;
       
   307             if (SysUtil::GetSWVersion(versionBuf) == KErrNone) {
       
   308                 versionText = QString::fromUtf16(versionBuf.Ptr(), versionBuf.Length());
       
   309             }
       
   310             return versionText.split("\n").at(0);
       
   311         }
       
   312         default:
       
   313             return QString();
       
   314     }
       
   315 }
       
   316 
       
   317 QString QSystemInfoPrivate::S60Version() const
       
   318 {
       
   319     QDir romInstallDir("z:\\system\\install\\");
       
   320     QStringList files = romInstallDir.entryList(QStringList("Series60v*.sis"), QDir::Files, QDir::Name | QDir::Reversed);
       
   321     if (files.size() > 0) {
       
   322         QRegExp rx("Series60v(.*).sis");
       
   323         if (rx.indexIn(files[0]) > -1) {
       
   324             return rx.cap(1);
       
   325         }
       
   326     }
       
   327     return QString();
       
   328 }
       
   329 
       
   330 QString QSystemInfoPrivate::currentCountryCode() const
       
   331 {
       
   332     return QLocale::system().name().mid(3,2);
       
   333 }
       
   334 
       
   335 
       
   336 bool QSystemInfoPrivate::hasFeatureSupported(QSystemInfo::Feature feature)
       
   337 {
       
   338     TInt featureId = 0;
       
   339     switch (feature) {
       
   340         case QSystemInfo::BluetoothFeature: featureId = KFeatureIdBt; break;
       
   341         case QSystemInfo::CameraFeature: featureId = KFeatureIdCamera; break;
       
   342         case QSystemInfo::IrFeature: featureId = KFeatureIdIrda; break;
       
   343         case QSystemInfo::MemcardFeature: featureId = KFeatureIdMmc; break;
       
   344         case QSystemInfo::UsbFeature: featureId = KFeatureIdUsb; break;
       
   345         case QSystemInfo::WlanFeature: featureId = KFeatureIdProtocolWlan; break;
       
   346         case QSystemInfo::LocationFeature: featureId = KFeatureIdLocationFrameworkCore; break;
       
   347         case QSystemInfo::SimFeature:
       
   348         {
       
   349             return true;    //Always true in S60
       
   350         }
       
   351         case QSystemInfo::VibFeature:
       
   352         {
       
   353             TRAPD(err,
       
   354                 //Leaves with KErrNotSupported if device doesn't support vibration feature.
       
   355                 CHWRMVibra *vibra = CHWRMVibra::NewLC();
       
   356                 CleanupStack::PopAndDestroy(vibra);
       
   357             )
       
   358             return err == KErrNone;
       
   359         }
       
   360         case QSystemInfo::HapticsFeature:
       
   361         {
       
   362             if (CCoeEnv::Static()) {
       
   363                 //TODO: Do something with the AVKON dependency
       
   364                 return AknLayoutUtils::PenEnabled();
       
   365             }
       
   366             return false;
       
   367         }
       
   368         case QSystemInfo::FmradioFeature:   //Not available in public SDK
       
   369         case QSystemInfo::LedFeature:
       
   370         case QSystemInfo::VideoOutFeature:  //Accessory monitor available from S60 5.x onwards
       
   371         default:
       
   372             return false;
       
   373     }
       
   374 
       
   375     bool isFeatureSupported = false;
       
   376     TRAP_IGNORE(isFeatureSupported = CFeatureDiscovery::IsFeatureSupportedL(featureId);)
       
   377     return isFeatureSupported;
       
   378 }
       
   379 
       
   380 QSystemNetworkInfoPrivate::QSystemNetworkInfoPrivate(QObject *parent)
       
   381     : QObject(parent)
       
   382 {
       
   383     DeviceInfo::instance()->cellSignalStrenghtInfo()->addObserver(this);
       
   384     DeviceInfo::instance()->cellNetworkInfo()->addObserver(this);
       
   385     DeviceInfo::instance()->cellNetworkRegistrationInfo()->addObserver(this);
       
   386     connect(DeviceInfo::instance()->wlanInfo(), SIGNAL(wlanNetworkNameChanged()),
       
   387         this, SLOT(wlanNetworkNameChanged()));
       
   388     connect(DeviceInfo::instance()->wlanInfo(), SIGNAL(wlanNetworkSignalStrengthChanged()),
       
   389         this, SLOT(wlanNetworkSignalStrengthChanged()));
       
   390     connect(DeviceInfo::instance()->wlanInfo(), SIGNAL(wlanNetworkStatusChanged()),
       
   391         this, SLOT(wlanNetworkStatusChanged()));
       
   392 }
       
   393 
       
   394 QSystemNetworkInfoPrivate::~QSystemNetworkInfoPrivate()
       
   395 {
       
   396     DeviceInfo::instance()->cellSignalStrenghtInfo()->removeObserver(this);
       
   397     DeviceInfo::instance()->cellNetworkInfo()->removeObserver(this);
       
   398     DeviceInfo::instance()->cellNetworkRegistrationInfo()->removeObserver(this);
       
   399 }
       
   400 
       
   401 QSystemNetworkInfo::NetworkStatus QSystemNetworkInfoPrivate::networkStatus(QSystemNetworkInfo::NetworkMode mode)
       
   402 {
       
   403     switch(mode) {
       
   404         case QSystemNetworkInfo::GsmMode:
       
   405         case QSystemNetworkInfo::CdmaMode:
       
   406         case QSystemNetworkInfo::WcdmaMode:
       
   407         {
       
   408             CTelephony::TRegistrationStatus networkStatus = DeviceInfo::instance()
       
   409                 ->cellNetworkRegistrationInfo()->cellNetworkStatus();
       
   410 
       
   411             CTelephony::TNetworkMode networkMode = DeviceInfo::instance()->cellNetworkInfo()->networkMode();
       
   412             if (networkMode == CTelephony::ENetworkModeGsm && mode != QSystemNetworkInfo::GsmMode)
       
   413                 return QSystemNetworkInfo::NoNetworkAvailable;
       
   414 
       
   415             if ((networkMode == CTelephony::ENetworkModeCdma95 || networkMode == CTelephony::ENetworkModeCdma2000) &&
       
   416                 mode != QSystemNetworkInfo::CdmaMode)
       
   417                 return QSystemNetworkInfo::NoNetworkAvailable;
       
   418 
       
   419             if (networkMode == CTelephony::ENetworkModeWcdma && mode != QSystemNetworkInfo::WcdmaMode)
       
   420                 return QSystemNetworkInfo::NoNetworkAvailable;
       
   421 
       
   422             switch(networkStatus) {
       
   423                 case CTelephony::ERegistrationUnknown: return QSystemNetworkInfo::UndefinedStatus;
       
   424                 case CTelephony::ENotRegisteredNoService: return QSystemNetworkInfo::NoNetworkAvailable;
       
   425                 case CTelephony::ENotRegisteredEmergencyOnly: return QSystemNetworkInfo::EmergencyOnly;
       
   426                 case CTelephony::ENotRegisteredSearching: return QSystemNetworkInfo::Searching;
       
   427                 case CTelephony::ERegisteredBusy: return QSystemNetworkInfo::Busy;
       
   428                 case CTelephony::ERegisteredOnHomeNetwork: return QSystemNetworkInfo::HomeNetwork;
       
   429                 case CTelephony::ERegistrationDenied: return QSystemNetworkInfo::Denied;
       
   430                 case CTelephony::ERegisteredRoaming: return QSystemNetworkInfo::Roaming;
       
   431                 default:
       
   432                     break;
       
   433             };
       
   434         }
       
   435         case QSystemNetworkInfo::WlanMode:
       
   436         {
       
   437             if (DeviceInfo::instance()->wlanInfo()->wlanNetworkConnectionStatus())
       
   438                 return QSystemNetworkInfo::Connected;
       
   439             else
       
   440                 return QSystemNetworkInfo::NoNetworkAvailable;
       
   441         }
       
   442         case QSystemNetworkInfo::EthernetMode:
       
   443         case QSystemNetworkInfo::BluetoothMode:
       
   444         case QSystemNetworkInfo::WimaxMode:
       
   445         default:
       
   446             break;
       
   447     };
       
   448     return QSystemNetworkInfo::UndefinedStatus;
       
   449 }
       
   450 
       
   451 int QSystemNetworkInfoPrivate::networkSignalStrength(QSystemNetworkInfo::NetworkMode mode)
       
   452 {
       
   453     switch(mode) {
       
   454         case QSystemNetworkInfo::GsmMode:
       
   455         case QSystemNetworkInfo::CdmaMode:
       
   456         case QSystemNetworkInfo::WcdmaMode:
       
   457         {
       
   458             CTelephony::TNetworkMode networkMode = DeviceInfo::instance()->cellNetworkInfo()->networkMode();
       
   459             if (networkMode == CTelephony::ENetworkModeGsm && mode != QSystemNetworkInfo::GsmMode)
       
   460                 return -1;
       
   461 
       
   462             if ((networkMode == CTelephony::ENetworkModeCdma95 || networkMode == CTelephony::ENetworkModeCdma2000) &&
       
   463                 mode != QSystemNetworkInfo::CdmaMode)
       
   464                 return -1;
       
   465 
       
   466             if (networkMode == CTelephony::ENetworkModeWcdma && mode != QSystemNetworkInfo::WcdmaMode)
       
   467                 return -1;
       
   468 
       
   469             return DeviceInfo::instance()->cellSignalStrenghtInfo()->cellNetworkSignalStrength();
       
   470         }
       
   471 
       
   472         case QSystemNetworkInfo::WlanMode:
       
   473             return DeviceInfo::instance()->wlanInfo()->wlanNetworkSignalStrength();
       
   474         case QSystemNetworkInfo::EthernetMode:
       
   475         case QSystemNetworkInfo::BluetoothMode:
       
   476         case QSystemNetworkInfo::WimaxMode:
       
   477         default:
       
   478             break;
       
   479     };
       
   480     return -1;
       
   481 }
       
   482 
       
   483 int QSystemNetworkInfoPrivate::cellId()
       
   484 {
       
   485 	return DeviceInfo::instance()->cellNetworkInfo()->cellId();
       
   486 }
       
   487 
       
   488 int QSystemNetworkInfoPrivate::locationAreaCode()
       
   489 {
       
   490 	return DeviceInfo::instance()->cellNetworkInfo()->locationAreaCode();
       
   491 }
       
   492 
       
   493 QString QSystemNetworkInfoPrivate::currentMobileCountryCode()
       
   494 {
       
   495 	return DeviceInfo::instance()->cellNetworkInfo()->countryCode();
       
   496 }
       
   497 
       
   498 QString QSystemNetworkInfoPrivate::currentMobileNetworkCode()
       
   499 {
       
   500 	return DeviceInfo::instance()->cellNetworkInfo()->networkCode();
       
   501 }
       
   502 
       
   503 QString QSystemNetworkInfoPrivate::homeMobileCountryCode()
       
   504 {
       
   505     QString imsi = DeviceInfo::instance()->subscriberInfo()->imsi();
       
   506     if (imsi.length() >= 3) {
       
   507         return imsi.left(3);
       
   508     }
       
   509 	return QString();
       
   510 }
       
   511 
       
   512 QString QSystemNetworkInfoPrivate::homeMobileNetworkCode()
       
   513 {
       
   514     CTelephony::TRegistrationStatus networkStatus = DeviceInfo::instance()
       
   515         ->cellNetworkRegistrationInfo()->cellNetworkStatus();
       
   516     if (networkStatus == CTelephony::ERegisteredOnHomeNetwork) {
       
   517         return DeviceInfo::instance()->cellNetworkInfo()->networkCode();
       
   518     }
       
   519     return QString();
       
   520 }
       
   521 
       
   522 QString QSystemNetworkInfoPrivate::networkName(QSystemNetworkInfo::NetworkMode mode)
       
   523 {
       
   524     QString name;
       
   525     switch(mode) {
       
   526         case QSystemNetworkInfo::GsmMode:
       
   527         case QSystemNetworkInfo::CdmaMode:
       
   528         case QSystemNetworkInfo::WcdmaMode:
       
   529         {
       
   530             CTelephony::TNetworkMode networkMode = DeviceInfo::instance()->cellNetworkInfo()->networkMode();
       
   531             if (networkMode == CTelephony::ENetworkModeGsm && mode != QSystemNetworkInfo::GsmMode)
       
   532                 return QString();
       
   533 
       
   534             if ((networkMode == CTelephony::ENetworkModeCdma95 || networkMode == CTelephony::ENetworkModeCdma2000) &&
       
   535                 mode != QSystemNetworkInfo::CdmaMode)
       
   536                 return QString();
       
   537 
       
   538             if (networkMode == CTelephony::ENetworkModeWcdma && mode != QSystemNetworkInfo::WcdmaMode)
       
   539                 return QString();
       
   540 
       
   541             return DeviceInfo::instance()->cellNetworkInfo()->networkName();
       
   542         }
       
   543         case QSystemNetworkInfo::WlanMode:
       
   544             return DeviceInfo::instance()->wlanInfo()->wlanNetworkName();
       
   545         case QSystemNetworkInfo::EthernetMode:
       
   546         case QSystemNetworkInfo::BluetoothMode:
       
   547         case QSystemNetworkInfo::WimaxMode:
       
   548         default:
       
   549             break;
       
   550     };
       
   551     return name;
       
   552 }
       
   553 
       
   554 QString QSystemNetworkInfoPrivate::macAddress(QSystemNetworkInfo::NetworkMode mode)
       
   555 {
       
   556     QString address;
       
   557 
       
   558     switch(mode) {
       
   559         case QSystemNetworkInfo::WlanMode:
       
   560         {
       
   561             const TUid KPSUidWlan = {0x101f8ec5};
       
   562             const TUint KPSWlanMacAddress = 0x00000001;
       
   563             const TUint KPSWlanMacAddressLength = 6;
       
   564             TBuf8<KPSWlanMacAddressLength> wlanMacAddr;
       
   565             if (RProperty::Get(KPSUidWlan, KPSWlanMacAddress, wlanMacAddr) == KErrNone) {
       
   566                 for (TUint i = 0; i < KPSWlanMacAddressLength - 1; ++i) {
       
   567                     address += QString(QByteArray((const char*)wlanMacAddr.Mid(i, 1).Ptr(), 1).toHex());
       
   568                     address += ":";
       
   569                 }
       
   570                 address += QString(QByteArray((const char*)wlanMacAddr.Mid(KPSWlanMacAddressLength - 1, 1).Ptr(), 1).toHex());
       
   571             }
       
   572             break;
       
   573         }
       
   574         case QSystemNetworkInfo::BluetoothMode:
       
   575         {
       
   576             TBuf<20> bluetoothAddr;
       
   577             TPckgBuf<TBTDevAddr> bluetoothAddrPckg;
       
   578             if (RProperty::Get(KUidSystemCategory,
       
   579                 KPropertyKeyBluetoothGetLocalDeviceAddress, bluetoothAddrPckg) == KErrNone) {
       
   580                 bluetoothAddrPckg().GetReadable(bluetoothAddr, KNullDesC, _L(":"), KNullDesC);
       
   581                 address = QString::fromUtf16(bluetoothAddr.Ptr(), bluetoothAddr.Length());
       
   582             }
       
   583             break;
       
   584         }
       
   585         case QSystemNetworkInfo::GsmMode:
       
   586         case QSystemNetworkInfo::CdmaMode:
       
   587         case QSystemNetworkInfo::WcdmaMode:
       
   588         case QSystemNetworkInfo::WimaxMode:
       
   589         case QSystemNetworkInfo::EthernetMode:
       
   590         default:
       
   591             break;
       
   592     };
       
   593     return address;
       
   594 }
       
   595 
       
   596 QNetworkInterface QSystemNetworkInfoPrivate::interfaceForMode(QSystemNetworkInfo::NetworkMode /*mode*/)
       
   597 {
       
   598     return QNetworkInterface();
       
   599 }
       
   600 
       
   601 void QSystemNetworkInfoPrivate::countryCodeChanged()
       
   602 {
       
   603     emit currentMobileCountryCodeChanged(DeviceInfo::instance()->cellNetworkInfo()->countryCode());
       
   604 }
       
   605 
       
   606 void QSystemNetworkInfoPrivate::networkCodeChanged()
       
   607 {
       
   608     emit currentMobileNetworkCodeChanged(DeviceInfo::instance()->cellNetworkInfo()->networkCode());
       
   609 }
       
   610 
       
   611 void QSystemNetworkInfoPrivate::networkNameChanged()
       
   612 {
       
   613     emit networkNameChanged(currentMode(), DeviceInfo::instance()->cellNetworkInfo()->networkName());
       
   614 }
       
   615 
       
   616 void QSystemNetworkInfoPrivate::networkModeChanged()
       
   617 {
       
   618     emit networkModeChanged(currentMode());
       
   619 }
       
   620 
       
   621 void QSystemNetworkInfoPrivate::cellNetworkSignalStrengthChanged()
       
   622 {
       
   623     emit networkSignalStrengthChanged(currentMode(),
       
   624         DeviceInfo::instance()->cellSignalStrenghtInfo()->cellNetworkSignalStrength());
       
   625 }
       
   626 
       
   627 void QSystemNetworkInfoPrivate::cellNetworkStatusChanged()
       
   628 {
       
   629     QSystemNetworkInfo::NetworkMode mode = currentMode();
       
   630     emit networkStatusChanged(mode, networkStatus(mode));
       
   631 }
       
   632 
       
   633 void QSystemNetworkInfoPrivate::wlanNetworkNameChanged()
       
   634 {
       
   635     emit networkNameChanged(QSystemNetworkInfo::WlanMode,
       
   636         DeviceInfo::instance()->wlanInfo()->wlanNetworkName());
       
   637 }
       
   638 
       
   639 void QSystemNetworkInfoPrivate::wlanNetworkSignalStrengthChanged()
       
   640 {
       
   641     emit networkSignalStrengthChanged(QSystemNetworkInfo::WlanMode,
       
   642         DeviceInfo::instance()->wlanInfo()->wlanNetworkSignalStrength());
       
   643 }
       
   644 
       
   645 //TODO: There are no WLAN specific modes (Not connected, Infrastructure, Adhoc, Secure Infrastructure and Searching)
       
   646 void QSystemNetworkInfoPrivate::wlanNetworkStatusChanged()
       
   647 {
       
   648     bool status = DeviceInfo::instance()->wlanInfo()->wlanNetworkConnectionStatus();
       
   649     if (status)
       
   650         emit networkStatusChanged(QSystemNetworkInfo::WlanMode, QSystemNetworkInfo::Connected);
       
   651     else
       
   652         emit networkStatusChanged(QSystemNetworkInfo::WlanMode, QSystemNetworkInfo::NoNetworkAvailable);
       
   653 }
       
   654 
       
   655 QSystemNetworkInfo::NetworkMode QSystemNetworkInfoPrivate::currentMode()
       
   656 {
       
   657     QSystemNetworkInfo::NetworkMode mode = QSystemNetworkInfo::UnknownMode;
       
   658     CTelephony::TNetworkMode networkMode = DeviceInfo::instance()->cellNetworkInfo()->networkMode();
       
   659     switch (networkMode) {
       
   660         case CTelephony::ENetworkModeGsm: mode = QSystemNetworkInfo::GsmMode; break;
       
   661         case CTelephony::ENetworkModeCdma95:
       
   662         case CTelephony::ENetworkModeCdma2000: mode = QSystemNetworkInfo::CdmaMode; break;
       
   663         case CTelephony::ENetworkModeWcdma: mode = QSystemNetworkInfo::WcdmaMode; break;
       
   664         default:
       
   665             break;
       
   666     }
       
   667     return mode;
       
   668 }
       
   669 
       
   670 QSystemDisplayInfoPrivate::QSystemDisplayInfoPrivate(QObject *parent)
       
   671     : QObject(parent)
       
   672 {
       
   673 }
       
   674 
       
   675 QSystemDisplayInfoPrivate::~QSystemDisplayInfoPrivate()
       
   676 {
       
   677 }
       
   678 
       
   679 int QSystemDisplayInfoPrivate::displayBrightness(int /*screen*/)
       
   680 {
       
   681     const TUid KCRUidLightSettings = {0x10200C8C};
       
   682     const TUint32 KLightSensorSensitivity = 0x00000002;
       
   683     int ret = 0;
       
   684     TRAP_IGNORE(
       
   685         CRepository *lightRepository = CRepository::NewLC(KCRUidLightSettings);
       
   686         User::LeaveIfError(lightRepository->Get(KLightSensorSensitivity, ret));
       
   687         if (ret == 0) {
       
   688             ret = 1;
       
   689         }
       
   690         CleanupStack::PopAndDestroy(lightRepository);
       
   691     )
       
   692     return ret;
       
   693 }
       
   694 
       
   695 int QSystemDisplayInfoPrivate::colorDepth(int screen)
       
   696 {
       
   697     int depth = 0;
       
   698     TRAP_IGNORE(
       
   699         RWsSession ws;
       
   700         User::LeaveIfError(ws.Connect());
       
   701         CleanupClosePushL(ws);
       
   702         CWsScreenDevice *wsScreenDevice = new (ELeave)CWsScreenDevice(ws);
       
   703         CleanupStack::PushL(wsScreenDevice);
       
   704         User::LeaveIfError(wsScreenDevice->Construct(screen));
       
   705         depth = TDisplayModeUtils::NumDisplayModeBitsPerPixel(wsScreenDevice->DisplayMode());
       
   706         CleanupStack::PopAndDestroy(2, &ws);
       
   707     )
       
   708     return depth;
       
   709 }
       
   710 
       
   711 QSystemStorageInfoPrivate::QSystemStorageInfoPrivate(QObject *parent)
       
   712     : QObject(parent)
       
   713 {
       
   714     iFs.Connect();
       
   715 }
       
   716 
       
   717 QSystemStorageInfoPrivate::~QSystemStorageInfoPrivate()
       
   718 {
       
   719     iFs.Close();
       
   720 }
       
   721 
       
   722 qlonglong QSystemStorageInfoPrivate::totalDiskSpace(const QString &driveVolume)
       
   723 {
       
   724     if (driveVolume.size() != 1) {
       
   725         return -1;
       
   726     }
       
   727 
       
   728     TInt drive;
       
   729     if (RFs::CharToDrive(TChar(driveVolume[0].toAscii()), drive) != KErrNone) {
       
   730         return -1;
       
   731     }
       
   732 
       
   733     TVolumeInfo volumeInfo;
       
   734     if (iFs.Volume(volumeInfo, drive) != KErrNone) {
       
   735         return -1;
       
   736     }
       
   737 
       
   738     return volumeInfo.iSize;
       
   739 }
       
   740 
       
   741 qlonglong QSystemStorageInfoPrivate::availableDiskSpace(const QString &driveVolume)
       
   742 {
       
   743     if (driveVolume.size() != 1) {
       
   744         return -1;
       
   745     }
       
   746 
       
   747     TInt drive;
       
   748     if (RFs::CharToDrive(TChar(driveVolume[0].toAscii()), drive) != KErrNone) {
       
   749         return -1;
       
   750     }
       
   751 
       
   752     TVolumeInfo volumeInfo;
       
   753     if (iFs.Volume(volumeInfo, drive) != KErrNone) {
       
   754         return -1;
       
   755     }
       
   756 
       
   757     return volumeInfo.iFree;
       
   758 }
       
   759 
       
   760 QStringList QSystemStorageInfoPrivate::logicalDrives()
       
   761 {
       
   762     QStringList logicalDrives;
       
   763     RFs fsSession;
       
   764     TRAPD(err,
       
   765         User::LeaveIfError(fsSession.Connect());
       
   766         CleanupClosePushL(fsSession);
       
   767         TDriveList drivelist;
       
   768         User::LeaveIfError(fsSession.DriveList(drivelist));
       
   769         for (int i = 0; i < KMaxDrives; ++i) {
       
   770             if (drivelist[i] != 0) {
       
   771                 TChar driveChar;
       
   772                 User::LeaveIfError(RFs::DriveToChar(i, driveChar));
       
   773                 logicalDrives << QChar(driveChar);
       
   774             }
       
   775         }
       
   776         CleanupStack::PopAndDestroy(&fsSession);
       
   777     )
       
   778     if (err != KErrNone) {
       
   779         return QStringList();
       
   780     }
       
   781     return logicalDrives;
       
   782 }
       
   783 
       
   784 QSystemStorageInfo::DriveType QSystemStorageInfoPrivate::typeForDrive(const QString &driveVolume)
       
   785 {
       
   786     if (driveVolume.size() != 1) {
       
   787         return QSystemStorageInfo::NoDrive;
       
   788     }
       
   789 
       
   790     TInt drive;
       
   791     if (RFs::CharToDrive(TChar(driveVolume[0].toAscii()), drive) != KErrNone) {
       
   792         return QSystemStorageInfo::NoDrive;
       
   793     }
       
   794 
       
   795     TDriveInfo driveInfo;
       
   796     if (iFs.Drive(driveInfo, drive) != KErrNone) {
       
   797         return QSystemStorageInfo::NoDrive;
       
   798     }
       
   799 
       
   800     if (driveInfo.iType == EMediaRemote) {
       
   801         return QSystemStorageInfo::RemoteDrive;
       
   802     } else if (driveInfo.iType == EMediaCdRom) {
       
   803         return QSystemStorageInfo::CdromDrive;
       
   804     }
       
   805 
       
   806     if (driveInfo.iDriveAtt & KDriveAttInternal) {
       
   807         return QSystemStorageInfo::InternalDrive;
       
   808     } else if (driveInfo.iDriveAtt & KDriveAttRemovable) {
       
   809         return QSystemStorageInfo::RemovableDrive;
       
   810     }
       
   811 
       
   812     return QSystemStorageInfo::NoDrive;
       
   813 };
       
   814 
       
   815 QSystemDeviceInfoPrivate::QSystemDeviceInfoPrivate(QObject *parent)
       
   816     : QObject(parent), m_profileEngine(NULL), m_proEngNotifyHandler(NULL),
       
   817     m_bluetoothRepository(NULL), m_bluetoothNotifyHandler(NULL)
       
   818 {
       
   819     DeviceInfo::instance()->batteryInfo()->addObserver(this);
       
   820     DeviceInfo::instance()->chargingStatus()->addObserver(this);
       
   821 }
       
   822 
       
   823 QSystemDeviceInfoPrivate::~QSystemDeviceInfoPrivate()
       
   824 {
       
   825     DeviceInfo::instance()->chargingStatus()->removeObserver(this);
       
   826     DeviceInfo::instance()->batteryInfo()->removeObserver(this);
       
   827 
       
   828     if (m_proEngNotifyHandler) {
       
   829         m_proEngNotifyHandler->CancelProfileActivationNotifications();
       
   830         delete m_proEngNotifyHandler;
       
   831     }
       
   832 
       
   833     if(m_profileEngine) {
       
   834         m_profileEngine->Release();
       
   835     }
       
   836 
       
   837     delete m_bluetoothNotifyHandler;
       
   838     delete m_bluetoothRepository;
       
   839 }
       
   840 
       
   841 void QSystemDeviceInfoPrivate::connectNotify(const char *signal)
       
   842 {
       
   843     if (QLatin1String(signal) == SIGNAL(currentProfileChanged(QSystemDeviceInfo::Profile))) {
       
   844         if (!m_proEngNotifyHandler) {
       
   845             TRAPD(err,
       
   846                 m_proEngNotifyHandler = ProEngFactory::NewNotifyHandlerL();
       
   847                 m_proEngNotifyHandler->RequestProfileActivationNotificationsL(*this);
       
   848             )
       
   849             if (err != KErrNone) {
       
   850                 delete m_proEngNotifyHandler;
       
   851                 m_proEngNotifyHandler = NULL;
       
   852             }
       
   853         }
       
   854     } else if (QLatin1String(signal) == SIGNAL(bluetoothStateChanged(bool))) {
       
   855         if (!m_bluetoothRepository) {
       
   856             TRAPD(btErr,
       
   857                 m_bluetoothRepository = CRepository::NewL(KCRUidBluetoothPowerState);
       
   858                 m_bluetoothNotifyHandler = CCenRepNotifyHandler::NewL(
       
   859                     *this, *m_bluetoothRepository, CCenRepNotifyHandler::EIntKey, KBTPowerState);
       
   860                 m_bluetoothNotifyHandler->StartListeningL();
       
   861             )
       
   862             if (btErr != KErrNone) {
       
   863                 delete m_bluetoothNotifyHandler;
       
   864                 m_bluetoothNotifyHandler = NULL;
       
   865                 delete m_bluetoothRepository;
       
   866                 m_bluetoothRepository = NULL;
       
   867             }
       
   868         }
       
   869     }
       
   870 }
       
   871 
       
   872 void QSystemDeviceInfoPrivate::QSystemDeviceInfoPrivate::HandleNotifyInt(TUint32 aId, TInt aNewValue)
       
   873 {
       
   874     if (aId == KBTPowerState) {
       
   875         emit bluetoothStateChanged(aNewValue & 0x00000001 != 0);
       
   876     }
       
   877 }
       
   878 
       
   879 void QSystemDeviceInfoPrivate::HandleProfileActivatedL(TInt aProfileId)
       
   880 {
       
   881     QSystemDeviceInfo::Profile profile = s60ProfileIdToProfile(aProfileId);
       
   882     emit currentProfileChanged(profile);
       
   883 }
       
   884 
       
   885 QSystemDeviceInfo::Profile QSystemDeviceInfoPrivate::currentProfile()
       
   886 {
       
   887     QSystemDeviceInfo::Profile profile = QSystemDeviceInfo::UnknownProfile;
       
   888 
       
   889     if (!m_profileEngine) {
       
   890         TRAP_IGNORE(m_profileEngine = ProEngFactory::NewEngineL();)
       
   891     }
       
   892 
       
   893     if (m_profileEngine) {
       
   894         return s60ProfileIdToProfile(m_profileEngine->ActiveProfileId());
       
   895     }
       
   896 
       
   897     return profile;
       
   898 }
       
   899 
       
   900 QSystemDeviceInfo::Profile QSystemDeviceInfoPrivate::s60ProfileIdToProfile(TInt profileId) const
       
   901 {
       
   902     QSystemDeviceInfo::Profile profile = QSystemDeviceInfo::UnknownProfile;
       
   903 
       
   904     //From profileenginesdkcrkeys.h:
       
   905     //0 = General profile (default value)<br>
       
   906     //1 = Silent profile<br>
       
   907     //2 = Meeting profile<br>
       
   908     //3 = Outdoor profile<br>
       
   909     //4 = Pager profile<br>
       
   910     //5 = Off-line profile<br>
       
   911     //6 = Drive profile<br>
       
   912     //30-49 = User-created profiles<br>
       
   913 
       
   914     switch (profileId) {
       
   915     case 0: profile = QSystemDeviceInfo::NormalProfile; break;
       
   916     case 1: profile = QSystemDeviceInfo::SilentProfile; break;
       
   917     case 2: profile = QSystemDeviceInfo::CustomProfile; break;
       
   918     case 3: profile = QSystemDeviceInfo::LoudProfile; break;
       
   919     case 4: profile = QSystemDeviceInfo::CustomProfile; break;
       
   920     case 5: profile = QSystemDeviceInfo::OfflineProfile; break;
       
   921     case 6: profile = QSystemDeviceInfo::CustomProfile; break;
       
   922     default:
       
   923         {
       
   924             if (profileId >= 30 && profileId <= 49) {
       
   925                 profile = QSystemDeviceInfo::CustomProfile;
       
   926             } else {
       
   927                 profile = QSystemDeviceInfo::UnknownProfile; break;
       
   928             }
       
   929         }
       
   930     }
       
   931     return profile;
       
   932 }
       
   933 
       
   934 QSystemDeviceInfo::InputMethodFlags QSystemDeviceInfoPrivate::inputMethodType()
       
   935 {
       
   936     QSystemDeviceInfo::InputMethodFlags methods;
       
   937 
       
   938     methods |= QSystemDeviceInfo::Keys;
       
   939     methods |= QSystemDeviceInfo::Keypad;
       
   940 
       
   941     if (CCoeEnv::Static()) {
       
   942         //TODO: Do something with the AVKON dependency
       
   943         if (AknLayoutUtils::PenEnabled()) methods |= QSystemDeviceInfo::SingleTouch;
       
   944     }
       
   945 
       
   946     TRAP_IGNORE(
       
   947         if (CFeatureDiscovery::IsFeatureSupportedL(KFeatureIdQwertyInput)) {
       
   948             methods |= QSystemDeviceInfo::Keyboard;
       
   949         }
       
   950     )
       
   951     return methods;
       
   952 }
       
   953 
       
   954 QSystemDeviceInfo::PowerState QSystemDeviceInfoPrivate::currentPowerState()
       
   955 {
       
   956     switch (DeviceInfo::instance()->chargingStatus()->chargingStatus()) {
       
   957     case EChargingStatusNotConnected:
       
   958     case EChargingStatusNotCharging:
       
   959     case EChargingStatusError:
       
   960         return QSystemDeviceInfo::BatteryPower;
       
   961     case EChargingStatusCharging:
       
   962     case EChargingStatusChargingContinued:
       
   963     case EChargingStatusAlmostComplete:
       
   964         return QSystemDeviceInfo::WallPowerChargingBattery;
       
   965     case EChargingStatusChargingComplete:
       
   966         return QSystemDeviceInfo::WallPower;
       
   967     default:
       
   968         return QSystemDeviceInfo::UnknownPower;
       
   969     }
       
   970 }
       
   971 
       
   972 QString QSystemDeviceInfoPrivate::imei()
       
   973 {
       
   974     return DeviceInfo::instance()->phoneInfo()->imei();
       
   975 }
       
   976 
       
   977 QString QSystemDeviceInfoPrivate::imsi()
       
   978 {
       
   979     if (simStatus() == QSystemDeviceInfo::SimNotAvailable)
       
   980         return QString();
       
   981     else
       
   982         return DeviceInfo::instance()->subscriberInfo()->imsi();
       
   983 }
       
   984 
       
   985 QString QSystemDeviceInfoPrivate::manufacturer()
       
   986 {
       
   987     return DeviceInfo::instance()->phoneInfo()->manufacturer();
       
   988 }
       
   989 
       
   990 QString QSystemDeviceInfoPrivate::model()
       
   991 {
       
   992     return DeviceInfo::instance()->phoneInfo()->model();
       
   993 }
       
   994 
       
   995 QString QSystemDeviceInfoPrivate::productName()
       
   996 {
       
   997     QString productname;
       
   998     TBuf<KSysUtilVersionTextLength> versionBuf;
       
   999     if (SysUtil::GetSWVersion(versionBuf) == KErrNone) {
       
  1000 		productname = QString::fromUtf16(versionBuf.Ptr(), versionBuf.Length());
       
  1001     }
       
  1002     return productname.split("\n").at(2);
       
  1003 }
       
  1004 
       
  1005 int QSystemDeviceInfoPrivate::batteryLevel() const
       
  1006 {
       
  1007     return DeviceInfo::instance()->batteryInfo()->batteryLevel();
       
  1008 }
       
  1009 
       
  1010 QSystemDeviceInfo::BatteryStatus QSystemDeviceInfoPrivate::batteryStatus()
       
  1011 {
       
  1012     int batteryLevel = DeviceInfo::instance()->batteryInfo()->batteryLevel();
       
  1013     if(batteryLevel < 4) {
       
  1014         return QSystemDeviceInfo::BatteryCritical;
       
  1015     }   else if (batteryLevel < 11) {
       
  1016         return QSystemDeviceInfo::BatteryVeryLow;
       
  1017     }  else if (batteryLevel < 41) {
       
  1018         return QSystemDeviceInfo::BatteryLow;
       
  1019     }   else if (batteryLevel > 40) {
       
  1020         return QSystemDeviceInfo::BatteryNormal;
       
  1021     }
       
  1022 
       
  1023     return QSystemDeviceInfo::NoBatteryLevel;
       
  1024 }
       
  1025 
       
  1026 QSystemDeviceInfo::SimStatus QSystemDeviceInfoPrivate::simStatus()
       
  1027 {
       
  1028     TInt lockStatus = 0;
       
  1029     TInt err = RProperty::Get(KPSUidStartup, KStartupSimLockStatus, lockStatus);
       
  1030     if (err == KErrNone && (TPSSimLockStatus)lockStatus != ESimLockOk) {
       
  1031         return QSystemDeviceInfo::SimLocked;
       
  1032     }
       
  1033 
       
  1034     TInt simStatus = 0;
       
  1035     err = RProperty::Get(KPSUidStartup, KPSSimStatus, simStatus);
       
  1036     if (err == KErrNone && TPSSimStatus(simStatus) == ESimUsable) {
       
  1037         return QSystemDeviceInfo::SingleSimAvailable;
       
  1038     }
       
  1039 
       
  1040     return QSystemDeviceInfo::SimNotAvailable;
       
  1041 }
       
  1042 
       
  1043 bool QSystemDeviceInfoPrivate::isDeviceLocked()
       
  1044 {
       
  1045     bool isLocked = false;
       
  1046 
       
  1047     RAknKeylock2 keyLock;
       
  1048     TInt err = keyLock.Connect();
       
  1049     if (err == KErrNone) {
       
  1050         isLocked = keyLock.IsKeyLockEnabled();
       
  1051         keyLock.Close();
       
  1052     }
       
  1053 
       
  1054     return isLocked;
       
  1055 }
       
  1056 
       
  1057 void QSystemDeviceInfoPrivate::batteryLevelChanged()
       
  1058 {
       
  1059     emit batteryLevelChanged(batteryLevel());
       
  1060 
       
  1061     int batteryLevel = DeviceInfo::instance()->batteryInfo()->batteryLevel();
       
  1062     QSystemDeviceInfo::BatteryStatus status(batteryStatus());
       
  1063 
       
  1064     if(batteryLevel < 4 && status != QSystemDeviceInfo::BatteryCritical) {
       
  1065         emit batteryStatusChanged(QSystemDeviceInfo::BatteryCritical);
       
  1066     } else if (batteryLevel < 11 && status != QSystemDeviceInfo::BatteryVeryLow) {
       
  1067         emit batteryStatusChanged(QSystemDeviceInfo::BatteryVeryLow);
       
  1068     } else if (batteryLevel < 41 && status != QSystemDeviceInfo::BatteryLow) {
       
  1069         emit batteryStatusChanged(QSystemDeviceInfo::BatteryLow);
       
  1070     } else if (batteryLevel > 40 && status != QSystemDeviceInfo::BatteryNormal) {
       
  1071         emit batteryStatusChanged(QSystemDeviceInfo::BatteryNormal);
       
  1072     } else {
       
  1073         emit batteryStatusChanged(QSystemDeviceInfo::NoBatteryLevel);
       
  1074     }
       
  1075 }
       
  1076 
       
  1077 void QSystemDeviceInfoPrivate::chargingStatusChanged()
       
  1078 {
       
  1079     emit powerStateChanged(currentPowerState());
       
  1080 }
       
  1081 
       
  1082 DeviceInfo *DeviceInfo::m_instance = NULL;
       
  1083 
       
  1084 QSystemScreenSaverPrivate::QSystemScreenSaverPrivate(QObject *parent)
       
  1085     : QObject(parent), m_screenSaverInhibited(false)
       
  1086 {
       
  1087 }
       
  1088 
       
  1089 bool QSystemScreenSaverPrivate::screenSaverInhibited()
       
  1090 {
       
  1091     return m_screenSaverInhibited;
       
  1092 }
       
  1093 
       
  1094 bool QSystemScreenSaverPrivate::setScreenSaverInhibit()
       
  1095 {
       
  1096     if (m_screenSaverInhibited) {
       
  1097         return true;
       
  1098     }
       
  1099 
       
  1100     m_screenSaverInhibited = true;
       
  1101     resetInactivityTime();
       
  1102 
       
  1103     QTimer *timer = new QTimer(this);
       
  1104     connect(timer, SIGNAL(timeout()), this, SLOT(resetInactivityTime()));
       
  1105     timer->start(3000); //3 seconds interval
       
  1106 
       
  1107     return true;
       
  1108 }
       
  1109 
       
  1110 void QSystemScreenSaverPrivate::resetInactivityTime()
       
  1111 {
       
  1112     User::ResetInactivityTime();
       
  1113 }
       
  1114 
       
  1115 #include "moc_qsysteminfo_s60_p.cpp"
       
  1116 
       
  1117 QTM_END_NAMESPACE