automotive-message-broker  0.14.803
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
bmdbus.h
1 /*
2  Copyright (C) 2012 Intel Corporation
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #ifndef BM_DBUS_H_
20 #define BM_DBUS_H_
21 
22 #include <QObject>
23 #include <QJSValue>
24 #include <QDBusConnection>
25 
26 class BMDBus : public QObject
27 {
28  Q_OBJECT
29  Q_PROPERTY(int Session READ sessionBus)
30  Q_PROPERTY(int System READ systemBus)
31 
32 public:
33 
34  enum Connection{
35  System = 0,
36  Session
37  };
38 
39  Q_ENUMS(Connection)
40 
41  BMDBus(QObject * parent = nullptr);
42 
43  Connection sessionBus() { return BMDBus::Session; }
44  Connection systemBus() { return BMDBus::System; }
45 
46 public Q_SLOTS:
47 
48  QObject* createInterface(const QString & service, const QString & path, const QString & interface, Connection bus);
49 
50  bool registerService(const QString & service, Connection bus);
51 
52  bool unregisterService(const QString & service, Connection bus);
53 
54  bool exportObject(const QString & path, const QString & interface, Connection bus, const QJSValue &obj);
55 
56  QString errorMessage(const Connection bus = Session);
57 
58 private:
59 
60  QDBusConnection getConnection(const Connection bus);
61 };
62 
63 class BareQObject : public QObject
64 {
65  Q_OBJECT
66 public Q_SLOTS:
67  void becauseImHappy() { }
68 };
69 
70 class TestQObject : public QObject
71 {
72  Q_OBJECT
73 public:
74  TestQObject(QObject * parent = nullptr) : QObject(parent) {}
75 public Q_SLOTS:
76  QString awesomeMethod() { return "awesome"; }
77 };
78 
79 #endif