[Libreoffice-commits] .: 130 commits - config_host.mk.in configure.in .gitignore Makefile.top Module_tail_build.mk officecfg/registry RepositoryExternal.mk Repository.mk RepositoryModule_ooo.mk sc/AllLangResTarget_sc.mk sc/CppunitTest_sc_ucalc.mk sc/CustomTarget_uiconfig.mk sc/inc sc/Library_sc.mk sc/Module_sc.mk scp2/InstallModule_ooo.mk scp2/source sc/Package_uiconfig.mk sc/prj sc/sdi sc/source sc/uiconfig solenv/gbuild tubes/CppunitTest_tubes_test.mk tubes/Executable_liboapprover.mk tubes/inc tubes/Library_tubes.mk tubes/LibreOfficeApprover.client tubes/LibreOffice.client tubes/Makefile tubes/Module_tubes.mk tubes/org.freedesktop.Telepathy.Client.LibreOfficeApprover.service tubes/org.freedesktop.Telepathy.Client.LibreOffice.service tubes/Package_inc.mk tubes/prj tubes/qa tubes/README tubes/source

Matus Kukan mkukan at kemper.freedesktop.org
Tue Jul 17 07:41:58 PDT 2012


 .gitignore                                                         |    3 
 Makefile.top                                                       |    1 
 Module_tail_build.mk                                               |    1 
 Repository.mk                                                      |    2 
 RepositoryExternal.mk                                              |   24 
 RepositoryModule_ooo.mk                                            |    1 
 config_host.mk.in                                                  |    3 
 configure.in                                                       |   30 
 officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu  |    5 
 sc/AllLangResTarget_sc.mk                                          |    1 
 sc/CppunitTest_sc_ucalc.mk                                         |   12 
 sc/CustomTarget_uiconfig.mk                                        |   22 
 sc/Library_sc.mk                                                   |   21 
 sc/Module_sc.mk                                                    |    1 
 sc/Package_uiconfig.mk                                             |    2 
 sc/inc/sc.hrc                                                      |    2 
 sc/prj/build.lst                                                   |    2 
 sc/sdi/cellsh.sdi                                                  |    1 
 sc/sdi/scalc.sdi                                                   |   25 
 sc/source/ui/collab/contacts.cxx                                   |  299 +
 sc/source/ui/collab/contacts.hrc                                   |   11 
 sc/source/ui/collab/contacts.hxx                                   |   35 
 sc/source/ui/collab/contacts.src                                   |   61 
 sc/source/ui/collab/sendfunc.cxx                                   |  437 ++
 sc/source/ui/collab/sendfunc.hxx                                   |  268 +
 sc/source/ui/docshell/docfunc.cxx                                  |   45 
 sc/source/ui/docshell/docsh.cxx                                    |    9 
 sc/source/ui/inc/docfunc.hxx                                       |   11 
 sc/source/ui/inc/docsh.hxx                                         |    3 
 sc/source/ui/inc/viewfunc.hxx                                      |    6 
 sc/source/ui/view/cellsh3.cxx                                      |   14 
 sc/source/ui/view/viewfun4.cxx                                     |    8 
 sc/source/ui/view/viewfunc.cxx                                     |  178 
 sc/uiconfig/scalc/menubar/menubar.xml                              |    1 
 scp2/InstallModule_ooo.mk                                          |    1 
 scp2/source/ooo/file_library_ooo.scp                               |    4 
 solenv/gbuild/CustomTarget.mk                                      |    1 
 tubes/CppunitTest_tubes_test.mk                                    |   53 
 tubes/Executable_liboapprover.mk                                   |   47 
 tubes/Library_tubes.mk                                             |   60 
 tubes/LibreOffice.client                                           |   11 
 tubes/LibreOfficeApprover.client                                   |    8 
 tubes/Makefile                                                     |    7 
 tubes/Module_tubes.mk                                              |   44 
 tubes/Package_inc.mk                                               |   40 
 tubes/README                                                       |  130 
 tubes/inc/tubes/conference.hxx                                     |  125 
 tubes/inc/tubes/constants.h                                        |   50 
 tubes/inc/tubes/contact-list.hxx                                   |   57 
 tubes/inc/tubes/file-transfer-helper.h                             |  120 
 tubes/inc/tubes/manager.hxx                                        |  231 +
 tubes/inc/tubes/packet.hxx                                         |   83 
 tubes/inc/tubes/tubesdllapi.h                                      |   16 
 tubes/inc/tubes/warnings_guard_boost_signals2.hpp                  |   44 
 tubes/org.freedesktop.Telepathy.Client.LibreOffice.service         |    3 
 tubes/org.freedesktop.Telepathy.Client.LibreOfficeApprover.service |    3 
 tubes/prj/build.lst                                                |    2 
 tubes/prj/makefile.mk                                              |    1 
 tubes/qa/test-config.ini.example                                   |    5 
 tubes/qa/test_manager.cxx                                          |  395 ++
 tubes/source/approver.c                                            |  254 +
 tubes/source/conference.cxx                                        |  519 ++
 tubes/source/contact-list.cxx                                      |  141 
 tubes/source/file-transfer-helper.c                                | 1806 ++++++++++
 tubes/source/manager.cxx                                           |  898 ++++
 tubes/source/packet.cxx                                            |   33 
 66 files changed, 6578 insertions(+), 159 deletions(-)

