Merge lp:~uriboni/unity-2d/clean-up-dash-dbus into lp:unity-2d/3.0

Proposed by Ugo Riboni
Status: Merged
Approved by: Olivier Tilloy
Approved revision: no longer in the source branch.
Merged at revision: 429
Proposed branch: lp:~uriboni/unity-2d/clean-up-dash-dbus
Merge into: lp:unity-2d/3.0
Diff against target: 249 lines (+78/-36)
10 files modified
.bzrignore (+1/-0)
launcher/UnityApplications/placeentry.cpp (+1/-1)
launcher/app/gesturehandler.cpp (+1/-1)
panel/applets/homebutton/homebuttonapplet.cpp (+1/-1)
places/app/CMakeLists.txt (+5/-0)
places/app/dash.xml (+47/-0)
places/app/dashdeclarativeview.cpp (+17/-1)
places/app/dashdeclarativeview.h (+2/-2)
places/app/places.cpp (+2/-29)
places/app/unity-2d-places.service.in (+1/-1)
To merge this branch: bzr merge lp:~uriboni/unity-2d/clean-up-dash-dbus
Reviewer Review Type Date Requested Status
Olivier Tilloy (community) code functional Approve
Review via email: mp+52037@code.launchpad.net

Description of the change

[dash] Avoid exposing the entire QObject to DBUS, expose instead only what we really use

To post a comment you must log in.
Revision history for this message
Olivier Tilloy (osomon) wrote :

You need to update the other components to activate the service on the new, normalized interface name:

$ grep -rn "\"com.canonical.Unity2d\"" *
launcher/UnityApplications/placeentry.cpp:146:static const char* DASH_DBUS_SERVICE = "com.canonical.Unity2d";
launcher/app/gesturehandler.cpp:120: QDBusInterface dashInterface("com.canonical.Unity2d", "/Dash", "com.canonical.Unity2d.Dash");
panel/applets/homebutton/homebuttonapplet.cpp:34:static const char* DBUS_SERVICE = "com.canonical.Unity2d";

review: Needs Fixing (code)
Revision history for this message
Olivier Tilloy (osomon) wrote :

Also, I compared the interfaces before and after your changes, and it seems a lot of methods are gone, some (or all?) of which are actually used in the other components:

List of methods before:
 - activateHome
 - activatePlaceEntry
 - setActive
 - setActivePlaceEntry
 - setExpanded

List of methods after:
 - activateHome

review: Needs Fixing
Revision history for this message
Ugo Riboni (uriboni) wrote :

> Also, I compared the interfaces before and after your changes, and it seems a
> lot of methods are gone, some (or all?) of which are actually used in the
> other components:

Actually the only one that was really removed in error is activatePlaceEntry. The others are not actually used via DBUS.

I also fixed the interface name used by clients, as pointed out in the previous comment.

Revision history for this message
Olivier Tilloy (osomon) wrote :

In places/app/dash.xml:

+ <method name="activatePlaceEntry">
+ <dox:d>Activates the Dash and shows the specified Place</dox:d>

Should be "[…] shows the specified place entry".

+ <signal name="activePlaceEntryChanged">
+ <dox:d>Signals when the currently active place in the Dash changes</dox:d>

Same here, and everywhere else really: "place" ≠ "place entry". Please make sure that the terminology is consistent.

review: Needs Fixing
Revision history for this message
Olivier Tilloy (osomon) wrote :

The value of the 'Name' key in places/app/unity-2d-places.service.in needs to be updated.

review: Needs Fixing
Revision history for this message
Olivier Tilloy (osomon) wrote :

Packages fail to build from source with the following error:

Building CXX object places/app/CMakeFiles/unity-2d-places.dir/dashdeclarativeview.cpp.o
cd /home/osomon/dev/unity-2d/build-area/unity-2d-3.6.1/obj-x86_64-linux-gnu/places/app && /usr/bin/g++ -g -O2 -g -Wall -O2 -Woverloaded-virtual -Wall -std=c++0x -I/home/osomon/dev/unity-2d/build-area/unity-2d-3.6.1/obj-x86_64-linux-gnu -I/usr/include/qt4 -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtDBus -I/usr/include/qt4/QtDeclarative -I/usr/include/qt4/QtXml -I/usr/include/qt4/QtGui -I/home/osomon/dev/unity-2d/build-area/unity-2d-3.6.1/obj-x86_64-linux-gnu/places/app -I/usr/include/QtGConf -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/home/osomon/dev/unity-2d/build-area/unity-2d-3.6.1/libunity-2d-private/src -o CMakeFiles/unity-2d-places.dir/dashdeclarativeview.cpp.o -c /home/osomon/dev/unity-2d/build-area/unity-2d-3.6.1/places/app/dashdeclarativeview.cpp

