915 { |
915 { |
916 } |
916 } |
917 |
917 |
918 int QSystemDisplayInfoPrivate::displayBrightness(int screen) |
918 int QSystemDisplayInfoPrivate::displayBrightness(int screen) |
919 { |
919 { |
920 Q_UNUSED(screen); |
920 QDesktopWidget wid; |
|
921 if(wid.screenCount() - 1 < screen) { |
|
922 return -1; |
|
923 } |
921 GConfItem currentBrightness("/system/osso/dsm/display/display_brightness"); |
924 GConfItem currentBrightness("/system/osso/dsm/display/display_brightness"); |
922 GConfItem maxBrightness("/system/osso/dsm/display/max_display_brightness_levels"); |
925 GConfItem maxBrightness("/system/osso/dsm/display/max_display_brightness_levels"); |
923 if(maxBrightness.value().toInt()) { |
926 if(maxBrightness.value().toInt()) { |
924 float retVal = 100 * (currentBrightness.value().toFloat() / |
927 float retVal = 100 * (currentBrightness.value().toFloat() / |
925 maxBrightness.value().toFloat()); |
928 maxBrightness.value().toFloat()); |
1223 if (previousProfile != newProfile) |
1226 if (previousProfile != newProfile) |
1224 emit currentProfileChanged(newProfile); |
1227 emit currentProfileChanged(newProfile); |
1225 } |
1228 } |
1226 } |
1229 } |
1227 |
1230 |
|
1231 QString QSystemDeviceInfoPrivate::model() |
|
1232 { |
|
1233 QString name; |
|
1234 if(productName()== "RX-51") |
|
1235 return "N900"; |
|
1236 |
|
1237 name = "Harmattan"; //fake this for now |
|
1238 |
|
1239 return name; |
|
1240 |
|
1241 } |
|
1242 |
|
1243 QString QSystemDeviceInfoPrivate::productName() |
|
1244 { |
|
1245 #if !defined(QT_NO_DBUS) |
|
1246 #if defined(Q_WS_MAEMO_6) |
|
1247 QString dBusService = "com.nokia.SystemInfo"; |
|
1248 #else |
|
1249 /* Maemo 5 */ |
|
1250 QString dBusService = "com.nokia.SystemInfo"; |
|
1251 #endif |
|
1252 QDBusInterface connectionInterface(dBusService, |
|
1253 "/com/nokia/SystemInfo", |
|
1254 "com.nokia.SystemInfo", |
|
1255 QDBusConnection::systemBus()); |
|
1256 |
|
1257 QDBusReply< QByteArray > reply = connectionInterface.call("GetConfigValue","/component/product"); |
|
1258 return reply.value(); |
|
1259 #endif |
|
1260 } |
|
1261 |
1228 #endif |
1262 #endif |
1229 |
1263 |
1230 ////////////// |
1264 ////////////// |
1231 /////// |
1265 /////// |
1232 QSystemScreenSaverPrivate::QSystemScreenSaverPrivate(QObject *parent) |
1266 QSystemScreenSaverPrivate::QSystemScreenSaverPrivate(QObject *parent) |
1233 : QSystemScreenSaverLinuxCommonPrivate(parent) |
1267 : QSystemScreenSaverLinuxCommonPrivate(parent),isInhibited(0) |
1234 { |
1268 { |
1235 ssTimer = new QTimer(this); |
1269 ssTimer = new QTimer(this); |
1236 #if !defined(QT_NO_DBUS) |
1270 #if !defined(QT_NO_DBUS) |
1237 mceConnectionInterface = new QDBusInterface("com.nokia.mce", |
1271 mceConnectionInterface = new QDBusInterface("com.nokia.mce", |
1238 "/com/nokia/mce/request", |
1272 "/com/nokia/mce/request", |
1258 connect(ssTimer, SIGNAL(timeout()), this, SLOT(wakeUpDisplay())); |
1292 connect(ssTimer, SIGNAL(timeout()), this, SLOT(wakeUpDisplay())); |
1259 // Set a wake up interval of 30 seconds. |
1293 // Set a wake up interval of 30 seconds. |
1260 // The reason for this is to avoid the situation where |
1294 // The reason for this is to avoid the situation where |
1261 // a crashed/hung application keeps the display on. |
1295 // a crashed/hung application keeps the display on. |
1262 ssTimer->start(30000); |
1296 ssTimer->start(30000); |
1263 } |
1297 isInhibited = true; |
|
1298 } else { |
|
1299 isInhibited = false; |
|
1300 } |
1264 return screenSaverInhibited(); |
1301 return screenSaverInhibited(); |
1265 } |
1302 } |
1266 |
1303 |
1267 void QSystemScreenSaverPrivate::wakeUpDisplay() |
1304 void QSystemScreenSaverPrivate::wakeUpDisplay() |
1268 { |
1305 { |
1275 } |
1312 } |
1276 |
1313 |
1277 bool QSystemScreenSaverPrivate::screenSaverInhibited() |
1314 bool QSystemScreenSaverPrivate::screenSaverInhibited() |
1278 { |
1315 { |
1279 bool displayOn = false; |
1316 bool displayOn = false; |
|
1317 GConfItem screenBlankItem("/system/osso/dsm/display/inhibit_blank_mode"); |
|
1318 /* 0 - no inhibit |
|
1319 1 - inhibit dim with charger |
|
1320 2 - inhibit blank with charger (display still dims) |
|
1321 3 - inhibit dim (always) |
|
1322 4 - inhibit blank (always; display still dims) |
|
1323 */ |
|
1324 int blankingItem = screenBlankItem.value().toInt(); |
|
1325 |
|
1326 bool isBlankingInhibited = false; |
|
1327 QSystemDeviceInfo devInfo(this); |
|
1328 QSystemDeviceInfo::PowerState batState = devInfo.currentPowerState(); |
|
1329 |
|
1330 if( ((batState == QSystemDeviceInfo::WallPower || batState == QSystemDeviceInfo::WallPowerChargingBattery) |
|
1331 && blankingItem == 2) || blankingItem == 4) { |
|
1332 isBlankingInhibited = true; |
|
1333 } |
|
1334 |
1280 #if !defined(QT_NO_DBUS) |
1335 #if !defined(QT_NO_DBUS) |
1281 if (mceConnectionInterface->isValid()) { |
1336 if (mceConnectionInterface->isValid()) { |
1282 // The most educated guess for the screen saver being inhibited is to determine |
1337 // The most educated guess for the screen saver being inhibited is to determine |
1283 // whether the display is on. That is because the QSystemScreenSaver cannot |
1338 // whether the display is on. That is because the QSystemScreenSaver cannot |
1284 // prevent other processes from blanking the screen (like, if |
1339 // prevent other processes from blanking the screen (like, if |
1285 // MCE decides to blank the screen for some reason). |
1340 // MCE decides to blank the screen for some reason). |
|
1341 // but that means it reports to be inhibited when display is on. meaning |
|
1342 // effectly always inhibited by default. so we try a bit harder |
1286 QDBusReply<QString> reply = mceConnectionInterface->call("get_display_status"); |
1343 QDBusReply<QString> reply = mceConnectionInterface->call("get_display_status"); |
1287 displayOn = ("on" == reply.value()); |
1344 displayOn = ("on" == reply.value()); |
1288 } |
1345 } |
1289 #endif |
1346 #endif |
1290 return displayOn; |
1347 return (displayOn && isBlankingInhibited && isInhibited); |
1291 } |
1348 } |
1292 |
1349 |
1293 #include "moc_qsysteminfo_maemo_p.cpp" |
1350 #include "moc_qsysteminfo_maemo_p.cpp" |
1294 |
1351 |
1295 QTM_END_NAMESPACE |
1352 QTM_END_NAMESPACE |