[Libreoffice-commits] .: 6 commits - desktop/inc desktop/source Makefile Makefile.top sc/source tubes/inc tubes/qa tubes/source

Matus Kukan mkukan at kemper.freedesktop.org
Thu Jul 26 06:59:56 PDT 2012


 Makefile                         |    6 +-
 Makefile.top                     |   10 ---
 desktop/inc/app.hxx              |    3 -
 desktop/source/app/app.cxx       |    9 ++-
 sc/source/ui/collab/contacts.cxx |    4 -
 sc/source/ui/collab/sendfunc.cxx |    4 -
 tubes/inc/tubes/manager.hxx      |   41 ++-------------
 tubes/qa/test_manager.cxx        |    5 -
 tubes/source/manager.cxx         |  105 +++++++++------------------------------
 9 files changed, 52 insertions(+), 135 deletions(-)

New commits:
commit a236141e4aec1046dab191abcdea226522127242
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Thu Jul 26 15:49:10 2012 +0200

    move help target to Makefile; it doesn't need config_host.mk
    
    Change-Id: Ib627bb0a12b5b055f8d6077c00cc8099473fa176

diff --git a/Makefile b/Makefile
index 8b27545..4d97e71 100644
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@ SRCDIR:=$(patsubst %/,%,$(dir $(realpath $(firstword $(MAKEFILE_LIST)))))
 .PHONY : $(filter-out $(SRCDIR)/config_host.mk,$(MAKECMDGOALS))
 
 # recursively invoke Makefile.top, which includes config_host.mk
-$(firstword $(MAKECMDGOALS)) : $(SRCDIR)/config_host.mk
+$(filter-out help,$(firstword $(MAKECMDGOALS))) : $(SRCDIR)/config_host.mk
 	$(MAKE) -r -f $(SRCDIR)/Makefile.top $(MAKECMDGOALS)
 
 # run configure in an environment not polluted by config_host.mk
@@ -34,4 +34,8 @@ $(SRCDIR)/config_host.mk : \
 $(SRCDIR)/autogen.lastrun:
 	@true
 
+help:
+	@cat $(SRCDIR)/solenv/gbuild/gbuild.help.txt
+	@true
+
 # vim: set noet sw=4 ts=4:
diff --git a/Makefile.top b/Makefile.top
index 11468c5..4aaf832 100644
--- a/Makefile.top
+++ b/Makefile.top
@@ -527,14 +527,4 @@ debugrun:
 
 endif # not clean or distclean
 
-
-#########################
-# help
-#
-.PHONY: help
-help:
-	@cat $(SRCDIR)/solenv/gbuild/gbuild.help.txt
-	@true
-
-
 # vim: set noet sw=4 ts=4:
commit 7f77377850537194ea634f0d2c81e8cc5cb90a1b
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Thu Jul 26 12:56:19 2012 +0200

    tubes: clean this out
    
    Change-Id: I7d4cafbe51695c0ff36480311858b9167344c119

diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index 9938f6f..b5a68b2 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -30,13 +30,8 @@
 #define INCLUDED_TUBES_MANAGER_HXX
 
 #include <sal/config.h>
-#include "tubes/tubesdllapi.h"
-#include "tubes/conference.hxx"
-#include "tubes/contact-list.hxx"
+#include <tubes/tubesdllapi.h>
 #include <rtl/ustring.hxx>
-#include <salhelper/thread.hxx>
-#include <rtl/ref.hxx>
-#include <tools/link.hxx>
 
 // For testing purposes, we might need more in future.
 #define LIBO_TUBES_DBUS_INTERFACE "org.libreoffice.calc"
@@ -44,11 +39,11 @@
 #define LIBO_TUBES_DBUS_PATH "/org/libreoffice/calc"
 
 namespace osl { class Mutex; }
+class ContactList;
+class TeleConference;
 class TeleManagerImpl;
 typedef struct _TpAccount TpAccount;
 typedef struct _TpContact TpContact;
-typedef struct _GMainLoop GMainLoop;
-typedef struct _GMainContext GMainContext;
 
 /** Interface to Telepathy DBus Tubes.
 
@@ -193,8 +188,6 @@ private:
     static sal_uInt32       nRefCount;
     static rtl::OString     aNameSuffix;
 
-    friend class TeleManagerImpl;   // access to mutex
-
     static ::osl::Mutex&    GetMutex();
 };
 
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index 9fe6d4f..9df5468 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -26,9 +26,11 @@
  * instead of those above.
  */
 
