1 | /* |
2 | This file is part of the KDE project. |
3 | |
4 | Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr> |
5 | Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com> |
6 | |
7 | Permission is hereby granted, free of charge, to any person obtaining a |
8 | copy of this software and associated documentation files (the "Software"), |
9 | to deal in the Software without restriction, including without limitation |
10 | the rights to use, copy, modify, merge, publish, distribute, sublicense, |
11 | and/or sell copies of the Software, and to permit persons to whom the |
12 | Software is furnished to do so, subject to the following conditions: |
13 | |
14 | The above copyright notice and this permission notice shall be included in |
15 | all copies or substantial portions of the Software. |
16 | |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
20 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | DEALINGS IN THE SOFTWARE. |
24 | */ |
25 | |
26 | #include "appmenu_dbus.h" |
27 | #include "kdbusimporter.h" |
28 | #include "appmenuadaptor.h" |
29 | |
30 | #include <QApplication> |
31 | #include <QDBusMessage> |
32 | #include <QDBusObjectPath> |
33 | #include <QDBusServiceWatcher> |
34 | |
35 | static const char* DBUS_SERVICE = "org.kde.kded" ; |
36 | static const char* DBUS_OBJECT_PATH = "/modules/appmenu" ; |
37 | |
38 | AppmenuDBus::(QObject* parent) |
39 | : QObject(parent) |
40 | { |
41 | } |
42 | |
43 | AppmenuDBus::() |
44 | { |
45 | } |
46 | |
47 | bool AppmenuDBus::(const QString& service, const QString& path) |
48 | { |
49 | m_service = service.isEmpty() ? DBUS_SERVICE : service; |
50 | QString newPath = path.isEmpty() ? DBUS_OBJECT_PATH : path; |
51 | |
52 | if (!QDBusConnection::sessionBus().registerService(m_service)) { |
53 | return false; |
54 | } |
55 | new AppmenuAdaptor(this); |
56 | QDBusConnection::sessionBus().registerObject(newPath, this); |
57 | |
58 | return true; |
59 | } |
60 | |
61 | void AppmenuDBus::(int x, int y, WId id) |
62 | { |
63 | emit appShowMenu(x, y, id); |
64 | } |
65 | |
66 | void AppmenuDBus::() |
67 | { |
68 | emit moduleReconfigure(); |
69 | } |