[Libreoffice-commits] .: 3 commits - desktop/inc desktop/Library_sofficeapp.mk desktop/source sc/source tubes/inc tubes/source

Matus Kukan mkukan at kemper.freedesktop.org
Tue Jul 24 04:54:51 PDT 2012


 desktop/Library_sofficeapp.mk    |    8 +++
 desktop/inc/app.hxx              |    6 ++
 desktop/source/app/app.cxx       |   13 +++++
 sc/source/ui/collab/contacts.cxx |   89 +++++++++++++++++----------------------
 sc/source/ui/collab/sendfunc.cxx |    9 +--
 sc/source/ui/collab/sendfunc.hxx |    1 
 tubes/inc/tubes/manager.hxx      |    1 
 tubes/source/manager.cxx         |   17 +++++++
 8 files changed, 87 insertions(+), 57 deletions(-)

New commits:
commit da5220d7d2707dd87e3f322141edc5f3ccbe1df4
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Tue Jul 24 13:46:17 2012 +0200

    tubes: fix crash: do not delete boost::shared_ptr's pointer
    
    This prevents a crash on exit for INTERCEPT=demo but there is another:
    Open more calc documents, close one, and then type something -> crash.
    I wonder if this was working in the past.
    
    Change-Id: I599b1babb02488d317c6684aba7431b5de7af15b

diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index a0bd1f2..a366956 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -205,7 +205,9 @@ ScDocFuncSend::~ScDocFuncSend()
     fprintf( stderr, "Sender destroyed !\n" );
     if (mpConference)
         mpConference->close();
-    delete mpDirect;
+
+    if (!dynamic_cast<ScDocFuncDemo*> (mpDirect))
+        delete mpDirect;
 }
 
 void ScDocFuncSend::SetCollaboration( TeleConference* pConference )
commit bbeb2ea423d106fd4e7f35fedc4ba9bf58362ab5
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Tue Jul 24 10:24:03 2012 +0200

    tubes: remove unused method
    
    Change-Id: I8657786fe64753a2e2a57febd1d56b39f83dec33

diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index 190f8b1..a0bd1f2 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -221,11 +221,6 @@ TeleConference* ScDocFuncSend::GetConference()
     return mpConference;
 }
 
