summaryrefslogtreecommitdiff
path: root/tubes/source
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2012-03-22 13:24:00 +0000
committerMatúš Kukan <matus.kukan@gmail.com>2012-07-17 16:39:33 +0200
commitcf3dcac5ccac798d5eeb64d69b38ed6269f70960 (patch)
tree230e69fad7296ead7efd97e70b7ff9a96bfcddda /tubes/source
parent066479973ce488b0cbf37cf409cd3616661b7943 (diff)
tubes: make Conference hold TpAccount
Diffstat (limited to 'tubes/source')
-rw-r--r--tubes/source/conference.cxx21
-rw-r--r--tubes/source/manager.cxx31
2 files changed, 41 insertions, 11 deletions
diff --git a/tubes/source/conference.cxx b/tubes/source/conference.cxx
index 830db5fa1c67..823a9a93f69c 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 5497435f233b..e7060cccf64f 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);
}