-#include "tubes/manager.hxx"
-#include "tubes/constants.h"
-#include "tubes/file-transfer-helper.h"
+#include <tubes/manager.hxx>
+#include <tubes/conference.hxx>
+#include <tubes/constants.h>
+#include <tubes/contact-list.hxx>
+#include <tubes/file-transfer-helper.h>
 
 #include <com/sun/star/uno/Sequence.hxx>
 #include <com/sun/star/frame/XComponentLoader.hpp>
commit b70c2d352ddb6350ec366b055b28b3d892b54b1c
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Thu Jul 26 12:17:09 2012 +0200

    tubes: avoid unnecessary re-building; move the include into source file
    
    Change-Id: Ib45a5fab8d4dc118ac0ae5282d47f46f9f86edc2

diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx
index 09f0a4d..c31b953 100644
--- a/desktop/inc/app.hxx
+++ b/desktop/inc/app.hxx
@@ -41,8 +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>
+class TeleManager;
 #endif
 
 using namespace com::sun::star::task;
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 6d5ea30..4e76579 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -102,6 +102,10 @@
 
 #include "langselect.hxx"
 
+#ifdef ENABLE_TELEPATHY
+#include <tubes/manager.hxx>
+#endif
+
 #if defined MACOSX
 #include <errno.h>
 #include <sys/wait.h>
commit f86cc45d8795073e61d39edc469a4876085941b8
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Thu Jul 26 12:12:42 2012 +0200

    tubes: move mbChannelReadyHandlerInvoked to pImpl
    
    Change-Id: If2ddd8bdcb11727be719e8966aa689fbabd94f44

diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index 163b58e..9938f6f 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -141,8 +141,8 @@ public:
 
     // Only for callbacks.
     void                    addConference( TeleConference* pConference );
-    void                    setChannelReadyHandlerInvoked( bool b ) { mbChannelReadyHandlerInvoked = b; }
-    bool                    isChannelReadyHandlerInvoked() const { return mbChannelReadyHandlerInvoked; }
+    void                    setChannelReadyHandlerInvoked( bool b );
+    bool                    isChannelReadyHandlerInvoked() const;
     void                    setAccountManagerReadyHandlerInvoked( bool b );
     bool                    isAccountManagerReadyHandlerInvoked() const;
 
@@ -189,8 +189,6 @@ public:
 private:
     void                    ensureLegacyChannel( TpAccount* pAccount, TpContact* pBuddy );
 
-    bool                    mbChannelReadyHandlerInvoked : 1;
-
     static TeleManagerImpl* pImpl;
     static sal_uInt32       nRefCount;
     static rtl::OString     aNameSuffix;
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index cfff455..9fe6d4f 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -90,7 +90,8 @@ public:
     TpBaseClient*                       mpFileTransferClient;
     TpAccountManager*                   mpAccountManager;
     TeleManager::AccountManagerStatus   meAccountManagerStatus;
-    bool                                mbAccountManagerReadyHandlerInvoked;
+    bool                                mbAccountManagerReadyHandlerInvoked : 1;
+    bool                                mbChannelReadyHandlerInvoked : 1;
     ContactList*                        mpContactList;
     OString                             msCurrentUUID;
     typedef std::map< OString, TeleConference* > MapStringConference;
