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

Will Thompson wjt at kemper.freedesktop.org
Mon Mar 26 06:41:06 PDT 2012


 sc/source/ui/collab/collab.cxx   |    4 +--
 sc/source/ui/collab/sendfunc.cxx |    5 ++--
 sc/source/ui/inc/collab.hxx      |    2 -
 tubes/inc/tubes/manager.hxx      |    7 ++++--
 tubes/qa/test_manager.cxx        |    4 +--
 tubes/source/manager.cxx         |   40 ++++++++++++++++++++++++++++++++++++---
 6 files changed, 50 insertions(+), 12 deletions(-)

New commits:
commit 602fae9a0d2984790b1c5be8ac607990f4168202
Author: Will Thompson <will.thompson at collabora.co.uk>
Date:   Mon Mar 26 14:40:17 2012 +0100

    tubes: work around “We are supposed to handle only one channel” bug.
    
    This is the bug which breaks the first request after the offerer signed
    in.

diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index c75e3c1..8ba3a02 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -221,6 +221,8 @@ public:
     static void             TransferDone( EmpathyFTHandler *handler, TpFileTransferChannel *, gpointer user_data);
 
 private:
+    void                    ensureLegacyChannel( TpAccount* pAccount, TpContact* pBuddy );
+
     TeleConferenceVector    maConferences;
 
     bool                    mbAcceptIncoming;
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index 21d0d41..73895f9 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -592,11 +592,41 @@ bool TeleManager::startGroupSession( const rtl::OUString& rUConferenceRoom, cons
 #endif
 
 
+void TeleManager::ensureLegacyChannel( TpAccount* pAccount, TpContact* pBuddy )
+{
+    /* This is a workaround for a Telepathy bug.
+     * <https://bugs.freedesktop.org/show_bug.cgi?id=47760>. The first time you
+     * request a tube to a contact on an account, you actually get two channels
+     * back: the tube you asked for, along with a legacy Channel.Type.Tubes
+     * object. This breaks create_and_handle_channel_async(), which expects to
+     * only get one channel back.
+     *
+     * To work around this, we make sure the legacy Tubes channel already
+     * exists before we request the channel we actually want. We don't actually
+     * have to wait for this request to succeed—we fire it off and forget about
+     * it.
+     */
+    GHashTable* pRequest = tp_asv_new(
+            TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_TUBES,
+            TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, TP_TYPE_HANDLE, TP_HANDLE_TYPE_CONTACT,
+            TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, tp_contact_get_identifier (pBuddy),
+            NULL);
+    TpAccountChannelRequest* pChannelRequest = tp_account_channel_request_new(
+            pAccount, pRequest, TP_USER_ACTION_TIME_NOT_USER_ACTION);
+    tp_account_channel_request_ensure_channel_async( pChannelRequest, NULL,
+            NULL, NULL, NULL );
+    g_object_unref( pChannelRequest );
+    g_hash_table_unref( pRequest );
+}
+
+
 /* TODO: factor out common code with startGroupSession() */
 bool TeleManager::startBuddySession( TpAccount *pAccount, TpContact *pBuddy )
 {
     INFO_LOGGER( "TeleManager::startBuddySession");
 
+    ensureLegacyChannel( pAccount, pBuddy );
+
     OString aSessionId( TeleManager::createUuid());
 
     TeleConferencePtr pConference( new TeleConference( this, NULL, NULL, aSessionId));
commit 2ab2ac613510cf16c4cdfb8f2ac31815de56956e
Author: Will Thompson <will.thompson at collabora.co.uk>
Date:   Mon Mar 26 14:22:25 2012 +0100

    tubes: quick hack to allow running two instances
    
    To record a screencast, I wanted to get two instances of LibreOffice
    running in the same session. But the Client object(s) claim D-Bus names,
    so initializing the second instance failed.
    
    This patch changes things so that if LIBO_TUBES=master, no Client
    objects are created. As a result, only the slave can receive files.

diff --git a/sc/source/ui/collab/collab.cxx b/sc/source/ui/collab/collab.cxx
index 4c02045..a03f4f8 100644
--- a/sc/source/ui/collab/collab.cxx
+++ b/sc/source/ui/collab/collab.cxx
@@ -66,9 +66,9 @@ void ScCollaboration::packetReceivedCallback( TeleConference *pConference, TeleP
     sigPacketReceived( pConference, aString);
 }
 
-bool ScCollaboration::initManager()
+bool ScCollaboration::initManager(bool bAcceptIncoming)
 {
-    mpManager = TeleManager::get();
+    mpManager = TeleManager::get(bAcceptIncoming);
     mpManager->sigPacketReceived.connect(
         boost::bind( &ScCollaboration::packetReceivedCallback, this, _1, _2 ));
     mpManager->connect();
diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index 0f74209..3dddabf 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -557,8 +557,9 @@ SC_DLLPRIVATE ScDocFunc *ScDocShell::CreateDocFunc()
             boost::bind( &ScDocFuncRecv::packetReceived, pReceiver, _1, _2 ));
         pCollab->sigFileReceived.connect(
             boost::bind( &ScDocFuncRecv::fileReceived, pReceiver, _1));
-        bOk = bOk && pCollab->initManager();
-        if (!strcmp( pEnv, "master"))
+        bool bIsMaster = !strcmp( pEnv, "master");
+        bOk = bOk && pCollab->initManager(!bIsMaster);
+        if (bIsMaster)
         {
             bOk = bOk && pCollab->initAccountContact();
             bOk = bOk && pCollab->startCollaboration();
diff --git a/sc/source/ui/inc/collab.hxx b/sc/source/ui/inc/collab.hxx
index df059ad..e995d1b 100644
--- a/sc/source/ui/inc/collab.hxx
+++ b/sc/source/ui/inc/collab.hxx
@@ -46,7 +46,7 @@ public:
                             ScCollaboration();
                             ~ScCollaboration();
 
-    bool                    initManager();
+    bool                    initManager(bool bAcceptIncoming);
     bool                    initAccountContact();
     bool                    startCollaboration();
 
diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index ec85d91..c75e3c1 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -77,10 +77,10 @@ public:
             Whether to create and iterate an own GMainLoop. For testing
             purposes when no GMainLoop is available.
      */
-    TeleManager( bool bCreateOwnGMainLoop = false );
+    TeleManager( bool bAcceptIncoming = true, bool bCreateOwnGMainLoop = false );
     ~TeleManager();
 
-    static TeleManager     *get();
+    static TeleManager     *get( bool bAcceptIncoming );
     void                    unref();
 
     /** Prepare the Telepathy Account Manager. Requires connect() to have succeeded.
@@ -223,6 +223,7 @@ public:
 private:
     TeleConferenceVector    maConferences;
 
+    bool                    mbAcceptIncoming;
     bool                    mbChannelReadyHandlerInvoked : 1;
 
     static TeleManagerImpl* pImpl;
diff --git a/tubes/qa/test_manager.cxx b/tubes/qa/test_manager.cxx
index cb31362..ae9b713 100644
--- a/tubes/qa/test_manager.cxx
+++ b/tubes/qa/test_manager.cxx
@@ -211,12 +211,12 @@ void TestTeleTubes::testContactList()
 
 void TestTeleTubes::testSetupManager1()
 {
-    mpManager1 = new TeleManager( true);
+    mpManager1 = new TeleManager( true, true);
 }
 
 void TestTeleTubes::testSetupManager2()
 {
-    mpManager2 = new TeleManager();
+    mpManager2 = new TeleManager( true );
 }
 
 void TestTeleTubes::testPrepareAccountManager1()
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index b9f9744..21d0d41 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -357,8 +357,9 @@ static void TeleManager_AccountManagerReadyHandler(
 }
 
 
-TeleManager::TeleManager( bool bCreateOwnGMainLoop )
+TeleManager::TeleManager( bool bAcceptIncoming, bool bCreateOwnGMainLoop )
     :
+        mbAcceptIncoming( bAcceptIncoming ),
         mbChannelReadyHandlerInvoked( false)
 {
     // The glib object types need to be initialized, else we aren't going
@@ -390,11 +391,11 @@ TeleManager::~TeleManager()
 }
 
 TeleManager *
-TeleManager::get()
+TeleManager::get( bool bAcceptIncoming )
 {
     MutexGuard aGuard( GetAnotherMutex());
     if (!pSingleton)
-        pSingleton = new TeleManager();
+        pSingleton = new TeleManager(bAcceptIncoming);
 
     nAnotherRefCount++;
     return pSingleton;
@@ -446,6 +447,9 @@ bool TeleManager::connect()
 
     pImpl->mpContactList = new ContactList(pAccountManager);
 
+    if (!mbAcceptIncoming)
+        return true;
+
     pImpl->mpClient = tp_simple_handler_new_with_factory(
             TP_SIMPLE_CLIENT_FACTORY (pFactory), // factory
             FALSE,                          // bypass_approval


More information about the Libreoffice-commits mailing list