From kde-devel Sun Mar 07 22:57:52 2010 From: Holger Macht Date: Sun, 07 Mar 2010 22:57:52 +0000 To: kde-devel Subject: [PATCH] powerdevil-fix-SetPowerSave.patch Message-Id: <4B942F70.9090909 () homac ! de> X-MARC-Message: https://marc.info/?l=kde-devel&m=126800285531900 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--------------020806030707080603060506" This is a multi-part message in MIME format. --------------020806030707080603060506 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Current powerdevil and solid implementation has the concept of schemes, not to be confused with profiles, which is currently hard coded to "powersave" and "performance". The only thing this is doing is to map powersave/performance to the SetPowerSave HAL method which either enabled or disables certain system level power management functionality. I have no idea why this was implemented in this way and lacks any basis for me. The SetPowerSave HAL method is not intended, and will never be used for any kind of scheme methodology. Even more recent system application like DeviceKit-power/upower lack things of this kind. With this patch I propose to remove the "scheme"-stuff and implement the pure SetPowerSave method to be just a toggle, on or off. This will result in a more comprehensible implementation. Regards, Holger --------------020806030707080603060506 Content-Type: text/x-patch; name="powerdevil-fix-SetPowerSave.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="powerdevil-fix-SetPowerSave.patch" Index: KDE/kdebase/workspace/powerdevil/daemon/PowerDevilDaemon.cpp =================================================================== --- KDE.orig/kdebase/workspace/powerdevil/daemon/PowerDevilDaemon.cpp +++ KDE/kdebase/workspace/powerdevil/daemon/PowerDevilDaemon.cpp @@ -361,7 +361,7 @@ void PowerDevilDaemon::applyProfile() Solid::Control::PowerManager::setBrightness(settings->readEntry("brightness").toInt()); d->brightness = settings->readEntry("brightness").toInt(); - Solid::Control::PowerManager::setScheme(settings->readEntry("scheme")); + Solid::Control::PowerManager::setPowerSave(settings->readEntry("setPowerSave", true)); // Compositing!! @@ -1169,18 +1169,13 @@ QVariantMap PowerDevilDaemon::getSupport return retlist; } -QStringList PowerDevilDaemon::getSupportedSchemes() -{ - return Solid::Control::PowerManager::supportedSchemes(); -} - -void PowerDevilDaemon::setPowersavingScheme(const QString &scheme) +void PowerDevilDaemon::setPowerSave(bool powersave) { if (!checkIfCurrentSessionActive()) { return; } - Solid::Control::PowerManager::setScheme(scheme); + Solid::Control::PowerManager::setPowerSave(powersave); } void PowerDevilDaemon::suspend(int method) Index: KDE/kdebase/workspace/powerdevil/daemon/PowerDevilDaemon.h =================================================================== --- KDE.orig/kdebase/workspace/powerdevil/daemon/PowerDevilDaemon.h +++ KDE/kdebase/workspace/powerdevil/daemon/PowerDevilDaemon.h @@ -46,7 +46,7 @@ public Q_SLOTS: void streamData(); void suspend(int method); - void setPowersavingScheme(const QString &scheme); + void setPowerSave(bool powersave); void setBrightness(int value); void turnOffScreen(); @@ -54,7 +54,6 @@ public Q_SLOTS: deleteLater(); } - QStringList getSupportedSchemes(); QVariantMap getSupportedSuspendMethods(); SuspensionLockHandler *lockHandler(); Index: KDE/kdebase/workspace/powerdevil/daemon/org.kde.PowerDevil.xml =================================================================== --- KDE.orig/kdebase/workspace/powerdevil/daemon/org.kde.PowerDevil.xml +++ KDE/kdebase/workspace/powerdevil/daemon/org.kde.PowerDevil.xml @@ -19,8 +19,8 @@ - - + + @@ -31,9 +31,6 @@ - - - Index: KDE/kdebase/workspace/powerdevil/default.powerdevilprofiles =================================================================== --- KDE.orig/kdebase/workspace/powerdevil/default.powerdevilprofiles +++ KDE/kdebase/workspace/powerdevil/default.powerdevilprofiles @@ -16,7 +16,7 @@ idleTime=10 lidAction=2 name=Aggressive Powersave powerButtonAction=2 -scheme=powersaving +setPowerSave=true scriptpath= sleepButtonAction=2 turnOffIdle=true @@ -40,7 +40,7 @@ idleTime=99 lidAction=16 name=Performance powerButtonAction=32 -scheme=performance +setPowerSave=false scriptpath= sleepButtonAction=2 turnOffIdle=false @@ -64,7 +64,7 @@ idleTime=15 lidAction=2 name=Powersave powerButtonAction=32 -scheme=powersaving +setPowerSave=true scriptpath= sleepButtonAction=2 turnOffIdle=true @@ -87,7 +87,7 @@ idleAction=0 idleTime=50 lidAction=0 powerButtonAction=0 -scheme=powersaving +setPowerSave=true scriptpath= sleepButtonAction=0 turnOffIdle=false @@ -111,7 +111,7 @@ idleTime=5 lidAction=2 name=Xtreme Powersave powerButtonAction=2 -scheme=powersaving +setPowerSave=true scriptpath= sleepButtonAction=2 turnOffIdle=true Index: KDE/kdebase/workspace/powerdevil/kcmodule/capabilitiesPage.ui =================================================================== --- KDE.orig/kdebase/workspace/powerdevil/kcmodule/capabilitiesPage.ui +++ KDE/kdebase/workspace/powerdevil/kcmodule/capabilitiesPage.ui @@ -65,34 +65,20 @@ - - - Scheme support - - - - - - - - - - - Qt::Horizontal - + Supported suspend methods - + @@ -105,28 +91,14 @@ - - - - Supported schemes - - - - - - - - - - - + Qt::Horizontal - + Support for DPMS @@ -139,14 +111,14 @@ - + - + Checks if ConsoleKit is active on your system @@ -159,28 +131,28 @@ - + - + Qt::Horizontal - + Status - + Index: KDE/kdebase/workspace/powerdevil/kcmodule/EditPage.cpp =================================================================== --- KDE.orig/kdebase/workspace/powerdevil/kcmodule/EditPage.cpp +++ KDE/kdebase/workspace/powerdevil/kcmodule/EditPage.cpp @@ -143,8 +143,6 @@ void EditPage::fillUi() powerButtonCombo->addItem(KIcon("system-suspend"), i18n("Standby"), (int) Standby); } - schemeCombo->addItems(Solid::Control::PowerManager::supportedSchemes()); - reloadAvailableProfiles(); tabWidget->setTabIcon(0, KIcon("preferences-system-session-services")); @@ -180,7 +178,7 @@ void EditPage::fillUi() connect(dimDisplayOnIdle, SIGNAL(stateChanged(int)), SLOT(enableBoxes())); - connect(schemeCombo, SIGNAL(currentIndexChanged(int)), SLOT(setProfileChanged())); + connect(SetPowerSaveCheckBox, SIGNAL(stateChanged(int)), SLOT(setProfileChanged())); connect(scriptRequester, SIGNAL(textChanged(const QString&)), SLOT(setProfileChanged())); #ifdef HAVE_DPMS @@ -273,7 +271,8 @@ void EditPage::loadProfile() dimOnIdleTime->setValue(group->readEntry("dimOnIdleTime").toInt()); idleTime->setValue(group->readEntry("idleTime").toInt()); idleCombo->setCurrentIndex(idleCombo->findData(group->readEntry("idleAction").toInt())); - schemeCombo->setCurrentIndex(schemeCombo->findText(group->readEntry("scheme"))); + SetPowerSaveCheckBox->setChecked(group->readEntry("setPowerSave", true)); + scriptRequester->setUrl(KUrl::fromPath(group->readEntry("scriptpath"))); laptopClosedCombo->setCurrentIndex(laptopClosedCombo->findData(group->readEntry("lidAction").toInt())); @@ -325,7 +324,7 @@ void EditPage::saveProfile(const QString group->writeEntry("lidAction", laptopClosedCombo->itemData(laptopClosedCombo->currentIndex()).toInt()); group->writeEntry("sleepButtonAction", sleepButtonCombo->itemData(sleepButtonCombo->currentIndex()).toInt()); group->writeEntry("powerButtonAction", powerButtonCombo->itemData(powerButtonCombo->currentIndex()).toInt()); - group->writeEntry("scheme", schemeCombo->currentText()); + group->writeEntry("setPowerSave", SetPowerSaveCheckBox->isChecked()); group->writeEntry("scriptpath", scriptRequester->url().path()); group->writeEntry("disableCompositing", disableCompositing->isChecked()); Index: KDE/kdebase/workspace/powerdevil/kcmodule/profileEditPage.ui =================================================================== --- KDE.orig/kdebase/workspace/powerdevil/kcmodule/profileEditPage.ui +++ KDE/kdebase/workspace/powerdevil/kcmodule/profileEditPage.ui @@ -471,20 +471,29 @@ QFormLayout::ExpandingFieldsGrow - - + + + + true + + + Qt::LeftToRight + - System powersaving scheme: + Enable system power saving - - schemeCombo + + true + + + false - - + + - + 0 0 @@ -497,7 +506,7 @@ - + When loading profile execute: @@ -507,27 +516,7 @@ - - - - - 0 - 0 - - - - - 250 - 16777215 - - - - - schemeCombo - label_20 - label_19 - scriptRequester Index: KDE/kdebase/workspace/libs/solid/control/ifaces/powermanager.h =================================================================== --- KDE.orig/kdebase/workspace/libs/solid/control/ifaces/powermanager.h +++ KDE/kdebase/workspace/libs/solid/control/ifaces/powermanager.h @@ -58,39 +58,6 @@ namespace Ifaces */ virtual ~PowerManager(); - - /** - * Retrieves the list of power management schemes available on this system. - * - * @return the available power management schemes - */ - virtual QStringList supportedSchemes() const = 0; - - /** - * Retrieves a localized description corresponding to the given scheme. - * - * @param schemeName the name of the scheme we request the description for - * @return the associated description - */ - virtual QString schemeDescription(const QString &schemeName) const = 0; - - /** - * Retrieves the name of the current power management scheme used - * by the system. - * - * @return the current scheme - */ - virtual QString scheme() const = 0; - - /** - * Changes the current power management scheme. - * - * @param name the name of the new scheme - * @return true if the scheme change succeeded, false otherwise - */ - virtual bool setScheme(const QString &name) = 0; - - /** * Retrieves the current state of the system battery. * @@ -158,6 +125,15 @@ namespace Ifaces virtual Solid::Control::PowerManager::CpuFreqPolicy cpuFreqPolicy() const = 0; /** + * Changes the current power management policy of the system. + * + * @param powersave if powersaving should be anabled + * @return true if the policy change succeeded, false otherwise + * @see Solid::Control::PowerManager::setPowerSave + */ + virtual bool setPowerSave(bool powersave) = 0; + + /** * Changes the current CPU frequency policy of the system. * * @param newPolicy the new policy @@ -209,13 +185,6 @@ namespace Ifaces Q_SIGNALS: /** - * This signal is emitted when the power management scheme has changed. - * - * @param newScheme the new scheme name - */ - void schemeChanged(QString newScheme); - - /** * This signal is emitted when the AC adapter is plugged or unplugged. * * @param newState the new state of the AC adapter, it's one of the Index: KDE/kdebase/workspace/libs/solid/control/powermanager.cpp =================================================================== --- KDE.orig/kdebase/workspace/libs/solid/control/powermanager.cpp +++ KDE/kdebase/workspace/libs/solid/control/powermanager.cpp @@ -34,8 +34,6 @@ Solid::Control::PowerManagerPrivate::Pow loadBackend("Power Management", "SolidPowerManager", "Solid::Control::Ifaces::PowerManager"); if (managerBackend()!=0) { - connect(managerBackend(), SIGNAL(schemeChanged(QString)), - this, SIGNAL(schemeChanged(QString))); connect(managerBackend(), SIGNAL(acAdapterStateChanged(int)), this, SIGNAL(acAdapterStateChanged(int))); connect(managerBackend(), SIGNAL(batteryStateChanged(int)), @@ -53,27 +51,10 @@ Solid::Control::PowerManagerPrivate::~Po { } -QStringList Solid::Control::PowerManager::supportedSchemes() +bool Solid::Control::PowerManager::setPowerSave(bool powersave) { return_SOLID_CALL(Ifaces::PowerManager *, globalPowerManager->managerBackend(), - QStringList(), supportedSchemes()); -} - -QString Solid::Control::PowerManager::schemeDescription(const QString &schemeName) -{ - return_SOLID_CALL(Ifaces::PowerManager *, globalPowerManager->managerBackend(), - QString(), schemeDescription(schemeName)); -} - -QString Solid::Control::PowerManager::scheme() -{ - return_SOLID_CALL(Ifaces::PowerManager *, globalPowerManager->managerBackend(), QString(), scheme()); -} - -bool Solid::Control::PowerManager::setScheme(const QString &name) -{ - return_SOLID_CALL(Ifaces::PowerManager *, globalPowerManager->managerBackend(), - false, setScheme(name)); + false, setPowerSave(powersave)); } Solid::Control::PowerManager::BatteryState Solid::Control::PowerManager::batteryState() Index: KDE/kdebase/workspace/libs/solid/control/powermanager.h =================================================================== --- KDE.orig/kdebase/workspace/libs/solid/control/powermanager.h +++ KDE/kdebase/workspace/libs/solid/control/powermanager.h @@ -119,37 +119,13 @@ namespace Control typedef QHash BrightnessControlsList; - - /** - * Retrieves the list of power management schemes available on this system. - * - * @return the available power management schemes - */ - SOLIDCONTROL_EXPORT QStringList supportedSchemes(); - - /** - * Retrieves a localized description corresponding to the given scheme. - * - * @param schemeName the name of the scheme we request the description for - * @return the associated description - */ - SOLIDCONTROL_EXPORT QString schemeDescription(const QString &schemeName); - /** - * Retrieves the name of the current power management scheme used - * by the system. + * Changes the current power management policy of the system * - * @return the current scheme - */ - SOLIDCONTROL_EXPORT QString scheme(); - - /** - * Changes the current power management scheme. - * - * @param name the name of the new scheme - * @return true if the scheme change succeeded, false otherwise + * @param true if powersaving should be enabled + * @return true if the policy change succeeded, false otherwise */ - SOLIDCONTROL_EXPORT bool setScheme(const QString &name); + SOLIDCONTROL_EXPORT bool setPowerSave(bool powersave); /** @@ -273,13 +249,6 @@ namespace Control Q_OBJECT Q_SIGNALS: /** - * This signal is emitted when the power management scheme has changed. - * - * @param newScheme the new scheme name - */ - void schemeChanged(QString newScheme); - - /** * This signal is emitted when the AC adapter is plugged or unplugged. * * @param newState the new state of the AC adapter, it's one of the Index: KDE/kdebase/workspace/powerdevil/kcmodule/CapabilitiesPage.cpp =================================================================== --- KDE.orig/kdebase/workspace/powerdevil/kcmodule/CapabilitiesPage.cpp +++ KDE/kdebase/workspace/powerdevil/kcmodule/CapabilitiesPage.cpp @@ -132,26 +132,6 @@ void CapabilitiesPage::fillCapabilities( supportedMethods->setText(sMethods); - if (!Solid::Control::PowerManager::supportedSchemes().isEmpty()) { - isSchemeSupported->setPixmap(KIcon("dialog-ok-apply").pixmap(16, 16)); - } else { - isSchemeSupported->setPixmap(KIcon("dialog-cancel").pixmap(16, 16)); - } - - QString schemes; - - foreach(const QString &scheme, Solid::Control::PowerManager::supportedSchemes()) { - schemes.append(scheme + QString(", ")); - } - - if (!schemes.isEmpty()) { - schemes.remove(schemes.length() - 2, 2); - } else { - schemes = i18nc("None", "No methods found"); - } - - supportedSchemes->setText(schemes); - bool dpms = false; #ifdef HAVE_DPMS Index: KDE/kdebase/workspace/solid/hal/halpower.cpp =================================================================== --- KDE.orig/kdebase/workspace/solid/hal/halpower.cpp +++ KDE/kdebase/workspace/solid/hal/halpower.cpp @@ -72,52 +72,8 @@ HalPower::~HalPower() qDeleteAll(m_buttons); } -QStringList HalPower::supportedSchemes() const +bool HalPower::setPowerSave(bool powersave) { - return QStringList() << "performance" << "powersaving"; -} - -QString HalPower::schemeDescription(const QString &schemeName) const -{ - if (schemeName=="performance") - { - return "Use all the performances of the system"; - } - else if (schemeName=="powersaving") - { - return "Try to keep as much power as possible to improve battery life"; - } - else - { - return QString(); - } - - return QString(); -} - -QString HalPower::scheme() const -{ - // FIXME: We miss an accessor in HAL to make scheme management useful - return QString(); -} - -bool HalPower::setScheme(const QString &name) -{ - bool powersave; - - if (name=="powersaving") - { - powersave = true; - } - else if (name=="performance") - { - powersave = false; - } - else - { - return false; - } - QDBusReply reply = m_halPowerManagement.call("SetPowerSave", powersave); if (reply.isValid()) Index: KDE/kdebase/workspace/solid/hal/halpower.h =================================================================== --- KDE.orig/kdebase/workspace/solid/hal/halpower.h +++ KDE/kdebase/workspace/solid/hal/halpower.h @@ -40,10 +40,7 @@ public: HalPower(QObject *parent, const QVariantList &args); virtual ~HalPower(); - virtual QStringList supportedSchemes() const; - virtual QString schemeDescription(const QString &schemeName) const; - virtual QString scheme() const; - virtual bool setScheme(const QString &name); + virtual bool setPowerSave(bool powersave); virtual Solid::Control::PowerManager::BatteryState batteryState() const; virtual int batteryChargePercent() const; Index: KDE/kdebase/workspace/solid/solidshell/solid-powermanagement.cpp =================================================================== --- KDE.orig/kdebase/workspace/solid/solidshell/solid-powermanagement.cpp +++ KDE/kdebase/workspace/solid/solidshell/solid-powermanagement.cpp @@ -196,19 +196,15 @@ int main(int argc, char **argv) cout << endl << i18n("Syntax:") << endl << endl; - cout << " solid-powermanagement query (suspend|scheme|cpufreq)" << endl; + cout << " solid-powermanagement query (suspend|cpufreq)" << endl; cout << i18n(" # List a particular set of information regarding power management.\n" " # - If the 'suspend' option is specified, give the list of suspend\n" " # methods supported by the system\n" - " # - If the 'scheme' option is specified, give the list of\n" - " # power management schemes supported by this system\n" " # - If the 'cpufreq' option is specified, give the list of\n" " # supported CPU frequency policies\n") << endl; - cout << " solid-powermanagement set (scheme|cpufreq) 'value'" << endl; + cout << " solid-powermanagement set (cpufreq) 'value'" << endl; cout << i18n(" # Set power management options of the system.\n" - " # - If the 'scheme' option is specified, the power management\n" - " # scheme set corresponds to 'value'\n" " # - If the 'cpufreq' option is specified, the CPU frequency policy\n" " # set corresponds to 'value'\n") << endl; @@ -257,10 +253,6 @@ bool SolidPowermanagement::doIt() { return shell.powerQuerySuspendMethods(); } - else if (type == "scheme") - { - return shell.powerQuerySchemes(); - } else if (type == "cpufreq") { return shell.powerQueryCpuPolicies(); @@ -276,11 +268,7 @@ bool SolidPowermanagement::doIt() QString type(args->arg(1)); QString value(args->arg(2)); - if (type == "scheme") - { - return shell.powerChangeScheme(value); - } - else if (type == "cpufreq") + if (type == "cpufreq") { return shell.powerChangeCpuPolicy(value); } @@ -380,41 +368,6 @@ bool SolidPowermanagement::powerSuspend( } } -bool SolidPowermanagement::powerQuerySchemes() -{ - QString current = Solid::Control::PowerManager::scheme(); - QStringList schemes = Solid::Control::PowerManager::supportedSchemes(); - - foreach (const QString& scheme, schemes) - { - cout << scheme << " (" << Solid::Control::PowerManager::schemeDescription(scheme) << ")"; - - if (scheme==current) - { - cout << " [*]" << endl; - } - else - { - cout << endl; - } - } - - return true; -} - -bool SolidPowermanagement::powerChangeScheme(const QString &schemeName) -{ - QStringList supported = Solid::Control::PowerManager::supportedSchemes(); - - if (!supported.contains(schemeName)) - { - cerr << i18n("Unsupported scheme: %1" , schemeName) << endl; - return false; - } - - return Solid::Control::PowerManager::setScheme(schemeName); -} - bool SolidPowermanagement::powerQueryCpuPolicies() { Solid::Control::PowerManager::CpuFreqPolicy current = Solid::Control::PowerManager::cpuFreqPolicy(); Index: KDE/kdebase/workspace/solid/solidshell/solid-powermanagement.h =================================================================== --- KDE.orig/kdebase/workspace/solid/solidshell/solid-powermanagement.h +++ KDE/kdebase/workspace/solid/solidshell/solid-powermanagement.h @@ -45,9 +45,6 @@ public: bool powerQuerySuspendMethods(); bool powerSuspend(const QString &method); - bool powerQuerySchemes(); - bool powerChangeScheme(const QString &schemeName); - bool powerQueryCpuPolicies(); bool powerChangeCpuPolicy(const QString &policyName); --------------020806030707080603060506 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe << --------------020806030707080603060506--