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

Matus Kukan mkukan at kemper.freedesktop.org
Sat Jul 14 09:55:33 PDT 2012


 sc/source/ui/collab/contacts.cxx |  114 +++++++++++++++++-------
 sc/source/ui/collab/contacts.hrc |    3 
 sc/source/ui/collab/contacts.hxx |    3 
 sc/source/ui/collab/contacts.src |    6 +
 sc/source/ui/collab/sendfunc.cxx |   95 +++++++-------------
 sc/source/ui/collab/sendfunc.hxx |   20 ++--
 sc/source/ui/docshell/docsh.cxx  |    2 
 sc/source/ui/view/cellsh3.cxx    |    5 -
 tubes/inc/tubes/conference.hxx   |   27 ++---
 tubes/inc/tubes/manager.hxx      |   75 ++++-----------
 tubes/qa/test_manager.cxx        |   36 +++++--
 tubes/source/conference.cxx      |   17 ++-
 tubes/source/manager.cxx         |  185 ++++++++++++---------------------------
 13 files changed, 274 insertions(+), 314 deletions(-)

New commits:
commit a4c0b57c4da9c17aed24f20cffd7ed2d01d8f9a1
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Sat Jul 14 10:56:14 2012 +0200

    tubes: add possibility to invite contacts to MUC
    
    Change-Id: Ia27c725aff1d16d21ee1f5abcfff9a107bd87a82

diff --git a/sc/source/ui/collab/contacts.cxx b/sc/source/ui/collab/contacts.cxx
index ac16c39..725b1f5 100644
--- a/sc/source/ui/collab/contacts.cxx
+++ b/sc/source/ui/collab/contacts.cxx
@@ -47,6 +47,7 @@ class TubeContacts : public ModelessDialog
 {
     FixedLine               maLabel;
     PushButton              maBtnConnect;
+    PushButton              maBtnInvite;
     PushButton              maBtnListen;
     SvxSimpleTableContainer maListContainer;
     SvxSimpleTable          maList;
@@ -54,6 +55,7 @@ class TubeContacts : public ModelessDialog
     ScDocFuncSend*          mpSender;
 
     DECL_LINK( BtnConnectHdl, void * );
+    DECL_LINK( BtnInviteHdl, void * );
     DECL_LINK( BtnListenHdl, void * );
 
     struct AccountContact
@@ -65,6 +67,19 @@ class TubeContacts : public ModelessDialog
     };
     boost::ptr_vector<AccountContact> maACs;
 
+    void Invite()
+    {
+        AccountContact *pAC = NULL;
+        if (maList.FirstSelected())
+            pAC = static_cast<AccountContact*> (maList.FirstSelected()->GetUserData());
+        if (pAC && mpSender->GetConference())
+        {
+            TpContact* pContact = pAC->mpContact;
+            fprintf( stderr, "inviting %s\n", tp_contact_get_identifier( pContact ) );
+            mpSender->GetConference()->invite( pContact );
+        }
+    }
+
     void Listen()
     {
         if (!mpManager->registerClients())
@@ -128,6 +143,7 @@ public:
         ModelessDialog( NULL, ScResId( RID_SCDLG_CONTACTS ) ),
         maLabel( this, ScResId( FL_LABEL ) ),
         maBtnConnect( this, ScResId( BTN_CONNECT ) ),
+        maBtnInvite( this, ScResId( BTN_INVITE ) ),
         maBtnListen( this, ScResId( BTN_LISTEN ) ),
         maListContainer( this, ScResId( CTL_LIST ) ),
         maList( maListContainer ),
@@ -159,6 +175,7 @@ public:
             }
         }
         maBtnConnect.SetClickHdl( LINK( this, TubeContacts, BtnConnectHdl ) );
+        maBtnInvite.SetClickHdl( LINK( this, TubeContacts, BtnInviteHdl ) );
         maBtnListen.SetClickHdl( LINK( this, TubeContacts, BtnListenHdl ) );
 
         static long aStaticTabs[]=
@@ -242,6 +259,13 @@ IMPL_LINK_NOARG( TubeContacts, BtnConnectHdl )
     return 0;
 }
 
+IMPL_LINK_NOARG( TubeContacts, BtnInviteHdl )
+{
+    Invite();
+    Close();
+    return 0;
+}
+
 IMPL_LINK_NOARG( TubeContacts, BtnListenHdl )
 {
     Listen();
diff --git a/sc/source/ui/collab/contacts.hrc b/sc/source/ui/collab/contacts.hrc
index cb69916..59aeb67 100644
--- a/sc/source/ui/collab/contacts.hrc
+++ b/sc/source/ui/collab/contacts.hrc
@@ -3,7 +3,8 @@
 #define FL_LABEL             1
 #define CTL_LIST             2
 #define BTN_CONNECT          3
-#define BTN_LISTEN           4
+#define BTN_INVITE           4
+#define BTN_LISTEN           5
 
 #define STR_HEADER_ALIAS     20
 #define STR_HEADER_NAME      21
diff --git a/sc/source/ui/collab/contacts.src b/sc/source/ui/collab/contacts.src
index 0de2849..27d1dca 100644
--- a/sc/source/ui/collab/contacts.src
+++ b/sc/source/ui/collab/contacts.src
@@ -25,6 +25,12 @@ ModelessDialog RID_SCDLG_CONTACTS
         Size = MAP_APPFONT( 50 , 10 );
         Text [ en-US ] = "Collaborate";
     };
+    PushButton BTN_INVITE
+    {
+        Pos = MAP_APPFONT( 130 , 200 );
+        Size = MAP_APPFONT( 50 , 10 );
+        Text [ en-US ] = "Invite";
+    };
     PushButton BTN_LISTEN
     {
         Pos = MAP_APPFONT( 8 , 200 );
diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index e5e6c54..e70021b 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -286,6 +286,11 @@ void ScDocFuncSend::SetCollaboration( TeleConference* pConference )
                 &ScDocFuncRecv::packetReceived, mpDirect, _1 ) );
 }
 
