diff options
author | Matúš Kukan <matus.kukan@gmail.com> | 2012-08-04 01:52:29 +0200 |
---|---|---|
committer | Matúš Kukan <matus.kukan@gmail.com> | 2012-08-04 01:57:17 +0200 |
commit | 769e2b59e605c2c882d2039ad89e0958ea7bb2f2 (patch) | |
tree | 0f03a29e170e77e744c1ded69bf12ee9f3154952 /tubes/source | |
parent | 01839d6c7fbf2b32779c7c9037c0930b79c9e979 (diff) |
tubes: stop collaborating when the account gets off-line
Change-Id: Ic6f1bc41bc212e0c36751168f1204c41ebe0ce61
Diffstat (limited to 'tubes/source')
-rw-r--r-- | tubes/source/contact-list.cxx | 14 | ||||
-rw-r--r-- | tubes/source/manager.cxx | 26 |
2 files changed, 38 insertions, 2 deletions
diff --git a/tubes/source/contact-list.cxx b/tubes/source/contact-list.cxx index 1b27af23adf8..b238a2cc24be 100644 --- a/tubes/source/contact-list.cxx +++ b/tubes/source/contact-list.cxx @@ -71,9 +71,9 @@ ContactList::~ContactList() mpAccountManager = NULL; } -bool tb_contact_is_online( TpContact *contact ) +bool tb_presence_is_online( const TpConnectionPresenceType& presence ) { - switch (tp_contact_get_presence_type (contact)) + switch (presence) { case TP_CONNECTION_PRESENCE_TYPE_UNSET: case TP_CONNECTION_PRESENCE_TYPE_OFFLINE: @@ -91,6 +91,16 @@ bool tb_contact_is_online( TpContact *contact ) } } +bool tb_account_is_online( TpAccount *account ) +{ + return tb_presence_is_online (tp_account_get_current_presence (account, NULL, NULL)); +} + +bool tb_contact_is_online( TpContact *contact ) +{ + return tb_presence_is_online (tp_contact_get_presence_type (contact)); +} + namespace tubes { void reDrawAllContacts(); } diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx index dd3dcd5a37c0..3a2fc1b4ac11 100644 --- a/tubes/source/manager.cxx +++ b/tubes/source/manager.cxx @@ -105,8 +105,24 @@ public: ~TeleManagerImpl(); }; +bool tb_account_is_online( TpAccount* pAccount ); bool tb_contact_is_online( TpContact* pContact ); +static void account_presence_changed_cb( TpAccount* pAccount, + guint /* type */, + gchar* /* status */, + gchar* /* message */, + gpointer pConference ) +{ + if (!tb_account_is_online( pAccount )) + { + Collaboration* pCollaboration = + reinterpret_cast<TeleConference*> (pConference)->getCollaboration(); + if (pCollaboration) + pCollaboration->ContactLeft(); + } +} + static void contact_presence_changed_cb( TpContact* pContact, guint /* type */, gchar* /* status */, @@ -157,6 +173,10 @@ void TeleManager_DBusChannelHandler( TeleConference* pConference = new TeleConference( pManager, pAccount, TP_DBUS_TUBE_CHANNEL( pChannel ) ); pConference->acceptTube(); pManager->addConference( pConference ); + + g_signal_connect( pAccount, "presence-changed", + G_CALLBACK (account_presence_changed_cb), pConference ); + TpContact* pContact = tp_channel_get_target_contact( pChannel ); if (pContact) g_signal_connect( pContact, "presence-changed", @@ -636,6 +656,9 @@ TeleConference* TeleManager::startGroupSession( TpAccount *pAccount, if (!pConference->isReady()) return NULL; + g_signal_connect( pAccount, "presence-changed", + G_CALLBACK (account_presence_changed_cb), pConference ); + return pConference; } @@ -711,6 +734,9 @@ TeleConference* TeleManager::startBuddySession( TpAccount *pAccount, TpContact * if (!pConference->isReady()) return NULL; + g_signal_connect( pAccount, "presence-changed", + G_CALLBACK (account_presence_changed_cb), pConference ); + g_signal_connect( pBuddy, "presence-changed", G_CALLBACK (contact_presence_changed_cb), pConference ); |