From 6766c6a2a0a933b507e8e98a30280d1963f5b7db Mon Sep 17 00:00:00 2001 From: Matúš Kukan Date: Tue, 7 Aug 2012 16:04:52 +0200 Subject: tubes: re-use typedefs from contact-list.hxx Change-Id: I7b1ac653d22275a64d00913f014ca2536be3ffed --- tubes/source/contacts.cxx | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'tubes/source/contacts.cxx') diff --git a/tubes/source/contacts.cxx b/tubes/source/contacts.cxx index 37a9de46a904..ef772dee58db 100644 --- a/tubes/source/contacts.cxx +++ b/tubes/source/contacts.cxx @@ -43,7 +43,6 @@ #include #include -#include #include namespace { @@ -76,25 +75,18 @@ class TubeContacts : public ModelessDialog DECL_LINK( BtnInviteHdl, void * ); DECL_LINK( BtnListenHdl, void * ); - struct AccountContact - { - TpAccount* mpAccount; - TpContact* mpContact; - AccountContact( TpAccount* pAccount, TpContact* pContact ): - mpAccount(pAccount), mpContact(pContact) {} - }; - boost::ptr_vector maACs; + AccountContactPairV maACs; void Invite() { - AccountContact *pAC = NULL; + AccountContactPair *pAC = NULL; if (maList.FirstSelected()) - pAC = static_cast (maList.FirstSelected()->GetUserData()); + pAC = static_cast (maList.FirstSelected()->GetUserData()); if (pAC) { if (mpCollaboration->GetConference()) { - TpContact* pContact = pAC->mpContact; + TpContact* pContact = pAC->second; mpCollaboration->GetConference()->invite( pContact ); mpCollaboration->SaveAndSendFile( pContact, OStringToOUString( mpCollaboration->GetConference()->getUuid(), RTL_TEXTENCODING_UTF8 ) ); @@ -123,13 +115,13 @@ class TubeContacts : public ModelessDialog void StartBuddySession() { - AccountContact *pAC = NULL; + AccountContactPair *pAC = NULL; if (maList.FirstSelected()) - pAC = static_cast (maList.FirstSelected()->GetUserData()); + pAC = static_cast (maList.FirstSelected()->GetUserData()); if (pAC) { - TpAccount* pAccount = pAC->mpAccount; - TpContact* pContact = pAC->mpContact; + TpAccount* pAccount = pAC->first; + TpContact* pContact = pAC->second; SAL_INFO( "tubes", "picked " << tp_contact_get_identifier( pContact ) ); TeleConference* pConference = TeleManager::startBuddySession( pAccount, pContact ); if (!pConference) @@ -146,12 +138,12 @@ class TubeContacts : public ModelessDialog void StartGroupSession() { - AccountContact *pAC = NULL; + AccountContactPair *pAC = NULL; if (maList.FirstSelected()) - pAC = static_cast (maList.FirstSelected()->GetUserData()); + pAC = static_cast (maList.FirstSelected()->GetUserData()); if (pAC) { - TpAccount* pAccount = pAC->mpAccount; + TpAccount* pAccount = pAC->first; SAL_INFO( "tubes", "picked " << tp_account_get_display_name( pAccount ) ); TeleConference* pConference = TeleManager::startGroupSession( pAccount, rtl::OUString("liboroom"), rtl::OUString("conference.jabber.org") ); @@ -211,11 +203,15 @@ public: { SAL_INFO( "sc.tubes", "Populating contact list dialog" ); maList.Clear(); + maACs.clear(); ContactList *pContacts = TeleManager::getContactList(); if ( pContacts ) { AccountContactPairV aPairs = pContacts->getContacts(); AccountContactPairV::iterator it; + // make sure we have enough memory to not need re-allocation + // which would invalidate pointers stored in maList entries + maACs.reserve( aPairs.size() ); for( it = aPairs.begin(); it != aPairs.end(); ++it ) { Image aImage; @@ -240,7 +236,7 @@ public: aEntry.append( sal_Unicode( '\t' ) ); SvLBoxEntry* pEntry = maList.InsertEntry( aEntry.makeStringAndClear(), aImage, aImage ); // FIXME: ref the TpAccount, TpContact ... - maACs.push_back( new AccountContact( it->first, it->second ) ); + maACs.push_back( AccountContactPair( it->first, it->second ) ); pEntry->SetUserData( &maACs.back() ); } } -- cgit v1.2.3