Merge lp:~mzanetti/unity8/async-dashcommunicator into lp:unity8

Proposed by Michael Zanetti
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 1277
Merged at revision: 1324
Proposed branch: lp:~mzanetti/unity8/async-dashcommunicator
Merge into: lp:unity8
Diff against target: 635 lines (+350/-37)
23 files modified
CMakeLists.txt (+2/-2)
debian/control (+1/-1)
debian/unity8-private.install (+1/-0)
plugins/LightDM/DBusGreeter.h (+0/-1)
plugins/LightDM/DBusGreeterList.h (+0/-1)
plugins/Unity/DashCommunicator/CMakeLists.txt (+8/-2)
plugins/Unity/DashCommunicator/dashcommunicator.cpp (+27/-18)
plugins/Unity/DashCommunicator/dashcommunicator.h (+17/-7)
plugins/Unity/DashCommunicator/dashconnection.cpp (+33/-0)
plugins/Unity/DashCommunicator/dashconnection.h (+34/-0)
plugins/Unity/Launcher/CMakeLists.txt (+1/-1)
qml/Shell.qml (+7/-0)
src/CMakeLists.txt (+1/-0)
src/Dash/CMakeLists.txt (+2/-0)
src/Panel/CMakeLists.txt (+2/-0)
src/libunity8-private/CMakeLists.txt (+25/-0)
src/libunity8-private/abstractdbusservicemonitor.cpp (+87/-0)
src/libunity8-private/abstractdbusservicemonitor.h (+66/-0)
tests/mocks/Unity/Application/ApplicationManager.cpp (+26/-0)
tests/mocks/Unity/Application/ApplicationManager.h (+6/-2)
tests/mocks/Unity/Application/CMakeLists.txt (+1/-1)
tests/plugins/Unity/Launcher/CMakeLists.txt (+1/-1)
tests/plugins/Unity/Launcher/launchermodeltest.cpp (+2/-0)
To merge this branch: bzr merge lp:~mzanetti/unity8/async-dashcommunicator
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Gerry Boland (community) Needs Fixing
Review via email: mp+235272@code.launchpad.net

Commit message

Make the DashCommunicator async and more flexible to handle a lifecycle-suspended dash

Description of the change

* Are there any related MPs required for this MP to build/function as expected? Please list.

https://code.launchpad.net/~unity-team/qtmir/fix-some-lifecycle-bugs/+merge/234087
https://code.launchpad.net/~mzanetti/unity-api/dashActive/+merge/235273

 * Did you perform an exploratory manual test run of your code change and any related functionality?

yip yip

 * Did you make sure that your branch does not contain spurious tags?

yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?

nope

 * If you changed the UI, has there been a design review?

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1269. By Michael Zanetti

make it compile

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

I think it would be better to only try creating a DBus connection when that DBus instance appears on the bus. I have code doing that working here:
lp:~gerboland/unity8/dbus-async
Welcome to take it

It would also yield code that doesn't depend on AppManager, which I think would be a win here.

review: Needs Fixing
Revision history for this message
Gerry Boland (gerboland) wrote :

I understand now that my branch does not solve all the problems that you are dealing with here - mainly that is the service is SIGSTOPPed, creating a QDbusInterface for it blocks until dbus times out.

Perhaps putting the creation of the QDbusInterface in a separate thread would solve all the issues

1270. By Michael Zanetti

merge Gerry's proposal and make it threaded

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

+ print("*******************************++ dbus call")
oops :)

1271. By Michael Zanetti

make it threaded

1272. By Michael Zanetti

add missing files, drop debug print

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

+void DashConnection::setCurrentScope(const QString &scopeId, bool animate, bool isSwipe)
+{
+ dbusInterface()->asyncCall("SetCurrentScope", scopeId, animate, isSwipe);
+}
dbusInterface() could return null if the service isn't available, you should check for that. Am happy to drop calls if service not available

review: Needs Fixing
1273. By Michael Zanetti

check for a valid interface connection

Revision history for this message
Albert Astals Cid (aacid) wrote :

if (m_dbusInterface) {
    delete m_dbusInterface;
}

You can just remove the if.

review: Needs Fixing
1274. By Michael Zanetti

merge/update

1275. By Michael Zanetti

dashActive -> forceDashActive