@@ -383,8 +384,6 @@ static void TeleManager_AccountManagerReadyHandler(
 
 
 TeleManager::TeleManager()
-    :
-        mbChannelReadyHandlerInvoked( false)
 {
     SAL_INFO( "tubes", "TeleManager::get: count: " << nRefCount );
     // The glib object types need to be initialized, else we aren't going
@@ -734,12 +733,21 @@ void TeleManager::setAccountManagerReadyHandlerInvoked( bool b )
     pImpl->mbAccountManagerReadyHandlerInvoked = b;
 }
 
-
 bool TeleManager::isAccountManagerReadyHandlerInvoked() const
 {
     return pImpl->mbAccountManagerReadyHandlerInvoked;
 }
 
+void TeleManager::setChannelReadyHandlerInvoked( bool b )
+{
+    pImpl->mbChannelReadyHandlerInvoked = b;
+}
+
+bool TeleManager::isChannelReadyHandlerInvoked() const
+{
+    return pImpl->mbChannelReadyHandlerInvoked;
+}
+
 ContactList* TeleManager::getContactList() const
 {
     return pImpl->mpContactList;
@@ -902,7 +910,8 @@ TeleManagerImpl::TeleManagerImpl()
         mpFileTransferClient( NULL),
         mpAccountManager( NULL),
         meAccountManagerStatus( TeleManager::AMS_UNINITIALIZED),
-        mbAccountManagerReadyHandlerInvoked( false)
+        mbAccountManagerReadyHandlerInvoked( false),
+        mbChannelReadyHandlerInvoked( false)
 {
 }
 
commit bb9399e2cf0072d1de7cb0aea162d107ebde4360
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Thu Jul 26 11:55:39 2012 +0200

    tubes: kill double-singletonning of TeleManager
    
    I am not sure why it was introduced in
    0dae49a03c9b4816d8cdde69e30bcd2db2e30724
    and hope that it's safe to remove it now.
    
    Change-Id: I62f0ac230a83473386eabc45c9fcc387f62631e3

diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 8582af5..6d5ea30 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -624,8 +624,7 @@ Desktop::Desktop()
 Desktop::~Desktop()
 {
 #ifdef ENABLE_TELEPATHY
-    if (m_pTeleManager)
-        m_pTeleManager->unref();
+    delete m_pTeleManager;
 #endif
 }
 
@@ -1708,7 +1707,7 @@ int Desktop::Main()
     SetSplashScreenProgress(60);
 
 #ifdef ENABLE_TELEPATHY
-    m_pTeleManager = TeleManager::get();
+    m_pTeleManager = new TeleManager();
     bool bListen = rCmdLineArgs.IsInvisible();
     m_pTeleManager->init( bListen );
 #endif
diff --git a/sc/source/ui/collab/contacts.cxx b/sc/source/ui/collab/contacts.cxx
index 80cb756..8529b3d 100644
--- a/sc/source/ui/collab/contacts.cxx
+++ b/sc/source/ui/collab/contacts.cxx
@@ -170,7 +170,7 @@ public:
         maBtnListen( this, ScResId( BTN_LISTEN ) ),
         maListContainer( this, ScResId( CTL_LIST ) ),
         maList( maListContainer ),
-        mpManager( TeleManager::get() )
+        mpManager( new TeleManager() )
     {
         Hide();
         maBtnConnect.SetClickHdl( LINK( this, TubeContacts, BtnConnectHdl ) );
@@ -196,7 +196,7 @@ public:
     }
     virtual ~TubeContacts()
     {
-        mpManager->unref();
+        delete mpManager;
     }
 
     static rtl::OUString fromUTF8( const char *pStr )
diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index a366956..b78d34c 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -355,9 +355,9 @@ ScDocFunc *ScDocShell::CreateDocFunc()
         ScDocFuncDirect *pDirect = new ScDocFuncDirect( *this );
         ScDocFuncRecv *pReceiver = new ScDocFuncRecv( pDirect );
         ScDocFuncSend *pSender = new ScDocFuncSend( *this, pReceiver );
-        TeleManager *pManager = TeleManager::get();
+        TeleManager *pManager = new TeleManager();
         pSender->SetCollaboration( pManager->getConference() );
-        pManager->unref();
+        delete pManager;
         return pSender;
     }
     else
diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index 0e96826..163b58e 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -72,11 +72,9 @@ public:
     /** Prepare tube manager with account and service to be offered/listened
         to.
      */
-    TeleManager();
-    ~TeleManager();
+    TUBES_DLLPUBLIC                         TeleManager();
+    TUBES_DLLPUBLIC                         ~TeleManager();
 
-    TUBES_DLLPUBLIC static TeleManager*     get();
-    TUBES_DLLPUBLIC void                    unref();
     TUBES_DLLPUBLIC bool                    init( bool bListen );
 
     /** Connect to DBus and create AccountManager. */
@@ -197,13 +195,6 @@ private:
     static sal_uInt32       nRefCount;
     static rtl::OString     aNameSuffix;
 
-    /* FIXME: double-singletonning is bad. These two are used by ::get and
-     * ::unref, and are a quick hack so that we can have a demo working.
-     */
-    static TeleManager*     pSingleton;
-    static sal_uInt32       nAnotherRefCount;
-    static ::osl::Mutex&    GetAnotherMutex();
-
     friend class TeleManagerImpl;   // access to mutex
 
     static ::osl::Mutex&    GetMutex();
diff --git a/tubes/qa/test_manager.cxx b/tubes/qa/test_manager.cxx
index 81298d0..f914b33 100644
--- a/tubes/qa/test_manager.cxx
+++ b/tubes/qa/test_manager.cxx
@@ -129,7 +129,7 @@ void TestTeleTubes::testInitialize()
     mpMainLoop = g_main_loop_new (NULL, FALSE);
     g_timeout_add_seconds (10, timed_out, mpMainLoop);
 
-    mpManager = TeleManager::get();
+    mpManager = new TeleManager();
 }
 
 void TestTeleTubes::testContactList()
