summaryrefslogtreecommitdiff
path: root/tubes
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@gmail.com>2012-07-28 11:16:01 +0200
committerMatúš Kukan <matus.kukan@gmail.com>2012-08-02 18:00:54 +0200
commit4311938f7e838c6263b0e5774e611ec213cb02c6 (patch)
tree2d1ffba0cb321b65165dcd90f9c34b97e4ec005b /tubes
parent326235584f9dc17c0adf4c02180f45d4c3dc1e64 (diff)
tubes: impose strict ordering on 1-1 collaboration
- master (the one who started the session) echoes back packets from slave, who only then, after receiving own commands executes them Change-Id: I8b5a1d1bae0d665b65fe2ec0121430178728274d
Diffstat (limited to 'tubes')
-rw-r--r--tubes/inc/tubes/conference.hxx8
-rw-r--r--tubes/source/conference.cxx29
-rw-r--r--tubes/source/manager.cxx2
3 files changed, 29 insertions, 10 deletions
diff --git a/tubes/inc/tubes/conference.hxx b/tubes/inc/tubes/conference.hxx
index e5c5d370098b..6a026049237e 100644
--- a/tubes/inc/tubes/conference.hxx
+++ b/tubes/inc/tubes/conference.hxx
@@ -46,7 +46,11 @@ class TeleConference
{
public:
- TeleConference( TeleManager* pManager, TpAccount *pAccount, TpDBusTubeChannel* pChannel, const OString sUuid = OString() );
+ TeleConference( TeleManager* pManager,
+ TpAccount* pAccount,
+ TpDBusTubeChannel* pChannel,
+ const OString sUuid = OString(),
+ bool bMaster = false );
~TeleConference();
/// Close channel and call finalize()
@@ -80,6 +84,7 @@ public:
bool setTube( GDBusConnection* pTube );
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; }
@@ -97,6 +102,7 @@ private:
TpAccount* mpAccount;
TpDBusTubeChannel* mpChannel;
OString msUuid;
+ bool mbMaster;
TeleConferenceImpl* pImpl;
};
diff --git a/tubes/source/conference.cxx b/tubes/source/conference.cxx
index bc2dc753f91f..f024685f04d9 100644
--- a/tubes/source/conference.cxx
+++ b/tubes/source/conference.cxx
@@ -131,7 +131,13 @@ static void TeleConference_MethodCallHandler(
SAL_INFO( "tubes", "TeleConference_MethodCallHandler: received packet from sender "
<< (pSender ? pSender : "(null)") << " with size " << nPacketSize);
- pConference->queue( OString( pPacketData, nPacketSize ) );
+ OString aPacket( pPacketData, nPacketSize );
+ pConference->queue( aPacket );
+ // Master needs to send the packet back to impose ordering,
+ // so the slave can execute his command.
+ if (pConference->isMaster())
+ pConference->sendPacket( aPacket );
+
g_dbus_method_invocation_return_value( pInvocation, 0 );
g_variant_unref( ay);
@@ -226,12 +232,14 @@ static void TeleConference_TubeAcceptedHandler(
}
-TeleConference::TeleConference( TeleManager* pManager, TpAccount* pAccount, TpDBusTubeChannel* pChannel, const OString sUuid )
+TeleConference::TeleConference( TeleManager* pManager, TpAccount* pAccount,
+ TpDBusTubeChannel* pChannel, const OString sUuid, bool bMaster )
:
- mpManager( pManager),
- mpAccount( NULL),
- mpChannel( NULL),
- msUuid( sUuid),
+ mpManager( pManager ),
+ mpAccount( NULL ),
+ mpChannel( NULL ),
+ msUuid( sUuid ),
+ mbMaster( bMaster ),
pImpl( new TeleConferenceImpl() )
{
setChannel( pAccount, pChannel );
@@ -431,12 +439,17 @@ bool TeleConference::sendPacket( const OString& rPacket )
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, NULL, NULL);
- /* FIXME: need to impose an ordering on packets. */
- queue( rPacket );
+ // If we started the session, we can execute commands immediately.
+ if (mbMaster)
+ queue( rPacket );
return true;
}
+bool TeleConference::isMaster() const
+{
+ return mbMaster;
+}
void TeleConference::queue( const OString &rPacket )
{
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index c0f742719321..40754a4d1667 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -676,7 +676,7 @@ TeleConference* TeleManager::startBuddySession( TpAccount *pAccount, TpContact *
setChannelReadyHandlerInvoked( false);
- TeleConference* pConference = new TeleConference( this, NULL, NULL, createUuid() );
+ TeleConference* pConference = new TeleConference( this, NULL, NULL, createUuid(), true );
tp_account_channel_request_create_and_handle_channel_async(
pChannelRequest, NULL, TeleManager_ChannelReadyHandler, pConference );