Revision history for this message
Michael Zanetti (mzanetti) wrote :

> +void DashConnection::setCurrentScope(const QString &scopeId, bool animate,
> bool isSwipe)
> +{
> + dbusInterface()->asyncCall("SetCurrentScope", scopeId, animate, isSwipe);
> +}
> dbusInterface() could return null if the service isn't available, you should
> check for that. Am happy to drop calls if service not available

done

1276. By Michael Zanetti

minor tweak from review comment

Revision history for this message
Michael Zanetti (mzanetti) wrote :

> if (m_dbusInterface) {
> delete m_dbusInterface;
> }
>
> You can just remove the if.

done

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Looks good from a code pov, need to test it in the device

1277. By Michael Zanetti

update the launcher tests mock appman backend

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

* Did you perform an exploratory manual test run of the code change and any related functionality?
I did

* Did CI run pass? If not, please explain why.
No, requires new unity-api from a different branch

* Did you make sure that the branch does not contain spurious tags?
Yes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-07-23 06:54:10 +0000
3+++ CMakeLists.txt 2014-09-29 14:27:27 +0000
4@@ -64,13 +64,13 @@
5 message(FATAL_ERROR "Could not determine plugin installation dir.")
6 endif()
7
8+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
9+
10 execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=plugindir unity-shell-api OUTPUT_VARIABLE SHELL_PLUGINDIR OUTPUT_STRIP_TRAILING_WHITESPACE)
11 if(SHELL_PLUGINDIR STREQUAL "")
12 message(FATAL_ERROR "Could not determine plugin import dir.")
13 endif()
14
15-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
16-
17 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-permissive -pedantic -Wall -Wextra")
18
19 if ("${CMAKE_BUILD_TYPE}" STREQUAL "release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "relwithdebinfo")
20
21=== modified file 'debian/control'
22--- debian/control 2014-09-26 19:12:24 +0000
23+++ debian/control 2014-09-29 14:27:27 +0000
24@@ -25,7 +25,7 @@
25 libpulse-dev,
26 libqmenumodel-dev (>= 0.2.8),
27 libqt5xmlpatterns5-dev,
28- libunity-api-dev (>= 7.91),
29+ libunity-api-dev (>= 7.92),
30 libusermetricsoutput1-dev,
31 libxcb1-dev,
32 pkg-config,
33
34=== modified file 'debian/unity8-private.install'
35--- debian/unity8-private.install 2014-07-29 16:18:49 +0000
36+++ debian/unity8-private.install 2014-09-29 14:27:27 +0000
37@@ -1,3 +1,4 @@
38+usr/lib/*/libunity8-private.*
39 usr/lib/*/unity8/qml/AccountsService
40 usr/lib/*/unity8/qml/Dash
41 usr/lib/*/unity8/qml/HudClient
42
43=== modified file 'plugins/LightDM/DBusGreeter.h'
44--- plugins/LightDM/DBusGreeter.h 2014-08-27 15:11:21 +0000
45+++ plugins/LightDM/DBusGreeter.h 2014-09-29 14:27:27 +0000
46@@ -21,7 +21,6 @@
47 #include <QObject>
48
49 class Greeter;
50-class QDBusInterface;
51
52 /** This is an internal class used to talk with the indicators.
53 */
54
55=== modified file 'plugins/LightDM/DBusGreeterList.h'
56--- plugins/LightDM/DBusGreeterList.h 2013-12-03 16:55:03 +0000
57+++ plugins/LightDM/DBusGreeterList.h 2014-09-29 14:27:27 +0000
58@@ -21,7 +21,6 @@
59 #include <QObject>
60
61 class Greeter;
62-class QDBusInterface;
63
64 /** This is an internal class used to talk with the indicators.
65 */
66
67=== modified file 'plugins/Unity/DashCommunicator/CMakeLists.txt'
68--- plugins/Unity/DashCommunicator/CMakeLists.txt 2014-07-24 16:02:27 +0000
69+++ plugins/Unity/DashCommunicator/CMakeLists.txt 2014-09-29 14:27:27 +0000
70@@ -1,5 +1,6 @@
71 include_directories(
72 ${CMAKE_CURRENT_SOURCE_DIR}
73+ ${libunity8-private_SOURCE_DIR}
74 )
75
76 set(QMLDASHCOMMUNICATORPLUGIN_SRC
77@@ -7,13 +8,18 @@
78 dbusdashcommunicatorservice.cpp
79 dashcommunicatorservice.cpp
80 dashcommunicator.cpp
81- )
82+ dashconnection.cpp
83+)
84
85 add_library(DashCommunicator-qml MODULE
86 ${QMLDASHCOMMUNICATORPLUGIN_SRC}
87- )
88+)
89
90 qt5_use_modules(DashCommunicator-qml DBus Qml)
91
92+target_link_libraries(DashCommunicator-qml
93+ unity8-private
94+)
95+
96 # export the qmldir and qmltypes files
97 add_unity8_plugin(Unity.DashCommunicator 0.1 Unity/DashCommunicator TARGETS DashCommunicator-qml)
98
99=== modified file 'plugins/Unity/DashCommunicator/dashcommunicator.cpp'
100--- plugins/Unity/DashCommunicator/dashcommunicator.cpp 2014-09-02 10:14:23 +0000
101+++ plugins/Unity/DashCommunicator/dashcommunicator.cpp 2014-09-29 14:27:27 +0000
102@@ -15,29 +15,38 @@
103 */
104
105 #include "dashcommunicator.h"
106+#include "dashconnection.h"
107
108 #include <QObject>
109-#include <QDBusConnection>
110-#include <QDBusInterface>
111-#include <QDebug>
112
113 DashCommunicator::DashCommunicator(QObject *parent):
114- QObject(parent)
115-{
116-}
117-
118-DashCommunicator::~DashCommunicator()
119-{
120-}
121-
122+ QThread(parent),
123+ m_dashConnection(nullptr),
124+ m_created(false)
125+{
126+ start();
127+}
128
129 void DashCommunicator::setCurrentScope(const QString &scopeId, bool animate, bool isSwipe)
130 {
131- QDBusConnection connection = QDBusConnection::sessionBus();
132- QDBusInterface dashIface ("com.canonical.UnityDash",
133- "/com/canonical/UnityDash",
134- "",
135- connection);
136-
137- dashIface.call("SetCurrentScope", scopeId, animate, isSwipe);
138+ m_mutex.lock();
139+ if (m_created) {
140+ QMetaObject::invokeMethod(m_dashConnection, "setCurrentScope",
141+ Q_ARG(QString, scopeId),
142+ Q_ARG(bool, animate),
143+ Q_ARG(bool, isSwipe));
144+ }
145+ m_mutex.unlock();
146+}
147+
148+void DashCommunicator::run()
149+{
150+ m_dashConnection = new DashConnection("com.canonical.UnityDash",
151+ "/com/canonical/UnityDash",
152+ "", this);
153+ m_mutex.lock();
154+ m_created = true;
155+ m_mutex.unlock();
156+
157+ exec();
158 }
159
160=== modified file 'plugins/Unity/DashCommunicator/dashcommunicator.h'
161--- plugins/Unity/DashCommunicator/dashcommunicator.h 2014-09-02 10:14:23 +0000
162+++ plugins/Unity/DashCommunicator/dashcommunicator.h 2014-09-29 14:27:27 +0000
163@@ -17,19 +17,29 @@
164 #ifndef DASHCOMMUNICATOR_H
165 #define DASHCOMMUNICATOR_H
166
167-#include <QObject>
168-
169-class DashCommunicator: public QObject
170+// Qt
171+#include <QThread>
172+#include <QMutex>
173+
174+class DashConnection;
175+
176+class DashCommunicator: public QThread
177 {
178 Q_OBJECT
179- Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity.DashCommunicator")
180-
181 public:
182- DashCommunicator(QObject *parent = 0);
183- ~DashCommunicator();
184+ explicit DashCommunicator(QObject *parent = 0);
185+ ~DashCommunicator() = default;
186
187 public Q_SLOTS:
188 void setCurrentScope(const QString &scopeId, bool animate, bool isSwipe);
189+
190+protected:
191+ void run() override;
192+
193+private:
194+ DashConnection *m_dashConnection;
195+ bool m_created;
196+ QMutex m_mutex;
197 };
198
199 #endif
200
201=== added file 'plugins/Unity/DashCommunicator/dashconnection.cpp'
202--- plugins/Unity/DashCommunicator/dashconnection.cpp 1970-01-01 00:00:00 +0000
203+++ plugins/Unity/DashCommunicator/dashconnection.cpp 2014-09-29 14:27:27 +0000
204@@ -0,0 +1,33 @@
205+/*
206+ * Copyright (C) 2014 Canonical, Ltd.
207+ *
208+ * This program is free software: you can redistribute it and/or modify it under
209+ * the terms of the GNU Lesser General Public License version 3, as published by
210+ * the Free Software Foundation.
211+ *
212+ * This program is distributed in the hope that it will be useful, but WITHOUT
213+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
214+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
215+ * Lesser General Public License for more details.
216+ *
217+ * You should have received a copy of the GNU Lesser General Public License
218+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
219+ */
220+
221+#include "dashconnection.h"
222+
223+#include <QDBusInterface>
224+#include <QDBusPendingCall>
225+
226+DashConnection::DashConnection(const QString &service, const QString &path, const QString &interface, QObject *parent):
227+ AbstractDBusServiceMonitor(service, path, interface, SessionBus, parent)
228+{
229+
230+}
231+
232+void DashConnection::setCurrentScope(const QString &scopeId, bool animate, bool isSwipe)
233+{
234+ if (dbusInterface()) {
235+ dbusInterface()->asyncCall("SetCurrentScope", scopeId, animate, isSwipe);
236+ }
237+}
238
239=== added file 'plugins/Unity/DashCommunicator/dashconnection.h'
240--- plugins/Unity/DashCommunicator/dashconnection.h 1970-01-01 00:00:00 +0000
241+++ plugins/Unity/DashCommunicator/dashconnection.h 2014-09-29 14:27:27 +0000
242@@ -0,0 +1,34 @@
243+/*
244+ * Copyright (C) 2014 Canonical, Ltd.
245+ *
246+ * This program is free software: you can redistribute it and/or modify it under
247+ * the terms of the GNU Lesser General Public License version 3, as published by
248+ * the Free Software Foundation.
249+ *
250+ * This program is distributed in the hope that it will be useful, but WITHOUT
251+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
252+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
253+ * Lesser General Public License for more details.
254+ *
255+ * You should have received a copy of the GNU Lesser General Public License
256+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
257+ */
258+
259+#ifndef THREADEDDASHCONNECTION_H
260+#define THREADEDDASHCONNECTION_H
261+
262+// local
263+#include "abstractdbusservicemonitor.h"
264+
265+
266+class DashConnection: public AbstractDBusServiceMonitor
267+{
268+ Q_OBJECT
269+public:
270+ DashConnection(const QString &service, const QString &path, const QString &interface, QObject *parent = 0);
271+
272+public Q_SLOTS:
273+ void setCurrentScope(const QString &scopeId, bool animate, bool isSwipe);
274+};
275+
276+#endif
277
278=== modified file 'plugins/Unity/Launcher/CMakeLists.txt'
279--- plugins/Unity/Launcher/CMakeLists.txt 2014-09-19 11:20:07 +0000
280+++ plugins/Unity/Launcher/CMakeLists.txt 2014-09-29 14:27:27 +0000
281@@ -1,6 +1,6 @@
282 include(FindPkgConfig)
283 pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=4)
284-pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=4)
285+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=5)
286 pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
287
288 add_definitions(-DSM_BUSNAME=systemBus)
289
290=== modified file 'qml/Shell.qml'
291--- qml/Shell.qml 2014-09-22 18:24:43 +0000
292+++ qml/Shell.qml 2014-09-29 14:27:27 +0000
293@@ -128,6 +128,13 @@
294 objectName: "dashCommunicator"
295 }
296
297+ Binding {
298+ target: ApplicationManager
299+ property: "forceDashActive"
300+ value: launcher.shown || launcher.dashSwipe
301+ }
302+
303+
304 WindowKeysFilter {
305 // Handle but do not filter out volume keys
306 Keys.onVolumeUpPressed: { volumeControl.volumeUp(); event.accepted = false; }
307
308=== modified file 'src/CMakeLists.txt'
309--- src/CMakeLists.txt 2014-07-23 06:54:10 +0000
310+++ src/CMakeLists.txt 2014-09-29 14:27:27 +0000
311@@ -36,3 +36,4 @@
312
313 add_subdirectory(Panel)
314 add_subdirectory(Dash)
315+add_subdirectory(libunity8-private)
316
317=== modified file 'src/Dash/CMakeLists.txt'
318--- src/Dash/CMakeLists.txt 2014-09-04 13:15:13 +0000
319+++ src/Dash/CMakeLists.txt 2014-09-29 14:27:27 +0000
320@@ -9,6 +9,8 @@
321
322 qt5_use_modules(unity8-dash Gui Qml Quick Test)
323
324+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
325+
326 # install binaries
327 install(TARGETS ${DASH_APP}
328 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
329
330=== modified file 'src/Panel/CMakeLists.txt'
331--- src/Panel/CMakeLists.txt 2013-06-18 18:02:29 +0000
332+++ src/Panel/CMakeLists.txt 2014-09-29 14:27:27 +0000
333@@ -1,1 +1,3 @@
334 add_subdirectory(Indicators)
335+
336+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
337
338=== added directory 'src/libunity8-private'
339=== added file 'src/libunity8-private/CMakeLists.txt'
340--- src/libunity8-private/CMakeLists.txt 1970-01-01 00:00:00 +0000
341+++ src/libunity8-private/CMakeLists.txt 2014-09-29 14:27:27 +0000
342@@ -0,0 +1,25 @@
343+set(LIB_NAME "unity8-private")
344+set(SOVERSION 0)
345+set(VERSION ${SOVERSION}.0.0)
346+
347+project(lib${LIB_NAME})
348+
349+set(lib${LIB_NAME}_SRCS
350+ abstractdbusservicemonitor.cpp
351+ )
352+
353+add_library(${LIB_NAME} SHARED
354+ ${lib${LIB_NAME}_SRCS}
355+ )
356+
357+set_target_properties(${LIB_NAME} PROPERTIES
358+ VERSION ${VERSION}
359+ SOVERSION ${SOVERSION}
360+ )
361+
362+qt5_use_modules(${LIB_NAME} DBus)
363+
364+# install library
365+install(TARGETS ${LIB_NAME}
366+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
367+ )
368
369=== added file 'src/libunity8-private/abstractdbusservicemonitor.cpp'
370--- src/libunity8-private/abstractdbusservicemonitor.cpp 1970-01-01 00:00:00 +0000
371+++ src/libunity8-private/abstractdbusservicemonitor.cpp 2014-09-29 14:27:27 +0000
372@@ -0,0 +1,87 @@
373+/*
374+ * Copyright (C) 2011-2014 Canonical, Ltd.
375+ *
376+ * Authors:
377+ * Ugo Riboni <ugo.riboni@canonical.com>
378+ *
379+ * This program is free software; you can redistribute it and/or modify
380+ * it under the terms of the GNU General Public License as published by
381+ * the Free Software Foundation; version 3.
382+ *
383+ * This program is distributed in the hope that it will be useful,
384+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
385+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
386+ * GNU General Public License for more details.
387+ *
388+ * You should have received a copy of the GNU General Public License
389+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
390+ */
391+
392+#include "abstractdbusservicemonitor.h"
393+
394+#include <QDBusInterface>
395+#include <QDBusServiceWatcher>
396+#include <QDBusConnection>
397+#include <QDBusConnectionInterface>
398+#include <QDBusReply>
399+
400+AbstractDBusServiceMonitor::AbstractDBusServiceMonitor(const QString &service, const QString &path,
401+ const QString &interface, const Bus bus,
402+ QObject *parent)
403+ : QObject(parent)
404+ , m_service(service)
405+ , m_path(path)
406+ , m_interface(interface)
407+ , m_watcher(new QDBusServiceWatcher(service,
408+ (bus == SystemBus) ? QDBusConnection::systemBus()
409+ : QDBusConnection::sessionBus()))
410+ , m_dbusInterface(nullptr)
411+{
412+ connect(m_watcher, &QDBusServiceWatcher::serviceRegistered, this, &AbstractDBusServiceMonitor::createInterface);
413+ connect(m_watcher, &QDBusServiceWatcher::serviceUnregistered, this, &AbstractDBusServiceMonitor::destroyInterface);
414+
415+ // Connect to the service if it's up already
416+ QDBusConnectionInterface* sessionBus = QDBusConnection::sessionBus().interface();
417+ QDBusReply<bool> reply = sessionBus->isServiceRegistered(m_service);
418+ if (reply.isValid() && reply.value()) {
419+ createInterface(m_service);
420+ }
421+}
422+
423+AbstractDBusServiceMonitor::~AbstractDBusServiceMonitor()
424+{
425+ delete m_watcher;
426+ delete m_dbusInterface;
427+}
428+
429+void AbstractDBusServiceMonitor::createInterface(const QString &)
430+{
431+ if (m_dbusInterface != nullptr) {
432+ delete m_dbusInterface;
433+ m_dbusInterface = nullptr;
434+ }
435+
436+ m_dbusInterface = new QDBusInterface(m_service, m_path, m_interface,
437+ QDBusConnection::sessionBus());
438+ Q_EMIT serviceAvailableChanged(true);
439+}
440+
441+void AbstractDBusServiceMonitor::destroyInterface(const QString &)
442+{
443+ if (m_dbusInterface != nullptr) {
444+ delete m_dbusInterface;
445+ m_dbusInterface = nullptr;
446+ }
447+
448+ Q_EMIT serviceAvailableChanged(false);
449+}
450+
451+QDBusInterface* AbstractDBusServiceMonitor::dbusInterface() const
452+{
453+ return m_dbusInterface;
454+}
455+
456+bool AbstractDBusServiceMonitor::serviceAvailable() const
457+{
458+ return m_dbusInterface != nullptr;
459+}
460
461=== added file 'src/libunity8-private/abstractdbusservicemonitor.h'
462--- src/libunity8-private/abstractdbusservicemonitor.h 1970-01-01 00:00:00 +0000
463+++ src/libunity8-private/abstractdbusservicemonitor.h 2014-09-29 14:27:27 +0000
464@@ -0,0 +1,66 @@
465+/*
466+ * Copyright (C) 2011-2014 Canonical, Ltd.
467+ *
468+ * Authors:
469+ * Ugo Riboni <ugo.riboni@canonical.com>
470+ *
471+ * This program is free software; you can redistribute it and/or modify
472+ * it under the terms of the GNU General Public License as published by
473+ * the Free Software Foundation; version 3.
474+ *
475+ * This program is distributed in the hope that it will be useful,
476+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
477+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
478+ * GNU General Public License for more details.
479+ *
480+ * You should have received a copy of the GNU General Public License
481+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
482+ */
483+
484+#ifndef ABSTRACTDBUSSERVICEMONITOR_H
485+#define ABSTRACTDBUSSERVICEMONITOR_H
486+
487+#include <QObject>
488+#include <QString>
489+#include <QDBusConnection>
490+
491+class QDBusInterface;
492+class QDBusServiceWatcher;
493+
494+class Q_DECL_EXPORT AbstractDBusServiceMonitor : public QObject
495+{
496+ Q_OBJECT
497+ Q_ENUMS(Bus)
498+ Q_PROPERTY(bool serviceAvailable READ serviceAvailable NOTIFY serviceAvailableChanged)
499+
500+public:
501+ enum Bus {
502+ SessionBus,
503+ SystemBus,
504+ };
505+
506+ explicit AbstractDBusServiceMonitor(const QString &service, const QString &path, const QString &interface,
507+ const Bus bus = SessionBus,
508+ QObject *parent = 0);
509+ ~AbstractDBusServiceMonitor();
510+
511+ QDBusInterface* dbusInterface() const;
512+
513+ bool serviceAvailable() const;
514+
515+Q_SIGNALS:
516+ void serviceAvailableChanged(bool available);
517+
518+private Q_SLOTS:
519+ void createInterface(const QString &service);
520+ void destroyInterface(const QString &service);
521+
522+protected:
523+ const QString m_service;
524+ const QString m_path;
525+ const QString m_interface;
526+ QDBusServiceWatcher* m_watcher;
527+ QDBusInterface* m_dbusInterface;
528+};
529+
530+#endif // ABSTRACTDBUSSERVICEMONITOR_H
531
532=== modified file 'tests/mocks/Unity/Application/ApplicationManager.cpp'
533--- tests/mocks/Unity/Application/ApplicationManager.cpp 2014-08-27 16:12:21 +0000
534+++ tests/mocks/Unity/Application/ApplicationManager.cpp 2014-09-29 14:27:27 +0000
535@@ -43,6 +43,7 @@
536 ApplicationManager::ApplicationManager(QObject *parent)
537 : ApplicationManagerInterface(parent)
538 , m_suspended(false)
539+ , m_forceDashActive(false)
540 {
541 m_roleNames.insert(RoleSession, "session");
542 m_roleNames.insert(RoleFullscreen, "fullscreen");
543@@ -292,6 +293,31 @@
544 Q_EMIT suspendedChanged();
545 }
546
547+bool ApplicationManager::forceDashActive() const
548+{
549+ return m_forceDashActive;
550+}
551+
552+void ApplicationManager::setForceDashActive(bool forceDashActive)
553+{
554+ if (m_forceDashActive == forceDashActive) {
555+ return;
556+ }
557+
558+ ApplicationInfo *dash = findApplication("unity8-dash");
559+ if (dash) {
560+ if (forceDashActive) {
561+ dash->setState(ApplicationInfo::Running);
562+ } else {
563+ if (!dash->focused()) {
564+ dash->setState(ApplicationInfo::Suspended);
565+ }
566+ }
567+ }
568+ m_forceDashActive = forceDashActive;
569+ Q_EMIT forceDashActiveChanged();
570+}
571+
572 bool ApplicationManager::focusApplication(const QString &appId)
573 {
574 ApplicationInfo *application = findApplication(appId);
575
576=== modified file 'tests/mocks/Unity/Application/ApplicationManager.h'
577--- tests/mocks/Unity/Application/ApplicationManager.h 2014-08-27 20:58:10 +0000
578+++ tests/mocks/Unity/Application/ApplicationManager.h 2014-09-29 14:27:27 +0000
579@@ -99,8 +99,11 @@
580 Q_INVOKABLE bool stopApplication(const QString &appId) override;
581
582 QString focusedApplicationId() const override;
583- bool suspended() const;
584- void setSuspended(bool suspended);
585+ bool suspended() const override;
586+ void setSuspended(bool suspended) override;
587+
588+ bool forceDashActive() const override;
589+ void setForceDashActive(bool forceDashActive) override;
590
591 // Only for testing
592 Q_INVOKABLE QStringList availableApplications();
593@@ -124,6 +127,7 @@
594 void buildListOfAvailableApplications();
595 void onWindowCreated();
596 bool m_suspended;
597+ bool m_forceDashActive;
598 QList<ApplicationInfo*> m_runningApplications;
599 QList<ApplicationInfo*> m_availableApplications;
600 QTimer m_windowCreatedTimer;
601
602=== modified file 'tests/mocks/Unity/Application/CMakeLists.txt'
603--- tests/mocks/Unity/Application/CMakeLists.txt 2014-09-12 20:16:54 +0000
604+++ tests/mocks/Unity/Application/CMakeLists.txt 2014-09-29 14:27:27 +0000
605@@ -1,4 +1,4 @@
606-pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=4)
607+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=5)
608
609 set(FakeUnityApplicationQml_SOURCES
610 plugin.cpp
611
612=== modified file 'tests/plugins/Unity/Launcher/CMakeLists.txt'
613--- tests/plugins/Unity/Launcher/CMakeLists.txt 2014-09-19 11:20:07 +0000
614+++ tests/plugins/Unity/Launcher/CMakeLists.txt 2014-09-29 14:27:27 +0000
615@@ -1,6 +1,6 @@
616 pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
617 pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=4)
618-pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=4)
619+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=5)
620
621 include_directories(
622 ${CMAKE_CURRENT_BINARY_DIR}
623
624=== modified file 'tests/plugins/Unity/Launcher/launchermodeltest.cpp'
625--- tests/plugins/Unity/Launcher/launchermodeltest.cpp 2014-09-19 11:20:07 +0000
626+++ tests/plugins/Unity/Launcher/launchermodeltest.cpp 2014-09-29 14:27:27 +0000
627@@ -105,6 +105,8 @@
628 bool requestFocusApplication(const QString &appId) { Q_UNUSED(appId); return true; }
629 bool suspended() const { return false; }
630 void setSuspended(bool) {}
631+ bool forceDashActive() const { return false; }
632+ void setForceDashActive(bool) {}
633
634 private:
635 QList<MockApp*> m_list;

Subscribers

People subscribed via source and target branches