@@ -279,12 +279,11 @@ void TestTeleTubes::testDestroyTeleTubes()
         g_object_unref(mpAccepterContact);
         mpAccepterContact = NULL;
     }
-    if (mpManager)
-        mpManager->unref();
     g_main_loop_unref( mpMainLoop );
     if (mpConference1)
         mpConference1->close();
     delete mpConference1;
+    delete mpManager;
 }
 
 void TestTeleTubes::testFailAlways()
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index c60388f..cfff455 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -81,10 +81,6 @@ TeleManagerImpl* TeleManager::pImpl     = NULL;
 sal_uInt32       TeleManager::nRefCount = 0;
 rtl::OString     TeleManager::aNameSuffix;
 
-sal_uInt32       TeleManager::nAnotherRefCount = 0;
-TeleManager*     TeleManager::pSingleton = NULL;
-
-
 /** Refcounted singleton implementation class. */
 class TeleManagerImpl
 {
@@ -390,6 +386,7 @@ TeleManager::TeleManager()
     :
         mbChannelReadyHandlerInvoked( false)
 {
+    SAL_INFO( "tubes", "TeleManager::get: count: " << nRefCount );
     // The glib object types need to be initialized, else we aren't going
     // anywhere.
     g_type_init();
@@ -400,7 +397,6 @@ TeleManager::TeleManager()
         pImpl = new TeleManagerImpl;
 }
 
-
 TeleManager::~TeleManager()
 {
     MutexGuard aGuard( GetMutex());
@@ -411,29 +407,7 @@ TeleManager::~TeleManager()
         delete pImpl;
         pImpl = NULL;
     }
-}
-
-TeleManager *
-TeleManager::get()
-{
-    MutexGuard aGuard( GetAnotherMutex());
-    SAL_INFO( "tubes", "TeleManager::get: count: " << nAnotherRefCount );
-    if (!pSingleton)
-        pSingleton = new TeleManager();
-
-    nAnotherRefCount++;
-    return pSingleton;
-}
-
-void
-TeleManager::unref()
-{
-    MutexGuard aGuard( GetAnotherMutex());
-    if (nAnotherRefCount && --nAnotherRefCount == 0) {
-        delete pSingleton;
-        pSingleton = NULL;
-    }
-    SAL_INFO( "tubes", "TeleManager::unref: count: " << nAnotherRefCount );
+    SAL_INFO( "tubes", "TeleManager::unref: count: " << nRefCount );
 }
 
 bool TeleManager::init( bool bListen )
@@ -913,19 +887,6 @@ Mutex& TeleManager::GetMutex()
     return *pMutex;
 }
 
-Mutex& TeleManager::GetAnotherMutex()
-{
-    static Mutex* pMutex = NULL;
-    if (!pMutex)
-    {
-        MutexGuard aGuard( Mutex::getGlobalMutex());
-        if (!pMutex)
-            pMutex = new Mutex;
-    }
-    return *pMutex;
-}
-
-
 // static
 void TeleManager::addSuffixToNames( const char* pName )
 {
commit c55b2d0b32dd210c2a809ce2b5ebca12bfb5b1d8
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Thu Jul 26 10:30:44 2012 +0200

    tubes: TeleManger's GMainLoop* now unused
    
    Change-Id: I99b482a60155c596c4b64534f62ce4c9d4d9a94b

diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index a47a566..0e96826 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -71,12 +71,8 @@ public:
 
     /** Prepare tube manager with account and service to be offered/listened
         to.
-
-        @param bCreateOwnGMainLoop
-            Whether to create and iterate an own GMainLoop. For testing
-            purposes when no GMainLoop is available.
      */
-    TeleManager( bool bCreateOwnGMainLoop = false );
+    TeleManager();
     ~TeleManager();
 
     TUBES_DLLPUBLIC static TeleManager*     get();
@@ -142,11 +138,6 @@ public:
 
     void                    disconnect();
 
-    /// Only for use with MainLoopFlusher
-    GMainLoop*              getMainLoop() const;
-
-    GMainContext*           getMainContext() const;
-
     static rtl::OString     createUuid();
 
 
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index 80f9c1c..c60388f 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -89,7 +89,6 @@ TeleManager*     TeleManager::pSingleton = NULL;
 class TeleManagerImpl
 {
 public:
-    GMainLoop*                          mpLoop;
     TpAutomaticClientFactory*           mpFactory;
     TpBaseClient*                       mpClient;
     TpBaseClient*                       mpFileTransferClient;
@@ -387,7 +386,7 @@ static void TeleManager_AccountManagerReadyHandler(
 }
 
 
-TeleManager::TeleManager( bool bCreateOwnGMainLoop )
+TeleManager::TeleManager()
     :
         mbChannelReadyHandlerInvoked( false)
 {
@@ -399,11 +398,6 @@ TeleManager::TeleManager( bool bCreateOwnGMainLoop )
     ++nRefCount;
     if (!pImpl)
         pImpl = new TeleManagerImpl;
-
-    // We need a main loop, else no callbacks.
-    /* TODO: could the loop be run in another thread? */
-    if (bCreateOwnGMainLoop && !pImpl->mpLoop)
-        pImpl->mpLoop = g_main_loop_new( NULL, FALSE);
 }
 
 
@@ -860,53 +854,37 @@ rtl::OString TeleManager::getFullObjectPath()
 
 void TeleManager::iterateLoop()
 {
-    GMainContext* pContext = getMainContext();
-    g_main_context_iteration( pContext, TRUE);
+    g_main_context_iteration( NULL, TRUE );
 }
 
 
 void TeleManager::iterateLoop( CallBackInvokedFunc pFunc )
 {
-    GMainContext* pContext = getMainContext();
     while (!(*pFunc)())
     {
-        g_main_context_iteration( pContext, TRUE);
+        g_main_context_iteration( NULL, TRUE );
     }
 }
 
 
 void TeleManager::iterateLoop( ManagerCallBackInvokedFunc pFunc )
 {
-    GMainContext* pContext = getMainContext();
     while (!(this->*pFunc)())
     {
-        g_main_context_iteration( pContext, TRUE);
+        g_main_context_iteration( NULL, TRUE );
     }
 }
 
 
 void TeleManager::iterateLoop( const TeleConference* pConference, ConferenceCallBackInvokedFunc pFunc )
 {
-    GMainContext* pContext = getMainContext();
     while (!(pConference->*pFunc)())
     {
-        g_main_context_iteration( pContext, TRUE);
+        g_main_context_iteration( NULL, TRUE );
     }
 }
 
 
-GMainLoop* TeleManager::getMainLoop() const
-{
-    return pImpl->mpLoop;
-}
-
-
-GMainContext* TeleManager::getMainContext() const
-{
-    return (pImpl->mpLoop ? g_main_loop_get_context( pImpl->mpLoop) : NULL);
-}
-
-
 // static
 rtl::OString TeleManager::createUuid()
 {
@@ -958,7 +936,6 @@ void TeleManager::addSuffixToNames( const char* pName )
 
 TeleManagerImpl::TeleManagerImpl()
     :
-        mpLoop( NULL),
         mpFactory( NULL),
         mpClient( NULL),
         mpFileTransferClient( NULL),
@@ -986,8 +963,6 @@ TeleManagerImpl::~TeleManagerImpl()
         g_object_unref( mpAccountManager);
     if (mpContactList)
         delete mpContactList;
-    if (mpLoop)
-        g_main_loop_unref( mpLoop);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list