-ScDocFuncRecv* ScDocFuncSend::GetReceiver()
-{
-    return mpDirect;
-}
-
 void ScDocFuncSend::EnterListAction( sal_uInt16 nNameResId )
 {
     // Want to group these operations for the other side ...
diff --git a/sc/source/ui/collab/sendfunc.hxx b/sc/source/ui/collab/sendfunc.hxx
index c6ca2f4..7299983 100644
--- a/sc/source/ui/collab/sendfunc.hxx
+++ b/sc/source/ui/collab/sendfunc.hxx
@@ -235,7 +235,6 @@ public:
 
     void                SetCollaboration( TeleConference* pConference );
     TeleConference*     GetConference();
-    ScDocFuncRecv*      GetReceiver();
     // TODO: I think this could be moved to TeleManager later.
     void                SendFile( const rtl::OUString &rURL );
 
commit b12954531953fb8ad585847fe42677d714991ef1
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Fri Jul 20 21:31:30 2012 +0200

    tubes: init TeleManager in desktop
    
    - register clients when we run --invisible
    - create ScDocFuncSend only if we are going to use it
    
    Change-Id: I7e33cd5a2e42e34a055146dc6c2bdac3657d6529

diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index 9495883..607d751 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -88,6 +88,14 @@ $(eval $(call gb_Library_add_exception_objects,sofficeapp,\
     desktop/source/migration/migration \
 ))
 
+ifeq ($(ENABLE_TELEPATHY),TRUE)
+$(eval $(call gb_Library_use_libraries,sofficeapp,tubes))
+
+$(eval $(call gb_Library_add_defs,sofficeapp,\
+    -DENABLE_TELEPATHY \
+))
+endif
+
 #
 # We need the lo_main symbol for our boostrap loader
 #
diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx
index 06dc4c7..09f0a4d 100644
--- a/desktop/inc/app.hxx
+++ b/desktop/inc/app.hxx
@@ -41,6 +41,9 @@
 #include <com/sun/star/task/XStatusIndicator.hpp>
 #include <com/sun/star/uno/Reference.h>
 #include <osl/mutex.hxx>
+#ifdef ENABLE_TELEPATHY
+#include <tubes/manager.hxx>
+#endif
 
 using namespace com::sun::star::task;
 using namespace com::sun::star::uno;
@@ -205,6 +208,9 @@ class Desktop : public Application
         sal_uInt16                          m_nAppEvents;
         BootstrapError                  m_aBootstrapError;
         BootstrapStatus                 m_aBootstrapStatus;
+#ifdef ENABLE_TELEPATHY
+        TeleManager*                    m_pTeleManager;
+#endif
 
         std::auto_ptr< Lockfile > m_pLockfile;
         Timer    m_firstRunTimer;
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 3ee805b..65dd453 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -614,12 +614,19 @@ throw()
 Desktop::Desktop()
 : m_bServicesRegistered( false )
 , m_aBootstrapError( BE_OK )
+#ifdef ENABLE_TELEPATHY
+, m_pTeleManager( NULL )
+#endif
 {
     RTL_LOGFILE_TRACE( "desktop (cd100003) ::Desktop::Desktop" );
 }
 
 Desktop::~Desktop()
 {
+#ifdef ENABLE_TELEPATHY
+    if (m_pTeleManager)
+        m_pTeleManager->unref();
+#endif
 }
 
 void Desktop::Init()
@@ -1700,6 +1707,12 @@ int Desktop::Main()
     aOptions.SetVCLSettings();
     SetSplashScreenProgress(60);
 
+#ifdef ENABLE_TELEPATHY
+    m_pTeleManager = TeleManager::get();
+    bool bListen = rCmdLineArgs.IsInvisible();
+    m_pTeleManager->init( bListen );
+#endif
+
     if ( !pExecGlobals->bRestartRequested )
     {
         Application::SetFilterHdl( LINK( this, Desktop, ImplInitFilterHdl ) );
diff --git a/sc/source/ui/collab/contacts.cxx b/sc/source/ui/collab/contacts.cxx
index 84f73e1..5ade483 100644
--- a/sc/source/ui/collab/contacts.cxx
+++ b/sc/source/ui/collab/contacts.cxx
@@ -55,7 +55,6 @@ class TubeContacts : public ModelessDialog
     SvxSimpleTableContainer maListContainer;
     SvxSimpleTable          maList;
     TeleManager*            mpManager;
-    ScDocFuncSend*          mpSender;
 
     DECL_LINK( BtnConnectHdl, void * );
     DECL_LINK( BtnGroupHdl, void * );
@@ -71,35 +70,53 @@ class TubeContacts : public ModelessDialog
     };
     boost::ptr_vector<AccountContact> maACs;
 
+    ScDocFuncSend* GetScDocFuncSendInCurrentSfxObjectShell()
+    {
+        ScDocShell *pScDocShell = dynamic_cast<ScDocShell*> (SfxObjectShell::Current());
+        ScDocFunc *pDocFunc = pScDocShell ? &pScDocShell->GetDocFunc() : NULL;
+        return dynamic_cast<ScDocFuncSend*> (pDocFunc);
+    }
+
+    ScDocFuncSend* EnsureScDocFuncSendInCurrentSfxObjectShell()
+    {
+        ScDocShell *pScDocShell = dynamic_cast<ScDocShell*> (SfxObjectShell::Current());
+        ScDocFunc *pDocFunc = pScDocShell ? &pScDocShell->GetDocFunc() : NULL;
+        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 );
+        }
+        return pSender;
+    }
+
     void Invite()
     {
         AccountContact *pAC = NULL;
         if (maList.FirstSelected())
             pAC = static_cast<AccountContact*> (maList.FirstSelected()->GetUserData());
-        if (pAC && mpSender->GetConference())
+        if (pAC)
         {
-            TpContact* pContact = pAC->mpContact;
-            fprintf( stderr, "inviting %s\n", tp_contact_get_identifier( pContact ) );
-            mpSender->GetConference()->invite( pContact );
+            ScDocFuncSend *pSender = GetScDocFuncSendInCurrentSfxObjectShell();
+            if (pSender && pSender->GetConference())
+            {
+                TpContact* pContact = pAC->mpContact;
+                pSender->GetConference()->invite( pContact );
+            }
         }
     }
 
     void Listen()
     {
-        if (!mpManager)
-            return ;
-
         if (!mpManager->registerClients())
-        {
-            fprintf( stderr, "Could not register client handlers.\n" );
-        }
+            SAL_INFO( "sc.tubes", "Could not register client handlers." );
     }
 
     void StartBuddySession()
     {
-        if (!mpManager)
-            return ;
-
         AccountContact *pAC = NULL;
         if (maList.FirstSelected())
             pAC = static_cast<AccountContact*> (maList.FirstSelected()->GetUserData());
@@ -114,8 +131,9 @@ class TubeContacts : public ModelessDialog
                         tp_contact_get_identifier( pContact ) );
             else
             {
-                mpSender->SetCollaboration( pConference );
-                mpSender->SendFile( OStringToOUString(
+                ScDocFuncSend* pSender = EnsureScDocFuncSendInCurrentSfxObjectShell();
+                pSender->SetCollaboration( pConference );
+                pSender->SendFile( OStringToOUString(
                             pConference->getUuid(), RTL_TEXTENCODING_UTF8 ) );
             }
         }
@@ -123,9 +141,6 @@ class TubeContacts : public ModelessDialog
 
     void StartGroupSession()
     {
-        if (!mpManager)
-            return ;
-
         AccountContact *pAC = NULL;
         if (maList.FirstSelected())
             pAC = static_cast<AccountContact*> (maList.FirstSelected()->GetUserData());
@@ -138,7 +153,10 @@ class TubeContacts : public ModelessDialog
             if (!pConference)
                 fprintf( stderr, "could not start group session\n" );
             else
-                mpSender->SetCollaboration( pConference );
+            {
+                ScDocFuncSend* pSender = EnsureScDocFuncSendInCurrentSfxObjectShell();
+                pSender->SetCollaboration( pConference );
+            }
         }
     }
 
