[Libreoffice-commits] .: 7 commits - sc/source tubes/inc tubes/Package_inc.mk tubes/qa tubes/source
Matus Kukan
mkukan at kemper.freedesktop.org
Sat Aug 4 13:52:31 PDT 2012
sc/source/ui/collab/sccollaboration.cxx | 11 +-
sc/source/ui/collab/sendfunc.cxx | 101 ++--------------------
sc/source/ui/collab/sendfunc.hxx | 22 ----
sc/source/ui/inc/sccollaboration.hxx | 1
tubes/Package_inc.mk | 1
tubes/inc/tubes/collaboration.hxx | 1
tubes/inc/tubes/conference.hxx | 19 ----
tubes/inc/tubes/manager.hxx | 19 ++--
tubes/inc/tubes/warnings_guard_boost_signals2.hpp | 44 ---------
tubes/qa/test_manager.cxx | 31 ------
tubes/source/conference.cxx | 74 ++++++++--------
tubes/source/contacts.cxx | 24 +++++
tubes/source/contacts.hrc | 1
tubes/source/contacts.src | 6 +
tubes/source/manager.cxx | 95 ++++++++++++--------
15 files changed, 164 insertions(+), 286 deletions(-)
New commits:
commit c3c9ae052bd062c9057fd08675e0593d00ccd601
Author: Matúš Kukan <matus.kukan at gmail.com>
Date: Sat Aug 4 22:40:40 2012 +0200
tubes: do not queue incoming packets
Change-Id: Ida0f3b9ce7cebdb0517457900d2b0b2377e6c8ab
diff --git a/tubes/inc/tubes/conference.hxx b/tubes/inc/tubes/conference.hxx
index ad5ae1e..9222f0f 100644
--- a/tubes/inc/tubes/conference.hxx
+++ b/tubes/inc/tubes/conference.hxx
@@ -59,17 +59,14 @@ public:
TUBES_DLLPUBLIC bool sendPacket( const OString& rPacket );
- /** Pop a received packet. */
- bool popPacket( OString& rPacket );
-
void invite( TpContact *pContact );
typedef void (*FileSentCallback)( bool aSuccess, void* pUserData);
TUBES_DLLPUBLIC void sendFile( TpContact* pContact, rtl::OUString &localUri, FileSentCallback pCallback, void* pUserData);
const OString& getUuid() const { return msUuid; }
- Collaboration* getCollaboration() const { return mpCollaboration; }
- void setCollaboration( Collaboration* pCollaboration ) { mpCollaboration = pCollaboration; }
+ Collaboration* getCollaboration() const;
+ void setCollaboration( Collaboration* pCollaboration );
// --- following only to be called only by manager's callbacks ---
// TODO: make friends instead
@@ -82,8 +79,6 @@ public:
void setTubeOfferedHandlerInvoked( bool b );
bool isTubeOfferedHandlerInvoked() const;
bool isMaster() const;
- /** Queue incoming data as OString */
- void queue( const OString& rPacket );
void setUuid( const OString& rUuid ) { msUuid = rUuid; }
private:
diff --git a/tubes/qa/test_manager.cxx b/tubes/qa/test_manager.cxx
index 89afd11..850d5d5 100644
--- a/tubes/qa/test_manager.cxx
+++ b/tubes/qa/test_manager.cxx
@@ -221,22 +221,7 @@ void TestTeleTubes::testReceivePacket()
* and extracting UUID from the name.
*/
- sal_uInt32 nReceivedPackets = 0;
- /* We expect to get every packet we send pushed
- * onto the queue to be echoed locally.
- */
- bool bOk;
- do
- {
- OString aReceived;
- bOk = mpConference1->popPacket( aReceived );
- if (bOk)
- {
- ++nReceivedPackets;
- CPPUNIT_ASSERT( "from 1 to 2" == aReceived );
- }
- } while (bOk);
- CPPUNIT_ASSERT( nReceivedPackets == mnSentPackets );
+ // TODO implement me
}
void TestTeleTubes::FileSent( bool success, void * )
diff --git a/tubes/source/conference.cxx b/tubes/source/conference.cxx
index 4eaaf8c..88109df 100644
--- a/tubes/source/conference.cxx
+++ b/tubes/source/conference.cxx
@@ -34,7 +34,6 @@
#include <tubes/manager.hxx>
#include <telepathy-glib/telepathy-glib.h>
-#include <queue>
#if defined SAL_LOG_INFO
namespace
@@ -65,11 +64,8 @@ struct InfoLogger
class TeleConferenceImpl
{
- typedef ::std::queue<OString> TelePacketQueue;
-
public:
guint maObjectRegistrationId;
- TelePacketQueue maPacketQueue;
GDBusConnection* mpTube;
bool mbTubeOfferedHandlerInvoked : 1;
@@ -129,7 +125,8 @@ static void TeleConference_MethodCallHandler(
SAL_INFO( "tubes", "TeleConference_MethodCallHandler: received packet from sender "
<< (pSender ? pSender : "(null)") << " with size " << nPacketSize);
OString aPacket( pPacketData, nPacketSize );
- pConference->queue( aPacket );
+ if (pConference->getCollaboration())
+ pConference->getCollaboration()->PacketReceived( aPacket );
// Master needs to send the packet back to impose ordering,
// so the slave can execute his command.
if (pConference->isMaster())
@@ -447,8 +444,8 @@ bool TeleConference::sendPacket( const OString& rPacket )
-1, NULL, NULL, NULL);
// If we started the session, we can execute commands immediately.
- if (mbMaster)
- queue( rPacket );
+ if (mbMaster && mpCollaboration)
+ mpCollaboration->PacketReceived( rPacket );
return true;
}
@@ -458,16 +455,15 @@ bool TeleConference::isMaster() const
return mbMaster;
}
-void TeleConference::queue( const OString &rPacket )
+Collaboration* TeleConference::getCollaboration() const
{
- INFO_LOGGER( "TeleConference::queue");
-
- pImpl->maPacketQueue.push( rPacket);
-
- if (mpCollaboration)
- mpCollaboration->PacketReceived( rPacket );
+ return mpCollaboration;
}
+void TeleConference::setCollaboration( Collaboration* pCollaboration )
+{
+ mpCollaboration = pCollaboration;
+}
void TeleConference::invite( TpContact *pContact )
{
@@ -559,16 +555,4 @@ void TeleConference::sendFile( TpContact* pContact, rtl::OUString &localUri, Fil
TeleConference_FTReady, pReq);
}
-
-bool TeleConference::popPacket( OString& rPacket )
-{
- INFO_LOGGER( "TeleConference::popPacket");
-
- if (pImpl->maPacketQueue.empty())
- return false;
- rPacket = pImpl->maPacketQueue.front();
- pImpl->maPacketQueue.pop();
- return true;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index fd00cd0..f371497 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -236,7 +236,8 @@ void TeleManager::broadcastPacket( const OString& rPacket )
INFO_LOGGER_F( "TeleManager::broadcastPacket" );
for (TeleManagerImpl::DemoConferences::iterator it = pImpl->maDemoConferences.begin();
it != pImpl->maDemoConferences.end(); ++it)
- (*it)->queue( rPacket );
+ if ((*it)->getCollaboration())
+ (*it)->getCollaboration()->PacketReceived( rPacket );
}
bool TeleManager::hasWaitingConference()
commit b3da63d28fedeee9306fb2c44ffd85271408fa7d
Author: Matúš Kukan <matus.kukan at gmail.com>
Date: Sat Aug 4 22:14:08 2012 +0200
tubes: avoid boost::signaling received packets
Change-Id: I63e262aa05ec7c06c15eaf74201b6ac1966e2e56
diff --git a/sc/source/ui/collab/sccollaboration.cxx b/sc/source/ui/collab/sccollaboration.cxx
index 1008263..e9c4ea0 100644
--- a/sc/source/ui/collab/sccollaboration.cxx
+++ b/sc/source/ui/collab/sccollaboration.cxx
@@ -46,6 +46,13 @@ sal_uInt64 ScCollaboration::GetId()
return reinterpret_cast<sal_uInt64> (mpScDocShell);
}
+void ScCollaboration::PacketReceived( const OString& rPacket )
+{
+ ScDocFuncSend* pSender = GetScDocFuncSend();
+ if (pSender)
+ return pSender->RecvMessage( rPacket );
+}
+
void ScCollaboration::SetCollaboration( TeleConference* pConference )
{
ScDocFunc* pDocFunc = &mpScDocShell->GetDocFunc();
diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index 7c2e1f3..6b59d53 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -86,11 +86,6 @@ void ScDocFuncSend::RecvMessage( const rtl::OString &rString )
}
}
-void ScDocFuncSend::packetReceived( const OString &rPacket )
-{
- RecvMessage( rPacket );
-}
-
extern "C"
{
static void file_sent_cb( bool aSuccess, void* /* pUserData */ )
@@ -159,9 +154,6 @@ ScDocFuncSend::~ScDocFuncSend()
void ScDocFuncSend::SetCollaboration( TeleConference* pConference )
{
mpConference = pConference;
- if (mpConference)
- mpConference->sigPacketReceived.connect( boost::bind(
- &ScDocFuncSend::packetReceived, this, _1 ) );
}
TeleConference* ScDocFuncSend::GetConference()
diff --git a/sc/source/ui/collab/sendfunc.hxx b/sc/source/ui/collab/sendfunc.hxx
index d4485d5..07160c8 100644
--- a/sc/source/ui/collab/sendfunc.hxx
+++ b/sc/source/ui/collab/sendfunc.hxx
@@ -209,8 +209,6 @@ class ScDocFuncSend : public ScDocFunc
ScDocFuncDirect *mpDirect;
TeleConference *mpConference;
- void packetReceived( const OString &rPacket );
- void RecvMessage( const rtl::OString &rString );
void SendMessage( ScChangeOpWriter &rOp );
public:
@@ -219,6 +217,7 @@ public:
ScDocFuncSend( ScDocShell& rDocSh, ScDocFuncDirect *pDirect );
virtual ~ScDocFuncSend();
+ void RecvMessage( const rtl::OString &rString );
void SetCollaboration( TeleConference* pConference );
TeleConference* GetConference();
// TODO: I think this could be moved to TeleManager later.
diff --git a/sc/source/ui/inc/sccollaboration.hxx b/sc/source/ui/inc/sccollaboration.hxx
index bfdb985..811f1cf 100644
--- a/sc/source/ui/inc/sccollaboration.hxx
+++ b/sc/source/ui/inc/sccollaboration.hxx
@@ -24,6 +24,7 @@ public:
virtual void ContactLeft();
virtual TeleConference* GetConference();
virtual sal_uInt64 GetId();
+ virtual void PacketReceived( const OString& rPacket );
virtual void SetCollaboration( TeleConference* pConference );
virtual void SendFile( TpContact* pContact, const OUString& rURL );
private:
diff --git a/tubes/Package_inc.mk b/tubes/Package_inc.mk
index c6606fc..1aff70b 100644
--- a/tubes/Package_inc.mk
+++ b/tubes/Package_inc.mk
@@ -31,6 +31,5 @@ $(eval $(call gb_Package_add_file,tubes_inc,inc/tubes/conference.hxx,tubes/confe
$(eval $(call gb_Package_add_file,tubes_inc,inc/tubes/contacts.hxx,tubes/contacts.hxx))
$(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/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))
# vim: set noet sw=4 ts=4:
diff --git a/tubes/inc/tubes/collaboration.hxx b/tubes/inc/tubes/collaboration.hxx
index 6249173..65595cd 100644
--- a/tubes/inc/tubes/collaboration.hxx
+++ b/tubes/inc/tubes/collaboration.hxx
@@ -26,6 +26,7 @@ public:
virtual void ContactLeft() = 0;
virtual TeleConference* GetConference() = 0;
virtual sal_uInt64 GetId() = 0;
+ virtual void PacketReceived( const OString& rPacket ) = 0;
virtual void SetCollaboration( TeleConference* pConference ) = 0;
// TODO: I think this could be moved to TeleManager later.
virtual void SendFile( TpContact* pContact, const OUString& rURL ) = 0;
diff --git a/tubes/inc/tubes/conference.hxx b/tubes/inc/tubes/conference.hxx
index 1a8627b..ad5ae1e 100644
--- a/tubes/inc/tubes/conference.hxx
+++ b/tubes/inc/tubes/conference.hxx
@@ -32,7 +32,6 @@
#include <sal/config.h>
#include "tubes/tubesdllapi.h"
#include <rtl/ustring.hxx>
-#include <tubes/warnings_guard_boost_signals2.hpp>
class Collaboration;
class TeleConferenceImpl;
@@ -65,9 +64,6 @@ public:
void invite( TpContact *pContact );
- /** Emitted when a packet is received. */
- boost::signals2::signal<void (const OString&)> sigPacketReceived;
-
typedef void (*FileSentCallback)( bool aSuccess, void* pUserData);
TUBES_DLLPUBLIC void sendFile( TpContact* pContact, rtl::OUString &localUri, FileSentCallback pCallback, void* pUserData);
const OString& getUuid() const { return msUuid; }
diff --git a/tubes/inc/tubes/warnings_guard_boost_signals2.hpp b/tubes/inc/tubes/warnings_guard_boost_signals2.hpp
deleted file mode 100644
index 90a4c08..0000000
--- a/tubes/inc/tubes/warnings_guard_boost_signals2.hpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- 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: */
diff --git a/tubes/qa/test_manager.cxx b/tubes/qa/test_manager.cxx
index ca03bae..89afd11 100644
--- a/tubes/qa/test_manager.cxx
+++ b/tubes/qa/test_manager.cxx
@@ -63,7 +63,6 @@ public:
void testDestroyTeleTubes();
void testFailAlways();
- void ReceiverCallback( const OString &rPacket );
static void FileSent( bool success, void *user_data);
// Order is significant.
@@ -91,7 +90,6 @@ static TpContact* mpAccepterContact = NULL;
static GMainLoop* mpMainLoop = NULL;
static bool maFileSentSuccess = false;
static sal_uInt32 mnSentPackets = 0;
-static sal_uInt32 mnPacketReceivedEmissions = 0;
static OUString maTestConfigIniURL;
static OString maOffererIdentifier;
static OString maAccepterIdentifier;
@@ -185,16 +183,6 @@ void TestTeleTubes::testPrepareAccountManager()
CPPUNIT_ASSERT( eStatus == TeleManager::AMS_PREPARED);
}
-void TestTeleTubes::ReceiverCallback( const OString & rPacket )
-{
- SAL_INFO( "tubes", "TestTeleTubes::ReceiverCallback: " << rPacket.getStr());
- if (!rPacket.isEmpty())
- {
- // we could pop a packet here
- mnPacketReceivedEmissions++;
- }
-}
-
void TestTeleTubes::testStartBuddySession()
{
TpAccount *pAcc1 = mpManager->getAccount(maOffererIdentifier);
@@ -221,11 +209,9 @@ void TestTeleTubes::testSendPacket()
{
OString aPacket( "from 1 to 2" );
- mpConference1->sigPacketReceived.connect( boost::bind( &TestTeleTubes::ReceiverCallback, this, _1 ) );
bool bSentPacket = mpConference1->sendPacket( aPacket );
CPPUNIT_ASSERT( bSentPacket );
mnSentPackets++;
- CPPUNIT_ASSERT( mnPacketReceivedEmissions == 1 );
}
void TestTeleTubes::testReceivePacket()
diff --git a/tubes/source/conference.cxx b/tubes/source/conference.cxx
index 6203685..4eaaf8c 100644
--- a/tubes/source/conference.cxx
+++ b/tubes/source/conference.cxx
@@ -27,9 +27,11 @@
*/
#include <tubes/conference.hxx>
-#include <tubes/manager.hxx>
+
+#include <tubes/collaboration.hxx>
#include <tubes/constants.h>
#include <tubes/file-transfer-helper.h>
+#include <tubes/manager.hxx>
#include <telepathy-glib/telepathy-glib.h>
#include <queue>
@@ -230,6 +232,7 @@ static void TeleConference_TubeAcceptedHandler(
TeleConference::TeleConference( TpAccount* pAccount,
TpDBusTubeChannel* pChannel, const OString sUuid, bool bMaster )
:
+ mpCollaboration( NULL ),
mpAccount( NULL ),
mpChannel( NULL ),
msUuid( sUuid ),
@@ -461,7 +464,8 @@ void TeleConference::queue( const OString &rPacket )
pImpl->maPacketQueue.push( rPacket);
- sigPacketReceived( rPacket );
+ if (mpCollaboration)
+ mpCollaboration->PacketReceived( rPacket );
}
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index 6c9007a..fd00cd0 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -236,7 +236,7 @@ void TeleManager::broadcastPacket( const OString& rPacket )
INFO_LOGGER_F( "TeleManager::broadcastPacket" );
for (TeleManagerImpl::DemoConferences::iterator it = pImpl->maDemoConferences.begin();
it != pImpl->maDemoConferences.end(); ++it)
- (*it)->sigPacketReceived( rPacket );
+ (*it)->queue( rPacket );
}
bool TeleManager::hasWaitingConference()
@@ -296,7 +296,7 @@ static void TeleManager_TransferDone( EmpathyFTHandler *handler, TpFileTransferC
SAL_INFO( "tubes", "TeleManager_TransferDone: hooray!");
GFile *gfile = empathy_ft_handler_get_gfile( handler);
char *uri = g_file_get_uri( gfile);
- rtl::OUString aUri( uri, strlen( uri), RTL_TEXTENCODING_UTF8);
+ rtl::OUString aUri( OUString::createFromAscii( uri ) );
g_free( uri);
TeleManager_fileReceived( aUri );
commit ee1b41dcc2fd00c9b45c7a7a7e2357c2c9c23ed5
Author: Matúš Kukan <matus.kukan at gmail.com>
Date: Sat Aug 4 20:12:57 2012 +0200
tubes: avoid ugly SAL_DLLPUBLIC_EXPORT here
Change-Id: Icd839cd70dd32f766ad52d74fcf3cff28281da7e
diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index cbc3787..7c2e1f3 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -47,9 +47,6 @@
namespace css = ::com::sun::star;
-// FIXME: this is only meant for demo I think
-extern void TeleManager_fileReceived( const OUString& );
-
void ScDocFuncSend::RecvMessage( const rtl::OString &rString )
{
try {
@@ -135,10 +132,7 @@ void ScDocFuncSend::SendFile( TpContact* pContact, const rtl::OUString &sUuid )
fprintf( stderr, "Temp file is '%s'\n",
rtl::OUStringToOString( aFileURL, RTL_TEXTENCODING_UTF8 ).getStr() );
- if (pContact)
- mpConference->sendFile( pContact, aFileURL, file_sent_cb, NULL );
- else
- TeleManager_fileReceived( aFileURL );
+ mpConference->sendFile( pContact, aFileURL, file_sent_cb, NULL );
// FIXME: unlink the file after send ...
}
diff --git a/tubes/source/conference.cxx b/tubes/source/conference.cxx
index 76fb0ae..6203685 100644
--- a/tubes/source/conference.cxx
+++ b/tubes/source/conference.cxx
@@ -526,11 +526,19 @@ static void TeleConference_FTReady( EmpathyFTHandler *handler, GError *error, gp
}
}
-
+// TODO: move sending file to TeleManager
+extern void TeleManager_fileReceived( const OUString& );
void TeleConference::sendFile( TpContact* pContact, rtl::OUString &localUri, FileSentCallback pCallback, void* pUserData)
{
INFO_LOGGER( "TeleConference::sendFile");
+ if (!pContact)
+ {
+ // used in demo mode
+ TeleManager_fileReceived( localUri );
+ return;
+ }
+
SAL_WARN_IF( ( !mpAccount || !mpChannel), "tubes",
"can't send a file before the tube is set up");
if ( !mpAccount || !mpChannel)
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index e8368df..6c9007a 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -249,8 +249,8 @@ void TeleManager::setCurrentUuid( const OString& rUuid )
pImpl->msCurrentUUID = rUuid;
}
-// FIXME this is exported only because of ScDocFuncDemo
-SAL_DLLPUBLIC_EXPORT void TeleManager_fileReceived( const rtl::OUString &rStr )
+// FIXME: should be static and not used in conference.cxx
+void TeleManager_fileReceived( const rtl::OUString &rStr )
{
SAL_INFO( "tubes", "TeleManager_fileReceived: incoming file: " << rStr );
@@ -291,7 +291,7 @@ SAL_DLLPUBLIC_EXPORT void TeleManager_fileReceived( const rtl::OUString &rStr )
}
}
-void TeleManager_TransferDone( EmpathyFTHandler *handler, TpFileTransferChannel *, gpointer )
+static void TeleManager_TransferDone( EmpathyFTHandler *handler, TpFileTransferChannel *, gpointer )
{
SAL_INFO( "tubes", "TeleManager_TransferDone: hooray!");
GFile *gfile = empathy_ft_handler_get_gfile( handler);
commit 8269d572d084d6db200f2c02a439c7d95a235643
Author: Matúš Kukan <matus.kukan at gmail.com>
Date: Sat Aug 4 19:59:39 2012 +0200
tubes: remove unused parameter
Change-Id: I22cd7cc866696dd7def7d7cb20d00da68d408137
diff --git a/tubes/inc/tubes/conference.hxx b/tubes/inc/tubes/conference.hxx
index 150e77f..1a8627b 100644
--- a/tubes/inc/tubes/conference.hxx
+++ b/tubes/inc/tubes/conference.hxx
@@ -35,7 +35,6 @@
#include <tubes/warnings_guard_boost_signals2.hpp>
class Collaboration;
-class TeleManager;
class TeleConferenceImpl;
typedef struct _TpAccount TpAccount;
typedef struct _TpContact TpContact;
@@ -47,8 +46,7 @@ class TeleConference
{
public:
- TeleConference( TeleManager* pManager,
- TpAccount* pAccount,
+ TeleConference( TpAccount* pAccount,
TpDBusTubeChannel* pChannel,
const OString sUuid = OString(),
bool bMaster = false );
@@ -82,7 +80,6 @@ public:
void setChannel( TpAccount* pAccount, TpDBusTubeChannel* pChannel );
bool offerTube();
bool acceptTube();
- TeleManager* getManager() const { return mpManager; }
// Only for callbacks.
bool setTube( GDBusConnection* pTube );
@@ -103,7 +100,6 @@ private:
bool spinUntilTubeEstablished();
Collaboration* mpCollaboration;
- TeleManager* mpManager;
TpAccount* mpAccount;
TpDBusTubeChannel* mpChannel;
OString msUuid;
diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index 7c895e4..ab5e39a 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -144,7 +144,7 @@ public:
// Only for callbacks.
static void addConference( TeleConference* pConference );
- void setChannelReadyHandlerInvoked( bool b );
+ static void setChannelReadyHandlerInvoked( bool b );
bool isChannelReadyHandlerInvoked() const;
void setAccountManagerReadyHandlerInvoked( bool b );
bool isAccountManagerReadyHandlerInvoked() const;
diff --git a/tubes/source/conference.cxx b/tubes/source/conference.cxx
index c1592bf..76fb0ae 100644
--- a/tubes/source/conference.cxx
+++ b/tubes/source/conference.cxx
@@ -96,11 +96,6 @@ static void TeleConference_MethodCallHandler(
if (!pConference)
return;
- TeleManager* pManager = pConference->getManager();
- SAL_WARN_IF( !pManager, "tubes", "TeleConference_MethodCallHandler: no manager");
- if (!pManager)
- return;
-
if (tp_strdiff (pMethodName, LIBO_TUBES_DBUS_MSG_METHOD))
{
g_dbus_method_invocation_return_error ( pInvocation,
@@ -232,10 +227,9 @@ static void TeleConference_TubeAcceptedHandler(
}
-TeleConference::TeleConference( TeleManager* pManager, TpAccount* pAccount,
+TeleConference::TeleConference( TpAccount* pAccount,
TpDBusTubeChannel* pChannel, const OString sUuid, bool bMaster )
:
- mpManager( pManager ),
mpAccount( NULL ),
mpChannel( NULL ),
msUuid( sUuid ),
@@ -426,9 +420,8 @@ bool TeleConference::sendPacket( const OString& rPacket )
return true;
}
- OSL_ENSURE( mpManager, "tubes: TeleConference::sendPacket: no TeleManager");
SAL_WARN_IF( !pImpl->mpTube, "tubes", "TeleConference::sendPacket: no tube");
- if (!(mpManager && pImpl->mpTube))
+ if (!pImpl->mpTube)
return false;
/* FIXME: in GLib 2.32 we can use g_variant_new_fixed_array(). It does
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index ae79e5a..e8368df 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -173,7 +173,7 @@ void TeleManager_DBusChannelHandler(
SAL_INFO( "tubes", "accepting");
aAccepted = true;
- TeleConference* pConference = new TeleConference( pManager, pAccount, TP_DBUS_TUBE_CHANNEL( pChannel ) );
+ TeleConference* pConference = new TeleConference( pAccount, TP_DBUS_TUBE_CHANNEL( pChannel ) );
pConference->acceptTube();
pManager->addConference( pConference );
@@ -264,7 +264,7 @@ SAL_DLLPUBLIC_EXPORT void TeleManager_fileReceived( const rtl::OUString &rStr )
if (sUuid == "demo")
{
sUuid = TeleManager::createUuid();
- TeleConference* pConference = new TeleConference( NULL, NULL, NULL, sUuid );
+ TeleConference* pConference = new TeleConference( NULL, NULL, sUuid );
TeleManager::addConference( pConference );
TeleManager::registerDemoConference( pConference );
}
@@ -405,12 +405,7 @@ static void TeleManager_ChannelReadyHandler(
if (!pConference)
return;
- TeleManager* pManager = pConference->getManager();
- SAL_WARN_IF( !pManager, "tubes", "TeleManager_ChannelReadyHandler: no manager");
- if (!pManager)
- return;
-
- pManager->setChannelReadyHandlerInvoked( true);
+ TeleManager::setChannelReadyHandlerInvoked( true );
TpAccountChannelRequest* pChannelRequest = TP_ACCOUNT_CHANNEL_REQUEST( pSourceObject);
GError* pError = NULL;
@@ -628,7 +623,7 @@ TeleConference* TeleManager::startDemoSession()
{
INFO_LOGGER( "TeleManager::startDemoSession");
- TeleConference* pConference = new TeleConference( NULL, NULL, NULL, "demo" );
+ TeleConference* pConference = new TeleConference( NULL, NULL, "demo" );
registerDemoConference( pConference );
return pConference;
@@ -681,7 +676,7 @@ TeleConference* TeleManager::startGroupSession( TpAccount *pAccount,
setChannelReadyHandlerInvoked( false);
- TeleConference* pConference = new TeleConference( this, NULL, NULL, aSessionId );
+ TeleConference* pConference = new TeleConference( NULL, NULL, aSessionId );
tp_account_channel_request_create_and_handle_channel_async(
pChannelRequest, NULL, TeleManager_ChannelReadyHandler, pConference);
@@ -759,7 +754,7 @@ TeleConference* TeleManager::startBuddySession( TpAccount *pAccount, TpContact *
setChannelReadyHandlerInvoked( false);
- TeleConference* pConference = new TeleConference( this, NULL, NULL, createUuid(), true );
+ TeleConference* pConference = new TeleConference( NULL, NULL, createUuid(), true );
tp_account_channel_request_create_and_handle_channel_async(
pChannelRequest, NULL, TeleManager_ChannelReadyHandler, pConference );
commit 525b1ad345ab04eb56e69cb67c38df1229897d83
Author: Matúš Kukan <matus.kukan at gmail.com>
Date: Sat Aug 4 19:48:06 2012 +0200
tubes: call the function directly
Change-Id: Ic9f02f7df77fabaec585c3f53bf0a86044bf27bb
diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index 06ff543..7c895e4 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -152,9 +152,6 @@ public:
/** Only the callback of prepareAccountManager() is to set this. */
void setAccountManagerReady( bool bPrepared);
- /** Iterate our GMainLoop, blocking, unconditionally. */
- void iterateLoop();
-
typedef bool (*CallBackInvokedFunc)();
/** Iterate our GMainLoop, blocking, until the callback is done. */
void iterateLoop( CallBackInvokedFunc pFunc );
@@ -163,10 +160,6 @@ public:
/** Iterate our GMainLoop, blocking, until the callback is done. */
void iterateLoop( ManagerCallBackInvokedFunc pFunc );
- typedef bool (TeleConference::*ConferenceCallBackInvokedFunc)() const;
- /** Iterate our GMainLoop, blocking, until the callback is done. */
- void iterateLoop( const TeleConference* pConference, ConferenceCallBackInvokedFunc pFunc );
-
/// "LibreOfficeWhatEver"
static rtl::OString getFullClientName();
diff --git a/tubes/source/conference.cxx b/tubes/source/conference.cxx
index 3d1bd0a..c1592bf 100644
--- a/tubes/source/conference.cxx
+++ b/tubes/source/conference.cxx
@@ -273,7 +273,10 @@ void TeleConference::setChannel( TpAccount *pAccount, TpDBusTubeChannel* pChanne
bool TeleConference::spinUntilTubeEstablished()
{
- mpManager->iterateLoop( this, &TeleConference::isTubeOfferedHandlerInvoked);
+ while (!isTubeOfferedHandlerInvoked())
+ {
+ g_main_context_iteration( NULL, TRUE );
+ }
bool bOpen = pImpl->mpTube != NULL;
SAL_INFO( "tubes", "TeleConference::spinUntilTubeEstablished: tube open: " << bOpen);
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index e07db63..ae79e5a 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -925,13 +925,6 @@ rtl::OString TeleManager::getFullObjectPath()
return aStr;
}
-
-void TeleManager::iterateLoop()
-{
- g_main_context_iteration( NULL, TRUE );
-}
-
-
void TeleManager::iterateLoop( CallBackInvokedFunc pFunc )
{
while (!(*pFunc)())
@@ -949,16 +942,6 @@ void TeleManager::iterateLoop( ManagerCallBackInvokedFunc pFunc )
}
}
-
-void TeleManager::iterateLoop( const TeleConference* pConference, ConferenceCallBackInvokedFunc pFunc )
-{
- while (!(pConference->*pFunc)())
- {
- g_main_context_iteration( NULL, TRUE );
- }
-}
-
-
// static
rtl::OString TeleManager::createUuid()
{
commit 8b3596bccdb4b3aa252c5d4a7db96cbff57632f5
Author: Matúš Kukan <matus.kukan at gmail.com>
Date: Sat Aug 4 19:27:02 2012 +0200
tubes: get rid of old way of demo collaboration and ScDocFuncDemo
Also merge ScDocFuncRecv into ScDocFuncSend, now that is possible.
Change-Id: I39bec141a99a8c8ce00400f581cce8d87f7d1972
diff --git a/sc/source/ui/collab/sccollaboration.cxx b/sc/source/ui/collab/sccollaboration.cxx
index 4651bfc..1008263 100644
--- a/sc/source/ui/collab/sccollaboration.cxx
+++ b/sc/source/ui/collab/sccollaboration.cxx
@@ -53,9 +53,7 @@ void ScCollaboration::SetCollaboration( TeleConference* pConference )
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( *mpScDocShell, pReceiver );
+ pSender = new ScDocFuncSend( *mpScDocShell, dynamic_cast<ScDocFuncDirect*> (pDocFunc) );
mpScDocShell->SetDocFunc( pSender );
}
pSender->SetCollaboration( pConference );
diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index 0530980..cbc3787 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -50,20 +50,7 @@ namespace css = ::com::sun::star;
// FIXME: this is only meant for demo I think
extern void TeleManager_fileReceived( const OUString& );
-// FIXME: really ScDocFunc should be an abstract base
-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 )
+void ScDocFuncSend::RecvMessage( const rtl::OString &rString )
{
try {
ScChangeOpReader aReader( rtl::OUString( rString.getStr(),
@@ -73,26 +60,26 @@ void ScDocFuncRecv::RecvMessage( const rtl::OString &rString )
if ( aReader.getMethod() == "setNormalString" )
{
bool bNumFmtSet = false;
- mpChain->SetNormalString( bNumFmtSet, aReader.getAddress( 1 ), aReader.getString( 2 ),
+ mpDirect->SetNormalString( bNumFmtSet, aReader.getAddress( 1 ), aReader.getString( 2 ),
aReader.getBool( 3 ) );
}
else if ( aReader.getMethod() == "putCell" )
{
ScBaseCell *pNewCell = aReader.getCell( 2 );
if ( pNewCell )
- mpChain->PutCell( aReader.getAddress( 1 ), pNewCell, aReader.getBool( 3 ) );
+ mpDirect->PutCell( aReader.getAddress( 1 ), pNewCell, aReader.getBool( 3 ) );
}
else if ( aReader.getMethod() == "enterListAction" )
- mpChain->EnterListAction( aReader.getInt( 1 ) );
+ mpDirect->EnterListAction( aReader.getInt( 1 ) );
else if ( aReader.getMethod() == "endListAction" )
- mpChain->EndListAction();
+ mpDirect->EndListAction();
else if ( aReader.getMethod() == "showNote" )
- mpChain->ShowNote( aReader.getAddress( 1 ), aReader.getBool( 2 ) );
+ mpDirect->ShowNote( aReader.getAddress( 1 ), aReader.getBool( 2 ) );
else if ( aReader.getMethod() == "setNoteText" )
- mpChain->SetNoteText( aReader.getAddress( 1 ), aReader.getString( 2 ),
+ mpDirect->SetNoteText( aReader.getAddress( 1 ), aReader.getString( 2 ),
aReader.getBool( 3 ) );
else if ( aReader.getMethod() == "renameTable" )
- mpChain->RenameTable( aReader.getInt( 1 ), aReader.getString( 2 ),
+ mpDirect->RenameTable( aReader.getInt( 1 ), aReader.getString( 2 ),
aReader.getBool( 3 ), aReader.getBool( 4 ) );
else
fprintf( stderr, "Error: unknown message '%s' (%d)\n",
@@ -102,42 +89,11 @@ void ScDocFuncRecv::RecvMessage( const rtl::OString &rString )
}
}
-void ScDocFuncRecv::packetReceived( const OString &rPacket )
+void ScDocFuncSend::packetReceived( const OString &rPacket )
{
RecvMessage( rPacket );
}
-/*
- * Provides a local bus that doesn't require an IM channel for
- * quick demoing, export INTERCEPT=demo # to enable.
- */
-class ScDocFuncDemo : public ScDocFuncRecv
-{
- std::vector< boost::shared_ptr<ScDocFuncRecv> > maClients;
- public:
- // FIXME: really ScDocFuncRecv should be an abstract base
- ScDocFuncDemo()
- : ScDocFuncRecv()
- {
- fprintf( stderr, "Receiver created !\n" );
- }
- virtual ~ScDocFuncDemo() {}
-
- void add_client (const boost::shared_ptr<ScDocFuncRecv> &aClient)
- {
- maClients.push_back( aClient );
- }
-
- virtual void RecvMessage( const rtl::OString &rString )
- {
- // FIXME: Lifecycle nightmare
- std::vector< boost::shared_ptr<ScDocFuncRecv> > aCopy( maClients );
- for (std::vector< boost::shared_ptr<ScDocFuncRecv> >::iterator i
- = aCopy.begin(); i != aCopy.end(); ++i)
- (*i)->RecvMessage(rString);
- }
-};
-
extern "C"
{
static void file_sent_cb( bool aSuccess, void* /* pUserData */ )
@@ -150,11 +106,7 @@ void ScDocFuncSend::SendMessage( ScChangeOpWriter &rOp )
{
fprintf( stderr, "Op: '%s'\n", rOp.toString().getStr() );
if (mpConference)
- {
mpConference->sendPacket( rOp.toString() );
- }
- else // local demo mode
- mpDirect->RecvMessage( rOp.toString() );
}
void ScDocFuncSend::SendFile( TpContact* pContact, const rtl::OUString &sUuid )
@@ -193,7 +145,7 @@ void ScDocFuncSend::SendFile( TpContact* pContact, const rtl::OUString &sUuid )
// FIXME: really ScDocFunc should be an abstract base, so
// we don't need the rDocSh hack/pointer
-ScDocFuncSend::ScDocFuncSend( ScDocShell& rDocSh, ScDocFuncRecv *pDirect )
+ScDocFuncSend::ScDocFuncSend( ScDocShell& rDocSh, ScDocFuncDirect *pDirect )
: ScDocFunc( rDocSh ),
mpDirect( pDirect ),
mpConference( NULL )
@@ -207,8 +159,7 @@ ScDocFuncSend::~ScDocFuncSend()
if (mpConference)
mpConference->close();
- if (!dynamic_cast<ScDocFuncDemo*> (mpDirect))
- delete mpDirect;
+ delete mpDirect;
}
void ScDocFuncSend::SetCollaboration( TeleConference* pConference )
@@ -216,7 +167,7 @@ void ScDocFuncSend::SetCollaboration( TeleConference* pConference )
mpConference = pConference;
if (mpConference)
mpConference->sigPacketReceived.connect( boost::bind(
- &ScDocFuncRecv::packetReceived, mpDirect, _1 ) );
+ &ScDocFuncSend::packetReceived, this, _1 ) );
}
TeleConference* ScDocFuncSend::GetConference()
@@ -341,21 +292,9 @@ sal_Bool ScDocFuncSend::MergeCells( const ScCellMergeOption& rOption, sal_Bool b
ScDocFunc *ScDocShell::CreateDocFunc()
{
- if (getenv ("INTERCEPT"))
- {
- ScDocFuncDirect* pDirect = new ScDocFuncDirect( *this );
- boost::shared_ptr<ScDocFuncRecv> pReceiver( new ScDocFuncRecv( pDirect ) );
-
- static boost::shared_ptr<ScDocFuncDemo> aDemoBus( new ScDocFuncDemo() );
- aDemoBus->add_client( pReceiver ); // a lifecycle horror no doubt.
-
- return new ScDocFuncSend( *this, aDemoBus.get() );
- }
- else if (TeleManager::hasWaitingConference())
+ if (TeleManager::hasWaitingConference())
{
- ScDocFuncDirect *pDirect = new ScDocFuncDirect( *this );
- ScDocFuncRecv *pReceiver = new ScDocFuncRecv( pDirect );
- ScDocFuncSend *pSender = new ScDocFuncSend( *this, pReceiver );
+ ScDocFuncSend *pSender = new ScDocFuncSend( *this, new ScDocFuncDirect( *this ) );
TeleConference* pConference = TeleManager::getConference();
pConference->setCollaboration( mpCollaboration );
pSender->SetCollaboration( pConference );
diff --git a/sc/source/ui/collab/sendfunc.hxx b/sc/source/ui/collab/sendfunc.hxx
index 16f6e88..d4485d5 100644
--- a/sc/source/ui/collab/sendfunc.hxx
+++ b/sc/source/ui/collab/sendfunc.hxx
@@ -204,34 +204,19 @@ public:
} // anonymous namespace
-class ScDocFuncRecv
-{
- ScDocFuncDirect *mpChain;
-
-protected:
- ScDocFuncRecv() {}
-
-public:
- // FIXME: really ScDocFunc should be an abstract base
- ScDocFuncRecv( ScDocFuncDirect *pChain );
- virtual ~ScDocFuncRecv();
-
- void packetReceived( const OString &rPacket );
-
- virtual void RecvMessage( const rtl::OString &rString );
-};
-
class ScDocFuncSend : public ScDocFunc
{
- ScDocFuncRecv *mpDirect;
+ ScDocFuncDirect *mpDirect;
TeleConference *mpConference;
+ void packetReceived( const OString &rPacket );
+ void RecvMessage( const rtl::OString &rString );
void SendMessage( ScChangeOpWriter &rOp );
public:
// FIXME: really ScDocFunc should be an abstract base, so
// we don't need the rDocSh hack/pointer
- ScDocFuncSend( ScDocShell& rDocSh, ScDocFuncRecv *pDirect );
+ ScDocFuncSend( ScDocShell& rDocSh, ScDocFuncDirect *pDirect );
virtual ~ScDocFuncSend();
void SetCollaboration( TeleConference* pConference );
commit 401806233ca0ca25c6124a21fd3c873e219cc3e9
Author: Matúš Kukan <matus.kukan at gmail.com>
Date: Sat Aug 4 16:30:55 2012 +0200
tubes: implement another way for demoing collaboration
This way it affects code ~only internally in tubes/ module.
Change-Id: I1fd1fa460d51ad57ae2f6df0adeb5fadfc7a8c95
diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index 67f319c..06ff543 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -94,6 +94,9 @@ public:
*/
ContactList* getContactList() const;
+ /** Start a demo session where all local documents are shared to each other */
+ TeleConference* startDemoSession();
+
/** Start a group session in a MUC.
@param pAccount
@@ -125,6 +128,11 @@ public:
/** Get a conference with current UUID to set a session. */
TUBES_DLLPUBLIC static TeleConference* getConference();
+ static void registerDemoConference( TeleConference* pConference );
+ static void unregisterDemoConference( TeleConference* pConference );
+ /** Broadcast packet to all conferences. Used for demo mode. */
+ static void broadcastPacket( const OString& rPacket );
+
/** True if there has been tube channel received and is still not used. */
TUBES_DLLPUBLIC static bool hasWaitingConference();
static void setCurrentUuid( const OString& rUuid );
@@ -135,7 +143,7 @@ public:
// Only for callbacks.
- void addConference( TeleConference* pConference );
+ static void addConference( TeleConference* pConference );
void setChannelReadyHandlerInvoked( bool b );
bool isChannelReadyHandlerInvoked() const;
void setAccountManagerReadyHandlerInvoked( bool b );
diff --git a/tubes/source/conference.cxx b/tubes/source/conference.cxx
index f024685..3d1bd0a 100644
--- a/tubes/source/conference.cxx
+++ b/tubes/source/conference.cxx
@@ -376,6 +376,8 @@ void TeleConference::close()
{
INFO_LOGGER( "TeleConference::close");
+ TeleManager::unregisterDemoConference( this );
+
if (mpChannel)
tp_cli_channel_call_close( TP_CHANNEL( mpChannel), 5000, TeleConference_ChannelCloseHandler, this, NULL, NULL);
else
@@ -415,6 +417,12 @@ bool TeleConference::sendPacket( const OString& rPacket )
{
INFO_LOGGER( "TeleConference::sendPacket");
+ if (!mpChannel && !pImpl->mpTube)
+ {
+ TeleManager::broadcastPacket( rPacket );
+ return true;
+ }
+
OSL_ENSURE( mpManager, "tubes: TeleConference::sendPacket: no TeleManager");
SAL_WARN_IF( !pImpl->mpTube, "tubes", "TeleConference::sendPacket: no tube");
if (!(mpManager && pImpl->mpTube))
diff --git a/tubes/source/contacts.cxx b/tubes/source/contacts.cxx
index 4db9113..62cb7bf 100644
--- a/tubes/source/contacts.cxx
+++ b/tubes/source/contacts.cxx
@@ -62,6 +62,7 @@ ResId TubesResId( sal_uInt32 nId )
class TubeContacts : public ModelessDialog
{
FixedLine maLabel;
+ PushButton maBtnDemo;
PushButton maBtnConnect;
PushButton maBtnGroup;
PushButton maBtnInvite;
@@ -71,6 +72,7 @@ class TubeContacts : public ModelessDialog
TeleManager* mpManager;
Collaboration* mpCollaboration;
+ DECL_LINK( BtnDemoHdl, void * );
DECL_LINK( BtnConnectHdl, void * );
DECL_LINK( BtnGroupHdl, void * );
DECL_LINK( BtnInviteHdl, void * );
@@ -108,6 +110,20 @@ class TubeContacts : public ModelessDialog
SAL_INFO( "sc.tubes", "Could not register client handlers." );
}
+ void StartDemoSession()
+ {
+ TeleConference* pConference = mpManager->startDemoSession();
+ if (!pConference)
+ SAL_WARN( "tubes", "Could not start demo session!" );
+ else
+ {
+ pConference->setCollaboration( mpCollaboration );
+ mpCollaboration->SetCollaboration( pConference );
+ mpCollaboration->SendFile( NULL, OStringToOUString(
+ pConference->getUuid(), RTL_TEXTENCODING_UTF8 ) );
+ }
+ }
+
void StartBuddySession()
{
AccountContact *pAC = NULL;
@@ -157,6 +173,7 @@ public:
TubeContacts( Collaboration* pCollaboration ) :
ModelessDialog( NULL, TubesResId( RID_TUBES_DLG_CONTACTS ) ),
maLabel( this, TubesResId( FL_LABEL ) ),
+ maBtnDemo( this, TubesResId( BTN_DEMO ) ),
maBtnConnect( this, TubesResId( BTN_CONNECT ) ),
maBtnGroup( this, TubesResId( BTN_GROUP ) ),
maBtnInvite( this, TubesResId( BTN_INVITE ) ),
@@ -167,6 +184,7 @@ public:
mpCollaboration( pCollaboration )
{
Hide();
+ maBtnDemo.SetClickHdl( LINK( this, TubeContacts, BtnDemoHdl ) );
maBtnConnect.SetClickHdl( LINK( this, TubeContacts, BtnConnectHdl ) );
maBtnGroup.SetClickHdl( LINK( this, TubeContacts, BtnGroupHdl ) );
maBtnInvite.SetClickHdl( LINK( this, TubeContacts, BtnInviteHdl ) );
@@ -237,6 +255,12 @@ public:
}
};
+IMPL_LINK_NOARG( TubeContacts, BtnDemoHdl )
+{
+ StartDemoSession();
+ return 0;
+}
+
IMPL_LINK_NOARG( TubeContacts, BtnConnectHdl )
{
StartBuddySession();
diff --git a/tubes/source/contacts.hrc b/tubes/source/contacts.hrc
index 84c5c33..a9e1e0a 100644
--- a/tubes/source/contacts.hrc
+++ b/tubes/source/contacts.hrc
@@ -6,6 +6,7 @@
#define BTN_INVITE 4
#define BTN_LISTEN 5
#define BTN_GROUP 6
+#define BTN_DEMO 7
#define STR_HEADER_ALIAS 20
#define STR_HEADER_NAME 21
diff --git a/tubes/source/contacts.src b/tubes/source/contacts.src
index 0cd386a..08ad165 100644
--- a/tubes/source/contacts.src
+++ b/tubes/source/contacts.src
@@ -18,6 +18,12 @@ ModelessDialog RID_TUBES_DLG_CONTACTS
Size = MAP_APPFONT ( 198 , 8 ) ;
Text [ en-US ] = "Select a contact to collaborate with" ;
};
+ PushButton BTN_DEMO
+ {
+ Pos = MAP_APPFONT( 8, 212 );
+ Size = MAP_APPFONT( 50 , 10 );
+ Text [ en-US ] = "startDemoSession";
+ };
PushButton BTN_CONNECT
{
Pos = MAP_APPFONT( 70 , 200 );
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index 3a2fc1b..e07db63 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -46,6 +46,7 @@
#include <telepathy-glib/telepathy-glib.h>
#include <map>
+#include <set>
namespace css = ::com::sun::star;
@@ -100,6 +101,8 @@ public:
OString msCurrentUUID;
typedef std::map< OString, TeleConference* > MapStringConference;
MapStringConference maAcceptedConferences;
+ typedef std::set< TeleConference* > DemoConferences;
+ DemoConferences maDemoConferences;
TeleManagerImpl();
~TeleManagerImpl();
@@ -218,6 +221,24 @@ TeleConference* TeleManager::getConference()
return pConference;
}
+void TeleManager::registerDemoConference( TeleConference* pConference )
+{
+ pImpl->maDemoConferences.insert( pConference );
+}
+
+void TeleManager::unregisterDemoConference( TeleConference* pConference )
+{
+ pImpl->maDemoConferences.erase( pConference );
+}
+
+void TeleManager::broadcastPacket( const OString& rPacket )
+{
+ INFO_LOGGER_F( "TeleManager::broadcastPacket" );
+ for (TeleManagerImpl::DemoConferences::iterator it = pImpl->maDemoConferences.begin();
+ it != pImpl->maDemoConferences.end(); ++it)
+ (*it)->sigPacketReceived( rPacket );
+}
+
bool TeleManager::hasWaitingConference()
{
return pImpl && !pImpl->msCurrentUUID.isEmpty();
@@ -233,6 +254,23 @@ SAL_DLLPUBLIC_EXPORT void TeleManager_fileReceived( const rtl::OUString &rStr )
{
SAL_INFO( "tubes", "TeleManager_fileReceived: incoming file: " << rStr );
+ sal_Int32 first = rStr.indexOf('_');
+ sal_Int32 last = rStr.lastIndexOf('_');
+ SAL_WARN_IF( first == last, "tubes", "No UUID to associate with the file!" );
+ if (first != last)
+ {
+ OString sUuid( OUStringToOString( rStr.copy( first + 1, last - first - 1),
+ RTL_TEXTENCODING_UTF8));
+ if (sUuid == "demo")
+ {
+ sUuid = TeleManager::createUuid();
+ TeleConference* pConference = new TeleConference( NULL, NULL, NULL, sUuid );
+ TeleManager::addConference( pConference );
+ TeleManager::registerDemoConference( pConference );
+ }
+ TeleManager::setCurrentUuid( sUuid );
+ }
+
css::uno::Reference< css::lang::XMultiServiceFactory > rFactory =
::comphelper::getProcessServiceFactory();
@@ -261,15 +299,6 @@ void TeleManager_TransferDone( EmpathyFTHandler *handler, TpFileTransferChannel
rtl::OUString aUri( uri, strlen( uri), RTL_TEXTENCODING_UTF8);
g_free( uri);
- sal_Int32 first = aUri.indexOf('_');
- sal_Int32 last = aUri.lastIndexOf('_');
- SAL_WARN_IF( first == last, "tubes", "No UUID to associate with the file!" );
- if (first != last)
- {
- OString sUuid( OUStringToOString( aUri.copy( first + 1, last - first - 1),
- RTL_TEXTENCODING_UTF8));
- TeleManager::setCurrentUuid( sUuid );
- }
TeleManager_fileReceived( aUri );
g_object_unref( handler);
@@ -595,6 +624,15 @@ bool TeleManager::registerClients()
return true;
}
+TeleConference* TeleManager::startDemoSession()
+{
+ INFO_LOGGER( "TeleManager::startDemoSession");
+
+ TeleConference* pConference = new TeleConference( NULL, NULL, NULL, "demo" );
+ registerDemoConference( pConference );
+
+ return pConference;
+}
/* TODO: factor out common code with startBuddySession() */
TeleConference* TeleManager::startGroupSession( TpAccount *pAccount,
More information about the Libreoffice-commits
mailing list