[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/base/plasma/dataengines/presence
From:       Dariusz Mikulski <dariusz.mikulski () gmail ! com>
Date:       2009-01-09 22:37:41
Message-ID: 1231540661.839936.6108.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 908571 by mikulski:

set of simplepresence account data to data source, change account to qdbusobjectpath \
(depends new implementation telepathy-qt4)

 M  +35 -12    presence.cpp  


--- trunk/playground/base/plasma/dataengines/presence/presence.cpp #908570:908571
@@ -36,10 +36,24 @@
 	
 	Telepathy::Client::AccountManager * m_accountManager;
 	
-	void createAccountDataSource(Telepathy::Client::Account *account)
+	void createAccountDataSource(const QDBusObjectPath &path)
 	{
+		// \todo: FIXME
 		kDebug() << "createAccountDataSource called";
-		// \brief: todo
+		kDebug() << path.path();
+	    Telepathy::Client::Account *account = accountFromObjectPath(path);
+
+	    QString source;
+	    // \todo: FIXME
+	    // source = account.uniqueIdentifier();
+	    Telepathy::SimplePresence sp = account->currentPresence();
+	    QVariant vsp;
+	    vsp.setValue(sp);
+	    parent->setData(source, "current_presence", vsp);
+	    
+		// emit parent->sourceAdded(account->uniqueIdentifier());
+
+		// \todo: remove
 /*
 			QString source;
 		    source.setNum(handle);
@@ -65,16 +79,25 @@
 */
 	}
 	
-	void removeAccountDataSource(Telepathy::Client::Account *account)
+	void removeAccountDataSource(const QDBusObjectPath &path)
 	{
 		kDebug() << "removeAccountDataSource called";
-		// \brief: todo
+		kDebug() << path.path();
+		
+		Telepathy::Client::Account *account = accountFromObjectPath(path);
+		
+		// \todo: FIXME
 /*
 		QString identifier = account->uniqueIdentifier();
 		parent->removeSource(identifier);
 		emit parent->sourceRemoved(identifier);
 */
 	}
+	
+	Telepathy::Client::Account *accountFromObjectPath(const QDBusObjectPath &path)
+	{
+		return m_accountManager->accountForPath(path);
+	}
 };
 
 PresenceEngine::PresenceEngine(QObject * parent, const QVariantList & args)
@@ -118,6 +141,8 @@
      */
     QList<Telepathy::Client::Account *> accounts = \
d->m_accountManager->allAccounts();  kDebug() << "accounts: " << accounts.size();
+    
+    Telepathy::ObjectPathList objectPathList = \
d->m_accountManager->allAccountPaths();  /*
      * connect signals from the account manager
      * to slots within this data engine.
@@ -138,9 +163,9 @@
      * create a datasource for each
      * of the accounts we got in the list.
      */
-    foreach(Telepathy::Client::Account *account, accounts)
+    foreach(const QDBusObjectPath &path, objectPathList)
     {
-        d->createAccountDataSource(account);
+        d->createAccountDataSource(path);
     }
 }
 
@@ -164,20 +189,19 @@
     // Load the data for the new account. To avoid duplicating code, we treat
     // this just as if an account was updated, and call the method to handle
     // that.
-    Telepathy::Client::Account *account = d->m_accountManager->accountForPath(path);
-    d->createAccountDataSource(account);
+    d->createAccountDataSource(path);
 }
 
 void
 PresenceEngine::accountValidityChanged(const QDBusObjectPath &path, bool valid)
 {
+	Q_UNUSED(valid);
     kDebug() << "accountValidityChanged() called";
     /*
      * slot called when an account has
      * been updated.
      */
-    Telepathy::Client::Account *account = d->m_accountManager->accountForPath(path);
-    d->createAccountDataSource(account);
+    d->createAccountDataSource(path);
 }
 
 void
@@ -189,8 +213,7 @@
      *
      * remove that source.
      */
-    Telepathy::Client::Account *account = d->m_accountManager->accountForPath(path);
-    d->removeAccountDataSource(account);
+    d->removeAccountDataSource(path);
 }
 
 #include "presence.moc"


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic