diff options
author | Eike Rathke <erack@redhat.com> | 2012-03-20 20:24:33 +0100 |
---|---|---|
committer | Matúš Kukan <matus.kukan@gmail.com> | 2012-07-17 16:39:20 +0200 |
commit | 6b16cc2ca82027bac2306a062c6a61b5800e6853 (patch) | |
tree | 6978079549fc005b6952c83b6e19594002cac687 /tubes | |
parent | 894151477330cea23f92247132c5c64065a2eb14 (diff) |
restructure things to one account manager and one connection
tubes are offered and accepted now, sending/receiving works
YAY! Thanks to Will Thompson from Collabora.
Diffstat (limited to 'tubes')
-rw-r--r-- | tubes/README | 30 | ||||
-rw-r--r-- | tubes/inc/tubes/conference.hxx | 12 | ||||
-rw-r--r-- | tubes/inc/tubes/manager.hxx | 49 | ||||
-rw-r--r-- | tubes/inc/tubes/packet.hxx | 16 | ||||
-rw-r--r-- | tubes/qa/test_manager.cxx | 38 | ||||
-rw-r--r-- | tubes/source/conference.cxx | 113 | ||||
-rw-r--r-- | tubes/source/manager.cxx | 82 |
7 files changed, 265 insertions, 75 deletions
diff --git a/tubes/README b/tubes/README index 20cdcfa8de10..3527a72743fb 100644 --- a/tubes/README +++ b/tubes/README @@ -8,7 +8,7 @@ the same TeleConference abstraction. To enable configure LibO with --enable-telepathy -Status 2012-03-16: +Status 2012-03-20: * no LibO code depends on this module yet, so it is not built in a regular build, even if configured with --enable-telepathy, so cd tubes and make here @@ -27,19 +27,25 @@ Status 2012-03-16: * libo1 and libo2 must be contacts/buddies of each other * both accounts need to be online in Empathy -* very nasty GMainLoop handling for cppunittest, MAYBE we could get rid of - that in a real LibO, this might be responsible for some ugly behaviour -* contact channels seem to be successfully setup -* the client's callback TeleManager_DBusChannelHandler setup with - TeleManager::connect() does not appear to get ever called -* hence the tube offer triggered by TeleManager_ChannelReadyHandler is never - accepted -* unsure if the uniquify setup with tp_simple_handler_new_with_factory() would - work at all, hence trying to have one instance un-uniquified, but to no - avail +* very nasty GMainLoop handling for cppunittest, HOPEFULLY we will get rid of + that in a real LibO +* working: + * contact channels are setup + * tube is offered/accepted + * packets are sent and received -TODOs (once those basic problems are solved) +TODO: + +* cleanup code to use a refcounted single instance thats holds mpAccountManager + and stuff and actually releases them, instead of statics +* TeleManager should be a single instance, not holding any account information; + instead, the start...Session() methods should also get the account passed +* implement master/slave mode in 1-1 buddy conferences, master would do strong + ordering + + +other TODOs: * associate a document with a conference * use SfxObjectShell as an abstraction and broadcast incoming changes? diff --git a/tubes/inc/tubes/conference.hxx b/tubes/inc/tubes/conference.hxx index db78cd5e80aa..8f68333e940e 100644 --- a/tubes/inc/tubes/conference.hxx +++ b/tubes/inc/tubes/conference.hxx @@ -62,6 +62,9 @@ public: */ bool sendPacket( TelePacket& rPacket ) const; + /** Pop a received packet. */ + bool popPacket( TelePacket& rPacket ); + /** Queue incoming data as TelePacket */ void queue( const char* pDBusSender, const char* pPacket, int nSize ); @@ -75,10 +78,17 @@ public: bool offerTube(); bool setTube( DBusConnection* pTube ); bool acceptTube( const char* pAddress ); + /// got tube accepted on other end as well? + bool isTubeOpen() const { return meTubeChannelState == TP_TUBE_CHANNEL_STATE_OPEN; } // Only for callbacks. void setTubeOfferedHandlerInvoked( bool b ) { mbTubeOfferedHandlerInvoked = b; } bool isTubeOfferedHandlerInvoked() const { return mbTubeOfferedHandlerInvoked; } + void setTubeChannelStateChangedHandlerInvoked( bool b ) + { mbTubeChannelStateChangedHandlerInvoked = b; } + bool isTubeChannelStateChangedHandlerInvoked() const + { return mbTubeChannelStateChangedHandlerInvoked; } + void setTubeChannelState( TpTubeChannelState eState ) { meTubeChannelState = eState; } private: @@ -88,8 +98,10 @@ private: TpChannel* mpChannel; DBusConnection* mpTube; TelePacketQueue maPacketQueue; + TpTubeChannelState meTubeChannelState; bool mbTubeOfferedHandlerInvoked : 1; + bool mbTubeChannelStateChangedHandlerInvoked : 1; // hide from the public using boost::enable_shared_from_this<TeleConference>::shared_from_this; diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx index b47455a78ea0..92fcc6bb2e77 100644 --- a/tubes/inc/tubes/manager.hxx +++ b/tubes/inc/tubes/manager.hxx @@ -118,15 +118,29 @@ public: bool startBuddySession( const rtl::OUString& rBuddy ); void unregisterConference( TeleConferencePtr pConference ); + + /** Connect to DBus and setup client handler. */ bool connect(); + void disconnect(); + void acceptTube( TpChannel* pChannel, const char* pAddress ); - /** Only the callback of prepareAccountManager() is to set this. */ - void setAccountManagerReady( bool bPrepared); + /** 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. - /** Send data to all registered conferences. */ - bool sendPacket( const TelePacket& rPacket ) const; + 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 ); /// "org.freedesktop.Telepathy.Client.LibreOfficeWhatEver" rtl::OString getFullServiceName() const; @@ -145,13 +159,23 @@ public: // Only for callbacks. void setChannelReadyHandlerInvoked( bool b ) { mbChannelReadyHandlerInvoked = b; } bool isChannelReadyHandlerInvoked() const { return mbChannelReadyHandlerInvoked; } - void setAccountManagerReadyHandlerInvoked( bool b ) { mbAccountManagerReadyHandlerInvoked = b; } - bool isAccountManagerReadyHandlerInvoked() const { return mbAccountManagerReadyHandlerInvoked; } + static void setAccountManagerReadyHandlerInvoked( bool b ) { mbAccountManagerReadyHandlerInvoked = b; } + static bool isAccountManagerReadyHandlerInvoked() { return mbAccountManagerReadyHandlerInvoked; } - typedef bool (TeleManager::*CallBackInvokedFunc)() const; + /** Only the callback of prepareAccountManager() is to set this. */ + static 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 ); + typedef bool (TeleManager::*ManagerCallBackInvokedFunc)() const; + /** 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 ); @@ -165,18 +189,21 @@ private: rtl::OString maService; // the "WhatEver" part TeleConferenceVector maConferences; GMainLoop* mpLoop; - TpDBusDaemon* mpDBus; - TpAccountManager* mpAccountManager; TpAccount* mpAccount; TpConnection* mpConnection; + TpDBusDaemon* mpDBus; TpBaseClient* mpClient; - AccountManagerStatus meAccountManagerStatus; bool mbChannelReadyHandlerInvoked : 1; - bool mbAccountManagerReadyHandlerInvoked : 1; TpAccount* getMyAccount(); + /* FIXME: currently these leak */ + /* TODO: make all statics a reference counted impl class */ + static TpAccountManager* mpAccountManager; + static AccountManagerStatus meAccountManagerStatus; + static bool mbAccountManagerReadyHandlerInvoked; + }; diff --git a/tubes/inc/tubes/packet.hxx b/tubes/inc/tubes/packet.hxx index f357782aff66..21136fba33da 100644 --- a/tubes/inc/tubes/packet.hxx +++ b/tubes/inc/tubes/packet.hxx @@ -45,18 +45,32 @@ public: { } - TelePacket( const TelePacket& r ) + explicit TelePacket( const TelePacket& r ) : maSender( r.maSender), maData( r.maData) { } + TelePacket() {} + /** Underlying getArray() ensures reference count is exactly one, hence this method is non-const! */ const char* getData() { return reinterpret_cast<const char*>( maData.getArray()); } sal_Int32 getSize() const { return maData.getLength(); } + bool operator==( const TelePacket& r ) const + { return maSender == r.maSender && maData == r.maData; } + + TelePacket& operator=( const TelePacket& r ) + { + if (this == &r) + return *this; + maSender = r.maSender; + maData = r.maData; + return *this; + } + private: rtl::OString maSender; diff --git a/tubes/qa/test_manager.cxx b/tubes/qa/test_manager.cxx index acf3da64bd78..07dd264d3b23 100644 --- a/tubes/qa/test_manager.cxx +++ b/tubes/qa/test_manager.cxx @@ -54,6 +54,7 @@ public: void testStartBuddySession1(); void testStartBuddySession2(); void testSendPacket(); + void testReceivePacket(); void testFlushLoops(); void testDestroyManager1(); void testDestroyManager2(); @@ -70,6 +71,7 @@ public: CPPUNIT_TEST( testStartBuddySession1 ); CPPUNIT_TEST( testStartBuddySession2 ); CPPUNIT_TEST( testSendPacket ); + CPPUNIT_TEST( testReceivePacket ); CPPUNIT_TEST( testFlushLoops ); CPPUNIT_TEST( testDestroyManager1 ); CPPUNIT_TEST( testDestroyManager2 ); @@ -91,6 +93,7 @@ static TeleManager* mpManager2 = NULL; static rtl::OUString sAcc1( RTL_CONSTASCII_USTRINGPARAM( "libo1@localhost.localdomain")); static rtl::OUString sAcc2( RTL_CONSTASCII_USTRINGPARAM( "libo2@localhost.localdomain")); static rtl::OUString sService( RTL_CONSTASCII_USTRINGPARAM( "TeleTest")); +static sal_uInt32 nSentPackets = 0; TestTeleTubes::TestTeleTubes() { @@ -132,8 +135,8 @@ void TestTeleTubes::testStartBuddySession1() void TestTeleTubes::testStartBuddySession2() { - bool bStarted = mpManager2->startBuddySession( sAcc1); - CPPUNIT_ASSERT( bStarted == true); + //bool bStarted = mpManager2->startBuddySession( sAcc1); + //CPPUNIT_ASSERT( bStarted == true); } void TestTeleTubes::testConnect1() @@ -144,15 +147,38 @@ void TestTeleTubes::testConnect1() void TestTeleTubes::testConnect2() { - bool bConnected = mpManager2->connect(); - CPPUNIT_ASSERT( bConnected == true); + //bool bConnected = mpManager2->connect(); + //CPPUNIT_ASSERT( bConnected == true); } void TestTeleTubes::testSendPacket() { TelePacket aPacket( "", RTL_CONSTASCII_STRINGPARAM( "from 1 to 2")); - bool bPacketSent = mpManager1->sendPacket( aPacket); - CPPUNIT_ASSERT( bPacketSent == true); + nSentPackets = mpManager1->sendPacket( aPacket); + CPPUNIT_ASSERT( nSentPackets == 2); // expect out+in conference, as own instance accepted self +} + +void TestTeleTubes::testReceivePacket() +{ + TelePacket aPacket( "", RTL_CONSTASCII_STRINGPARAM( "from 1 to 2")); + TelePacket aReceived; + sal_uInt32 nReceivedPackets = 0; + bool bOk; + do + { + do + { + bOk = mpManager1->popPacket( aReceived); + if (bOk) + { + ++nReceivedPackets; + CPPUNIT_ASSERT( aPacket == aReceived); + } + } while (bOk); + if (nReceivedPackets < nSentPackets) + mpManager1->iterateLoop(); + } while (nReceivedPackets < nSentPackets); + CPPUNIT_ASSERT( nReceivedPackets == nSentPackets); } void TestTeleTubes::testFlushLoops() diff --git a/tubes/source/conference.cxx b/tubes/source/conference.cxx index 3195df6bceab..a5a6604ff90c 100644 --- a/tubes/source/conference.cxx +++ b/tubes/source/conference.cxx @@ -93,14 +93,14 @@ static DBusHandlerResult TeleConference_DBusMessageHandler( DBUS_TYPE_INVALID)) { SAL_INFO( "tubes", "TeleConference_DBusMessageHandler: received packet from sender " - << pSender << " with size " << nPacketSize); + << (pSender ? pSender : "(null)") << " with size " << nPacketSize); pConference->queue( pSender, pPacketData, nPacketSize); return DBUS_HANDLER_RESULT_HANDLED; } else { SAL_INFO( "tubes", "TeleConference_DBusMessageHandler: unhandled message from sender " - << pSender << " " << aDBusError.message); + << (pSender ? pSender : "(null)") << " " << aDBusError.message); dbus_error_free( &aDBusError); } } @@ -148,6 +148,13 @@ static void TeleConference_TubeOfferedHandler( { INFO_LOGGER_F( "TeleConference_TubeOfferedHandler"); + TeleConference* pConference = reinterpret_cast<TeleConference*>(pUserData); + SAL_WARN_IF( !pConference, "tubes", "TeleConference_TubeOfferedHandler: no conference"); + if (!pConference) + return; + + pConference->setTubeOfferedHandlerInvoked( true); + // "can't find contact ... presence" means contact is not a contact. /* FIXME: detect and handle */ SAL_WARN_IF( pError, "tubes", "TeleConference_TubeOfferedHandler: entered with error: " << pError->message); @@ -158,11 +165,6 @@ static void TeleConference_TubeOfferedHandler( if (!pOutAddress) return; - TeleConference* pConference = reinterpret_cast<TeleConference*>(pUserData); - SAL_WARN_IF( !pConference, "tubes", "TeleConference_TubeOfferedHandler: no conference"); - if (!pConference) - return; - SAL_WARN_IF( pChannel != pConference->getChannel(), "tubes", "TeleConference_TubeOfferedHandler: not my channel"); if (pChannel != pConference->getChannel()) return; @@ -172,8 +174,6 @@ static void TeleConference_TubeOfferedHandler( if (!pManager) return; - pConference->setTubeOfferedHandlerInvoked( true); - DBusError aDBusError; dbus_error_init( &aDBusError); DBusConnection* pTube = dbus_connection_open_private( pOutAddress, &aDBusError); @@ -188,13 +188,42 @@ static void TeleConference_TubeOfferedHandler( } +static void TeleConference_TubeChannelStateChangedHandler( + TpChannel* pChannel, + guint nState, + gpointer pUserData, + GObject* /*weak_object*/ + ) +{ + INFO_LOGGER_F( "TeleConference_TubeChannelStateChangedHandler"); + + SAL_INFO( "tubes", "TeleConference_TubeChannelStateChangedHandler: state: " << static_cast<sal_uInt32>(nState)); + + TeleConference* pConference = reinterpret_cast<TeleConference*>(pUserData); + SAL_WARN_IF( !pConference, "tubes", "TeleConference_DBusMessageHandler: no conference"); + if (!pConference) + return; + + pConference->setTubeChannelStateChangedHandlerInvoked( true); + + SAL_WARN_IF( pChannel != pConference->getChannel(), "tubes", + "TeleConference_TubeChannelStateChangedHandler: not my channel"); + if (pChannel != pConference->getChannel()) + return; + + pConference->setTubeChannelState( static_cast<TpTubeChannelState>(nState)); +} + + TeleConference::TeleConference( TeleManager* pManager, TpChannel* pChannel, const rtl::OString& rSessionId ) : maSessionId( rSessionId ), mpManager( pManager), mpChannel( pChannel), mpTube( NULL), - mbTubeOfferedHandlerInvoked( false) + meTubeChannelState( TP_TUBE_CHANNEL_STATE_NOT_OFFERED), + mbTubeOfferedHandlerInvoked( false), + mbTubeChannelStateChangedHandlerInvoked( false) { if (mpChannel) g_object_ref( mpChannel); @@ -265,27 +294,51 @@ bool TeleConference::offerTube() setTubeOfferedHandlerInvoked( false); - // There must be a hash table with some content. + // We must pass a hash table, it could be empty though. /* TODO: anything meaningful to go in here? */ GHashTable* pParams = tp_asv_new( "LibreOffice", G_TYPE_STRING, "Collaboration", NULL); tp_cli_channel_type_dbus_tube_call_offer( - mpChannel, // proxy - -1, // timeout_ms - pParams, // in_parameters - TP_SOCKET_ACCESS_CONTROL_LOCALHOST, // in_access_control - TeleConference_TubeOfferedHandler, // callback - this, // user_data - NULL, // destroy - NULL); // weak_object + mpChannel, // proxy + -1, // timeout_ms + pParams, // in_parameters + TP_SOCKET_ACCESS_CONTROL_CREDENTIALS, // in_access_control + TeleConference_TubeOfferedHandler, // callback + this, // user_data + NULL, // destroy + NULL); // weak_object mpManager->iterateLoop( this, &TeleConference::isTubeOfferedHandlerInvoked); g_hash_table_unref( pParams); - return true; + setTubeChannelStateChangedHandlerInvoked( false); + + /* TODO: remember the TpProxySignalConnection for further use? */ + GError* pError = NULL; + TpProxySignalConnection* pProxySignalConnection = + tp_cli_channel_interface_tube_connect_to_tube_channel_state_changed( + mpChannel, + TeleConference_TubeChannelStateChangedHandler, + this, + NULL, + NULL, + &pError); + + if (!pProxySignalConnection || pError) + { + SAL_WARN_IF( pError, "tubes", "TeleConference::offerTube: channel state changed error: " << pError->message); + g_error_free( pError); + return false; + } + + mpManager->iterateLoop( this, &TeleConference::isTubeChannelStateChangedHandlerInvoked); + + bool bOpen = isTubeOpen(); + SAL_INFO( "tubes", "TeleConference::offerTube: tube open: " << bOpen); + return bOpen; } @@ -364,8 +417,12 @@ bool TeleConference::sendPacket( TelePacket& rPacket ) const DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &pPacketData, rPacket.getSize(), DBUS_TYPE_INVALID); - SAL_INFO( "tubes", "TeleConference::sendPacket: from " << - dbus_message_get_sender( pMessage) << " to " << dbus_message_get_destination( pMessage)); +#if defined SAL_LOG_INFO + const char* pSrc = dbus_message_get_sender( pMessage); + SAL_INFO_IF( pSrc, "tubes", "TeleConference::sendPacket: from " << pSrc); + const char* pDst = dbus_message_get_destination( pMessage); + SAL_INFO_IF( pDst, "tubes", "TeleConference::sendPacket: to " << pDst); +#endif bool bSent = dbus_connection_send( mpTube, pMessage, NULL); SAL_WARN_IF( !bSent, "tubes", "TeleConference::sendPacket: not sent"); @@ -381,4 +438,16 @@ void TeleConference::queue( const char* pDBusSender, const char* pPacketData, in maPacketQueue.push( TelePacket( pDBusSender, pPacketData, nPacketSize)); } + +bool TeleConference::popPacket( TelePacket& rPacket ) +{ + INFO_LOGGER( "TeleConference::popPacket"); + + if (maPacketQueue.empty()) + return false; + rPacket = maPacketQueue.front(); + maPacketQueue.pop(); + return true; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx index ba9185258469..213bc14dfb9f 100644 --- a/tubes/source/manager.cxx +++ b/tubes/source/manager.cxx @@ -66,6 +66,11 @@ using namespace rtl; #define LIBO_TP_NAME_PREFIX "LibreOffice" +TpAccountManager* TeleManager::mpAccountManager = NULL; +TeleManager::AccountManagerStatus TeleManager::meAccountManagerStatus = AMS_UNINITIALIZED; +bool TeleManager::mbAccountManagerReadyHandlerInvoked = false; + + static void TeleManager_DBusTubeAcceptHandler( TpChannel* pChannel, const char* pAddress, @@ -118,7 +123,7 @@ static void TeleManager_DBusChannelHandler( { SAL_INFO( "tubes", "accepting"); tp_cli_channel_type_dbus_tube_call_accept( pChannel, -1, - TP_SOCKET_ACCESS_CONTROL_LOCALHOST, + TP_SOCKET_ACCESS_CONTROL_CREDENTIALS, TeleManager_DBusTubeAcceptHandler, pUserData, NULL, NULL); } else @@ -181,7 +186,7 @@ static void TeleManager_AccountManagerReadyHandler( if (!pManager) return; - pManager->setAccountManagerReadyHandlerInvoked( true); + TeleManager::setAccountManagerReadyHandlerInvoked( true); GError* pError = NULL; gboolean bPrepared = tp_proxy_prepare_finish( pSourceObject, pResult, &pError); @@ -192,7 +197,7 @@ static void TeleManager_AccountManagerReadyHandler( g_error_free( pError); } - pManager->setAccountManagerReady( bPrepared); + TeleManager::setAccountManagerReady( bPrepared); } @@ -200,14 +205,11 @@ TeleManager::TeleManager( const rtl::OUString& rAccount, const rtl::OUString& rS : maAccountID( OUStringToOString( rAccount, RTL_TEXTENCODING_UTF8)), mpLoop( NULL), - mpDBus( NULL), - mpAccountManager( NULL), mpAccount( NULL), mpConnection( NULL), + mpDBus( NULL), mpClient( NULL), - meAccountManagerStatus( AMS_UNINITIALIZED), - mbChannelReadyHandlerInvoked( false), - mbAccountManagerReadyHandlerInvoked( false) + mbChannelReadyHandlerInvoked( false) { OStringBuffer aBuf(64); aBuf.append( RTL_CONSTASCII_STRINGPARAM( LIBO_TP_NAME_PREFIX)).append( @@ -231,16 +233,14 @@ TeleManager::~TeleManager() { disconnect(); - if (mpDBus) - g_object_unref( mpDBus); - if (mpAccountManager) - g_object_unref( mpAccountManager); if (mpAccount) g_object_unref( mpAccount); if (mpConnection) g_object_unref( mpConnection); if (mpClient) g_object_unref( mpClient); + if (mpDBus) + g_object_unref( mpDBus); if (mpLoop) g_main_loop_unref( mpLoop); @@ -386,7 +386,7 @@ bool TeleManager::startGroupSession( const rtl::OUString& rUConferenceRoom, cons iterateLoop( &TeleManager::isChannelReadyHandlerInvoked); - return pConference->getChannel() != NULL; + return pConference->getChannel() != NULL && pConference->isTubeOpen(); } @@ -439,7 +439,7 @@ bool TeleManager::startBuddySession( const rtl::OUString& rBuddy ) g_object_unref( pChannelRequest); g_hash_table_unref( pRequest); - return pConference->getChannel() != NULL; + return pConference->getChannel() != NULL && pConference->isTubeOpen(); } @@ -449,6 +449,11 @@ void TeleManager::prepareAccountManager() MainLoopFlusher aFlusher( this); + SAL_INFO_IF( meAccountManagerStatus == AMS_PREPARED, "tubes", + "TeleManager::prepareAccountManager: already prepared"); + if (meAccountManagerStatus == AMS_PREPARED) + return; + SAL_WARN_IF( meAccountManagerStatus == AMS_INPREPARATION, "tubes", "TeleManager::prepareAccountManager: already in preparation"); if (meAccountManagerStatus == AMS_INPREPARATION) @@ -518,24 +523,36 @@ TpAccount* TeleManager::getMyAccount() } -bool TeleManager::sendPacket( const TelePacket& rPacket ) const +sal_uInt32 TeleManager::sendPacket( const TelePacket& rPacket ) const { INFO_LOGGER( "TeleManager::sendPacket"); MainLoopFlusher aFlusher( this); - bool bToSend = false; - bool bSent = true; + 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) { - bToSend = true; - if (!(*it)->sendPacket( aPacket)) - bSent = false; + if ((*it)->sendPacket( aPacket)) + ++nSent; + /* TODO: what if failed? */ } - return bSent && bToSend; + 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; } @@ -615,13 +632,32 @@ rtl::OString TeleManager::getFullObjectPath() const } +void TeleManager::iterateLoop() +{ + GMainContext* pContext = (mpLoop ? g_main_loop_get_context( mpLoop) : NULL); + SAL_INFO( "tubes.loop", "TeleManager::iterateLoop: once"); + g_main_context_iteration( pContext, TRUE); +} + + void TeleManager::iterateLoop( CallBackInvokedFunc pFunc ) { GMainContext* pContext = (mpLoop ? g_main_loop_get_context( mpLoop) : NULL); + while (!(*pFunc)()) + { + SAL_INFO( "tubes.loop", "TeleManager::iterateLoop: CallBackInvokedFunc"); + g_main_context_iteration( pContext, TRUE); + } +} + + +void TeleManager::iterateLoop( ManagerCallBackInvokedFunc pFunc ) +{ + GMainContext* pContext = (mpLoop ? g_main_loop_get_context( mpLoop) : NULL); while (!(this->*pFunc)()) { + SAL_INFO( "tubes.loop", "TeleManager::iterateLoop: ManagerCallBackInvokedFunc"); g_main_context_iteration( pContext, TRUE); - SAL_INFO( "tubes.loop", "TeleManager::iterateLoop"); } } @@ -631,8 +667,8 @@ void TeleManager::iterateLoop( const TeleConference* pConference, ConferenceCall GMainContext* pContext = (mpLoop ? g_main_loop_get_context( mpLoop) : NULL); while (!(pConference->*pFunc)()) { + SAL_INFO( "tubes.loop", "TeleManager::iterateLoop: ConferenceCallBackInvokedFunc"); g_main_context_iteration( pContext, TRUE); - SAL_INFO( "tubes.loop", "TeleManager::iterateLoop conference"); } } |