[Telepathy-commits] [telepathy-qt4/master] Splitting signals for removing accounts.

Stefan Eilers stefan.eilers at basyskom.de
Wed Jan 28 02:13:48 PST 2009


- signalAboutToRemoveAccount() is emitted if the account is removed in telepathy and immediately before it is removed from local lists.
- signalAccountRemoved() is emmitted after the account was removed from internal lists.
---
 TelepathyQt4/Prototype/AccountManager.cpp |    9 ++++++---
 TelepathyQt4/Prototype/AccountManager.h   |   11 +++++++++--
 tests/prototype/prototype.cpp             |    2 +-
 3 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/TelepathyQt4/Prototype/AccountManager.cpp b/TelepathyQt4/Prototype/AccountManager.cpp
index 6f036f1..af1c009 100644
--- a/TelepathyQt4/Prototype/AccountManager.cpp
+++ b/TelepathyQt4/Prototype/AccountManager.cpp
@@ -280,8 +280,9 @@ void AccountManager::slotAccountValidityChanged( const QDBusObjectPath& account,
 #ifdef ENABLE_DEBUG_OUTPUT_
             qDebug() << "AccountManager::slotAccountValidityChanged: Remove account from list";
 #endif
-            emit signalAccountRemoved( d->m_validAccountHandles.value( account.path() ) );
+            emit signalAboutToRemoveAccount( d->m_validAccountHandles.value( account.path() ) );
             d->removeAccount( account.path() );
+            emit signalAccountRemoved();
             update_occurred = true;
         }
     }
@@ -305,8 +306,9 @@ void AccountManager::slotAccountRemoved( const QDBusObjectPath& account )
 
     // These signals are emitted if an account was removed extarnally.
     // The signals were already emitted by slotAccountRemoved() if the account was removed locally
-    emit signalAccountRemoved( account_object );
+    emit signalAboutToRemoveAccount( account_object );
     d->removeAccount( account.path() );
+    emit signalAccountRemoved();
     emit signalAccountsUpdated();
 }
 
@@ -334,8 +336,9 @@ void AccountManager::slotAccountRemoved()
     if ( account )
     {
         QString handle = account->handle();
-        emit signalAccountRemoved( account );
+        emit signalAboutToRemoveAccount( account );
         d->removeAccount( handle );
+        emit signalAccountRemoved();
         emit signalAccountsUpdated();
     }
 }
diff --git a/TelepathyQt4/Prototype/AccountManager.h b/TelepathyQt4/Prototype/AccountManager.h
index 94f9607..41af365 100644
--- a/TelepathyQt4/Prototype/AccountManager.h
+++ b/TelepathyQt4/Prototype/AccountManager.h
@@ -118,10 +118,17 @@ signals:
     void signalNewAccountAvailable( TpPrototype::Account* account );
 
     /**
+     * An account will be removed from internal data.
+     * This signal is emitted after the account was removed but immediately before the account is removed from the internal lists.<br>
+     * Do not use <i>account</i> after receiving this signal!
+     */
+    void signalAboutToRemoveAccount( TpPrototype::Account* account );
+
+    /**
      * An account was removed.
-     * This signal is emitted after an account was removed. Do not use <i>account</i> after receiving this signal!
+     * This signal is emitted after <i>signalAboutToRemoveAccount()</i>. The internal lists are updated now.
      */
-    void signalAccountRemoved( TpPrototype::Account* account );
+    void signalAccountRemoved();
     
     /**
      * An account was updated.
diff --git a/tests/prototype/prototype.cpp b/tests/prototype/prototype.cpp
index 8431387..27374b8 100644
--- a/tests/prototype/prototype.cpp
+++ b/tests/prototype/prototype.cpp
@@ -535,7 +535,7 @@ void UnitTests::testPrototypeAccountManager()
 
     QVERIFY2( waitForSignal( &spy_update_account, 2 ), "Received no signals after removeAccount() ");
     
-    QSignalSpy spy_remove_account( account_manager, SIGNAL( signalAccountRemoved( TpPrototype::Account* ) ) );
+    QSignalSpy spy_remove_account( account_manager, SIGNAL( signalAboutToRemoveAccount( TpPrototype::Account* ) ) );
     QCOMPARE( spy_remove_account.isValid(), true );
 
     int count = 0;
-- 
1.5.6.5




More information about the telepathy-commits mailing list