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

List:       kde-commits
Subject:    playground/network/telepathy-accounts-kcm/src
From:       George Goldberg <grundleborg () googlemail ! com>
Date:       2009-01-26 20:39:30
Message-ID: 1233002370.591545.29288.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 917084 by gberg:

Once the accountmanager is ready, load up all the accounts and get them ready too.

 M  +31 -3     kcm-telepathy-accounts.cpp  
 M  +1 -0      kcm-telepathy-accounts.h  


--- trunk/playground/network/telepathy-accounts-kcm/src/kcm-telepathy-accounts.cpp #917083:917084
@@ -23,6 +23,7 @@
 #include <kcategorizedsortfilterproxymodel.h>
 #include <kgenericfactory.h>
 
+#include <TelepathyQt4/Client/Account>
 #include <TelepathyQt4/Client/AccountManager>
 #include <TelepathyQt4/Client/PendingOperation>
 
@@ -67,20 +68,47 @@
 
 void KCMTelepathyAccounts::startAccountManagerFinished(Telepathy::Client::PendingOperation *op)
 {
+    disconnect(op, SIGNAL(finished(Telepathy::Client::PendingOperation*)),
+            this, SLOT(startAccountManagerFinished(Telepathy::Client::PendingOperation*)));
+
     Q_ASSERT(op->isFinished());
     if(op->isError())
     {
-        kDebug() << "An error occurred setting up the AccountManager.";
+        kDebug() << "An error occurred making the AccountManager ready.";
         return;
     }
     else
     {
-        kDebug() << "AccountManager set up successfully.";
+        kDebug() << "AccountManager became ready successfully.";
     }
 
-    // TODO: Load the model up with Accounts from the Account Manager.
+    QList<Telepathy::Client::Account*> accounts = m_accountManager->allAccounts();
+    foreach(Telepathy::Client::Account* account, accounts)
+    {
+        connect(account->becomeReady(), SIGNAL(finished(Telepathy::Client::PendingOperation*)),
+                this, SLOT(onAccountReady(Telepathy::Client::PendingOperation*)));
+    }
 }
 
+void KCMTelepathyAccounts::onAccountReady(Telepathy::Client::PendingOperation *op)
+{
+    disconnect(op, SIGNAL(finished(Telepathy::Client::PendingOperation*)),
+            this, SLOT(onAccountReady(Telepathy::Client::PendingOperation*)));
 
+    Q_ASSERT(op->isFinished());
+    if(op->isError())
+    {
+        kDebug() << "An error occurred in making and Account ready.";
+    }
+    else
+    {
+        kDebug() << "An Account became ready successfully.";
+    }
+
+    // TODO: Add the account to the model.
+    // FIXME: Need to get the AccountManager::allAccounts() API fixed before can continue easily.
+}
+
+
 #include "kcm-telepathy-accounts.moc"
 
--- trunk/playground/network/telepathy-accounts-kcm/src/kcm-telepathy-accounts.h #917083:917084
@@ -50,6 +50,7 @@
 private Q_SLOTS:
     void startAccountManager();
     void startAccountManagerFinished(Telepathy::Client::PendingOperation *op);
+    void onAccountReady(Telepathy::Client::PendingOperation *op);
 
 private:
     KCategorizedSortFilterProxyModel *m_accountsListProxyModel;
[prev in list] [next in list] [prev in thread] [next in thread] 

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