[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/solid/solid
From:       Dario Freddi <drf () kde ! org>
Date:       2010-11-08 23:03:34
Message-ID: 20101108230334.7192DAC89E () svn ! kde ! org
[Download RAW message or body]

SVN commit 1194423 by dafre:

Switch solid to new KDE Power Management System's Policy Agent. This also adds some \
new useful methods for clients.

 M  +4 -1      CMakeLists.txt  
 A             org.kde.Solid.PowerManagement.PolicyAgent.xml  
 M  +43 -1     powermanagement.cpp  
 M  +24 -0     powermanagement.h  
 M  +10 -1     powermanagement_p.h  


--- trunk/KDE/kdelibs/solid/solid/CMakeLists.txt #1194422:1194423
@@ -296,10 +296,12 @@
 
 set_source_files_properties( org.freedesktop.PowerManagement.xml
                              org.freedesktop.PowerManagement.Inhibit.xml
+                             org.kde.Solid.PowerManagement.PolicyAgent.xml
                              PROPERTIES NO_NAMESPACE TRUE)
 
 qt4_add_dbus_interfaces(solid_LIB_SRCS org.freedesktop.PowerManagement.xml
-                        org.freedesktop.PowerManagement.Inhibit.xml )
+                        org.freedesktop.PowerManagement.Inhibit.xml
+                        org.kde.Solid.PowerManagement.PolicyAgent.xml)
 
 qt4_add_dbus_interface(solid_LIB_SRCS org.kde.Solid.Networking.Client.xml
                        org_kde_solid_networking_client)
@@ -341,6 +343,7 @@
 install(TARGETS solid EXPORT kdelibsLibraryTargets ${INSTALL_TARGETS_DEFAULT_ARGS})
 
 install(FILES org.kde.Solid.Networking.Client.xml DESTINATION \
${DBUS_INTERFACES_INSTALL_DIR}) +install(FILES \
org.kde.Solid.PowerManagement.PolicyAgent.xml DESTINATION \
${DBUS_INTERFACES_INSTALL_DIR})  install(FILES org.freedesktop.PowerManagement.xml \
DESTINATION ${DBUS_INTERFACES_INSTALL_DIR})  install(FILES \
org.freedesktop.PowerManagement.Inhibit.xml DESTINATION \
${DBUS_INTERFACES_INSTALL_DIR})  
--- trunk/KDE/kdelibs/solid/solid/powermanagement.cpp #1194422:1194423
@@ -31,6 +31,9 @@
     : managerIface("org.freedesktop.PowerManagement",
                    "/org/freedesktop/PowerManagement",
                    QDBusConnection::sessionBus()),
+      policyAgentIface("org.kde.Solid.PowerManagement.PolicyAgent",
+                       "/org/kde/Solid/PowerManagement/PolicyAgent",
+                       QDBusConnection::sessionBus()),
       inhibitIface("org.freedesktop.PowerManagement.Inhibit",
                    "/org/freedesktop/PowerManagement/Inhibit",
                    QDBusConnection::sessionBus())
@@ -92,8 +95,15 @@
 
 int Solid::PowerManagement::beginSuppressingSleep(const QString &reason)
 {
-    QDBusReply<uint> reply = globalPowerManager->inhibitIface.Inhibit(
+    QDBusReply<uint> reply;
+    if (globalPowerManager->policyAgentIface.isValid()) {
+        reply = globalPowerManager->policyAgentIface.AddInhibition(
+            (uint)PowerManagementPrivate::InterruptSession,
         QCoreApplication::applicationName(), reason);
+    } else {
+        // Fallback to the fd.o Inhibit interface
+        reply = globalPowerManager->inhibitIface.Inhibit(QCoreApplication::applicationName(), \
reason); +    }
 
     if (reply.isValid())
         return reply;
@@ -103,9 +113,41 @@
 
 bool Solid::PowerManagement::stopSuppressingSleep(int cookie)
 {
+    if (globalPowerManager->policyAgentIface.isValid()) {
+        return globalPowerManager->policyAgentIface.ReleaseInhibition(cookie).isValid();
 +    } else {
+        // Fallback to the fd.o Inhibit interface
     return globalPowerManager->inhibitIface.UnInhibit(cookie).isValid();
 }
+}
 
+int Solid::PowerManagement::beginSuppressingScreenPowerManagement(const QString& \
reason) +{
+    if (globalPowerManager->policyAgentIface.isValid()) {
+        QDBusReply<uint> reply = globalPowerManager->policyAgentIface.AddInhibition(
+            (uint)PowerManagementPrivate::ChangeScreenSettings,
+            QCoreApplication::applicationName(), reason);
+
+        if (reply.isValid())
+            return reply;
+        else
+            return -1;
+    } else {
+        // No way to fallback on something, hence return failure
+        return -1;
+    }
+}
+
+bool Solid::PowerManagement::stopSuppressingScreenPowerManagement(int cookie)
+{
+    if (globalPowerManager->policyAgentIface.isValid()) {
+        return globalPowerManager->policyAgentIface.ReleaseInhibition(cookie).isValid();
 +    } else {
+        // No way to fallback on something, hence return failure
+        return false;
+    }
+}
+
 Solid::PowerManagement::Notifier *Solid::PowerManagement::notifier()
 {
     return globalPowerManager;
--- trunk/KDE/kdelibs/solid/solid/powermanagement.h #1194422:1194423
@@ -98,6 +98,30 @@
          */
         SOLID_EXPORT bool stopSuppressingSleep(int cookie);
 
+        /**
+         * Tell the power management subsystem to suppress automatic screen power \
management until +         * further notice.
+         *
+         * @param reason Give a reason for not allowing screen power management, to \
be used in giving user feedback +         * about why a screen power management event \
was prevented +         * @return a 'cookie' value representing the suppression \
request.  Used by the power manager to +         * track the application's \
outstanding suppression requests.  Returns -1 if the request was +         * denied.
+         *
+         * @since 4.6
+         */
+        SOLID_EXPORT int beginSuppressingScreenPowerManagement(const QString &reason \
= QString()); +
+        /**
+         * Tell the power management that a particular screen power management \
suppression is no longer needed.  When +         * no more suppressions are active, \
the system will be free to handle screen power management automatically +         * \
@param cookie The cookie acquired when requesting screen power management suppression \
+         * @return true if the suppression was stopped, false if an invalid cookie \
was given +         *
+         * @since 4.6
+         */
+        SOLID_EXPORT bool stopSuppressingScreenPowerManagement(int cookie);
+
         class SOLID_EXPORT Notifier : public QObject
         {
             Q_OBJECT
--- trunk/KDE/kdelibs/solid/solid/powermanagement_p.h #1194422:1194423
@@ -23,8 +23,9 @@
 
 #include "powermanagement.h"
 
+#include "inhibitinterface.h"
 #include "powermanagementinterface.h"
-#include "inhibitinterface.h"
+#include "policyagentinterface.h"
 
 namespace Solid
 {
@@ -32,6 +33,13 @@
     {
         Q_OBJECT
     public:
+        enum RequiredPolicy {
+            None = 0,
+            InterruptSession = 1,
+            ChangeProfile = 2,
+            ChangeScreenSettings = 4
+        };
+
         PowerManagementPrivate();
         ~PowerManagementPrivate();
 
@@ -42,6 +50,7 @@
 
     public:
         OrgFreedesktopPowerManagementInterface managerIface;
+        OrgKdeSolidPowerManagementPolicyAgentInterface policyAgentIface;
         OrgFreedesktopPowerManagementInhibitInterface inhibitIface;
 
         bool powerSaveStatus;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic