branches/KDE/4.6/kdebase/workspace/powerdevil/daemon

Dario Freddi drf at kde.org
Mon Jan 24 11:19:16 CET 2011


SVN commit 1216709 by dafre:

CCMAIL: Dirk Mueller <mueller at kde.org>
CCMAIL: release-team at kde.org

Backporting r1216706

This commit fixes a critical bug in the migrator, hence it should be released with 4.6.0


 M  +27 -14    powerdevilprofilegenerator.cpp  
 M  +23 -0     powerdevilprofilegenerator.h  


--- branches/KDE/4.6/kdebase/workspace/powerdevil/daemon/powerdevilprofilegenerator.cpp #1216708:1216709
@@ -260,26 +260,18 @@
             runScript.writeEntry< uint >("scriptPhase", 0);
         }
         // SuspendSession
-        if (oldGroup.readEntry< int >("idleAction", 0) > 0) {
+        if (oldGroup.readEntry< uint >("idleAction", 0) > 0) {
             KConfigGroup suspendSession(&newGroup, "SuspendSession");
             suspendSession.writeEntry< uint >("idleTime", oldGroup.readEntry< int >("idleTime", 30) * 60 * 1000);
-            if (!methods.contains(Solid::PowerManagement::SuspendState)) {
-                suspendSession.writeEntry< uint >("suspendType", 2);
-            } else {
-                suspendSession.writeEntry< uint >("suspendType", 1);
+            suspendSession.writeEntry< uint >("suspendType", upgradeOldAction(oldGroup.readEntry< uint >("idleAction", 0)));
             }
-        }
         // Buttons
-        if (oldGroup.readEntry< int >("powerButtonAction", 0) > 0 || oldGroup.readEntry< int >("lidAction", 0) > 0) {
-            KConfigGroup suspendSession(&newGroup, "SuspendSession");
-            suspendSession.writeEntry< uint >("idleTime", oldGroup.readEntry< int >("idleTime", 30) * 60 * 1000);
-            if (!methods.contains(Solid::PowerManagement::SuspendState)) {
-                suspendSession.writeEntry< uint >("suspendType", 2);
-            } else {
-                suspendSession.writeEntry< uint >("suspendType", 1);
+        if (oldGroup.readEntry< uint >("powerButtonAction", 0) > 0 || oldGroup.readEntry< uint >("lidAction", 0) > 0) {
+            KConfigGroup handleButtons(&newGroup, "HandleButtonEvents");
+            handleButtons.writeEntry< uint >("powerButtonAction", upgradeOldAction(oldGroup.readEntry< uint >("powerButtonAction", 0)));
+            handleButtons.writeEntry< uint >("lidAction", upgradeOldAction(oldGroup.readEntry< uint >("lidAction", 0)));
             }
         }
-    }
 
     // Save and be happy
     profilesConfig->sync();
@@ -301,4 +293,25 @@
     }
 }
 
+uint ProfileGenerator::upgradeOldAction(uint oldAction)
+{
+    switch ((OldIdleAction)oldAction) {
+        case Standby:
+        case S2Ram:
+            return ToRamMode;
+        case S2Disk:
+            return ToDiskMode;
+        case Shutdown:
+            return ShutdownMode;
+        case Lock:
+            return LockScreenMode;
+        case ShutdownDialog:
+            return LogoutDialogMode;
+        case TurnOffScreen:
+            return TurnOffScreenMode;
+        default:
+            return 0;
 }
+}
+
+}
--- branches/KDE/4.6/kdebase/workspace/powerdevil/daemon/powerdevilprofilegenerator.h #1216708:1216709
@@ -31,8 +31,31 @@
         ResultUpgraded = 2
     };
 
+    enum OldIdleAction {
+        None = 0,
+        Standby = 1,
+        S2Ram = 2,
+        S2Disk = 4,
+        Shutdown = 8,
+        Lock = 16,
+        ShutdownDialog = 32,
+        TurnOffScreen = 64
+    };
+
+    enum NewMode {
+        NoneMode = 0,
+        ToRamMode = 1,
+        ToDiskMode = 2,
+        SuspendHybridMode = 4,
+        ShutdownMode = 8,
+        LogoutDialogMode = 16,
+        LockScreenMode = 32,
+        TurnOffScreenMode = 64
+    };
+
     GeneratorResult generateProfiles(bool tryUpgrade = false);
     void upgradeProfiles();
+    unsigned int upgradeOldAction(unsigned int actionId);
 }
 
 }


More information about the release-team mailing list