qtmobility/src/systeminfo/qsysteminfo_s60.cpp
changeset 5 453da2cfceef
parent 4 90517678cc4f
child 8 71781823f776
equal deleted inserted replaced
4:90517678cc4f 5:453da2cfceef
   582         User::LeaveIfError(ws.Connect());
   582         User::LeaveIfError(ws.Connect());
   583         CleanupClosePushL(ws);
   583         CleanupClosePushL(ws);
   584         CWsScreenDevice *wsScreenDevice = new (ELeave)CWsScreenDevice(ws);
   584         CWsScreenDevice *wsScreenDevice = new (ELeave)CWsScreenDevice(ws);
   585         CleanupStack::PushL(wsScreenDevice);
   585         CleanupStack::PushL(wsScreenDevice);
   586         User::LeaveIfError(wsScreenDevice->Construct(screen));
   586         User::LeaveIfError(wsScreenDevice->Construct(screen));
   587         TDisplayMode mode = wsScreenDevice->DisplayMode();
   587         depth = TDisplayModeUtils::NumDisplayModeBitsPerPixel(wsScreenDevice->DisplayMode());
   588         switch (mode) {
       
   589             case EGray2: depth = 1; break;
       
   590             case EGray4: depth = 2; break;
       
   591             case EGray16:
       
   592             case EColor16: depth = 4; break;
       
   593             case EGray256:
       
   594             case EColor256: depth = 8; break;
       
   595             case EColor4K: depth = 12; break;
       
   596             case EColor64K: depth = 16; break;
       
   597             case EColor16M:
       
   598             case EColor16MA: depth = 24; break;
       
   599             case EColor16MU: depth = 32; break;
       
   600             case ENone:
       
   601             case ERgb:
       
   602             case EColorLast:
       
   603             default: depth = 0;
       
   604                 break;
       
   605         }
       
   606         CleanupStack::PopAndDestroy(2, &ws);
   588         CleanupStack::PopAndDestroy(2, &ws);
   607     )
   589     )
   608 
       
   609     return depth;
   590     return depth;
   610 }
   591 }
   611 
   592 
   612 QSystemStorageInfoPrivate::QSystemStorageInfoPrivate(QObject *parent)
   593 QSystemStorageInfoPrivate::QSystemStorageInfoPrivate(QObject *parent)
   613     : QObject(parent)
   594     : QObject(parent)
   716 QSystemDeviceInfoPrivate::QSystemDeviceInfoPrivate(QObject *parent)
   697 QSystemDeviceInfoPrivate::QSystemDeviceInfoPrivate(QObject *parent)
   717     : QObject(parent), m_profileEngine(NULL), m_proEngNotifyHandler(NULL),
   698     : QObject(parent), m_profileEngine(NULL), m_proEngNotifyHandler(NULL),
   718     m_bluetoothRepository(NULL), m_bluetoothNotifyHandler(NULL)
   699     m_bluetoothRepository(NULL), m_bluetoothNotifyHandler(NULL)
   719 {
   700 {
   720     DeviceInfo::instance()->batteryInfo()->addObserver(this);
   701     DeviceInfo::instance()->batteryInfo()->addObserver(this);
       
   702     DeviceInfo::instance()->chargingStatus()->addObserver(this);
   721 }
   703 }
   722 
   704 
   723 QSystemDeviceInfoPrivate::~QSystemDeviceInfoPrivate()
   705 QSystemDeviceInfoPrivate::~QSystemDeviceInfoPrivate()
   724 {
   706 {
       
   707     DeviceInfo::instance()->chargingStatus()->removeObserver(this);
   725     DeviceInfo::instance()->batteryInfo()->removeObserver(this);
   708     DeviceInfo::instance()->batteryInfo()->removeObserver(this);
   726 
   709 
   727     if (m_proEngNotifyHandler) {
   710     if (m_proEngNotifyHandler) {
   728         m_proEngNotifyHandler->CancelProfileActivationNotifications();
   711         m_proEngNotifyHandler->CancelProfileActivationNotifications();
   729         delete m_proEngNotifyHandler;
   712         delete m_proEngNotifyHandler;
   850     return methods;
   833     return methods;
   851 }
   834 }
   852 
   835 
   853 QSystemDeviceInfo::PowerState QSystemDeviceInfoPrivate::currentPowerState()
   836 QSystemDeviceInfo::PowerState QSystemDeviceInfoPrivate::currentPowerState()
   854 {
   837 {
   855     CTelephony::TBatteryStatus powerState = DeviceInfo::instance()->batteryInfo()->powerState();
   838     switch (DeviceInfo::instance()->chargingStatus()->chargingStatus()) {
   856 
   839     case EChargingStatusNotConnected:
   857     switch (powerState) {
   840     case EChargingStatusNotCharging:
   858         case CTelephony::EPoweredByBattery:
   841     case EChargingStatusError:
   859             return QSystemDeviceInfo::BatteryPower;
   842         return QSystemDeviceInfo::BatteryPower;
   860 
   843     case EChargingStatusCharging:
   861         case CTelephony::EBatteryConnectedButExternallyPowered:
   844     case EChargingStatusChargingContinued:
   862         {
   845     case EChargingStatusAlmostComplete:
   863             if (DeviceInfo::instance()->batteryInfo()->batteryLevel() < 100) { //TODO: Use real indicator, EPSHWRMChargingStatus::EChargingStatusNotCharging?
   846         return QSystemDeviceInfo::WallPowerChargingBattery;
   864                 return QSystemDeviceInfo::WallPowerChargingBattery;
   847     case EChargingStatusChargingComplete:
   865             }
   848         return QSystemDeviceInfo::WallPower;
   866             return QSystemDeviceInfo::WallPower;
   849     default:
   867         }
   850         return QSystemDeviceInfo::UnknownPower;
   868         case CTelephony::ENoBatteryConnected:
       
   869             return QSystemDeviceInfo::WallPower;
       
   870 
       
   871         case CTelephony::EPowerFault:
       
   872         case CTelephony::EPowerStatusUnknown:
       
   873         default:
       
   874             return QSystemDeviceInfo::UnknownPower;
       
   875     }
   851     }
   876 }
   852 }
   877 
   853 
   878 QString QSystemDeviceInfoPrivate::imei()
   854 QString QSystemDeviceInfoPrivate::imei()
   879 {
   855 {
   963     } else {
   939     } else {
   964         emit batteryStatusChanged(QSystemDeviceInfo::NoBatteryLevel);
   940         emit batteryStatusChanged(QSystemDeviceInfo::NoBatteryLevel);
   965     }
   941     }
   966 }
   942 }
   967 
   943 
   968 void QSystemDeviceInfoPrivate::powerStateChanged()
   944 void QSystemDeviceInfoPrivate::chargingStatusChanged()
   969 {
   945 {
   970     emit powerStateChanged(currentPowerState());
   946     emit powerStateChanged(currentPowerState());
   971 }
   947 }
   972 
   948 
   973 DeviceInfo *DeviceInfo::m_instance = NULL;
   949 DeviceInfo *DeviceInfo::m_instance = NULL;