Merge lp:~lool/qtpowerd/misc-fixes into lp:~music-app-dev/qtpowerd/trunk

Proposed by Loïc Minier
Status: Merged
Merged at revision: 5
Proposed branch: lp:~lool/qtpowerd/misc-fixes
Merge into: lp:~music-app-dev/qtpowerd/trunk
Diff against target: 233 lines (+83/-47)
7 files modified
QtPowerd.cpp (+50/-23)
QtPowerd.h (+12/-7)
debian/changelog (+6/-0)
plugin.cpp (+6/-6)
plugin.h (+3/-4)
qmldir (+2/-3)
qtpowerd.pro (+4/-4)
To merge this branch: bzr merge lp:~lool/qtpowerd/misc-fixes
Reviewer Review Type Date Requested Status
David Planella Needs Information
Review via email: mp+188718@code.launchpad.net

Commit message

Misc fixes allowing qtpowerd to function with music-app.

Description of the change

Hi there,

Misc fixes in here, but more importantly this fixes the requestSysState() and clearSysState() so that it basically works.

On the long run, I think we ought to:
* never use this from apps since some backgrond music service should do it for them
* allow for multiple locks or various types, even if apps should not take them most of the time, sometimes it makes sense; there are other reasons for bindings such as tracking display state changes (as unity8 Shell does)
* allow naming the locks (currently qtpowerd hardcodes "music-app-background")
* move this to powerd itself to provide; this would allow using the header

However I think this is good enough for music-app for 13.10 :-)

I might try to fix some of the other bits there if time allow.

I also wonder if the name Powerd 0.1 might break unity8's Powerd 0.1 plugin.

To post a comment you must log in.
lp:~lool/qtpowerd/misc-fixes updated
17. By Loïc Minier

Rename from Powerd to QtPowerd to avoid clash with Unity8 Shell plugi.

18. By Loïc Minier

Bump to 0.2.

Revision history for this message
Loïc Minier (lool) wrote :

So indeed this clashed with Unity8 Shell's powerd plugin; fixed in r17/r18.

Revision history for this message
Victor Thompson (vthompson) wrote :

The plugin is under Ubuntu.Powerd, so I don't think it should break Unity's plugin. Changing the version to 0.2 doesn't necessary fix the issue--if it exists--however. Maybe we should rename the plugin to something directly related to "keepAlive"?

Revision history for this message
Victor Thompson (vthompson) wrote :

Nevermind my previous comment. I thought you bumped the version to deconflict with the Unity plugin. Renaming the plugin as you are should accomplish this.

Revision history for this message
David Planella (dpm) wrote :

I guess another solution would have been that we install it as a private plugin: the settings app does that for example, each panel being a private plugin installed within the app and not accessible by other applications.

So either the music app or Unity could have installed their powerd plugin privately to prevent it being picked up by other apps.

The question that comes to mind is: could we not just have one single powerd plugin that can be used by both Unity and the Music app?

