[Libreoffice-commits] .: Branch 'feature/tubes2' - sc/source tubes/inc tubes/qa tubes/source
Will Thompson
wjt at kemper.freedesktop.org
Fri Mar 23 10:15:03 PDT 2012
sc/source/ui/collab/collab.cxx | 26 ++++++--------------------
sc/source/ui/collab/sendfunc.cxx | 10 ++++------
sc/source/ui/inc/collab.hxx | 5 +++--
tubes/inc/tubes/manager.hxx | 10 +++-------
tubes/qa/test_manager.cxx | 19 +++++++++----------
tubes/source/conference.cxx | 2 +-
tubes/source/manager.cxx | 12 +++---------
7 files changed, 29 insertions(+), 55 deletions(-)
New commits:
commit 30ad3ccd848e0832d5dd669b3feb9579e5248ba8
Author: Will Thompson <will.thompson at collabora.co.uk>
Date: Fri Mar 23 17:14:36 2012 +0000
Include packet in packetReceived signals.
(And also signalify receiving files.)
diff --git a/sc/source/ui/collab/collab.cxx b/sc/source/ui/collab/collab.cxx
index cf8777c..a68ba45 100644
--- a/sc/source/ui/collab/collab.cxx
+++ b/sc/source/ui/collab/collab.cxx
@@ -61,28 +61,22 @@ void ScCollaboration::receivedFile( rtl::OUString &rFileURL )
maLinkFile.Call( &rFileURL );
}
-extern "C" {
- void file_recv_cb( rtl::OUString &localUri, void* pUserData )
- {
- ScCollaboration *pCollab = reinterpret_cast<ScCollaboration *>( pUserData );
- pCollab->receivedFile( localUri );
- }
-}
-
-void ScCollaboration::packetReceivedCallback( TeleConference *pConference )
+void ScCollaboration::packetReceivedCallback( TeleConference *pConference, TelePacket &rPacket )
{
+ rtl::OString aString( rPacket.getData(), rPacket.getSize());
/* Relay the signal out⦠*/
- sigPacketReceived( pConference);
+ sigPacketReceived( pConference, aString);
}
bool ScCollaboration::initManager()
{
mpManager = TeleManager::get();
mpManager->sigPacketReceived.connect(
- boost::bind( &ScCollaboration::packetReceivedCallback, this, _1 ));
+ boost::bind( &ScCollaboration::packetReceivedCallback, this, _1, _2 ));
mpManager->connect();
mpManager->prepareAccountManager();
- mpManager->setFileReceivedCallback( file_recv_cb, (void *)this );
+ mpManager->sigFileReceived.connect(
+ boost::bind( &ScCollaboration::receivedFile, this, _1 ));
return true;
}
@@ -119,14 +113,6 @@ bool ScCollaboration::sendPacket( const rtl::OString& rString )
}
-bool ScCollaboration::recvPacket( rtl::OString& rString, TeleConference* pConference )
-{
- TelePacket aPacket;
- bool bOk = (pConference ? pConference->popPacket( aPacket) : mpManager->popPacket( aPacket));
- rString = rtl::OString( aPacket.getData(), aPacket.getSize());
- return bOk;
-}
-
extern "C" {
static void file_sent_cb( bool aSuccess, void* /* pUserData */ )
{
diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index 08383fa..38c598f 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -261,7 +261,7 @@ public:
mpCollab = pCollab;
}
- void packetReceived( TeleConference* pConference);
+ void packetReceived( TeleConference* pConference, const rtl::OString & );
DECL_LINK( ReceiveFileCallback, rtl::OUString * );
void RecvMessage( const rtl::OString &rString )
@@ -301,11 +301,9 @@ public:
}
};
-void ScDocFuncRecv::packetReceived( TeleConference* pConference)
+void ScDocFuncRecv::packetReceived( TeleConference* pConference, const rtl::OString &rStr)
{
- rtl::OString aStr;
- if (mpCollab && mpCollab->recvPacket( aStr, pConference))
- RecvMessage( aStr);
+ RecvMessage( rStr);
}
IMPL_LINK( ScDocFuncRecv, ReceiveFileCallback, rtl::OUString *, pStr )
@@ -557,7 +555,7 @@ SC_DLLPRIVATE ScDocFunc *ScDocShell::CreateDocFunc()
ScCollaboration* pCollab = new ScCollaboration(
LINK( pReceiver, ScDocFuncRecv, ReceiveFileCallback) );
pCollab->sigPacketReceived.connect(
- boost::bind( &ScDocFuncRecv::packetReceived, pReceiver, _1 ));
+ boost::bind( &ScDocFuncRecv::packetReceived, pReceiver, _1, _2 ));
bOk = bOk && pCollab->initManager();
if (!strcmp( pEnv, "master"))
{
diff --git a/sc/source/ui/inc/collab.hxx b/sc/source/ui/inc/collab.hxx
index faf8145..0337b79 100644
--- a/sc/source/ui/inc/collab.hxx
+++ b/sc/source/ui/inc/collab.hxx
@@ -37,6 +37,7 @@ typedef struct _TpContact TpContact;
typedef struct _TpAccount TpAccount;
class TeleManager;
class TeleConference;
+class TelePacket;
namespace rtl { class OString; class OUString; }
class ScCollaboration
@@ -56,14 +57,14 @@ public:
bool sendPacket( const rtl::OString& rString );
/** Emitted when a packet is received
*/
- boost::signals2::signal<void (TeleConference*)> sigPacketReceived;
+ boost::signals2::signal<void (TeleConference*, rtl::OString& rString )> sigPacketReceived;
bool recvPacket( rtl::OString& rString, TeleConference* pConference );
void sendFile( rtl::OUString &rFileURL );
void receivedFile( rtl::OUString &rFileURL );
/* Internal callbacks */
- void packetReceivedCallback( TeleConference *pConference );
+ void packetReceivedCallback( TeleConference *pConference, TelePacket &rPacket );
private:
diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index 6d26b02..7c877f5 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -142,9 +142,9 @@ public:
/** Emitted when a packet is received, with a TeleConference*
pointing to the instance that received the packet.
*/
- boost::signals2::signal<void (TeleConference*)> sigPacketReceived;
+ 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 ) const;
+ void callbackOnRecieved( TeleConference* pConference, TelePacket& rPacket ) const;
/** Pop a received data packet.
@@ -158,8 +158,7 @@ public:
void sendFile( rtl::OUString &localUri, TeleConference::FileSentCallback pCallback, void* pUserData);
- typedef void (*FileReceivedCallback)( rtl::OUString &localUri, void* pUserData );
- void setFileReceivedCallback( FileReceivedCallback callback, void* pUserData );
+ boost::signals2::signal<void ( rtl::OUString &localUri )> sigFileReceived;
/// Only for use with MainLoopFlusher
GMainLoop* getMainLoop() const;
@@ -237,9 +236,6 @@ private:
static sal_uInt32 nAnotherRefCount;
TUBES_DLLPRIVATE static ::osl::Mutex& GetAnotherMutex();
- FileReceivedCallback mpFileReceivedCallback;
- void *mpFileReceivedCallbackData;
-
friend class TeleManagerImpl; // access to mutex
TUBES_DLLPRIVATE static ::osl::Mutex& GetMutex();
diff --git a/tubes/qa/test_manager.cxx b/tubes/qa/test_manager.cxx
index ebd3176..cb31362 100644
--- a/tubes/qa/test_manager.cxx
+++ b/tubes/qa/test_manager.cxx
@@ -66,13 +66,13 @@ public:
void testDestroyAccepterContact();
void testFailAlways();
- void ReceiverCallback( TeleConference* pConference );
+ void ReceiverCallback( TeleConference* pConference, const TelePacket &rPacket );
GMainLoop* mpMainLoop;
void spinMainLoop();
static void FileSent( bool success, void *user_data);
- static void FileReceived( rtl::OUString& aUri, void *user_data);
+ void FileReceived( rtl::OUString& aUri );
// Order is significant.
CPPUNIT_TEST_SUITE( TestTeleTubes );
@@ -233,7 +233,7 @@ void TestTeleTubes::testPrepareAccountManager2()
CPPUNIT_ASSERT( eStatus == TeleManager::AMS_PREPARED);
}
-void TestTeleTubes::ReceiverCallback( TeleConference* pConference )
+void TestTeleTubes::ReceiverCallback( TeleConference* pConference, const TelePacket & )
{
SAL_INFO( "tubes", "TestTeleTubes::ReceiverCallback: " << pConference);
if (pConference)
@@ -275,7 +275,7 @@ void TestTeleTubes::testSendPacket()
{
TelePacket aPacket( "", RTL_CONSTASCII_STRINGPARAM( "from 1 to 2"));
- mpManager1->sigPacketReceived.connect( boost::bind( &TestTeleTubes::ReceiverCallback, this, _1 ) );
+ mpManager1->sigPacketReceived.connect( boost::bind( &TestTeleTubes::ReceiverCallback, this, _1, _2 ) );
nSentPackets = mpManager1->sendPacket( aPacket);
CPPUNIT_ASSERT( nSentPackets == 2); // expect out+in conference, as own instance accepted self
CPPUNIT_ASSERT( mnPacketReceivedEmissions == 2 );
@@ -318,12 +318,10 @@ void TestTeleTubes::FileSent( bool success, void *user_data)
g_main_loop_quit (self->mpMainLoop);
}
-void TestTeleTubes::FileReceived( rtl::OUString& aUri, void *user_data)
+void TestTeleTubes::FileReceived( rtl::OUString& aUri )
{
- TestTeleTubes *self = reinterpret_cast<TestTeleTubes *>(user_data);
-
- self->maFileReceivedUri = aUri;
- g_main_loop_quit (self->mpMainLoop);
+ maFileReceivedUri = aUri;
+ g_main_loop_quit (mpMainLoop);
}
void TestTeleTubes::testSendFile()
@@ -333,7 +331,8 @@ void TestTeleTubes::testSendFile()
/* This has to run after testContactList has run successfully. */
CPPUNIT_ASSERT( mpAccepterContact != 0);
- mpManager1->setFileReceivedCallback(&TestTeleTubes::FileReceived, this);
+ mpManager1->sigFileReceived.connect(
+ boost::bind(&TestTeleTubes::FileReceived, this, _1));
mpManager1->sendFile( maTestConfigIniURL,
&TestTeleTubes::FileSent, this);
diff --git a/tubes/source/conference.cxx b/tubes/source/conference.cxx
index 4e218b8..f91799f 100644
--- a/tubes/source/conference.cxx
+++ b/tubes/source/conference.cxx
@@ -447,7 +447,7 @@ void TeleConference::queue( TelePacket &rPacket )
maPacketQueue.push( rPacket);
- getManager()->callbackOnRecieved( this);
+ getManager()->callbackOnRecieved( this, rPacket);
}
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index e0e2425..3128ea2 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -188,7 +188,7 @@ void TeleManager::TransferDone( EmpathyFTHandler *handler, TpFileTransferChannel
rtl::OUString aUri( uri, strlen( uri), RTL_TEXTENCODING_UTF8);
g_free( uri);
- pManager->mpFileReceivedCallback( aUri, pManager->mpFileReceivedCallbackData);
+ pManager->sigFileReceived( aUri );
g_object_unref( handler);
}
@@ -742,11 +742,11 @@ sal_uInt32 TeleManager::sendPacket( const TelePacket& rPacket ) const
}
-void TeleManager::callbackOnRecieved( TeleConference* pConference ) const
+void TeleManager::callbackOnRecieved( TeleConference* pConference, TelePacket& rPacket) const
{
INFO_LOGGER( "TeleManager::callbackOnRecieved");
- sigPacketReceived( pConference );
+ sigPacketReceived( pConference, rPacket );
}
@@ -774,12 +774,6 @@ void TeleManager::sendFile( rtl::OUString &localUri, TeleConference::FileSentCal
}
}
-void TeleManager::setFileReceivedCallback( TeleManager::FileReceivedCallback callback, void* pUserData )
-{
- mpFileReceivedCallback = callback;
- mpFileReceivedCallbackData = pUserData;
-}
-
void TeleManager::unregisterConference( TeleConferencePtr pConference )
{
INFO_LOGGER( "TeleManager::unregisterConference");
More information about the Libreoffice-commits
mailing list