From 91feefd7d952d1e3a6b6e985afe34e2d726b2e38 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Tue, 17 Mar 2015 13:32:29 +0100 Subject: Export the symbols of libdbus-1 when loading it at runtime. This allows applications that need additional symbols from the library to easily obtain them without needing to replicate the library open logic from qdbus_symbols.cpp. Change-Id: Ic65ef6684637fbcd1c9f4fe1dc7a57f0624b61a8 Reviewed-by: Thiago Macieira --- src/dbus/qdbus_symbols.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/dbus') diff --git a/src/dbus/qdbus_symbols.cpp b/src/dbus/qdbus_symbols.cpp index 56e836c9ae..b82d92b561 100644 --- a/src/dbus/qdbus_symbols.cpp +++ b/src/dbus/qdbus_symbols.cpp @@ -81,6 +81,7 @@ bool qdbus_loadLibDBus() return lib && lib->isLoaded(); lib = new QLibrary; + lib->setLoadHints(QLibrary::ExportExternalSymbolsHint); // make libdbus symbols available for apps that need more advanced control over the dbus triedToLoadLibrary = true; static int majorversions[] = { 3, 2, -1 }; -- cgit v1.2.3 From c885efb3cd3835bfd565575a450235cc8a7983a9 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Tue, 17 Mar 2015 13:19:50 +0100 Subject: Skip non-exported slots early when creating a XML interface description. This will prevent unnecessary warnings about unknown types for signals or slots that are not even exported to the D-Bus. Change-Id: Iecda5beca5ebe6665a193245fe1c2578156f6abe Reviewed-by: Thiago Macieira --- src/dbus/qdbusxmlgenerator.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/dbus') diff --git a/src/dbus/qdbusxmlgenerator.cpp b/src/dbus/qdbusxmlgenerator.cpp index 8794292146..243440f48b 100644 --- a/src/dbus/qdbusxmlgenerator.cpp +++ b/src/dbus/qdbusxmlgenerator.cpp @@ -137,6 +137,12 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method !(flags & (QDBusConnection::ExportScriptableInvokables | QDBusConnection::ExportNonScriptableInvokables)))) continue; // we're not exporting any slots or invokables + // we want to skip non-scriptable stuff as early as possible to avoid bogus warning + // for methods that are not being exported at all + bool isScriptable = mm.attributes() & QMetaMethod::Scriptable; + if (!isScriptable && !(flags & (isSignal ? QDBusConnection::ExportNonScriptableSignals : QDBusConnection::ExportNonScriptableInvokables | QDBusConnection::ExportNonScriptableSlots))) + continue; + QString xml = QString::fromLatin1(" <%1 name=\"%2\">\n") .arg(isSignal ? QLatin1String("signal") : QLatin1String("method")) .arg(QString::fromLatin1(mm.name())); @@ -179,7 +185,6 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method continue; // cloned signal? int j; - bool isScriptable = mm.attributes() & QMetaMethod::Scriptable; for (j = 1; j < types.count(); ++j) { // input parameter for a slot or output for a signal if (types.at(j) == QDBusMetaTypeId::message()) { -- cgit v1.2.3 From 3203ac3f4e245427902bd912cb0c644c7e870657 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 30 Mar 2015 14:24:21 +0200 Subject: Use QDebugStateSaver to restore space setting in stream operators. Returning dbg.space() breaks formatting on streams that already have nospace() set. Change-Id: I55e38b018679a67eb40be6b4664505483a3a7d8e Reviewed-by: David Faure --- src/dbus/qdbuserror.cpp | 3 ++- src/dbus/qdbusintegrator.cpp | 6 ++++-- src/dbus/qdbusmessage.cpp | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src/dbus') diff --git a/src/dbus/qdbuserror.cpp b/src/dbus/qdbuserror.cpp index 0cfb0aa7c2..2b13f90fac 100644 --- a/src/dbus/qdbuserror.cpp +++ b/src/dbus/qdbuserror.cpp @@ -395,8 +395,9 @@ QString QDBusError::errorString(ErrorType error) #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QDBusError &msg) { + QDebugStateSaver saver(dbg); dbg.nospace() << "QDBusError(" << msg.name() << ", " << msg.message() << ')'; - return dbg.space(); + return dbg; } #endif diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 74d6a11dee..6edf08ebbe 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -91,18 +91,20 @@ static inline QString dbusInterfaceString() static inline QDebug operator<<(QDebug dbg, const QThread *th) { + QDebugStateSaver saver(dbg); dbg.nospace() << "QThread(ptr=" << (const void*)th; if (th && !th->objectName().isEmpty()) dbg.nospace() << ", name=" << th->objectName(); else if (th) dbg.nospace() << ", name=" << th->metaObject()->className(); dbg.nospace() << ')'; - return dbg.space(); + return dbg; } #if QDBUS_THREAD_DEBUG static inline QDebug operator<<(QDebug dbg, const QDBusConnectionPrivate *conn) { + QDebugStateSaver saver(dbg); dbg.nospace() << "QDBusConnection(" << "ptr=" << (const void*)conn << ", name=" << conn->name @@ -113,7 +115,7 @@ static inline QDebug operator<<(QDebug dbg, const QDBusConnectionPrivate *conn) else dbg.nospace() << conn->thread(); dbg.nospace() << ')'; - return dbg.space(); + return dbg; } void qdbusDefaultThreadDebug(int action, int condition, QDBusConnectionPrivate *conn) diff --git a/src/dbus/qdbusmessage.cpp b/src/dbus/qdbusmessage.cpp index 491e1273e7..b92e7f5cd7 100644 --- a/src/dbus/qdbusmessage.cpp +++ b/src/dbus/qdbusmessage.cpp @@ -785,6 +785,7 @@ static void debugVariantList(QDebug dbg, const QVariantList &list) QDebug operator<<(QDebug dbg, const QDBusMessage &msg) { + QDebugStateSaver saver(dbg); dbg.nospace() << "QDBusMessage(type=" << msg.type() << ", service=" << msg.service(); if (msg.type() == QDBusMessage::MethodCallMessage || @@ -799,7 +800,7 @@ QDebug operator<<(QDebug dbg, const QDBusMessage &msg) << ", contents=("; debugVariantList(dbg, msg.arguments()); dbg.nospace() << ") )"; - return dbg.space(); + return dbg; } #endif -- cgit v1.2.3 From 26edd5a3b127c09ade9e75c45e5271113da81064 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 29 Dec 2014 20:36:17 -0200 Subject: Use QStringLiteral where applicable in QtDBus Move to qdbusutil_p.h the string constants that are used often and in multiple places; use QStringLiteral in qdbusintegrator.cpp for the strings that are used often. Change-Id: I8e1325b9ba015bda91bf01c42175d8032ea32f62 Reviewed-by: Alex Blasche --- src/dbus/qdbusabstractinterface.cpp | 24 ++++++++--------- src/dbus/qdbusconnection.cpp | 8 +++--- src/dbus/qdbusconnectioninterface.cpp | 6 ++--- src/dbus/qdbusintegrator.cpp | 49 ++++++++++++----------------------- src/dbus/qdbuspendingcall.cpp | 3 ++- src/dbus/qdbusserver.cpp | 3 ++- src/dbus/qdbusservicewatcher.cpp | 10 +++---- src/dbus/qdbusutil_p.h | 22 ++++++++++++++++ 8 files changed, 64 insertions(+), 61 deletions(-) (limited to 'src/dbus') diff --git a/src/dbus/qdbusabstractinterface.cpp b/src/dbus/qdbusabstractinterface.cpp index 29d5c3d88c..03640cdd21 100644 --- a/src/dbus/qdbusabstractinterface.cpp +++ b/src/dbus/qdbusabstractinterface.cpp @@ -88,7 +88,7 @@ QDBusAbstractInterfacePrivate::QDBusAbstractInterfacePrivate(const QString &serv if (!connection.isConnected()) { lastError = QDBusError(QDBusError::Disconnected, - QLatin1String("Not connected to D-Bus server")); + QDBusUtil::disconnectedErrorMessage()); } else if (!service.isEmpty()) { currentOwner = connectionPrivate()->getNameOwner(service); // verify the name owner if (currentOwner.isEmpty()) { @@ -131,8 +131,8 @@ bool QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, void *retu // try to read this property QDBusMessage msg = QDBusMessage::createMethodCall(service, path, - QLatin1String(DBUS_INTERFACE_PROPERTIES), - QLatin1String("Get")); + QDBusUtil::dbusInterfaceProperties(), + QStringLiteral("Get")); QDBusMessagePrivate::setParametersValidated(msg, true); msg << interface << QString::fromUtf8(mp.name()); QDBusMessage reply = connection.call(msg, QDBus::Block, timeout); @@ -144,7 +144,7 @@ bool QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, void *retu if (reply.signature() != QLatin1String("v")) { QString errmsg = QLatin1String("Invalid signature `%1' in return from call to " DBUS_INTERFACE_PROPERTIES); - lastError = QDBusError(QDBusError::InvalidSignature, errmsg.arg(reply.signature())); + lastError = QDBusError(QDBusError::InvalidSignature, qMove(errmsg).arg(reply.signature())); return false; } @@ -198,8 +198,8 @@ bool QDBusAbstractInterfacePrivate::setProperty(const QMetaProperty &mp, const Q // send the value QDBusMessage msg = QDBusMessage::createMethodCall(service, path, - QLatin1String(DBUS_INTERFACE_PROPERTIES), - QLatin1String("Set")); + QDBusUtil::dbusInterfaceProperties(), + QStringLiteral("Set")); QDBusMessagePrivate::setParametersValidated(msg, true); msg << interface << QString::fromUtf8(mp.name()) << QVariant::fromValue(QDBusVariant(value)); QDBusMessage reply = connection.call(msg, QDBus::Block, timeout); @@ -290,10 +290,10 @@ QDBusAbstractInterface::QDBusAbstractInterface(QDBusAbstractInterfacePrivate &d, && !d.service.isEmpty() && !d.service.startsWith(QLatin1Char(':')) && d.connectionPrivate()->mode != QDBusConnectionPrivate::PeerMode) - d_func()->connection.connect(QLatin1String(DBUS_SERVICE_DBUS), // service + d_func()->connection.connect(QDBusUtil::dbusService(), // service QString(), // path - QLatin1String(DBUS_INTERFACE_DBUS), // interface - QLatin1String("NameOwnerChanged"), + QDBusUtil::dbusInterface(), // interface + QDBusUtil::nameOwnerChanged(), QStringList() << d.service, QString(), // signature this, SLOT(_q_serviceOwnerChanged(QString,QString,QString))); @@ -316,10 +316,10 @@ QDBusAbstractInterface::QDBusAbstractInterface(const QString &service, const QSt && !service.isEmpty() && !service.startsWith(QLatin1Char(':')) && d_func()->connectionPrivate()->mode != QDBusConnectionPrivate::PeerMode) - d_func()->connection.connect(QLatin1String(DBUS_SERVICE_DBUS), // service + d_func()->connection.connect(QDBusUtil::dbusService(), // service QString(), // path - QLatin1String(DBUS_INTERFACE_DBUS), // interface - QLatin1String("NameOwnerChanged"), + QDBusUtil::dbusInterface(), // interface + QDBusUtil::nameOwnerChanged(), QStringList() << service, QString(), //signature this, SLOT(_q_serviceOwnerChanged(QString,QString,QString))); diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index 5dc18fe908..0adb3dd748 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -462,7 +462,7 @@ bool QDBusConnection::send(const QDBusMessage &message) const { if (!d || !d->connection) { QDBusError err = QDBusError(QDBusError::Disconnected, - QLatin1String("Not connected to D-BUS server")); + QDBusUtil::disconnectedErrorMessage()); if (d) d->lastError = err; return false; @@ -495,7 +495,7 @@ bool QDBusConnection::callWithCallback(const QDBusMessage &message, QObject *rec { if (!d || !d->connection) { QDBusError err = QDBusError(QDBusError::Disconnected, - QLatin1String("Not connected to D-BUS server")); + QDBusUtil::disconnectedErrorMessage()); if (d) d->lastError = err; return false; @@ -553,7 +553,7 @@ QDBusMessage QDBusConnection::call(const QDBusMessage &message, QDBus::CallMode { if (!d || !d->connection) { QDBusError err = QDBusError(QDBusError::Disconnected, - QLatin1String("Not connected to D-Bus server")); + QDBusUtil::disconnectedErrorMessage()); if (d) d->lastError = err; @@ -968,7 +968,7 @@ bool QDBusConnection::isConnected() const */ QDBusError QDBusConnection::lastError() const { - return d ? d->lastError : QDBusError(QDBusError::Disconnected, QStringLiteral("Not connected.")); + return d ? d->lastError : QDBusError(QDBusError::Disconnected, QDBusUtil::disconnectedErrorMessage()); } /*! diff --git a/src/dbus/qdbusconnectioninterface.cpp b/src/dbus/qdbusconnectioninterface.cpp index f3ca04b86c..ff923ba282 100644 --- a/src/dbus/qdbusconnectioninterface.cpp +++ b/src/dbus/qdbusconnectioninterface.cpp @@ -42,7 +42,7 @@ #include #include -#include "qdbus_symbols_p.h" // for the DBUS_* constants +#include "qdbusutil_p.h" // for the DBUS_* constants #ifndef QT_NO_DBUS @@ -154,8 +154,8 @@ const char *QDBusConnectionInterface::staticInterfaceName() */ QDBusConnectionInterface::QDBusConnectionInterface(const QDBusConnection &connection, QObject *parent) - : QDBusAbstractInterface(QLatin1String(DBUS_SERVICE_DBUS), - QLatin1String(DBUS_PATH_DBUS), + : QDBusAbstractInterface(QDBusUtil::dbusService(), + QDBusUtil::dbusPath(), DBUS_INTERFACE_DBUS, connection, parent) { connect(this, SIGNAL(NameAcquired(QString)), this, SIGNAL(serviceRegistered(QString))); diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 6edf08ebbe..9eac1ed933 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -72,23 +72,6 @@ static dbus_int32_t server_slot = -1; static QBasicAtomicInt isDebugging = Q_BASIC_ATOMIC_INITIALIZER(-1); #define qDBusDebug if (::isDebugging == 0); else qDebug -static inline QString orgFreedesktopDBusString() -{ - return QStringLiteral(DBUS_SERVICE_DBUS); -} - -static inline QString dbusServiceString() -{ - return orgFreedesktopDBusString(); -} - -static inline QString dbusInterfaceString() -{ - // it's the same string, but just be sure - Q_ASSERT(orgFreedesktopDBusString() == QLatin1String(DBUS_INTERFACE_DBUS)); - return orgFreedesktopDBusString(); -} - static inline QDebug operator<<(QDebug dbg, const QThread *th) { QDebugStateSaver saver(dbg); @@ -1041,7 +1024,7 @@ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p) // prepopulate watchedServices: // we know that the owner of org.freedesktop.DBus is itself - watchedServices.insert(dbusServiceString(), WatchedServiceData(dbusServiceString(), 1)); + watchedServices.insert(QDBusUtil::dbusService(), WatchedServiceData(QDBusUtil::dbusService(), 1)); // prepopulate matchRefCounts: // we know that org.freedesktop.DBus will never change owners @@ -1377,7 +1360,7 @@ bool QDBusConnectionPrivate::activateInternalFilters(const ObjectTreeNode &node, // object may be null const QString interface = msg.interface(); - if (interface.isEmpty() || interface == QLatin1String(DBUS_INTERFACE_INTROSPECTABLE)) { + if (interface.isEmpty() || interface == QDBusUtil::dbusInterfaceIntrospectable()) { if (msg.member() == QLatin1String("Introspect") && msg.signature().isEmpty()) { //qDebug() << "QDBusConnectionPrivate::activateInternalFilters introspect" << msg.d_ptr->msg; QDBusMessage reply = msg.createReply(qDBusIntrospectObject(node, msg.path())); @@ -1392,7 +1375,7 @@ bool QDBusConnectionPrivate::activateInternalFilters(const ObjectTreeNode &node, } if (node.obj && (interface.isEmpty() || - interface == QLatin1String(DBUS_INTERFACE_PROPERTIES))) { + interface == QDBusUtil::dbusInterfaceProperties())) { //qDebug() << "QDBusConnectionPrivate::activateInternalFilters properties" << msg.d_ptr->msg; if (msg.member() == QLatin1String("Get") && msg.signature() == QLatin1String("ss")) { QDBusMessage reply = qDBusPropertyGet(node, msg); @@ -1779,7 +1762,7 @@ void QDBusConnectionPrivate::setConnection(DBusConnection *dbc, const QDBusError // we don't use connectSignal here because we don't need the rules to be sent to the bus // the bus will always send us these two signals SignalHook hook; - hook.service = dbusServiceString(); + hook.service = QDBusUtil::dbusService(); hook.path.clear(); // no matching hook.obj = this; hook.params << QMetaType::Void << QVariant::String; // both functions take a QString as parameter and return void @@ -2205,10 +2188,10 @@ QDBusPendingCallPrivate *QDBusConnectionPrivate::sendWithReplyAsync(const QDBusM return pcall; } else { // we're probably disconnected at this point - lastError = error = QDBusError(QDBusError::Disconnected, QLatin1String("Not connected to server")); + lastError = error = QDBusError(QDBusError::Disconnected, QDBusUtil::disconnectedErrorMessage()); } } else { - lastError = error = QDBusError(QDBusError::NoMemory, QLatin1String("Out of memory")); + lastError = error = QDBusError(QDBusError::NoMemory, QStringLiteral("Out of memory")); } q_dbus_message_unref(msg); @@ -2279,8 +2262,8 @@ void QDBusConnectionPrivate::connectSignal(const QString &key, const SignalHook WatchedServicesHash::mapped_type &data = watchedServices[hook.service]; if (++data.refcount == 1) { // we need to watch for this service changing - connectSignal(dbusServiceString(), QString(), dbusInterfaceString(), - QLatin1String("NameOwnerChanged"), QStringList() << hook.service, QString(), + connectSignal(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(), + QStringLiteral("NameOwnerChanged"), QStringList() << hook.service, QString(), this, SLOT(serviceOwnerChangedNoLock(QString,QString,QString))); data.owner = getNameOwnerNoCache(hook.service); qDBusDebug() << this << "Watching service" << hook.service << "for owner changes (current owner:" @@ -2359,8 +2342,8 @@ QDBusConnectionPrivate::disconnectSignal(SignalHookHash::Iterator &it) if (sit != watchedServices.end()) { if (--sit.value().refcount == 0) { watchedServices.erase(sit); - disconnectSignal(dbusServiceString(), QString(), dbusInterfaceString(), - QLatin1String("NameOwnerChanged"), QStringList() << hook.service, QString(), + disconnectSignal(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(), + QStringLiteral("NameOwnerChanged"), QStringList() << hook.service, QString(), this, SLOT(serviceOwnerChangedNoLock(QString,QString,QString))); } } @@ -2501,9 +2484,9 @@ QString QDBusConnectionPrivate::getNameOwner(const QString& serviceName) QString QDBusConnectionPrivate::getNameOwnerNoCache(const QString &serviceName) { - QDBusMessage msg = QDBusMessage::createMethodCall(dbusServiceString(), - QLatin1String(DBUS_PATH_DBUS), dbusInterfaceString(), - QLatin1String("GetNameOwner")); + QDBusMessage msg = QDBusMessage::createMethodCall(QDBusUtil::dbusService(), + QDBusUtil::dbusPath(), QDBusUtil::dbusInterface(), + QStringLiteral("GetNameOwner")); QDBusMessagePrivate::setParametersValidated(msg, true); msg << serviceName; QDBusMessage reply = sendWithReply(msg, QDBus::Block); @@ -2526,8 +2509,8 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa // introspect the target object QDBusMessage msg = QDBusMessage::createMethodCall(service, path, - QLatin1String(DBUS_INTERFACE_INTROSPECTABLE), - QLatin1String("Introspect")); + QDBusUtil::dbusInterfaceIntrospectable(), + QStringLiteral("Introspect")); QDBusMessagePrivate::setParametersValidated(msg, true); QDBusMessage reply = sendWithReply(msg, QDBus::Block); @@ -2586,7 +2569,7 @@ bool QDBusConnectionPrivate::isServiceRegisteredByThread(const QString &serviceN { if (!serviceName.isEmpty() && serviceName == baseService) return true; - if (serviceName == dbusServiceString()) + if (serviceName == QDBusUtil::dbusService()) return false; QDBusReadLocker locker(UnregisterServiceAction, this); diff --git a/src/dbus/qdbuspendingcall.cpp b/src/dbus/qdbuspendingcall.cpp index 321dcb4ef4..09eff81107 100644 --- a/src/dbus/qdbuspendingcall.cpp +++ b/src/dbus/qdbuspendingcall.cpp @@ -36,6 +36,7 @@ #include "qdbusconnection_p.h" #include "qdbusmetatype_p.h" +#include "qdbusutil_p.h" #include "qcoreapplication.h" #include "qcoreevent.h" #include @@ -383,7 +384,7 @@ QDBusError QDBusPendingCall::error() const // not connected, return an error QDBusError err = QDBusError(QDBusError::Disconnected, - QLatin1String("Not connected to D-Bus server")); + QDBusUtil::disconnectedErrorMessage()); return err; } diff --git a/src/dbus/qdbusserver.cpp b/src/dbus/qdbusserver.cpp index 3b7b797cff..2fc7c75d83 100644 --- a/src/dbus/qdbusserver.cpp +++ b/src/dbus/qdbusserver.cpp @@ -34,6 +34,7 @@ #include "qdbusserver.h" #include "qdbusconnection_p.h" #include "qdbusconnectionmanager_p.h" +#include "qdbusutil_p.h" #ifndef QT_NO_DBUS @@ -130,7 +131,7 @@ bool QDBusServer::isConnected() const */ QDBusError QDBusServer::lastError() const { - return d ? d->lastError : QDBusError(QDBusError::Disconnected, QStringLiteral("Not connected.")); + return d ? d->lastError : QDBusError(QDBusError::Disconnected, QDBusUtil::disconnectedErrorMessage()); } /*! diff --git a/src/dbus/qdbusservicewatcher.cpp b/src/dbus/qdbusservicewatcher.cpp index a7832eb3ff..4adf049d17 100644 --- a/src/dbus/qdbusservicewatcher.cpp +++ b/src/dbus/qdbusservicewatcher.cpp @@ -33,7 +33,7 @@ #include "qdbusservicewatcher.h" #include "qdbusconnection.h" -#include "qdbus_symbols_p.h" +#include "qdbusutil_p.h" #include @@ -43,10 +43,6 @@ QT_BEGIN_NAMESPACE -Q_GLOBAL_STATIC_WITH_ARGS(QString, busService, (QLatin1String(DBUS_SERVICE_DBUS))) -Q_GLOBAL_STATIC_WITH_ARGS(QString, busInterface, (QLatin1String(DBUS_INTERFACE_DBUS))) -Q_GLOBAL_STATIC_WITH_ARGS(QString, signalName, (QLatin1String("NameOwnerChanged"))) - class QDBusServiceWatcherPrivate: public QObjectPrivate { Q_DECLARE_PUBLIC(QDBusServiceWatcher) @@ -120,7 +116,7 @@ QStringList QDBusServiceWatcherPrivate::matchArgsForService(const QString &servi void QDBusServiceWatcherPrivate::addService(const QString &service) { QStringList matchArgs = matchArgsForService(service); - connection.connect(*busService(), QString(), *busInterface(), *signalName(), + connection.connect(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(), QDBusUtil::nameOwnerChanged(), matchArgs, QString(), q_func(), SLOT(_q_serviceOwnerChanged(QString,QString,QString))); } @@ -128,7 +124,7 @@ void QDBusServiceWatcherPrivate::addService(const QString &service) void QDBusServiceWatcherPrivate::removeService(const QString &service) { QStringList matchArgs = matchArgsForService(service); - connection.disconnect(*busService(), QString(), *busInterface(), *signalName(), + connection.disconnect(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(), QDBusUtil::nameOwnerChanged(), matchArgs, QString(), q_func(), SLOT(_q_serviceOwnerChanged(QString,QString,QString))); } diff --git a/src/dbus/qdbusutil_p.h b/src/dbus/qdbusutil_p.h index b5f92f2e47..8f5ae922db 100644 --- a/src/dbus/qdbusutil_p.h +++ b/src/dbus/qdbusutil_p.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2015 Intel Corporation. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtDBus module of the Qt Toolkit. @@ -51,6 +52,8 @@ #include #include +#include "qdbus_symbols_p.h" + #ifndef QT_NO_DBUS QT_BEGIN_NAMESPACE @@ -147,6 +150,25 @@ namespace QDBusUtil *error = QDBusError(QDBusError::InvalidInterface, QString::fromLatin1("Invalid error name: %1").arg(name)); return false; } + + inline QString dbusService() + { return QStringLiteral(DBUS_SERVICE_DBUS); } + inline QString dbusPath() + { return QStringLiteral(DBUS_PATH_DBUS); } + inline QString dbusInterface() + { + // it's the same string, but just be sure + Q_ASSERT(dbusService() == QLatin1String(DBUS_INTERFACE_DBUS)); + return dbusService(); + } + inline QString dbusInterfaceProperties() + { return QStringLiteral(DBUS_INTERFACE_PROPERTIES); } + inline QString dbusInterfaceIntrospectable() + { return QStringLiteral(DBUS_INTERFACE_INTROSPECTABLE); } + inline QString nameOwnerChanged() + { return QStringLiteral("NameOwnerChanged"); } + inline QString disconnectedErrorMessage() + { return QStringLiteral("Not connected to D-Bus server"); } } QT_END_NAMESPACE -- cgit v1.2.3