[Telepathy-commits] [telepathy-qt4/master] Implemented Account::getConnection.
Andre Moreira Magalhaes (andrunko)
andre.magalhaes at collabora.co.uk
Tue Jan 13 11:49:38 PST 2009
---
TelepathyQt4/Client/account.cpp | 25 +++++++++++++++++++++----
TelepathyQt4/Client/account.h | 4 ++--
2 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/TelepathyQt4/Client/account.cpp b/TelepathyQt4/Client/account.cpp
index c893684..046e623 100644
--- a/TelepathyQt4/Client/account.cpp
+++ b/TelepathyQt4/Client/account.cpp
@@ -30,6 +30,7 @@
#include "TelepathyQt4/debug-internal.h"
#include <TelepathyQt4/Client/AccountManager>
+#include <TelepathyQt4/Client/Connection>
#include <TelepathyQt4/Client/ConnectionManager>
#include <TelepathyQt4/Client/PendingVoidMethodCall>
#include <TelepathyQt4/Constants>
@@ -801,10 +802,26 @@ Telepathy::ConnectionStatusReason Account::connectionStatusReason() const
return mPriv->connectionStatusReason;
}
-// PendingConnection *Account::getConnection(Connection::Features features = 0) const
-// {
-// return 0;
-// }
+/**
+ * Get the Connection object for this account.
+ *
+ * Note that the Connection object won't be cached by account, and
+ * should be done by the application itself.
+ *
+ * Remember to call Connection::becomeReady on the new connection, to
+ * make sure it is ready before using it.
+ *
+ * \return Connection object, or 0 if an error occurred.
+ */
+Connection *Account::getConnection() const
+{
+ if (mPriv->connectionObjectPath.isEmpty()) {
+ return 0;
+ }
+ QString objectPath = mPriv->connectionObjectPath;
+ QString serviceName = objectPath.replace('/', '.');
+ return new Connection(dbusConnection(), serviceName, objectPath);
+}
/**
* Set the presence status that this account should have if it is brought
diff --git a/TelepathyQt4/Client/account.h b/TelepathyQt4/Client/account.h
index 328154f..e5f6b37 100644
--- a/TelepathyQt4/Client/account.h
+++ b/TelepathyQt4/Client/account.h
@@ -45,6 +45,7 @@ namespace Client
{
class AccountManager;
+class Connection;
class PendingConnection;
class PendingOperation;
class ProtocolInfo;
@@ -112,8 +113,7 @@ public:
Telepathy::ConnectionStatus connectionStatus() const;
Telepathy::ConnectionStatusReason connectionStatusReason() const;
- // not finished until the Connection is ready
- // PendingConnection *getConnection(Connection::Features features = 0) const;
+ Connection *getConnection() const;
Telepathy::SimplePresence automaticPresence() const;
PendingOperation *setAutomaticPresence(
--
1.5.6.5
More information about the Telepathy-commits
mailing list