+TeleConference* ScDocFuncSend::GetConference()
+{
+    return mpConference;
+}
+
 ScDocFuncRecv* ScDocFuncSend::GetReceiver()
 {
     return mpDirect;
diff --git a/sc/source/ui/collab/sendfunc.hxx b/sc/source/ui/collab/sendfunc.hxx
index 1bcbe23..459be2a 100644
--- a/sc/source/ui/collab/sendfunc.hxx
+++ b/sc/source/ui/collab/sendfunc.hxx
@@ -238,6 +238,7 @@ public:
     virtual ~ScDocFuncSend();
 
     void                SetCollaboration( TeleConference* pConference );
+    TeleConference*     GetConference();
     ScDocFuncRecv*      GetReceiver();
 
     virtual void        EnterListAction( sal_uInt16 nNameResId );
diff --git a/tubes/inc/tubes/conference.hxx b/tubes/inc/tubes/conference.hxx
index a43a6dc..b35fddc 100644
--- a/tubes/inc/tubes/conference.hxx
+++ b/tubes/inc/tubes/conference.hxx
@@ -70,6 +70,8 @@ public:
     void                    queue( const char* pDBusSender, const char* pPacket, int nSize );
     void                    queue( TelePacket &rPacket );
 
+    TUBES_DLLPUBLIC void    invite( TpContact *pContact );
+
     /** Emitted when a packet is received. */
     boost::signals2::signal<void (TelePacket&)> sigPacketReceived;
 
diff --git a/tubes/source/conference.cxx b/tubes/source/conference.cxx
index a04851e..97da5cf 100644
--- a/tubes/source/conference.cxx
+++ b/tubes/source/conference.cxx
@@ -418,6 +418,15 @@ void TeleConference::queue( const char* pDBusSender, const char* pPacketData, in
     queue( aPacket );
 }
 
+void TeleConference::invite( TpContact *pContact )
+{
+    INFO_LOGGER( "TeleConference::invite" );
+    TpHandle aHandle = tp_contact_get_handle( pContact );
+    GArray handles = { reinterpret_cast<gchar *> (&aHandle), 1 };
+    tp_cli_channel_interface_group_call_add_members( TP_CHANNEL( mpChannel ),
+            -1, &handles, NULL, NULL, NULL, NULL, NULL );
+}
+
 
 class SendFileRequest {
 public:
commit bb4ec9aa2514fad18f7a97ebf966686fccfe4228
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Sat Jul 14 00:06:01 2012 +0200

    tubes: selectively export TeleManager's symbols
    
    Change-Id: I70053c4b1e31ecd281701bab692764ef581e0f57

diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index 79ab92b..4e0e3b4 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -56,8 +56,7 @@ class TeleManagerImpl;
     Accounts need to have been setup within Empathy already.
  */
 
-/* FIXME: selective dllprivate methods */
-class TUBES_DLLPUBLIC TeleManager
+class TeleManager
 {
 public:
 
@@ -79,14 +78,14 @@ public:
     TeleManager( bool bCreateOwnGMainLoop = false );
     ~TeleManager();
 
-    static TeleManager     *get();
-    void                    unref();
+    TUBES_DLLPUBLIC static TeleManager*     get();
+    TUBES_DLLPUBLIC void                    unref();
 
     /** Connect to DBus and create AccountManager. */
-    bool                    createAccountManager();
+    TUBES_DLLPUBLIC bool                    createAccountManager();
 
     /** Setup client handlers. */
-    bool                    registerClients();
+    TUBES_DLLPUBLIC bool                    registerClients();
 
     /** Prepare the Telepathy Account Manager.
         Requires createAccountManager() to have succeeded.
@@ -96,13 +95,13 @@ public:
 
         TODO: this needs some signalling mechanism
      */
-    void                    prepareAccountManager();
-    AccountManagerStatus    getAccountManagerStatus() const;
+    TUBES_DLLPUBLIC void                    prepareAccountManager();
+    TUBES_DLLPUBLIC AccountManagerStatus    getAccountManagerStatus() const;
 
     /** Fetches the contact list. Returns 0 before connect() is called successfully.
         Is non-functional until prepareAccountManager().
      */
-    ContactList*            getContactList() const;
+    TUBES_DLLPUBLIC ContactList*            getContactList() const;
 
     /** Start a group session in a MUC.
 
@@ -118,9 +117,9 @@ public:
             empty, only the conference's UUID is used and rConferenceRoom is
             ignored, hopefully resulting in a local DBus tube.
      */
-    TeleConference*         startGroupSession( TpAccount *pAccount,
-                                               const rtl::OUString& rConferenceRoom,
-                                               const rtl::OUString& rConferenceServer );
+    TUBES_DLLPUBLIC TeleConference*         startGroupSession( TpAccount *pAccount,
+                                                const rtl::OUString& rConferenceRoom,
+                                                const rtl::OUString& rConferenceServer );
 
     /** Start a session with a buddy.
 
@@ -130,7 +129,7 @@ public:
         @param pBuddy
             The buddy to be connected. Must be a contact of pAccount.
      */
-    TeleConference*         startBuddySession( TpAccount *pAccount, TpContact *pBuddy );
+    TUBES_DLLPUBLIC TeleConference*         startBuddySession( TpAccount *pAccount, TpContact *pBuddy );
 
     void                    disconnect();
 
@@ -219,11 +218,11 @@ private:
      */
     static TeleManager*     pSingleton;
     static sal_uInt32       nAnotherRefCount;
-    TUBES_DLLPRIVATE static ::osl::Mutex&   GetAnotherMutex();
+    static ::osl::Mutex&    GetAnotherMutex();
 
     friend class TeleManagerImpl;   // access to mutex
 
-    TUBES_DLLPRIVATE static ::osl::Mutex&   GetMutex();
+    static ::osl::Mutex&    GetMutex();
 };
 
 
commit 21821820cb7ea8c086d7a07357654c4f2b362204
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Fri Jul 13 23:35:05 2012 +0200

    tubes: remove now unused code, when we don't use maConferences
    
    Change-Id: I403253793791236eaf8e9fd3fc72489ebd447d99

diff --git a/tubes/inc/tubes/conference.hxx b/tubes/inc/tubes/conference.hxx
index 4849b42..a43a6dc 100644
--- a/tubes/inc/tubes/conference.hxx
+++ b/tubes/inc/tubes/conference.hxx
@@ -33,8 +33,6 @@
 #include "tubes/tubesdllapi.h"
 #include "tubes/packet.hxx"
 #include "tubes/file-transfer-helper.h"
-#include <boost/shared_ptr.hpp>
-#include <boost/enable_shared_from_this.hpp>
 #include <rtl/ustring.hxx>
 #include <telepathy-glib/telepathy-glib.h>
 #include <queue>
@@ -45,7 +43,7 @@ typedef ::std::queue<TelePacket> TelePacketQueue;
 class TeleManager;
 
 /** Conference setup by TeleManager */
-class TeleConference : public boost::enable_shared_from_this<TeleConference>
+class TeleConference
 {
 public:
 
@@ -118,15 +116,8 @@ private:
     TelePacketQueue         maPacketQueue;
 
     bool                    mbTubeOfferedHandlerInvoked : 1;
-
-    // hide from the public
-    using boost::enable_shared_from_this<TeleConference>::shared_from_this;
-
 };
 
-
-typedef boost::shared_ptr<TeleConference> TeleConferencePtr;
-
 #endif // INCLUDED_TUBES_CONFERENCE_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index a15d101..79ab92b 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -39,7 +39,6 @@
 #include <rtl/ref.hxx>
 #include <tools/link.hxx>
 #include <telepathy-glib/telepathy-glib.h>
-#include <vector>
 #include <tubes/warnings_guard_boost_signals2.hpp>
 
 // For testing purposes, we might need more in future.
@@ -47,8 +46,6 @@
 #define LIBO_TUBES_DBUS_MSG_METHOD "LibOMsg"
 #define LIBO_TUBES_DBUS_PATH "/org/libreoffice/calc"
 
-typedef ::std::vector<TeleConferencePtr> TeleConferenceVector;
-
 namespace osl { class Mutex; }
 class TeleManagerImpl;
 
@@ -135,28 +132,8 @@ public:
      */
     TeleConference*         startBuddySession( TpAccount *pAccount, TpContact *pBuddy );
 
-    void                    unregisterConference( TeleConferencePtr pConference );
-
     void                    disconnect();
 
-    /** Send data to all registered conferences.
-
-        @returns to how many conferences the packet was send
-     */
-    sal_uInt32              sendPacket( const TelePacket& rPacket ) const;
-
-    /** Pop a received data packet.
-
-        XXX This needs to be elaborated to pop from a specific conference, or
-        for a specific document. Currently the conferences are simply iterated
-        and the first non-empty queue is popped.
-
-        @returns whether there was any packet to pop
-     */
-    bool                    popPacket( TelePacket& rPacket );
-
-    void                    sendFile( rtl::OUString &localUri, TeleConference::FileSentCallback pCallback, void* pUserData);
-
     boost::signals2::signal<void ( const rtl::OUString &localUri )> sigFileReceived;
 
     boost::signals2::signal<void (TeleConference*)> sigConferenceCreated;
@@ -231,8 +208,6 @@ public:
 private:
     void                    ensureLegacyChannel( TpAccount* pAccount, TpContact* pBuddy );
 
-    TeleConferenceVector    maConferences;
-
     bool                    mbChannelReadyHandlerInvoked : 1;
 
     static TeleManagerImpl* pImpl;
diff --git a/tubes/source/conference.cxx b/tubes/source/conference.cxx
index 1b5a397..a04851e 100644
--- a/tubes/source/conference.cxx
+++ b/tubes/source/conference.cxx
@@ -363,9 +363,6 @@ void TeleConference::finalize()
         mpAddress = NULL;
     }
 
-    TeleConferencePtr pThis( shared_from_this());
-    mpManager->unregisterConference( pThis);
-
     //! *this gets destructed here!
 }
 
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index b524942..b026d85 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -733,58 +733,6 @@ TpAccount* TeleManager::getAccount( const rtl::OString& rAccountID )
     return pAccount;
 }
 
-
-sal_uInt32 TeleManager::sendPacket( const TelePacket& rPacket ) const
-{
-    INFO_LOGGER( "TeleManager::sendPacket");
-
-    sal_uInt32 nSent = 0;
-    // Access to data ByteStream array forces reference count of one, provide
-    // non-const instance here before passing it down to each conference.
-    TelePacket aPacket( rPacket);
-    for (TeleConferenceVector::const_iterator it = maConferences.begin(); it != maConferences.end(); ++it)
-    {
-        if ((*it)->sendPacket( aPacket))
-            ++nSent;
-        /* TODO: what if failed? */
-    }
-    return nSent;
-}
-
-bool TeleManager::popPacket( TelePacket& rPacket )
-{
-    INFO_LOGGER( "TeleManager::popPacket");
-
-    for (TeleConferenceVector::const_iterator it = maConferences.begin(); it != maConferences.end(); ++it)
-    {
-        if ((*it)->popPacket( rPacket))
-            return true;
-    }
-    return false;
-}
-
-void TeleManager::sendFile( rtl::OUString &localUri, TeleConference::FileSentCallback pCallback, void* pUserData)
-{
-    INFO_LOGGER( "TeleManager::sendFile");
-
-    /* TODO: pluralize */
-    for (TeleConferenceVector::const_iterator it = maConferences.begin(); it != maConferences.end(); ++it)
-    {
-        (*it)->sendFile( localUri, pCallback, pUserData);
-        return;
-    }
-}
-
-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);
-}
-
-
 void TeleManager::disconnect()
 {
     INFO_LOGGER( "TeleManager::disconnect");
@@ -797,20 +745,6 @@ void TeleManager::disconnect()
 
     tp_base_client_unregister( pImpl->mpFileTransferClient);
     pImpl->mpFileTransferClient = NULL;
-
-    size_t nSize = maConferences.size();
-    for (size_t i=0; i < nSize; /*nop*/)
-    {
-        maConferences[i]->close();
-        // close() may remove the conference from the vector and move following
-        // elements to this position (hence we don't use an iterator here),
-        // adjust accordingly.
-        size_t n = maConferences.size();
-        if (n < nSize)
-            nSize = n;
-        else
-            ++i;
-    }
 }
 
 
