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
=== modified file '.bzrignore'
--- .bzrignore 2011-02-10 13:44:13 +0000
+++ .bzrignore 2011-03-08 11:26:49 +0000
@@ -11,6 +11,7 @@
11places/UnityPlaces/libUnityPlaces.so*11places/UnityPlaces/libUnityPlaces.so*
12places/app/unity-2d-places12places/app/unity-2d-places
13places/app/unity-2d-places.service13places/app/unity-2d-places.service
14places/app/dashadaptor.*
1415
15spread/app/unity-2d-spread16spread/app/unity-2d-spread
16spread/app/unity-2d-spread.service17spread/app/unity-2d-spread.service
1718
=== modified file 'launcher/UnityApplications/placeentry.cpp'
--- launcher/UnityApplications/placeentry.cpp 2011-02-10 01:00:41 +0000
+++ launcher/UnityApplications/placeentry.cpp 2011-03-08 11:26:49 +0000
@@ -143,7 +143,7 @@
143static const char* UNITY_PLACE_ENTRY_INTERFACE = "com.canonical.Unity.PlaceEntry";143static const char* UNITY_PLACE_ENTRY_INTERFACE = "com.canonical.Unity.PlaceEntry";
144static const char* SECTION_PROPERTY = "section";144static const char* SECTION_PROPERTY = "section";
145145
146static const char* DASH_DBUS_SERVICE = "com.canonical.Unity2d";146static const char* DASH_DBUS_SERVICE = "com.canonical.Unity2d.Dash";
147static const char* DASH_DBUS_PATH = "/Dash";147static const char* DASH_DBUS_PATH = "/Dash";
148static const char* DASH_DBUS_INTERFACE = "com.canonical.Unity2d.Dash";148static const char* DASH_DBUS_INTERFACE = "com.canonical.Unity2d.Dash";
149149
150150
=== modified file 'launcher/app/gesturehandler.cpp'
--- launcher/app/gesturehandler.cpp 2011-02-21 00:25:44 +0000
+++ launcher/app/gesturehandler.cpp 2011-03-08 11:26:49 +0000
@@ -117,7 +117,7 @@
117 - show the home page of the dash if the dash is closed117 - show the home page of the dash if the dash is closed
118 - close the dash, if the dash is opened118 - close the dash, if the dash is opened
119 */119 */
120 QDBusInterface dashInterface("com.canonical.Unity2d", "/Dash", "com.canonical.Unity2d.Dash");120 QDBusInterface dashInterface("com.canonical.Unity2d.Dash", "/Dash", "com.canonical.Unity2d.Dash");
121 bool dashActive = dashInterface.property("active").toBool();121 bool dashActive = dashInterface.property("active").toBool();
122122
123 if (dashActive) {123 if (dashActive) {
124124
=== modified file 'panel/applets/homebutton/homebuttonapplet.cpp'
--- panel/applets/homebutton/homebuttonapplet.cpp 2011-02-15 11:47:42 +0000
+++ panel/applets/homebutton/homebuttonapplet.cpp 2011-03-08 11:26:49 +0000
@@ -31,7 +31,7 @@
31#include <QDBusServiceWatcher>31#include <QDBusServiceWatcher>
32#include <QDBusConnectionInterface>32#include <QDBusConnectionInterface>
3333
34static const char* DBUS_SERVICE = "com.canonical.Unity2d";34static const char* DBUS_SERVICE = "com.canonical.Unity2d.Dash";
35static const char* DBUS_PATH = "/Dash";35static const char* DBUS_PATH = "/Dash";
36static const char* DBUS_IFACE = "com.canonical.Unity2d.Dash";36static const char* DBUS_IFACE = "com.canonical.Unity2d.Dash";
3737
3838
=== modified file 'places/app/CMakeLists.txt'
--- places/app/CMakeLists.txt 2011-02-24 01:13:42 +0000
+++ places/app/CMakeLists.txt 2011-03-08 11:26:49 +0000
@@ -18,9 +18,14 @@
18# Build18# Build
19configure_file(unity-2d-places.service.in unity-2d-places.service)19configure_file(unity-2d-places.service.in unity-2d-places.service)
2020
21qt4_add_dbus_adaptor(places_SRCS dash.xml
22 dashdeclarativeview.h DashDeclarativeView
23 )
24
21add_executable(unity-2d-places ${places_SRCS} ${places_MOC_SRCS})25add_executable(unity-2d-places ${places_SRCS} ${places_MOC_SRCS})
2226
23include_directories(27include_directories(
28 ${CMAKE_CURRENT_SOURCE_DIR}
24 ${CMAKE_CURRENT_BINARY_DIR}29 ${CMAKE_CURRENT_BINARY_DIR}
25 ${QTGCONF_INCLUDE_DIRS}30 ${QTGCONF_INCLUDE_DIRS}
26 ${GTK_INCLUDE_DIRS}31 ${GTK_INCLUDE_DIRS}
2732
=== added file 'places/app/dash.xml'
--- places/app/dash.xml 1970-01-01 00:00:00 +0000
+++ places/app/dash.xml 2011-03-08 11:26:49 +0000
@@ -0,0 +1,47 @@
1<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
2<node xmlns:dox="http://www.ayatana.org/dbus/dox.dtd">
3 <dox:d><![CDATA[
4 @mainpage
5
6 An interface to control the dash in Unity-2d.
7 ]]></dox:d>
8 <interface name="com.canonical.Unity2d.Dash" xmlns:dox="http://www.ayatana.org/dbus/dox.dtd">
9 <dox:d>
10 An interface to control the dash in Unity-2d.
11 </dox:d>
12 <method name="activateHome">
13 <dox:d>Activates the Dash and shows the home section</dox:d>
14 </method>
15 <method name="activatePlaceEntry">
16 <dox:d>Activates the Dash and shows the specified place entry</dox:d>
17 <arg name="file" type="s" direction="in">
18 <dox:d>The .place file for the place containing the entry that should be activated</dox:d>
19 </arg>
20 <arg name="entry" type="s" direction="in">
21 <dox:d>The place entry that should be activated</dox:d>
22 </arg>
23 <arg name="section" type="i" direction="in">
24 <dox:d>The section of the place entry that should be activated</dox:d>
25 </arg>
26 </method>
27 <property name="active" type="b" access="readwrite">
28 <dox:d>True if the Dash is active</dox:d>
29 </property>
30 <property name="activePlaceEntry" type="s" access="readwrite">
31 <dox:d>The currently active place entry</dox:d>
32 </property>
33 <signal name="activeChanged">
34 <dox:d>Signals when the active status of the Dash changes</dox:d>
35 <arg name="active" type="b" direction="out">
36 <dox:d>True if the Dash is active</dox:d>
37 </arg>
38 </signal>
39 <signal name="activePlaceEntryChanged">
40 <dox:d>Signals when the currently active place entry in the Dash changes</dox:d>
41 <arg name="activePlaceEntry" type="s" direction="out">
42 <dox:d>The currently active place entry</dox:d>
43 </arg>
44 </signal>
45 </interface>
46</node>
47
048
=== modified file 'places/app/dashdeclarativeview.cpp'
--- places/app/dashdeclarativeview.cpp 2011-03-08 09:57:38 +0000
+++ places/app/dashdeclarativeview.cpp 2011-03-08 11:26:49 +0000
@@ -15,6 +15,8 @@
15 */15 */
1616
17#include "dashdeclarativeview.h"17#include "dashdeclarativeview.h"
18#include "dashadaptor.h"
19
18#include <QDesktopWidget>20#include <QDesktopWidget>
19#include <QApplication>21#include <QApplication>
20#include <QBitmap>22#include <QBitmap>
@@ -22,8 +24,8 @@
22#include <QDeclarativeContext>24#include <QDeclarativeContext>
23#include <QX11Info>25#include <QX11Info>
24#include <QGraphicsObject>26#include <QGraphicsObject>
27#include <QtDBus/QDBusConnection>
25#include <QTimer>28#include <QTimer>
26
27#include <QDebug>29#include <QDebug>
2830
29#include <X11/Xlib.h>31#include <X11/Xlib.h>
@@ -38,6 +40,9 @@
38static const int DASH_DESKTOP_COLLAPSED_HEIGHT = 115;40static const int DASH_DESKTOP_COLLAPSED_HEIGHT = 115;
39static const int DASH_DESKTOP_EXPANDED_HEIGHT = 606;41static const int DASH_DESKTOP_EXPANDED_HEIGHT = 606;
4042
43static const char* DASH_DBUS_SERVICE = "com.canonical.Unity2d.Dash";
44static const char* DASH_DBUS_OBJECT_PATH = "/Dash";
45
41DashDeclarativeView::DashDeclarativeView()46DashDeclarativeView::DashDeclarativeView()
42: QDeclarativeView()47: QDeclarativeView()
43, m_mode(HiddenMode)48, m_mode(HiddenMode)
@@ -320,3 +325,14 @@
320{325{
321 return QX11Info::isCompositingManagerRunning();326 return QX11Info::isCompositingManagerRunning();
322}327}
328
329bool
330DashDeclarativeView::connectToBus()
331{
332 bool ok = QDBusConnection::sessionBus().registerService(DASH_DBUS_SERVICE);
333 if (!ok) {
334 return false;
335 }
336 new DashAdaptor(this);
337 return QDBusConnection::sessionBus().registerObject(DASH_DBUS_OBJECT_PATH, this);
338}
323339
=== modified file 'places/app/dashdeclarativeview.h'
--- places/app/dashdeclarativeview.h 2011-03-08 09:57:38 +0000
+++ places/app/dashdeclarativeview.h 2011-03-08 11:26:49 +0000
@@ -24,7 +24,6 @@
24 Q_OBJECT24 Q_OBJECT
25 Q_ENUMS(DashMode)25 Q_ENUMS(DashMode)
2626
27 Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity2d.Dash")
28 Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)27 Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
29 Q_PROPERTY(bool expanded READ expanded WRITE setExpanded NOTIFY expandedChanged)28 Q_PROPERTY(bool expanded READ expanded WRITE setExpanded NOTIFY expandedChanged)
30 Q_PROPERTY(DashMode dashMode READ dashMode WRITE setDashMode NOTIFY dashModeChanged)29 Q_PROPERTY(DashMode dashMode READ dashMode WRITE setDashMode NOTIFY dashModeChanged)
@@ -58,7 +57,8 @@
5857
59 /* methods */58 /* methods */
60 Q_INVOKABLE void activatePlaceEntry(const QString& file, const QString& entry, const int section = 0);59 Q_INVOKABLE void activatePlaceEntry(const QString& file, const QString& entry, const int section = 0);
61 Q_INVOKABLE void activateHome();60 Q_SLOT void activateHome();
61 bool connectToBus();
6262
63Q_SIGNALS:63Q_SIGNALS:
64 void activeChanged(bool);64 void activeChanged(bool);
6565
=== modified file 'places/app/places.cpp'
--- places/app/places.cpp 2011-02-24 01:13:42 +0000
+++ places/app/places.cpp 2011-03-08 11:26:49 +0000
@@ -39,33 +39,6 @@
39#include "dashdeclarativeview.h"39#include "dashdeclarativeview.h"
40#include "config.h"40#include "config.h"
4141
42/* Register a D-Bus service for activation and deactivation of the dash */
43static bool registerDBusService(DashDeclarativeView* view)
44{
45 QDBusConnection bus = QDBusConnection::sessionBus();
46 if (!bus.registerService("com.canonical.Unity2d")) {
47 qCritical() << "Failed to register DBus service, is there another instance already running?";
48 return false;
49 }
50 /* FIXME: use an adaptor class in order not to expose all of the view's
51 properties and methods. */\
52 if (!bus.registerObject("/Dash", view, QDBusConnection::ExportAllContents)) {
53 qCritical() << "Failed to register /Dash, this should not happen!";
54 return false;
55 }
56 /* It would be nice to support the newly introduced (D-Bus 0.14 07/09/2010)
57 property change notification that Qt 4.7 does not implement.
58
59 org.freedesktop.DBus.Properties.PropertiesChanged (
60 STRING interface_name,
61 DICT<STRING,VARIANT> changed_properties,
62 ARRAY<STRING> invalidated_properties);
63
64 ref.: http://randomguy3.wordpress.com/2010/09/07/the-magic-of-qtdbus-and-the-propertychanged-signal/
65 */
66 return true;
67}
68
69int main(int argc, char *argv[])42int main(int argc, char *argv[])
70{43{
71 /* gtk needs to be inited, otherwise we get an assert failure in gdk */44 /* gtk needs to be inited, otherwise we get an assert failure in gdk */
@@ -86,8 +59,8 @@
8659
87 qmlRegisterType<DashDeclarativeView>("Places", 1, 0, "DashDeclarativeView");60 qmlRegisterType<DashDeclarativeView>("Places", 1, 0, "DashDeclarativeView");
88 DashDeclarativeView view;61 DashDeclarativeView view;
8962 if (!view.connectToBus()) {
90 if (!registerDBusService(&view)) {63 qCritical() << "Another instance of the Dash already exists. Quitting.";
91 return -1;64 return -1;
92 }65 }
9366
9467
=== modified file 'places/app/unity-2d-places.service.in'
--- places/app/unity-2d-places.service.in 2011-01-14 20:47:33 +0000
+++ places/app/unity-2d-places.service.in 2011-03-08 11:26:49 +0000
@@ -1,3 +1,3 @@
1[D-BUS Service]1[D-BUS Service]
2Name=com.canonical.Unity2d2Name=com.canonical.Unity2d.Dash
3Exec=@CMAKE_INSTALL_PREFIX@/bin/unity-2d-places3Exec=@CMAKE_INSTALL_PREFIX@/bin/unity-2d-places

Subscribers

People subscribed via source and target branches

to all changes: