The const char *-based API is deprecated and will be removed in Qt5.
Change-Id: I1c7f0e46149964367f42faccfff4b89acbf16511
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
\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);
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();
\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);
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,
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);
#include <QtCore/QByteArray>
#include <QtCore/QList>
#include <QtCore/QMap>
+#include <QtCore/QMetaMethod>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QVariant>
/*!
\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
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
};
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
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