2 * Copyright (C) 2014 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17#include "unitydbusobject.h"
20#include <QDBusMessage>
21#include <QMetaClassInfo>
24UnityDBusObject::UnityDBusObject(const QString &path, const QString &service, QObject *parent)
26 , m_connection(QDBusConnection::sessionBus())
30 // Use a zero-timer to let Qml finish loading before we announce on DBus
31 QTimer::singleShot(0, this, SLOT(registerObject()));
34UnityDBusObject::~UnityDBusObject()
36 // Leave service in place because multiple objects may be registered with
37 // the same service. But we know we own the object path and can unregister it.
38 m_connection.unregisterObject(path());
41QDBusConnection UnityDBusObject::connection() const
46QString UnityDBusObject::path() const
51// Manually emit a PropertiesChanged signal over DBus, because QtDBus
52// doesn't do it for us on Q_PROPERTIES, oddly enough.
53void UnityDBusObject::notifyPropertyChanged(const QString& propertyName, const QVariant &value)
57 QVariantMap changedProps;
59 interface = metaObject()->classInfo(metaObject()->indexOfClassInfo("D-Bus Interface")).value();
60 changedProps.insert(propertyName, value);
62 message = QDBusMessage::createSignal(path(),
63 "org.freedesktop.DBus.Properties",
66 message << changedProps;
67 message << QStringList();
69 connection().send(message);
72void UnityDBusObject::registerObject()
74 if (!m_connection.registerObject(m_path, this, QDBusConnection::ExportScriptableContents)) {
75 qWarning() << "Unable to register DBus object" << m_path;
77 if (!m_service.isEmpty()) {
78 if (!m_connection.registerService(m_service)) {
79 qWarning() << "Unable to register DBus service" << m_service;
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list