In file included from /home/osomon/dev/unity-2d/build-area/unity-2d-3.6.1/places/app/dashdeclarativeview.cpp:18:
/home/osomon/dev/unity-2d/build-area/unity-2d-3.6.1/obj-x86_64-linux-gnu/places/app/dashadaptor.h:17: fatal error: dashdeclarativeview.h: No such file or directory

review: Needs Fixing
Revision history for this message
Olivier Tilloy (osomon) wrote :

Quoting Aurélien on IRC:

bzr bd uses a separate build dir (src dir != build dir),
dashdeclarativeview.h is in src dir, so it needs to be added to the list of include directories,
adding ${CMAKE_CURRENT_SOURCE_DIR} to the existing include_directories() call should be enough

Revision history for this message
Ugo Riboni (uriboni) wrote :

Build error when building package is fixed now. Aureliene suggestion was good.

Revision history for this message
Olivier Tilloy (osomon) wrote :

It now builds and works as expected.

review: Approve (code functional)
Revision history for this message
Florian Boucault (fboucault) wrote :

Attempt to merge into lp:unity-2d failed due to conflicts:

text conflict in places/app/dashdeclarativeview.cpp

Revision history for this message
Ugo Riboni (uriboni) wrote :

Conflict is now fixed

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2011-02-10 13:44:13 +0000
3+++ .bzrignore 2011-03-08 11:26:49 +0000
4@@ -11,6 +11,7 @@
5 places/UnityPlaces/libUnityPlaces.so*
6 places/app/unity-2d-places
7 places/app/unity-2d-places.service
8+places/app/dashadaptor.*
9
10 spread/app/unity-2d-spread
11 spread/app/unity-2d-spread.service
12
13=== modified file 'launcher/UnityApplications/placeentry.cpp'
14--- launcher/UnityApplications/placeentry.cpp 2011-02-10 01:00:41 +0000
15+++ launcher/UnityApplications/placeentry.cpp 2011-03-08 11:26:49 +0000
16@@ -143,7 +143,7 @@
17 static const char* UNITY_PLACE_ENTRY_INTERFACE = "com.canonical.Unity.PlaceEntry";
18 static const char* SECTION_PROPERTY = "section";
19
20-static const char* DASH_DBUS_SERVICE = "com.canonical.Unity2d";
21+static const char* DASH_DBUS_SERVICE = "com.canonical.Unity2d.Dash";
22 static const char* DASH_DBUS_PATH = "/Dash";
23 static const char* DASH_DBUS_INTERFACE = "com.canonical.Unity2d.Dash";
24
25
26=== modified file 'launcher/app/gesturehandler.cpp'
27--- launcher/app/gesturehandler.cpp 2011-02-21 00:25:44 +0000
28+++ launcher/app/gesturehandler.cpp 2011-03-08 11:26:49 +0000
29@@ -117,7 +117,7 @@
30 - show the home page of the dash if the dash is closed
31 - close the dash, if the dash is opened
32 */
33- QDBusInterface dashInterface("com.canonical.Unity2d", "/Dash", "com.canonical.Unity2d.Dash");
34+ QDBusInterface dashInterface("com.canonical.Unity2d.Dash", "/Dash", "com.canonical.Unity2d.Dash");
35 bool dashActive = dashInterface.property("active").toBool();
36
37 if (dashActive) {
38
39=== modified file 'panel/applets/homebutton/homebuttonapplet.cpp'
40--- panel/applets/homebutton/homebuttonapplet.cpp 2011-02-15 11:47:42 +0000
41+++ panel/applets/homebutton/homebuttonapplet.cpp 2011-03-08 11:26:49 +0000
42@@ -31,7 +31,7 @@
43 #include <QDBusServiceWatcher>
44 #include <QDBusConnectionInterface>
45
46-static const char* DBUS_SERVICE = "com.canonical.Unity2d";
47+static const char* DBUS_SERVICE = "com.canonical.Unity2d.Dash";
48 static const char* DBUS_PATH = "/Dash";
49 static const char* DBUS_IFACE = "com.canonical.Unity2d.Dash";
50
51
52=== modified file 'places/app/CMakeLists.txt'
53--- places/app/CMakeLists.txt 2011-02-24 01:13:42 +0000
54+++ places/app/CMakeLists.txt 2011-03-08 11:26:49 +0000
55@@ -18,9 +18,14 @@
56 # Build
57 configure_file(unity-2d-places.service.in unity-2d-places.service)
58
59+qt4_add_dbus_adaptor(places_SRCS dash.xml
60+ dashdeclarativeview.h DashDeclarativeView
61+ )
62+
63 add_executable(unity-2d-places ${places_SRCS} ${places_MOC_SRCS})
64
65 include_directories(
66+ ${CMAKE_CURRENT_SOURCE_DIR}
67 ${CMAKE_CURRENT_BINARY_DIR}
68 ${QTGCONF_INCLUDE_DIRS}
69 ${GTK_INCLUDE_DIRS}
70
71=== added file 'places/app/dash.xml'
72--- places/app/dash.xml 1970-01-01 00:00:00 +0000
73+++ places/app/dash.xml 2011-03-08 11:26:49 +0000
74@@ -0,0 +1,47 @@
75+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
76+<node xmlns:dox="http://www.ayatana.org/dbus/dox.dtd">
77+ <dox:d><![CDATA[
78+ @mainpage
79+
80+ An interface to control the dash in Unity-2d.
81+ ]]></dox:d>
82+ <interface name="com.canonical.Unity2d.Dash" xmlns:dox="http://www.ayatana.org/dbus/dox.dtd">
83+ <dox:d>
84+ An interface to control the dash in Unity-2d.
85+ </dox:d>
86+ <method name="activateHome">
87+ <dox:d>Activates the Dash and shows the home section</dox:d>
88+ </method>
89+ <method name="activatePlaceEntry">
90+ <dox:d>Activates the Dash and shows the specified place entry</dox:d>
91+ <arg name="file" type="s" direction="in">
92+ <dox:d>The .place file for the place containing the entry that should be activated</dox:d>
93+ </arg>
94+ <arg name="entry" type="s" direction="in">
95+ <dox:d>The place entry that should be activated</dox:d>
96+ </arg>
97+ <arg name="section" type="i" direction="in">
98+ <dox:d>The section of the place entry that should be activated</dox:d>
99+ </arg>
100+ </method>
101+ <property name="active" type="b" access="readwrite">
102+ <dox:d>True if the Dash is active</dox:d>
103+ </property>
104+ <property name="activePlaceEntry" type="s" access="readwrite">
105+ <dox:d>The currently active place entry</dox:d>
106+ </property>
107+ <signal name="activeChanged">
108+ <dox:d>Signals when the active status of the Dash changes</dox:d>
109+ <arg name="active" type="b" direction="out">
110+ <dox:d>True if the Dash is active</dox:d>
111+ </arg>
112+ </signal>
113+ <signal name="activePlaceEntryChanged">
114+ <dox:d>Signals when the currently active place entry in the Dash changes</dox:d>
115+ <arg name="activePlaceEntry" type="s" direction="out">
116+ <dox:d>The currently active place entry</dox:d>
117+ </arg>
118+ </signal>
119+ </interface>
120+</node>
121+
122
123=== modified file 'places/app/dashdeclarativeview.cpp'
124--- places/app/dashdeclarativeview.cpp 2011-03-08 09:57:38 +0000
125+++ places/app/dashdeclarativeview.cpp 2011-03-08 11:26:49 +0000
126@@ -15,6 +15,8 @@
127 */
128
129 #include "dashdeclarativeview.h"
130+#include "dashadaptor.h"
131+
132 #include <QDesktopWidget>
133 #include <QApplication>
134 #include <QBitmap>
135@@ -22,8 +24,8 @@
136 #include <QDeclarativeContext>
137 #include <QX11Info>
138 #include <QGraphicsObject>
139+#include <QtDBus/QDBusConnection>
140 #include <QTimer>
141-
142 #include <QDebug>
143
144 #include <X11/Xlib.h>
145@@ -38,6 +40,9 @@
146 static const int DASH_DESKTOP_COLLAPSED_HEIGHT = 115;
147 static const int DASH_DESKTOP_EXPANDED_HEIGHT = 606;
148
149+static const char* DASH_DBUS_SERVICE = "com.canonical.Unity2d.Dash";
150+static const char* DASH_DBUS_OBJECT_PATH = "/Dash";
151+
152 DashDeclarativeView::DashDeclarativeView()
153 : QDeclarativeView()
154 , m_mode(HiddenMode)
155@@ -320,3 +325,14 @@
156 {
157 return QX11Info::isCompositingManagerRunning();
158 }
159+
160+bool
161+DashDeclarativeView::connectToBus()
162+{
163+ bool ok = QDBusConnection::sessionBus().registerService(DASH_DBUS_SERVICE);
164+ if (!ok) {
165+ return false;
166+ }
167+ new DashAdaptor(this);
168+ return QDBusConnection::sessionBus().registerObject(DASH_DBUS_OBJECT_PATH, this);
169+}
170
171=== modified file 'places/app/dashdeclarativeview.h'
172--- places/app/dashdeclarativeview.h 2011-03-08 09:57:38 +0000
173+++ places/app/dashdeclarativeview.h 2011-03-08 11:26:49 +0000
174@@ -24,7 +24,6 @@
175 Q_OBJECT
176 Q_ENUMS(DashMode)
177
178- Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity2d.Dash")
179 Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
180 Q_PROPERTY(bool expanded READ expanded WRITE setExpanded NOTIFY expandedChanged)
181 Q_PROPERTY(DashMode dashMode READ dashMode WRITE setDashMode NOTIFY dashModeChanged)
182@@ -58,7 +57,8 @@
183
184 /* methods */
185 Q_INVOKABLE void activatePlaceEntry(const QString& file, const QString& entry, const int section = 0);
186- Q_INVOKABLE void activateHome();
187+ Q_SLOT void activateHome();
188+ bool connectToBus();
189
190 Q_SIGNALS:
191 void activeChanged(bool);
192
193=== modified file 'places/app/places.cpp'
194--- places/app/places.cpp 2011-02-24 01:13:42 +0000
195+++ places/app/places.cpp 2011-03-08 11:26:49 +0000
196@@ -39,33 +39,6 @@
197 #include "dashdeclarativeview.h"
198 #include "config.h"
199
200-/* Register a D-Bus service for activation and deactivation of the dash */
201-static bool registerDBusService(DashDeclarativeView* view)
202-{
203- QDBusConnection bus = QDBusConnection::sessionBus();
204- if (!bus.registerService("com.canonical.Unity2d")) {
205- qCritical() << "Failed to register DBus service, is there another instance already running?";
206- return false;
207- }
208- /* FIXME: use an adaptor class in order not to expose all of the view's
209- properties and methods. */\
210- if (!bus.registerObject("/Dash", view, QDBusConnection::ExportAllContents)) {
211- qCritical() << "Failed to register /Dash, this should not happen!";
212- return false;
213- }
214- /* It would be nice to support the newly introduced (D-Bus 0.14 07/09/2010)
215- property change notification that Qt 4.7 does not implement.
216-
217- org.freedesktop.DBus.Properties.PropertiesChanged (
218- STRING interface_name,
219- DICT<STRING,VARIANT> changed_properties,
220- ARRAY<STRING> invalidated_properties);
221-
222- ref.: http://randomguy3.wordpress.com/2010/09/07/the-magic-of-qtdbus-and-the-propertychanged-signal/
223- */
224- return true;
225-}
226-
227 int main(int argc, char *argv[])
228 {
229 /* gtk needs to be inited, otherwise we get an assert failure in gdk */
230@@ -86,8 +59,8 @@
231
232 qmlRegisterType<DashDeclarativeView>("Places", 1, 0, "DashDeclarativeView");
233 DashDeclarativeView view;
234-
235- if (!registerDBusService(&view)) {
236+ if (!view.connectToBus()) {
237+ qCritical() << "Another instance of the Dash already exists. Quitting.";
238 return -1;
239 }
240
241
242=== modified file 'places/app/unity-2d-places.service.in'
243--- places/app/unity-2d-places.service.in 2011-01-14 20:47:33 +0000
244+++ places/app/unity-2d-places.service.in 2011-03-08 11:26:49 +0000
245@@ -1,3 +1,3 @@
246 [D-BUS Service]
247-Name=com.canonical.Unity2d
248+Name=com.canonical.Unity2d.Dash
249 Exec=@CMAKE_INSTALL_PREFIX@/bin/unity-2d-places

Subscribers

People subscribed via source and target branches

to all changes: