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

2012-03-28 Thread Eike Rathke
 sc/source/ui/collab/sendfunc.cxx |   72 ++-
 1 file changed, 48 insertions(+), 24 deletions(-)

New commits:
commit eb452d90e6f8afdff69649881f8b7f2ff0f7b047
Author: Eike Rathke er...@redhat.com
Date:   Wed Mar 28 20:24:32 2012 +0200

tubes: shared_ptr for ScDocFunc chains and ScCollaboration

diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index c753eee..26f1ef5 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -256,20 +256,19 @@ public:
 
 class ScDocFuncRecv : public ScDocFunc
 {
-ScDocFunc *mpChain;
-ScCollaboration* mpCollab;
+boost::shared_ptrScDocFuncDirect  mpChain;
+boost::shared_ptrScCollaboration  mpCollab;
 public:
 // FIXME: really ScDocFunc should be an abstract base
-ScDocFuncRecv( ScDocShell rDocSh, ScDocFunc *pChain )
+ScDocFuncRecv( ScDocShell rDocSh, boost::shared_ptrScDocFuncDirect 
pChain )
 : ScDocFunc( rDocSh ),
-  mpChain( pChain ),
-  mpCollab( NULL)
+  mpChain( pChain )
 {
 fprintf( stderr, Receiver created !\n );
 }
 virtual ~ScDocFuncRecv() {}
 
-void SetCollaboration( ScCollaboration* pCollab )
+void SetCollaboration( boost::shared_ptrScCollaboration pCollab )
 {
 mpCollab = pCollab;
 }
@@ -380,8 +379,8 @@ void ScDocFuncRecv::fileReceived( rtl::OUString *pStr )
 
 class ScDocFuncSend : public ScDocFunc
 {
-ScDocFuncRecv *mpChain;
-ScCollaboration* mpCollab;
+boost::shared_ptrScDocFuncRecvmpChain;
+boost::shared_ptrScCollaboration  mpCollab;
 
 void SendMessage( ScChangeOpWriter rOp )
 {
@@ -424,16 +423,15 @@ class ScDocFuncSend : public ScDocFunc
 public:
 // FIXME: really ScDocFunc should be an abstract base, so
 // we don't need the rDocSh hack/pointer
-ScDocFuncSend( ScDocShell rDocSh, ScDocFuncRecv *pChain )
+ScDocFuncSend( ScDocShell rDocSh, boost::shared_ptrScDocFuncRecv 
pChain )
 : ScDocFunc( rDocSh ),
-mpChain( pChain ),
-mpCollab( NULL)
+mpChain( pChain )
 {
 fprintf( stderr, Sender created !\n );
 }
 virtual ~ScDocFuncSend() {}
 
-void SetCollaboration( ScCollaboration* pCollab )
+void SetCollaboration( boost::shared_ptrScCollaboration pCollab )
 {
 mpCollab = pCollab;
 }
@@ -562,20 +560,28 @@ public:
 
 SC_DLLPRIVATE ScDocFunc *ScDocShell::CreateDocFunc()
 {
-// FIXME: the chains should be auto-ptrs, so should be collab
+// With ScDocFuncDirect shared_ptr it should even be possible during
+// runtime to replace a ScDocFuncDirect instance with a ScDocFuncSend
+// chained instance (holding the same ScDocFuncDirect instance) and vice
+// versa.
 bool bIsMaster = false;
 if (getenv (INTERCEPT))
-return new ScDocFuncSend( *this, new ScDocFuncRecv( *this, new 
ScDocFuncDirect( *this ) ) );
+{
+boost::shared_ptrScDocFuncDirect pDirect( new ScDocFuncDirect( *this 
) );
+boost::shared_ptrScDocFuncRecv pReceiver( new ScDocFuncRecv( *this, 
pDirect ) );
+return new ScDocFuncSend( *this, pReceiver );
+}
 else if (isCollabMode( bIsMaster ))
 {
-ScDocFuncRecv* pReceiver = new ScDocFuncRecv( *this, new 
ScDocFuncDirect( *this ) );
+boost::shared_ptrScDocFuncDirect pDirect( new ScDocFuncDirect( *this 
) );
+boost::shared_ptrScDocFuncRecv pReceiver( new ScDocFuncRecv( *this, 
pDirect ) );
 ScDocFuncSend* pSender = new ScDocFuncSend( *this, pReceiver );
-bool bOk = true;
-ScCollaboration* pCollab = new ScCollaboration();
+boost::shared_ptrScCollaboration pCollab( new ScCollaboration );
 pCollab-sigPacketReceived.connect(
-boost::bind( ScDocFuncRecv::packetReceived, pReceiver, _1, _2 ));
+boost::bind( ScDocFuncRecv::packetReceived, pReceiver, _1, _2 
));
 pCollab-sigFileReceived.connect(
-boost::bind( ScDocFuncRecv::fileReceived, pReceiver, _1));
+boost::bind( ScDocFuncRecv::fileReceived, pReceiver, _1));
+bool bOk = true;
 bOk = bOk  pCollab-initManager(!bIsMaster);
 if (bIsMaster)
 {
@@ -590,7 +596,7 @@ SC_DLLPRIVATE ScDocFunc *ScDocShell::CreateDocFunc()
 else
 {
 fprintf( stderr, Could not start collaboration.\n);
-delete pCollab;
+// pCollab shared_ptr will be destructed
 }
 return pSender;
 }
commit e41d2677b159f8179829b0cdcb290bc581c628ff
Author: Eike Rathke er...@redhat.com
Date:   Wed Mar 28 20:24:23 2012 +0200

tubes: TeleManager::get() takes an argument

initialize with same mode as collaboration

diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index 3dddabf..c753eee 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -68,6 +68,18 @@ ScBaseCell 

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

2012-03-26 Thread Will Thompson
 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.thomp...@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:
+voidensureLegacyChannel( TpAccount* pAccount, 
TpContact* pBuddy );
+
 TeleConferenceVectormaConferences;
 
 boolmbAcceptIncoming;
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.thomp...@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();
-