New commits:
commit 864c1402e2ef9964ed69f7cad937400487bab889
Author: Eike Rathke <erack at redhat.com>
Date:   Tue Jul 17 12:47:29 2012 +0200

    tubes: rearranged some lines for readability of code
    
    Change-Id: Ifd5b086e687842721247ba893d22a2514710625d

diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 1ac9b21..4f0b304 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -212,18 +212,16 @@ void ScViewFunc::DoAutoAttributes( SCCOL nCol, SCROW nRow, SCTAB nTab,
                             aFormatSource.Col(), aFormatSource.Row(), nTab );
     if ( !((const ScMergeAttr&)pSource->GetItem(ATTR_MERGE)).IsMerged() )
     {
-        const ScPatternAttr* pDocOld = pDoc->GetPattern( nCol, nRow, nTab );
-        //  pDocOld is only valid till call ApplyPattern!
-
-        const ScStyleSheet* pSrcStyle = pSource->GetStyleSheet();
-
-        // Ho hum ... - totally untested but looks fun ! :-)
         ScRange aRange( nCol, nRow, nTab, nCol, nRow, nTab );
         ScMarkData aMark;
         aMark.SetMarkArea( aRange );
 
         ScDocFunc &rFunc = GetViewData()->GetDocFunc();
-        if ( pSrcStyle && pSrcStyle != pDocOld->GetStyleSheet() )
+
+        // pOldPattern is only valid until call to ApplyAttributes!
+        const ScPatternAttr* pOldPattern = pDoc->GetPattern( nCol, nRow, nTab );
+        const ScStyleSheet* pSrcStyle = pSource->GetStyleSheet();
+        if ( pSrcStyle && pSrcStyle != pOldPattern->GetStyleSheet() )
             rFunc.ApplyStyle( aMark, pSrcStyle->GetName(), sal_True, sal_False );
 
         rFunc.ApplyAttributes( aMark, *pSource, sal_True, sal_False );
commit ce9bc65e125cff96e53e37116a5475260f773535
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Tue Jul 17 12:00:35 2012 +0200

    tubes: do not freeze when preparing Account Manager
    
    We don't need to wait for our capabilities update to propagate from one
    account via the network and back.
    Since e3d1001c08d255c588ed6ca93f3b58b2161cce45 ContactList returns all
    online contacts regardless of its capabilities.
    
    Change-Id: Icf8982dd1e6aedec4f21920ff8020f8547d7b855

diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index 896fcc8..a01d267 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -287,14 +287,6 @@ static void TeleManager_ChannelReadyHandler(
     pConference->offerTube();
 }
 
-static gboolean caps_hack_timeout_cb (void *pUserData)
-{
-    TeleManager* pManager = reinterpret_cast<TeleManager*>(pUserData);
-
-    pManager->setAccountManagerReadyHandlerInvoked( true);
-    return FALSE;
-}
-
 static void TeleManager_AccountManagerReadyHandler(
         GObject*        pSourceObject,
         GAsyncResult*   pResult,
@@ -308,10 +300,6 @@ static void TeleManager_AccountManagerReadyHandler(
     if (!pManager)
         return;
 
-    // Hack
-    // pManager->setAccountManagerReadyHandlerInvoked( true);
-    g_timeout_add_seconds( 2, caps_hack_timeout_cb, pManager);
-
     GError* pError = NULL;
     gboolean bPrepared = tp_proxy_prepare_finish( pSourceObject, pResult, &pError);
     SAL_WARN_IF( !bPrepared, "tubes", "TeleManager_AccountManagerReadyHandler: not prepared");
@@ -322,6 +310,7 @@ static void TeleManager_AccountManagerReadyHandler(
     }
 
     pManager->setAccountManagerReady( bPrepared);
+    pManager->setAccountManagerReadyHandlerInvoked( true);
 }
 
 
commit 98cd5f3fa3f90b38073f10b4c9e62f4ace8a0477
Author: Eike Rathke <erack at redhat.com>
Date:   Tue Jul 17 11:28:22 2012 +0200

    tubes: reintroduced handling of extending formats in ScViewFunc::EnterData()
    
    In ScDocFunc*::SetNormalString() pass the underlying
    ScDocument::SetString() return value back to caller.
    
    Change-Id: Ie75169af1bd9bc55d1447ee14e1206407d750c73

diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index 27d8c93..c16364b 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -77,8 +77,11 @@ void ScDocFuncRecv::RecvMessage( const rtl::OString &rString )
                                                  RTL_TEXTENCODING_UTF8 ) );
         // FIXME: have some hash to enumeration mapping here
         if ( aReader.getMethod() == "setNormalString" )
