diff options
-rw-r--r-- | sc/source/ui/collab/contacts.cxx | 7 | ||||
-rw-r--r-- | tubes/inc/tubes/contact-list.hxx | 6 | ||||
-rw-r--r-- | tubes/source/contact-list.cxx | 15 |
3 files changed, 27 insertions, 1 deletions
diff --git a/sc/source/ui/collab/contacts.cxx b/sc/source/ui/collab/contacts.cxx index 5ade483c016f..80cb756d095f 100644 --- a/sc/source/ui/collab/contacts.cxx +++ b/sc/source/ui/collab/contacts.cxx @@ -190,6 +190,9 @@ public: sHeader += String( ScResId( STR_HEADER_NAME ) ); sHeader += '\t'; maList.InsertHeaderEntry( sHeader, HEADERBAR_APPEND, HIB_LEFT ); + + mpManager->getContactList()->sigContactListChanged.connect( + boost::bind( &TubeContacts::Populate, this ) ); } virtual ~TubeContacts() { @@ -204,6 +207,8 @@ public: void Populate() { + SAL_INFO( "sc.tubes", "Populating contact list dialog" ); + maList.Clear(); ContactList *pContacts = mpManager->getContactList(); if ( pContacts ) { @@ -272,7 +277,7 @@ namespace tubes { void createContacts() { #ifdef CONTACTS_DLG - TubeContacts *pContacts = new TubeContacts(); + static TubeContacts *pContacts = new TubeContacts(); pContacts->Populate(); #endif } diff --git a/tubes/inc/tubes/contact-list.hxx b/tubes/inc/tubes/contact-list.hxx index 9c48ab7896ce..bb504dc7fafc 100644 --- a/tubes/inc/tubes/contact-list.hxx +++ b/tubes/inc/tubes/contact-list.hxx @@ -29,10 +29,12 @@ #ifndef INCLUDED_TUBES_CONTACT_LIST_HXX #define INCLUDED_TUBES_CONTACT_LIST_HXX +#include <set> #include <utility> #include <vector> #include "tubes/tubesdllapi.h" +#include <tubes/warnings_guard_boost_signals2.hpp> typedef struct _TpAccount TpAccount; typedef struct _TpContact TpContact; @@ -49,8 +51,12 @@ public: AccountContactPairV getContacts(); + /** Emitted when a contact changes its presence. */ + boost::signals2::signal<void ()> sigContactListChanged; + private: TpAccountManager* mpAccountManager; + std::set< TpContact* > maRegistered; }; diff --git a/tubes/source/contact-list.cxx b/tubes/source/contact-list.cxx index 0d4680358fd3..78f84b534417 100644 --- a/tubes/source/contact-list.cxx +++ b/tubes/source/contact-list.cxx @@ -92,6 +92,15 @@ tb_contact_is_online (TpContact *contact) } } +static void presence_changed_cb( TpContact* /* contact */, + guint /* type */, + gchar* /* status */, + gchar* /* message */, + gpointer pContactList ) +{ + reinterpret_cast<ContactList*> (pContactList)->sigContactListChanged(); +} + AccountContactPairV ContactList::getContacts() { GList *accounts; @@ -121,6 +130,12 @@ AccountContactPairV ContactList::getContacts() { TpContact *contact = reinterpret_cast<TpContact *>(g_ptr_array_index (contacts, i)); + if (maRegistered.find (contact) == maRegistered.end()) + { + maRegistered.insert (contact); + g_signal_connect (contact, "presence-changed", + G_CALLBACK (presence_changed_cb), this ); + } if (contact != self && tb_contact_is_online (contact)) |