@@ -155,32 +173,6 @@ public:
         mpManager( TeleManager::get() )
     {
         Hide();
-        ScDocShell *pScDocShell = dynamic_cast<ScDocShell*> (SfxObjectShell::Current());
-        ScDocFunc *pDocFunc = pScDocShell ? &pScDocShell->GetDocFunc() : NULL;
-        mpSender = dynamic_cast<ScDocFuncSend*> (pDocFunc);
-        if (!mpSender)
-        {
-            // This means pDocFunc has to be ScDocFuncDirect* and we are not collaborating yet.
-            ScDocFuncDirect *pDirect = dynamic_cast<ScDocFuncDirect*> (pDocFunc);
-            ScDocFuncRecv *pReceiver = new ScDocFuncRecv( pDirect );
-            mpSender = new ScDocFuncSend( *pScDocShell, pReceiver );
-            pScDocShell->SetDocFunc( mpSender );
-
-            // FIXME: Who should really own TeleManager and where it can be destroyed ?
-            // Take reference, so TeleManager does not get destroyed after closing dialog:
-            mpManager = TeleManager::get();
-
-            if (mpManager->createAccountManager())
-            {
-                mpManager->prepareAccountManager();
-            }
-            else
-            {
-                fprintf( stderr, "Could not create AccountManager.\n" );
-                mpManager->unref();
-                mpManager = NULL;
-            }
-        }
         maBtnConnect.SetClickHdl( LINK( this, TubeContacts, BtnConnectHdl ) );
         maBtnGroup.SetClickHdl( LINK( this, TubeContacts, BtnGroupHdl ) );
         maBtnInvite.SetClickHdl( LINK( this, TubeContacts, BtnInviteHdl ) );
@@ -201,8 +193,7 @@ public:
     }
     virtual ~TubeContacts()
     {
-        if (mpManager)
-            mpManager->unref();
+        mpManager->unref();
     }
 
     static rtl::OUString fromUTF8( const char *pStr )
@@ -213,8 +204,6 @@ public:
 
     void Populate()
     {
-        if (!mpManager)
-            return ;
         ContactList *pContacts = mpManager->getContactList();
         if ( pContacts )
         {
diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index a112b61..a47a566 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -81,6 +81,7 @@ public:
 
     TUBES_DLLPUBLIC static TeleManager*     get();
     TUBES_DLLPUBLIC void                    unref();
+    TUBES_DLLPUBLIC bool                    init( bool bListen );
 
     /** Connect to DBus and create AccountManager. */
     TUBES_DLLPUBLIC bool                    createAccountManager();
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index d16422d..eeccbe9 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -420,6 +420,7 @@ TeleManager *
 TeleManager::get()
 {
     MutexGuard aGuard( GetAnotherMutex());
+    SAL_INFO( "tubes", "TeleManager::get: count: " << nAnotherRefCount );
     if (!pSingleton)
         pSingleton = new TeleManager();
 
@@ -435,8 +436,24 @@ TeleManager::unref()
         delete pSingleton;
         pSingleton = NULL;
     }
+    SAL_INFO( "tubes", "TeleManager::unref: count: " << nAnotherRefCount );
 }
 
+bool TeleManager::init( bool bListen )
+{
+    if (createAccountManager())
+    {
+        prepareAccountManager();
+        if (bListen && !registerClients())
+            SAL_WARN( "tubes", "TeleManager::init: Could not register client handlers." );
+
+        return true;
+    }
+    else
+        SAL_WARN( "tubes", "TeleManager::init: Could not create AccountManager." );
+
+    return false;
+}
 
 bool TeleManager::createAccountManager()
 {


More information about the Libreoffice-commits mailing list