[Telepathy-commits] [telepathy-qt4/master] Changed Account classes to use QString instead of QDBusObjectPath.
Andre Moreira Magalhaes (andrunko)
andre.magalhaes at collabora.co.uk
Tue Jan 13 11:49:53 PST 2009
Changed Account classes to use QString instead of QDBusObjectPath.
All other classes were already doing it, so change.
---
TelepathyQt4/Client/account-manager-internal.h | 12 ++--
TelepathyQt4/Client/account-manager.cpp | 92 ++++++++++++++----------
TelepathyQt4/Client/account-manager.h | 17 ++---
TelepathyQt4/Client/account.cpp | 4 +-
TelepathyQt4/Client/account.h | 3 +-
TelepathyQt4/Client/pending-account.cpp | 3 +-
tests/dbus/account-basics.cpp | 22 ++----
7 files changed, 79 insertions(+), 74 deletions(-)
diff --git a/TelepathyQt4/Client/account-manager-internal.h b/TelepathyQt4/Client/account-manager-internal.h
index 82457b0..8752fc9 100644
--- a/TelepathyQt4/Client/account-manager-internal.h
+++ b/TelepathyQt4/Client/account-manager-internal.h
@@ -45,7 +45,7 @@ public:
~Private();
void callGetAll();
- void setAccountPaths(QSet<QDBusObjectPath> &set, const QVariant &variant);
+ void setAccountPaths(QSet<QString> &set, const QVariant &variant);
class PendingReady;
@@ -55,13 +55,13 @@ public:
QQueue<void (Private::*)()> introspectQueue;
QStringList interfaces;
AccountManager::Features features;
- QSet<QDBusObjectPath> validAccountPaths;
- QSet<QDBusObjectPath> invalidAccountPaths;
+ QSet<QString> validAccountPaths;
+ QSet<QString> invalidAccountPaths;
Q_SIGNALS:
- void accountCreated(const QDBusObjectPath &path);
- void accountRemoved(const QDBusObjectPath &path);
- void accountValidityChanged(const QDBusObjectPath &path, bool valid);
+ void accountCreated(const QString &path);
+ void accountRemoved(const QString &path);
+ void accountValidityChanged(const QString &path, bool valid);
private Q_SLOTS:
void onGetAllAccountManagerReturn(QDBusPendingCallWatcher *);
diff --git a/TelepathyQt4/Client/account-manager.cpp b/TelepathyQt4/Client/account-manager.cpp
index a2f8238..c109353 100644
--- a/TelepathyQt4/Client/account-manager.cpp
+++ b/TelepathyQt4/Client/account-manager.cpp
@@ -105,7 +105,7 @@ void AccountManager::Private::callGetAll()
SLOT(onGetAllAccountManagerReturn(QDBusPendingCallWatcher *)));
}
-void AccountManager::Private::setAccountPaths(QSet<QDBusObjectPath> &set,
+void AccountManager::Private::setAccountPaths(QSet<QString> &set,
const QVariant &variant)
{
Telepathy::ObjectPathList paths = qdbus_cast<Telepathy::ObjectPathList>(variant);
@@ -120,13 +120,14 @@ void AccountManager::Private::setAccountPaths(QSet<QDBusObjectPath> &set,
warning() << "AccountManager returned wrong type "
"(expected 'ao', got 'as'); working around it";
Q_FOREACH (QString path, wronglyTypedPaths) {
- paths << QDBusObjectPath(path);
+ set << path;
}
}
}
-
- Q_FOREACH (const QDBusObjectPath &path, paths) {
- set << path;
+ else {
+ Q_FOREACH (const QDBusObjectPath &path, paths) {
+ set << path.path();
+ }
}
}
@@ -164,22 +165,24 @@ void AccountManager::Private::onGetAllAccountManagerReturn(
watcher->deleteLater();
}
-void AccountManager::Private::onAccountValidityChanged(const QDBusObjectPath &path,
+void AccountManager::Private::onAccountValidityChanged(const QDBusObjectPath &objectPath,
bool nowValid)
{
+ QString path = objectPath.path();
bool newAccount = false;
- if (!validAccountPaths.contains(path) && !invalidAccountPaths.contains(path)) {
+ if (!validAccountPaths.contains(path) &&
+ !invalidAccountPaths.contains(path)) {
newAccount = true;
}
if (nowValid) {
- debug() << "Account created or became valid:" << path.path();
+ debug() << "Account created or became valid:" << path;
invalidAccountPaths.remove(path);
validAccountPaths.insert(path);
}
else {
- debug() << "Account became invalid:" << path.path();
+ debug() << "Account became invalid:" << path;
validAccountPaths.remove(path);
invalidAccountPaths.insert(path);
}
@@ -197,9 +200,11 @@ void AccountManager::Private::onAccountValidityChanged(const QDBusObjectPath &pa
}
}
-void AccountManager::Private::onAccountRemoved(const QDBusObjectPath &path)
+void AccountManager::Private::onAccountRemoved(const QDBusObjectPath &objectPath)
{
- debug() << "Account removed:" << path.path();
+ QString path = objectPath.path();
+
+ debug() << "Account removed:" << path;
validAccountPaths.remove(path);
invalidAccountPaths.remove(path);
@@ -285,37 +290,33 @@ QStringList AccountManager::interfaces() const
*/
/**
- * Return a list of QDBusObjectPath for all valid accounts.
+ * Return a list of object paths for all valid accounts.
*
- * \return A list of QDBusObjectPath.
+ * \return A list of object paths.
*/
-Telepathy::ObjectPathList AccountManager::validAccountPaths() const
+QStringList AccountManager::validAccountPaths() const
{
- Telepathy::ObjectPathList result;
- result.append(mPriv->validAccountPaths.values());
- return result;
+ return mPriv->validAccountPaths.values();
}
/**
- * Return a list of QDBusObjectPath for all invalid accounts.
+ * Return a list of object paths for all invalid accounts.
*
- * \return A list of QDBusObjectPath.
+ * \return A list of object paths.
*/
-Telepathy::ObjectPathList AccountManager::invalidAccountPaths() const
+QStringList AccountManager::invalidAccountPaths() const
{
- Telepathy::ObjectPathList result;
- result.append(mPriv->invalidAccountPaths.values());
- return result;
+ return mPriv->invalidAccountPaths.values();
}
/**
- * Return a list of QDBusObjectPath for all accounts.
+ * Return a list of object paths for all accounts.
*
- * \return A list of QDBusObjectPath.
+ * \return A list of object paths.
*/
-Telepathy::ObjectPathList AccountManager::allAccountPaths() const
+QStringList AccountManager::allAccountPaths() const
{
- ObjectPathList result;
+ QStringList result;
result.append(mPriv->validAccountPaths.values());
result.append(mPriv->invalidAccountPaths.values());
return result;
@@ -327,6 +328,9 @@ Telepathy::ObjectPathList AccountManager::allAccountPaths() const
* Note that the Account objects won't be cached by account manager, and
* should be done by the application itself.
*
+ * Remember to call Account::becomeReady on the new accounts, to
+ * make sure they are ready before using it.
+ *
* \return A list of Account objects
* \sa invalidAccounts(), allAccounts(), accountsForPaths()
*/
@@ -341,6 +345,9 @@ QList<Account *> AccountManager::validAccounts()
* Note that the Account objects won't be cached by account manager, and
* should be done by the application itself.
*
+ * Remember to call Account::becomeReady on the new accounts, to
+ * make sure they are ready before using it.
+ *
* \return A list of Account objects
* \sa validAccounts(), allAccounts(), accountsForPaths()
*/
@@ -355,6 +362,9 @@ QList<Account *> AccountManager::invalidAccounts()
* Note that the Account objects won't be cached by account manager, and
* should be done by the application itself.
*
+ * Remember to call Account::becomeReady on the new accounts, to
+ * make sure they are ready before using it.
+ *
* \return A list of Account objects
* \sa validAccounts(), invalidAccounts(), accountsForPaths()
*/
@@ -369,11 +379,14 @@ QList<Account *> AccountManager::allAccounts()
* 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.
+ * Remember to call Account::becomeReady on the new account, to
+ * make sure it is ready before using it.
+ *
+ * \param path The object path to create account for.
* \return A list of Account objects
* \sa validAccounts(), invalidAccounts(), accountsForPaths()
*/
-Account *AccountManager::accountForPath(const QDBusObjectPath &path)
+Account *AccountManager::accountForPath(const QString &path)
{
// TODO should we use AM as parent of account,
// or receive parent as a param?
@@ -386,14 +399,17 @@ Account *AccountManager::accountForPath(const QDBusObjectPath &path)
* 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.
+ * Remember to call Account::becomeReady on the new accounts, to
+ * make sure they are ready before using it.
+ *
+ * \param paths List of object paths to create accounts for.
* \return A list of Account objects
* \sa validAccounts(), invalidAccounts(), allAccounts()
*/
-QList<Account *> AccountManager::accountsForPaths(const QList<QDBusObjectPath> &paths)
+QList<Account *> AccountManager::accountsForPaths(const QStringList &paths)
{
QList<Account *> result;
- Q_FOREACH (const QDBusObjectPath &path, paths) {
+ Q_FOREACH (const QString &path, paths) {
result << accountForPath(path);
}
return result;
@@ -479,14 +495,14 @@ AccountManagerInterface *AccountManager::baseInterface() const
void AccountManager::init()
{
connect(mPriv,
- SIGNAL(accountCreated(const QDBusObjectPath &)),
- SIGNAL(accountCreated(const QDBusObjectPath &)));
+ SIGNAL(accountCreated(const QString &)),
+ SIGNAL(accountCreated(const QString &)));
connect(mPriv,
- SIGNAL(accountRemoved(const QDBusObjectPath &)),
- SIGNAL(accountRemoved(const QDBusObjectPath &)));
+ SIGNAL(accountRemoved(const QString &)),
+ SIGNAL(accountRemoved(const QString &)));
connect(mPriv,
- SIGNAL(accountValidityChanged(const QDBusObjectPath &, bool)),
- SIGNAL(accountValidityChanged(const QDBusObjectPath &, bool)));
+ SIGNAL(accountValidityChanged(const QString &, bool)),
+ SIGNAL(accountValidityChanged(const QString &, bool)));
}
} // Telepathy::Client
diff --git a/TelepathyQt4/Client/account-manager.h b/TelepathyQt4/Client/account-manager.h
index 2a7c014..fae2df9 100644
--- a/TelepathyQt4/Client/account-manager.h
+++ b/TelepathyQt4/Client/account-manager.h
@@ -32,7 +32,6 @@
#include <TelepathyQt4/Client/DBusProxy>
#include <TelepathyQt4/Client/OptionalInterfaceFactory>
-#include <QDBusObjectPath>
#include <QString>
#include <QVariantMap>
@@ -70,16 +69,16 @@ public:
*baseInterface());
}
- Telepathy::ObjectPathList validAccountPaths() const;
- Telepathy::ObjectPathList invalidAccountPaths() const;
- Telepathy::ObjectPathList allAccountPaths() const;
+ QStringList validAccountPaths() const;
+ QStringList invalidAccountPaths() const;
+ QStringList allAccountPaths() const;
QList<Account *> validAccounts();
QList<Account *> invalidAccounts();
QList<Account *> allAccounts();
- Account *accountForPath(const QDBusObjectPath &path);
- QList<Account *> accountsForPaths(const QList<QDBusObjectPath> &paths);
+ Account *accountForPath(const QString &path);
+ QList<Account *> accountsForPaths(const QStringList &paths);
PendingAccount *createAccount(const QString &connectionManager,
const QString &protocol, const QString &displayName,
@@ -92,9 +91,9 @@ public:
PendingOperation *becomeReady(Features features = 0);
Q_SIGNALS:
- void accountCreated(const QDBusObjectPath &path);
- void accountRemoved(const QDBusObjectPath &path);
- void accountValidityChanged(const QDBusObjectPath &path, bool valid);
+ void accountCreated(const QString &path);
+ void accountRemoved(const QString &path);
+ void accountValidityChanged(const QString &path, bool valid);
protected:
AccountManagerInterface *baseInterface() const;
diff --git a/TelepathyQt4/Client/account.cpp b/TelepathyQt4/Client/account.cpp
index 046e623..494ba39 100644
--- a/TelepathyQt4/Client/account.cpp
+++ b/TelepathyQt4/Client/account.cpp
@@ -485,10 +485,10 @@ PendingOperation *Account::Private::becomeReady(Account::Features requestedFeatu
* \param objectPath Account object path.
* \param parent Object parent.
*/
-Account::Account(AccountManager *am, const QDBusObjectPath &objectPath,
+Account::Account(AccountManager *am, const QString &objectPath,
QObject *parent)
: StatelessDBusProxy(am->dbusConnection(),
- am->busName(), objectPath.path(), parent),
+ am->busName(), objectPath, parent),
mPriv(new Private(this))
{
connect(mPriv,
diff --git a/TelepathyQt4/Client/account.h b/TelepathyQt4/Client/account.h
index e5f6b37..8827ad3 100644
--- a/TelepathyQt4/Client/account.h
+++ b/TelepathyQt4/Client/account.h
@@ -34,7 +34,6 @@
#include <TelepathyQt4/Constants>
#include <TelepathyQt4/Types>
-#include <QDBusObjectPath>
#include <QString>
#include <QStringList>
#include <QVariantMap>
@@ -72,7 +71,7 @@ public:
BypassInterfaceCheck
};
- Account(AccountManager *am, const QDBusObjectPath &objectPath,
+ Account(AccountManager *am, const QString &objectPath,
QObject *parent = 0);
virtual ~Account();
diff --git a/TelepathyQt4/Client/pending-account.cpp b/TelepathyQt4/Client/pending-account.cpp
index 6bcfeff..4608866 100644
--- a/TelepathyQt4/Client/pending-account.cpp
+++ b/TelepathyQt4/Client/pending-account.cpp
@@ -135,7 +135,8 @@ void PendingAccount::onCallFinished(QDBusPendingCallWatcher *watcher)
debug() << "Got reply to AccountManager.CreateAccount";
QDBusObjectPath objectPath = reply.value();
debug() << "Creating account for objectPath: " << objectPath.path();
- mPriv->account = new Account(mPriv->manager, objectPath, mPriv->manager);
+ mPriv->account = new Account(mPriv->manager,
+ objectPath.path(), mPriv->manager);
setFinished();
} else {
debug().nospace() <<
diff --git a/tests/dbus/account-basics.cpp b/tests/dbus/account-basics.cpp
index 2063e91..22880a5 100644
--- a/tests/dbus/account-basics.cpp
+++ b/tests/dbus/account-basics.cpp
@@ -1,6 +1,5 @@
#include <QtCore/QEventLoop>
#include <QtTest/QtTest>
-#include <QtDBus/QDBusObjectPath>
#include <TelepathyQt4/Debug>
#include <TelepathyQt4/Types>
@@ -13,15 +12,6 @@
using namespace Telepathy;
using namespace Telepathy::Client;
-static QStringList objectPathListToStringList(const ObjectPathList &paths)
-{
- QStringList result;
- Q_FOREACH (const QDBusObjectPath &path, paths) {
- result << path.path();
- }
- return result;
-}
-
class TestAccountBasics : public QObject
{
Q_OBJECT
@@ -136,17 +126,17 @@ void TestAccountBasics::testBasics()
QCOMPARE(mAM->interfaces(), QStringList());
- QCOMPARE(objectPathListToStringList(mAM->validAccountPaths()),
+ QCOMPARE(mAM->validAccountPaths(),
QStringList() <<
"/org/freedesktop/Telepathy/Account/foo/bar/Account0");
- QCOMPARE(objectPathListToStringList(mAM->invalidAccountPaths()),
+ QCOMPARE(mAM->invalidAccountPaths(),
QStringList());
- QCOMPARE(objectPathListToStringList(mAM->allAccountPaths()),
+ QCOMPARE(mAM->allAccountPaths(),
QStringList() <<
"/org/freedesktop/Telepathy/Account/foo/bar/Account0");
Account *acc = mAM->accountForPath(
- QDBusObjectPath("/org/freedesktop/Telepathy/Account/foo/bar/Account0"));
+ "/org/freedesktop/Telepathy/Account/foo/bar/Account0");
connect(acc->becomeReady(),
SIGNAL(finished(Telepathy::Client::PendingOperation *)),
this,
@@ -192,7 +182,7 @@ void TestAccountBasics::testBasics()
QCOMPARE(mLoop->exec(), 0);
acc = mAM->accountForPath(
- QDBusObjectPath("/org/freedesktop/Telepathy/Account/spurious/normal/Account0"));
+ "/org/freedesktop/Telepathy/Account/spurious/normal/Account0");
connect(acc->becomeReady(),
SIGNAL(finished(Telepathy::Client::PendingOperation *)),
this,
@@ -200,7 +190,7 @@ void TestAccountBasics::testBasics()
QCOMPARE(mLoop->exec(), 0);
acc = mAM->accountForPath(
- QDBusObjectPath("/org/freedesktop/Telepathy/Account/spurious/normal/Account0"));
+ "/org/freedesktop/Telepathy/Account/spurious/normal/Account0");
connect(acc->becomeReady(Account::FeatureProtocolInfo),
SIGNAL(finished(Telepathy::Client::PendingOperation *)),
this,
--
1.5.6.5
More information about the Telepathy-commits
mailing list