[Telepathy-commits] [telepathy-qt4/master] Initial integration between AccountManager and Account.
Andre Moreira Magalhaes (andrunko)
andre.magalhaes at collabora.co.uk
Fri Jan 9 08:44:14 PST 2009
---
TelepathyQt4/Client/account-manager.cpp | 82 ++++++++++++++++++++-----------
TelepathyQt4/Client/account-manager.h | 11 +++--
2 files changed, 60 insertions(+), 33 deletions(-)
diff --git a/TelepathyQt4/Client/account-manager.cpp b/TelepathyQt4/Client/account-manager.cpp
index 305eb23..0bf9b9b 100644
--- a/TelepathyQt4/Client/account-manager.cpp
+++ b/TelepathyQt4/Client/account-manager.cpp
@@ -29,6 +29,7 @@
#include "TelepathyQt4/debug-internal.h"
+#include <TelepathyQt4/Client/Account>
#include <TelepathyQt4/Client/PendingSuccess>
#include <TelepathyQt4/Constants>
@@ -317,64 +318,87 @@ Telepathy::ObjectPathList AccountManager::allAccountPaths() const
return result;
}
-#if 0
/**
- * Return a list of pending operations for all valid accounts from which
- * Accounts can be retrieved if it succeeds.
+ * Return a list of Account objects for all valid accounts.
*
- * Note that the account objects won't be cached by account manager, and
+ * Note that the Account objects won't be cached by account manager, and
* should be done by the application itself.
*
- * \return A list of PendingAccount which each one will emit
- * PendingAccount::finished when it has finished or failed creating the
- * account object.
+ * \return A list of Account objects
+ * \sa invalidAccounts(), allAccounts(), accountsForPaths()
*/
-PendingAccounts *AccountManager::validAccounts() const
+QList<Account *> AccountManager::validAccounts()
{
- return 0;
+ return accountsForPaths(validAccountPaths());
}
/**
- * Return a list of pending operations for all invalid accounts from which
- * Accounts can be retrieved if it succeeds.
+ * Return a list of Account objects for all invalid accounts.
*
- * Note that the account objects won't be cached by account manager, and
+ * Note that the Account objects won't be cached by account manager, and
* should be done by the application itself.
*
- * \return A list of PendingAccount which each one will emit
- * PendingAccount::finished when it has finished or failed creating the
- * account object.
+ * \return A list of Account objects
+ * \sa validAccounts(), allAccounts(), accountsForPaths()
*/
-PendingAccounts *AccountManager::invalidAccounts() const
+QList<Account *> AccountManager::invalidAccounts()
{
- return 0;
+ return accountsForPaths(invalidAccountPaths());
}
/**
- * Return a list of pending operations for all accounts from which
- * Accounts can be retrieved if it succeeds.
+ * Return a list of Account objects for all accounts.
*
- * Note that the account objects won't be cached by account manager, and
+ * Note that the Account objects won't be cached by account manager, and
* should be done by the application itself.
*
- * \return A list of PendingAccount which each one will emit
- * PendingAccount::finished when it has finished or failed creating the
- * account object.
+ * \return A list of Account objects
+ * \sa validAccounts(), invalidAccounts(), accountsForPaths()
*/
-PendingAccounts *AccountManager::allAccounts() const
+QList<Account *> AccountManager::allAccounts()
{
- return 0;
+ return accountsForPaths(allAccountPaths());
}
-PendingAccount *AccountManager::accountForPath(const QString &path) const
+/**
+ * Return an Account object for the given \a path.
+ *
+ * Note that the Account object won't be cached by account manager, and
+ * should be done by the application itself.
+ *
+ * \param path A QDBusObjectPath to create account for.
+ * \return A list of Account objects
+ * \sa validAccounts(), invalidAccounts(), accountsForPaths()
+ */
+Account *AccountManager::accountForPath(const QDBusObjectPath &path)
{
- return 0;
+ return new Account(this, path, this);
+}
+
+/**
+ * Return a list of Account objects for the given \a paths.
+ *
+ * Note that the Account objects won't be cached by account manager, and
+ * should be done by the application itself.
+ *
+ * \param paths List of QDBusObjectPath to create accounts for.
+ * \return A list of Account objects
+ * \sa validAccounts(), invalidAccounts(), allAccounts()
+ */
+QList<Account *> AccountManager::accountsForPaths(const QList<QDBusObjectPath> &paths)
+{
+ QList<Account *> result;
+ Q_FOREACH (const QDBusObjectPath &path, paths) {
+ result << accountForPath(path);
+ }
+ return result;
}
+#if 0
/**
- * Create an account with the given parameters.
+ * Create an Account with the given parameters.
*
- * Return a pending operation representing the account which will succeed
+ * Return a pending operation representing the Account object which will succeed
* when the account has been created or fail if an error occurred.
*
* \param connectionManager Name of the connection manager to create the account for.
diff --git a/TelepathyQt4/Client/account-manager.h b/TelepathyQt4/Client/account-manager.h
index c0e7392..637e1f9 100644
--- a/TelepathyQt4/Client/account-manager.h
+++ b/TelepathyQt4/Client/account-manager.h
@@ -32,6 +32,7 @@
#include <TelepathyQt4/Client/DBusProxy>
#include <TelepathyQt4/Client/OptionalInterfaceFactory>
+#include <QDBusObjectPath>
#include <QString>
#include <QVariantMap>
@@ -40,6 +41,7 @@ namespace Telepathy
namespace Client
{
+class Account;
class PendingAccount;
class PendingAccounts;
class PendingOperation;
@@ -72,11 +74,12 @@ public:
Telepathy::ObjectPathList invalidAccountPaths() const;
Telepathy::ObjectPathList allAccountPaths() const;
- PendingAccounts *validAccounts() const;
- PendingAccounts *invalidAccounts() const;
- PendingAccounts *allAccounts() const;
+ QList<Account *> validAccounts();
+ QList<Account *> invalidAccounts();
+ QList<Account *> allAccounts();
- PendingAccount *accountForPath(const QString &path) const;
+ Account *accountForPath(const QDBusObjectPath &path);
+ QList<Account *> accountsForPaths(const QList<QDBusObjectPath> &paths);
PendingAccount *createAccount(const QString &connectionManager,
const QString &protocol, const QString &displayName,
--
1.5.6.5
More information about the Telepathy-commits
mailing list