review: Needs Information

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== renamed file 'Powerd.cpp' => 'QtPowerd.cpp'
--- Powerd.cpp 2013-09-25 23:31:51 +0000
+++ QtPowerd.cpp 2013-10-01 21:50:24 +0000
@@ -16,39 +16,66 @@
16 * Author: Michael Terry <michael.terry@canonical.com>16 * Author: Michael Terry <michael.terry@canonical.com>
17 */17 */
1818
19#include "Powerd.h"19#include <QtDebug>
2020
21Powerd::Powerd(QObject* parent)21/* FIXME should really include powerd.h, but not available right now */
22//#include <powerd.h>
23enum SysPowerStates {
24 //Note that callers will be notified of suspend state changes
25 //but may not request this state.
26 POWERD_SYS_STATE_SUSPEND = 0,
27
28 //The Active state will prevent system suspend
29 POWERD_SYS_STATE_ACTIVE,
30
31 POWERD_NUM_POWER_STATES
32};
33
34#include "QtPowerd.h"
35
36// XXX this should be set by QML app; in fact it could hold multiple ones
37#define LOCK_NAME "music-app-background"
38
39QtPowerd::QtPowerd(QObject* parent)
22 : QObject(parent),40 : QObject(parent),
23 m_powerd(NULL)41 m_keepAlive(false),
42 m_qtpowerd(NULL)
24{43{
25 m_powerd = new QDBusInterface("com.canonical.powerd",44 m_qtpowerd = new QDBusInterface("com.canonical.powerd",
26 "/com/canonical/powerd",45 "/com/canonical/powerd",
27 "com.canonical.powerd",46 "com.canonical.powerd",
28 QDBusConnection::SM_BUSNAME(), this);47 QDBusConnection::SM_BUSNAME(), this);
29}48}
3049
31bool Powerd::keepAlive() const50bool QtPowerd::keepAlive() const
32{51{
33 return m_keepAlive;52 return m_keepAlive;
34}53}
3554
36void Powerd::setKeepAlive(bool keep)55void QtPowerd::setKeepAlive(const bool keep)
37{56{
38 m_keepAlive = keep;57 if (m_keepAlive == keep) {
58 // nothing to do
59 return;
60 }
61
39 if (keep) {62 if (keep) {
40 m_cookie = m_powerd->connection().connect("com.canonical.powerd",63 QDBusReply<QString> reply = m_qtpowerd->call("requestSysState",
41 "/com/canonical/powerd",64 LOCK_NAME,
42 "com.canonical.powerd",65 POWERD_SYS_STATE_ACTIVE);
43 "RequestSysState",66 if (!reply.isValid()) {
44 this,67 qCritical() << "requestSysState:" << reply.error();
45 METHOD(requestSysState("music-app-background", 1)));68 return;
69 }
70 m_cookie = reply.value();
46 } else {71 } else {
47 m_cookie = m_powerd->connection().connect("com.canonical.powerd",72 QDBusReply<void> reply = m_qtpowerd->call("clearSysState", m_cookie);
48 "/com/canonical/powerd",73 if (!reply.isValid()) {
49 "com.canonical.powerd",74 qCritical() << "clearSysState:" << reply.error();
50 "ClearSysState",75 return;
51 this,76 }
52 METHOD(clearSysState(m_cookie)));
53 }77 }
78
79 m_keepAlive = keep;
80 Q_EMIT keepAliveChanged();
54}81}
5582
=== renamed file 'Powerd.h' => 'QtPowerd.h'
--- Powerd.h 2013-09-25 13:04:12 +0000
+++ QtPowerd.h 2013-10-01 21:50:24 +0000
@@ -17,26 +17,31 @@
17 * Michael Terry <michael.terry@canonical.com>17 * Michael Terry <michael.terry@canonical.com>
18 */18 */
1919
20#ifndef UBUNTU_POWERD_H20#ifndef QTPOWERD_H
21#define UBUNTU_POWERD_H21#define QTPOWERD_H
2222
23#include <QtCore/QObject>23#include <QtCore/QObject>
24#include <QtDBus/QDBusInterface>24#include <QtDBus/QDBusInterface>
25#include <QtDBus/QDBusReply>
2526
26class Powerd: public QObject27class QtPowerd: public QObject
27{28{
28 Q_OBJECT29 Q_OBJECT
29 Q_PROPERTY(bool keepAlive READ keepAlive WRITE setKeepAlive NOTIFY keepAliveChanged)30 Q_PROPERTY(bool keepAlive READ keepAlive WRITE setKeepAlive NOTIFY keepAliveChanged)
31
30public:32public:
31 explicit Powerd(QObject *parent = 0);33 explicit QtPowerd(QObject *parent = 0);
34
32 bool keepAlive() const;35 bool keepAlive() const;
33 void setKeepAlive(bool keepAlive);36 void setKeepAlive(const bool keepAlive);
34signals:37
38Q_SIGNALS:
35 void keepAliveChanged();39 void keepAliveChanged();
40
36private:41private:
37 QString m_cookie;42 QString m_cookie;
38 bool m_keepAlive;43 bool m_keepAlive;
39 QDBusInterface *m_powerd;44 QDBusInterface *m_qtpowerd;
40};45};
4146
42#endif47#endif
4348
=== modified file 'debian/changelog'
--- debian/changelog 2013-09-25 13:04:12 +0000
+++ debian/changelog 2013-10-01 21:50:24 +0000
@@ -1,3 +1,9 @@
1qtpowerd (0.2-0ubuntu1) UNRELEASED; urgency=low
2
3 * Bump to 0.2.
4
5 -- Loïc Minier <loic.minier@ubuntu.com> Tue, 01 Oct 2013 23:11:10 +0200
6
1qtpowerd (0.0.20130924-0ubuntu1) saucy; urgency=low7qtpowerd (0.0.20130924-0ubuntu1) saucy; urgency=low
28
3 * Initial release.9 * Initial release.
410
=== modified file 'plugin.cpp'
--- plugin.cpp 2013-09-26 00:12:18 +0000
+++ plugin.cpp 2013-10-01 21:50:24 +0000
@@ -18,19 +18,19 @@
18 */18 */
1919
20#include "plugin.h"20#include "plugin.h"
21#include "Powerd.h"21#include "QtPowerd.h"
2222
23#include <QtQml/qqml.h>23#include <QtQml/qqml.h>
2424
25static QObject *powerd_provider(QQmlEngine *engine, QJSEngine *scriptEngine)25static QObject *qtpowerd_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
26{26{
27 Q_UNUSED(engine)27 Q_UNUSED(engine)
28 Q_UNUSED(scriptEngine)28 Q_UNUSED(scriptEngine)
29 return new Powerd();29 return new QtPowerd();
30}30}
3131
32void PowerdPlugin::registerTypes(const char *uri)32void QtPowerdPlugin::registerTypes(const char *uri)
33{33{
34 Q_ASSERT(uri == QLatin1String("Powerd"));34 Q_ASSERT(uri == QLatin1String("QtPowerd"));
35 qmlRegisterSingletonType<Powerd>(uri, 0, 1, "Powerd", powerd_provider);35 qmlRegisterSingletonType<QtPowerd>(uri, 0, 1, "QtPowerd", qtpowerd_provider);
36}36}
3737
=== modified file 'plugin.h'
--- plugin.h 2013-09-25 13:04:12 +0000
+++ plugin.h 2013-10-01 21:50:24 +0000
@@ -17,13 +17,12 @@
17 * Michael Terry <michael.terry@canonical.com>17 * Michael Terry <michael.terry@canonical.com>
18 */18 */
1919
20#ifndef POWER_PLUGIN_H20#ifndef QTPOWERD_PLUGIN_H
21#define POWER_PLUGIN_H21#define QTPOWERD_PLUGIN_H
2222
23#include <QtQml/QQmlEngine>
24#include <QtQml/QQmlExtensionPlugin>23#include <QtQml/QQmlExtensionPlugin>
2524
26class PowerdPlugin : public QQmlExtensionPlugin25class QtPowerdPlugin : public QQmlExtensionPlugin
27{26{
28 Q_OBJECT27 Q_OBJECT
29 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")28 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
3029
=== modified file 'qmldir'
--- qmldir 2013-09-25 13:04:12 +0000
+++ qmldir 2013-10-01 21:50:24 +0000
@@ -1,3 +1,2 @@
1module Ubuntu.Powerd1module QtPowerd
2plugin qmlpowerdplugin2plugin qmlqtpowerdplugin
3typeinfo plugin.qmltypes
43
=== modified file 'qtpowerd.pro'
--- qtpowerd.pro 2013-09-30 14:38:19 +0000
+++ qtpowerd.pro 2013-10-01 21:50:24 +0000
@@ -5,14 +5,14 @@
55
6PKGCONFIG =6PKGCONFIG =
77
8TARGET = qmlpowerdplugin8TARGET = qmlqtpowerdplugin
9PLUGIN_IMPORT_PATH = Ubuntu/Powerd.0.19PLUGIN_IMPORT_PATH = QtPowerd.0.1
1010
11SOURCES += Powerd.cpp plugin.cpp11SOURCES += QtPowerd.cpp plugin.cpp
1212
13DEFINES += "SM_BUSNAME=systemBus"13DEFINES += "SM_BUSNAME=systemBus"
1414
15HEADERS += Powerd.h plugin.h15HEADERS += QtPowerd.h plugin.h
1616
17equals(QT_MAJOR_VERSION, 5): target.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH17equals(QT_MAJOR_VERSION, 5): target.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH
1818

Subscribers

People subscribed via source and target branches

to all changes: