From kde-commits Tue Feb 17 20:28:25 2009 From: Siraj Razick Date: Tue, 17 Feb 2009 20:28:25 +0000 To: kde-commits Subject: playground/base/plasma/dataengines/presence Message-Id: <1234902505.327390.11766.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=123490252024881 SVN commit 927540 by siraj: 1.) Clean up code style , 2.) fix the engine so that it builds agaist the new TelepathyQt4 accountmanager API changes M +15 -43 presence.cpp --- trunk/playground/base/plasma/dataengines/presence/presence.cpp #927539:927540 @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -38,10 +39,9 @@ void createAccountDataSource(const QString &path) { - // \todo: FIXME - kDebug() << "createAccountDataSource called"; - kDebug() << path; - Telepathy::Client::Account *account = accountFromPath(path); + kDebug() << "createAccountDataSource called"; + kDebug() << path; + QSharedPointer account = accountFromPath(path); QString source; source = account->uniqueIdentifier(); @@ -50,44 +50,21 @@ QVariant vsp; vsp.setValue(sp); parent->setData(source, "current_presence", vsp); - - // \todo: remove -/* - QString source; - source.setNum(handle); - QVariantMap accountData = m_accountManager->queryAccount(handle); - QMap::const_iterator end( accountData.constEnd() ); - for(QMap::const_iterator itr(accountData.constBegin()); itr != end; ++itr) - { - if(itr.key() == Decibel::name_current_presence) - { - QtTapioca::PresenceState ps = qdbus_cast(itr.value().value()); - QVariant psv; - psv.setValue(ps); - setData(source, "current_presence", psv); - continue; - } - else if(itr.key() == Decibel::name_presence_parameters) - { - setData(source, "status_message", itr.value().toMap().value("status_message").toString()); - } - } -*/ } void removeAccountDataSource(const QString &path) { - kDebug() << "removeAccountDataSource called"; - kDebug() << path; + kDebug() << "removeAccountDataSource called"; + kDebug() << path; - Telepathy::Client::Account *account = accountFromPath(path); - QString identifier = account->uniqueIdentifier(); - parent->removeSource(identifier); + QSharedPointer account = accountFromPath(path); + QString identifier = account->uniqueIdentifier(); + parent->removeSource(identifier); } - Telepathy::Client::Account *accountFromPath(const QString &path) + QSharedPointer accountFromPath(const QString &path) { - return m_accountManager->accountForPath(path); + return m_accountManager->accountForPath(path); } }; @@ -134,9 +111,12 @@ * check that we are connected to the session * bus OK. */ + d->m_accountManager = 0; + if (!QDBusConnection::sessionBus().isConnected()) { kDebug() << "PresenceEngine::init(): cannot connect to session bus."; + return; } /* @@ -208,15 +188,7 @@ * get a list of all the accounts that * are all ready there */ - QList accounts = d->m_accountManager->allAccounts(); - kDebug() << "accounts: " << accounts.size(); - - /* - * create a datasource for each - * of the accounts we got in the list. - */ - foreach(const QString &path, pathList) - { + foreach (const QString &path, d->m_accountManager->allAccountPaths()) { d->createAccountDataSource(path); } }