Kaydet (Commit) 769e2b59 authored tarafından Matúš Kukan's avatar Matúš Kukan

tubes: stop collaborating when the account gets off-line

Change-Id: Ic6f1bc41bc212e0c36751168f1204c41ebe0ce61
üst 01839d6c
......@@ -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();
}
......
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment