[Telepathy-commits] [telepathy-qt4/master] Ref/unref handles in ReferencedHandles (still not implemented in Connection because of willingness to sleep)
Olli Salli
olli.salli at collabora.co.uk
Wed Jan 21 04:42:13 PST 2009
---
TelepathyQt4/cli-connection.cpp | 10 +++++
TelepathyQt4/cli-connection.h | 4 ++
TelepathyQt4/cli-referenced-handles.cpp | 57 +++++++++++++++++++++++++++++-
3 files changed, 69 insertions(+), 2 deletions(-)
diff --git a/TelepathyQt4/cli-connection.cpp b/TelepathyQt4/cli-connection.cpp
index 6237184..00a0114 100644
--- a/TelepathyQt4/cli-connection.cpp
+++ b/TelepathyQt4/cli-connection.cpp
@@ -508,6 +508,16 @@ PendingOperation* Connection::requestDisconnect()
return new PendingVoidMethodCall(this, this->Disconnect());
}
+void Connection::refHandle(uint handle)
+{
+ // FIXME implement
+}
+
+void Connection::unrefHandle(uint handle)
+{
+ // FIXME implement
+}
+
struct PendingHandles::Private
{
Connection* connection;
diff --git a/TelepathyQt4/cli-connection.h b/TelepathyQt4/cli-connection.h
index 668f7b1..c2c2e37 100644
--- a/TelepathyQt4/cli-connection.h
+++ b/TelepathyQt4/cli-connection.h
@@ -503,6 +503,10 @@ private Q_SLOTS:
void gotSimpleStatuses(QDBusPendingCallWatcher* watcher);
private:
+ friend class ReferencedHandles;
+ void refHandle(uint handle);
+ void unrefHandle(uint handle);
+
struct Private;
friend struct Private;
Private *mPriv;
diff --git a/TelepathyQt4/cli-referenced-handles.cpp b/TelepathyQt4/cli-referenced-handles.cpp
index 004a1cd..30b820f 100644
--- a/TelepathyQt4/cli-referenced-handles.cpp
+++ b/TelepathyQt4/cli-referenced-handles.cpp
@@ -36,14 +36,59 @@ struct ReferencedHandles::Private : public QSharedData
QPointer<Connection> connection;
uint handleType;
UIntList handles;
+
+ Private()
+ {
+ debug() << "ReferencedHandles::Private(default)";
+
+ handleType = 0;
+ }
+
+ Private(const Private& a)
+ : connection(a.connection),
+ handleType(a.handleType),
+ handles(a.handles)
+ {
+ debug() << "ReferencedHandles::Private(copy)";
+
+ if (!handles.isEmpty()) {
+ if (!connection) {
+ warning() << "ReferencedHandles with" << handles.size() << "handles detached with connection destroyed so can't reference";
+ return;
+ }
+
+ for (const_iterator i = handles.begin();
+ i != handles.end();
+ ++i)
+ connection->refHandle(*i);
+ }
+ }
+
+ ~Private()
+ {
+ debug() << "~ReferencedHandles::Private()";
+
+ if (!handles.isEmpty()) {
+ if (!connection) {
+ warning() << "ReferencedHandles with last copy of" << handles.size() << "handles destroyed with connection destroyed so can't unreference";
+ return;
+ }
+
+ for (const_iterator i = handles.begin();
+ i != handles.end();
+ ++i)
+ connection->unrefHandle(*i);
+ }
+ }
+
+private:
+ void operator=(const Private&);
};
ReferencedHandles::ReferencedHandles()
: mPriv(new Private)
{
debug() << "ReferencedHandles(default)";
-
- mPriv->handleType = 0;
}
ReferencedHandles::ReferencedHandles(const ReferencedHandles& other)
@@ -189,9 +234,17 @@ ReferencedHandles::ReferencedHandles(Connection* connection, uint handleType, co
{
debug() << "ReferencedHandles(prime)";
+ Q_ASSERT(connection != NULL);
+ Q_ASSERT(handleType != 0);
+
mPriv->connection = connection;
mPriv->handleType = handleType;
mPriv->handles = handles;
+
+ for (const_iterator i = handles.begin();
+ i != handles.end();
+ ++i)
+ connection->refHandle(*i);
}
}
--
1.5.6.5
More information about the Telepathy-commits
mailing list