[Libreoffice-commits] .: Branch 'feature/tubes2' - 2 commits - tubes/inc tubes/qa tubes/source

Michael Meeks michael at kemper.freedesktop.org
Wed Mar 21 11:34:07 PDT 2012


 tubes/inc/tubes/constants.h   |    6 ++----
 tubes/inc/tubes/manager.hxx   |   30 ++++++++++++++++++++++--------
 tubes/qa/test_manager.cxx     |    8 +++-----
 tubes/source/contact-list.cxx |    3 ++-
 tubes/source/manager.cxx      |   37 ++++++++++++++++++++++++++-----------
 5 files changed, 55 insertions(+), 29 deletions(-)

New commits:
commit 786b18fe7e6038797fcb4812add78e4888913f5b
Author: Eike Rathke <erack at redhat.com>
Date:   Wed Mar 21 16:41:34 2012 +0100

    removed trailing whitespace

diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index 6376ca0..7f325c3 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -125,7 +125,7 @@ public:
     void                    acceptTube( TpChannel* pChannel, const char* pAddress );
 
     /** Send data to all registered conferences.
-        
+
         @returns to how many conferences the packet was send
      */
     sal_uInt32              sendPacket( const TelePacket& rPacket ) const;
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index 1ce78dd..796e986 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -742,7 +742,7 @@ rtl::OString TeleManager::createUuid()
     }
     aBuf[32] = 0;
     return rtl::OString( aBuf);
-} 
+}
 
 
 // static
commit 8536137020fa3ab9b48e12de2e0dc5c65808186a
Author: Eike Rathke <erack at redhat.com>
Date:   Wed Mar 21 19:31:50 2012 +0100

    make service name configurable for tests

diff --git a/tubes/inc/tubes/constants.h b/tubes/inc/tubes/constants.h
index 6087115..447910e 100644
--- a/tubes/inc/tubes/constants.h
+++ b/tubes/inc/tubes/constants.h
@@ -39,13 +39,11 @@
  * etc. This does not need to include the org.freedesktop.Telepathy.Client
  * stuff.
  */
-#define LIBO_DTUBE_SERVICE \
-    TP_CLIENT_BUS_NAME_BASE "LibreOfficeTeleTest"
+#define LIBO_DTUBE_SERVICE "org.libreoffice.calc"
 
 /* Client name suffix, for passing as 'name' to
  * tp_simple_handler_new_with_am(). */
-#define LIBO_CLIENT_SUFFIX \
-    "LibreOffice"
+#define LIBO_CLIENT_SUFFIX "LibreOffice"
 
 #endif // INCLUDED_TUBES_CONSTANTS_H
 
diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index decd548..6376ca0 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -140,12 +140,6 @@ public:
      */
     bool                    popPacket( TelePacket& rPacket );
 
-    /// "org.freedesktop.Telepathy.Client.LibreOfficeWhatEver"
-    rtl::OString            getFullServiceName() const;
-
-    /// "/org/freedesktop/Telepathy/Client/LibreOfficeWhatEver"
-    rtl::OString            getFullObjectPath() const;
-
     /// Only for use with MainLoopFlusher
     GMainLoop*              getMainLoop() const;
 
@@ -181,9 +175,28 @@ public:
     /** Iterate our GMainLoop, non-blocking, until nothing pending. */
     void                    flushLoop() const;
 
+    /// "LibreOfficeWhatEver"
+    static rtl::OString     getFullClientName();
+
+    /// "org.libreoffice.calcWhatEver"
+    static rtl::OString     getFullServiceName();
+
+    /// "/org/libreoffice/calcWhatEver"
+    static rtl::OString     getFullObjectPath();
+
+    /** Add a suffix to the client name and DBus tube names, e.g. "WhatEver"
+
+        Normally the client name is LibreOffice and the DBus tube service name
+        is something like org.libreoffice.calc, this modifies the names to
+        "LibreOffice"+pName and "org.libreoffice.calc"+pName to make tests not
+        interfere with the real world. This is not to be used otherwise. If
+        used it must be called before the first TeleManager is instanciated and 
+        connects.
+     */
+    static void             addSuffixToNames( const char* pName );
+
 private:
 
-    rtl::OString            maService;      // the "WhatEver" part
     TeleConferenceVector    maConferences;
 
     bool                    mbChannelReadyHandlerInvoked : 1;
@@ -192,6 +205,7 @@ private:
 
     static TeleManagerImpl* pImpl;
     static sal_uInt32       nRefCount;
+    static rtl::OString     aNameSuffix;
 
     friend class TeleManagerImpl;   // access to mutex
 
diff --git a/tubes/qa/test_manager.cxx b/tubes/qa/test_manager.cxx
index 3618f6c..69266d0 100644
--- a/tubes/qa/test_manager.cxx
+++ b/tubes/qa/test_manager.cxx
@@ -46,11 +46,11 @@ public:
 
     TestTeleTubes();
     ~TestTeleTubes();
-    void testContactList();
     void testSetupManager1();
     void testSetupManager2();
     void testConnect1();
     void testConnect2();
+    void testContactList();
     void testPrepareAccountManager1();
     void testPrepareAccountManager2();
     void testStartBuddySession1();
@@ -66,11 +66,11 @@ public:
 
     // Order is significant.
     CPPUNIT_TEST_SUITE( TestTeleTubes );
-    CPPUNIT_TEST( testContactList );
     CPPUNIT_TEST( testSetupManager1 );
     CPPUNIT_TEST( testSetupManager2 );
     CPPUNIT_TEST( testConnect1 );
     CPPUNIT_TEST( testConnect2 );
