diff options
author | Eike Rathke <erack@redhat.com> | 2012-03-23 10:55:09 +0100 |
---|---|---|
committer | Matúš Kukan <matus.kukan@gmail.com> | 2012-07-17 16:39:40 +0200 |
commit | 70a5f05a4f08b45acc13df80e7b7ee5cb2610c52 (patch) | |
tree | 0361115ff2ee66fa37b7b9e20fd806d3b05c95de /tubes | |
parent | 14efb92f907215f72cf841da98996bc9d39fc9e7 (diff) |
tubes: wrapper to enable tubes
If environment variable LIBO_TUBES is set, Calc's ScDocFuncSend and
ScDocFuncRecv act over tubes.
Diffstat (limited to 'tubes')
-rw-r--r-- | tubes/inc/tubes/conference.hxx | 3 | ||||
-rw-r--r-- | tubes/inc/tubes/manager.hxx | 15 | ||||
-rw-r--r-- | tubes/qa/test_manager.cxx | 15 | ||||
-rw-r--r-- | tubes/source/conference.cxx | 2 | ||||
-rw-r--r-- | tubes/source/manager.cxx | 13 |
5 files changed, 41 insertions, 7 deletions
diff --git a/tubes/inc/tubes/conference.hxx b/tubes/inc/tubes/conference.hxx index 7c5fd30bd994..8a891d579a36 100644 --- a/tubes/inc/tubes/conference.hxx +++ b/tubes/inc/tubes/conference.hxx @@ -30,6 +30,7 @@ #define INCLUDED_TUBES_CONFERENCE_HXX #include <sal/config.h> +#include "tubes/tubesdllapi.h" #include "tubes/packet.hxx" #include "tubes/file-transfer-helper.h" #include <boost/shared_ptr.hpp> @@ -65,7 +66,7 @@ public: bool sendPacket( TelePacket& rPacket ) const; /** Pop a received packet. */ - bool popPacket( TelePacket& rPacket ); + TUBES_DLLPUBLIC bool popPacket( TelePacket& rPacket ); /** Queue incoming data as TelePacket */ void queue( const char* pDBusSender, const char* pPacket, int nSize ); diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx index 0d2ef3eec745..aa6a027726af 100644 --- a/tubes/inc/tubes/manager.hxx +++ b/tubes/inc/tubes/manager.hxx @@ -36,6 +36,7 @@ #include <rtl/ustring.hxx> #include <salhelper/thread.hxx> #include <rtl/ref.hxx> +#include <tools/link.hxx> #include <telepathy-glib/telepathy-glib.h> #include <vector> @@ -70,11 +71,15 @@ public: /** Prepare tube manager with account and service to be offered/listened to. + @param rLink + Callback when a packet is received. Called with a TeleConference* + pointing to the instance that received the packet. + @param bCreateOwnGMainLoop Whether to create and iterate an own GMainLoop. For testing purposes when no GMainLoop is available. */ - TeleManager( bool bCreateOwnGMainLoop = false ); + TeleManager( const Link& rLink, bool bCreateOwnGMainLoop = false ); ~TeleManager(); /** Prepare the Telepathy Account Manager. @@ -109,9 +114,9 @@ public: The account to use. This must be a valid Jabber account. @param pBuddy - The buddy to be connected. Must be a contact of rAccount. + The buddy to be connected. Must be a contact of pAccount. */ - bool startBuddySession( TpAccount *pAccount, TpContact *pBuddy); + bool startBuddySession( TpAccount *pAccount, TpContact *pBuddy ); void unregisterConference( TeleConferencePtr pConference ); @@ -128,6 +133,9 @@ public: */ sal_uInt32 sendPacket( const TelePacket& rPacket ) const; + /** Calls the callback Link set with ctor. */ + long callbackOnRecieved( TeleConference* pConference ) const; + /** Pop a received data packet. XXX This needs to be elaborated to pop from a specific conference, or @@ -205,6 +213,7 @@ public: private: + Link maLink; TeleConferenceVector maConferences; bool mbChannelReadyHandlerInvoked : 1; diff --git a/tubes/qa/test_manager.cxx b/tubes/qa/test_manager.cxx index 540728a5fa39..31148efe5f13 100644 --- a/tubes/qa/test_manager.cxx +++ b/tubes/qa/test_manager.cxx @@ -65,6 +65,7 @@ public: void testDestroyManager2(); void testDestroyAccepterContact(); void testFailAlways(); + DECL_STATIC_LINK( TestTeleTubes, ReceiverCallback, TeleConference* ); GMainLoop* mpMainLoop; void spinMainLoop(); @@ -213,12 +214,12 @@ void TestTeleTubes::testContactList() void TestTeleTubes::testSetupManager1() { - mpManager1 = new TeleManager( true); + mpManager1 = new TeleManager( STATIC_LINK( this, TestTeleTubes, ReceiverCallback), true); } void TestTeleTubes::testSetupManager2() { - mpManager2 = new TeleManager; + mpManager2 = new TeleManager( STATIC_LINK( this, TestTeleTubes, ReceiverCallback)); } void TestTeleTubes::testPrepareAccountManager1() @@ -235,6 +236,16 @@ void TestTeleTubes::testPrepareAccountManager2() CPPUNIT_ASSERT( eStatus == TeleManager::AMS_PREPARED); } +IMPL_STATIC_LINK_NOINSTANCE( TestTeleTubes, ReceiverCallback, TeleConference*, pConference ) +{ + SAL_INFO( "tubes", "TestTeleTubes::ReceiverCallback: " << pConference); + if (pConference) + { + // we could pop a packet here + } + return 0; +} + void TestTeleTubes::testStartBuddySession1() { TpAccount *pAcc1 = mpManager1->getAccount(maOffererIdentifier); diff --git a/tubes/source/conference.cxx b/tubes/source/conference.cxx index 88ec817a3170..d48807d1b933 100644 --- a/tubes/source/conference.cxx +++ b/tubes/source/conference.cxx @@ -442,6 +442,8 @@ void TeleConference::queue( const char* pDBusSender, const char* pPacketData, in INFO_LOGGER( "TeleConference::queue"); maPacketQueue.push( TelePacket( pDBusSender, pPacketData, nPacketSize)); + + getManager()->callbackOnRecieved( this); } diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx index cb9e5d7a72b0..fd852ae170dd 100644 --- a/tubes/source/manager.cxx +++ b/tubes/source/manager.cxx @@ -338,8 +338,9 @@ static void TeleManager_AccountManagerReadyHandler( } -TeleManager::TeleManager( bool bCreateOwnGMainLoop ) +TeleManager::TeleManager( const Link& rLink, bool bCreateOwnGMainLoop ) : + maLink( rLink), mbChannelReadyHandlerInvoked( false) { MutexGuard aGuard( GetMutex()); @@ -705,6 +706,16 @@ sal_uInt32 TeleManager::sendPacket( const TelePacket& rPacket ) const } +long TeleManager::callbackOnRecieved( TeleConference* pConference ) const +{ + INFO_LOGGER( "TeleManager::callbackOnRecieved"); + + if (maLink.IsSet()) + return maLink.Call( pConference); + return 0; +} + + bool TeleManager::popPacket( TelePacket& rPacket ) { INFO_LOGGER( "TeleManager::popPacket"); |