-            mpChain->SetNormalString( aReader.getAddress( 1 ), aReader.getString( 2 ),
+        {
+            bool bNumFmtSet = false;
+            mpChain->SetNormalString( bNumFmtSet, aReader.getAddress( 1 ), aReader.getString( 2 ),
                                       aReader.getBool( 3 ) );
+        }
         else if ( aReader.getMethod() == "putCell" )
         {
             ScBaseCell *pNewCell = aReader.getCell( 2 );
@@ -313,7 +316,7 @@ void ScDocFuncSend::EndListAction()
     SendMessage( aOp );
 }
 
-sal_Bool ScDocFuncSend::SetNormalString( const ScAddress& rPos, const String& rText, sal_Bool bApi )
+sal_Bool ScDocFuncSend::SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos, const String& rText, sal_Bool bApi )
 {
     ScChangeOpWriter aOp( "setNormalString" );
     aOp.appendAddress( rPos );
@@ -321,6 +324,8 @@ sal_Bool ScDocFuncSend::SetNormalString( const ScAddress& rPos, const String& rT
     aOp.appendBool( bApi );
     SendMessage( aOp );
 
+    o_rbNumFmtSet = false;
+
     if ( rtl::OUString( rText ) == "saveme" )
         SendFile( rText );
 
diff --git a/sc/source/ui/collab/sendfunc.hxx b/sc/source/ui/collab/sendfunc.hxx
index 459be2a..9813633 100644
--- a/sc/source/ui/collab/sendfunc.hxx
+++ b/sc/source/ui/collab/sendfunc.hxx
@@ -244,7 +244,7 @@ public:
     virtual void        EnterListAction( sal_uInt16 nNameResId );
     virtual void        EndListAction();
 
-    virtual sal_Bool    SetNormalString( const ScAddress& rPos, const String& rText, sal_Bool bApi );
+    virtual sal_Bool    SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos, const String& rText, sal_Bool bApi );
     virtual sal_Bool    PutCell( const ScAddress& rPos, ScBaseCell* pNewCell, sal_Bool bApi );
     virtual sal_Bool    PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine,
                                 sal_Bool bInterpret, sal_Bool bApi );
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index f22c599..29dda06 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -754,7 +754,7 @@ sal_Bool ScDocFunc::TransliterateText( const ScMarkData& rMark, sal_Int32 nType,
 
 //------------------------------------------------------------------------
 
-sal_Bool ScDocFunc::SetNormalString( const ScAddress& rPos, const String& rText, sal_Bool bApi )
+sal_Bool ScDocFunc::SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos, const String& rText, sal_Bool bApi )
 {
     ScDocShellModificator aModificator( rDocShell );
     ScDocument* pDoc = rDocShell.GetDocument();
@@ -795,7 +795,7 @@ sal_Bool ScDocFunc::SetNormalString( const ScAddress& rPos, const String& rText,
             pHasFormat[0] = false;
     }
 
-    pDoc->SetString( rPos.Col(), rPos.Row(), rPos.Tab(), rText );
+    o_rbNumFmtSet = pDoc->SetString( rPos.Col(), rPos.Row(), rPos.Tab(), rText );
 
     if (bUndo)
     {
@@ -981,7 +981,10 @@ sal_Bool ScDocFunc::PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngi
     {
         String aText = rEngine.GetText();
         if ( bInterpret || !aText.Len() )
-            bRet = SetNormalString( rPos, aText, bApi );
+        {
+            bool bNumFmtSet = false;
+            bRet = SetNormalString( bNumFmtSet, rPos, aText, bApi );
+        }
         else
             bRet = PutCell( rPos, new ScStringCell( aText ), bApi );
     }
@@ -1100,7 +1103,10 @@ sal_Bool ScDocFunc::SetCellText( const ScAddress& rPos, const String& rText,
     if (pNewCell)
         return PutCell( rPos, pNewCell, bApi );
     else
-        return SetNormalString( rPos, rText, bApi );
+    {
+        bool bNumFmtSet = false;
+        return SetNormalString( bNumFmtSet, rPos, rText, bApi );
+    }
 }
 
 //------------------------------------------------------------------------
diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx
index 61524c7..fcf851c 100644
--- a/sc/source/ui/inc/docfunc.hxx
+++ b/sc/source/ui/inc/docfunc.hxx
@@ -95,7 +95,7 @@ public:
     virtual sal_Bool        TransliterateText( const ScMarkData& rMark, sal_Int32 nType,
                                                sal_Bool bRecord, sal_Bool bApi );
 
-    virtual sal_Bool        SetNormalString( const ScAddress& rPos, const String& rText, sal_Bool bApi );
+    virtual sal_Bool        SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos, const String& rText, sal_Bool bApi );
     virtual sal_Bool        PutCell( const ScAddress& rPos, ScBaseCell* pNewCell, sal_Bool bApi );
     virtual sal_Bool        PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine,
                                       sal_Bool bInterpret, sal_Bool bApi );
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 19153ec..1ac9b21 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -539,9 +539,16 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
         {
             ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
             for ( ; itr != itrEnd; ++itr )
-                if ( rFunc.SetNormalString( ScAddress( nCol, nRow, *itr ),
-                                            rString, sal_False ) )
+            {
+                bool bNumFmtSet = false;
+                rFunc.SetNormalString( bNumFmtSet, ScAddress( nCol, nRow, *itr ), rString, sal_False );
+                if (bNumFmtSet)
+                {
+                    /* FIXME: if set on any sheet results in changed only on
+                     * sheet nTab for TestFormatArea() and DoAutoAttributes() */
                     bNumFmtChanged = true;
+                }
+            }
         }
 
         sal_Bool bAutoFormat = TestFormatArea(nCol, nRow, nTab, bNumFmtChanged);
commit 1abd8c22a56bd51a2da2be4da1ef79be04e5b985
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Tue Jul 17 00:32:37 2012 +0200

    tubes: improve contacts dialog
    
    - do not show until it's ready
    - do not close it with buttons
    - buttons for both 1-1 and MUC sessions
    - display all online contacts
    
    Change-Id: Idfbea7ffdf76ef3f31dbeeefe62d69cb5e3e64b7

diff --git a/sc/source/ui/collab/contacts.cxx b/sc/source/ui/collab/contacts.cxx
index 51bd1e4..4536e2e 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              maBtnGroup;
     PushButton              maBtnInvite;
     PushButton              maBtnListen;
     SvxSimpleTableContainer maListContainer;
@@ -55,6 +56,7 @@ class TubeContacts : public ModelessDialog
     ScDocFuncSend*          mpSender;
 
     DECL_LINK( BtnConnectHdl, void * );
+    DECL_LINK( BtnGroupHdl, void * );
     DECL_LINK( BtnInviteHdl, void * );
     DECL_LINK( BtnListenHdl, void * );
 
@@ -152,12 +154,14 @@ public:
         ModelessDialog( NULL, ScResId( RID_SCDLG_CONTACTS ) ),
         maLabel( this, ScResId( FL_LABEL ) ),
         maBtnConnect( this, ScResId( BTN_CONNECT ) ),
+        maBtnGroup( this, ScResId( BTN_GROUP ) ),
         maBtnInvite( this, ScResId( BTN_INVITE ) ),
         maBtnListen( this, ScResId( BTN_LISTEN ) ),
         maListContainer( this, ScResId( CTL_LIST ) ),
         maList( maListContainer ),
         mpManager( TeleManager::get() )
     {
+        Hide();
         ScDocShell *pScDocShell = dynamic_cast<ScDocShell*> (SfxObjectShell::Current());
         ScDocFunc *pDocFunc = pScDocShell ? &pScDocShell->GetDocFunc() : NULL;
         mpSender = dynamic_cast<ScDocFuncSend*> (pDocFunc);
@@ -185,6 +189,7 @@ public:
             }
         }
         maBtnConnect.SetClickHdl( LINK( this, TubeContacts, BtnConnectHdl ) );
+        maBtnGroup.SetClickHdl( LINK( this, TubeContacts, BtnGroupHdl ) );
         maBtnInvite.SetClickHdl( LINK( this, TubeContacts, BtnInviteHdl ) );
         maBtnListen.SetClickHdl( LINK( this, TubeContacts, BtnListenHdl ) );
 
@@ -200,7 +205,6 @@ public:
         sHeader += String( ScResId( STR_HEADER_NAME ) );
         sHeader += '\t';
         maList.InsertHeaderEntry( sHeader, HEADERBAR_APPEND, HIB_LEFT );
-        Show();
     }
     virtual ~TubeContacts()
     {
@@ -221,7 +225,6 @@ public:
         ContactList *pContacts = mpManager->getContactList();
         if ( pContacts )
         {
-            fprintf( stderr, "contacts !\n" );
             AccountContactPairV aPairs = pContacts->getContacts();
             AccountContactPairV::iterator it;
             for( it = aPairs.begin(); it != aPairs.end(); it++ )
@@ -240,10 +243,6 @@ public:
                         aImage = Image( aBitmap );
                     }
                 }
-                fprintf( stderr, "'%s' => '%s' '%s'\n",
-                         tp_account_get_display_name( it->first ),
-                         tp_contact_get_alias( it->second ),
-                         tp_contact_get_identifier( it->second ) );
                 rtl::OUStringBuffer aEntry( 128 );
                 aEntry.append( sal_Unicode( '\t' ) );
                 aEntry.append( fromUTF8 ( tp_contact_get_alias( it->second ) ) );
@@ -256,31 +255,31 @@ public:
                 pEntry->SetUserData( &maACs.back() );
             }
         }
+        Show();
     }
 };
 
 IMPL_LINK_NOARG( TubeContacts, BtnConnectHdl )
 {
-#if 0
     StartBuddySession();
-#else
+    return 0;
+}
+
+IMPL_LINK_NOARG( TubeContacts, BtnGroupHdl )
+{
     StartGroupSession();
-#endif
-    Close();
     return 0;
 }
 
 IMPL_LINK_NOARG( TubeContacts, BtnInviteHdl )
 {
     Invite();
-    Close();
     return 0;
 }
 
 IMPL_LINK_NOARG( TubeContacts, BtnListenHdl )
 {
     Listen();
-    Close();
     return 0;
 }
 
diff --git a/sc/source/ui/collab/contacts.hrc b/sc/source/ui/collab/contacts.hrc
index 59aeb67..4d7cc5f 100644
--- a/sc/source/ui/collab/contacts.hrc
+++ b/sc/source/ui/collab/contacts.hrc
@@ -5,6 +5,7 @@
 #define BTN_CONNECT          3
 #define BTN_INVITE           4
 #define BTN_LISTEN           5
+#define BTN_GROUP            6
 
 #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 27d1dca..6a868ae 100644
--- a/sc/source/ui/collab/contacts.src
+++ b/sc/source/ui/collab/contacts.src
@@ -9,7 +9,7 @@ ModelessDialog RID_SCDLG_CONTACTS
     Hide = FALSE ;
     Moveable = TRUE ;
     Closeable = TRUE ;
-    Size = MAP_APPFONT ( 220 , 215 ) ;
+    Size = MAP_APPFONT ( 220 , 225 ) ;
     OutputSize = TRUE ;
     Text [ en-US ] = "Contacts" ;
 
@@ -23,7 +23,13 @@ ModelessDialog RID_SCDLG_CONTACTS
     {
         Pos = MAP_APPFONT( 70 , 200 );
         Size = MAP_APPFONT( 50 , 10 );
-        Text [ en-US ] = "Collaborate";
+        Text [ en-US ] = "startBuddySession";
+    };
+    PushButton BTN_GROUP
+    {
+        Pos = MAP_APPFONT( 70 , 212 );
+        Size = MAP_APPFONT( 50 , 10 );
+        Text [ en-US ] = "startGroupSession";
     };
     PushButton BTN_INVITE
     {
diff --git a/tubes/source/contact-list.cxx b/tubes/source/contact-list.cxx
index c74a950..0d46803 100644
--- a/tubes/source/contact-list.cxx
+++ b/tubes/source/contact-list.cxx
@@ -61,6 +61,7 @@ ContactList::ContactList(TpAccountManager *pAccountManager)
         TP_CONTACT_FEATURE_ALIAS,
         TP_CONTACT_FEATURE_AVATAR_DATA,
         TP_CONTACT_FEATURE_CAPABILITIES,
+        TP_CONTACT_FEATURE_PRESENCE,
         TP_CONTACT_FEATURE_INVALID);
 }
 
@@ -70,16 +71,25 @@ ContactList::~ContactList()
     mpAccountManager = NULL;
 }
 
-static gboolean
-contact_supports_libo_dtube (TpContact *contact)
+static bool
+tb_contact_is_online (TpContact *contact)
 {
-    TpCapabilities *caps = tp_contact_get_capabilities (contact);
-
-    if (caps == NULL)
-        return FALSE;
-
-    return tp_capabilities_supports_dbus_tubes (caps,
-        TP_HANDLE_TYPE_CONTACT, TeleManager::getFullServiceName().getStr());
+    switch (tp_contact_get_presence_type (contact))
+    {
+        case TP_CONNECTION_PRESENCE_TYPE_UNSET:
+        case TP_CONNECTION_PRESENCE_TYPE_OFFLINE:
+            return false;
+        case TP_CONNECTION_PRESENCE_TYPE_AVAILABLE:
+        case TP_CONNECTION_PRESENCE_TYPE_AWAY:
+        case TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY:
+        case TP_CONNECTION_PRESENCE_TYPE_HIDDEN:
+        case TP_CONNECTION_PRESENCE_TYPE_BUSY:
+            return true;
+        case TP_CONNECTION_PRESENCE_TYPE_UNKNOWN:
+        case TP_CONNECTION_PRESENCE_TYPE_ERROR:
+        default:
+            return false;
+    }
 }
 
 AccountContactPairV ContactList::getContacts()
