[Libreoffice-commits] .: Branch 'feature/tubes2' - 2 commits - tubes/inc tubes/source
Will Thompson
wjt at kemper.freedesktop.org
Thu Mar 22 08:26:44 PDT 2012
tubes/inc/tubes/conference.hxx | 5 ++--
tubes/inc/tubes/manager.hxx | 2 -
tubes/source/conference.cxx | 21 ++++++++++++++++++--
tubes/source/manager.cxx | 43 +++++++++++++++++++++++++++++++----------
4 files changed, 56 insertions(+), 15 deletions(-)
New commits:
commit ed93ef3dadd72b79cf88e695cecd0da2600f6e11
Author: Will Thompson <will.thompson at collabora.co.uk>
Date: Thu Mar 22 13:30:11 2012 +0000
Throw an error if we get channels we don't understand.
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index e7060cc..ed53a10 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -127,6 +127,7 @@ static void TeleManager_DBusChannelHandler(
TpHandleChannelsContext* pContext,
gpointer pUserData)
{
+ bool aAccepted = false;
INFO_LOGGER_F( "TeleManager_DBusChannelHandler");
TeleManager* pManager = reinterpret_cast<TeleManager*>(pUserData);
@@ -146,6 +147,7 @@ static void TeleManager_DBusChannelHandler(
if (tp_channel_get_channel_type_id( pChannel) == TP_IFACE_QUARK_CHANNEL_TYPE_DBUS_TUBE)
{
SAL_INFO( "tubes", "accepting");
+ aAccepted = true;
g_object_ref( pAccount);
tp_cli_channel_type_dbus_tube_call_accept( pChannel, -1,
TP_SOCKET_ACCESS_CONTROL_CREDENTIALS,
@@ -158,7 +160,15 @@ static void TeleManager_DBusChannelHandler(
}
}
- tp_handle_channels_context_accept( pContext);
+ if (aAccepted)
+ tp_handle_channels_context_accept( pContext);
+ else
+ {
+ GError aError = { TP_ERRORS, TP_ERROR_CONFUSED,
+ "None of these channels were LibreOffice D-Bus tubes; "
+ "why did the Channel Dispatcher give them to us?" };
+ tp_handle_channels_context_fail( pContext, &aError);
+ }
}
commit 7e2d156a570646fd508b92968a338ed9c3f28ce7
Author: Will Thompson <will.thompson at collabora.co.uk>
Date: Thu Mar 22 13:24:00 2012 +0000
tubes: make Conference hold TpAccount
diff --git a/tubes/inc/tubes/conference.hxx b/tubes/inc/tubes/conference.hxx
index b9fd366..a5ce7fb 100644
--- a/tubes/inc/tubes/conference.hxx
+++ b/tubes/inc/tubes/conference.hxx
@@ -46,7 +46,7 @@ class TeleConference : public boost::enable_shared_from_this<TeleConference>
{
public:
- TeleConference( TeleManager* pManager, TpChannel* pChannel, const rtl::OString& rSessionId );
+ TeleConference( TeleManager* pManager, TpAccount *pAccount, TpChannel* pChannel, const rtl::OString& rSessionId );
~TeleConference();
/// Close channel and call finalize()
@@ -71,7 +71,7 @@ public:
// --- following only to be called only by manager's callbacks ---
// TODO: make friends instead
- void setChannel( TpChannel* pChannel );
+ void setChannel( TpAccount* pAccount, TpChannel* pChannel );
TpChannel* getChannel() const { return mpChannel; }
bool offerTube();
bool setTube( DBusConnection* pTube );
@@ -92,6 +92,7 @@ private:
rtl::OString maSessionId;
TeleManager* mpManager;
+ TpAccount* mpAccount;
TpChannel* mpChannel;
DBusConnection* mpTube;
TelePacketQueue maPacketQueue;
diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index 10f20ef..954e412 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -120,7 +120,7 @@ public:
void disconnect();
- void acceptTube( TpChannel* pChannel, const char* pAddress );
+ void acceptTube( TpAccount* pAccount, TpChannel* pChannel, const char* pAddress );
/** Send data to all registered conferences.
diff --git a/tubes/source/conference.cxx b/tubes/source/conference.cxx
index 830db5f..823a9a9 100644
--- a/tubes/source/conference.cxx
+++ b/tubes/source/conference.cxx
@@ -210,16 +210,20 @@ static void TeleConference_TubeChannelStateChangedHandler(
}
-TeleConference::TeleConference( TeleManager* pManager, TpChannel* pChannel, const rtl::OString& rSessionId )
+TeleConference::TeleConference( TeleManager* pManager, TpAccount* pAccount, TpChannel* pChannel, const rtl::OString& rSessionId )
:
maSessionId( rSessionId ),
mpManager( pManager),
+ mpAccount( pAccount),
mpChannel( pChannel),
mpTube( NULL),
meTubeChannelState( TP_TUBE_CHANNEL_STATE_NOT_OFFERED),
mbTubeOfferedHandlerInvoked( false),
mbTubeChannelStateChangedHandlerInvoked( false)
{
+ if (mpAccount)
+ g_object_ref( mpAccount);
+
if (mpChannel)
g_object_ref( mpChannel);
}
@@ -231,14 +235,21 @@ TeleConference::~TeleConference()
}
-void TeleConference::setChannel( TpChannel* pChannel )
+void TeleConference::setChannel( TpAccount *pAccount, TpChannel* pChannel )
{
OSL_ENSURE( !mpChannel, "TeleConference::setChannel: already have channel");
if (mpChannel)
g_object_unref( mpChannel);
+ if (mpAccount)
+ g_object_unref( mpAccount);
+
mpChannel = pChannel;
if (mpChannel)
g_object_ref( mpChannel);
+
+ mpAccount = pAccount;
+ if (mpAccount)
+ g_object_ref( mpAccount);
}
@@ -368,6 +379,12 @@ void TeleConference::finalize()
mpChannel = NULL;
}
+ if (mpAccount)
+ {
+ g_object_unref( mpAccount);
+ mpAccount = NULL;
+ }
+
if (mpTube)
{
dbus_connection_remove_filter( mpTube, TeleConference_DBusMessageHandler, this);
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index 5497435..e7060cc 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -91,26 +91,35 @@ static void TeleManager_DBusTubeAcceptHandler(
const char* pAddress,
const GError* pError,
gpointer pUserData,
- GObject* /*weak_object*/)
+ GObject* pWeakObject)
{
INFO_LOGGER_F( "TeleManager_DBusTubeAcceptHandler");
+ TpAccount* pAccount = TP_ACCOUNT(pWeakObject);
+
SAL_WARN_IF( pError, "tubes", "TeleManager_DBusTubeAcceptHandler: entered with error: " << pError->message);
if (pError)
+ {
+ g_object_unref(pAccount);
return;
+ }
TeleManager* pManager = reinterpret_cast<TeleManager*>(pUserData);
SAL_WARN_IF( !pManager, "tubes", "TeleManager_DBusTubeAcceptHandler: no manager");
if (!pManager)
+ {
+ g_object_unref(pAccount);
return;
+ }
- pManager->acceptTube( pChannel, pAddress);
+ pManager->acceptTube( pAccount, pChannel, pAddress);
+ g_object_unref (pAccount);
}
static void TeleManager_DBusChannelHandler(
TpSimpleHandler* /*handler*/,
- TpAccount* /*account*/,
+ TpAccount* pAccount,
TpConnection* /*connection*/,
GList* pChannels,
GList* /*requests_satisfied*/,
@@ -137,9 +146,11 @@ static void TeleManager_DBusChannelHandler(
if (tp_channel_get_channel_type_id( pChannel) == TP_IFACE_QUARK_CHANNEL_TYPE_DBUS_TUBE)
{
SAL_INFO( "tubes", "accepting");
+ g_object_ref( pAccount);
tp_cli_channel_type_dbus_tube_call_accept( pChannel, -1,
TP_SOCKET_ACCESS_CONTROL_CREDENTIALS,
- TeleManager_DBusTubeAcceptHandler, pUserData, NULL, NULL);
+ TeleManager_DBusTubeAcceptHandler, pUserData, NULL,
+ G_OBJECT (pAccount));
}
else
{
@@ -171,9 +182,10 @@ static void TeleManager_ChannelReadyHandler(
pManager->setChannelReadyHandlerInvoked( true);
+ TpAccountChannelRequest* pChannelRequest = TP_ACCOUNT_CHANNEL_REQUEST( pSourceObject);
GError* pError = NULL;
TpChannel * pChannel = tp_account_channel_request_create_and_handle_channel_finish(
- TP_ACCOUNT_CHANNEL_REQUEST( pSourceObject), pResult, NULL, &pError);
+ pChannelRequest, pResult, NULL, &pError);
if (!pChannel)
{
// "account isn't Enabled" means just that..
@@ -183,7 +195,8 @@ static void TeleManager_ChannelReadyHandler(
return;
}
- pConference->setChannel( pChannel);
+ pConference->setChannel( tp_account_channel_request_get_account( pChannelRequest),
+ pChannel);
pConference->offerTube();
}
@@ -400,7 +413,7 @@ bool TeleManager::startBuddySession( TpAccount *pAccount, TpContact *pBuddy )
OString aSessionId( TeleManager::createUuid());
- TeleConferencePtr pConference( new TeleConference( this, NULL, aSessionId));
+ TeleConferencePtr pConference( new TeleConference( this, NULL, NULL, aSessionId));
maConferences.push_back( pConference);
/* TODO: associate the document with this session and conference */
@@ -606,7 +619,7 @@ void TeleManager::disconnect()
}
-void TeleManager::acceptTube( TpChannel* pChannel, const char* pAddress )
+void TeleManager::acceptTube( TpAccount* pAccount, TpChannel* pChannel, const char* pAddress )
{
INFO_LOGGER( "TeleManager::acceptTube");
@@ -618,7 +631,7 @@ void TeleManager::acceptTube( TpChannel* pChannel, const char* pAddress )
if (!pChannel || !pAddress)
return;
- TeleConferencePtr pConference( new TeleConference( this, pChannel, ""));
+ TeleConferencePtr pConference( new TeleConference( this, pAccount, pChannel, ""));
maConferences.push_back( pConference);
pConference->acceptTube( pAddress);
}
More information about the Libreoffice-commits
mailing list