[Telepathy-commits] [telepathy-qt4/master] Account: Return a QSharedPointer<Connection> on ::connection.
Andre Moreira Magalhaes (andrunko)
andre.magalhaes at collabora.co.uk
Wed Feb 4 09:54:33 PST 2009
---
TelepathyQt4/Client/account.cpp | 12 +++++++++---
TelepathyQt4/Client/account.h | 3 ++-
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/TelepathyQt4/Client/account.cpp b/TelepathyQt4/Client/account.cpp
index e5563b2..ef3097b 100644
--- a/TelepathyQt4/Client/account.cpp
+++ b/TelepathyQt4/Client/account.cpp
@@ -87,6 +87,7 @@ struct Account::Private
Telepathy::SimplePresence automaticPresence;
Telepathy::SimplePresence currentPresence;
Telepathy::SimplePresence requestedPresence;
+ QSharedPointer<Connection> connection;
};
Account::Private::Private(Account *parent)
@@ -458,14 +459,18 @@ Telepathy::ConnectionStatusReason Account::connectionStatusReason() const
*
* \return Connection object, or 0 if an error occurred.
*/
-Connection *Account::connection() const
+QSharedPointer<Connection> Account::connection() const
{
if (mPriv->connectionObjectPath.isEmpty()) {
- return 0;
+ return QSharedPointer<Connection>();
}
QString objectPath = mPriv->connectionObjectPath;
QString serviceName = objectPath.mid(1).replace('/', '.');
- return new Connection(dbusConnection(), serviceName, objectPath);
+ if (!mPriv->connection) {
+ mPriv->connection = QSharedPointer<Connection>(
+ new Connection(dbusConnection(), serviceName, objectPath));
+ }
+ return mPriv->connection;
}
/**
@@ -856,6 +861,7 @@ void Account::updateProperties(const QVariantMap &props)
if (path == QLatin1String("/")) {
path = QString();
}
+ mPriv->connection.clear();
mPriv->connectionObjectPath = path;
}
diff --git a/TelepathyQt4/Client/account.h b/TelepathyQt4/Client/account.h
index 2dfbb57..472ffd1 100644
--- a/TelepathyQt4/Client/account.h
+++ b/TelepathyQt4/Client/account.h
@@ -33,6 +33,7 @@
#include <TelepathyQt4/Client/OptionalInterfaceFactory>
#include <TelepathyQt4/Constants>
+#include <QSharedPointer>
#include <QString>
#include <QStringList>
#include <QVariantMap>
@@ -105,7 +106,7 @@ public:
Telepathy::ConnectionStatus connectionStatus() const;
Telepathy::ConnectionStatusReason connectionStatusReason() const;
- Connection *connection() const;
+ QSharedPointer<Connection> connection() const;
Telepathy::SimplePresence automaticPresence() const;
PendingOperation *setAutomaticPresence(
--
1.5.6.5
More information about the telepathy-commits
mailing list