diff options
author | Alvaro Soliverez <alvaro.soliverez@collabora.co.uk> | 2011-06-02 08:02:52 -0700 |
---|---|---|
committer | Alvaro Soliverez <alvaro.soliverez@collabora.co.uk> | 2011-06-02 08:02:52 -0700 |
commit | 068ba40dfbebe7b271123b1cfe083541716bb59f (patch) | |
tree | f6c5dabcd931836f98bb659bca9c8d7db8e9d5f3 | |
parent | bdbfa4a0f77c76f88fc16395b477c9cb41ae76ef (diff) |
Use the connection pointer to update the status and connect to its signals
-rw-r--r-- | TelepathyQt4Yell/Models/accounts-model-item.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/TelepathyQt4Yell/Models/accounts-model-item.cpp b/TelepathyQt4Yell/Models/accounts-model-item.cpp index 2c51764..6638c2e 100644 --- a/TelepathyQt4Yell/Models/accounts-model-item.cpp +++ b/TelepathyQt4Yell/Models/accounts-model-item.cpp @@ -123,11 +123,16 @@ AccountsModelItem::AccountsModelItem(const Tp::AccountPtr &account) SIGNAL(onlinenessChanged(bool)), SLOT(onChanged())); connect(mPriv->mAccount.data(), - SIGNAL(connectionStatusChanged(Tp::ConnectionStatus)), - SLOT(onStatusChanged(Tp::ConnectionStatus))); - connect(mPriv->mAccount.data(), SIGNAL(connectionChanged(Tp::ConnectionPtr)), SLOT(onConnectionChanged(Tp::ConnectionPtr))); + + // if connection is valid, connect to the status + if (!mPriv->mAccount->connection().isNull() + && mPriv->mAccount->connection()->isValid()) { + connect(mPriv->mAccount->connection().data(), SIGNAL(statusChanged(Tp::ConnectionStatus)), + SLOT(onStatusChanged(Tp::ConnectionStatus))); + onStatusChanged(mPriv->mAccount->connection()->status()); + } } AccountsModelItem::~AccountsModelItem() @@ -296,14 +301,11 @@ void AccountsModelItem::onContactsChanged(const Tp::Contacts &addedContacts, void AccountsModelItem::onStatusChanged(Tp::ConnectionStatus status) { onChanged(); - emit connectionStatusChanged(mPriv->mAccount->uniqueIdentifier(), status); } void AccountsModelItem::onConnectionChanged(const Tp::ConnectionPtr &connection) { - onChanged(); - // if the connection is invalid or disconnected, clear the contacts list if (connection.isNull() || !connection->isValid() @@ -314,17 +316,18 @@ void AccountsModelItem::onConnectionChanged(const Tp::ConnectionPtr &connection) return; } - mPriv->mManager = connection->contactManager(); + connect(connection.data(), SIGNAL(statusChanged(Tp::ConnectionStatus)), + SLOT(onStatusChanged(Tp::ConnectionStatus))); + onStatusChanged(connection->status()); + mPriv->mManager = connection->contactManager(); connect(mPriv->mManager.data(), SIGNAL(allKnownContactsChanged(Tp::Contacts,Tp::Contacts, Tp::Channel::GroupMemberChangeDetails)), SLOT(onContactsChanged(Tp::Contacts,Tp::Contacts))); - connect(mPriv->mManager.data(), SIGNAL(stateChanged(Tp::ContactListState)), SLOT(onContactManagerStateChanged(Tp::ContactListState))); - onContactManagerStateChanged(mPriv->mManager->state()); } |