summaryrefslogtreecommitdiff
path: root/tubes
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@gmail.com>2012-07-13 22:42:48 +0200
committerMatúš Kukan <matus.kukan@gmail.com>2012-07-17 16:40:25 +0200
commit53b180a49af8aaa25b9b38a8b020113483f0af6b (patch)
treee784ec91a5a2b6614cfc8c050891c2ff0104d9e4 /tubes
parent019f35d7e4e4494af3a11429219cb361897a7872 (diff)
tubes: associate the document directly with TeleConference
Packet communication now goes directly through TeleConference and TeleManager is used only for receiving files and new channels. This should also allow collaboration of different documents with different contacts independently. Change-Id: Iaf719dce156f1c4c9edc3db4ff0964dec0e0c944
Diffstat (limited to 'tubes')
-rw-r--r--tubes/inc/tubes/conference.hxx11
-rw-r--r--tubes/inc/tubes/manager.hxx13
-rw-r--r--tubes/source/conference.cxx2
-rw-r--r--tubes/source/manager.cxx48
4 files changed, 32 insertions, 42 deletions
diff --git a/tubes/inc/tubes/conference.hxx b/tubes/inc/tubes/conference.hxx
index b5ca996751c1..4849b4254b1e 100644
--- a/tubes/inc/tubes/conference.hxx
+++ b/tubes/inc/tubes/conference.hxx
@@ -38,6 +38,7 @@
#include <rtl/ustring.hxx>
#include <telepathy-glib/telepathy-glib.h>
#include <queue>
+#include <tubes/warnings_guard_boost_signals2.hpp>
typedef ::std::queue<TelePacket> TelePacketQueue;
@@ -52,7 +53,7 @@ public:
~TeleConference();
/// Close channel and call finalize()
- void close();
+ TUBES_DLLPUBLIC void close();
/// Unrefs, unregisters from manager and calls dtor if last reference!
void finalize();
@@ -62,18 +63,20 @@ public:
/** @param rPacket
non-const on purpose, see TelePacket::getData()
*/
- bool sendPacket( TelePacket& rPacket );
+ TUBES_DLLPUBLIC bool sendPacket( TelePacket& rPacket );
/** Pop a received packet. */
- TUBES_DLLPUBLIC bool popPacket( TelePacket& rPacket );
+ bool popPacket( TelePacket& rPacket );
/** Queue incoming data as TelePacket */
void queue( const char* pDBusSender, const char* pPacket, int nSize );
void queue( TelePacket &rPacket );
+ /** Emitted when a packet is received. */
+ boost::signals2::signal<void (TelePacket&)> sigPacketReceived;
typedef void (*FileSentCallback)( bool aSuccess, void* pUserData);
- void sendFile( rtl::OUString &localUri, FileSentCallback pCallback, void* pUserData);
+ TUBES_DLLPUBLIC void sendFile( rtl::OUString &localUri, FileSentCallback pCallback, void* pUserData);
// --- following only to be called only by manager's callbacks ---
// TODO: make friends instead
diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index 6eb7915e31bd..a15d101cb3cf 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -121,7 +121,7 @@ public:
empty, only the conference's UUID is used and rConferenceRoom is
ignored, hopefully resulting in a local DBus tube.
*/
- bool startGroupSession( TpAccount *pAccount,
+ TeleConference* startGroupSession( TpAccount *pAccount,
const rtl::OUString& rConferenceRoom,
const rtl::OUString& rConferenceServer );
@@ -133,7 +133,7 @@ public:
@param pBuddy
The buddy to be connected. Must be a contact of pAccount.
*/
- bool startBuddySession( TpAccount *pAccount, TpContact *pBuddy );
+ TeleConference* startBuddySession( TpAccount *pAccount, TpContact *pBuddy );
void unregisterConference( TeleConferencePtr pConference );
@@ -145,13 +145,6 @@ public:
*/
sal_uInt32 sendPacket( const TelePacket& rPacket ) const;
- /** Emitted when a packet is received, with a TeleConference*
- pointing to the instance that received the packet.
- */
- 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, TelePacket& rPacket ) const;
-
/** Pop a received data packet.
XXX This needs to be elaborated to pop from a specific conference, or
@@ -166,6 +159,8 @@ public:
boost::signals2::signal<void ( const rtl::OUString &localUri )> sigFileReceived;
+ boost::signals2::signal<void (TeleConference*)> sigConferenceCreated;
+
/// Only for use with MainLoopFlusher
GMainLoop* getMainLoop() const;
diff --git a/tubes/source/conference.cxx b/tubes/source/conference.cxx
index 458063ba1f08..1b5a397dc007 100644
--- a/tubes/source/conference.cxx
+++ b/tubes/source/conference.cxx
@@ -411,7 +411,7 @@ void TeleConference::queue( TelePacket &rPacket )
maPacketQueue.push( rPacket);
- getManager()->callbackOnRecieved( this, rPacket);
+ sigPacketReceived( rPacket );
}
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index 944d33a9b503..b524942071b1 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -124,9 +124,9 @@ void TeleManager::DBusChannelHandler(
SAL_INFO( "tubes", "accepting");
aAccepted = true;
- TeleConferencePtr pConference( new TeleConference( pManager, pAccount, TP_DBUS_TUBE_CHANNEL( pChannel ) ) );
- pManager->maConferences.push_back( pConference);
+ TeleConference* pConference = new TeleConference( pManager, pAccount, TP_DBUS_TUBE_CHANNEL( pChannel ) );
pConference->acceptTube();
+ pManager->sigConferenceCreated( pConference );
}
else
{
@@ -506,7 +506,7 @@ bool TeleManager::registerClients()
/* TODO: factor out common code with startBuddySession() */
-bool TeleManager::startGroupSession( TpAccount *pAccount,
+TeleConference* TeleManager::startGroupSession( TpAccount *pAccount,
const rtl::OUString& rUConferenceRoom,
const rtl::OUString& rUConferenceServer )
{
@@ -514,11 +514,6 @@ bool TeleManager::startGroupSession( TpAccount *pAccount,
OString aSessionId( TeleManager::createUuid());
- TeleConferencePtr pConference( new TeleConference( this, NULL, NULL ) );
- maConferences.push_back( pConference);
-
- /* TODO: associate the document with this session and conference */
-
/* FIXME: does this work at all _creating_ a MUC? */
// Use conference and server if given, else create conference.
OString aConferenceRoom( OUStringToOString( rUConferenceRoom, RTL_TEXTENCODING_UTF8));
@@ -552,20 +547,25 @@ bool TeleManager::startGroupSession( TpAccount *pAccount,
if (!pChannelRequest)
{
g_hash_table_unref( pRequest);
- return false;
+ return NULL;
}
setChannelReadyHandlerInvoked( false);
+ TeleConference* pConference = new TeleConference( this, NULL, NULL );
+
tp_account_channel_request_create_and_handle_channel_async(
- pChannelRequest, NULL, TeleManager_ChannelReadyHandler, pConference.get());
+ pChannelRequest, NULL, TeleManager_ChannelReadyHandler, pConference);
iterateLoop( &TeleManager::isChannelReadyHandlerInvoked);
g_object_unref( pChannelRequest);
g_hash_table_unref( pRequest);
- return pConference->getChannel() != NULL && pConference->isTubeOpen();
+ if (!pConference->getChannel() || !pConference->isTubeOpen())
+ return NULL;
+
+ return pConference;
}
@@ -598,16 +598,12 @@ void TeleManager::ensureLegacyChannel( TpAccount* pAccount, TpContact* pBuddy )
/* TODO: factor out common code with startGroupSession() */
-bool TeleManager::startBuddySession( TpAccount *pAccount, TpContact *pBuddy )
+TeleConference* TeleManager::startBuddySession( TpAccount *pAccount, TpContact *pBuddy )
{
INFO_LOGGER( "TeleManager::startBuddySession");
ensureLegacyChannel( pAccount, pBuddy );
- TeleConferencePtr pConference( new TeleConference( this, NULL, NULL ) );
- maConferences.push_back( pConference);
-
- /* TODO: associate the document with this session and conference */
const char *pIdentifier = tp_contact_get_identifier( pBuddy);
SAL_INFO( "tubes", "TeleManager::startBuddySession: creating channel request from "
<< tp_account_get_path_suffix( pAccount)
@@ -626,20 +622,25 @@ bool TeleManager::startBuddySession( TpAccount *pAccount, TpContact *pBuddy )
if (!pChannelRequest)
{
g_hash_table_unref( pRequest);
- return false;
+ return NULL;
}
setChannelReadyHandlerInvoked( false);
+ TeleConference* pConference = new TeleConference( this, NULL, NULL );
+
tp_account_channel_request_create_and_handle_channel_async(
- pChannelRequest, NULL, TeleManager_ChannelReadyHandler, pConference.get());
+ pChannelRequest, NULL, TeleManager_ChannelReadyHandler, pConference );
iterateLoop( &TeleManager::isChannelReadyHandlerInvoked);
g_object_unref( pChannelRequest);
g_hash_table_unref( pRequest);
- return pConference->getChannel() != NULL && pConference->isTubeOpen();
+ if (!pConference->getChannel() || !pConference->isTubeOpen())
+ return NULL;
+
+ return pConference;
}
void TeleManager::prepareAccountManager()
@@ -750,15 +751,6 @@ sal_uInt32 TeleManager::sendPacket( const TelePacket& rPacket ) const
return nSent;
}
-
-void TeleManager::callbackOnRecieved( TeleConference* pConference, TelePacket& rPacket) const
-{
- INFO_LOGGER( "TeleManager::callbackOnRecieved");
-
- sigPacketReceived( pConference, rPacket );
-}
-
-
bool TeleManager::popPacket( TelePacket& rPacket )
{
INFO_LOGGER( "TeleManager::popPacket");