+    CPPUNIT_TEST( testContactList );
     CPPUNIT_TEST( testPrepareAccountManager1 );
     CPPUNIT_TEST( testPrepareAccountManager2 );
     CPPUNIT_TEST( testStartBuddySession1 );
@@ -83,9 +83,6 @@ public:
     CPPUNIT_TEST( testFailAlways );     // need failure to display SAL_LOG, comment out for real builds
     CPPUNIT_TEST_SUITE_END();
 
-private:
-
-    void runSetupManager( TeleManager* pManager, const rtl::OUString& rBuddy );
 };
 
 // static, not members, so they actually survive cppunit test iteration
@@ -101,6 +98,7 @@ static sal_uInt32 nSentPackets = 0;
 
 TestTeleTubes::TestTeleTubes()
 {
+    TeleManager::addSuffixToNames( "TeleTest");
 }
 
 TestTeleTubes::~TestTeleTubes()
diff --git a/tubes/source/contact-list.cxx b/tubes/source/contact-list.cxx
index c342115..602bb63 100644
--- a/tubes/source/contact-list.cxx
+++ b/tubes/source/contact-list.cxx
@@ -32,6 +32,7 @@
 
 #include <tubes/constants.h>
 #include <tubes/contact-list.hxx>
+#include <tubes/manager.hxx>
 
 ContactList::ContactList()
 {
@@ -76,7 +77,7 @@ contact_supports_libo_dtube (TpContact *contact)
         return FALSE;
 
     return tp_capabilities_supports_dbus_tubes (caps,
-        TP_HANDLE_TYPE_CONTACT, LIBO_DTUBE_SERVICE);
+        TP_HANDLE_TYPE_CONTACT, TeleManager::getFullServiceName().getStr());
 }
 
 typedef ::std::pair< ContactList::PrepareCallback, void * > Foo;
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index 414c7c4..1ce78dd 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -27,6 +27,7 @@
  */
 
 #include "tubes/manager.hxx"
+#include "tubes/constants.h"
 #include <rtl/strbuf.hxx>
 #include <rtl/uuid.h>
 #include <osl/mutex.hxx>
@@ -66,6 +67,7 @@ using namespace osl;
 
 TeleManagerImpl* TeleManager::pImpl     = NULL;
 sal_uInt32       TeleManager::nRefCount = 0;
+rtl::OString     TeleManager::aNameSuffix;
 
 
 /** Refcounted singleton implementation class. */
@@ -84,11 +86,6 @@ public:
 };
 
 
-// To form "org.freedesktop.Telepathy.Client.LibreOfficeWhatEver" (bus name)
-// or "/org/freedesktop/Telepathy/Client/LibreOfficeWhatEver" (object path)
-#define LIBO_TP_NAME_PREFIX "LibreOffice"
-
-
 static void TeleManager_DBusTubeAcceptHandler(
         TpChannel*      pChannel,
         const char*     pAddress,
@@ -284,7 +281,7 @@ bool TeleManager::connect()
             pFactory,                       // factory
             TRUE,                           // bypass_approval
             FALSE,                          // requests
-            LIBO_TP_NAME_PREFIX,            // name
+            getFullClientName().getStr(),   // name
             FALSE,                          // uniquify
             TeleManager_DBusChannelHandler, // callback
             this,                           // user_data
@@ -582,6 +579,8 @@ bool TeleManager::popPacket( TelePacket& rPacket )
 
 void TeleManager::unregisterConference( TeleConferencePtr pConference )
 {
+    INFO_LOGGER( "TeleManager::unregisterConference");
+
     TeleConferenceVector::iterator it = ::std::find( maConferences.begin(), maConferences.end(), pConference);
     if (it != maConferences.end())
         maConferences.erase( it);
@@ -640,22 +639,31 @@ void TeleManager::setAccountManagerReady( bool bPrepared)
 }
 
 
-rtl::OString TeleManager::getFullServiceName() const
+rtl::OString TeleManager::getFullClientName()
 {
     OStringBuffer aBuf(64);
-    aBuf.append( RTL_CONSTASCII_STRINGPARAM( TP_CLIENT_BUS_NAME_BASE)).append( LIBO_TP_NAME_PREFIX);
+    aBuf.append( RTL_CONSTASCII_STRINGPARAM( LIBO_CLIENT_SUFFIX)).append( aNameSuffix);
     return aBuf.makeStringAndClear();
 }
 
 
-rtl::OString TeleManager::getFullObjectPath() const
+rtl::OString TeleManager::getFullServiceName()
 {
     OStringBuffer aBuf(64);
-    aBuf.append( RTL_CONSTASCII_STRINGPARAM( TP_CLIENT_OBJECT_PATH_BASE)).append( LIBO_TP_NAME_PREFIX);
+    aBuf.append( RTL_CONSTASCII_STRINGPARAM( LIBO_DTUBE_SERVICE)).append( aNameSuffix);
     return aBuf.makeStringAndClear();
 }
 
 
+rtl::OString TeleManager::getFullObjectPath()
+{
+    OStringBuffer aBuf(64);
+    aBuf.append( '/').append( RTL_CONSTASCII_STRINGPARAM( LIBO_DTUBE_SERVICE)).append( aNameSuffix);
+    OString aStr( aBuf.makeStringAndClear().replace( '.', '/'));
+    return aStr;
+}
+
+
 void TeleManager::iterateLoop()
 {
     GMainContext* pContext = getMainContext();
@@ -750,6 +758,13 @@ Mutex& TeleManager::GetMutex()
     return *pMutex;
 }
 
+
+// static
+void TeleManager::addSuffixToNames( const char* pName )
+{
+    aNameSuffix = pName;
+}
+
 // ===========================================================================
 
 TeleManagerImpl::TeleManagerImpl()


More information about the Libreoffice-commits mailing list