SVN commit 910104 by mikulski: waiting when account manager is ready M +41 -15 presence.cpp M +2 -0 presence.h --- trunk/playground/base/plasma/dataengines/presence/presence.cpp #910103:910104 @@ -120,6 +120,7 @@ { // Register custom types: Telepathy::registerTypes(); + setIcon(QString()); } /** @@ -127,7 +128,8 @@ */ PresenceEngine::~PresenceEngine() { - delete d->m_accountManager; + // \todo: FIXME. Why there is a problem? +// delete d->m_accountManager; delete d; } @@ -155,13 +157,15 @@ new Telepathy::Client::AccountManager(QDBusConnection::sessionBus()); /* - * get a list of all the accounts that - * are all ready there + * connect signal from the account manager + * to waiting when it's ready */ - QList accounts = d->m_accountManager->allAccounts(); - kDebug() << "accounts: " << accounts.size(); + connect(d->m_accountManager->becomeReady(), + SIGNAL(finished(Telepathy::Client::PendingOperation*)), + this, + SLOT(onAccountReady(Telepathy::Client::PendingOperation*)) + ); - Telepathy::ObjectPathList objectPathList = d->m_accountManager->allAccountPaths(); /* * connect signals from the account manager * to slots within this data engine. @@ -177,15 +181,6 @@ this, SLOT(accountValidityChanged(const QDBusObjectPath &, bool))); connect(d->m_accountManager, SIGNAL(accountRemoved(const QDBusObjectPath &)), this, SLOT(accountRemoved(const QDBusObjectPath &))); - - /* - * create a datasource for each - * of the accounts we got in the list. - */ - foreach(const QDBusObjectPath &path, objectPathList) - { - d->createAccountDataSource(path); - } } /** @@ -205,6 +200,37 @@ return false; } +void PresenceEngine::onAccountReady(Telepathy::Client::PendingOperation *operation) +{ + kDebug() << "onAccountReady() called"; + if(operation->isError()) + { + kDebug() << operation->errorName() << ": " << operation->errorMessage(); + return; + } + + Telepathy::ObjectPathList pathList = d->m_accountManager->allAccountPaths(); + kDebug() << "All Account Paths: " << pathList.size(); + + /* + * get a list of all the accounts that + * are all ready there + */ + QList accounts = d->m_accountManager->allAccounts(); + kDebug() << "accounts: " << accounts.size(); + + Telepathy::ObjectPathList objectPathList = d->m_accountManager->allAccountPaths(); + + /* + * create a datasource for each + * of the accounts we got in the list. + */ + foreach(const QDBusObjectPath &path, objectPathList) + { + d->createAccountDataSource(path); + } +} + /** * Slot for new account. * --- trunk/playground/base/plasma/dataengines/presence/presence.h #910103:910104 @@ -20,6 +20,7 @@ #define PLASMA_DATAENGINE_PRESENCE_H #include +#include class QDBusObjectPath; @@ -36,6 +37,7 @@ bool sourceRequestEvent(const QString & name); private Q_SLOTS: + void onAccountReady(Telepathy::Client::PendingOperation *operation); void accountCreated(const QDBusObjectPath &path); void accountRemoved(const QDBusObjectPath &path); void accountValidityChanged(const QDBusObjectPath &path, bool valid);