summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2012-04-22 15:05:56 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-01 01:18:03 +0200
commita08e0fca276341396d92c63dd4a417cb482de82d (patch)
treee5ac78a65f581ded19d4310f80adfd6287d3f55d
parente525957253de61b9f2f7066e222fa8f06a6afacc (diff)
Port QtDBus to QMetaMethod-based connectNotify()
The const char *-based API is deprecated and will be removed in Qt5. Change-Id: I1c7f0e46149964367f42faccfff4b89acbf16511 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/dbus/qdbusabstractinterface.cpp7
-rw-r--r--src/dbus/qdbusabstractinterface.h4
-rw-r--r--src/dbus/qdbusconnection_p.h4
-rw-r--r--src/dbus/qdbusconnectioninterface.cpp49
-rw-r--r--src/dbus/qdbusconnectioninterface.h4
-rw-r--r--src/dbus/qdbusintegrator.cpp14
6 files changed, 51 insertions, 31 deletions
diff --git a/src/dbus/qdbusabstractinterface.cpp b/src/dbus/qdbusabstractinterface.cpp
index 79c607e6b4..76089f2c7d 100644
--- a/src/dbus/qdbusabstractinterface.cpp
+++ b/src/dbus/qdbusabstractinterface.cpp
@@ -577,7 +577,7 @@ bool QDBusAbstractInterface::callWithCallback(const QString &method,
\internal
Catch signal connections.
*/
-void QDBusAbstractInterface::connectNotify(const char *signal)
+void QDBusAbstractInterface::connectNotify(const QMetaMethod &signal)
{
// someone connecting to one of our signals
Q_D(QDBusAbstractInterface);
@@ -585,7 +585,8 @@ void QDBusAbstractInterface::connectNotify(const char *signal)
return;
// we end up recursing here, so optimize away
- if (qstrcmp(signal + 1, "destroyed(QObject*)") == 0)
+ static const QMetaMethod destroyedSignal = QMetaMethod::fromSignal(&QDBusAbstractInterface::destroyed);
+ if (signal == destroyedSignal)
return;
QDBusConnectionPrivate *conn = d->connectionPrivate();
@@ -599,7 +600,7 @@ void QDBusAbstractInterface::connectNotify(const char *signal)
\internal
Catch signal disconnections.
*/
-void QDBusAbstractInterface::disconnectNotify(const char *signal)
+void QDBusAbstractInterface::disconnectNotify(const QMetaMethod &signal)
{
// someone disconnecting from one of our signals
Q_D(QDBusAbstractInterface);
diff --git a/src/dbus/qdbusabstractinterface.h b/src/dbus/qdbusabstractinterface.h
index 648229c061..2752458312 100644
--- a/src/dbus/qdbusabstractinterface.h
+++ b/src/dbus/qdbusabstractinterface.h
@@ -146,8 +146,8 @@ protected:
const QDBusConnection &connection, QObject *parent);
QDBusAbstractInterface(QDBusAbstractInterfacePrivate &, QObject *parent);
- void connectNotify(const char *signal);
- void disconnectNotify(const char *signal);
+ void connectNotify(const QMetaMethod &signal);
+ void disconnectNotify(const QMetaMethod &signal);
QVariant internalPropGet(const char *propname) const;
void internalPropSet(const char *propname, const QVariant &value);
QDBusMessage internalConstCall(QDBus::CallMode mode,
diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h
index fb53f3efba..d249789a5f 100644
--- a/src/dbus/qdbusconnection_p.h
+++ b/src/dbus/qdbusconnection_p.h
@@ -210,10 +210,10 @@ public:
void registerObject(const ObjectTreeNode *node);
void connectRelay(const QString &service,
const QString &path, const QString &interface,
- QDBusAbstractInterface *receiver, const char *signal);
+ QDBusAbstractInterface *receiver, const QMetaMethod &signal);
void disconnectRelay(const QString &service,
const QString &path, const QString &interface,
- QDBusAbstractInterface *receiver, const char *signal);
+ QDBusAbstractInterface *receiver, const QMetaMethod &signal);
void registerService(const QString &serviceName);
void unregisterService(const QString &serviceName);
diff --git a/src/dbus/qdbusconnectioninterface.cpp b/src/dbus/qdbusconnectioninterface.cpp
index 0f85f9090e..1b7b69933e 100644
--- a/src/dbus/qdbusconnectioninterface.cpp
+++ b/src/dbus/qdbusconnectioninterface.cpp
@@ -44,6 +44,7 @@
#include <QtCore/QByteArray>
#include <QtCore/QList>
#include <QtCore/QMap>
+#include <QtCore/QMetaMethod>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QVariant>
@@ -328,41 +329,53 @@ QDBusConnectionInterface::unregisterService(const QString &serviceName)
/*!
\internal
*/
-void QDBusConnectionInterface::connectNotify(const char *signalName)
+void QDBusConnectionInterface::connectNotify(const QMetaMethod &signal)
{
// translate the signal names to what we really want
// this avoids setting hooks for signals that don't exist on the bus
- if (qstrcmp(signalName, SIGNAL(serviceRegistered(QString))) == 0)
- QDBusAbstractInterface::connectNotify(SIGNAL(NameAcquired(QString)));
-
- else if (qstrcmp(signalName, SIGNAL(serviceUnregistered(QString))) == 0)
- QDBusAbstractInterface::connectNotify(SIGNAL(NameLost(QString)));
-
- else if (qstrcmp(signalName, SIGNAL(serviceOwnerChanged(QString,QString,QString))) == 0) {
+ static const QMetaMethod serviceRegisteredSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::serviceRegistered);
+ static const QMetaMethod serviceUnregisteredSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::serviceUnregistered);
+ static const QMetaMethod serviceOwnerChangedSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::serviceOwnerChanged);
+ static const QMetaMethod NameAcquiredSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::NameAcquired);
+ static const QMetaMethod NameLostSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::NameLost);
+ static const QMetaMethod NameOwnerChangedSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::NameOwnerChanged);
+ if (signal == serviceRegisteredSignal)
+ QDBusAbstractInterface::connectNotify(NameAcquiredSignal);
+
+ else if (signal == serviceUnregisteredSignal)
+ QDBusAbstractInterface::connectNotify(NameLostSignal);
+
+ else if (signal == serviceOwnerChangedSignal) {
static bool warningPrinted = false;
if (!warningPrinted) {
qWarning("Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)");
warningPrinted = true;
}
- QDBusAbstractInterface::connectNotify(SIGNAL(NameOwnerChanged(QString,QString,QString)));
+ QDBusAbstractInterface::connectNotify(NameOwnerChangedSignal);
}
}
/*!
\internal
*/
-void QDBusConnectionInterface::disconnectNotify(const char *signalName)
+void QDBusConnectionInterface::disconnectNotify(const QMetaMethod &signal)
{
// translate the signal names to what we really want
// this avoids setting hooks for signals that don't exist on the bus
- if (qstrcmp(signalName, SIGNAL(serviceRegistered(QString))) == 0)
- QDBusAbstractInterface::disconnectNotify(SIGNAL(NameAcquired(QString)));
-
- else if (qstrcmp(signalName, SIGNAL(serviceUnregistered(QString))) == 0)
- QDBusAbstractInterface::disconnectNotify(SIGNAL(NameLost(QString)));
-
- else if (qstrcmp(signalName, SIGNAL(serviceOwnerChanged(QString,QString,QString))) == 0)
- QDBusAbstractInterface::disconnectNotify(SIGNAL(NameOwnerChanged(QString,QString,QString)));
+ static const QMetaMethod serviceRegisteredSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::serviceRegistered);
+ static const QMetaMethod serviceUnregisteredSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::serviceUnregistered);
+ static const QMetaMethod serviceOwnerChangedSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::serviceOwnerChanged);
+ static const QMetaMethod NameAcquiredSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::NameAcquired);
+ static const QMetaMethod NameLostSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::NameLost);
+ static const QMetaMethod NameOwnerChangedSignal = QMetaMethod::fromSignal(&QDBusConnectionInterface::NameOwnerChanged);
+ if (signal == serviceRegisteredSignal)
+ QDBusAbstractInterface::disconnectNotify(NameAcquiredSignal);
+
+ else if (signal == serviceUnregisteredSignal)
+ QDBusAbstractInterface::disconnectNotify(NameLostSignal);
+
+ else if (signal == serviceOwnerChangedSignal)
+ QDBusAbstractInterface::disconnectNotify(NameOwnerChangedSignal);
}
// signals
diff --git a/src/dbus/qdbusconnectioninterface.h b/src/dbus/qdbusconnectioninterface.h
index b3651c87a7..e822edd525 100644
--- a/src/dbus/qdbusconnectioninterface.h
+++ b/src/dbus/qdbusconnectioninterface.h
@@ -116,8 +116,8 @@ Q_SIGNALS:
void NameLost(const QString &);
void NameOwnerChanged(const QString &, const QString &, const QString &);
protected:
- void connectNotify(const char *);
- void disconnectNotify(const char *);
+ void connectNotify(const QMetaMethod &);
+ void disconnectNotify(const QMetaMethod &);
#endif
};
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index 5bdd0ee8d8..35b40a16f9 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -2236,14 +2236,17 @@ void QDBusConnectionPrivate::registerObject(const ObjectTreeNode *node)
void QDBusConnectionPrivate::connectRelay(const QString &service,
const QString &path, const QString &interface,
QDBusAbstractInterface *receiver,
- const char *signal)
+ const QMetaMethod &signal)
{
// this function is called by QDBusAbstractInterface when one of its signals is connected
// we set up a relay from D-Bus into it
SignalHook hook;
QString key;
- if (!prepareHook(hook, key, service, path, interface, QString(), QStringList(), receiver, signal,
+ QByteArray sig;
+ sig.append(QSIGNAL_CODE + '0');
+ sig.append(signal.methodSignature());
+ if (!prepareHook(hook, key, service, path, interface, QString(), QStringList(), receiver, sig,
QDBusAbstractInterface::staticMetaObject.methodCount(), true))
return; // don't connect
@@ -2267,14 +2270,17 @@ void QDBusConnectionPrivate::connectRelay(const QString &service,
void QDBusConnectionPrivate::disconnectRelay(const QString &service,
const QString &path, const QString &interface,
QDBusAbstractInterface *receiver,
- const char *signal)
+ const QMetaMethod &signal)
{
// this function is called by QDBusAbstractInterface when one of its signals is disconnected
// we remove relay from D-Bus into it
SignalHook hook;
QString key;
- if (!prepareHook(hook, key, service, path, interface, QString(), QStringList(), receiver, signal,
+ QByteArray sig;
+ sig.append(QSIGNAL_CODE + '0');
+ sig.append(signal.methodSignature());
+ if (!prepareHook(hook, key, service, path, interface, QString(), QStringList(), receiver, sig,
QDBusAbstractInterface::staticMetaObject.methodCount(), true))
return; // don't connect