commit 13b0a87d5fbe5e4fabbcd86f2c7f639298cfadb2
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Fri Jul 13 22:42:48 2012 +0200

    tubes: associate the document directly with TeleConference
    
    Packet communication now goes directly through TeleConference and
    TeleManager is used only for receiving files and new channels.
    
    This should also allow collaboration of different documents with
    different contacts independently.
    
    Change-Id: Iaf719dce156f1c4c9edc3db4ff0964dec0e0c944

diff --git a/sc/source/ui/collab/contacts.cxx b/sc/source/ui/collab/contacts.cxx
index 67002c2..ac16c39 100644
--- a/sc/source/ui/collab/contacts.cxx
+++ b/sc/source/ui/collab/contacts.cxx
@@ -51,6 +51,7 @@ class TubeContacts : public ModelessDialog
     SvxSimpleTableContainer maListContainer;
     SvxSimpleTable          maList;
     TeleManager*            mpManager;
+    ScDocFuncSend*          mpSender;
 
     DECL_LINK( BtnConnectHdl, void * );
     DECL_LINK( BtnListenHdl, void * );
@@ -70,6 +71,19 @@ class TubeContacts : public ModelessDialog
         {
             fprintf( stderr, "Could not register client handlers.\n" );
         }
+        else
+        {
+            // FIXME: These signals should not be bind to a document specific code.
+
+            // Receiving file is not related to any document.
+            mpManager->sigFileReceived.connect( boost::bind(
+                        &ScDocFuncRecv::fileReceived, mpSender->GetReceiver(), _1 ) );
+
+            // TODO: It's still not clear to me who should take care of this signal
+            // and what exactly it is supposed to happen.
+            mpManager->sigConferenceCreated.connect( boost::bind(
+                        &ScDocFuncSend::SetCollaboration, mpSender, _1 ) );
+        }
     }
 
     void StartBuddySession()
@@ -82,9 +96,12 @@ class TubeContacts : public ModelessDialog
             TpAccount* pAccount = pAC->mpAccount;
             TpContact* pContact = pAC->mpContact;
             fprintf( stderr, "picked %s\n", tp_contact_get_identifier( pContact ) );
-            if (!mpManager->startBuddySession( pAccount, pContact ))
+            TeleConference* pConference = mpManager->startBuddySession( pAccount, pContact );
+            if (!pConference)
                 fprintf( stderr, "could not start session with %s\n",
                         tp_contact_get_identifier( pContact ) );
+            else
+                mpSender->SetCollaboration( pConference );
         }
     }
 
@@ -97,8 +114,12 @@ class TubeContacts : public ModelessDialog
         {
             TpAccount* pAccount = pAC->mpAccount;
             fprintf( stderr, "picked %s\n", tp_account_get_display_name( pAccount ) );
-            if (!mpManager->startGroupSession( pAccount, rtl::OUString("liboroom"), rtl::OUString("conference.jabber.org") ))
+            TeleConference* pConference = mpManager->startGroupSession( pAccount,
+                    rtl::OUString("liboroom"), rtl::OUString("conference.jabber.org") );
+            if (!pConference)
                 fprintf( stderr, "could not start group session\n" );
+            else
+                mpSender->SetCollaboration( pConference );
         }
     }
 
@@ -114,24 +135,19 @@ public:
     {
         ScDocShell *pScDocShell = dynamic_cast<ScDocShell*> (SfxObjectShell::Current());
         ScDocFunc *pDocFunc = pScDocShell ? &pScDocShell->GetDocFunc() : NULL;
-        ScDocFuncSend *pSender = dynamic_cast<ScDocFuncSend*> (pDocFunc);
-        if (!pSender)
+        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 );
-            pSender = new ScDocFuncSend( *pScDocShell, pReceiver );
-            pScDocShell->SetDocFunc( pSender );
+            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();
 
-            mpManager->sigPacketReceived.connect( boost::bind(
-                    &ScDocFuncRecv::packetReceived, pReceiver, _1, _2 ));
-            mpManager->sigFileReceived.connect( boost::bind(
-                    &ScDocFuncRecv::fileReceived, pReceiver, _1 ));
-
             if (mpManager->createAccountManager())
             {
                 mpManager->prepareAccountManager();
diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index 1a10213..e5e6c54 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -105,7 +105,7 @@ void ScDocFuncRecv::RecvMessage( const rtl::OString &rString )
     }
 }
 
-void ScDocFuncRecv::packetReceived( TeleConference*, TelePacket &rPacket )
+void ScDocFuncRecv::packetReceived( TelePacket &rPacket )
 {
     rtl::OString aString( rPacket.getData(), rPacket.getSize() );
     RecvMessage( aString );
@@ -220,10 +220,10 @@ extern "C"
 void ScDocFuncSend::SendMessage( ScChangeOpWriter &rOp )
 {
     fprintf( stderr, "Op: '%s'\n", rOp.toString().getStr() );
-    if (mpManager)
+    if (mpConference)
     {
         TelePacket aPacket( "sender", rOp.toString().getStr(), rOp.toString().getLength() );
-        mpManager->sendPacket( aPacket );
+        mpConference->sendPacket( aPacket );
     }
     else // local demo mode
         mpDirect->RecvMessage( rOp.toString() );
@@ -254,8 +254,8 @@ void ScDocFuncSend::SendFile( const rtl::OUString &rURL )
     fprintf( stderr, "Temp file is '%s'\n",
              rtl::OUStringToOString( aFileURL, RTL_TEXTENCODING_UTF8 ).getStr() );
 
-    if (mpManager)
-        mpManager->sendFile( aFileURL, file_sent_cb, NULL );
+    if (mpConference)
+        mpConference->sendFile( aFileURL, file_sent_cb, NULL );
     else
         mpDirect->fileReceived( aFileURL );
 
@@ -267,7 +267,7 @@ void ScDocFuncSend::SendFile( const rtl::OUString &rURL )
 ScDocFuncSend::ScDocFuncSend( ScDocShell& rDocSh, ScDocFuncRecv *pDirect )
         : ScDocFunc( rDocSh ),
         mpDirect( pDirect ),
-        mpManager( NULL )
+        mpConference( NULL )
 {
     fprintf( stderr, "Sender created !\n" );
 }
@@ -275,9 +275,22 @@ ScDocFuncSend::ScDocFuncSend( ScDocShell& rDocSh, ScDocFuncRecv *pDirect )
 ScDocFuncSend::~ScDocFuncSend()
 {
     fprintf( stderr, "Sender destroyed !\n" );
+    mpConference->close();
     delete mpDirect;
 }
 
+void ScDocFuncSend::SetCollaboration( TeleConference* pConference )
+{
+    mpConference = pConference;
+    mpConference->sigPacketReceived.connect( boost::bind(
+                &ScDocFuncRecv::packetReceived, mpDirect, _1 ) );
+}
+
+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 bae2ad3..1bcbe23 100644
--- a/sc/source/ui/collab/sendfunc.hxx
+++ b/sc/source/ui/collab/sendfunc.hxx
@@ -217,7 +217,7 @@ public:
     ScDocFuncRecv( ScDocFuncDirect *pChain );
     virtual ~ScDocFuncRecv();
 
-    void packetReceived( TeleConference*, TelePacket &rPacket );
+    void packetReceived( TelePacket &rPacket );
 
     virtual void fileReceived( const rtl::OUString &rStr );
     virtual void RecvMessage( const rtl::OString &rString );
@@ -226,7 +226,7 @@ public:
 class ScDocFuncSend : public ScDocFunc
 {
     ScDocFuncRecv       *mpDirect;
-    TeleManager         *mpManager;
+    TeleConference      *mpConference;
 
     void SendMessage( ScChangeOpWriter &rOp );
     void SendFile( const rtl::OUString &rURL );
@@ -237,6 +237,9 @@ public:
     ScDocFuncSend( ScDocShell& rDocSh, ScDocFuncRecv *pDirect );
     virtual ~ScDocFuncSend();
 
+    void                SetCollaboration( TeleConference* pConference );
+    ScDocFuncRecv*      GetReceiver();
+
     virtual void        EnterListAction( sal_uInt16 nNameResId );
     virtual void        EndListAction();
 
diff --git a/tubes/inc/tubes/conference.hxx b/tubes/inc/tubes/conference.hxx
index b5ca996..4849b42 100644
--- a/tubes/inc/tubes/conference.hxx
+++ b/tubes/inc/tubes/conference.hxx
@@ -38,6 +38,7 @@
 #include <rtl/ustring.hxx>
 #include <telepathy-glib/telepathy-glib.h>
 #include <queue>
+#include <tubes/warnings_guard_boost_signals2.hpp>
 
 typedef ::std::queue<TelePacket> TelePacketQueue;
 
@@ -52,7 +53,7 @@ public:
     ~TeleConference();
 
     /// Close channel and call finalize()
-    void                    close();
+    TUBES_DLLPUBLIC void    close();
 
     /// Unrefs, unregisters from manager and calls dtor if last reference!
     void                    finalize();
@@ -62,18 +63,20 @@ public:
     /** @param rPacket
             non-const on purpose, see TelePacket::getData()
      */
-    bool                    sendPacket( TelePacket& rPacket );
+    TUBES_DLLPUBLIC bool    sendPacket( TelePacket& rPacket );
 
     /** Pop a received packet. */
-    TUBES_DLLPUBLIC bool    popPacket( TelePacket& rPacket );
+    bool                    popPacket( TelePacket& rPacket );
 
     /** Queue incoming data as TelePacket */
     void                    queue( const char* pDBusSender, const char* pPacket, int nSize );
     void                    queue( TelePacket &rPacket );
 
+    /** Emitted when a packet is received. */
+    boost::signals2::signal<void (TelePacket&)> sigPacketReceived;
 
     typedef void          (*FileSentCallback)( bool aSuccess, void* pUserData);
-    void                    sendFile( rtl::OUString &localUri, FileSentCallback pCallback, void* pUserData);
+    TUBES_DLLPUBLIC void    sendFile( rtl::OUString &localUri, FileSentCallback pCallback, void* pUserData);
 
     // --- following only to be called only by manager's callbacks ---
     // TODO: make friends instead
diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index 6eb7915..a15d101 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -121,7 +121,7 @@ public:
             empty, only the conference's UUID is used and rConferenceRoom is
             ignored, hopefully resulting in a local DBus tube.
      */
-    bool                    startGroupSession( TpAccount *pAccount,
+    TeleConference*         startGroupSession( TpAccount *pAccount,
                                                const rtl::OUString& rConferenceRoom,
                                                const rtl::OUString& rConferenceServer );
 
@@ -133,7 +133,7 @@ public:
         @param pBuddy
             The buddy to be connected. Must be a contact of pAccount.
      */
-    bool                    startBuddySession( TpAccount *pAccount, TpContact *pBuddy );
+    TeleConference*         startBuddySession( TpAccount *pAccount, TpContact *pBuddy );
 
     void                    unregisterConference( TeleConferencePtr pConference );
 
@@ -145,13 +145,6 @@ public:
      */
     sal_uInt32              sendPacket( const TelePacket& rPacket ) const;
 
-    /** Emitted when a packet is received, with a TeleConference*
-        pointing to the instance that received the packet.
-     */
-    boost::signals2::signal<void (TeleConference*, TelePacket&)> sigPacketReceived;
-    /* FIXME: listen to a signal on the conference rather than having it call us */
-    void                    callbackOnRecieved( TeleConference* pConference, TelePacket& rPacket ) const;
-
     /** Pop a received data packet.
 
         XXX This needs to be elaborated to pop from a specific conference, or
@@ -166,6 +159,8 @@ public:
 
     boost::signals2::signal<void ( const rtl::OUString &localUri )> sigFileReceived;
 
+    boost::signals2::signal<void (TeleConference*)> sigConferenceCreated;
+
     /// Only for use with MainLoopFlusher
     GMainLoop*              getMainLoop() const;
 
diff --git a/tubes/source/conference.cxx b/tubes/source/conference.cxx
index 458063b..1b5a397 100644
--- a/tubes/source/conference.cxx
+++ b/tubes/source/conference.cxx
@@ -411,7 +411,7 @@ void TeleConference::queue( TelePacket &rPacket )
 
     maPacketQueue.push( rPacket);
 
-    getManager()->callbackOnRecieved( this, rPacket);
+    sigPacketReceived( rPacket );
 }
 
 
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index 944d33a..b524942 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -124,9 +124,9 @@ void TeleManager::DBusChannelHandler(
             SAL_INFO( "tubes", "accepting");
             aAccepted = true;
 
-            TeleConferencePtr pConference( new TeleConference( pManager, pAccount, TP_DBUS_TUBE_CHANNEL( pChannel ) ) );
-            pManager->maConferences.push_back( pConference);
+            TeleConference* pConference = new TeleConference( pManager, pAccount, TP_DBUS_TUBE_CHANNEL( pChannel ) );
             pConference->acceptTube();
+            pManager->sigConferenceCreated( pConference );
         }
         else
         {
@@ -506,7 +506,7 @@ bool TeleManager::registerClients()
 
 
 /* TODO: factor out common code with startBuddySession() */
-bool TeleManager::startGroupSession( TpAccount *pAccount,
+TeleConference* TeleManager::startGroupSession( TpAccount *pAccount,
                                      const rtl::OUString& rUConferenceRoom,
                                      const rtl::OUString& rUConferenceServer )
 {
@@ -514,11 +514,6 @@ bool TeleManager::startGroupSession( TpAccount *pAccount,
 
     OString aSessionId( TeleManager::createUuid());
 
-    TeleConferencePtr pConference( new TeleConference( this, NULL, NULL ) );
-    maConferences.push_back( pConference);
-
-    /* TODO: associate the document with this session and conference */
-
     /* FIXME: does this work at all _creating_ a MUC? */
     // Use conference and server if given, else create conference.
     OString aConferenceRoom( OUStringToOString( rUConferenceRoom, RTL_TEXTENCODING_UTF8));
@@ -552,20 +547,25 @@ bool TeleManager::startGroupSession( TpAccount *pAccount,
     if (!pChannelRequest)
     {
         g_hash_table_unref( pRequest);
-        return false;
+        return NULL;
     }
 
     setChannelReadyHandlerInvoked( false);
 
+    TeleConference* pConference = new TeleConference( this, NULL, NULL );
+
     tp_account_channel_request_create_and_handle_channel_async(
-            pChannelRequest, NULL, TeleManager_ChannelReadyHandler, pConference.get());
+            pChannelRequest, NULL, TeleManager_ChannelReadyHandler, pConference);
 
     iterateLoop( &TeleManager::isChannelReadyHandlerInvoked);
 
     g_object_unref( pChannelRequest);
     g_hash_table_unref( pRequest);
 
-    return pConference->getChannel() != NULL && pConference->isTubeOpen();
+    if (!pConference->getChannel() || !pConference->isTubeOpen())
+        return NULL;
+
+    return pConference;
 }
 
 
@@ -598,16 +598,12 @@ void TeleManager::ensureLegacyChannel( TpAccount* pAccount, TpContact* pBuddy )
 
 
 /* TODO: factor out common code with startGroupSession() */
-bool TeleManager::startBuddySession( TpAccount *pAccount, TpContact *pBuddy )
+TeleConference* TeleManager::startBuddySession( TpAccount *pAccount, TpContact *pBuddy )
 {
     INFO_LOGGER( "TeleManager::startBuddySession");
 
     ensureLegacyChannel( pAccount, pBuddy );
 
-    TeleConferencePtr pConference( new TeleConference( this, NULL, NULL ) );
-    maConferences.push_back( pConference);
-
-    /* TODO: associate the document with this session and conference */
     const char *pIdentifier = tp_contact_get_identifier( pBuddy);
     SAL_INFO( "tubes", "TeleManager::startBuddySession: creating channel request from "
             << tp_account_get_path_suffix( pAccount)
@@ -626,20 +622,25 @@ bool TeleManager::startBuddySession( TpAccount *pAccount, TpContact *pBuddy )
     if (!pChannelRequest)
     {
         g_hash_table_unref( pRequest);
-        return false;
+        return NULL;
     }
 
     setChannelReadyHandlerInvoked( false);
 
+    TeleConference* pConference = new TeleConference( this, NULL, NULL );
+
     tp_account_channel_request_create_and_handle_channel_async(
-            pChannelRequest, NULL, TeleManager_ChannelReadyHandler, pConference.get());
+            pChannelRequest, NULL, TeleManager_ChannelReadyHandler, pConference );
 
     iterateLoop( &TeleManager::isChannelReadyHandlerInvoked);
 
     g_object_unref( pChannelRequest);
     g_hash_table_unref( pRequest);
 
-    return pConference->getChannel() != NULL && pConference->isTubeOpen();
+    if (!pConference->getChannel() || !pConference->isTubeOpen())
+        return NULL;
+
+    return pConference;
 }
 
 void TeleManager::prepareAccountManager()
@@ -750,15 +751,6 @@ sal_uInt32 TeleManager::sendPacket( const TelePacket& rPacket ) const
     return nSent;
 }
 
-
-void TeleManager::callbackOnRecieved( TeleConference* pConference, TelePacket& rPacket) const
-{
-    INFO_LOGGER( "TeleManager::callbackOnRecieved");
-
-    sigPacketReceived( pConference, rPacket );
-}
-
-
 bool TeleManager::popPacket( TelePacket& rPacket )
 {
     INFO_LOGGER( "TeleManager::popPacket");
commit af739e1c21099cf926588b752dadfd33ae02ee09
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Fri Jul 13 21:26:43 2012 +0200

    tubes: remove unused TeleConference::maSessionId
    
    Change-Id: Ic6100aa03764cd62b5426e4ec1f3aeb085241c16

diff --git a/tubes/inc/tubes/conference.hxx b/tubes/inc/tubes/conference.hxx
index 6841f9a..b5ca996 100644
--- a/tubes/inc/tubes/conference.hxx
+++ b/tubes/inc/tubes/conference.hxx
@@ -48,7 +48,7 @@ class TeleConference : public boost::enable_shared_from_this<TeleConference>
 {
 public:
 
-    TeleConference( TeleManager* pManager, TpAccount *pAccount, TpDBusTubeChannel* pChannel, const rtl::OString& rSessionId );
+    TeleConference( TeleManager* pManager, TpAccount *pAccount, TpDBusTubeChannel* pChannel );
     ~TeleConference();
 
     /// Close channel and call finalize()
@@ -106,7 +106,6 @@ private:
     bool                    spinUntilTubeEstablished();
     bool                    setTube( GDBusConnection* pTube);
 
-    rtl::OString            maSessionId;
     TeleManager*            mpManager;
     TpAccount*              mpAccount;
     TpDBusTubeChannel*      mpChannel;
diff --git a/tubes/source/conference.cxx b/tubes/source/conference.cxx
index 3df23c6..458063b 100644
--- a/tubes/source/conference.cxx
+++ b/tubes/source/conference.cxx
@@ -201,9 +201,8 @@ void TeleConference::TubeAcceptedHandler(
 }
 
 
-TeleConference::TeleConference( TeleManager* pManager, TpAccount* pAccount, TpDBusTubeChannel* pChannel, const rtl::OString& rSessionId )
+TeleConference::TeleConference( TeleManager* pManager, TpAccount* pAccount, TpDBusTubeChannel* pChannel )
     :
-        maSessionId( rSessionId ),
         mpManager( pManager),
         mpAccount( NULL),
         mpChannel( NULL),
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index 14df6e1..944d33a 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -124,7 +124,7 @@ void TeleManager::DBusChannelHandler(
             SAL_INFO( "tubes", "accepting");
             aAccepted = true;
 
-            TeleConferencePtr pConference( new TeleConference( pManager, pAccount, TP_DBUS_TUBE_CHANNEL( pChannel), ""));
+            TeleConferencePtr pConference( new TeleConference( pManager, pAccount, TP_DBUS_TUBE_CHANNEL( pChannel ) ) );
             pManager->maConferences.push_back( pConference);
             pConference->acceptTube();
         }
@@ -514,7 +514,7 @@ bool TeleManager::startGroupSession( TpAccount *pAccount,
 
     OString aSessionId( TeleManager::createUuid());
 
-    TeleConferencePtr pConference( new TeleConference( this, NULL, NULL, aSessionId));
+    TeleConferencePtr pConference( new TeleConference( this, NULL, NULL ) );
     maConferences.push_back( pConference);
 
     /* TODO: associate the document with this session and conference */
@@ -604,9 +604,7 @@ bool TeleManager::startBuddySession( TpAccount *pAccount, TpContact *pBuddy )
 
     ensureLegacyChannel( pAccount, pBuddy );
 
-    OString aSessionId( TeleManager::createUuid());
-
-    TeleConferencePtr pConference( new TeleConference( this, NULL, NULL, aSessionId));
+    TeleConferencePtr pConference( new TeleConference( this, NULL, NULL ) );
     maConferences.push_back( pConference);
 
     /* TODO: associate the document with this session and conference */
commit 0361747a269fc4db8a16ecc5fa531e69b2e878df
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Fri Jul 13 20:42:16 2012 +0200

    tubes: start collaboration from the File->Collaborate menu as the only way
    
    This also kills LIBO_TUBES variable.
    Listen button is used for registering client handlers (was LIBO_TUBES=slave).
    It may not be possible (if the name is already in use by another process).
    
    Change-Id: I04e0eb8721fa8e74c6cff585c79124b18046aad4

diff --git a/sc/source/ui/collab/contacts.cxx b/sc/source/ui/collab/contacts.cxx
index 2fc8e1a..67002c2 100644
--- a/sc/source/ui/collab/contacts.cxx
+++ b/sc/source/ui/collab/contacts.cxx
@@ -66,27 +66,9 @@ class TubeContacts : public ModelessDialog
 
     void Listen()
     {
-        ScDocShell *pScDocShell = dynamic_cast<ScDocShell*> (SfxObjectShell::Current());
-        ScDocFunc *pDocFunc = pScDocShell ? &pScDocShell->GetDocFunc() : NULL;
-        ScDocFuncSend *pSender = dynamic_cast<ScDocFuncSend*> (pDocFunc);
-        if (!pSender)
-        {
-            ScDocFuncDirect *pDirect = dynamic_cast<ScDocFuncDirect*> (pDocFunc);
-            ScDocFuncRecv *pReceiver = new ScDocFuncRecv( pDirect );
-            pSender = new ScDocFuncSend( *pScDocShell, pReceiver );
-            pScDocShell->SetDocFunc( pSender );
-        }
-        // This is a hack to work around:
-        //  `error registering client handler: Name
-        //  'org.freedesktop.Telepathy.Client.LibreOffice' already in use by another process`
-        // This happens when there is already slave instance running,
-        // so we try to init TeleManager as master.
-        bool bIsMaster = false;
-        if (!pSender->InitTeleManager( bIsMaster ))
+        if (!mpManager->registerClients())
         {
-            fprintf( stderr, "Trying to initialize TeleManager as master..\n" );
-            bIsMaster = true;
-            pSender->InitTeleManager( bIsMaster );
+            fprintf( stderr, "Could not register client handlers.\n" );
         }
     }
 
@@ -127,11 +109,39 @@ public:
         maBtnConnect( this, ScResId( BTN_CONNECT ) ),
         maBtnListen( this, ScResId( BTN_LISTEN ) ),
         maListContainer( this, ScResId( CTL_LIST ) ),
-        maList( maListContainer )
+        maList( maListContainer ),
+        mpManager( TeleManager::get() )
     {
-        // FIXME: Who should really own TeleManager and where it can be destroyed ?
-        mpManager = TeleManager::get();
+        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 );
+
+            // 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();
+
+            mpManager->sigPacketReceived.connect( boost::bind(
+                    &ScDocFuncRecv::packetReceived, pReceiver, _1, _2 ));
+            mpManager->sigFileReceived.connect( boost::bind(
+                    &ScDocFuncRecv::fileReceived, pReceiver, _1 ));
 
+            if (mpManager->createAccountManager())
+            {
+                mpManager->prepareAccountManager();
+            }
+            else
+            {
+                fprintf( stderr, "Could not create AccountManager.\n" );
+                mpManager->unref();
+            }
+        }
         maBtnConnect.SetClickHdl( LINK( this, TubeContacts, BtnConnectHdl ) );
         maBtnListen.SetClickHdl( LINK( this, TubeContacts, BtnListenHdl ) );
 
@@ -149,7 +159,10 @@ public:
         maList.InsertHeaderEntry( sHeader, HEADERBAR_APPEND, HIB_LEFT );
         Show();
     }
-    virtual ~TubeContacts() {}
+    virtual ~TubeContacts()
+    {
+        mpManager->unref();
+    }
 
     static rtl::OUString fromUTF8( const char *pStr )
     {
diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index 2989815..1a10213 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -56,22 +56,6 @@
 
 namespace css = ::com::sun::star;
 
-namespace {
-
-bool isCollabMode( bool& rbMaster )
-{
-    const char* pEnv = getenv ("LIBO_TUBES");
-    if (pEnv)
-    {
-        rbMaster = !strcmp( pEnv, "master");
-        return true;
-    }
-    rbMaster = false;
-    return false;
-}
-
-}
-
 // FIXME: really ScDocFunc should be an abstract base
 ScDocFuncRecv::ScDocFuncRecv( ScDocFuncDirect *pChain )
     : mpChain( pChain )
@@ -294,30 +278,6 @@ ScDocFuncSend::~ScDocFuncSend()
     delete mpDirect;
 }
 
-bool ScDocFuncSend::InitTeleManager( bool bIsMaster )
-{
-    if (mpManager)
-    {
-        fprintf( stderr, "TeleManager is already connected.\n" );
-        return true;
-    }
-    TeleManager *pManager = TeleManager::get();
-    pManager->sigPacketReceived.connect( boost::bind(
-            &ScDocFuncRecv::packetReceived, mpDirect, _1, _2 ));
-    pManager->sigFileReceived.connect( boost::bind(
-            &ScDocFuncRecv::fileReceived, mpDirect, _1 ));
-
-    if (pManager->createAccountManager())
-    {
-        pManager->prepareAccountManager();
-        mpManager = pManager;
-        return true;
-    }
-    fprintf( stderr, "Could not connect.\n" );
-    pManager->unref();
-    return false;
-}
-
 void ScDocFuncSend::EnterListAction( sal_uInt16 nNameResId )
 {
     // Want to group these operations for the other side ...
@@ -431,13 +391,9 @@ sal_Bool ScDocFuncSend::MergeCells( const ScCellMergeOption& rOption, sal_Bool b
     return ScDocFunc::MergeCells( rOption, bContents, bRecord, bApi );
 }
 
+#ifdef INTERCEPT
 SC_DLLPRIVATE ScDocFunc *ScDocShell::CreateDocFunc()
 {
-    // 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"))
     {
         boost::shared_ptr<ScDocFuncDirect> pDirect( new ScDocFuncDirect( *this ) );
@@ -448,16 +404,9 @@ SC_DLLPRIVATE ScDocFunc *ScDocShell::CreateDocFunc()
 
         return new ScDocFuncSend( *this, boost::shared_ptr<ScDocFuncRecv>( aDemoBus.get() ) );
     }
-    else if (isCollabMode( bIsMaster ))
-    {
-        ScDocFuncDirect *pDirect = new ScDocFuncDirect( *this );
-        ScDocFuncRecv *pReceiver = new ScDocFuncRecv( pDirect );
-        ScDocFuncSend *pSender = new ScDocFuncSend( *this, pReceiver );
-        pSender->InitTeleManager( bIsMaster );
-        return pSender;
-    }
     else
         return new ScDocFuncDirect( *this );
 }
+#endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/collab/sendfunc.hxx b/sc/source/ui/collab/sendfunc.hxx
index 1798743..bae2ad3 100644
--- a/sc/source/ui/collab/sendfunc.hxx
+++ b/sc/source/ui/collab/sendfunc.hxx
@@ -237,8 +237,6 @@ public:
     ScDocFuncSend( ScDocShell& rDocSh, ScDocFuncRecv *pDirect );
     virtual ~ScDocFuncSend();
 
-    bool                InitTeleManager( bool bIsMaster );
-
     virtual void        EnterListAction( sal_uInt16 nNameResId );
     virtual void        EndListAction();
 
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index d193500..601366b 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -2504,12 +2504,10 @@ sal_Bool ScDocShell::HasAutomaticTableName( const String& rFilter )
         || rFilter.EqualsAscii( pFilterRtf );
 }
 
-#ifndef ENABLE_TELEPATHY
 ScDocFunc *ScDocShell::CreateDocFunc()
 {
     return new ScDocFuncDirect( *this );
 }
-#endif
 
 ScDocShell::ScDocShell( const ScDocShell& rShell ) :
     SvRefBase(),
commit 15ba006551d2af1c2fbd14d25898e9728b9f2c41
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Fri Jul 13 19:34:30 2012 +0200

    tubes: remove unused TeleManager::mbAcceptIncoming
    
    Change-Id: Idb4f8e4e47be88efa9e199588936cf426b3e1ce4

diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index 4e91b7e..2989815 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -301,7 +301,7 @@ bool ScDocFuncSend::InitTeleManager( bool bIsMaster )
         fprintf( stderr, "TeleManager is already connected.\n" );
         return true;
     }
-    TeleManager *pManager = TeleManager::get( !bIsMaster );
+    TeleManager *pManager = TeleManager::get();
     pManager->sigPacketReceived.connect( boost::bind(
             &ScDocFuncRecv::packetReceived, mpDirect, _1, _2 ));
     pManager->sigFileReceived.connect( boost::bind(
diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index f926ec1..6eb7915 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -79,11 +79,10 @@ public:
             Whether to create and iterate an own GMainLoop. For testing
             purposes when no GMainLoop is available.
      */
-    TeleManager( bool bAcceptIncoming = true, bool bCreateOwnGMainLoop = false );
+    TeleManager( bool bCreateOwnGMainLoop = false );
     ~TeleManager();
 
-    static TeleManager     *get() { return pSingleton; }
-    static TeleManager     *get( bool bAcceptIncoming );
+    static TeleManager     *get();
     void                    unref();
 
     /** Connect to DBus and create AccountManager. */
@@ -239,7 +238,6 @@ 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 1254973..6f9a7ba 100644
--- a/tubes/qa/test_manager.cxx
+++ b/tubes/qa/test_manager.cxx
@@ -213,12 +213,12 @@ void TestTeleTubes::testContactList()
 
 void TestTeleTubes::testSetupManager1()
 {
-    mpManager1 = new TeleManager( true, true);
+    mpManager1 = new TeleManager(true);
 }
 
 void TestTeleTubes::testSetupManager2()
 {
-    mpManager2 = new TeleManager( true );
+    mpManager2 = new TeleManager();
 }
 
 void TestTeleTubes::testPrepareAccountManager1()
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index 047e54a..14df6e1 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -325,9 +325,8 @@ static void TeleManager_AccountManagerReadyHandler(
 }
 
 
-TeleManager::TeleManager( bool bAcceptIncoming, bool bCreateOwnGMainLoop )
+TeleManager::TeleManager( bool bCreateOwnGMainLoop )
     :
-        mbAcceptIncoming( bAcceptIncoming ),
         mbChannelReadyHandlerInvoked( false)
 {
     // The glib object types need to be initialized, else we aren't going
@@ -359,11 +358,11 @@ TeleManager::~TeleManager()
 }
 
 TeleManager *
-TeleManager::get( bool bAcceptIncoming )
+TeleManager::get()
 {
     MutexGuard aGuard( GetAnotherMutex());
     if (!pSingleton)
-        pSingleton = new TeleManager(bAcceptIncoming);
+        pSingleton = new TeleManager();
 
     nAnotherRefCount++;
     return pSingleton;
commit fd5729351ec0ab800bad1f240d5cfafc29e17da2
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Fri Jul 13 19:42:44 2012 +0200

    tubes: create TeleManager when starting Collaboration dialog
    
    And store the reference. I need to find a place where to unref it.
    
    Change-Id: I4a9d6d8dfadf94c21cfed06524f495e8e48b8323

diff --git a/sc/source/ui/collab/contacts.cxx b/sc/source/ui/collab/contacts.cxx
index f15c9e0..2fc8e1a 100644
--- a/sc/source/ui/collab/contacts.cxx
+++ b/sc/source/ui/collab/contacts.cxx
@@ -50,6 +50,7 @@ class TubeContacts : public ModelessDialog
     PushButton              maBtnListen;
     SvxSimpleTableContainer maListContainer;
     SvxSimpleTable          maList;
+    TeleManager*            mpManager;
 
     DECL_LINK( BtnConnectHdl, void * );
     DECL_LINK( BtnListenHdl, void * );
@@ -99,8 +100,7 @@ class TubeContacts : public ModelessDialog
             TpAccount* pAccount = pAC->mpAccount;
             TpContact* pContact = pAC->mpContact;
             fprintf( stderr, "picked %s\n", tp_contact_get_identifier( pContact ) );
-            TeleManager *pManager = TeleManager::get();
-            if (!pManager->startBuddySession( pAccount, pContact ))
+            if (!mpManager->startBuddySession( pAccount, pContact ))
                 fprintf( stderr, "could not start session with %s\n",
                         tp_contact_get_identifier( pContact ) );
         }
@@ -115,8 +115,7 @@ class TubeContacts : public ModelessDialog
         {
             TpAccount* pAccount = pAC->mpAccount;
             fprintf( stderr, "picked %s\n", tp_account_get_display_name( pAccount ) );
-            TeleManager *pManager = TeleManager::get();
-            if (!pManager->startGroupSession( pAccount, rtl::OUString("liboroom"), rtl::OUString("conference.jabber.org") ))
+            if (!mpManager->startGroupSession( pAccount, rtl::OUString("liboroom"), rtl::OUString("conference.jabber.org") ))
                 fprintf( stderr, "could not start group session\n" );
         }
     }
@@ -130,6 +129,9 @@ public:
         maListContainer( this, ScResId( CTL_LIST ) ),
         maList( maListContainer )
     {
+        // FIXME: Who should really own TeleManager and where it can be destroyed ?
+        mpManager = TeleManager::get();
+
         maBtnConnect.SetClickHdl( LINK( this, TubeContacts, BtnConnectHdl ) );
         maBtnListen.SetClickHdl( LINK( this, TubeContacts, BtnListenHdl ) );
 
@@ -155,11 +157,11 @@ public:
                                        RTL_TEXTENCODING_UTF8 );
     }
 
-    void Populate( const TeleManager *pManager )
+    void Populate()
     {
-        if (!pManager)
+        if (!mpManager)
             return ;
-        ContactList *pContacts = pManager->getContactList();
+        ContactList *pContacts = mpManager->getContactList();
         if ( pContacts )
         {
             fprintf( stderr, "contacts !\n" );
@@ -222,11 +224,11 @@ IMPL_LINK_NOARG( TubeContacts, BtnListenHdl )
 #endif
 
 namespace tubes {
-void createContacts( const TeleManager *pManager )
+void createContacts()
 {
 #ifdef CONTACTS_DLG
     TubeContacts *pContacts = new TubeContacts();
-    pContacts->Populate( pManager );
+    pContacts->Populate();
 #endif
 }
 }
diff --git a/sc/source/ui/collab/contacts.hxx b/sc/source/ui/collab/contacts.hxx
index 404a6fc..9c8345e 100644
--- a/sc/source/ui/collab/contacts.hxx
+++ b/sc/source/ui/collab/contacts.hxx
@@ -28,9 +28,8 @@
 
 #include "sal/config.h"
 
-class TeleManager;
 namespace tubes {
-    void createContacts( const TeleManager *pManager );
+    void createContacts();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index c1962f9..4e91b7e 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -345,7 +345,7 @@ sal_Bool ScDocFuncSend::SetNormalString( const ScAddress& rPos, const String& rT
         SendFile( rText );
 
     if ( rtl::OUString( rText ) == "contacts" )
-        tubes::createContacts( mpManager );
+        tubes::createContacts();
 
     return true; // needs some code auditing action
 }
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index a57bfda..19b2541 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -53,9 +53,8 @@
 #include "scabstdlg.hxx"
 
 #ifdef ENABLE_TELEPATHY
-#include <tubes/manager.hxx>
 namespace tubes {
-    void createContacts( const TeleManager *pManager );
+    void createContacts();
 }
 #endif
 
@@ -120,7 +119,7 @@ void ScCellShell::Execute( SfxRequest& rReq )
 
         case SID_COLLABORATION:
 #ifdef ENABLE_TELEPATHY
-            tubes::createContacts( TeleManager::get() );
+            tubes::createContacts();
 #endif
             break;
 
commit 88fbe137d9fa1757c755be934ccc26a3296018ab
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Fri Jul 13 19:06:34 2012 +0200

    tubes: split TeleManager::connect method.
    
    Use createAccountManager instead.
    Optionally also register clients for accepting tubes. Will be used more later.
    
    Change-Id: I353d45e95fa130c0c578b74d016b650039358ea7

diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index 256a9ae..c1962f9 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -307,7 +307,7 @@ bool ScDocFuncSend::InitTeleManager( bool bIsMaster )
     pManager->sigFileReceived.connect( boost::bind(
             &ScDocFuncRecv::fileReceived, mpDirect, _1 ));
 
-    if (pManager->connect())
+    if (pManager->createAccountManager())
     {
         pManager->prepareAccountManager();
         mpManager = pManager;
diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index ee74343..f926ec1 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -86,7 +86,14 @@ public:
     static TeleManager     *get( bool bAcceptIncoming );
     void                    unref();
 
-    /** Prepare the Telepathy Account Manager. Requires connect() to have succeeded.
+    /** Connect to DBus and create AccountManager. */
+    bool                    createAccountManager();
+
+    /** Setup client handlers. */
+    bool                    registerClients();
+
+    /** Prepare the Telepathy Account Manager.
+        Requires createAccountManager() to have succeeded.
 
         Invokes an async call that is not ready until meAccountManagerStatus is
         set! Until that is AMS_PREPARED nothing else will work.
@@ -131,9 +138,6 @@ public:
 
     void                    unregisterConference( TeleConferencePtr pConference );
 
-    /** Connect to DBus and setup client handler. */
-    bool                    connect();
-
     void                    disconnect();
 
     /** Send data to all registered conferences.
diff --git a/tubes/qa/test_manager.cxx b/tubes/qa/test_manager.cxx
index dcfbb47..1254973 100644
--- a/tubes/qa/test_manager.cxx
+++ b/tubes/qa/test_manager.cxx
@@ -50,8 +50,10 @@ public:
     ~TestTeleTubes();
     void testSetupManager1();
     void testSetupManager2();
-    void testConnect1();
-    void testConnect2();
+    void testCreateAccountManager1();
+    void testCreateAccountManager2();
+    void testRegisterClients1();
+    void testRegisterClients2();
     void testContactList();
     void testPrepareAccountManager1();
     void testPrepareAccountManager2();
@@ -77,8 +79,10 @@ public:
     CPPUNIT_TEST_SUITE( TestTeleTubes );
     CPPUNIT_TEST( testSetupManager1 );
     CPPUNIT_TEST( testSetupManager2 );
-    CPPUNIT_TEST( testConnect1 );
-    CPPUNIT_TEST( testConnect2 );
+    CPPUNIT_TEST( testCreateAccountManager1 );
+    CPPUNIT_TEST( testCreateAccountManager2 );
+    CPPUNIT_TEST( testRegisterClients1 );
+    CPPUNIT_TEST( testRegisterClients2 );
     CPPUNIT_TEST( testPrepareAccountManager1 );
     CPPUNIT_TEST( testPrepareAccountManager2 );
     CPPUNIT_TEST( testContactList );
@@ -257,18 +261,30 @@ void TestTeleTubes::testStartBuddySession2()
     //CPPUNIT_ASSERT( bStarted == true);
 }
 
-void TestTeleTubes::testConnect1()
+void TestTeleTubes::testCreateAccountManager1()
 {
-    bool bConnected = mpManager1->connect();
+    bool bConnected = mpManager1->createAccountManager();
     CPPUNIT_ASSERT( bConnected == true);
 }
 
-void TestTeleTubes::testConnect2()
+void TestTeleTubes::testCreateAccountManager2()
 {
-    bool bConnected = mpManager2->connect();
+    bool bConnected = mpManager2->createAccountManager();
     CPPUNIT_ASSERT( bConnected == true);
 }
 
+void TestTeleTubes::testRegisterClients1()
+{
+    bool bRegistered = mpManager1->registerClients();
+    CPPUNIT_ASSERT( bRegistered == true);
+}
+
+void TestTeleTubes::testRegisterClients2()
+{
+    bool bRegistered = mpManager2->registerClients();
+    CPPUNIT_ASSERT( bRegistered == true);
+}
+
 void TestTeleTubes::testSendPacket()
 {
     TelePacket aPacket( "", RTL_CONSTASCII_STRINGPARAM( "from 1 to 2"));
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index 06b1533..047e54a 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -79,7 +79,7 @@ class TeleManagerImpl
 {
 public:
     GMainLoop*                          mpLoop;
-    TpDBusDaemon*                       mpDBus;
+    TpAutomaticClientFactory*           mpFactory;
     TpBaseClient*                       mpClient;
     TpBaseClient*                       mpFileTransferClient;
     TpAccountManager*                   mpAccountManager;
@@ -380,34 +380,34 @@ TeleManager::unref()
 }
 
 
-bool TeleManager::connect()
+bool TeleManager::createAccountManager()
 {
-    INFO_LOGGER( "TeleManager::connect");
+    INFO_LOGGER( "TeleManager::createAccountManager");
 
     MutexGuard aGuard( GetMutex());
 
-    /* TODO: also check whether client could be registered and retry if not? */
-    SAL_INFO_IF( pImpl->mpDBus && pImpl->mpClient, "tubes", "TeleManager::connect: already connected");
-    if (pImpl->mpDBus && pImpl->mpClient)
+    SAL_INFO_IF( pImpl->mpAccountManager, "tubes", "TeleManager::createAccountManager: already connected");
+    if (pImpl->mpAccountManager)
         return true;
 
     GError* pError = NULL;
-    pImpl->mpDBus = tp_dbus_daemon_dup( &pError);
-    SAL_WARN_IF( !pImpl->mpDBus, "tubes", "TeleManager::connect: no dbus daemon");
-    if (!pImpl->mpDBus || pError)
+    TpDBusDaemon *pDBus = tp_dbus_daemon_dup( &pError);
+    SAL_WARN_IF( !pDBus, "tubes", "TeleManager::createAccountManager: no dbus daemon");
+    if (!pDBus || pError)
     {
-        SAL_WARN_IF( pError, "tubes", "TeleManager::connect: dbus daemon error: " << pError->message);
+        SAL_WARN_IF( pError, "tubes", "TeleManager::createAccountManager: dbus daemon error: " << pError->message);
         g_error_free( pError);
         return false;
     }
 
-    TpAutomaticClientFactory* pFactory = tp_automatic_client_factory_new( pImpl->mpDBus);
-    SAL_WARN_IF( !pFactory, "tubes", "TeleManager::connect: no client factory");
-    if (!pFactory)
+    pImpl->mpFactory = tp_automatic_client_factory_new( pDBus);
+    g_object_unref( pDBus);
+    SAL_WARN_IF( !pImpl->mpFactory, "tubes", "TeleManager::createAccountManager: no client factory");
+    if (!pImpl->mpFactory)
         return false;
 
     TpAccountManager* pAccountManager = tp_account_manager_new_with_factory (
-        TP_SIMPLE_CLIENT_FACTORY (pFactory));
+        TP_SIMPLE_CLIENT_FACTORY (pImpl->mpFactory));
     tp_account_manager_set_default( pAccountManager);
 
     /* Takes our ref. */
@@ -415,11 +415,22 @@ bool TeleManager::connect()
 
     pImpl->mpContactList = new ContactList(pAccountManager);
 
-    if (!mbAcceptIncoming)
+    return true;
+}
+
+bool TeleManager::registerClients()
+{
+    INFO_LOGGER( "TeleManager::registerClients");
+
+    MutexGuard aGuard( GetMutex());
+
+    /* TODO: also check whether client could be registered and retry if not? */
+    SAL_INFO_IF( pImpl->mpClient && pImpl->mpFileTransferClient, "tubes", "TeleManager::registerClients: already registered");
+    if (pImpl->mpClient && pImpl->mpFileTransferClient)
         return true;
 
     pImpl->mpClient = tp_simple_handler_new_with_factory(
-            TP_SIMPLE_CLIENT_FACTORY (pFactory), // factory
+            TP_SIMPLE_CLIENT_FACTORY (pImpl->mpFactory), // factory
             FALSE,                          // bypass_approval
             FALSE,                          // requests
             getFullClientName().getStr(),   // name
@@ -428,7 +439,7 @@ bool TeleManager::connect()
             this,                           // user_data
             NULL                            // destroy
             );
-    SAL_WARN_IF( !pImpl->mpClient, "tubes", "TeleManager::connect: no client");
+    SAL_WARN_IF( !pImpl->mpClient, "tubes", "TeleManager::registerClients: no client");
     if (!pImpl->mpClient)
         return false;
 
@@ -450,15 +461,16 @@ bool TeleManager::connect()
                 TP_PROP_CHANNEL_TYPE_DBUS_TUBE_SERVICE_NAME, G_TYPE_STRING, getFullServiceName().getStr(),
                 NULL));
 
+    GError* pError = NULL;
     if (!tp_base_client_register( pImpl->mpClient, &pError))
     {
-        SAL_WARN( "tubes", "TeleManager::connect: error registering client handler: " << pError->message);
+        SAL_WARN( "tubes", "TeleManager::registerClients: error registering client handler: " << pError->message);
         g_error_free( pError);
         return false;
     }
 
-    SAL_INFO( "tubes", "TeleManager::connect: bus name: " << tp_base_client_get_bus_name( pImpl->mpClient));
-    SAL_INFO( "tubes", "TeleManager::connect: object path: " << tp_base_client_get_object_path( pImpl->mpClient));
+    SAL_INFO( "tubes", "TeleManager::registerClients: bus name: " << tp_base_client_get_bus_name( pImpl->mpClient));
+    SAL_INFO( "tubes", "TeleManager::registerClients: object path: " << tp_base_client_get_object_path( pImpl->mpClient));
 
     /* Register a second "head" for incoming file transfers. This uses a more
      * specific filter than Empathy's handler by matching on the file
@@ -466,7 +478,7 @@ bool TeleManager::connect()
      * user isn't prompted before the channel gets passed to us.
      */
     pImpl->mpFileTransferClient = tp_simple_handler_new_with_factory (
-            TP_SIMPLE_CLIENT_FACTORY( pFactory),            // factory
+            TP_SIMPLE_CLIENT_FACTORY( pImpl->mpFactory),            // factory
             TRUE,                                           // bypass_approval
             FALSE,                                          // requests
             getFullClientName().getStr(),                   // name
@@ -485,7 +497,7 @@ bool TeleManager::connect()
     if (!tp_base_client_register( pImpl->mpFileTransferClient, &pError))
     {
         /* This shouldn't fail if registering the main handler succeeded */
-        SAL_WARN( "tubes", "TeleManager::connect: error registering file transfer handler: " << pError->message);
+        SAL_WARN( "tubes", "TeleManager::registerClients: error registering file transfer handler: " << pError->message);
         g_error_free( pError);
         return false;
     }
@@ -945,7 +957,7 @@ void TeleManager::addSuffixToNames( const char* pName )
 TeleManagerImpl::TeleManagerImpl()
     :
         mpLoop( NULL),
-        mpDBus( NULL),
+        mpFactory( NULL),
         mpClient( NULL),
         mpFileTransferClient( NULL),
         mpAccountManager( NULL),
@@ -957,12 +969,12 @@ TeleManagerImpl::TeleManagerImpl()
 
 TeleManagerImpl::~TeleManagerImpl()
 {
+    if (mpFactory)
+        g_object_unref( mpFactory);
     if (mpClient)
         g_object_unref( mpClient);
     if (mpFileTransferClient)
         g_object_unref( mpFileTransferClient);
-    if (mpDBus)
-        g_object_unref( mpDBus);
     if (mpAccountManager)
         g_object_unref( mpAccountManager);
     if (mpContactList)
commit d8dbc1aa90f1d3fde44330a054f7f4553304da59
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Sun Jul 1 23:46:44 2012 +0200

    tubes: reduce the use of boost::shared_ptr
    
    Change-Id: Iafb38cf635ac8a967e5a94965f537fe0fa021f87

diff --git a/sc/source/ui/collab/contacts.cxx b/sc/source/ui/collab/contacts.cxx
index 078bcdd..f15c9e0 100644
--- a/sc/source/ui/collab/contacts.cxx
+++ b/sc/source/ui/collab/contacts.cxx
@@ -70,9 +70,8 @@ class TubeContacts : public ModelessDialog
         ScDocFuncSend *pSender = dynamic_cast<ScDocFuncSend*> (pDocFunc);
         if (!pSender)
         {
-            delete pDocFunc;
-            boost::shared_ptr<ScDocFuncDirect> pDirect( new ScDocFuncDirect( *pScDocShell ) );
-            boost::shared_ptr<ScDocFuncRecv> pReceiver( new ScDocFuncRecv( pDirect ) );
+            ScDocFuncDirect *pDirect = dynamic_cast<ScDocFuncDirect*> (pDocFunc);
+            ScDocFuncRecv *pReceiver = new ScDocFuncRecv( pDirect );
             pSender = new ScDocFuncSend( *pScDocShell, pReceiver );
             pScDocShell->SetDocFunc( pSender );
         }
diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index b6068ad..256a9ae 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -73,12 +73,18 @@ bool isCollabMode( bool& rbMaster )
 }
 
 // FIXME: really ScDocFunc should be an abstract base
-ScDocFuncRecv::ScDocFuncRecv( boost::shared_ptr<ScDocFuncDirect>& pChain )
+ScDocFuncRecv::ScDocFuncRecv( ScDocFuncDirect *pChain )
     : mpChain( pChain )
 {
     fprintf( stderr, "Receiver created !\n" );
 }
 
+ScDocFuncRecv::~ScDocFuncRecv()
+{
+    fprintf( stderr, "Receiver destroyed !\n" );
+    delete mpChain;
+}
+
 void ScDocFuncRecv::RecvMessage( const rtl::OString &rString )
 {
     try {
@@ -274,7 +280,7 @@ void ScDocFuncSend::SendFile( const rtl::OUString &rURL )
 
 // FIXME: really ScDocFunc should be an abstract base, so
 // we don't need the rDocSh hack/pointer
-ScDocFuncSend::ScDocFuncSend( ScDocShell& rDocSh, boost::shared_ptr<ScDocFuncRecv> pDirect )
+ScDocFuncSend::ScDocFuncSend( ScDocShell& rDocSh, ScDocFuncRecv *pDirect )
         : ScDocFunc( rDocSh ),
         mpDirect( pDirect ),
         mpManager( NULL )
@@ -282,6 +288,12 @@ ScDocFuncSend::ScDocFuncSend( ScDocShell& rDocSh, boost::shared_ptr<ScDocFuncRec
     fprintf( stderr, "Sender created !\n" );
 }
 
+ScDocFuncSend::~ScDocFuncSend()
+{
+    fprintf( stderr, "Sender destroyed !\n" );
+    delete mpDirect;
+}
+
 bool ScDocFuncSend::InitTeleManager( bool bIsMaster )
 {
     if (mpManager)
@@ -291,9 +303,9 @@ bool ScDocFuncSend::InitTeleManager( bool bIsMaster )
     }
     TeleManager *pManager = TeleManager::get( !bIsMaster );
     pManager->sigPacketReceived.connect( boost::bind(
-            &ScDocFuncRecv::packetReceived, mpDirect.get(), _1, _2 ));
+            &ScDocFuncRecv::packetReceived, mpDirect, _1, _2 ));
     pManager->sigFileReceived.connect( boost::bind(
-            &ScDocFuncRecv::fileReceived, mpDirect.get(), _1 ));
+            &ScDocFuncRecv::fileReceived, mpDirect, _1 ));
 
     if (pManager->connect())
     {
@@ -438,9 +450,9 @@ SC_DLLPRIVATE ScDocFunc *ScDocShell::CreateDocFunc()
     }
     else if (isCollabMode( bIsMaster ))
     {
-        boost::shared_ptr<ScDocFuncDirect> pDirect( new ScDocFuncDirect( *this ) );
-        boost::shared_ptr<ScDocFuncRecv> pReceiver( new ScDocFuncRecv( pDirect ) );
-        ScDocFuncSend* pSender = new ScDocFuncSend( *this, pReceiver );
+        ScDocFuncDirect *pDirect = new ScDocFuncDirect( *this );
+        ScDocFuncRecv *pReceiver = new ScDocFuncRecv( pDirect );
+        ScDocFuncSend *pSender = new ScDocFuncSend( *this, pReceiver );
         pSender->InitTeleManager( bIsMaster );
         return pSender;
     }
diff --git a/sc/source/ui/collab/sendfunc.hxx b/sc/source/ui/collab/sendfunc.hxx
index 99fde98..1798743 100644
--- a/sc/source/ui/collab/sendfunc.hxx
+++ b/sc/source/ui/collab/sendfunc.hxx
@@ -207,15 +207,15 @@ public:
 
 class ScDocFuncRecv
 {
-    boost::shared_ptr<ScDocFuncDirect> mpChain;
+    ScDocFuncDirect *mpChain;
 
 protected:
     ScDocFuncRecv() {}
 
 public:
     // FIXME: really ScDocFunc should be an abstract base
-    ScDocFuncRecv( boost::shared_ptr<ScDocFuncDirect>& pChain );
-    virtual ~ScDocFuncRecv() {}
+    ScDocFuncRecv( ScDocFuncDirect *pChain );
+    virtual ~ScDocFuncRecv();
 
     void packetReceived( TeleConference*, TelePacket &rPacket );
 
@@ -225,8 +225,8 @@ public:
 
 class ScDocFuncSend : public ScDocFunc
 {
-    boost::shared_ptr<ScDocFuncRecv>    mpDirect;
-    TeleManager                         *mpManager;
+    ScDocFuncRecv       *mpDirect;
+    TeleManager         *mpManager;
 
     void SendMessage( ScChangeOpWriter &rOp );
     void SendFile( const rtl::OUString &rURL );
@@ -234,8 +234,8 @@ 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, boost::shared_ptr<ScDocFuncRecv> pDirect );
-    virtual ~ScDocFuncSend() {}
+    ScDocFuncSend( ScDocShell& rDocSh, ScDocFuncRecv *pDirect );
+    virtual ~ScDocFuncSend();
 
     bool                InitTeleManager( bool bIsMaster );
 


More information about the Libreoffice-commits mailing list