[Libreoffice-commits] .: Branch 'feature/tubes2' - 5 commits - sc/source tubes/inc

Matus Kukan mkukan at kemper.freedesktop.org
Fri Jun 29 10:38:36 PDT 2012


 sc/source/ui/collab/contacts.cxx |   29 +++++++++++++++++++++--------
 sc/source/ui/collab/contacts.hxx |    2 +-
 sc/source/ui/collab/sendfunc.cxx |    6 +-----
 sc/source/ui/collab/sendfunc.hxx |    1 -
 sc/source/ui/view/cellsh3.cxx    |    4 ++--
 tubes/inc/tubes/manager.hxx      |    1 +
 6 files changed, 26 insertions(+), 17 deletions(-)

New commits:
commit 9fb21707db92e051493a3e959308a37112d32ffe
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Fri Jun 29 19:30:46 2012 +0200

    tubes: fallback to master mode when not possible to init TeleManager as slave

diff --git a/sc/source/ui/collab/contacts.cxx b/sc/source/ui/collab/contacts.cxx
index 7ef5ab0..0c70585 100644
--- a/sc/source/ui/collab/contacts.cxx
+++ b/sc/source/ui/collab/contacts.cxx
@@ -76,7 +76,18 @@ class TubeContacts : public ModelessDialog
             pSender = new ScDocFuncSend( *pScDocShell, pReceiver );
             pDocFunc = pSender;
         }
-        pSender->InitTeleManager( false );
+        // This is a hack to work around:
+        //  `error registering client handler: Name
+        //  'org.freedesktop.Telepathy.Client.LibreOffice' already in use by another process`
+        // This happens when there is already slave instance running,
+        // so we try to init TeleManager as master.
+        bool bIsMaster = false;
+        if (!pSender->InitTeleManager( bIsMaster ))
+        {
+            fprintf( stderr, "Trying to initialize TeleManager as master..\n" );
+            bIsMaster = true;
+            pSender->InitTeleManager( bIsMaster );
+        }
     }
 
     void StartBuddySession()
commit 26ff9e3b06efcefb1b9cda2b41378fcb23a01ece
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Fri Jun 29 19:17:59 2012 +0200

    tubes: unref TeleManager if we do not store the pointer

diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index f58fd6a..9ab6e78 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -302,6 +302,7 @@ bool ScDocFuncSend::InitTeleManager( bool bIsMaster )
         return true;
     }
     fprintf( stderr, "Could not connect.\n" );
+    pManager->unref();
     return false;
 }
 
commit c81e93931f42567f4e662804129d97b6e0cfa0d7
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Fri Jun 29 19:15:40 2012 +0200

    tubes: use new TeleManager::get() method without parameter

diff --git a/sc/source/ui/collab/contacts.cxx b/sc/source/ui/collab/contacts.cxx
index bd6e6d4..7ef5ab0 100644
--- a/sc/source/ui/collab/contacts.cxx
+++ b/sc/source/ui/collab/contacts.cxx
@@ -132,9 +132,11 @@ public:
                                        RTL_TEXTENCODING_UTF8 );
     }
 
-    void Populate( const TeleManager &rManager )
+    void Populate( const TeleManager *pManager )
     {
-        ContactList *pContacts = rManager.getContactList();
+        if (!pManager)
+            return ;
+        ContactList *pContacts = pManager->getContactList();
         if ( pContacts )
         {
             fprintf( stderr, "contacts !\n" );
@@ -193,11 +195,11 @@ IMPL_LINK_NOARG( TubeContacts, BtnListenHdl )
 #endif
 
 namespace tubes {
-void createContacts( const TeleManager &rManager )
+void createContacts( const TeleManager *pManager )
 {
 #ifdef CONTACTS_DLG
     TubeContacts *pContacts = new TubeContacts();
-    pContacts->Populate( rManager );
+    pContacts->Populate( pManager );
 #endif
 }
 }
diff --git a/sc/source/ui/collab/contacts.hxx b/sc/source/ui/collab/contacts.hxx
index f7ff6a9..404a6fc 100644
--- a/sc/source/ui/collab/contacts.hxx
+++ b/sc/source/ui/collab/contacts.hxx
@@ -30,7 +30,7 @@
 
 class TeleManager;
 namespace tubes {
-    void createContacts( const TeleManager &rContacts );
+    void createContacts( const TeleManager *pManager );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index 6d3fcf3..e10d5b5 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -60,7 +60,7 @@
 #ifdef ENABLE_TELEPATHY
 #include <tubes/manager.hxx>
 namespace tubes {
-    void createContacts( const TeleManager &rContacts );
+    void createContacts( const TeleManager *pManager );
 }
 #endif
 
@@ -125,7 +125,7 @@ void ScCellShell::Execute( SfxRequest& rReq )
 
         case SID_COLLABORATION:
 #ifdef ENABLE_TELEPATHY
-            tubes::createContacts( TeleManager::get( true ) );
+            tubes::createContacts( TeleManager::get() );
 #endif
             break;
 
diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index 1aba675..c780fd2 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -82,6 +82,7 @@ public:
     TeleManager( bool bAcceptIncoming = true, bool bCreateOwnGMainLoop = false );
     ~TeleManager();
 
+    static TeleManager     *get() { return pSingleton; }
     static TeleManager     *get( bool bAcceptIncoming );
     void                    unref();
 
commit 352c5e358dba7cd575c5579698b2fff348612926
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Fri Jun 29 19:00:16 2012 +0200

    tubes: remove unused SetCollaboration method

diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index 262273d..f58fd6a 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -282,11 +282,6 @@ ScDocFuncSend::ScDocFuncSend( ScDocShell& rDocSh, boost::shared_ptr<ScDocFuncRec
     fprintf( stderr, "Sender created !\n" );
 }
 
-void ScDocFuncSend::SetCollaboration( TeleManager *pManager )
-{
-    mpManager = pManager;
-}
-
 bool ScDocFuncSend::InitTeleManager( bool bIsMaster )
 {
     if (mpManager)
diff --git a/sc/source/ui/collab/sendfunc.hxx b/sc/source/ui/collab/sendfunc.hxx
index dcb30aa..99fde98 100644
--- a/sc/source/ui/collab/sendfunc.hxx
+++ b/sc/source/ui/collab/sendfunc.hxx
@@ -237,7 +237,6 @@ public:
     ScDocFuncSend( ScDocShell& rDocSh, boost::shared_ptr<ScDocFuncRecv> pDirect );
     virtual ~ScDocFuncSend() {}
 
-    void                SetCollaboration( TeleManager *pManager );
     bool                InitTeleManager( bool bIsMaster );
 
     virtual void        EnterListAction( sal_uInt16 nNameResId );
commit d6b287f158cf49909f7f6ee3d4385c26161eaa6f
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Fri Jun 29 18:58:37 2012 +0200

    tubes: use correct casts

diff --git a/sc/source/ui/collab/contacts.cxx b/sc/source/ui/collab/contacts.cxx
index 085237b..bd6e6d4 100644
--- a/sc/source/ui/collab/contacts.cxx
+++ b/sc/source/ui/collab/contacts.cxx
@@ -65,9 +65,9 @@ class TubeContacts : public ModelessDialog
 
     void Listen()
     {
-        ScDocShell *pScDocShell = reinterpret_cast<ScDocShell*> (SfxObjectShell::Current());
+        ScDocShell *pScDocShell = dynamic_cast<ScDocShell*> (SfxObjectShell::Current());
         ScDocFunc *pDocFunc = pScDocShell ? &pScDocShell->GetDocFunc() : NULL;
-        ScDocFuncSend *pSender = reinterpret_cast<ScDocFuncSend*> (pDocFunc);
+        ScDocFuncSend *pSender = dynamic_cast<ScDocFuncSend*> (pDocFunc);
         if (!pSender)
         {
             delete pDocFunc;
@@ -83,7 +83,7 @@ class TubeContacts : public ModelessDialog
     {
         AccountContact *pAC = NULL;
         if (maList.FirstSelected())
-            pAC = reinterpret_cast<AccountContact*> (maList.FirstSelected()->GetUserData());
+            pAC = static_cast<AccountContact*> (maList.FirstSelected()->GetUserData());
         if (pAC)
         {
             TpAccount* pAccount = pAC->mpAccount;


More information about the Libreoffice-commits mailing list