diff options
author | Matúš Kukan <matus.kukan@gmail.com> | 2012-06-16 23:42:03 +0200 |
---|---|---|
committer | Matúš Kukan <matus.kukan@gmail.com> | 2012-07-17 16:40:14 +0200 |
commit | d10839a1bd4d03abd7bba56b42ad437a02aefa65 (patch) | |
tree | 4e208bb0c245c9309c4dd24f94e1db1685976261 | |
parent | deea13f9657f37d1c266cf5914faa14f3a641f80 (diff) |
tubes: start collaboration from the contacts widget
-rw-r--r-- | sc/source/ui/collab/contacts.cxx | 47 | ||||
-rw-r--r-- | sc/source/ui/collab/contacts.hrc | 1 | ||||
-rw-r--r-- | sc/source/ui/collab/contacts.src | 8 | ||||
-rw-r--r-- | sc/source/ui/collab/sendfunc.cxx | 26 |
4 files changed, 56 insertions, 26 deletions
diff --git a/sc/source/ui/collab/contacts.cxx b/sc/source/ui/collab/contacts.cxx index c02910510d4c..44821a599e06 100644 --- a/sc/source/ui/collab/contacts.cxx +++ b/sc/source/ui/collab/contacts.cxx @@ -44,16 +44,50 @@ namespace { class TubeContacts : public ModelessDialog { FixedLine maLabel; + PushButton maBtnConnect; SvxSimpleTableContainer maListContainer; SvxSimpleTable maList; + DECL_LINK( BtnConnectHdl, void * ); + + struct AccountContact + { + TpAccount* mpAccount; + TpContact* mpContact; + AccountContact( TpAccount* pAccount, TpContact* pContact ): + mpAccount(pAccount), mpContact(pContact) {} + }; + boost::ptr_vector<AccountContact> maACs; + + void StartBuddySession() + { + AccountContact *pAC = NULL; + if (maList.FirstSelected()) + pAC = reinterpret_cast<AccountContact*> (maList.FirstSelected()->GetUserData()); + if (pAC) + { + TpAccount* pAccount = pAC->mpAccount; + TpContact* pContact = pAC->mpContact; + fprintf( stderr, "picked %s\n", tp_contact_get_identifier( pContact ) ); + // TeleManager has to exist already, false will be ignored: + TeleManager *pManager = TeleManager::get( false ); + if (!pManager->startBuddySession( pAccount, pContact )) + fprintf( stderr, "could not start session with %s\n", + tp_contact_get_identifier( pContact ) ); + pManager->unref(); + } + } + public: TubeContacts() : ModelessDialog( NULL, ScResId( RID_SCDLG_CONTACTS ) ), maLabel( this, ScResId( FL_LABEL ) ), + maBtnConnect( this, ScResId( BTN_CONNECT ) ), maListContainer( this, ScResId( CTL_LIST ) ), maList( maListContainer ) { + maBtnConnect.SetClickHdl( LINK( this, TubeContacts, BtnConnectHdl ) ); + static long aStaticTabs[]= { 3 /* count */, 0, 20, 100, 150, 200 @@ -111,12 +145,21 @@ public: aEntry.append( fromUTF8 ( tp_contact_get_identifier( it->second ) ) ); aEntry.append( sal_Unicode( '\t' ) ); SvLBoxEntry* pEntry = maList.InsertEntry( aEntry.makeStringAndClear(), aImage, aImage ); - // FIXME: ref the TpContact ... - pEntry->SetUserData( it->second ); + // FIXME: ref the TpAccount, TpContact ... + maACs.push_back( new AccountContact( it->first, it->second ) ); + pEntry->SetUserData( &maACs.back() ); } } } }; + +IMPL_LINK_NOARG( TubeContacts, BtnConnectHdl ) +{ + StartBuddySession(); + Close(); + return 0; +} + } // anonymous namespace #endif diff --git a/sc/source/ui/collab/contacts.hrc b/sc/source/ui/collab/contacts.hrc index c6e38d329462..dd3fcc4af1af 100644 --- a/sc/source/ui/collab/contacts.hrc +++ b/sc/source/ui/collab/contacts.hrc @@ -2,6 +2,7 @@ #define FL_LABEL 1 #define CTL_LIST 2 +#define BTN_CONNECT 3 #define STR_HEADER_ALIAS 20 #define STR_HEADER_NAME 21 diff --git a/sc/source/ui/collab/contacts.src b/sc/source/ui/collab/contacts.src index 878c1ae92355..1689823a9d0b 100644 --- a/sc/source/ui/collab/contacts.src +++ b/sc/source/ui/collab/contacts.src @@ -9,7 +9,7 @@ ModelessDialog RID_SCDLG_CONTACTS Hide = FALSE ; Moveable = TRUE ; Closeable = TRUE ; - Size = MAP_APPFONT ( 220 , 200 ) ; + Size = MAP_APPFONT ( 220 , 215 ) ; OutputSize = TRUE ; Text [ en-US ] = "Contacts" ; @@ -19,6 +19,12 @@ ModelessDialog RID_SCDLG_CONTACTS Size = MAP_APPFONT ( 198 , 8 ) ; Text [ en-US ] = "Select a contact to collaborate with" ; }; + PushButton BTN_CONNECT + { + Pos = MAP_APPFONT( 8 , 200 ); + Size = MAP_APPFONT( 50 , 10 ); + Text [ en-US ] = "Collaborate"; + }; Control CTL_LIST { Pos = MAP_APPFONT ( 8 , 10 ) ; diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx index eba602997d03..a4a8e232dc63 100644 --- a/sc/source/ui/collab/sendfunc.cxx +++ b/sc/source/ui/collab/sendfunc.cxx @@ -627,40 +627,20 @@ SC_DLLPRIVATE ScDocFunc *ScDocShell::CreateDocFunc() boost::shared_ptr<ScDocFuncRecv> pReceiver( new ScDocFuncRecv( pDirect ) ); ScDocFuncSend* pSender = new ScDocFuncSend( *this, pReceiver ); TeleManager *pManager = TeleManager::get( !bIsMaster ); - bool bOk = true; pManager->sigPacketReceived.connect( boost::bind( &ScDocFuncRecv::packetReceived, pReceiver.get(), _1, _2 )); pManager->sigFileReceived.connect( boost::bind( &ScDocFuncRecv::fileReceived, pReceiver.get(), _1 )); - bOk = bOk && pManager->connect(); - pManager->prepareAccountManager(); - - if (bIsMaster) - { - ContactList* pContactList = pManager->getContactList(); - AccountContactPairV aVec( pContactList->getContacts()); - - fprintf( stderr, "%u contacts\n", (int) aVec.size() ); - if (aVec.empty()) - bOk = false; - else - { - /* TODO: select a pair, for now just take the first */ - TpAccount* pAccount = aVec[0].first; - TpContact* pContact = aVec[0].second; - fprintf( stderr, "picked %s\n", tp_contact_get_identifier( pContact ) ); - bOk = bOk && pManager->startBuddySession( pAccount, pContact ); - } - } - if (bOk) + if (pManager->connect()) { + pManager->prepareAccountManager(); pSender->SetCollaboration( pManager ); } else { - fprintf( stderr, "Could not start collaboration.\n"); + fprintf( stderr, "Could not connect.\n"); } return pSender; } |