sc/source/ui/collab/sccollaboration.cxx | 34 ++++++++++++++------ sc/source/ui/collab/sendfunc.cxx | 8 ++-- sc/source/ui/docshell/docsh.cxx | 17 ++++++++++ sc/source/ui/inc/docsh.hxx | 9 +++++ sc/source/ui/inc/sccollaboration.hxx | 10 ++++-- sc/source/ui/view/cellsh3.cxx | 2 - tubes/CppunitTest_tubes_test.mk | 5 +++ tubes/Package_inc.mk | 1 tubes/inc/tubes/collaboration.hxx | 4 +- tubes/inc/tubes/conference.hxx | 9 ++++- tubes/inc/tubes/contact-list.hxx | 8 ---- tubes/inc/tubes/manager.hxx | 16 ++++----- tubes/source/contact-list.cxx | 22 ++++++++++--- tubes/source/contacts.cxx | 46 ++++++++++++++++++--------- tubes/source/manager.cxx | 53 +++++++++++++++++++++++++++++++- 15 files changed, 185 insertions(+), 59 deletions(-)
New commits: commit 769e2b59e605c2c882d2039ad89e0958ea7bb2f2 Author: Matúš Kukan <matus.ku...@gmail.com> Date: Sat Aug 4 01:52:29 2012 +0200 tubes: stop collaborating when the account gets off-line Change-Id: Ic6f1bc41bc212e0c36751168f1204c41ebe0ce61 diff --git a/tubes/source/contact-list.cxx b/tubes/source/contact-list.cxx index 1b27af2..b238a2c 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 dd3dcd5..3a2fc1b 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 ); commit 01839d6c7fbf2b32779c7c9037c0930b79c9e979 Author: Matúš Kukan <matus.ku...@gmail.com> Date: Sat Aug 4 00:02:12 2012 +0200 tubes: fix build of unit test; set include path for now Later we would want to move headers if they are not used outside. Change-Id: I863f6f00254b335af563598a195aea01595f6c99 diff --git a/tubes/CppunitTest_tubes_test.mk b/tubes/CppunitTest_tubes_test.mk index 597102c..6b3b40d 100644 --- a/tubes/CppunitTest_tubes_test.mk +++ b/tubes/CppunitTest_tubes_test.mk @@ -30,6 +30,11 @@ $(eval $(call gb_CppunitTest_add_exception_objects,tubes_test, \ tubes/qa/test_manager \ )) +$(eval $(call gb_CppunitTest_set_include,tubes_test, \ + -I$(SRCDIR)/tubes/inc \ + $$(INCLUDE) \ +)) + $(eval $(call gb_CppunitTest_use_packages,tubes_test,tubes_inc)) $(eval $(call gb_CppunitTest_use_library_objects,tubes_test,tubes)) commit 8aef9f4027a9908f9f7f8e023fed4d9db50c5696 Author: Matúš Kukan <matus.ku...@gmail.com> Date: Fri Aug 3 23:50:03 2012 +0200 tubes: stop collaborating when the contact leaves Change-Id: I779aededb95eac6cbfb2fec3e97d207704244e25 diff --git a/sc/source/ui/collab/sccollaboration.cxx b/sc/source/ui/collab/sccollaboration.cxx index aea2f0b..4651bfc 100644 --- a/sc/source/ui/collab/sccollaboration.cxx +++ b/sc/source/ui/collab/sccollaboration.cxx @@ -21,6 +21,17 @@ ScCollaboration::~ScCollaboration() { } +void ScCollaboration::ContactLeft() +{ + SAL_INFO( "sc.tubes", "Contact has left the collaboration" ); + ScDocFuncSend* pSender = GetScDocFuncSend(); + if (pSender) + { + delete pSender; + mpScDocShell->SetDocFunc( new ScDocFuncDirect( *mpScDocShell ) ); + } +} + TeleConference* ScCollaboration::GetConference() { ScDocFuncSend* pSender = GetScDocFuncSend(); diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx index e3ee4dc..0530980 100644 --- a/sc/source/ui/collab/sendfunc.cxx +++ b/sc/source/ui/collab/sendfunc.cxx @@ -356,7 +356,9 @@ ScDocFunc *ScDocShell::CreateDocFunc() ScDocFuncDirect *pDirect = new ScDocFuncDirect( *this ); ScDocFuncRecv *pReceiver = new ScDocFuncRecv( pDirect ); ScDocFuncSend *pSender = new ScDocFuncSend( *this, pReceiver ); - pSender->SetCollaboration( TeleManager::getConference() ); + TeleConference* pConference = TeleManager::getConference(); + pConference->setCollaboration( mpCollaboration ); + pSender->SetCollaboration( pConference ); return pSender; } else diff --git a/sc/source/ui/inc/sccollaboration.hxx b/sc/source/ui/inc/sccollaboration.hxx index 283cce4..bfdb985 100644 --- a/sc/source/ui/inc/sccollaboration.hxx +++ b/sc/source/ui/inc/sccollaboration.hxx @@ -21,6 +21,7 @@ public: ScCollaboration( ScDocShell* pScDocShell ); virtual ~ScCollaboration(); + virtual void ContactLeft(); virtual TeleConference* GetConference(); virtual sal_uInt64 GetId(); virtual void SetCollaboration( TeleConference* pConference ); diff --git a/tubes/inc/tubes/collaboration.hxx b/tubes/inc/tubes/collaboration.hxx index 31eff7a..6249173 100644 --- a/tubes/inc/tubes/collaboration.hxx +++ b/tubes/inc/tubes/collaboration.hxx @@ -23,6 +23,7 @@ public: Collaboration() {} virtual ~Collaboration() {} + virtual void ContactLeft() = 0; virtual TeleConference* GetConference() = 0; virtual sal_uInt64 GetId() = 0; virtual void SetCollaboration( TeleConference* pConference ) = 0; diff --git a/tubes/inc/tubes/conference.hxx b/tubes/inc/tubes/conference.hxx index 99eb009..150e77f 100644 --- a/tubes/inc/tubes/conference.hxx +++ b/tubes/inc/tubes/conference.hxx @@ -34,6 +34,7 @@ #include <rtl/ustring.hxx> #include <tubes/warnings_guard_boost_signals2.hpp> +class Collaboration; class TeleManager; class TeleConferenceImpl; typedef struct _TpAccount TpAccount; @@ -73,6 +74,9 @@ public: TUBES_DLLPUBLIC void sendFile( TpContact* pContact, rtl::OUString &localUri, FileSentCallback pCallback, void* pUserData); const OString& getUuid() const { return msUuid; } + Collaboration* getCollaboration() const { return mpCollaboration; } + void setCollaboration( Collaboration* pCollaboration ) { mpCollaboration = pCollaboration; } + // --- following only to be called only by manager's callbacks --- // TODO: make friends instead void setChannel( TpAccount* pAccount, TpDBusTubeChannel* pChannel ); @@ -98,6 +102,7 @@ private: // Private: bool spinUntilTubeEstablished(); + Collaboration* mpCollaboration; TeleManager* mpManager; TpAccount* mpAccount; TpDBusTubeChannel* mpChannel; diff --git a/tubes/source/contact-list.cxx b/tubes/source/contact-list.cxx index 9a5b492..1b27af2 100644 --- a/tubes/source/contact-list.cxx +++ b/tubes/source/contact-list.cxx @@ -71,8 +71,7 @@ ContactList::~ContactList() mpAccountManager = NULL; } -static bool -tb_contact_is_online (TpContact *contact) +bool tb_contact_is_online( TpContact *contact ) { switch (tp_contact_get_presence_type (contact)) { diff --git a/tubes/source/contacts.cxx b/tubes/source/contacts.cxx index aa3fb79..4db9113 100644 --- a/tubes/source/contacts.cxx +++ b/tubes/source/contacts.cxx @@ -124,6 +124,7 @@ class TubeContacts : public ModelessDialog tp_contact_get_identifier( pContact ) ); else { + pConference->setCollaboration( mpCollaboration ); mpCollaboration->SetCollaboration( pConference ); mpCollaboration->SendFile( pContact, OStringToOUString( pConference->getUuid(), RTL_TEXTENCODING_UTF8 ) ); @@ -146,6 +147,7 @@ class TubeContacts : public ModelessDialog SAL_WARN( "tubes", "Could not start group session." ); else { + pConference->setCollaboration( mpCollaboration ); mpCollaboration->SetCollaboration( pConference ); } } diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx index 7722844..dd3dcd5 100644 --- a/tubes/source/manager.cxx +++ b/tubes/source/manager.cxx @@ -27,6 +27,8 @@ */ #include <tubes/manager.hxx> + +#include <tubes/collaboration.hxx> #include <tubes/conference.hxx> #include <tubes/constants.h> #include <tubes/contact-list.hxx> @@ -103,6 +105,22 @@ public: ~TeleManagerImpl(); }; +bool tb_contact_is_online( TpContact* pContact ); + +static void contact_presence_changed_cb( TpContact* pContact, + guint /* type */, + gchar* /* status */, + gchar* /* message */, + gpointer pConference ) +{ + if (!tb_contact_is_online( pContact )) + { + Collaboration* pCollaboration = + reinterpret_cast<TeleConference*> (pConference)->getCollaboration(); + if (pCollaboration) + pCollaboration->ContactLeft(); + } +} void TeleManager_DBusChannelHandler( TpSimpleHandler* /*handler*/, @@ -139,6 +157,10 @@ void TeleManager_DBusChannelHandler( TeleConference* pConference = new TeleConference( pManager, pAccount, TP_DBUS_TUBE_CHANNEL( pChannel ) ); pConference->acceptTube(); pManager->addConference( pConference ); + TpContact* pContact = tp_channel_get_target_contact( pChannel ); + if (pContact) + g_signal_connect( pContact, "presence-changed", + G_CALLBACK (contact_presence_changed_cb), pConference ); } else { @@ -689,6 +711,9 @@ TeleConference* TeleManager::startBuddySession( TpAccount *pAccount, TpContact * if (!pConference->isReady()) return NULL; + g_signal_connect( pBuddy, "presence-changed", + G_CALLBACK (contact_presence_changed_cb), pConference ); + return pConference; } commit 374fb913a78edaa765e0f731d823d6e8180f56fe Author: Matúš Kukan <matus.ku...@gmail.com> Date: Fri Aug 3 23:32:58 2012 +0200 tubes: make ScDocShell* member of ScCollaboration Change-Id: I8e9bab6d97e7fb4a3de3b3d3896a57c6496958bd diff --git a/sc/source/ui/collab/sccollaboration.cxx b/sc/source/ui/collab/sccollaboration.cxx index fbdbe0a..aea2f0b 100644 --- a/sc/source/ui/collab/sccollaboration.cxx +++ b/sc/source/ui/collab/sccollaboration.cxx @@ -12,7 +12,8 @@ #include "docsh.hxx" #include "sendfunc.hxx" -ScCollaboration::ScCollaboration() +ScCollaboration::ScCollaboration( ScDocShell* pScDocShell ) : + mpScDocShell( pScDocShell ) { } @@ -31,21 +32,20 @@ TeleConference* ScCollaboration::GetConference() sal_uInt64 ScCollaboration::GetId() { - return reinterpret_cast<sal_uInt64> (SfxObjectShell::Current()); + return reinterpret_cast<sal_uInt64> (mpScDocShell); } void ScCollaboration::SetCollaboration( TeleConference* pConference ) { - ScDocShell* pScDocShell = dynamic_cast<ScDocShell*> (SfxObjectShell::Current()); - ScDocFunc* pDocFunc = pScDocShell ? &pScDocShell->GetDocFunc() : NULL; + ScDocFunc* pDocFunc = &mpScDocShell->GetDocFunc(); ScDocFuncSend* pSender = dynamic_cast<ScDocFuncSend*> (pDocFunc); if (!pSender) { // This means pDocFunc has to be ScDocFuncDirect* and we are not collaborating yet. ScDocFuncDirect *pDirect = dynamic_cast<ScDocFuncDirect*> (pDocFunc); ScDocFuncRecv *pReceiver = new ScDocFuncRecv( pDirect ); - pSender = new ScDocFuncSend( *pScDocShell, pReceiver ); - pScDocShell->SetDocFunc( pSender ); + pSender = new ScDocFuncSend( *mpScDocShell, pReceiver ); + mpScDocShell->SetDocFunc( pSender ); } pSender->SetCollaboration( pConference ); } @@ -59,9 +59,7 @@ void ScCollaboration::SendFile( TpContact* pContact, const OUString& rURL ) ScDocFuncSend* ScCollaboration::GetScDocFuncSend() { - ScDocShell *pScDocShell = dynamic_cast<ScDocShell*> (SfxObjectShell::Current()); - ScDocFunc *pDocFunc = pScDocShell ? &pScDocShell->GetDocFunc() : NULL; - return dynamic_cast<ScDocFuncSend*> (pDocFunc); + return dynamic_cast<ScDocFuncSend*> (&mpScDocShell->GetDocFunc()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 6bf7aec..228c6da 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -2540,7 +2540,7 @@ ScDocShell::ScDocShell( const ScDocShell& rShell ) : pSheetSaveData ( NULL ), pModificator ( NULL ) #ifdef ENABLE_TELEPATHY - , mpCollaboration( new ScCollaboration() ) + , mpCollaboration( new ScCollaboration( this ) ) #endif { RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::ScDocShell" ); @@ -2589,7 +2589,7 @@ ScDocShell::ScDocShell( const sal_uInt64 i_nSfxCreationFlags ) : pSheetSaveData ( NULL ), pModificator ( NULL ) #ifdef ENABLE_TELEPATHY - , mpCollaboration( new ScCollaboration() ) + , mpCollaboration( new ScCollaboration( this ) ) #endif { RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::ScDocShell" ); diff --git a/sc/source/ui/inc/sccollaboration.hxx b/sc/source/ui/inc/sccollaboration.hxx index 41b2c58..283cce4 100644 --- a/sc/source/ui/inc/sccollaboration.hxx +++ b/sc/source/ui/inc/sccollaboration.hxx @@ -12,11 +12,13 @@ #include <tubes/collaboration.hxx> class ScDocFuncSend; +class ScDocShell; class ScCollaboration : public Collaboration { + ScDocShell* mpScDocShell; public: - ScCollaboration(); + ScCollaboration( ScDocShell* pScDocShell ); virtual ~ScCollaboration(); virtual TeleConference* GetConference(); commit 56977dfaa541dfc06f2cec921a49f5a68a8dbcb9 Author: Matúš Kukan <matus.ku...@gmail.com> Date: Fri Aug 3 22:53:26 2012 +0200 tubes: fix leaking ScCollaboration; add it to ScDocShell Change-Id: I43c951b5694ad38aa1a2e5da7cc99dfb52685349 diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx index d52f8b0..e3ee4dc 100644 --- a/sc/source/ui/collab/sendfunc.cxx +++ b/sc/source/ui/collab/sendfunc.cxx @@ -253,7 +253,7 @@ sal_Bool ScDocFuncSend::SetNormalString( bool& o_rbNumFmtSet, const ScAddress& r SendFile( NULL, rText ); if ( rtl::OUString( rText ) == "contacts" ) - tubes::createContacts( new ScCollaboration() ); + tubes::createContacts( rDocShell.GetCollaboration() ); return true; // needs some code auditing action } diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 2c3d5ac..6bf7aec 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -112,6 +112,9 @@ #include "cellsuno.hxx" #include "dpobject.hxx" #include "markdata.hxx" +#ifdef ENABLE_TELEPATHY +#include "sccollaboration.hxx" +#endif #include <vector> #include <boost/shared_ptr.hpp> @@ -2505,6 +2508,11 @@ ScDocFunc *ScDocShell::CreateDocFunc() { return new ScDocFuncDirect( *this ); } +#else +Collaboration* ScDocShell::GetCollaboration() +{ + return mpCollaboration; +} #endif ScDocShell::ScDocShell( const ScDocShell& rShell ) : @@ -2531,6 +2539,9 @@ ScDocShell::ScDocShell( const ScDocShell& rShell ) : pSolverSaveData ( NULL ), pSheetSaveData ( NULL ), pModificator ( NULL ) +#ifdef ENABLE_TELEPATHY + , mpCollaboration( new ScCollaboration() ) +#endif { RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::ScDocShell" ); @@ -2577,6 +2588,9 @@ ScDocShell::ScDocShell( const sal_uInt64 i_nSfxCreationFlags ) : pSolverSaveData ( NULL ), pSheetSaveData ( NULL ), pModificator ( NULL ) +#ifdef ENABLE_TELEPATHY + , mpCollaboration( new ScCollaboration() ) +#endif { RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::ScDocShell" ); @@ -2635,6 +2649,9 @@ ScDocShell::~ScDocShell() OSL_FAIL("The Modificator should not exist"); delete pModificator; } +#ifdef ENABLE_TELEPATHY + delete mpCollaboration; +#endif } //------------------------------------------------------------------ diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index dc55102..3076592 100644 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -73,6 +73,9 @@ class ScOptSolverSave; class ScSheetSaveData; class ScFlatBoolRowSegments; struct ScColWidthParam; +#ifdef ENABLE_TELEPATHY +class Collaboration; +#endif namespace sfx2 { class FileDialogHelper; } struct DocShell_Impl; @@ -121,6 +124,9 @@ class SC_DLLPUBLIC ScDocShell: public SfxObjectShell, public SfxListener ScSheetSaveData* pSheetSaveData; ScDocShellModificator* pModificator; // #109979#; is used to load XML (created in BeforeXMLLoading and destroyed in AfterXMLLoading) +#ifdef ENABLE_TELEPATHY + Collaboration* mpCollaboration; +#endif SC_DLLPRIVATE void InitItems(); SC_DLLPRIVATE void DoEnterHandler(); @@ -186,6 +192,9 @@ public: using SfxShell::Deactivate; // with sal_Bool bMDI using SfxObjectShell::Print; // print styles +#ifdef ENABLE_TELEPATHY + SC_DLLPRIVATE Collaboration* GetCollaboration(); +#endif virtual void Activate(); virtual void Deactivate(); diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx index 32b5a00..4850229 100644 --- a/sc/source/ui/view/cellsh3.cxx +++ b/sc/source/ui/view/cellsh3.cxx @@ -118,7 +118,7 @@ void ScCellShell::Execute( SfxRequest& rReq ) case SID_COLLABORATION: #ifdef ENABLE_TELEPATHY - tubes::createContacts( new ScCollaboration() ); + tubes::createContacts( GetViewData()->GetDocShell()->GetCollaboration() ); #endif break; diff --git a/tubes/source/contacts.cxx b/tubes/source/contacts.cxx index d24ffd3..aa3fb79 100644 --- a/tubes/source/contacts.cxx +++ b/tubes/source/contacts.cxx @@ -185,7 +185,6 @@ public: } virtual ~TubeContacts() { - delete mpCollaboration; delete mpManager; } commit 0c9aae91bcbd0cb7b0f0f7e8631aa4aeebb20993 Author: Matúš Kukan <matus.ku...@gmail.com> Date: Fri Aug 3 15:40:04 2012 +0200 tubes: use SAL_INFO SAL_WARN here Change-Id: Iae41c7f3d6718c06092d41d9b3757a821dba87b5 diff --git a/tubes/source/contacts.cxx b/tubes/source/contacts.cxx index ff42df3..d24ffd3 100644 --- a/tubes/source/contacts.cxx +++ b/tubes/source/contacts.cxx @@ -117,10 +117,10 @@ class TubeContacts : public ModelessDialog { TpAccount* pAccount = pAC->mpAccount; TpContact* pContact = pAC->mpContact; - fprintf( stderr, "picked %s\n", tp_contact_get_identifier( pContact ) ); + SAL_INFO( "tubes", "picked " << tp_contact_get_identifier( pContact ) ); TeleConference* pConference = mpManager->startBuddySession( pAccount, pContact ); if (!pConference) - fprintf( stderr, "could not start session with %s\n", + SAL_WARN( "tubes", "Could not start session with " << tp_contact_get_identifier( pContact ) ); else { @@ -139,11 +139,11 @@ class TubeContacts : public ModelessDialog if (pAC) { TpAccount* pAccount = pAC->mpAccount; - fprintf( stderr, "picked %s\n", tp_account_get_display_name( pAccount ) ); + SAL_INFO( "tubes", "picked " << tp_account_get_display_name( pAccount ) ); TeleConference* pConference = mpManager->startGroupSession( pAccount, rtl::OUString("liboroom"), rtl::OUString("conference.jabber.org") ); if (!pConference) - fprintf( stderr, "could not start group session\n" ); + SAL_WARN( "tubes", "Could not start group session." ); else { mpCollaboration->SetCollaboration( pConference ); commit 2965a1c3fca6d8807e657252e53bbb2f4f63b60f Author: Matúš Kukan <matus.ku...@gmail.com> Date: Fri Aug 3 15:32:28 2012 +0200 tubes: we use less symbols after bc21b49a464ae153341ee8d836993ca89b1a6919 Change-Id: Ibf2e3d3f5de87848ba8efb669308fe790d6622d6 diff --git a/tubes/Package_inc.mk b/tubes/Package_inc.mk index 1502b90..c6606fc 100644 --- a/tubes/Package_inc.mk +++ b/tubes/Package_inc.mk @@ -28,7 +28,6 @@ $(eval $(call gb_Package_Package,tubes_inc,$(SRCDIR)/tubes/inc)) $(eval $(call gb_Package_add_file,tubes_inc,inc/tubes/collaboration.hxx,tubes/collaboration.hxx)) $(eval $(call gb_Package_add_file,tubes_inc,inc/tubes/conference.hxx,tubes/conference.hxx)) -$(eval $(call gb_Package_add_file,tubes_inc,inc/tubes/contact-list.hxx,tubes/contact-list.hxx)) $(eval $(call gb_Package_add_file,tubes_inc,inc/tubes/contacts.hxx,tubes/contacts.hxx)) $(eval $(call gb_Package_add_file,tubes_inc,inc/tubes/manager.hxx,tubes/manager.hxx)) $(eval $(call gb_Package_add_file,tubes_inc,inc/tubes/tubesdllapi.h,tubes/tubesdllapi.h)) diff --git a/tubes/inc/tubes/conference.hxx b/tubes/inc/tubes/conference.hxx index 6a02604..99eb009 100644 --- a/tubes/inc/tubes/conference.hxx +++ b/tubes/inc/tubes/conference.hxx @@ -64,14 +64,14 @@ public: /** Pop a received packet. */ bool popPacket( OString& rPacket ); - TUBES_DLLPUBLIC void invite( TpContact *pContact ); + void invite( TpContact *pContact ); /** Emitted when a packet is received. */ boost::signals2::signal<void (const OString&)> sigPacketReceived; typedef void (*FileSentCallback)( bool aSuccess, void* pUserData); TUBES_DLLPUBLIC void sendFile( TpContact* pContact, rtl::OUString &localUri, FileSentCallback pCallback, void* pUserData); - TUBES_DLLPUBLIC const OString& getUuid() const { return msUuid; } + const OString& getUuid() const { return msUuid; } // --- following only to be called only by manager's callbacks --- // TODO: make friends instead diff --git a/tubes/inc/tubes/contact-list.hxx b/tubes/inc/tubes/contact-list.hxx index eca9f70..6dc4f32 100644 --- a/tubes/inc/tubes/contact-list.hxx +++ b/tubes/inc/tubes/contact-list.hxx @@ -33,8 +33,6 @@ #include <utility> #include <vector> -#include "tubes/tubesdllapi.h" - typedef struct _TpAccount TpAccount; typedef struct _TpContact TpContact; typedef struct _TpAccountManager TpAccountManager; @@ -42,7 +40,7 @@ typedef struct _TpAccountManager TpAccountManager; typedef ::std::pair< TpAccount *, TpContact * > AccountContactPair; typedef ::std::vector< AccountContactPair > AccountContactPairV; -class TUBES_DLLPUBLIC ContactList +class ContactList { public: ContactList(TpAccountManager *pAccountManager); diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx index 8f7afa6..67f319c 100644 --- a/tubes/inc/tubes/manager.hxx +++ b/tubes/inc/tubes/manager.hxx @@ -73,10 +73,10 @@ public: TUBES_DLLPUBLIC bool init( bool bListen ); /** Connect to DBus and create AccountManager. */ - TUBES_DLLPUBLIC bool createAccountManager(); + bool createAccountManager(); /** Setup client handlers. */ - TUBES_DLLPUBLIC bool registerClients(); + bool registerClients(); /** Prepare the Telepathy Account Manager. Requires createAccountManager() to have succeeded. @@ -86,13 +86,13 @@ public: TODO: this needs some signalling mechanism */ - TUBES_DLLPUBLIC void prepareAccountManager(); - TUBES_DLLPUBLIC AccountManagerStatus getAccountManagerStatus() const; + void prepareAccountManager(); + AccountManagerStatus getAccountManagerStatus() const; /** Fetches the contact list. Returns 0 before connect() is called successfully. Is non-functional until prepareAccountManager(). */ - TUBES_DLLPUBLIC ContactList* getContactList() const; + ContactList* getContactList() const; /** Start a group session in a MUC. @@ -108,7 +108,7 @@ public: empty, only the conference's UUID is used and rConferenceRoom is ignored, hopefully resulting in a local DBus tube. */ - TUBES_DLLPUBLIC TeleConference* startGroupSession( TpAccount *pAccount, + TeleConference* startGroupSession( TpAccount *pAccount, const rtl::OUString& rConferenceRoom, const rtl::OUString& rConferenceServer ); @@ -120,7 +120,7 @@ public: @param pBuddy The buddy to be connected. Must be a contact of pAccount. */ - TUBES_DLLPUBLIC TeleConference* startBuddySession( TpAccount *pAccount, TpContact *pBuddy ); + TeleConference* startBuddySession( TpAccount *pAccount, TpContact *pBuddy ); /** Get a conference with current UUID to set a session. */ TUBES_DLLPUBLIC static TeleConference* getConference(); commit b7e077787849a91efbc81fbbf5fd885b7cd0f3e1 Author: Matúš Kukan <matus.ku...@gmail.com> Date: Fri Aug 3 15:22:26 2012 +0200 tubes: do not use boost::signal here; call function directly Change-Id: Iaab997f3d56d76fe98d70f8cffdbb44a34500901 diff --git a/tubes/inc/tubes/contact-list.hxx b/tubes/inc/tubes/contact-list.hxx index bb504dc..eca9f70 100644 --- a/tubes/inc/tubes/contact-list.hxx +++ b/tubes/inc/tubes/contact-list.hxx @@ -34,7 +34,6 @@ #include <vector> #include "tubes/tubesdllapi.h" -#include <tubes/warnings_guard_boost_signals2.hpp> typedef struct _TpAccount TpAccount; typedef struct _TpContact TpContact; @@ -51,9 +50,6 @@ 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 78f84b5..9a5b492 100644 --- a/tubes/source/contact-list.cxx +++ b/tubes/source/contact-list.cxx @@ -92,13 +92,16 @@ tb_contact_is_online (TpContact *contact) } } +namespace tubes { + void reDrawAllContacts(); +} static void presence_changed_cb( TpContact* /* contact */, guint /* type */, gchar* /* status */, gchar* /* message */, - gpointer pContactList ) + gpointer /* pContactList*/ ) { - reinterpret_cast<ContactList*> (pContactList)->sigContactListChanged(); + tubes::reDrawAllContacts(); } AccountContactPairV ContactList::getContacts() diff --git a/tubes/source/contacts.cxx b/tubes/source/contacts.cxx index 9245b55..ff42df3 100644 --- a/tubes/source/contacts.cxx +++ b/tubes/source/contacts.cxx @@ -182,9 +182,6 @@ public: sHeader += String( TubesResId( STR_HEADER_NAME ) ); sHeader += '\t'; maList.InsertHeaderEntry( sHeader, HEADERBAR_APPEND, HIB_LEFT ); - - mpManager->getContactList()->sigContactListChanged.connect( - boost::bind( &TubeContacts::Populate, this ) ); } virtual ~TubeContacts() { @@ -263,10 +260,12 @@ IMPL_LINK_NOARG( TubeContacts, BtnListenHdl ) return 0; } +// Mapping contacts dialog instance for each document +typedef std::map< sal_uInt64, TubeContacts* > DialogsMap; +static DialogsMap aDialogsMap; + TubeContacts* ContactsFactory( Collaboration* pCollaboration ) { - // Mapping contacts dialog instance for each document - static std::map< sal_uInt64, TubeContacts* > aDialogsMap; sal_uInt64 Id = pCollaboration->GetId(); if (aDialogsMap.find( Id ) == aDialogsMap.end()) aDialogsMap[ Id ] = new TubeContacts( pCollaboration ); @@ -281,6 +280,14 @@ void createContacts( Collaboration* pCollaboration ) TubeContacts* pContacts = ContactsFactory( pCollaboration ); pContacts->Populate(); } + +void reDrawAllContacts() +{ + for (DialogsMap::const_iterator it = aDialogsMap.begin(); + it != aDialogsMap.end(); ++it) + it->second->Populate(); +} + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 4e648b8e7c65fd8c382baf6b6798cdedfac5cdd8 Author: Matúš Kukan <matus.ku...@gmail.com> Date: Fri Aug 3 14:02:01 2012 +0200 tubes: create contacts dialog instance for each document separately This solves a crash when static dialog instance was destroyed on closing of one document but then was used in another document. Change-Id: I6ac9edb1de83f638bdf4ce7c0814fcbdf4b4b1e5 diff --git a/sc/source/ui/collab/sccollaboration.cxx b/sc/source/ui/collab/sccollaboration.cxx index 758db89..fbdbe0a 100644 --- a/sc/source/ui/collab/sccollaboration.cxx +++ b/sc/source/ui/collab/sccollaboration.cxx @@ -20,7 +20,7 @@ ScCollaboration::~ScCollaboration() { } -TeleConference* ScCollaboration::GetConference() const +TeleConference* ScCollaboration::GetConference() { ScDocFuncSend* pSender = GetScDocFuncSend(); if (pSender) @@ -29,6 +29,11 @@ TeleConference* ScCollaboration::GetConference() const return NULL; } +sal_uInt64 ScCollaboration::GetId() +{ + return reinterpret_cast<sal_uInt64> (SfxObjectShell::Current()); +} + void ScCollaboration::SetCollaboration( TeleConference* pConference ) { ScDocShell* pScDocShell = dynamic_cast<ScDocShell*> (SfxObjectShell::Current()); @@ -52,7 +57,7 @@ void ScCollaboration::SendFile( TpContact* pContact, const OUString& rURL ) pSender->SendFile( pContact, rURL ); } -ScDocFuncSend* ScCollaboration::GetScDocFuncSend() const +ScDocFuncSend* ScCollaboration::GetScDocFuncSend() { ScDocShell *pScDocShell = dynamic_cast<ScDocShell*> (SfxObjectShell::Current()); ScDocFunc *pDocFunc = pScDocShell ? &pScDocShell->GetDocFunc() : NULL; diff --git a/sc/source/ui/inc/sccollaboration.hxx b/sc/source/ui/inc/sccollaboration.hxx index 545db92..41b2c58 100644 --- a/sc/source/ui/inc/sccollaboration.hxx +++ b/sc/source/ui/inc/sccollaboration.hxx @@ -19,11 +19,12 @@ public: ScCollaboration(); virtual ~ScCollaboration(); - virtual TeleConference* GetConference() const; + virtual TeleConference* GetConference(); + virtual sal_uInt64 GetId(); virtual void SetCollaboration( TeleConference* pConference ); virtual void SendFile( TpContact* pContact, const OUString& rURL ); private: - ScDocFuncSend* GetScDocFuncSend() const; + ScDocFuncSend* GetScDocFuncSend(); }; #endif // INCLUDED_SC_COLLABORATION_HXX diff --git a/tubes/inc/tubes/collaboration.hxx b/tubes/inc/tubes/collaboration.hxx index 5a3dddc..31eff7a 100644 --- a/tubes/inc/tubes/collaboration.hxx +++ b/tubes/inc/tubes/collaboration.hxx @@ -23,7 +23,8 @@ public: Collaboration() {} virtual ~Collaboration() {} - virtual TeleConference* GetConference() const = 0; + virtual TeleConference* GetConference() = 0; + virtual sal_uInt64 GetId() = 0; virtual void SetCollaboration( TeleConference* pConference ) = 0; // TODO: I think this could be moved to TeleManager later. virtual void SendFile( TpContact* pContact, const OUString& rURL ) = 0; diff --git a/tubes/source/contacts.cxx b/tubes/source/contacts.cxx index 540e8a6..9245b55 100644 --- a/tubes/source/contacts.cxx +++ b/tubes/source/contacts.cxx @@ -42,10 +42,13 @@ #include <vcl/dialog.hxx> #include <vcl/unohelp.hxx> +#include <map> #include <vector> #include <boost/ptr_container/ptr_vector.hpp> #include <telepathy-glib/telepathy-glib.h> +namespace { + ResId TubesResId( sal_uInt32 nId ) { static ResMgr* pResMgr = NULL; @@ -56,7 +59,6 @@ ResId TubesResId( sal_uInt32 nId ) return ResId( nId, *pResMgr ); } -namespace { class TubeContacts : public ModelessDialog { FixedLine maLabel; @@ -261,12 +263,22 @@ IMPL_LINK_NOARG( TubeContacts, BtnListenHdl ) return 0; } +TubeContacts* ContactsFactory( Collaboration* pCollaboration ) +{ + // Mapping contacts dialog instance for each document + static std::map< sal_uInt64, TubeContacts* > aDialogsMap; + sal_uInt64 Id = pCollaboration->GetId(); + if (aDialogsMap.find( Id ) == aDialogsMap.end()) + aDialogsMap[ Id ] = new TubeContacts( pCollaboration ); + return aDialogsMap[ Id ]; +} + } // anonymous namespace namespace tubes { void createContacts( Collaboration* pCollaboration ) { - static TubeContacts *pContacts = new TubeContacts( pCollaboration ); + TubeContacts* pContacts = ContactsFactory( pCollaboration ); pContacts->Populate(); } } commit f2c7d7aea4ec8c1f9f38e1d00c14dadca67b863e Author: Matúš Kukan <matus.ku...@gmail.com> Date: Fri Aug 3 13:29:47 2012 +0200 tubes: remove pointless define Change-Id: I5ef7f8a5a37d0a77a9dadc44e1e895581c2ebb50 diff --git a/tubes/source/contacts.cxx b/tubes/source/contacts.cxx index 046be97..540e8a6 100644 --- a/tubes/source/contacts.cxx +++ b/tubes/source/contacts.cxx @@ -56,9 +56,6 @@ ResId TubesResId( sal_uInt32 nId ) return ResId( nId, *pResMgr ); } -#define CONTACTS_DLG - -#ifdef CONTACTS_DLG namespace { class TubeContacts : public ModelessDialog { @@ -265,15 +262,12 @@ IMPL_LINK_NOARG( TubeContacts, BtnListenHdl ) } } // anonymous namespace -#endif namespace tubes { void createContacts( Collaboration* pCollaboration ) { -#ifdef CONTACTS_DLG static TubeContacts *pContacts = new TubeContacts( pCollaboration ); pContacts->Populate(); -#endif } } commit 3ef03fbf80760a1d21df5cfb410e94162f121914 Author: Matúš Kukan <matus.ku...@gmail.com> Date: Fri Aug 3 11:44:57 2012 +0200 tubes: make TeleManager::getConference() static Change-Id: Ic7023a40eb2f09802b100d9317c0a6a66d901476 diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx index 1a1203d..d52f8b0 100644 --- a/sc/source/ui/collab/sendfunc.cxx +++ b/sc/source/ui/collab/sendfunc.cxx @@ -356,9 +356,7 @@ ScDocFunc *ScDocShell::CreateDocFunc() ScDocFuncDirect *pDirect = new ScDocFuncDirect( *this ); ScDocFuncRecv *pReceiver = new ScDocFuncRecv( pDirect ); ScDocFuncSend *pSender = new ScDocFuncSend( *this, pReceiver ); - TeleManager *pManager = new TeleManager(); - pSender->SetCollaboration( pManager->getConference() ); - delete pManager; + pSender->SetCollaboration( TeleManager::getConference() ); return pSender; } else diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx index b5a68b2..8f7afa6 100644 --- a/tubes/inc/tubes/manager.hxx +++ b/tubes/inc/tubes/manager.hxx @@ -123,7 +123,7 @@ public: TUBES_DLLPUBLIC TeleConference* startBuddySession( TpAccount *pAccount, TpContact *pBuddy ); /** Get a conference with current UUID to set a session. */ - TUBES_DLLPUBLIC TeleConference* getConference(); + TUBES_DLLPUBLIC static TeleConference* getConference(); /** True if there has been tube channel received and is still not used. */ TUBES_DLLPUBLIC static bool hasWaitingConference(); diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx index 40754a4..7722844 100644 --- a/tubes/source/manager.cxx +++ b/tubes/source/manager.cxx @@ -165,7 +165,7 @@ void TeleManager::addConference( TeleConference* pConference ) TeleConference* TeleManager::getConference() { - TeleManagerImpl::MapStringConference::iterator it = + TeleManagerImpl::MapStringConference::const_iterator it = pImpl->maAcceptedConferences.find( pImpl->msCurrentUUID ); TeleConference* pConference = NULL; if (it != pImpl->maAcceptedConferences.end())
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits