summaryrefslogtreecommitdiffstats
path: root/src/dbus
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-10-23 17:33:38 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-10-28 09:16:48 (GMT)
commited75146e45d41ca52b64193acbf433e6d2ceaaf5 (patch)
tree59ea6072b07fbe7a9391ccf2a15f97fd31ba3ce5 /src/dbus
parent26c5680cf5adbf0c87357d84f2e2a6256724d4b7 (diff)
downloadQt-ed75146e45d41ca52b64193acbf433e6d2ceaaf5.zip
Qt-ed75146e45d41ca52b64193acbf433e6d2ceaaf5.tar.gz
Qt-ed75146e45d41ca52b64193acbf433e6d2ceaaf5.tar.bz2
Move the bulk of the signal connecting/disconnecting code to QDBusConnectionPrivate
I'll need to recurse into the signal connection mechanism in the next commit.
Diffstat (limited to 'src/dbus')
-rw-r--r--src/dbus/qdbusconnection.cpp63
-rw-r--r--src/dbus/qdbusconnection_p.h6
-rw-r--r--src/dbus/qdbusintegrator.cpp73
3 files changed, 82 insertions, 60 deletions
diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp
index 3aaba68..71e433e 100644
--- a/src/dbus/qdbusconnection.cpp
+++ b/src/dbus/qdbusconnection.cpp
@@ -619,37 +619,10 @@ bool QDBusConnection::connect(const QString &service, const QString &path, const
if (interface.isEmpty() && name.isEmpty())
return false;
- // check the slot
- QDBusConnectionPrivate::SignalHook hook;
- QString key;
- QString name2 = name;
- if (name2.isNull())
- name2.detach();
-
QString owner = d->getNameOwner(service); // we don't care if the owner is empty
- hook.signature = signature; // it might get started later
- if (!d->prepareHook(hook, key, service, owner, path, interface, name, argumentMatch, receiver, slot, 0, false))
- return false; // don't connect
-
- // avoid duplicating:
+ // it might get started later
QDBusWriteLocker locker(ConnectAction, d);
- QDBusConnectionPrivate::SignalHookHash::ConstIterator it = d->signalHooks.find(key);
- QDBusConnectionPrivate::SignalHookHash::ConstIterator end = d->signalHooks.constEnd();
- for ( ; it != end && it.key() == key; ++it) {
- const QDBusConnectionPrivate::SignalHook &entry = it.value();
- if (entry.service == hook.service &&
- entry.owner == hook.owner &&
- entry.path == hook.path &&
- entry.signature == hook.signature &&
- entry.obj == hook.obj &&
- entry.midx == hook.midx) {
- // no need to compare the parameters if it's the same slot
- return true; // already there
- }
- }
-
- d->connectSignal(key, hook);
- return true;
+ return d->connectSignal(service, owner, path, interface, name, argumentMatch, signature, receiver, slot);
}
/*!
@@ -704,38 +677,8 @@ bool QDBusConnection::disconnect(const QString &service, const QString &path, co
if (interface.isEmpty() && name.isEmpty())
return false;
- // check the slot
- QDBusConnectionPrivate::SignalHook hook;
- QString key;
- QString name2 = name;
- if (name2.isNull())
- name2.detach();
-
- QString owner = d->getNameOwner(service); // we don't care of owner is empty
- hook.signature = signature;
- if (!d->prepareHook(hook, key, service, owner, path, interface, name, argumentMatch, receiver, slot, 0, false))
- return false; // don't disconnect
-
- // avoid duplicating:
QDBusWriteLocker locker(DisconnectAction, d);
- QDBusConnectionPrivate::SignalHookHash::Iterator it = d->signalHooks.find(key);
- QDBusConnectionPrivate::SignalHookHash::Iterator end = d->signalHooks.end();
- for ( ; it != end && it.key() == key; ++it) {
- const QDBusConnectionPrivate::SignalHook &entry = it.value();
- if (entry.service == hook.service &&
- entry.owner == hook.owner &&
- entry.path == hook.path &&
- entry.signature == hook.signature &&
- entry.obj == hook.obj &&
- entry.midx == hook.midx) {
- // no need to compare the parameters if it's the same slot
- d->disconnectSignal(it);
- return true; // it was there
- }
- }
-
- // the slot was not found
- return false;
+ return d->disconnectSignal(service, path, interface, name, argumentMatch, signature, receiver, slot);
}
/*!
diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h
index df51c27..2402719 100644
--- a/src/dbus/qdbusconnection_p.h
+++ b/src/dbus/qdbusconnection_p.h
@@ -175,8 +175,14 @@ public:
QDBusPendingCallPrivate *sendWithReplyAsync(const QDBusMessage &message, int timeout = -1);
int sendWithReplyAsync(const QDBusMessage &message, QObject *receiver,
const char *returnMethod, const char *errorMethod, int timeout = -1);
+ bool connectSignal(const QString &service, const QString &owner, const QString &path, const QString& interface,
+ const QString &name, const QStringList &argumentMatch, const QString &signature,
+ QObject *receiver, const char *slot);
void connectSignal(const QString &key, const SignalHook &hook);
SignalHookHash::Iterator disconnectSignal(SignalHookHash::Iterator &it);
+ bool disconnectSignal(const QString &service, const QString &path, const QString& interface,
+ const QString &name, const QStringList &argumentMatch, const QString &signature,
+ QObject *receiver, const char *slot);
void registerObject(const ObjectTreeNode *node);
void connectRelay(const QString &service, const QString &currentOwner,
const QString &path, const QString &interface,
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index 8fff8b3..89a7449 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -1942,6 +1942,42 @@ int QDBusConnectionPrivate::sendWithReplyAsync(const QDBusMessage &message, QObj
return 1;
}
+bool QDBusConnectionPrivate::connectSignal(const QString &service, const QString &owner,
+ const QString &path, const QString &interface, const QString &name,
+ const QStringList &argumentMatch, const QString &signature,
+ QObject *receiver, const char *slot)
+{
+ // check the slot
+ QDBusConnectionPrivate::SignalHook hook;
+ QString key;
+ QString name2 = name;
+ if (name2.isNull())
+ name2.detach();
+
+ hook.signature = signature;
+ if (!prepareHook(hook, key, service, owner, path, interface, name, argumentMatch, receiver, slot, 0, false))
+ return false; // don't connect
+
+ // avoid duplicating:
+ QDBusConnectionPrivate::SignalHookHash::ConstIterator it = signalHooks.find(key);
+ QDBusConnectionPrivate::SignalHookHash::ConstIterator end = signalHooks.constEnd();
+ for ( ; it != end && it.key() == key; ++it) {
+ const QDBusConnectionPrivate::SignalHook &entry = it.value();
+ if (entry.service == hook.service &&
+ entry.owner == hook.owner &&
+ entry.path == hook.path &&
+ entry.signature == hook.signature &&
+ entry.obj == hook.obj &&
+ entry.midx == hook.midx) {
+ // no need to compare the parameters if it's the same slot
+ return true; // already there
+ }
+ }
+
+ connectSignal(key, hook);
+ return true;
+}
+
void QDBusConnectionPrivate::connectSignal(const QString &key, const SignalHook &hook)
{
signalHooks.insertMulti(key, hook);
@@ -1973,6 +2009,43 @@ void QDBusConnectionPrivate::connectSignal(const QString &key, const SignalHook
}
}
+bool QDBusConnectionPrivate::disconnectSignal(const QString &service,
+ const QString &path, const QString &interface, const QString &name,
+ const QStringList &argumentMatch, const QString &signature,
+ QObject *receiver, const char *slot)
+{
+ // check the slot
+ QDBusConnectionPrivate::SignalHook hook;
+ QString key;
+ QString name2 = name;
+ if (name2.isNull())
+ name2.detach();
+
+ hook.signature = signature;
+ if (!prepareHook(hook, key, service, QString(), path, interface, name, argumentMatch, receiver, slot, 0, false))
+ return false; // don't disconnect
+
+ // avoid duplicating:
+ QDBusConnectionPrivate::SignalHookHash::Iterator it = signalHooks.find(key);
+ QDBusConnectionPrivate::SignalHookHash::Iterator end = signalHooks.end();
+ for ( ; it != end && it.key() == key; ++it) {
+ const QDBusConnectionPrivate::SignalHook &entry = it.value();
+ if (entry.service == hook.service &&
+ //entry.owner == hook.owner &&
+ entry.path == hook.path &&
+ entry.signature == hook.signature &&
+ entry.obj == hook.obj &&
+ entry.midx == hook.midx) {
+ // no need to compare the parameters if it's the same slot
+ disconnectSignal(it);
+ return true; // it was there
+ }
+ }
+
+ // the slot was not found
+ return false;
+}
+
QDBusConnectionPrivate::SignalHookHash::Iterator
QDBusConnectionPrivate::disconnectSignal(SignalHookHash::Iterator &it)
{