@@ -113,7 +123,7 @@ AccountContactPairV ContactList::getContacts()
               reinterpret_cast<TpContact *>(g_ptr_array_index (contacts, i));
 
           if (contact != self &&
-              contact_supports_libo_dtube (contact))
+              tb_contact_is_online (contact))
             {
               g_object_ref (account);
               g_object_ref (contact);
commit a64fa6c7235559667afef1bb185203fd0d262e44
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Jul 16 22:44:12 2012 +0200

    tubes: do the "interpret once" only if not API in ScDocFunc::PutCell()
    
    Change-Id: Ib8bcb89b83f0fd98f1b01f72308d07af1f7777f9

diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index bfeb3f0..f22c599 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -848,7 +848,11 @@ sal_Bool ScDocFunc::PutCell( const ScAddress& rPos, ScBaseCell* pNewCell, sal_Bo
 
     pDoc->PutCell( rPos, pNewCell );
 
-    if ( !bXMLLoading && pNewCell->GetCellType() == CELLTYPE_FORMULA && !pDoc->GetAutoCalc() )
+    // This "interpret once" block was moved from ScViewFunc::EnterData() where
+    // it was never executed from API, so don't do it here. For performance
+    // reasons API calls may disable calculation while operating and
+    // recalculate once when done.
+    if ( !bXMLLoading && !bApi && pNewCell->GetCellType() == CELLTYPE_FORMULA && !pDoc->GetAutoCalc() )
     {
         ScFormulaCell *pFormCell = static_cast<ScFormulaCell *>( pNewCell );
         // calculate just the cell once and set Dirty again
commit da7af862e856e453e0ed624b76199d7cf21ad3c2
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Jul 16 22:27:46 2012 +0200

    tubes: removed duplicated iterator initialization in ScViewFunc::EnterData()
    
    Change-Id: I322e937e9c3e0bc478d566e1b14499cc610bd273

diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index cbd7bb7..19153ec 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -557,7 +557,6 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
         {
             ScRangeList aChangeRanges;
             ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
-            itr = rMark.begin();
             for (; itr != itrEnd; ++itr)
                 aChangeRanges.Append( ScRange( nCol, nRow, *itr ) );
 
commit 581860f47173a3ebc8f834d229e8d2878aaf12ba
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Jul 16 17:49:14 2012 +0200

    tubes: guard unref() against "accidental" calls
    
    Change-Id: I73b0f8faaa9b6d0707153f3150ca531a33cb0dd3

diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index b026d85..896fcc8 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -372,7 +372,7 @@ void
 TeleManager::unref()
 {
     MutexGuard aGuard( GetAnotherMutex());
-    if (--nAnotherRefCount == 0) {
+    if (nAnotherRefCount && --nAnotherRefCount == 0) {
         delete pSingleton;
         pSingleton = NULL;
     }
commit b1032a684c0ddb1fd1aabe979517897f4ba91dd7
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Jul 16 17:40:52 2012 +0200

    tubes: do not use mpManager after unref
    
    Change-Id: If8bb6da915d6470b9796e26c46f3e8f2000879fd

diff --git a/sc/source/ui/collab/contacts.cxx b/sc/source/ui/collab/contacts.cxx
index 725b1f5..51bd1e4 100644
--- a/sc/source/ui/collab/contacts.cxx
+++ b/sc/source/ui/collab/contacts.cxx
@@ -82,6 +82,9 @@ class TubeContacts : public ModelessDialog
 
     void Listen()
     {
+        if (!mpManager)
+            return ;
+
         if (!mpManager->registerClients())
         {
             fprintf( stderr, "Could not register client handlers.\n" );
@@ -103,6 +106,9 @@ class TubeContacts : public ModelessDialog
 
     void StartBuddySession()
     {
+        if (!mpManager)
+            return ;
+
         AccountContact *pAC = NULL;
         if (maList.FirstSelected())
             pAC = static_cast<AccountContact*> (maList.FirstSelected()->GetUserData());
@@ -122,6 +128,9 @@ class TubeContacts : public ModelessDialog
 
     void StartGroupSession()
     {
+        if (!mpManager)
+            return ;
+
         AccountContact *pAC = NULL;
         if (maList.FirstSelected())
             pAC = static_cast<AccountContact*> (maList.FirstSelected()->GetUserData());
@@ -172,6 +181,7 @@ public:
             {
                 fprintf( stderr, "Could not create AccountManager.\n" );
                 mpManager->unref();
+                mpManager = NULL;
             }
         }
         maBtnConnect.SetClickHdl( LINK( this, TubeContacts, BtnConnectHdl ) );
@@ -194,7 +204,8 @@ public:
     }
     virtual ~TubeContacts()
     {
-        mpManager->unref();
+        if (mpManager)
+            mpManager->unref();
     }
 
     static rtl::OUString fromUTF8( const char *pStr )
commit bf4c5e3454874c85cf15973fced9a83c0a95913d
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Jul 16 16:59:00 2012 +0200

    tubes: check mpConference before using it
    
    Change-Id: I8949ae1f43439465701244b501f6779debc34565

diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index e70021b..27d8c93 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -275,15 +275,17 @@ ScDocFuncSend::ScDocFuncSend( ScDocShell& rDocSh, ScDocFuncRecv *pDirect )
 ScDocFuncSend::~ScDocFuncSend()
 {
     fprintf( stderr, "Sender destroyed !\n" );
-    mpConference->close();
+    if (mpConference)
+        mpConference->close();
     delete mpDirect;
 }
 
 void ScDocFuncSend::SetCollaboration( TeleConference* pConference )
 {
     mpConference = pConference;
-    mpConference->sigPacketReceived.connect( boost::bind(
-                &ScDocFuncRecv::packetReceived, mpDirect, _1 ) );
+    if (mpConference)
+        mpConference->sigPacketReceived.connect( boost::bind(
+                    &ScDocFuncRecv::packetReceived, mpDirect, _1 ) );
 }
 
 TeleConference* ScDocFuncSend::GetConference()
commit f5ee5d794f0c7500755df68b2b57d56e4566c9c1
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 c8a6a1ff706600562bc08fe1dd490c149bbf8012
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 ee956067d633f8e0b40e303e58c10bba42a0da85
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 53b180a49af8aaa25b9b38a8b020113483f0af6b
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 019f35d7e4e4494af3a11429219cb361897a7872
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 36170cd0dbc3409270cf3cf998805a790ee6228f
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 2c3d5ac..cfdd455 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -2500,12 +2500,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 eafd7161ed544cebb450a334d8c13d15170e987b
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 f0685e2c69a3a31c2669c67d7638e7a1dbd203a3
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 fd9d7f35d9cec7584061d9930c05189ec5838036
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 17c549221427bde2390368be39f48134409a933f
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 );
 
commit 44b32113852758a0b14d2f52b072d6d96d659f27
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Jul 12 12:24:32 2012 +0200

    include tubes/warnings_guard_boost_signals2.hpp [-Werror=shadow]
    
    Change-Id: I20236d46f5ed631b073f572a16a098f64f998179

diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index 9ab6e78..b6068ad 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -28,7 +28,7 @@
 
 #include "sal/config.h"
 
-#include <boost/signals2.hpp>
+#include <tubes/warnings_guard_boost_signals2.hpp>
 #include <vector>
 
 #include "cell.hxx"
commit 6b2da137e595002eb2d8d76d24960be8aa07f07c
Author: Eike Rathke <erack at redhat.com>
Date:   Wed Jul 11 20:03:35 2012 +0200

    tubes: warning guard for boost/signals2.hpp [-Werror=shadow]
    
    boost 1.44 boost/signals2.hpp with gcc 4.6.3 causes
    solver/unxlngx6/inc/boost/signals2/detail/slot_template.hpp:122:7: error:
    declaration of ‘slot’ shadows a member of 'this' [-Werror=shadow]
    
    Change-Id: I276e008aaebaca9c115bedc58d29c93c6dc526b8

diff --git a/tubes/Package_inc.mk b/tubes/Package_inc.mk
index 3ac8876..2573c05 100644
--- a/tubes/Package_inc.mk
+++ b/tubes/Package_inc.mk
@@ -33,6 +33,7 @@ $(eval $(call gb_Package_add_file,tubes_inc,inc/tubes/file-transfer-helper.h,tub
 $(eval $(call gb_Package_add_file,tubes_inc,inc/tubes/manager.hxx,tubes/manager.hxx))
 $(eval $(call gb_Package_add_file,tubes_inc,inc/tubes/packet.hxx,tubes/packet.hxx))
 $(eval $(call gb_Package_add_file,tubes_inc,inc/tubes/tubesdllapi.h,tubes/tubesdllapi.h))
+$(eval $(call gb_Package_add_file,tubes_inc,inc/tubes/warnings_guard_boost_signals2.hpp,tubes/warnings_guard_boost_signals2.hpp))
 
 #$(eval $(call gb_Package_add_file,tubes_inc,inc/tubes/,tubes/))
 
diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index 326cc51..ee74343 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -40,7 +40,7 @@
 #include <tools/link.hxx>
 #include <telepathy-glib/telepathy-glib.h>
 #include <vector>
-#include <boost/signals2.hpp>
+#include <tubes/warnings_guard_boost_signals2.hpp>
 
 // For testing purposes, we might need more in future.
 #define LIBO_TUBES_DBUS_INTERFACE "org.libreoffice.calc"
diff --git a/tubes/inc/tubes/warnings_guard_boost_signals2.hpp b/tubes/inc/tubes/warnings_guard_boost_signals2.hpp
new file mode 100644
index 0000000..90a4c08
--- /dev/null
+++ b/tubes/inc/tubes/warnings_guard_boost_signals2.hpp
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_WARNINGS_GUARD_BOOST_SIGNALS2_HPP
+#define INCLUDED_WARNINGS_GUARD_BOOST_SIGNALS2_HPP
+
+// Because the GCC system_header mechanism doesn't work in .c/.cxx compilation
+// units and more important affects the rest of the current include file, the
+// warnings guard is separated into this header file on its own.
+
+// boost 1.44 boost/signals2.hpp with gcc 4.6.3 causes
+// solver/unxlngx6/inc/boost/signals2/detail/slot_template.hpp:122:7: error: 
+// declaration of ‘slot’ shadows a member of 'this' [-Werror=shadow]
+// We want to minimize the patches to external headers, so the warnings are
+// disabled here instead of in the header file itself.
+#ifdef _MSC_VER
+#pragma warning(push, 1)
+#elif defined __GNUC__
+#pragma GCC system_header
+#endif
+#include <boost/signals2.hpp>
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
+#endif // INCLUDED_WARNINGS_GUARD_BOOST_SIGNALS2_HPP
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 1c15d509daff7835b02f8c5c47efca31b2788d61
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Tue Jul 3 12:40:14 2012 +0200

    tubes: add Collaborate menu item only in telepathy enabled build
    
    Change-Id: Ibfd90941a64540d0e59f1e884a0992758cbc3bb8

diff --git a/sc/CustomTarget_uiconfig.mk b/sc/CustomTarget_uiconfig.mk
new file mode 100644
index 0000000..8e4e1ae
--- /dev/null
+++ b/sc/CustomTarget_uiconfig.mk
@@ -0,0 +1,22 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_CustomTarget_CustomTarget,sc/uiconfig))
+
+ifeq ($(ENABLE_TELEPATHY),TRUE)
+$(call gb_CustomTarget_get_target,sc/uiconfig) : \
+	$(OUTDIR)/xml/uiconfig/modules/scalc/menubar/menubar.xml
+
+$(OUTDIR)/xml/uiconfig/modules/scalc/menubar/menubar.xml : $(SRCDIR)/sc/uiconfig/scalc/menubar/menubar.xml \
+		| $(OUTDIR)/xml/uiconfig/modules/scalc/menubar/.dir
+	sed 's/.*.uno:Collaborate.*/            <menu:menuseparator\/>\n            <menu:menuitem menu:id=".uno:Collaborate"\/>/' $< > $@
+
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index b2cd2ab..bf606df 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -25,6 +25,7 @@ $(eval $(call gb_Module_Module,sc))
 
 $(eval $(call gb_Module_add_targets,sc,\
 	AllLangResTarget_sc \
+	CustomTarget_uiconfig \
 	Library_sc \
 	Library_scd \
 	Library_scfilt \
diff --git a/sc/Package_uiconfig.mk b/sc/Package_uiconfig.mk
index bc3ec4d..f85a789 100644
--- a/sc/Package_uiconfig.mk
+++ b/sc/Package_uiconfig.mk
@@ -21,7 +21,9 @@
 # instead of those above.
 
 $(eval $(call gb_Package_Package,sc_uiconfig,$(SRCDIR)/sc/uiconfig))
+ifneq ($(ENABLE_TELEPATHY),TRUE)
 $(eval $(call gb_Package_add_file,sc_uiconfig,xml/uiconfig/modules/scalc/menubar/menubar.xml,scalc/menubar/menubar.xml))
+endif
 $(eval $(call gb_Package_add_file,sc_uiconfig,xml/uiconfig/modules/scalc/statusbar/statusbar.xml,scalc/statusbar/statusbar.xml))
 $(eval $(call gb_Package_add_file,sc_uiconfig,xml/uiconfig/modules/scalc/toolbar/alignmentbar.xml,scalc/toolbar/alignmentbar.xml))
 $(eval $(call gb_Package_add_file,sc_uiconfig,xml/uiconfig/modules/scalc/toolbar/arrowshapes.xml,scalc/toolbar/arrowshapes.xml))
diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml
index ac94fa0..5a95a26 100644
--- a/sc/uiconfig/scalc/menubar/menubar.xml
+++ b/sc/uiconfig/scalc/menubar/menubar.xml
@@ -15,8 +15,7 @@
             <menu:menuseparator/>
             <menu:menuitem menu:id=".uno:Reload"/>
             <menu:menuitem menu:id=".uno:VersionDialog"/>
-            <menu:menuseparator/>
-            <menu:menuitem menu:id=".uno:Collaborate"/>
+            <!-- .uno:Collaborate menuitem, see CustomTarget_uiconfig.mk -->
             <menu:menuseparator/>
             <menu:menuitem menu:id=".uno:ExportTo"/>
             <menu:menuitem menu:id=".uno:ExportToPDF"/>
diff --git a/solenv/gbuild/CustomTarget.mk b/solenv/gbuild/CustomTarget.mk
index 31c5e9c..d8b59d2 100644
--- a/solenv/gbuild/CustomTarget.mk
+++ b/solenv/gbuild/CustomTarget.mk

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list